@azx-pbc/axiom-runtime 0.0.0-stage → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +714 -2
- package/dist/cache/index.d.ts +191 -0
- package/dist/cache/index.d.ts.map +1 -0
- package/dist/cache/index.js +361 -0
- package/dist/cache/index.js.map +1 -0
- package/dist/canonical/jcs.d.ts +78 -0
- package/dist/canonical/jcs.d.ts.map +1 -0
- package/dist/canonical/jcs.js +500 -0
- package/dist/canonical/jcs.js.map +1 -0
- package/dist/canonical/restricted-json.d.ts +7 -0
- package/dist/canonical/restricted-json.d.ts.map +1 -0
- package/dist/canonical/restricted-json.js +318 -0
- package/dist/canonical/restricted-json.js.map +1 -0
- package/dist/canonical/restricted-value.d.ts +59 -0
- package/dist/canonical/restricted-value.d.ts.map +1 -0
- package/dist/canonical/restricted-value.js +156 -0
- package/dist/canonical/restricted-value.js.map +1 -0
- package/dist/canonical/restricted.d.ts +85 -0
- package/dist/canonical/restricted.d.ts.map +1 -0
- package/dist/canonical/restricted.js +163 -0
- package/dist/canonical/restricted.js.map +1 -0
- package/dist/canonical/signature.d.ts +38 -0
- package/dist/canonical/signature.d.ts.map +1 -0
- package/dist/canonical/signature.js +47 -0
- package/dist/canonical/signature.js.map +1 -0
- package/dist/eval/access/delivery.d.ts +63 -0
- package/dist/eval/access/delivery.d.ts.map +1 -0
- package/dist/eval/access/delivery.js +98 -0
- package/dist/eval/access/delivery.js.map +1 -0
- package/dist/eval/access/overlay.d.ts +72 -0
- package/dist/eval/access/overlay.d.ts.map +1 -0
- package/dist/eval/access/overlay.js +402 -0
- package/dist/eval/access/overlay.js.map +1 -0
- package/dist/eval/access/projection.d.ts +159 -0
- package/dist/eval/access/projection.d.ts.map +1 -0
- package/dist/eval/access/projection.js +211 -0
- package/dist/eval/access/projection.js.map +1 -0
- package/dist/eval/access/window.d.ts +128 -0
- package/dist/eval/access/window.d.ts.map +1 -0
- package/dist/eval/access/window.js +254 -0
- package/dist/eval/access/window.js.map +1 -0
- package/dist/eval/access/write.d.ts +113 -0
- package/dist/eval/access/write.d.ts.map +1 -0
- package/dist/eval/access/write.js +119 -0
- package/dist/eval/access/write.js.map +1 -0
- package/dist/eval/addressing.d.ts +131 -0
- package/dist/eval/addressing.d.ts.map +1 -0
- package/dist/eval/addressing.js +270 -0
- package/dist/eval/addressing.js.map +1 -0
- package/dist/eval/budget.d.ts +143 -0
- package/dist/eval/budget.d.ts.map +1 -0
- package/dist/eval/budget.js +387 -0
- package/dist/eval/budget.js.map +1 -0
- package/dist/eval/computed.d.ts +46 -0
- package/dist/eval/computed.d.ts.map +1 -0
- package/dist/eval/computed.js +89 -0
- package/dist/eval/computed.js.map +1 -0
- package/dist/eval/denials.d.ts +64 -0
- package/dist/eval/denials.d.ts.map +1 -0
- package/dist/eval/denials.js +87 -0
- package/dist/eval/denials.js.map +1 -0
- package/dist/eval/engine/cancellation.d.ts +12 -0
- package/dist/eval/engine/cancellation.d.ts.map +1 -0
- package/dist/eval/engine/cancellation.js +56 -0
- package/dist/eval/engine/cancellation.js.map +1 -0
- package/dist/eval/engine/delta.d.ts +104 -0
- package/dist/eval/engine/delta.d.ts.map +1 -0
- package/dist/eval/engine/delta.js +466 -0
- package/dist/eval/engine/delta.js.map +1 -0
- package/dist/eval/engine/deps.d.ts +136 -0
- package/dist/eval/engine/deps.d.ts.map +1 -0
- package/dist/eval/engine/deps.js +345 -0
- package/dist/eval/engine/deps.js.map +1 -0
- package/dist/eval/engine/identity.d.ts +128 -0
- package/dist/eval/engine/identity.d.ts.map +1 -0
- package/dist/eval/engine/identity.js +398 -0
- package/dist/eval/engine/identity.js.map +1 -0
- package/dist/eval/engine/index.d.ts +200 -0
- package/dist/eval/engine/index.d.ts.map +1 -0
- package/dist/eval/engine/index.js +1242 -0
- package/dist/eval/engine/index.js.map +1 -0
- package/dist/eval/engine/measurement.d.ts +23 -0
- package/dist/eval/engine/measurement.d.ts.map +1 -0
- package/dist/eval/engine/measurement.js +42 -0
- package/dist/eval/engine/measurement.js.map +1 -0
- package/dist/eval/engine/naive.d.ts +19 -0
- package/dist/eval/engine/naive.d.ts.map +1 -0
- package/dist/eval/engine/naive.js +59 -0
- package/dist/eval/engine/naive.js.map +1 -0
- package/dist/eval/engine/ops.d.ts +214 -0
- package/dist/eval/engine/ops.d.ts.map +1 -0
- package/dist/eval/engine/ops.js +1422 -0
- package/dist/eval/engine/ops.js.map +1 -0
- package/dist/eval/engine/patches.d.ts +40 -0
- package/dist/eval/engine/patches.d.ts.map +1 -0
- package/dist/eval/engine/patches.js +125 -0
- package/dist/eval/engine/patches.js.map +1 -0
- package/dist/eval/engine/ports.d.ts +71 -0
- package/dist/eval/engine/ports.d.ts.map +1 -0
- package/dist/eval/engine/ports.js +2 -0
- package/dist/eval/engine/ports.js.map +1 -0
- package/dist/eval/engine/session.d.ts +116 -0
- package/dist/eval/engine/session.d.ts.map +1 -0
- package/dist/eval/engine/session.js +653 -0
- package/dist/eval/engine/session.js.map +1 -0
- package/dist/eval/engine/snapshot.d.ts +97 -0
- package/dist/eval/engine/snapshot.d.ts.map +1 -0
- package/dist/eval/engine/snapshot.js +221 -0
- package/dist/eval/engine/snapshot.js.map +1 -0
- package/dist/eval/engine/subscriptions.d.ts +47 -0
- package/dist/eval/engine/subscriptions.d.ts.map +1 -0
- package/dist/eval/engine/subscriptions.js +103 -0
- package/dist/eval/engine/subscriptions.js.map +1 -0
- package/dist/eval/engine/trace.d.ts +77 -0
- package/dist/eval/engine/trace.d.ts.map +1 -0
- package/dist/eval/engine/trace.js +140 -0
- package/dist/eval/engine/trace.js.map +1 -0
- package/dist/eval/error-diagnostic.d.ts +26 -0
- package/dist/eval/error-diagnostic.d.ts.map +1 -0
- package/dist/eval/error-diagnostic.js +63 -0
- package/dist/eval/error-diagnostic.js.map +1 -0
- package/dist/eval/evaluate-expr.d.ts +44 -0
- package/dist/eval/evaluate-expr.d.ts.map +1 -0
- package/dist/eval/evaluate-expr.js +149 -0
- package/dist/eval/evaluate-expr.js.map +1 -0
- package/dist/eval/evaluate.d.ts +282 -0
- package/dist/eval/evaluate.d.ts.map +1 -0
- package/dist/eval/evaluate.js +391 -0
- package/dist/eval/evaluate.js.map +1 -0
- package/dist/eval/evolution/relocate.d.ts +72 -0
- package/dist/eval/evolution/relocate.d.ts.map +1 -0
- package/dist/eval/evolution/relocate.js +427 -0
- package/dist/eval/evolution/relocate.js.map +1 -0
- package/dist/eval/evolution/select.d.ts +11 -0
- package/dist/eval/evolution/select.d.ts.map +1 -0
- package/dist/eval/evolution/select.js +53 -0
- package/dist/eval/evolution/select.js.map +1 -0
- package/dist/eval/evolution/upcast.d.ts +13 -0
- package/dist/eval/evolution/upcast.d.ts.map +1 -0
- package/dist/eval/evolution/upcast.js +88 -0
- package/dist/eval/evolution/upcast.js.map +1 -0
- package/dist/eval/expr/aggregates.d.ts +75 -0
- package/dist/eval/expr/aggregates.d.ts.map +1 -0
- package/dist/eval/expr/aggregates.js +991 -0
- package/dist/eval/expr/aggregates.js.map +1 -0
- package/dist/eval/expr/arithmetic.d.ts +26 -0
- package/dist/eval/expr/arithmetic.d.ts.map +1 -0
- package/dist/eval/expr/arithmetic.js +387 -0
- package/dist/eval/expr/arithmetic.js.map +1 -0
- package/dist/eval/expr/between.d.ts +17 -0
- package/dist/eval/expr/between.d.ts.map +1 -0
- package/dist/eval/expr/between.js +46 -0
- package/dist/eval/expr/between.js.map +1 -0
- package/dist/eval/expr/binder.d.ts +96 -0
- package/dist/eval/expr/binder.d.ts.map +1 -0
- package/dist/eval/expr/binder.js +253 -0
- package/dist/eval/expr/binder.js.map +1 -0
- package/dist/eval/expr/call-dispatch.d.ts +28 -0
- package/dist/eval/expr/call-dispatch.d.ts.map +1 -0
- package/dist/eval/expr/call-dispatch.js +114 -0
- package/dist/eval/expr/call-dispatch.js.map +1 -0
- package/dist/eval/expr/collections.d.ts +20 -0
- package/dist/eval/expr/collections.d.ts.map +1 -0
- package/dist/eval/expr/collections.js +66 -0
- package/dist/eval/expr/collections.js.map +1 -0
- package/dist/eval/expr/compare.d.ts +36 -0
- package/dist/eval/expr/compare.d.ts.map +1 -0
- package/dist/eval/expr/compare.js +115 -0
- package/dist/eval/expr/compare.js.map +1 -0
- package/dist/eval/expr/datasets.d.ts +28 -0
- package/dist/eval/expr/datasets.d.ts.map +1 -0
- package/dist/eval/expr/datasets.js +304 -0
- package/dist/eval/expr/datasets.js.map +1 -0
- package/dist/eval/expr/digest.d.ts +23 -0
- package/dist/eval/expr/digest.d.ts.map +1 -0
- package/dist/eval/expr/digest.js +89 -0
- package/dist/eval/expr/digest.js.map +1 -0
- package/dist/eval/expr/domains.d.ts +19 -0
- package/dist/eval/expr/domains.d.ts.map +1 -0
- package/dist/eval/expr/domains.js +18 -0
- package/dist/eval/expr/domains.js.map +1 -0
- package/dist/eval/expr/host.d.ts +152 -0
- package/dist/eval/expr/host.d.ts.map +1 -0
- package/dist/eval/expr/host.js +36 -0
- package/dist/eval/expr/host.js.map +1 -0
- package/dist/eval/expr/lists.d.ts +24 -0
- package/dist/eval/expr/lists.d.ts.map +1 -0
- package/dist/eval/expr/lists.js +155 -0
- package/dist/eval/expr/lists.js.map +1 -0
- package/dist/eval/expr/member.d.ts +15 -0
- package/dist/eval/expr/member.d.ts.map +1 -0
- package/dist/eval/expr/member.js +32 -0
- package/dist/eval/expr/member.js.map +1 -0
- package/dist/eval/expr/money-ops.d.ts +10 -0
- package/dist/eval/expr/money-ops.d.ts.map +1 -0
- package/dist/eval/expr/money-ops.js +17 -0
- package/dist/eval/expr/money-ops.js.map +1 -0
- package/dist/eval/expr/operands.d.ts +27 -0
- package/dist/eval/expr/operands.d.ts.map +1 -0
- package/dist/eval/expr/operands.js +167 -0
- package/dist/eval/expr/operands.js.map +1 -0
- package/dist/eval/expr/presence.d.ts +27 -0
- package/dist/eval/expr/presence.d.ts.map +1 -0
- package/dist/eval/expr/presence.js +140 -0
- package/dist/eval/expr/presence.js.map +1 -0
- package/dist/eval/expr/records.d.ts +22 -0
- package/dist/eval/expr/records.d.ts.map +1 -0
- package/dist/eval/expr/records.js +101 -0
- package/dist/eval/expr/records.js.map +1 -0
- package/dist/eval/expr/rule-refs.d.ts +25 -0
- package/dist/eval/expr/rule-refs.d.ts.map +1 -0
- package/dist/eval/expr/rule-refs.js +60 -0
- package/dist/eval/expr/rule-refs.js.map +1 -0
- package/dist/eval/expr/sequences.d.ts +26 -0
- package/dist/eval/expr/sequences.d.ts.map +1 -0
- package/dist/eval/expr/sequences.js +151 -0
- package/dist/eval/expr/sequences.js.map +1 -0
- package/dist/eval/expr/value.d.ts +99 -0
- package/dist/eval/expr/value.d.ts.map +1 -0
- package/dist/eval/expr/value.js +14 -0
- package/dist/eval/expr/value.js.map +1 -0
- package/dist/eval/expression.d.ts +142 -0
- package/dist/eval/expression.d.ts.map +1 -0
- package/dist/eval/expression.js +446 -0
- package/dist/eval/expression.js.map +1 -0
- package/dist/eval/firing.d.ts +68 -0
- package/dist/eval/firing.d.ts.map +1 -0
- package/dist/eval/firing.js +222 -0
- package/dist/eval/firing.js.map +1 -0
- package/dist/eval/gate.d.ts +110 -0
- package/dist/eval/gate.d.ts.map +1 -0
- package/dist/eval/gate.js +278 -0
- package/dist/eval/gate.js.map +1 -0
- package/dist/eval/layout-visibility.d.ts +18 -0
- package/dist/eval/layout-visibility.d.ts.map +1 -0
- package/dist/eval/layout-visibility.js +61 -0
- package/dist/eval/layout-visibility.js.map +1 -0
- package/dist/eval/option-availability.d.ts +26 -0
- package/dist/eval/option-availability.d.ts.map +1 -0
- package/dist/eval/option-availability.js +580 -0
- package/dist/eval/option-availability.js.map +1 -0
- package/dist/eval/options-boundary.d.ts +15 -0
- package/dist/eval/options-boundary.d.ts.map +1 -0
- package/dist/eval/options-boundary.js +40 -0
- package/dist/eval/options-boundary.js.map +1 -0
- package/dist/eval/options.d.ts +99 -0
- package/dist/eval/options.d.ts.map +1 -0
- package/dist/eval/options.js +96 -0
- package/dist/eval/options.js.map +1 -0
- package/dist/eval/overrides.d.ts +116 -0
- package/dist/eval/overrides.d.ts.map +1 -0
- package/dist/eval/overrides.js +176 -0
- package/dist/eval/overrides.js.map +1 -0
- package/dist/eval/paths.d.ts +25 -0
- package/dist/eval/paths.d.ts.map +1 -0
- package/dist/eval/paths.js +47 -0
- package/dist/eval/paths.js.map +1 -0
- package/dist/eval/presentation-reads.d.ts +20 -0
- package/dist/eval/presentation-reads.d.ts.map +1 -0
- package/dist/eval/presentation-reads.js +2 -0
- package/dist/eval/presentation-reads.js.map +1 -0
- package/dist/eval/presentation.d.ts +122 -0
- package/dist/eval/presentation.d.ts.map +1 -0
- package/dist/eval/presentation.js +255 -0
- package/dist/eval/presentation.js.map +1 -0
- package/dist/eval/reader/context-value.d.ts +41 -0
- package/dist/eval/reader/context-value.d.ts.map +1 -0
- package/dist/eval/reader/context-value.js +129 -0
- package/dist/eval/reader/context-value.js.map +1 -0
- package/dist/eval/reader/covered.d.ts +53 -0
- package/dist/eval/reader/covered.d.ts.map +1 -0
- package/dist/eval/reader/covered.js +139 -0
- package/dist/eval/reader/covered.js.map +1 -0
- package/dist/eval/reader/declarations.d.ts +182 -0
- package/dist/eval/reader/declarations.d.ts.map +1 -0
- package/dist/eval/reader/declarations.js +153 -0
- package/dist/eval/reader/declarations.js.map +1 -0
- package/dist/eval/reader/member-access.d.ts +87 -0
- package/dist/eval/reader/member-access.d.ts.map +1 -0
- package/dist/eval/reader/member-access.js +212 -0
- package/dist/eval/reader/member-access.js.map +1 -0
- package/dist/eval/reader/memo.d.ts +34 -0
- package/dist/eval/reader/memo.d.ts.map +1 -0
- package/dist/eval/reader/memo.js +67 -0
- package/dist/eval/reader/memo.js.map +1 -0
- package/dist/eval/reader/overlay.d.ts +74 -0
- package/dist/eval/reader/overlay.d.ts.map +1 -0
- package/dist/eval/reader/overlay.js +365 -0
- package/dist/eval/reader/overlay.js.map +1 -0
- package/dist/eval/reader/questions.d.ts +37 -0
- package/dist/eval/reader/questions.d.ts.map +1 -0
- package/dist/eval/reader/questions.js +78 -0
- package/dist/eval/reader/questions.js.map +1 -0
- package/dist/eval/reader/resolve.d.ts +84 -0
- package/dist/eval/reader/resolve.d.ts.map +1 -0
- package/dist/eval/reader/resolve.js +310 -0
- package/dist/eval/reader/resolve.js.map +1 -0
- package/dist/eval/reader/value-read.d.ts +50 -0
- package/dist/eval/reader/value-read.d.ts.map +1 -0
- package/dist/eval/reader/value-read.js +133 -0
- package/dist/eval/reader/value-read.js.map +1 -0
- package/dist/eval/reader/withheld.d.ts +48 -0
- package/dist/eval/reader/withheld.d.ts.map +1 -0
- package/dist/eval/reader/withheld.js +108 -0
- package/dist/eval/reader/withheld.js.map +1 -0
- package/dist/eval/reader-paths.d.ts +24 -0
- package/dist/eval/reader-paths.d.ts.map +1 -0
- package/dist/eval/reader-paths.js +23 -0
- package/dist/eval/reader-paths.js.map +1 -0
- package/dist/eval/reader.d.ts +281 -0
- package/dist/eval/reader.d.ts.map +1 -0
- package/dist/eval/reader.js +560 -0
- package/dist/eval/reader.js.map +1 -0
- package/dist/eval/receipt.d.ts +37 -0
- package/dist/eval/receipt.d.ts.map +1 -0
- package/dist/eval/receipt.js +222 -0
- package/dist/eval/receipt.js.map +1 -0
- package/dist/eval/report/assemble.d.ts +84 -0
- package/dist/eval/report/assemble.d.ts.map +1 -0
- package/dist/eval/report/assemble.js +277 -0
- package/dist/eval/report/assemble.js.map +1 -0
- package/dist/eval/report/fold.d.ts +18 -0
- package/dist/eval/report/fold.d.ts.map +1 -0
- package/dist/eval/report/fold.js +58 -0
- package/dist/eval/report/fold.js.map +1 -0
- package/dist/eval/rule/alternatives.d.ts +23 -0
- package/dist/eval/rule/alternatives.d.ts.map +1 -0
- package/dist/eval/rule/alternatives.js +46 -0
- package/dist/eval/rule/alternatives.js.map +1 -0
- package/dist/eval/rule/behaviour.d.ts +47 -0
- package/dist/eval/rule/behaviour.d.ts.map +1 -0
- package/dist/eval/rule/behaviour.js +249 -0
- package/dist/eval/rule/behaviour.js.map +1 -0
- package/dist/eval/rule/compute.d.ts +46 -0
- package/dist/eval/rule/compute.d.ts.map +1 -0
- package/dist/eval/rule/compute.js +158 -0
- package/dist/eval/rule/compute.js.map +1 -0
- package/dist/eval/rule/create-state.d.ts +42 -0
- package/dist/eval/rule/create-state.d.ts.map +1 -0
- package/dist/eval/rule/create-state.js +134 -0
- package/dist/eval/rule/create-state.js.map +1 -0
- package/dist/eval/rule/diagnostics.d.ts +24 -0
- package/dist/eval/rule/diagnostics.d.ts.map +1 -0
- package/dist/eval/rule/diagnostics.js +45 -0
- package/dist/eval/rule/diagnostics.js.map +1 -0
- package/dist/eval/rule/execution.d.ts +24 -0
- package/dist/eval/rule/execution.d.ts.map +1 -0
- package/dist/eval/rule/execution.js +495 -0
- package/dist/eval/rule/execution.js.map +1 -0
- package/dist/eval/rule/gate.d.ts +12 -0
- package/dist/eval/rule/gate.d.ts.map +1 -0
- package/dist/eval/rule/gate.js +34 -0
- package/dist/eval/rule/gate.js.map +1 -0
- package/dist/eval/rule/item.d.ts +11 -0
- package/dist/eval/rule/item.d.ts.map +1 -0
- package/dist/eval/rule/item.js +265 -0
- package/dist/eval/rule/item.js.map +1 -0
- package/dist/eval/rule/prepare.d.ts +64 -0
- package/dist/eval/rule/prepare.d.ts.map +1 -0
- package/dist/eval/rule/prepare.js +131 -0
- package/dist/eval/rule/prepare.js.map +1 -0
- package/dist/eval/rule/result.d.ts +97 -0
- package/dist/eval/rule/result.d.ts.map +1 -0
- package/dist/eval/rule/result.js +347 -0
- package/dist/eval/rule/result.js.map +1 -0
- package/dist/eval/rule/runner.d.ts +128 -0
- package/dist/eval/rule/runner.d.ts.map +1 -0
- package/dist/eval/rule/runner.js +296 -0
- package/dist/eval/rule/runner.js.map +1 -0
- package/dist/eval/rule/screen.d.ts +32 -0
- package/dist/eval/rule/screen.d.ts.map +1 -0
- package/dist/eval/rule/screen.js +73 -0
- package/dist/eval/rule/screen.js.map +1 -0
- package/dist/eval/rule/state.d.ts +137 -0
- package/dist/eval/rule/state.d.ts.map +1 -0
- package/dist/eval/rule/state.js +2 -0
- package/dist/eval/rule/state.js.map +1 -0
- package/dist/eval/rule/steps.d.ts +44 -0
- package/dist/eval/rule/steps.d.ts.map +1 -0
- package/dist/eval/rule/steps.js +367 -0
- package/dist/eval/rule/steps.js.map +1 -0
- package/dist/eval/rule/visibility.d.ts +18 -0
- package/dist/eval/rule/visibility.d.ts.map +1 -0
- package/dist/eval/rule/visibility.js +79 -0
- package/dist/eval/rule/visibility.js.map +1 -0
- package/dist/eval/seal.d.ts +74 -0
- package/dist/eval/seal.d.ts.map +1 -0
- package/dist/eval/seal.js +154 -0
- package/dist/eval/seal.js.map +1 -0
- package/dist/eval/signature-coverage.d.ts +19 -0
- package/dist/eval/signature-coverage.d.ts.map +1 -0
- package/dist/eval/signature-coverage.js +160 -0
- package/dist/eval/signature-coverage.js.map +1 -0
- package/dist/eval/state/derive.d.ts +72 -0
- package/dist/eval/state/derive.d.ts.map +1 -0
- package/dist/eval/state/derive.js +61 -0
- package/dist/eval/state/derive.js.map +1 -0
- package/dist/eval/state/describe.d.ts +18 -0
- package/dist/eval/state/describe.d.ts.map +1 -0
- package/dist/eval/state/describe.js +19 -0
- package/dist/eval/state/describe.js.map +1 -0
- package/dist/eval/state/field-state.d.ts +471 -0
- package/dist/eval/state/field-state.d.ts.map +1 -0
- package/dist/eval/state/field-state.js +1604 -0
- package/dist/eval/state/field-state.js.map +1 -0
- package/dist/eval/state/measurement.d.ts +136 -0
- package/dist/eval/state/measurement.d.ts.map +1 -0
- package/dist/eval/state/measurement.js +209 -0
- package/dist/eval/state/measurement.js.map +1 -0
- package/dist/eval/state/options.d.ts +21 -0
- package/dist/eval/state/options.d.ts.map +1 -0
- package/dist/eval/state/options.js +3 -0
- package/dist/eval/state/options.js.map +1 -0
- package/dist/eval/state/readiness.d.ts +400 -0
- package/dist/eval/state/readiness.d.ts.map +1 -0
- package/dist/eval/state/readiness.js +1067 -0
- package/dist/eval/state/readiness.js.map +1 -0
- package/dist/eval/state/snapshot.d.ts +130 -0
- package/dist/eval/state/snapshot.d.ts.map +1 -0
- package/dist/eval/state/snapshot.js +35 -0
- package/dist/eval/state/snapshot.js.map +1 -0
- package/dist/eval/state/unavailable-options.d.ts +54 -0
- package/dist/eval/state/unavailable-options.d.ts.map +1 -0
- package/dist/eval/state/unavailable-options.js +82 -0
- package/dist/eval/state/unavailable-options.js.map +1 -0
- package/dist/eval/state/value-state.d.ts +38 -0
- package/dist/eval/state/value-state.d.ts.map +1 -0
- package/dist/eval/state/value-state.js +52 -0
- package/dist/eval/state/value-state.js.map +1 -0
- package/dist/eval/submission/admission.d.ts +50 -0
- package/dist/eval/submission/admission.d.ts.map +1 -0
- package/dist/eval/submission/admission.js +174 -0
- package/dist/eval/submission/admission.js.map +1 -0
- package/dist/eval/submission/authority.d.ts +71 -0
- package/dist/eval/submission/authority.d.ts.map +1 -0
- package/dist/eval/submission/authority.js +118 -0
- package/dist/eval/submission/authority.js.map +1 -0
- package/dist/eval/submission/datasets.d.ts +28 -0
- package/dist/eval/submission/datasets.d.ts.map +1 -0
- package/dist/eval/submission/datasets.js +109 -0
- package/dist/eval/submission/datasets.js.map +1 -0
- package/dist/eval/submission/index.d.ts +15 -0
- package/dist/eval/submission/index.d.ts.map +1 -0
- package/dist/eval/submission/index.js +13 -0
- package/dist/eval/submission/index.js.map +1 -0
- package/dist/eval/submission/refusals.d.ts +103 -0
- package/dist/eval/submission/refusals.d.ts.map +1 -0
- package/dist/eval/submission/refusals.js +15 -0
- package/dist/eval/submission/refusals.js.map +1 -0
- package/dist/eval/submission/signatures.d.ts +7 -0
- package/dist/eval/submission/signatures.d.ts.map +1 -0
- package/dist/eval/submission/signatures.js +215 -0
- package/dist/eval/submission/signatures.js.map +1 -0
- package/dist/eval/submission/writes.d.ts +51 -0
- package/dist/eval/submission/writes.d.ts.map +1 -0
- package/dist/eval/submission/writes.js +203 -0
- package/dist/eval/submission/writes.js.map +1 -0
- package/dist/eval/submission.d.ts +53 -0
- package/dist/eval/submission.d.ts.map +1 -0
- package/dist/eval/submission.js +521 -0
- package/dist/eval/submission.js.map +1 -0
- package/dist/eval/suggestions-to-engine.d.ts +18 -0
- package/dist/eval/suggestions-to-engine.d.ts.map +1 -0
- package/dist/eval/suggestions-to-engine.js +40 -0
- package/dist/eval/suggestions-to-engine.js.map +1 -0
- package/dist/eval/suggestions.d.ts +17 -0
- package/dist/eval/suggestions.d.ts.map +1 -0
- package/dist/eval/suggestions.js +314 -0
- package/dist/eval/suggestions.js.map +1 -0
- package/dist/eval/undecided.d.ts +64 -0
- package/dist/eval/undecided.d.ts.map +1 -0
- package/dist/eval/undecided.js +101 -0
- package/dist/eval/undecided.js.map +1 -0
- package/dist/eval/verdict.d.ts +66 -0
- package/dist/eval/verdict.d.ts.map +1 -0
- package/dist/eval/verdict.js +106 -0
- package/dist/eval/verdict.js.map +1 -0
- package/dist/eval/verify-signature.d.ts +78 -0
- package/dist/eval/verify-signature.d.ts.map +1 -0
- package/dist/eval/verify-signature.js +185 -0
- package/dist/eval/verify-signature.js.map +1 -0
- package/dist/eval/version-dispatch.d.ts +38 -0
- package/dist/eval/version-dispatch.d.ts.map +1 -0
- package/dist/eval/version-dispatch.js +61 -0
- package/dist/eval/version-dispatch.js.map +1 -0
- package/dist/eval/visibility.d.ts +33 -0
- package/dist/eval/visibility.d.ts.map +1 -0
- package/dist/eval/visibility.js +83 -0
- package/dist/eval/visibility.js.map +1 -0
- package/dist/evaluate.d.ts +24 -0
- package/dist/evaluate.d.ts.map +1 -0
- package/dist/evaluate.js +18 -0
- package/dist/evaluate.js.map +1 -0
- package/dist/expr/builtin-docs.d.ts +51 -0
- package/dist/expr/builtin-docs.d.ts.map +1 -0
- package/dist/expr/builtin-docs.js +874 -0
- package/dist/expr/builtin-docs.js.map +1 -0
- package/dist/expr/builtins.d.ts +50 -0
- package/dist/expr/builtins.d.ts.map +1 -0
- package/dist/expr/builtins.js +966 -0
- package/dist/expr/builtins.js.map +1 -0
- package/dist/expr/decimal-precision.d.ts +39 -0
- package/dist/expr/decimal-precision.d.ts.map +1 -0
- package/dist/expr/decimal-precision.js +62 -0
- package/dist/expr/decimal-precision.js.map +1 -0
- package/dist/expr/decimal.d.ts +172 -0
- package/dist/expr/decimal.d.ts.map +1 -0
- package/dist/expr/decimal.js +782 -0
- package/dist/expr/decimal.js.map +1 -0
- package/dist/expr/deprecations.d.ts +34 -0
- package/dist/expr/deprecations.d.ts.map +1 -0
- package/dist/expr/deprecations.js +17 -0
- package/dist/expr/deprecations.js.map +1 -0
- package/dist/expr/diagnostics.d.ts +21 -0
- package/dist/expr/diagnostics.d.ts.map +1 -0
- package/dist/expr/diagnostics.js +231 -0
- package/dist/expr/diagnostics.js.map +1 -0
- package/dist/expr/direction.d.ts +30 -0
- package/dist/expr/direction.d.ts.map +1 -0
- package/dist/expr/direction.js +77 -0
- package/dist/expr/direction.js.map +1 -0
- package/dist/expr/example-expression.d.ts +62 -0
- package/dist/expr/example-expression.d.ts.map +1 -0
- package/dist/expr/example-expression.js +670 -0
- package/dist/expr/example-expression.js.map +1 -0
- package/dist/expr/instant.d.ts +49 -0
- package/dist/expr/instant.d.ts.map +1 -0
- package/dist/expr/instant.js +111 -0
- package/dist/expr/instant.js.map +1 -0
- package/dist/expr/logic.d.ts +17 -0
- package/dist/expr/logic.d.ts.map +1 -0
- package/dist/expr/logic.js +65 -0
- package/dist/expr/logic.js.map +1 -0
- package/dist/expr/messages.d.ts +45 -0
- package/dist/expr/messages.d.ts.map +1 -0
- package/dist/expr/messages.js +280 -0
- package/dist/expr/messages.js.map +1 -0
- package/dist/expr/money.d.ts +38 -0
- package/dist/expr/money.d.ts.map +1 -0
- package/dist/expr/money.js +127 -0
- package/dist/expr/money.js.map +1 -0
- package/dist/expr/ordering.d.ts +56 -0
- package/dist/expr/ordering.d.ts.map +1 -0
- package/dist/expr/ordering.js +167 -0
- package/dist/expr/ordering.js.map +1 -0
- package/dist/expr/pattern.d.ts +44 -0
- package/dist/expr/pattern.d.ts.map +1 -0
- package/dist/expr/pattern.js +458 -0
- package/dist/expr/pattern.js.map +1 -0
- package/dist/expr/plain-date.d.ts +90 -0
- package/dist/expr/plain-date.d.ts.map +1 -0
- package/dist/expr/plain-date.js +230 -0
- package/dist/expr/plain-date.js.map +1 -0
- package/dist/expr/plural-categories.d.ts +8 -0
- package/dist/expr/plural-categories.d.ts.map +1 -0
- package/dist/expr/plural-categories.js +15 -0
- package/dist/expr/plural-categories.js.map +1 -0
- package/dist/expr/plural-keys.d.ts +39 -0
- package/dist/expr/plural-keys.d.ts.map +1 -0
- package/dist/expr/plural-keys.js +46 -0
- package/dist/expr/plural-keys.js.map +1 -0
- package/dist/expr/plural.d.ts +33 -0
- package/dist/expr/plural.d.ts.map +1 -0
- package/dist/expr/plural.js +50 -0
- package/dist/expr/plural.js.map +1 -0
- package/dist/expr/quantity.d.ts +31 -0
- package/dist/expr/quantity.d.ts.map +1 -0
- package/dist/expr/quantity.js +83 -0
- package/dist/expr/quantity.js.map +1 -0
- package/dist/expr/reduce.d.ts +50 -0
- package/dist/expr/reduce.d.ts.map +1 -0
- package/dist/expr/reduce.js +236 -0
- package/dist/expr/reduce.js.map +1 -0
- package/dist/expr/regex.d.ts +108 -0
- package/dist/expr/regex.d.ts.map +1 -0
- package/dist/expr/regex.js +1210 -0
- package/dist/expr/regex.js.map +1 -0
- package/dist/expr/select-locale.d.ts +67 -0
- package/dist/expr/select-locale.d.ts.map +1 -0
- package/dist/expr/select-locale.js +219 -0
- package/dist/expr/select-locale.js.map +1 -0
- package/dist/expr/sequences.d.ts +123 -0
- package/dist/expr/sequences.d.ts.map +1 -0
- package/dist/expr/sequences.js +234 -0
- package/dist/expr/sequences.js.map +1 -0
- package/dist/expr/strings.d.ts +50 -0
- package/dist/expr/strings.d.ts.map +1 -0
- package/dist/expr/strings.js +184 -0
- package/dist/expr/strings.js.map +1 -0
- package/dist/expr/validation.d.ts +32 -0
- package/dist/expr/validation.d.ts.map +1 -0
- package/dist/expr/validation.js +182 -0
- package/dist/expr/validation.js.map +1 -0
- package/dist/graph/freeze.d.ts +4 -0
- package/dist/graph/freeze.d.ts.map +1 -0
- package/dist/graph/freeze.js +52 -0
- package/dist/graph/freeze.js.map +1 -0
- package/dist/graph/index.d.ts +15 -0
- package/dist/graph/index.d.ts.map +1 -0
- package/dist/graph/index.js +13 -0
- package/dist/graph/index.js.map +1 -0
- package/dist/graph/inspect.d.ts +76 -0
- package/dist/graph/inspect.d.ts.map +1 -0
- package/dist/graph/inspect.js +263 -0
- package/dist/graph/inspect.js.map +1 -0
- package/dist/graph/read-walk.d.ts +101 -0
- package/dist/graph/read-walk.d.ts.map +1 -0
- package/dist/graph/read-walk.js +358 -0
- package/dist/graph/read-walk.js.map +1 -0
- package/dist/graph/record-index.d.ts +24 -0
- package/dist/graph/record-index.d.ts.map +1 -0
- package/dist/graph/record-index.js +35 -0
- package/dist/graph/record-index.js.map +1 -0
- package/dist/index.d.ts +104 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +139 -0
- package/dist/index.js.map +1 -0
- package/dist/lookup/digest.d.ts +51 -0
- package/dist/lookup/digest.d.ts.map +1 -0
- package/dist/lookup/digest.js +46 -0
- package/dist/lookup/digest.js.map +1 -0
- package/dist/lookup/index.d.ts +28 -0
- package/dist/lookup/index.d.ts.map +1 -0
- package/dist/lookup/index.js +27 -0
- package/dist/lookup/index.js.map +1 -0
- package/dist/lookup/install.d.ts +48 -0
- package/dist/lookup/install.d.ts.map +1 -0
- package/dist/lookup/install.js +315 -0
- package/dist/lookup/install.js.map +1 -0
- package/dist/lookup/pass.d.ts +55 -0
- package/dist/lookup/pass.d.ts.map +1 -0
- package/dist/lookup/pass.js +212 -0
- package/dist/lookup/pass.js.map +1 -0
- package/dist/lookup/pins.d.ts +34 -0
- package/dist/lookup/pins.d.ts.map +1 -0
- package/dist/lookup/pins.js +39 -0
- package/dist/lookup/pins.js.map +1 -0
- package/dist/lookup/provenance.d.ts +23 -0
- package/dist/lookup/provenance.d.ts.map +1 -0
- package/dist/lookup/provenance.js +78 -0
- package/dist/lookup/provenance.js.map +1 -0
- package/dist/lookup/readiness.d.ts +13 -0
- package/dist/lookup/readiness.d.ts.map +1 -0
- package/dist/lookup/readiness.js +57 -0
- package/dist/lookup/readiness.js.map +1 -0
- package/dist/lookup/resolve.d.ts +24 -0
- package/dist/lookup/resolve.d.ts.map +1 -0
- package/dist/lookup/resolve.js +201 -0
- package/dist/lookup/resolve.js.map +1 -0
- package/dist/lookup/store.d.ts +41 -0
- package/dist/lookup/store.d.ts.map +1 -0
- package/dist/lookup/store.js +74 -0
- package/dist/lookup/store.js.map +1 -0
- package/dist/model/access.d.ts +200 -0
- package/dist/model/access.d.ts.map +1 -0
- package/dist/model/access.js +125 -0
- package/dist/model/access.js.map +1 -0
- package/dist/model/artifact-members.d.ts +3 -0
- package/dist/model/artifact-members.d.ts.map +1 -0
- package/dist/model/artifact-members.js +38 -0
- package/dist/model/artifact-members.js.map +1 -0
- package/dist/model/composition.d.ts +47 -0
- package/dist/model/composition.d.ts.map +1 -0
- package/dist/model/composition.js +66 -0
- package/dist/model/composition.js.map +1 -0
- package/dist/model/domain.d.ts +51 -0
- package/dist/model/domain.d.ts.map +1 -0
- package/dist/model/domain.js +75 -0
- package/dist/model/domain.js.map +1 -0
- package/dist/model/duration.d.ts +31 -0
- package/dist/model/duration.d.ts.map +1 -0
- package/dist/model/duration.js +136 -0
- package/dist/model/duration.js.map +1 -0
- package/dist/model/errors.d.ts +58 -0
- package/dist/model/errors.d.ts.map +1 -0
- package/dist/model/errors.js +81 -0
- package/dist/model/errors.js.map +1 -0
- package/dist/model/evolution.d.ts +177 -0
- package/dist/model/evolution.d.ts.map +1 -0
- package/dist/model/evolution.js +5 -0
- package/dist/model/evolution.js.map +1 -0
- package/dist/model/expr-children.d.ts +15 -0
- package/dist/model/expr-children.d.ts.map +1 -0
- package/dist/model/expr-children.js +45 -0
- package/dist/model/expr-children.js.map +1 -0
- package/dist/model/guards.d.ts +9 -0
- package/dist/model/guards.d.ts.map +1 -0
- package/dist/model/guards.js +11 -0
- package/dist/model/guards.js.map +1 -0
- package/dist/model/input.d.ts +42 -0
- package/dist/model/input.d.ts.map +1 -0
- package/dist/model/input.js +26 -0
- package/dist/model/input.js.map +1 -0
- package/dist/model/integer.d.ts +14 -0
- package/dist/model/integer.d.ts.map +1 -0
- package/dist/model/integer.js +16 -0
- package/dist/model/integer.js.map +1 -0
- package/dist/model/intrinsic.d.ts +18 -0
- package/dist/model/intrinsic.d.ts.map +1 -0
- package/dist/model/intrinsic.js +21 -0
- package/dist/model/intrinsic.js.map +1 -0
- package/dist/model/layout.d.ts +129 -0
- package/dist/model/layout.d.ts.map +1 -0
- package/dist/model/layout.js +2 -0
- package/dist/model/layout.js.map +1 -0
- package/dist/model/media.d.ts +33 -0
- package/dist/model/media.d.ts.map +1 -0
- package/dist/model/media.js +86 -0
- package/dist/model/media.js.map +1 -0
- package/dist/model/members.generated.d.ts +11 -0
- package/dist/model/members.generated.d.ts.map +1 -0
- package/dist/model/members.generated.js +71 -0
- package/dist/model/members.generated.js.map +1 -0
- package/dist/model/row-address.d.ts +27 -0
- package/dist/model/row-address.d.ts.map +1 -0
- package/dist/model/row-address.js +146 -0
- package/dist/model/row-address.js.map +1 -0
- package/dist/model/schema.d.ts +108 -0
- package/dist/model/schema.d.ts.map +1 -0
- package/dist/model/schema.js +2 -0
- package/dist/model/schema.js.map +1 -0
- package/dist/model/shape.d.ts +193 -0
- package/dist/model/shape.d.ts.map +1 -0
- package/dist/model/shape.js +2 -0
- package/dist/model/shape.js.map +1 -0
- package/dist/model/time.d.ts +61 -0
- package/dist/model/time.d.ts.map +1 -0
- package/dist/model/time.js +110 -0
- package/dist/model/time.js.map +1 -0
- package/dist/model/types.d.ts +1329 -0
- package/dist/model/types.d.ts.map +1 -0
- package/dist/model/types.js +424 -0
- package/dist/model/types.js.map +1 -0
- package/dist/model/values.d.ts +91 -0
- package/dist/model/values.d.ts.map +1 -0
- package/dist/model/values.js +195 -0
- package/dist/model/values.js.map +1 -0
- package/dist/model/wire.d.ts +356 -0
- package/dist/model/wire.d.ts.map +1 -0
- package/dist/model/wire.js +1504 -0
- package/dist/model/wire.js.map +1 -0
- package/dist/offline/index.d.ts +374 -0
- package/dist/offline/index.d.ts.map +1 -0
- package/dist/offline/index.js +422 -0
- package/dist/offline/index.js.map +1 -0
- package/dist/testing.d.ts +30 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +42 -0
- package/dist/testing.js.map +1 -0
- package/dist/version.d.ts +30 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +116 -0
- package/dist/version.js.map +1 -0
- package/package.json +98 -3
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import type { AddressValue, CoordinateValue, DecimalString, DurationValue, ItemPrimitive, MoneyValue, Primitive, TimeslotValue, WireRecord, WireValue } from './types.js';
|
|
2
|
+
import type { CompiledSchema } from './schema.js';
|
|
3
|
+
/**
|
|
4
|
+
* A document's declared shape, carried in a type rather than read from an artifact.
|
|
5
|
+
*
|
|
6
|
+
* `@azx-pbc/axiom-builder`'s `defineDocument` compiles an authored literal and returns the
|
|
7
|
+
* artifact a host already knows how to use; these types are how that return value also remembers
|
|
8
|
+
* the literal it came from. Nothing here has a runtime member: a `TypedArtifact` *is* the
|
|
9
|
+
* `CompiledSchema` the compiler emitted, and the shape exists only in the type system, so the
|
|
10
|
+
* untyped doors — `useField(fieldId)`, `FormProvider compiled={artifact}` — see exactly the value
|
|
11
|
+
* they saw before.
|
|
12
|
+
*
|
|
13
|
+
* The derivation reads the document literal's own types (`fieldId`, `primitive`, `fields`,
|
|
14
|
+
* `items`), which are the metaschema's vocabulary, so a second field table cannot drift from the
|
|
15
|
+
* contract the compiler validates.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* How a binding addresses one declared field.
|
|
19
|
+
*
|
|
20
|
+
* - `required`: the field is a member of an array, so its value lives once per row and a
|
|
21
|
+
* row-less binding would report an absent value forever.
|
|
22
|
+
* - `optional`: the field is an array container, which binds as a container and can also bind
|
|
23
|
+
* one of its rows.
|
|
24
|
+
* - `forbidden`: the field holds no rows, so a row key names nothing.
|
|
25
|
+
*/
|
|
26
|
+
export type RowKeyRequirement = 'required' | 'optional' | 'forbidden';
|
|
27
|
+
/**
|
|
28
|
+
* The structural subset of a declared field the shape derivation reads.
|
|
29
|
+
*
|
|
30
|
+
* Both the authored `AuthoringField` and a compiled `CompiledField` satisfy it, and neither is
|
|
31
|
+
* restated here: the derivation only needs the metaschema's own `primitive` and container
|
|
32
|
+
* vocabulary plus the id.
|
|
33
|
+
*/
|
|
34
|
+
export interface DeclaredFieldLike {
|
|
35
|
+
readonly fieldId: string;
|
|
36
|
+
readonly primitive: Primitive;
|
|
37
|
+
readonly fields?: readonly DeclaredFieldLike[] | undefined;
|
|
38
|
+
readonly items?: {
|
|
39
|
+
readonly primitive: ItemPrimitive;
|
|
40
|
+
} | undefined;
|
|
41
|
+
}
|
|
42
|
+
/** One entry of an artifact's declared field map. */
|
|
43
|
+
export interface DeclaredFieldShape {
|
|
44
|
+
readonly primitive: Primitive;
|
|
45
|
+
readonly rowKey: RowKeyRequirement;
|
|
46
|
+
/**
|
|
47
|
+
* The wire value one binding of this field states, before `null` and absence.
|
|
48
|
+
*
|
|
49
|
+
* `unknown` in the constraint rather than `WireValue`, because a record's derived members are
|
|
50
|
+
* optional and an optional member is not assignable to `WireRecord`'s index signature. A
|
|
51
|
+
* concrete shape supplies a concrete type here.
|
|
52
|
+
*/
|
|
53
|
+
readonly value: unknown;
|
|
54
|
+
}
|
|
55
|
+
/** The shape a typed artifact carries: its record, its declared fields and its declared rules. */
|
|
56
|
+
export interface ArtifactShape {
|
|
57
|
+
/** The submission record, typed from the top-level declarations. */
|
|
58
|
+
readonly record: unknown;
|
|
59
|
+
/** Every declared field id at every nesting level, with its binding requirement. */
|
|
60
|
+
readonly fields: Readonly<Record<string, DeclaredFieldShape>>;
|
|
61
|
+
/** The declared rule ids. */
|
|
62
|
+
readonly rules: string;
|
|
63
|
+
}
|
|
64
|
+
declare const artifactShape: unique symbol;
|
|
65
|
+
/**
|
|
66
|
+
* A compiled artifact that remembers the document literal it was compiled from.
|
|
67
|
+
*
|
|
68
|
+
* The brand is optional and has no runtime representation: `defineDocument` returns the
|
|
69
|
+
* compiler's own artifact unchanged, and a host that never names a type still receives a value
|
|
70
|
+
* whose only difference from `CompiledSchema` is invisible outside the type system.
|
|
71
|
+
*/
|
|
72
|
+
export interface TypedArtifact<Shape extends ArtifactShape = ArtifactShape> extends CompiledSchema {
|
|
73
|
+
readonly [artifactShape]?: Shape;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* The shape a typed artifact carries.
|
|
77
|
+
*
|
|
78
|
+
* The brand is optional, so the compiler's own `CompiledSchema` — which states no brand and no
|
|
79
|
+
* literal — resolves to the open `ArtifactShape`: an untyped artifact really does declare fields
|
|
80
|
+
* and rules, only not their literal ids. `never` is for a type that is no artifact at all, such
|
|
81
|
+
* as a primitive or a host's unrelated interface.
|
|
82
|
+
*/
|
|
83
|
+
export type ShapeOfArtifact<Artifact> = Artifact extends TypedArtifact<infer Shape> ? Shape : never;
|
|
84
|
+
/** The declared field ids of a shape. */
|
|
85
|
+
export type FieldIdsOf<Shape extends ArtifactShape> = Extract<keyof Shape['fields'], string>;
|
|
86
|
+
/** The declared rule ids of a shape. */
|
|
87
|
+
export type RuleIdsOf<Shape extends ArtifactShape> = Extract<Shape['rules'], string>;
|
|
88
|
+
/** The submission record of a shape, keyed by its top-level field ids. */
|
|
89
|
+
export type RecordOf<Shape extends ArtifactShape> = Shape['record'];
|
|
90
|
+
/** One field's entry in a shape. */
|
|
91
|
+
export type FieldShapeOf<Shape extends ArtifactShape, Id extends FieldIdsOf<Shape>> = Shape['fields'][Id];
|
|
92
|
+
/** One field's row-key requirement. */
|
|
93
|
+
export type RowKeyRequirementOf<Shape extends ArtifactShape, Id extends FieldIdsOf<Shape>> = Shape['fields'][Id]['rowKey'];
|
|
94
|
+
/** One field's wire value, before `null` and absence. */
|
|
95
|
+
export type WireValueOf<Shape extends ArtifactShape, Id extends FieldIdsOf<Shape>> = Shape['fields'][Id]['value'];
|
|
96
|
+
/** The member declarations a field holds, or none. */
|
|
97
|
+
type MembersOf<Field extends DeclaredFieldLike> = Field extends {
|
|
98
|
+
readonly fields: infer Members extends readonly DeclaredFieldLike[];
|
|
99
|
+
} ? Members : readonly [];
|
|
100
|
+
/** Whether a field's value lives once per row of an array above it. */
|
|
101
|
+
type InArrayAfter<Parent extends boolean, Field extends DeclaredFieldLike> = Parent extends true ? true : Field['primitive'] extends 'array' ? true : false;
|
|
102
|
+
/**
|
|
103
|
+
* The row-key requirement of one field.
|
|
104
|
+
*
|
|
105
|
+
* An array declared inside another array is `forbidden` rather than `optional`: v1 addresses no
|
|
106
|
+
* row of a nested array (`FormFieldState.addressableRows` is `unsupported` for it), so a row key
|
|
107
|
+
* on that container would be a runtime refusal rather than a container binding.
|
|
108
|
+
*/
|
|
109
|
+
type RowKeyOf<Field extends DeclaredFieldLike, InArray extends boolean> = Field['primitive'] extends 'array' ? InArray extends true ? 'forbidden' : 'optional' : InArray extends true ? 'required' : 'forbidden';
|
|
110
|
+
/** One field's entry, with its declared members flattened beside it. */
|
|
111
|
+
type EntryOf<Field extends DeclaredFieldLike, InArray extends boolean> = {
|
|
112
|
+
readonly [Id in Field['fieldId']]: {
|
|
113
|
+
readonly primitive: Field['primitive'];
|
|
114
|
+
readonly rowKey: RowKeyOf<Field, InArray>;
|
|
115
|
+
readonly value: WireValueFor<Field>;
|
|
116
|
+
};
|
|
117
|
+
};
|
|
118
|
+
/**
|
|
119
|
+
* Every declared field in one tree, flattened into one id-keyed map.
|
|
120
|
+
*
|
|
121
|
+
* A tuple is walked entry by entry so the result stays an object type. A document that reaches
|
|
122
|
+
* the compiler as a non-tuple (`readonly AuthoringField[]`) falls back to a string index: the
|
|
123
|
+
* field ids are not knowable then, and claiming a literal union would be a false guarantee.
|
|
124
|
+
*/
|
|
125
|
+
type FieldMapOf<Fields extends readonly DeclaredFieldLike[], InArray extends boolean> = number extends Fields['length'] ? Readonly<Record<string, DeclaredFieldShape>> : Fields extends readonly [
|
|
126
|
+
infer Head extends DeclaredFieldLike,
|
|
127
|
+
...infer Rest extends readonly DeclaredFieldLike[]
|
|
128
|
+
] ? EntryOf<Head, InArray> & FieldMapOf<MembersOf<Head>, InArrayAfter<InArray, Head>> & FieldMapOf<Rest, InArray> : {};
|
|
129
|
+
/** A scalar-array item's wire value, where the item declaration makes it knowable. */
|
|
130
|
+
type ItemWireValue<Primitive extends ItemPrimitive> = Primitive extends 'string' | 'date' ? string : Primitive extends 'integer' ? number : Primitive extends 'decimal' ? DecimalString : Primitive extends 'money' ? MoneyValue : Primitive extends 'media_ref' ? WireRecord : Primitive extends 'duration' ? DurationValue : WireValue;
|
|
131
|
+
/**
|
|
132
|
+
* An array field's wire value.
|
|
133
|
+
*
|
|
134
|
+
* A scalar array's element may be `null`, which the wire reader admits for every implemented
|
|
135
|
+
* primitive; a record array's rows must be objects, so no `null` element is stated.
|
|
136
|
+
*/
|
|
137
|
+
type ArrayWireValue<Field extends DeclaredFieldLike> = Field extends {
|
|
138
|
+
readonly items: {
|
|
139
|
+
readonly primitive: infer ItemKind extends ItemPrimitive;
|
|
140
|
+
};
|
|
141
|
+
} ? readonly (ItemWireValue<ItemKind> | null)[] : Field extends {
|
|
142
|
+
readonly fields: infer Members extends readonly DeclaredFieldLike[];
|
|
143
|
+
} ? readonly RecordOfMembers<Members>[] : readonly WireValue[];
|
|
144
|
+
/**
|
|
145
|
+
* One declared field's wire value.
|
|
146
|
+
*
|
|
147
|
+
* What each primitive states, and what it cannot:
|
|
148
|
+
*
|
|
149
|
+
* - `string`, `date` and `instant` are `string`: the runtime's values are canonical text, not a
|
|
150
|
+
* `Date`, and no branded type exists for a civil date or an instant.
|
|
151
|
+
* - `boolean`, `integer` are the JavaScript primitive the wire admits.
|
|
152
|
+
* - `decimal` is `DecimalString`, the runtime's own brand for canonical decimal text.
|
|
153
|
+
* - `money` is `MoneyValue`, whose shape is exact; the declared `currency` and `scale` are
|
|
154
|
+
* runtime members, not type literals.
|
|
155
|
+
* - `timeslot` is `TimeslotValue`; `media_ref` and `signature_ref` are `WireRecord`, because the
|
|
156
|
+
* closed member sets live in the generated metaschema registry and no interface states them.
|
|
157
|
+
* - `record` and `array` recurse into the declarations the literal states.
|
|
158
|
+
*/
|
|
159
|
+
type WireValueFor<Field extends DeclaredFieldLike> = Field['primitive'] extends infer Kind extends Primitive ? Kind extends 'string' | 'date' | 'instant' | 'time' ? string : Kind extends 'boolean' ? boolean : Kind extends 'integer' ? number : Kind extends 'decimal' ? DecimalString : Kind extends 'money' ? MoneyValue : Kind extends 'duration' ? DurationValue : Kind extends 'address' ? AddressValue : Kind extends 'coordinate' ? CoordinateValue : Kind extends 'timeslot' ? TimeslotValue : Kind extends 'media_ref' | 'signature_ref' ? WireRecord : Kind extends 'record' ? RecordOfMembers<MembersOf<Field>> : Kind extends 'array' ? ArrayWireValue<Field> : WireValue : never;
|
|
160
|
+
/** One top-level member of a submission record: the declared value, or the empty `null`. */
|
|
161
|
+
type MemberOf<Field extends DeclaredFieldLike> = WireValueFor<Field> | null;
|
|
162
|
+
/**
|
|
163
|
+
* The record a submission carries.
|
|
164
|
+
*
|
|
165
|
+
* Members are optional because the projection omits a field no input supplies, and the compiler
|
|
166
|
+
* emits only fields the document declares. A non-tuple field list falls back to a string index
|
|
167
|
+
* over the same member type rather than inventing ids it cannot know.
|
|
168
|
+
*/
|
|
169
|
+
type RecordOfMembers<Fields extends readonly DeclaredFieldLike[]> = number extends Fields['length'] ? Readonly<Record<string, MemberOf<Fields[number]> | undefined>> : Fields extends readonly [
|
|
170
|
+
infer Head extends DeclaredFieldLike,
|
|
171
|
+
...infer Rest extends readonly DeclaredFieldLike[]
|
|
172
|
+
] ? {
|
|
173
|
+
readonly [Id in Head['fieldId']]?: MemberOf<Head>;
|
|
174
|
+
} & RecordOfMembers<Rest> : {};
|
|
175
|
+
/**
|
|
176
|
+
* The shape an authored document literal states.
|
|
177
|
+
*
|
|
178
|
+
* This is the one derivation: `defineDocument` reads `Doc` from its argument and returns a
|
|
179
|
+
* `TypedArtifact<ShapeOfDocument<Doc>>`, so a host never writes the field ids twice.
|
|
180
|
+
*/
|
|
181
|
+
export type ShapeOfDocument<Document> = Document extends {
|
|
182
|
+
readonly fields: infer Fields extends readonly DeclaredFieldLike[];
|
|
183
|
+
} ? {
|
|
184
|
+
readonly record: RecordOfMembers<Fields>;
|
|
185
|
+
readonly fields: FieldMapOf<Fields, false>;
|
|
186
|
+
readonly rules: Document extends {
|
|
187
|
+
readonly rules: readonly (infer Rule)[];
|
|
188
|
+
} ? Rule extends {
|
|
189
|
+
readonly ruleId: infer Id extends string;
|
|
190
|
+
} ? Id : never : never;
|
|
191
|
+
} : never;
|
|
192
|
+
export {};
|
|
193
|
+
//# sourceMappingURL=shape.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shape.d.ts","sourceRoot":"","sources":["../../src/model/shape.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,eAAe,EACf,aAAa,EACb,aAAa,EACb,aAAa,EACb,UAAU,EACV,SAAS,EACT,aAAa,EACb,UAAU,EACV,SAAS,EACV,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD;;;;;;;;;;;;;GAaG;AAEH;;;;;;;;GAQG;AACH,MAAM,MAAM,iBAAiB,GAAG,UAAU,GAAG,UAAU,GAAG,WAAW,CAAC;AAEtE;;;;;;GAMG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,iBAAi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M,SAAS,SAAS,iBAAiB,EAAE,IAAI,MAAM,SAAS,MAAM,CAAC,QAAQ,CAAC,GAC/F,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,GAC9D,MAAM,SAAS,SAAS;IACpB,MAAM,IAAI,SAAS,iBAAiB;IACpC,GAAG,MAAM,IAAI,SAAS,SAAS,iBAAiB,EAAE;CACnD,GACD;IAAE,QAAQ,EAAE,EAAE,IAAI,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,IAAI,CAAC;CAAE,GAAG,eAAe,CAAC,IAAI,CAAC,GAC7E,EAAE,CAAC;AAET;;;;;GAKG;AACH,MAAM,MAAM,eAAe,CAAC,QAAQ,IAAI,QAAQ,SAAS;IACvD,QAAQ,CAAC,MAAM,EAAE,MAAM,MAAM,SAAS,SAAS,iBAAiB,EAAE,CAAC;CACpE,GACG;IACE,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAC,MAAM,CAAC,CAAC;IACzC,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC3C,QAAQ,CAAC,KAAK,EAAE,QAAQ,SAAS;QAAE,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC,MAAM,IAAI,CAAC,EAAE,CAAA;KAAE,GACxE,IAAI,SAAS;QAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,MAAM,CAAA;KAAE,GACvD,EAAE,GACF,KAAK,GACP,KAAK,CAAC;CACX,GACD,KAAK,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shape.js","sourceRoot":"","sources":["../../src/model/shape.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n AddressValue,\n CoordinateValue,\n DecimalString,\n DurationValue,\n ItemPrimitive,\n MoneyValue,\n Primitive,\n TimeslotValue,\n WireRecord,\n WireValue,\n} from './types.js';\nimport type { CompiledSchema } from './schema.js';\n\n/**\n * A document's declared shape, carried in a type rather than read from an artifact.\n *\n * `@azx-pbc/axiom-builder`'s `defineDocument` compiles an authored literal and returns the\n * artifact a host already knows how to use; these types are how that return value also remembers\n * the literal it came from. Nothing here has a runtime member: a `TypedArtifact` *is* the\n * `CompiledSchema` the compiler emitted, and the shape exists only in the type system, so the\n * untyped doors — `useField(fieldId)`, `FormProvider compiled={artifact}` — see exactly the value\n * they saw before.\n *\n * The derivation reads the document literal's own types (`fieldId`, `primitive`, `fields`,\n * `items`), which are the metaschema's vocabulary, so a second field table cannot drift from the\n * contract the compiler validates.\n */\n\n/**\n * How a binding addresses one declared field.\n *\n * - `required`: the field is a member of an array, so its value lives once per row and a\n * row-less binding would report an absent value forever.\n * - `optional`: the field is an array container, which binds as a container and can also bind\n * one of its rows.\n * - `forbidden`: the field holds no rows, so a row key names nothing.\n */\nexport type RowKeyRequirement = 'required' | 'optional' | 'forbidden';\n\n/**\n * The structural subset of a declared field the shape derivation reads.\n *\n * Both the authored `AuthoringField` and a compiled `CompiledField` satisfy it, and neither is\n * restated here: the derivation only needs the metaschema's own `primitive` and container\n * vocabulary plus the id.\n */\nexport interface DeclaredFieldLike {\n readonly fieldId: string;\n readonly primitive: Primitive;\n readonly fields?: readonly DeclaredFieldLike[] | undefined;\n readonly items?: { readonly primitive: ItemPrimitive } | undefined;\n}\n\n/** One entry of an artifact's declared field map. */\nexport interface DeclaredFieldShape {\n readonly primitive: Primitive;\n readonly rowKey: RowKeyRequirement;\n /**\n * The wire value one binding of this field states, before `null` and absence.\n *\n * `unknown` in the constraint rather than `WireValue`, because a record's derived members are\n * optional and an optional member is not assignable to `WireRecord`'s index signature. A\n * concrete shape supplies a concrete type here.\n */\n readonly value: unknown;\n}\n\n/** The shape a typed artifact carries: its record, its declared fields and its declared rules. */\nexport interface ArtifactShape {\n /** The submission record, typed from the top-level declarations. */\n readonly record: unknown;\n /** Every declared field id at every nesting level, with its binding requirement. */\n readonly fields: Readonly<Record<string, DeclaredFieldShape>>;\n /** The declared rule ids. */\n readonly rules: string;\n}\n\ndeclare const artifactShape: unique symbol;\n\n/**\n * A compiled artifact that remembers the document literal it was compiled from.\n *\n * The brand is optional and has no runtime representation: `defineDocument` returns the\n * compiler's own artifact unchanged, and a host that never names a type still receives a value\n * whose only difference from `CompiledSchema` is invisible outside the type system.\n */\nexport interface TypedArtifact<Shape extends ArtifactShape = ArtifactShape> extends CompiledSchema {\n readonly [artifactShape]?: Shape;\n}\n\n/**\n * The shape a typed artifact carries.\n *\n * The brand is optional, so the compiler's own `CompiledSchema` — which states no brand and no\n * literal — resolves to the open `ArtifactShape`: an untyped artifact really does declare fields\n * and rules, only not their literal ids. `never` is for a type that is no artifact at all, such\n * as a primitive or a host's unrelated interface.\n */\nexport type ShapeOfArtifact<Artifact> = Artifact extends TypedArtifact<infer Shape> ? Shape : never;\n\n/** The declared field ids of a shape. */\nexport type FieldIdsOf<Shape extends ArtifactShape> = Extract<keyof Shape['fields'], string>;\n\n/** The declared rule ids of a shape. */\nexport type RuleIdsOf<Shape extends ArtifactShape> = Extract<Shape['rules'], string>;\n\n/** The submission record of a shape, keyed by its top-level field ids. */\nexport type RecordOf<Shape extends ArtifactShape> = Shape['record'];\n\n/** One field's entry in a shape. */\nexport type FieldShapeOf<\n Shape extends ArtifactShape,\n Id extends FieldIdsOf<Shape>,\n> = Shape['fields'][Id];\n\n/** One field's row-key requirement. */\nexport type RowKeyRequirementOf<\n Shape extends ArtifactShape,\n Id extends FieldIdsOf<Shape>,\n> = Shape['fields'][Id]['rowKey'];\n\n/** One field's wire value, before `null` and absence. */\nexport type WireValueOf<\n Shape extends ArtifactShape,\n Id extends FieldIdsOf<Shape>,\n> = Shape['fields'][Id]['value'];\n\n/** The member declarations a field holds, or none. */\ntype MembersOf<Field extends DeclaredFieldLike> = Field extends {\n readonly fields: infer Members extends readonly DeclaredFieldLike[];\n}\n ? Members\n : readonly [];\n\n/** Whether a field's value lives once per row of an array above it. */\ntype InArrayAfter<Parent extends boolean, Field extends DeclaredFieldLike> = Parent extends true\n ? true\n : Field['primitive'] extends 'array'\n ? true\n : false;\n\n/**\n * The row-key requirement of one field.\n *\n * An array declared inside another array is `forbidden` rather than `optional`: v1 addresses no\n * row of a nested array (`FormFieldState.addressableRows` is `unsupported` for it), so a row key\n * on that container would be a runtime refusal rather than a container binding.\n */\ntype RowKeyOf<\n Field extends DeclaredFieldLike,\n InArray extends boolean,\n> = Field['primitive'] extends 'array'\n ? InArray extends true\n ? 'forbidden'\n : 'optional'\n : InArray extends true\n ? 'required'\n : 'forbidden';\n\n/** One field's entry, with its declared members flattened beside it. */\ntype EntryOf<Field extends DeclaredFieldLike, InArray extends boolean> = {\n readonly [Id in Field['fieldId']]: {\n readonly primitive: Field['primitive'];\n readonly rowKey: RowKeyOf<Field, InArray>;\n readonly value: WireValueFor<Field>;\n };\n};\n\n/**\n * Every declared field in one tree, flattened into one id-keyed map.\n *\n * A tuple is walked entry by entry so the result stays an object type. A document that reaches\n * the compiler as a non-tuple (`readonly AuthoringField[]`) falls back to a string index: the\n * field ids are not knowable then, and claiming a literal union would be a false guarantee.\n */\ntype FieldMapOf<\n Fields extends readonly DeclaredFieldLike[],\n InArray extends boolean,\n> = number extends Fields['length']\n ? Readonly<Record<string, DeclaredFieldShape>>\n : Fields extends readonly [\n infer Head extends DeclaredFieldLike,\n ...infer Rest extends readonly DeclaredFieldLike[],\n ]\n ? EntryOf<Head, InArray> &\n FieldMapOf<MembersOf<Head>, InArrayAfter<InArray, Head>> &\n FieldMapOf<Rest, InArray>\n : {};\n\n/** A scalar-array item's wire value, where the item declaration makes it knowable. */\ntype ItemWireValue<Primitive extends ItemPrimitive> = Primitive extends 'string' | 'date'\n ? string\n : Primitive extends 'integer'\n ? number\n : Primitive extends 'decimal'\n ? DecimalString\n : Primitive extends 'money'\n ? MoneyValue\n : Primitive extends 'media_ref'\n ? WireRecord\n : Primitive extends 'duration'\n ? DurationValue\n : // An item primitive added to the union before this table learns it degrades to the\n // wire union rather than to `never`, so a record member cannot become unassignable.\n WireValue;\n\n/**\n * An array field's wire value.\n *\n * A scalar array's element may be `null`, which the wire reader admits for every implemented\n * primitive; a record array's rows must be objects, so no `null` element is stated.\n */\ntype ArrayWireValue<Field extends DeclaredFieldLike> = Field extends {\n readonly items: { readonly primitive: infer ItemKind extends ItemPrimitive };\n}\n ? readonly (ItemWireValue<ItemKind> | null)[]\n : Field extends { readonly fields: infer Members extends readonly DeclaredFieldLike[] }\n ? readonly RecordOfMembers<Members>[]\n : readonly WireValue[];\n\n/**\n * One declared field's wire value.\n *\n * What each primitive states, and what it cannot:\n *\n * - `string`, `date` and `instant` are `string`: the runtime's values are canonical text, not a\n * `Date`, and no branded type exists for a civil date or an instant.\n * - `boolean`, `integer` are the JavaScript primitive the wire admits.\n * - `decimal` is `DecimalString`, the runtime's own brand for canonical decimal text.\n * - `money` is `MoneyValue`, whose shape is exact; the declared `currency` and `scale` are\n * runtime members, not type literals.\n * - `timeslot` is `TimeslotValue`; `media_ref` and `signature_ref` are `WireRecord`, because the\n * closed member sets live in the generated metaschema registry and no interface states them.\n * - `record` and `array` recurse into the declarations the literal states.\n */\ntype WireValueFor<Field extends DeclaredFieldLike> = Field['primitive'] extends infer Kind extends\n Primitive\n ? Kind extends 'string' | 'date' | 'instant' | 'time'\n ? string\n : Kind extends 'boolean'\n ? boolean\n : Kind extends 'integer'\n ? number\n : Kind extends 'decimal'\n ? DecimalString\n : Kind extends 'money'\n ? MoneyValue\n : Kind extends 'duration'\n ? DurationValue\n : Kind extends 'address'\n ? AddressValue\n : Kind extends 'coordinate'\n ? CoordinateValue\n : Kind extends 'timeslot'\n ? TimeslotValue\n : Kind extends 'media_ref' | 'signature_ref'\n ? WireRecord\n : Kind extends 'record'\n ? RecordOfMembers<MembersOf<Field>>\n : Kind extends 'array'\n ? ArrayWireValue<Field>\n : // A primitive added to the union before this table learns it degrades to the\n // wire union rather than to `never`; the contract is the floor, not a guess.\n WireValue\n : never;\n\n/** One top-level member of a submission record: the declared value, or the empty `null`. */\ntype MemberOf<Field extends DeclaredFieldLike> = WireValueFor<Field> | null;\n\n/**\n * The record a submission carries.\n *\n * Members are optional because the projection omits a field no input supplies, and the compiler\n * emits only fields the document declares. A non-tuple field list falls back to a string index\n * over the same member type rather than inventing ids it cannot know.\n */\ntype RecordOfMembers<Fields extends readonly DeclaredFieldLike[]> = number extends Fields['length']\n ? Readonly<Record<string, MemberOf<Fields[number]> | undefined>>\n : Fields extends readonly [\n infer Head extends DeclaredFieldLike,\n ...infer Rest extends readonly DeclaredFieldLike[],\n ]\n ? { readonly [Id in Head['fieldId']]?: MemberOf<Head> } & RecordOfMembers<Rest>\n : {};\n\n/**\n * The shape an authored document literal states.\n *\n * This is the one derivation: `defineDocument` reads `Doc` from its argument and returns a\n * `TypedArtifact<ShapeOfDocument<Doc>>`, so a host never writes the field ids twice.\n */\nexport type ShapeOfDocument<Document> = Document extends {\n readonly fields: infer Fields extends readonly DeclaredFieldLike[];\n}\n ? {\n readonly record: RecordOfMembers<Fields>;\n readonly fields: FieldMapOf<Fields, false>;\n readonly rules: Document extends { readonly rules: readonly (infer Rule)[] }\n ? Rule extends { readonly ruleId: infer Id extends string }\n ? Id\n : never\n : never;\n }\n : never;\n"]}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A local time of day, `spec/semantics/model-v1.md` `MODEL-2.1.23`.
|
|
3
|
+
*
|
|
4
|
+
* A time is a civil clock reading with no date and no zone: `HH:MM` when the seconds are zero and
|
|
5
|
+
* `HH:MM:SS` otherwise, 24-hour. It is deliberately *not* an instant and not a `Date`: the value a
|
|
6
|
+
* form captures is what a person reads on a wall clock, and a zone would be a claim the runtime
|
|
7
|
+
* cannot verify. Ordering is the canonical text's order: `HH:MM` is a prefix of `HH:MM:SS` for
|
|
8
|
+
* the same minute, so the byte order is the clock's order. Minute arithmetic wraps inside one day
|
|
9
|
+
* because a time names no day.
|
|
10
|
+
*/
|
|
11
|
+
/** The admitted time spellings: 24-hour, seconds optional, no zone. */
|
|
12
|
+
export declare const TIME_PATTERN: RegExp;
|
|
13
|
+
/** The canonical spelling of a time already known to be valid. */
|
|
14
|
+
export interface ClockTime {
|
|
15
|
+
readonly hours: number;
|
|
16
|
+
readonly minutes: number;
|
|
17
|
+
readonly seconds: number;
|
|
18
|
+
}
|
|
19
|
+
/** The number of seconds in one day. */
|
|
20
|
+
export declare const SECONDS_PER_DAY = 86400;
|
|
21
|
+
/**
|
|
22
|
+
* The canonical text of a clock reading.
|
|
23
|
+
*
|
|
24
|
+
* `HH:MM` is canonical exactly when the seconds are zero, so one time has one spelling and two
|
|
25
|
+
* documents that write `09:00` and `09:00:00` cannot compare as different values.
|
|
26
|
+
*/
|
|
27
|
+
export declare function formatClockTime(time: ClockTime): string;
|
|
28
|
+
/**
|
|
29
|
+
* Reads one time spelling, or refuses it at `path`.
|
|
30
|
+
*
|
|
31
|
+
* The pattern bounds the digits and the ranges a pattern can express; the canonical check is
|
|
32
|
+
* separate because `09:00:00` is a valid clock reading but not the canonical spelling of it, and
|
|
33
|
+
* the wire contract never repairs a value (`MODEL-7.1.2`).
|
|
34
|
+
*/
|
|
35
|
+
export declare function parseClockTime(text: string, path?: string): ClockTime;
|
|
36
|
+
/** Reads a time and answers its canonical text, for the boundary that has not yet checked it. */
|
|
37
|
+
export declare function canonicalTimeText(text: string, path?: string): string;
|
|
38
|
+
/** The seconds from midnight a canonical time names. */
|
|
39
|
+
export declare function secondsSinceMidnight(time: ClockTime): number;
|
|
40
|
+
/** A clock reading from a seconds-from-midnight count, wrapped into one day. */
|
|
41
|
+
export declare function clockTimeFromSeconds(total: number): ClockTime;
|
|
42
|
+
/** The canonical time a whole number of minutes later, wrapping inside the day. */
|
|
43
|
+
export declare function addMinutesToTime(text: string, minutes: number, path?: string): string;
|
|
44
|
+
/**
|
|
45
|
+
* Whole minutes from `from` to `to`, `to - from`.
|
|
46
|
+
*
|
|
47
|
+
* A pair with seconds contributes only whole minutes: the answer is an integer because
|
|
48
|
+
* `minutes_between` is typed `integer`, and a half minute is not a minute. The difference is not
|
|
49
|
+
* wrapped, so `minutes_between(time "23:00", time "01:00")` is negative and a caller that means
|
|
50
|
+
* "until tomorrow" adds a day at the host boundary, where the day is known.
|
|
51
|
+
*/
|
|
52
|
+
export declare function minutesBetweenTimes(from: string, to: string, path?: string): number;
|
|
53
|
+
/**
|
|
54
|
+
* The order of two canonical times.
|
|
55
|
+
*
|
|
56
|
+
* The spelling is not fixed-width — `HH:MM` when the seconds are zero, `HH:MM:SS` otherwise — but
|
|
57
|
+
* a shorter canonical time is a prefix of the longer one for the same minute, so the byte order
|
|
58
|
+
* is still the clock's order.
|
|
59
|
+
*/
|
|
60
|
+
export declare function compareTimeText(left: string, right: string, path?: string): number;
|
|
61
|
+
//# sourceMappingURL=time.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"time.d.ts","sourceRoot":"","sources":["../../src/model/time.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AAEH,uEAAuE;AACvE,eAAO,MAAM,YAAY,EAAE,MAA4D,CAAC;AAExF,kEAAkE;AAClE,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,wCAAwC;AACxC,eAAO,MAAM,eAAe,QAAS,CAAC;AAEtC;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,SAAS,GAAG,MAAM,CAKvD;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,SAAK,GAAG,SAAS,CAsBjE;AAED,iGAAiG;AACjG,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,SAAK,GAAG,MAAM,CAEjE;AAED,wDAAwD;AACxD,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,SAAS,GAAG,MAAM,CAE5D;AAED,gFAAgF;AAChF,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAO7D;AAED,mFAAmF;AACnF,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,SAAK,GAAG,MAAM,CAUjF;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,SAAK,GAAG,MAAM,CAO/E;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,SAAK,GAAG,MAAM,CAK9E"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { AxiomError } from './errors.js';
|
|
2
|
+
/**
|
|
3
|
+
* A local time of day, `spec/semantics/model-v1.md` `MODEL-2.1.23`.
|
|
4
|
+
*
|
|
5
|
+
* A time is a civil clock reading with no date and no zone: `HH:MM` when the seconds are zero and
|
|
6
|
+
* `HH:MM:SS` otherwise, 24-hour. It is deliberately *not* an instant and not a `Date`: the value a
|
|
7
|
+
* form captures is what a person reads on a wall clock, and a zone would be a claim the runtime
|
|
8
|
+
* cannot verify. Ordering is the canonical text's order: `HH:MM` is a prefix of `HH:MM:SS` for
|
|
9
|
+
* the same minute, so the byte order is the clock's order. Minute arithmetic wraps inside one day
|
|
10
|
+
* because a time names no day.
|
|
11
|
+
*/
|
|
12
|
+
/** The admitted time spellings: 24-hour, seconds optional, no zone. */
|
|
13
|
+
export const TIME_PATTERN = /^(?:[01][0-9]|2[0-3]):[0-5][0-9](?::[0-5][0-9])?$/;
|
|
14
|
+
/** The number of seconds in one day. */
|
|
15
|
+
export const SECONDS_PER_DAY = 86_400;
|
|
16
|
+
/**
|
|
17
|
+
* The canonical text of a clock reading.
|
|
18
|
+
*
|
|
19
|
+
* `HH:MM` is canonical exactly when the seconds are zero, so one time has one spelling and two
|
|
20
|
+
* documents that write `09:00` and `09:00:00` cannot compare as different values.
|
|
21
|
+
*/
|
|
22
|
+
export function formatClockTime(time) {
|
|
23
|
+
const hours = String(time.hours).padStart(2, '0');
|
|
24
|
+
const minutes = String(time.minutes).padStart(2, '0');
|
|
25
|
+
if (time.seconds === 0)
|
|
26
|
+
return `${hours}:${minutes}`;
|
|
27
|
+
return `${hours}:${minutes}:${String(time.seconds).padStart(2, '0')}`;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Reads one time spelling, or refuses it at `path`.
|
|
31
|
+
*
|
|
32
|
+
* The pattern bounds the digits and the ranges a pattern can express; the canonical check is
|
|
33
|
+
* separate because `09:00:00` is a valid clock reading but not the canonical spelling of it, and
|
|
34
|
+
* the wire contract never repairs a value (`MODEL-7.1.2`).
|
|
35
|
+
*/
|
|
36
|
+
export function parseClockTime(text, path = '') {
|
|
37
|
+
if (!TIME_PATTERN.test(text)) {
|
|
38
|
+
throw new AxiomError('ENGINE_ERROR', `time must be a 24-hour local time of day spelled HH:MM or HH:MM:SS; ${JSON.stringify(text)} is not`, path);
|
|
39
|
+
}
|
|
40
|
+
const parts = text.split(':');
|
|
41
|
+
const hours = Number(parts[0]);
|
|
42
|
+
const minutes = Number(parts[1]);
|
|
43
|
+
const seconds = parts[2] === undefined ? 0 : Number(parts[2]);
|
|
44
|
+
const time = { hours, minutes, seconds };
|
|
45
|
+
const canonical = formatClockTime(time);
|
|
46
|
+
if (canonical !== text) {
|
|
47
|
+
throw new AxiomError('ENGINE_ERROR', `time ${JSON.stringify(text)} is not canonical; write ${JSON.stringify(canonical)}`, path);
|
|
48
|
+
}
|
|
49
|
+
return time;
|
|
50
|
+
}
|
|
51
|
+
/** Reads a time and answers its canonical text, for the boundary that has not yet checked it. */
|
|
52
|
+
export function canonicalTimeText(text, path = '') {
|
|
53
|
+
return formatClockTime(parseClockTime(text, path));
|
|
54
|
+
}
|
|
55
|
+
/** The seconds from midnight a canonical time names. */
|
|
56
|
+
export function secondsSinceMidnight(time) {
|
|
57
|
+
return time.hours * 3600 + time.minutes * 60 + time.seconds;
|
|
58
|
+
}
|
|
59
|
+
/** A clock reading from a seconds-from-midnight count, wrapped into one day. */
|
|
60
|
+
export function clockTimeFromSeconds(total) {
|
|
61
|
+
const wrapped = ((total % SECONDS_PER_DAY) + SECONDS_PER_DAY) % SECONDS_PER_DAY;
|
|
62
|
+
return {
|
|
63
|
+
hours: Math.floor(wrapped / 3600),
|
|
64
|
+
minutes: Math.floor((wrapped % 3600) / 60),
|
|
65
|
+
seconds: wrapped % 60,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
/** The canonical time a whole number of minutes later, wrapping inside the day. */
|
|
69
|
+
export function addMinutesToTime(text, minutes, path = '') {
|
|
70
|
+
if (!Number.isSafeInteger(minutes)) {
|
|
71
|
+
throw new AxiomError('ENGINE_ERROR', 'add_minutes needs a whole number of minutes', path);
|
|
72
|
+
}
|
|
73
|
+
// BigInt, because `seconds + minutes * 60` in doubles loses low bits above `2^53` and the wrap
|
|
74
|
+
// then reports a plausible but wrong clock reading. The modulo is floored by hand so a negative
|
|
75
|
+
// shift wraps forward inside the day, which is what a time-of-day means.
|
|
76
|
+
const day = BigInt(SECONDS_PER_DAY);
|
|
77
|
+
const total = BigInt(secondsSinceMidnight(parseClockTime(text, path))) + BigInt(minutes) * 60n;
|
|
78
|
+
return formatClockTime(clockTimeFromSeconds(Number(((total % day) + day) % day)));
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Whole minutes from `from` to `to`, `to - from`.
|
|
82
|
+
*
|
|
83
|
+
* A pair with seconds contributes only whole minutes: the answer is an integer because
|
|
84
|
+
* `minutes_between` is typed `integer`, and a half minute is not a minute. The difference is not
|
|
85
|
+
* wrapped, so `minutes_between(time "23:00", time "01:00")` is negative and a caller that means
|
|
86
|
+
* "until tomorrow" adds a day at the host boundary, where the day is known.
|
|
87
|
+
*/
|
|
88
|
+
export function minutesBetweenTimes(from, to, path = '') {
|
|
89
|
+
const start = secondsSinceMidnight(parseClockTime(from, path));
|
|
90
|
+
const end = secondsSinceMidnight(parseClockTime(to, path));
|
|
91
|
+
// Truncation toward zero; a negative fraction truncates to `-0`, which is outside `WireValue`,
|
|
92
|
+
// so zero is stated as zero.
|
|
93
|
+
const minutes = Math.trunc((end - start) / 60);
|
|
94
|
+
return minutes === 0 ? 0 : minutes;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* The order of two canonical times.
|
|
98
|
+
*
|
|
99
|
+
* The spelling is not fixed-width — `HH:MM` when the seconds are zero, `HH:MM:SS` otherwise — but
|
|
100
|
+
* a shorter canonical time is a prefix of the longer one for the same minute, so the byte order
|
|
101
|
+
* is still the clock's order.
|
|
102
|
+
*/
|
|
103
|
+
export function compareTimeText(left, right, path = '') {
|
|
104
|
+
parseClockTime(left, path);
|
|
105
|
+
parseClockTime(right, path);
|
|
106
|
+
if (left === right)
|
|
107
|
+
return 0;
|
|
108
|
+
return left < right ? -1 : 1;
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=time.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"time.js","sourceRoot":"","sources":["../../src/model/time.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC;;;;;;;;;GASG;AAEH,uEAAuE;AACvE,MAAM,CAAC,MAAM,YAAY,GAAW,mDAAmD,CAAC;AASxF,wCAAwC;AACxC,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC;AAEtC;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,IAAe;IAC7C,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAClD,MAAM,OAAO,GAAG,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AC,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,GAAG,CAAC;IAC/F,OAAO,eAAe,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;AACpF,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,mBAAmB,CAAC,IAAY,EAAE,EAAU,EAAE,IAAI,GAAG,EAAE;IACrE,MAAM,KAAK,GAAG,oBAAoB,CAAC,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;IAC/D,MAAM,GAAG,GAAG,oBAAoB,CAAC,cAAc,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC;IAC3D,+FAA+F;IAC/F,6BAA6B;IAC7B,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC;IAC/C,OAAO,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;AACrC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAAC,IAAY,EAAE,KAAa,EAAE,IAAI,GAAG,EAAE;IACpE,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC3B,cAAc,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IAC5B,IAAI,IAAI,KAAK,KAAK;QAAE,OAAO,CAAC,CAAC;IAC7B,OAAO,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC/B,CAAC","sourcesContent":["import { AxiomError } from './errors.js';\n\n/**\n * A local time of day, `spec/semantics/model-v1.md` `MODEL-2.1.23`.\n *\n * A time is a civil clock reading with no date and no zone: `HH:MM` when the seconds are zero and\n * `HH:MM:SS` otherwise, 24-hour. It is deliberately *not* an instant and not a `Date`: the value a\n * form captures is what a person reads on a wall clock, and a zone would be a claim the runtime\n * cannot verify. Ordering is the canonical text's order: `HH:MM` is a prefix of `HH:MM:SS` for\n * the same minute, so the byte order is the clock's order. Minute arithmetic wraps inside one day\n * because a time names no day.\n */\n\n/** The admitted time spellings: 24-hour, seconds optional, no zone. */\nexport const TIME_PATTERN: RegExp = /^(?:[01][0-9]|2[0-3]):[0-5][0-9](?::[0-5][0-9])?$/;\n\n/** The canonical spelling of a time already known to be valid. */\nexport interface ClockTime {\n readonly hours: number;\n readonly minutes: number;\n readonly seconds: number;\n}\n\n/** The number of seconds in one day. */\nexport const SECONDS_PER_DAY = 86_400;\n\n/**\n * The canonical text of a clock reading.\n *\n * `HH:MM` is canonical exactly when the seconds are zero, so one time has one spelling and two\n * documents that write `09:00` and `09:00:00` cannot compare as different values.\n */\nexport function formatClockTime(time: ClockTime): string {\n const hours = String(time.hours).padStart(2, '0');\n const minutes = String(time.minutes).padStart(2, '0');\n if (time.seconds === 0) return `${hours}:${minutes}`;\n return `${hours}:${minutes}:${String(time.seconds).padStart(2, '0')}`;\n}\n\n/**\n * Reads one time spelling, or refuses it at `path`.\n *\n * The pattern bounds the digits and the ranges a pattern can express; the canonical check is\n * separate because `09:00:00` is a valid clock reading but not the canonical spelling of it, and\n * the wire contract never repairs a value (`MODEL-7.1.2`).\n */\nexport function parseClockTime(text: string, path = ''): ClockTime {\n if (!TIME_PATTERN.test(text)) {\n throw new AxiomError(\n 'ENGINE_ERROR',\n `time must be a 24-hour local time of day spelled HH:MM or HH:MM:SS; ${JSON.stringify(text)} is not`,\n path,\n );\n }\n const parts = text.split(':');\n const hours = Number(parts[0]);\n const minutes = Number(parts[1]);\n const seconds = parts[2] === undefined ? 0 : Number(parts[2]);\n const time: ClockTime = { hours, minutes, seconds };\n const canonical = formatClockTime(time);\n if (canonical !== text) {\n throw new AxiomError(\n 'ENGINE_ERROR',\n `time ${JSON.stringify(text)} is not canonical; write ${JSON.stringify(canonical)}`,\n path,\n );\n }\n return time;\n}\n\n/** Reads a time and answers its canonical text, for the boundary that has not yet checked it. */\nexport function canonicalTimeText(text: string, path = ''): string {\n return formatClockTime(parseClockTime(text, path));\n}\n\n/** The seconds from midnight a canonical time names. */\nexport function secondsSinceMidnight(time: ClockTime): number {\n return time.hours * 3600 + time.minutes * 60 + time.seconds;\n}\n\n/** A clock reading from a seconds-from-midnight count, wrapped into one day. */\nexport function clockTimeFromSeconds(total: number): ClockTime {\n const wrapped = ((total % SECONDS_PER_DAY) + SECONDS_PER_DAY) % SECONDS_PER_DAY;\n return {\n hours: Math.floor(wrapped / 3600),\n minutes: Math.floor((wrapped % 3600) / 60),\n seconds: wrapped % 60,\n };\n}\n\n/** The canonical time a whole number of minutes later, wrapping inside the day. */\nexport function addMinutesToTime(text: string, minutes: number, path = ''): string {\n if (!Number.isSafeInteger(minutes)) {\n throw new AxiomError('ENGINE_ERROR', 'add_minutes needs a whole number of minutes', path);\n }\n // BigInt, because `seconds + minutes * 60` in doubles loses low bits above `2^53` and the wrap\n // then reports a plausible but wrong clock reading. The modulo is floored by hand so a negative\n // shift wraps forward inside the day, which is what a time-of-day means.\n const day = BigInt(SECONDS_PER_DAY);\n const total = BigInt(secondsSinceMidnight(parseClockTime(text, path))) + BigInt(minutes) * 60n;\n return formatClockTime(clockTimeFromSeconds(Number(((total % day) + day) % day)));\n}\n\n/**\n * Whole minutes from `from` to `to`, `to - from`.\n *\n * A pair with seconds contributes only whole minutes: the answer is an integer because\n * `minutes_between` is typed `integer`, and a half minute is not a minute. The difference is not\n * wrapped, so `minutes_between(time \"23:00\", time \"01:00\")` is negative and a caller that means\n * \"until tomorrow\" adds a day at the host boundary, where the day is known.\n */\nexport function minutesBetweenTimes(from: string, to: string, path = ''): number {\n const start = secondsSinceMidnight(parseClockTime(from, path));\n const end = secondsSinceMidnight(parseClockTime(to, path));\n // Truncation toward zero; a negative fraction truncates to `-0`, which is outside `WireValue`,\n // so zero is stated as zero.\n const minutes = Math.trunc((end - start) / 60);\n return minutes === 0 ? 0 : minutes;\n}\n\n/**\n * The order of two canonical times.\n *\n * The spelling is not fixed-width — `HH:MM` when the seconds are zero, `HH:MM:SS` otherwise — but\n * a shorter canonical time is a prefix of the longer one for the same minute, so the byte order\n * is still the clock's order.\n */\nexport function compareTimeText(left: string, right: string, path = ''): number {\n parseClockTime(left, path);\n parseClockTime(right, path);\n if (left === right) return 0;\n return left < right ? -1 : 1;\n}\n"]}
|