# Millwork > Shapes, values and wire codecs for WarpDrive and ember-data. A codec turns one raw wire > value (JSON) into an immutable value object, such as `Money` or a date, and back. A shape > is a nested object that the app edits in place, with change tracking by path. A value is > immutable: to change it, set a new one. Install `@millwork-ts/core` and `@millwork-ts/warp-drive`. Add one package for each peer library: `@millwork-ts/temporal`, `@millwork-ts/luxon`, `@millwork-ts/date-fns`, `@millwork-ts/dayjs`, `@millwork-ts/dinero`, `@millwork-ts/decimal`, `@millwork-ts/phone`, `@millwork-ts/color`, `@millwork-ts/quantity`, `@millwork-ts/semver`, `@millwork-ts/ip`, `@millwork-ts/rrule`, `@millwork-ts/cron` and `@millwork-ts/geo`. Guide: https://joegaudet.com/millwork/guide/ API reference: https://joegaudet.com/millwork/api/ Full API as text: https://joegaudet.com/millwork/api/llms-full.txt ## Rules for writing code with Millwork 1. Make every codec with `defineCodec({ name, parse, format, isValue, equals })` from `@millwork-ts/core`. Do not write a `Codec` object by hand: `defineCodec` gives the rules for `null`, errors and freezing. `parse` may throw on bad input; `hydrate` then gives `undefined` and a report to `onInvalid`. 2. Never mutate a value. `Money`, dates, `Decimal`, `LatLng` and `Value` instances are immutable. To change a field, set a new value: `record.total = Money.fromDecimal('5.00', 'USD')`. For a `Value` class, use `price.with({ label: 'Sale' })`. 3. Choose shape or value on purpose. A shape (`extends Shape`) is a nested object that a form edits in place, such as an address. A value (a codec value, or `extends Value`) is a quantity that is replaced whole, such as money or a date. Do not use the word "fragment". 4. Every shape and value class has a unique `static override type = 'name'`. Never derive the name from the class name: minifiers rename classes. A second class with the same `type` throws. 5. In SchemaRecord schemas, use the helpers from `@millwork-ts/warp-drive`: `valueField`, `valueArrayField`, `shapeField` and `shapeArrayField`. They make `kind: 'field'` fields. Never declare a codec or a shape as `kind: 'object'` or `kind: 'schema-object'`: those remove the class prototype and use a nested write path that loses edits. 6. Give the store every Transformation with `transformations: transformations()` from `@millwork-ts/warp-drive`. Call `registerCodecs(codecs)` for each adapter package before `transformations()` runs. Do not register Millwork Transformations one by one. 7. To edit a Polaris record, use `checkout` from `@millwork-ts/warp-drive`, not from `@warp-drive/core`. The Millwork `checkout` lets the copy read its remote values. 8. Change a shape array only with `add`, `remove` and `move`. It is frozen; `push` and `splice` do not work. Do not change the `key` of a member while you edit it. 9. Use `isDirty`, `changes()` and `rollback(path?)` on a shape for dirty state. Do not compare JSON by hand. 10. On a legacy `Model`, a value is `@attr('money', { wire: 'decimal' })`. Core codecs are app transforms already; do not write a transform file. For a codec from another package, call `registerTransforms(owner, { datetime })` from `@millwork-ts/warp-drive/legacy` in an instance initializer. `store.push` does not run `@attr` transforms. 11. A `Model` attribute cannot hold a shape. Put `@value`, `@shape` and `@shapeArray` from `@millwork-ts/warp-drive/legacy` on a plain class, then `withDefaults(modelSchema('order', OrderFields))` with `withDefaults` from `@warp-drive/legacy/model/migration-support`. 12. Ember compiles legacy decorators: write `@field declare city: string`. With standard decorators, write `@field accessor city!: string`. 13. To validate input, use `toStandardSchema(codec, options)` or `toStandardSchema(Address)`. No validation runs when a record reads a field. 14. Never read a date-only string with `new Date('2026-12-01')`. Use a date codec. 15. For a closed list of strings, such as an order status, use real-enums (https://joegaudet.com/real-enums/), not a Millwork codec. ## Example ```ts import { Shape, field } from '@millwork-ts/core' import { checkout, shapeField, valueField } from '@millwork-ts/warp-drive' import { withDefaults } from '@warp-drive/core/reactive' export class Address extends Shape { static override type = 'address' @field declare city: string @field declare zip: string } export const InvoiceSchema = withDefaults({ type: 'invoice', fields: [valueField('total', 'money', { wire: 'decimal' }), shapeField('billTo', Address)], }) const draft = await checkout(invoice) draft.total.toDecimalString() // "5.00" draft.billTo.city = 'Montreal' draft.billTo.isDirty // true draft.billTo.rollback(['city']) ``` ## API reference The same reference as HTML: https://joegaudet.com/millwork/api/ **Millwork** *** Millwork / @millwork-ts/color # @millwork-ts/color A Millwork codec for colors with [culori](https://culorijs.org). ## Install ```bash pnpm add @millwork-ts/color @millwork-ts/core culori ``` ## Codecs | Codec | Value | Raw | | ------- | ---------------------------- | ----------------------------------- | | `color` | a frozen culori color object | a CSS color string or an rgb object | The codec reads these raw forms: | Raw | Example | Value mode | | ---------- | ------------------------------------------- | ---------- | | hex | `"#1e90ff"`, `"#1e90ff80"`, `"#fff"` | `rgb` | | `rgb()` | `"rgb(30 144 255)"` | `rgb` | | `hsl()` | `"hsl(210 50% 40%)"` | `hsl` | | `oklch()` | `"oklch(0.65 0.18 250)"` | `oklch` | | rgb object | `{ "r": 30, "g": 144, "b": 255, "a": 0.5 }` | `rgb` | - The value keeps the color space of the wire string. - In an rgb object, the channels `r`, `g` and `b` are 0 to 255. The alpha `a` is 0 to 1. - culori also reads other CSS colors, such as `"red"`. ## Options | Option | Type | Use | | -------- | ------------------------------------ | ----------------------------------------- | | `format` | `'hex' \| 'rgb' \| 'hsl' \| 'oklch'` | The written form. The default is `'hex'`. | | `format` | Written form | | --------- | ------------------------------------------------------- | | `'hex'` | `"#1e90ff"`, or `"#1e90ff80"` when alpha is less than 1 | | `'rgb'` | `"rgb(30, 144, 255)"` | | `'hsl'` | `"hsl(210, 50%, 40%)"` | | `'oklch'` | `"oklch(0.65 0.18 250)"` | Hex, `rgb()` and `hsl()` are in the sRGB gamut. An `oklch()` color out of that gamut is clipped when you write it in one of these forms. ## Equality `equals` converts the two colors to rgb. It compares each channel and the alpha with a tolerance of half of one 8-bit step. Thus `"#336699"` equals `"hsl(210 50% 40%)"`, and `"#336698"` does not equal `"#336699"`. ## Example with WarpDrive Register the codecs before the store calls `transformations()`, because `transformations()` reads the registry when it runs. See the [`@millwork-ts/warp-drive` README](https://github.com/joegaudet/millwork/tree/main/packages/warp-drive#the-store). ```ts import { codecs } from '@millwork-ts/color' import { registerCodecs, valueField } from '@millwork-ts/warp-drive' import { withDefaults } from '@warp-drive/core/reactive' registerCodecs(codecs) export const ThemeSchema = withDefaults({ type: 'theme', fields: [valueField('accent', 'color', { format: 'oklch' })], }) ``` ## Interfaces - ColorOptions - RgbObject ## Type Aliases - ColorFormat - ColorRaw ## Variables - codecs - color --- **Millwork** *** Millwork / @millwork-ts/color / ColorOptions # Interface: ColorOptions Defined in: [index.ts:18](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/color/src/index.ts#L18) Options of the `color` codec. ## Properties ### format? > `optional` **format?**: `ColorFormat` Defined in: [index.ts:20](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/color/src/index.ts#L20) The written form. The default is `'hex'`: `"#1e90ff"`, or `"#1e90ff80"` with alpha. --- **Millwork** *** Millwork / @millwork-ts/color / RgbObject # Interface: RgbObject Defined in: [index.ts:24](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/color/src/index.ts#L24) An rgb object on the wire. The channels are 0 to 255. The alpha `a` is 0 to 1. ## Properties ### a? > `optional` **a?**: `number` Defined in: [index.ts:28](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/color/src/index.ts#L28) *** ### b > **b**: `number` Defined in: [index.ts:27](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/color/src/index.ts#L27) *** ### g > **g**: `number` Defined in: [index.ts:26](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/color/src/index.ts#L26) *** ### r > **r**: `number` Defined in: [index.ts:25](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/color/src/index.ts#L25) --- **Millwork** *** Millwork / @millwork-ts/color / ColorFormat # Type Alias: ColorFormat > **ColorFormat** = `"hex"` \| `"rgb"` \| `"hsl"` \| `"oklch"` Defined in: [index.ts:15](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/color/src/index.ts#L15) The written forms of the `color` codec. --- **Millwork** *** Millwork / @millwork-ts/color / ColorRaw # Type Alias: ColorRaw > **ColorRaw** = `string` \| `RgbObject` Defined in: [index.ts:32](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/color/src/index.ts#L32) The raw forms of the `color` codec: a CSS color string or an rgb object. --- **Millwork** *** Millwork / @millwork-ts/color / codecs # Variable: codecs > `const` **codecs**: `Readonly`\<\{ `color`: `Codec`\<`ColorRaw`, `Color`, `ColorOptions` \| `undefined`\>; \}\> Defined in: [index.ts:84](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/color/src/index.ts#L84) Each codec in this package, keyed by its name. --- **Millwork** *** Millwork / @millwork-ts/color / color # Variable: color > `const` **color**: `Codec`\<`ColorRaw`, `Color`, `ColorOptions` \| `undefined`\> Defined in: [index.ts:48](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/color/src/index.ts#L48) The `color` codec: a CSS color string (hex, `rgb()`, `hsl()`, `oklch()`) or an rgb object to a frozen culori color object. The value keeps the color space of the wire string. `equals` compares in rgb with a tolerance of half of one 8-bit step. --- **Millwork** *** Millwork / @millwork-ts/core # @millwork-ts/core Codecs, shapes and values: turn wire data into real objects and back. Core has no framework and no peer dependency. **Docs:** [joegaudet.com/millwork](https://joegaudet.com/millwork/) · [Guide](https://joegaudet.com/millwork/guide/) · [API](https://joegaudet.com/millwork/api/) ## Install ```bash pnpm add @millwork-ts/core ``` For WarpDrive and ember-data, also add [`@millwork-ts/warp-drive`](https://github.com/joegaudet/millwork/tree/main/packages/warp-drive). ## Terms - A **codec** turns one raw wire value into a value and back. - A **value** is immutable. To change it, set a new one. Two values are equal when the codec `equals` says so. - A **shape** is a nested object that you edit in place. It tracks its changes by path. ## Codecs A codec has `name`, `hydrate`, `serialize`, `equals` and `isValue`. - `hydrate` is forgiving. Bad wire data gives `undefined` and a report to `onInvalid`. It never throws. - `serialize` is strict. A value of the wrong type throws a `TypeError`. - `null` and a missing value give `undefined`. `nullable(codec)` keeps `null`. ```ts import { money, onInvalid } from '@millwork-ts/core' const total = money.hydrate({ amount: '19.99', currency: 'USD' }, { wire: 'decimal' }) total?.toDecimalString() // "19.99" money.serialize(total, { wire: 'minor' }) // { amount: 1999, currency: 'USD' } onInvalid(({ codec, raw, error }) => console.error(codec, raw, error)) ``` The core codecs are `money`, `decimal`, `bigint`, `number-string`, `percent`, `ratio`, `boolean-ish`, `url`, `email`, `uuid`, `ulid`, `snowflake`, `country`, `currency-code`, `language`, `locale`, `time-zone`, `latlng`, `geojson`, `bytes`, `byte-size`, `bitflags`, `mime-type` and `i18n-text`. The `codecs` record has all of them by name. `arrayOf`, `nullable`, `setOf`, `mapOf` and `rangeOf` make a codec from another codec. Core has no date type. Use one of the date packages: `@millwork-ts/temporal`, `@millwork-ts/luxon`, `@millwork-ts/date-fns` or `@millwork-ts/dayjs`. The wire forms and options of each codec are in the [guide](https://joegaudet.com/millwork/guide/#core-codecs). ### URLs The `url` codec accepts only `http:`, `https:`, `mailto:` and `tel:` URLs by default. A `javascript:` or `data:` URL is bad input, so it is not safe to put a hydrated URL in a link without this check. Set the `protocols` option to change the list, or to `'*'` to accept all protocols. With the `base` option, the codec resolves a relative URL first, and then checks its protocol. ```ts url.hydrate('javascript:alert(1)') // undefined, and a report to onInvalid url.hydrate('ftp://example.com/a', { protocols: ['ftp:'] }) // a FrozenURL url.hydrate('/a', { base: 'https://example.com' }) // https://example.com/a ``` ## Write a codec Use `defineCodec`. Do not write the `Codec` object by hand: `defineCodec` gives the rules for `null`, errors and freezing. ```ts import { defineCodec, registerCodecs } from '@millwork-ts/core' export const upper = defineCodec({ name: 'upper', parse(raw) { if (typeof raw !== 'string') throw new TypeError('not a string') return raw.toUpperCase() }, format: value => value.toLowerCase(), isValue: (input): input is string => typeof input === 'string', }) registerCodecs({ upper }) // now a field can name it: 'upper' ``` ## Shapes and values ```ts import { Shape, Value, field, type Money, type ShapeArray } from '@millwork-ts/core' export class Address extends Shape { static override type = 'address' @field accessor city!: string @field accessor zip!: string } export class LineItem extends Shape { static override type = 'line-item' @field accessor sku!: string @field accessor qty!: number } export class Price extends Value { static override type = 'price' @field('money', { wire: 'decimal' }) accessor amount!: Money @field accessor label!: string } ``` - Each class has a unique static `type`. Minifiers rename classes, so the name does not come from the class. A second class with the same `type` throws. - Ember compiles legacy decorators. There, write `@field declare city: string`. - `shape({ type, fields })` and `value({ type, fields })` make a class from JSON, with the same power. - `@field(LineItem, { array: true, key: 'sku' })` gives a `ShapeArray`. Change it with `add`, `remove` and `move`. - `@field({ card: Card, bank: Bank })` is polymorphic. The `$type` key of the raw value picks the class. The `discriminator` option changes the key. A shape and a shape array have the `Tracked` API: ```ts address.city = 'Montreal' address.isDirty // true address.changes() // [{ kind: 'set', path: ['city'], from: 'Toronto', to: 'Montreal' }] address.rollback(['city']) ``` A value is immutable. A write throws a `TypeError`. `price.with({ label: 'Sale' })` gives a copy. `Price.codec` is the codec of the class. ## Validation `toStandardSchema` gives a [Standard Schema](https://standardschema.dev/) for a codec, or for a shape or value class. It reads the raw wire form. No validation runs when a field is read. ```ts import { money, toStandardSchema } from '@millwork-ts/core' const total = toStandardSchema(money, { wire: 'decimal' }) total['~standard'].validate({ amount: 'x', currency: 'USD' }) // { issues: [{ message: '[millwork] money: not a decimal: "x"' }] } const address = toStandardSchema(Address) address['~standard'].validate({ city: 'Toronto' }) // { issues: [{ message: '[millwork] zip: required', path: ['zip'] }] } ``` ## License MIT ## Classes - Decimal - FrozenURL - I18nText - Money - Percent - RawWrite - Shape - ShapeArray - Slot - Value ## Interfaces - Binding - BitflagsOptions - BooleanIshOptions - BytesOptions - Change - Codec - CodecSpec - DateCodecFamily - DateRecord - DateTypes - DecimalOptions - DurationRecord - EpochRecord - Feature - FeatureCollection - FieldDecorator - FieldDefinition - FieldInput - FieldOptions - IntervalOptions - IntervalParts - IntervalWire - InvalidReport - Issue - LatLng - LatLngOptions - MapOptions - MimeType - MoneyOptions - NamedClass - OffsetDateTimeRecord - PercentOptions - Range - RangeOptions - Ratio - RatioOptions - RegisterShapesOptions - ShapeDefinition - StructuredClass - StructureInput - TimeRecord - Tracked - UrlOptions - YearMonthRecord - ZonedDateTimeRecord - ZonedOptions ## Type Aliases - AnyCodec - Bounds - DurationFields - EpochUnit - FieldRef - GeoJson - Geometry - InvalidHandler - LatLngRaw - LocalDateTimeRecord - MapRaw - MoneyRaw - MoneyWire - OptionsOf - PercentUnit - PolymorphicMap - Position - RangeRaw - RawObject - RawOf - ShapeRef - Structured - ValueOf ## Variables - bigint - bitflags - booleanIsh - bytes - byteSize - codecFactories - codecs - country - currencyCode - decimal - DEFAULT\_URL\_PROTOCOLS - DISCORD\_EPOCH - email - geojson - i18nText - language - latlng - locale - mimeType - money - numberString - percent - ratio - snowflake - timeZone - TWITTER\_EPOCH - ulid - url - uuid ## Functions - arrayOf - codecNamed - currencyExponent - defineCodec - definitionOf - durationMilliseconds - field - formatDuration - formatEpoch - formatOffset - fraction - mapOf - nullable - onInvalid - parseEpoch - parseIsoDate - parseIsoDuration - parseIsoTime - parseLocalDateTime - parseRfc3339 - parseRfc9557 - parseWith - parseYearMonth - rangeOf - rawOf - readDuration - readInterval - registerCodecs - registeredCodecs - registerShapes - reportInvalid - sameDuration - setOf - shape - shapeNamed - shapeSchema - snowflakeTime - splitIsoInterval - toStandardSchema - ulidTime - value - valueCodec - writeDuration --- **Millwork** *** Millwork / @millwork-ts/core / Decimal # Class: Decimal Defined in: [packages/core/src/decimal.ts:16](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/decimal.ts#L16) An exact decimal number. It keeps the digits and the scale of the wire string, so `"123.4500"` writes back as `"123.4500"`. A `Decimal` is immutable. `equals` ignores trailing zeros. It does no arithmetic: use `@millwork-ts/decimal` for math. ## Properties ### coefficient > `readonly` **coefficient**: `bigint` Defined in: [packages/core/src/decimal.ts:18](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/decimal.ts#L18) The integer digits: the value is `coefficient / 10 ** scale`. *** ### scale > `readonly` **scale**: `number` Defined in: [packages/core/src/decimal.ts:20](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/decimal.ts#L20) The number of digits after the point. ## Methods ### compare() > **compare**(`other`): `number` Defined in: [packages/core/src/decimal.ts:68](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/decimal.ts#L68) Gives -1, 0 or 1. Trailing zeros have no effect. #### Parameters ##### other `Decimal` #### Returns `number` *** ### equals() > **equals**(`other`): `boolean` Defined in: [packages/core/src/decimal.ts:73](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/decimal.ts#L73) True when the two values are equal. `1.50` equals `1.5`. #### Parameters ##### other `Decimal` #### Returns `boolean` *** ### movePoint() > **movePoint**(`places`): `Decimal` Defined in: [packages/core/src/decimal.ts:60](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/decimal.ts#L60) Multiplies by `10 ** places`, exactly. A negative `places` divides. #### Parameters ##### places `number` #### Returns `Decimal` *** ### toFixed() > **toFixed**(`scale`): `string` Defined in: [packages/core/src/decimal.ts:50](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/decimal.ts#L50) Writes the decimal with `scale` digits after the point. It throws a `RangeError` if digits are lost. #### Parameters ##### scale `number` #### Returns `string` *** ### toJSON() > **toJSON**(): `string` Defined in: [packages/core/src/decimal.ts:45](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/decimal.ts#L45) Gives the same text as `toString`. `JSON.stringify` calls it. #### Returns `string` *** ### toNumber() > **toNumber**(): `number` Defined in: [packages/core/src/decimal.ts:55](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/decimal.ts#L55) Gives the nearest `number`. Precision can be lost. #### Returns `number` *** ### toString() > **toString**(): `string` Defined in: [packages/core/src/decimal.ts:40](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/decimal.ts#L40) Writes the decimal with its own scale. #### Returns `string` *** ### from() > `static` **from**(`input`): `Decimal` Defined in: [packages/core/src/decimal.ts:29](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/decimal.ts#L29) Makes a `Decimal` from a decimal string (exponent notation is allowed) or a finite number. #### Parameters ##### input `string` \| `number` #### Returns `Decimal` --- **Millwork** *** Millwork / @millwork-ts/core / FrozenURL # Class: FrozenURL Defined in: [packages/core/src/codecs/url.ts:10](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/url.ts#L10) A `URL` that cannot change. Each setter throws a `TypeError`. `searchParams` gives a copy, so a change to it has no effect on the URL. ## Extends - `URL` ## Constructors ### Constructor > **new FrozenURL**(`url`, `base?`): `FrozenURL` Defined in: [packages/core/src/codecs/url.ts:11](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/url.ts#L11) #### Parameters ##### url `string` \| `URL` ##### base? `string` \| `URL` #### Returns `FrozenURL` #### Overrides `URL.constructor` --- **Millwork** *** Millwork / @millwork-ts/core / I18nText # Class: I18nText Defined in: [packages/core/src/codecs/i18n-text.ts:7](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/i18n-text.ts#L7) A text in more than one language, keyed by BCP 47 locale. An `I18nText` is immutable. ## Constructors ### Constructor > **new I18nText**(`texts`): `I18nText` Defined in: [packages/core/src/codecs/i18n-text.ts:11](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/i18n-text.ts#L11) Locale keys are put in their canonical form. A bad key or a value that is not a string throws. #### Parameters ##### texts `Readonly`\<`Record`\<`string`, `string`\>\> #### Returns `I18nText` ## Accessors ### locales #### Get Signature > **get** **locales**(): `string`[] Defined in: [packages/core/src/codecs/i18n-text.ts:22](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/i18n-text.ts#L22) The locales that have a text. ##### Returns `string`[] ## Methods ### equals() > **equals**(`other`): `boolean` Defined in: [packages/core/src/codecs/i18n-text.ts:47](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/i18n-text.ts#L47) Returns `true` if both have the same texts for the same locales. #### Parameters ##### other `I18nText` #### Returns `boolean` *** ### for() > **for**(`locale`, `fallbacks?`): `string` \| `undefined` Defined in: [packages/core/src/codecs/i18n-text.ts:30](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/i18n-text.ts#L30) Gives the text for `locale`. It tries the locale, then each shorter parent (`fr-CA`, then `fr`), then each fallback in the same way. It gives `undefined` when no locale matches. #### Parameters ##### locale `string` ##### fallbacks? readonly `string`[] = `[]` #### Returns `string` \| `undefined` *** ### toJSON() > **toJSON**(): `Record`\<`string`, `string`\> Defined in: [packages/core/src/codecs/i18n-text.ts:42](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/i18n-text.ts#L42) Gives the texts as a plain object. #### Returns `Record`\<`string`, `string`\> --- **Millwork** *** Millwork / @millwork-ts/core / Money # Class: Money Defined in: [packages/core/src/money.ts:41](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/money.ts#L41) An amount of money. `amount` is an integer in units of `10 ** -scale` of `currency`. A `Money` is immutable. It does no arithmetic: use dinero or a decimal library for math. ## Constructors ### Constructor > **new Money**(`amount`, `currency`, `scale?`): `Money` Defined in: [packages/core/src/money.ts:50](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/money.ts#L50) Use `fromMinor` or `fromDecimal`. Without `scale`, the currency must be in the table. #### Parameters ##### amount `bigint` ##### currency `string` ##### scale? `number` #### Returns `Money` ## Properties ### amount > `readonly` **amount**: `bigint` Defined in: [packages/core/src/money.ts:45](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/money.ts#L45) *** ### currency > `readonly` **currency**: `string` Defined in: [packages/core/src/money.ts:46](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/money.ts#L46) *** ### scale > `readonly` **scale**: `number` Defined in: [packages/core/src/money.ts:47](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/money.ts#L47) *** ### currencies > `readonly` `static` **currencies**: readonly `string`[] Defined in: [packages/core/src/money.ts:43](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/money.ts#L43) All the currency codes in the built-in ISO 4217 table. ## Methods ### equals() > **equals**(`other`): `boolean` Defined in: [packages/core/src/money.ts:89](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/money.ts#L89) True when the currency is the same and the amounts are equal at a common scale. #### Parameters ##### other `Money` #### Returns `boolean` *** ### toDecimalString() > **toDecimalString**(): `string` Defined in: [packages/core/src/money.ts:84](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/money.ts#L84) Writes the amount as a decimal string with `scale` digits after the point. #### Returns `string` *** ### toString() > **toString**(): `string` Defined in: [packages/core/src/money.ts:100](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/money.ts#L100) Writes the amount and the currency, for example `12.50 USD`. #### Returns `string` *** ### fromDecimal() > `static` **fromDecimal**(`text`, `currency`): `Money` Defined in: [packages/core/src/money.ts:75](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/money.ts#L75) Makes a `Money` from a decimal string, such as `"19.99"`. The scale is the larger of the digits after the point and the ISO 4217 exponent. #### Parameters ##### text `string` ##### currency `string` #### Returns `Money` *** ### fromMinor() > `static` **fromMinor**(`amount`, `currency`, `scale?`): `Money` Defined in: [packages/core/src/money.ts:67](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/money.ts#L67) Makes a `Money` from minor units. The scale defaults to the ISO 4217 exponent. #### Parameters ##### amount `string` \| `number` \| `bigint` ##### currency `string` ##### scale? `number` #### Returns `Money` --- **Millwork** *** Millwork / @millwork-ts/core / Percent # Class: Percent Defined in: [packages/core/src/codecs/percent.ts:18](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/percent.ts#L18) A percentage. `fraction` is exact: 7.5 % is `0.075`. A `Percent` is immutable. ## Properties ### fraction > `readonly` **fraction**: `Decimal` Defined in: [packages/core/src/codecs/percent.ts:19](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/percent.ts#L19) ## Methods ### equals() > **equals**(`other`): `boolean` Defined in: [packages/core/src/codecs/percent.ts:42](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/percent.ts#L42) Returns `true` if both percents have the same fraction. #### Parameters ##### other `Percent` #### Returns `boolean` *** ### in() > **in**(`unit`): `Decimal` Defined in: [packages/core/src/codecs/percent.ts:32](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/percent.ts#L32) Gives the value in a unit: `in('percent')` of 0.075 is `7.5`. #### Parameters ##### unit `PercentUnit` #### Returns `Decimal` *** ### toNumber() > **toNumber**(): `number` Defined in: [packages/core/src/codecs/percent.ts:37](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/percent.ts#L37) Gives the fraction as the nearest `number`. #### Returns `number` *** ### fromFraction() > `static` **fromFraction**(`fraction`): `Percent` Defined in: [packages/core/src/codecs/percent.ts:27](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/percent.ts#L27) Makes a `Percent` from a fraction, where 1 is 100 %. #### Parameters ##### fraction `Decimal` #### Returns `Percent` --- **Millwork** *** Millwork / @millwork-ts/core / RawWrite # Class: RawWrite Defined in: [packages/core/src/shapes/shape.ts:660](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L660) A raw value for a `Slot` write. A binding that writes through a setter passes this. ## Constructors ### Constructor > **new RawWrite**(`raw`): `RawWrite` Defined in: [packages/core/src/shapes/shape.ts:661](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L661) #### Parameters ##### raw `unknown` #### Returns `RawWrite` ## Properties ### raw > `readonly` **raw**: `unknown` Defined in: [packages/core/src/shapes/shape.ts:661](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L661) --- **Millwork** *** Millwork / @millwork-ts/core / Shape # Class: Shape Defined in: [packages/core/src/shapes/shape.ts:896](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L896) A mutable nested structure with no identity. The app edits it in place. It tracks each change by path and rolls back by path. ## Implements - `Tracked` ## Constructors ### Constructor > **new Shape**(`values?`): `Shape` Defined in: [packages/core/src/shapes/shape.ts:902](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L902) A new, clean shape from field values (hydrated values, not raw JSON). #### Parameters ##### values? `object` #### Returns `Shape` ## Properties ### kind > `readonly` `static` **kind**: `"value"` \| `"shape"` = `'shape'` Defined in: [packages/core/src/shapes/shape.ts:899](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L899) *** ### type > `static` **type**: `string` = `''` Defined in: [packages/core/src/shapes/shape.ts:898](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L898) The registry name. Each subclass sets it: minifiers rename classes. ## Accessors ### isDirty #### Get Signature > **get** **isDirty**(): `boolean` Defined in: [packages/core/src/shapes/shape.ts:914](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L914) `true` when the local raw value is not equal to the remote raw value. ##### Returns `boolean` `true` when the local raw value is not equal to the remote raw value. #### Implementation of `Tracked`.`isDirty` ## Methods ### changes() > **changes**(): `Change`[] Defined in: [packages/core/src/shapes/shape.ts:918](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L918) Each change from the remote value, with its path. #### Returns `Change`[] #### Implementation of `Tracked`.`changes` *** ### equals() > **equals**(`other`): `boolean` Defined in: [packages/core/src/shapes/shape.ts:927](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L927) Structural equality, field by field, with each codec `equals`. #### Parameters ##### other `unknown` #### Returns `boolean` *** ### rollback() > **rollback**(`path?`): `void` Defined in: [packages/core/src/shapes/shape.ts:922](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L922) Rolls back one path, or everything when there is no path. #### Parameters ##### path? readonly `string`[] #### Returns `void` #### Implementation of `Tracked`.`rollback` *** ### fromRaw() > `static` **fromRaw**\<`T`\>(`this`, `raw`): `T` Defined in: [packages/core/src/shapes/shape.ts:910](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L910) A standalone shape over a raw JSON value. #### Type Parameters ##### T `T` #### Parameters ##### this new (`values?`) => `T` ##### raw `unknown` #### Returns `T` --- **Millwork** *** Millwork / @millwork-ts/core / ShapeArray # Class: ShapeArray\ Defined in: [packages/core/src/shapes/shape.ts:1015](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L1015) A read-only list of shapes. Change it with `add`, `remove` and `move`, so each change goes through the owner and is tracked. ## Extends - `Array`\<`T`\> ## Type Parameters ### T `T` ## Implements - `Tracked` ## Indexable > \[`n`: `number`\]: `T` ## Accessors ### isDirty #### Get Signature > **get** **isDirty**(): `boolean` Defined in: [packages/core/src/shapes/shape.ts:1021](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L1021) `true` when the local raw value is not equal to the remote raw value. ##### Returns `boolean` `true` when the local raw value is not equal to the remote raw value. #### Implementation of `Tracked`.`isDirty` *** ### \[species\] #### Get Signature > **get** `static` **\[species\]**(): `ArrayConstructor` Defined in: [packages/core/src/shapes/shape.ts:1017](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L1017) Makes array methods such as `map` give a plain `Array`, not a `ShapeArray`. ##### Returns `ArrayConstructor` #### Overrides `Array.[species]` ## Methods ### add() > **add**(`member`, `at?`): `void` Defined in: [packages/core/src/shapes/shape.ts:1034](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L1034) Adds a member (a shape, or its field values) at an index, or at the end. #### Parameters ##### member `object` \| `T` ##### at? `number` #### Returns `void` *** ### changes() > **changes**(): `Change`[] Defined in: [packages/core/src/shapes/shape.ts:1025](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L1025) Each change from the remote value, with its path. #### Returns `Change`[] #### Implementation of `Tracked`.`changes` *** ### move() > **move**(`from`, `to`): `void` Defined in: [packages/core/src/shapes/shape.ts:1049](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L1049) Moves the member at one index to another index. #### Parameters ##### from `number` ##### to `number` #### Returns `void` *** ### remove() > **remove**(`member`): `void` Defined in: [packages/core/src/shapes/shape.ts:1041](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L1041) Removes a member: the shape itself, its key, or its index when there is no key. #### Parameters ##### member `string` \| `number` \| `T` #### Returns `void` *** ### rollback() > **rollback**(`path?`): `void` Defined in: [packages/core/src/shapes/shape.ts:1029](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L1029) Rolls back one path, or everything when there is no path. #### Parameters ##### path? readonly `string`[] #### Returns `void` #### Implementation of `Tracked`.`rollback` --- **Millwork** *** Millwork / @millwork-ts/core / Slot # Class: Slot Defined in: [packages/core/src/shapes/shape.ts:669](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L669) The live node of one field: a shape, a polymorphic shape or a shape array. It keeps the node identity while the raw value changes. Shapes use it for their nested fields; the WarpDrive adapter uses it for record fields. ## Constructors ### Constructor > **new Slot**(`definition`, `binding`): `Slot` Defined in: [packages/core/src/shapes/shape.ts:678](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L678) #### Parameters ##### definition `Omit`\<`FieldInput`, `"name"`\> ##### binding `Binding` #### Returns `Slot` ## Methods ### node() > **node**(...`given`): `unknown` Defined in: [packages/core/src/shapes/shape.ts:687](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L687) The node for this raw value (the current raw value when there is no argument). #### Parameters ##### given ...\[`raw?`: `unknown`\] #### Returns `unknown` *** ### prepare() > **prepare**(`value`): `unknown` Defined in: [packages/core/src/shapes/shape.ts:710](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L710) The raw value to write for an assigned value, reconciled with the remote raw value. #### Parameters ##### value `unknown` #### Returns `unknown` --- **Millwork** *** Millwork / @millwork-ts/core / Value # Class: Value Defined in: [packages/core/src/shapes/shape.ts:959](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L959) An immutable value object made of fields. To change it, make a copy with `with()`. ## Constructors ### Constructor > **new Value**(`values?`): `Value` Defined in: [packages/core/src/shapes/shape.ts:964](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L964) #### Parameters ##### values? `object` #### Returns `Value` ## Properties ### kind > `readonly` `static` **kind**: `"value"` \| `"shape"` = `'value'` Defined in: [packages/core/src/shapes/shape.ts:962](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L962) *** ### type > `static` **type**: `string` = `''` Defined in: [packages/core/src/shapes/shape.ts:961](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L961) The registry and codec name. Each subclass sets it: minifiers rename classes. ## Accessors ### codec #### Get Signature > **get** `static` **codec**(): `Codec`\<`RawObject`, `Value`\> Defined in: [packages/core/src/shapes/shape.ts:979](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L979) The codec of this value class, for a record field or a legacy transform. ##### Returns `Codec`\<`RawObject`, `Value`\> ## Methods ### equals() > **equals**(`other`): `boolean` Defined in: [packages/core/src/shapes/shape.ts:994](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L994) Structural equality, field by field, with each codec `equals`. #### Parameters ##### other `unknown` #### Returns `boolean` *** ### with() > **with**(`changes`): `this` Defined in: [packages/core/src/shapes/shape.ts:984](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L984) A copy with some fields changed. #### Parameters ##### changes `Partial`\<`Omit`\<`this`, keyof `Value`\>\> #### Returns `this` *** ### fromRaw() > `static` **fromRaw**\<`T`\>(`this`, `raw`): `T` Defined in: [packages/core/src/shapes/shape.ts:974](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L974) A value over a raw JSON value. #### Type Parameters ##### T `T` #### Parameters ##### this new (`values?`) => `T` ##### raw `unknown` #### Returns `T` --- **Millwork** *** Millwork / @millwork-ts/core / arrayOf # Function: arrayOf() > **arrayOf**\<`Raw`, `Value`, `Options`\>(`codec`): `Codec`\<`Raw`[], readonly (`Value` \| `undefined`)[], `Options`\> Defined in: [packages/core/src/codec.ts:132](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codec.ts#L132) A codec for an array of values. Bad elements hydrate to `undefined`. ## Type Parameters ### Raw `Raw` ### Value `Value` ### Options `Options` ## Parameters ### codec `Codec`\<`Raw`, `Value`, `Options`\> ## Returns `Codec`\<`Raw`[], readonly (`Value` \| `undefined`)[], `Options`\> --- **Millwork** *** Millwork / @millwork-ts/core / codecNamed # Function: codecNamed() > **codecNamed**(`name`): `AnyCodec` \| `undefined` Defined in: [packages/core/src/shapes/registry.ts:28](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/registry.ts#L28) The codec with this name: a registered codec, or a codec from core. ## Parameters ### name `string` ## Returns `AnyCodec` \| `undefined` --- **Millwork** *** Millwork / @millwork-ts/core / currencyExponent # Function: currencyExponent() > **currencyExponent**(`code`): `number` \| `undefined` Defined in: [packages/core/src/money.ts:31](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/money.ts#L31) Gives the ISO 4217 minor unit exponent of a currency code, or `undefined` for an unknown code. ## Parameters ### code `string` ## Returns `number` \| `undefined` --- **Millwork** *** Millwork / @millwork-ts/core / defineCodec # Function: defineCodec() > **defineCodec**\<`Raw`, `Value`, `Options`\>(`spec`): `Codec`\<`Raw`, `Value`, `Options`\> Defined in: [packages/core/src/codec.ts:98](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codec.ts#L98) Makes a codec from a parse and format pair. ## Type Parameters ### Raw `Raw` ### Value `Value` ### Options `Options` = `undefined` ## Parameters ### spec `CodecSpec`\<`Raw`, `Value`, `Options`\> ## Returns `Codec`\<`Raw`, `Value`, `Options`\> --- **Millwork** *** Millwork / @millwork-ts/core / definitionOf # Function: definitionOf() > **definitionOf**(`cls`): `ShapeDefinition` Defined in: [packages/core/src/shapes/shape.ts:123](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L123) The internal definition of a shape or value class. ## Parameters ### cls `StructuredClass` ## Returns `ShapeDefinition` --- **Millwork** *** Millwork / @millwork-ts/core / durationMilliseconds # Function: durationMilliseconds() > **durationMilliseconds**(`fields`): `number` Defined in: [packages/core/src/date-writers.ts:74](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/date-writers.ts#L74) The length of a duration in milliseconds. A day is 24 hours. Years, months and weeks have no fixed length, so they give a RangeError. ## Parameters ### fields `DurationFields` ## Returns `number` --- **Millwork** *** Millwork / @millwork-ts/core / field # Function: field() ## Call Signature > **field**\<`This`, `V`\>(`target`, `context`): `ClassAccessorDecoratorResult`\<`This`, `V`\> Defined in: [packages/core/src/shapes/shape.ts:217](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L217) Declares a field of a shape or value class. - `@field accessor city!: string`: a plain JSON field. - `@field('money', { wire: 'decimal' }) accessor total!: Money`: a codec field. - `@field(Address) accessor shipTo!: Address`: a nested shape (or value) class. - `@field(LineItem, { array: true, key: 'sku' }) accessor items!: ShapeArray`. - `@field({ card: Card, bank: Bank }, { discriminator: '$type' })`: polymorphic. Ember compiles decorators with legacy semantics. There, use `declare`: `@field('money') declare total: Money`. ### Type Parameters #### This `This` #### V `V` ### Parameters #### target `ClassAccessorDecoratorTarget`\<`This`, `V`\> #### context `ClassAccessorDecoratorContext`\<`This`, `V`\> ### Returns `ClassAccessorDecoratorResult`\<`This`, `V`\> ## Call Signature > **field**(`prototype`, `key`): `void` Defined in: [packages/core/src/shapes/shape.ts:221](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L221) Declares a field of a shape or value class. - `@field accessor city!: string`: a plain JSON field. - `@field('money', { wire: 'decimal' }) accessor total!: Money`: a codec field. - `@field(Address) accessor shipTo!: Address`: a nested shape (or value) class. - `@field(LineItem, { array: true, key: 'sku' }) accessor items!: ShapeArray`. - `@field({ card: Card, bank: Bank }, { discriminator: '$type' })`: polymorphic. Ember compiles decorators with legacy semantics. There, use `declare`: `@field('money') declare total: Money`. ### Parameters #### prototype `object` #### key `string` ### Returns `void` ## Call Signature > **field**(`ref?`, `options?`): `FieldDecorator` Defined in: [packages/core/src/shapes/shape.ts:222](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L222) Declares a field of a shape or value class. - `@field accessor city!: string`: a plain JSON field. - `@field('money', { wire: 'decimal' }) accessor total!: Money`: a codec field. - `@field(Address) accessor shipTo!: Address`: a nested shape (or value) class. - `@field(LineItem, { array: true, key: 'sku' }) accessor items!: ShapeArray`. - `@field({ card: Card, bank: Bank }, { discriminator: '$type' })`: polymorphic. Ember compiles decorators with legacy semantics. There, use `declare`: `@field('money') declare total: Money`. ### Parameters #### ref? `FieldRef` #### options? `FieldOptions` ### Returns `FieldDecorator` --- **Millwork** *** Millwork / @millwork-ts/core / formatDuration # Function: formatDuration() > **formatDuration**(`fields`): `string` Defined in: [packages/core/src/date-writers.ts:41](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/date-writers.ts#L41) Writes an ISO 8601 duration. A negative duration is `-P1D`. Zero is `PT0S`. ## Parameters ### fields `DurationFields` ## Returns `string` --- **Millwork** *** Millwork / @millwork-ts/core / formatEpoch # Function: formatEpoch() > **formatEpoch**(`epochNanoseconds`, `unit?`): `string` \| `number` Defined in: [packages/core/src/date-writers.ts:17](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/date-writers.ts#L17) Writes an epoch in a unit: a number when it is a safe integer, else a decimal string. ## Parameters ### epochNanoseconds `bigint` ### unit? `EpochUnit` = `'ms'` ## Returns `string` \| `number` --- **Millwork** *** Millwork / @millwork-ts/core / formatOffset # Function: formatOffset() > **formatOffset**(`minutes`): `string` Defined in: [packages/core/src/date-writers.ts:33](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/date-writers.ts#L33) Writes an offset in minutes as `±hh:mm`. ## Parameters ### minutes `number` ## Returns `string` --- **Millwork** *** Millwork / @millwork-ts/core / fraction # Function: fraction() > **fraction**(`nanoseconds`): `string` Defined in: [packages/core/src/date-writers.ts:27](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/date-writers.ts#L27) Writes a fraction of a second with no zeros at the end: `.5`, `.123456789`, or nothing. ## Parameters ### nanoseconds `number` ## Returns `string` --- **Millwork** *** Millwork / @millwork-ts/core / mapOf # Function: mapOf() > **mapOf**\<`R`, `V`, `O`\>(`inner`): `Codec`\<`MapRaw`\<`R`\>, `ReadonlyMap`\<`string`, `V`\>, `MapOptions`\<`O`\> \| `undefined`\> Defined in: [packages/core/src/codecs/collections.ts:57](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/collections.ts#L57) Makes a codec for a map: an object or a list of entries to a `ReadonlyMap` that throws on change. ## Type Parameters ### R `R` ### V `V` ### O `O` ## Parameters ### inner `Codec`\<`R`, `V`, `O`\> ## Returns `Codec`\<`MapRaw`\<`R`\>, `ReadonlyMap`\<`string`, `V`\>, `MapOptions`\<`O`\> \| `undefined`\> --- **Millwork** *** Millwork / @millwork-ts/core / nullable # Function: nullable() > **nullable**\<`Raw`, `Value`, `Options`\>(`codec`): `Codec`\<`Raw`, `Value` \| `null`, `Options`\> Defined in: [packages/core/src/codec.ts:169](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codec.ts#L169) A codec that keeps `null` as `null`, where the plain codec gives `undefined`. ## Type Parameters ### Raw `Raw` ### Value `Value` ### Options `Options` ## Parameters ### codec `Codec`\<`Raw`, `Value`, `Options`\> ## Returns `Codec`\<`Raw`, `Value` \| `null`, `Options`\> --- **Millwork** *** Millwork / @millwork-ts/core / onInvalid # Function: onInvalid() > **onInvalid**(`next`): `void` Defined in: [packages/core/src/codec.ts:87](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codec.ts#L87) Sets the function that gets a report for each raw value that a codec cannot hydrate. Pass `undefined` to go back to the default: one `console.warn` for each codec and raw value. ## Parameters ### next `InvalidHandler` \| `undefined` ## Returns `void` --- **Millwork** *** Millwork / @millwork-ts/core / parseEpoch # Function: parseEpoch() > **parseEpoch**(`value`, `unit`): `EpochRecord` Defined in: [packages/core/src/dates.ts:192](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L192) Reads an epoch number in seconds, milliseconds, microseconds or nanoseconds. It must be an integer. ## Parameters ### value `string` \| `number` \| `bigint` ### unit `EpochUnit` ## Returns `EpochRecord` --- **Millwork** *** Millwork / @millwork-ts/core / parseIsoDate # Function: parseIsoDate() > **parseIsoDate**(`text`): `DateRecord` Defined in: [packages/core/src/dates.ts:100](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L100) Reads `"2026-12-01"`. ## Parameters ### text `string` ## Returns `DateRecord` --- **Millwork** *** Millwork / @millwork-ts/core / parseIsoDuration # Function: parseIsoDuration() > **parseIsoDuration**(`text`): `DurationRecord` Defined in: [packages/core/src/dates.ts:205](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L205) Reads an ISO 8601 duration such as `"P1Y2M3DT4H5M6.5S"`. Only seconds can have a fraction. ## Parameters ### text `string` ## Returns `DurationRecord` --- **Millwork** *** Millwork / @millwork-ts/core / parseIsoTime # Function: parseIsoTime() > **parseIsoTime**(`text`): `TimeRecord` Defined in: [packages/core/src/dates.ts:118](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L118) Reads `"14:30"`, `"14:30:05"` or `"14:30:05.123456789"`. ## Parameters ### text `string` ## Returns `TimeRecord` --- **Millwork** *** Millwork / @millwork-ts/core / parseLocalDateTime # Function: parseLocalDateTime() > **parseLocalDateTime**(`text`): `LocalDateTimeRecord` Defined in: [packages/core/src/dates.ts:128](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L128) Reads `"2026-12-01T14:30:00"`, with no offset and no zone. ## Parameters ### text `string` ## Returns `LocalDateTimeRecord` --- **Millwork** *** Millwork / @millwork-ts/core / parseRfc3339 # Function: parseRfc3339() > **parseRfc3339**(`text`): `OffsetDateTimeRecord` Defined in: [packages/core/src/dates.ts:136](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L136) Reads an RFC 3339 date-time with an offset or `Z`, such as `"2026-12-01T14:30:00-05:00"`. ## Parameters ### text `string` ## Returns `OffsetDateTimeRecord` --- **Millwork** *** Millwork / @millwork-ts/core / parseRfc9557 # Function: parseRfc9557() > **parseRfc9557**(`text`): `ZonedDateTimeRecord` Defined in: [packages/core/src/dates.ts:163](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L163) Reads an RFC 9557 date-time: RFC 3339 plus a time zone in brackets, such as `"2026-12-01T14:30:00-05:00[America/Toronto]"`. Other annotations (`[u-ca=iso8601]`) are given in `annotations`. The critical flag (`!`) is read and dropped. ## Parameters ### text `string` ## Returns `ZonedDateTimeRecord` --- **Millwork** *** Millwork / @millwork-ts/core / parseWith # Function: parseWith() > **parseWith**\<`Raw`, `Value`, `Options`\>(`codec`, `raw`, `options?`): `Value` Defined in: [packages/core/src/codec.ts:190](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codec.ts#L190) Reads a raw value strictly: it throws on bad input and sends no report. It uses `codec.parse`, or `hydrate` with reports muted when a codec has no `parse`. ## Type Parameters ### Raw `Raw` ### Value `Value` ### Options `Options` ## Parameters ### codec `Codec`\<`Raw`, `Value`, `Options`\> ### raw `Raw` \| `null` \| `undefined` ### options? `Options` ## Returns `Value` --- **Millwork** *** Millwork / @millwork-ts/core / parseYearMonth # Function: parseYearMonth() > **parseYearMonth**(`text`): `YearMonthRecord` Defined in: [packages/core/src/dates.ts:110](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L110) Reads `"2026-12"`. ## Parameters ### text `string` ## Returns `YearMonthRecord` --- **Millwork** *** Millwork / @millwork-ts/core / rangeOf # Function: rangeOf() > **rangeOf**\<`R`, `V`, `O`\>(`inner`): `Codec`\<`RangeRaw`\<`R`\>, `Range`\<`V`\>, `RangeOptions`\<`O`\> \| `undefined`\> Defined in: [packages/core/src/codecs/range.ts:40](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/range.ts#L40) Makes a codec for a range of an inner codec's values. In the `'iso'` and `'postgres'` forms, each end point is a string, so the inner codec must read a string raw. ## Type Parameters ### R `R` ### V `V` ### O `O` ## Parameters ### inner `Codec`\<`R`, `V`, `O`\> ## Returns `Codec`\<`RangeRaw`\<`R`\>, `Range`\<`V`\>, `RangeOptions`\<`O`\> \| `undefined`\> --- **Millwork** *** Millwork / @millwork-ts/core / rawOf # Function: rawOf() > **rawOf**(`node`): `unknown` Defined in: [packages/core/src/shapes/shape.ts:655](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L655) The raw JSON value of a shape, value or shape array. ## Parameters ### node `Shape` \| `Value` \| `ShapeArray`\<`Structured`\> ## Returns `unknown` --- **Millwork** *** Millwork / @millwork-ts/core / readDuration # Function: readDuration() > **readDuration**(`raw`, `unit?`): `DurationFields` Defined in: [packages/core/src/date-writers.ts:116](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/date-writers.ts#L116) Reads a wire duration into its units. A string is ISO 8601. A number is in `unit`: seconds by default, or milliseconds. It must be a whole number of milliseconds. ## Parameters ### raw `string` \| `number` ### unit? `"s"` \| `"ms"` \| `"iso"` ## Returns `DurationFields` --- **Millwork** *** Millwork / @millwork-ts/core / readInterval # Function: readInterval() > **readInterval**\<`I`\>(`raw`, `instant`, `plus`): `IntervalWire`\<`I`\> Defined in: [packages/core/src/date-writers.ts:137](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/date-writers.ts#L137) Reads `"a/b"`, `"a/PT1H"`, `"P1D/b"` or `{ start, end }`. Each end must be there: an open interval is bad input. `plus` adds a duration to an instant; `sign` is `-1` to subtract. ## Type Parameters ### I `I` ## Parameters ### raw `string` \| \{ `end`: `string`; `start`: `string`; \} ### instant (`text`) => `I` ### plus (`at`, `duration`, `sign`) => `I` ## Returns `IntervalWire`\<`I`\> --- **Millwork** *** Millwork / @millwork-ts/core / registerCodecs # Function: registerCodecs() > **registerCodecs**(`map`): `void` Defined in: [packages/core/src/shapes/registry.ts:23](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/registry.ts#L23) Adds codecs to the name registry, so a field can name them (`@field('datetime')`, `valueField('at', 'datetime')`). Adapter packages give their codecs to the app; the app registers them once, before the first read. A name that is already there is replaced. ## Parameters ### map `Readonly`\<`Record`\<`string`, `AnyCodec`\>\> ## Returns `void` --- **Millwork** *** Millwork / @millwork-ts/core / registerShapes # Function: registerShapes() > **registerShapes**(...`args`): `void` Defined in: [packages/core/src/shapes/registry.ts:53](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/registry.ts#L53) Adds shape and value classes to the name registry, by their static `type`. A class can register again. A different class with a `type` that is already there throws a `TypeError`, unless the last argument is `{ replace: true }`. ## Parameters ### args \[`...NamedClass[]`, `RegisterShapesOptions`\] \| `NamedClass`[] ## Returns `void` --- **Millwork** *** Millwork / @millwork-ts/core / registeredCodecs # Function: registeredCodecs() > **registeredCodecs**(): `Readonly`\<`Record`\<`string`, `AnyCodec`\>\> Defined in: [packages/core/src/shapes/registry.ts:35](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/registry.ts#L35) Each codec that a name can find: the core codecs, then the registered codecs. ## Returns `Readonly`\<`Record`\<`string`, `AnyCodec`\>\> --- **Millwork** *** Millwork / @millwork-ts/core / reportInvalid # Function: reportInvalid() > **reportInvalid**(`report`): `void` Defined in: [packages/core/src/codec.ts:93](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codec.ts#L93) Gives a report to the current `onInvalid` handler. Codec authors can call it. ## Parameters ### report `InvalidReport` ## Returns `void` --- **Millwork** *** Millwork / @millwork-ts/core / sameDuration # Function: sameDuration() > **sameDuration**(`a`, `b`): `boolean` Defined in: [packages/core/src/date-writers.ts:95](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/date-writers.ts#L95) Compares two durations. Years, months, weeks and days have no fixed length (a day is not always 24 hours across a DST change), so they must be the same. The other units compare by their length: `PT1H` equals `PT60M`, but `P1D` does not equal `PT24H`. ## Parameters ### a `DurationFields` ### b `DurationFields` ## Returns `boolean` --- **Millwork** *** Millwork / @millwork-ts/core / setOf # Function: setOf() > **setOf**\<`R`, `V`, `O`\>(`inner`): `Codec`\<`R`[], `ReadonlySet`\<`V`\>, `O`\> Defined in: [packages/core/src/codecs/collections.ts:10](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/collections.ts#L10) Makes a codec for a set: a raw array to a `ReadonlySet` that throws on change. Duplicates by the inner `equals` are removed. One bad element makes the whole value bad. ## Type Parameters ### R `R` ### V `V` ### O `O` ## Parameters ### inner `Codec`\<`R`, `V`, `O`\> ## Returns `Codec`\<`R`[], `ReadonlySet`\<`V`\>, `O`\> --- **Millwork** *** Millwork / @millwork-ts/core / shape # Function: shape() > **shape**(`input`): *typeof* `Shape` Defined in: [packages/core/src/shapes/shape.ts:1102](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L1102) A shape class from the JSON form. It has the same power as a class with `@field`. ## Parameters ### input `StructureInput` ## Returns *typeof* `Shape` --- **Millwork** *** Millwork / @millwork-ts/core / shapeNamed # Function: shapeNamed() > **shapeNamed**(`type`): `NamedClass` \| `undefined` Defined in: [packages/core/src/shapes/registry.ts:74](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/registry.ts#L74) The shape or value class with this `type` name. ## Parameters ### type `string` ## Returns `NamedClass` \| `undefined` --- **Millwork** *** Millwork / @millwork-ts/core / shapeSchema # Function: shapeSchema() > **shapeSchema**\<`T`\>(`cls`): `StandardSchemaV1`\<`unknown`, `T`\> Defined in: [packages/core/src/shapes/schema.ts:16](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/schema.ts#L16) A Standard Schema (v1) for a shape or value class. It checks the raw JSON form: each required field, and each codec field with the strict codec read. Each issue has the path of the field. A valid input gives a new standalone instance. ## Type Parameters ### T `T` *extends* `Shape` \| `Value` ## Parameters ### cls `StructuredClass`\<`T`\> ## Returns `StandardSchemaV1`\<`unknown`, `T`\> --- **Millwork** *** Millwork / @millwork-ts/core / snowflakeTime # Function: snowflakeTime() > **snowflakeTime**(`id`, `epoch?`): `number` Defined in: [packages/core/src/codecs/snowflake.ts:29](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/snowflake.ts#L29) Gives the time of a snowflake in milliseconds since the Unix epoch. ## Parameters ### id `bigint` ### epoch? `bigint` = `TWITTER_EPOCH` ## Returns `number` --- **Millwork** *** Millwork / @millwork-ts/core / splitIsoInterval # Function: splitIsoInterval() > **splitIsoInterval**(`text`): `IntervalParts` Defined in: [packages/core/src/dates.ts:231](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L231) Splits an ISO 8601 interval: `"a/b"`, `"a/PT1H"`, `"P1D/b"`, with `..` or empty for an open end. It does not parse the parts; the caller picks the parser for each one. ## Parameters ### text `string` ## Returns `IntervalParts` --- **Millwork** *** Millwork / @millwork-ts/core / toStandardSchema # Function: toStandardSchema() ## Call Signature > **toStandardSchema**\<`T`\>(`cls`): `StandardSchemaV1`\<`unknown`, `T`\> Defined in: [packages/core/src/standard-schema.ts:16](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/standard-schema.ts#L16) Makes a Standard Schema (v1) from a codec, or from a shape or value class. - A class gives the same schema as `shapeSchema(cls)`. - For a codec, `validate` reads the raw form with the strict path, so bad input gives issues and no `onInvalid` report. `null` and `undefined` give an issue: a shape schema decides if a field is optional. ### Type Parameters #### T `T` *extends* `Shape` \| `Value` ### Parameters #### cls `StructuredClass`\<`T`\> ### Returns `StandardSchemaV1`\<`unknown`, `T`\> ## Call Signature > **toStandardSchema**\<`R`, `V`, `O`\>(`codec`, `options?`): `StandardSchemaV1`\<`R`, `V`\> Defined in: [packages/core/src/standard-schema.ts:19](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/standard-schema.ts#L19) Makes a Standard Schema (v1) from a codec, or from a shape or value class. - A class gives the same schema as `shapeSchema(cls)`. - For a codec, `validate` reads the raw form with the strict path, so bad input gives issues and no `onInvalid` report. `null` and `undefined` give an issue: a shape schema decides if a field is optional. ### Type Parameters #### R `R` #### V `V` #### O `O` ### Parameters #### codec `Codec`\<`R`, `V`, `O`\> #### options? `O` ### Returns `StandardSchemaV1`\<`R`, `V`\> --- **Millwork** *** Millwork / @millwork-ts/core / ulidTime # Function: ulidTime() > **ulidTime**(`id`): `number` Defined in: [packages/core/src/codecs/ulid.ts:12](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/ulid.ts#L12) Gives the time of a ULID in milliseconds since the Unix epoch. ## Parameters ### id `string` ## Returns `number` --- **Millwork** *** Millwork / @millwork-ts/core / value # Function: value() > **value**(`input`): *typeof* `Value` Defined in: [packages/core/src/shapes/shape.ts:1112](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L1112) A value class from the JSON form. It has the same power as a class with `@field`. ## Parameters ### input `StructureInput` ## Returns *typeof* `Value` --- **Millwork** *** Millwork / @millwork-ts/core / valueCodec # Function: valueCodec() > **valueCodec**\<`T`\>(`cls`): `Codec`\<`RawObject`, `T`\> Defined in: [packages/core/src/shapes/shape.ts:939](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L939) The codec of a value class: raw JSON object in, value instance out. ## Type Parameters ### T `T` *extends* `Value` ## Parameters ### cls `StructuredClass`\<`T`\> ## Returns `Codec`\<`RawObject`, `T`\> --- **Millwork** *** Millwork / @millwork-ts/core / writeDuration # Function: writeDuration() > **writeDuration**(`fields`, `unit?`): `string` \| `number` Defined in: [packages/core/src/date-writers.ts:106](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/date-writers.ts#L106) Writes a duration as ISO 8601, or as a number of seconds or milliseconds. ## Parameters ### fields `DurationFields` ### unit? `"s"` \| `"ms"` \| `"iso"` ## Returns `string` \| `number` --- **Millwork** *** Millwork / @millwork-ts/core / Binding # Interface: Binding Defined in: [packages/core/src/shapes/shape.ts:601](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L601) Where a shape reads and writes its raw value. A standalone shape has a local binding. The WarpDrive adapter gives a binding to a record field. ## Methods ### read() > **read**(): `unknown` Defined in: [packages/core/src/shapes/shape.ts:603](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L603) The current (local) raw value. #### Returns `unknown` *** ### remote() > **remote**(): `unknown` Defined in: [packages/core/src/shapes/shape.ts:605](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L605) The remote raw value: what the server sent. #### Returns `unknown` *** ### write() > **write**(`next`): `void` Defined in: [packages/core/src/shapes/shape.ts:607](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L607) Replaces the raw value. #### Parameters ##### next `unknown` #### Returns `void` --- **Millwork** *** Millwork / @millwork-ts/core / BitflagsOptions # Interface: BitflagsOptions Defined in: [packages/core/src/codecs/bitflags.ts:7](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/bitflags.ts#L7) Options of the `bitflags` codec. ## Properties ### flags > **flags**: readonly `string`[] Defined in: [packages/core/src/codecs/bitflags.ts:9](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/bitflags.ts#L9) The flag names. The name at index `i` is bit `i`. At most 53 flags. --- **Millwork** *** Millwork / @millwork-ts/core / BooleanIshOptions # Interface: BooleanIshOptions Defined in: [packages/core/src/codecs/boolean-ish.ts:7](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/boolean-ish.ts#L7) Options of the `boolean-ish` codec: the raw values that serialize writes. ## Properties ### false? > `optional` **false?**: `string` \| `number` \| `boolean` Defined in: [packages/core/src/codecs/boolean-ish.ts:11](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/boolean-ish.ts#L11) The raw for `false`. The default is `false`. *** ### true? > `optional` **true?**: `string` \| `number` \| `boolean` Defined in: [packages/core/src/codecs/boolean-ish.ts:9](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/boolean-ish.ts#L9) The raw for `true`. The default is `true`. --- **Millwork** *** Millwork / @millwork-ts/core / BytesOptions # Interface: BytesOptions Defined in: [packages/core/src/codecs/bytes.ts:7](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/bytes.ts#L7) Options of the `bytes` codec. ## Properties ### encoding? > `optional` **encoding?**: `"base64"` \| `"base64url"` \| `"hex"` Defined in: [packages/core/src/codecs/bytes.ts:9](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/bytes.ts#L9) The text encoding on the wire. The default is `'base64'`. --- **Millwork** *** Millwork / @millwork-ts/core / Change # Interface: Change Defined in: [packages/core/src/shapes/shape.ts:461](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L461) One change between the remote raw value and the local raw value. ## Properties ### from > `readonly` **from**: `unknown` Defined in: [packages/core/src/shapes/shape.ts:467](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L467) The remote value. A leaf gives its hydrated value; a shape or member gives raw JSON. *** ### kind > `readonly` **kind**: `"set"` \| `"add"` \| `"remove"` \| `"move"` Defined in: [packages/core/src/shapes/shape.ts:463](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L463) `set` for a value, `add` and `remove` for a member of a shape array, `move` for order. *** ### path > `readonly` **path**: readonly `string`[] Defined in: [packages/core/src/shapes/shape.ts:465](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L465) The path from the shape. A shape array member is named by its key (or its index). *** ### to > `readonly` **to**: `unknown` Defined in: [packages/core/src/shapes/shape.ts:469](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L469) The local value, in the same form as `from`. --- **Millwork** *** Millwork / @millwork-ts/core / Codec # Interface: Codec\ Defined in: [packages/core/src/codec.ts:12](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codec.ts#L12) A codec turns a raw wire value into a rich value and back. - `hydrate` is forgiving. Bad wire data gives `undefined` and a report through `onInvalid`. It never throws, so one bad field does not fail a whole response. - `serialize` is strict. A value of the wrong type throws a `TypeError`. - `equals` compares two values. Dirty checks use it. - Hydrated plain objects and arrays are frozen. To change a value, set a new one. ## Type Parameters ### Raw `Raw` ### Value `Value` ### Options `Options` = `undefined` ## Properties ### name > `readonly` **name**: `string` Defined in: [packages/core/src/codec.ts:13](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codec.ts#L13) ## Methods ### equals() > **equals**(`a`, `b`): `boolean` Defined in: [packages/core/src/codec.ts:19](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codec.ts#L19) Returns `true` if the two values are equal. #### Parameters ##### a `Value` ##### b `Value` #### Returns `boolean` *** ### hydrate() > **hydrate**(`raw`, `options?`): `Value` \| `undefined` Defined in: [packages/core/src/codec.ts:15](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codec.ts#L15) Turns a raw wire value into a value. It returns `undefined` for `null`, `undefined` or bad input. #### Parameters ##### raw `Raw` \| `null` \| `undefined` ##### options? `Options` #### Returns `Value` \| `undefined` *** ### isValue() > **isValue**(`input`): `input is Value` Defined in: [packages/core/src/codec.ts:21](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codec.ts#L21) Returns `true` if the input is a value of this codec. #### Parameters ##### input `unknown` #### Returns `input is Value` *** ### key()? > `optional` **key**(`value`): `unknown` Defined in: [packages/core/src/codec.ts:26](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codec.ts#L26) Optional. Gives a primitive key for a value. Two values that `equals` says are equal have the same key. `setOf` uses it to find duplicates fast. #### Parameters ##### value `Value` #### Returns `unknown` *** ### parse()? > `optional` **parse**(`raw`, `options?`): `Value` Defined in: [packages/core/src/codec.ts:31](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codec.ts#L31) The strict, quiet read. It throws on bad input, and on `null` or `undefined`, and sends no report to `onInvalid`. Composite codecs and validation use it. `defineCodec` always sets it. #### Parameters ##### raw `Raw` \| `null` \| `undefined` ##### options? `Options` #### Returns `Value` *** ### serialize() > **serialize**(`value`, `options?`): `Raw` \| `null` Defined in: [packages/core/src/codec.ts:17](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codec.ts#L17) Turns a value into a raw wire value. It returns `null` for `null` or `undefined`. #### Parameters ##### value `Value` \| `null` \| `undefined` ##### options? `Options` #### Returns `Raw` \| `null` --- **Millwork** *** Millwork / @millwork-ts/core / CodecSpec # Interface: CodecSpec\ Defined in: [packages/core/src/codec.ts:42](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codec.ts#L42) What `defineCodec` needs. `parse` may throw on bad input; the codec catches it. ## Type Parameters ### Raw `Raw` ### Value `Value` ### Options `Options` ## Properties ### name > **name**: `string` Defined in: [packages/core/src/codec.ts:43](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codec.ts#L43) ## Methods ### equals()? > `optional` **equals**(`a`, `b`): `boolean` Defined in: [packages/core/src/codec.ts:51](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codec.ts#L51) Defaults to `Object.is`. #### Parameters ##### a `Value` ##### b `Value` #### Returns `boolean` *** ### format() > **format**(`value`, `options`): `Raw` Defined in: [packages/core/src/codec.ts:47](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codec.ts#L47) Turns a value into a raw value. #### Parameters ##### value `Value` ##### options `Options` #### Returns `Raw` *** ### isValue() > **isValue**(`input`): `input is Value` Defined in: [packages/core/src/codec.ts:49](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codec.ts#L49) Returns `true` if the input is a value of this codec. #### Parameters ##### input `unknown` #### Returns `input is Value` *** ### key()? > `optional` **key**(`value`): `unknown` Defined in: [packages/core/src/codec.ts:53](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codec.ts#L53) A primitive key that is the same for equal values. See `Codec.key`. #### Parameters ##### value `Value` #### Returns `unknown` *** ### parse() > **parse**(`raw`, `options`): `Value` Defined in: [packages/core/src/codec.ts:45](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codec.ts#L45) Turns a raw value into a value. It can throw on bad input. #### Parameters ##### raw `Raw` ##### options `Options` #### Returns `Value` --- **Millwork** *** Millwork / @millwork-ts/core / DateCodecFamily # Interface: DateCodecFamily\ Defined in: [packages/core/src/dates.ts:277](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L277) The contract that each date adapter package implements: one codec factory for each wire kind. `date`, `datetime` and `epoch` are required. The other kinds are optional, because not every library has them. Build each codec with `defineCodec` and the parsers in this module. ## Type Parameters ### T `T` *extends* `DateTypes` ## Properties ### name > `readonly` **name**: `string` Defined in: [packages/core/src/dates.ts:279](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L279) The adapter name, such as `'temporal'`. ## Methods ### date() > **date**(): `Codec`\<`string`, `T`\[`"date"`\]\> Defined in: [packages/core/src/dates.ts:281](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L281) `"2026-12-01"`. #### Returns `Codec`\<`string`, `T`\[`"date"`\]\> *** ### datetime() > **datetime**(): `Codec`\<`string`, `T`\[`"instant"`\], \{ `keepOffset?`: `boolean`; \} \| `undefined`\> Defined in: [packages/core/src/dates.ts:283](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L283) RFC 3339 with an offset or `Z`. `keepOffset` writes the offset of the value, not `Z`. #### Returns `Codec`\<`string`, `T`\[`"instant"`\], \{ `keepOffset?`: `boolean`; \} \| `undefined`\> *** ### duration()? > `optional` **duration**(): `Codec`\<`string` \| `number`, `T`\[`"duration"`\], \{ `unit?`: `"s"` \| `"ms"` \| `"iso"`; \} \| `undefined`\> Defined in: [packages/core/src/dates.ts:299](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L299) ISO 8601, or a number in the given unit. #### Returns `Codec`\<`string` \| `number`, `T`\[`"duration"`\], \{ `unit?`: `"s"` \| `"ms"` \| `"iso"`; \} \| `undefined`\> *** ### epoch() > **epoch**(): `Codec`\<`string` \| `number`, `T`\[`"instant"`\], \{ `unit?`: `EpochUnit`; \} \| `undefined`\> Defined in: [packages/core/src/dates.ts:285](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L285) An epoch number. The default unit is `'ms'`. #### Returns `Codec`\<`string` \| `number`, `T`\[`"instant"`\], \{ `unit?`: `EpochUnit`; \} \| `undefined`\> *** ### interval()? > `optional` **interval**(): `Codec`\<`string` \| \{ `end`: `string`; `start`: `string`; \}, `T`\[`"interval"`\], `IntervalOptions` \| `undefined`\> Defined in: [packages/core/src/dates.ts:301](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L301) `"a/b"`, `"a/PT1H"` or `{ start, end }`. #### Returns `Codec`\<`string` \| \{ `end`: `string`; `start`: `string`; \}, `T`\[`"interval"`\], `IntervalOptions` \| `undefined`\> *** ### localDateTime()? > `optional` **localDateTime**(): `Codec`\<`string`, `T`\[`"localDateTime"`\]\> Defined in: [packages/core/src/dates.ts:289](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L289) `"2026-12-01T14:30:00"`. #### Returns `Codec`\<`string`, `T`\[`"localDateTime"`\]\> *** ### time()? > `optional` **time**(): `Codec`\<`string`, `T`\[`"time"`\]\> Defined in: [packages/core/src/dates.ts:287](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L287) `"14:30"`, `"14:30:00.000"`. #### Returns `Codec`\<`string`, `T`\[`"time"`\]\> *** ### yearMonth()? > `optional` **yearMonth**(): `Codec`\<`string`, `T`\[`"yearMonth"`\]\> Defined in: [packages/core/src/dates.ts:297](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L297) `"2026-12"`. #### Returns `Codec`\<`string`, `T`\[`"yearMonth"`\]\> *** ### zonedDateTime()? > `optional` **zonedDateTime**(): `Codec`\<`string` \| \{ `at`: `string`; `zone`: `string`; \}, `T`\[`"zonedDateTime"`\], `ZonedOptions` \| `undefined`\> Defined in: [packages/core/src/dates.ts:291](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L291) RFC 9557 `"...[America/Toronto]"`, or `{ at, zone }`. #### Returns `Codec`\<`string` \| \{ `at`: `string`; `zone`: `string`; \}, `T`\[`"zonedDateTime"`\], `ZonedOptions` \| `undefined`\> --- **Millwork** *** Millwork / @millwork-ts/core / DateRecord # Interface: DateRecord Defined in: [packages/core/src/dates.ts:11](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L11) A calendar date. ## Properties ### day > `readonly` **day**: `number` Defined in: [packages/core/src/dates.ts:14](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L14) *** ### month > `readonly` **month**: `number` Defined in: [packages/core/src/dates.ts:13](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L13) *** ### year > `readonly` **year**: `number` Defined in: [packages/core/src/dates.ts:12](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L12) --- **Millwork** *** Millwork / @millwork-ts/core / DateTypes # Interface: DateTypes Defined in: [packages/core/src/dates.ts:248](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L248) The rich date types of one adapter package. An adapter sets `never` for a kind that its library does not have. ## Properties ### date > **date**: `unknown` Defined in: [packages/core/src/dates.ts:249](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L249) *** ### duration > **duration**: `unknown` Defined in: [packages/core/src/dates.ts:255](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L255) *** ### instant > **instant**: `unknown` Defined in: [packages/core/src/dates.ts:252](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L252) *** ### interval > **interval**: `unknown` Defined in: [packages/core/src/dates.ts:256](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L256) *** ### localDateTime > **localDateTime**: `unknown` Defined in: [packages/core/src/dates.ts:251](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L251) *** ### time > **time**: `unknown` Defined in: [packages/core/src/dates.ts:250](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L250) *** ### yearMonth > **yearMonth**: `unknown` Defined in: [packages/core/src/dates.ts:254](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L254) *** ### zonedDateTime > **zonedDateTime**: `unknown` Defined in: [packages/core/src/dates.ts:253](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L253) --- **Millwork** *** Millwork / @millwork-ts/core / DecimalOptions # Interface: DecimalOptions Defined in: [packages/core/src/codecs/decimal.ts:7](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/decimal.ts#L7) Options of the `decimal` codec. ## Properties ### scale? > `optional` **scale?**: `number` Defined in: [packages/core/src/codecs/decimal.ts:9](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/decimal.ts#L9) The number of digits after the point on serialize. It throws a `RangeError` if digits are lost. --- **Millwork** *** Millwork / @millwork-ts/core / DurationRecord # Interface: DurationRecord Defined in: [packages/core/src/dates.ts:61](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L61) An ISO 8601 duration. Each unit is kept apart: months and years are not turned into days or milliseconds. For a negative duration, every field is negative or zero. ## Properties ### days > `readonly` **days**: `number` Defined in: [packages/core/src/dates.ts:66](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L66) *** ### hours > `readonly` **hours**: `number` Defined in: [packages/core/src/dates.ts:67](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L67) *** ### microseconds > `readonly` **microseconds**: `number` Defined in: [packages/core/src/dates.ts:71](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L71) *** ### milliseconds > `readonly` **milliseconds**: `number` Defined in: [packages/core/src/dates.ts:70](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L70) *** ### minutes > `readonly` **minutes**: `number` Defined in: [packages/core/src/dates.ts:68](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L68) *** ### months > `readonly` **months**: `number` Defined in: [packages/core/src/dates.ts:64](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L64) *** ### nanoseconds > `readonly` **nanoseconds**: `number` Defined in: [packages/core/src/dates.ts:72](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L72) *** ### seconds > `readonly` **seconds**: `number` Defined in: [packages/core/src/dates.ts:69](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L69) *** ### sign > `readonly` **sign**: `-1` \| `1` Defined in: [packages/core/src/dates.ts:62](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L62) *** ### weeks > `readonly` **weeks**: `number` Defined in: [packages/core/src/dates.ts:65](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L65) *** ### years > `readonly` **years**: `number` Defined in: [packages/core/src/dates.ts:63](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L63) --- **Millwork** *** Millwork / @millwork-ts/core / EpochRecord # Interface: EpochRecord Defined in: [packages/core/src/dates.ts:52](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L52) An instant from an epoch number. ## Properties ### epochMilliseconds > `readonly` **epochMilliseconds**: `number` Defined in: [packages/core/src/dates.ts:54](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L54) *** ### epochNanoseconds > `readonly` **epochNanoseconds**: `bigint` Defined in: [packages/core/src/dates.ts:53](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L53) --- **Millwork** *** Millwork / @millwork-ts/core / Feature # Interface: Feature Defined in: [packages/core/src/codecs/geojson.ts:24](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/geojson.ts#L24) A GeoJSON feature. ## Properties ### geometry > `readonly` **geometry**: `Geometry` \| `null` Defined in: [packages/core/src/codecs/geojson.ts:26](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/geojson.ts#L26) *** ### id? > `readonly` `optional` **id?**: `string` \| `number` Defined in: [packages/core/src/codecs/geojson.ts:28](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/geojson.ts#L28) *** ### properties > `readonly` **properties**: `Readonly`\<`Record`\<`string`, `unknown`\>\> \| `null` Defined in: [packages/core/src/codecs/geojson.ts:27](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/geojson.ts#L27) *** ### type > `readonly` **type**: `"Feature"` Defined in: [packages/core/src/codecs/geojson.ts:25](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/geojson.ts#L25) --- **Millwork** *** Millwork / @millwork-ts/core / FeatureCollection # Interface: FeatureCollection Defined in: [packages/core/src/codecs/geojson.ts:32](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/geojson.ts#L32) A GeoJSON feature collection. ## Properties ### features > `readonly` **features**: readonly `Feature`[] Defined in: [packages/core/src/codecs/geojson.ts:34](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/geojson.ts#L34) *** ### type > `readonly` **type**: `"FeatureCollection"` Defined in: [packages/core/src/codecs/geojson.ts:33](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/geojson.ts#L33) --- **Millwork** *** Millwork / @millwork-ts/core / FieldDecorator # Interface: FieldDecorator() Defined in: [packages/core/src/shapes/shape.ts:144](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L144) A field decorator, for standard (`accessor`) and legacy (Ember, `declare`) decorators. ## Call Signature > **FieldDecorator**\<`This`, `V`\>(`target`, `context`): `ClassAccessorDecoratorResult`\<`This`, `V`\> Defined in: [packages/core/src/shapes/shape.ts:145](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L145) A field decorator, for standard (`accessor`) and legacy (Ember, `declare`) decorators. ### Type Parameters #### This `This` #### V `V` ### Parameters #### target `ClassAccessorDecoratorTarget`\<`This`, `V`\> #### context `ClassAccessorDecoratorContext`\<`This`, `V`\> ### Returns `ClassAccessorDecoratorResult`\<`This`, `V`\> ## Call Signature > **FieldDecorator**(`prototype`, `key`): `void` Defined in: [packages/core/src/shapes/shape.ts:151](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L151) A field decorator, for standard (`accessor`) and legacy (Ember, `declare`) decorators. ### Parameters #### prototype `object` #### key `string` ### Returns `void` --- **Millwork** *** Millwork / @millwork-ts/core / FieldDefinition # Interface: FieldDefinition Defined in: [packages/core/src/shapes/shape.ts:50](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L50) One field, as the definition keeps it. ## Extends - `FieldInput` ## Properties ### array? > `readonly` `optional` **array?**: `boolean` Defined in: [packages/core/src/shapes/shape.ts:42](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L42) A list of shapes. #### Inherited from `FieldInput`.`array` *** ### codec? > `readonly` `optional` **codec?**: `string` \| `AnyCodec` Defined in: [packages/core/src/shapes/shape.ts:34](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L34) A codec, or the registered name of a codec. #### Inherited from `FieldInput`.`codec` *** ### discriminator? > `readonly` `optional` **discriminator?**: `string` Defined in: [packages/core/src/shapes/shape.ts:40](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L40) The discriminator key of a polymorphic field. The default is `$type`. #### Inherited from `FieldInput`.`discriminator` *** ### key? > `readonly` `optional` **key?**: `string` Defined in: [packages/core/src/shapes/shape.ts:44](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L44) The field that gives each member of a shape array its identity. #### Inherited from `FieldInput`.`key` *** ### name > `readonly` **name**: `string` Defined in: [packages/core/src/shapes/shape.ts:32](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L32) #### Inherited from `FieldInput`.`name` *** ### optional > `readonly` **optional**: `boolean` Defined in: [packages/core/src/shapes/shape.ts:51](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L51) A field that can be missing. The default is `false`. #### Overrides `FieldInput`.`optional` *** ### options? > `readonly` `optional` **options?**: `unknown` Defined in: [packages/core/src/shapes/shape.ts:36](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L36) The codec options. #### Inherited from `FieldInput`.`options` *** ### shape? > `readonly` `optional` **shape?**: `ShapeRef` \| `Readonly`\<`Record`\<`string`, `ShapeRef`\>\> Defined in: [packages/core/src/shapes/shape.ts:38](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L38) A nested shape or value class, or a polymorphic map. #### Inherited from `FieldInput`.`shape` --- **Millwork** *** Millwork / @millwork-ts/core / FieldInput # Interface: FieldInput Defined in: [packages/core/src/shapes/shape.ts:31](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L31) One field of the JSON form. The class form makes the same object. ## Extended by - `FieldDefinition` ## Properties ### array? > `readonly` `optional` **array?**: `boolean` Defined in: [packages/core/src/shapes/shape.ts:42](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L42) A list of shapes. *** ### codec? > `readonly` `optional` **codec?**: `string` \| `AnyCodec` Defined in: [packages/core/src/shapes/shape.ts:34](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L34) A codec, or the registered name of a codec. *** ### discriminator? > `readonly` `optional` **discriminator?**: `string` Defined in: [packages/core/src/shapes/shape.ts:40](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L40) The discriminator key of a polymorphic field. The default is `$type`. *** ### key? > `readonly` `optional` **key?**: `string` Defined in: [packages/core/src/shapes/shape.ts:44](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L44) The field that gives each member of a shape array its identity. *** ### name > `readonly` **name**: `string` Defined in: [packages/core/src/shapes/shape.ts:32](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L32) *** ### optional? > `readonly` `optional` **optional?**: `boolean` Defined in: [packages/core/src/shapes/shape.ts:46](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L46) A field that can be missing. The default is `false`. *** ### options? > `readonly` `optional` **options?**: `unknown` Defined in: [packages/core/src/shapes/shape.ts:36](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L36) The codec options. *** ### shape? > `readonly` `optional` **shape?**: `ShapeRef` \| `Readonly`\<`Record`\<`string`, `ShapeRef`\>\> Defined in: [packages/core/src/shapes/shape.ts:38](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L38) A nested shape or value class, or a polymorphic map. --- **Millwork** *** Millwork / @millwork-ts/core / FieldOptions # Interface: FieldOptions Defined in: [packages/core/src/shapes/shape.ts:135](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L135) The options of `@field(...)`: the codec options, or the shape options. ## Indexable > \[`option`: `string`\]: `unknown` ## Properties ### array? > `optional` **array?**: `boolean` Defined in: [packages/core/src/shapes/shape.ts:137](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L137) *** ### discriminator? > `optional` **discriminator?**: `string` Defined in: [packages/core/src/shapes/shape.ts:139](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L139) *** ### key? > `optional` **key?**: `string` Defined in: [packages/core/src/shapes/shape.ts:138](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L138) *** ### optional? > `optional` **optional?**: `boolean` Defined in: [packages/core/src/shapes/shape.ts:136](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L136) --- **Millwork** *** Millwork / @millwork-ts/core / IntervalOptions # Interface: IntervalOptions Defined in: [packages/core/src/dates.ts:266](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L266) Options of an `interval` codec. ## Properties ### wire? > `optional` **wire?**: `"object"` \| `"iso"` Defined in: [packages/core/src/dates.ts:268](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L268) The form that `serialize` writes. The default is `'iso'` (`"a/b"`). Both forms are read. --- **Millwork** *** Millwork / @millwork-ts/core / IntervalParts # Interface: IntervalParts Defined in: [packages/core/src/dates.ts:76](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L76) The parts of an ISO 8601 interval. An absent part is open (`..` or empty). ## Properties ### duration? > `readonly` `optional` **duration?**: `string` Defined in: [packages/core/src/dates.ts:79](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L79) *** ### end? > `readonly` `optional` **end?**: `string` Defined in: [packages/core/src/dates.ts:78](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L78) *** ### start? > `readonly` `optional` **start?**: `string` Defined in: [packages/core/src/dates.ts:77](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L77) --- **Millwork** *** Millwork / @millwork-ts/core / IntervalWire # Interface: IntervalWire\ Defined in: [packages/core/src/date-writers.ts:128](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/date-writers.ts#L128) The ends of a closed interval on the wire. One of them can be a duration. ## Type Parameters ### I `I` ## Properties ### end > **end**: `I` Defined in: [packages/core/src/date-writers.ts:130](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/date-writers.ts#L130) *** ### start > **start**: `I` Defined in: [packages/core/src/date-writers.ts:129](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/date-writers.ts#L129) --- **Millwork** *** Millwork / @millwork-ts/core / InvalidReport # Interface: InvalidReport Defined in: [packages/core/src/codec.ts:57](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codec.ts#L57) The report for one raw value that a codec could not hydrate. ## Properties ### codec > **codec**: `string` Defined in: [packages/core/src/codec.ts:58](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codec.ts#L58) *** ### error > **error**: `unknown` Defined in: [packages/core/src/codec.ts:60](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codec.ts#L60) *** ### raw > **raw**: `unknown` Defined in: [packages/core/src/codec.ts:59](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codec.ts#L59) --- **Millwork** *** Millwork / @millwork-ts/core / Issue # Interface: Issue Defined in: [packages/core/src/shapes/shape.ts:1126](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L1126) One validation issue, in the Standard Schema form. ## Properties ### message > `readonly` **message**: `string` Defined in: [packages/core/src/shapes/shape.ts:1127](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L1127) *** ### path > `readonly` **path**: readonly (`string` \| `number`)[] Defined in: [packages/core/src/shapes/shape.ts:1128](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L1128) --- **Millwork** *** Millwork / @millwork-ts/core / LatLng # Interface: LatLng Defined in: [packages/core/src/codecs/latlng.ts:7](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/latlng.ts#L7) A point on the earth in degrees. The value is a frozen plain object. ## Properties ### lat > `readonly` **lat**: `number` Defined in: [packages/core/src/codecs/latlng.ts:8](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/latlng.ts#L8) *** ### lng > `readonly` **lng**: `number` Defined in: [packages/core/src/codecs/latlng.ts:9](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/latlng.ts#L9) --- **Millwork** *** Millwork / @millwork-ts/core / LatLngOptions # Interface: LatLngOptions Defined in: [packages/core/src/codecs/latlng.ts:13](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/latlng.ts#L13) Options of the `latlng` codec. ## Properties ### order? > `optional` **order?**: `"latlng"` \| `"lnglat"` Defined in: [packages/core/src/codecs/latlng.ts:15](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/latlng.ts#L15) The order in a tuple or a string. The default is `'latlng'`. GeoJSON uses `'lnglat'`. *** ### wire? > `optional` **wire?**: `"string"` \| `"object"` \| `"long-object"` \| `"tuple"` Defined in: [packages/core/src/codecs/latlng.ts:20](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/latlng.ts#L20) The wire form on serialize. The default is `'object'` (`{ lat, lng }`). `'long-object'` is `{ latitude, longitude }`. All forms are read, whatever this option is. --- **Millwork** *** Millwork / @millwork-ts/core / MapOptions # Interface: MapOptions\ Defined in: [packages/core/src/codecs/collections.ts:46](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/collections.ts#L46) Options of a `mapOf` codec. ## Type Parameters ### O `O` ## Properties ### of? > `optional` **of?**: `O` Defined in: [packages/core/src/codecs/collections.ts:50](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/collections.ts#L50) Options for the inner codec. *** ### wire? > `optional` **wire?**: `"object"` \| `"entries"` Defined in: [packages/core/src/codecs/collections.ts:48](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/collections.ts#L48) The wire form on serialize. The default is `'object'`. Both forms are read. --- **Millwork** *** Millwork / @millwork-ts/core / MimeType # Interface: MimeType Defined in: [packages/core/src/codecs/mime-type.ts:7](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/mime-type.ts#L7) A media type. Type, subtype and parameter names are lower case. The value is a frozen plain object. ## Properties ### parameters > `readonly` **parameters**: `Readonly`\<`Record`\<`string`, `string`\>\> Defined in: [packages/core/src/codecs/mime-type.ts:10](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/mime-type.ts#L10) *** ### subtype > `readonly` **subtype**: `string` Defined in: [packages/core/src/codecs/mime-type.ts:9](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/mime-type.ts#L9) *** ### type > `readonly` **type**: `string` Defined in: [packages/core/src/codecs/mime-type.ts:8](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/mime-type.ts#L8) --- **Millwork** *** Millwork / @millwork-ts/core / MoneyOptions # Interface: MoneyOptions Defined in: [packages/core/src/codecs/money.ts:18](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/money.ts#L18) Options of the `money` codec. ## Properties ### currency? > `optional` **currency?**: `string` Defined in: [packages/core/src/codecs/money.ts:22](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/money.ts#L22) The currency for the `'amount'` wire, which has a bare amount in minor units. *** ### wire? > `optional` **wire?**: `MoneyWire` Defined in: [packages/core/src/codecs/money.ts:20](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/money.ts#L20) The wire form. The default is `'minor'`: `{ amount: 1999, currency: 'USD' }`. --- **Millwork** *** Millwork / @millwork-ts/core / NamedClass # Interface: NamedClass Defined in: [packages/core/src/shapes/registry.ts:10](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/registry.ts#L10) A class that a registry name can point to: a shape or a value class. ## Extended by - `StructuredClass` ## Properties ### kind > `readonly` **kind**: `"value"` \| `"shape"` Defined in: [packages/core/src/shapes/registry.ts:12](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/registry.ts#L12) *** ### type > `readonly` **type**: `string` Defined in: [packages/core/src/shapes/registry.ts:11](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/registry.ts#L11) --- **Millwork** *** Millwork / @millwork-ts/core / OffsetDateTimeRecord # Interface: OffsetDateTimeRecord Defined in: [packages/core/src/dates.ts:35](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L35) An RFC 3339 date-time. `offset` is `'Z'` or `'+hh:mm'`. ## Extends - `LocalDateTimeRecord` ## Extended by - `ZonedDateTimeRecord` ## Properties ### day > `readonly` **day**: `number` Defined in: [packages/core/src/dates.ts:14](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L14) #### Inherited from `LocalDateTimeRecord.day` *** ### epochMilliseconds > `readonly` **epochMilliseconds**: `number` Defined in: [packages/core/src/dates.ts:39](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L39) The instant in milliseconds since the Unix epoch. Sub-millisecond digits are dropped. *** ### hour > `readonly` **hour**: `number` Defined in: [packages/core/src/dates.ts:25](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L25) #### Inherited from `LocalDateTimeRecord.hour` *** ### minute > `readonly` **minute**: `number` Defined in: [packages/core/src/dates.ts:26](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L26) #### Inherited from `LocalDateTimeRecord.minute` *** ### month > `readonly` **month**: `number` Defined in: [packages/core/src/dates.ts:13](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L13) #### Inherited from `LocalDateTimeRecord.month` *** ### nanosecond > `readonly` **nanosecond**: `number` Defined in: [packages/core/src/dates.ts:28](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L28) #### Inherited from `LocalDateTimeRecord.nanosecond` *** ### offset > `readonly` **offset**: `string` Defined in: [packages/core/src/dates.ts:36](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L36) *** ### offsetMinutes > `readonly` **offsetMinutes**: `number` Defined in: [packages/core/src/dates.ts:37](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L37) *** ### second > `readonly` **second**: `number` Defined in: [packages/core/src/dates.ts:27](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L27) #### Inherited from `LocalDateTimeRecord.second` *** ### year > `readonly` **year**: `number` Defined in: [packages/core/src/dates.ts:12](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L12) #### Inherited from `LocalDateTimeRecord.year` --- **Millwork** *** Millwork / @millwork-ts/core / PercentOptions # Interface: PercentOptions Defined in: [packages/core/src/codecs/percent.ts:8](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/percent.ts#L8) Options of the `percent` codec. ## Properties ### as? > `optional` **as?**: `"string"` \| `"number"` Defined in: [packages/core/src/codecs/percent.ts:12](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/percent.ts#L12) The raw type on serialize. The default is `'number'`. *** ### unit? > `optional` **unit?**: `PercentUnit` Defined in: [packages/core/src/codecs/percent.ts:10](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/percent.ts#L10) The wire unit. The default is `'fraction'`. --- **Millwork** *** Millwork / @millwork-ts/core / Range # Interface: Range\ Defined in: [packages/core/src/codecs/range.ts:10](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/range.ts#L10) A range of values. `null` is an unbounded side. The value is a frozen plain object. ## Type Parameters ### V `V` ## Properties ### bounds > `readonly` **bounds**: `Bounds` Defined in: [packages/core/src/codecs/range.ts:13](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/range.ts#L13) *** ### empty > `readonly` **empty**: `boolean` Defined in: [packages/core/src/codecs/range.ts:14](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/range.ts#L14) *** ### end > `readonly` **end**: `V` \| `null` Defined in: [packages/core/src/codecs/range.ts:12](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/range.ts#L12) *** ### start > `readonly` **start**: `V` \| `null` Defined in: [packages/core/src/codecs/range.ts:11](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/range.ts#L11) --- **Millwork** *** Millwork / @millwork-ts/core / RangeOptions # Interface: RangeOptions\ Defined in: [packages/core/src/codecs/range.ts:18](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/range.ts#L18) Options of a `rangeOf` codec. ## Type Parameters ### O `O` ## Properties ### bounds? > `optional` **bounds?**: `Bounds` Defined in: [packages/core/src/codecs/range.ts:26](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/range.ts#L26) The bounds of the forms that have no bounds of their own. The default is `'[)'`. *** ### of? > `optional` **of?**: `O` Defined in: [packages/core/src/codecs/range.ts:28](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/range.ts#L28) Options for the inner codec. *** ### wire? > `optional` **wire?**: `"object"` \| `"iso"` \| `"tuple"` \| `"postgres"` Defined in: [packages/core/src/codecs/range.ts:24](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/range.ts#L24) The wire form on serialize. The default is `'object'` (`{ start, end }`). The others are `'tuple'` (`[a, b]`), `'iso'` (`"a/b"`, `..` is unbounded) and `'postgres'` (`"[a,b)"`). All forms are read, whatever this option is. --- **Millwork** *** Millwork / @millwork-ts/core / Ratio # Interface: Ratio Defined in: [packages/core/src/codecs/ratio.ts:7](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/ratio.ts#L7) A ratio such as 16:9. The value is a frozen plain object. ## Properties ### den > `readonly` **den**: `number` Defined in: [packages/core/src/codecs/ratio.ts:9](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/ratio.ts#L9) *** ### num > `readonly` **num**: `number` Defined in: [packages/core/src/codecs/ratio.ts:8](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/ratio.ts#L8) --- **Millwork** *** Millwork / @millwork-ts/core / RatioOptions # Interface: RatioOptions Defined in: [packages/core/src/codecs/ratio.ts:13](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/ratio.ts#L13) Options of the `ratio` codec. ## Properties ### wire? > `optional` **wire?**: `"string"` \| `"object"` Defined in: [packages/core/src/codecs/ratio.ts:15](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/ratio.ts#L15) The wire form on serialize. The default is `'string'`: `"16:9"`. --- **Millwork** *** Millwork / @millwork-ts/core / RegisterShapesOptions # Interface: RegisterShapesOptions Defined in: [packages/core/src/shapes/registry.ts:43](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/registry.ts#L43) Options of `registerShapes`. ## Properties ### replace? > `optional` **replace?**: `boolean` Defined in: [packages/core/src/shapes/registry.ts:45](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/registry.ts#L45) Replace a different class that has the same `type`, such as after a hot reload. --- **Millwork** *** Millwork / @millwork-ts/core / ShapeDefinition # Interface: ShapeDefinition Defined in: [packages/core/src/shapes/shape.ts:55](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L55) The internal definition. The class form and the JSON form make the same one. ## Properties ### fields > `readonly` **fields**: readonly `FieldDefinition`[] Defined in: [packages/core/src/shapes/shape.ts:58](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L58) *** ### kind > `readonly` **kind**: `"value"` \| `"shape"` Defined in: [packages/core/src/shapes/shape.ts:56](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L56) *** ### type > `readonly` **type**: `string` Defined in: [packages/core/src/shapes/shape.ts:57](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L57) --- **Millwork** *** Millwork / @millwork-ts/core / StructureInput # Interface: StructureInput Defined in: [packages/core/src/shapes/shape.ts:1083](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L1083) The JSON form of a shape or value class. ## Properties ### fields > `readonly` **fields**: readonly `FieldInput`[] Defined in: [packages/core/src/shapes/shape.ts:1085](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L1085) *** ### type > `readonly` **type**: `string` Defined in: [packages/core/src/shapes/shape.ts:1084](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L1084) --- **Millwork** *** Millwork / @millwork-ts/core / StructuredClass # Interface: StructuredClass\ Defined in: [packages/core/src/shapes/shape.ts:62](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L62) A `Shape` or `Value` subclass. ## Extends - `NamedClass` ## Type Parameters ### T `T` *extends* `Structured` = `Structured` ## Constructors ### Constructor > **new StructuredClass**(`values?`): `T` Defined in: [packages/core/src/shapes/shape.ts:63](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L63) #### Parameters ##### values? `object` #### Returns `T` #### Inherited from `NamedClass.constructor` ## Properties ### kind > `readonly` **kind**: `"value"` \| `"shape"` Defined in: [packages/core/src/shapes/registry.ts:12](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/registry.ts#L12) #### Inherited from `NamedClass`.`kind` *** ### prototype > `readonly` **prototype**: `T` Defined in: [packages/core/src/shapes/shape.ts:64](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L64) *** ### type > `readonly` **type**: `string` Defined in: [packages/core/src/shapes/registry.ts:11](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/registry.ts#L11) #### Inherited from `NamedClass`.`type` --- **Millwork** *** Millwork / @millwork-ts/core / TimeRecord # Interface: TimeRecord Defined in: [packages/core/src/dates.ts:24](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L24) A wall-clock time. `nanosecond` holds the fraction of the second. ## Properties ### hour > `readonly` **hour**: `number` Defined in: [packages/core/src/dates.ts:25](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L25) *** ### minute > `readonly` **minute**: `number` Defined in: [packages/core/src/dates.ts:26](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L26) *** ### nanosecond > `readonly` **nanosecond**: `number` Defined in: [packages/core/src/dates.ts:28](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L28) *** ### second > `readonly` **second**: `number` Defined in: [packages/core/src/dates.ts:27](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L27) --- **Millwork** *** Millwork / @millwork-ts/core / Tracked # Interface: Tracked Defined in: [packages/core/src/shapes/shape.ts:856](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L856) Per-path change tracking. Shapes and shape arrays have it. Formwright binds to it. ## Properties ### isDirty > `readonly` **isDirty**: `boolean` Defined in: [packages/core/src/shapes/shape.ts:858](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L858) `true` when the local raw value is not equal to the remote raw value. ## Methods ### changes() > **changes**(): `Change`[] Defined in: [packages/core/src/shapes/shape.ts:860](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L860) Each change from the remote value, with its path. #### Returns `Change`[] *** ### rollback() > **rollback**(`path?`): `void` Defined in: [packages/core/src/shapes/shape.ts:862](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L862) Rolls back one path, or everything when there is no path. #### Parameters ##### path? readonly `string`[] #### Returns `void` --- **Millwork** *** Millwork / @millwork-ts/core / UrlOptions # Interface: UrlOptions Defined in: [packages/core/src/codecs/url.ts:49](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/url.ts#L49) Options of the `url` codec. ## Properties ### base? > `optional` **base?**: `string` Defined in: [packages/core/src/codecs/url.ts:51](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/url.ts#L51) The base for a relative raw URL. The codec checks the protocol after it resolves the URL. *** ### protocols? > `optional` **protocols?**: readonly `string`[] \| `"*"` Defined in: [packages/core/src/codecs/url.ts:56](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/url.ts#L56) The protocols that hydrate accepts, with the colon: `['https:']`. A URL with another protocol is bad input. `'*'` accepts all protocols. The default is `DEFAULT_URL_PROTOCOLS`. --- **Millwork** *** Millwork / @millwork-ts/core / YearMonthRecord # Interface: YearMonthRecord Defined in: [packages/core/src/dates.ts:18](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L18) A year and a month. ## Properties ### month > `readonly` **month**: `number` Defined in: [packages/core/src/dates.ts:20](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L20) *** ### year > `readonly` **year**: `number` Defined in: [packages/core/src/dates.ts:19](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L19) --- **Millwork** *** Millwork / @millwork-ts/core / ZonedDateTimeRecord # Interface: ZonedDateTimeRecord Defined in: [packages/core/src/dates.ts:43](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L43) An RFC 9557 date-time: an RFC 3339 date-time plus a time zone and other annotations. ## Extends - `OffsetDateTimeRecord` ## Properties ### annotations > `readonly` **annotations**: `Readonly`\<`Record`\<`string`, `string`\>\> Defined in: [packages/core/src/dates.ts:45](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L45) *** ### day > `readonly` **day**: `number` Defined in: [packages/core/src/dates.ts:14](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L14) #### Inherited from `OffsetDateTimeRecord`.`day` *** ### epochMilliseconds > `readonly` **epochMilliseconds**: `number` Defined in: [packages/core/src/dates.ts:39](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L39) The instant in milliseconds since the Unix epoch. Sub-millisecond digits are dropped. #### Inherited from `OffsetDateTimeRecord`.`epochMilliseconds` *** ### hour > `readonly` **hour**: `number` Defined in: [packages/core/src/dates.ts:25](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L25) #### Inherited from `OffsetDateTimeRecord`.`hour` *** ### minute > `readonly` **minute**: `number` Defined in: [packages/core/src/dates.ts:26](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L26) #### Inherited from `OffsetDateTimeRecord`.`minute` *** ### month > `readonly` **month**: `number` Defined in: [packages/core/src/dates.ts:13](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L13) #### Inherited from `OffsetDateTimeRecord`.`month` *** ### nanosecond > `readonly` **nanosecond**: `number` Defined in: [packages/core/src/dates.ts:28](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L28) #### Inherited from `OffsetDateTimeRecord`.`nanosecond` *** ### offset > `readonly` **offset**: `string` Defined in: [packages/core/src/dates.ts:36](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L36) #### Inherited from `OffsetDateTimeRecord`.`offset` *** ### offsetMinutes > `readonly` **offsetMinutes**: `number` Defined in: [packages/core/src/dates.ts:37](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L37) #### Inherited from `OffsetDateTimeRecord`.`offsetMinutes` *** ### second > `readonly` **second**: `number` Defined in: [packages/core/src/dates.ts:27](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L27) #### Inherited from `OffsetDateTimeRecord`.`second` *** ### timeZone > `readonly` **timeZone**: `string` Defined in: [packages/core/src/dates.ts:44](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L44) *** ### year > `readonly` **year**: `number` Defined in: [packages/core/src/dates.ts:12](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L12) #### Inherited from `OffsetDateTimeRecord`.`year` --- **Millwork** *** Millwork / @millwork-ts/core / ZonedOptions # Interface: ZonedOptions Defined in: [packages/core/src/dates.ts:260](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L260) Options of a `zonedDateTime` codec. ## Properties ### wire? > `optional` **wire?**: `"object"` \| `"rfc9557"` Defined in: [packages/core/src/dates.ts:262](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L262) The form that `serialize` writes. The default is `'rfc9557'`. Both forms are read. --- **Millwork** *** Millwork / @millwork-ts/core / AnyCodec # Type Alias: AnyCodec > **AnyCodec** = `Codec`\<`unknown`, `unknown`, `unknown`\> Defined in: [packages/core/src/shapes/registry.ts:7](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/registry.ts#L7) A codec of any raw, value and options type. The `Codec` methods are bivariant, so each codec fits. --- **Millwork** *** Millwork / @millwork-ts/core / Bounds # Type Alias: Bounds > **Bounds** = `"[)"` \| `"[]"` \| `"(]"` \| `"()"` Defined in: [packages/core/src/codecs/range.ts:7](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/range.ts#L7) The bounds of a range: `[` and `]` include the end point; `(` and `)` do not. --- **Millwork** *** Millwork / @millwork-ts/core / DurationFields # Type Alias: DurationFields > **DurationFields** = `Partial`\<`Omit`\<`DurationRecord`, `"sign"`\>\> Defined in: [packages/core/src/date-writers.ts:7](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/date-writers.ts#L7) The duration units that a wire duration can hold. Absent units are zero. --- **Millwork** *** Millwork / @millwork-ts/core / EpochUnit # Type Alias: EpochUnit > **EpochUnit** = `"s"` \| `"ms"` \| `"us"` \| `"ns"` Defined in: [packages/core/src/dates.ts:49](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L49) The unit of an epoch number. --- **Millwork** *** Millwork / @millwork-ts/core / FieldRef # Type Alias: FieldRef > **FieldRef** = `string` \| `AnyCodec` \| `ShapeRef` \| `PolymorphicMap` Defined in: [packages/core/src/shapes/shape.ts:132](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L132) What `@field(...)` takes first: a codec or its name, or a class, or a polymorphic map. --- **Millwork** *** Millwork / @millwork-ts/core / GeoJson # Type Alias: GeoJson > **GeoJson** = `Geometry` \| `Feature` \| `FeatureCollection` Defined in: [packages/core/src/codecs/geojson.ts:38](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/geojson.ts#L38) Any GeoJSON object. --- **Millwork** *** Millwork / @millwork-ts/core / Geometry # Type Alias: Geometry > **Geometry** = \{ `coordinates`: `Position`; `type`: `"Point"`; \} \| \{ `coordinates`: readonly `Position`[]; `type`: `"MultiPoint"` \| `"LineString"`; \} \| \{ `coordinates`: readonly (readonly `Position`[])[]; `type`: `"MultiLineString"` \| `"Polygon"`; \} \| \{ `coordinates`: readonly (readonly (readonly `Position`[])[])[]; `type`: `"MultiPolygon"`; \} \| \{ `geometries`: readonly `Geometry`[]; `type`: `"GeometryCollection"`; \} Defined in: [packages/core/src/codecs/geojson.ts:10](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/geojson.ts#L10) A GeoJSON geometry (RFC 7946). --- **Millwork** *** Millwork / @millwork-ts/core / InvalidHandler # Type Alias: InvalidHandler > **InvalidHandler** = (`report`) => `void` Defined in: [packages/core/src/codec.ts:64](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codec.ts#L64) A function that gets the report for a raw value that a codec could not hydrate. ## Parameters ### report `InvalidReport` ## Returns `void` --- **Millwork** *** Millwork / @millwork-ts/core / LatLngRaw # Type Alias: LatLngRaw > **LatLngRaw** = \{ `lat`: `number`; `lng`: `number`; \} \| \{ `latitude`: `number`; `longitude`: `number`; \} \| \[`number`, `number`\] \| `string` Defined in: [packages/core/src/codecs/latlng.ts:24](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/latlng.ts#L24) The raw forms of the `latlng` codec. --- **Millwork** *** Millwork / @millwork-ts/core / LocalDateTimeRecord # Type Alias: LocalDateTimeRecord > **LocalDateTimeRecord** = `DateRecord` & `TimeRecord` Defined in: [packages/core/src/dates.ts:32](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/dates.ts#L32) A date and a wall-clock time with no offset or zone. --- **Millwork** *** Millwork / @millwork-ts/core / MapRaw # Type Alias: MapRaw\ > **MapRaw**\<`R`\> = `Record`\<`string`, `R`\> \| \[`string`, `R`\][] Defined in: [packages/core/src/codecs/collections.ts:54](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/collections.ts#L54) The raw forms of a `mapOf` codec. ## Type Parameters ### R `R` --- **Millwork** *** Millwork / @millwork-ts/core / MoneyRaw # Type Alias: MoneyRaw > **MoneyRaw** = \{ `amount`: `number` \| `string`; `currency`: `string`; `scale?`: `number`; \} \| \{ `amount`: `number` \| `string`; `currency`: \{ `base`: `number`; `code`: `string`; `exponent`: `number`; \}; `scale`: `number`; \} \| `number` \| `string` Defined in: [packages/core/src/codecs/money.ts:26](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/money.ts#L26) The raw forms of the `money` codec. --- **Millwork** *** Millwork / @millwork-ts/core / MoneyWire # Type Alias: MoneyWire > **MoneyWire** = `"minor"` \| `"decimal"` \| `"snapshot"` \| `"minor-scaled"` \| `"amount"` Defined in: [packages/core/src/codecs/money.ts:15](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/money.ts#L15) The wire forms of the `money` codec. --- **Millwork** *** Millwork / @millwork-ts/core / OptionsOf # Type Alias: OptionsOf\ > **OptionsOf**\<`C`\> = `C` *extends* `Codec`\<`unknown`, `unknown`, infer Options\> ? `Options` : `never` Defined in: [packages/core/src/codec.ts:39](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codec.ts#L39) The options type of a codec. ## Type Parameters ### C `C` --- **Millwork** *** Millwork / @millwork-ts/core / PercentUnit # Type Alias: PercentUnit > **PercentUnit** = `"fraction"` \| `"percent"` \| `"bps"` Defined in: [packages/core/src/codecs/percent.ts:5](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/percent.ts#L5) The unit of a percent on the wire: `0.075`, `7.5` or `750`. --- **Millwork** *** Millwork / @millwork-ts/core / PolymorphicMap # Type Alias: PolymorphicMap > **PolymorphicMap** = `Readonly`\<`Record`\<`string`, `ShapeRef`\>\> Defined in: [packages/core/src/shapes/shape.ts:28](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L28) Polymorphic: each discriminator value names a class. --- **Millwork** *** Millwork / @millwork-ts/core / Position # Type Alias: Position > **Position** = readonly `number`[] Defined in: [packages/core/src/codecs/geojson.ts:7](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/geojson.ts#L7) A GeoJSON position: `[lng, lat]` or `[lng, lat, alt]`. --- **Millwork** *** Millwork / @millwork-ts/core / RangeRaw # Type Alias: RangeRaw\ > **RangeRaw**\<`R`\> = \{ `end`: `R` \| `null`; `start`: `R` \| `null`; \} \| \[`R` \| `null`, `R` \| `null`\] \| `string` Defined in: [packages/core/src/codecs/range.ts:32](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/range.ts#L32) The raw forms of a `rangeOf` codec. ## Type Parameters ### R `R` --- **Millwork** *** Millwork / @millwork-ts/core / RawObject # Type Alias: RawObject > **RawObject** = `Record`\<`string`, `unknown`\> Defined in: [packages/core/src/shapes/shape.ts:310](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L310) The raw wire form of a shape or a value: a plain object with string keys. --- **Millwork** *** Millwork / @millwork-ts/core / RawOf # Type Alias: RawOf\ > **RawOf**\<`C`\> = `C` *extends* `Codec`\ ? `Raw` : `never` Defined in: [packages/core/src/codec.ts:35](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codec.ts#L35) The raw type of a codec. ## Type Parameters ### C `C` --- **Millwork** *** Millwork / @millwork-ts/core / ShapeRef # Type Alias: ShapeRef > **ShapeRef** = `StructuredClass` \| `string` Defined in: [packages/core/src/shapes/shape.ts:26](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L26) A shape or value class, or its registered `type` name. --- **Millwork** *** Millwork / @millwork-ts/core / Structured # Type Alias: Structured > **Structured** = `Shape` \| `Value` Defined in: [packages/core/src/shapes/shape.ts:68](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/shapes/shape.ts#L68) A `Shape` or a `Value` instance. --- **Millwork** *** Millwork / @millwork-ts/core / ValueOf # Type Alias: ValueOf\ > **ValueOf**\<`C`\> = `C` *extends* `Codec`\<`unknown`, infer Value, `unknown`\> ? `Value` : `never` Defined in: [packages/core/src/codec.ts:37](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codec.ts#L37) The value type of a codec. ## Type Parameters ### C `C` --- **Millwork** *** Millwork / @millwork-ts/core / DEFAULT\_URL\_PROTOCOLS # Variable: DEFAULT\_URL\_PROTOCOLS > `const` **DEFAULT\_URL\_PROTOCOLS**: readonly `string`[] Defined in: [packages/core/src/codecs/url.ts:63](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/url.ts#L63) The protocols that the `url` codec accepts by default: `http:`, `https:`, `mailto:` and `tel:`. `javascript:` and `data:` URLs are not safe to put in a link, so they are bad input. --- **Millwork** *** Millwork / @millwork-ts/core / DISCORD\_EPOCH # Variable: DISCORD\_EPOCH > `const` **DISCORD\_EPOCH**: `1420070400000n` = `1420070400000n` Defined in: [packages/core/src/codecs/snowflake.ts:9](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/snowflake.ts#L9) The Discord snowflake epoch, in milliseconds. --- **Millwork** *** Millwork / @millwork-ts/core / TWITTER\_EPOCH # Variable: TWITTER\_EPOCH > `const` **TWITTER\_EPOCH**: `1288834974657n` = `1288834974657n` Defined in: [packages/core/src/codecs/snowflake.ts:7](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/snowflake.ts#L7) The Twitter (X) snowflake epoch, in milliseconds. --- **Millwork** *** Millwork / @millwork-ts/core / bigint # Variable: bigint > `const` **bigint**: `Codec`\<`string` \| `number`, `bigint`, `undefined`\> Defined in: [packages/core/src/codecs/bigint.ts:10](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/bigint.ts#L10) The `bigint` codec: a string of digits to a `bigint`, and back to a string. A number raw is accepted when it is a safe integer. The raw is a string because JSON has no `bigint`. --- **Millwork** *** Millwork / @millwork-ts/core / bitflags # Variable: bitflags > `const` **bitflags**: `Codec`\<`number`, `ReadonlySet`\<`string`\>, `BitflagsOptions` \| `undefined`\> Defined in: [packages/core/src/codecs/bitflags.ts:13](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/bitflags.ts#L13) The `bitflags` codec: an integer to a `ReadonlySet` of flag names. An unknown bit is bad input. --- **Millwork** *** Millwork / @millwork-ts/core / booleanIsh # Variable: booleanIsh > `const` **booleanIsh**: `Codec`\<`string` \| `number` \| `boolean`, `boolean`, `BooleanIshOptions` \| `undefined`\> Defined in: [packages/core/src/codecs/boolean-ish.ts:18](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/boolean-ish.ts#L18) The `boolean-ish` codec: `"true"`, `"1"`, `"Y"`, `"yes"`, `"on"`, `1` and their opposites. --- **Millwork** *** Millwork / @millwork-ts/core / byteSize # Variable: byteSize > `const` **byteSize**: `Codec`\<`string` \| `number`, `number`, `undefined`\> Defined in: [packages/core/src/codecs/byte-size.ts:25](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/byte-size.ts#L25) The `byte-size` codec: a number of bytes, or a string such as `"1 MiB"` or `"2 kB"`, to a number of bytes. Serialize writes the number. --- **Millwork** *** Millwork / @millwork-ts/core / bytes # Variable: bytes > `const` **bytes**: `Codec`\<`string`, `Uint8Array`\<`ArrayBufferLike`\>, `BytesOptions` \| `undefined`\> Defined in: [packages/core/src/codecs/bytes.ts:44](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/bytes.ts#L44) The `bytes` codec: base64, base64url or hex text to a `Uint8Array`. A typed array cannot be frozen, so hydrate gives a new copy each time. Do not change it; set a new value. --- **Millwork** *** Millwork / @millwork-ts/core / codecFactories # Variable: codecFactories > `const` **codecFactories**: `Readonly`\<\{ `array`: \<`Raw`, `Value`, `Options`\>(`codec`) => `Codec`\<`Raw`[], readonly (`Value` \| `undefined`)[], `Options`\>; `map`: \<`R`, `V`, `O`\>(`inner`) => `Codec`\<`MapRaw`\<`R`\>, `ReadonlyMap`\<`string`, `V`\>, `MapOptions`\<`O`\> \| `undefined`\>; `nullable`: \<`Raw`, `Value`, `Options`\>(`codec`) => `Codec`\<`Raw`, `Value` \| `null`, `Options`\>; `range`: \<`R`, `V`, `O`\>(`inner`) => `Codec`\<`RangeRaw`\<`R`\>, `Range`\<`V`\>, `RangeOptions`\<`O`\> \| `undefined`\>; `set`: \<`R`, `V`, `O`\>(`inner`) => `Codec`\<`R`[], `ReadonlySet`\<`V`\>, `O`\>; \}\> Defined in: [packages/core/src/registry.ts:57](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/registry.ts#L57) The codec factories in core, keyed by the prefix of the codec names that they make. --- **Millwork** *** Millwork / @millwork-ts/core / codecs # Variable: codecs > `const` **codecs**: `Readonly`\<\{ `bigint`: `Codec`\<`string` \| `number`, `bigint`, `undefined`\>; `bitflags`: `Codec`\<`number`, `ReadonlySet`\<`string`\>, `BitflagsOptions` \| `undefined`\>; `boolean-ish`: `Codec`\<`string` \| `number` \| `boolean`, `boolean`, `BooleanIshOptions` \| `undefined`\>; `byte-size`: `Codec`\<`string` \| `number`, `number`, `undefined`\>; `bytes`: `Codec`\<`string`, `Uint8Array`\<`ArrayBufferLike`\>, `BytesOptions` \| `undefined`\>; `country`: `Codec`\<`string`, `string`, `undefined`\>; `currency-code`: `Codec`\<`string`, `string`, `undefined`\>; `decimal`: `Codec`\<`string` \| `number`, `Decimal`, `DecimalOptions` \| `undefined`\>; `email`: `Codec`\<`string`, `string`, `undefined`\>; `geojson`: `Codec`\<`GeoJson`, `GeoJson`, `undefined`\>; `i18n-text`: `Codec`\<`Record`\<`string`, `string`\>, `I18nText`, `undefined`\>; `language`: `Codec`\<`string`, `string`, `undefined`\>; `latlng`: `Codec`\<`LatLngRaw`, `LatLng`, `LatLngOptions` \| `undefined`\>; `locale`: `Codec`\<`string`, `string`, `undefined`\>; `mime-type`: `Codec`\<`string`, `MimeType`, `undefined`\>; `money`: `Codec`\<`MoneyRaw`, `Money`, `MoneyOptions` \| `undefined`\>; `number-string`: `Codec`\<`string` \| `number`, `number`, `undefined`\>; `percent`: `Codec`\<`string` \| `number`, `Percent`, `PercentOptions` \| `undefined`\>; `ratio`: `Codec`\<`string` \| `Ratio`, `Ratio`, `RatioOptions` \| `undefined`\>; `snowflake`: `Codec`\<`string`, `bigint`, `undefined`\>; `time-zone`: `Codec`\<`string`, `string`, `undefined`\>; `ulid`: `Codec`\<`string`, `string`, `undefined`\>; `url`: `Codec`\<`string`, `URL`, `UrlOptions` \| `undefined`\>; `uuid`: `Codec`\<`string`, `string`, `undefined`\>; \}\> Defined in: [packages/core/src/registry.ts:29](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/registry.ts#L29) Each concrete codec in core, keyed by its name. The WarpDrive adapter uses it to register the codecs as Transformations. Dates are not here: they come from an adapter package. --- **Millwork** *** Millwork / @millwork-ts/core / country # Variable: country > `const` **country**: `Codec`\<`string`, `string`, `undefined`\> Defined in: [packages/core/src/codecs/codes.ts:9](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/codes.ts#L9) The `country` codec: an ISO 3166-1 alpha-2 code, upper case. `Intl` checks it. --- **Millwork** *** Millwork / @millwork-ts/core / currencyCode # Variable: currencyCode > `const` **currencyCode**: `Codec`\<`string`, `string`, `undefined`\> Defined in: [packages/core/src/codecs/codes.ts:17](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/codes.ts#L17) The `currency-code` codec: an ISO 4217 code, upper case. `Intl` or the money table checks it. --- **Millwork** *** Millwork / @millwork-ts/core / decimal # Variable: decimal > `const` **decimal**: `Codec`\<`string` \| `number`, `Decimal`, `DecimalOptions` \| `undefined`\> Defined in: [packages/core/src/codecs/decimal.ts:13](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/decimal.ts#L13) The `decimal` codec: a decimal string (or a number on read) to an exact `Decimal`. --- **Millwork** *** Millwork / @millwork-ts/core / email # Variable: email > `const` **email**: `Codec`\<`string`, `string`, `undefined`\> Defined in: [packages/core/src/codecs/email.ts:6](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/email.ts#L6) The `email` codec. It checks the form and lower-cases the domain. The local part keeps its case. --- **Millwork** *** Millwork / @millwork-ts/core / geojson # Variable: geojson > `const` **geojson**: `Codec`\<`GeoJson`, `GeoJson`, `undefined`\> Defined in: [packages/core/src/codecs/geojson.ts:63](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/geojson.ts#L63) The `geojson` codec: a typed pass-through with a shallow type check. The value is a deep-frozen copy; the raw is not frozen. Serialize gives a copy that is not frozen. --- **Millwork** *** Millwork / @millwork-ts/core / i18nText # Variable: i18nText > `const` **i18nText**: `Codec`\<`Record`\<`string`, `string`\>, `I18nText`, `undefined`\> Defined in: [packages/core/src/codecs/i18n-text.ts:64](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/i18n-text.ts#L64) The `i18n-text` codec: `{ en: 'Hello', fr: 'Bonjour' }` to an `I18nText`. --- **Millwork** *** Millwork / @millwork-ts/core / language # Variable: language > `const` **language**: `Codec`\<`string`, `string`, `undefined`\> Defined in: [packages/core/src/codecs/codes.ts:25](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/codes.ts#L25) The `language` codec: an ISO 639 language code with no subtags, lower case. --- **Millwork** *** Millwork / @millwork-ts/core / latlng # Variable: latlng > `const` **latlng**: `Codec`\<`LatLngRaw`, `LatLng`, `LatLngOptions` \| `undefined`\> Defined in: [packages/core/src/codecs/latlng.ts:28](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/latlng.ts#L28) The `latlng` codec. It checks that the latitude is in ±90 and the longitude is in ±180. --- **Millwork** *** Millwork / @millwork-ts/core / locale # Variable: locale > `const` **locale**: `Codec`\<`string`, `string`, `undefined`\> Defined in: [packages/core/src/codecs/codes.ts:33](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/codes.ts#L33) The `locale` codec: a BCP 47 tag in its canonical form, through `Intl.getCanonicalLocales`. --- **Millwork** *** Millwork / @millwork-ts/core / mimeType # Variable: mimeType > `const` **mimeType**: `Codec`\<`string`, `MimeType`, `undefined`\> Defined in: [packages/core/src/codecs/mime-type.ts:17](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/mime-type.ts#L17) The `mime-type` codec: `"text/html; charset=utf-8"` to a `MimeType`. --- **Millwork** *** Millwork / @millwork-ts/core / money # Variable: money > `const` **money**: `Codec`\<`MoneyRaw`, `Money`, `MoneyOptions` \| `undefined`\> Defined in: [packages/core/src/codecs/money.ts:40](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/money.ts#L40) The `money` codec. It reads a number amount on the `'decimal'` wire, but it never writes a float. An integer amount that is not a safe integer is written as a string. --- **Millwork** *** Millwork / @millwork-ts/core / numberString # Variable: numberString > `const` **numberString**: `Codec`\<`string` \| `number`, `number`, `undefined`\> Defined in: [packages/core/src/codecs/number-string.ts:17](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/number-string.ts#L17) The `number-string` codec: a number sent as a string, such as `"42"`, to a `number`. The tokens `"NaN"`, `"Infinity"` and `"-Infinity"` are read and written for the special values. --- **Millwork** *** Millwork / @millwork-ts/core / percent # Variable: percent > `const` **percent**: `Codec`\<`string` \| `number`, `Percent`, `PercentOptions` \| `undefined`\> Defined in: [packages/core/src/codecs/percent.ts:48](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/percent.ts#L48) The `percent` codec. The value is backed by an exact `Decimal` fraction. --- **Millwork** *** Millwork / @millwork-ts/core / ratio # Variable: ratio > `const` **ratio**: `Codec`\<`string` \| `Ratio`, `Ratio`, `RatioOptions` \| `undefined`\> Defined in: [packages/core/src/codecs/ratio.ts:19](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/ratio.ts#L19) The `ratio` codec: `"16:9"` or `{ num, den }`. `equals` compares the value, so 32:18 equals 16:9. --- **Millwork** *** Millwork / @millwork-ts/core / snowflake # Variable: snowflake > `const` **snowflake**: `Codec`\<`string`, `bigint`, `undefined`\> Defined in: [packages/core/src/codecs/snowflake.ts:17](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/snowflake.ts#L17) The `snowflake` codec: a 64-bit id string to a `bigint`, and back to a string. A number raw is not accepted, because a snowflake is larger than a safe integer. --- **Millwork** *** Millwork / @millwork-ts/core / timeZone # Variable: timeZone > `const` **timeZone**: `Codec`\<`string`, `string`, `undefined`\> Defined in: [packages/core/src/codecs/codes.ts:39](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/codes.ts#L39) The `time-zone` codec: an IANA time zone ID. `Intl.DateTimeFormat` checks it and fixes the case. --- **Millwork** *** Millwork / @millwork-ts/core / ulid # Variable: ulid > `const` **ulid**: `Codec`\<`string`, `string`, `undefined`\> Defined in: [packages/core/src/codecs/ulid.ts:7](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/ulid.ts#L7) The `ulid` codec. The value is the upper-case string; `equals` ignores case. --- **Millwork** *** Millwork / @millwork-ts/core / url # Variable: url > `const` **url**: `Codec`\<`string`, `URL`, `UrlOptions` \| `undefined`\> Defined in: [packages/core/src/codecs/url.ts:74](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/url.ts#L74) The `url` codec: a string to a `FrozenURL`. `equals` compares `href`. By default, only `DEFAULT_URL_PROTOCOLS` are accepted: set the `protocols` option to change them. --- **Millwork** *** Millwork / @millwork-ts/core / uuid # Variable: uuid > `const` **uuid**: `Codec`\<`string`, `string`, `undefined`\> Defined in: [packages/core/src/codecs/uuid.ts:6](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/core/src/codecs/uuid.ts#L6) The `uuid` codec. The value is the lower-case string; `equals` ignores case. --- **Millwork** *** Millwork / @millwork-ts/cron # @millwork-ts/cron A Millwork codec for cron expressions with [croner](https://github.com/Hexagon/croner). ## Install ```bash pnpm add @millwork-ts/cron @millwork-ts/core croner ``` ## Codecs | Codec | Value | Raw | | ------ | -------------------------------------------------- | --------------- | | `cron` | a frozen `{ expression, dialect, next, nextRuns }` | `"0 9 * * 1-5"` | - croner checks the expression. A bad field, such as `61` minutes, is bad input. - The codec writes the expression with one space between the fields. - `value.next(from?)` gives the first run after `from`, or `null`. The default of `from` is now. - `value.nextRuns(count, from?)` gives the next `count` runs. - The run times use the local time zone of the device. - The codec does not start a job. To run a job, use croner directly. ## Options | Option | Type | Use | | --------- | ----------------------- | ---------------------------------------------------------------------------------------- | | `dialect` | `'unix'` \| `'seconds'` | `'unix'` has 5 fields. `'seconds'` has 6 fields, seconds first. The default is `'unix'`. | ## Equality `equals` compares the expression, with one space between the fields, and the dialect. `"0 9 * * 1-5"` equals `"0 9 * * 1-5"`. `"0 9 * * MON-FRI"` does not equal `"0 9 * * 1-5"`. ## Example with WarpDrive Register the codecs before the store calls `transformations()`, because `transformations()` reads the registry when it runs. See the [`@millwork-ts/warp-drive` README](https://github.com/joegaudet/millwork/tree/main/packages/warp-drive#the-store). ```ts import { codecs } from '@millwork-ts/cron' import { registerCodecs, valueField } from '@millwork-ts/warp-drive' import { withDefaults } from '@warp-drive/core/reactive' registerCodecs(codecs) export const ReportSchema = withDefaults({ type: 'report', fields: [valueField('schedule', 'cron', { dialect: 'seconds' })], }) ``` ## Interfaces - CronOptions - CronValue ## Type Aliases - CronDialect ## Variables - codecs - cron --- **Millwork** *** Millwork / @millwork-ts/cron / CronOptions # Interface: CronOptions Defined in: [index.ts:8](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/cron/src/index.ts#L8) Options of the `cron` codec. ## Properties ### dialect? > `optional` **dialect?**: `CronDialect` Defined in: [index.ts:10](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/cron/src/index.ts#L10) The number of fields. The default is `'unix'` (5 fields). --- **Millwork** *** Millwork / @millwork-ts/cron / CronValue # Interface: CronValue Defined in: [index.ts:14](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/cron/src/index.ts#L14) A cron expression. The value is a frozen plain object. Times use the local time zone. ## Properties ### dialect > `readonly` **dialect**: `CronDialect` Defined in: [index.ts:17](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/cron/src/index.ts#L17) *** ### expression > `readonly` **expression**: `string` Defined in: [index.ts:16](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/cron/src/index.ts#L16) The expression, with one space between fields. ## Methods ### next() > **next**(`from?`): `Date` \| `null` Defined in: [index.ts:19](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/cron/src/index.ts#L19) The first run after `from` (the default is now), or `null` when there is none. #### Parameters ##### from? `Date` #### Returns `Date` \| `null` *** ### nextRuns() > **nextRuns**(`count`, `from?`): `Date`[] Defined in: [index.ts:21](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/cron/src/index.ts#L21) The next `count` runs after `from` (the default is now). #### Parameters ##### count `number` ##### from? `Date` #### Returns `Date`[] --- **Millwork** *** Millwork / @millwork-ts/cron / CronDialect # Type Alias: CronDialect > **CronDialect** = `"unix"` \| `"seconds"` Defined in: [index.ts:5](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/cron/src/index.ts#L5) The cron dialect: `'unix'` has 5 fields, `'seconds'` has 6 (seconds first). --- **Millwork** *** Millwork / @millwork-ts/cron / codecs # Variable: codecs > `const` **codecs**: `Readonly`\<\{ `cron`: `Codec`\<`string`, `CronValue`, `CronOptions` \| `undefined`\>; \}\> Defined in: [index.ts:60](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/cron/src/index.ts#L60) The codecs of this package, keyed by name. --- **Millwork** *** Millwork / @millwork-ts/cron / cron # Variable: cron > `const` **cron**: `Codec`\<`string`, `CronValue`, `CronOptions` \| `undefined`\> Defined in: [index.ts:48](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/cron/src/index.ts#L48) The `cron` codec: `"0 9 * * 1-5"` to a frozen `{ expression, dialect, next, nextRuns }`. croner checks the expression. Serialize writes the expression with one space between fields. `equals` compares the expression and the dialect. --- **Millwork** *** Millwork / @millwork-ts/date-fns # @millwork-ts/date-fns Millwork codecs for [date-fns](https://date-fns.org/). Each codec reads a wire value into a native `Date`, a date-fns `Duration` or `Interval`, or a `TZDate`, and writes it back. ## Install ```bash pnpm add @millwork-ts/core @millwork-ts/date-fns date-fns ``` For the zoned codec, also install `@date-fns/tz` and import from `@millwork-ts/date-fns/tz`: ```bash pnpm add @date-fns/tz ``` The main entry does not import `@date-fns/tz`, so an app without it still works. ## Frozen dates A `Date` is mutable, and `Object.freeze` does not stop its setters. So each codec gives a `FrozenDate` (or a `FrozenTZDate`): a frozen subclass where each `set…` method throws a `TypeError`. date-fns functions such as `addDays` give a plain, mutable `Date` back (a `TZDate` in the same zone for a `FrozenTZDate`). To change a field, set a new value. ## Codecs Each codec is a named export. The `codecs` record has each codec two times: with its kind as the key (`date`) and with the adapter prefix (`date-fns:date`). The `name` of each codec has the prefix. If your app registers two date families, use the prefixed keys. From `@millwork-ts/date-fns`: | Export | Key | Wire | Value | | ---------- | ---------- | ------------------------------------------------- | ----------------------------------- | | `date` | `date` | `"2026-12-01"` | `FrozenDate` at local midnight | | `datetime` | `datetime` | RFC 3339, `"2026-12-01T14:30:00-05:00"` or `"…Z"` | `FrozenDate` | | `epoch` | `epoch` | a number, or a string for large values | `FrozenDate` | | `duration` | `duration` | ISO 8601 `"PT1H30M"`, or a number | frozen date-fns `Duration` | | `interval` | `interval` | `"a/b"`, `"a/PT1H"`, `"P1D/b"`, `{ start, end }` | frozen date-fns `Interval` of dates | From `@millwork-ts/date-fns/tz`, with all of the above: | Export | Key | Wire | Value | | --------------- | ---------------- | -------------------------------------------------------------- | -------------- | | `zonedDateTime` | `zoned-datetime` | `"2026-12-01T14:30:00-05:00[America/Toronto]"`, `{ at, zone }` | `FrozenTZDate` | date-fns has no time, local date-time or year-month type, so the package has no codec for them. Options: - `date`: the value is local midnight. It is never made with `new Date("2026-12-01")`, which gives UTC midnight and the day before in western zones. - `datetime`: a `Date` has no offset, so `serialize` always writes `Z`. The `keepOffset` option has no effect. Digits below the millisecond are dropped. - `epoch`: `unit` is `'s'`, `'ms'` (the default), `'us'` or `'ns'`. `serialize` writes a number when it is a safe integer. It writes `'ns'` as a string. - `duration`: `unit` is `'iso'` (the default), `'s'` or `'ms'`. Parts of a second go in `seconds`. A duration with years, months or weeks cannot become a number, so `serialize` throws a `RangeError`. A day is 24 hours. - `interval`: `wire: 'object'` writes `{ start, end }`. A duration is added in UTC. An open interval (`..`) is bad input. The interval is half-open: `[start, end)`. - `zonedDateTime`: `wire: 'object'` writes `{ at, zone }`. The default writes RFC 9557. Both are read. The wire offset must be the offset of the zone at that instant, or the value is bad. Bad wire input gives `undefined` and a report to `onInvalid`. A value of the wrong type, or an `Invalid Date`, makes `serialize` throw a `TypeError`. `serialize` accepts any valid `Date`, not only a `FrozenDate`. ## Equality - `datetime`, `epoch` and `interval` compare the instant (`getTime()`). - `zonedDateTime` compares the instant and the zone. - `date` compares the local calendar day. - `duration` compares years, months and weeks one by one, and the other units by length. `PT1H` equals `PT60M`. `P1M` does not equal `P30D`. ## WarpDrive Register the codecs before the store calls `transformations()`, because `transformations()` reads the registry when it runs. See the [`@millwork-ts/warp-drive` README](https://github.com/joegaudet/millwork/tree/main/packages/warp-drive#the-store). ```ts import { codecs } from '@millwork-ts/date-fns/tz' import { registerCodecs, valueField } from '@millwork-ts/warp-drive' import { withDefaults } from '@warp-drive/core/reactive' registerCodecs(codecs) export const EventSchema = withDefaults({ type: 'event', fields: [ valueField('startsOn', 'date-fns:date'), valueField('startsAt', 'date-fns:datetime'), valueField('local', 'date-fns:zoned-datetime'), ], }) ``` ## Modules - index - tz --- **Millwork** *** Millwork / @millwork-ts/date-fns / index # index ## Classes - FrozenDate ## Interfaces - DateFnsTypes - IntervalOptions ## Type Aliases - FrozenInterval - IntervalRaw ## Variables - codecs - date - dateFnsFamily - datetime - duration - epoch - interval --- **Millwork** *** Millwork / @millwork-ts/date-fns / index / FrozenDate # Class: FrozenDate Defined in: [packages/date-fns/src/frozen.ts:34](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/date-fns/src/frozen.ts#L34) The `Date` that the codecs give. It is frozen, and each setter throws. date-fns functions (`addDays`, `startOfMonth` and others) give a plain, mutable `Date` back. ## Extends - `Date` ## Methods ### \constructFromSymbol\ > **\[constructFromSymbol\]**(`value`): `Date` Defined in: [packages/date-fns/src/frozen.ts:36](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/date-fns/src/frozen.ts#L36) Lets date-fns make a new plain `Date` from a value, a number or a string. #### Parameters ##### value `string` \| `number` \| `Date` #### Returns `Date` --- **Millwork** *** Millwork / @millwork-ts/date-fns / index / DateFnsTypes # Interface: DateFnsTypes Defined in: [packages/date-fns/src/index.ts:29](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/date-fns/src/index.ts#L29) The date-fns type of each date kind. date-fns has no time, local or year-month type. ## Properties ### date > **date**: `Date` Defined in: [packages/date-fns/src/index.ts:30](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/date-fns/src/index.ts#L30) *** ### duration > **duration**: `Readonly`\<`Duration`\> Defined in: [packages/date-fns/src/index.ts:36](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/date-fns/src/index.ts#L36) *** ### instant > **instant**: `Date` Defined in: [packages/date-fns/src/index.ts:33](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/date-fns/src/index.ts#L33) *** ### interval > **interval**: `FrozenInterval` Defined in: [packages/date-fns/src/index.ts:37](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/date-fns/src/index.ts#L37) *** ### localDateTime > **localDateTime**: `never` Defined in: [packages/date-fns/src/index.ts:32](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/date-fns/src/index.ts#L32) *** ### time > **time**: `never` Defined in: [packages/date-fns/src/index.ts:31](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/date-fns/src/index.ts#L31) *** ### yearMonth > **yearMonth**: `never` Defined in: [packages/date-fns/src/index.ts:35](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/date-fns/src/index.ts#L35) *** ### zonedDateTime > **zonedDateTime**: `Date` Defined in: [packages/date-fns/src/index.ts:34](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/date-fns/src/index.ts#L34) --- **Millwork** *** Millwork / @millwork-ts/date-fns / index / IntervalOptions # Interface: IntervalOptions Defined in: packages/core/dist/dates.d.ts:109 Options of an `interval` codec. ## Properties ### wire? > `optional` **wire?**: `"object"` \| `"iso"` Defined in: packages/core/dist/dates.d.ts:111 The form that `serialize` writes. The default is `'iso'` (`"a/b"`). Both forms are read. --- **Millwork** *** Millwork / @millwork-ts/date-fns / index / FrozenInterval # Type Alias: FrozenInterval > **FrozenInterval** = `Readonly`\<`Interval`\<`Date`, `Date`\>\> Defined in: [packages/date-fns/src/index.ts:26](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/date-fns/src/index.ts#L26) A frozen date-fns `Interval` of frozen dates. It is half-open: `[start, end)`. --- **Millwork** *** Millwork / @millwork-ts/date-fns / index / IntervalRaw # Type Alias: IntervalRaw > **IntervalRaw** = `string` \| \{ `end`: `string`; `start`: `string`; \} Defined in: [packages/date-fns/src/index.ts:41](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/date-fns/src/index.ts#L41) The raw wire form of an interval: `start/end` text, or `{ start, end }`. --- **Millwork** *** Millwork / @millwork-ts/date-fns / index / codecs # Variable: codecs > `const` **codecs**: `Readonly`\<\{ `date`: `Codec`\<`string`, `Date`, `undefined`\>; `date-fns:date`: `Codec`\<`string`, `Date`, `undefined`\>; `date-fns:datetime`: `Codec`\<`string`, `Date`, \{ `keepOffset?`: `boolean`; \} \| `undefined`\>; `date-fns:duration`: `Codec`\<`string` \| `number`, `Readonly`\<`Duration`\>, \{ `unit?`: `"iso"` \| `"s"` \| `"ms"`; \} \| `undefined`\>; `date-fns:epoch`: `Codec`\<`string` \| `number`, `Date`, \{ `unit?`: `EpochUnit`; \} \| `undefined`\>; `date-fns:interval`: `Codec`\<`IntervalRaw`, `Readonly`\<`Interval`\<`Date`, `Date`\>\>, `IntervalOptions` \| `undefined`\>; `datetime`: `Codec`\<`string`, `Date`, \{ `keepOffset?`: `boolean`; \} \| `undefined`\>; `duration`: `Codec`\<`string` \| `number`, `Readonly`\<`Duration`\>, \{ `unit?`: `"iso"` \| `"s"` \| `"ms"`; \} \| `undefined`\>; `epoch`: `Codec`\<`string` \| `number`, `Date`, \{ `unit?`: `EpochUnit`; \} \| `undefined`\>; `interval`: `Codec`\<`IntervalRaw`, `Readonly`\<`Interval`\<`Date`, `Date`\>\>, `IntervalOptions` \| `undefined`\>; \}\> Defined in: [packages/date-fns/src/index.ts:194](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/date-fns/src/index.ts#L194) Each date-fns codec, keyed by its kind (`date`) and by an alias with the adapter prefix (`date-fns:date`). Use the prefixed keys when an app registers two date families. --- **Millwork** *** Millwork / @millwork-ts/date-fns / index / date # Variable: date > `const` **date**: `Codec`\<`string`, `Date`\> Defined in: [packages/date-fns/src/index.ts:82](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/date-fns/src/index.ts#L82) `"2026-12-01"` ↔ a frozen `Date` at local midnight of that day (never UTC midnight). --- **Millwork** *** Millwork / @millwork-ts/date-fns / index / dateFnsFamily # Variable: dateFnsFamily > `const` **dateFnsFamily**: `Readonly`\<\{ `date`: () => `Codec`\<`string`, `Date`, `undefined`\>; `datetime`: () => `Codec`\<`string`, `Date`, \{ `keepOffset?`: `boolean`; \} \| `undefined`\>; `duration`: () => `Codec`\<`string` \| `number`, `Readonly`\<`Duration`\>, \{ `unit?`: `"iso"` \| `"s"` \| `"ms"`; \} \| `undefined`\>; `epoch`: () => `Codec`\<`string` \| `number`, `Date`, \{ `unit?`: `EpochUnit`; \} \| `undefined`\>; `interval`: () => `Codec`\<`IntervalRaw`, `Readonly`\<`Interval`\<`Date`, `Date`\>\>, `IntervalOptions` \| `undefined`\>; `name`: `"date-fns"`; \}\> Defined in: [packages/date-fns/src/index.ts:176](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/date-fns/src/index.ts#L176) The date-fns date family. The zoned codec needs `@date-fns/tz`, so it is in the `@millwork-ts/date-fns/tz` entry, with `dateFnsTzFamily`. --- **Millwork** *** Millwork / @millwork-ts/date-fns / index / datetime # Variable: datetime > `const` **datetime**: `Codec`\<`string`, `Date`, \{ `keepOffset?`: `boolean`; \} \| `undefined`\> Defined in: [packages/date-fns/src/index.ts:100](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/date-fns/src/index.ts#L100) RFC 3339 ↔ a frozen `Date`. A `Date` has no offset, so `serialize` always writes `Z`, and the `keepOffset` option has no effect. Digits below the millisecond are dropped. --- **Millwork** *** Millwork / @millwork-ts/date-fns / index / duration # Variable: duration > `const` **duration**: `Codec`\<`string` \| `number`, `Readonly`\<`Duration`\>, \{ `unit?`: `"iso"` \| `"s"` \| `"ms"`; \} \| `undefined`\> Defined in: [packages/date-fns/src/index.ts:131](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/date-fns/src/index.ts#L131) ISO 8601 or a number ↔ a frozen date-fns `Duration` object. The `unit` option is `'iso'` (default), `'s'` or `'ms'`. Parts of a second go in `seconds`. `equals` compares years, months, weeks and days per unit and the rest by length. --- **Millwork** *** Millwork / @millwork-ts/date-fns / index / epoch # Variable: epoch > `const` **epoch**: `Codec`\<`number` \| `string`, `Date`, \{ `unit?`: `EpochUnit`; \} \| `undefined`\> Defined in: [packages/date-fns/src/index.ts:113](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/date-fns/src/index.ts#L113) An epoch number ↔ a frozen `Date`. The `unit` option is `'s'`, `'ms'` (default), `'us'` or `'ns'`. --- **Millwork** *** Millwork / @millwork-ts/date-fns / index / interval # Variable: interval > `const` **interval**: `Codec`\<`IntervalRaw`, `FrozenInterval`, `IntervalOptions` \| `undefined`\> Defined in: [packages/date-fns/src/index.ts:147](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/date-fns/src/index.ts#L147) `"a/b"`, `"a/PT1H"`, `"P1D/b"` or `{ start, end }` ↔ a frozen date-fns `Interval` of frozen dates. A duration is added in UTC. Both ends must be there. --- **Millwork** *** Millwork / @millwork-ts/date-fns / tz # tz ## Classes - FrozenTZDate ## Interfaces - ZonedOptions ## Type Aliases - ZonedRaw ## Variables - codecs - dateFnsTzFamily - zonedDateTime --- **Millwork** *** Millwork / @millwork-ts/date-fns / tz / FrozenTZDate # Class: FrozenTZDate Defined in: [packages/date-fns/src/tz.ts:20](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/date-fns/src/tz.ts#L20) The `TZDate` that the zoned codec gives. It is frozen, and each setter throws. ## Extends - `TZDate` ## Constructors ### Constructor > **new FrozenTZDate**(): `FrozenTZDate` Defined in: node\_modules/.pnpm/@date-fns+tz@1.5.0/node\_modules/@date-fns/tz/date/index.d.ts:23 Constructs a new `TZDate` instance in the system time zone. #### Returns `FrozenTZDate` #### Inherited from `TZDate.constructor` ### Constructor > **new FrozenTZDate**(`dateStr`, `timeZone?`): `FrozenTZDate` Defined in: node\_modules/.pnpm/@date-fns+tz@1.5.0/node\_modules/@date-fns/tz/date/index.d.ts:31 Constructs a new `TZDate` instance from the date time string and time zone. #### Parameters ##### dateStr `string` Date time string to create a new instance from ##### timeZone? `string` Time zone name (IANA or UTC offset) #### Returns `FrozenTZDate` #### Inherited from `TZDate.constructor` ### Constructor > **new FrozenTZDate**(`date`, `timeZone?`): `FrozenTZDate` Defined in: node\_modules/.pnpm/@date-fns+tz@1.5.0/node\_modules/@date-fns/tz/date/index.d.ts:39 Constructs a new `TZDate` instance from the date object and time zone. #### Parameters ##### date `Date` Date object to create a new instance from ##### timeZone? `string` Time zone name (IANA or UTC offset) #### Returns `FrozenTZDate` #### Inherited from `TZDate.constructor` ### Constructor > **new FrozenTZDate**(`timestamp`, `timeZone?`): `FrozenTZDate` Defined in: node\_modules/.pnpm/@date-fns+tz@1.5.0/node\_modules/@date-fns/tz/date/index.d.ts:48 Constructs a new `TZDate` instance from the Unix timestamp in milliseconds and time zone. #### Parameters ##### timestamp `number` Unix timestamp in milliseconds to create a new instance from ##### timeZone? `string` Time zone name (IANA or UTC offset) #### Returns `FrozenTZDate` #### Inherited from `TZDate.constructor` ### Constructor > **new FrozenTZDate**(`year`, `month`, `timeZone?`): `FrozenTZDate` Defined in: node\_modules/.pnpm/@date-fns+tz@1.5.0/node\_modules/@date-fns/tz/date/index.d.ts:57 Constructs a new `TZDate` instance from the year, month, and time zone. #### Parameters ##### year `number` Year ##### month `number` Month (0-11) ##### timeZone? `string` Time zone name (IANA or UTC offset) #### Returns `FrozenTZDate` #### Inherited from `TZDate.constructor` ### Constructor > **new FrozenTZDate**(`year`, `month`, `date`, `timeZone?`): `FrozenTZDate` Defined in: node\_modules/.pnpm/@date-fns+tz@1.5.0/node\_modules/@date-fns/tz/date/index.d.ts:67 Constructs a new `TZDate` instance from the year, month, date and time zone. #### Parameters ##### year `number` Year ##### month `number` Month (0-11) ##### date `number` Date ##### timeZone? `string` Time zone name (IANA or UTC offset) #### Returns `FrozenTZDate` #### Inherited from `TZDate.constructor` ### Constructor > **new FrozenTZDate**(`year`, `month`, `date`, `hours`, `timeZone?`): `FrozenTZDate` Defined in: node\_modules/.pnpm/@date-fns+tz@1.5.0/node\_modules/@date-fns/tz/date/index.d.ts:79 Constructs a new `TZDate` instance from the year, month, date, hours and time zone. #### Parameters ##### year `number` Year ##### month `number` Month (0-11) ##### date `number` Date ##### hours `number` Hours ##### timeZone? `string` Time zone name (IANA or UTC offset) #### Returns `FrozenTZDate` #### Inherited from `TZDate.constructor` ### Constructor > **new FrozenTZDate**(`year`, `month`, `date`, `hours`, `minutes`, `timeZone?`): `FrozenTZDate` Defined in: node\_modules/.pnpm/@date-fns+tz@1.5.0/node\_modules/@date-fns/tz/date/index.d.ts:98 Constructs a new `TZDate` instance from the year, month, date, hours, minutes and time zone. #### Parameters ##### year `number` Year ##### month `number` Month (0-11) ##### date `number` Date ##### hours `number` Hours ##### minutes `number` Minutes ##### timeZone? `string` Time zone name (IANA or UTC offset) #### Returns `FrozenTZDate` #### Inherited from `TZDate.constructor` ### Constructor > **new FrozenTZDate**(`year`, `month`, `date`, `hours`, `minutes`, `seconds`, `timeZone?`): `FrozenTZDate` Defined in: node\_modules/.pnpm/@date-fns+tz@1.5.0/node\_modules/@date-fns/tz/date/index.d.ts:119 Constructs a new `TZDate` instance from the year, month, date, hours, minutes, seconds and time zone. #### Parameters ##### year `number` Year ##### month `number` Month (0-11) ##### date `number` Date ##### hours `number` Hours ##### minutes `number` Minutes ##### seconds `number` Seconds ##### timeZone? `string` Time zone name (IANA or UTC offset) #### Returns `FrozenTZDate` #### Inherited from `TZDate.constructor` ### Constructor > **new FrozenTZDate**(`year`, `month`, `date`, `hours`, `minutes`, `seconds`, `milliseconds`, `timeZone?`): `FrozenTZDate` Defined in: node\_modules/.pnpm/@date-fns+tz@1.5.0/node\_modules/@date-fns/tz/date/index.d.ts:142 Constructs a new `TZDate` instance from the year, month, date, hours, minutes, seconds, milliseconds and time zone. #### Parameters ##### year `number` Year ##### month `number` Month (0-11) ##### date `number` Date ##### hours `number` Hours ##### minutes `number` Minutes ##### seconds `number` Seconds ##### milliseconds `number` Milliseconds ##### timeZone? `string` Time zone name (IANA or UTC offset) #### Returns `FrozenTZDate` #### Inherited from `TZDate.constructor` ## Properties ### timeZone > `readonly` **timeZone**: `string` \| `undefined` Defined in: node\_modules/.pnpm/@date-fns+tz@1.5.0/node\_modules/@date-fns/tz/date/index.d.ts:294 The current time zone of the date. #### Inherited from `TZDate.timeZone` ## Methods ### \constructFromSymbol\ > **\[constructFromSymbol\]**(`date`): `TZDate` Defined in: node\_modules/.pnpm/@date-fns+tz@1.5.0/node\_modules/@date-fns/tz/date/index.d.ts:307 Creates a new `TZDate` instance in the current instance time zone and the specified date time value. #### Parameters ##### date `string` \| `number` \| `Date` Date value to create a new instance from #### Returns `TZDate` #### Inherited from `TZDate.[constructFromSymbol]` *** ### withTimeZone() > **withTimeZone**(`timeZone`): `TZDate` Defined in: node\_modules/.pnpm/@date-fns+tz@1.5.0/node\_modules/@date-fns/tz/date/index.d.ts:299 Creates a new `TZDate` instance in the given time zone. #### Parameters ##### timeZone `string` #### Returns `TZDate` #### Inherited from `TZDate.withTimeZone` *** ### tz() #### Call Signature > `static` **tz**(`tz`): `TZDate` Defined in: node\_modules/.pnpm/@date-fns+tz@1.5.0/node\_modules/@date-fns/tz/date/index.d.ts:158 Creates a new `TZDate` instance in the given time zone. ##### Parameters ###### tz `string` Time zone name (IANA or UTC offset) ##### Returns `TZDate` ##### Inherited from `TZDate.tz` #### Call Signature > `static` **tz**(`tz`, `timestamp`): `TZDate` Defined in: node\_modules/.pnpm/@date-fns+tz@1.5.0/node\_modules/@date-fns/tz/date/index.d.ts:167 Creates a new `TZDate` instance in the given time zone from the Unix timestamp in milliseconds. ##### Parameters ###### tz `string` Time zone name (IANA or UTC offset) ###### timestamp `number` Unix timestamp in milliseconds ##### Returns `TZDate` ##### Inherited from `TZDate.tz` #### Call Signature > `static` **tz**(`tz`, `dateStr`): `TZDate` Defined in: node\_modules/.pnpm/@date-fns+tz@1.5.0/node\_modules/@date-fns/tz/date/index.d.ts:176 Creates a new `TZDate` instance in the given time zone from the date time string. ##### Parameters ###### tz `string` Time zone name (IANA or UTC offset) ###### dateStr `string` Date time string ##### Returns `TZDate` ##### Inherited from `TZDate.tz` #### Call Signature > `static` **tz**(`tz`, `date`): `TZDate` Defined in: node\_modules/.pnpm/@date-fns+tz@1.5.0/node\_modules/@date-fns/tz/date/index.d.ts:184 Creates a new `TZDate` instance in the given time zone from the date object. ##### Parameters ###### tz `string` Time zone name (IANA or UTC offset) ###### date `Date` Date object ##### Returns `TZDate` ##### Inherited from `TZDate.tz` #### Call Signature > `static` **tz**(`tz`, `year`, `month`): `TZDate` Defined in: node\_modules/.pnpm/@date-fns+tz@1.5.0/node\_modules/@date-fns/tz/date/index.d.ts:194 Creates a new `TZDate` instance in the given time zone from the year and month. ##### Parameters ###### tz `string` Time zone name (IANA or UTC offset) ###### year `number` Year ###### month `number` Month (0-11) ##### Returns `TZDate` ##### Inherited from `TZDate.tz` #### Call Signature > `static` **tz**(`tz`, `year`, `month`, `date`): `TZDate` Defined in: node\_modules/.pnpm/@date-fns+tz@1.5.0/node\_modules/@date-fns/tz/date/index.d.ts:205 Creates a new `TZDate` instance in the given time zone from the year, month and date. ##### Parameters ###### tz `string` Time zone name (IANA or UTC offset) ###### year `number` Year ###### month `number` Month (0-11) ###### date `number` Date ##### Returns `TZDate` ##### Inherited from `TZDate.tz` #### Call Signature > `static` **tz**(`tz`, `year`, `month`, `date`, `hours`): `TZDate` Defined in: node\_modules/.pnpm/@date-fns+tz@1.5.0/node\_modules/@date-fns/tz/date/index.d.ts:217 Creates a new `TZDate` instance in the given time zone from the year, month, date and hours. ##### Parameters ###### tz `string` Time zone name (IANA or UTC offset) ###### year `number` Year ###### month `number` Month (0-11) ###### date `number` Date ###### hours `number` Hours ##### Returns `TZDate` ##### Inherited from `TZDate.tz` #### Call Signature > `static` **tz**(`tz`, `year`, `month`, `date`, `hours`, `minutes`): `TZDate` Defined in: node\_modules/.pnpm/@date-fns+tz@1.5.0/node\_modules/@date-fns/tz/date/index.d.ts:236 Creates a new `TZDate` instance in the given time zone from the year, month, date, hours and minutes. ##### Parameters ###### tz `string` Time zone name (IANA or UTC offset) ###### year `number` Year ###### month `number` Month (0-11) ###### date `number` Date ###### hours `number` Hours ###### minutes `number` Minutes ##### Returns `TZDate` ##### Inherited from `TZDate.tz` #### Call Signature > `static` **tz**(`tz`, `year`, `month`, `date`, `hours`, `minutes`, `seconds`): `TZDate` Defined in: node\_modules/.pnpm/@date-fns+tz@1.5.0/node\_modules/@date-fns/tz/date/index.d.ts:257 Creates a new `TZDate` instance in the given time zone from the year, month, date, hours, minutes and seconds. ##### Parameters ###### tz `string` Time zone name (IANA or UTC offset) ###### year `number` Year ###### month `number` Month (0-11) ###### date `number` Date ###### hours `number` Hours ###### minutes `number` Minutes ###### seconds `number` Seconds ##### Returns `TZDate` ##### Inherited from `TZDate.tz` #### Call Signature > `static` **tz**(`tz`, `year`, `month`, `date`, `hours`, `minutes`, `seconds`, `milliseconds`): `TZDate` Defined in: node\_modules/.pnpm/@date-fns+tz@1.5.0/node\_modules/@date-fns/tz/date/index.d.ts:280 Creates a new `TZDate` instance in the given time zone from the year, month, date, hours, minutes, seconds and milliseconds. ##### Parameters ###### tz `string` Time zone name (IANA or UTC offset) ###### year `number` Year ###### month `number` Month (0-11) ###### date `number` Date ###### hours `number` Hours ###### minutes `number` Minutes ###### seconds `number` Seconds ###### milliseconds `number` Milliseconds ##### Returns `TZDate` ##### Inherited from `TZDate.tz` --- **Millwork** *** Millwork / @millwork-ts/date-fns / tz / ZonedOptions # Interface: ZonedOptions Defined in: packages/core/dist/dates.d.ts:104 Options of a `zonedDateTime` codec. ## Properties ### wire? > `optional` **wire?**: `"object"` \| `"rfc9557"` Defined in: packages/core/dist/dates.d.ts:106 The form that `serialize` writes. The default is `'rfc9557'`. Both forms are read. --- **Millwork** *** Millwork / @millwork-ts/date-fns / tz / ZonedRaw # Type Alias: ZonedRaw > **ZonedRaw** = `string` \| \{ `at`: `string`; `zone`: `string`; \} Defined in: [packages/date-fns/src/tz.ts:24](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/date-fns/src/tz.ts#L24) The raw wire form of a zoned datetime: RFC 9557 text, or `{ at, zone }`. --- **Millwork** *** Millwork / @millwork-ts/date-fns / tz / codecs # Variable: codecs > `const` **codecs**: `Readonly`\<\{ `date`: `Codec`\<`string`, `Date`, `undefined`\>; `date-fns:date`: `Codec`\<`string`, `Date`, `undefined`\>; `date-fns:datetime`: `Codec`\<`string`, `Date`, \{ `keepOffset?`: `boolean`; \} \| `undefined`\>; `date-fns:duration`: `Codec`\<`string` \| `number`, `Readonly`\<`Duration`\>, \{ `unit?`: `"iso"` \| `"s"` \| `"ms"`; \} \| `undefined`\>; `date-fns:epoch`: `Codec`\<`string` \| `number`, `Date`, \{ `unit?`: `EpochUnit`; \} \| `undefined`\>; `date-fns:interval`: `Codec`\<`IntervalRaw`, `Readonly`\<`Interval`\<`Date`, `Date`\>\>, `IntervalOptions` \| `undefined`\>; `date-fns:zoned-datetime`: `Codec`\<`ZonedRaw`, `TZDate`, `ZonedOptions` \| `undefined`\>; `datetime`: `Codec`\<`string`, `Date`, \{ `keepOffset?`: `boolean`; \} \| `undefined`\>; `duration`: `Codec`\<`string` \| `number`, `Readonly`\<`Duration`\>, \{ `unit?`: `"iso"` \| `"s"` \| `"ms"`; \} \| `undefined`\>; `epoch`: `Codec`\<`string` \| `number`, `Date`, \{ `unit?`: `EpochUnit`; \} \| `undefined`\>; `interval`: `Codec`\<`IntervalRaw`, `Readonly`\<`Interval`\<`Date`, `Date`\>\>, `IntervalOptions` \| `undefined`\>; `zoned-datetime`: `Codec`\<`ZonedRaw`, `TZDate`, `ZonedOptions` \| `undefined`\>; \}\> Defined in: [packages/date-fns/src/tz.ts:70](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/date-fns/src/tz.ts#L70) The codecs of the main entry, plus `zoned-datetime` and `date-fns:zoned-datetime`. --- **Millwork** *** Millwork / @millwork-ts/date-fns / tz / dateFnsTzFamily # Variable: dateFnsTzFamily > `const` **dateFnsTzFamily**: `Readonly`\<\{ `date`: () => `Codec`\<`string`, `Date`, `undefined`\>; `datetime`: () => `Codec`\<`string`, `Date`, \{ `keepOffset?`: `boolean`; \} \| `undefined`\>; `duration`: () => `Codec`\<`string` \| `number`, `Readonly`\<`Duration`\>, \{ `unit?`: `"iso"` \| `"s"` \| `"ms"`; \} \| `undefined`\>; `epoch`: () => `Codec`\<`string` \| `number`, `Date`, \{ `unit?`: `EpochUnit`; \} \| `undefined`\>; `interval`: () => `Codec`\<`IntervalRaw`, `Readonly`\<`Interval`\<`Date`, `Date`\>\>, `IntervalOptions` \| `undefined`\>; `name`: `"date-fns"`; `zonedDateTime`: () => `Codec`\<`ZonedRaw`, `TZDate`, `ZonedOptions` \| `undefined`\>; \}\> Defined in: [packages/date-fns/src/tz.ts:63](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/date-fns/src/tz.ts#L63) The date-fns date family with the zoned codec. --- **Millwork** *** Millwork / @millwork-ts/date-fns / tz / zonedDateTime # Variable: zonedDateTime > `const` **zonedDateTime**: `Codec`\<`ZonedRaw`, `TZDate`, `ZonedOptions` \| `undefined`\> Defined in: [packages/date-fns/src/tz.ts:34](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/date-fns/src/tz.ts#L34) RFC 9557 `"…-05:00[America/Toronto]"` or `{ at, zone }` ↔ a frozen `TZDate`. The wire offset must be the offset of the zone at that instant. `equals` compares the instant and the zone. --- **Millwork** *** Millwork / @millwork-ts/dayjs # @millwork-ts/dayjs Millwork codecs for [Day.js](https://day.js.org/). Each codec reads a wire value into a `Dayjs` or a dayjs `Duration`, and writes it back. ## Install ```bash pnpm add @millwork-ts/core @millwork-ts/dayjs dayjs ``` ## Plugins The codecs need the `utc`, `timezone` and `duration` plugins. This package calls `dayjs.extend` for each of them when it loads, on the `dayjs` instance of your app. The package marks its entry as a module with side effects, so a bundler keeps these calls. You do not have to extend them yourself. It is safe to extend them again. ## Codecs Each codec is a named export. The `codecs` record has each codec two times: with its kind as the key (`date`) and with the adapter prefix (`dayjs:date`). The `name` of each codec has the prefix. If your app registers two date families, use the prefixed keys. | Export | Key | Wire | Value | | --------------- | ---------------- | -------------------------------------------------------------- | ---------------------------------- | | `date` | `date` | `"2026-12-01"` | `Dayjs` at local midnight | | `datetime` | `datetime` | RFC 3339, `"2026-12-01T14:30:00-05:00"` or `"…Z"` | local `Dayjs` | | `epoch` | `epoch` | a number, or a string for large values | local `Dayjs` | | `time` | `time` | `"14:30"`, `"14:30:00.123"` | UTC `Dayjs` of today | | `localDateTime` | `local-datetime` | `"2026-12-01T14:30:00"` | UTC `Dayjs` | | `zonedDateTime` | `zoned-datetime` | `"2026-12-01T14:30:00-05:00[America/Toronto]"`, `{ at, zone }` | `Dayjs` in that zone (`.tz()`) | | `yearMonth` | `year-month` | `"2026-12"` | `Dayjs` at local midnight of day 1 | | `duration` | `duration` | ISO 8601 `"PT1H30M"`, or a number | dayjs `Duration` | dayjs has no interval type, so the package has no `interval` codec. Options: - `datetime`: `keepOffset: true` keeps the wire offset in the value (`utcOffset`), and `serialize` writes that offset. Without it, `serialize` writes `Z`. dayjs reads an offset of 16 minutes or less as hours, so such an offset is bad input. - `epoch`: `unit` is `'s'`, `'ms'` (the default), `'us'` or `'ns'`. `serialize` writes a number when it is a safe integer. It writes `'ns'` as a string. dayjs keeps milliseconds only. - `zonedDateTime`: `wire: 'object'` writes `{ at, zone }`. The default writes RFC 9557. Both are read. The wire offset must be the offset of the zone at that instant, or the value is bad. - `duration`: `unit` is `'iso'` (the default), `'s'` or `'ms'`. A duration with years, months or weeks cannot become a number, so `serialize` throws a `RangeError`. A day is 24 hours. dayjs arithmetic on a `Duration` (`add`, `subtract`) turns the result into years, months and days of fixed length. So `duration.hydrate('P10D').add(25, 'day')` can serialize with a month in it. Make a new duration from its units when the units are important. `time` and `local-datetime` values are in UTC, so a DST gap in the local zone cannot move the wall clock. Bad wire input gives `undefined` and a report to `onInvalid`. A value of the wrong type, or an invalid `Dayjs`, makes `serialize` throw a `TypeError`. ## Equality - `datetime` and `epoch` compare the instant (`valueOf()`). - `zonedDateTime` compares the instant and the zone. - `dayjsFamily.datetime({ strict: true })` (also `epoch` and `zonedDateTime`) gives a codec that also compares the offset and the zone. - `date`, `time`, `local-datetime` and `year-month` compare the wire text. - `duration` compares years, months and weeks one by one, and the other units by length. `PT1H` equals `PT60M`. `P1M` does not equal `P30D`. ## WarpDrive Register the codecs before the store calls `transformations()`, because `transformations()` reads the registry when it runs. See the [`@millwork-ts/warp-drive` README](https://github.com/joegaudet/millwork/tree/main/packages/warp-drive#the-store). ```ts import { codecs } from '@millwork-ts/dayjs' import { registerCodecs, valueField } from '@millwork-ts/warp-drive' import { withDefaults } from '@warp-drive/core/reactive' registerCodecs(codecs) export const EventSchema = withDefaults({ type: 'event', fields: [ valueField('startsOn', 'dayjs:date'), valueField('startsAt', 'dayjs:datetime', { keepOffset: true }), valueField('length', 'dayjs:duration'), ], }) ``` ## Interfaces - DayjsTypes - StrictOptions - ZonedOptions ## Type Aliases - ZonedRaw ## Variables - codecs - date - datetime - dayjsFamily - duration - epoch - localDateTime - time - yearMonth - zonedDateTime --- **Millwork** *** Millwork / @millwork-ts/dayjs / DayjsTypes # Interface: DayjsTypes Defined in: [dayjs/src/index.ts:35](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/dayjs/src/index.ts#L35) The dayjs type of each date kind. dayjs has no interval type. ## Properties ### date > **date**: `Dayjs` Defined in: [dayjs/src/index.ts:36](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/dayjs/src/index.ts#L36) *** ### duration > **duration**: `Duration` Defined in: [dayjs/src/index.ts:42](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/dayjs/src/index.ts#L42) *** ### instant > **instant**: `Dayjs` Defined in: [dayjs/src/index.ts:39](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/dayjs/src/index.ts#L39) *** ### interval > **interval**: `never` Defined in: [dayjs/src/index.ts:43](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/dayjs/src/index.ts#L43) *** ### localDateTime > **localDateTime**: `Dayjs` Defined in: [dayjs/src/index.ts:38](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/dayjs/src/index.ts#L38) *** ### time > **time**: `Dayjs` Defined in: [dayjs/src/index.ts:37](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/dayjs/src/index.ts#L37) *** ### yearMonth > **yearMonth**: `Dayjs` Defined in: [dayjs/src/index.ts:41](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/dayjs/src/index.ts#L41) *** ### zonedDateTime > **zonedDateTime**: `Dayjs` Defined in: [dayjs/src/index.ts:40](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/dayjs/src/index.ts#L40) --- **Millwork** *** Millwork / @millwork-ts/dayjs / StrictOptions # Interface: StrictOptions Defined in: [dayjs/src/index.ts:47](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/dayjs/src/index.ts#L47) Options of the codec factories that compare instants. ## Properties ### strict? > `optional` **strict?**: `boolean` Defined in: [dayjs/src/index.ts:49](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/dayjs/src/index.ts#L49) Also compare the offset and the zone. The default compares the instant only. --- **Millwork** *** Millwork / @millwork-ts/dayjs / ZonedOptions # Interface: ZonedOptions Defined in: core/dist/dates.d.ts:104 Options of a `zonedDateTime` codec. ## Properties ### wire? > `optional` **wire?**: `"object"` \| `"rfc9557"` Defined in: core/dist/dates.d.ts:106 The form that `serialize` writes. The default is `'rfc9557'`. Both forms are read. --- **Millwork** *** Millwork / @millwork-ts/dayjs / ZonedRaw # Type Alias: ZonedRaw > **ZonedRaw** = `string` \| \{ `at`: `string`; `zone`: `string`; \} Defined in: [dayjs/src/index.ts:53](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/dayjs/src/index.ts#L53) The raw wire form of a zoned datetime: RFC 9557 text, or `{ at, zone }`. --- **Millwork** *** Millwork / @millwork-ts/dayjs / codecs # Variable: codecs > `const` **codecs**: `Readonly`\<\{ `date`: `Codec`\<`string`, `Dayjs`, `undefined`\>; `datetime`: `Codec`\<`string`, `Dayjs`, \{ `keepOffset?`: `boolean`; \} \| `undefined`\>; `dayjs:date`: `Codec`\<`string`, `Dayjs`, `undefined`\>; `dayjs:datetime`: `Codec`\<`string`, `Dayjs`, \{ `keepOffset?`: `boolean`; \} \| `undefined`\>; `dayjs:duration`: `Codec`\<`string` \| `number`, `Duration`, \{ `unit?`: `"s"` \| `"ms"` \| `"iso"`; \} \| `undefined`\>; `dayjs:epoch`: `Codec`\<`string` \| `number`, `Dayjs`, \{ `unit?`: `EpochUnit`; \} \| `undefined`\>; `dayjs:local-datetime`: `Codec`\<`string`, `Dayjs`, `undefined`\>; `dayjs:time`: `Codec`\<`string`, `Dayjs`, `undefined`\>; `dayjs:year-month`: `Codec`\<`string`, `Dayjs`, `undefined`\>; `dayjs:zoned-datetime`: `Codec`\<`ZonedRaw`, `Dayjs`, `ZonedOptions` \| `undefined`\>; `duration`: `Codec`\<`string` \| `number`, `Duration`, \{ `unit?`: `"s"` \| `"ms"` \| `"iso"`; \} \| `undefined`\>; `epoch`: `Codec`\<`string` \| `number`, `Dayjs`, \{ `unit?`: `EpochUnit`; \} \| `undefined`\>; `local-datetime`: `Codec`\<`string`, `Dayjs`, `undefined`\>; `time`: `Codec`\<`string`, `Dayjs`, `undefined`\>; `year-month`: `Codec`\<`string`, `Dayjs`, `undefined`\>; `zoned-datetime`: `Codec`\<`ZonedRaw`, `Dayjs`, `ZonedOptions` \| `undefined`\>; \}\> Defined in: [dayjs/src/index.ts:266](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/dayjs/src/index.ts#L266) Each dayjs codec, keyed by its kind (`date`) and by an alias with the adapter prefix (`dayjs:date`). Use the prefixed keys when an app registers two date families. --- **Millwork** *** Millwork / @millwork-ts/dayjs / date # Variable: date > `const` **date**: `Codec`\<`string`, `Dayjs`\> Defined in: [dayjs/src/index.ts:144](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/dayjs/src/index.ts#L144) `"2026-12-01"` ↔ a `Dayjs` at local midnight of that day (never UTC midnight). --- **Millwork** *** Millwork / @millwork-ts/dayjs / datetime # Variable: datetime > `const` **datetime**: `Codec`\<`string`, `Dayjs`, \{ `keepOffset?`: `boolean`; \} \| `undefined`\> Defined in: [dayjs/src/index.ts:157](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/dayjs/src/index.ts#L157) RFC 3339 ↔ a `Dayjs`. The value is local, and `serialize` writes `Z`. With `keepOffset`, the value keeps the wire offset (`utcOffset`), and `serialize` writes it. --- **Millwork** *** Millwork / @millwork-ts/dayjs / dayjsFamily # Variable: dayjsFamily > `const` **dayjsFamily**: `Readonly`\<\{ `date`: () => `Codec`\<`string`, `Dayjs`, `undefined`\>; `datetime`: (`options?`) => `Codec`\<`string`, `Dayjs`, \{ `keepOffset?`: `boolean`; \} \| `undefined`\>; `duration`: () => `Codec`\<`string` \| `number`, `Duration`, \{ `unit?`: `"s"` \| `"ms"` \| `"iso"`; \} \| `undefined`\>; `epoch`: (`options?`) => `Codec`\<`string` \| `number`, `Dayjs`, \{ `unit?`: `EpochUnit`; \} \| `undefined`\>; `localDateTime`: () => `Codec`\<`string`, `Dayjs`, `undefined`\>; `name`: `"dayjs"`; `time`: () => `Codec`\<`string`, `Dayjs`, `undefined`\>; `yearMonth`: () => `Codec`\<`string`, `Dayjs`, `undefined`\>; `zonedDateTime`: (`options?`) => `Codec`\<`ZonedRaw`, `Dayjs`, `ZonedOptions` \| `undefined`\>; \}\> Defined in: [dayjs/src/index.ts:242](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/dayjs/src/index.ts#L242) The dayjs date family. The factories that compare instants take `{ strict: true }`. --- **Millwork** *** Millwork / @millwork-ts/dayjs / duration # Variable: duration > `const` **duration**: `Codec`\<`string` \| `number`, `Duration`, \{ `unit?`: `"iso"` \| `"s"` \| `"ms"`; \} \| `undefined`\> Defined in: [dayjs/src/index.ts:227](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/dayjs/src/index.ts#L227) ISO 8601 or a number ↔ a dayjs `Duration`. The `unit` option is `'iso'` (default), `'s'` or `'ms'`. Each unit is kept on the wire. `equals` compares years, months, weeks and days per unit and the rest by length. --- **Millwork** *** Millwork / @millwork-ts/dayjs / epoch # Variable: epoch > `const` **epoch**: `Codec`\<`number` \| `string`, `Dayjs`, \{ `unit?`: `EpochUnit`; \} \| `undefined`\> Defined in: [dayjs/src/index.ts:160](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/dayjs/src/index.ts#L160) An epoch number ↔ a local `Dayjs`. The `unit` option is `'s'`, `'ms'` (default), `'us'` or `'ns'`. --- **Millwork** *** Millwork / @millwork-ts/dayjs / localDateTime # Variable: localDateTime > `const` **localDateTime**: `Codec`\<`string`, `Dayjs`\> Defined in: [dayjs/src/index.ts:173](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/dayjs/src/index.ts#L173) `"2026-12-01T14:30:00"` ↔ a UTC `Dayjs`, so that a DST gap cannot move the wall clock. --- **Millwork** *** Millwork / @millwork-ts/dayjs / time # Variable: time > `const` **time**: `Codec`\<`string`, `Dayjs`\> Defined in: [dayjs/src/index.ts:163](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/dayjs/src/index.ts#L163) `"14:30:00"` ↔ a UTC `Dayjs` of today, so that the wall clock never moves. --- **Millwork** *** Millwork / @millwork-ts/dayjs / yearMonth # Variable: yearMonth > `const` **yearMonth**: `Codec`\<`string`, `Dayjs`\> Defined in: [dayjs/src/index.ts:213](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/dayjs/src/index.ts#L213) `"2026-12"` ↔ a `Dayjs` at local midnight of the first day of the month. --- **Millwork** *** Millwork / @millwork-ts/dayjs / zonedDateTime # Variable: zonedDateTime > `const` **zonedDateTime**: `Codec`\<`ZonedRaw`, `Dayjs`, `ZonedOptions` \| `undefined`\> Defined in: [dayjs/src/index.ts:210](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/dayjs/src/index.ts#L210) RFC 9557 `"…-05:00[America/Toronto]"` or `{ at, zone }` ↔ a `Dayjs` in that zone (`.tz()`). The wire offset must be the offset of the zone at that instant. `equals` compares the instant and the zone. --- **Millwork** *** Millwork / @millwork-ts/decimal # @millwork-ts/decimal A Millwork codec factory for exact decimals with [decimal.js](https://mikemcl.github.io/decimal.js/), [big.js](https://mikemcl.github.io/big.js/) or [bignumber.js](https://mikemcl.github.io/bignumber.js/). ## Install Install one of the three libraries. ```bash pnpm add @millwork-ts/decimal @millwork-ts/core decimal.js ``` ## Codecs This package has one factory, `decimalCodec(lib)`. Give it the `Decimal`, `Big` or `BigNumber` constructor. It gives a codec with the name `big-decimal`. Give a second argument to use another name. The default name does not clash with the `decimal` codec of `@millwork-ts/core`. ```ts import Decimal from 'decimal.js' import { decimalCodec } from '@millwork-ts/decimal' export const decimal = decimalCodec(Decimal) ``` | Codec | Value | Raw | | --------- | ------------------------------------------- | --------------------------------- | | `decimal` | an instance of the library that you give it | `"123.45"`; a number on read only | - The codec reads a decimal string. Exponent notation, such as `"1e21"`, is accepted. - The codec reads a finite number, such as `19.99`. It never writes a number. - The codec writes plain notation, such as `"1000000000000000000000"`. - `NaN` and `Infinity` are bad input. - The three libraries remove trailing zeros. `"123.4500"` writes back as `"123.45"`. Use the `scale` option to keep a fixed number of digits. - The value is frozen. The package has no ready codec, because the three libraries are optional peers. A ready codec would import a library that you possibly do not have. ## Options | Option | Type | Use | | ------- | -------- | ---------------------------------------------------------------------------------------------------------------- | | `scale` | `number` | The number of digits after the point on serialize. It never rounds: it throws a `RangeError` if digits are lost. | ## Equality `equals` uses the `eq` method of the library. `1.50` equals `1.5`. ## Example with WarpDrive Register the codecs before the store calls `transformations()`, because `transformations()` reads the registry when it runs. See the [`@millwork-ts/warp-drive` README](https://github.com/joegaudet/millwork/tree/main/packages/warp-drive#the-store). ```ts import Decimal from 'decimal.js' import { decimalCodec } from '@millwork-ts/decimal' import { registerCodecs, valueField } from '@millwork-ts/warp-drive' import { withDefaults } from '@warp-drive/core/reactive' registerCodecs({ 'big-decimal': decimalCodec(Decimal) }) export const InvoiceSchema = withDefaults({ type: 'invoice', fields: [valueField('taxRate', 'big-decimal', { scale: 4 })], }) ``` ## Interfaces - DecimalLike - DecimalOptions ## Type Aliases - DecimalLibrary ## Functions - decimalCodec --- **Millwork** *** Millwork / @millwork-ts/decimal / decimalCodec # Function: decimalCodec() > **decimalCodec**\<`T`\>(`lib`, `name?`): `Codec`\<`string` \| `number`, `T`, `DecimalOptions` \| `undefined`\> Defined in: [index.ts:28](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/decimal/src/index.ts#L28) Makes a `decimal` codec for a decimal library. Give it the `Decimal`, `Big` or `BigNumber` constructor. The raw value is a decimal string. A number is also read, but never written. The codec writes plain notation, never exponent notation. The default name is `'big-decimal'`, so that it does not clash with the `decimal` codec of `@millwork-ts/core` when an app registers both. Give `name` to use another name. ## Type Parameters ### T `T` *extends* `DecimalLike` ## Parameters ### lib `DecimalLibrary`\<`T`\> ### name? `string` = `'big-decimal'` ## Returns `Codec`\<`string` \| `number`, `T`, `DecimalOptions` \| `undefined`\> --- **Millwork** *** Millwork / @millwork-ts/decimal / DecimalLike # Interface: DecimalLike Defined in: [index.ts:4](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/decimal/src/index.ts#L4) The methods that the codec uses. `decimal.js`, `big.js` and `bignumber.js` all have them. ## Methods ### eq() > **eq**(`other`): `boolean` Defined in: [index.ts:8](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/decimal/src/index.ts#L8) Returns `true` if the other number is equal. #### Parameters ##### other `never` #### Returns `boolean` *** ### toFixed() > **toFixed**(`scale?`): `string` Defined in: [index.ts:6](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/decimal/src/index.ts#L6) Writes the number with `scale` digits after the point. #### Parameters ##### scale? `number` #### Returns `string` --- **Millwork** *** Millwork / @millwork-ts/decimal / DecimalOptions # Interface: DecimalOptions Defined in: [index.ts:15](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/decimal/src/index.ts#L15) Options of a codec from `decimalCodec`. ## Properties ### scale? > `optional` **scale?**: `number` Defined in: [index.ts:17](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/decimal/src/index.ts#L17) The number of digits after the point on serialize. It throws a `RangeError` if digits are lost. --- **Millwork** *** Millwork / @millwork-ts/decimal / DecimalLibrary # Type Alias: DecimalLibrary\ > **DecimalLibrary**\<`T`\> = new (`value`) => `T` Defined in: [index.ts:12](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/decimal/src/index.ts#L12) A decimal library constructor: `Decimal`, `Big` or `BigNumber`. ## Type Parameters ### T `T` *extends* `DecimalLike` ## Parameters ### value `string` ## Returns `T` --- **Millwork** *** Millwork / @millwork-ts/dinero # @millwork-ts/dinero Millwork codecs for money as [dinero.js](https://dinerojs.com) v2 objects. ## Install ```bash pnpm add @millwork-ts/dinero @millwork-ts/core dinero.js ``` ## Codecs | Codec | Value | Raw | | -------- | ------------------------------------ | ---------------------- | | `dinero` | `Dinero` or `Dinero` | one of five wire forms | The `wire` option selects the wire form. The names are the same as the `money` codec of `@millwork-ts/core`. | `wire` | Raw | | ---------------- | ------------------------------------------------------------------------------------------ | | `'minor'` | `{ "amount": 1999, "currency": "USD" }` (the default) | | `'decimal'` | `{ "amount": "19.99", "currency": "USD" }` | | `'snapshot'` | `{ "amount": 1999, "currency": { "code": "USD", "base": 10, "exponent": 2 }, "scale": 2 }` | | `'minor-scaled'` | `{ "amount": 19990, "currency": "USD", "scale": 3 }` | | `'amount'` | `1999`, with the currency in the `currency` option | - The codec reads a number amount, such as `19.99`, on the `'decimal'` wire. It never writes a float. - An amount that is not a safe integer is written as a string, such as `"9007199254740993"`. - The `'minor'` and `'amount'` wires write the amount at the exponent of the currency. If digits are lost, `serialize` throws a `RangeError`. - The `'snapshot'` wire keeps the currency object of the wire. The base must be 10. ## Options | Option | Type | Use | | ------------ | -------------------------- | ------------------------------------------------------------------ | | `wire` | `MoneyWire` | The wire form. The default is `'minor'`. | | `currency` | `string` | The currency code for the `'amount'` wire. | | `currencies` | `Record` | More currencies, keyed by code. They replace a dinero.js currency. | | `bigint` | `boolean` | Make every amount a `bigint`. | The codec finds a currency code in the ISO 4217 currency objects of `dinero.js`. A lower-case code is accepted. ### Big amounts Without the `bigint` option, the amount is a `number` when it is a safe integer. Other amounts use `dinero.js/bigint`, and the value is a `Dinero`. dinero.js cannot add a `Dinero` to a `Dinero`. If your amounts can be larger than `Number.MAX_SAFE_INTEGER`, set `bigint: true`. Then all values have one amount type. ## Equality `equals` is true when the currency codes are the same and the amounts are equal at a common scale. `19.99 USD` at scale 2 equals `19.990 USD` at scale 3. It uses the dinero.js `equal` function. ## Example with WarpDrive Register the codecs before the store calls `transformations()`, because `transformations()` reads the registry when it runs. See the [`@millwork-ts/warp-drive` README](https://github.com/joegaudet/millwork/tree/main/packages/warp-drive#the-store). ```ts import { codecs } from '@millwork-ts/dinero' import { registerCodecs, valueField } from '@millwork-ts/warp-drive' import { withDefaults } from '@warp-drive/core/reactive' registerCodecs(codecs) export const OrderSchema = withDefaults({ type: 'order', fields: [valueField('total', 'dinero', { wire: 'decimal' })], }) ``` ## Interfaces - DineroOptions ## Type Aliases - AnyDinero - Currency - DineroRaw ## Variables - codecs - dinero --- **Millwork** *** Millwork / @millwork-ts/dinero / DineroOptions # Interface: DineroOptions Defined in: [index.ts:19](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/dinero/src/index.ts#L19) Options of the `dinero` codec. ## Properties ### bigint? > `optional` **bigint?**: `boolean` Defined in: [index.ts:27](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/dinero/src/index.ts#L27) Make every amount a `bigint`. Without it, only an amount that is not a safe integer is a `bigint`. *** ### currencies? > `optional` **currencies?**: `Readonly`\<`Record`\<`string`, `Currency`\>\> Defined in: [index.ts:25](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/dinero/src/index.ts#L25) More currencies, keyed by code. They replace the dinero.js currency of the same code. *** ### currency? > `optional` **currency?**: `string` Defined in: [index.ts:23](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/dinero/src/index.ts#L23) The currency code for the `'amount'` wire, which has a bare amount in minor units. *** ### wire? > `optional` **wire?**: `MoneyWire` Defined in: [index.ts:21](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/dinero/src/index.ts#L21) The wire form. The default is `'minor'`: `{ amount: 1999, currency: 'USD' }`. --- **Millwork** *** Millwork / @millwork-ts/dinero / AnyDinero # Type Alias: AnyDinero > **AnyDinero** = `Dinero`\<`number`\> \| `Dinero`\<`bigint`\> Defined in: [index.ts:13](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/dinero/src/index.ts#L13) A dinero.js v2 object. The amount is a `number`, or a `bigint` for a large amount. --- **Millwork** *** Millwork / @millwork-ts/dinero / Currency # Type Alias: Currency > **Currency** = `DineroCurrency`\<`number`\> Defined in: [index.ts:16](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/dinero/src/index.ts#L16) A currency in the form of the dinero.js currency objects. --- **Millwork** *** Millwork / @millwork-ts/dinero / DineroRaw # Type Alias: DineroRaw > **DineroRaw** = \{ `amount`: `number` \| `string`; `currency`: `string`; `scale?`: `number`; \} \| \{ `amount`: `number` \| `string`; `currency`: `Currency`; `scale`: `number`; \} \| `number` \| `string` Defined in: [index.ts:31](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/dinero/src/index.ts#L31) The raw forms of the `dinero` codec. --- **Millwork** *** Millwork / @millwork-ts/dinero / codecs # Variable: codecs > `const` **codecs**: `Readonly`\<\{ `dinero`: `Codec`\<`DineroRaw`, `AnyDinero`, `DineroOptions` \| `undefined`\>; \}\> Defined in: [index.ts:110](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/dinero/src/index.ts#L110) Each codec in this package, keyed by its name. --- **Millwork** *** Millwork / @millwork-ts/dinero / dinero # Variable: dinero > `const` **dinero**: `Codec`\<`DineroRaw`, `AnyDinero`, `DineroOptions` \| `undefined`\> Defined in: [index.ts:44](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/dinero/src/index.ts#L44) The `dinero` codec: money as a dinero.js v2 object. It has the same five wire forms as the `money` codec of core. It reads a number amount on the `'decimal'` wire, but it never writes a float. An integer that is not a safe integer is written as a string. --- **Millwork** *** Millwork / @millwork-ts/geo # @millwork-ts/geo Millwork codecs for WKT with [betterknown](https://github.com/placemark/betterknown) and for geohash with [ngeohash](https://github.com/sunng87/node-geohash). ## Install Install the peer of each codec that you use. ```bash pnpm add @millwork-ts/geo @millwork-ts/core betterknown ngeohash ``` ## Entry points | Entry | Codecs | Peers | | -------------------------- | -------------------------- | ------------------------- | | `@millwork-ts/geo` | `wkt`, `geohash`, `codecs` | `betterknown`, `ngeohash` | | `@millwork-ts/geo/wkt` | `wkt` | `betterknown` | | `@millwork-ts/geo/geohash` | `geohash` | `ngeohash` | The root entry loads both peers. If you use only one codec, import its entry. ## Codecs | Codec | Value | Raw | | --------- | ----------------------------------------- | ----------------------- | | `wkt` | a frozen GeoJSON geometry | `"POINT(-79.38 43.65)"` | | `geohash` | a frozen `{ lat, lng, error, precision }` | `"dpz83d"` | ### wkt - The codec writes WKT in the betterknown form, with a space after the keyword, such as `"POINT (1 2)"`. It reads both `"POINT(1 2)"` and `"POINT (1 2)"`. - The codec reads lower-case keywords, such as `"point(1 2)"`, and writes upper case. - The codec does not read EWKT, such as `"SRID=4326;POINT(1 2)"`. GeoJSON has no SRID, so a write would remove it. - There is no WKB codec. PostGIS hex WKB is EWKB with an SRID, so a write would remove the SRID. - The codec does not read `EMPTY` geometries, such as `"POINT EMPTY"`. They are bad input, because betterknown gives no geometry for them. - betterknown needs no `Buffer`, so the entry loads in a browser. ### geohash - `lat` and `lng` are the center of the cell. `error` is the half-size of the cell in degrees. `precision` is the length of the hash. - The codec reads upper case and writes lower case. ## Options | Codec | Option | Type | Use | | --------- | ----------- | -------- | ---------------------------------------------------------------------------------------- | | `geohash` | `precision` | `number` | The length of the hash that the codec writes. The default is the precision of the value. | ## Equality - `wkt`: `equals` compares the WKT form. - `geohash`: `equals` compares the point and the precision. `"dpz83d"` equals `"DPZ83D"`. `"dpz83"` is a different cell. ## Example with WarpDrive Register the codecs before the store calls `transformations()`, because `transformations()` reads the registry when it runs. See the [`@millwork-ts/warp-drive` README](https://github.com/joegaudet/millwork/tree/main/packages/warp-drive#the-store). ```ts import { codecs } from '@millwork-ts/geo' import { registerCodecs, valueField } from '@millwork-ts/warp-drive' import { withDefaults } from '@warp-drive/core/reactive' registerCodecs(codecs) export const StoreSchema = withDefaults({ type: 'store', fields: [valueField('area', 'wkt'), valueField('cell', 'geohash', { precision: 7 })], }) ``` ## Interfaces - GeohashOptions - GeohashValue ## Variables - codecs - geohash - wkt --- **Millwork** *** Millwork / @millwork-ts/geo / GeohashOptions # Interface: GeohashOptions Defined in: [geohash.ts:14](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/geo/src/geohash.ts#L14) Options of the `geohash` codec. ## Properties ### precision? > `optional` **precision?**: `number` Defined in: [geohash.ts:16](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/geo/src/geohash.ts#L16) The number of characters on serialize. The default is the precision of the value. --- **Millwork** *** Millwork / @millwork-ts/geo / GeohashValue # Interface: GeohashValue Defined in: [geohash.ts:5](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/geo/src/geohash.ts#L5) A decoded geohash: the center of its cell, the half-size of the cell, and the length. ## Properties ### error > `readonly` **error**: `object` Defined in: [geohash.ts:8](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/geo/src/geohash.ts#L8) #### lat > `readonly` **lat**: `number` #### lng > `readonly` **lng**: `number` *** ### lat > `readonly` **lat**: `number` Defined in: [geohash.ts:6](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/geo/src/geohash.ts#L6) *** ### lng > `readonly` **lng**: `number` Defined in: [geohash.ts:7](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/geo/src/geohash.ts#L7) *** ### precision > `readonly` **precision**: `number` Defined in: [geohash.ts:10](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/geo/src/geohash.ts#L10) The number of characters in the hash that was read. --- **Millwork** *** Millwork / @millwork-ts/geo / codecs # Variable: codecs > `const` **codecs**: `Readonly`\<\{ `geohash`: `Codec`\<`string`, `GeohashValue`, `GeohashOptions` \| `undefined`\>; `wkt`: `Codec`\<`string`, `Geometry`, `undefined`\>; \}\> Defined in: [index.ts:11](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/geo/src/index.ts#L11) The codecs of this package, keyed by name. This entry loads `betterknown` and `ngeohash`. To load only one peer, import from `@millwork-ts/geo/wkt` or `@millwork-ts/geo/geohash`. --- **Millwork** *** Millwork / @millwork-ts/geo / geohash # Variable: geohash > `const` **geohash**: `Codec`\<`string`, `GeohashValue`, `GeohashOptions` \| `undefined`\> Defined in: [geohash.ts:25](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/geo/src/geohash.ts#L25) The `geohash` codec: a base32 geohash to a frozen `{ lat, lng, error, precision }`, with ngeohash. Serialize writes lower case. `equals` compares the point and the precision. --- **Millwork** *** Millwork / @millwork-ts/geo / wkt # Variable: wkt > `const` **wkt**: `Codec`\<`string`, `Geometry`, `undefined`\> Defined in: [wkt.ts:17](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/geo/src/wkt.ts#L17) The `wkt` codec: a WKT string (`"POINT(-79.38 43.65)"`) to a frozen GeoJSON geometry, with betterknown. It needs no `Buffer`, so it loads in a browser. Serialize writes WKT in the betterknown form (`"POINT (-79.38 43.65)"`). `equals` compares the WKT form. The codec does not read EWKT (`SRID=4326;…`), because GeoJSON has no SRID and a write would drop it. It does not read `EMPTY`, because betterknown gives no geometry for it. --- **Millwork** *** Millwork / @millwork-ts/ip # @millwork-ts/ip Millwork codecs for IP addresses and CIDR ranges with [ipaddr.js](https://github.com/whitequark/ipaddr.js). ## Install ```bash pnpm add @millwork-ts/ip @millwork-ts/core ipaddr.js ``` ## Codecs | Codec | Value | Raw | | ------ | ---------------------------------------- | ------------------------ | | `ip` | a frozen ipaddr.js `IPv4` or `IPv6` | `"192.168.0.1"`, `"::1"` | | `cidr` | a frozen `{ address, prefix, contains }` | `"10.0.0.0/8"` | - IPv4 must have the four-part decimal form. The codecs do not read `"127.1"`, octal or hex forms, because different tools read these forms differently. - The `ip` codec writes IPv6 in the short form of RFC 5952, such as `"2001:db8::1"`. - The `cidr` codec keeps host bits as the server sent them: `"10.1.2.3/8"` stays `"10.1.2.3/8"`. - `range.contains(address)` takes an address value or a string. It gives `false` for a bad address or for an address of a different kind. It does not throw. - The package exports `ipaddr`, the ipaddr.js module. ## Options | Codec | Option | Type | Use | | ----- | ----------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------- | | `ip` | `unmapIPv4` | `boolean` | Read an IPv4-mapped IPv6 address, such as `"::ffff:10.0.0.1"`, as IPv4, and write it as IPv4: `"10.0.0.1"`. The default is `false`. | ## Equality - `ip`: `equals` compares the kind and the normalized form. `"2001:DB8::1"` equals `"2001:db8:0:0:0:0:0:1"`. An IPv4 address does not equal its IPv4-mapped IPv6 form. - `cidr`: `equals` compares the address and the prefix. ## Example with WarpDrive Register the codecs before the store calls `transformations()`, because `transformations()` reads the registry when it runs. See the [`@millwork-ts/warp-drive` README](https://github.com/joegaudet/millwork/tree/main/packages/warp-drive#the-store). ```ts import { codecs } from '@millwork-ts/ip' import { registerCodecs, valueField } from '@millwork-ts/warp-drive' import { withDefaults } from '@warp-drive/core/reactive' registerCodecs(codecs) export const FirewallRuleSchema = withDefaults({ type: 'firewall-rule', fields: [valueField('source', 'cidr'), valueField('lastClient', 'ip', { unmapIPv4: true })], }) ``` ## Namespaces - ipaddr ## Interfaces - Cidr - IpOptions ## Type Aliases - IpAddress ## Variables - cidr - codecs - ip --- **Millwork** *** Millwork / @millwork-ts/ip / Cidr # Interface: Cidr Defined in: [packages/ip/src/index.ts:19](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/ip/src/index.ts#L19) A CIDR range. The value is a frozen plain object. ## Properties ### address > `readonly` **address**: `IpAddress` Defined in: [packages/ip/src/index.ts:20](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/ip/src/index.ts#L20) *** ### prefix > `readonly` **prefix**: `number` Defined in: [packages/ip/src/index.ts:21](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/ip/src/index.ts#L21) ## Methods ### contains() > **contains**(`address`): `boolean` Defined in: [packages/ip/src/index.ts:23](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/ip/src/index.ts#L23) Gives `true` when the address is in the range. A bad address or another kind gives `false`. #### Parameters ##### address `string` \| `IpAddress` #### Returns `boolean` --- **Millwork** *** Millwork / @millwork-ts/ip / IpOptions # Interface: IpOptions Defined in: [packages/ip/src/index.ts:10](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/ip/src/index.ts#L10) Options of the `ip` codec. ## Properties ### unmapIPv4? > `optional` **unmapIPv4?**: `boolean` Defined in: [packages/ip/src/index.ts:15](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/ip/src/index.ts#L15) Read and write an IPv4-mapped IPv6 address (`::ffff:10.0.0.1`) as IPv4 (`10.0.0.1`). The default is `false`: the address stays IPv6. --- **Millwork** *** Millwork / @millwork-ts/ip / ipaddr # ipaddr ## Classes - IPv4 - IPv6 ## Functions - fromByteArray - isValid - isValidCIDR - parse - parseCIDR - process - subnetMatch --- **Millwork** *** Millwork / @millwork-ts/ip / ipaddr / IPv4 # Class: IPv4 Defined in: node\_modules/.pnpm/ipaddr.js@2.5.0/node\_modules/ipaddr.js/lib/ipaddr.d.ts:27 ## Extends - `IP` ## Constructors ### Constructor > **new IPv4**(`octets`): `IPv4` Defined in: node\_modules/.pnpm/ipaddr.js@2.5.0/node\_modules/ipaddr.js/lib/ipaddr.d.ts:38 #### Parameters ##### octets `number`[] #### Returns `IPv4` #### Overrides `IP.constructor` ## Properties ### octets > **octets**: `number`[] Defined in: node\_modules/.pnpm/ipaddr.js@2.5.0/node\_modules/ipaddr.js/lib/ipaddr.d.ts:39 ## Methods ### kind() > **kind**(): `"ipv4"` Defined in: node\_modules/.pnpm/ipaddr.js@2.5.0/node\_modules/ipaddr.js/lib/ipaddr.d.ts:41 #### Returns `"ipv4"` *** ### match() > **match**(`what`, `bits?`): `boolean` Defined in: node\_modules/.pnpm/ipaddr.js@2.5.0/node\_modules/ipaddr.js/lib/ipaddr.d.ts:42 #### Parameters ##### what `IPv4` \| `IPv6` \| \`IPv4` \| [`IPv6`, `number`\] ##### bits? `number` #### Returns `boolean` *** ### prefixLengthFromSubnetMask() > **prefixLengthFromSubnetMask**(): `number` \| `null` Defined in: node\_modules/.pnpm/ipaddr.js@2.5.0/node\_modules/ipaddr.js/lib/ipaddr.d.ts:12 #### Returns `number` \| `null` #### Inherited from `IP.prefixLengthFromSubnetMask` *** ### range() > **range**(): `IPv4Range` Defined in: node\_modules/.pnpm/ipaddr.js@2.5.0/node\_modules/ipaddr.js/lib/ipaddr.d.ts:43 #### Returns `IPv4Range` *** ### subnetMatch() > **subnetMatch**(`rangeList`, `defaultName?`): `string` Defined in: node\_modules/.pnpm/ipaddr.js@2.5.0/node\_modules/ipaddr.js/lib/ipaddr.d.ts:44 #### Parameters ##### rangeList `RangeList`\<`IPv4`\> ##### defaultName? `string` #### Returns `string` *** ### toByteArray() > **toByteArray**(): `number`[] Defined in: node\_modules/.pnpm/ipaddr.js@2.5.0/node\_modules/ipaddr.js/lib/ipaddr.d.ts:13 #### Returns `number`[] #### Inherited from `IP.toByteArray` *** ### toIPv4MappedAddress() > **toIPv4MappedAddress**(): `IPv6` Defined in: node\_modules/.pnpm/ipaddr.js@2.5.0/node\_modules/ipaddr.js/lib/ipaddr.d.ts:45 #### Returns `IPv6` *** ### toNormalizedString() > **toNormalizedString**(): `string` Defined in: node\_modules/.pnpm/ipaddr.js@2.5.0/node\_modules/ipaddr.js/lib/ipaddr.d.ts:14 #### Returns `string` #### Inherited from `IP.toNormalizedString` *** ### toString() > **toString**(): `string` Defined in: node\_modules/.pnpm/ipaddr.js@2.5.0/node\_modules/ipaddr.js/lib/ipaddr.d.ts:15 #### Returns `string` #### Inherited from `IP.toString` *** ### broadcastAddressFromCIDR() > `static` **broadcastAddressFromCIDR**(`addr`): `IPv4` Defined in: node\_modules/.pnpm/ipaddr.js@2.5.0/node\_modules/ipaddr.js/lib/ipaddr.d.ts:28 #### Parameters ##### addr `string` #### Returns `IPv4` *** ### isIPv4() > `static` **isIPv4**(`addr`): `boolean` Defined in: node\_modules/.pnpm/ipaddr.js@2.5.0/node\_modules/ipaddr.js/lib/ipaddr.d.ts:29 #### Parameters ##### addr `string` #### Returns `boolean` *** ### isValid() > `static` **isValid**(`addr`): `boolean` Defined in: node\_modules/.pnpm/ipaddr.js@2.5.0/node\_modules/ipaddr.js/lib/ipaddr.d.ts:30 #### Parameters ##### addr `string` #### Returns `boolean` *** ### isValidCIDR() > `static` **isValidCIDR**(`addr`): `boolean` Defined in: node\_modules/.pnpm/ipaddr.js@2.5.0/node\_modules/ipaddr.js/lib/ipaddr.d.ts:31 #### Parameters ##### addr `string` #### Returns `boolean` *** ### isValidCIDRFourPartDecimal() > `static` **isValidCIDRFourPartDecimal**(`addr`): `boolean` Defined in: node\_modules/.pnpm/ipaddr.js@2.5.0/node\_modules/ipaddr.js/lib/ipaddr.d.ts:33 #### Parameters ##### addr `string` #### Returns `boolean` *** ### isValidFourPartDecimal() > `static` **isValidFourPartDecimal**(`addr`): `boolean` Defined in: node\_modules/.pnpm/ipaddr.js@2.5.0/node\_modules/ipaddr.js/lib/ipaddr.d.ts:32 #### Parameters ##### addr `string` #### Returns `boolean` *** ### networkAddressFromCIDR() > `static` **networkAddressFromCIDR**(`addr`): `IPv4` Defined in: node\_modules/.pnpm/ipaddr.js@2.5.0/node\_modules/ipaddr.js/lib/ipaddr.d.ts:34 #### Parameters ##### addr `string` #### Returns `IPv4` *** ### parse() > `static` **parse**(`addr`): `IPv4` Defined in: node\_modules/.pnpm/ipaddr.js@2.5.0/node\_modules/ipaddr.js/lib/ipaddr.d.ts:35 #### Parameters ##### addr `string` #### Returns `IPv4` *** ### parseCIDR() > `static` **parseCIDR**(`addr`): \[`IPv4`, `number`\] Defined in: node\_modules/.pnpm/ipaddr.js@2.5.0/node\_modules/ipaddr.js/lib/ipaddr.d.ts:36 #### Parameters ##### addr `string` #### Returns \[`IPv4`, `number`\] *** ### subnetMaskFromPrefixLength() > `static` **subnetMaskFromPrefixLength**(`prefix`): `IPv4` Defined in: node\_modules/.pnpm/ipaddr.js@2.5.0/node\_modules/ipaddr.js/lib/ipaddr.d.ts:37 #### Parameters ##### prefix `number` #### Returns `IPv4` --- **Millwork** *** Millwork / @millwork-ts/ip / ipaddr / IPv6 # Class: IPv6 Defined in: node\_modules/.pnpm/ipaddr.js@2.5.0/node\_modules/ipaddr.js/lib/ipaddr.d.ts:48 ## Extends - `IP` ## Constructors ### Constructor > **new IPv6**(`parts`): `IPv6` Defined in: node\_modules/.pnpm/ipaddr.js@2.5.0/node\_modules/ipaddr.js/lib/ipaddr.d.ts:57 #### Parameters ##### parts `number`[] #### Returns `IPv6` #### Overrides `IP.constructor` ## Properties ### parts > **parts**: `number`[] Defined in: node\_modules/.pnpm/ipaddr.js@2.5.0/node\_modules/ipaddr.js/lib/ipaddr.d.ts:58 *** ### zoneId? > `optional` **zoneId?**: `string` Defined in: node\_modules/.pnpm/ipaddr.js@2.5.0/node\_modules/ipaddr.js/lib/ipaddr.d.ts:59 ## Methods ### isIPv4MappedAddress() > **isIPv4MappedAddress**(): `boolean` Defined in: node\_modules/.pnpm/ipaddr.js@2.5.0/node\_modules/ipaddr.js/lib/ipaddr.d.ts:61 #### Returns `boolean` *** ### kind() > **kind**(): `"ipv6"` Defined in: node\_modules/.pnpm/ipaddr.js@2.5.0/node\_modules/ipaddr.js/lib/ipaddr.d.ts:62 #### Returns `"ipv6"` *** ### match() > **match**(`what`, `bits?`): `boolean` Defined in: node\_modules/.pnpm/ipaddr.js@2.5.0/node\_modules/ipaddr.js/lib/ipaddr.d.ts:63 #### Parameters ##### what `IPv4` \| `IPv6` \| \[`IPv4` \| `IPv6`, `number`\] ##### bits? `number` #### Returns `boolean` *** ### prefixLengthFromSubnetMask() > **prefixLengthFromSubnetMask**(): `number` \| `null` Defined in: node\_modules/.pnpm/ipaddr.js@2.5.0/node\_modules/ipaddr.js/lib/ipaddr.d.ts:12 #### Returns `number` \| `null` #### Inherited from `IP.prefixLengthFromSubnetMask` *** ### range() > **range**(): `IPv6Range` Defined in: node\_modules/.pnpm/ipaddr.js@2.5.0/node\_modules/ipaddr.js/lib/ipaddr.d.ts:64 #### Returns `IPv6Range` *** ### subnetMatch() > **subnetMatch**(`rangeList`, `defaultName?`): `string` Defined in: node\_modules/.pnpm/ipaddr.js@2.5.0/node\_modules/ipaddr.js/lib/ipaddr.d.ts:65 #### Parameters ##### rangeList `RangeList`\<`IPv6`\> ##### defaultName? `string` #### Returns `string` *** ### toByteArray() > **toByteArray**(): `number`[] Defined in: node\_modules/.pnpm/ipaddr.js@2.5.0/node\_modules/ipaddr.js/lib/ipaddr.d.ts:13 #### Returns `number`[] #### Inherited from `IP.toByteArray` *** ### toIPv4Address() > **toIPv4Address**(): `IPv4` Defined in: node\_modules/.pnpm/ipaddr.js@2.5.0/node\_modules/ipaddr.js/lib/ipaddr.d.ts:66 #### Returns `IPv4` *** ### toNormalizedString() > **toNormalizedString**(): `string` Defined in: node\_modules/.pnpm/ipaddr.js@2.5.0/node\_modules/ipaddr.js/lib/ipaddr.d.ts:14 #### Returns `string` #### Inherited from `IP.toNormalizedString` *** ### toRFC5952String() > **toRFC5952String**(): `string` Defined in: node\_modules/.pnpm/ipaddr.js@2.5.0/node\_modules/ipaddr.js/lib/ipaddr.d.ts:67 #### Returns `string` *** ### toString() > **toString**(): `string` Defined in: node\_modules/.pnpm/ipaddr.js@2.5.0/node\_modules/ipaddr.js/lib/ipaddr.d.ts:15 #### Returns `string` #### Inherited from `IP.toString` *** ### broadcastAddressFromCIDR() > `static` **broadcastAddressFromCIDR**(`addr`): `IPv6` Defined in: node\_modules/.pnpm/ipaddr.js@2.5.0/node\_modules/ipaddr.js/lib/ipaddr.d.ts:49 #### Parameters ##### addr `string` #### Returns `IPv6` *** ### isIPv6() > `static` **isIPv6**(`addr`): `boolean` Defined in: node\_modules/.pnpm/ipaddr.js@2.5.0/node\_modules/ipaddr.js/lib/ipaddr.d.ts:50 #### Parameters ##### addr `string` #### Returns `boolean` *** ### isValid() > `static` **isValid**(`addr`): `boolean` Defined in: node\_modules/.pnpm/ipaddr.js@2.5.0/node\_modules/ipaddr.js/lib/ipaddr.d.ts:51 #### Parameters ##### addr `string` #### Returns `boolean` *** ### isValidCIDR() > `static` **isValidCIDR**(`addr`): `boolean` Defined in: node\_modules/.pnpm/ipaddr.js@2.5.0/node\_modules/ipaddr.js/lib/ipaddr.d.ts:52 #### Parameters ##### addr `string` #### Returns `boolean` *** ### networkAddressFromCIDR() > `static` **networkAddressFromCIDR**(`addr`): `IPv6` Defined in: node\_modules/.pnpm/ipaddr.js@2.5.0/node\_modules/ipaddr.js/lib/ipaddr.d.ts:53 #### Parameters ##### addr `string` #### Returns `IPv6` *** ### parse() > `static` **parse**(`addr`): `IPv6` Defined in: node\_modules/.pnpm/ipaddr.js@2.5.0/node\_modules/ipaddr.js/lib/ipaddr.d.ts:54 #### Parameters ##### addr `string` #### Returns `IPv6` *** ### parseCIDR() > `static` **parseCIDR**(`addr`): \[`IPv6`, `number`\] Defined in: node\_modules/.pnpm/ipaddr.js@2.5.0/node\_modules/ipaddr.js/lib/ipaddr.d.ts:55 #### Parameters ##### addr `string` #### Returns \[`IPv6`, `number`\] *** ### subnetMaskFromPrefixLength() > `static` **subnetMaskFromPrefixLength**(`prefix`): `IPv6` Defined in: node\_modules/.pnpm/ipaddr.js@2.5.0/node\_modules/ipaddr.js/lib/ipaddr.d.ts:56 #### Parameters ##### prefix `number` #### Returns `IPv6` --- **Millwork** *** Millwork / @millwork-ts/ip / ipaddr / fromByteArray # Function: fromByteArray() > **fromByteArray**(`bytes`): `IPv4` \| `IPv6` Defined in: node\_modules/.pnpm/ipaddr.js@2.5.0/node\_modules/ipaddr.js/lib/ipaddr.d.ts:19 ## Parameters ### bytes `number`[] ## Returns `IPv4` \| `IPv6` --- **Millwork** *** Millwork / @millwork-ts/ip / ipaddr / isValid # Function: isValid() > **isValid**(`addr`): `boolean` Defined in: node\_modules/.pnpm/ipaddr.js@2.5.0/node\_modules/ipaddr.js/lib/ipaddr.d.ts:20 ## Parameters ### addr `string` ## Returns `boolean` --- **Millwork** *** Millwork / @millwork-ts/ip / ipaddr / isValidCIDR # Function: isValidCIDR() > **isValidCIDR**(`addr`): `boolean` Defined in: node\_modules/.pnpm/ipaddr.js@2.5.0/node\_modules/ipaddr.js/lib/ipaddr.d.ts:21 ## Parameters ### addr `string` ## Returns `boolean` --- **Millwork** *** Millwork / @millwork-ts/ip / ipaddr / parse # Function: parse() > **parse**(`addr`): `IPv4` \| `IPv6` Defined in: node\_modules/.pnpm/ipaddr.js@2.5.0/node\_modules/ipaddr.js/lib/ipaddr.d.ts:22 ## Parameters ### addr `string` ## Returns `IPv4` \| `IPv6` --- **Millwork** *** Millwork / @millwork-ts/ip / ipaddr / parseCIDR # Function: parseCIDR() > **parseCIDR**(`mask`): \[`IPv4` \| `IPv6`, `number`\] Defined in: node\_modules/.pnpm/ipaddr.js@2.5.0/node\_modules/ipaddr.js/lib/ipaddr.d.ts:23 ## Parameters ### mask `string` ## Returns \[`IPv4` \| `IPv6`, `number`\] --- **Millwork** *** Millwork / @millwork-ts/ip / ipaddr / process # Function: process() > **process**(`addr`): `IPv4` \| `IPv6` Defined in: node\_modules/.pnpm/ipaddr.js@2.5.0/node\_modules/ipaddr.js/lib/ipaddr.d.ts:24 ## Parameters ### addr `string` ## Returns `IPv4` \| `IPv6` --- **Millwork** *** Millwork / @millwork-ts/ip / ipaddr / subnetMatch # Function: subnetMatch() > **subnetMatch**(`addr`, `rangeList`, `defaultName?`): `string` Defined in: node\_modules/.pnpm/ipaddr.js@2.5.0/node\_modules/ipaddr.js/lib/ipaddr.d.ts:25 ## Parameters ### addr `IPv4` \| `IPv6` ### rangeList `RangeList`\<`IPv4` \| `IPv6`\> ### defaultName? `string` ## Returns `string` --- **Millwork** *** Millwork / @millwork-ts/ip / IpAddress # Type Alias: IpAddress > **IpAddress** = `IPv4` \| `IPv6` Defined in: [packages/ip/src/index.ts:7](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/ip/src/index.ts#L7) An IPv4 or IPv6 address of ipaddr.js. The codec freezes it. --- **Millwork** *** Millwork / @millwork-ts/ip / cidr # Variable: cidr > `const` **cidr**: `Codec`\<`string`, `Cidr`, `undefined`\> Defined in: [packages/ip/src/index.ts:86](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/ip/src/index.ts#L86) The `cidr` codec: `"10.0.0.0/8"` to a frozen `{ address, prefix, contains }`. The address keeps host bits as the server sent them (`10.1.2.3/8` stays `10.1.2.3/8`). --- **Millwork** *** Millwork / @millwork-ts/ip / codecs # Variable: codecs > `const` **codecs**: `Readonly`\<\{ `cidr`: `Codec`\<`string`, `Cidr`, `undefined`\>; `ip`: `Codec`\<`string`, `IpAddress`, `IpOptions` \| `undefined`\>; \}\> Defined in: [packages/ip/src/index.ts:101](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/ip/src/index.ts#L101) The codecs of this package, keyed by name. --- **Millwork** *** Millwork / @millwork-ts/ip / ip # Variable: ip > `const` **ip**: `Codec`\<`string`, `IpAddress`, `IpOptions` \| `undefined`\> Defined in: [packages/ip/src/index.ts:52](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/ip/src/index.ts#L52) The `ip` codec: `"192.168.0.1"` or `"::1"` to a frozen ipaddr.js `IPv4` or `IPv6`. IPv6 is written in the short RFC 5952 form. `equals` compares the kind and the normalized form. --- **Millwork** *** Millwork / @millwork-ts/luxon # @millwork-ts/luxon Millwork codecs for [luxon](https://moment.github.io/luxon/). Each codec reads a wire value into a luxon `DateTime`, `Duration` or `Interval`, and writes it back. ## Install ```bash pnpm add @millwork-ts/core @millwork-ts/luxon luxon ``` ## Codecs Each codec is a named export. The `codecs` record has each codec two times: with its kind as the key (`date`) and with the adapter prefix (`luxon:date`). The `name` of each codec has the prefix. If your app registers two date families, use the prefixed keys. | Export | Key | Wire | Value | | --------------- | ---------------- | -------------------------------------------------------------- | -------------------------------------- | | `date` | `date` | `"2026-12-01"` | `DateTime`, local midnight of that day | | `datetime` | `datetime` | RFC 3339, `"2026-12-01T14:30:00-05:00"` or `"…Z"` | `DateTime`, local zone | | `epoch` | `epoch` | a number, or a string for large values | `DateTime`, local zone | | `time` | `time` | `"14:30"`, `"14:30:00.123"` | `DateTime` of today, in UTC | | `localDateTime` | `local-datetime` | `"2026-12-01T14:30:00"` | `DateTime` in UTC | | `zonedDateTime` | `zoned-datetime` | `"2026-12-01T14:30:00-05:00[America/Toronto]"`, `{ at, zone }` | `DateTime` in that zone | | `yearMonth` | `year-month` | `"2026-12"` | `DateTime`, local midnight of day 1 | | `duration` | `duration` | ISO 8601 `"PT1H30M"`, or a number | `Duration` | | `interval` | `interval` | `"a/b"`, `"a/PT1H"`, `"P1D/b"`, `{ start, end }` | `Interval` | Options: - `datetime`: `keepOffset: true` keeps the wire offset in the value (luxon `setZone: true`), and `serialize` writes that offset. Without it, `serialize` writes `Z`. - `epoch`: `unit` is `'s'`, `'ms'` (the default), `'us'` or `'ns'`. `serialize` writes a number when it is a safe integer. It writes `'ns'` as a string. luxon keeps milliseconds only. - `zonedDateTime`: `wire: 'object'` writes `{ at, zone }`. The default writes RFC 9557. Both are read. The wire offset must be the offset of the zone at that instant, or the value is bad. - `duration`: `unit` is `'iso'` (the default), `'s'` or `'ms'`. A duration with years, months or weeks cannot become a number, so `serialize` throws a `RangeError`. A day is 24 hours. - `interval`: `wire: 'object'` writes `{ start, end }`. A duration is added in UTC. An open interval (`..`) is bad input. `time` and `local-datetime` values are in UTC, so a DST gap in the local zone cannot move the wall clock. To put one in a zone, use `setZone(zone, { keepLocalTime: true })`. Bad wire input gives `undefined` and a report to `onInvalid`. A value of the wrong type, or an invalid luxon value, makes `serialize` throw a `TypeError`. ## Equality - `datetime`, `epoch` and `interval` compare the instant (`+a === +b`), not the zone or the locale. - `zonedDateTime` compares the instant and the zone name. - `luxonFamily.datetime({ strict: true })` (also `epoch`, `zonedDateTime` and `interval`) gives a codec that uses luxon `equals`, which also compares the zone and the locale. - `date`, `time`, `local-datetime` and `year-month` compare the wire text. - `duration` compares years, months and weeks one by one, and the other units by length. `PT1H` equals `PT60M`. `P1M` does not equal `P30D`. ## WarpDrive Register the codecs before the store calls `transformations()`, because `transformations()` reads the registry when it runs. See the [`@millwork-ts/warp-drive` README](https://github.com/joegaudet/millwork/tree/main/packages/warp-drive#the-store). ```ts import { codecs } from '@millwork-ts/luxon' import { registerCodecs, valueField } from '@millwork-ts/warp-drive' import { withDefaults } from '@warp-drive/core/reactive' registerCodecs(codecs) export const EventSchema = withDefaults({ type: 'event', fields: [ valueField('startsOn', 'luxon:date'), valueField('startsAt', 'luxon:datetime', { keepOffset: true }), valueField('length', 'luxon:duration'), ], }) ``` ## Interfaces - IntervalOptions - LuxonTypes - StrictOptions - ZonedOptions ## Type Aliases - IntervalRaw - ZonedRaw ## Variables - codecs - date - datetime - duration - epoch - interval - localDateTime - luxonFamily - time - yearMonth - zonedDateTime --- **Millwork** *** Millwork / @millwork-ts/luxon / IntervalOptions # Interface: IntervalOptions Defined in: core/dist/dates.d.ts:109 Options of an `interval` codec. ## Properties ### wire? > `optional` **wire?**: `"object"` \| `"iso"` Defined in: core/dist/dates.d.ts:111 The form that `serialize` writes. The default is `'iso'` (`"a/b"`). Both forms are read. --- **Millwork** *** Millwork / @millwork-ts/luxon / LuxonTypes # Interface: LuxonTypes Defined in: [luxon/src/index.ts:29](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/luxon/src/index.ts#L29) The luxon type of each date kind. ## Properties ### date > **date**: `DateTime` Defined in: [luxon/src/index.ts:30](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/luxon/src/index.ts#L30) *** ### duration > **duration**: `Duration` Defined in: [luxon/src/index.ts:36](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/luxon/src/index.ts#L36) *** ### instant > **instant**: `DateTime` Defined in: [luxon/src/index.ts:33](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/luxon/src/index.ts#L33) *** ### interval > **interval**: `Interval` Defined in: [luxon/src/index.ts:37](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/luxon/src/index.ts#L37) *** ### localDateTime > **localDateTime**: `DateTime` Defined in: [luxon/src/index.ts:32](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/luxon/src/index.ts#L32) *** ### time > **time**: `DateTime` Defined in: [luxon/src/index.ts:31](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/luxon/src/index.ts#L31) *** ### yearMonth > **yearMonth**: `DateTime` Defined in: [luxon/src/index.ts:35](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/luxon/src/index.ts#L35) *** ### zonedDateTime > **zonedDateTime**: `DateTime` Defined in: [luxon/src/index.ts:34](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/luxon/src/index.ts#L34) --- **Millwork** *** Millwork / @millwork-ts/luxon / StrictOptions # Interface: StrictOptions Defined in: [luxon/src/index.ts:41](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/luxon/src/index.ts#L41) Options of the codec factories that compare instants. ## Properties ### strict? > `optional` **strict?**: `boolean` Defined in: [luxon/src/index.ts:43](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/luxon/src/index.ts#L43) Also compare the zone and the locale (luxon `equals`). The default compares the instant only. --- **Millwork** *** Millwork / @millwork-ts/luxon / ZonedOptions # Interface: ZonedOptions Defined in: core/dist/dates.d.ts:104 Options of a `zonedDateTime` codec. ## Properties ### wire? > `optional` **wire?**: `"object"` \| `"rfc9557"` Defined in: core/dist/dates.d.ts:106 The form that `serialize` writes. The default is `'rfc9557'`. Both forms are read. --- **Millwork** *** Millwork / @millwork-ts/luxon / IntervalRaw # Type Alias: IntervalRaw > **IntervalRaw** = `string` \| \{ `end`: `string`; `start`: `string`; \} Defined in: [luxon/src/index.ts:49](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/luxon/src/index.ts#L49) The raw wire form of an interval: `start/end` text, or `{ start, end }`. --- **Millwork** *** Millwork / @millwork-ts/luxon / ZonedRaw # Type Alias: ZonedRaw > **ZonedRaw** = `string` \| \{ `at`: `string`; `zone`: `string`; \} Defined in: [luxon/src/index.ts:47](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/luxon/src/index.ts#L47) The raw wire form of a zoned datetime: RFC 9557 text, or `{ at, zone }`. --- **Millwork** *** Millwork / @millwork-ts/luxon / codecs # Variable: codecs > `const` **codecs**: `Readonly`\<\{ `date`: `Codec`\<`string`, `DateTime`\<`boolean`\>, `undefined`\>; `datetime`: `Codec`\<`string`, `DateTime`\<`boolean`\>, \{ `keepOffset?`: `boolean`; \} \| `undefined`\>; `duration`: `Codec`\<`string` \| `number`, `Duration`\<`boolean`\>, \{ `unit?`: `"s"` \| `"ms"` \| `"iso"`; \} \| `undefined`\>; `epoch`: `Codec`\<`string` \| `number`, `DateTime`\<`boolean`\>, \{ `unit?`: `EpochUnit`; \} \| `undefined`\>; `interval`: `Codec`\<`IntervalRaw`, `Interval`\<`boolean`\>, `IntervalOptions` \| `undefined`\>; `local-datetime`: `Codec`\<`string`, `DateTime`\<`boolean`\>, `undefined`\>; `luxon:date`: `Codec`\<`string`, `DateTime`\<`boolean`\>, `undefined`\>; `luxon:datetime`: `Codec`\<`string`, `DateTime`\<`boolean`\>, \{ `keepOffset?`: `boolean`; \} \| `undefined`\>; `luxon:duration`: `Codec`\<`string` \| `number`, `Duration`\<`boolean`\>, \{ `unit?`: `"s"` \| `"ms"` \| `"iso"`; \} \| `undefined`\>; `luxon:epoch`: `Codec`\<`string` \| `number`, `DateTime`\<`boolean`\>, \{ `unit?`: `EpochUnit`; \} \| `undefined`\>; `luxon:interval`: `Codec`\<`IntervalRaw`, `Interval`\<`boolean`\>, `IntervalOptions` \| `undefined`\>; `luxon:local-datetime`: `Codec`\<`string`, `DateTime`\<`boolean`\>, `undefined`\>; `luxon:time`: `Codec`\<`string`, `DateTime`\<`boolean`\>, `undefined`\>; `luxon:year-month`: `Codec`\<`string`, `DateTime`\<`boolean`\>, `undefined`\>; `luxon:zoned-datetime`: `Codec`\<`ZonedRaw`, `DateTime`\<`boolean`\>, `ZonedOptions` \| `undefined`\>; `time`: `Codec`\<`string`, `DateTime`\<`boolean`\>, `undefined`\>; `year-month`: `Codec`\<`string`, `DateTime`\<`boolean`\>, `undefined`\>; `zoned-datetime`: `Codec`\<`ZonedRaw`, `DateTime`\<`boolean`\>, `ZonedOptions` \| `undefined`\>; \}\> Defined in: [luxon/src/index.ts:259](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/luxon/src/index.ts#L259) Each luxon codec, keyed by its kind (`date`) and by an alias with the adapter prefix (`luxon:date`). Use the prefixed keys when an app registers two date families. --- **Millwork** *** Millwork / @millwork-ts/luxon / date # Variable: date > `const` **date**: `Codec`\<`string`, `DateTime`\> Defined in: [luxon/src/index.ts:170](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/luxon/src/index.ts#L170) `"2026-12-01"` ↔ a `DateTime` at local midnight of that day. `equals` compares the day. --- **Millwork** *** Millwork / @millwork-ts/luxon / datetime # Variable: datetime > `const` **datetime**: `Codec`\<`string`, `DateTime`, \{ `keepOffset?`: `boolean`; \} \| `undefined`\> Defined in: [luxon/src/index.ts:180](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/luxon/src/index.ts#L180) RFC 3339 ↔ a `DateTime`. The value is in the local zone, and `serialize` writes `Z`. With `keepOffset`, the value keeps the wire offset (`setZone: true`), and `serialize` writes it. --- **Millwork** *** Millwork / @millwork-ts/luxon / duration # Variable: duration > `const` **duration**: `Codec`\<`string` \| `number`, `Duration`, \{ `unit?`: `"iso"` \| `"s"` \| `"ms"`; \} \| `undefined`\> Defined in: [luxon/src/index.ts:215](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/luxon/src/index.ts#L215) ISO 8601 or a number ↔ a luxon `Duration`. The `unit` option is `'iso'` (default), `'s'` or `'ms'`. Each unit is kept on the wire. `equals` compares years, months, weeks and days per unit and the rest by length: `PT1H` equals `PT60M`, but `P1M` is not `P30D`. --- **Millwork** *** Millwork / @millwork-ts/luxon / epoch # Variable: epoch > `const` **epoch**: `Codec`\<`number` \| `string`, `DateTime`, \{ `unit?`: `EpochUnit`; \} \| `undefined`\> Defined in: [luxon/src/index.ts:184](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/luxon/src/index.ts#L184) An epoch number ↔ a `DateTime`. The `unit` option is `'s'`, `'ms'` (default), `'us'` or `'ns'`. --- **Millwork** *** Millwork / @millwork-ts/luxon / interval # Variable: interval > `const` **interval**: `Codec`\<`IntervalRaw`, `Interval`, `IntervalOptions` \| `undefined`\> Defined in: [luxon/src/index.ts:225](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/luxon/src/index.ts#L225) `"a/b"`, `"a/PT1H"`, `"P1D/b"` or `{ start, end }` ↔ a luxon `Interval` (half-open). --- **Millwork** *** Millwork / @millwork-ts/luxon / localDateTime # Variable: localDateTime > `const` **localDateTime**: `Codec`\<`string`, `DateTime`\> Defined in: [luxon/src/index.ts:194](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/luxon/src/index.ts#L194) `"2026-12-01T14:30:00"` ↔ a `DateTime` in UTC, so that a DST gap cannot move the wall clock. --- **Millwork** *** Millwork / @millwork-ts/luxon / luxonFamily # Variable: luxonFamily > `const` **luxonFamily**: `Readonly`\<\{ `date`: () => `Codec`\<`string`, `DateTime`\<`boolean`\>, `undefined`\>; `datetime`: (`options?`) => `Codec`\<`string`, `DateTime`\<`boolean`\>, \{ `keepOffset?`: `boolean`; \} \| `undefined`\>; `duration`: () => `Codec`\<`string` \| `number`, `Duration`\<`boolean`\>, \{ `unit?`: `"s"` \| `"ms"` \| `"iso"`; \} \| `undefined`\>; `epoch`: (`options?`) => `Codec`\<`string` \| `number`, `DateTime`\<`boolean`\>, \{ `unit?`: `EpochUnit`; \} \| `undefined`\>; `interval`: (`options?`) => `Codec`\<`IntervalRaw`, `Interval`\<`boolean`\>, `IntervalOptions` \| `undefined`\>; `localDateTime`: () => `Codec`\<`string`, `DateTime`\<`boolean`\>, `undefined`\>; `name`: `"luxon"`; `time`: () => `Codec`\<`string`, `DateTime`\<`boolean`\>, `undefined`\>; `yearMonth`: () => `Codec`\<`string`, `DateTime`\<`boolean`\>, `undefined`\>; `zonedDateTime`: (`options?`) => `Codec`\<`ZonedRaw`, `DateTime`\<`boolean`\>, `ZonedOptions` \| `undefined`\>; \}\> Defined in: [luxon/src/index.ts:233](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/luxon/src/index.ts#L233) The luxon date family. The factories that compare instants take `{ strict: true }`. --- **Millwork** *** Millwork / @millwork-ts/luxon / time # Variable: time > `const` **time**: `Codec`\<`string`, `DateTime`\> Defined in: [luxon/src/index.ts:187](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/luxon/src/index.ts#L187) `"14:30:00"` ↔ a `DateTime` of today in UTC, so that the wall clock never moves. --- **Millwork** *** Millwork / @millwork-ts/luxon / yearMonth # Variable: yearMonth > `const` **yearMonth**: `Codec`\<`string`, `DateTime`\> Defined in: [luxon/src/index.ts:204](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/luxon/src/index.ts#L204) `"2026-12"` ↔ a `DateTime` at local midnight of the first day of the month. --- **Millwork** *** Millwork / @millwork-ts/luxon / zonedDateTime # Variable: zonedDateTime > `const` **zonedDateTime**: `Codec`\<`ZonedRaw`, `DateTime`, `ZonedOptions` \| `undefined`\> Defined in: [luxon/src/index.ts:201](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/luxon/src/index.ts#L201) RFC 9557 `"…-05:00[America/Toronto]"` or `{ at, zone }` ↔ a `DateTime` in that zone. --- **Millwork** *** Millwork / @millwork-ts/phone # @millwork-ts/phone A Millwork codec for phone numbers with [libphonenumber-js](https://gitlab.com/catamphetamine/libphonenumber-js). ## Install ```bash pnpm add @millwork-ts/phone @millwork-ts/core libphonenumber-js ``` ## Codecs | Codec | Value | Raw | | ------- | ---------------------------------------- | --------------------------------- | | `phone` | a frozen libphonenumber-js `PhoneNumber` | an E.164 string, `"+14165551234"` | - The codec reads an international number in any format, such as `"+1 (416) 555-1234"`. - The codec reads a national number, such as `"(416) 555-1234"`, with the `defaultCountry` option. - The codec writes E.164. - A number that has a length that is not possible for its country is bad input. The codec does not do a full validity check, because the metadata can be older than the number plan. Use `value.isValid()` for that check. ## Options | Option | Type | Use | | ---------------- | -------------- | ------------------------------------------------- | | `defaultCountry` | `CountryCode` | The country of a national number, such as `'CA'`. | | `metadata` | `MetadataJson` | The metadata flavour. The default is `min`. | The `min` metadata is the smallest. It does not give the number type. To get the type, such as `MOBILE`, give the `max` or `mobile` flavour: ```ts import max from 'libphonenumber-js/max/metadata' phone.hydrate('+14165551234', { metadata: max })?.getType() ``` ## Equality `equals` compares the E.164 numbers. `"+1 416 555 1234"` equals `"(416) 555-1234"` with `defaultCountry: 'CA'`. ## Example with WarpDrive Register the codecs before the store calls `transformations()`, because `transformations()` reads the registry when it runs. See the [`@millwork-ts/warp-drive` README](https://github.com/joegaudet/millwork/tree/main/packages/warp-drive#the-store). ```ts import { codecs } from '@millwork-ts/phone' import { registerCodecs, valueField } from '@millwork-ts/warp-drive' import { withDefaults } from '@warp-drive/core/reactive' registerCodecs(codecs) export const ContactSchema = withDefaults({ type: 'contact', fields: [valueField('mobile', 'phone', { defaultCountry: 'CA' })], }) ``` ## Interfaces - PhoneOptions ## Variables - codecs - phone --- **Millwork** *** Millwork / @millwork-ts/phone / PhoneOptions # Interface: PhoneOptions Defined in: [index.ts:11](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/phone/src/index.ts#L11) Options of the `phone` codec. ## Properties ### defaultCountry? > `optional` **defaultCountry?**: `CountryCode` Defined in: [index.ts:13](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/phone/src/index.ts#L13) The country of a national number, such as `'CA'` for `"(416) 555-1234"`. *** ### metadata? > `optional` **metadata?**: `MetadataJson` Defined in: [index.ts:18](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/phone/src/index.ts#L18) The libphonenumber-js metadata. The default is the `min` flavour. Give the `max` or `mobile` flavour (`libphonenumber-js/max/metadata`) to get number types such as mobile. --- **Millwork** *** Millwork / @millwork-ts/phone / codecs # Variable: codecs > `const` **codecs**: `Readonly`\<\{ `phone`: `Codec`\<`string`, `PhoneNumber`, `PhoneOptions` \| `undefined`\>; \}\> Defined in: [index.ts:46](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/phone/src/index.ts#L46) Each codec in this package, keyed by its name. --- **Millwork** *** Millwork / @millwork-ts/phone / phone # Variable: phone > `const` **phone**: `Codec`\<`string`, `PhoneNumber`, `PhoneOptions` \| `undefined`\> Defined in: [index.ts:26](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/phone/src/index.ts#L26) The `phone` codec: an E.164 string, such as `"+14165551234"`, to a libphonenumber-js `PhoneNumber`. It reads a national number with the `defaultCountry` option. It writes E.164. A number that has a length that is not possible for its country is bad input. --- **Millwork** *** Millwork / @millwork-ts/quantity # @millwork-ts/quantity A Millwork codec for units of measure with [js-quantities](https://github.com/gentooboontoo/js-quantities). ## Install ```bash pnpm add @millwork-ts/quantity @millwork-ts/core js-quantities ``` ## Codecs | Codec | Value | Raw | | ---------- | ---------------------------- | ------------------------------------------------ | | `quantity` | a frozen js-quantities `Qty` | `{ "value": 12.5, "unit": "kg" }` or `"12.5 kg"` | - The codec reads both raw forms, whatever the `wire` option is. - A string must start with a number. `"kg"` and `""` are bad input. - The codec writes the unit of the value. It does not convert the value to a different unit. - js-quantities writes some units in its own case. For example, `mg/dL` is written as `mg/dl`. If your server uses case-sensitive UCUM codes, do a check of your units. - The package exports `Qty`, the js-quantities function with types. js-quantities has no types of its own. ## Options | Option | Type | Use | | ------ | ------------------------ | -------------------------------------------------------------- | | `wire` | `'object'` \| `'string'` | The raw form that the codec writes. The default is `'object'`. | ## Equality `equals` converts the two values to one unit, then compares them. `"1 m"` equals `"100 cm"`. Values with incompatible units, such as `kg` and `m`, are not equal. ## Example with WarpDrive Register the codecs before the store calls `transformations()`, because `transformations()` reads the registry when it runs. See the [`@millwork-ts/warp-drive` README](https://github.com/joegaudet/millwork/tree/main/packages/warp-drive#the-store). ```ts import { codecs } from '@millwork-ts/quantity' import { registerCodecs, valueField } from '@millwork-ts/warp-drive' import { withDefaults } from '@warp-drive/core/reactive' registerCodecs(codecs) export const ParcelSchema = withDefaults({ type: 'parcel', fields: [valueField('weight', 'quantity', { wire: 'string' })], }) ``` ## Interfaces - Qty - QtyFactory - QuantityObject - QuantityOptions ## Type Aliases - QuantityRaw ## Variables - codecs - Qty - quantity --- **Millwork** *** Millwork / @millwork-ts/quantity / Qty # Interface: Qty Defined in: [qty.ts:4](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/quantity/src/qty.ts#L4) The part of a js-quantities `Qty` that Millwork uses and types. Each method gives a new `Qty`. ## Properties ### baseScalar > `readonly` **baseScalar**: `number` Defined in: [qty.ts:6](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/quantity/src/qty.ts#L6) *** ### scalar > `readonly` **scalar**: `number` Defined in: [qty.ts:5](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/quantity/src/qty.ts#L5) ## Methods ### add() > **add**(`other`): `Qty` Defined in: [qty.ts:20](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/quantity/src/qty.ts#L20) Adds a compatible quantity. #### Parameters ##### other `string` \| `Qty` #### Returns `Qty` *** ### div() > **div**(`other`): `Qty` Defined in: [qty.ts:26](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/quantity/src/qty.ts#L26) Divides by a quantity or a number. #### Parameters ##### other `string` \| `number` \| `Qty` #### Returns `Qty` *** ### eq() > **eq**(`other`): `boolean` Defined in: [qty.ts:14](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/quantity/src/qty.ts#L14) Returns `true` if both quantities are equal after conversion to base units. #### Parameters ##### other `Qty` #### Returns `boolean` *** ### format() > **format**(`unit?`): `string` Defined in: [qty.ts:28](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/quantity/src/qty.ts#L28) Writes the quantity as text. With a unit, it converts to that unit first. #### Parameters ##### unit? `string` #### Returns `string` *** ### isBase() > **isBase**(): `boolean` Defined in: [qty.ts:10](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/quantity/src/qty.ts#L10) Returns `true` if the unit is a base unit. #### Returns `boolean` *** ### isCompatible() > **isCompatible**(`other`): `boolean` Defined in: [qty.ts:12](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/quantity/src/qty.ts#L12) Returns `true` if the other quantity can convert to this unit. #### Parameters ##### other `string` \| `Qty` #### Returns `boolean` *** ### mul() > **mul**(`other`): `Qty` Defined in: [qty.ts:24](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/quantity/src/qty.ts#L24) Multiplies by a quantity or a number. #### Parameters ##### other `string` \| `number` \| `Qty` #### Returns `Qty` *** ### sub() > **sub**(`other`): `Qty` Defined in: [qty.ts:22](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/quantity/src/qty.ts#L22) Subtracts a compatible quantity. #### Parameters ##### other `string` \| `Qty` #### Returns `Qty` *** ### to() > **to**(`unit`): `Qty` Defined in: [qty.ts:16](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/quantity/src/qty.ts#L16) Converts to a unit, or to the unit of another quantity. #### Parameters ##### unit `string` \| `Qty` #### Returns `Qty` *** ### toBase() > **toBase**(): `Qty` Defined in: [qty.ts:18](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/quantity/src/qty.ts#L18) Converts to base units. #### Returns `Qty` *** ### toString() > **toString**(`unit?`): `string` Defined in: [qty.ts:30](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/quantity/src/qty.ts#L30) Writes the quantity as text. A unit or a number of decimals changes the output. #### Parameters ##### unit? `string` \| `number` #### Returns `string` *** ### units() > **units**(): `string` Defined in: [qty.ts:8](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/quantity/src/qty.ts#L8) Gives the unit as text, for example `m/s`. #### Returns `string` --- **Millwork** *** Millwork / @millwork-ts/quantity / QtyFactory # Interface: QtyFactory() Defined in: [qty.ts:34](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/quantity/src/qty.ts#L34) The js-quantities `Qty` function, typed. ## Call Signature > **QtyFactory**(`value`, `unit?`): `Qty` Defined in: [qty.ts:35](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/quantity/src/qty.ts#L35) The js-quantities `Qty` function, typed. ### Parameters #### value `number` #### unit? `string` ### Returns `Qty` ## Call Signature > **QtyFactory**(`text`): `Qty` Defined in: [qty.ts:36](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/quantity/src/qty.ts#L36) The js-quantities `Qty` function, typed. ### Parameters #### text `string` ### Returns `Qty` ## Properties ### prototype > `readonly` **prototype**: `Qty` Defined in: [qty.ts:37](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/quantity/src/qty.ts#L37) --- **Millwork** *** Millwork / @millwork-ts/quantity / QuantityObject # Interface: QuantityObject Defined in: [index.ts:9](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/quantity/src/index.ts#L9) The object wire form of a quantity. ## Properties ### unit > **unit**: `string` Defined in: [index.ts:11](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/quantity/src/index.ts#L11) *** ### value > **value**: `number` Defined in: [index.ts:10](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/quantity/src/index.ts#L10) --- **Millwork** *** Millwork / @millwork-ts/quantity / QuantityOptions # Interface: QuantityOptions Defined in: [index.ts:18](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/quantity/src/index.ts#L18) Options of the `quantity` codec. ## Properties ### wire? > `optional` **wire?**: `"string"` \| `"object"` Defined in: [index.ts:20](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/quantity/src/index.ts#L20) The wire form on serialize. The default is `'object'`. Hydrate reads both forms. --- **Millwork** *** Millwork / @millwork-ts/quantity / QuantityRaw # Type Alias: QuantityRaw > **QuantityRaw** = `QuantityObject` \| `string` Defined in: [index.ts:15](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/quantity/src/index.ts#L15) The raw forms of the `quantity` codec: `{ value, unit }` or `"12.5 kg"`. --- **Millwork** *** Millwork / @millwork-ts/quantity / Qty # Variable: Qty > **Qty**: `QtyFactory` Defined in: [qty.ts:4](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/quantity/src/qty.ts#L4) The js-quantities `Qty` function. --- **Millwork** *** Millwork / @millwork-ts/quantity / codecs # Variable: codecs > `const` **codecs**: `Readonly`\<\{ `quantity`: `Codec`\<`QuantityRaw`, `Qty`, `QuantityOptions` \| `undefined`\>; \}\> Defined in: [index.ts:67](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/quantity/src/index.ts#L67) The codecs of this package, keyed by name. --- **Millwork** *** Millwork / @millwork-ts/quantity / quantity # Variable: quantity > `const` **quantity**: `Codec`\<`QuantityRaw`, `Qty`, `QuantityOptions` \| `undefined`\> Defined in: [index.ts:56](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/quantity/src/index.ts#L56) The `quantity` codec: `{ value, unit }` or `"12.5 kg"` to a frozen js-quantities `Qty`. Serialize keeps the unit of the value. It does not convert. --- **Millwork** *** Millwork / @millwork-ts/rrule # @millwork-ts/rrule A Millwork codec for RFC 5545 recurrence rules with [rrule](https://github.com/jkbrzt/rrule). ## Install ```bash pnpm add @millwork-ts/rrule @millwork-ts/core rrule ``` ## Codecs | Codec | Value | Raw | | ------- | ------------------------ | ------------------------------------------------------ | | `rrule` | an `RRule` or `RRuleSet` | `"FREQ=WEEKLY;BYDAY=MO,WE"`, with or without `DTSTART` | - The codec reads the string with `rrulestr`. A string with `EXDATE`, `RDATE` or more than one rule gives an `RRuleSet`. - The codec writes `value.toString()`. A bare `"FREQ=…"` is written as `"RRULE:FREQ=…"`. - A number part that is not a number, such as `COUNT=abc`, is bad input. - **The value is not frozen.** rrule writes caches into the instance, and `RRuleSet` setters change it. Do not change the value. To change a rule, make a new one and set it. ## Time zones rrule uses JavaScript `Date` values in UTC. It shows local times as "floating" UTC times. For example, `DTSTART;TZID=America/New_York:20240101T090000` gives dates at `09:00Z`, not at `14:00Z`. Read the dates with their UTC fields, or use the [rrule time zone notes](https://github.com/jkbrzt/rrule#important-use-utc-dates). The codec does not change this. ## Options | Option | Default | Meaning | | --------------- | ------- | ------------------------------------- | | `allowSecondly` | `false` | When `true`, `FREQ=SECONDLY` is read. | ## Expensive rules rrule finds each date by a step of the frequency. A rule that has no dates, or very few, can make `after()`, `between()` and `all()` iterate for many seconds before they stop. For example, `FREQ=MINUTELY;BYMONTH=2;BYMONTHDAY=30` blocks for about 20 seconds. - `FREQ=SECONDLY` is bad input by default. Set `allowSecondly: true` only for rules that you trust. - A `BYMONTHDAY` that no month of `BYMONTH` has is bad input, at each frequency. - Other rules with no dates are possible (for example, `BYYEARDAY` and `BYMONTH` that do not meet). Do not iterate a rule from a user that you do not trust without a limit: give `between()` a short range, or use `COUNT` or `UNTIL`. ## Equality `equals` compares the string form. `"FREQ=DAILY"` equals `"RRULE:FREQ=DAILY"`. ## Example with WarpDrive Register the codecs before the store calls `transformations()`, because `transformations()` reads the registry when it runs. See the [`@millwork-ts/warp-drive` README](https://github.com/joegaudet/millwork/tree/main/packages/warp-drive#the-store). ```ts import { codecs } from '@millwork-ts/rrule' import { registerCodecs, valueField } from '@millwork-ts/warp-drive' import { withDefaults } from '@warp-drive/core/reactive' registerCodecs(codecs) export const MeetingSchema = withDefaults({ type: 'meeting', fields: [valueField('recurrence', 'rrule')], }) ``` ## Interfaces - RRuleOptions ## Type Aliases - RRule - RRuleSet ## Variables - codecs - rrule - RRule - RRuleSet --- **Millwork** *** Millwork / @millwork-ts/rrule / RRuleOptions # Interface: RRuleOptions Defined in: [index.ts:36](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/rrule/src/index.ts#L36) Options of the `rrule` codec. ## Properties ### allowSecondly? > `optional` **allowSecondly?**: `boolean` Defined in: [index.ts:41](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/rrule/src/index.ts#L41) Allow `FREQ=SECONDLY`. The default is `false`, because a secondly rule can take a very long time to iterate. --- **Millwork** *** Millwork / @millwork-ts/rrule / RRule # Type Alias: RRule > **RRule** = `rruleModule.RRule` Defined in: [index.ts:13](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/rrule/src/index.ts#L13) An `RRule` instance. --- **Millwork** *** Millwork / @millwork-ts/rrule / RRuleSet # Type Alias: RRuleSet > **RRuleSet** = `rruleModule.RRuleSet` Defined in: [index.ts:17](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/rrule/src/index.ts#L17) An `RRuleSet` instance. --- **Millwork** *** Millwork / @millwork-ts/rrule / RRule # Variable: RRule > `const` **RRule**: *typeof* `RRule` = `lib.RRule` Defined in: [index.ts:13](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/rrule/src/index.ts#L13) The `RRule` class of the `rrule` package. --- **Millwork** *** Millwork / @millwork-ts/rrule / RRuleSet # Variable: RRuleSet > `const` **RRuleSet**: *typeof* `RRuleSet` = `lib.RRuleSet` Defined in: [index.ts:17](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/rrule/src/index.ts#L17) The `RRuleSet` class of the `rrule` package. It extends `RRule`. --- **Millwork** *** Millwork / @millwork-ts/rrule / codecs # Variable: codecs > `const` **codecs**: `Readonly`\<\{ `rrule`: `Codec`\<`string`, `RRule`, `RRuleOptions` \| `undefined`\>; \}\> Defined in: [index.ts:94](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/rrule/src/index.ts#L94) The codecs of this package, keyed by name. --- **Millwork** *** Millwork / @millwork-ts/rrule / rrule # Variable: rrule > `const` **rrule**: `Codec`\<`string`, `RRule`, `RRuleOptions` \| `undefined`\> Defined in: [index.ts:85](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/rrule/src/index.ts#L85) The `rrule` codec: an RFC 5545 string, with or without a `DTSTART` line, to an `RRule`, or to an `RRuleSet` when the string has `EXDATE`, `RDATE` or more than one rule. Serialize uses `toString()`, so a bare `FREQ=…` is written as `RRULE:FREQ=…`. `equals` compares the string form. The value is not frozen, because rrule writes caches into the instance. Do not change it. `FREQ=SECONDLY` is bad input unless `allowSecondly` is true. A `BYMONTHDAY` that no month of `BYMONTH` has is bad input. --- **Millwork** *** Millwork / @millwork-ts/semver # @millwork-ts/semver A Millwork codec for semantic versions with [semver](https://github.com/npm/node-semver). ## Install ```bash pnpm add @millwork-ts/semver @millwork-ts/core semver ``` ## Codecs | Codec | Value | Raw | | -------- | ----------------- | ---------------- | | `semver` | a frozen `SemVer` | `"1.2.3-beta.1"` | - Each hydrate makes a new `SemVer` instance, and the codec freezes it. - `value.inc()` and `value.format()` change the instance, so they throw a `TypeError` on the frozen value. To get the next version, use `semver.inc(value.version, 'patch')` from the `semver` package. It gives a string. - The codec writes the version with its build metadata, such as `"1.2.3+sha.5114f85"`. - A leading `v` is removed: `"v1.2.3"` is written as `"1.2.3"`. ## Options | Option | Type | Use | | ------- | --------- | ---------------------------------------------------------------------------- | | `loose` | `boolean` | Read loose forms, such as `"=1.2.3"` and `"01.2.3"`. The default is `false`. | ## Equality `equals` uses `semver.eq`. It ignores build metadata, as SemVer 2.0.0 tells. `"1.2.3+a"` equals `"1.2.3+b"`. To sort versions, use `semver.compare`. ## Example with WarpDrive Register the codecs before the store calls `transformations()`, because `transformations()` reads the registry when it runs. See the [`@millwork-ts/warp-drive` README](https://github.com/joegaudet/millwork/tree/main/packages/warp-drive#the-store). ```ts import { codecs } from '@millwork-ts/semver' import { registerCodecs, valueField } from '@millwork-ts/warp-drive' import { withDefaults } from '@warp-drive/core/reactive' registerCodecs(codecs) export const ReleaseSchema = withDefaults({ type: 'release', fields: [valueField('version', 'semver')], }) ``` ## Interfaces - SemverOptions ## Type Aliases - SemVer ## Variables - codecs - semver - SemVer --- **Millwork** *** Millwork / @millwork-ts/semver / SemverOptions # Interface: SemverOptions Defined in: [index.ts:10](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/semver/src/index.ts#L10) Options of the `semver` codec. ## Properties ### loose? > `optional` **loose?**: `boolean` Defined in: [index.ts:12](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/semver/src/index.ts#L12) Read loose forms such as `=1.2.3` and `01.2.3`. The default is `false`. --- **Millwork** *** Millwork / @millwork-ts/semver / SemVer # Type Alias: SemVer > **SemVer** = `SemVerType` Defined in: [index.ts:5](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/semver/src/index.ts#L5) A `SemVer` instance. The codec freezes it. --- **Millwork** *** Millwork / @millwork-ts/semver / SemVer # Variable: SemVer > `const` **SemVer**: *typeof* `SemVer` = `semverLib.SemVer` Defined in: [index.ts:5](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/semver/src/index.ts#L5) The `SemVer` class of the `semver` package. --- **Millwork** *** Millwork / @millwork-ts/semver / codecs # Variable: codecs > `const` **codecs**: `Readonly`\<\{ `semver`: `Codec`\<`string`, `SemVer`, `SemverOptions` \| `undefined`\>; \}\> Defined in: [index.ts:31](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/semver/src/index.ts#L31) The codecs of this package, keyed by name. --- **Millwork** *** Millwork / @millwork-ts/semver / semver # Variable: semver > `const` **semver**: `Codec`\<`string`, `SemVer`, `SemverOptions` \| `undefined`\> Defined in: [index.ts:21](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/semver/src/index.ts#L21) The `semver` codec: `"1.2.3-beta.1"` to a frozen `SemVer`. Each hydrate makes a new instance. `inc()` and `format()` write to the instance, so they throw on the frozen value. Use `semver.inc(value.version, 'patch')`, which gives a string. Serialize keeps build metadata. `equals` uses `semver.eq`, so it ignores build metadata (SemVer 2.0.0, section 10). --- **Millwork** *** Millwork / @millwork-ts/temporal # @millwork-ts/temporal Millwork codecs for the [Temporal](https://tc39.es/proposal-temporal/docs/) API. Each codec reads a wire value into a Temporal object, and writes it back. Temporal keeps nanoseconds, so this package does not drop digits. ## Install ```bash pnpm add @millwork-ts/core @millwork-ts/temporal ``` The codecs use the global `Temporal`. Firefox 139+ and Chrome 144+ have it. For other browsers and for Node 22, install the polyfill and import it one time, before the app reads data: ```bash pnpm add temporal-polyfill ``` ```ts import 'temporal-polyfill/global' ``` The package does not import the polyfill. Each codec reads `globalThis.Temporal` when it runs, not when the module loads. So the import stays sync, and the polyfill can load first or last. If there is no global `Temporal`, `hydrate` gives `undefined` with a report, and `isValue` is `false`. The types come from the TypeScript lib `esnext.temporal`. The package adds a reference to it, so you do not have to change your `tsconfig.json`. TypeScript 6.0 has this lib. Older versions are not tested and can fail to find it. ## Codecs Each codec is a named export. The `codecs` record has each codec two times: with its kind as the key (`date`) and with the adapter prefix (`temporal:date`). The `name` of each codec has the prefix. If your app registers two date families, use the prefixed keys. | Export | Key | Wire | Value | | --------------- | ---------------- | -------------------------------------------------------------- | ------------------------------------ | | `date` | `date` | `"2026-12-01"` | `Temporal.PlainDate` | | `datetime` | `datetime` | RFC 3339, `"2026-12-01T14:30:00-05:00"` or `"…Z"` | `Temporal.Instant` | | `epoch` | `epoch` | a number, or a string for large values | `Temporal.Instant` | | `time` | `time` | `"14:30"`, `"14:30:00.123456789"` | `Temporal.PlainTime` | | `localDateTime` | `local-datetime` | `"2026-12-01T14:30:00"` | `Temporal.PlainDateTime` | | `zonedDateTime` | `zoned-datetime` | `"2026-12-01T14:30:00-05:00[America/Toronto]"`, `{ at, zone }` | `Temporal.ZonedDateTime` | | `yearMonth` | `year-month` | `"2026-12"` | `Temporal.PlainYearMonth` | | `duration` | `duration` | ISO 8601 `"PT1H30M"`, or a number | `Temporal.Duration` | | `interval` | `interval` | `"a/b"`, `"a/PT1H"`, `"P1D/b"`, `{ start, end }` | frozen `{ start, end }` of `Instant` | Options: - `datetime`: an `Instant` has no offset, so `serialize` always writes `Z`. The `keepOffset` option has no effect. Use `zonedDateTime` to keep a zone. - `epoch`: `unit` is `'s'`, `'ms'` (the default), `'us'` or `'ns'`. `serialize` writes a number when it is a safe integer. It writes `'ns'` as a string, such as `"1796153400123456789"`. - `zonedDateTime`: `wire: 'object'` writes `{ at, zone }`. The default writes RFC 9557. Both are read. The wire offset must be the offset of the zone at that instant, or the value is bad. A `[u-ca=…]` calendar annotation is kept. - `duration`: `unit` is `'iso'` (the default), `'s'` or `'ms'`. A duration with years, months or weeks cannot become a number, so `serialize` throws a `RangeError`. A day is 24 hours. - `interval`: `wire: 'object'` writes `{ start, end }`. A duration is added in UTC. An open interval (`..`) is bad input. The interval is half-open: `[start, end)`. Bad wire input gives `undefined` and a report to `onInvalid`. A value of the wrong type makes `serialize` throw a `TypeError`. Temporal objects do not survive `structuredClone`. Keep the raw string in the cache, and hydrate it when you read the field. ## Equality - `date`, `time`, `local-datetime`, `year-month`, `datetime` and `epoch` use Temporal `equals`. - `zonedDateTime` compares the instant and the zone. `temporalFamily.zonedDateTime({ strict: true })` gives a codec that uses Temporal `equals`, which also compares the calendar. - `interval` compares the two instants. - `duration` compares years, months and weeks one by one, and the other units by length. `PT1H` equals `PT60M`. `P1M` does not equal `P30D`. ## WarpDrive Register the codecs before the store calls `transformations()`, because `transformations()` reads the registry when it runs. See the [`@millwork-ts/warp-drive` README](https://github.com/joegaudet/millwork/tree/main/packages/warp-drive#the-store). ```ts import 'temporal-polyfill/global' import { codecs } from '@millwork-ts/temporal' import { registerCodecs, valueField } from '@millwork-ts/warp-drive' import { withDefaults } from '@warp-drive/core/reactive' registerCodecs(codecs) export const EventSchema = withDefaults({ type: 'event', fields: [ valueField('startsOn', 'temporal:date'), valueField('startsAt', 'temporal:zoned-datetime', { wire: 'object' }), valueField('length', 'temporal:duration'), ], }) ``` ## Interfaces - IntervalOptions - StrictOptions - TemporalInterval - TemporalTypes - ZonedOptions ## Type Aliases - IntervalRaw - ZonedRaw ## Variables - codecs - date - datetime - duration - epoch - interval - localDateTime - temporalFamily - time - yearMonth - zonedDateTime --- **Millwork** *** Millwork / @millwork-ts/temporal / IntervalOptions # Interface: IntervalOptions Defined in: core/dist/dates.d.ts:109 Options of an `interval` codec. ## Properties ### wire? > `optional` **wire?**: `"object"` \| `"iso"` Defined in: core/dist/dates.d.ts:111 The form that `serialize` writes. The default is `'iso'` (`"a/b"`). Both forms are read. --- **Millwork** *** Millwork / @millwork-ts/temporal / StrictOptions # Interface: StrictOptions Defined in: [temporal/src/index.ts:78](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/temporal/src/index.ts#L78) Options of the `zoned-datetime` factory. ## Properties ### strict? > `optional` **strict?**: `boolean` Defined in: [temporal/src/index.ts:80](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/temporal/src/index.ts#L80) Also compare the calendar (Temporal `equals`). The default compares the instant and the zone. --- **Millwork** *** Millwork / @millwork-ts/temporal / TemporalInterval # Interface: TemporalInterval Defined in: [temporal/src/index.ts:60](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/temporal/src/index.ts#L60) A closed interval of instants. It is a frozen plain object, and it is half-open: `[start, end)`. ## Properties ### end > `readonly` **end**: `Instant` Defined in: [temporal/src/index.ts:62](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/temporal/src/index.ts#L62) *** ### start > `readonly` **start**: `Instant` Defined in: [temporal/src/index.ts:61](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/temporal/src/index.ts#L61) --- **Millwork** *** Millwork / @millwork-ts/temporal / TemporalTypes # Interface: TemporalTypes Defined in: [temporal/src/index.ts:66](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/temporal/src/index.ts#L66) The Temporal type of each date kind. ## Properties ### date > **date**: `PlainDate` Defined in: [temporal/src/index.ts:67](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/temporal/src/index.ts#L67) *** ### duration > **duration**: `Duration` Defined in: [temporal/src/index.ts:73](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/temporal/src/index.ts#L73) *** ### instant > **instant**: `Instant` Defined in: [temporal/src/index.ts:70](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/temporal/src/index.ts#L70) *** ### interval > **interval**: `TemporalInterval` Defined in: [temporal/src/index.ts:74](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/temporal/src/index.ts#L74) *** ### localDateTime > **localDateTime**: `PlainDateTime` Defined in: [temporal/src/index.ts:69](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/temporal/src/index.ts#L69) *** ### time > **time**: `PlainTime` Defined in: [temporal/src/index.ts:68](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/temporal/src/index.ts#L68) *** ### yearMonth > **yearMonth**: `PlainYearMonth` Defined in: [temporal/src/index.ts:72](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/temporal/src/index.ts#L72) *** ### zonedDateTime > **zonedDateTime**: `ZonedDateTime` Defined in: [temporal/src/index.ts:71](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/temporal/src/index.ts#L71) --- **Millwork** *** Millwork / @millwork-ts/temporal / ZonedOptions # Interface: ZonedOptions Defined in: core/dist/dates.d.ts:104 Options of a `zonedDateTime` codec. ## Properties ### wire? > `optional` **wire?**: `"object"` \| `"rfc9557"` Defined in: core/dist/dates.d.ts:106 The form that `serialize` writes. The default is `'rfc9557'`. Both forms are read. --- **Millwork** *** Millwork / @millwork-ts/temporal / IntervalRaw # Type Alias: IntervalRaw > **IntervalRaw** = `string` \| \{ `end`: `string`; `start`: `string`; \} Defined in: [temporal/src/index.ts:86](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/temporal/src/index.ts#L86) The raw wire form of an interval: `start/end` text, or `{ start, end }`. --- **Millwork** *** Millwork / @millwork-ts/temporal / ZonedRaw # Type Alias: ZonedRaw > **ZonedRaw** = `string` \| \{ `at`: `string`; `zone`: `string`; \} Defined in: [temporal/src/index.ts:84](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/temporal/src/index.ts#L84) The raw wire form of a zoned datetime: RFC 9557 text, or `{ at, zone }`. --- **Millwork** *** Millwork / @millwork-ts/temporal / codecs # Variable: codecs > `const` **codecs**: `Readonly`\<\{ `date`: `Codec`\<`string`, `PlainDate`, `undefined`\>; `datetime`: `Codec`\<`string`, `Instant`, \{ `keepOffset?`: `boolean`; \} \| `undefined`\>; `duration`: `Codec`\<`string` \| `number`, `Duration`, \{ `unit?`: `"s"` \| `"ms"` \| `"iso"`; \} \| `undefined`\>; `epoch`: `Codec`\<`string` \| `number`, `Instant`, \{ `unit?`: `EpochUnit`; \} \| `undefined`\>; `interval`: `Codec`\<`IntervalRaw`, `TemporalInterval`, `IntervalOptions` \| `undefined`\>; `local-datetime`: `Codec`\<`string`, `PlainDateTime`, `undefined`\>; `temporal:date`: `Codec`\<`string`, `PlainDate`, `undefined`\>; `temporal:datetime`: `Codec`\<`string`, `Instant`, \{ `keepOffset?`: `boolean`; \} \| `undefined`\>; `temporal:duration`: `Codec`\<`string` \| `number`, `Duration`, \{ `unit?`: `"s"` \| `"ms"` \| `"iso"`; \} \| `undefined`\>; `temporal:epoch`: `Codec`\<`string` \| `number`, `Instant`, \{ `unit?`: `EpochUnit`; \} \| `undefined`\>; `temporal:interval`: `Codec`\<`IntervalRaw`, `TemporalInterval`, `IntervalOptions` \| `undefined`\>; `temporal:local-datetime`: `Codec`\<`string`, `PlainDateTime`, `undefined`\>; `temporal:time`: `Codec`\<`string`, `PlainTime`, `undefined`\>; `temporal:year-month`: `Codec`\<`string`, `PlainYearMonth`, `undefined`\>; `temporal:zoned-datetime`: `Codec`\<`ZonedRaw`, `ZonedDateTime`, `ZonedOptions` \| `undefined`\>; `time`: `Codec`\<`string`, `PlainTime`, `undefined`\>; `year-month`: `Codec`\<`string`, `PlainYearMonth`, `undefined`\>; `zoned-datetime`: `Codec`\<`ZonedRaw`, `ZonedDateTime`, `ZonedOptions` \| `undefined`\>; \}\> Defined in: [temporal/src/index.ts:290](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/temporal/src/index.ts#L290) Each Temporal codec, keyed by its kind (`date`) and by an alias with the adapter prefix (`temporal:date`). Use the prefixed keys when an app registers two date families. --- **Millwork** *** Millwork / @millwork-ts/temporal / date # Variable: date > `const` **date**: `Codec`\<`string`, `Temporal.PlainDate`\> Defined in: [temporal/src/index.ts:115](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/temporal/src/index.ts#L115) `"2026-12-01"` ↔ `Temporal.PlainDate`. --- **Millwork** *** Millwork / @millwork-ts/temporal / datetime # Variable: datetime > `const` **datetime**: `Codec`\<`string`, `Temporal.Instant`, \{ `keepOffset?`: `boolean`; \} \| `undefined`\> Defined in: [temporal/src/index.ts:127](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/temporal/src/index.ts#L127) RFC 3339 ↔ `Temporal.Instant`. An `Instant` has no offset, so `serialize` always writes `Z`, and the `keepOffset` option has no effect. Use `zoned-datetime` to keep a zone. --- **Millwork** *** Millwork / @millwork-ts/temporal / duration # Variable: duration > `const` **duration**: `Codec`\<`string` \| `number`, `Temporal.Duration`, \{ `unit?`: `"iso"` \| `"s"` \| `"ms"`; \} \| `undefined`\> Defined in: [temporal/src/index.ts:216](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/temporal/src/index.ts#L216) ISO 8601 or a number ↔ `Temporal.Duration`. The `unit` option is `'iso'` (default), `'s'` or `'ms'`. Each unit is kept on the wire. `equals` compares years, months, weeks and days per unit and the rest by length: `PT1H` equals `PT60M`, but `P1M` is not `P30D`. --- **Millwork** *** Millwork / @millwork-ts/temporal / epoch # Variable: epoch > `const` **epoch**: `Codec`\<`number` \| `string`, `Temporal.Instant`, \{ `unit?`: `EpochUnit`; \} \| `undefined`\> Defined in: [temporal/src/index.ts:140](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/temporal/src/index.ts#L140) An epoch number ↔ `Temporal.Instant`. The `unit` option is `'s'`, `'ms'` (default), `'us'` or `'ns'`. `serialize` writes a number when it is a safe integer, and a string for `'ns'`. --- **Millwork** *** Millwork / @millwork-ts/temporal / interval # Variable: interval > `const` **interval**: `Codec`\<`IntervalRaw`, `TemporalInterval`, `IntervalOptions` \| `undefined`\> Defined in: [temporal/src/index.ts:232](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/temporal/src/index.ts#L232) `"a/b"`, `"a/PT1H"`, `"P1D/b"` or `{ start, end }` ↔ a frozen `{ start, end }` of `Temporal.Instant`. A duration is added in UTC. Both ends must be there. --- **Millwork** *** Millwork / @millwork-ts/temporal / localDateTime # Variable: localDateTime > `const` **localDateTime**: `Codec`\<`string`, `Temporal.PlainDateTime`\> Defined in: [temporal/src/index.ts:160](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/temporal/src/index.ts#L160) `"2026-12-01T14:30:00"` ↔ `Temporal.PlainDateTime`. --- **Millwork** *** Millwork / @millwork-ts/temporal / temporalFamily # Variable: temporalFamily > `const` **temporalFamily**: `Readonly`\<\{ `date`: () => `Codec`\<`string`, `PlainDate`, `undefined`\>; `datetime`: () => `Codec`\<`string`, `Instant`, \{ `keepOffset?`: `boolean`; \} \| `undefined`\>; `duration`: () => `Codec`\<`string` \| `number`, `Duration`, \{ `unit?`: `"s"` \| `"ms"` \| `"iso"`; \} \| `undefined`\>; `epoch`: () => `Codec`\<`string` \| `number`, `Instant`, \{ `unit?`: `EpochUnit`; \} \| `undefined`\>; `interval`: () => `Codec`\<`IntervalRaw`, `TemporalInterval`, `IntervalOptions` \| `undefined`\>; `localDateTime`: () => `Codec`\<`string`, `PlainDateTime`, `undefined`\>; `name`: `"temporal"`; `time`: () => `Codec`\<`string`, `PlainTime`, `undefined`\>; `yearMonth`: () => `Codec`\<`string`, `PlainYearMonth`, `undefined`\>; `zonedDateTime`: (`options?`) => `Codec`\<`ZonedRaw`, `ZonedDateTime`, `ZonedOptions` \| `undefined`\>; \}\> Defined in: [temporal/src/index.ts:264](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/temporal/src/index.ts#L264) The Temporal date family. `zonedDateTime({ strict: true })` also compares the calendar. --- **Millwork** *** Millwork / @millwork-ts/temporal / time # Variable: time > `const` **time**: `Codec`\<`string`, `Temporal.PlainTime`\> Defined in: [temporal/src/index.ts:151](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/temporal/src/index.ts#L151) `"14:30:00"` ↔ `Temporal.PlainTime`. --- **Millwork** *** Millwork / @millwork-ts/temporal / yearMonth # Variable: yearMonth > `const` **yearMonth**: `Codec`\<`string`, `Temporal.PlainYearMonth`\> Defined in: [temporal/src/index.ts:203](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/temporal/src/index.ts#L203) `"2026-12"` ↔ `Temporal.PlainYearMonth`. --- **Millwork** *** Millwork / @millwork-ts/temporal / zonedDateTime # Variable: zonedDateTime > `const` **zonedDateTime**: `Codec`\<`ZonedRaw`, `Temporal.ZonedDateTime`, `ZonedOptions` \| `undefined`\> Defined in: [temporal/src/index.ts:199](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/temporal/src/index.ts#L199) RFC 9557 `"…-05:00[America/Toronto]"` or `{ at, zone }` ↔ `Temporal.ZonedDateTime`. The wire offset must be the offset of the zone at that instant. `equals` compares the instant and the zone. The `wire` option sets the form that `serialize` writes. --- **Millwork** *** Millwork / @millwork-ts/warp-drive # @millwork-ts/warp-drive Millwork for WarpDrive and ember-data: codecs as Transformations and `@attr` transforms, and shapes and values as record fields. **Docs:** [joegaudet.com/millwork](https://joegaudet.com/millwork/) · [Guide](https://joegaudet.com/millwork/guide/#schema-record) · [API](https://joegaudet.com/millwork/api/) ## Install ```bash pnpm add @millwork-ts/warp-drive @millwork-ts/core ``` The peer is `@warp-drive/core` 5.8 or later. The package is a v2 Ember addon: it gives the app one `transform:` for each core codec. ## The store `transformations()` gives every Millwork Transformation: each codec (and its `array:` form), shapes and value classes. Core codecs are in the registry already. Register the codecs of other packages first, because `transformations()` reads the registry when you call it. ```ts import { codecs as luxon } from '@millwork-ts/luxon' import { registerCodecs, transformations } from '@millwork-ts/warp-drive' import { useLegacyStore } from '@warp-drive/legacy' import { JSONAPICache } from '@warp-drive/json-api' registerCodecs(luxon) export default useLegacyStore({ linksMode: true, cache: JSONAPICache, schemas: [InvoiceSchema], transformations: transformations(), }) ``` ## SchemaRecord fields | Helper | Field | | ---------------------------------------- | -------------------------------------------------------------------------- | | `valueField(name, codec?, options?)` | A value. The codec is a name, a codec object or a `Value` class. | | `valueArrayField(name, codec, options?)` | A list of values. The codec runs on each element. | | `shapeField(name, Class, options?)` | A shape. A map of classes makes a polymorphic shape. | | `shapeArrayField(name, Class, { key })` | A `ShapeArray`. `key` names the field that gives each member its identity. | ```ts import { shapeArrayField, shapeField, valueField } from '@millwork-ts/warp-drive' import { withDefaults } from '@warp-drive/core/reactive' export const InvoiceSchema = withDefaults({ type: 'invoice', fields: [ valueField('total', 'money', { wire: 'decimal' }), valueField('issuedAt', 'datetime'), shapeField('billTo', Address), shapeArrayField('items', LineItem, { key: 'sku' }), shapeField('payment', { card: Card, bank: Bank }, { discriminator: '$type' }), ], }) ``` - Each helper makes a `kind: 'field'` field. Do not use `kind: 'object'` or `schema-object` for a Millwork field ([ADR 0001](https://github.com/joegaudet/millwork/blob/main/docs/adr/0001-codec-field-kind.md), [ADR 0007](https://github.com/joegaudet/millwork/blob/main/docs/adr/0007-shape-field-kind.md)). - A read is memoized: `invoice.total === invoice.total`. - A shape writes the whole top-level raw value ([ADR 0005](https://github.com/joegaudet/millwork/blob/main/docs/adr/0005-nested-write-strategy.md)). ### Polaris records A Polaris record is immutable. Use `checkout` from this package, not from WarpDrive. It records the store, so the editable copy can read its remote values ([ADR 0009](https://github.com/joegaudet/millwork/blob/main/docs/adr/0009-checkout-store.md)). ```ts import { checkout } from '@millwork-ts/warp-drive' const draft = await checkout(invoice) draft.billTo.city = 'Montreal' draft.billTo.isDirty // true ``` ## The legacy door The `@millwork-ts/warp-drive/legacy` entry loads no WarpDrive code at run time. ### `@attr` transforms Each core codec is an app transform, so `@attr('money', { wire: 'decimal' })` needs no file in the app. Give a codec from another package to `registerTransforms` in an instance initializer: ```ts import type ApplicationInstance from '@ember/application/instance' import { datetime } from '@millwork-ts/luxon' import { registerTransforms } from '@millwork-ts/warp-drive/legacy' export function initialize(owner: ApplicationInstance) { registerTransforms(owner, { datetime }) } export default { initialize } ``` ember-data runs an `@attr` transform only in a serializer. `store.push` does not run it, so a pushed `Model` record shows the raw value. For pushed data, use a schema field. ### Shapes: the class form A `Model` attribute cannot hold a shape. Put the fields on a plain class, and make a legacy-mode schema with `modelSchema`: ```ts import type { Money, ShapeArray } from '@millwork-ts/core' import { modelSchema, shape, shapeArray, value } from '@millwork-ts/warp-drive/legacy' import { withDefaults } from '@warp-drive/legacy/model/migration-support' class OrderFields { @value() declare customer: string @value('money', { wire: 'decimal' }) declare total: Money @shape(Address) declare shipTo: Address @shapeArray(LineItem, { key: 'sku' }) declare items: ShapeArray } export const OrderSchema = withDefaults(modelSchema('order', OrderFields)) ``` The record is editable with no `checkout`, and `rollbackAttributes()` works for the whole record ([ADR 0003](https://github.com/joegaudet/millwork/blob/main/docs/adr/0003-legacy-door-base.md), [ADR 0012](https://github.com/joegaudet/millwork/blob/main/docs/adr/0012-legacy-door-and-registration.md)). ## License MIT ## Modules - index - legacy --- **Millwork** *** Millwork / @millwork-ts/warp-drive / index # index ## Interfaces - ShapeArrayFieldOptions - ShapeFieldOptions ## Type Aliases - ShapeFieldRef - ValueRef ## Variables - SHAPE\_TYPE - VALUE\_TYPE ## Functions - checkout - elementTransformation - registerCodecs - registerShapes - shapeArrayField - shapeField - transformation - transformations - valueArrayField - valueField ## References ### codecTransform Re-exports codecTransform *** ### CodecTransform Re-exports CodecTransform *** ### MoneyTransform Re-exports MoneyTransform *** ### Transforms Re-exports Transforms --- **Millwork** *** Millwork / @millwork-ts/warp-drive / index / checkout # Function: checkout() > **checkout**\<`T`\>(`record`): `Promise`\<`T`\> Defined in: [warp-drive/src/transformation.ts:93](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/warp-drive/src/transformation.ts#L93) WarpDrive `checkout`, for a Polaris record with Millwork fields. It records the store of the record first, so the editable copy can read the remote raw values (dirty state, rollback, and the `equals` check that clears a change). ## Type Parameters ### T `T` ## Parameters ### record `T` ## Returns `Promise`\<`T`\> --- **Millwork** *** Millwork / @millwork-ts/warp-drive / index / elementTransformation # Function: elementTransformation() > **elementTransformation**\<`Raw`, `V`, `O`\>(`codec`, `name?`): `Transformation`\<`Value`, `V` \| `undefined`\> Defined in: [warp-drive/src/transformation.ts:194](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/warp-drive/src/transformation.ts#L194) The `array:` Transformation: WarpDrive runs it on each element of a `kind: 'array'`. ## Type Parameters ### Raw `Raw` ### V `V` ### O `O` ## Parameters ### codec `Codec`\<`Raw`, `V`, `O`\> ### name? `string` = `codec.name` ## Returns `Transformation`\<`Value`, `V` \| `undefined`\> --- **Millwork** *** Millwork / @millwork-ts/warp-drive / index / registerCodecs # Function: registerCodecs() > **registerCodecs**(`map`): `void` Defined in: core/dist/shapes/registry.d.ts:14 Adds codecs to the name registry, so a field can name them (`@field('datetime')`, `valueField('at', 'datetime')`). Adapter packages give their codecs to the app; the app registers them once, before the first read. A name that is already there is replaced. ## Parameters ### map `Readonly`\<`Record`\<`string`, `AnyCodec`\>\> ## Returns `void` --- **Millwork** *** Millwork / @millwork-ts/warp-drive / index / registerShapes # Function: registerShapes() > **registerShapes**(...`args`): `void` Defined in: core/dist/shapes/registry.d.ts:29 Adds shape and value classes to the name registry, by their static `type`. A class can register again. A different class with a `type` that is already there throws a `TypeError`, unless the last argument is `{ replace: true }`. ## Parameters ### args `NamedClass`[] \| \[`...NamedClass[]`, `RegisterShapesOptions`\] ## Returns `void` --- **Millwork** *** Millwork / @millwork-ts/warp-drive / index / shapeArrayField # Function: shapeArrayField() > **shapeArrayField**(`name`, `ref`, `options?`): `GenericField` Defined in: [warp-drive/src/fields.ts:103](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/warp-drive/src/fields.ts#L103) A shape array field: `shapeArrayField('items', LineItem, { key: 'sku' })`. ## Parameters ### name `string` ### ref `ShapeFieldRef` ### options? `ShapeArrayFieldOptions` ## Returns `GenericField` --- **Millwork** *** Millwork / @millwork-ts/warp-drive / index / shapeField # Function: shapeField() > **shapeField**(`name`, `ref`, `options?`): `GenericField` Defined in: [warp-drive/src/fields.ts:89](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/warp-drive/src/fields.ts#L89) A shape field: `shapeField('shipTo', Address)`, or polymorphic: `shapeField('payment', { card: Card, bank: Bank }, { discriminator: '$type' })`. The record gives the shape instance. A shape writes the whole top-level raw value (ADR 0005), so it never uses the nested `setAttr` path. ## Parameters ### name `string` ### ref `ShapeFieldRef` ### options? `ShapeFieldOptions` ## Returns `GenericField` --- **Millwork** *** Millwork / @millwork-ts/warp-drive / index / transformation # Function: transformation() > **transformation**\<`Raw`, `V`, `O`\>(`codec`, `name?`): `Transformation`\<`Value`, `V` \| `undefined`\> Defined in: [warp-drive/src/transformation.ts:174](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/warp-drive/src/transformation.ts#L174) A WarpDrive Transformation for a codec, for `kind: 'field'`. Register it under the codec name, or another name: `type` on the field names it. `hydrate` is memoized per record and field (use `valueField`, which puts the field name in the options). Bad raw values give `undefined`; the codec reports them through `onInvalid`. ## Type Parameters ### Raw `Raw` ### V `V` ### O `O` ## Parameters ### codec `Codec`\<`Raw`, `V`, `O`\> ### name? `string` = `codec.name` ## Returns `Transformation`\<`Value`, `V` \| `undefined`\> --- **Millwork** *** Millwork / @millwork-ts/warp-drive / index / transformations # Function: transformations() > **transformations**(`map?`): `Transformation`\<`Value`, `unknown`\>[] Defined in: [warp-drive/src/transformation.ts:289](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/warp-drive/src/transformation.ts#L289) Every Transformation that Millwork fields need, for the store's `transformations`: each codec (and its `array:` variant), shapes and value classes. With no map, it takes each core codec and each codec from `registerCodecs`. ## Parameters ### map? `Readonly`\<`Record`\<`string`, `Codec`\<`never`, `unknown`, `never`\> \| `AnyCodec`\>\> = `...` ## Returns `Transformation`\<`Value`, `unknown`\>[] --- **Millwork** *** Millwork / @millwork-ts/warp-drive / index / valueArrayField # Function: valueArrayField() > **valueArrayField**(`name`, `ref`, `options?`): `ArrayField` Defined in: [warp-drive/src/fields.ts:60](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/warp-drive/src/fields.ts#L60) A `kind: 'array'` schema field: the codec runs on each element (`array:`). ## Parameters ### name `string` ### ref `ValueRef` ### options? `object` ## Returns `ArrayField` --- **Millwork** *** Millwork / @millwork-ts/warp-drive / index / valueField # Function: valueField() > **valueField**(`name`, `ref?`, `options?`): `GenericField` Defined in: [warp-drive/src/fields.ts:53](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/warp-drive/src/fields.ts#L53) A `kind: 'field'` schema field for a value: a codec (or its name) or a `Value` class. The field name goes in `options.field`, because WarpDrive does not give it to `hydrate`. With no codec, it is a plain field. ## Parameters ### name `string` ### ref? `ValueRef` ### options? `object` ## Returns `GenericField` --- **Millwork** *** Millwork / @millwork-ts/warp-drive / index / ShapeArrayFieldOptions # Interface: ShapeArrayFieldOptions Defined in: [warp-drive/src/fields.ts:33](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/warp-drive/src/fields.ts#L33) The options of a shape array field. ## Extends - `ShapeFieldOptions` ## Properties ### discriminator? > `optional` **discriminator?**: `string` Defined in: [warp-drive/src/fields.ts:29](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/warp-drive/src/fields.ts#L29) The discriminator key in the raw value. The default is `$type`. #### Inherited from `ShapeFieldOptions`.`discriminator` *** ### key? > `optional` **key?**: `string` Defined in: [warp-drive/src/fields.ts:35](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/warp-drive/src/fields.ts#L35) The field that gives each member its identity. Without it, the index does. --- **Millwork** *** Millwork / @millwork-ts/warp-drive / index / ShapeFieldOptions # Interface: ShapeFieldOptions Defined in: [warp-drive/src/fields.ts:27](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/warp-drive/src/fields.ts#L27) The options of a polymorphic shape field. ## Extended by - `ShapeArrayFieldOptions` ## Properties ### discriminator? > `optional` **discriminator?**: `string` Defined in: [warp-drive/src/fields.ts:29](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/warp-drive/src/fields.ts#L29) The discriminator key in the raw value. The default is `$type`. --- **Millwork** *** Millwork / @millwork-ts/warp-drive / index / ShapeFieldRef # Type Alias: ShapeFieldRef > **ShapeFieldRef** = `StructuredClass` \| `Readonly`\<`Record`\<`string`, `StructuredClass`\>\> Defined in: [warp-drive/src/fields.ts:24](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/warp-drive/src/fields.ts#L24) A shape class, or a map of discriminator values to shape classes (polymorphic). --- **Millwork** *** Millwork / @millwork-ts/warp-drive / index / ValueRef # Type Alias: ValueRef > **ValueRef** = `string` \| `Codec`\<`never`, `unknown`, `never`\> \| `AnyCodec` \| `StructuredClass`\<`Value`\> Defined in: [warp-drive/src/fields.ts:21](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/warp-drive/src/fields.ts#L21) A codec, its registered name, or a `Value` class. --- **Millwork** *** Millwork / @millwork-ts/warp-drive / index / SHAPE\_TYPE # Variable: SHAPE\_TYPE > `const` **SHAPE\_TYPE**: `"millwork:shape"` = `'millwork:shape'` Defined in: [warp-drive/src/fields.ts:16](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/warp-drive/src/fields.ts#L16) The Transformation name of every shape field. Its options name the shape. --- **Millwork** *** Millwork / @millwork-ts/warp-drive / index / VALUE\_TYPE # Variable: VALUE\_TYPE > `const` **VALUE\_TYPE**: `"millwork:value"` = `'millwork:value'` Defined in: [warp-drive/src/fields.ts:18](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/warp-drive/src/fields.ts#L18) The Transformation name of a field that holds a `Value` class. --- **Millwork** *** Millwork / @millwork-ts/warp-drive / legacy # legacy ## Classes - CodecTransform ## Interfaces - CodecTransformClass - ModelDecorator - TransformOwner ## Type Aliases - CodecTransformFor - MoneyTransform - Transforms - Wire ## Variables - transforms ## Functions - codecTransform - modelSchema - registerTransforms - shape - shapeArray - value ## References ### shapeArrayField Re-exports shapeArrayField *** ### shapeField Re-exports shapeField *** ### valueArrayField Re-exports valueArrayField *** ### valueField Re-exports valueField --- **Millwork** *** Millwork / @millwork-ts/warp-drive / legacy / CodecTransform # Class: CodecTransform\ Defined in: [warp-drive/src/legacy.ts:38](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/warp-drive/src/legacy.ts#L38) The legacy ember-data transform of one codec. ember-data gives the `@attr` options to the transform, so `@attr('money', { wire: 'decimal' })` reads the decimal wire form. Note: ember-data runs a transform only in a serializer. `store.push` does not run it, so a pushed record shows the raw value. Use a SchemaRecord field (`valueField`) for pushed data. ## Type Parameters ### V `V` = `unknown` ### O `O` = `unknown` ### Raw `Raw` = `unknown` ## Constructors ### Constructor > **new CodecTransform**\<`V`, `O`, `Raw`\>(`codec`): `CodecTransform`\<`V`, `O`, `Raw`\> Defined in: [warp-drive/src/legacy.ts:41](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/warp-drive/src/legacy.ts#L41) #### Parameters ##### codec `AnyCodec` #### Returns `CodecTransform`\<`V`, `O`, `Raw`\> ## Methods ### deserialize() > **deserialize**(`serialized`, `options?`): `V` \| `undefined` Defined in: [warp-drive/src/legacy.ts:46](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/warp-drive/src/legacy.ts#L46) The raw value from the payload as the rich value. Bad raw data gives `undefined`. #### Parameters ##### serialized `Raw` \| `null` \| `undefined` ##### options? `O` \| `null` #### Returns `V` \| `undefined` *** ### serialize() > **serialize**(`deserialized`, `options?`): `Raw` \| `null` Defined in: [warp-drive/src/legacy.ts:51](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/warp-drive/src/legacy.ts#L51) The rich value back to its raw form. `null` for a missing value. #### Parameters ##### deserialized `V` \| `null` \| `undefined` ##### options? `O` \| `null` #### Returns `Raw` \| `null` --- **Millwork** *** Millwork / @millwork-ts/warp-drive / legacy / codecTransform # Function: codecTransform() > **codecTransform**\<`C`, `Name`\>(`codec`): `CodecTransformClass`\<`Name`, `C`\> Defined in: [warp-drive/src/legacy.ts:88](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/warp-drive/src/legacy.ts#L88) A legacy ember-data transform for one codec: `export default codecTransform(datetime)` from `app/transforms/datetime.js`. ## Type Parameters ### C `C` *extends* `Codec`\<`never`, `unknown`, `never`\> \| `AnyCodec` ### Name `Name` *extends* `string` = `string` ## Parameters ### codec `C` ## Returns `CodecTransformClass`\<`Name`, `C`\> --- **Millwork** *** Millwork / @millwork-ts/warp-drive / legacy / modelSchema # Function: modelSchema() > **modelSchema**(`type`, `cls`): `object` Defined in: [warp-drive/src/legacy.ts:194](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/warp-drive/src/legacy.ts#L194) The fields of a decorated model class, as the input of `withDefaults` from `@warp-drive/legacy/model/migration-support`: `withDefaults(modelSchema('order', Order))`. A legacy `Model` attribute cannot hold a shape (ADR 0003), so the class form makes a legacy-mode schema. ## Parameters ### type `string` ### cls new (...`args`) => `unknown` ## Returns `object` ### fields > **fields**: `GenericField`[] ### type > **type**: `string` --- **Millwork** *** Millwork / @millwork-ts/warp-drive / legacy / registerTransforms # Function: registerTransforms() > **registerTransforms**(`owner`, `map`): `void` Defined in: [warp-drive/src/legacy.ts:131](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/warp-drive/src/legacy.ts#L131) Adds adapter codecs to both doors by name: to the codec registry (for SchemaRecord fields and shapes) and to the owner as `transform:` (for `@attr`). Call it in an instance initializer: `registerTransforms(owner, { datetime, duration })`. ## Parameters ### owner `TransformOwner` ### map `Readonly`\<`Record`\<`string`, `Codec`\<`never`, `unknown`, `never`\> \| `AnyCodec`\>\> ## Returns `void` --- **Millwork** *** Millwork / @millwork-ts/warp-drive / legacy / shape # Function: shape() > **shape**(`ref`, `options?`): `ModelDecorator` Defined in: [warp-drive/src/legacy.ts:174](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/warp-drive/src/legacy.ts#L174) A shape field on a model class: `@shape(Address) declare shipTo: Address`. ## Parameters ### ref `ShapeFieldRef` ### options? `ShapeFieldOptions` ## Returns `ModelDecorator` --- **Millwork** *** Millwork / @millwork-ts/warp-drive / legacy / shapeArray # Function: shapeArray() > **shapeArray**(`ref`, `options?`): `ModelDecorator` Defined in: [warp-drive/src/legacy.ts:179](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/warp-drive/src/legacy.ts#L179) A shape array field: `@shapeArray(LineItem, { key: 'sku' }) declare items: …`. ## Parameters ### ref `ShapeFieldRef` ### options? `ShapeArrayFieldOptions` ## Returns `ModelDecorator` --- **Millwork** *** Millwork / @millwork-ts/warp-drive / legacy / value # Function: value() > **value**(`ref?`, `options?`): `ModelDecorator` Defined in: [warp-drive/src/legacy.ts:184](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/warp-drive/src/legacy.ts#L184) A value field: `@value('money', { wire: 'decimal' }) declare total: Money`. No codec: plain. ## Parameters ### ref? `ValueRef` ### options? `object` ## Returns `ModelDecorator` --- **Millwork** *** Millwork / @millwork-ts/warp-drive / legacy / CodecTransformClass # Interface: CodecTransformClass\ Defined in: [warp-drive/src/legacy.ts:78](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/warp-drive/src/legacy.ts#L78) The transform class of one codec. ## Type Parameters ### Name `Name` *extends* `string` ### C `C` ## Constructors ### Constructor > **new CodecTransformClass**(): `CodecTransformFor`\<`Name`, `C`\> Defined in: [warp-drive/src/legacy.ts:79](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/warp-drive/src/legacy.ts#L79) #### Returns `CodecTransformFor`\<`Name`, `C`\> ## Methods ### create() > **create**(): `CodecTransformFor`\<`Name`, `C`\> Defined in: [warp-drive/src/legacy.ts:81](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/warp-drive/src/legacy.ts#L81) Makes a transform. ember-data calls it. #### Returns `CodecTransformFor`\<`Name`, `C`\> --- **Millwork** *** Millwork / @millwork-ts/warp-drive / legacy / ModelDecorator # Interface: ModelDecorator() Defined in: [warp-drive/src/legacy.ts:153](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/warp-drive/src/legacy.ts#L153) A decorator for a model class, for legacy (Ember, `declare`) and standard decorators. ## Call Signature > **ModelDecorator**(`target`, `context`): `void` Defined in: [warp-drive/src/legacy.ts:154](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/warp-drive/src/legacy.ts#L154) A decorator for a model class, for legacy (Ember, `declare`) and standard decorators. ### Parameters #### target `unknown` #### context `ClassFieldDecoratorContext`\<`unknown`, `unknown`\> \| `ClassAccessorDecoratorContext`\<`unknown`, `unknown`\> ### Returns `void` ## Call Signature > **ModelDecorator**(`prototype`, `key`): `void` Defined in: [warp-drive/src/legacy.ts:155](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/warp-drive/src/legacy.ts#L155) A decorator for a model class, for legacy (Ember, `declare`) and standard decorators. ### Parameters #### prototype `object` #### key `string` ### Returns `void` --- **Millwork** *** Millwork / @millwork-ts/warp-drive / legacy / TransformOwner # Interface: TransformOwner Defined in: [warp-drive/src/legacy.ts:121](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/warp-drive/src/legacy.ts#L121) What `registerTransforms` needs: the app owner (`ApplicationInstance` or `Owner`). ## Methods ### register() > **register**(`fullName`, `factory`): `void` Defined in: [warp-drive/src/legacy.ts:123](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/warp-drive/src/legacy.ts#L123) Registers a factory under the full name, for example `transform:datetime`. #### Parameters ##### fullName `string` ##### factory `unknown` #### Returns `void` --- **Millwork** *** Millwork / @millwork-ts/warp-drive / legacy / CodecTransformFor # Type Alias: CodecTransformFor\ > **CodecTransformFor**\<`Name`, `C`\> = `CodecTransform`\<`ValueOf`\<`C`\>, `OptionsOf`\<`C`\>, `Wire`\<`RawOf`\<`C`\>\>\> & `object` Defined in: [warp-drive/src/legacy.ts:71](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/warp-drive/src/legacy.ts#L71) A transform instance of one codec, with the brand that `@attr(name, options)` checks. ## Type Parameters ### Name `Name` *extends* `string` ### C `C` ## Type Declaration ### \_\_\_(unique) Symbol($type) > **\_\_\_(unique) Symbol($type)**: `Name` --- **Millwork** *** Millwork / @millwork-ts/warp-drive / legacy / MoneyTransform # Type Alias: MoneyTransform > **MoneyTransform** = `InstanceType`\<`Transforms`\[`"money"`\]\> Defined in: [warp-drive/src/legacy.ts:118](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/warp-drive/src/legacy.ts#L118) The `money` transform instance, for `@attr('money', { wire: 'decimal' })`. --- **Millwork** *** Millwork / @millwork-ts/warp-drive / legacy / Transforms # Type Alias: Transforms > **Transforms** = `{ [K in keyof CoreCodecs & string]: CodecTransformClass }` Defined in: [warp-drive/src/legacy.ts:107](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/warp-drive/src/legacy.ts#L107) The transform classes of the core codecs, by name. --- **Millwork** *** Millwork / @millwork-ts/warp-drive / legacy / Wire # Type Alias: Wire\ > **Wire**\<`Raw`\> = \[`Raw`\] *extends* \[`string`\] ? `string` : \[`Raw`\] *extends* \[`number`\] ? `number` : \[`Raw`\] *extends* \[`boolean`\] ? `boolean` : \[`Raw`\] *extends* \[readonly `unknown`[]\] ? `ArrayValue` : `ObjectValue` Defined in: [warp-drive/src/legacy.ts:60](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/warp-drive/src/legacy.ts#L60) The main JSON type of a raw form, for the ember-data attr types. They accept one JSON type for each transform, so a codec with more than one raw form gets the object type. ## Type Parameters ### Raw `Raw` --- **Millwork** *** Millwork / @millwork-ts/warp-drive / legacy / transforms # Variable: transforms > `const` **transforms**: `Transforms` Defined in: [warp-drive/src/legacy.ts:113](https://github.com/joegaudet/millwork/blob/v1.0.0/packages/warp-drive/src/legacy.ts#L113) One transform for each core codec. The Ember build merges them into the app as `transform:` (`app-js`), so `@attr('money', { wire: 'decimal' })` needs no file.