Skip to content
1 min read · 152 words

Function: resolveArtifact() ​

ts
function resolveArtifact(
  resolver: ArtifactResolver,
  onInvalid: (reason: string) => never,
): Promise<() => SpooledArtifactCtor>;

Defined in: src/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 ​

ParameterTypeDescription
resolverArtifactResolverThe 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) => neverThrows 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.