@azx-pbc/axiom-compiler 0.0.0-stage → 0.0.6
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 +415 -2
- package/dist/article.d.ts +12 -0
- package/dist/article.d.ts.map +1 -0
- package/dist/article.js +16 -0
- package/dist/article.js.map +1 -0
- package/dist/cli/args.d.ts +101 -0
- package/dist/cli/args.d.ts.map +1 -0
- package/dist/cli/args.js +158 -0
- package/dist/cli/args.js.map +1 -0
- package/dist/cli/check.d.ts +2 -0
- package/dist/cli/check.d.ts.map +1 -0
- package/dist/cli/check.js +33 -0
- package/dist/cli/check.js.map +1 -0
- package/dist/cli/compile.d.ts +2 -0
- package/dist/cli/compile.d.ts.map +1 -0
- package/dist/cli/compile.js +43 -0
- package/dist/cli/compile.js.map +1 -0
- package/dist/cli/count.d.ts +15 -0
- package/dist/cli/count.d.ts.map +1 -0
- package/dist/cli/count.js +21 -0
- package/dist/cli/count.js.map +1 -0
- package/dist/cli/dataset.d.ts +28 -0
- package/dist/cli/dataset.d.ts.map +1 -0
- package/dist/cli/dataset.js +115 -0
- package/dist/cli/dataset.js.map +1 -0
- package/dist/cli/diff.d.ts +2 -0
- package/dist/cli/diff.d.ts.map +1 -0
- package/dist/cli/diff.js +297 -0
- package/dist/cli/diff.js.map +1 -0
- package/dist/cli/explain.d.ts +2 -0
- package/dist/cli/explain.d.ts.map +1 -0
- package/dist/cli/explain.js +95 -0
- package/dist/cli/explain.js.map +1 -0
- package/dist/cli/fields.d.ts +11 -0
- package/dist/cli/fields.d.ts.map +1 -0
- package/dist/cli/fields.js +13 -0
- package/dist/cli/fields.js.map +1 -0
- package/dist/cli/main.d.ts +2 -0
- package/dist/cli/main.d.ts.map +1 -0
- package/dist/cli/main.js +40 -0
- package/dist/cli/main.js.map +1 -0
- package/dist/cli/read.d.ts +56 -0
- package/dist/cli/read.d.ts.map +1 -0
- package/dist/cli/read.js +179 -0
- package/dist/cli/read.js.map +1 -0
- package/dist/cli/render.d.ts +58 -0
- package/dist/cli/render.d.ts.map +1 -0
- package/dist/cli/render.js +422 -0
- package/dist/cli/render.js.map +1 -0
- package/dist/cli/schema.d.ts +28 -0
- package/dist/cli/schema.d.ts.map +1 -0
- package/dist/cli/schema.js +46 -0
- package/dist/cli/schema.js.map +1 -0
- package/dist/cli/suite-report.d.ts +18 -0
- package/dist/cli/suite-report.d.ts.map +1 -0
- package/dist/cli/suite-report.js +58 -0
- package/dist/cli/suite-report.js.map +1 -0
- package/dist/cli/suites.d.ts +25 -0
- package/dist/cli/suites.d.ts.map +1 -0
- package/dist/cli/suites.js +67 -0
- package/dist/cli/suites.js.map +1 -0
- package/dist/cli/terminal.d.ts +45 -0
- package/dist/cli/terminal.d.ts.map +1 -0
- package/dist/cli/terminal.js +119 -0
- package/dist/cli/terminal.js.map +1 -0
- package/dist/cli/test.d.ts +12 -0
- package/dist/cli/test.d.ts.map +1 -0
- package/dist/cli/test.js +199 -0
- package/dist/cli/test.js.map +1 -0
- package/dist/cli/usage.d.ts +15 -0
- package/dist/cli/usage.d.ts.map +1 -0
- package/dist/cli/usage.js +95 -0
- package/dist/cli/usage.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +51 -0
- package/dist/cli.js.map +1 -0
- package/dist/compile/artifact-members.d.ts +57 -0
- package/dist/compile/artifact-members.d.ts.map +1 -0
- package/dist/compile/artifact-members.js +130 -0
- package/dist/compile/artifact-members.js.map +1 -0
- package/dist/compile/artifact.d.ts +20 -0
- package/dist/compile/artifact.d.ts.map +1 -0
- package/dist/compile/artifact.js +87 -0
- package/dist/compile/artifact.js.map +1 -0
- package/dist/compile/compilation.d.ts +46 -0
- package/dist/compile/compilation.d.ts.map +1 -0
- package/dist/compile/compilation.js +4 -0
- package/dist/compile/compilation.js.map +1 -0
- package/dist/compile/computed.d.ts +22 -0
- package/dist/compile/computed.d.ts.map +1 -0
- package/dist/compile/computed.js +245 -0
- package/dist/compile/computed.js.map +1 -0
- package/dist/compile/condition-warnings.d.ts +12 -0
- package/dist/compile/condition-warnings.d.ts.map +1 -0
- package/dist/compile/condition-warnings.js +26 -0
- package/dist/compile/condition-warnings.js.map +1 -0
- package/dist/compile/conditions.d.ts +18 -0
- package/dist/compile/conditions.d.ts.map +1 -0
- package/dist/compile/conditions.js +22 -0
- package/dist/compile/conditions.js.map +1 -0
- package/dist/compile/cross-checks.d.ts +67 -0
- package/dist/compile/cross-checks.d.ts.map +1 -0
- package/dist/compile/cross-checks.js +238 -0
- package/dist/compile/cross-checks.js.map +1 -0
- package/dist/compile/datasets.d.ts +52 -0
- package/dist/compile/datasets.d.ts.map +1 -0
- package/dist/compile/datasets.js +183 -0
- package/dist/compile/datasets.js.map +1 -0
- package/dist/compile/dead-weight.d.ts +26 -0
- package/dist/compile/dead-weight.d.ts.map +1 -0
- package/dist/compile/dead-weight.js +244 -0
- package/dist/compile/dead-weight.js.map +1 -0
- package/dist/compile/declaration-rules.d.ts +54 -0
- package/dist/compile/declaration-rules.d.ts.map +1 -0
- package/dist/compile/declaration-rules.js +510 -0
- package/dist/compile/declaration-rules.js.map +1 -0
- package/dist/compile/declarations.d.ts +44 -0
- package/dist/compile/declarations.d.ts.map +1 -0
- package/dist/compile/declarations.js +160 -0
- package/dist/compile/declarations.js.map +1 -0
- package/dist/compile/document.d.ts +4 -0
- package/dist/compile/document.d.ts.map +1 -0
- package/dist/compile/document.js +13 -0
- package/dist/compile/document.js.map +1 -0
- package/dist/compile/expression.d.ts +38 -0
- package/dist/compile/expression.d.ts.map +1 -0
- package/dist/compile/expression.js +288 -0
- package/dist/compile/expression.js.map +1 -0
- package/dist/compile/hashes.d.ts +26 -0
- package/dist/compile/hashes.d.ts.map +1 -0
- package/dist/compile/hashes.js +96 -0
- package/dist/compile/hashes.js.map +1 -0
- package/dist/compile/item-targets.d.ts +12 -0
- package/dist/compile/item-targets.d.ts.map +1 -0
- package/dist/compile/item-targets.js +287 -0
- package/dist/compile/item-targets.js.map +1 -0
- package/dist/compile/messages.d.ts +8 -0
- package/dist/compile/messages.d.ts.map +1 -0
- package/dist/compile/messages.js +62 -0
- package/dist/compile/messages.js.map +1 -0
- package/dist/compile/option-availability.d.ts +51 -0
- package/dist/compile/option-availability.d.ts.map +1 -0
- package/dist/compile/option-availability.js +171 -0
- package/dist/compile/option-availability.js.map +1 -0
- package/dist/compile/option-codes.d.ts +27 -0
- package/dist/compile/option-codes.d.ts.map +1 -0
- package/dist/compile/option-codes.js +212 -0
- package/dist/compile/option-codes.js.map +1 -0
- package/dist/compile/references.d.ts +14 -0
- package/dist/compile/references.d.ts.map +1 -0
- package/dist/compile/references.js +126 -0
- package/dist/compile/references.js.map +1 -0
- package/dist/compile/rows-from.d.ts +27 -0
- package/dist/compile/rows-from.d.ts.map +1 -0
- package/dist/compile/rows-from.js +164 -0
- package/dist/compile/rows-from.js.map +1 -0
- package/dist/compile/rules.d.ts +58 -0
- package/dist/compile/rules.d.ts.map +1 -0
- package/dist/compile/rules.js +327 -0
- package/dist/compile/rules.js.map +1 -0
- package/dist/compile/suggestions.d.ts +52 -0
- package/dist/compile/suggestions.d.ts.map +1 -0
- package/dist/compile/suggestions.js +633 -0
- package/dist/compile/suggestions.js.map +1 -0
- package/dist/compile/targets.d.ts +22 -0
- package/dist/compile/targets.d.ts.map +1 -0
- package/dist/compile/targets.js +125 -0
- package/dist/compile/targets.js.map +1 -0
- package/dist/compile/types.d.ts +84 -0
- package/dist/compile/types.d.ts.map +1 -0
- package/dist/compile/types.js +2 -0
- package/dist/compile/types.js.map +1 -0
- package/dist/compile/warning.d.ts +45 -0
- package/dist/compile/warning.d.ts.map +1 -0
- package/dist/compile/warning.js +2 -0
- package/dist/compile/warning.js.map +1 -0
- package/dist/compile-yaml.d.ts +23 -0
- package/dist/compile-yaml.d.ts.map +1 -0
- package/dist/compile-yaml.js +30 -0
- package/dist/compile-yaml.js.map +1 -0
- package/dist/compile.d.ts +78 -0
- package/dist/compile.d.ts.map +1 -0
- package/dist/compile.js +372 -0
- package/dist/compile.js.map +1 -0
- package/dist/csv/limits.d.ts +43 -0
- package/dist/csv/limits.d.ts.map +1 -0
- package/dist/csv/limits.js +51 -0
- package/dist/csv/limits.js.map +1 -0
- package/dist/csv/scalar.d.ts +33 -0
- package/dist/csv/scalar.d.ts.map +1 -0
- package/dist/csv/scalar.js +77 -0
- package/dist/csv/scalar.js.map +1 -0
- package/dist/datasets/csv.d.ts +46 -0
- package/dist/datasets/csv.d.ts.map +1 -0
- package/dist/datasets/csv.js +293 -0
- package/dist/datasets/csv.js.map +1 -0
- package/dist/datasets/declaration.d.ts +16 -0
- package/dist/datasets/declaration.d.ts.map +1 -0
- package/dist/datasets/declaration.js +104 -0
- package/dist/datasets/declaration.js.map +1 -0
- package/dist/datasets/diagnostics.d.ts +65 -0
- package/dist/datasets/diagnostics.d.ts.map +1 -0
- package/dist/datasets/diagnostics.js +2 -0
- package/dist/datasets/diagnostics.js.map +1 -0
- package/dist/datasets/diff.d.ts +46 -0
- package/dist/datasets/diff.d.ts.map +1 -0
- package/dist/datasets/diff.js +84 -0
- package/dist/datasets/diff.js.map +1 -0
- package/dist/datasets/document.d.ts +12 -0
- package/dist/datasets/document.d.ts.map +1 -0
- package/dist/datasets/document.js +382 -0
- package/dist/datasets/document.js.map +1 -0
- package/dist/datasets/index.d.ts +43 -0
- package/dist/datasets/index.d.ts.map +1 -0
- package/dist/datasets/index.js +68 -0
- package/dist/datasets/index.js.map +1 -0
- package/dist/datasets/repair.d.ts +26 -0
- package/dist/datasets/repair.d.ts.map +1 -0
- package/dist/datasets/repair.js +60 -0
- package/dist/datasets/repair.js.map +1 -0
- package/dist/document-path.d.ts +62 -0
- package/dist/document-path.d.ts.map +1 -0
- package/dist/document-path.js +200 -0
- package/dist/document-path.js.map +1 -0
- package/dist/expr/boundary.d.ts +8 -0
- package/dist/expr/boundary.d.ts.map +1 -0
- package/dist/expr/boundary.js +243 -0
- package/dist/expr/boundary.js.map +1 -0
- package/dist/expr/compile-expr.d.ts +35 -0
- package/dist/expr/compile-expr.d.ts.map +1 -0
- package/dist/expr/compile-expr.js +66 -0
- package/dist/expr/compile-expr.js.map +1 -0
- package/dist/expr/deprecation.d.ts +23 -0
- package/dist/expr/deprecation.d.ts.map +1 -0
- package/dist/expr/deprecation.js +28 -0
- package/dist/expr/deprecation.js.map +1 -0
- package/dist/expr/diagnostics.d.ts +31 -0
- package/dist/expr/diagnostics.d.ts.map +1 -0
- package/dist/expr/diagnostics.js +34 -0
- package/dist/expr/diagnostics.js.map +1 -0
- package/dist/expr/lexer.d.ts +49 -0
- package/dist/expr/lexer.d.ts.map +1 -0
- package/dist/expr/lexer.js +277 -0
- package/dist/expr/lexer.js.map +1 -0
- package/dist/expr/lint-warnings.d.ts +11 -0
- package/dist/expr/lint-warnings.d.ts.map +1 -0
- package/dist/expr/lint-warnings.js +20 -0
- package/dist/expr/lint-warnings.js.map +1 -0
- package/dist/expr/lint.d.ts +41 -0
- package/dist/expr/lint.d.ts.map +1 -0
- package/dist/expr/lint.js +1034 -0
- package/dist/expr/lint.js.map +1 -0
- package/dist/expr/parse/aggregates.d.ts +13 -0
- package/dist/expr/parse/aggregates.d.ts.map +1 -0
- package/dist/expr/parse/aggregates.js +48 -0
- package/dist/expr/parse/aggregates.js.map +1 -0
- package/dist/expr/parse/budget.d.ts +11 -0
- package/dist/expr/parse/budget.d.ts.map +1 -0
- package/dist/expr/parse/budget.js +57 -0
- package/dist/expr/parse/budget.js.map +1 -0
- package/dist/expr/parse/grammar.d.ts +9 -0
- package/dist/expr/parse/grammar.d.ts.map +1 -0
- package/dist/expr/parse/grammar.js +699 -0
- package/dist/expr/parse/grammar.js.map +1 -0
- package/dist/expr/parse/literals.d.ts +20 -0
- package/dist/expr/parse/literals.d.ts.map +1 -0
- package/dist/expr/parse/literals.js +132 -0
- package/dist/expr/parse/literals.js.map +1 -0
- package/dist/expr/parse/stream.d.ts +60 -0
- package/dist/expr/parse/stream.d.ts.map +1 -0
- package/dist/expr/parse/stream.js +151 -0
- package/dist/expr/parse/stream.js.map +1 -0
- package/dist/expr/parser.d.ts +45 -0
- package/dist/expr/parser.d.ts.map +1 -0
- package/dist/expr/parser.js +110 -0
- package/dist/expr/parser.js.map +1 -0
- package/dist/expr/print/spell.d.ts +78 -0
- package/dist/expr/print/spell.d.ts.map +1 -0
- package/dist/expr/print/spell.js +592 -0
- package/dist/expr/print/spell.js.map +1 -0
- package/dist/expr/print.d.ts +20 -0
- package/dist/expr/print.d.ts.map +1 -0
- package/dist/expr/print.js +102 -0
- package/dist/expr/print.js.map +1 -0
- package/dist/expr/suggest.d.ts +26 -0
- package/dist/expr/suggest.d.ts.map +1 -0
- package/dist/expr/suggest.js +77 -0
- package/dist/expr/suggest.js.map +1 -0
- package/dist/expr/typecheck/aggregates.d.ts +8 -0
- package/dist/expr/typecheck/aggregates.d.ts.map +1 -0
- package/dist/expr/typecheck/aggregates.js +334 -0
- package/dist/expr/typecheck/aggregates.js.map +1 -0
- package/dist/expr/typecheck/arithmetic.d.ts +6 -0
- package/dist/expr/typecheck/arithmetic.d.ts.map +1 -0
- package/dist/expr/typecheck/arithmetic.js +258 -0
- package/dist/expr/typecheck/arithmetic.js.map +1 -0
- package/dist/expr/typecheck/arity.d.ts +38 -0
- package/dist/expr/typecheck/arity.d.ts.map +1 -0
- package/dist/expr/typecheck/arity.js +173 -0
- package/dist/expr/typecheck/arity.js.map +1 -0
- package/dist/expr/typecheck/calls.d.ts +6 -0
- package/dist/expr/typecheck/calls.d.ts.map +1 -0
- package/dist/expr/typecheck/calls.js +137 -0
- package/dist/expr/typecheck/calls.js.map +1 -0
- package/dist/expr/typecheck/comparison.d.ts +13 -0
- package/dist/expr/typecheck/comparison.d.ts.map +1 -0
- package/dist/expr/typecheck/comparison.js +200 -0
- package/dist/expr/typecheck/comparison.js.map +1 -0
- package/dist/expr/typecheck/compound.d.ts +24 -0
- package/dist/expr/typecheck/compound.d.ts.map +1 -0
- package/dist/expr/typecheck/compound.js +175 -0
- package/dist/expr/typecheck/compound.js.map +1 -0
- package/dist/expr/typecheck/context.d.ts +44 -0
- package/dist/expr/typecheck/context.d.ts.map +1 -0
- package/dist/expr/typecheck/context.js +2 -0
- package/dist/expr/typecheck/context.js.map +1 -0
- package/dist/expr/typecheck/datasets.d.ts +17 -0
- package/dist/expr/typecheck/datasets.d.ts.map +1 -0
- package/dist/expr/typecheck/datasets.js +136 -0
- package/dist/expr/typecheck/datasets.js.map +1 -0
- package/dist/expr/typecheck/digest.d.ts +7 -0
- package/dist/expr/typecheck/digest.d.ts.map +1 -0
- package/dist/expr/typecheck/digest.js +44 -0
- package/dist/expr/typecheck/digest.js.map +1 -0
- package/dist/expr/typecheck/fold.d.ts +41 -0
- package/dist/expr/typecheck/fold.d.ts.map +1 -0
- package/dist/expr/typecheck/fold.js +71 -0
- package/dist/expr/typecheck/fold.js.map +1 -0
- package/dist/expr/typecheck/gate-folds.d.ts +22 -0
- package/dist/expr/typecheck/gate-folds.d.ts.map +1 -0
- package/dist/expr/typecheck/gate-folds.js +40 -0
- package/dist/expr/typecheck/gate-folds.js.map +1 -0
- package/dist/expr/typecheck/guards.d.ts +6 -0
- package/dist/expr/typecheck/guards.d.ts.map +1 -0
- package/dist/expr/typecheck/guards.js +38 -0
- package/dist/expr/typecheck/guards.js.map +1 -0
- package/dist/expr/typecheck/member.d.ts +17 -0
- package/dist/expr/typecheck/member.d.ts.map +1 -0
- package/dist/expr/typecheck/member.js +46 -0
- package/dist/expr/typecheck/member.js.map +1 -0
- package/dist/expr/typecheck/money.d.ts +8 -0
- package/dist/expr/typecheck/money.d.ts.map +1 -0
- package/dist/expr/typecheck/money.js +49 -0
- package/dist/expr/typecheck/money.js.map +1 -0
- package/dist/expr/typecheck/numeric.d.ts +8 -0
- package/dist/expr/typecheck/numeric.d.ts.map +1 -0
- package/dist/expr/typecheck/numeric.js +84 -0
- package/dist/expr/typecheck/numeric.js.map +1 -0
- package/dist/expr/typecheck/operands.d.ts +27 -0
- package/dist/expr/typecheck/operands.d.ts.map +1 -0
- package/dist/expr/typecheck/operands.js +106 -0
- package/dist/expr/typecheck/operands.js.map +1 -0
- package/dist/expr/typecheck/paths.d.ts +21 -0
- package/dist/expr/typecheck/paths.d.ts.map +1 -0
- package/dist/expr/typecheck/paths.js +321 -0
- package/dist/expr/typecheck/paths.js.map +1 -0
- package/dist/expr/typecheck/records.d.ts +24 -0
- package/dist/expr/typecheck/records.d.ts.map +1 -0
- package/dist/expr/typecheck/records.js +53 -0
- package/dist/expr/typecheck/records.js.map +1 -0
- package/dist/expr/typecheck/sequences.d.ts +15 -0
- package/dist/expr/typecheck/sequences.d.ts.map +1 -0
- package/dist/expr/typecheck/sequences.js +55 -0
- package/dist/expr/typecheck/sequences.js.map +1 -0
- package/dist/expr/typecheck/strings.d.ts +8 -0
- package/dist/expr/typecheck/strings.d.ts.map +1 -0
- package/dist/expr/typecheck/strings.js +188 -0
- package/dist/expr/typecheck/strings.js.map +1 -0
- package/dist/expr/typecheck/temporal.d.ts +7 -0
- package/dist/expr/typecheck/temporal.d.ts.map +1 -0
- package/dist/expr/typecheck/temporal.js +80 -0
- package/dist/expr/typecheck/temporal.js.map +1 -0
- package/dist/expr/typecheck/types.d.ts +163 -0
- package/dist/expr/typecheck/types.d.ts.map +1 -0
- package/dist/expr/typecheck/types.js +404 -0
- package/dist/expr/typecheck/types.js.map +1 -0
- package/dist/expr/typecheck.d.ts +75 -0
- package/dist/expr/typecheck.d.ts.map +1 -0
- package/dist/expr/typecheck.js +242 -0
- package/dist/expr/typecheck.js.map +1 -0
- package/dist/expr/undecided.d.ts +13 -0
- package/dist/expr/undecided.d.ts.map +1 -0
- package/dist/expr/undecided.js +58 -0
- package/dist/expr/undecided.js.map +1 -0
- package/dist/expr/values/code-points.d.ts +13 -0
- package/dist/expr/values/code-points.d.ts.map +1 -0
- package/dist/expr/values/code-points.js +25 -0
- package/dist/expr/values/code-points.js.map +1 -0
- package/dist/expr/values/inline.d.ts +77 -0
- package/dist/expr/values/inline.d.ts.map +1 -0
- package/dist/expr/values/inline.js +404 -0
- package/dist/expr/values/inline.js.map +1 -0
- package/dist/expr/values/interval.d.ts +19 -0
- package/dist/expr/values/interval.d.ts.map +1 -0
- package/dist/expr/values/interval.js +1180 -0
- package/dist/expr/values/interval.js.map +1 -0
- package/dist/index.d.ts +163 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +128 -0
- package/dist/index.js.map +1 -0
- package/dist/ingest/document.d.ts +58 -0
- package/dist/ingest/document.d.ts.map +1 -0
- package/dist/ingest/document.js +83 -0
- package/dist/ingest/document.js.map +1 -0
- package/dist/ingest/yaml-document.d.ts +15 -0
- package/dist/ingest/yaml-document.d.ts.map +1 -0
- package/dist/ingest/yaml-document.js +42 -0
- package/dist/ingest/yaml-document.js.map +1 -0
- package/dist/ingest/yaml.d.ts +51 -0
- package/dist/ingest/yaml.d.ts.map +1 -0
- package/dist/ingest/yaml.js +340 -0
- package/dist/ingest/yaml.js.map +1 -0
- package/dist/layout/compile.d.ts +6 -0
- package/dist/layout/compile.d.ts.map +1 -0
- package/dist/layout/compile.js +224 -0
- package/dist/layout/compile.js.map +1 -0
- package/dist/layout/context.d.ts +12 -0
- package/dist/layout/context.d.ts.map +1 -0
- package/dist/layout/context.js +26 -0
- package/dist/layout/context.js.map +1 -0
- package/dist/layout/grammar.d.ts +34 -0
- package/dist/layout/grammar.d.ts.map +1 -0
- package/dist/layout/grammar.js +171 -0
- package/dist/layout/grammar.js.map +1 -0
- package/dist/layout/read.d.ts +54 -0
- package/dist/layout/read.d.ts.map +1 -0
- package/dist/layout/read.js +101 -0
- package/dist/layout/read.js.map +1 -0
- package/dist/layout/shape.d.ts +34 -0
- package/dist/layout/shape.d.ts.map +1 -0
- package/dist/layout/shape.js +149 -0
- package/dist/layout/shape.js.map +1 -0
- package/dist/messages/compile.d.ts +47 -0
- package/dist/messages/compile.d.ts.map +1 -0
- package/dist/messages/compile.js +202 -0
- package/dist/messages/compile.js.map +1 -0
- package/dist/messages/locale.d.ts +18 -0
- package/dist/messages/locale.d.ts.map +1 -0
- package/dist/messages/locale.js +33 -0
- package/dist/messages/locale.js.map +1 -0
- package/dist/messages/slots.d.ts +54 -0
- package/dist/messages/slots.d.ts.map +1 -0
- package/dist/messages/slots.js +137 -0
- package/dist/messages/slots.js.map +1 -0
- package/dist/overlay/compile-overlay.d.ts +29 -0
- package/dist/overlay/compile-overlay.d.ts.map +1 -0
- package/dist/overlay/compile-overlay.js +120 -0
- package/dist/overlay/compile-overlay.js.map +1 -0
- package/dist/overlay/compose.d.ts +26 -0
- package/dist/overlay/compose.d.ts.map +1 -0
- package/dist/overlay/compose.js +674 -0
- package/dist/overlay/compose.js.map +1 -0
- package/dist/overlay/types.d.ts +41 -0
- package/dist/overlay/types.d.ts.map +1 -0
- package/dist/overlay/types.js +2 -0
- package/dist/overlay/types.js.map +1 -0
- package/dist/publish/classify.d.ts +50 -0
- package/dist/publish/classify.d.ts.map +1 -0
- package/dist/publish/classify.js +85 -0
- package/dist/publish/classify.js.map +1 -0
- package/dist/publish/environment.d.ts +15 -0
- package/dist/publish/environment.d.ts.map +1 -0
- package/dist/publish/environment.js +2 -0
- package/dist/publish/environment.js.map +1 -0
- package/dist/publish/migrations.d.ts +108 -0
- package/dist/publish/migrations.d.ts.map +1 -0
- package/dist/publish/migrations.js +166 -0
- package/dist/publish/migrations.js.map +1 -0
- package/dist/publish/observation.d.ts +29 -0
- package/dist/publish/observation.d.ts.map +1 -0
- package/dist/publish/observation.js +43 -0
- package/dist/publish/observation.js.map +1 -0
- package/dist/publish/readiness.d.ts +197 -0
- package/dist/publish/readiness.d.ts.map +1 -0
- package/dist/publish/readiness.js +239 -0
- package/dist/publish/readiness.js.map +1 -0
- package/dist/publish/vectors.d.ts +50 -0
- package/dist/publish/vectors.d.ts.map +1 -0
- package/dist/publish/vectors.js +306 -0
- package/dist/publish/vectors.js.map +1 -0
- package/dist/publish/verify.d.ts +146 -0
- package/dist/publish/verify.d.ts.map +1 -0
- package/dist/publish/verify.js +548 -0
- package/dist/publish/verify.js.map +1 -0
- package/dist/scenarios/branch.d.ts +36 -0
- package/dist/scenarios/branch.d.ts.map +1 -0
- package/dist/scenarios/branch.js +30 -0
- package/dist/scenarios/branch.js.map +1 -0
- package/dist/scenarios/capture.d.ts +89 -0
- package/dist/scenarios/capture.d.ts.map +1 -0
- package/dist/scenarios/capture.js +443 -0
- package/dist/scenarios/capture.js.map +1 -0
- package/dist/scenarios/classifier.d.ts +20 -0
- package/dist/scenarios/classifier.d.ts.map +1 -0
- package/dist/scenarios/classifier.js +88 -0
- package/dist/scenarios/classifier.js.map +1 -0
- package/dist/scenarios/credit.d.ts +33 -0
- package/dist/scenarios/credit.d.ts.map +1 -0
- package/dist/scenarios/credit.js +330 -0
- package/dist/scenarios/credit.js.map +1 -0
- package/dist/scenarios/csv.d.ts +34 -0
- package/dist/scenarios/csv.d.ts.map +1 -0
- package/dist/scenarios/csv.js +1047 -0
- package/dist/scenarios/csv.js.map +1 -0
- package/dist/scenarios/data-identity.d.ts +39 -0
- package/dist/scenarios/data-identity.d.ts.map +1 -0
- package/dist/scenarios/data-identity.js +28 -0
- package/dist/scenarios/data-identity.js.map +1 -0
- package/dist/scenarios/document.d.ts +148 -0
- package/dist/scenarios/document.d.ts.map +1 -0
- package/dist/scenarios/document.js +513 -0
- package/dist/scenarios/document.js.map +1 -0
- package/dist/scenarios/environment.d.ts +64 -0
- package/dist/scenarios/environment.d.ts.map +1 -0
- package/dist/scenarios/environment.js +106 -0
- package/dist/scenarios/environment.js.map +1 -0
- package/dist/scenarios/evidence.d.ts +128 -0
- package/dist/scenarios/evidence.d.ts.map +1 -0
- package/dist/scenarios/evidence.js +179 -0
- package/dist/scenarios/evidence.js.map +1 -0
- package/dist/scenarios/expectations.d.ts +63 -0
- package/dist/scenarios/expectations.d.ts.map +1 -0
- package/dist/scenarios/expectations.js +490 -0
- package/dist/scenarios/expectations.js.map +1 -0
- package/dist/scenarios/references.d.ts +15 -0
- package/dist/scenarios/references.d.ts.map +1 -0
- package/dist/scenarios/references.js +239 -0
- package/dist/scenarios/references.js.map +1 -0
- package/dist/scenarios/report.d.ts +216 -0
- package/dist/scenarios/report.d.ts.map +1 -0
- package/dist/scenarios/report.js +54 -0
- package/dist/scenarios/report.js.map +1 -0
- package/dist/scenarios/runner.d.ts +55 -0
- package/dist/scenarios/runner.d.ts.map +1 -0
- package/dist/scenarios/runner.js +205 -0
- package/dist/scenarios/runner.js.map +1 -0
- package/dist/scenarios/vocabulary.d.ts +19 -0
- package/dist/scenarios/vocabulary.d.ts.map +1 -0
- package/dist/scenarios/vocabulary.js +56 -0
- package/dist/scenarios/vocabulary.js.map +1 -0
- package/dist/schema/catalogue.d.ts +54 -0
- package/dist/schema/catalogue.d.ts.map +1 -0
- package/dist/schema/catalogue.js +221 -0
- package/dist/schema/catalogue.js.map +1 -0
- package/dist/schema/check.d.ts +22 -0
- package/dist/schema/check.d.ts.map +1 -0
- package/dist/schema/check.js +30 -0
- package/dist/schema/check.js.map +1 -0
- package/dist/schema/closed.d.ts +19 -0
- package/dist/schema/closed.d.ts.map +1 -0
- package/dist/schema/closed.js +33 -0
- package/dist/schema/closed.js.map +1 -0
- package/dist/schema/collapse.d.ts +27 -0
- package/dist/schema/collapse.d.ts.map +1 -0
- package/dist/schema/collapse.js +143 -0
- package/dist/schema/collapse.js.map +1 -0
- package/dist/schema/controls.d.ts +46 -0
- package/dist/schema/controls.d.ts.map +1 -0
- package/dist/schema/controls.js +75 -0
- package/dist/schema/controls.js.map +1 -0
- package/dist/schema/dataset-declaration.d.ts +11 -0
- package/dist/schema/dataset-declaration.d.ts.map +1 -0
- package/dist/schema/dataset-declaration.js +11 -0
- package/dist/schema/dataset-declaration.js.map +1 -0
- package/dist/schema/declaration-warnings.d.ts +14 -0
- package/dist/schema/declaration-warnings.d.ts.map +1 -0
- package/dist/schema/declaration-warnings.js +77 -0
- package/dist/schema/declaration-warnings.js.map +1 -0
- package/dist/schema/declarations.d.ts +41 -0
- package/dist/schema/declarations.d.ts.map +1 -0
- package/dist/schema/declarations.js +1299 -0
- package/dist/schema/declarations.js.map +1 -0
- package/dist/schema/diagnostic.d.ts +118 -0
- package/dist/schema/diagnostic.d.ts.map +1 -0
- package/dist/schema/diagnostic.js +39 -0
- package/dist/schema/diagnostic.js.map +1 -0
- package/dist/schema/document.d.ts +93 -0
- package/dist/schema/document.d.ts.map +1 -0
- package/dist/schema/document.js +507 -0
- package/dist/schema/document.js.map +1 -0
- package/dist/schema/fields.d.ts +11 -0
- package/dist/schema/fields.d.ts.map +1 -0
- package/dist/schema/fields.js +265 -0
- package/dist/schema/fields.js.map +1 -0
- package/dist/schema/gates.d.ts +4 -0
- package/dist/schema/gates.d.ts.map +1 -0
- package/dist/schema/gates.js +68 -0
- package/dist/schema/gates.js.map +1 -0
- package/dist/schema/located.d.ts +27 -0
- package/dist/schema/located.d.ts.map +1 -0
- package/dist/schema/located.js +56 -0
- package/dist/schema/located.js.map +1 -0
- package/dist/schema/measurement.d.ts +9 -0
- package/dist/schema/measurement.d.ts.map +1 -0
- package/dist/schema/measurement.js +38 -0
- package/dist/schema/measurement.js.map +1 -0
- package/dist/schema/member-wording.d.ts +35 -0
- package/dist/schema/member-wording.d.ts.map +1 -0
- package/dist/schema/member-wording.js +286 -0
- package/dist/schema/member-wording.js.map +1 -0
- package/dist/schema/metaschema.d.ts +20 -0
- package/dist/schema/metaschema.d.ts.map +1 -0
- package/dist/schema/metaschema.js +476 -0
- package/dist/schema/metaschema.js.map +1 -0
- package/dist/schema/pointer.d.ts +31 -0
- package/dist/schema/pointer.d.ts.map +1 -0
- package/dist/schema/pointer.js +73 -0
- package/dist/schema/pointer.js.map +1 -0
- package/dist/schema/primary.d.ts +29 -0
- package/dist/schema/primary.d.ts.map +1 -0
- package/dist/schema/primary.js +48 -0
- package/dist/schema/primary.js.map +1 -0
- package/dist/schema/publish-vector.d.ts +17 -0
- package/dist/schema/publish-vector.d.ts.map +1 -0
- package/dist/schema/publish-vector.js +34 -0
- package/dist/schema/publish-vector.js.map +1 -0
- package/dist/schema/repair.d.ts +34 -0
- package/dist/schema/repair.d.ts.map +1 -0
- package/dist/schema/repair.js +163 -0
- package/dist/schema/repair.js.map +1 -0
- package/dist/schema/schema-v1.generated.d.ts +14 -0
- package/dist/schema/schema-v1.generated.d.ts.map +1 -0
- package/dist/schema/schema-v1.generated.js +7089 -0
- package/dist/schema/schema-v1.generated.js.map +1 -0
- package/dist/schema/screens.d.ts +4 -0
- package/dist/schema/screens.d.ts.map +1 -0
- package/dist/schema/screens.js +28 -0
- package/dist/schema/screens.js.map +1 -0
- package/dist/schema/test-values.d.ts +12 -0
- package/dist/schema/test-values.d.ts.map +1 -0
- package/dist/schema/test-values.js +97 -0
- package/dist/schema/test-values.js.map +1 -0
- package/dist/schema/unions.d.ts +46 -0
- package/dist/schema/unions.d.ts.map +1 -0
- package/dist/schema/unions.js +131 -0
- package/dist/schema/unions.js.map +1 -0
- package/dist/schema/validate-yaml.d.ts +14 -0
- package/dist/schema/validate-yaml.d.ts.map +1 -0
- package/dist/schema/validate-yaml.js +17 -0
- package/dist/schema/validate-yaml.js.map +1 -0
- package/dist/schema/validate.d.ts +46 -0
- package/dist/schema/validate.d.ts.map +1 -0
- package/dist/schema/validate.js +186 -0
- package/dist/schema/validate.js.map +1 -0
- package/dist/testing.d.ts +21 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +28 -0
- package/dist/testing.js.map +1 -0
- package/dist/vocabulary.d.ts +6 -0
- package/dist/vocabulary.d.ts.map +1 -0
- package/dist/vocabulary.js +26 -0
- package/dist/vocabulary.js.map +1 -0
- package/package.json +66 -3
|
@@ -0,0 +1,633 @@
|
|
|
1
|
+
import { assertNever, canonicalizeRestricted, isRecord, rowKeyToken, rowKeyValue, } from '@azx-pbc/axiom-runtime';
|
|
2
|
+
import { indefiniteArticle } from '../article.js';
|
|
3
|
+
import { constantOf } from '../expr/lint.js';
|
|
4
|
+
import { closestNames } from '../expr/suggest.js';
|
|
5
|
+
import { refuse } from './compilation.js';
|
|
6
|
+
import { textAt } from './document.js';
|
|
7
|
+
import { compileExpressionSlot } from './expression.js';
|
|
8
|
+
import { crossCheckWriterLiteral } from './option-codes.js';
|
|
9
|
+
import { isArrayElementTarget, rejectTargetMismatch } from './targets.js';
|
|
10
|
+
/** The reserved row key that names the row the owner judged, `RULES-6.1.2`. */
|
|
11
|
+
const CURRENT_ROW = 'current';
|
|
12
|
+
function bindingKey(fieldId, rowKey) {
|
|
13
|
+
// The token carries the key's wire type, so the integer `7` and the text `"7"` are two rows
|
|
14
|
+
// and therefore two bindings rather than one.
|
|
15
|
+
return rowKey === undefined ? fieldId : `${fieldId}\u0000${rowKeyToken(rowKey)}`;
|
|
16
|
+
}
|
|
17
|
+
/** The earlier write this binding collides with, including a literal key the current row can hold. */
|
|
18
|
+
function earlierClaim(claims, binding) {
|
|
19
|
+
const direct = claims.get(binding.key);
|
|
20
|
+
if (direct !== undefined)
|
|
21
|
+
return direct;
|
|
22
|
+
if (binding.rowKey === undefined)
|
|
23
|
+
return undefined;
|
|
24
|
+
const fieldId = binding.field.fieldId;
|
|
25
|
+
if (binding.rowKey !== CURRENT_ROW)
|
|
26
|
+
return claims.get(bindingKey(fieldId, CURRENT_ROW));
|
|
27
|
+
// `current` resolves separately for each failing row, so no literal key on that field is
|
|
28
|
+
// provably disjoint from it. Two such writes would collide on the row carrying that key.
|
|
29
|
+
for (const [key, operationIndex] of claims) {
|
|
30
|
+
if (key.startsWith(`${fieldId}\u0000`))
|
|
31
|
+
return operationIndex;
|
|
32
|
+
}
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
/** The prose a refusal uses for one binding: the field, and the row when there is one. */
|
|
36
|
+
function describeBinding(binding) {
|
|
37
|
+
if (binding.rowKey === undefined)
|
|
38
|
+
return `field \`${binding.field.fieldId}\``;
|
|
39
|
+
// The wire label keeps the integer `7` and the text `"7"` apart, because they are two rows.
|
|
40
|
+
const row = binding.rowKey === CURRENT_ROW
|
|
41
|
+
? 'the `current` row'
|
|
42
|
+
: `row \`${rowKeyWireLabel(binding.rowKey)}\``;
|
|
43
|
+
return `${row} of field \`${binding.field.fieldId}\``;
|
|
44
|
+
}
|
|
45
|
+
/** The natural key or item value whose write can destroy this binding's row identity. */
|
|
46
|
+
function rowIdentityOf(compilation, binding) {
|
|
47
|
+
const fieldId = binding.field.fieldId;
|
|
48
|
+
const container = compilation.rowContainers.get(fieldId);
|
|
49
|
+
const rowKey = container === undefined ? undefined : compilation.fieldsById.get(container)?.rowKey;
|
|
50
|
+
if (rowKey?.mode === 'natural' && rowKey.fieldId === fieldId) {
|
|
51
|
+
return { fieldId, description: `natural key \`${fieldId}\`` };
|
|
52
|
+
}
|
|
53
|
+
if (isArrayElementTarget(compilation, binding.field, binding.rowKey) &&
|
|
54
|
+
binding.field.rowKey === undefined) {
|
|
55
|
+
return { fieldId, description: `value-identified row of \`${fieldId}\`` };
|
|
56
|
+
}
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
/** A write that would leave a row without an addressable identity. */
|
|
60
|
+
function refuseRowIdentityValue(compilation, path, subject, identity, action) {
|
|
61
|
+
refuse(compilation, 'INVALID_ROW_KEY', path, `${subject} ${action} ${identity.description}; a row key must be a non-empty string or a safe integer so the row remains addressable, so state a valid key value`, { repairStated: true });
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
64
|
+
/** The compiled ref a `value`, `null` or `remove` operation writes. */
|
|
65
|
+
function refOf(binding) {
|
|
66
|
+
return binding.rowKey === undefined
|
|
67
|
+
? { fieldId: binding.field.fieldId }
|
|
68
|
+
: { fieldId: binding.field.fieldId, rowKey: binding.rowKey };
|
|
69
|
+
}
|
|
70
|
+
/** The nearest declared names, as the suggestion a refused identifier offers. */
|
|
71
|
+
function nearestNames(name, candidates) {
|
|
72
|
+
return closestNames(name, [...candidates]);
|
|
73
|
+
}
|
|
74
|
+
/** The clause a refused identifier's detail ends with, offering what the document does declare. */
|
|
75
|
+
function didYouMean(name, candidates) {
|
|
76
|
+
return candidates.length === 0 ? '' : `; did you mean ${candidates.join(' or ')}?`;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* The refusal metadata an identifier carries: the nearest declared names, when any is close.
|
|
80
|
+
*
|
|
81
|
+
* A detail that already asked `did you mean …` must carry the same names structurally, so an
|
|
82
|
+
* editor offers the repair the sentence states rather than parsing English.
|
|
83
|
+
*/
|
|
84
|
+
function nearestExtra(nearest) {
|
|
85
|
+
return nearest.length === 0 ? {} : { suggestions: nearest };
|
|
86
|
+
}
|
|
87
|
+
/** The wire type a row key states, so a refusal cannot confuse the integer `7` with `"7"`. */
|
|
88
|
+
function rowKeyWireLabel(rowKey) {
|
|
89
|
+
return `${typeof rowKey} ${JSON.stringify(rowKey)}`;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* The row-key wire type a declared primitive produces, or `undefined` when it produces none.
|
|
93
|
+
*
|
|
94
|
+
* A value-identified row's key is the item value itself and a natural key's key is its member's
|
|
95
|
+
* value, so the primitive's wire form decides it: every text-shaped primitive is a string key and
|
|
96
|
+
* `integer` is a numeric one. A record-shaped primitive (`money`, `quantity`, `duration`,
|
|
97
|
+
* `address`, `coordinate`, `media_ref`, `signature_ref`, `timeslot`, `record`, `array`) and
|
|
98
|
+
* `boolean` carry no scalar value, so no literal key addresses one of their rows.
|
|
99
|
+
*/
|
|
100
|
+
function rowKeyWireTypeOf(primitive) {
|
|
101
|
+
switch (primitive) {
|
|
102
|
+
case 'integer':
|
|
103
|
+
return 'integer';
|
|
104
|
+
case 'string':
|
|
105
|
+
case 'date':
|
|
106
|
+
case 'decimal':
|
|
107
|
+
case 'instant':
|
|
108
|
+
case 'time':
|
|
109
|
+
return 'string';
|
|
110
|
+
case 'boolean':
|
|
111
|
+
case 'money':
|
|
112
|
+
case 'quantity':
|
|
113
|
+
case 'duration':
|
|
114
|
+
case 'address':
|
|
115
|
+
case 'coordinate':
|
|
116
|
+
case 'media_ref':
|
|
117
|
+
case 'signature_ref':
|
|
118
|
+
case 'timeslot':
|
|
119
|
+
case 'record':
|
|
120
|
+
case 'array':
|
|
121
|
+
return undefined;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* The key domain one array declares, and how a refusal names where the domain comes from.
|
|
126
|
+
*
|
|
127
|
+
* A natural-keyed record array takes the wire type of its declared key member; a value-identified
|
|
128
|
+
* scalar array takes its item domain, because the item value is the row's identity. An array that
|
|
129
|
+
* states neither has no literal-key domain to check.
|
|
130
|
+
*/
|
|
131
|
+
function rowKeyDomainOf(array) {
|
|
132
|
+
const rowKey = array.rowKey;
|
|
133
|
+
if (rowKey?.mode === 'natural') {
|
|
134
|
+
const member = (array.fields ?? []).find((field) => field.fieldId === rowKey.fieldId);
|
|
135
|
+
if (member === undefined)
|
|
136
|
+
return undefined;
|
|
137
|
+
const article = indefiniteArticle(member.primitive);
|
|
138
|
+
const source = `whose natural key \`${member.fieldId}\` is ${article} \`${member.primitive}\``;
|
|
139
|
+
const wireType = rowKeyWireTypeOf(member.primitive);
|
|
140
|
+
return wireType === undefined
|
|
141
|
+
? {
|
|
142
|
+
outcome: 'unaddressable',
|
|
143
|
+
source,
|
|
144
|
+
repair: `${article} \`${member.primitive}\` value carries no scalar key, so declare a \`string\` or \`integer\` member as the key, or declare the array with a \`rowKey\` the session assigns`,
|
|
145
|
+
}
|
|
146
|
+
: { outcome: 'scalar', wireType, source };
|
|
147
|
+
}
|
|
148
|
+
if (rowKey === undefined && array.items !== undefined) {
|
|
149
|
+
const primitive = array.items.primitive;
|
|
150
|
+
const source = `whose item domain is \`${primitive}\``;
|
|
151
|
+
const wireType = rowKeyWireTypeOf(primitive);
|
|
152
|
+
return wireType === undefined
|
|
153
|
+
? {
|
|
154
|
+
outcome: 'unaddressable',
|
|
155
|
+
source,
|
|
156
|
+
repair: `a \`${primitive}\` item carries no scalar value a row key can name, so declare the array with a \`rowKey\` the session assigns, or choose an array whose items are \`string\` or \`integer\``,
|
|
157
|
+
}
|
|
158
|
+
: { outcome: 'scalar', wireType, source };
|
|
159
|
+
}
|
|
160
|
+
return undefined;
|
|
161
|
+
}
|
|
162
|
+
/** Whether a literal row key's wire type is the one the array's key domain declares. */
|
|
163
|
+
function rowKeyFitsWireType(rowKey, wireType) {
|
|
164
|
+
return wireType === 'integer' ? typeof rowKey === 'number' : typeof rowKey === 'string';
|
|
165
|
+
}
|
|
166
|
+
/** Refuse a literal row key whose wire type the array's key domain cannot hold. */
|
|
167
|
+
function refuseRowKeyDomain(compilation, array, rowKey, site) {
|
|
168
|
+
const domain = rowKeyDomainOf(array);
|
|
169
|
+
if (domain === undefined)
|
|
170
|
+
return false;
|
|
171
|
+
const names = `${site.subject} names row key \`${rowKeyWireLabel(rowKey)}\` in array \`${array.fieldId}\`, ${domain.source}`;
|
|
172
|
+
if (domain.outcome === 'unaddressable') {
|
|
173
|
+
refuse(compilation, 'INVALID_ROW_KEY', `${site.at}.rowKey`, `${names}; ${domain.repair}`, {
|
|
174
|
+
repairStated: true,
|
|
175
|
+
});
|
|
176
|
+
return true;
|
|
177
|
+
}
|
|
178
|
+
if (rowKeyFitsWireType(rowKey, domain.wireType))
|
|
179
|
+
return false;
|
|
180
|
+
refuse(compilation, 'INVALID_ROW_KEY', `${site.at}.rowKey`, `${names}; a row key is never coerced, so state the key as ${domain.wireType === 'string' ? 'a non-empty string' : 'a safe integer'}`, { expected: domain.wireType, repairStated: true });
|
|
181
|
+
return true;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Whether a whole-array literal write states rows the runtime could not address.
|
|
185
|
+
*
|
|
186
|
+
* A value-identified array identifies each row by the item value itself and holds each item once;
|
|
187
|
+
* a natural-keyed row is identified by its key member, which must be a key and appear once. A
|
|
188
|
+
* literal that breaks any of those rules is a row the session refuses (`IDENTITY_UNSUPPORTED`,
|
|
189
|
+
* `ROW_KEY_DUPLICATE`), so the compile refuses it here and names the value the author can repair.
|
|
190
|
+
*/
|
|
191
|
+
function refuseLiteralArrayIdentity(compilation, array, node, path, subject) {
|
|
192
|
+
if (array.rowKey === undefined && array.items !== undefined) {
|
|
193
|
+
const seen = new Set();
|
|
194
|
+
for (const item of node.items) {
|
|
195
|
+
if (item.kind !== 'literal')
|
|
196
|
+
continue;
|
|
197
|
+
// The key is the item's own wire value, so it is read with the predicate the session reads
|
|
198
|
+
// before the value is canonicalised: a null or empty item names no row at all.
|
|
199
|
+
const key = rowKeyValue(item.value);
|
|
200
|
+
if (key === undefined) {
|
|
201
|
+
refuse(compilation, 'INVALID_ROW_KEY', path, `${subject} writes array \`${array.fieldId}\` with a literal item that is not a row key; a value-identified array identifies each row by its own value, and that value must be a non-empty string or a safe integer, so state such a value for that row`, { repairStated: true });
|
|
202
|
+
return true;
|
|
203
|
+
}
|
|
204
|
+
const token = rowKeyToken(key);
|
|
205
|
+
if (seen.has(token)) {
|
|
206
|
+
refuse(compilation, 'INVALID_ROW_KEY', path, `${subject} writes array \`${array.fieldId}\` with a literal that states \`${canonicalizeRestricted(key)}\` more than once; a value-identified array holds each value at most once, so state each value once`, { repairStated: true });
|
|
207
|
+
return true;
|
|
208
|
+
}
|
|
209
|
+
seen.add(token);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
const naturalKey = array.rowKey?.mode === 'natural' ? array.rowKey.fieldId : undefined;
|
|
213
|
+
if (naturalKey !== undefined) {
|
|
214
|
+
const seen = new Set();
|
|
215
|
+
for (const item of node.items) {
|
|
216
|
+
if (item.kind !== 'literal' || !isRecord(item.value))
|
|
217
|
+
continue;
|
|
218
|
+
if (!Object.hasOwn(item.value, naturalKey)) {
|
|
219
|
+
refuse(compilation, 'INVALID_ROW_KEY', path, `${subject} writes array \`${array.fieldId}\` with a literal row that omits its declared natural key \`${naturalKey}\`; a row is identified by that member, so state \`"${naturalKey}": <value>\` in that row`, { repairStated: true });
|
|
220
|
+
return true;
|
|
221
|
+
}
|
|
222
|
+
const key = rowKeyValue(item.value[naturalKey]);
|
|
223
|
+
if (key === undefined) {
|
|
224
|
+
refuse(compilation, 'INVALID_ROW_KEY', path, `${subject} writes array \`${array.fieldId}\` with a literal row whose natural key \`${naturalKey}\` is not a row key; a row is identified by that member, and it must be a non-empty string or a safe integer, so state such a value in \`"${naturalKey}"\``, { repairStated: true });
|
|
225
|
+
return true;
|
|
226
|
+
}
|
|
227
|
+
const token = rowKeyToken(key);
|
|
228
|
+
if (seen.has(token)) {
|
|
229
|
+
refuse(compilation, 'INVALID_ROW_KEY', path, `${subject} writes array \`${array.fieldId}\` with two literal rows that share the natural key \`${canonicalizeRestricted(key)}\`; a row is identified by that member, so state each key once`, { repairStated: true });
|
|
230
|
+
return true;
|
|
231
|
+
}
|
|
232
|
+
seen.add(token);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
return false;
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* One declared binding, narrowed from the operation's `ref` and refused where it is not one a
|
|
239
|
+
* write can address.
|
|
240
|
+
*
|
|
241
|
+
* A `signature_ref` is a captured value rather than one a record supplies, a value a `compute`
|
|
242
|
+
* writer owns is produced by that writer, and a member of an array has no value of its own until
|
|
243
|
+
* a row is named. Each is a write the host could only refuse, so the artifact never states it.
|
|
244
|
+
*/
|
|
245
|
+
function resolveBinding(compilation, authored, site, owner) {
|
|
246
|
+
if (!isRecord(authored))
|
|
247
|
+
return undefined;
|
|
248
|
+
const fieldId = textAt(authored, 'fieldId');
|
|
249
|
+
if (fieldId === undefined)
|
|
250
|
+
return undefined;
|
|
251
|
+
const fieldAt = `${site.at}.fieldId`;
|
|
252
|
+
const field = compilation.fieldsById.get(fieldId);
|
|
253
|
+
if (field === undefined) {
|
|
254
|
+
const nearest = nearestNames(fieldId, compilation.fieldsById.keys());
|
|
255
|
+
refuse(compilation, 'UNKNOWN_IDENTIFIER', fieldAt, `${site.subject} writes field \`${fieldId}\`, which this document does not declare${didYouMean(fieldId, nearest)}; name a declared \`fieldId\`, or add the field first`, nearestExtra(nearest));
|
|
256
|
+
return undefined;
|
|
257
|
+
}
|
|
258
|
+
const writer = compilation.computed.writers.get(fieldId);
|
|
259
|
+
if (writer !== undefined) {
|
|
260
|
+
refuse(compilation, 'DUPLICATE_WRITER', fieldAt, `${site.subject} writes field \`${fieldId}\`, which rule \`${writer.ruleId}\` produces as a \`${writer.kind}\` value; a computed field has one writer, so name a field the record supplies, or remove that ${writer.kind === 'defaultCompute' ? 'default' : 'computation'}`, { repairStated: true });
|
|
261
|
+
return undefined;
|
|
262
|
+
}
|
|
263
|
+
if (field.primitive === 'signature_ref') {
|
|
264
|
+
refuse(compilation, 'SCHEMA_INVALID', fieldAt, `${site.subject} writes field \`${fieldId}\`, which is a \`signature_ref\`; a signature is captured by the person who signs and never assigned, so name a field the record supplies`, { repairStated: true });
|
|
265
|
+
return undefined;
|
|
266
|
+
}
|
|
267
|
+
const container = compilation.rowContainers.get(fieldId);
|
|
268
|
+
// A scalar array is itself the container when one of its elements is addressed. Its `items`
|
|
269
|
+
// declaration supplies the element's type; a record array's members instead name their own
|
|
270
|
+
// enclosing array through `rowContainers`.
|
|
271
|
+
const elementContainer = field.primitive === 'array' && field.items !== undefined ? field.fieldId : undefined;
|
|
272
|
+
const rowContainer = container ?? elementContainer;
|
|
273
|
+
// A row of an array that is itself a row member needs two keys to address, and a binding carries
|
|
274
|
+
// one. v1 addresses no row of a nested array, so the write would name a row no host can find.
|
|
275
|
+
const outer = container === undefined ? undefined : compilation.rowContainers.get(container);
|
|
276
|
+
if (container !== undefined && outer !== undefined) {
|
|
277
|
+
refuse(compilation, 'INVALID_RULE_SCOPE', fieldAt, `${site.subject} writes field \`${fieldId}\`, a member of array \`${container}\`, which sits inside a row of array \`${outer}\`; v1 addresses no row of a nested array, so name a value the record holds once or a member of a top-level array's row`, { repairStated: true });
|
|
278
|
+
return undefined;
|
|
279
|
+
}
|
|
280
|
+
const rowKey = authored['rowKey'];
|
|
281
|
+
if (rowKey === undefined) {
|
|
282
|
+
if (container === undefined)
|
|
283
|
+
return { field, key: fieldId };
|
|
284
|
+
refuse(compilation, 'INVALID_ROW_KEY', fieldAt, `${site.subject} writes field \`${fieldId}\`, a member of array \`${container}\`; a member holds one value per row, so state the row in \`rowKey\`, or name the value the record holds once`, { repairStated: true });
|
|
285
|
+
return undefined;
|
|
286
|
+
}
|
|
287
|
+
if (rowContainer === undefined) {
|
|
288
|
+
refuse(compilation, 'INVALID_ROW_KEY', `${site.at}.rowKey`, `${site.subject} writes field \`${fieldId}\` with a \`rowKey\`, and \`${fieldId}\` sits inside no array; a value the record holds once belongs to no row, so remove \`rowKey\``, { repairStated: true });
|
|
289
|
+
return undefined;
|
|
290
|
+
}
|
|
291
|
+
if (rowKey === CURRENT_ROW) {
|
|
292
|
+
// An item-scoped owner on a nested array is refused by `itemScopeDiagnostics`, and an option
|
|
293
|
+
// on a nested member is refused by `compileOption` before this walk, so no reachable owner
|
|
294
|
+
// reaches `current` for a nested row. The two branches below own every case that can.
|
|
295
|
+
if (owner.itemFieldId === undefined) {
|
|
296
|
+
refuse(compilation, 'INVALID_RULE_SCOPE', `${site.at}.rowKey`, `${site.subject} names the \`current\` row, which is the row an \`item\`-scoped owner judged, and ${owner.description} addresses no row; state the row's literal key, or address the array \`${rowContainer}\` at \`item\` scope`, { repairStated: true });
|
|
297
|
+
return undefined;
|
|
298
|
+
}
|
|
299
|
+
if (owner.itemFieldId !== rowContainer) {
|
|
300
|
+
refuse(compilation, 'INVALID_RULE_SCOPE', `${site.at}.rowKey`, `${site.subject} names the \`current\` row, which is a row of array \`${owner.itemFieldId}\`, and \`${fieldId}\` is a member of array \`${rowContainer}\`; state the row's literal key, or write a member of \`${owner.itemFieldId}\``, { repairStated: true });
|
|
301
|
+
return undefined;
|
|
302
|
+
}
|
|
303
|
+
return { field, rowKey: CURRENT_ROW, key: bindingKey(fieldId, CURRENT_ROW) };
|
|
304
|
+
}
|
|
305
|
+
if (typeof rowKey !== 'string' && typeof rowKey !== 'number')
|
|
306
|
+
return undefined;
|
|
307
|
+
// An assigned key is produced by the session's `idFactory`, so no literal the author can write
|
|
308
|
+
// names one of its rows; the symbolic row is the only spelling that resolves.
|
|
309
|
+
if (compilation.fieldsById.get(rowContainer)?.rowKey?.mode === 'assigned') {
|
|
310
|
+
refuse(compilation, 'INVALID_ROW_KEY', `${site.at}.rowKey`, `${site.subject} writes row \`${String(rowKey)}\` of field \`${fieldId}\`, whose array \`${rowContainer}\` assigns its row keys at run time; the artifact cannot name a key the session creates, so write the \`current\` row from an \`item\`-scoped owner on \`${rowContainer}\``, { repairStated: true });
|
|
311
|
+
return undefined;
|
|
312
|
+
}
|
|
313
|
+
const rowArray = compilation.fieldsById.get(rowContainer);
|
|
314
|
+
if (rowArray !== undefined && refuseRowKeyDomain(compilation, rowArray, rowKey, site)) {
|
|
315
|
+
return undefined;
|
|
316
|
+
}
|
|
317
|
+
return { field, rowKey, key: bindingKey(fieldId, rowKey) };
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* One array an `append` or `removeRow` operation names, refused where the named field is not an
|
|
321
|
+
* array whose rows a write can address.
|
|
322
|
+
*/
|
|
323
|
+
function resolveArray(compilation, authored, site) {
|
|
324
|
+
const fieldId = textAt(authored, 'fieldId');
|
|
325
|
+
if (fieldId === undefined)
|
|
326
|
+
return undefined;
|
|
327
|
+
const fieldAt = `${site.at}.fieldId`;
|
|
328
|
+
const field = compilation.fieldsById.get(fieldId);
|
|
329
|
+
if (field === undefined) {
|
|
330
|
+
const nearest = nearestNames(fieldId, compilation.fieldsById.keys());
|
|
331
|
+
refuse(compilation, 'UNKNOWN_IDENTIFIER', fieldAt, `${site.subject} names array \`${fieldId}\`, which this document does not declare${didYouMean(fieldId, nearest)}; name a declared \`array\` field`, nearestExtra(nearest));
|
|
332
|
+
return undefined;
|
|
333
|
+
}
|
|
334
|
+
if (field.primitive !== 'array') {
|
|
335
|
+
refuse(compilation, 'INVALID_RULE_SCOPE', fieldAt, `${site.subject} acts on the rows of \`${fieldId}\`, which is a \`${field.primitive}\` field; rows are held by an \`array\`, so name the array whose rows this operation changes`, { repairStated: true });
|
|
336
|
+
return undefined;
|
|
337
|
+
}
|
|
338
|
+
const writer = compilation.computed.writers.get(fieldId);
|
|
339
|
+
if (writer !== undefined) {
|
|
340
|
+
refuse(compilation, 'DUPLICATE_WRITER', fieldAt, `${site.subject} changes the rows of field \`${fieldId}\`, which rule \`${writer.ruleId}\` produces as a \`${writer.kind}\` value; a computed array has one writer, so name an array the record supplies, or remove that ${writer.kind === 'defaultCompute' ? 'default' : 'computation'}`, { repairStated: true });
|
|
341
|
+
return undefined;
|
|
342
|
+
}
|
|
343
|
+
const outer = compilation.rowContainers.get(field.fieldId);
|
|
344
|
+
if (outer !== undefined) {
|
|
345
|
+
refuse(compilation, 'INVALID_RULE_SCOPE', fieldAt, `${site.subject} changes the rows of array \`${field.fieldId}\`, which sits inside a row of array \`${outer}\`; v1 addresses no row of a nested array, so change the rows of a top-level array`, { repairStated: true });
|
|
346
|
+
return undefined;
|
|
347
|
+
}
|
|
348
|
+
return field;
|
|
349
|
+
}
|
|
350
|
+
function nodeRowKey(node) {
|
|
351
|
+
const constant = node.kind === 'literal' ? { value: node.value } : constantOf(node);
|
|
352
|
+
if (constant === undefined)
|
|
353
|
+
return { outcome: 'not-constant' };
|
|
354
|
+
const value = rowKeyValue(constant.value);
|
|
355
|
+
return value === undefined ? { outcome: 'not-a-key' } : { outcome: 'key', value };
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* The row an `append` adds, compiled member by member.
|
|
359
|
+
*
|
|
360
|
+
* Each member is a declaration of the array's own item declaration, so a template naming a member
|
|
361
|
+
* the row does not carry, writing a computed one, or producing another member's type is refused
|
|
362
|
+
* where the author wrote it. The declared natural key is required: a row without it is a row the
|
|
363
|
+
* artifact cannot identify.
|
|
364
|
+
*/
|
|
365
|
+
function compileRowTemplate(compilation, authored, site, array, owner, slots) {
|
|
366
|
+
const template = authored['row'];
|
|
367
|
+
if (!isRecord(template))
|
|
368
|
+
return undefined;
|
|
369
|
+
const members = array.fields ?? [];
|
|
370
|
+
const naturalKey = array.rowKey?.mode === 'natural' ? array.rowKey.fieldId : undefined;
|
|
371
|
+
if (members.length === 0) {
|
|
372
|
+
refuse(compilation, 'INVALID_RULE_SCOPE', `${site.at}.fieldId`, `${site.subject} adds a row to array \`${array.fieldId}\`, whose rows hold one value each rather than row members; a template states the members of a record row, so name an array whose items are records`, { repairStated: true });
|
|
373
|
+
return undefined;
|
|
374
|
+
}
|
|
375
|
+
const compiled = [];
|
|
376
|
+
let refused = false;
|
|
377
|
+
for (const [memberId, source] of Object.entries(template)) {
|
|
378
|
+
const memberAt = `${site.at}.row.${memberId}`;
|
|
379
|
+
const member = members.find((candidate) => candidate.fieldId === memberId);
|
|
380
|
+
if (member === undefined) {
|
|
381
|
+
const nearest = nearestNames(memberId, members.map((candidate) => candidate.fieldId));
|
|
382
|
+
refuse(compilation, 'UNKNOWN_IDENTIFIER', memberAt, `${site.subject} adds a row to array \`${array.fieldId}\` with a value for \`${memberId}\`, which the row does not carry${didYouMean(memberId, nearest)}; name a member of the array's item declaration`, nearestExtra(nearest));
|
|
383
|
+
refused = true;
|
|
384
|
+
continue;
|
|
385
|
+
}
|
|
386
|
+
const writer = compilation.computed.writers.get(memberId);
|
|
387
|
+
if (writer !== undefined) {
|
|
388
|
+
refuse(compilation, 'DUPLICATE_WRITER', memberAt, `${site.subject} adds a row to array \`${array.fieldId}\` with a value for \`${memberId}\`, which rule \`${writer.ruleId}\` produces as a \`${writer.kind}\` value; a computed member has one writer, so leave it out of the row template`, { repairStated: true });
|
|
389
|
+
refused = true;
|
|
390
|
+
continue;
|
|
391
|
+
}
|
|
392
|
+
if (member.primitive === 'signature_ref') {
|
|
393
|
+
refuse(compilation, 'SCHEMA_INVALID', memberAt, `${site.subject} adds a row to array \`${array.fieldId}\` with a value for \`${memberId}\`, which is a \`signature_ref\`; a signature is captured by the person who signs and never assigned, so leave it out of the row template`, { repairStated: true });
|
|
394
|
+
refused = true;
|
|
395
|
+
continue;
|
|
396
|
+
}
|
|
397
|
+
const slot = compileExpressionSlot(compilation, source, memberAt, owner.itemFieldId);
|
|
398
|
+
if (slot === undefined) {
|
|
399
|
+
refused = true;
|
|
400
|
+
continue;
|
|
401
|
+
}
|
|
402
|
+
slots.push({ path: memberAt, node: slot.node });
|
|
403
|
+
if (rejectTargetMismatch(compilation, memberId, slot.type, memberAt, site.subject) ||
|
|
404
|
+
crossCheckWriterLiteral(compilation, memberId, slot.node, memberAt, site.subject)) {
|
|
405
|
+
refused = true;
|
|
406
|
+
continue;
|
|
407
|
+
}
|
|
408
|
+
// A natural key must be a key the session can address, whether the author wrote it as a
|
|
409
|
+
// literal or as a closed expression that folds to one.
|
|
410
|
+
if (memberId === naturalKey && nodeRowKey(slot.node).outcome === 'not-a-key') {
|
|
411
|
+
refuseRowIdentityValue(compilation, memberAt, site.subject, { fieldId: memberId, description: `natural key \`${memberId}\`` }, 'states an invalid value for');
|
|
412
|
+
refused = true;
|
|
413
|
+
continue;
|
|
414
|
+
}
|
|
415
|
+
compiled.push({ fieldId: memberId, node: slot.node });
|
|
416
|
+
}
|
|
417
|
+
// The presence test reads what the author wrote rather than the compiled members: a template
|
|
418
|
+
// that states the key with an expression which did not compile already reports that cause, and
|
|
419
|
+
// a second refusal for the missing key would state a defect the author does not have.
|
|
420
|
+
if (naturalKey !== undefined && !Object.hasOwn(template, naturalKey)) {
|
|
421
|
+
refuse(compilation, 'INVALID_ROW_KEY', `${site.at}.row`, `${site.subject} adds a row to array \`${array.fieldId}\` whose template omits its declared natural key \`${naturalKey}\`; a row is identified by that member, so state \`"${naturalKey}": <expression>\` in \`row\``, { repairStated: true });
|
|
422
|
+
refused = true;
|
|
423
|
+
}
|
|
424
|
+
return refused ? undefined : compiled;
|
|
425
|
+
}
|
|
426
|
+
/** The refusal a literal row key earns on an array whose keys a literal cannot name. */
|
|
427
|
+
function refuseLiteralRowKey(compilation, array, rowKey, site) {
|
|
428
|
+
const mode = array.rowKey?.mode;
|
|
429
|
+
if (mode === 'assigned') {
|
|
430
|
+
refuse(compilation, 'INVALID_ROW_KEY', `${site.at}.rowKey`, `${site.subject} removes row \`${String(rowKey)}\` from array \`${array.fieldId}\`, which assigns its row keys at run time; the artifact cannot name a key the session creates, so remove the \`current\` row from an \`item\`-scoped owner on \`${array.fieldId}\``, { repairStated: true });
|
|
431
|
+
return undefined;
|
|
432
|
+
}
|
|
433
|
+
refuse(compilation, 'INVALID_ROW_KEY', `${site.at}.rowKey`, `${site.subject} removes row \`${String(rowKey)}\` from array \`${array.fieldId}\`, which declares no \`rowKey\`, so none of its rows has a key to name; name an array whose rows carry a natural key, or state the row the owner judged as \`current\``, { repairStated: true });
|
|
434
|
+
return undefined;
|
|
435
|
+
}
|
|
436
|
+
/** The row a `removeRow` names: a literal key, or the row an `item`-scoped owner judged. */
|
|
437
|
+
function removeRowKey(compilation, array, authored, site, owner) {
|
|
438
|
+
const rowKey = authored['rowKey'];
|
|
439
|
+
if (rowKey === CURRENT_ROW) {
|
|
440
|
+
if (owner.itemFieldId === undefined) {
|
|
441
|
+
refuse(compilation, 'INVALID_RULE_SCOPE', `${site.at}.rowKey`, `${site.subject} names the \`current\` row of array \`${array.fieldId}\`, which is the row an \`item\`-scoped owner judged, and ${owner.description} addresses no row; state the row's literal key, or address \`${array.fieldId}\` at \`item\` scope`, { repairStated: true });
|
|
442
|
+
return undefined;
|
|
443
|
+
}
|
|
444
|
+
if (owner.itemFieldId !== array.fieldId) {
|
|
445
|
+
refuse(compilation, 'INVALID_RULE_SCOPE', `${site.at}.rowKey`, `${site.subject} removes the \`current\` row of array \`${array.fieldId}\`, and the \`current\` row is a row of array \`${owner.itemFieldId}\`; remove the row from that array, or state this row's literal key`, { repairStated: true });
|
|
446
|
+
return undefined;
|
|
447
|
+
}
|
|
448
|
+
return CURRENT_ROW;
|
|
449
|
+
}
|
|
450
|
+
if (typeof rowKey !== 'string' && typeof rowKey !== 'number')
|
|
451
|
+
return undefined;
|
|
452
|
+
const valueIdentified = array.rowKey === undefined && array.items !== undefined;
|
|
453
|
+
if (array.rowKey?.mode === 'natural' || valueIdentified) {
|
|
454
|
+
if (refuseRowKeyDomain(compilation, array, rowKey, site))
|
|
455
|
+
return undefined;
|
|
456
|
+
return rowKey;
|
|
457
|
+
}
|
|
458
|
+
return refuseLiteralRowKey(compilation, array, rowKey, site);
|
|
459
|
+
}
|
|
460
|
+
/** Whether a string names one of the five operation kinds, so the switch below is exhaustive. */
|
|
461
|
+
function isSuggestionOperationKind(value) {
|
|
462
|
+
return (value === 'value' ||
|
|
463
|
+
value === 'null' ||
|
|
464
|
+
value === 'remove' ||
|
|
465
|
+
value === 'append' ||
|
|
466
|
+
value === 'removeRow');
|
|
467
|
+
}
|
|
468
|
+
/** One operation compiled into the artifact shape, or `undefined` when it was refused. */
|
|
469
|
+
function compileOperation(compilation, authored, site, owner, claims, operationIndex, slots) {
|
|
470
|
+
if (!isRecord(authored))
|
|
471
|
+
return undefined;
|
|
472
|
+
const kind = textAt(authored, 'kind');
|
|
473
|
+
// The closed metaschema refuses a `kind` outside the five before this walk runs, so an authored
|
|
474
|
+
// document never reaches here. The guard stays as defence in depth for a caller that hands this
|
|
475
|
+
// walk a compiled form: an operation this version does not understand is refused rather than
|
|
476
|
+
// dropped, because an alternative lowered without it would apply a change set the author never
|
|
477
|
+
// wrote.
|
|
478
|
+
if (!isSuggestionOperationKind(kind)) {
|
|
479
|
+
refuse(compilation, 'SCHEMA_INVALID', `${site.at}.kind`, kind === undefined
|
|
480
|
+
? `${site.subject} states no operation \`kind\`; name one of \`value\`, \`null\`, \`remove\`, \`append\` or \`removeRow\``
|
|
481
|
+
: `${site.subject} states operation kind \`${kind}\`, which is not one of \`value\`, \`null\`, \`remove\`, \`append\` or \`removeRow\`; name one of those kinds`, { repairStated: true });
|
|
482
|
+
return undefined;
|
|
483
|
+
}
|
|
484
|
+
switch (kind) {
|
|
485
|
+
case 'value':
|
|
486
|
+
case 'null':
|
|
487
|
+
case 'remove': {
|
|
488
|
+
const refAt = `${site.at}.ref`;
|
|
489
|
+
const binding = resolveBinding(compilation, authored['ref'], { at: refAt, subject: site.subject }, owner);
|
|
490
|
+
if (binding === undefined)
|
|
491
|
+
return undefined;
|
|
492
|
+
const identity = rowIdentityOf(compilation, binding);
|
|
493
|
+
const arrayElement = isArrayElementTarget(compilation, binding.field, binding.rowKey);
|
|
494
|
+
if (identity !== undefined && (kind === 'null' || (kind === 'remove' && !arrayElement))) {
|
|
495
|
+
return refuseRowIdentityValue(compilation, `${refAt}.fieldId`, site.subject, identity, kind === 'null' ? 'writes null to' : 'removes');
|
|
496
|
+
}
|
|
497
|
+
const earlier = earlierClaim(claims, binding);
|
|
498
|
+
if (earlier !== undefined) {
|
|
499
|
+
refuse(compilation, 'DUPLICATE_WRITER', `${refAt}.fieldId`, `${site.subject} writes ${describeBinding(binding)} in operation ${String(earlier + 1)} and again in operation ${String(operationIndex + 1)}; two writes to one binding leave the value to their order, so state each binding once`, { repairStated: true });
|
|
500
|
+
return undefined;
|
|
501
|
+
}
|
|
502
|
+
claims.set(binding.key, operationIndex);
|
|
503
|
+
if (kind === 'null')
|
|
504
|
+
return { kind: 'null', ref: refOf(binding) };
|
|
505
|
+
if (kind === 'remove') {
|
|
506
|
+
if (arrayElement) {
|
|
507
|
+
refuse(compilation, 'INVALID_RULE_SCOPE', `${refAt}.fieldId`, `${site.subject} removes one element of array \`${binding.field.fieldId}\`; an element is a row, so removing it moves the array's identity and must be stated as \`removeRow\` rather than \`remove\``, { repairStated: true });
|
|
508
|
+
return undefined;
|
|
509
|
+
}
|
|
510
|
+
return { kind: 'remove', ref: refOf(binding) };
|
|
511
|
+
}
|
|
512
|
+
const valueSlot = compileExpressionSlot(compilation, authored['value'], `${site.at}.value`, owner.itemFieldId);
|
|
513
|
+
if (valueSlot === undefined)
|
|
514
|
+
return undefined;
|
|
515
|
+
slots.push({ path: `${site.at}.value`, node: valueSlot.node });
|
|
516
|
+
// A whole-array literal write bypasses the row-by-row identity rules an `append` states, so
|
|
517
|
+
// it is checked before the type so a literal row with no identity is named as that rather
|
|
518
|
+
// than as the type mismatch its shape also earns. The written field is an array either when
|
|
519
|
+
// it is top level or when it is a member of an outer row; only an array-element target is
|
|
520
|
+
// excluded, because that write addresses one existing element rather than the whole list.
|
|
521
|
+
if (binding.field.primitive === 'array' &&
|
|
522
|
+
!isArrayElementTarget(compilation, binding.field, binding.rowKey) &&
|
|
523
|
+
valueSlot.node.kind === 'list' &&
|
|
524
|
+
refuseLiteralArrayIdentity(compilation, binding.field, valueSlot.node, `${site.at}.value`, site.subject)) {
|
|
525
|
+
return undefined;
|
|
526
|
+
}
|
|
527
|
+
if (rejectTargetMismatch(compilation, binding.field.fieldId, valueSlot.type, `${site.at}.value`, site.subject, binding.rowKey) ||
|
|
528
|
+
crossCheckWriterLiteral(compilation, binding.field.fieldId, valueSlot.node, `${site.at}.value`, site.subject)) {
|
|
529
|
+
return undefined;
|
|
530
|
+
}
|
|
531
|
+
if (identity !== undefined && nodeRowKey(valueSlot.node).outcome === 'not-a-key') {
|
|
532
|
+
return refuseRowIdentityValue(compilation, `${site.at}.value`, site.subject, identity, 'states an invalid value for');
|
|
533
|
+
}
|
|
534
|
+
return { kind: 'value', ref: refOf(binding), value: valueSlot.node };
|
|
535
|
+
}
|
|
536
|
+
case 'append': {
|
|
537
|
+
const array = resolveArray(compilation, authored, site);
|
|
538
|
+
if (array === undefined)
|
|
539
|
+
return undefined;
|
|
540
|
+
const row = compileRowTemplate(compilation, authored, site, array, owner, slots);
|
|
541
|
+
if (row === undefined)
|
|
542
|
+
return undefined;
|
|
543
|
+
const naturalKey = array.rowKey?.mode === 'natural' ? array.rowKey.fieldId : undefined;
|
|
544
|
+
const keyNode = row.find((member) => member.fieldId === naturalKey)?.node;
|
|
545
|
+
const key = keyNode === undefined ? undefined : nodeRowKey(keyNode);
|
|
546
|
+
if (naturalKey !== undefined && key?.outcome === 'key') {
|
|
547
|
+
const binding = {
|
|
548
|
+
field: array,
|
|
549
|
+
rowKey: key.value,
|
|
550
|
+
key: bindingKey(array.fieldId, key.value),
|
|
551
|
+
};
|
|
552
|
+
const earlier = earlierClaim(claims, binding);
|
|
553
|
+
if (earlier !== undefined) {
|
|
554
|
+
refuse(compilation, 'DUPLICATE_WRITER', `${site.at}.row.${naturalKey}`, `${site.subject} names ${describeBinding(binding)} in operation ${String(earlier + 1)} and again in operation ${String(operationIndex + 1)}; two operations name one binding, so state each binding once`, { repairStated: true });
|
|
555
|
+
return undefined;
|
|
556
|
+
}
|
|
557
|
+
claims.set(binding.key, operationIndex);
|
|
558
|
+
}
|
|
559
|
+
return {
|
|
560
|
+
kind: 'append',
|
|
561
|
+
fieldId: array.fieldId,
|
|
562
|
+
row: Object.fromEntries(row.map((member) => [member.fieldId, member.node])),
|
|
563
|
+
};
|
|
564
|
+
}
|
|
565
|
+
case 'removeRow': {
|
|
566
|
+
const array = resolveArray(compilation, authored, site);
|
|
567
|
+
if (array === undefined)
|
|
568
|
+
return undefined;
|
|
569
|
+
const rowKey = removeRowKey(compilation, array, authored, site, owner);
|
|
570
|
+
if (rowKey === undefined)
|
|
571
|
+
return undefined;
|
|
572
|
+
const binding = {
|
|
573
|
+
field: array,
|
|
574
|
+
rowKey,
|
|
575
|
+
key: bindingKey(array.fieldId, rowKey),
|
|
576
|
+
};
|
|
577
|
+
const earlier = earlierClaim(claims, binding);
|
|
578
|
+
if (earlier !== undefined) {
|
|
579
|
+
refuse(compilation, 'DUPLICATE_WRITER', `${site.at}.rowKey`, `${site.subject} names ${describeBinding(binding)} in operation ${String(earlier + 1)} and again in operation ${String(operationIndex + 1)}; two operations name one binding, so state each binding once`, { repairStated: true });
|
|
580
|
+
return undefined;
|
|
581
|
+
}
|
|
582
|
+
claims.set(binding.key, operationIndex);
|
|
583
|
+
return { kind: 'removeRow', fieldId: array.fieldId, rowKey };
|
|
584
|
+
}
|
|
585
|
+
default:
|
|
586
|
+
// Every kind is handled above; a sixth arm added to the union fails here at typecheck.
|
|
587
|
+
return assertNever(kind);
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
/**
|
|
591
|
+
* Every alternative one owner declares, compiled for the artifact.
|
|
592
|
+
*
|
|
593
|
+
* `at` is the member that holds the list, e.g. `$.rules[0].suggests`, so a refusal names the
|
|
594
|
+
* alternative and the operation the author can repair.
|
|
595
|
+
*/
|
|
596
|
+
export function compileSuggestions(compilation, authored, at, owner) {
|
|
597
|
+
const slots = [];
|
|
598
|
+
if (!Array.isArray(authored))
|
|
599
|
+
return { slots };
|
|
600
|
+
const suggestions = [];
|
|
601
|
+
let refused = false;
|
|
602
|
+
authored.forEach((entry, suggestionIndex) => {
|
|
603
|
+
if (!isRecord(entry))
|
|
604
|
+
return;
|
|
605
|
+
const labelKey = textAt(entry, 'labelKey');
|
|
606
|
+
const operations = entry['operations'];
|
|
607
|
+
if (labelKey === undefined || !Array.isArray(operations))
|
|
608
|
+
return;
|
|
609
|
+
const subject = `alternative ${String(suggestionIndex + 1)} of ${owner.description}`;
|
|
610
|
+
const claims = new Map();
|
|
611
|
+
const compiled = [];
|
|
612
|
+
let alternativeRefused = false;
|
|
613
|
+
operations.forEach((operation, operationIndex) => {
|
|
614
|
+
const site = {
|
|
615
|
+
at: `${at}[${String(suggestionIndex)}].operations[${String(operationIndex)}]`,
|
|
616
|
+
subject,
|
|
617
|
+
};
|
|
618
|
+
const value = compileOperation(compilation, operation, site, owner, claims, operationIndex, slots);
|
|
619
|
+
if (value === undefined) {
|
|
620
|
+
alternativeRefused = true;
|
|
621
|
+
return;
|
|
622
|
+
}
|
|
623
|
+
compiled.push(value);
|
|
624
|
+
});
|
|
625
|
+
if (alternativeRefused || compiled.length === 0) {
|
|
626
|
+
refused = true;
|
|
627
|
+
return;
|
|
628
|
+
}
|
|
629
|
+
suggestions.push({ labelKey, operations: compiled });
|
|
630
|
+
});
|
|
631
|
+
return refused ? { slots } : { suggestions, slots };
|
|
632
|
+
}
|
|
633
|
+
//# sourceMappingURL=suggestions.js.map
|