Function: resolveArtifact()
ts
function resolveArtifact(
resolver: ArtifactResolver,
onInvalid: (reason: string) => never,
): Promise<() => SpooledArtifactCtor>;Defined in: batteries/tools/_shared/index.ts:103
Resolve an ArtifactResolver to the sync () => SpooledArtifactCtor that Tool.artifactConstructor requires (the wrap-site and the construction-time validator both invoke it synchronously, so an async resolver cannot be passed straight through).
Parameters
| Parameter | Type | Description |
|---|---|---|
resolver | ArtifactResolver | The artifact configuration. When undefined, callers should fall back to their own default (this function rejects undefined so the default lives with the caller). |
onInvalid | (reason: string) => never | Throws a battery-scoped error; receives a human-readable reason. |
Returns
Promise<() => SpooledArtifactCtor>
A sync () => SpooledArtifactCtor suitable for Tool.artifactConstructor.
Remarks
A bare constructor is itself a function, so it is distinguished from a resolver via SpooledArtifact.isSpooledArtifactConstructor (the same duck-typed guard the core validator uses) rather than by arity. Async because a dynamic-import resolver must be awaited here.