UCD.js Docs

Schemas

Architecture notes for @ucdjs/schemas

@ucdjs/schemas is the shared contract layer for structured data in UCD.js.

Role

  • Defines Zod schemas for API responses, manifests, lockfiles, filesystem entries, and Unicode metadata.
  • Provides a single contract source for both producers and consumers.
  • Keeps runtime validation and type inference aligned.

Mental Model

This package is not just “types in one place.” It is the runtime validation layer that lets API producers, HTTP clients, and storage code agree on the same shapes.

Schema families in this package:

  • api: well-known config and error response contracts
  • fs: directory/file entry shapes for store and backend surfaces
  • lockfile: .ucd-store.lock and {version}/snapshot.json
  • manifest: expected-file and per-version manifest contracts
  • unicode: versions, file trees, and version-detail payloads

Contract Ownership

@ucdjs/schemas

API routes / responses

client response validation

store manifests, snapshots, trees

filesystem backend entry shapes

tests / docs / contract reuse

Validation Flow

Zod schemaZod schemaalt[payload valid][payload invalid]API / package producerclient / store / appemit payload intended to match schemaparse() / safeParse() / safeParseAsync()typed validated datavalidation issues / failure resultAPI / package producerclient / store / app

Schema Families

API Contracts

UCDWellKnownConfigSchema

client discovery

store discovery / endpoint config

ApiErrorSchema

error guards / HTTP consumers

Filesystem & Tree Contracts

FileEntrySchema / BackendEntrySchema

mirror / file filtering

fs-backend implementations

UnicodeFileTreeSchema

client.versions.getFileTree()

Lockfile & Manifest Contracts

LockfileSchema

expected file planning / orphan cleanup

SnapshotSchema

UCDStoreVersionManifestSchema

client.versions.getManifest()

Testing Use

The high-value test categories here are:

  • example payloads that should parse successfully
  • malformed payloads that should fail with precise issues
  • recursive tree/entry validation
  • lockfile and snapshot date coercion
  • manifest and well-known contract compatibility across producer/consumer code

On this page