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
| Name | Signature | Synopsis |
|---|---|---|
| create | Contract.create name currentVersion currentSchema | Starts a contract at its current version and schema. |
| supersedes | Contract.supersedes version schema migrate builder | Adds the immediately preceding wire version and its typed migration to the next registered version. |
| build | Contract.build source builder | Finishes a contract with an explicit version-detection strategy. |
| parseVersion | Contract.parseVersion contract version raw | Parses input using an out-of-band version value. |
| parse | Contract.parse contract raw | Detects the input version according to the contract and parses it into the current trusted model. |
| name | Contract.name contract | Returns the contract's stable name. |
| currentVersion | Contract.currentVersion contract | Returns the highest supported version. |
| currentSchema | Contract.currentSchema contract | Returns the schema for the current domain model. |
Starts a contract at its current version and schema.
Parameters
| Name | Type | Description |
|---|---|---|
| name | string | |
| currentVersion | int | |
| currentSchema | Schema<'model> |
Returns
ContractBuilder<'model, 'model>
Adds the immediately preceding wire version and its typed migration to the next registered version.
Parameters
| Name | Type | Description |
|---|---|---|
| version | int | |
| schema | Schema<'previous> | |
| migrate | 'previous -> Result<'current, MigrationError> | |
| builder | ContractBuilder<'model, 'current> |
Returns
ContractBuilder<'model, 'previous>
Finishes a contract with an explicit version-detection strategy.
Parameters
| Name | Type | Description |
|---|---|---|
| source | VersionSource | |
| builder | ContractBuilder<'model, 'oldest> |
Returns
Contract<'model>
Parses input using an out-of-band version value.
Parameters
| Name | Type | Description |
|---|---|---|
| contract | Contract<'model> | |
| version | int | |
| raw | Data |
Returns
Result<'model, ContractError>
Detects the input version according to the contract and parses it into the current trusted model.
Parameters
| Name | Type | Description |
|---|---|---|
| contract | Contract<'model> | |
| raw | Data |
Returns
Result<'model, ContractError>
Returns the contract's stable name.
Parameters
| Name | Type | Description |
|---|---|---|
| contract | Contract<'model> |
Returns
string
Returns the highest supported version.
Parameters
| Name | Type | Description |
|---|---|---|
| contract | Contract<'model> |
Returns
int