@azx-pbc/axiom-compiler 0.0.0-stage → 0.0.1
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,510 @@
|
|
|
1
|
+
import { asDecimalString, assertNever, isRecord } from '@azx-pbc/axiom-runtime';
|
|
2
|
+
import { fieldDeclarations } from '../schema/document.js';
|
|
3
|
+
import { refuse } from './compilation.js';
|
|
4
|
+
import { warnConditionNeverFires } from './condition-warnings.js';
|
|
5
|
+
import { listAt, textAt } from './document.js';
|
|
6
|
+
import { compileExpressionSlot } from './expression.js';
|
|
7
|
+
import { requireBooleanCondition } from './conditions.js';
|
|
8
|
+
import { crossCheckExpression } from './cross-checks.js';
|
|
9
|
+
import { crossCheckOptionCodes } from './option-codes.js';
|
|
10
|
+
function requiredRuleId(fieldId) {
|
|
11
|
+
return `r_${fieldId}_required`;
|
|
12
|
+
}
|
|
13
|
+
function visibleRuleId(fieldId) {
|
|
14
|
+
return `r_${fieldId}_visible`;
|
|
15
|
+
}
|
|
16
|
+
function minimumRuleId(fieldId) {
|
|
17
|
+
return `r_${fieldId}_minimum`;
|
|
18
|
+
}
|
|
19
|
+
function maximumRuleId(fieldId) {
|
|
20
|
+
return `r_${fieldId}_maximum`;
|
|
21
|
+
}
|
|
22
|
+
function minLengthRuleId(fieldId) {
|
|
23
|
+
return `r_${fieldId}_min_length`;
|
|
24
|
+
}
|
|
25
|
+
function maxLengthRuleId(fieldId) {
|
|
26
|
+
return `r_${fieldId}_max_length`;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The one table of declaration members that compile to a rule.
|
|
30
|
+
*
|
|
31
|
+
* Emission, the origin walk a builder command uses, and the evidence member each rule carries all
|
|
32
|
+
* read this list: a member added to one copy and not another is how a generated rule becomes
|
|
33
|
+
* unaddressable, and one table cannot disagree with itself. `required` and `requiredWhen` share
|
|
34
|
+
* one id, so exactly one of them states it — the metaschema refuses a field that states both.
|
|
35
|
+
*/
|
|
36
|
+
const DECLARATION_BINDINGS = [
|
|
37
|
+
{
|
|
38
|
+
kind: 'required',
|
|
39
|
+
member: 'required',
|
|
40
|
+
evidenceMember: 'requiredTestCases',
|
|
41
|
+
ruleId: requiredRuleId,
|
|
42
|
+
states: (field) => field['required'] === true && field['requiredWhen'] === undefined,
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
kind: 'required',
|
|
46
|
+
member: 'requiredWhen',
|
|
47
|
+
evidenceMember: 'requiredTestCases',
|
|
48
|
+
ruleId: requiredRuleId,
|
|
49
|
+
states: (field) => field['requiredWhen'] !== undefined,
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
kind: 'visible',
|
|
53
|
+
member: 'visibleWhen',
|
|
54
|
+
evidenceMember: 'visibleWhenTestCases',
|
|
55
|
+
ruleId: visibleRuleId,
|
|
56
|
+
states: (field) => field['visibleWhen'] !== undefined,
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
kind: 'validate',
|
|
60
|
+
member: 'minimum',
|
|
61
|
+
evidenceMember: 'minimumTestCases',
|
|
62
|
+
ruleId: minimumRuleId,
|
|
63
|
+
states: (field) => field['minimum'] !== undefined,
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
kind: 'validate',
|
|
67
|
+
member: 'maximum',
|
|
68
|
+
evidenceMember: 'maximumTestCases',
|
|
69
|
+
ruleId: maximumRuleId,
|
|
70
|
+
states: (field) => field['maximum'] !== undefined,
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
kind: 'validate',
|
|
74
|
+
member: 'minLength',
|
|
75
|
+
evidenceMember: 'minLengthTestCases',
|
|
76
|
+
ruleId: minLengthRuleId,
|
|
77
|
+
states: (field) => field['minLength'] !== undefined,
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
kind: 'validate',
|
|
81
|
+
member: 'maxLength',
|
|
82
|
+
evidenceMember: 'maxLengthTestCases',
|
|
83
|
+
ruleId: maxLengthRuleId,
|
|
84
|
+
states: (field) => field['maxLength'] !== undefined,
|
|
85
|
+
},
|
|
86
|
+
];
|
|
87
|
+
/** The evidence a declaration carries for one of its rules, as the artifact spells it. */
|
|
88
|
+
function declaredEvidence(field, evidenceMember) {
|
|
89
|
+
const value = field[evidenceMember];
|
|
90
|
+
return Array.isArray(value) ? value : undefined;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Every rule a document's field declarations compile to, with the declaration each came from.
|
|
94
|
+
*
|
|
95
|
+
* This is the same walk the compile performs, without the compile: a builder command that must
|
|
96
|
+
* address a generated rule — `addRuleTestCase` — asks this rather than re-deriving the id scheme,
|
|
97
|
+
* so the store cannot invent a rule the compiler does not emit.
|
|
98
|
+
*/
|
|
99
|
+
export function declaredRuleOrigins(document) {
|
|
100
|
+
const origins = [];
|
|
101
|
+
for (const declaration of fieldDeclarations(document).values()) {
|
|
102
|
+
const fieldId = textAt(declaration.field, 'fieldId');
|
|
103
|
+
if (fieldId === undefined)
|
|
104
|
+
continue;
|
|
105
|
+
for (const binding of DECLARATION_BINDINGS) {
|
|
106
|
+
if (!binding.states(declaration.field))
|
|
107
|
+
continue;
|
|
108
|
+
origins.push({
|
|
109
|
+
ruleId: binding.ruleId(fieldId),
|
|
110
|
+
path: declaration.path,
|
|
111
|
+
fieldId,
|
|
112
|
+
member: binding.member,
|
|
113
|
+
evidenceMember: binding.evidenceMember,
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return origins;
|
|
118
|
+
}
|
|
119
|
+
/** Whether a declaration is a direct member of the row of its enclosing array. */
|
|
120
|
+
function itemScopeOf(declaration) {
|
|
121
|
+
return (declaration.rowArray !== undefined &&
|
|
122
|
+
declaration.ancestors[declaration.ancestors.length - 1] === declaration.rowArray);
|
|
123
|
+
}
|
|
124
|
+
/** The dotted value path of a field that is not inside an array. */
|
|
125
|
+
function fieldPath(declaration) {
|
|
126
|
+
return [...declaration.ancestors, textAt(declaration.field, 'fieldId') ?? ''].join('.');
|
|
127
|
+
}
|
|
128
|
+
/** The path node a declaration reads: the field itself, or one row's member under `$it`. */
|
|
129
|
+
function pathNode(declaration, itemScope) {
|
|
130
|
+
const fieldId = textAt(declaration.field, 'fieldId') ?? '';
|
|
131
|
+
return { kind: 'path', path: itemScope ? `$it.${fieldId}` : fieldPath(declaration) };
|
|
132
|
+
}
|
|
133
|
+
/** The empty string a length check reads in place of an absent value. */
|
|
134
|
+
const EMPTY_STRING = { kind: 'literal', domain: 'string', value: '' };
|
|
135
|
+
/** The explicit `null` an absence guard excuses beside a genuinely missing member. */
|
|
136
|
+
const NULL_VALUE = { kind: 'literal', domain: 'null', value: null };
|
|
137
|
+
/** The literal one bound spells in the field's own domain. */
|
|
138
|
+
function boundLiteral(field, value) {
|
|
139
|
+
const primitive = textAt(field, 'primitive');
|
|
140
|
+
switch (primitive) {
|
|
141
|
+
case 'integer':
|
|
142
|
+
return { kind: 'literal', domain: 'integer', value: value };
|
|
143
|
+
case 'decimal':
|
|
144
|
+
return { kind: 'literal', domain: 'decimal', value: asDecimalString(String(value)) };
|
|
145
|
+
case 'quantity':
|
|
146
|
+
return { kind: 'literal', domain: 'decimal', value: asDecimalString(String(value)) };
|
|
147
|
+
case 'money': {
|
|
148
|
+
const currency = textAt(field, 'currency') ?? '';
|
|
149
|
+
const scale = field['scale'];
|
|
150
|
+
if (typeof scale !== 'number') {
|
|
151
|
+
throw new Error('a money field lost the scale its bound needs');
|
|
152
|
+
}
|
|
153
|
+
return { kind: 'literal', domain: 'money', value: { minor: String(value), currency, scale } };
|
|
154
|
+
}
|
|
155
|
+
case 'date':
|
|
156
|
+
return { kind: 'literal', domain: 'date', value: String(value) };
|
|
157
|
+
case 'instant':
|
|
158
|
+
return { kind: 'literal', domain: 'instant', value: String(value) };
|
|
159
|
+
case 'time':
|
|
160
|
+
return { kind: 'literal', domain: 'time', value: String(value) };
|
|
161
|
+
default:
|
|
162
|
+
throw new Error(`a ${String(primitive)} field declares a bound it cannot spell`);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
/** The value a bound reads: the field, or a quantity's `value` member. */
|
|
166
|
+
function boundSubject(declaration, itemScope) {
|
|
167
|
+
const node = pathNode(declaration, itemScope);
|
|
168
|
+
if (textAt(declaration.field, 'primitive') !== 'quantity')
|
|
169
|
+
return node;
|
|
170
|
+
if (node.kind !== 'path')
|
|
171
|
+
throw new Error('a quantity field path is not a path node');
|
|
172
|
+
return { kind: 'path', path: `${node.path}.value` };
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* The presence question that lets an absent or cleared value pass a comparison bound,
|
|
176
|
+
* `RULES-2.1.5`.
|
|
177
|
+
*
|
|
178
|
+
* A numeric, money, date or instant value has content whenever it exists, so `empty(p)` is true
|
|
179
|
+
* exactly for absence and `null` there; `0` is not empty (`EXPR-7.2.3`). The length guard cannot
|
|
180
|
+
* use it, because `empty("")` is true and would let blank text pass.
|
|
181
|
+
*/
|
|
182
|
+
function emptyGuard(declaration, itemScope) {
|
|
183
|
+
return { kind: 'call', op: 'empty', args: [pathNode(declaration, itemScope)] };
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* The absence question that lets a missing or cleared value pass a length bound.
|
|
187
|
+
*
|
|
188
|
+
* The guard is `absent(p) or p == null`, never `empty(p)`: `empty("")` is true (`EXPR-7.2.3`), so
|
|
189
|
+
* an emptiness guard would let the blank text `minLength: 1` exists to refuse pass the bound.
|
|
190
|
+
*/
|
|
191
|
+
function absenceGuard(declaration, itemScope) {
|
|
192
|
+
const path = pathNode(declaration, itemScope);
|
|
193
|
+
return [
|
|
194
|
+
{ kind: 'call', op: 'absent', args: [path] },
|
|
195
|
+
{ kind: 'compare', op: '==', args: [path, NULL_VALUE] },
|
|
196
|
+
];
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* The guarded compare node one inclusive bound states.
|
|
200
|
+
*
|
|
201
|
+
* `empty(f) or f >= bound` is the rule an author means by "if given, at least …". An absent or
|
|
202
|
+
* explicitly cleared value passes the bound so presence stays `required`'s question alone
|
|
203
|
+
* (`RULES-2.1.5`); an unguarded compare answered `UNKNOWN` on absence, which made an optional
|
|
204
|
+
* validated field unsubmittable and raised a message asserting a violation nothing had checked.
|
|
205
|
+
*
|
|
206
|
+
* A quantity bound guards the field itself and bounds the amount, `q.value`: the unit is the
|
|
207
|
+
* field's own and the bound states one decimal for every unit the field admits.
|
|
208
|
+
*/
|
|
209
|
+
function boundComparison(declaration, op, value, itemScope) {
|
|
210
|
+
return {
|
|
211
|
+
kind: 'or',
|
|
212
|
+
args: [
|
|
213
|
+
emptyGuard(declaration, itemScope),
|
|
214
|
+
{
|
|
215
|
+
kind: 'compare',
|
|
216
|
+
op,
|
|
217
|
+
args: [boundSubject(declaration, itemScope), boundLiteral(declaration.field, value)],
|
|
218
|
+
},
|
|
219
|
+
],
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* The guarded length comparison, `MODEL-2.1.19`.
|
|
224
|
+
*
|
|
225
|
+
* `absent(f) or f == null or len(f ?? "") >= n` is the rule a business author means by "if given,
|
|
226
|
+
* at least n characters": an absent or explicitly cleared value passes the bound, and `required`
|
|
227
|
+
* is the one declaration that makes a value mandatory. The coalesce keeps a present-but-null
|
|
228
|
+
* reading the empty string, so the length arm never goes undecided on a value the bound already
|
|
229
|
+
* admitted.
|
|
230
|
+
*/
|
|
231
|
+
function lengthComparison(declaration, op, length, itemScope) {
|
|
232
|
+
return {
|
|
233
|
+
kind: 'or',
|
|
234
|
+
args: [
|
|
235
|
+
...absenceGuard(declaration, itemScope),
|
|
236
|
+
{
|
|
237
|
+
kind: 'compare',
|
|
238
|
+
op,
|
|
239
|
+
args: [
|
|
240
|
+
{
|
|
241
|
+
kind: 'call',
|
|
242
|
+
op: 'len',
|
|
243
|
+
args: [
|
|
244
|
+
{
|
|
245
|
+
kind: 'coalesce',
|
|
246
|
+
args: [pathNode(declaration, itemScope), EMPTY_STRING],
|
|
247
|
+
},
|
|
248
|
+
],
|
|
249
|
+
},
|
|
250
|
+
{ kind: 'literal', domain: 'integer', value: length },
|
|
251
|
+
],
|
|
252
|
+
},
|
|
253
|
+
],
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
/** Every path one expression reads, at any depth, with comprehension binders included. */
|
|
257
|
+
function expressionReads(node, into) {
|
|
258
|
+
switch (node.kind) {
|
|
259
|
+
case 'path':
|
|
260
|
+
into.add(node.path);
|
|
261
|
+
return;
|
|
262
|
+
case 'literal':
|
|
263
|
+
return;
|
|
264
|
+
case 'list':
|
|
265
|
+
for (const item of node.items)
|
|
266
|
+
expressionReads(item, into);
|
|
267
|
+
return;
|
|
268
|
+
case 'comprehension':
|
|
269
|
+
expressionReads(node.source, into);
|
|
270
|
+
if (node.valueExpr !== undefined)
|
|
271
|
+
expressionReads(node.valueExpr, into);
|
|
272
|
+
if (node.predicate !== undefined)
|
|
273
|
+
expressionReads(node.predicate, into);
|
|
274
|
+
return;
|
|
275
|
+
default:
|
|
276
|
+
for (const arg of node.args)
|
|
277
|
+
expressionReads(arg, into);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Refuse a `requiredWhen` whose condition reads the field it makes required, at the
|
|
282
|
+
* declaration the author wrote.
|
|
283
|
+
*
|
|
284
|
+
* The written form is refused by `crossCheckItemTargets` (`RULES-5.1.3`); the declared form
|
|
285
|
+
* compiles to the same `required` rule, so it must meet the same refusal. A condition that
|
|
286
|
+
* reads its target only ever holds once the value already exists, which is not a requirement at
|
|
287
|
+
* all. An item member reads its own row through `$it`, and a bare `$it` names the whole row.
|
|
288
|
+
*/
|
|
289
|
+
function refuseRequiredWhenSelfRead(compilation, declaration, expr, itemScope) {
|
|
290
|
+
const fieldId = textAt(declaration.field, 'fieldId') ?? '';
|
|
291
|
+
const target = itemScope ? `$it.${fieldId}` : fieldPath(declaration);
|
|
292
|
+
const reads = new Set();
|
|
293
|
+
expressionReads(expr, reads);
|
|
294
|
+
const selfRead = itemScope ? reads.has(target) || reads.has('$it') : reads.has(target);
|
|
295
|
+
if (!selfRead)
|
|
296
|
+
return false;
|
|
297
|
+
refuse(compilation, 'CYCLE_DETECTED', `${declaration.path}.requiredWhen`, `field \`${fieldId}\` declares \`requiredWhen\` under a condition that reads \`${target}\`; a \`required\` rule's condition decides whether the field is required, and the engine decides presence itself, so a condition reading the field can never make it required; state the condition on sibling fields, or use \`required: true\``);
|
|
298
|
+
return true;
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* The rule one declaration compiles to, or `undefined` when its expression was refused.
|
|
302
|
+
*
|
|
303
|
+
* A refusal is already reported at the declaration; the caller emits nothing, exactly as the
|
|
304
|
+
* hand-written rule path does. The members are built in the order `compileRule` builds them, so a
|
|
305
|
+
* declaration with evidence and the hand-written rule with the same cases are one artifact byte for
|
|
306
|
+
* byte; the artifact writer preserves member order, and a canonical hash would hide the drift a
|
|
307
|
+
* reader diffing two `.artifact.json` files sees.
|
|
308
|
+
*/
|
|
309
|
+
function ruleOfDeclaration(compilation, declaration, raw, binding, shape) {
|
|
310
|
+
const evidence = declaredEvidence(declaration.field, binding.evidenceMember);
|
|
311
|
+
const withEvidence = evidence === undefined ? {} : { testCases: evidence };
|
|
312
|
+
const addressed = {
|
|
313
|
+
...(shape.ownerId === undefined ? {} : { fieldId: shape.ownerId }),
|
|
314
|
+
...(shape.target === undefined ? {} : { targetFieldId: shape.target }),
|
|
315
|
+
};
|
|
316
|
+
switch (binding.kind) {
|
|
317
|
+
case 'required': {
|
|
318
|
+
if (binding.member === 'requiredWhen') {
|
|
319
|
+
const condition = compileExpressionSlot(compilation, raw['requiredWhen'], `${declaration.path}.requiredWhen`, shape.itemFieldId);
|
|
320
|
+
if (condition === undefined)
|
|
321
|
+
return undefined;
|
|
322
|
+
crossCheckOptionCodes(compilation, `${declaration.path}.requiredWhen`, condition.node, shape.itemFieldId);
|
|
323
|
+
crossCheckExpression(compilation, `${declaration.path}.requiredWhen`, condition.node, undefined, compilation.layoutTargets);
|
|
324
|
+
requireBooleanCondition(compilation, condition, `${declaration.path}.requiredWhen`, 'a requiredWhen declaration');
|
|
325
|
+
warnConditionNeverFires(compilation, `${declaration.path}.requiredWhen`, condition.node, 'this `requiredWhen` declaration');
|
|
326
|
+
if (refuseRequiredWhenSelfRead(compilation, declaration, condition.node, shape.itemScope)) {
|
|
327
|
+
return undefined;
|
|
328
|
+
}
|
|
329
|
+
const messageKey = textAt(raw, 'requiredMessageKey');
|
|
330
|
+
return {
|
|
331
|
+
ruleId: shape.ruleId,
|
|
332
|
+
kind: 'required',
|
|
333
|
+
scope: shape.scope,
|
|
334
|
+
evaluateOn: 'client',
|
|
335
|
+
expr: condition.node,
|
|
336
|
+
...addressed,
|
|
337
|
+
...(messageKey === undefined ? {} : { messageKey }),
|
|
338
|
+
...withEvidence,
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
const messageKey = textAt(raw, 'requiredMessageKey');
|
|
342
|
+
return {
|
|
343
|
+
ruleId: shape.ruleId,
|
|
344
|
+
kind: 'required',
|
|
345
|
+
scope: shape.scope,
|
|
346
|
+
evaluateOn: 'client',
|
|
347
|
+
expr: { kind: 'literal', domain: 'boolean', value: true },
|
|
348
|
+
...addressed,
|
|
349
|
+
...(messageKey === undefined ? {} : { messageKey }),
|
|
350
|
+
...withEvidence,
|
|
351
|
+
};
|
|
352
|
+
}
|
|
353
|
+
case 'visible': {
|
|
354
|
+
const condition = compileExpressionSlot(compilation, raw['visibleWhen'], `${declaration.path}.visibleWhen`, shape.itemFieldId);
|
|
355
|
+
if (condition === undefined)
|
|
356
|
+
return undefined;
|
|
357
|
+
crossCheckOptionCodes(compilation, `${declaration.path}.visibleWhen`, condition.node, shape.itemFieldId);
|
|
358
|
+
crossCheckExpression(compilation, `${declaration.path}.visibleWhen`, condition.node, undefined, compilation.layoutTargets);
|
|
359
|
+
requireBooleanCondition(compilation, condition, `${declaration.path}.visibleWhen`, 'a visibleWhen declaration');
|
|
360
|
+
warnConditionNeverFires(compilation, `${declaration.path}.visibleWhen`, condition.analysisNode, 'this `visibleWhen` declaration');
|
|
361
|
+
return {
|
|
362
|
+
ruleId: shape.ruleId,
|
|
363
|
+
kind: 'visible',
|
|
364
|
+
scope: shape.scope,
|
|
365
|
+
evaluateOn: 'client',
|
|
366
|
+
expr: condition.node,
|
|
367
|
+
...addressed,
|
|
368
|
+
...withEvidence,
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
case 'validate': {
|
|
372
|
+
const bound = (messageKey, expr) => ({
|
|
373
|
+
ruleId: shape.ruleId,
|
|
374
|
+
kind: 'validate',
|
|
375
|
+
scope: shape.scope,
|
|
376
|
+
evaluateOn: 'client',
|
|
377
|
+
expr,
|
|
378
|
+
severity: 'block',
|
|
379
|
+
...addressed,
|
|
380
|
+
messageKey,
|
|
381
|
+
...withEvidence,
|
|
382
|
+
});
|
|
383
|
+
switch (binding.member) {
|
|
384
|
+
case 'minimum':
|
|
385
|
+
return bound(textAt(raw, 'minimumMessageKey') ?? '', boundComparison(declaration, '>=', raw['minimum'], shape.itemScope));
|
|
386
|
+
case 'maximum':
|
|
387
|
+
return bound(textAt(raw, 'maximumMessageKey') ?? '', boundComparison(declaration, '<=', raw['maximum'], shape.itemScope));
|
|
388
|
+
case 'minLength':
|
|
389
|
+
return bound(textAt(raw, 'minLengthMessageKey') ?? '', lengthComparison(declaration, '>=', raw['minLength'], shape.itemScope));
|
|
390
|
+
case 'maxLength':
|
|
391
|
+
return bound(textAt(raw, 'maxLengthMessageKey') ?? '', lengthComparison(declaration, '<=', raw['maxLength'], shape.itemScope));
|
|
392
|
+
default:
|
|
393
|
+
return assertNever(binding);
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
default:
|
|
397
|
+
return assertNever(binding);
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
/**
|
|
401
|
+
* Every rule a document's field declarations compile to, in declaration order, plus the
|
|
402
|
+
* refusals that compiling them adds.
|
|
403
|
+
*
|
|
404
|
+
* The metaschema has already refused the shapes that cannot arrive here, so a throw would be
|
|
405
|
+
* a compiler defect; the diagnostics here cover the relations it cannot state — two
|
|
406
|
+
* declarations generating one rule id as a rule the author wrote, or as each other, which would
|
|
407
|
+
* make one of them invisible to `rule_ok` and one of them ambiguous in the report.
|
|
408
|
+
*/
|
|
409
|
+
export function declarationRules(compilation, document) {
|
|
410
|
+
const diagnostics = [];
|
|
411
|
+
const rules = [];
|
|
412
|
+
const origins = [];
|
|
413
|
+
const declared = fieldDeclarations(document);
|
|
414
|
+
const generated = new Set();
|
|
415
|
+
const emit = (declaration, binding, rule) => {
|
|
416
|
+
if (compilation.ruleIds.has(rule.ruleId) || generated.has(rule.ruleId)) {
|
|
417
|
+
diagnostics.push({
|
|
418
|
+
code: 'SCHEMA_INVALID',
|
|
419
|
+
path: `${declaration.path}.${binding.member}`,
|
|
420
|
+
detail: `field \`${textAt(declaration.field, 'fieldId') ?? '$'}\` declares \`${binding.member}\`, which compiles to rule \`${rule.ruleId}\`, and this schema already declares that rule id; rename the written rule, because one id must name one rule`,
|
|
421
|
+
});
|
|
422
|
+
return;
|
|
423
|
+
}
|
|
424
|
+
generated.add(rule.ruleId);
|
|
425
|
+
rules.push(rule);
|
|
426
|
+
origins.push({
|
|
427
|
+
ruleId: rule.ruleId,
|
|
428
|
+
path: declaration.path,
|
|
429
|
+
fieldId: textAt(declaration.field, 'fieldId') ?? '',
|
|
430
|
+
member: binding.member,
|
|
431
|
+
evidenceMember: binding.evidenceMember,
|
|
432
|
+
});
|
|
433
|
+
};
|
|
434
|
+
const visit = (fields, arrayId) => {
|
|
435
|
+
for (const raw of fields) {
|
|
436
|
+
if (!isRecord(raw))
|
|
437
|
+
continue;
|
|
438
|
+
const fieldId = textAt(raw, 'fieldId');
|
|
439
|
+
if (fieldId === undefined)
|
|
440
|
+
continue;
|
|
441
|
+
const declaration = declared.get(fieldId);
|
|
442
|
+
if (declaration === undefined)
|
|
443
|
+
continue;
|
|
444
|
+
// A member of a record inside a row is not a direct member, so an item rule cannot name
|
|
445
|
+
// it; the declaration check refused it already and this walk leaves it out.
|
|
446
|
+
const itemScope = itemScopeOf(declaration);
|
|
447
|
+
const scope = itemScope ? 'item' : 'field';
|
|
448
|
+
const ownerId = itemScope ? (arrayId ?? declaration.rowArray) : fieldId;
|
|
449
|
+
const target = itemScope ? fieldId : undefined;
|
|
450
|
+
const itemFieldId = itemScope ? ownerId : undefined;
|
|
451
|
+
for (const binding of DECLARATION_BINDINGS) {
|
|
452
|
+
if (!binding.states(raw))
|
|
453
|
+
continue;
|
|
454
|
+
// A row member's `visibleWhen` would compile to an item-scoped `visible` rule, which
|
|
455
|
+
// `RULES-1.1.10` forbids: visibility is decided for a declaration, never one row, and
|
|
456
|
+
// the runtime indexes it by field. Under `onHide: "exclude"` the value the author
|
|
457
|
+
// withheld from a row would still travel, so the declaration is refused where the
|
|
458
|
+
// author wrote it rather than shipped as an inert rule.
|
|
459
|
+
if (binding.kind === 'visible' && itemScope) {
|
|
460
|
+
diagnostics.push({
|
|
461
|
+
code: 'INVALID_RULE_SCOPE',
|
|
462
|
+
path: `${declaration.path}.visibleWhen`,
|
|
463
|
+
detail: `field \`${fieldId}\` is a direct member of array \`${String(ownerId)}\`, so \`visibleWhen\` would compile to an item-scoped \`visible\` rule the runtime cannot apply per row; state the condition on the array's own declaration, or express the per-row hide as an item-scoped \`validate\``,
|
|
464
|
+
});
|
|
465
|
+
continue;
|
|
466
|
+
}
|
|
467
|
+
const rule = ruleOfDeclaration(compilation, declaration, raw, binding, {
|
|
468
|
+
ruleId: binding.ruleId(fieldId),
|
|
469
|
+
scope,
|
|
470
|
+
ownerId,
|
|
471
|
+
target,
|
|
472
|
+
itemScope,
|
|
473
|
+
itemFieldId,
|
|
474
|
+
});
|
|
475
|
+
if (rule === undefined)
|
|
476
|
+
continue;
|
|
477
|
+
emit(declaration, binding, rule);
|
|
478
|
+
}
|
|
479
|
+
visit(listAt(raw, 'fields'), textAt(raw, 'primitive') === 'array' ? fieldId : arrayId);
|
|
480
|
+
}
|
|
481
|
+
};
|
|
482
|
+
visit(listAt(document, 'fields'));
|
|
483
|
+
return { rules, diagnostics, origins };
|
|
484
|
+
}
|
|
485
|
+
/**
|
|
486
|
+
* Refuse a declaration that has no message key where the compiled rule requires one.
|
|
487
|
+
*
|
|
488
|
+
* The metaschema states the message keys as dependent-required, so this cannot arrive from a
|
|
489
|
+
* validated document; the check exists because the emitter must not mint a `validate` rule
|
|
490
|
+
* whose `messageKey` is the empty string, which the runtime would refuse at evaluation time.
|
|
491
|
+
*/
|
|
492
|
+
export function checkDeclaredMessages(compilation, document) {
|
|
493
|
+
for (const declaration of fieldDeclarations(document).values()) {
|
|
494
|
+
const field = declaration.field;
|
|
495
|
+
const fieldId = textAt(field, 'fieldId') ?? '';
|
|
496
|
+
for (const [member, keyMember, ruleId] of [
|
|
497
|
+
['minimum', 'minimumMessageKey', minimumRuleId(fieldId)],
|
|
498
|
+
['maximum', 'maximumMessageKey', maximumRuleId(fieldId)],
|
|
499
|
+
['minLength', 'minLengthMessageKey', minLengthRuleId(fieldId)],
|
|
500
|
+
['maxLength', 'maxLengthMessageKey', maxLengthRuleId(fieldId)],
|
|
501
|
+
]) {
|
|
502
|
+
if (field[member] === undefined)
|
|
503
|
+
continue;
|
|
504
|
+
if (typeof field[keyMember] === 'string')
|
|
505
|
+
continue;
|
|
506
|
+
refuse(compilation, 'SCHEMA_INVALID', `${declaration.path}.${keyMember}`, `\`${member}\` compiles to validate rule \`${ruleId}\`, which must name the sentence it raises; declare \`${keyMember}\` with a key in \`messages\``);
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
//# sourceMappingURL=declaration-rules.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"declaration-rules.js","sourceRoot":"","sources":["../../src/compile/declaration-rules.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAWhF,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE1D,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAi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AAC;QAChC,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,EAAE,SAAS,CAAC,IAAI,EAAE,CAAC;QAC/C,KAAK,MAAM,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,IAAI;YACxC,CAAC,SAAS,EAAE,mBAAmB,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;YACxD,CAAC,SAAS,EAAE,mBAAmB,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;YACxD,CAAC,WAAW,EAAE,qBAAqB,EAAE,eAAe,CAAC,OAAO,CAAC,CAAC;YAC9D,CAAC,WAAW,EAAE,qBAAqB,EAAE,eAAe,CAAC,OAAO,CAAC,CAAC;SACtD,EAAE,CAAC;YACX,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,SAAS;gBAAE,SAAS;YAC1C,IAAI,OAAO,KAAK,CAAC,SAAS,CAAC,KAAK,QAAQ;gBAAE,SAAS;YACnD,MAAM,CACJ,WAAW,EACX,gBAAgB,EAChB,GAAG,WAAW,CAAC,IAAI,IAAI,SAAS,EAAE,EAClC,KAAK,MAAM,kCAAkC,MAAM,yDAAyD,SAAS,+BAA+B,CACrJ,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import { asDecimalString, assertNever, isRecord } from '@azx-pbc/axiom-runtime';\nimport type {\n CompiledRule,\n ExprNode,\n LiteralNode,\n Primitive,\n RuleScope,\n} from '@azx-pbc/axiom-runtime';\nimport type { DeclarationEvidenceMember, DeclaredRuleOrigin } from '../publish/readiness.js';\nimport type { SchemaDiagnostic } from '../schema/diagnostic.js';\nimport type { FieldDeclaration } from '../schema/document.js';\nimport { fieldDeclarations } from '../schema/document.js';\nimport type { Compilation } from './compilation.js';\nimport { refuse } from './compilation.js';\nimport { warnConditionNeverFires } from './condition-warnings.js';\nimport { listAt, textAt } from './document.js';\nimport { compileExpressionSlot } from './expression.js';\nimport { requireBooleanCondition } from './conditions.js';\nimport { crossCheckExpression } from './cross-checks.js';\nimport { crossCheckOptionCodes } from './option-codes.js';\n\n/**\n * The declaration members that compile down to the rule an author writes by hand.\n *\n * `required: true`, `requiredWhen`, `visibleWhen`, `minimum`, `maximum`, `minLength` and\n * `maxLength` are declarations of policy, and the rule form stays for a conditional\n * requirement. Compiling both through one emitter is what makes a declared requirement and a\n * hand-written rule one behaviour rather than two: the artifact carries the same rule, the\n * report hashes it the same way, and the runtime has no second path to read.\n *\n * The synthesized ids are deterministic — `r_<fieldId>_required`, `r_<fieldId>_visible`,\n * `r_<fieldId>_minimum`, `r_<fieldId>_maximum`, `r_<fieldId>_min_length`,\n * `r_<fieldId>_max_length` — so an author can name a required rule in `rule_ok(...)` and a test\n * can compare a declared document with the hand-written one. Each declaration may carry its\n * evidence in the sibling `<member>TestCases`, and the emitter copies that list onto the rule\n * verbatim: the artifact keeps one evidence place, and a declaration's evidence hashes and reads\n * exactly as the same cases on a hand-written rule (`RULES-3.1.1`).\n */\nexport interface DeclarationRuleResult {\n readonly rules: readonly CompiledRule[];\n readonly diagnostics: readonly SchemaDiagnostic[];\n /** Where each synthesized rule came from, so a publish gap can name the declaration. */\n readonly origins: readonly DeclaredRuleOrigin[];\n}\n\nfunction requiredRuleId(fieldId: string): string {\n return `r_${fieldId}_required`;\n}\n\nfunction visibleRuleId(fieldId: string): string {\n return `r_${fieldId}_visible`;\n}\n\nfunction minimumRuleId(fieldId: string): string {\n return `r_${fieldId}_minimum`;\n}\n\nfunction maximumRuleId(fieldId: string): string {\n return `r_${fieldId}_maximum`;\n}\n\nfunction minLengthRuleId(fieldId: string): string {\n return `r_${fieldId}_min_length`;\n}\n\nfunction maxLengthRuleId(fieldId: string): string {\n return `r_${fieldId}_max_length`;\n}\n\n/** The members every binding shares, whatever kind of rule it compiles to. */\ninterface DeclarationBindingBase {\n /** The sibling member that carries this rule's evidence on the field declaration. */\n readonly evidenceMember: DeclarationEvidenceMember;\n readonly ruleId: (fieldId: string) => string;\n /** Whether the field states this declaration, so the member compiles to a rule at all. */\n readonly states: (field: Record<string, unknown>) => boolean;\n}\n\n/** A declaration member that compiles to a rule, tagged by the kind of rule it states. */\ntype DeclarationBinding =\n | (DeclarationBindingBase & {\n readonly kind: 'required';\n readonly member: 'required' | 'requiredWhen';\n })\n | (DeclarationBindingBase & {\n readonly kind: 'visible';\n readonly member: 'visibleWhen';\n })\n | (DeclarationBindingBase & {\n readonly kind: 'validate';\n readonly member: 'minimum' | 'maximum' | 'minLength' | 'maxLength';\n });\n\n/**\n * The one table of declaration members that compile to a rule.\n *\n * Emission, the origin walk a builder command uses, and the evidence member each rule carries all\n * read this list: a member added to one copy and not another is how a generated rule becomes\n * unaddressable, and one table cannot disagree with itself. `required` and `requiredWhen` share\n * one id, so exactly one of them states it — the metaschema refuses a field that states both.\n */\nconst DECLARATION_BINDINGS: readonly DeclarationBinding[] = [\n {\n kind: 'required',\n member: 'required',\n evidenceMember: 'requiredTestCases',\n ruleId: requiredRuleId,\n states: (field) => field['required'] === true && field['requiredWhen'] === undefined,\n },\n {\n kind: 'required',\n member: 'requiredWhen',\n evidenceMember: 'requiredTestCases',\n ruleId: requiredRuleId,\n states: (field) => field['requiredWhen'] !== undefined,\n },\n {\n kind: 'visible',\n member: 'visibleWhen',\n evidenceMember: 'visibleWhenTestCases',\n ruleId: visibleRuleId,\n states: (field) => field['visibleWhen'] !== undefined,\n },\n {\n kind: 'validate',\n member: 'minimum',\n evidenceMember: 'minimumTestCases',\n ruleId: minimumRuleId,\n states: (field) => field['minimum'] !== undefined,\n },\n {\n kind: 'validate',\n member: 'maximum',\n evidenceMember: 'maximumTestCases',\n ruleId: maximumRuleId,\n states: (field) => field['maximum'] !== undefined,\n },\n {\n kind: 'validate',\n member: 'minLength',\n evidenceMember: 'minLengthTestCases',\n ruleId: minLengthRuleId,\n states: (field) => field['minLength'] !== undefined,\n },\n {\n kind: 'validate',\n member: 'maxLength',\n evidenceMember: 'maxLengthTestCases',\n ruleId: maxLengthRuleId,\n states: (field) => field['maxLength'] !== undefined,\n },\n];\n\n/** The evidence a declaration carries for one of its rules, as the artifact spells it. */\nfunction declaredEvidence(\n field: Record<string, unknown>,\n evidenceMember: DeclarationEvidenceMember,\n): readonly unknown[] | undefined {\n const value = field[evidenceMember];\n return Array.isArray(value) ? value : undefined;\n}\n\n/**\n * Every rule a document's field declarations compile to, with the declaration each came from.\n *\n * This is the same walk the compile performs, without the compile: a builder command that must\n * address a generated rule — `addRuleTestCase` — asks this rather than re-deriving the id scheme,\n * so the store cannot invent a rule the compiler does not emit.\n */\nexport function declaredRuleOrigins(\n document: Record<string, unknown>,\n): readonly DeclaredRuleOrigin[] {\n const origins: DeclaredRuleOrigin[] = [];\n for (const declaration of fieldDeclarations(document).values()) {\n const fieldId = textAt(declaration.field, 'fieldId');\n if (fieldId === undefined) continue;\n for (const binding of DECLARATION_BINDINGS) {\n if (!binding.states(declaration.field)) continue;\n origins.push({\n ruleId: binding.ruleId(fieldId),\n path: declaration.path,\n fieldId,\n member: binding.member,\n evidenceMember: binding.evidenceMember,\n });\n }\n }\n return origins;\n}\n\n/** Whether a declaration is a direct member of the row of its enclosing array. */\nfunction itemScopeOf(declaration: FieldDeclaration): boolean {\n return (\n declaration.rowArray !== undefined &&\n declaration.ancestors[declaration.ancestors.length - 1] === declaration.rowArray\n );\n}\n\n/** The dotted value path of a field that is not inside an array. */\nfunction fieldPath(declaration: FieldDeclaration): string {\n return [...declaration.ancestors, textAt(declaration.field, 'fieldId') ?? ''].join('.');\n}\n\n/** The path node a declaration reads: the field itself, or one row's member under `$it`. */\nfunction pathNode(declaration: FieldDeclaration, itemScope: boolean): ExprNode {\n const fieldId = textAt(declaration.field, 'fieldId') ?? '';\n return { kind: 'path', path: itemScope ? `$it.${fieldId}` : fieldPath(declaration) };\n}\n\n/** The empty string a length check reads in place of an absent value. */\nconst EMPTY_STRING: LiteralNode = { kind: 'literal', domain: 'string', value: '' };\n\n/** The explicit `null` an absence guard excuses beside a genuinely missing member. */\nconst NULL_VALUE: LiteralNode = { kind: 'literal', domain: 'null', value: null };\n\n/** The literal one bound spells in the field's own domain. */\nfunction boundLiteral(field: Record<string, unknown>, value: unknown): LiteralNode {\n const primitive = textAt(field, 'primitive') as Primitive | undefined;\n switch (primitive) {\n case 'integer':\n return { kind: 'literal', domain: 'integer', value: value as number };\n case 'decimal':\n return { kind: 'literal', domain: 'decimal', value: asDecimalString(String(value)) };\n case 'quantity':\n return { kind: 'literal', domain: 'decimal', value: asDecimalString(String(value)) };\n case 'money': {\n const currency = textAt(field, 'currency') ?? '';\n const scale = field['scale'];\n if (typeof scale !== 'number') {\n throw new Error('a money field lost the scale its bound needs');\n }\n return { kind: 'literal', domain: 'money', value: { minor: String(value), currency, scale } };\n }\n case 'date':\n return { kind: 'literal', domain: 'date', value: String(value) };\n case 'instant':\n return { kind: 'literal', domain: 'instant', value: String(value) };\n case 'time':\n return { kind: 'literal', domain: 'time', value: String(value) };\n default:\n throw new Error(`a ${String(primitive)} field declares a bound it cannot spell`);\n }\n}\n\n/** The value a bound reads: the field, or a quantity's `value` member. */\nfunction boundSubject(declaration: FieldDeclaration, itemScope: boolean): ExprNode {\n const node = pathNode(declaration, itemScope);\n if (textAt(declaration.field, 'primitive') !== 'quantity') return node;\n if (node.kind !== 'path') throw new Error('a quantity field path is not a path node');\n return { kind: 'path', path: `${node.path}.value` };\n}\n\n/**\n * The presence question that lets an absent or cleared value pass a comparison bound,\n * `RULES-2.1.5`.\n *\n * A numeric, money, date or instant value has content whenever it exists, so `empty(p)` is true\n * exactly for absence and `null` there; `0` is not empty (`EXPR-7.2.3`). The length guard cannot\n * use it, because `empty(\"\")` is true and would let blank text pass.\n */\nfunction emptyGuard(declaration: FieldDeclaration, itemScope: boolean): ExprNode {\n return { kind: 'call', op: 'empty', args: [pathNode(declaration, itemScope)] };\n}\n\n/**\n * The absence question that lets a missing or cleared value pass a length bound.\n *\n * The guard is `absent(p) or p == null`, never `empty(p)`: `empty(\"\")` is true (`EXPR-7.2.3`), so\n * an emptiness guard would let the blank text `minLength: 1` exists to refuse pass the bound.\n */\nfunction absenceGuard(\n declaration: FieldDeclaration,\n itemScope: boolean,\n): readonly [ExprNode, ExprNode] {\n const path = pathNode(declaration, itemScope);\n return [\n { kind: 'call', op: 'absent', args: [path] },\n { kind: 'compare', op: '==', args: [path, NULL_VALUE] },\n ];\n}\n\n/**\n * The guarded compare node one inclusive bound states.\n *\n * `empty(f) or f >= bound` is the rule an author means by \"if given, at least …\". An absent or\n * explicitly cleared value passes the bound so presence stays `required`'s question alone\n * (`RULES-2.1.5`); an unguarded compare answered `UNKNOWN` on absence, which made an optional\n * validated field unsubmittable and raised a message asserting a violation nothing had checked.\n *\n * A quantity bound guards the field itself and bounds the amount, `q.value`: the unit is the\n * field's own and the bound states one decimal for every unit the field admits.\n */\nfunction boundComparison(\n declaration: FieldDeclaration,\n op: '>=' | '<=',\n value: unknown,\n itemScope: boolean,\n): ExprNode {\n return {\n kind: 'or',\n args: [\n emptyGuard(declaration, itemScope),\n {\n kind: 'compare',\n op,\n args: [boundSubject(declaration, itemScope), boundLiteral(declaration.field, value)],\n },\n ],\n };\n}\n\n/**\n * The guarded length comparison, `MODEL-2.1.19`.\n *\n * `absent(f) or f == null or len(f ?? \"\") >= n` is the rule a business author means by \"if given,\n * at least n characters\": an absent or explicitly cleared value passes the bound, and `required`\n * is the one declaration that makes a value mandatory. The coalesce keeps a present-but-null\n * reading the empty string, so the length arm never goes undecided on a value the bound already\n * admitted.\n */\nfunction lengthComparison(\n declaration: FieldDeclaration,\n op: '>=' | '<=',\n length: number,\n itemScope: boolean,\n): ExprNode {\n return {\n kind: 'or',\n args: [\n ...absenceGuard(declaration, itemScope),\n {\n kind: 'compare',\n op,\n args: [\n {\n kind: 'call',\n op: 'len',\n args: [\n {\n kind: 'coalesce',\n args: [pathNode(declaration, itemScope), EMPTY_STRING],\n },\n ],\n },\n { kind: 'literal', domain: 'integer', value: length },\n ],\n },\n ],\n };\n}\n\n/** The identity every generated rule shares with the hand-written rule of the same id. */\ninterface EmissionShape {\n readonly ruleId: string;\n readonly scope: RuleScope;\n readonly ownerId: string | undefined;\n readonly target: string | undefined;\n readonly itemScope: boolean;\n readonly itemFieldId: string | undefined;\n}\n\n/** Every path one expression reads, at any depth, with comprehension binders included. */\nfunction expressionReads(node: ExprNode, into: Set<string>): void {\n switch (node.kind) {\n case 'path':\n into.add(node.path);\n return;\n case 'literal':\n return;\n case 'list':\n for (const item of node.items) expressionReads(item, into);\n return;\n case 'comprehension':\n expressionReads(node.source, into);\n if (node.valueExpr !== undefined) expressionReads(node.valueExpr, into);\n if (node.predicate !== undefined) expressionReads(node.predicate, into);\n return;\n default:\n for (const arg of node.args) expressionReads(arg, into);\n }\n}\n\n/**\n * Refuse a `requiredWhen` whose condition reads the field it makes required, at the\n * declaration the author wrote.\n *\n * The written form is refused by `crossCheckItemTargets` (`RULES-5.1.3`); the declared form\n * compiles to the same `required` rule, so it must meet the same refusal. A condition that\n * reads its target only ever holds once the value already exists, which is not a requirement at\n * all. An item member reads its own row through `$it`, and a bare `$it` names the whole row.\n */\nfunction refuseRequiredWhenSelfRead(\n compilation: Compilation,\n declaration: FieldDeclaration,\n expr: ExprNode,\n itemScope: boolean,\n): boolean {\n const fieldId = textAt(declaration.field, 'fieldId') ?? '';\n const target = itemScope ? `$it.${fieldId}` : fieldPath(declaration);\n const reads = new Set<string>();\n expressionReads(expr, reads);\n const selfRead = itemScope ? reads.has(target) || reads.has('$it') : reads.has(target);\n if (!selfRead) return false;\n refuse(\n compilation,\n 'CYCLE_DETECTED',\n `${declaration.path}.requiredWhen`,\n `field \\`${fieldId}\\` declares \\`requiredWhen\\` under a condition that reads \\`${target}\\`; a \\`required\\` rule's condition decides whether the field is required, and the engine decides presence itself, so a condition reading the field can never make it required; state the condition on sibling fields, or use \\`required: true\\``,\n );\n return true;\n}\n\n/**\n * The rule one declaration compiles to, or `undefined` when its expression was refused.\n *\n * A refusal is already reported at the declaration; the caller emits nothing, exactly as the\n * hand-written rule path does. The members are built in the order `compileRule` builds them, so a\n * declaration with evidence and the hand-written rule with the same cases are one artifact byte for\n * byte; the artifact writer preserves member order, and a canonical hash would hide the drift a\n * reader diffing two `.artifact.json` files sees.\n */\nfunction ruleOfDeclaration(\n compilation: Compilation,\n declaration: FieldDeclaration,\n raw: Record<string, unknown>,\n binding: DeclarationBinding,\n shape: EmissionShape,\n): CompiledRule | undefined {\n const evidence = declaredEvidence(declaration.field, binding.evidenceMember);\n const withEvidence = evidence === undefined ? {} : { testCases: evidence };\n const addressed = {\n ...(shape.ownerId === undefined ? {} : { fieldId: shape.ownerId }),\n ...(shape.target === undefined ? {} : { targetFieldId: shape.target }),\n };\n switch (binding.kind) {\n case 'required': {\n if (binding.member === 'requiredWhen') {\n const condition = compileExpressionSlot(\n compilation,\n raw['requiredWhen'],\n `${declaration.path}.requiredWhen`,\n shape.itemFieldId,\n );\n if (condition === undefined) return undefined;\n crossCheckOptionCodes(\n compilation,\n `${declaration.path}.requiredWhen`,\n condition.node,\n shape.itemFieldId,\n );\n crossCheckExpression(\n compilation,\n `${declaration.path}.requiredWhen`,\n condition.node,\n undefined,\n compilation.layoutTargets,\n );\n requireBooleanCondition(\n compilation,\n condition,\n `${declaration.path}.requiredWhen`,\n 'a requiredWhen declaration',\n );\n warnConditionNeverFires(\n compilation,\n `${declaration.path}.requiredWhen`,\n condition.node,\n 'this `requiredWhen` declaration',\n );\n if (refuseRequiredWhenSelfRead(compilation, declaration, condition.node, shape.itemScope)) {\n return undefined;\n }\n const messageKey = textAt(raw, 'requiredMessageKey');\n return {\n ruleId: shape.ruleId,\n kind: 'required',\n scope: shape.scope,\n evaluateOn: 'client',\n expr: condition.node,\n ...addressed,\n ...(messageKey === undefined ? {} : { messageKey }),\n ...withEvidence,\n };\n }\n const messageKey = textAt(raw, 'requiredMessageKey');\n return {\n ruleId: shape.ruleId,\n kind: 'required',\n scope: shape.scope,\n evaluateOn: 'client',\n expr: { kind: 'literal', domain: 'boolean', value: true },\n ...addressed,\n ...(messageKey === undefined ? {} : { messageKey }),\n ...withEvidence,\n };\n }\n case 'visible': {\n const condition = compileExpressionSlot(\n compilation,\n raw['visibleWhen'],\n `${declaration.path}.visibleWhen`,\n shape.itemFieldId,\n );\n if (condition === undefined) return undefined;\n crossCheckOptionCodes(\n compilation,\n `${declaration.path}.visibleWhen`,\n condition.node,\n shape.itemFieldId,\n );\n crossCheckExpression(\n compilation,\n `${declaration.path}.visibleWhen`,\n condition.node,\n undefined,\n compilation.layoutTargets,\n );\n requireBooleanCondition(\n compilation,\n condition,\n `${declaration.path}.visibleWhen`,\n 'a visibleWhen declaration',\n );\n warnConditionNeverFires(\n compilation,\n `${declaration.path}.visibleWhen`,\n condition.analysisNode,\n 'this `visibleWhen` declaration',\n );\n return {\n ruleId: shape.ruleId,\n kind: 'visible',\n scope: shape.scope,\n evaluateOn: 'client',\n expr: condition.node,\n ...addressed,\n ...withEvidence,\n };\n }\n case 'validate': {\n const bound = (messageKey: string, expr: ExprNode): CompiledRule => ({\n ruleId: shape.ruleId,\n kind: 'validate',\n scope: shape.scope,\n evaluateOn: 'client',\n expr,\n severity: 'block',\n ...addressed,\n messageKey,\n ...withEvidence,\n });\n switch (binding.member) {\n case 'minimum':\n return bound(\n textAt(raw, 'minimumMessageKey') ?? '',\n boundComparison(declaration, '>=', raw['minimum'], shape.itemScope),\n );\n case 'maximum':\n return bound(\n textAt(raw, 'maximumMessageKey') ?? '',\n boundComparison(declaration, '<=', raw['maximum'], shape.itemScope),\n );\n case 'minLength':\n return bound(\n textAt(raw, 'minLengthMessageKey') ?? '',\n lengthComparison(declaration, '>=', raw['minLength'] as number, shape.itemScope),\n );\n case 'maxLength':\n return bound(\n textAt(raw, 'maxLengthMessageKey') ?? '',\n lengthComparison(declaration, '<=', raw['maxLength'] as number, shape.itemScope),\n );\n default:\n return assertNever(binding);\n }\n }\n default:\n return assertNever(binding);\n }\n}\n\n/**\n * Every rule a document's field declarations compile to, in declaration order, plus the\n * refusals that compiling them adds.\n *\n * The metaschema has already refused the shapes that cannot arrive here, so a throw would be\n * a compiler defect; the diagnostics here cover the relations it cannot state — two\n * declarations generating one rule id as a rule the author wrote, or as each other, which would\n * make one of them invisible to `rule_ok` and one of them ambiguous in the report.\n */\nexport function declarationRules(\n compilation: Compilation,\n document: Record<string, unknown>,\n): DeclarationRuleResult {\n const diagnostics: SchemaDiagnostic[] = [];\n const rules: CompiledRule[] = [];\n const origins: DeclaredRuleOrigin[] = [];\n const declared = fieldDeclarations(document);\n const generated = new Set<string>();\n\n const emit = (\n declaration: FieldDeclaration,\n binding: DeclarationBinding,\n rule: CompiledRule,\n ): void => {\n if (compilation.ruleIds.has(rule.ruleId) || generated.has(rule.ruleId)) {\n diagnostics.push({\n code: 'SCHEMA_INVALID',\n path: `${declaration.path}.${binding.member}`,\n detail: `field \\`${textAt(declaration.field, 'fieldId') ?? '$'}\\` declares \\`${binding.member}\\`, which compiles to rule \\`${rule.ruleId}\\`, and this schema already declares that rule id; rename the written rule, because one id must name one rule`,\n });\n return;\n }\n generated.add(rule.ruleId);\n rules.push(rule);\n origins.push({\n ruleId: rule.ruleId,\n path: declaration.path,\n fieldId: textAt(declaration.field, 'fieldId') ?? '',\n member: binding.member,\n evidenceMember: binding.evidenceMember,\n });\n };\n\n const visit = (fields: readonly unknown[], arrayId?: string): void => {\n for (const raw of fields) {\n if (!isRecord(raw)) continue;\n const fieldId = textAt(raw, 'fieldId');\n if (fieldId === undefined) continue;\n const declaration = declared.get(fieldId);\n if (declaration === undefined) continue;\n // A member of a record inside a row is not a direct member, so an item rule cannot name\n // it; the declaration check refused it already and this walk leaves it out.\n const itemScope = itemScopeOf(declaration);\n const scope = itemScope ? ('item' as const) : ('field' as const);\n const ownerId = itemScope ? (arrayId ?? declaration.rowArray) : fieldId;\n const target = itemScope ? fieldId : undefined;\n const itemFieldId = itemScope ? ownerId : undefined;\n\n for (const binding of DECLARATION_BINDINGS) {\n if (!binding.states(raw)) continue;\n // A row member's `visibleWhen` would compile to an item-scoped `visible` rule, which\n // `RULES-1.1.10` forbids: visibility is decided for a declaration, never one row, and\n // the runtime indexes it by field. Under `onHide: \"exclude\"` the value the author\n // withheld from a row would still travel, so the declaration is refused where the\n // author wrote it rather than shipped as an inert rule.\n if (binding.kind === 'visible' && itemScope) {\n diagnostics.push({\n code: 'INVALID_RULE_SCOPE',\n path: `${declaration.path}.visibleWhen`,\n detail: `field \\`${fieldId}\\` is a direct member of array \\`${String(ownerId)}\\`, so \\`visibleWhen\\` would compile to an item-scoped \\`visible\\` rule the runtime cannot apply per row; state the condition on the array's own declaration, or express the per-row hide as an item-scoped \\`validate\\``,\n });\n continue;\n }\n const rule = ruleOfDeclaration(compilation, declaration, raw, binding, {\n ruleId: binding.ruleId(fieldId),\n scope,\n ownerId,\n target,\n itemScope,\n itemFieldId,\n });\n if (rule === undefined) continue;\n emit(declaration, binding, rule);\n }\n\n visit(listAt(raw, 'fields'), textAt(raw, 'primitive') === 'array' ? fieldId : arrayId);\n }\n };\n visit(listAt(document, 'fields'));\n\n return { rules, diagnostics, origins };\n}\n\n/**\n * Refuse a declaration that has no message key where the compiled rule requires one.\n *\n * The metaschema states the message keys as dependent-required, so this cannot arrive from a\n * validated document; the check exists because the emitter must not mint a `validate` rule\n * whose `messageKey` is the empty string, which the runtime would refuse at evaluation time.\n */\nexport function checkDeclaredMessages(\n compilation: Compilation,\n document: Record<string, unknown>,\n): void {\n for (const declaration of fieldDeclarations(document).values()) {\n const field = declaration.field;\n const fieldId = textAt(field, 'fieldId') ?? '';\n for (const [member, keyMember, ruleId] of [\n ['minimum', 'minimumMessageKey', minimumRuleId(fieldId)],\n ['maximum', 'maximumMessageKey', maximumRuleId(fieldId)],\n ['minLength', 'minLengthMessageKey', minLengthRuleId(fieldId)],\n ['maxLength', 'maxLengthMessageKey', maxLengthRuleId(fieldId)],\n ] as const) {\n if (field[member] === undefined) continue;\n if (typeof field[keyMember] === 'string') continue;\n refuse(\n compilation,\n 'SCHEMA_INVALID',\n `${declaration.path}.${keyMember}`,\n `\\`${member}\\` compiles to validate rule \\`${ruleId}\\`, which must name the sentence it raises; declare \\`${keyMember}\\` with a key in \\`messages\\``,\n );\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { CompiledField, DatasetDeclaration, ExpressionDeclarations } from '@azx-pbc/axiom-runtime';
|
|
2
|
+
/** The declarations an expression is checked against, built from the document itself. */
|
|
3
|
+
export declare function declarationsOf(document: Record<string, unknown>, datasets: readonly DatasetDeclaration[]): ExpressionDeclarations;
|
|
4
|
+
/**
|
|
5
|
+
* Every `annotations.sectionId` a declared field states, at any nesting level.
|
|
6
|
+
*
|
|
7
|
+
* Section access is owned by the field annotation, so a layout `sectionId` is only a
|
|
8
|
+
* presentation anchor that must resolve to one of these; the layout walk never treats a
|
|
9
|
+
* missing anchor as a grant.
|
|
10
|
+
*/
|
|
11
|
+
export declare function declaredSectionIds(document: Record<string, unknown>): ReadonlySet<string>;
|
|
12
|
+
/**
|
|
13
|
+
* The coverage each `signature_capture` field declares, keyed by `fieldId`.
|
|
14
|
+
* The metaschema admits the member only on such a field; this index is what the expression
|
|
15
|
+
* cross-check compares a verifying `digest(...)` against.
|
|
16
|
+
*/
|
|
17
|
+
export declare function declaredSignatureCovers(document: Record<string, unknown>): ReadonlyMap<string, readonly string[]>;
|
|
18
|
+
/**
|
|
19
|
+
* The fields whose option domain is declared dynamically (`optionSource`).
|
|
20
|
+
*
|
|
21
|
+
* Their branches cannot be checked against a list the compiler does not have, but the domain is
|
|
22
|
+
* real, so a `select` on one is admitted rather than refused as if the field declared nothing.
|
|
23
|
+
*/
|
|
24
|
+
export declare function dynamicOptionFields(document: Record<string, unknown>): ReadonlySet<string>;
|
|
25
|
+
/** The option codes declared per field, keyed by the immutable `fieldId`. */
|
|
26
|
+
export declare function declaredOptions(document: Record<string, unknown>): ReadonlyMap<string, readonly string[]>;
|
|
27
|
+
/**
|
|
28
|
+
* Every declared field by its dotted path, so a message parameter's path resolves to the
|
|
29
|
+
* declaration it reads: a top-level id, a record member `f_record.f_code`, or an item
|
|
30
|
+
* member reached through the rule's own row scope `$it.f_code`.
|
|
31
|
+
*/
|
|
32
|
+
export declare function fieldsByPath(fields: readonly CompiledField[]): ReadonlyMap<string, CompiledField>;
|
|
33
|
+
/** Every declared field by its immutable `fieldId`, at any nesting level. */
|
|
34
|
+
export declare function fieldsById(fields: readonly CompiledField[]): ReadonlyMap<string, CompiledField>;
|
|
35
|
+
/**
|
|
36
|
+
* The array each declared field sits inside, by its immutable `fieldId`.
|
|
37
|
+
*
|
|
38
|
+
* A member of an array holds one value per row and none of its own, so a write to it has to name
|
|
39
|
+
* the row. The nearest enclosing array is the one a row key belongs to, whether the member is
|
|
40
|
+
* declared directly on the array or inside a record the row holds. A top-level value or array sits
|
|
41
|
+
* inside no array; a nested array names the enclosing array whose row holds it.
|
|
42
|
+
*/
|
|
43
|
+
export declare function rowContainers(fields: readonly CompiledField[]): ReadonlyMap<string, string>;
|
|
44
|
+
//# sourceMappingURL=declarations.d.ts.map
|