Skip to main content

Interface: SchemaRegistry

Defined in: packages/core/src/application/ports/schema-registry.ts:66

Port for routing schema references and resolving schemas.

Resolution is prefix-driven — no implicit multi-level fallback:

  • @scope/name — npm package; loaded from node_modules/@scope/name/schema.yaml
  • #workspace:name — workspace-qualified; delegated to SchemaRepository for that workspace
  • #name or bare name — equivalent to #default:name; delegated to the default workspace's SchemaRepository
  • relative or absolute path — loaded directly from that path

Implementations receive a ReadonlyMap<string, SchemaRepository> at construction time, mapping workspace names to their corresponding SchemaRepository instances.

Methods

list()

list(): Promise<SchemaEntry[]>

Defined in: packages/core/src/application/ports/schema-registry.ts:107

Lists all schemas discoverable from workspace repositories and installed npm packages. Does not load or validate schema file contents — use resolve() to get a fully-parsed Schema.

Results are grouped by source: workspace entries first (in workspace declaration order), npm entries last.

Returns

Promise<SchemaEntry[]>

All discoverable schema entries


resolve()

resolve(ref): Promise<Schema | null>

Defined in: packages/core/src/application/ports/schema-registry.ts:81

Resolves a schema reference and returns the fully-parsed Schema.

The ref value is the schema field from specd.yaml verbatim. Returns null if the resolved file does not exist; the caller is responsible for converting a null result to SchemaNotFoundError.

Workspace schema resolution is delegated to the corresponding SchemaRepository instance.

Parameters

ref

string

The schema reference as declared in specd.yaml (e.g. "@specd/schema-std", "#billing:my-schema", "spec-driven", "./custom/schema.yaml")

Returns

Promise<Schema | null>

The resolved schema, or null if the file was not found


resolveRaw()

resolveRaw(ref): Promise<SchemaRawResult | null>

Defined in: packages/core/src/application/ports/schema-registry.ts:95

Resolves a schema reference and returns the intermediate representation (parsed YAML data, templates, and resolved path) without building the final domain Schema.

Used by ResolveSchema for the merge pipeline where raw data is needed. Workspace schema resolution is delegated to the corresponding SchemaRepository instance.

Parameters

ref

string

The schema reference as declared in specd.yaml

Returns

Promise<SchemaRawResult | null>

The raw resolution result, or null if the file was not found