ContractModule

PackageReified.Schema

Contract

A schema describes the current model. A Contract records previously shipped wire versions and a typed migration from each version into that model.

Contract.parse selects the declared version, parses its frozen shape, and runs the migration. It returns the current model, an unrecognized-version error, or the path-aware parse failures for the selected version.

See Versioned Contracts for the complete authoring workflow.

Summary

NameSignatureSynopsis
createContract.create name currentVersion currentSchemaStarts a contract at its current version and schema.
supersedesContract.supersedes version schema migrate builderAdds the immediately preceding wire version and its typed migration to the next registered version.
buildContract.build source builderFinishes a contract with an explicit version-detection strategy.
parseVersionContract.parseVersion contract version rawParses input using an out-of-band version value.
parseContract.parse contract rawDetects the input version according to the contract and parses it into the current trusted model.
nameContract.name contractReturns the contract's stable name.
currentVersionContract.currentVersion contractReturns the highest supported version.
currentSchemaContract.currentSchema contractReturns the schema for the current domain model.

create

Contract.create name currentVersion currentSchema
Member
Starts a contract at its current version and schema.

Parameters

NameTypeDescription
namestring
currentVersionint
currentSchemaSchema<'model>

Returns

ContractBuilder<'model, 'model>

supersedes

Contract.supersedes version schema migrate builder
Member
Adds the immediately preceding wire version and its typed migration to the next registered version.

Parameters

NameTypeDescription
versionint
schemaSchema<'previous>
migrate'previous -> Result<'current, MigrationError>
builderContractBuilder<'model, 'current>

Returns

ContractBuilder<'model, 'previous>

build

Contract.build source builder
Member
Finishes a contract with an explicit version-detection strategy.

Parameters

NameTypeDescription
sourceVersionSource
builderContractBuilder<'model, 'oldest>

Returns

Contract<'model>

parseVersion

Contract.parseVersion contract version raw
Member
Parses input using an out-of-band version value.

Parameters

NameTypeDescription
contractContract<'model>
versionint
rawData

Returns

Result<'model, ContractError>

parse

Contract.parse contract raw
Member
Detects the input version according to the contract and parses it into the current trusted model.

Parameters

NameTypeDescription
contractContract<'model>
rawData

Returns

Result<'model, ContractError>

name

Contract.name contract
Member
Returns the contract's stable name.

Parameters

NameTypeDescription
contractContract<'model>

Returns

string

currentVersion

Contract.currentVersion contract
Member
Returns the highest supported version.

Parameters

NameTypeDescription
contractContract<'model>

Returns

int

currentSchema

Contract.currentSchema contract
Member
Returns the schema for the current domain model.

Parameters

NameTypeDescription
contractContract<'model>

Returns

Schema<'model>