@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 @@
|
|
|
1
|
+
{"version":3,"file":"declarations.d.ts","sourceRoot":"","sources":["../../src/compile/declarations.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,aAAa,EACb,kBAAkB,EAClB,sBAAsB,EACvB,MAAM,wBAAwB,CAAC;AAMhC,yFAAyF;AACzF,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACjC,QAAQ,EAAE,SAAS,kBAAkB,EAAE,GACtC,sBAAsB,CAWxB;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,WAAW,CAAC,MAAM,CAAC,CAezF;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,WAAW,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAexC;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,WAAW,CAAC,MAAM,CAAC,CAY1F;AAED,6EAA6E;AAC7E,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,WAAW,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAuBxC;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,SAAS,aAAa,EAAE,GAAG,WAAW,CAAC,MAAM,EAAE,aAAa,CAAC,CAWjG;AAED,6EAA6E;AAC7E,wBAAgB,UAAU,CAAC,MAAM,EAAE,SAAS,aAAa,EAAE,GAAG,WAAW,CAAC,MAAM,EAAE,aAAa,CAAC,CAU/F;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,SAAS,aAAa,EAAE,GAAG,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAU3F"}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { isRecord } from '@azx-pbc/axiom-runtime';
|
|
2
|
+
import { declaredFields } from '../schema/validate.js';
|
|
3
|
+
import { documentContextRoots } from './artifact.js';
|
|
4
|
+
import { declaredTablesOf } from './datasets.js';
|
|
5
|
+
import { listAt, textAt } from './document.js';
|
|
6
|
+
/** The declarations an expression is checked against, built from the document itself. */
|
|
7
|
+
export function declarationsOf(document, datasets) {
|
|
8
|
+
const fields = [...declaredFields(document).values()];
|
|
9
|
+
const roots = documentContextRoots(document);
|
|
10
|
+
const declaredTables = declaredTablesOf(document);
|
|
11
|
+
return {
|
|
12
|
+
fields,
|
|
13
|
+
...(roots.length === 0 ? {} : { context: { roots } }),
|
|
14
|
+
...(declaredTables.size === 0
|
|
15
|
+
? {}
|
|
16
|
+
: { datasets: datasets.filter((dataset) => declaredTables.has(dataset.tableId)) }),
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Every `annotations.sectionId` a declared field states, at any nesting level.
|
|
21
|
+
*
|
|
22
|
+
* Section access is owned by the field annotation, so a layout `sectionId` is only a
|
|
23
|
+
* presentation anchor that must resolve to one of these; the layout walk never treats a
|
|
24
|
+
* missing anchor as a grant.
|
|
25
|
+
*/
|
|
26
|
+
export function declaredSectionIds(document) {
|
|
27
|
+
const ids = new Set();
|
|
28
|
+
const visit = (fields) => {
|
|
29
|
+
for (const field of fields) {
|
|
30
|
+
if (!isRecord(field))
|
|
31
|
+
continue;
|
|
32
|
+
const annotations = field['annotations'];
|
|
33
|
+
if (isRecord(annotations)) {
|
|
34
|
+
const sectionId = textAt(annotations, 'sectionId');
|
|
35
|
+
if (sectionId !== undefined)
|
|
36
|
+
ids.add(sectionId);
|
|
37
|
+
}
|
|
38
|
+
visit(listAt(field, 'fields'));
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
visit(listAt(document, 'fields'));
|
|
42
|
+
return ids;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The coverage each `signature_capture` field declares, keyed by `fieldId`.
|
|
46
|
+
* The metaschema admits the member only on such a field; this index is what the expression
|
|
47
|
+
* cross-check compares a verifying `digest(...)` against.
|
|
48
|
+
*/
|
|
49
|
+
export function declaredSignatureCovers(document) {
|
|
50
|
+
const covers = new Map();
|
|
51
|
+
const visit = (fields) => {
|
|
52
|
+
for (const field of fields) {
|
|
53
|
+
if (!isRecord(field))
|
|
54
|
+
continue;
|
|
55
|
+
const fieldId = textAt(field, 'fieldId');
|
|
56
|
+
const targets = listAt(field, 'covers').filter((target) => typeof target === 'string');
|
|
57
|
+
if (fieldId !== undefined && targets.length > 0)
|
|
58
|
+
covers.set(fieldId, targets);
|
|
59
|
+
visit(listAt(field, 'fields'));
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
visit(listAt(document, 'fields'));
|
|
63
|
+
return covers;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* The fields whose option domain is declared dynamically (`optionSource`).
|
|
67
|
+
*
|
|
68
|
+
* Their branches cannot be checked against a list the compiler does not have, but the domain is
|
|
69
|
+
* real, so a `select` on one is admitted rather than refused as if the field declared nothing.
|
|
70
|
+
*/
|
|
71
|
+
export function dynamicOptionFields(document) {
|
|
72
|
+
const dynamic = new Set();
|
|
73
|
+
const visit = (fields) => {
|
|
74
|
+
for (const field of fields) {
|
|
75
|
+
if (!isRecord(field))
|
|
76
|
+
continue;
|
|
77
|
+
const fieldId = textAt(field, 'fieldId');
|
|
78
|
+
if (fieldId !== undefined && field['optionSource'] !== undefined)
|
|
79
|
+
dynamic.add(fieldId);
|
|
80
|
+
visit(listAt(field, 'fields'));
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
visit(listAt(document, 'fields'));
|
|
84
|
+
return dynamic;
|
|
85
|
+
}
|
|
86
|
+
/** The option codes declared per field, keyed by the immutable `fieldId`. */
|
|
87
|
+
export function declaredOptions(document) {
|
|
88
|
+
const codes = new Map();
|
|
89
|
+
const visit = (fields) => {
|
|
90
|
+
for (const field of fields) {
|
|
91
|
+
if (!isRecord(field))
|
|
92
|
+
continue;
|
|
93
|
+
const fieldId = textAt(field, 'fieldId');
|
|
94
|
+
const options = listAt(field, 'options');
|
|
95
|
+
if (fieldId !== undefined && options.length > 0) {
|
|
96
|
+
codes.set(fieldId, options.filter(isRecord).flatMap((option) => {
|
|
97
|
+
const code = option['code'];
|
|
98
|
+
if (typeof code === 'string')
|
|
99
|
+
return [code];
|
|
100
|
+
if (typeof code === 'number')
|
|
101
|
+
return [String(code)];
|
|
102
|
+
return [];
|
|
103
|
+
}));
|
|
104
|
+
}
|
|
105
|
+
visit(listAt(field, 'fields'));
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
visit(listAt(document, 'fields'));
|
|
109
|
+
return codes;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Every declared field by its dotted path, so a message parameter's path resolves to the
|
|
113
|
+
* declaration it reads: a top-level id, a record member `f_record.f_code`, or an item
|
|
114
|
+
* member reached through the rule's own row scope `$it.f_code`.
|
|
115
|
+
*/
|
|
116
|
+
export function fieldsByPath(fields) {
|
|
117
|
+
const byPath = new Map();
|
|
118
|
+
const visit = (members, prefix) => {
|
|
119
|
+
for (const member of members) {
|
|
120
|
+
const path = prefix === '' ? member.fieldId : `${prefix}.${member.fieldId}`;
|
|
121
|
+
byPath.set(path, member);
|
|
122
|
+
visit(member.fields ?? [], path);
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
visit(fields, '');
|
|
126
|
+
return byPath;
|
|
127
|
+
}
|
|
128
|
+
/** Every declared field by its immutable `fieldId`, at any nesting level. */
|
|
129
|
+
export function fieldsById(fields) {
|
|
130
|
+
const byId = new Map();
|
|
131
|
+
const visit = (members) => {
|
|
132
|
+
for (const member of members) {
|
|
133
|
+
byId.set(member.fieldId, member);
|
|
134
|
+
visit(member.fields ?? []);
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
visit(fields);
|
|
138
|
+
return byId;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* The array each declared field sits inside, by its immutable `fieldId`.
|
|
142
|
+
*
|
|
143
|
+
* A member of an array holds one value per row and none of its own, so a write to it has to name
|
|
144
|
+
* the row. The nearest enclosing array is the one a row key belongs to, whether the member is
|
|
145
|
+
* declared directly on the array or inside a record the row holds. A top-level value or array sits
|
|
146
|
+
* inside no array; a nested array names the enclosing array whose row holds it.
|
|
147
|
+
*/
|
|
148
|
+
export function rowContainers(fields) {
|
|
149
|
+
const containers = new Map();
|
|
150
|
+
const visit = (members, inside) => {
|
|
151
|
+
for (const member of members) {
|
|
152
|
+
if (inside !== undefined)
|
|
153
|
+
containers.set(member.fieldId, inside);
|
|
154
|
+
visit(member.fields ?? [], member.primitive === 'array' ? member.fieldId : inside);
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
visit(fields, undefined);
|
|
158
|
+
return containers;
|
|
159
|
+
}
|
|
160
|
+
//# sourceMappingURL=declarations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"declarations.js","sourceRoot":"","sources":["../../src/compile/declarations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAMlD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAE/C,yFAAyF;AACzF,MAAM,UAAU,cAAc,CAC5B,QAAiC,EACjC,QAAuC;IAEvC,MAAM,MAAM,GAAG,CAAC,GAAG,cAAc,CAAC,QAAQ,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;IACtD,MAAM,KAAK,GAAG,oBAAoB,CAAC,QAAQ,CAAC,CAAC;IAC7C,MAAM,cAAc,GAAG,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IAClD,OAAO;QACL,MAAM;QACN,GAAG,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAA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AE,MAAM,CAAC,CAAC;YACjE,KAAK,CAAC,MAAM,CAAC,MAAM,IAAI,EAAE,EAAE,MAAM,CAAC,SAAS,KAAK,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;QACrF,CAAC;IACH,CAAC,CAAC;IACF,KAAK,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IACzB,OAAO,UAAU,CAAC;AACpB,CAAC","sourcesContent":["import { isRecord } from '@azx-pbc/axiom-runtime';\nimport type {\n CompiledField,\n DatasetDeclaration,\n ExpressionDeclarations,\n} from '@azx-pbc/axiom-runtime';\nimport { declaredFields } from '../schema/validate.js';\nimport { documentContextRoots } from './artifact.js';\nimport { declaredTablesOf } from './datasets.js';\nimport { listAt, textAt } from './document.js';\n\n/** The declarations an expression is checked against, built from the document itself. */\nexport function declarationsOf(\n document: Record<string, unknown>,\n datasets: readonly DatasetDeclaration[],\n): ExpressionDeclarations {\n const fields = [...declaredFields(document).values()];\n const roots = documentContextRoots(document);\n const declaredTables = declaredTablesOf(document);\n return {\n fields,\n ...(roots.length === 0 ? {} : { context: { roots } }),\n ...(declaredTables.size === 0\n ? {}\n : { datasets: datasets.filter((dataset) => declaredTables.has(dataset.tableId)) }),\n };\n}\n\n/**\n * Every `annotations.sectionId` a declared field states, at any nesting level.\n *\n * Section access is owned by the field annotation, so a layout `sectionId` is only a\n * presentation anchor that must resolve to one of these; the layout walk never treats a\n * missing anchor as a grant.\n */\nexport function declaredSectionIds(document: Record<string, unknown>): ReadonlySet<string> {\n const ids = new Set<string>();\n const visit = (fields: readonly unknown[]): void => {\n for (const field of fields) {\n if (!isRecord(field)) continue;\n const annotations = field['annotations'];\n if (isRecord(annotations)) {\n const sectionId = textAt(annotations, 'sectionId');\n if (sectionId !== undefined) ids.add(sectionId);\n }\n visit(listAt(field, 'fields'));\n }\n };\n visit(listAt(document, 'fields'));\n return ids;\n}\n\n/**\n * The coverage each `signature_capture` field declares, keyed by `fieldId`.\n * The metaschema admits the member only on such a field; this index is what the expression\n * cross-check compares a verifying `digest(...)` against.\n */\nexport function declaredSignatureCovers(\n document: Record<string, unknown>,\n): ReadonlyMap<string, readonly string[]> {\n const covers = new Map<string, readonly string[]>();\n const visit = (fields: readonly unknown[]): void => {\n for (const field of fields) {\n if (!isRecord(field)) continue;\n const fieldId = textAt(field, 'fieldId');\n const targets = listAt(field, 'covers').filter(\n (target): target is string => typeof target === 'string',\n );\n if (fieldId !== undefined && targets.length > 0) covers.set(fieldId, targets);\n visit(listAt(field, 'fields'));\n }\n };\n visit(listAt(document, 'fields'));\n return covers;\n}\n\n/**\n * The fields whose option domain is declared dynamically (`optionSource`).\n *\n * Their branches cannot be checked against a list the compiler does not have, but the domain is\n * real, so a `select` on one is admitted rather than refused as if the field declared nothing.\n */\nexport function dynamicOptionFields(document: Record<string, unknown>): ReadonlySet<string> {\n const dynamic = new Set<string>();\n const visit = (fields: readonly unknown[]): void => {\n for (const field of fields) {\n if (!isRecord(field)) continue;\n const fieldId = textAt(field, 'fieldId');\n if (fieldId !== undefined && field['optionSource'] !== undefined) dynamic.add(fieldId);\n visit(listAt(field, 'fields'));\n }\n };\n visit(listAt(document, 'fields'));\n return dynamic;\n}\n\n/** The option codes declared per field, keyed by the immutable `fieldId`. */\nexport function declaredOptions(\n document: Record<string, unknown>,\n): ReadonlyMap<string, readonly string[]> {\n const codes = new Map<string, readonly string[]>();\n const visit = (fields: readonly unknown[]): void => {\n for (const field of fields) {\n if (!isRecord(field)) continue;\n const fieldId = textAt(field, 'fieldId');\n const options = listAt(field, 'options');\n if (fieldId !== undefined && options.length > 0) {\n codes.set(\n fieldId,\n options.filter(isRecord).flatMap((option) => {\n const code = option['code'];\n if (typeof code === 'string') return [code];\n if (typeof code === 'number') return [String(code)];\n return [];\n }),\n );\n }\n visit(listAt(field, 'fields'));\n }\n };\n visit(listAt(document, 'fields'));\n return codes;\n}\n\n/**\n * Every declared field by its dotted path, so a message parameter's path resolves to the\n * declaration it reads: a top-level id, a record member `f_record.f_code`, or an item\n * member reached through the rule's own row scope `$it.f_code`.\n */\nexport function fieldsByPath(fields: readonly CompiledField[]): ReadonlyMap<string, CompiledField> {\n const byPath = new Map<string, CompiledField>();\n const visit = (members: readonly CompiledField[], prefix: string): void => {\n for (const member of members) {\n const path = prefix === '' ? member.fieldId : `${prefix}.${member.fieldId}`;\n byPath.set(path, member);\n visit(member.fields ?? [], path);\n }\n };\n visit(fields, '');\n return byPath;\n}\n\n/** Every declared field by its immutable `fieldId`, at any nesting level. */\nexport function fieldsById(fields: readonly CompiledField[]): ReadonlyMap<string, CompiledField> {\n const byId = new Map<string, CompiledField>();\n const visit = (members: readonly CompiledField[]): void => {\n for (const member of members) {\n byId.set(member.fieldId, member);\n visit(member.fields ?? []);\n }\n };\n visit(fields);\n return byId;\n}\n\n/**\n * The array each declared field sits inside, by its immutable `fieldId`.\n *\n * A member of an array holds one value per row and none of its own, so a write to it has to name\n * the row. The nearest enclosing array is the one a row key belongs to, whether the member is\n * declared directly on the array or inside a record the row holds. A top-level value or array sits\n * inside no array; a nested array names the enclosing array whose row holds it.\n */\nexport function rowContainers(fields: readonly CompiledField[]): ReadonlyMap<string, string> {\n const containers = new Map<string, string>();\n const visit = (members: readonly CompiledField[], inside: string | undefined): void => {\n for (const member of members) {\n if (inside !== undefined) containers.set(member.fieldId, inside);\n visit(member.fields ?? [], member.primitive === 'array' ? member.fieldId : inside);\n }\n };\n visit(fields, undefined);\n return containers;\n}\n"]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** A member every stage reads from the validated document, without asserting its shape. */
|
|
2
|
+
export declare function listAt(record: Record<string, unknown>, key: string): readonly unknown[];
|
|
3
|
+
export declare function textAt(record: Record<string, unknown>, key: string): string | undefined;
|
|
4
|
+
//# sourceMappingURL=document.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../../src/compile/document.ts"],"names":[],"mappings":"AAAA,2FAA2F;AAC3F,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,SAAS,OAAO,EAAE,CAKvF;AAED,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAGvF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** A member every stage reads from the validated document, without asserting its shape. */
|
|
2
|
+
export function listAt(record, key) {
|
|
3
|
+
const value = record[key];
|
|
4
|
+
if (!Array.isArray(value))
|
|
5
|
+
return [];
|
|
6
|
+
const list = value;
|
|
7
|
+
return list;
|
|
8
|
+
}
|
|
9
|
+
export function textAt(record, key) {
|
|
10
|
+
const value = record[key];
|
|
11
|
+
return typeof value === 'string' ? value : undefined;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=document.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document.js","sourceRoot":"","sources":["../../src/compile/document.ts"],"names":[],"mappings":"AAAA,2FAA2F;AAC3F,MAAM,UAAU,MAAM,CAAC,MAA+B,EAAE,GAAW;IACjE,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IAC1B,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IACrC,MAAM,IAAI,GAAuB,KAAK,CAAC;IACvC,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,MAAM,CAAC,MAA+B,EAAE,GAAW;IACjE,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IAC1B,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AACvD,CAAC","sourcesContent":["/** A member every stage reads from the validated document, without asserting its shape. */\nexport function listAt(record: Record<string, unknown>, key: string): readonly unknown[] {\n const value = record[key];\n if (!Array.isArray(value)) return [];\n const list: readonly unknown[] = value;\n return list;\n}\n\nexport function textAt(record: Record<string, unknown>, key: string): string | undefined {\n const value = record[key];\n return typeof value === 'string' ? value : undefined;\n}\n"]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { ExprNode } from '@azx-pbc/axiom-runtime';
|
|
2
|
+
import type { StaticType } from '../expr/typecheck.js';
|
|
3
|
+
import type { Compilation } from './compilation.js';
|
|
4
|
+
/** One expression slot: the compiled node and the static type it was given. */
|
|
5
|
+
interface CompiledSlot {
|
|
6
|
+
readonly node: ExprNode;
|
|
7
|
+
readonly type: StaticType;
|
|
8
|
+
/** The same slot with pure computed definitions inlined, for analysis only. */
|
|
9
|
+
readonly analysisNode: ExprNode;
|
|
10
|
+
}
|
|
11
|
+
/** One expression slot, parsed when it is authored and typed either way. */
|
|
12
|
+
export declare function compileExpressionSlot(compilation: Compilation, value: unknown, path: string, scope?: string): CompiledSlot | undefined;
|
|
13
|
+
/** The expression slots one message's arguments bind, and the field each names. */
|
|
14
|
+
export interface CompiledMessageBinding {
|
|
15
|
+
readonly nodes: Readonly<Record<string, ExprNode>>;
|
|
16
|
+
readonly paramFields: ReadonlyMap<string, string>;
|
|
17
|
+
/**
|
|
18
|
+
* The names whose expression was refused on its own.
|
|
19
|
+
*
|
|
20
|
+
* The parse is the diagnostic an author must fix; the message check must not then report
|
|
21
|
+
* the same parameter again as "not bound", which would send them looking for a binding
|
|
22
|
+
* defect that does not exist. Absent when every parameter parsed.
|
|
23
|
+
*/
|
|
24
|
+
readonly unparsedParams?: ReadonlySet<string>;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The message arguments one authored parameter block binds, compiled behind the owner's row scope
|
|
28
|
+
* and appended to the owner's expression slots.
|
|
29
|
+
*
|
|
30
|
+
* `member` names the block the author wrote, so a refusal points at the member that holds it: a
|
|
31
|
+
* rule's `params`, or an option's `unavailableParams` (`RULES-7.1.1`).
|
|
32
|
+
*/
|
|
33
|
+
export declare function compileParams(compilation: Compilation, authored: unknown, at: string, itemScope: string | undefined, slots: {
|
|
34
|
+
path: string;
|
|
35
|
+
node: ExprNode;
|
|
36
|
+
}[], member?: string): CompiledMessageBinding;
|
|
37
|
+
export {};
|
|
38
|
+
//# sourceMappingURL=expression.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expression.d.ts","sourceRoot":"","sources":["../../src/compile/expression.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAOvD,OAAO,KAAK,EAAE,UAAU,EAAiB,MAAM,sBAAsB,CAAC;AAStE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAyBpD,+EAA+E;AAC/E,UAAU,YAAY;IACpB,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,+EAA+E;IAC/E,QAAQ,CAAC,YAAY,EAAE,QAAQ,CAAC;CACjC;AAkFD,4EAA4E;AAC5E,wBAAgB,qBAAqB,CACnC,WAAW,EAAE,WAAW,EACxB,KAAK,EAAE,OAAO,EACd,IAAI,EAAE,MAAM,EACZ,KAAK,CAAC,EAAE,MAAM,GACb,YAAY,GAAG,SAAS,CA2K1B;AAoBD,mFAAmF;AACnF,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;IACnD,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClD;;;;;;OAMG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CAC/C;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAC3B,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,OAAO,EACjB,EAAE,EAAE,MAAM,EACV,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,KAAK,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,QAAQ,CAAA;CAAE,EAAE,EACzC,MAAM,SAAW,GAChB,sBAAsB,CAwBxB"}
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
import { diagnosticDoc, isRecord } from '@azx-pbc/axiom-runtime';
|
|
2
|
+
import { exprNodeOf, MalformedCompiledNode } from '../expr/boundary.js';
|
|
3
|
+
import { deprecationWarnings } from '../expr/deprecation.js';
|
|
4
|
+
import { ExpressionCompileError } from '../expr/diagnostics.js';
|
|
5
|
+
import { checkExpressionBudget, parseExpression } from '../expr/parser.js';
|
|
6
|
+
import { checkExpression, lintExpression, undecidedFolds } from '../expr/typecheck.js';
|
|
7
|
+
import { lintWarnings } from '../expr/lint-warnings.js';
|
|
8
|
+
import { undecidedWarnings } from '../expr/undecided.js';
|
|
9
|
+
import { analyzeExpression } from '../expr/values/interval.js';
|
|
10
|
+
import { inlineExpression } from '../expr/values/inline.js';
|
|
11
|
+
import { DATASET_DECLARATION_CHANNELS } from '../schema/dataset-declaration.js';
|
|
12
|
+
import { refuse } from './compilation.js';
|
|
13
|
+
import { datasetTableNames } from './datasets.js';
|
|
14
|
+
/** One expression refusal's structured metadata, for the caller that repairs it. */
|
|
15
|
+
function refusalExtra(diagnostic) {
|
|
16
|
+
return {
|
|
17
|
+
offset: diagnostic.offset,
|
|
18
|
+
// An expression offset indexes the expression source in this slot, not the document the
|
|
19
|
+
// command read, so a reporter must not turn it into a document line and column.
|
|
20
|
+
offsetSource: 'expression',
|
|
21
|
+
...(diagnostic.suggestions.length === 0 ? {} : { suggestions: diagnostic.suggestions }),
|
|
22
|
+
...(diagnostic.expected === undefined ? {} : { expected: diagnostic.expected }),
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/** One expression refusal as the compiler reports it, with its bounded suggestions. */
|
|
26
|
+
function refusalDetail(diagnostic) {
|
|
27
|
+
if (diagnostic.suggestions.length === 0)
|
|
28
|
+
return diagnostic.detail;
|
|
29
|
+
return `${diagnostic.detail}; did you mean ${diagnostic.suggestions.join(' or ')}?`;
|
|
30
|
+
}
|
|
31
|
+
/** Where a definition was inlined, and why one was not, for a diagnostic's detail. */
|
|
32
|
+
function inlineDetail(inline) {
|
|
33
|
+
const parts = [];
|
|
34
|
+
if (inline.uses.length > 0) {
|
|
35
|
+
const uses = inline.uses.map((use) => `\`${use.fieldId}\` (defined at ${use.path}, rule \`${use.ruleId}\`)`);
|
|
36
|
+
parts.push(`this expression reads ${uses.join(' and ')}`);
|
|
37
|
+
}
|
|
38
|
+
parts.push(...inline.notes);
|
|
39
|
+
return parts.join('; ');
|
|
40
|
+
}
|
|
41
|
+
function withInlineDetail(detail, inline) {
|
|
42
|
+
const suffix = inlineDetail(inline);
|
|
43
|
+
return suffix === '' ? detail : `${detail}; ${suffix}`;
|
|
44
|
+
}
|
|
45
|
+
function sourceOf(value) {
|
|
46
|
+
return typeof value === 'string' ? value : undefined;
|
|
47
|
+
}
|
|
48
|
+
/** The declaration condition warning the slot's own role earns, if any. */
|
|
49
|
+
function declarationConditionWarning(compilation, path, node, value, scope) {
|
|
50
|
+
const role = path.endsWith('.visibleWhen')
|
|
51
|
+
? 'visibleWhen'
|
|
52
|
+
: path.endsWith('.requiredWhen')
|
|
53
|
+
? 'requiredWhen'
|
|
54
|
+
: undefined;
|
|
55
|
+
if (role === undefined)
|
|
56
|
+
return undefined;
|
|
57
|
+
const analysis = analyzeExpression(compilation.declarations, node, scope);
|
|
58
|
+
if (!analysis.derived || analysis.truth === 'unknown')
|
|
59
|
+
return undefined;
|
|
60
|
+
const source = sourceOf(value);
|
|
61
|
+
const subject = source === undefined ? `this \`${role}\` condition` : `\`${source}\``;
|
|
62
|
+
if (role === 'visibleWhen') {
|
|
63
|
+
if (analysis.truth === 'true') {
|
|
64
|
+
return {
|
|
65
|
+
code: 'CONSTANT_COMPARISON',
|
|
66
|
+
path,
|
|
67
|
+
detail: `${subject} is always true, so this field is visible on every record; remove \`visibleWhen\`, or state the branch that should hide it`,
|
|
68
|
+
messageKey: diagnosticDoc('CONSTANT_COMPARISON').messageKey,
|
|
69
|
+
suggestions: [],
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
code: analysis.shape === 'connector' ? 'UNSATISFIABLE_CONDITION' : 'CONSTANT_COMPARISON',
|
|
74
|
+
path,
|
|
75
|
+
detail: `${subject} can never be true, so this field is never visible; correct the bounds, or remove \`visibleWhen\``,
|
|
76
|
+
messageKey: diagnosticDoc(analysis.shape === 'connector' ? 'UNSATISFIABLE_CONDITION' : 'CONSTANT_COMPARISON').messageKey,
|
|
77
|
+
suggestions: [],
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
if (analysis.truth === 'true') {
|
|
81
|
+
return {
|
|
82
|
+
code: 'CONSTANT_COMPARISON',
|
|
83
|
+
path,
|
|
84
|
+
detail: `${subject} is always true, so this field is required on every record; replace \`requiredWhen\` with \`required: true\`, or state the branch that should require it`,
|
|
85
|
+
messageKey: diagnosticDoc('CONSTANT_COMPARISON').messageKey,
|
|
86
|
+
suggestions: [],
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
return {
|
|
90
|
+
code: analysis.shape === 'connector' ? 'UNSATISFIABLE_CONDITION' : 'CONSTANT_COMPARISON',
|
|
91
|
+
path,
|
|
92
|
+
detail: `${subject} can never be true, so this field is never required; correct the bounds, or remove \`requiredWhen\``,
|
|
93
|
+
messageKey: diagnosticDoc(analysis.shape === 'connector' ? 'UNSATISFIABLE_CONDITION' : 'CONSTANT_COMPARISON').messageKey,
|
|
94
|
+
suggestions: [],
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
/** One expression slot, parsed when it is authored and typed either way. */
|
|
98
|
+
export function compileExpressionSlot(compilation, value, path, scope) {
|
|
99
|
+
let node;
|
|
100
|
+
let offsets;
|
|
101
|
+
let powerOperators;
|
|
102
|
+
let lengthProperties;
|
|
103
|
+
if (typeof value === 'string') {
|
|
104
|
+
try {
|
|
105
|
+
const parsed = parseExpression(value);
|
|
106
|
+
node = parsed.node;
|
|
107
|
+
// The authored offsets are the checker's too, so a warning names the operand's place in
|
|
108
|
+
// the source rather than the start of the expression.
|
|
109
|
+
offsets = parsed.offsets;
|
|
110
|
+
powerOperators = parsed.powerOperators;
|
|
111
|
+
lengthProperties = parsed.lengthProperties;
|
|
112
|
+
compilation.warnings.push(...deprecationWarnings(parsed.deprecations, path));
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
if (!(error instanceof ExpressionCompileError))
|
|
116
|
+
throw error;
|
|
117
|
+
refuse(compilation, error.diagnostic.code, path, refusalDetail(error.diagnostic), refusalExtra(error.diagnostic));
|
|
118
|
+
return undefined;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
else if (isRecord(value)) {
|
|
122
|
+
// The metaschema admits a node whose `kind` names one variant and whose members belong to
|
|
123
|
+
// another, so the document is narrowed here rather than asserted; the checker then proves
|
|
124
|
+
// the language. A node outside the union is an authoring defect, so it is a diagnostic
|
|
125
|
+
// rather than a stack trace.
|
|
126
|
+
try {
|
|
127
|
+
node = exprNodeOf(value, path);
|
|
128
|
+
}
|
|
129
|
+
catch (error) {
|
|
130
|
+
// Only the boundary's own refusal is a document defect; anything else is a bug in this
|
|
131
|
+
// compiler and must not be reported as an author's mistake.
|
|
132
|
+
if (!(error instanceof MalformedCompiledNode))
|
|
133
|
+
throw error;
|
|
134
|
+
refuse(compilation, 'EXPR_PARSE_ERROR', path, error.message);
|
|
135
|
+
return undefined;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
return undefined;
|
|
140
|
+
}
|
|
141
|
+
// A `datasetRef` names the table and the version it pins, but not its kind, columns or clock
|
|
142
|
+
// binding, so an expression that reads one is only checkable with the compiled declaration in
|
|
143
|
+
// hand. The declaration has to be the pinned version: the artifact carries the pin, and typing a
|
|
144
|
+
// rule against another version compiles an artifact its own runtime refuses as `STALE_DATA`.
|
|
145
|
+
for (const tableId of datasetTableNames(node)) {
|
|
146
|
+
if (!compilation.declaredTables.has(tableId))
|
|
147
|
+
continue;
|
|
148
|
+
if (!compilation.suppliedTables.has(tableId)) {
|
|
149
|
+
refuse(compilation, 'DATASET_DECLARATION_MISSING', path, `this expression reads table \`${tableId}\`, which the document's \`datasets\` member pins but no compiled declaration describes; pass that declaration with ${DATASET_DECLARATION_CHANNELS}`);
|
|
150
|
+
return undefined;
|
|
151
|
+
}
|
|
152
|
+
const pin = compilation.pinnedVersions.get(tableId);
|
|
153
|
+
const supplied = compilation.suppliedVersions.get(tableId) ?? new Set();
|
|
154
|
+
if (pin === undefined || supplied.has(pin))
|
|
155
|
+
continue;
|
|
156
|
+
const versions = [...supplied].sort((left, right) => left - right);
|
|
157
|
+
const stated = versions.length === 0
|
|
158
|
+
? 'no version'
|
|
159
|
+
: `version${versions.length === 1 ? '' : 's'} ${versions.join(', ')}`;
|
|
160
|
+
refuse(compilation, 'DATASET_DECLARATION_MISSING', path, `this expression reads table \`${tableId}\`, which the document's \`datasets\` member pins to version ${String(pin)}, but the supplied declaration states ${stated}; pass the declaration compiled for that version with ${DATASET_DECLARATION_CHANNELS}`);
|
|
161
|
+
return undefined;
|
|
162
|
+
}
|
|
163
|
+
// A pure computed field is a definition, so the value pass reads what the author wrote there
|
|
164
|
+
// rather than only the field's declared type. Substitution is for analysis: the emitted slot
|
|
165
|
+
// keeps the path the runtime evaluates, and the checker types that emitted tree first so
|
|
166
|
+
// check-time lowerings (`in`-to-`contains`, `.length`-to-`len`) land on the emitted node before
|
|
167
|
+
// the substituted analysis copy is built for the value and lint passes.
|
|
168
|
+
let inlined;
|
|
169
|
+
try {
|
|
170
|
+
// The budget bounds a compiled expression too: a document arrives in the compiled
|
|
171
|
+
// form as well as the authored one, and the metaschema cannot count nodes or depth.
|
|
172
|
+
checkExpressionBudget(node);
|
|
173
|
+
const emittedFindings = [];
|
|
174
|
+
const lint = [];
|
|
175
|
+
const type = checkExpression(compilation.declarations, node, offsets ?? new WeakMap(), {
|
|
176
|
+
// An item-scoped expression may read its row through `$it`, so the binder is decided
|
|
177
|
+
// from the declaration that owns the slot.
|
|
178
|
+
...(scope === undefined ? {} : { itemFieldId: scope }),
|
|
179
|
+
// A finding is advice about authored source. The compiled form is machine-made, so it
|
|
180
|
+
// is not reported back to the author as something to rewrite.
|
|
181
|
+
...(offsets === undefined
|
|
182
|
+
? {}
|
|
183
|
+
: { onUndecidedFold: (finding) => emittedFindings.push(finding) }),
|
|
184
|
+
// The build's own switch reaches every expression slot, authored or compiled, so a
|
|
185
|
+
// pattern cannot enter an artifact through a form that skipped the option.
|
|
186
|
+
allowRegex: compilation.allowRegex,
|
|
187
|
+
}, powerOperators, lengthProperties);
|
|
188
|
+
const resolvedInline = inlineExpression(node, compilation.computed, offsets);
|
|
189
|
+
inlined = resolvedInline;
|
|
190
|
+
const analysisNode = resolvedInline.node;
|
|
191
|
+
checkExpressionBudget(analysisNode);
|
|
192
|
+
let findings = emittedFindings;
|
|
193
|
+
// Lint and undecided-fold analysis read the substituted tree, where pure computed definitions
|
|
194
|
+
// (such as a non-empty list literal or constant bounds) are visible, while keeping the read
|
|
195
|
+
// site offsets recorded by `inlineExpression`.
|
|
196
|
+
if (offsets !== undefined) {
|
|
197
|
+
const analysisScope = {
|
|
198
|
+
...(scope === undefined ? {} : { itemFieldId: scope }),
|
|
199
|
+
allowRegex: compilation.allowRegex,
|
|
200
|
+
...(resolvedInline.inlinedNodes === undefined
|
|
201
|
+
? {}
|
|
202
|
+
: { inlinedNodes: resolvedInline.inlinedNodes }),
|
|
203
|
+
};
|
|
204
|
+
const analysisOffsets = resolvedInline.offsets ?? offsets;
|
|
205
|
+
if (resolvedInline.uses.length > 0) {
|
|
206
|
+
findings =
|
|
207
|
+
undecidedFolds(compilation.declarations, analysisNode, analysisOffsets, analysisScope) ??
|
|
208
|
+
emittedFindings;
|
|
209
|
+
}
|
|
210
|
+
lintExpression(compilation.declarations, analysisNode, analysisOffsets, (finding) => lint.push(finding), analysisScope);
|
|
211
|
+
}
|
|
212
|
+
compilation.warnings.push(...undecidedWarnings(findings, path).map((warning) => ({
|
|
213
|
+
...warning,
|
|
214
|
+
detail: withInlineDetail(warning.detail, resolvedInline),
|
|
215
|
+
})));
|
|
216
|
+
const declaration = declarationConditionWarning(compilation, path, analysisNode, value, scope);
|
|
217
|
+
const slotWarnings = lintWarnings(lint, path).map((warning) => ({
|
|
218
|
+
...warning,
|
|
219
|
+
detail: withInlineDetail(warning.detail, resolvedInline),
|
|
220
|
+
}));
|
|
221
|
+
compilation.warnings.push(...slotWarnings.filter((warning) => declaration === undefined || warning.path !== declaration.path));
|
|
222
|
+
if (declaration !== undefined) {
|
|
223
|
+
compilation.warnings.push({
|
|
224
|
+
...declaration,
|
|
225
|
+
detail: withInlineDetail(declaration.detail, resolvedInline),
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
return { node, type, analysisNode };
|
|
229
|
+
}
|
|
230
|
+
catch (error) {
|
|
231
|
+
if (!(error instanceof ExpressionCompileError))
|
|
232
|
+
throw error;
|
|
233
|
+
const provenance = inlined ?? inlineExpression(node, compilation.computed, offsets);
|
|
234
|
+
refuse(compilation, error.diagnostic.code, path, withInlineDetail(refusalDetail(error.diagnostic), provenance), refusalExtra(error.diagnostic));
|
|
235
|
+
return undefined;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
/** The declared field one message parameter's direct path names, when it names one. */
|
|
239
|
+
function paramFieldOf(compilation, itemFieldId, path) {
|
|
240
|
+
if (!path.startsWith('$'))
|
|
241
|
+
return compilation.declaredFieldPaths.get(path)?.fieldId;
|
|
242
|
+
const [head, ...rest] = path.split('.');
|
|
243
|
+
if (head === undefined || rest.length === 0 || itemFieldId === undefined)
|
|
244
|
+
return undefined;
|
|
245
|
+
// `$i` is the row's position, not a member: a row key is never an option field.
|
|
246
|
+
if (head !== '$it' && head !== '$prev' && head !== '$next' && head !== '$row') {
|
|
247
|
+
return undefined;
|
|
248
|
+
}
|
|
249
|
+
const itemPath = compilation.declaredPathsById.get(itemFieldId);
|
|
250
|
+
if (itemPath === undefined)
|
|
251
|
+
return undefined;
|
|
252
|
+
return compilation.declaredFieldPaths.get(`${itemPath}.${rest.join('.')}`)?.fieldId;
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* The message arguments one authored parameter block binds, compiled behind the owner's row scope
|
|
256
|
+
* and appended to the owner's expression slots.
|
|
257
|
+
*
|
|
258
|
+
* `member` names the block the author wrote, so a refusal points at the member that holds it: a
|
|
259
|
+
* rule's `params`, or an option's `unavailableParams` (`RULES-7.1.1`).
|
|
260
|
+
*/
|
|
261
|
+
export function compileParams(compilation, authored, at, itemScope, slots, member = 'params') {
|
|
262
|
+
const nodes = {};
|
|
263
|
+
const paramFields = new Map();
|
|
264
|
+
const unparsedParams = new Set();
|
|
265
|
+
if (!isRecord(authored))
|
|
266
|
+
return { nodes, paramFields };
|
|
267
|
+
for (const [name, node] of Object.entries(authored)) {
|
|
268
|
+
const path = `${at}.${member}.${name}`;
|
|
269
|
+
const compiled = compileExpressionSlot(compilation, node, path, itemScope);
|
|
270
|
+
if (compiled === undefined) {
|
|
271
|
+
unparsedParams.add(name);
|
|
272
|
+
continue;
|
|
273
|
+
}
|
|
274
|
+
nodes[name] = compiled.node;
|
|
275
|
+
if (compiled.node.kind === 'path') {
|
|
276
|
+
const boundField = paramFieldOf(compilation, itemScope, compiled.node.path);
|
|
277
|
+
if (boundField !== undefined)
|
|
278
|
+
paramFields.set(name, boundField);
|
|
279
|
+
}
|
|
280
|
+
slots.push({ path, node: compiled.node });
|
|
281
|
+
}
|
|
282
|
+
return {
|
|
283
|
+
nodes,
|
|
284
|
+
paramFields,
|
|
285
|
+
...(unparsedParams.size === 0 ? {} : { unparsedParams }),
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
//# sourceMappingURL=expression.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expression.js","sourceRoot":"","sources":["../../src/compile/expression.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAEjE,OAAO,EAAE,UAAU,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAEhE,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEvF,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAExD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAE5D,OAAO,EAAE,4BAA4B,EAAE,MAAM,kCAAkC,CAAC;AAGhF,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAGlD,oFAAoF;AACpF,SAAS,YAAY,CACnB,UAA0B;IAE1B,OAAO;QACL,MAAM,EAAE,UAAU,CAAC,MAAM;QACzB,wFAAwF;QACxF,gFAAgF;QAChF,YAAY,EAAE,YAAY;QAC1B,GAAG,CAAC,UAAU,CAAC,WAAW,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,UAAU,CAAC,WAAW,EAAE,CAAC;QACvF,GAAG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AK,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC;QAC5B,IAAI,QAAQ,CAAC,IAAI,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;YAClC,MAAM,UAAU,GAAG,YAAY,CAAC,WAAW,EAAE,SAAS,EAAE,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC5E,IAAI,UAAU,KAAK,SAAS;gBAAE,WAAW,CAAC,GAAG,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QAClE,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;IAC5C,CAAC;IACD,OAAO;QACL,KAAK;QACL,WAAW;QACX,GAAG,CAAC,cAAc,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,CAAC;KACzD,CAAC;AACJ,CAAC","sourcesContent":["import { diagnosticDoc, isRecord } from '@azx-pbc/axiom-runtime';\nimport type { ExprNode } from '@azx-pbc/axiom-runtime';\nimport { exprNodeOf, MalformedCompiledNode } from '../expr/boundary.js';\nimport { deprecationWarnings } from '../expr/deprecation.js';\nimport { ExpressionCompileError } from '../expr/diagnostics.js';\nimport type { ExprDiagnostic } from '../expr/diagnostics.js';\nimport { checkExpressionBudget, parseExpression } from '../expr/parser.js';\nimport { checkExpression, lintExpression, undecidedFolds } from '../expr/typecheck.js';\nimport type { StaticType, UndecidedFold } from '../expr/typecheck.js';\nimport { lintWarnings } from '../expr/lint-warnings.js';\nimport type { LintFinding } from '../expr/lint.js';\nimport { undecidedWarnings } from '../expr/undecided.js';\nimport { analyzeExpression } from '../expr/values/interval.js';\nimport { inlineExpression } from '../expr/values/inline.js';\nimport type { InlineResult } from '../expr/values/inline.js';\nimport { DATASET_DECLARATION_CHANNELS } from '../schema/dataset-declaration.js';\nimport type { SchemaDiagnostic } from '../schema/validate.js';\nimport type { Compilation } from './compilation.js';\nimport { refuse } from './compilation.js';\nimport { datasetTableNames } from './datasets.js';\nimport type { CompileWarning } from './warning.js';\n\n/** One expression refusal's structured metadata, for the caller that repairs it. */\nfunction refusalExtra(\n diagnostic: ExprDiagnostic,\n): Omit<SchemaDiagnostic, 'code' | 'path' | 'detail'> {\n return {\n offset: diagnostic.offset,\n // An expression offset indexes the expression source in this slot, not the document the\n // command read, so a reporter must not turn it into a document line and column.\n offsetSource: 'expression',\n ...(diagnostic.suggestions.length === 0 ? {} : { suggestions: diagnostic.suggestions }),\n ...(diagnostic.expected === undefined ? {} : { expected: diagnostic.expected }),\n };\n}\n\n/** One expression refusal as the compiler reports it, with its bounded suggestions. */\nfunction refusalDetail(diagnostic: ExprDiagnostic): string {\n if (diagnostic.suggestions.length === 0) return diagnostic.detail;\n return `${diagnostic.detail}; did you mean ${diagnostic.suggestions.join(' or ')}?`;\n}\n\n/** One expression slot: the compiled node and the static type it was given. */\ninterface CompiledSlot {\n readonly node: ExprNode;\n readonly type: StaticType;\n /** The same slot with pure computed definitions inlined, for analysis only. */\n readonly analysisNode: ExprNode;\n}\n\n/** Where a definition was inlined, and why one was not, for a diagnostic's detail. */\nfunction inlineDetail(inline: InlineResult): string {\n const parts: string[] = [];\n if (inline.uses.length > 0) {\n const uses = inline.uses.map(\n (use) => `\\`${use.fieldId}\\` (defined at ${use.path}, rule \\`${use.ruleId}\\`)`,\n );\n parts.push(`this expression reads ${uses.join(' and ')}`);\n }\n parts.push(...inline.notes);\n return parts.join('; ');\n}\n\nfunction withInlineDetail(detail: string, inline: InlineResult): string {\n const suffix = inlineDetail(inline);\n return suffix === '' ? detail : `${detail}; ${suffix}`;\n}\n\nfunction sourceOf(value: unknown): string | undefined {\n return typeof value === 'string' ? value : undefined;\n}\n\n/** The declaration condition warning the slot's own role earns, if any. */\nfunction declarationConditionWarning(\n compilation: Compilation,\n path: string,\n node: ExprNode,\n value: unknown,\n scope: string | undefined,\n): CompileWarning | undefined {\n const role = path.endsWith('.visibleWhen')\n ? 'visibleWhen'\n : path.endsWith('.requiredWhen')\n ? 'requiredWhen'\n : undefined;\n if (role === undefined) return undefined;\n const analysis = analyzeExpression(compilation.declarations, node, scope);\n if (!analysis.derived || analysis.truth === 'unknown') return undefined;\n const source = sourceOf(value);\n const subject = source === undefined ? `this \\`${role}\\` condition` : `\\`${source}\\``;\n if (role === 'visibleWhen') {\n if (analysis.truth === 'true') {\n return {\n code: 'CONSTANT_COMPARISON',\n path,\n detail: `${subject} is always true, so this field is visible on every record; remove \\`visibleWhen\\`, or state the branch that should hide it`,\n messageKey: diagnosticDoc('CONSTANT_COMPARISON').messageKey,\n suggestions: [],\n };\n }\n return {\n code: analysis.shape === 'connector' ? 'UNSATISFIABLE_CONDITION' : 'CONSTANT_COMPARISON',\n path,\n detail: `${subject} can never be true, so this field is never visible; correct the bounds, or remove \\`visibleWhen\\``,\n messageKey: diagnosticDoc(\n analysis.shape === 'connector' ? 'UNSATISFIABLE_CONDITION' : 'CONSTANT_COMPARISON',\n ).messageKey,\n suggestions: [],\n };\n }\n if (analysis.truth === 'true') {\n return {\n code: 'CONSTANT_COMPARISON',\n path,\n detail: `${subject} is always true, so this field is required on every record; replace \\`requiredWhen\\` with \\`required: true\\`, or state the branch that should require it`,\n messageKey: diagnosticDoc('CONSTANT_COMPARISON').messageKey,\n suggestions: [],\n };\n }\n return {\n code: analysis.shape === 'connector' ? 'UNSATISFIABLE_CONDITION' : 'CONSTANT_COMPARISON',\n path,\n detail: `${subject} can never be true, so this field is never required; correct the bounds, or remove \\`requiredWhen\\``,\n messageKey: diagnosticDoc(\n analysis.shape === 'connector' ? 'UNSATISFIABLE_CONDITION' : 'CONSTANT_COMPARISON',\n ).messageKey,\n suggestions: [],\n };\n}\n\n/** One expression slot, parsed when it is authored and typed either way. */\nexport function compileExpressionSlot(\n compilation: Compilation,\n value: unknown,\n path: string,\n scope?: string,\n): CompiledSlot | undefined {\n let node: ExprNode;\n let offsets: WeakMap<ExprNode, number> | undefined;\n let powerOperators: WeakSet<ExprNode> | undefined;\n let lengthProperties: WeakSet<ExprNode> | undefined;\n if (typeof value === 'string') {\n try {\n const parsed = parseExpression(value);\n node = parsed.node;\n // The authored offsets are the checker's too, so a warning names the operand's place in\n // the source rather than the start of the expression.\n offsets = parsed.offsets;\n powerOperators = parsed.powerOperators;\n lengthProperties = parsed.lengthProperties;\n compilation.warnings.push(...deprecationWarnings(parsed.deprecations, path));\n } catch (error) {\n if (!(error instanceof ExpressionCompileError)) throw error;\n refuse(\n compilation,\n error.diagnostic.code,\n path,\n refusalDetail(error.diagnostic),\n refusalExtra(error.diagnostic),\n );\n return undefined;\n }\n } else if (isRecord(value)) {\n // The metaschema admits a node whose `kind` names one variant and whose members belong to\n // another, so the document is narrowed here rather than asserted; the checker then proves\n // the language. A node outside the union is an authoring defect, so it is a diagnostic\n // rather than a stack trace.\n try {\n node = exprNodeOf(value, path);\n } catch (error) {\n // Only the boundary's own refusal is a document defect; anything else is a bug in this\n // compiler and must not be reported as an author's mistake.\n if (!(error instanceof MalformedCompiledNode)) throw error;\n refuse(compilation, 'EXPR_PARSE_ERROR', path, error.message);\n return undefined;\n }\n } else {\n return undefined;\n }\n // A `datasetRef` names the table and the version it pins, but not its kind, columns or clock\n // binding, so an expression that reads one is only checkable with the compiled declaration in\n // hand. The declaration has to be the pinned version: the artifact carries the pin, and typing a\n // rule against another version compiles an artifact its own runtime refuses as `STALE_DATA`.\n for (const tableId of datasetTableNames(node)) {\n if (!compilation.declaredTables.has(tableId)) continue;\n if (!compilation.suppliedTables.has(tableId)) {\n refuse(\n compilation,\n 'DATASET_DECLARATION_MISSING',\n path,\n `this expression reads table \\`${tableId}\\`, which the document's \\`datasets\\` member pins but no compiled declaration describes; pass that declaration with ${DATASET_DECLARATION_CHANNELS}`,\n );\n return undefined;\n }\n const pin = compilation.pinnedVersions.get(tableId);\n const supplied = compilation.suppliedVersions.get(tableId) ?? new Set<number>();\n if (pin === undefined || supplied.has(pin)) continue;\n const versions = [...supplied].sort((left, right) => left - right);\n const stated =\n versions.length === 0\n ? 'no version'\n : `version${versions.length === 1 ? '' : 's'} ${versions.join(', ')}`;\n refuse(\n compilation,\n 'DATASET_DECLARATION_MISSING',\n path,\n `this expression reads table \\`${tableId}\\`, which the document's \\`datasets\\` member pins to version ${String(pin)}, but the supplied declaration states ${stated}; pass the declaration compiled for that version with ${DATASET_DECLARATION_CHANNELS}`,\n );\n return undefined;\n }\n // A pure computed field is a definition, so the value pass reads what the author wrote there\n // rather than only the field's declared type. Substitution is for analysis: the emitted slot\n // keeps the path the runtime evaluates, and the checker types that emitted tree first so\n // check-time lowerings (`in`-to-`contains`, `.length`-to-`len`) land on the emitted node before\n // the substituted analysis copy is built for the value and lint passes.\n let inlined: InlineResult | undefined;\n try {\n // The budget bounds a compiled expression too: a document arrives in the compiled\n // form as well as the authored one, and the metaschema cannot count nodes or depth.\n checkExpressionBudget(node);\n const emittedFindings: UndecidedFold[] = [];\n const lint: LintFinding[] = [];\n const type = checkExpression(\n compilation.declarations,\n node,\n offsets ?? new WeakMap(),\n {\n // An item-scoped expression may read its row through `$it`, so the binder is decided\n // from the declaration that owns the slot.\n ...(scope === undefined ? {} : { itemFieldId: scope }),\n // A finding is advice about authored source. The compiled form is machine-made, so it\n // is not reported back to the author as something to rewrite.\n ...(offsets === undefined\n ? {}\n : { onUndecidedFold: (finding) => emittedFindings.push(finding) }),\n // The build's own switch reaches every expression slot, authored or compiled, so a\n // pattern cannot enter an artifact through a form that skipped the option.\n allowRegex: compilation.allowRegex,\n },\n powerOperators,\n lengthProperties,\n );\n const resolvedInline = inlineExpression(node, compilation.computed, offsets);\n inlined = resolvedInline;\n const analysisNode = resolvedInline.node;\n checkExpressionBudget(analysisNode);\n let findings: readonly UndecidedFold[] = emittedFindings;\n // Lint and undecided-fold analysis read the substituted tree, where pure computed definitions\n // (such as a non-empty list literal or constant bounds) are visible, while keeping the read\n // site offsets recorded by `inlineExpression`.\n if (offsets !== undefined) {\n const analysisScope = {\n ...(scope === undefined ? {} : { itemFieldId: scope }),\n allowRegex: compilation.allowRegex,\n ...(resolvedInline.inlinedNodes === undefined\n ? {}\n : { inlinedNodes: resolvedInline.inlinedNodes }),\n };\n const analysisOffsets = resolvedInline.offsets ?? offsets;\n if (resolvedInline.uses.length > 0) {\n findings =\n undecidedFolds(compilation.declarations, analysisNode, analysisOffsets, analysisScope) ??\n emittedFindings;\n }\n lintExpression(\n compilation.declarations,\n analysisNode,\n analysisOffsets,\n (finding) => lint.push(finding),\n analysisScope,\n );\n }\n compilation.warnings.push(\n ...undecidedWarnings(findings, path).map((warning) => ({\n ...warning,\n detail: withInlineDetail(warning.detail, resolvedInline),\n })),\n );\n const declaration = declarationConditionWarning(compilation, path, analysisNode, value, scope);\n const slotWarnings = lintWarnings(lint, path).map((warning) => ({\n ...warning,\n detail: withInlineDetail(warning.detail, resolvedInline),\n }));\n compilation.warnings.push(\n ...slotWarnings.filter(\n (warning) => declaration === undefined || warning.path !== declaration.path,\n ),\n );\n if (declaration !== undefined) {\n compilation.warnings.push({\n ...declaration,\n detail: withInlineDetail(declaration.detail, resolvedInline),\n });\n }\n return { node, type, analysisNode };\n } catch (error) {\n if (!(error instanceof ExpressionCompileError)) throw error;\n const provenance = inlined ?? inlineExpression(node, compilation.computed, offsets);\n refuse(\n compilation,\n error.diagnostic.code,\n path,\n withInlineDetail(refusalDetail(error.diagnostic), provenance),\n refusalExtra(error.diagnostic),\n );\n return undefined;\n }\n}\n\n/** The declared field one message parameter's direct path names, when it names one. */\nfunction paramFieldOf(\n compilation: Compilation,\n itemFieldId: string | undefined,\n path: string,\n): string | undefined {\n if (!path.startsWith('$')) return compilation.declaredFieldPaths.get(path)?.fieldId;\n const [head, ...rest] = path.split('.');\n if (head === undefined || rest.length === 0 || itemFieldId === undefined) return undefined;\n // `$i` is the row's position, not a member: a row key is never an option field.\n if (head !== '$it' && head !== '$prev' && head !== '$next' && head !== '$row') {\n return undefined;\n }\n const itemPath = compilation.declaredPathsById.get(itemFieldId);\n if (itemPath === undefined) return undefined;\n return compilation.declaredFieldPaths.get(`${itemPath}.${rest.join('.')}`)?.fieldId;\n}\n\n/** The expression slots one message's arguments bind, and the field each names. */\nexport interface CompiledMessageBinding {\n readonly nodes: Readonly<Record<string, ExprNode>>;\n readonly paramFields: ReadonlyMap<string, string>;\n /**\n * The names whose expression was refused on its own.\n *\n * The parse is the diagnostic an author must fix; the message check must not then report\n * the same parameter again as \"not bound\", which would send them looking for a binding\n * defect that does not exist. Absent when every parameter parsed.\n */\n readonly unparsedParams?: ReadonlySet<string>;\n}\n\n/**\n * The message arguments one authored parameter block binds, compiled behind the owner's row scope\n * and appended to the owner's expression slots.\n *\n * `member` names the block the author wrote, so a refusal points at the member that holds it: a\n * rule's `params`, or an option's `unavailableParams` (`RULES-7.1.1`).\n */\nexport function compileParams(\n compilation: Compilation,\n authored: unknown,\n at: string,\n itemScope: string | undefined,\n slots: { path: string; node: ExprNode }[],\n member = 'params',\n): CompiledMessageBinding {\n const nodes: Record<string, ExprNode> = {};\n const paramFields = new Map<string, string>();\n const unparsedParams = new Set<string>();\n if (!isRecord(authored)) return { nodes, paramFields };\n for (const [name, node] of Object.entries(authored)) {\n const path = `${at}.${member}.${name}`;\n const compiled = compileExpressionSlot(compilation, node, path, itemScope);\n if (compiled === undefined) {\n unparsedParams.add(name);\n continue;\n }\n nodes[name] = compiled.node;\n if (compiled.node.kind === 'path') {\n const boundField = paramFieldOf(compilation, itemScope, compiled.node.path);\n if (boundField !== undefined) paramFields.set(name, boundField);\n }\n slots.push({ path, node: compiled.node });\n }\n return {\n nodes,\n paramFields,\n ...(unparsedParams.size === 0 ? {} : { unparsedParams }),\n };\n}\n"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { CallNode, ExprNode } from '@azx-pbc/axiom-runtime';
|
|
2
|
+
/** An `==` comparison between a recomputed binding and one signature's stored `dataHash`. */
|
|
3
|
+
export interface HashComparison {
|
|
4
|
+
/** The `digest(...)` call side, when the comparison recomputes one. */
|
|
5
|
+
readonly digest: CallNode | undefined;
|
|
6
|
+
readonly signer: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Every comparison of a stored signature hash in this slot, with the digest that recomputes it.
|
|
10
|
+
*
|
|
11
|
+
* Only a comparison position is a verification: a digest computed beside one but never compared
|
|
12
|
+
* to a stored hash answers something else. Collecting the pairs — rather than every digest and
|
|
13
|
+
* every signer in the slot — makes the check non-existential, and a comparison that recomputes
|
|
14
|
+
* nothing is itself a defect: nothing then states which targets the value it trusts was computed
|
|
15
|
+
* over, so a digest in another rule could bind anything.
|
|
16
|
+
*/
|
|
17
|
+
export declare function hashComparisons(node: ExprNode, into?: HashComparison[]): readonly HashComparison[];
|
|
18
|
+
/** The `fieldId` each target of a `digest(...)` call binds, in declared order. */
|
|
19
|
+
export declare function digestTargets(node: CallNode): readonly string[] | undefined;
|
|
20
|
+
/** Whether a `digest` binds the artifact's dynamic schema version. */
|
|
21
|
+
export declare function bindsArtifactVersion(node: CallNode): boolean;
|
|
22
|
+
/** Whether two coverage lists name the same targets in the same order. */
|
|
23
|
+
export declare function sameTargets(left: readonly string[], right: readonly string[]): boolean;
|
|
24
|
+
/** Every target list one expression's digests bind, rendered for a refusal. */
|
|
25
|
+
export declare function describeTargets(digests: readonly (readonly string[])[]): string;
|
|
26
|
+
//# sourceMappingURL=hashes.d.ts.map
|