@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,1604 @@
|
|
|
1
|
+
import { AxiomError, assertNever } from '../../model/errors.js';
|
|
2
|
+
import { ruleTargets } from '../../model/types.js';
|
|
3
|
+
import { isRecord, isWireArray } from '../../model/values.js';
|
|
4
|
+
import { fractionalDigitCount, tryDecimalString } from '../../expr/decimal.js';
|
|
5
|
+
import { ROW_COUNT_CEILING } from '../../model/types.js';
|
|
6
|
+
import { mediaAcceptMatches } from '../../model/media.js';
|
|
7
|
+
import { rowKeyToken, toWireValue, wireDeclarationOf } from '../../model/wire.js';
|
|
8
|
+
import { diagnosticOfEngineError } from '../error-diagnostic.js';
|
|
9
|
+
import { addressingOf, addressingOfItems, declarationOf } from '../addressing.js';
|
|
10
|
+
import { meetAccess } from '../access/overlay.js';
|
|
11
|
+
import { fieldKey } from '../access/projection.js';
|
|
12
|
+
import { ineligibleOptionValue, ineligibleWireValue, optionCodeValue } from '../options.js';
|
|
13
|
+
import { declaredUnavailableOptions, hostUnavailableItems, hostUnavailableOption, } from './unavailable-options.js';
|
|
14
|
+
import { permitsUserWrite } from '../access/write.js';
|
|
15
|
+
import { indexUndecidedCauses } from '../undecided.js';
|
|
16
|
+
import { classifyValue } from './value-state.js';
|
|
17
|
+
import { noteAddressingBuild, noteCompiledRuleRead, noteDerivedEntry, noteReportRowTokenBuild, noteRuleResultRead, } from './measurement.js';
|
|
18
|
+
/** The pair an item-scoped writer is keyed by: the array that holds the row and the member it owns. */
|
|
19
|
+
function itemWriterKey(arrayFieldId, memberFieldId) {
|
|
20
|
+
return `${arrayFieldId}\u0000${memberFieldId}`;
|
|
21
|
+
}
|
|
22
|
+
/** Every writer target of one artifact, in one pass over its rules. */
|
|
23
|
+
export function writerTargetsOf(compiled) {
|
|
24
|
+
const fields = new Set();
|
|
25
|
+
const itemMembers = new Set();
|
|
26
|
+
const defaultFields = new Set();
|
|
27
|
+
const defaultItemMembers = new Set();
|
|
28
|
+
for (const rule of compiled.rules ?? []) {
|
|
29
|
+
noteCompiledRuleRead();
|
|
30
|
+
if (rule.kind !== 'compute' && rule.kind !== 'defaultCompute')
|
|
31
|
+
continue;
|
|
32
|
+
if (rule.scope === 'item') {
|
|
33
|
+
if (rule.fieldId !== undefined && rule.targetFieldId !== undefined) {
|
|
34
|
+
const key = itemWriterKey(rule.fieldId, rule.targetFieldId);
|
|
35
|
+
itemMembers.add(key);
|
|
36
|
+
if (rule.kind === 'defaultCompute')
|
|
37
|
+
defaultItemMembers.add(key);
|
|
38
|
+
}
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
for (const fieldId of ruleTargets(rule)) {
|
|
42
|
+
fields.add(fieldId);
|
|
43
|
+
if (rule.kind === 'defaultCompute')
|
|
44
|
+
defaultFields.add(fieldId);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return { fields, itemMembers, defaultFields, defaultItemMembers };
|
|
48
|
+
}
|
|
49
|
+
/** Indexes the artifact's rules by the field they decide and the report's results by rule. */
|
|
50
|
+
export function indexDerivedRules(compiled, report, undecided = new Map()) {
|
|
51
|
+
const byField = new Map();
|
|
52
|
+
const itemByArray = new Map();
|
|
53
|
+
const ruleById = new Map();
|
|
54
|
+
const firstResult = new Map();
|
|
55
|
+
const rowResults = new Map();
|
|
56
|
+
const rowlessResults = new Map();
|
|
57
|
+
const firstUndecided = new Map();
|
|
58
|
+
const undecidedCauses = indexUndecidedCauses(undecided);
|
|
59
|
+
let hasDeferred = false;
|
|
60
|
+
for (const rule of compiled.rules ?? []) {
|
|
61
|
+
noteCompiledRuleRead();
|
|
62
|
+
// Keep the former lookup's first answer if a hand-built artifact repeats an id.
|
|
63
|
+
if (!ruleById.has(rule.ruleId))
|
|
64
|
+
ruleById.set(rule.ruleId, rule);
|
|
65
|
+
if (rule.scope === 'item') {
|
|
66
|
+
if (rule.fieldId === undefined)
|
|
67
|
+
continue;
|
|
68
|
+
push(itemByArray, rule.fieldId, rule);
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
for (const fieldId of ruleTargets(rule))
|
|
72
|
+
push(byField, fieldId, rule);
|
|
73
|
+
}
|
|
74
|
+
for (const result of report.rules) {
|
|
75
|
+
noteRuleResultRead();
|
|
76
|
+
// The first result is the one every field-level question asks; a later one belongs to
|
|
77
|
+
// another row of the same item rule.
|
|
78
|
+
if (!firstResult.has(result.ruleId))
|
|
79
|
+
firstResult.set(result.ruleId, result);
|
|
80
|
+
// A `DEFERRED` result is the handoff it states, and a rule that did not decide but read a
|
|
81
|
+
// value the server holds leaves the same handoff: a Kleene fold can turn `DEFERRED` into
|
|
82
|
+
// `UNKNOWN`, and a permissive gate policy can turn an undecided verdict into `PASS`, so the
|
|
83
|
+
// result alone cannot say whether the server still owes the record an answer (`RULES-2.1.1`).
|
|
84
|
+
if (result.status === 'DEFERRED' ||
|
|
85
|
+
undecidedCauses.causeOf(result.ruleId, result.rowKey)?.handoff === true) {
|
|
86
|
+
hasDeferred = true;
|
|
87
|
+
}
|
|
88
|
+
if (result.severity === 'block' &&
|
|
89
|
+
result.status === 'UNKNOWN' &&
|
|
90
|
+
!firstUndecided.has(result.ruleId)) {
|
|
91
|
+
firstUndecided.set(result.ruleId, result);
|
|
92
|
+
}
|
|
93
|
+
if (result.rowKey === undefined) {
|
|
94
|
+
// The first row-less result is the whole-rule answer a row falls back to, which is what
|
|
95
|
+
// the former scan selected.
|
|
96
|
+
if (!rowlessResults.has(result.ruleId))
|
|
97
|
+
rowlessResults.set(result.ruleId, result);
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
let byRow = rowResults.get(result.ruleId);
|
|
101
|
+
if (byRow === undefined) {
|
|
102
|
+
byRow = new Map();
|
|
103
|
+
rowResults.set(result.ruleId, byRow);
|
|
104
|
+
}
|
|
105
|
+
const token = rowKeyToken(result.rowKey);
|
|
106
|
+
// A report states one result per addressed row; the first keeps the former scan's answer
|
|
107
|
+
// if an artifact ever repeated a key.
|
|
108
|
+
if (!byRow.has(token))
|
|
109
|
+
byRow.set(token, result);
|
|
110
|
+
}
|
|
111
|
+
return {
|
|
112
|
+
byField,
|
|
113
|
+
itemByArray,
|
|
114
|
+
ruleById,
|
|
115
|
+
firstResult,
|
|
116
|
+
rowResults,
|
|
117
|
+
rowlessResults,
|
|
118
|
+
firstUndecided,
|
|
119
|
+
undecided: undecidedCauses,
|
|
120
|
+
hasDeferred,
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
function push(index, key, value) {
|
|
124
|
+
const list = index.get(key);
|
|
125
|
+
if (list === undefined)
|
|
126
|
+
index.set(key, [value]);
|
|
127
|
+
else
|
|
128
|
+
list.push(value);
|
|
129
|
+
}
|
|
130
|
+
/** The addressing an array states when none of its rows is addressable. */
|
|
131
|
+
const UNSUPPORTED_ADDRESSING = { rowAddressing: 'unsupported', rows: [] };
|
|
132
|
+
/** The severity order readiness folds: a stricter rule outranks a looser one. */
|
|
133
|
+
const SEVERITY_RANK = {
|
|
134
|
+
block: 2,
|
|
135
|
+
warn: 1,
|
|
136
|
+
info: 0,
|
|
137
|
+
};
|
|
138
|
+
/** The stricter of two severities, ignoring an absent one. */
|
|
139
|
+
function strongestSeverity(current, next) {
|
|
140
|
+
if (next === undefined)
|
|
141
|
+
return current;
|
|
142
|
+
if (current === undefined)
|
|
143
|
+
return next;
|
|
144
|
+
return SEVERITY_RANK[next] > SEVERITY_RANK[current] ? next : current;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Derives every declared field's state, in declaration order.
|
|
148
|
+
*
|
|
149
|
+
* A record's members are read through the container value the record holds, so a member of a
|
|
150
|
+
* container this device may not read is itself withheld rather than reported as absent. An
|
|
151
|
+
* array's members are derived once per addressable row, because a row rule decides that row
|
|
152
|
+
* and no other.
|
|
153
|
+
*
|
|
154
|
+
* `reuse` names the entries a caller already holds and the fields whose facts the commit may
|
|
155
|
+
* have moved. A field outside that set is carried over whole: its declaration, value path,
|
|
156
|
+
* rows and rule answers are facts no change in this pass reached, so re-deriving it would
|
|
157
|
+
* repeat work whose result is already frozen in `previous`.
|
|
158
|
+
*/
|
|
159
|
+
export function deriveFields(context, reuse) {
|
|
160
|
+
const declared = walkDeclarations(context, context.compiled.fields, [], undefined, [], true, true, true);
|
|
161
|
+
// One addressing per array for the whole pass. A member shares the container's answer
|
|
162
|
+
// whenever its own delivery chain is the array's; a caller with a stricter chain is answered
|
|
163
|
+
// on its own, so the shared entry never widens what a record cell inside a row withheld.
|
|
164
|
+
const addressed = new Map();
|
|
165
|
+
const arrays = new Map(declared
|
|
166
|
+
.filter((entry) => entry.field.primitive === 'array')
|
|
167
|
+
.map((entry) => [entry.field.fieldId, entry]));
|
|
168
|
+
return withFieldSourceEligibility(context, declared.map((entry) => {
|
|
169
|
+
if (reuse === undefined ||
|
|
170
|
+
reuse.affected === 'all' ||
|
|
171
|
+
reuse.affected.has(entry.field.fieldId)) {
|
|
172
|
+
return deriveField(context, entry, addressed, arrays);
|
|
173
|
+
}
|
|
174
|
+
// The compiled artifact is static for a session, so every declaration still has an entry;
|
|
175
|
+
// a missing one is a caller's incomplete map, not a reason to state a stale fact.
|
|
176
|
+
return (reuse.previous.get(entry.field.fieldId) ?? deriveField(context, entry, addressed, arrays));
|
|
177
|
+
}), declared);
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* The addressing of one array, built once per pass.
|
|
181
|
+
*
|
|
182
|
+
* A container and every member of it ask the same question — which rows does this array
|
|
183
|
+
* address — so the pass answers it once per array. Building it per member made an artifact with
|
|
184
|
+
* M members allocate M+1 copies of every row object and M+1 token sets for the same rows. A
|
|
185
|
+
* caller whose delivery chain is stricter than the array's own (a record the row carries, whose
|
|
186
|
+
* own answer is a cell's) is answered on its own rather than handed a wider answer.
|
|
187
|
+
*/
|
|
188
|
+
function addressingFor(addressed, arrays, context, arrayFieldId, ancestorsDeliverable) {
|
|
189
|
+
const array = arrays.get(arrayFieldId);
|
|
190
|
+
if (array === undefined)
|
|
191
|
+
return UNSUPPORTED_ADDRESSING;
|
|
192
|
+
if (array.identityAncestorsDeliverable !== ancestorsDeliverable) {
|
|
193
|
+
return addressRows(context, array.field, ancestorsDeliverable);
|
|
194
|
+
}
|
|
195
|
+
const cached = addressed.get(arrayFieldId);
|
|
196
|
+
if (cached !== undefined)
|
|
197
|
+
return cached;
|
|
198
|
+
noteAddressingBuild();
|
|
199
|
+
const addressing = addressRows(context, array.field, array.identityAncestorsDeliverable);
|
|
200
|
+
addressed.set(arrayFieldId, addressing);
|
|
201
|
+
return addressing;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* The value a domain built from another field's recorded array offers, `[MODEL-3.1.8]`.
|
|
205
|
+
*
|
|
206
|
+
* Only a delivered value is read: a source this device may not read (`withheld` for `masked`,
|
|
207
|
+
* `write_only` or `hidden`) decides nothing, so eligibility can never be used to probe a value
|
|
208
|
+
* the access answer withholds. A readable absence is an empty domain — the list the user ranked
|
|
209
|
+
* was cleared — and therefore refuses every non-empty selection.
|
|
210
|
+
*/
|
|
211
|
+
function optionDomainOf(value) {
|
|
212
|
+
switch (value.kind) {
|
|
213
|
+
case 'value':
|
|
214
|
+
if (value.value === null)
|
|
215
|
+
return [];
|
|
216
|
+
return isWireArray(value.value) ? value.value : undefined;
|
|
217
|
+
case 'absent':
|
|
218
|
+
return [];
|
|
219
|
+
case 'withheld':
|
|
220
|
+
return undefined;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Fills in the eligibility a `field` option source states.
|
|
225
|
+
*
|
|
226
|
+
* The source is another field's recorded array, so the answer needs the derived state of a
|
|
227
|
+
* field that may be declared after the one reading it; this runs once over the finished list
|
|
228
|
+
* rather than threading a declaration index through every field. A row-scoped declarer reads a
|
|
229
|
+
* sibling member in the same row; every other declarer reads the source's field-level value.
|
|
230
|
+
* The entries a wrong or unchanged answer would leave alone keep their object identity.
|
|
231
|
+
*
|
|
232
|
+
* A writer owns the cell a rule reads through the overlay, so eligibility reads that same value:
|
|
233
|
+
* a row-scoped `optionSource` whose cell an item writer produced offers the written domain, not
|
|
234
|
+
* the submitted one (or none). A cell the access answer withholds decides nothing, and a writer
|
|
235
|
+
* the device may not read is never consulted for it.
|
|
236
|
+
*/
|
|
237
|
+
function withFieldSourceEligibility(context, fields, declared) {
|
|
238
|
+
const byId = new Map(fields.map((field) => [field.fieldId, field]));
|
|
239
|
+
const rowScoped = new Set(declared.filter((entry) => entry.array !== undefined).map((entry) => entry.field.fieldId));
|
|
240
|
+
/** The array whose rows hold each row-scoped declaration, for the writer-target key. */
|
|
241
|
+
const arrayOf = new Map(declared.flatMap((entry) => entry.array === undefined ? [] : [[entry.field.fieldId, entry.array.fieldId]]));
|
|
242
|
+
return fields.map((field) => {
|
|
243
|
+
const source = field.optionSource;
|
|
244
|
+
if (source?.kind !== 'field')
|
|
245
|
+
return field;
|
|
246
|
+
const sourceField = byId.get(source.fieldId);
|
|
247
|
+
if (sourceField === undefined)
|
|
248
|
+
return field;
|
|
249
|
+
const sourceScoped = rowScoped.has(source.fieldId);
|
|
250
|
+
// Built on the first delivered selection, not for an empty reader with no domain to judge.
|
|
251
|
+
let sourceRows;
|
|
252
|
+
const arrayFieldId = arrayOf.get(source.fieldId);
|
|
253
|
+
/** Whether a writer owns the source cell, so the stored value is not its answer. */
|
|
254
|
+
const owned = () => arrayFieldId === undefined
|
|
255
|
+
? context.writers.fields.has(source.fieldId)
|
|
256
|
+
: context.writers.itemMembers.has(itemWriterKey(arrayFieldId, source.fieldId));
|
|
257
|
+
/** Whether that writer is a default whose absent entry means the stored value is in force. */
|
|
258
|
+
const defaulted = arrayFieldId === undefined
|
|
259
|
+
? context.writers.defaultFields.has(source.fieldId)
|
|
260
|
+
: context.writers.defaultItemMembers.has(itemWriterKey(arrayFieldId, source.fieldId));
|
|
261
|
+
/** The domain the writer produced for this cell, when one owns it. */
|
|
262
|
+
const writtenDomain = (rowKey) => {
|
|
263
|
+
const written = sourceScoped
|
|
264
|
+
? rowKey === undefined
|
|
265
|
+
? undefined
|
|
266
|
+
: context.snapshot.computed.getRow(source.fieldId, rowKey)
|
|
267
|
+
: context.snapshot.computed.get(source.fieldId);
|
|
268
|
+
if (written === undefined)
|
|
269
|
+
return owned() && !defaulted ? undefined : NOT_WRITTEN;
|
|
270
|
+
// An undecided writer states no domain: an empty one would refuse every selection.
|
|
271
|
+
return written.kind === 'decided'
|
|
272
|
+
? optionDomainOf({ kind: 'value', value: written.value })
|
|
273
|
+
: undefined;
|
|
274
|
+
};
|
|
275
|
+
const domainFor = (rowKey) => {
|
|
276
|
+
const stored = sourceScoped
|
|
277
|
+
? rowKey === undefined
|
|
278
|
+
? undefined
|
|
279
|
+
: (sourceRows ??= new Map((sourceField.rows ?? []).map((row) => [rowKeyToken(row.rowKey), row]))).get(rowKeyToken(rowKey))
|
|
280
|
+
: sourceField;
|
|
281
|
+
// A cell this device may not read decides nothing, and its writer is not an oracle for it.
|
|
282
|
+
if (stored !== undefined && stored.value.kind === 'withheld')
|
|
283
|
+
return undefined;
|
|
284
|
+
const written = writtenDomain(rowKey);
|
|
285
|
+
if (written !== NOT_WRITTEN)
|
|
286
|
+
return written;
|
|
287
|
+
return stored === undefined ? undefined : optionDomainOf(stored.value);
|
|
288
|
+
};
|
|
289
|
+
const own = rowScoped.has(field.fieldId);
|
|
290
|
+
// Only a binding that holds a selection needs the domain; an empty field still pays nothing
|
|
291
|
+
// for a source array that may hold thousands of values.
|
|
292
|
+
const fieldLevel = own || field.value.kind !== 'value'
|
|
293
|
+
? field
|
|
294
|
+
: withInvalidValue(field, field.value, domainFor(undefined));
|
|
295
|
+
if (field.rows === undefined)
|
|
296
|
+
return fieldLevel;
|
|
297
|
+
let moved = false;
|
|
298
|
+
const rows = field.rows.map((row) => {
|
|
299
|
+
if (row.value.kind !== 'value')
|
|
300
|
+
return row;
|
|
301
|
+
const next = withRowInvalidValue(row, domainFor(own ? row.rowKey : undefined));
|
|
302
|
+
if (next !== row)
|
|
303
|
+
moved = true;
|
|
304
|
+
return next;
|
|
305
|
+
});
|
|
306
|
+
// A container whose rows all state the same refusal is the entry that already exists, so a
|
|
307
|
+
// pass that carried it over does not replace it with an equal copy.
|
|
308
|
+
return moved ? { ...fieldLevel, rows } : fieldLevel;
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
/** No overlay entry displaces the stored value: no writer owns the cell, or its default is overridden. */
|
|
312
|
+
const NOT_WRITTEN = Symbol('not written');
|
|
313
|
+
/** One field entry with the refusal its domain states, keeping the object when none moved. */
|
|
314
|
+
function withInvalidValue(field, value, domain) {
|
|
315
|
+
if (domain === undefined)
|
|
316
|
+
return field;
|
|
317
|
+
const invalidValue = ineligibleWireValue(value.value, domain);
|
|
318
|
+
if (invalidValue === field.invalidValue)
|
|
319
|
+
return field;
|
|
320
|
+
const { invalidValue: _previous, ...rest } = field;
|
|
321
|
+
return invalidValue === undefined ? rest : { ...rest, invalidValue };
|
|
322
|
+
}
|
|
323
|
+
/** One row entry with the refusal its domain states, keeping the object when none moved. */
|
|
324
|
+
function withRowInvalidValue(row, domain) {
|
|
325
|
+
if (domain === undefined || row.value.kind !== 'value')
|
|
326
|
+
return row;
|
|
327
|
+
const invalidValue = ineligibleWireValue(row.value.value, domain);
|
|
328
|
+
if (invalidValue === row.invalidValue)
|
|
329
|
+
return row;
|
|
330
|
+
const { invalidValue: _previous, ...rest } = row;
|
|
331
|
+
return invalidValue === undefined ? rest : { ...rest, invalidValue };
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* Walks every declared field, carrying the value path and the container's delivery answer.
|
|
335
|
+
*
|
|
336
|
+
* Delivery is per reference, but what "per reference" means differs by container shape. A record
|
|
337
|
+
* value is delivered as one payload and a read of it is refused when any member is unreadable, so
|
|
338
|
+
* a record member is withheld with its container. A member of an array is delivered once per row
|
|
339
|
+
* by that member's own row entry — the reader carries the members it may read and removes the one
|
|
340
|
+
* it may not — so an array's members are judged on their own and a withheld sibling withholds
|
|
341
|
+
* only itself. A record inside a row keeps the row that holds it, so a member of that record is
|
|
342
|
+
* still a member of the array: its value lives in the row's cell, never at a path that crosses
|
|
343
|
+
* the list.
|
|
344
|
+
*/
|
|
345
|
+
function walkDeclarations(context, members, valuePath, row, ancestors, containerPayload, containerVisible, ancestorsDeliverable) {
|
|
346
|
+
const declared = [];
|
|
347
|
+
const parent = ancestors[ancestors.length - 1];
|
|
348
|
+
const itemMember = parent?.primitive === 'array';
|
|
349
|
+
for (const field of members) {
|
|
350
|
+
const fieldPath = [...valuePath, field.fieldId];
|
|
351
|
+
// A record member is read through its container; an item member of an array has one
|
|
352
|
+
// value per row, so its field-level value path is the array that holds it.
|
|
353
|
+
const path = itemMember ? valuePath : fieldPath;
|
|
354
|
+
// A record member inherits its container's payload answer; a member of an array is judged once
|
|
355
|
+
// per row and needs only the chain above the array to deliver, because the array's rows are
|
|
356
|
+
// delivered by the member's own entries rather than inside the array's value.
|
|
357
|
+
const rowScoped = rowScopedMember(itemMember, field);
|
|
358
|
+
const own = rowScoped
|
|
359
|
+
? context.snapshot.access.ownDelivery(field.fieldId).deliverable
|
|
360
|
+
: subtreeDeliverable(context, field);
|
|
361
|
+
const deliverable = itemMember ? ancestorsDeliverable && own : containerPayload && own;
|
|
362
|
+
const rowsOnScreen = rowScoped ||
|
|
363
|
+
(!itemMember &&
|
|
364
|
+
field.primitive === 'array' &&
|
|
365
|
+
!context.snapshot.access.hiddenRow(field.fieldId));
|
|
366
|
+
const visible = containerVisible &&
|
|
367
|
+
!context.layoutHidden.has(field.fieldId) &&
|
|
368
|
+
derivedAccess(context, rowsOnScreen, field) !== 'hidden' &&
|
|
369
|
+
!hiddenByRule(context, field.fieldId);
|
|
370
|
+
const fieldRow = itemMember && parent !== undefined
|
|
371
|
+
? { path: [field.fieldId], array: parent }
|
|
372
|
+
: row === undefined
|
|
373
|
+
? undefined
|
|
374
|
+
: { path: [...row.path, field.fieldId], array: row.array };
|
|
375
|
+
const identityAncestorCount = itemMember ? ancestors.length - 1 : ancestors.length;
|
|
376
|
+
const identityAncestorsDeliverable = ancestors.every((ancestor, index) => index >= identityAncestorCount || declarationOwnDeliverable(context, ancestor));
|
|
377
|
+
declared.push({
|
|
378
|
+
field,
|
|
379
|
+
array: fieldRow?.array,
|
|
380
|
+
rowPath: fieldRow?.path ?? [],
|
|
381
|
+
valuePath: path,
|
|
382
|
+
deliverable,
|
|
383
|
+
rowScoped,
|
|
384
|
+
rowsOnScreen,
|
|
385
|
+
ancestorsDeliverable,
|
|
386
|
+
identityAncestorsDeliverable,
|
|
387
|
+
visible,
|
|
388
|
+
// A field-scope rule naming a member of an array decides the member in every row, so
|
|
389
|
+
// the answer is carried here and reaches the row facts below.
|
|
390
|
+
requirement: requirementByRules(context, field.fieldId),
|
|
391
|
+
enabledByRules: enabledByRules(context, field.fieldId),
|
|
392
|
+
});
|
|
393
|
+
if (field.fields !== undefined && field.fields.length > 0) {
|
|
394
|
+
declared.push(...walkDeclarations(context, field.fields, field.primitive === 'array' ? path : fieldPath,
|
|
395
|
+
// A nested array's children are its own rows; a record's children stay in this row.
|
|
396
|
+
field.primitive === 'array' ? undefined : fieldRow, [...ancestors, field], deliverable, visible, ancestorsDeliverable && declarationDeliverable(context, field)));
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
return declared;
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* Whether one declaration's answers are asked once per row rather than for a container payload.
|
|
403
|
+
*
|
|
404
|
+
* A member of an array is delivered once per row by that member's own row entry, so a row-exact
|
|
405
|
+
* restriction withholds that row's cell and never the field, its siblings or the row beside it
|
|
406
|
+
* (`[ACCESS-1.3.1]`). A record or array inside a row is one payload, and a container is one value,
|
|
407
|
+
* so their own answers still fold what they carry: no cell of an undelivered payload is stated.
|
|
408
|
+
*/
|
|
409
|
+
function rowScopedMember(itemMember, field) {
|
|
410
|
+
return itemMember && field.primitive !== 'record' && field.primitive !== 'array';
|
|
411
|
+
}
|
|
412
|
+
/**
|
|
413
|
+
* The access a declaration's own field-level facts are stated from.
|
|
414
|
+
*
|
|
415
|
+
* A declaration whose answers are asked per row states its own access rather than the fold over
|
|
416
|
+
* its rows: the fold says `hidden` when one row is restricted, which would take the control off
|
|
417
|
+
* screen and keep readiness from carrying the other rows' answers.
|
|
418
|
+
*/
|
|
419
|
+
function derivedAccess(context, rowsOnScreen, field) {
|
|
420
|
+
return rowsOnScreen
|
|
421
|
+
? context.snapshot.access.ownAccess(field.fieldId)
|
|
422
|
+
: context.snapshot.access.accessFor({ fieldId: field.fieldId });
|
|
423
|
+
}
|
|
424
|
+
/**
|
|
425
|
+
* Whether one declaration's own access answer delivers its value, ignoring its members.
|
|
426
|
+
*
|
|
427
|
+
* The window owns the answer, so this derivation, the report's writer path and an alternative's
|
|
428
|
+
* target filter cannot classify one binding differently.
|
|
429
|
+
*/
|
|
430
|
+
function declarationDeliverable(context, field) {
|
|
431
|
+
return context.snapshot.access.delivery({ fieldId: field.fieldId }).deliverable;
|
|
432
|
+
}
|
|
433
|
+
/**
|
|
434
|
+
* Whether a declaration's own field-wide answer delivers it, before a per-row answer narrows it.
|
|
435
|
+
*
|
|
436
|
+
* Row identity is the one question this separates from the payload answer above:
|
|
437
|
+
*
|
|
438
|
+
* - a container the field-wide levels withhold is not delivered at all, so its derived state
|
|
439
|
+
* states no row key, no length and no derived property (`[ACCESS-1.3.4]`);
|
|
440
|
+
* - a container whose only withheld value is one row's still delivers the rows the device may
|
|
441
|
+
* name, and each row states its own value as withheld, because one row's restriction
|
|
442
|
+
* withholds that row and not the rows and members the device may read (`[ACCESS-1.3.1]`).
|
|
443
|
+
*
|
|
444
|
+
* Stating a row's key is stating the identity of a value, so the first answer decides it. The
|
|
445
|
+
* second answer still decides each row's *value*, and a folded refusal keeps every row withheld.
|
|
446
|
+
*
|
|
447
|
+
* A per-row level that withholds every row (a masked `template`) is not a declaration answer, so
|
|
448
|
+
* the fold decides it and the container states nothing either: the two documented access inputs
|
|
449
|
+
* then agree about the identity a template withholds.
|
|
450
|
+
*/
|
|
451
|
+
function declarationOwnDeliverable(context, field) {
|
|
452
|
+
return context.snapshot.access.ownDelivery(field.fieldId).deliverable;
|
|
453
|
+
}
|
|
454
|
+
/** Whether the field and every member it declares may be delivered to this device. */
|
|
455
|
+
function subtreeDeliverable(context, field) {
|
|
456
|
+
return context.snapshot.access.subtreeDelivers(field.fieldId);
|
|
457
|
+
}
|
|
458
|
+
/** Whether a `visible` rule decided `FAIL` for this field. */
|
|
459
|
+
function hiddenByRule(context, fieldId) {
|
|
460
|
+
for (const rule of context.rules.byField.get(fieldId) ?? []) {
|
|
461
|
+
if (rule.kind !== 'visible')
|
|
462
|
+
continue;
|
|
463
|
+
if (statusOf(context, rule) === 'FAIL')
|
|
464
|
+
return true;
|
|
465
|
+
}
|
|
466
|
+
return false;
|
|
467
|
+
}
|
|
468
|
+
/** One rule's single field-level status; every non-item rule reports exactly one result. */
|
|
469
|
+
function statusOf(context, rule) {
|
|
470
|
+
return resultOf(context, rule).status;
|
|
471
|
+
}
|
|
472
|
+
/** The result of one field-level rule, or a loud failure when the report omits it. */
|
|
473
|
+
function resultOf(context, rule) {
|
|
474
|
+
const first = context.rules.firstResult.get(rule.ruleId);
|
|
475
|
+
if (first === undefined) {
|
|
476
|
+
throw new AxiomError('ENGINE_ERROR', 'the evaluation report carries no result for a declared rule', rule.ruleId);
|
|
477
|
+
}
|
|
478
|
+
return first;
|
|
479
|
+
}
|
|
480
|
+
/** One declared field's derived state. */
|
|
481
|
+
function deriveField(context, declared, addressed, arrays) {
|
|
482
|
+
noteDerivedEntry();
|
|
483
|
+
const { field, valuePath, deliverable } = declared;
|
|
484
|
+
const ref = { fieldId: field.fieldId };
|
|
485
|
+
// A row-answered declaration states its own answer: the fold would report `hidden` for a control
|
|
486
|
+
// one row's restriction leaves on screen (`[ACCESS-1.3.1]`).
|
|
487
|
+
const access = derivedAccess(context, declared.rowsOnScreen, field);
|
|
488
|
+
const writable = permitsUserWrite(access);
|
|
489
|
+
const raw = declared.array === undefined ? rawAt(context.snapshot.input.values, valuePath) : undefined;
|
|
490
|
+
// A member of an array has no field-level value: its value lives once per row, and the rows
|
|
491
|
+
// read the cell. Only a container's own declaration validates a value at a field path.
|
|
492
|
+
const read = declared.array === undefined
|
|
493
|
+
? readValueAt(context.snapshot.input.values, valuePath, field)
|
|
494
|
+
: undefined;
|
|
495
|
+
const wire = read?.kind === 'value' ? read.value : undefined;
|
|
496
|
+
const systemComputed = isSystemComputed(context, field.fieldId, declared.array?.fieldId);
|
|
497
|
+
const computed = declared.array === undefined ? context.snapshot.computed.get(field.fieldId) : undefined;
|
|
498
|
+
// Only an actual overlay entry owns the value. A default whose override is unreadable, or
|
|
499
|
+
// whose evaluation is server-deferred, has no entry and leaves the submitted value in force.
|
|
500
|
+
const presence = presenceOfField(context, raw, field, wire, computed);
|
|
501
|
+
const effectiveAccess = classifyAccess(access, deliverable);
|
|
502
|
+
// A writer is the sole authority for the value it owns, so its decided result is the wire
|
|
503
|
+
// value the control reads. Passing the submitted value here reported a computed field as
|
|
504
|
+
// absent every time nothing was submitted — the `computation` said one thing and `value`
|
|
505
|
+
// another.
|
|
506
|
+
const deliveredWire = computed?.kind === 'decided' ? computed.value : wire;
|
|
507
|
+
const value = classifyValue(presence, effectiveAccess, context.snapshot.access.sessionWriteKeys, deliveredWire, ref);
|
|
508
|
+
const refusal = refusalOf(read, context, presence, effectiveAccess, field.fieldId, computed !== undefined);
|
|
509
|
+
const visible = declared.visible;
|
|
510
|
+
const enabled = writable && declared.enabledByRules;
|
|
511
|
+
const members = (field.fields ?? []).map((member) => member.fieldId);
|
|
512
|
+
const addressing = field.primitive === 'array'
|
|
513
|
+
? addressingFor(addressed, arrays, context, field.fieldId, declared.identityAncestorsDeliverable)
|
|
514
|
+
: undefined;
|
|
515
|
+
// A member's rows are the rows of the array that holds it: one entry per row, holding this
|
|
516
|
+
// member's value in that row. An array declared inside another array states no row of its
|
|
517
|
+
// own — its addressing answers `unsupported` — but its per-row cells are still those of the
|
|
518
|
+
// parent, exactly as a scalar member's are.
|
|
519
|
+
const memberAddressing = declared.array === undefined
|
|
520
|
+
? undefined
|
|
521
|
+
: addressingFor(addressed, arrays, context, declared.array.fieldId, declared.identityAncestorsDeliverable);
|
|
522
|
+
const memberAddressed = memberAddressing !== undefined && memberAddressing.rowAddressing !== 'unsupported';
|
|
523
|
+
const rows = declared.array === undefined
|
|
524
|
+
? addressing === undefined
|
|
525
|
+
? undefined
|
|
526
|
+
: arrayRowStates(context, field, addressing.rows, deliverable,
|
|
527
|
+
// A named row's element is judged by the container's own answer, and one row a
|
|
528
|
+
// container *hides* takes every element with it. The payload fold would withhold a
|
|
529
|
+
// sibling's element for one masked or redacted row, which is that row's answer alone.
|
|
530
|
+
!context.snapshot.access.hiddenRow(field.fieldId) &&
|
|
531
|
+
declarationOwnDeliverable(context, field), rowValuesOf(computed, wire))
|
|
532
|
+
: memberRowStates(context, field, declared, memberAddressing ?? UNSUPPORTED_ADDRESSING);
|
|
533
|
+
// A member of an array has no field-level value, so its requirement is the rows'
|
|
534
|
+
// requirement folded up: the rows carry it, and the field states their answer.
|
|
535
|
+
const required = declared.requirement.required || (rows ?? []).some((row) => row.required);
|
|
536
|
+
let requiredSeverity = declared.requirement.required ? declared.requirement.severity : undefined;
|
|
537
|
+
for (const row of rows ?? []) {
|
|
538
|
+
if (row.required)
|
|
539
|
+
requiredSeverity = strongestSeverity(requiredSeverity, row.requiredSeverity);
|
|
540
|
+
}
|
|
541
|
+
const invalidValue = invalidValueOf(context, field, value, ref);
|
|
542
|
+
// A member of an array has no field-level list: its entries live once per row, and a nested
|
|
543
|
+
// array states no row of its own. Counting the absent field-level value read as a decided
|
|
544
|
+
// zero, which turned a nested `minItems` into a blocker on every record. The same guard the
|
|
545
|
+
// field-level `media` and `decimalScale` take leaves the count to the rows that hold it.
|
|
546
|
+
const cardinality = field.primitive === 'array' && declared.array === undefined
|
|
547
|
+
? cardinalityOf(field, value, computed, wire, raw)
|
|
548
|
+
: undefined;
|
|
549
|
+
// A member of an array has no field-level capture: its value lives once per row, and each row
|
|
550
|
+
// states its own media answer below. Reading the absent field-level value here reported
|
|
551
|
+
// `within` for a capture the rows refused.
|
|
552
|
+
const media = declared.array === undefined
|
|
553
|
+
? mediaConstraintsOf(field, value, computed, wire, raw)
|
|
554
|
+
: undefined;
|
|
555
|
+
// A member of an array has no field-level value, so its scale is answered once per row below.
|
|
556
|
+
const decimalScale = declared.array === undefined ? decimalScaleOf(field, value, computed, wire, raw) : undefined;
|
|
557
|
+
// A nested `rowsFrom` is the same case: the expected count belongs to a field-level list the
|
|
558
|
+
// member does not have, so the field states no count rather than a mismatch against zero.
|
|
559
|
+
const rowCount = field.primitive === 'array' &&
|
|
560
|
+
declared.array === undefined &&
|
|
561
|
+
field.rowsFromSource !== undefined
|
|
562
|
+
? rowCountOf(field, context, value, computed, wire, raw)
|
|
563
|
+
: undefined;
|
|
564
|
+
// A member of an array holds one option domain per row, so its availability is stated on each
|
|
565
|
+
// row below; the field-level answer would describe no row in particular. An array that
|
|
566
|
+
// addresses no row is the exception: its member has one row-less answer from the availability
|
|
567
|
+
// pass, and leaving it undefined would read as "every code is available" while readiness is
|
|
568
|
+
// `UNDETERMINED` (`ENGINE-7.1.7`).
|
|
569
|
+
const unavailableOptions = declared.array === undefined || !memberAddressed
|
|
570
|
+
? unavailableOptionsOf(context, field, ref)
|
|
571
|
+
: undefined;
|
|
572
|
+
return {
|
|
573
|
+
fieldId: field.fieldId,
|
|
574
|
+
path: valuePath,
|
|
575
|
+
primitive: field.primitive,
|
|
576
|
+
...(field.control === undefined ? {} : { control: field.control }),
|
|
577
|
+
...(field.labelKey === undefined ? {} : { labelKey: field.labelKey }),
|
|
578
|
+
...(field.descriptionKey === undefined ? {} : { descriptionKey: field.descriptionKey }),
|
|
579
|
+
access,
|
|
580
|
+
visible,
|
|
581
|
+
enabled,
|
|
582
|
+
required,
|
|
583
|
+
writable,
|
|
584
|
+
fillable: visible && enabled && writable && !systemComputed && field.primitive !== 'signature_ref',
|
|
585
|
+
systemComputed,
|
|
586
|
+
value,
|
|
587
|
+
computation: computationOf(context, field, deliverable),
|
|
588
|
+
missingRequired: declared.array === undefined
|
|
589
|
+
? requiredStatus(declared.requirement, presence, context.snapshot.access.mayFill({ fieldId: field.fieldId }))
|
|
590
|
+
: foldedRequired(rows ?? [], memberAddressed, memberRequirement(context, declared)),
|
|
591
|
+
...(requiredSeverity === undefined ? {} : { requiredSeverity }),
|
|
592
|
+
...(declared.requirement.messageKey === undefined
|
|
593
|
+
? {}
|
|
594
|
+
: { requiredMessageKey: declared.requirement.messageKey }),
|
|
595
|
+
...(declared.requirement.params === undefined
|
|
596
|
+
? {}
|
|
597
|
+
: { requiredParams: declared.requirement.params }),
|
|
598
|
+
...(field.options === undefined ? {} : { options: field.options }),
|
|
599
|
+
...(field.optionSource === undefined ? {} : { optionSource: field.optionSource }),
|
|
600
|
+
...(unavailableOptions === undefined ? {} : { unavailableOptions }),
|
|
601
|
+
messages: messagesOf(context, field.fieldId),
|
|
602
|
+
...(invalidValue === undefined ? {} : { invalidValue }),
|
|
603
|
+
...(refusal === undefined ? {} : { refusal }),
|
|
604
|
+
...(members.length === 0 ? {} : { members }),
|
|
605
|
+
...(addressing === undefined
|
|
606
|
+
? {}
|
|
607
|
+
: {
|
|
608
|
+
addressableRows: addressing.rows.map((row) => row.rowKey),
|
|
609
|
+
rowAddressing: addressing.rowAddressing,
|
|
610
|
+
}),
|
|
611
|
+
...(cardinality === undefined ? {} : { cardinality }),
|
|
612
|
+
...(media === undefined ? {} : { media }),
|
|
613
|
+
...(decimalScale === undefined ? {} : { decimalScale }),
|
|
614
|
+
...(rowCount === undefined ? {} : { rowCount }),
|
|
615
|
+
...(rows === undefined ? {} : { rows }),
|
|
616
|
+
};
|
|
617
|
+
}
|
|
618
|
+
/**
|
|
619
|
+
* The declared and actual row count of one array, `MODEL-2.1.22`.
|
|
620
|
+
*
|
|
621
|
+
* The expected value is the `rowsFrom` expression's evaluation from the snapshot; the actual is
|
|
622
|
+
* the delivered array's length (an absent array is zero). A count the device cannot read, or a
|
|
623
|
+
* length it may not state, is `undetermined`. A negative or over-ceiling value is `refused` and
|
|
624
|
+
* names the reason, so a host never paints a negative count as an empty list.
|
|
625
|
+
*/
|
|
626
|
+
function rowCountOf(field, context, value, computed, wire, raw) {
|
|
627
|
+
const source = field.rowsFromSource ?? '';
|
|
628
|
+
const expected = context.snapshot.rowCounts.get(field.fieldId);
|
|
629
|
+
const actual = arrayCountOf(value, computed, wire, raw);
|
|
630
|
+
if (expected === undefined || expected.kind === 'undetermined') {
|
|
631
|
+
return { kind: 'undetermined', source };
|
|
632
|
+
}
|
|
633
|
+
if (expected.kind === 'refused') {
|
|
634
|
+
return {
|
|
635
|
+
kind: 'refused',
|
|
636
|
+
reason: expected.reason,
|
|
637
|
+
expected: expected.value,
|
|
638
|
+
actual: actual ?? 0,
|
|
639
|
+
source,
|
|
640
|
+
...(expected.reason === 'ceiling' ? { ceiling: ROW_COUNT_CEILING } : {}),
|
|
641
|
+
};
|
|
642
|
+
}
|
|
643
|
+
if (actual === undefined)
|
|
644
|
+
return { kind: 'undetermined', source };
|
|
645
|
+
if (expected.expected === actual) {
|
|
646
|
+
return { kind: 'within', expected: expected.expected, actual, source };
|
|
647
|
+
}
|
|
648
|
+
return {
|
|
649
|
+
kind: 'mismatch',
|
|
650
|
+
expected: expected.expected,
|
|
651
|
+
actual,
|
|
652
|
+
source,
|
|
653
|
+
...(expected.expected > ROW_COUNT_CEILING ? { ceiling: ROW_COUNT_CEILING } : {}),
|
|
654
|
+
};
|
|
655
|
+
}
|
|
656
|
+
/** The raw value the record holds at one field's value path. */
|
|
657
|
+
function rawAt(values, path) {
|
|
658
|
+
let current = values;
|
|
659
|
+
for (const segment of path) {
|
|
660
|
+
if (!isRecord(current))
|
|
661
|
+
return undefined;
|
|
662
|
+
if (!Object.hasOwn(current, segment))
|
|
663
|
+
return undefined;
|
|
664
|
+
current = current[segment];
|
|
665
|
+
}
|
|
666
|
+
return current;
|
|
667
|
+
}
|
|
668
|
+
/**
|
|
669
|
+
* The value at one field's path, read against the field's declaration.
|
|
670
|
+
*
|
|
671
|
+
* Validation is the same boundary parse a value read performs, so the derived value and the
|
|
672
|
+
* evaluated value agree. A value the declaration refuses returns the refusal, never `absent`: the
|
|
673
|
+
* caller states it as a decided failure instead of reporting the value as missing.
|
|
674
|
+
*/
|
|
675
|
+
function readValueAt(values, path, field) {
|
|
676
|
+
const raw = rawAt(values, path);
|
|
677
|
+
if (raw === undefined)
|
|
678
|
+
return { kind: 'absent' };
|
|
679
|
+
try {
|
|
680
|
+
return {
|
|
681
|
+
kind: 'value',
|
|
682
|
+
value: toWireValue(raw, `$.values.${path.join('.')}`, wireDeclarationOf(field)),
|
|
683
|
+
};
|
|
684
|
+
}
|
|
685
|
+
catch (error) {
|
|
686
|
+
if (!(error instanceof AxiomError))
|
|
687
|
+
throw error;
|
|
688
|
+
return { kind: 'refused', error };
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
/**
|
|
692
|
+
* The refusal a displayed field states about a value its declaration refuses, when it states one.
|
|
693
|
+
*
|
|
694
|
+
* Two conditions decide it. The value must be *the field's own*: a writer that decided the value
|
|
695
|
+
* owns it, and a value the device may not read (`masked`, `hidden`, `redacted`) must not have its
|
|
696
|
+
* refusal — or the reader's cause — disclosed. And it must actually be a refusal of a present
|
|
697
|
+
* value: `presence` is `undetermined` exactly then, because `presenceOfDeclared` cannot call a
|
|
698
|
+
* value the declaration rejects either present or absent. The result is a block-severity
|
|
699
|
+
* `ENGINE_ERROR` at the reader's path, which readiness folds into an `invalidOption` blocker.
|
|
700
|
+
*/
|
|
701
|
+
function refusalOf(read, context, presence, access, fieldId, owned, rowKey) {
|
|
702
|
+
if (read?.kind !== 'refused')
|
|
703
|
+
return undefined;
|
|
704
|
+
// A writer owns its target's value, so the submitted value's refusal says nothing about it.
|
|
705
|
+
if (owned)
|
|
706
|
+
return undefined;
|
|
707
|
+
if (presence !== 'undetermined')
|
|
708
|
+
return undefined;
|
|
709
|
+
if (context.redacted.has(fieldId))
|
|
710
|
+
return undefined;
|
|
711
|
+
if (access !== 'read_write' && access !== 'read_only')
|
|
712
|
+
return undefined;
|
|
713
|
+
const diagnostic = diagnosticOfEngineError(read.error, {
|
|
714
|
+
operation: 'value',
|
|
715
|
+
...(rowKey === undefined ? {} : { rowKey }),
|
|
716
|
+
});
|
|
717
|
+
return { ...diagnostic, fieldId, path: read.error.path, detail: read.error.detail };
|
|
718
|
+
}
|
|
719
|
+
/** Presence is metadata: a withheld value is still present when the record holds one. */
|
|
720
|
+
function presenceOf(raw, redacted, fieldId) {
|
|
721
|
+
if (redacted.has(fieldId))
|
|
722
|
+
return 'redacted';
|
|
723
|
+
if (raw === undefined)
|
|
724
|
+
return 'absent';
|
|
725
|
+
return raw === null ? 'null' : 'present';
|
|
726
|
+
}
|
|
727
|
+
/**
|
|
728
|
+
* Presence for a field's own value, where the declaration decides whether the record holds
|
|
729
|
+
* one.
|
|
730
|
+
*
|
|
731
|
+
* A value the record holds but its declaration refuses is a question `empty()` answers
|
|
732
|
+
* `UNKNOWN` — the reader reports `ENGINE_ERROR` rather than calling the path populated — so
|
|
733
|
+
* presence is undetermined there. Counting it as present would report a required field as
|
|
734
|
+
* satisfied on a value nothing can read, and readiness would submit it.
|
|
735
|
+
*/
|
|
736
|
+
function presenceOfDeclared(raw, redacted, fieldId, wire) {
|
|
737
|
+
const presence = presenceOf(raw, redacted, fieldId);
|
|
738
|
+
return presence === 'present' && wire === undefined ? 'undetermined' : presence;
|
|
739
|
+
}
|
|
740
|
+
/**
|
|
741
|
+
* Presence for one field, honouring which value the field actually has.
|
|
742
|
+
*
|
|
743
|
+
* A writer owns its target's value, and the reader answers the writer's value rather than the
|
|
744
|
+
* submitted one, so a submitted value the declaration refuses says nothing about a field a
|
|
745
|
+
* writer decided. Every other field's value is the record's, where the declaration decides
|
|
746
|
+
* whether a value is there at all.
|
|
747
|
+
*/
|
|
748
|
+
function presenceOfField(context, raw, field, wire, computed, rowKey) {
|
|
749
|
+
// A host may hold one row of a member rather than the whole declaration, so the question is asked
|
|
750
|
+
// per reference: the row it names states `redacted` and its siblings answer for themselves
|
|
751
|
+
// (`[ACCESS-3.1.2]`).
|
|
752
|
+
if (rowKey !== undefined &&
|
|
753
|
+
context.snapshot.access.isRedacted({ fieldId: field.fieldId, rowKey })) {
|
|
754
|
+
return 'redacted';
|
|
755
|
+
}
|
|
756
|
+
const metadata = presenceOf(raw, context.redacted, field.fieldId);
|
|
757
|
+
if (metadata === 'redacted')
|
|
758
|
+
return metadata;
|
|
759
|
+
if (computed !== undefined) {
|
|
760
|
+
if (computed.kind === 'undetermined')
|
|
761
|
+
return 'undetermined';
|
|
762
|
+
return computed.value === null ? 'null' : 'present';
|
|
763
|
+
}
|
|
764
|
+
return presenceOfDeclared(raw, context.redacted, field.fieldId, wire);
|
|
765
|
+
}
|
|
766
|
+
/**
|
|
767
|
+
* The reason one array row's element cannot be stated, or `undefined` when it can.
|
|
768
|
+
*
|
|
769
|
+
* The element is one value carrying every member the row holds, so a member this device may not
|
|
770
|
+
* receive withholds the element with it and names its own reason. The members beside it answer for
|
|
771
|
+
* themselves through their own row entries, and the container's own answer decides whether the
|
|
772
|
+
* rows are shown at all.
|
|
773
|
+
*/
|
|
774
|
+
function rowElementWithheld(context, field, rowKey) {
|
|
775
|
+
const visit = (members) => {
|
|
776
|
+
for (const member of members) {
|
|
777
|
+
const answer = context.snapshot.access.delivery({ fieldId: member.fieldId, rowKey });
|
|
778
|
+
if (answer.reason === 'redacted' || answer.reason === 'masked')
|
|
779
|
+
return answer.reason;
|
|
780
|
+
if (answer.reason === 'hidden' || answer.reason === 'write_only')
|
|
781
|
+
return answer.reason;
|
|
782
|
+
const nested = visit(member.fields ?? []);
|
|
783
|
+
if (nested !== undefined)
|
|
784
|
+
return nested;
|
|
785
|
+
}
|
|
786
|
+
return undefined;
|
|
787
|
+
};
|
|
788
|
+
return visit(field.fields ?? []);
|
|
789
|
+
}
|
|
790
|
+
/** Whether one member's complete value may be stated for this row, descendants included. */
|
|
791
|
+
function rowMemberDelivers(context, declared, array, rowKey) {
|
|
792
|
+
// A direct scalar member answers for its own cell. A record or nested array is one payload,
|
|
793
|
+
// so every member of that payload, siblings included, decides whether any leaf may be stated.
|
|
794
|
+
const rootId = declared.rowPath[0];
|
|
795
|
+
const payload = declared.rowScoped
|
|
796
|
+
? declared.field
|
|
797
|
+
: (array.fields?.find((member) => member.fieldId === rootId) ?? declared.field);
|
|
798
|
+
return (rowElementWithheld(context, payload, rowKey) === undefined &&
|
|
799
|
+
context.snapshot.access.enclosingDelivers({ fieldId: declared.field.fieldId, rowKey }));
|
|
800
|
+
}
|
|
801
|
+
/**
|
|
802
|
+
* The access to classify a value against. A field's own withholding state names the reason the
|
|
803
|
+
* value is withheld; a field this device may not receive because a container above it is
|
|
804
|
+
* undeliverable is hidden, whatever its own state says.
|
|
805
|
+
*/
|
|
806
|
+
function classifyAccess(access, deliverable) {
|
|
807
|
+
if (access === 'masked' || access === 'hidden' || access === 'write_only')
|
|
808
|
+
return access;
|
|
809
|
+
return deliverable ? access : 'hidden';
|
|
810
|
+
}
|
|
811
|
+
/** Whether every declared `enabled` rule for one field passes. */
|
|
812
|
+
function enabledByRules(context, fieldId) {
|
|
813
|
+
for (const rule of context.rules.byField.get(fieldId) ?? []) {
|
|
814
|
+
if (rule.kind !== 'enabled')
|
|
815
|
+
continue;
|
|
816
|
+
if (statusOf(context, rule) !== 'PASS')
|
|
817
|
+
return false;
|
|
818
|
+
}
|
|
819
|
+
return true;
|
|
820
|
+
}
|
|
821
|
+
/** The requirement one field's non-item rules state, including an undecided condition. */
|
|
822
|
+
function requirementByRules(context, fieldId) {
|
|
823
|
+
let required = false;
|
|
824
|
+
let undetermined = false;
|
|
825
|
+
let severity;
|
|
826
|
+
let messageKey;
|
|
827
|
+
let params;
|
|
828
|
+
for (const rule of context.rules.byField.get(fieldId) ?? []) {
|
|
829
|
+
if (rule.kind !== 'required')
|
|
830
|
+
continue;
|
|
831
|
+
const result = resultOf(context, rule);
|
|
832
|
+
if (result.status === 'PASS') {
|
|
833
|
+
required = true;
|
|
834
|
+
severity = strongestSeverity(severity, result.severity);
|
|
835
|
+
// A required rule's message is the sentence the host uses instead of writing one. Take
|
|
836
|
+
// the first declared sentence among the rules that made the field required.
|
|
837
|
+
if (messageKey === undefined && result.messageKey !== undefined) {
|
|
838
|
+
messageKey = result.messageKey;
|
|
839
|
+
params = result.params;
|
|
840
|
+
}
|
|
841
|
+
continue;
|
|
842
|
+
}
|
|
843
|
+
// Only a block-severity condition can leave a requirement open for admission; a `warn`/`info`
|
|
844
|
+
// condition that did not decide opted out of refusing the record.
|
|
845
|
+
if (result.severity !== 'block')
|
|
846
|
+
continue;
|
|
847
|
+
// A check this device could never decide holds nobody to it, and a deferred condition is the
|
|
848
|
+
// server's to enforce: neither accuses the respondent of a gap (`RULES-2.1.5`).
|
|
849
|
+
if (context.rules.undecided.dispositionOf(rule.ruleId, result) === 'undetermined')
|
|
850
|
+
undetermined = true;
|
|
851
|
+
}
|
|
852
|
+
return {
|
|
853
|
+
required,
|
|
854
|
+
undetermined,
|
|
855
|
+
...(severity === undefined ? {} : { severity }),
|
|
856
|
+
...(messageKey === undefined ? {} : { messageKey }),
|
|
857
|
+
...(params === undefined ? {} : { params }),
|
|
858
|
+
};
|
|
859
|
+
}
|
|
860
|
+
/**
|
|
861
|
+
* The declared entry-count state of one array, `MODEL-2.1.17`.
|
|
862
|
+
*
|
|
863
|
+
* The count is the number of entries the record holds, independent of row addressing: an array
|
|
864
|
+
* whose identity is withheld still has a length, and stating it here would disclose the length
|
|
865
|
+
* of a value this device may not read. So the one withheld case answers `undetermined`, while
|
|
866
|
+
* an absent array answers a decided zero — that is the fact the old `len(...) > 0` rule could
|
|
867
|
+
* not state, because `len(absent)` is itself undecided.
|
|
868
|
+
*/
|
|
869
|
+
function cardinalityOf(field, value, computed, wire, raw) {
|
|
870
|
+
const minItems = field.minItems;
|
|
871
|
+
const maxItems = field.maxItems;
|
|
872
|
+
if (minItems === undefined && maxItems === undefined)
|
|
873
|
+
return undefined;
|
|
874
|
+
const count = arrayCountOf(value, computed, wire, raw);
|
|
875
|
+
if (count === undefined) {
|
|
876
|
+
return {
|
|
877
|
+
kind: 'undetermined',
|
|
878
|
+
...(minItems === undefined ? {} : { minItems }),
|
|
879
|
+
...(maxItems === undefined ? {} : { maxItems }),
|
|
880
|
+
};
|
|
881
|
+
}
|
|
882
|
+
if (minItems !== undefined && count < minItems)
|
|
883
|
+
return { kind: 'belowMin', count, minItems };
|
|
884
|
+
if (maxItems !== undefined && count > maxItems)
|
|
885
|
+
return { kind: 'aboveMax', count, maxItems };
|
|
886
|
+
return {
|
|
887
|
+
kind: 'within',
|
|
888
|
+
count,
|
|
889
|
+
...(minItems === undefined ? {} : { minItems }),
|
|
890
|
+
...(maxItems === undefined ? {} : { maxItems }),
|
|
891
|
+
};
|
|
892
|
+
}
|
|
893
|
+
/** How many entries the delivered array holds, or `undefined` when the device cannot count. */
|
|
894
|
+
function arrayCountOf(value, computed, wire, raw) {
|
|
895
|
+
if (computed !== undefined) {
|
|
896
|
+
if (computed.kind === 'undetermined')
|
|
897
|
+
return undefined;
|
|
898
|
+
return listLength(computed.value);
|
|
899
|
+
}
|
|
900
|
+
// A value this device may not read has no length it may state.
|
|
901
|
+
if (value.kind === 'withheld')
|
|
902
|
+
return undefined;
|
|
903
|
+
// An absent array is zero entries; a record that holds a malformed array is not a count.
|
|
904
|
+
if (value.kind === 'absent')
|
|
905
|
+
return raw === undefined ? 0 : undefined;
|
|
906
|
+
if (wire === undefined)
|
|
907
|
+
return undefined;
|
|
908
|
+
return listLength(wire);
|
|
909
|
+
}
|
|
910
|
+
/**
|
|
911
|
+
* The declared `accept` and byte constraints of one capture field, `MODEL-2.1.20`.
|
|
912
|
+
*
|
|
913
|
+
* A single `media_ref` and each element of a `media_ref[]` are checked alike, against the
|
|
914
|
+
* `mime` and `byteSize` the wire already validated. A recorded value the declaration refuses,
|
|
915
|
+
* or one the access answer withholds, is `undetermined` and states neither member; an absent
|
|
916
|
+
* field or the authored `null` is no capture and satisfies every constraint.
|
|
917
|
+
*/
|
|
918
|
+
function mediaConstraintsOf(field, value, computed, wire, raw) {
|
|
919
|
+
const { accept, minBytes, maxBytes } = field;
|
|
920
|
+
if (accept === undefined && minBytes === undefined && maxBytes === undefined)
|
|
921
|
+
return undefined;
|
|
922
|
+
const isArray = field.primitive === 'array';
|
|
923
|
+
let subject;
|
|
924
|
+
if (computed !== undefined) {
|
|
925
|
+
if (computed.kind === 'undetermined')
|
|
926
|
+
return { kind: 'undetermined' };
|
|
927
|
+
subject = computed.value;
|
|
928
|
+
}
|
|
929
|
+
else {
|
|
930
|
+
if (value.kind === 'withheld')
|
|
931
|
+
return { kind: 'undetermined' };
|
|
932
|
+
subject = wire;
|
|
933
|
+
if (value.kind === 'absent' && raw === undefined)
|
|
934
|
+
return { kind: 'within' };
|
|
935
|
+
if (subject === undefined)
|
|
936
|
+
return { kind: 'undetermined' };
|
|
937
|
+
}
|
|
938
|
+
if (subject === null)
|
|
939
|
+
return { kind: 'within' };
|
|
940
|
+
const elements = isArray ? (isWireArray(subject) ? subject : undefined) : [subject];
|
|
941
|
+
if (elements === undefined)
|
|
942
|
+
return { kind: 'undetermined' };
|
|
943
|
+
const violations = [];
|
|
944
|
+
elements.forEach((element, index) => {
|
|
945
|
+
if (element === null)
|
|
946
|
+
return;
|
|
947
|
+
if (!isRecord(element))
|
|
948
|
+
return;
|
|
949
|
+
const mime = element['mime'];
|
|
950
|
+
const byteSize = element['byteSize'];
|
|
951
|
+
if (typeof mime !== 'string' ||
|
|
952
|
+
typeof byteSize !== 'number' ||
|
|
953
|
+
!Number.isSafeInteger(byteSize) ||
|
|
954
|
+
byteSize < 0) {
|
|
955
|
+
return;
|
|
956
|
+
}
|
|
957
|
+
const at = isArray ? { index } : {};
|
|
958
|
+
if (accept !== undefined && !mediaAcceptMatches(accept, mime)) {
|
|
959
|
+
violations.push({ kind: 'accept', mime, limit: accept, ...at });
|
|
960
|
+
}
|
|
961
|
+
if (minBytes !== undefined && byteSize < minBytes) {
|
|
962
|
+
violations.push({ kind: 'minBytes', byteSize, limit: minBytes, ...at });
|
|
963
|
+
}
|
|
964
|
+
if (maxBytes !== undefined && byteSize > maxBytes) {
|
|
965
|
+
violations.push({ kind: 'maxBytes', byteSize, limit: maxBytes, ...at });
|
|
966
|
+
}
|
|
967
|
+
});
|
|
968
|
+
// A non-record element cannot be a `media_ref` the wire admitted, so the value is unreadable
|
|
969
|
+
// rather than compliant: `return` above skipped it and only a shape check would notice.
|
|
970
|
+
if (!isArray && !isRecord(subject))
|
|
971
|
+
return { kind: 'undetermined' };
|
|
972
|
+
if (isArray && !elements.every((element) => element === null || isRecord(element))) {
|
|
973
|
+
return { kind: 'undetermined' };
|
|
974
|
+
}
|
|
975
|
+
return violations.length === 0 ? { kind: 'within' } : { kind: 'violated', violations };
|
|
976
|
+
}
|
|
977
|
+
/** The entry count of a wire list, where `null` is the authored empty list. */
|
|
978
|
+
function listLength(value) {
|
|
979
|
+
if (value === null)
|
|
980
|
+
return 0;
|
|
981
|
+
return isWireArray(value) ? value.length : undefined;
|
|
982
|
+
}
|
|
983
|
+
/**
|
|
984
|
+
* The declared fractional-digit bound of one `decimal` value, `MODEL-2.1.27`.
|
|
985
|
+
*
|
|
986
|
+
* The scale is read from the value's canonical decimal text, the same text every other decimal
|
|
987
|
+
* reader accepts. An absent value and the authored `null` are no value to judge, so they are
|
|
988
|
+
* `within`; a value the device may not read and a computation that has not decided are
|
|
989
|
+
* `undetermined` and never block. A string that is not canonical decimal text is unreadable
|
|
990
|
+
* rather than compliant: the wire reader refused it before it could become a value.
|
|
991
|
+
*/
|
|
992
|
+
function decimalScaleOf(field, value, computed, wire, raw) {
|
|
993
|
+
const maxScale = field.maxScale;
|
|
994
|
+
if (maxScale === undefined)
|
|
995
|
+
return undefined;
|
|
996
|
+
let subject;
|
|
997
|
+
if (computed !== undefined) {
|
|
998
|
+
if (computed.kind === 'undetermined')
|
|
999
|
+
return { kind: 'undetermined', maxScale };
|
|
1000
|
+
if (computed.value === null)
|
|
1001
|
+
return { kind: 'within', maxScale };
|
|
1002
|
+
subject = typeof computed.value === 'string' ? computed.value : undefined;
|
|
1003
|
+
}
|
|
1004
|
+
else {
|
|
1005
|
+
if (value.kind === 'withheld')
|
|
1006
|
+
return { kind: 'undetermined', maxScale };
|
|
1007
|
+
if (value.kind === 'absent' && (raw === undefined || raw === null)) {
|
|
1008
|
+
return { kind: 'within', maxScale };
|
|
1009
|
+
}
|
|
1010
|
+
// The authored `null` is no value to judge; presence is `required`'s question.
|
|
1011
|
+
if (wire === null)
|
|
1012
|
+
return { kind: 'within', maxScale };
|
|
1013
|
+
subject = typeof wire === 'string' ? wire : undefined;
|
|
1014
|
+
}
|
|
1015
|
+
if (subject === undefined)
|
|
1016
|
+
return { kind: 'undetermined', maxScale };
|
|
1017
|
+
const decimal = tryDecimalString(subject);
|
|
1018
|
+
if (decimal === undefined)
|
|
1019
|
+
return { kind: 'undetermined', maxScale };
|
|
1020
|
+
const scale = fractionalDigitCount(decimal);
|
|
1021
|
+
return scale <= maxScale
|
|
1022
|
+
? { kind: 'within', maxScale, scale }
|
|
1023
|
+
: {
|
|
1024
|
+
kind: 'aboveMax',
|
|
1025
|
+
maxScale,
|
|
1026
|
+
scale,
|
|
1027
|
+
value: decimal,
|
|
1028
|
+
...(field.maxScaleMessageKey === undefined ? {} : { messageKey: field.maxScaleMessageKey }),
|
|
1029
|
+
};
|
|
1030
|
+
}
|
|
1031
|
+
/**
|
|
1032
|
+
* The `empty()` four-state answer for one required field (`missing`, `satisfied`, `undetermined`,
|
|
1033
|
+
* `deferred`), `RULES-2.1.5`.
|
|
1034
|
+
*
|
|
1035
|
+
* Only a gap the respondent may close is a blocker. A binding the access answer does not let a
|
|
1036
|
+
* user write is filled by the tier that holds it, so an absent or `null` value there is the same
|
|
1037
|
+
* handoff a redaction is (`ACCESS-3.1.2`): a `read_only` control with no value is not an
|
|
1038
|
+
* unfixable gap, and a `masked` or `hidden` one is not the respondent's question at all.
|
|
1039
|
+
*/
|
|
1040
|
+
function requiredStatus(requirement, presence, fillable) {
|
|
1041
|
+
// Failing optional does not make an unreadable condition a satisfied requirement.
|
|
1042
|
+
if (requirement.undetermined)
|
|
1043
|
+
return 'undetermined';
|
|
1044
|
+
if (!requirement.required)
|
|
1045
|
+
return 'satisfied';
|
|
1046
|
+
switch (presence) {
|
|
1047
|
+
case 'absent':
|
|
1048
|
+
case 'null':
|
|
1049
|
+
return fillable ? 'missing' : 'deferred';
|
|
1050
|
+
case 'redacted':
|
|
1051
|
+
// Redaction is the server's handoff, not a question for the respondent. `empty()` on the
|
|
1052
|
+
// same path already answers `DEFERRED` (`ACCESS-3.1.2`, `EXPR-9.1.8`).
|
|
1053
|
+
return 'deferred';
|
|
1054
|
+
case 'undetermined':
|
|
1055
|
+
return 'undetermined';
|
|
1056
|
+
case 'present':
|
|
1057
|
+
case 'unreadable':
|
|
1058
|
+
// Presence is metadata: a stored `write_only` value the device may not read was still
|
|
1059
|
+
// recorded, so the requirement is satisfied without reading it.
|
|
1060
|
+
return 'satisfied';
|
|
1061
|
+
}
|
|
1062
|
+
}
|
|
1063
|
+
/**
|
|
1064
|
+
* An item member's requirement, folded up from its rows.
|
|
1065
|
+
*
|
|
1066
|
+
* A member of an array holds one value per row and none of its own, so asking `empty()` at a
|
|
1067
|
+
* field-level path would answer `missing` for every record. The rows answer instead: a row
|
|
1068
|
+
* missing the member makes the field `missing`, a row that cannot decide makes it
|
|
1069
|
+
* `undetermined`, and zero rows satisfy it vacuously.
|
|
1070
|
+
*
|
|
1071
|
+
* Zero rows only satisfy a requirement when the engine actually addressed the rows: an array
|
|
1072
|
+
* whose identity is withheld or does not reconcile has no rows to answer, so a requirement that
|
|
1073
|
+
* reaches it was never decided and is `undetermined`, never `satisfied`.
|
|
1074
|
+
*/
|
|
1075
|
+
function foldedRequired(rows, addressed, requirement) {
|
|
1076
|
+
if (rows.some((row) => row.missingRequired === 'missing'))
|
|
1077
|
+
return 'missing';
|
|
1078
|
+
if (rows.some((row) => row.missingRequired === 'undetermined'))
|
|
1079
|
+
return 'undetermined';
|
|
1080
|
+
// A row the server redacted is a handoff; one row's missing value still outranks it above.
|
|
1081
|
+
if (rows.some((row) => row.missingRequired === 'deferred'))
|
|
1082
|
+
return 'deferred';
|
|
1083
|
+
return !addressed && requirement ? 'undetermined' : 'satisfied';
|
|
1084
|
+
}
|
|
1085
|
+
/**
|
|
1086
|
+
* Whether a `required` rule names one member of an array, in either scope.
|
|
1087
|
+
*
|
|
1088
|
+
* The rows carry a decided requirement, so with no rows this is what says a question still
|
|
1089
|
+
* exists: a field-scope rule the derivation could not read for lack of a row, or an item-scope
|
|
1090
|
+
* rule the report could not address at all.
|
|
1091
|
+
*/
|
|
1092
|
+
function memberRequirement(context, declared) {
|
|
1093
|
+
if (declared.requirement.required || declared.requirement.undetermined)
|
|
1094
|
+
return true;
|
|
1095
|
+
const array = declared.array;
|
|
1096
|
+
if (array === undefined)
|
|
1097
|
+
return false;
|
|
1098
|
+
return (context.rules.itemByArray.get(array.fieldId) ?? []).some((rule) => rule.kind === 'required' && rule.targetFieldId === declared.field.fieldId);
|
|
1099
|
+
}
|
|
1100
|
+
/** Whether a writer owns one field, so no control may fill it. */
|
|
1101
|
+
function isSystemComputed(context, fieldId, arrayFieldId) {
|
|
1102
|
+
if (context.writers.fields.has(fieldId))
|
|
1103
|
+
return true;
|
|
1104
|
+
if (arrayFieldId === undefined)
|
|
1105
|
+
return false;
|
|
1106
|
+
return context.writers.itemMembers.has(itemWriterKey(arrayFieldId, fieldId));
|
|
1107
|
+
}
|
|
1108
|
+
/** The result of a field-scope writer, when one owns the field. */
|
|
1109
|
+
function writerResultOf(context, field) {
|
|
1110
|
+
for (const rule of context.rules.byField.get(field.fieldId) ?? []) {
|
|
1111
|
+
if (rule.kind === 'compute' || rule.kind === 'defaultCompute')
|
|
1112
|
+
return resultOf(context, rule);
|
|
1113
|
+
}
|
|
1114
|
+
return undefined;
|
|
1115
|
+
}
|
|
1116
|
+
/** The value a field-scope writer produced for a field, honouring delivery. */
|
|
1117
|
+
function computationOf(context, field, deliverable) {
|
|
1118
|
+
const result = writerResultOf(context, field);
|
|
1119
|
+
if (result === undefined)
|
|
1120
|
+
return { kind: 'none' };
|
|
1121
|
+
if (result.status !== 'PASS')
|
|
1122
|
+
return { kind: 'undetermined', status: result.status };
|
|
1123
|
+
// A PASS writer owns the field whether or not the report states its value. The report omits
|
|
1124
|
+
// the value of a target delivery withholds (`[ACCESS-7.1.6]`), and the entry must say the
|
|
1125
|
+
// value is withheld rather than that no rule produced one.
|
|
1126
|
+
return deliverable && result.value !== undefined
|
|
1127
|
+
? { kind: 'value', value: result.value }
|
|
1128
|
+
: { kind: 'withheld' };
|
|
1129
|
+
}
|
|
1130
|
+
/** The validate messages a field-scope rule raised for one field. */
|
|
1131
|
+
function messagesOf(context, fieldId) {
|
|
1132
|
+
const messages = [];
|
|
1133
|
+
for (const rule of context.rules.byField.get(fieldId) ?? []) {
|
|
1134
|
+
if (rule.kind !== 'validate')
|
|
1135
|
+
continue;
|
|
1136
|
+
const result = resultOf(context, rule);
|
|
1137
|
+
pushMessage(messages, result);
|
|
1138
|
+
}
|
|
1139
|
+
return messages;
|
|
1140
|
+
}
|
|
1141
|
+
/** Adds one rule result's message, when it is one a caller shows. */
|
|
1142
|
+
function pushMessage(messages, result) {
|
|
1143
|
+
if (result.status === 'PASS' || result.messageKey === undefined)
|
|
1144
|
+
return;
|
|
1145
|
+
messages.push({
|
|
1146
|
+
ruleId: result.ruleId,
|
|
1147
|
+
severity: result.severity,
|
|
1148
|
+
status: result.status,
|
|
1149
|
+
messageKey: result.messageKey,
|
|
1150
|
+
...(result.params === undefined ? {} : { params: result.params }),
|
|
1151
|
+
});
|
|
1152
|
+
}
|
|
1153
|
+
/**
|
|
1154
|
+
* The held value an option domain refuses, `[DATA-5.1.3]`.
|
|
1155
|
+
*
|
|
1156
|
+
* The declared domain comes from the artifact; a `host` source's domain is the one the host's
|
|
1157
|
+
* loader returned for this binding, so a selection the loader no longer offers is reported
|
|
1158
|
+
* here once and nowhere else. A domain that has not been loaded decides nothing: an unanswered
|
|
1159
|
+
* question is not a refusal. The comparison is `sameWireValue`, so an integer code and its
|
|
1160
|
+
* text spelling stay two options.
|
|
1161
|
+
*
|
|
1162
|
+
* A `field` source is deliberately absent here: its domain is another field's derived state,
|
|
1163
|
+
* which may be declared after this one, so `withFieldSourceEligibility` fills that arm once
|
|
1164
|
+
* every field exists. This function decides only the domains an entry already carries.
|
|
1165
|
+
*/
|
|
1166
|
+
function invalidValueOf(context, field, value, ref) {
|
|
1167
|
+
if (value.kind !== 'value')
|
|
1168
|
+
return undefined;
|
|
1169
|
+
const domain = field.options !== undefined
|
|
1170
|
+
? declaredDomainOf(field)
|
|
1171
|
+
: field.optionSource?.kind === 'host'
|
|
1172
|
+
? context.options.optionDomains?.get(fieldKey(ref))
|
|
1173
|
+
: undefined;
|
|
1174
|
+
if (domain === undefined)
|
|
1175
|
+
return undefined;
|
|
1176
|
+
return ineligibleOptionValue(value.value, domain);
|
|
1177
|
+
}
|
|
1178
|
+
/**
|
|
1179
|
+
* The declared and host-loaded option codes one binding may not offer now, `ENGINE-7.1.7`.
|
|
1180
|
+
*
|
|
1181
|
+
* A declared answer comes from the evaluation that decided it, and a host page's answer is taken
|
|
1182
|
+
* as given: the engine evaluates no declaration for a code it does not know. The two sources are
|
|
1183
|
+
* one list because a control paints one list, and a code is only ever in one of them.
|
|
1184
|
+
*/
|
|
1185
|
+
function unavailableOptionsOf(context, field, ref) {
|
|
1186
|
+
const key = fieldKey(ref);
|
|
1187
|
+
const declared = declaredUnavailableOptions(context.snapshot.optionAvailability.get(key)?.options);
|
|
1188
|
+
const host = field.optionSource?.kind === 'host'
|
|
1189
|
+
? hostUnavailableItems(context.options.optionDomains?.get(key)).flatMap((item) => {
|
|
1190
|
+
const option = hostUnavailableOption(item);
|
|
1191
|
+
return option === undefined ? [] : [option];
|
|
1192
|
+
})
|
|
1193
|
+
: [];
|
|
1194
|
+
const options = [...declared, ...host];
|
|
1195
|
+
return options.length === 0 ? undefined : options;
|
|
1196
|
+
}
|
|
1197
|
+
/**
|
|
1198
|
+
* The declared domain as the wire values the control can hold, `[MODEL-3.1.5]`.
|
|
1199
|
+
*
|
|
1200
|
+
* The mapping from a code to the value the record holds is `optionCodeValue`, shared with the
|
|
1201
|
+
* availability answer that has to name the code a held value belongs to.
|
|
1202
|
+
*/
|
|
1203
|
+
function declaredDomainOf(field) {
|
|
1204
|
+
return (field.options ?? []).map((option) => ({ value: optionCodeValue(field, option.code) }));
|
|
1205
|
+
}
|
|
1206
|
+
/**
|
|
1207
|
+
* Whether the declaration that supplies a natural row's identity may be read by this device.
|
|
1208
|
+
*
|
|
1209
|
+
* A natural row key is a value of the key member, so an access answer that withholds the member
|
|
1210
|
+
* withholds the identity it would spell. A value-mode key *is* the item, and the array's own
|
|
1211
|
+
* delivery answer already decided that question (`declarationOwnDeliverable`), so only a key
|
|
1212
|
+
* member is asked here. The redaction set is consulted first because it collapses a row-scoped
|
|
1213
|
+
* `(fieldId, rowKey)` pair to the field, exactly as the reader does: a withheld member supplies
|
|
1214
|
+
* no key for any row.
|
|
1215
|
+
*/
|
|
1216
|
+
function identityReadable(context, fieldId) {
|
|
1217
|
+
return context.snapshot.access.delivery({ fieldId }).deliverable;
|
|
1218
|
+
}
|
|
1219
|
+
/**
|
|
1220
|
+
* The rows an array addresses, and how their identity is derived.
|
|
1221
|
+
*
|
|
1222
|
+
* Which rows an array has and what names each one is one fact, and the addressing authority
|
|
1223
|
+
* owns it, so the engine's identity and this derivation can never disagree about a row key. An
|
|
1224
|
+
* array that addresses nothing — an unreconciled manifest, an array declared inside another
|
|
1225
|
+
* array — states no row rather than a guessed one.
|
|
1226
|
+
*
|
|
1227
|
+
* Identity is a record value in two of the three modes, and a value the access answer withholds
|
|
1228
|
+
* is one the derivation must not spell ([ACCESS-7.1.6]): the array is therefore not addressable
|
|
1229
|
+
* at all when its own declaration is undeliverable, not only when its key member is. A withheld
|
|
1230
|
+
* container must state no key, length or derived property ([ACCESS-1.3.4]), and a row's key is
|
|
1231
|
+
* all three. An `assigned` identity is the host's manifest rather than a record value, so the
|
|
1232
|
+
* key member question does not arise; the container's own delivery still does.
|
|
1233
|
+
*
|
|
1234
|
+
* A writer that owns the whole array produces the value the report keys rows from, so the rows
|
|
1235
|
+
* are read from that value rather than from the submitted record. An undecided writer states no
|
|
1236
|
+
* mode at all: claiming the declared mode over zero rows would contradict the row keys the
|
|
1237
|
+
* report carries.
|
|
1238
|
+
*/
|
|
1239
|
+
function addressRows(context, field, ancestorsDeliverable) {
|
|
1240
|
+
if (!ancestorsDeliverable || !declarationOwnDeliverable(context, field)) {
|
|
1241
|
+
return UNSUPPORTED_ADDRESSING;
|
|
1242
|
+
}
|
|
1243
|
+
const declaration = declarationOf(context.compiled, field.fieldId);
|
|
1244
|
+
if (declaration === undefined || !declaration.topLevel)
|
|
1245
|
+
return UNSUPPORTED_ADDRESSING;
|
|
1246
|
+
const own = context.snapshot.computed.get(field.fieldId);
|
|
1247
|
+
const addressing = own === undefined
|
|
1248
|
+
? addressingOf(context.compiled, field.fieldId, context.snapshot.input.values, context.options.identity)
|
|
1249
|
+
: computedAddressing(field, own, context.options.identity?.get(field.fieldId));
|
|
1250
|
+
if (addressing.outcome !== 'addressed')
|
|
1251
|
+
return UNSUPPORTED_ADDRESSING;
|
|
1252
|
+
const identityFieldId = addressing.mode === 'natural' ? addressing.identityFieldId : undefined;
|
|
1253
|
+
// A natural key that a writer owns is a key the report already spells from the written value,
|
|
1254
|
+
// while this derivation would read the submitted one: two answers to one question. The array
|
|
1255
|
+
// is left unaddressable rather than restating the submission's key.
|
|
1256
|
+
if (identityFieldId !== undefined &&
|
|
1257
|
+
identitySourceComputed(context, field.fieldId, identityFieldId)) {
|
|
1258
|
+
return UNSUPPORTED_ADDRESSING;
|
|
1259
|
+
}
|
|
1260
|
+
if (identityFieldId !== undefined && !identityReadable(context, identityFieldId)) {
|
|
1261
|
+
return UNSUPPORTED_ADDRESSING;
|
|
1262
|
+
}
|
|
1263
|
+
if (identityFieldId !== undefined &&
|
|
1264
|
+
addressing.rows.some((row) => !context.snapshot.access.delivery({ fieldId: identityFieldId, rowKey: row.rowKey })
|
|
1265
|
+
.deliverable)) {
|
|
1266
|
+
// A key is a value too: one row whose key is withheld makes the row set unaddressable rather
|
|
1267
|
+
// than spelling that key through `addressableRows` or a row entry.
|
|
1268
|
+
return UNSUPPORTED_ADDRESSING;
|
|
1269
|
+
}
|
|
1270
|
+
return { rowAddressing: addressing.mode, rows: addressing.rows };
|
|
1271
|
+
}
|
|
1272
|
+
/**
|
|
1273
|
+
* The list a container's derived rows read their values from.
|
|
1274
|
+
*
|
|
1275
|
+
* A writer's decided value is the list the report keys rows from, so the rows state it; a
|
|
1276
|
+
* submitted list is the wire reader's answer, and none when it refused it.
|
|
1277
|
+
*/
|
|
1278
|
+
function rowValuesOf(computed, submittedWire) {
|
|
1279
|
+
if (computed !== undefined) {
|
|
1280
|
+
return computed.kind === 'decided' ? effectiveListOf(computed.value) : undefined;
|
|
1281
|
+
}
|
|
1282
|
+
return submittedWire !== undefined && isWireArray(submittedWire) ? submittedWire : undefined;
|
|
1283
|
+
}
|
|
1284
|
+
/** The items a writer's decided array value holds; `null` is the authored empty list. */
|
|
1285
|
+
function effectiveListOf(value) {
|
|
1286
|
+
if (value === null)
|
|
1287
|
+
return [];
|
|
1288
|
+
return isWireArray(value) ? value : undefined;
|
|
1289
|
+
}
|
|
1290
|
+
/** The addressing a writer's own entry states for the array it owns. */
|
|
1291
|
+
function computedAddressing(field, entry, manifest) {
|
|
1292
|
+
if (entry.kind === 'undetermined') {
|
|
1293
|
+
return { outcome: 'unsupported', reason: 'undetermined' };
|
|
1294
|
+
}
|
|
1295
|
+
const items = effectiveListOf(entry.value);
|
|
1296
|
+
if (items === undefined)
|
|
1297
|
+
return { outcome: 'unsupported', reason: 'not-a-list' };
|
|
1298
|
+
return addressingOfItems(field, items, manifest);
|
|
1299
|
+
}
|
|
1300
|
+
/** Whether a writer owns the declaration that supplies one array's row identity. */
|
|
1301
|
+
function identitySourceComputed(context, arrayFieldId, identityFieldId) {
|
|
1302
|
+
if (context.writers.fields.has(identityFieldId))
|
|
1303
|
+
return true;
|
|
1304
|
+
return context.writers.itemMembers.has(itemWriterKey(arrayFieldId, identityFieldId));
|
|
1305
|
+
}
|
|
1306
|
+
/** The messages a row-wide validate rule raised, attached to the array field and row. */
|
|
1307
|
+
function arrayRowStates(context, field, rows, deliverable, elementDelivers, items) {
|
|
1308
|
+
const rowWide = (context.rules.itemByArray.get(field.fieldId) ?? []).filter((rule) => rule.kind === 'validate' && rule.targetFieldId === undefined);
|
|
1309
|
+
// A row's value is the element the container's own wire validation accepted, at the same
|
|
1310
|
+
// index: `ValueState` promises a canonical value, and a record holding a member its
|
|
1311
|
+
// declaration refuses has none to deliver. Every row then reports `absent` exactly as the
|
|
1312
|
+
// container does, rather than spelling the refused member to a caller that trusts the type.
|
|
1313
|
+
const checked = items;
|
|
1314
|
+
return rows.map((row, index) => {
|
|
1315
|
+
const messages = [];
|
|
1316
|
+
if (rowWide.length > 0) {
|
|
1317
|
+
// One token for the row, however many row-wide rules ask about it.
|
|
1318
|
+
const token = rowToken(row.rowKey);
|
|
1319
|
+
for (const rule of rowWide) {
|
|
1320
|
+
const result = resultForRowOrRule(context, rule.ruleId, token);
|
|
1321
|
+
if (result !== undefined)
|
|
1322
|
+
pushMessage(messages, result);
|
|
1323
|
+
}
|
|
1324
|
+
}
|
|
1325
|
+
const access = context.snapshot.access.accessFor({
|
|
1326
|
+
fieldId: field.fieldId,
|
|
1327
|
+
rowKey: row.rowKey,
|
|
1328
|
+
});
|
|
1329
|
+
const value = checked?.[index];
|
|
1330
|
+
// A row element carries every member the row holds, so one this device may not receive
|
|
1331
|
+
// withholds the element with it, and states why (`[ACCESS-3.1.2]`). A value-mode array
|
|
1332
|
+
// declares no members: its element *is* the container's own value, so the payload answer
|
|
1333
|
+
// decides it.
|
|
1334
|
+
const named = (field.fields ?? []).length > 0;
|
|
1335
|
+
const withheld = named ? rowElementWithheld(context, field, row.rowKey) : undefined;
|
|
1336
|
+
const classified = withheld === undefined
|
|
1337
|
+
? classifyValue(presenceOf(value, context.redacted, field.fieldId), classifyAccess(access, named ? elementDelivers : deliverable), context.snapshot.access.sessionWriteKeys, value, { fieldId: field.fieldId, rowKey: row.rowKey })
|
|
1338
|
+
: { kind: 'withheld', reason: withheld };
|
|
1339
|
+
// A scalar array's domain belongs to the container selection. Each value row judges its
|
|
1340
|
+
// member against that same domain, exactly as the container's multi-select answer does.
|
|
1341
|
+
const invalidValue = invalidValueOf(context, field, classified, {
|
|
1342
|
+
fieldId: field.fieldId,
|
|
1343
|
+
});
|
|
1344
|
+
return {
|
|
1345
|
+
rowKey: row.rowKey,
|
|
1346
|
+
access,
|
|
1347
|
+
value: classified,
|
|
1348
|
+
...(invalidValue === undefined ? {} : { invalidValue }),
|
|
1349
|
+
computation: { kind: 'none' },
|
|
1350
|
+
required: false,
|
|
1351
|
+
enabled: permitsUserWrite(access) && enabledByRules(context, field.fieldId),
|
|
1352
|
+
fillable: false,
|
|
1353
|
+
missingRequired: 'satisfied',
|
|
1354
|
+
messages,
|
|
1355
|
+
};
|
|
1356
|
+
});
|
|
1357
|
+
}
|
|
1358
|
+
/**
|
|
1359
|
+
* One item member's per-row facts: the value, whether the row's rule leaves it fillable, the
|
|
1360
|
+
* requirement it must satisfy and the cell messages a `validate` rule attached to it.
|
|
1361
|
+
*
|
|
1362
|
+
* A field-scope `required` or `enabled` rule naming the member decides it in every row, so its
|
|
1363
|
+
* answer is conjuncted into the row facts rather than left at a field path no row holds. The
|
|
1364
|
+
* cell is read from the row at the member's own path inside it, so a member of a record the row
|
|
1365
|
+
* carries is not mistaken for a member of the array itself.
|
|
1366
|
+
*/
|
|
1367
|
+
function memberRowStates(context, field, declared, addressing) {
|
|
1368
|
+
const array = declared.array;
|
|
1369
|
+
if (array === undefined)
|
|
1370
|
+
return [];
|
|
1371
|
+
const rules = (context.rules.itemByArray.get(array.fieldId) ?? []).filter((rule) => rule.targetFieldId === field.fieldId);
|
|
1372
|
+
const visible = declared.visible;
|
|
1373
|
+
const systemComputed = isSystemComputed(context, field.fieldId, array.fieldId);
|
|
1374
|
+
return addressing.rows.map((row) => {
|
|
1375
|
+
const rowArrayAccess = context.snapshot.access.accessFor({
|
|
1376
|
+
fieldId: array.fieldId,
|
|
1377
|
+
rowKey: row.rowKey,
|
|
1378
|
+
});
|
|
1379
|
+
const memberRowAccess = context.snapshot.access.accessFor({
|
|
1380
|
+
fieldId: field.fieldId,
|
|
1381
|
+
rowKey: row.rowKey,
|
|
1382
|
+
});
|
|
1383
|
+
const access = meetAccess(memberRowAccess, rowArrayAccess);
|
|
1384
|
+
const raw = rawAt(row.item, declared.rowPath);
|
|
1385
|
+
const read = readValueAt(row.item, declared.rowPath, field);
|
|
1386
|
+
const wire = read.kind === 'value' ? read.value : undefined;
|
|
1387
|
+
const computed = context.snapshot.computed.getRow(field.fieldId, row.rowKey) ??
|
|
1388
|
+
context.snapshot.computed.get(field.fieldId);
|
|
1389
|
+
const presence = presenceOfField(context, raw, field, wire, computed, row.rowKey);
|
|
1390
|
+
// The writer is the sole authority for the cell it owns, exactly as it is for a field-level
|
|
1391
|
+
// target: passing the submitted cell here reported a computed member as the value it
|
|
1392
|
+
// replaced, so the row binding and the patch list disagreed with the writer's own result
|
|
1393
|
+
// (`[ENGINE-3.1.2]`). A default with no overlay entry leaves the stored cell in force.
|
|
1394
|
+
const deliveredWire = computed?.kind === 'decided' ? computed.value : wire;
|
|
1395
|
+
const rowDelivers = !context.snapshot.access.hiddenRow(array.fieldId) &&
|
|
1396
|
+
rowMemberDelivers(context, declared, array, row.rowKey);
|
|
1397
|
+
const rowAccess = classifyAccess(access, rowDelivers);
|
|
1398
|
+
const value = classifyValue(presence, rowAccess, context.snapshot.access.sessionWriteKeys, deliveredWire, { fieldId: field.fieldId, rowKey: row.rowKey });
|
|
1399
|
+
const refusal = refusalOf(read, context, presence, rowAccess, field.fieldId, computed !== undefined, row.rowKey);
|
|
1400
|
+
const invalidValue = invalidValueOf(context, field, value, {
|
|
1401
|
+
fieldId: field.fieldId,
|
|
1402
|
+
rowKey: row.rowKey,
|
|
1403
|
+
});
|
|
1404
|
+
// The capture lives in this row, so the declared `accept` and byte bounds are answered
|
|
1405
|
+
// against the row's own validated value — never against the member's absent field-level
|
|
1406
|
+
// one, which made an authored capture policy compile and silently admit anything.
|
|
1407
|
+
const rowMedia = mediaConstraintsOf(field, value, computed, wire, raw);
|
|
1408
|
+
const rowDecimalScale = decimalScaleOf(field, value, computed, wire, raw);
|
|
1409
|
+
const unavailableOptions = unavailableOptionsOf(context, field, {
|
|
1410
|
+
fieldId: field.fieldId,
|
|
1411
|
+
rowKey: row.rowKey,
|
|
1412
|
+
});
|
|
1413
|
+
// Every per-row rule answer is one map hit, so the row's token is built once and shared by
|
|
1414
|
+
// the requirement, the enablement, the messages and the writer.
|
|
1415
|
+
const facts = rules.length === 0
|
|
1416
|
+
? NO_ROW_RULE_FACTS
|
|
1417
|
+
: rowRuleFacts(context, rules, rowToken(row.rowKey), rowDelivers);
|
|
1418
|
+
const required = declared.requirement.required || facts.requirement.required;
|
|
1419
|
+
const requiredSeverity = strongestSeverity(declared.requirement.required ? declared.requirement.severity : undefined, facts.requirement.required ? facts.requirement.severity : undefined);
|
|
1420
|
+
// A row can be required by a field-scope rule that reaches every row and by an item rule;
|
|
1421
|
+
// the sentence is the first of those that declared one, so neither source is silently
|
|
1422
|
+
// preferred over the other.
|
|
1423
|
+
const requirementMessage = facts.requirement.required && facts.requirement.messageKey !== undefined
|
|
1424
|
+
? facts.requirement
|
|
1425
|
+
: declared.requirement.required && declared.requirement.messageKey !== undefined
|
|
1426
|
+
? declared.requirement
|
|
1427
|
+
: undefined;
|
|
1428
|
+
const enabled = permitsUserWrite(access) && declared.enabledByRules && facts.enabled;
|
|
1429
|
+
return {
|
|
1430
|
+
rowKey: row.rowKey,
|
|
1431
|
+
access,
|
|
1432
|
+
value,
|
|
1433
|
+
...(invalidValue === undefined ? {} : { invalidValue }),
|
|
1434
|
+
...(refusal === undefined ? {} : { refusal }),
|
|
1435
|
+
...(rowMedia === undefined ? {} : { media: rowMedia }),
|
|
1436
|
+
...(rowDecimalScale === undefined ? {} : { decimalScale: rowDecimalScale }),
|
|
1437
|
+
...(unavailableOptions === undefined ? {} : { unavailableOptions }),
|
|
1438
|
+
computation: facts.computation,
|
|
1439
|
+
required,
|
|
1440
|
+
enabled,
|
|
1441
|
+
fillable: visible &&
|
|
1442
|
+
enabled &&
|
|
1443
|
+
permitsUserWrite(access) &&
|
|
1444
|
+
!systemComputed &&
|
|
1445
|
+
field.primitive !== 'signature_ref',
|
|
1446
|
+
missingRequired: requiredStatus({
|
|
1447
|
+
required,
|
|
1448
|
+
undetermined: declared.requirement.undetermined || facts.requirement.undetermined,
|
|
1449
|
+
}, presence, context.snapshot.access.mayFill({ fieldId: field.fieldId, rowKey: row.rowKey })),
|
|
1450
|
+
...(requiredSeverity === undefined ? {} : { requiredSeverity }),
|
|
1451
|
+
...(requirementMessage?.messageKey === undefined
|
|
1452
|
+
? {}
|
|
1453
|
+
: { requiredMessageKey: requirementMessage.messageKey }),
|
|
1454
|
+
...(requirementMessage?.params === undefined
|
|
1455
|
+
? {}
|
|
1456
|
+
: { requiredParams: requirementMessage.params }),
|
|
1457
|
+
messages: facts.messages,
|
|
1458
|
+
};
|
|
1459
|
+
});
|
|
1460
|
+
}
|
|
1461
|
+
/** The per-row facts a member states when no item rule names it. */
|
|
1462
|
+
const NO_ROW_RULE_FACTS = {
|
|
1463
|
+
requirement: { required: false, undetermined: false },
|
|
1464
|
+
enabled: true,
|
|
1465
|
+
computation: { kind: 'none' },
|
|
1466
|
+
messages: [],
|
|
1467
|
+
};
|
|
1468
|
+
/**
|
|
1469
|
+
* Every per-row fact of one member in one pass over the rules that name it.
|
|
1470
|
+
*
|
|
1471
|
+
* The four questions a row answers — is it required, is it enabled, what did its writer produce,
|
|
1472
|
+
* which cells failed — read the same rules, so they are answered together. Asking each question
|
|
1473
|
+
* in its own loop walked the member's rules four times per row, which is four times the rows
|
|
1474
|
+
* times the rules on every commit that re-derives the array.
|
|
1475
|
+
*/
|
|
1476
|
+
function rowRuleFacts(context, rules, token, deliverable) {
|
|
1477
|
+
let required = false;
|
|
1478
|
+
let undetermined = false;
|
|
1479
|
+
let severity;
|
|
1480
|
+
let requiredMessageKey;
|
|
1481
|
+
let requiredParams;
|
|
1482
|
+
let enabled = true;
|
|
1483
|
+
const messages = [];
|
|
1484
|
+
let computation;
|
|
1485
|
+
for (const rule of rules) {
|
|
1486
|
+
switch (rule.kind) {
|
|
1487
|
+
case 'required': {
|
|
1488
|
+
const result = resultForRow(context, rule.ruleId, token);
|
|
1489
|
+
if (result === undefined) {
|
|
1490
|
+
// A required rule that could not address its rows reports once for the whole rule.
|
|
1491
|
+
// Silently satisfying the row would let an unreadable condition look satisfied, so the
|
|
1492
|
+
// row-less answer decides: it leaves the row open only when the device could decide it
|
|
1493
|
+
// and did not (`RULES-2.1.1`). Only a block-severity requirement can do that.
|
|
1494
|
+
if ((rule.severity ?? 'block') !== 'block')
|
|
1495
|
+
break;
|
|
1496
|
+
const rowless = context.rules.rowlessResults.get(rule.ruleId);
|
|
1497
|
+
if (rowless === undefined ||
|
|
1498
|
+
context.rules.undecided.dispositionOf(rule.ruleId, rowless) === 'undetermined') {
|
|
1499
|
+
undetermined = true;
|
|
1500
|
+
}
|
|
1501
|
+
break;
|
|
1502
|
+
}
|
|
1503
|
+
if (result.status === 'PASS') {
|
|
1504
|
+
required = true;
|
|
1505
|
+
severity = strongestSeverity(severity, result.severity);
|
|
1506
|
+
// One sentence per requirement: the first declaring rule that held, in declaration
|
|
1507
|
+
// order, is the row's message.
|
|
1508
|
+
if (requiredMessageKey === undefined && result.messageKey !== undefined) {
|
|
1509
|
+
requiredMessageKey = result.messageKey;
|
|
1510
|
+
requiredParams = result.params;
|
|
1511
|
+
}
|
|
1512
|
+
break;
|
|
1513
|
+
}
|
|
1514
|
+
// A block-severity condition the device could never decide, or one the server settles,
|
|
1515
|
+
// holds this row to nothing: only a gap the row can be asked to close stays open
|
|
1516
|
+
// (`RULES-2.1.1`, `RULES-2.1.5`).
|
|
1517
|
+
if (result.severity === 'block' &&
|
|
1518
|
+
context.rules.undecided.dispositionOf(rule.ruleId, result) === 'undetermined') {
|
|
1519
|
+
undetermined = true;
|
|
1520
|
+
}
|
|
1521
|
+
break;
|
|
1522
|
+
}
|
|
1523
|
+
case 'enabled': {
|
|
1524
|
+
const result = resultForRow(context, rule.ruleId, token);
|
|
1525
|
+
if (result === undefined || result.status !== 'PASS')
|
|
1526
|
+
enabled = false;
|
|
1527
|
+
break;
|
|
1528
|
+
}
|
|
1529
|
+
case 'validate': {
|
|
1530
|
+
const result = resultForRowOrRule(context, rule.ruleId, token);
|
|
1531
|
+
if (result !== undefined)
|
|
1532
|
+
pushMessage(messages, result);
|
|
1533
|
+
break;
|
|
1534
|
+
}
|
|
1535
|
+
case 'compute':
|
|
1536
|
+
case 'defaultCompute': {
|
|
1537
|
+
// The first writer with an answer owns the cell; a later one would be a second writer
|
|
1538
|
+
// the compiler refuses.
|
|
1539
|
+
if (computation !== undefined)
|
|
1540
|
+
break;
|
|
1541
|
+
const result = resultForRowOrRule(context, rule.ruleId, token);
|
|
1542
|
+
if (result === undefined)
|
|
1543
|
+
break;
|
|
1544
|
+
if (result.status !== 'PASS') {
|
|
1545
|
+
computation = { kind: 'undetermined', status: result.status };
|
|
1546
|
+
break;
|
|
1547
|
+
}
|
|
1548
|
+
// As at field scope: a PASS writer owns the row whether or not the report states the
|
|
1549
|
+
// value, so a value delivery withholds is `withheld`, not `none`.
|
|
1550
|
+
computation =
|
|
1551
|
+
deliverable && result.value !== undefined
|
|
1552
|
+
? { kind: 'value', value: result.value }
|
|
1553
|
+
: { kind: 'withheld' };
|
|
1554
|
+
break;
|
|
1555
|
+
}
|
|
1556
|
+
case 'visible':
|
|
1557
|
+
case 'gate':
|
|
1558
|
+
case 'screen':
|
|
1559
|
+
// Not per-row member facts: visibility, a gate verdict and a screen decision each
|
|
1560
|
+
// answer for the declaration or the whole record, never for one row's member.
|
|
1561
|
+
break;
|
|
1562
|
+
default:
|
|
1563
|
+
// A new kind must state how it answers a row, not silently contribute nothing.
|
|
1564
|
+
return assertNever(rule);
|
|
1565
|
+
}
|
|
1566
|
+
}
|
|
1567
|
+
return {
|
|
1568
|
+
requirement: {
|
|
1569
|
+
required,
|
|
1570
|
+
undetermined,
|
|
1571
|
+
...(severity === undefined ? {} : { severity }),
|
|
1572
|
+
...(requiredMessageKey === undefined ? {} : { messageKey: requiredMessageKey }),
|
|
1573
|
+
...(requiredParams === undefined ? {} : { params: requiredParams }),
|
|
1574
|
+
},
|
|
1575
|
+
enabled,
|
|
1576
|
+
computation: computation ?? { kind: 'none' },
|
|
1577
|
+
messages,
|
|
1578
|
+
};
|
|
1579
|
+
}
|
|
1580
|
+
/**
|
|
1581
|
+
* One row's lookup token, built once and shared by every rule result the row answers.
|
|
1582
|
+
*
|
|
1583
|
+
* The token is the map key every row result is indexed by. Building it inside each lookup made
|
|
1584
|
+
* one pass build a token per (rule, row) pair; a row derived against K rules built K tokens for
|
|
1585
|
+
* the same string.
|
|
1586
|
+
*/
|
|
1587
|
+
function rowToken(rowKey) {
|
|
1588
|
+
noteReportRowTokenBuild();
|
|
1589
|
+
return rowKeyToken(rowKey);
|
|
1590
|
+
}
|
|
1591
|
+
/** The result one item rule produced for one row, matched by its wire-typed key. */
|
|
1592
|
+
function resultForRow(context, ruleId, token) {
|
|
1593
|
+
return context.rules.rowResults.get(ruleId)?.get(token);
|
|
1594
|
+
}
|
|
1595
|
+
/**
|
|
1596
|
+
* One rule's answer for one row: the row's own result, or the whole-rule result a rule states
|
|
1597
|
+
* when it could not address its rows at all (a server-tier deferral, an unreadable array).
|
|
1598
|
+
* Attaching the row-less answer to every addressed row keeps an offline handoff visible per
|
|
1599
|
+
* row instead of making the rows look decided.
|
|
1600
|
+
*/
|
|
1601
|
+
function resultForRowOrRule(context, ruleId, token) {
|
|
1602
|
+
return resultForRow(context, ruleId, token) ?? context.rules.rowlessResults.get(ruleId);
|
|
1603
|
+
}
|
|
1604
|
+
//# sourceMappingURL=field-state.js.map
|