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
Representation
NameNameNo description available.
CurrentVersionCurrentVersionNo description available.
CurrentSchemaCurrentSchemaNo description available.
SourceSourceNo description available.
VersionsVersionsNo description available.
Operations
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.

Representation

kind:member

Name

Name
Member

Returns

string
kind:member

CurrentVersion

CurrentVersion
Member

Returns

int
kind:member

CurrentSchema

CurrentSchema
Member

Returns

Schema<'model>
kind:member

Source

Source
Member

Returns

VersionSource
kind:member

Versions

Versions
Member

Returns

ContractVersion list

Operations

kind:member

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>
kind:member

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>
kind:member

build

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

Parameters

NameTypeDescription
sourceVersionSource
builderContractBuilder<'model, 'oldest>

Returns

Contract<'model>
kind:member

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>
kind:member

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>
kind:member

name

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

Parameters

NameTypeDescription
contractContract<'model>

Returns

string
kind:member

currentVersion

Contract.currentVersion contract
Member
Returns the highest supported version.

Parameters

NameTypeDescription
contractContract<'model>

Returns

int
kind:member

currentSchema

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

Parameters

NameTypeDescription
contractContract<'model>

Returns

Schema<'model>