@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,244 @@
|
|
|
1
|
+
import { assertNever, declaredFieldExpressions, isRecord, ruleExpressions, } from '@azx-pbc/axiom-runtime';
|
|
2
|
+
import { listAt, textAt } from './document.js';
|
|
3
|
+
/**
|
|
4
|
+
* The constructs that can only be inert, reported as advice rather than as a refusal.
|
|
5
|
+
*
|
|
6
|
+
* The principle: a diagnostic refuses a document only when the document alone proves the
|
|
7
|
+
* construct cannot mean what it appears to. An inert construct is not that proof. A constant
|
|
8
|
+
* `visible: false` hides a field on purpose and a `compute: false` writes a constant; an
|
|
9
|
+
* unplaced field may be rendered by a host or read by a rule; an instruction-only step is a
|
|
10
|
+
* legitimate page. What remains after those are set aside is dead weight: a step that places
|
|
11
|
+
* nothing at all (`EMPTY_STEP`) and a field a declared layout never places and nothing reads
|
|
12
|
+
* (`UNUSED_FIELD`). A rule whose condition is literally `false` is the same kind of finding and
|
|
13
|
+
* states `UNSATISFIABLE_CONDITION` through `condition-warnings`, because the expression lint
|
|
14
|
+
* already proves it and one path earns one warning. The compiler names each with a warning code,
|
|
15
|
+
* so a host shows it beside the artifact without refusing the author's edit.
|
|
16
|
+
*
|
|
17
|
+
* A message key declared and never named is deliberately **not** warned about. The catalogue is
|
|
18
|
+
* part of the artifact a host may address directly, and an author may declare a key ahead of the
|
|
19
|
+
* slot that names it; a warning would penalise staged authoring for a construct the document
|
|
20
|
+
* cannot prove is a mistake.
|
|
21
|
+
*/
|
|
22
|
+
/** A warning that names a dead construct rather than a defect. */
|
|
23
|
+
export function deadWeightWarnings(document, entries, declared, layout, rawLayout, fields) {
|
|
24
|
+
return [
|
|
25
|
+
...emptyStepWarnings(rawLayout),
|
|
26
|
+
...unusedFieldWarnings(document, entries, declared, layout, rawLayout, fields),
|
|
27
|
+
];
|
|
28
|
+
}
|
|
29
|
+
/** One warning, with the members the compiler's warning contract states. */
|
|
30
|
+
function warning(code, path, detail, messageKey) {
|
|
31
|
+
return { code, path, detail, messageKey, suggestions: [] };
|
|
32
|
+
}
|
|
33
|
+
/** Every step node that places nothing at all. A step holding chrome is instruction-only. */
|
|
34
|
+
function emptyStepWarnings(rawLayout) {
|
|
35
|
+
const warnings = [];
|
|
36
|
+
const visit = (nodes) => {
|
|
37
|
+
for (const node of nodes) {
|
|
38
|
+
if (node.kind === 'step' && node.children.length === 0) {
|
|
39
|
+
warnings.push(warning('EMPTY_STEP', node.path, `step \`${node.stepId ?? node.path}\` places no node, so it renders an empty page; remove the step or place the fields and chrome it should show`, 'compiler.warning.empty_step'));
|
|
40
|
+
}
|
|
41
|
+
visit(node.children);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
visit(rawLayout);
|
|
45
|
+
return warnings;
|
|
46
|
+
}
|
|
47
|
+
/** Every field id a compiled expression reads as a path, by its first segment. */
|
|
48
|
+
function collectPathRoots(node, into) {
|
|
49
|
+
switch (node.kind) {
|
|
50
|
+
case 'literal':
|
|
51
|
+
return;
|
|
52
|
+
case 'path': {
|
|
53
|
+
// `$it.f_x` is a row member, not a top-level field. A nested record member
|
|
54
|
+
// (`f_record.f_code`) references the container that holds it.
|
|
55
|
+
const [root] = node.path.split('.');
|
|
56
|
+
if (root !== undefined && !root.startsWith('$'))
|
|
57
|
+
into.add(root);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
case 'list':
|
|
61
|
+
for (const item of node.items)
|
|
62
|
+
collectPathRoots(item, into);
|
|
63
|
+
return;
|
|
64
|
+
case 'comprehension':
|
|
65
|
+
collectPathRoots(node.source, into);
|
|
66
|
+
if (node.valueExpr !== undefined)
|
|
67
|
+
collectPathRoots(node.valueExpr, into);
|
|
68
|
+
if (node.predicate !== undefined)
|
|
69
|
+
collectPathRoots(node.predicate, into);
|
|
70
|
+
return;
|
|
71
|
+
default:
|
|
72
|
+
for (const arg of node.args)
|
|
73
|
+
collectPathRoots(arg, into);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/** Every layout node's expression slots, and the read-only fields a summary card lists. */
|
|
77
|
+
function collectLayoutReferences(layout, fields, readOnlyFields) {
|
|
78
|
+
for (const node of layout) {
|
|
79
|
+
if ('visibleWhen' in node && node.visibleWhen !== undefined) {
|
|
80
|
+
collectPathRoots(node.visibleWhen, fields);
|
|
81
|
+
}
|
|
82
|
+
if ('params' in node && node.params !== undefined) {
|
|
83
|
+
for (const expression of Object.values(node.params))
|
|
84
|
+
collectPathRoots(expression, fields);
|
|
85
|
+
}
|
|
86
|
+
if (node.kind === 'summary_card') {
|
|
87
|
+
for (const readout of node.readouts ?? [])
|
|
88
|
+
collectPathRoots(readout.value, fields);
|
|
89
|
+
for (const fieldId of node.fields ?? [])
|
|
90
|
+
readOnlyFields.add(fieldId);
|
|
91
|
+
}
|
|
92
|
+
if ('children' in node)
|
|
93
|
+
collectLayoutReferences(node.children, fields, readOnlyFields);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Every field an alternative names: the binding a write addresses, or the array whose rows it
|
|
98
|
+
* changes.
|
|
99
|
+
*
|
|
100
|
+
* An alternative is data a host applies, so a field it writes is as declared-and-used as a
|
|
101
|
+
* writer's target, whether the owner is a rule or an option.
|
|
102
|
+
*/
|
|
103
|
+
function collectSuggestionTargets(suggestion, into) {
|
|
104
|
+
for (const operation of suggestion.operations) {
|
|
105
|
+
switch (operation.kind) {
|
|
106
|
+
case 'value':
|
|
107
|
+
case 'null':
|
|
108
|
+
case 'remove':
|
|
109
|
+
into.add(operation.ref.fieldId);
|
|
110
|
+
break;
|
|
111
|
+
case 'append':
|
|
112
|
+
case 'removeRow':
|
|
113
|
+
into.add(operation.fieldId);
|
|
114
|
+
break;
|
|
115
|
+
default:
|
|
116
|
+
assertNever(operation);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
/** Every field id one rule names as a target, reader or writer. */
|
|
121
|
+
function collectRuleTargets(rule, into) {
|
|
122
|
+
if (rule.fieldId !== undefined)
|
|
123
|
+
into.add(rule.fieldId);
|
|
124
|
+
if (rule.targetFieldId !== undefined)
|
|
125
|
+
into.add(rule.targetFieldId);
|
|
126
|
+
if (rule.overrideFieldId !== undefined)
|
|
127
|
+
into.add(rule.overrideFieldId);
|
|
128
|
+
for (const fieldId of rule.fieldIds ?? [])
|
|
129
|
+
into.add(fieldId);
|
|
130
|
+
for (const expression of ruleExpressions(rule))
|
|
131
|
+
collectPathRoots(expression, into);
|
|
132
|
+
for (const suggestion of rule.suggests ?? [])
|
|
133
|
+
collectSuggestionTargets(suggestion, into);
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Every field a declaration outside a rule names: the expression slots a field carries, and the
|
|
137
|
+
* bindings an option's alternative writes.
|
|
138
|
+
*
|
|
139
|
+
* A field's own expressions are reads like a rule's — an array's count, an option's availability
|
|
140
|
+
* condition and its reason arguments — so the shared slot walk answers them. An alternative is
|
|
141
|
+
* data a host applies, so a binding it writes keeps that field alive even though nothing reads it.
|
|
142
|
+
*/
|
|
143
|
+
function collectFieldTargets(fields, into) {
|
|
144
|
+
for (const slot of declaredFieldExpressions(fields))
|
|
145
|
+
collectPathRoots(slot.node, into);
|
|
146
|
+
const visit = (members) => {
|
|
147
|
+
for (const member of members) {
|
|
148
|
+
for (const option of member.options ?? []) {
|
|
149
|
+
for (const suggestion of option.suggests ?? []) {
|
|
150
|
+
collectSuggestionTargets(suggestion, into);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
if (member.fields !== undefined)
|
|
154
|
+
visit(member.fields);
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
visit(fields);
|
|
158
|
+
}
|
|
159
|
+
/** Every field a declaration names outside its own body: a source, dependency or coverage. */
|
|
160
|
+
function collectDeclarationReferences(document, into) {
|
|
161
|
+
const visit = (fields) => {
|
|
162
|
+
for (const field of fields) {
|
|
163
|
+
if (!isRecord(field))
|
|
164
|
+
continue;
|
|
165
|
+
const source = field['optionSource'];
|
|
166
|
+
if (isRecord(source)) {
|
|
167
|
+
const sourceField = textAt(source, 'fieldId');
|
|
168
|
+
if (sourceField !== undefined)
|
|
169
|
+
into.add(sourceField);
|
|
170
|
+
for (const dependency of listAt(source, 'dependsOn')) {
|
|
171
|
+
if (typeof dependency === 'string')
|
|
172
|
+
into.add(dependency);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
const rowKey = field['rowKey'];
|
|
176
|
+
if (isRecord(rowKey)) {
|
|
177
|
+
const keyField = textAt(rowKey, 'fieldId');
|
|
178
|
+
if (keyField !== undefined)
|
|
179
|
+
into.add(keyField);
|
|
180
|
+
}
|
|
181
|
+
for (const target of listAt(field, 'covers')) {
|
|
182
|
+
if (typeof target === 'string')
|
|
183
|
+
into.add(target);
|
|
184
|
+
}
|
|
185
|
+
visit(listAt(field, 'fields'));
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
visit(listAt(document, 'fields'));
|
|
189
|
+
}
|
|
190
|
+
/** Every field id a raw layout places, including a summary card's read-only list. */
|
|
191
|
+
function placedFieldIds(rawLayout) {
|
|
192
|
+
const placed = new Set();
|
|
193
|
+
const visit = (nodes) => {
|
|
194
|
+
for (const node of nodes) {
|
|
195
|
+
if (node.kind === 'field' && node.fieldId !== undefined)
|
|
196
|
+
placed.add(node.fieldId);
|
|
197
|
+
if (node.kind === 'summary_card') {
|
|
198
|
+
for (const fieldId of node.fields)
|
|
199
|
+
placed.add(fieldId);
|
|
200
|
+
}
|
|
201
|
+
visit(node.children);
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
visit(rawLayout);
|
|
205
|
+
return placed;
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* A top-level field a declared layout never places and nothing reads.
|
|
209
|
+
*
|
|
210
|
+
* The check is deliberately conservative. It runs only when a layout exists and places at least
|
|
211
|
+
* one field: a headless document is a first-class artifact a host renders from `fields`, and a
|
|
212
|
+
* chrome-only layout may be paired with host-rendered controls. Row members are left to the
|
|
213
|
+
* array that places them, and a field named by a rule, a writer, a message argument, a layout
|
|
214
|
+
* expression, a summary card or an array's row key counts as read. What remains is a declaration
|
|
215
|
+
* with no consumer at all.
|
|
216
|
+
*/
|
|
217
|
+
function unusedFieldWarnings(document, entries, declared, layout, rawLayout, fields) {
|
|
218
|
+
if (rawLayout.length === 0)
|
|
219
|
+
return [];
|
|
220
|
+
const placed = placedFieldIds(rawLayout);
|
|
221
|
+
if (placed.size === 0)
|
|
222
|
+
return [];
|
|
223
|
+
const referenced = new Set();
|
|
224
|
+
for (const entry of entries)
|
|
225
|
+
collectRuleTargets(entry.rule, referenced);
|
|
226
|
+
for (const rule of declared)
|
|
227
|
+
collectRuleTargets(rule, referenced);
|
|
228
|
+
collectLayoutReferences(layout, referenced, placed);
|
|
229
|
+
collectFieldTargets(fields, referenced);
|
|
230
|
+
collectDeclarationReferences(document, referenced);
|
|
231
|
+
const warnings = [];
|
|
232
|
+
listAt(document, 'fields').forEach((field, index) => {
|
|
233
|
+
if (!isRecord(field))
|
|
234
|
+
return;
|
|
235
|
+
const fieldId = textAt(field, 'fieldId');
|
|
236
|
+
if (fieldId === undefined)
|
|
237
|
+
return;
|
|
238
|
+
if (placed.has(fieldId) || referenced.has(fieldId))
|
|
239
|
+
return;
|
|
240
|
+
warnings.push(warning('UNUSED_FIELD', `$.fields[${String(index)}]`, `field \`${fieldId}\` is declared, but the layout never places it and no rule, message or layout expression reads it; place it in the layout, or remove the field declaration`, 'compiler.warning.unused_field'));
|
|
241
|
+
});
|
|
242
|
+
return warnings;
|
|
243
|
+
}
|
|
244
|
+
//# sourceMappingURL=dead-weight.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dead-weight.js","sourceRoot":"","sources":["../../src/compile/dead-weight.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,wBAAwB,EACxB,QAAQ,EACR,eAAe,GAChB,MAAM,wBAAwB,CAAC;AAShC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAI/C;;;;;;;;;;;;;;;;;;GAkBG;AAEH,kEAAkE;AAClE,MAAM,UAAU,kBAAkB,CAChC,QAAiC,EACjC,OAAqC,EACrC,QAAiC,EACjC,MAA6B,EAC7B,SAAmC,EACnC,MAAgC;IAEhC,OAAO;QACL,GAAG,iBAAiB,C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,UAAU,CAAC,CAAC;IAEnD,MAAM,QAAQ,GAAqB,EAAE,CAAC;IACtC,MAAM,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;QAClD,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;YAAE,OAAO;QAC7B,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;QACzC,IAAI,OAAO,KAAK,SAAS;YAAE,OAAO;QAClC,IAAI,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC;YAAE,OAAO;QAC3D,QAAQ,CAAC,IAAI,CACX,OAAO,CACL,cAAc,EACd,YAAY,MAAM,CAAC,KAAK,CAAC,GAAG,EAC5B,WAAW,OAAO,4JAA4J,EAC9K,+BAA+B,CAChC,CACF,CAAC;IACJ,CAAC,CAAC,CAAC;IACH,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["import {\n assertNever,\n declaredFieldExpressions,\n isRecord,\n ruleExpressions,\n} from '@azx-pbc/axiom-runtime';\nimport type {\n CompiledField,\n CompiledRule,\n CompiledSuggestion,\n ExprNode,\n LayoutNode,\n} from '@azx-pbc/axiom-runtime';\nimport type { CompileWarning } from './warning.js';\nimport { listAt, textAt } from './document.js';\nimport type { CompiledRuleEntry } from './rules.js';\nimport type { RawLayoutNode } from '../layout/read.js';\n\n/**\n * The constructs that can only be inert, reported as advice rather than as a refusal.\n *\n * The principle: a diagnostic refuses a document only when the document alone proves the\n * construct cannot mean what it appears to. An inert construct is not that proof. A constant\n * `visible: false` hides a field on purpose and a `compute: false` writes a constant; an\n * unplaced field may be rendered by a host or read by a rule; an instruction-only step is a\n * legitimate page. What remains after those are set aside is dead weight: a step that places\n * nothing at all (`EMPTY_STEP`) and a field a declared layout never places and nothing reads\n * (`UNUSED_FIELD`). A rule whose condition is literally `false` is the same kind of finding and\n * states `UNSATISFIABLE_CONDITION` through `condition-warnings`, because the expression lint\n * already proves it and one path earns one warning. The compiler names each with a warning code,\n * so a host shows it beside the artifact without refusing the author's edit.\n *\n * A message key declared and never named is deliberately **not** warned about. The catalogue is\n * part of the artifact a host may address directly, and an author may declare a key ahead of the\n * slot that names it; a warning would penalise staged authoring for a construct the document\n * cannot prove is a mistake.\n */\n\n/** A warning that names a dead construct rather than a defect. */\nexport function deadWeightWarnings(\n document: Record<string, unknown>,\n entries: readonly CompiledRuleEntry[],\n declared: readonly CompiledRule[],\n layout: readonly LayoutNode[],\n rawLayout: readonly RawLayoutNode[],\n fields: readonly CompiledField[],\n): readonly CompileWarning[] {\n return [\n ...emptyStepWarnings(rawLayout),\n ...unusedFieldWarnings(document, entries, declared, layout, rawLayout, fields),\n ];\n}\n\n/** One warning, with the members the compiler's warning contract states. */\nfunction warning(\n code: CompileWarning['code'],\n path: string,\n detail: string,\n messageKey: string,\n): CompileWarning {\n return { code, path, detail, messageKey, suggestions: [] };\n}\n\n/** Every step node that places nothing at all. A step holding chrome is instruction-only. */\nfunction emptyStepWarnings(rawLayout: readonly RawLayoutNode[]): readonly CompileWarning[] {\n const warnings: CompileWarning[] = [];\n const visit = (nodes: readonly RawLayoutNode[]): void => {\n for (const node of nodes) {\n if (node.kind === 'step' && node.children.length === 0) {\n warnings.push(\n warning(\n 'EMPTY_STEP',\n node.path,\n `step \\`${node.stepId ?? node.path}\\` places no node, so it renders an empty page; remove the step or place the fields and chrome it should show`,\n 'compiler.warning.empty_step',\n ),\n );\n }\n visit(node.children);\n }\n };\n visit(rawLayout);\n return warnings;\n}\n\n/** Every field id a compiled expression reads as a path, by its first segment. */\nfunction collectPathRoots(node: ExprNode, into: Set<string>): void {\n switch (node.kind) {\n case 'literal':\n return;\n case 'path': {\n // `$it.f_x` is a row member, not a top-level field. A nested record member\n // (`f_record.f_code`) references the container that holds it.\n const [root] = node.path.split('.');\n if (root !== undefined && !root.startsWith('$')) into.add(root);\n return;\n }\n case 'list':\n for (const item of node.items) collectPathRoots(item, into);\n return;\n case 'comprehension':\n collectPathRoots(node.source, into);\n if (node.valueExpr !== undefined) collectPathRoots(node.valueExpr, into);\n if (node.predicate !== undefined) collectPathRoots(node.predicate, into);\n return;\n default:\n for (const arg of node.args) collectPathRoots(arg, into);\n }\n}\n\n/** Every layout node's expression slots, and the read-only fields a summary card lists. */\nfunction collectLayoutReferences(\n layout: readonly LayoutNode[],\n fields: Set<string>,\n readOnlyFields: Set<string>,\n): void {\n for (const node of layout) {\n if ('visibleWhen' in node && node.visibleWhen !== undefined) {\n collectPathRoots(node.visibleWhen, fields);\n }\n if ('params' in node && node.params !== undefined) {\n for (const expression of Object.values(node.params)) collectPathRoots(expression, fields);\n }\n if (node.kind === 'summary_card') {\n for (const readout of node.readouts ?? []) collectPathRoots(readout.value, fields);\n for (const fieldId of node.fields ?? []) readOnlyFields.add(fieldId);\n }\n if ('children' in node) collectLayoutReferences(node.children, fields, readOnlyFields);\n }\n}\n\n/**\n * Every field an alternative names: the binding a write addresses, or the array whose rows it\n * changes.\n *\n * An alternative is data a host applies, so a field it writes is as declared-and-used as a\n * writer's target, whether the owner is a rule or an option.\n */\nfunction collectSuggestionTargets(suggestion: CompiledSuggestion, into: Set<string>): void {\n for (const operation of suggestion.operations) {\n switch (operation.kind) {\n case 'value':\n case 'null':\n case 'remove':\n into.add(operation.ref.fieldId);\n break;\n case 'append':\n case 'removeRow':\n into.add(operation.fieldId);\n break;\n default:\n assertNever(operation);\n }\n }\n}\n\n/** Every field id one rule names as a target, reader or writer. */\nfunction collectRuleTargets(rule: CompiledRule, into: Set<string>): void {\n if (rule.fieldId !== undefined) into.add(rule.fieldId);\n if (rule.targetFieldId !== undefined) into.add(rule.targetFieldId);\n if (rule.overrideFieldId !== undefined) into.add(rule.overrideFieldId);\n for (const fieldId of rule.fieldIds ?? []) into.add(fieldId);\n for (const expression of ruleExpressions(rule)) collectPathRoots(expression, into);\n for (const suggestion of rule.suggests ?? []) collectSuggestionTargets(suggestion, into);\n}\n\n/**\n * Every field a declaration outside a rule names: the expression slots a field carries, and the\n * bindings an option's alternative writes.\n *\n * A field's own expressions are reads like a rule's — an array's count, an option's availability\n * condition and its reason arguments — so the shared slot walk answers them. An alternative is\n * data a host applies, so a binding it writes keeps that field alive even though nothing reads it.\n */\nfunction collectFieldTargets(fields: readonly CompiledField[], into: Set<string>): void {\n for (const slot of declaredFieldExpressions(fields)) collectPathRoots(slot.node, into);\n const visit = (members: readonly CompiledField[]): void => {\n for (const member of members) {\n for (const option of member.options ?? []) {\n for (const suggestion of option.suggests ?? []) {\n collectSuggestionTargets(suggestion, into);\n }\n }\n if (member.fields !== undefined) visit(member.fields);\n }\n };\n visit(fields);\n}\n\n/** Every field a declaration names outside its own body: a source, dependency or coverage. */\nfunction collectDeclarationReferences(document: Record<string, unknown>, into: Set<string>): void {\n const visit = (fields: readonly unknown[]): void => {\n for (const field of fields) {\n if (!isRecord(field)) continue;\n const source = field['optionSource'];\n if (isRecord(source)) {\n const sourceField = textAt(source, 'fieldId');\n if (sourceField !== undefined) into.add(sourceField);\n for (const dependency of listAt(source, 'dependsOn')) {\n if (typeof dependency === 'string') into.add(dependency);\n }\n }\n const rowKey = field['rowKey'];\n if (isRecord(rowKey)) {\n const keyField = textAt(rowKey, 'fieldId');\n if (keyField !== undefined) into.add(keyField);\n }\n for (const target of listAt(field, 'covers')) {\n if (typeof target === 'string') into.add(target);\n }\n visit(listAt(field, 'fields'));\n }\n };\n visit(listAt(document, 'fields'));\n}\n\n/** Every field id a raw layout places, including a summary card's read-only list. */\nfunction placedFieldIds(rawLayout: readonly RawLayoutNode[]): Set<string> {\n const placed = new Set<string>();\n const visit = (nodes: readonly RawLayoutNode[]): void => {\n for (const node of nodes) {\n if (node.kind === 'field' && node.fieldId !== undefined) placed.add(node.fieldId);\n if (node.kind === 'summary_card') {\n for (const fieldId of node.fields) placed.add(fieldId);\n }\n visit(node.children);\n }\n };\n visit(rawLayout);\n return placed;\n}\n\n/**\n * A top-level field a declared layout never places and nothing reads.\n *\n * The check is deliberately conservative. It runs only when a layout exists and places at least\n * one field: a headless document is a first-class artifact a host renders from `fields`, and a\n * chrome-only layout may be paired with host-rendered controls. Row members are left to the\n * array that places them, and a field named by a rule, a writer, a message argument, a layout\n * expression, a summary card or an array's row key counts as read. What remains is a declaration\n * with no consumer at all.\n */\nfunction unusedFieldWarnings(\n document: Record<string, unknown>,\n entries: readonly CompiledRuleEntry[],\n declared: readonly CompiledRule[],\n layout: readonly LayoutNode[],\n rawLayout: readonly RawLayoutNode[],\n fields: readonly CompiledField[],\n): readonly CompileWarning[] {\n if (rawLayout.length === 0) return [];\n const placed = placedFieldIds(rawLayout);\n if (placed.size === 0) return [];\n const referenced = new Set<string>();\n for (const entry of entries) collectRuleTargets(entry.rule, referenced);\n for (const rule of declared) collectRuleTargets(rule, referenced);\n collectLayoutReferences(layout, referenced, placed);\n collectFieldTargets(fields, referenced);\n collectDeclarationReferences(document, referenced);\n\n const warnings: CompileWarning[] = [];\n listAt(document, 'fields').forEach((field, index) => {\n if (!isRecord(field)) return;\n const fieldId = textAt(field, 'fieldId');\n if (fieldId === undefined) return;\n if (placed.has(fieldId) || referenced.has(fieldId)) return;\n warnings.push(\n warning(\n 'UNUSED_FIELD',\n `$.fields[${String(index)}]`,\n `field \\`${fieldId}\\` is declared, but the layout never places it and no rule, message or layout expression reads it; place it in the layout, or remove the field declaration`,\n 'compiler.warning.unused_field',\n ),\n );\n });\n return warnings;\n}\n"]}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { CompiledRule } from '@azx-pbc/axiom-runtime';
|
|
2
|
+
import type { DeclaredRuleOrigin } from '../publish/readiness.js';
|
|
3
|
+
import type { SchemaDiagnostic } from '../schema/diagnostic.js';
|
|
4
|
+
import type { Compilation } from './compilation.js';
|
|
5
|
+
/**
|
|
6
|
+
* The declaration members that compile down to the rule an author writes by hand.
|
|
7
|
+
*
|
|
8
|
+
* `required: true`, `requiredWhen`, `visibleWhen`, `minimum`, `maximum`, `minLength` and
|
|
9
|
+
* `maxLength` are declarations of policy, and the rule form stays for a conditional
|
|
10
|
+
* requirement. Compiling both through one emitter is what makes a declared requirement and a
|
|
11
|
+
* hand-written rule one behaviour rather than two: the artifact carries the same rule, the
|
|
12
|
+
* report hashes it the same way, and the runtime has no second path to read.
|
|
13
|
+
*
|
|
14
|
+
* The synthesized ids are deterministic — `r_<fieldId>_required`, `r_<fieldId>_visible`,
|
|
15
|
+
* `r_<fieldId>_minimum`, `r_<fieldId>_maximum`, `r_<fieldId>_min_length`,
|
|
16
|
+
* `r_<fieldId>_max_length` — so an author can name a required rule in `rule_ok(...)` and a test
|
|
17
|
+
* can compare a declared document with the hand-written one. Each declaration may carry its
|
|
18
|
+
* evidence in the sibling `<member>TestCases`, and the emitter copies that list onto the rule
|
|
19
|
+
* verbatim: the artifact keeps one evidence place, and a declaration's evidence hashes and reads
|
|
20
|
+
* exactly as the same cases on a hand-written rule (`RULES-3.1.1`).
|
|
21
|
+
*/
|
|
22
|
+
export interface DeclarationRuleResult {
|
|
23
|
+
readonly rules: readonly CompiledRule[];
|
|
24
|
+
readonly diagnostics: readonly SchemaDiagnostic[];
|
|
25
|
+
/** Where each synthesized rule came from, so a publish gap can name the declaration. */
|
|
26
|
+
readonly origins: readonly DeclaredRuleOrigin[];
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Every rule a document's field declarations compile to, with the declaration each came from.
|
|
30
|
+
*
|
|
31
|
+
* This is the same walk the compile performs, without the compile: a builder command that must
|
|
32
|
+
* address a generated rule — `addRuleTestCase` — asks this rather than re-deriving the id scheme,
|
|
33
|
+
* so the store cannot invent a rule the compiler does not emit.
|
|
34
|
+
*/
|
|
35
|
+
export declare function declaredRuleOrigins(document: Record<string, unknown>): readonly DeclaredRuleOrigin[];
|
|
36
|
+
/**
|
|
37
|
+
* Every rule a document's field declarations compile to, in declaration order, plus the
|
|
38
|
+
* refusals that compiling them adds.
|
|
39
|
+
*
|
|
40
|
+
* The metaschema has already refused the shapes that cannot arrive here, so a throw would be
|
|
41
|
+
* a compiler defect; the diagnostics here cover the relations it cannot state — two
|
|
42
|
+
* declarations generating one rule id as a rule the author wrote, or as each other, which would
|
|
43
|
+
* make one of them invisible to `rule_ok` and one of them ambiguous in the report.
|
|
44
|
+
*/
|
|
45
|
+
export declare function declarationRules(compilation: Compilation, document: Record<string, unknown>): DeclarationRuleResult;
|
|
46
|
+
/**
|
|
47
|
+
* Refuse a declaration that has no message key where the compiled rule requires one.
|
|
48
|
+
*
|
|
49
|
+
* The metaschema states the message keys as dependent-required, so this cannot arrive from a
|
|
50
|
+
* validated document; the check exists because the emitter must not mint a `validate` rule
|
|
51
|
+
* whose `messageKey` is the empty string, which the runtime would refuse at evaluation time.
|
|
52
|
+
*/
|
|
53
|
+
export declare function checkDeclaredMessages(compilation: Compilation, document: Record<string, unknown>): void;
|
|
54
|
+
//# sourceMappingURL=declaration-rules.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"declaration-rules.d.ts","sourceRoot":"","sources":["../../src/compile/declaration-rules.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,YAAY,EAKb,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAA6B,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAGhE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AASpD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,KAAK,EAAE,SAAS,YAAY,EAAE,CAAC;IACxC,QAAQ,CAAC,WAAW,EAAE,SAAS,gBAAgB,EAAE,CAAC;IAClD,wFAAwF;IACxF,QAAQ,CAAC,OAAO,EAAE,SAAS,kBAAkB,EAAE,CAAC;CACjD;AAuHD;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,SAAS,kBAAkB,EAAE,CAiB/B;AAyYD;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAC9B,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,qBAAqB,CA+EvB;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,IAAI,CAoBN"}
|