@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,202 @@
|
|
|
1
|
+
import { parse } from '@messageformat/parser';
|
|
2
|
+
import { AxiomError } from '@azx-pbc/axiom-runtime';
|
|
3
|
+
import { cardinalCategories } from '@azx-pbc/axiom-runtime/messages/categories';
|
|
4
|
+
/** The only CLDR category set a `=n`-free branch may name. */
|
|
5
|
+
const CARDINAL_KEYS = new Set(['zero', 'one', 'two', 'few', 'many', 'other']);
|
|
6
|
+
/** A refusal inside one message, carrying where in the node tree it happened. */
|
|
7
|
+
class MessageFailure extends Error {
|
|
8
|
+
path;
|
|
9
|
+
constructor(path, detail) {
|
|
10
|
+
super(detail);
|
|
11
|
+
this.name = 'MessageFailure';
|
|
12
|
+
this.path = path;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function isParserPluralCategory(value) {
|
|
16
|
+
return CARDINAL_KEYS.has(value);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The CLDR cardinal categories one locale selects. A catalogue may name a locale the
|
|
20
|
+
* runtime carries no rules for; only a `plural` needs them, so the refusal is reported for
|
|
21
|
+
* the node that needs it rather than thrown for the whole catalogue.
|
|
22
|
+
*/
|
|
23
|
+
function pluralRulesOf(locale) {
|
|
24
|
+
try {
|
|
25
|
+
return { known: true, categories: cardinalCategories(locale) };
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
// The runtime's refusal already names the supported set, so a diagnostic reuses it
|
|
29
|
+
// instead of restating a registry the compiler does not own.
|
|
30
|
+
if (error instanceof AxiomError)
|
|
31
|
+
return { known: false, refusal: error.message };
|
|
32
|
+
throw error;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/** The CLDR cardinal categories the declared locales select, plus the always-valid `other`. */
|
|
36
|
+
function selectablePluralKeys(locales) {
|
|
37
|
+
const keys = new Set(['other']);
|
|
38
|
+
for (const locale of locales) {
|
|
39
|
+
const rules = pluralRulesOf(locale);
|
|
40
|
+
if (!rules.known)
|
|
41
|
+
continue;
|
|
42
|
+
for (const category of rules.categories)
|
|
43
|
+
keys.add(category);
|
|
44
|
+
}
|
|
45
|
+
return keys;
|
|
46
|
+
}
|
|
47
|
+
/** Whether a plural branch key is an `=n` exact match or a category a locale selects. */
|
|
48
|
+
function isPluralKey(key, pluralKeys) {
|
|
49
|
+
if (/^=-?(?:0|[1-9][0-9]*)$/.test(key))
|
|
50
|
+
return true;
|
|
51
|
+
return CARDINAL_KEYS.has(key) && pluralKeys.has(key);
|
|
52
|
+
}
|
|
53
|
+
function casesOf(select, path, pluralKeys, pluralRefusal) {
|
|
54
|
+
const cases = new Map();
|
|
55
|
+
const args = new Set();
|
|
56
|
+
for (const [index, selectCase] of select.cases.entries()) {
|
|
57
|
+
const at = `${path}.cases[${String(index)}]`;
|
|
58
|
+
if (cases.has(selectCase.key)) {
|
|
59
|
+
throw new MessageFailure(at, `branch \`${selectCase.key}\` is declared twice`);
|
|
60
|
+
}
|
|
61
|
+
if (select.type === 'plural' && !isPluralKey(selectCase.key, pluralKeys)) {
|
|
62
|
+
throw new MessageFailure(at, `plural branch \`${selectCase.key}\` is neither an \`=n\` match nor a CLDR category a declared locale selects (${[...pluralKeys].join(', ')})`);
|
|
63
|
+
}
|
|
64
|
+
const branch = nodesOf(selectCase.tokens, at, pluralKeys, pluralRefusal);
|
|
65
|
+
cases.set(selectCase.key, branch.nodes);
|
|
66
|
+
for (const name of branch.arguments)
|
|
67
|
+
args.add(name);
|
|
68
|
+
}
|
|
69
|
+
if (!cases.has('other')) {
|
|
70
|
+
throw new MessageFailure(path, `\`${select.type}\` has no \`other\` branch`);
|
|
71
|
+
}
|
|
72
|
+
// `fromEntries` writes data properties, so an option code of `__proto__` cannot invoke the
|
|
73
|
+
// legacy prototype setter and turn the branch list into the case object's prototype.
|
|
74
|
+
return { cases: Object.fromEntries(cases), arguments: [...args] };
|
|
75
|
+
}
|
|
76
|
+
function nodesOf(tokens, path, pluralKeys, pluralRefusal) {
|
|
77
|
+
const nodes = [];
|
|
78
|
+
const args = new Set();
|
|
79
|
+
for (const [index, token] of tokens.entries()) {
|
|
80
|
+
const at = `${path}[${String(index)}]`;
|
|
81
|
+
switch (token.type) {
|
|
82
|
+
case 'content':
|
|
83
|
+
nodes.push({ kind: 'content', value: token.value });
|
|
84
|
+
break;
|
|
85
|
+
case 'argument':
|
|
86
|
+
nodes.push({ kind: 'argument', name: token.arg });
|
|
87
|
+
args.add(token.arg);
|
|
88
|
+
break;
|
|
89
|
+
case 'octothorpe':
|
|
90
|
+
nodes.push({ kind: 'pound' });
|
|
91
|
+
break;
|
|
92
|
+
case 'select':
|
|
93
|
+
case 'plural': {
|
|
94
|
+
// A `plural` renders through the locale's CLDR rules, so a locale without them
|
|
95
|
+
// cannot state one; `select` needs no rules and is unaffected.
|
|
96
|
+
if (token.type === 'plural' && pluralRefusal !== undefined) {
|
|
97
|
+
throw new MessageFailure(at, `a \`plural\` cannot be selected here: ${pluralRefusal}`);
|
|
98
|
+
}
|
|
99
|
+
args.add(token.arg);
|
|
100
|
+
const { cases, arguments: branchArgs } = casesOf(token, at, pluralKeys, pluralRefusal);
|
|
101
|
+
nodes.push(token.type === 'plural'
|
|
102
|
+
? { kind: 'plural', name: token.arg, offset: token.pluralOffset ?? 0, cases }
|
|
103
|
+
: { kind: 'select', name: token.arg, cases });
|
|
104
|
+
for (const name of branchArgs)
|
|
105
|
+
args.add(name);
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
case 'selectordinal':
|
|
109
|
+
throw new MessageFailure(at, '`selectordinal` is outside the supported ICU MF1 subset');
|
|
110
|
+
case 'function':
|
|
111
|
+
// a formatter would need a locale database the runtime does not carry.
|
|
112
|
+
throw new MessageFailure(at, `the \`${token.key}\` formatter is outside the supported ICU MF1 subset`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return { nodes, arguments: [...args] };
|
|
116
|
+
}
|
|
117
|
+
/** Compiles one authored message of one locale, against every locale it declares. */
|
|
118
|
+
export function compileMessage(source, locale, locales) {
|
|
119
|
+
const rules = pluralRulesOf(locale);
|
|
120
|
+
const pluralRefusal = rules.known ? undefined : rules.refusal;
|
|
121
|
+
const pluralKeys = selectablePluralKeys(locales);
|
|
122
|
+
try {
|
|
123
|
+
const tokens = parse(source, {
|
|
124
|
+
// The branch keys are validated by `isPluralKey` below, which names the categories the
|
|
125
|
+
// declared locales select and reports the branch at its own position. The parser is given
|
|
126
|
+
// the whole CLDR category vocabulary so it cannot refuse a key first: for a locale the
|
|
127
|
+
// registry does not carry, `pluralRefusal` must be what the author reads, and the parser
|
|
128
|
+
// only knows which keys the *declared* locales select — a set built from a locale that has
|
|
129
|
+
// no rules can reject `one` before the node's own refusal is reached.
|
|
130
|
+
cardinal: [...CARDINAL_KEYS].filter(isParserPluralCategory),
|
|
131
|
+
ordinal: [],
|
|
132
|
+
strict: true,
|
|
133
|
+
});
|
|
134
|
+
const { nodes, arguments: args } = nodesOf(tokens, 'nodes', pluralKeys, pluralRefusal);
|
|
135
|
+
return { ok: true, message: { source, nodes, locale }, arguments: args };
|
|
136
|
+
}
|
|
137
|
+
catch (error) {
|
|
138
|
+
if (error instanceof MessageFailure) {
|
|
139
|
+
return { ok: false, diagnostics: [{ path: error.path, detail: error.message }] };
|
|
140
|
+
}
|
|
141
|
+
if (error instanceof Error) {
|
|
142
|
+
return { ok: false, diagnostics: [{ path: '', detail: error.message }] };
|
|
143
|
+
}
|
|
144
|
+
throw error;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
/** The argument names a compiled message references, in first-appearance order. */
|
|
148
|
+
export function argumentsOf(nodes) {
|
|
149
|
+
const args = [];
|
|
150
|
+
const visit = (list) => {
|
|
151
|
+
for (const node of list) {
|
|
152
|
+
switch (node.kind) {
|
|
153
|
+
case 'content':
|
|
154
|
+
case 'pound':
|
|
155
|
+
break;
|
|
156
|
+
case 'argument':
|
|
157
|
+
if (!args.includes(node.name))
|
|
158
|
+
args.push(node.name);
|
|
159
|
+
break;
|
|
160
|
+
case 'select':
|
|
161
|
+
case 'plural':
|
|
162
|
+
if (!args.includes(node.name))
|
|
163
|
+
args.push(node.name);
|
|
164
|
+
for (const branch of Object.values(node.cases))
|
|
165
|
+
visit(branch);
|
|
166
|
+
break;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
visit(nodes);
|
|
171
|
+
return args;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* The `select` branches one compiled message declares, keyed by the argument it selects on.
|
|
175
|
+
* The compiler checks them against the options of the field the using rule binds that
|
|
176
|
+
* argument to.
|
|
177
|
+
*/
|
|
178
|
+
export function selectBranches(nodes) {
|
|
179
|
+
const branches = new Map();
|
|
180
|
+
const visit = (list) => {
|
|
181
|
+
for (const node of list) {
|
|
182
|
+
if (node.kind === 'plural') {
|
|
183
|
+
for (const branch of Object.values(node.cases))
|
|
184
|
+
visit(branch);
|
|
185
|
+
continue;
|
|
186
|
+
}
|
|
187
|
+
if (node.kind !== 'select')
|
|
188
|
+
continue;
|
|
189
|
+
const declared = Object.keys(node.cases).filter((key) => key !== 'other');
|
|
190
|
+
const keys = branches.get(node.name);
|
|
191
|
+
if (keys === undefined)
|
|
192
|
+
branches.set(node.name, declared);
|
|
193
|
+
else
|
|
194
|
+
keys.push(...declared.filter((key) => !keys.includes(key)));
|
|
195
|
+
for (const branch of Object.values(node.cases))
|
|
196
|
+
visit(branch);
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
visit(nodes);
|
|
200
|
+
return branches;
|
|
201
|
+
}
|
|
202
|
+
//# sourceMappingURL=compile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compile.js","sourceRoot":"","sources":["../../src/messages/compile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAE9C,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,4CAA4C,CAAC;AAoChF,8DAA8D;AAC9D,MAAM,aAAa,GAAwB,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAEnG,iFAAiF;AACjF,MAAM,c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C,IAAI,KAAK,QAAQ;gBAAE,SAAS;YACrC,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,KAAK,OAAO,CAAC,CAAC;YAC1E,MAAM,IAAI,GAAG,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACrC,IAAI,IAAI,KAAK,SAAS;gBAAE,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;;gBACrD,IAAI,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YACjE,KAAK,MAAM,MAAM,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;gBAAE,KAAK,CAAC,MAAM,CAAC,CAAC;QAChE,CAAC;IACH,CAAC,CAAC;IACF,KAAK,CAAC,KAAK,CAAC,CAAC;IACb,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["import { parse } from '@messageformat/parser';\nimport type { PluralCategory as ParserPluralCategory, Select, Token } from '@messageformat/parser';\nimport { AxiomError } from '@azx-pbc/axiom-runtime';\nimport type { CompiledMessage, MessageNode } from '@azx-pbc/axiom-runtime';\nimport { cardinalCategories } from '@azx-pbc/axiom-runtime/messages/categories';\nimport type { PluralCategory } from '@azx-pbc/axiom-runtime/messages';\n\n/**\n * ICU MessageFormat 1 compilation, `spec/semantics/model-v1.md` section 6.\n *\n * The compiler is the only producer of a message AST, so every authored\n * locale is parsed and checked here — the `number`/`date`/`time`/currency formatters are\n * refused, each `plural` branch must be a CLDR category one of the\n * declared locales can select, and every `select`/`plural` must carry an `other` branch so\n * a locale can never fall through to nothing.\n *\n * A catalogue may name any locale the metaschema admits, and its text renders as authored;\n * only a `plural` needs the runtime's CLDR rules to select a branch, so a `plural` in a\n * locale the runtime carries no rules for is refused at its own node rather than aborting\n * the compile.\n *\n * The data-only AST keeps the source text beside it: a host may show the source, and a\n * runtime never parses either.\n */\n\n/** Why one authored message did not compile. */\ninterface MessageDiagnostic {\n /** Where inside the message, as `nodes[1].cases[0]`, or empty for the whole message. */\n readonly path: string;\n readonly detail: string;\n}\n\n/** The names a message references, in first-appearance order. */\nexport type MessageArguments = readonly string[];\n\n/** One authored message compiled, or every reason it was not. */\nexport type MessageCompileResult =\n | { readonly ok: true; readonly message: CompiledMessage; readonly arguments: MessageArguments }\n | { readonly ok: false; readonly diagnostics: readonly MessageDiagnostic[] };\n\n/** The only CLDR category set a `=n`-free branch may name. */\nconst CARDINAL_KEYS: ReadonlySet<string> = new Set(['zero', 'one', 'two', 'few', 'many', 'other']);\n\n/** A refusal inside one message, carrying where in the node tree it happened. */\nclass MessageFailure extends Error {\n readonly path: string;\n\n constructor(path: string, detail: string) {\n super(detail);\n this.name = 'MessageFailure';\n this.path = path;\n }\n}\n\nfunction isParserPluralCategory(value: string): value is ParserPluralCategory {\n return CARDINAL_KEYS.has(value);\n}\n\n/** The runtime's plural rules for a locale, or the refusal that names why it has none. */\ntype LocalePluralRules =\n | { readonly known: true; readonly categories: readonly PluralCategory[] }\n | { readonly known: false; readonly refusal: string };\n\n/**\n * The CLDR cardinal categories one locale selects. A catalogue may name a locale the\n * runtime carries no rules for; only a `plural` needs them, so the refusal is reported for\n * the node that needs it rather than thrown for the whole catalogue.\n */\nfunction pluralRulesOf(locale: string): LocalePluralRules {\n try {\n return { known: true, categories: cardinalCategories(locale) };\n } catch (error) {\n // The runtime's refusal already names the supported set, so a diagnostic reuses it\n // instead of restating a registry the compiler does not own.\n if (error instanceof AxiomError) return { known: false, refusal: error.message };\n throw error;\n }\n}\n\n/** The CLDR cardinal categories the declared locales select, plus the always-valid `other`. */\nfunction selectablePluralKeys(locales: readonly string[]): ReadonlySet<string> {\n const keys = new Set<string>(['other']);\n for (const locale of locales) {\n const rules = pluralRulesOf(locale);\n if (!rules.known) continue;\n for (const category of rules.categories) keys.add(category);\n }\n return keys;\n}\n\n/** Whether a plural branch key is an `=n` exact match or a category a locale selects. */\nfunction isPluralKey(key: string, pluralKeys: ReadonlySet<string>): boolean {\n if (/^=-?(?:0|[1-9][0-9]*)$/.test(key)) return true;\n return CARDINAL_KEYS.has(key) && pluralKeys.has(key);\n}\n\ninterface CompiledNodes {\n readonly nodes: readonly MessageNode[];\n readonly arguments: MessageArguments;\n}\n\nfunction casesOf(\n select: Select,\n path: string,\n pluralKeys: ReadonlySet<string>,\n pluralRefusal: string | undefined,\n): {\n readonly cases: Readonly<Record<string, readonly MessageNode[]>>;\n readonly arguments: MessageArguments;\n} {\n const cases = new Map<string, readonly MessageNode[]>();\n const args = new Set<string>();\n for (const [index, selectCase] of select.cases.entries()) {\n const at = `${path}.cases[${String(index)}]`;\n if (cases.has(selectCase.key)) {\n throw new MessageFailure(at, `branch \\`${selectCase.key}\\` is declared twice`);\n }\n if (select.type === 'plural' && !isPluralKey(selectCase.key, pluralKeys)) {\n throw new MessageFailure(\n at,\n `plural branch \\`${selectCase.key}\\` is neither an \\`=n\\` match nor a CLDR category a declared locale selects (${[...pluralKeys].join(', ')})`,\n );\n }\n const branch = nodesOf(selectCase.tokens, at, pluralKeys, pluralRefusal);\n cases.set(selectCase.key, branch.nodes);\n for (const name of branch.arguments) args.add(name);\n }\n if (!cases.has('other')) {\n throw new MessageFailure(path, `\\`${select.type}\\` has no \\`other\\` branch`);\n }\n // `fromEntries` writes data properties, so an option code of `__proto__` cannot invoke the\n // legacy prototype setter and turn the branch list into the case object's prototype.\n return { cases: Object.fromEntries(cases), arguments: [...args] };\n}\n\nfunction nodesOf(\n tokens: readonly Token[],\n path: string,\n pluralKeys: ReadonlySet<string>,\n pluralRefusal: string | undefined,\n): CompiledNodes {\n const nodes: MessageNode[] = [];\n const args = new Set<string>();\n for (const [index, token] of tokens.entries()) {\n const at = `${path}[${String(index)}]`;\n switch (token.type) {\n case 'content':\n nodes.push({ kind: 'content', value: token.value });\n break;\n case 'argument':\n nodes.push({ kind: 'argument', name: token.arg });\n args.add(token.arg);\n break;\n case 'octothorpe':\n nodes.push({ kind: 'pound' });\n break;\n case 'select':\n case 'plural': {\n // A `plural` renders through the locale's CLDR rules, so a locale without them\n // cannot state one; `select` needs no rules and is unaffected.\n if (token.type === 'plural' && pluralRefusal !== undefined) {\n throw new MessageFailure(at, `a \\`plural\\` cannot be selected here: ${pluralRefusal}`);\n }\n args.add(token.arg);\n const { cases, arguments: branchArgs } = casesOf(token, at, pluralKeys, pluralRefusal);\n nodes.push(\n token.type === 'plural'\n ? { kind: 'plural', name: token.arg, offset: token.pluralOffset ?? 0, cases }\n : { kind: 'select', name: token.arg, cases },\n );\n for (const name of branchArgs) args.add(name);\n break;\n }\n case 'selectordinal':\n throw new MessageFailure(at, '`selectordinal` is outside the supported ICU MF1 subset');\n case 'function':\n // a formatter would need a locale database the runtime does not carry.\n throw new MessageFailure(\n at,\n `the \\`${token.key}\\` formatter is outside the supported ICU MF1 subset`,\n );\n }\n }\n return { nodes, arguments: [...args] };\n}\n\n/** Compiles one authored message of one locale, against every locale it declares. */\nexport function compileMessage(\n source: string,\n locale: string,\n locales: readonly string[],\n): MessageCompileResult {\n const rules = pluralRulesOf(locale);\n const pluralRefusal = rules.known ? undefined : rules.refusal;\n const pluralKeys = selectablePluralKeys(locales);\n try {\n const tokens = parse(source, {\n // The branch keys are validated by `isPluralKey` below, which names the categories the\n // declared locales select and reports the branch at its own position. The parser is given\n // the whole CLDR category vocabulary so it cannot refuse a key first: for a locale the\n // registry does not carry, `pluralRefusal` must be what the author reads, and the parser\n // only knows which keys the *declared* locales select — a set built from a locale that has\n // no rules can reject `one` before the node's own refusal is reached.\n cardinal: [...CARDINAL_KEYS].filter(isParserPluralCategory),\n ordinal: [],\n strict: true,\n });\n const { nodes, arguments: args } = nodesOf(tokens, 'nodes', pluralKeys, pluralRefusal);\n return { ok: true, message: { source, nodes, locale }, arguments: args };\n } catch (error) {\n if (error instanceof MessageFailure) {\n return { ok: false, diagnostics: [{ path: error.path, detail: error.message }] };\n }\n if (error instanceof Error) {\n return { ok: false, diagnostics: [{ path: '', detail: error.message }] };\n }\n throw error;\n }\n}\n\n/** The argument names a compiled message references, in first-appearance order. */\nexport function argumentsOf(nodes: readonly MessageNode[]): MessageArguments {\n const args: string[] = [];\n const visit = (list: readonly MessageNode[]): void => {\n for (const node of list) {\n switch (node.kind) {\n case 'content':\n case 'pound':\n break;\n case 'argument':\n if (!args.includes(node.name)) args.push(node.name);\n break;\n case 'select':\n case 'plural':\n if (!args.includes(node.name)) args.push(node.name);\n for (const branch of Object.values(node.cases)) visit(branch);\n break;\n }\n }\n };\n visit(nodes);\n return args;\n}\n\n/**\n * The `select` branches one compiled message declares, keyed by the argument it selects on.\n * The compiler checks them against the options of the field the using rule binds that\n * argument to.\n */\nexport function selectBranches(\n nodes: readonly MessageNode[],\n): ReadonlyMap<string, readonly string[]> {\n const branches = new Map<string, string[]>();\n const visit = (list: readonly MessageNode[]): void => {\n for (const node of list) {\n if (node.kind === 'plural') {\n for (const branch of Object.values(node.cases)) visit(branch);\n continue;\n }\n if (node.kind !== 'select') continue;\n const declared = Object.keys(node.cases).filter((key) => key !== 'other');\n const keys = branches.get(node.name);\n if (keys === undefined) branches.set(node.name, declared);\n else keys.push(...declared.filter((key) => !keys.includes(key)));\n for (const branch of Object.values(node.cases)) visit(branch);\n }\n };\n visit(nodes);\n return branches;\n}\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one grammar for a declared locale tag.
|
|
3
|
+
*
|
|
4
|
+
* A locale is written the way BCP-47 and CLDR spell it: a two- or three-letter language, then
|
|
5
|
+
* an optional four-letter script and an optional two-letter or three-digit region. Case is not
|
|
6
|
+
* significant to BCP-47, so the metaschema accepts any spelling and this module states the
|
|
7
|
+
* canonical one — `pt-br` is admitted and then refused with `pt-BR` named, so the catalogue's
|
|
8
|
+
* keys and the `locales` list can be compared as exact strings without a silent normalisation.
|
|
9
|
+
*
|
|
10
|
+
* The pattern text is the single source: `spec/metaschema/schema.v1.json` carries the same
|
|
11
|
+
* string and a drift test fails when the two disagree.
|
|
12
|
+
*/
|
|
13
|
+
export declare const LOCALE_TAG_PATTERN = "^[A-Za-z]{2,3}(-[A-Za-z]{4})?(-([A-Za-z]{2}|[0-9]{3}))?$";
|
|
14
|
+
/** Whether `value` is a well-formed locale tag in any case. */
|
|
15
|
+
export declare function isLocaleTag(value: string): boolean;
|
|
16
|
+
/** The canonical spelling of `tag`: lowercase language, title-case script, uppercase region. */
|
|
17
|
+
export declare function canonicalLocale(tag: string): string;
|
|
18
|
+
//# sourceMappingURL=locale.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"locale.d.ts","sourceRoot":"","sources":["../../src/messages/locale.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,kBAAkB,6DAA6D,CAAC;AAI7F,+DAA+D;AAC/D,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAElD;AAED,gGAAgG;AAChG,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CASnD"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one grammar for a declared locale tag.
|
|
3
|
+
*
|
|
4
|
+
* A locale is written the way BCP-47 and CLDR spell it: a two- or three-letter language, then
|
|
5
|
+
* an optional four-letter script and an optional two-letter or three-digit region. Case is not
|
|
6
|
+
* significant to BCP-47, so the metaschema accepts any spelling and this module states the
|
|
7
|
+
* canonical one — `pt-br` is admitted and then refused with `pt-BR` named, so the catalogue's
|
|
8
|
+
* keys and the `locales` list can be compared as exact strings without a silent normalisation.
|
|
9
|
+
*
|
|
10
|
+
* The pattern text is the single source: `spec/metaschema/schema.v1.json` carries the same
|
|
11
|
+
* string and a drift test fails when the two disagree.
|
|
12
|
+
*/
|
|
13
|
+
export const LOCALE_TAG_PATTERN = '^[A-Za-z]{2,3}(-[A-Za-z]{4})?(-([A-Za-z]{2}|[0-9]{3}))?$';
|
|
14
|
+
const LOCALE_TAG = new RegExp(LOCALE_TAG_PATTERN, 'u');
|
|
15
|
+
/** Whether `value` is a well-formed locale tag in any case. */
|
|
16
|
+
export function isLocaleTag(value) {
|
|
17
|
+
return LOCALE_TAG.test(value);
|
|
18
|
+
}
|
|
19
|
+
/** The canonical spelling of `tag`: lowercase language, title-case script, uppercase region. */
|
|
20
|
+
export function canonicalLocale(tag) {
|
|
21
|
+
const [language, ...rest] = tag.split('-');
|
|
22
|
+
if (language === undefined)
|
|
23
|
+
return tag;
|
|
24
|
+
const parts = [language.toLowerCase()];
|
|
25
|
+
for (const part of rest) {
|
|
26
|
+
if (part.length === 4)
|
|
27
|
+
parts.push(part[0]?.toUpperCase() + part.slice(1).toLowerCase());
|
|
28
|
+
else
|
|
29
|
+
parts.push(/^[A-Za-z]{2}$/.test(part) ? part.toUpperCase() : part);
|
|
30
|
+
}
|
|
31
|
+
return parts.join('-');
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=locale.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"locale.js","sourceRoot":"","sources":["../../src/messages/locale.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,0DAA0D,CAAC;AAE7F,MAAM,UAAU,GAAG,IAAI,MAAM,CAAC,kBAAkB,EAAE,GAAG,CAAC,CAAC;AAEvD,+DAA+D;AAC/D,MAAM,UAAU,WAAW,CAAC,KAAa;IACvC,OAAO,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAChC,CAAC;AAED,gGAAgG;AAChG,MAAM,UAAU,eAAe,CAAC,GAAW;IACzC,MAAM,CAAC,QAAQ,EAAE,GAAG,IAAI,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC3C,IAAI,QAAQ,KAAK,SAAS;QAAE,OAAO,GAAG,CAAC;IACvC,MAAM,KAAK,GAAG,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAC;IACvC,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE,CAAC;QACxB,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;YAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;;YACnF,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IAC1E,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACzB,CAAC","sourcesContent":["/**\n * The one grammar for a declared locale tag.\n *\n * A locale is written the way BCP-47 and CLDR spell it: a two- or three-letter language, then\n * an optional four-letter script and an optional two-letter or three-digit region. Case is not\n * significant to BCP-47, so the metaschema accepts any spelling and this module states the\n * canonical one — `pt-br` is admitted and then refused with `pt-BR` named, so the catalogue's\n * keys and the `locales` list can be compared as exact strings without a silent normalisation.\n *\n * The pattern text is the single source: `spec/metaschema/schema.v1.json` carries the same\n * string and a drift test fails when the two disagree.\n */\nexport const LOCALE_TAG_PATTERN = '^[A-Za-z]{2,3}(-[A-Za-z]{4})?(-([A-Za-z]{2}|[0-9]{3}))?$';\n\nconst LOCALE_TAG = new RegExp(LOCALE_TAG_PATTERN, 'u');\n\n/** Whether `value` is a well-formed locale tag in any case. */\nexport function isLocaleTag(value: string): boolean {\n return LOCALE_TAG.test(value);\n}\n\n/** The canonical spelling of `tag`: lowercase language, title-case script, uppercase region. */\nexport function canonicalLocale(tag: string): string {\n const [language, ...rest] = tag.split('-');\n if (language === undefined) return tag;\n const parts = [language.toLowerCase()];\n for (const part of rest) {\n if (part.length === 4) parts.push(part[0]?.toUpperCase() + part.slice(1).toLowerCase());\n else parts.push(/^[A-Za-z]{2}$/.test(part) ? part.toUpperCase() : part);\n }\n return parts.join('-');\n}\n"]}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/** One member a schema document names a message through. */
|
|
2
|
+
export interface MessageSlot {
|
|
3
|
+
/**
|
|
4
|
+
* The path to the slot from the document root, with list indices dropped, so
|
|
5
|
+
* `$.fields[0].options[2].labelKey` is `fields.options.labelKey`.
|
|
6
|
+
*
|
|
7
|
+
* A member written with a trailing `*` matches that member repeated zero or more times;
|
|
8
|
+
* a trailing `+` matches it one or more times. `layout.children*` admits a top-level
|
|
9
|
+
* layout node; `fields+` requires at least one enclosing field. The last segment is the
|
|
10
|
+
* member the key is read from; the segments before it are its owners.
|
|
11
|
+
*/
|
|
12
|
+
readonly path: string;
|
|
13
|
+
/**
|
|
14
|
+
* Whether the slot's owner binds the message's arguments in a parameter block.
|
|
15
|
+
*
|
|
16
|
+
* `none`: the slot states presentation text and has nothing to bind, so a message in it may
|
|
17
|
+
* not interpolate anything and the params-less check refuses it. `optional`: the owner may
|
|
18
|
+
* bind the message's arguments, so the check that compiles that declaration reports an
|
|
19
|
+
* argument it does not bind, naming the declaration, and the params-less check leaves the
|
|
20
|
+
* slot alone.
|
|
21
|
+
*/
|
|
22
|
+
readonly params: 'none' | 'optional';
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Every message slot of a schema document, `spec/semantics/model-v1.md`.
|
|
26
|
+
*
|
|
27
|
+
* A later layout or screen member adds its row here rather than another walk of the document.
|
|
28
|
+
*/
|
|
29
|
+
export declare const MESSAGE_SLOTS: readonly MessageSlot[];
|
|
30
|
+
/** One reference to a declared message, and the slot that makes it. */
|
|
31
|
+
export interface MessageKeyUse {
|
|
32
|
+
/** Where in the document, as `$.fields[0].labelKey`. */
|
|
33
|
+
readonly path: string;
|
|
34
|
+
readonly key: string;
|
|
35
|
+
/**
|
|
36
|
+
* The slot's declared class: `optional` when the owning declaration binds the message's
|
|
37
|
+
* arguments in `params`, `none` when the slot has nothing to bind.
|
|
38
|
+
*
|
|
39
|
+
* A use is not resolved against the entry it belongs to. The check that compiles a rule or a
|
|
40
|
+
* gate item refuses an argument that declaration does not bind and names the declaration, so
|
|
41
|
+
* a second refusal here would report one cause twice at one path.
|
|
42
|
+
*/
|
|
43
|
+
readonly params: 'none' | 'optional';
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Every message key the document names, in document order, tagged by whether the owning
|
|
47
|
+
* declaration binds the message's arguments.
|
|
48
|
+
*
|
|
49
|
+
* One walk, no per-slot traversal: the member chain is tracked as the tree is visited (list
|
|
50
|
+
* elements keep their owning member's chain, so indices never appear in it), and each table row
|
|
51
|
+
* decides which members of the object being visited are slots.
|
|
52
|
+
*/
|
|
53
|
+
export declare function messageKeyUses(document: Record<string, unknown>): readonly MessageKeyUse[];
|
|
54
|
+
//# sourceMappingURL=slots.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slots.d.ts","sourceRoot":"","sources":["../../src/messages/slots.ts"],"names":[],"mappings":"AAmBA,4DAA4D;AAC5D,MAAM,WAAW,WAAW;IAC1B;;;;;;;;OAQG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB;;;;;;;;OAQG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,CAAC;CACtC;AAED;;;;GAIG;AACH,eAAO,MAAM,aAAa,EAAE,SAAS,WAAW,EA0B/C,CAAC;AAEF,uEAAuE;AACvE,MAAM,WAAW,aAAa;IAC5B,wDAAwD;IACxD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB;;;;;;;OAOG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,CAAC;CACtC;AA2DD;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,aAAa,EAAE,CAuB1F"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one table of message slots: every member of a schema document whose value is a message
|
|
3
|
+
* key, and whether the owning declaration binds that message's arguments.
|
|
4
|
+
*
|
|
5
|
+
* A slot is params-bearing when its owner declares a parameter block of expressions that bind
|
|
6
|
+
* the message's arguments: `params` on a rule, gate item, screen reason or layout node, and
|
|
7
|
+
* `unavailableParams` on an option. A params-less slot states
|
|
8
|
+
* presentation text with nothing to bind, so a message in it that interpolates anything would
|
|
9
|
+
* render with a missing argument on every record; refusing that at publish time
|
|
10
|
+
* (`MESSAGE_BINDING`) is the only place it can be refused.
|
|
11
|
+
*
|
|
12
|
+
* The table is the single answer to "which members name a message": the unresolved-key check,
|
|
13
|
+
* the params-less `{param}` refusal and the documentation drift test all read it, so a slot
|
|
14
|
+
* added here is checked everywhere and a slot missing here cannot quietly escape. The table is
|
|
15
|
+
* published on `@azx-pbc/axiom-compiler/testing`, not on the host door: it is the compiler's own
|
|
16
|
+
* walk, and the drift gate is its consumer.
|
|
17
|
+
*/
|
|
18
|
+
import { isRecord } from '@azx-pbc/axiom-runtime';
|
|
19
|
+
/**
|
|
20
|
+
* Every message slot of a schema document, `spec/semantics/model-v1.md`.
|
|
21
|
+
*
|
|
22
|
+
* A later layout or screen member adds its row here rather than another walk of the document.
|
|
23
|
+
*/
|
|
24
|
+
export const MESSAGE_SLOTS = [
|
|
25
|
+
{ path: 'titleKey', params: 'none' },
|
|
26
|
+
{ path: 'fields+.labelKey', params: 'none' },
|
|
27
|
+
{ path: 'fields+.descriptionKey', params: 'none' },
|
|
28
|
+
{ path: 'fields+.placeholderKey', params: 'none' },
|
|
29
|
+
{ path: 'fields+.requiredMessageKey', params: 'none' },
|
|
30
|
+
{ path: 'fields+.minimumMessageKey', params: 'none' },
|
|
31
|
+
{ path: 'fields+.maximumMessageKey', params: 'none' },
|
|
32
|
+
{ path: 'fields+.minLengthMessageKey', params: 'none' },
|
|
33
|
+
{ path: 'fields+.maxLengthMessageKey', params: 'none' },
|
|
34
|
+
{ path: 'fields+.maxScaleMessageKey', params: 'none' },
|
|
35
|
+
{ path: 'fields+.options.labelKey', params: 'none' },
|
|
36
|
+
// An option's availability states the sentence a reader sees when the code may not be chosen,
|
|
37
|
+
// with its arguments in `unavailableParams`, so the slot binds them like a rule's message.
|
|
38
|
+
{ path: 'fields+.options.unavailableMessageKey', params: 'optional' },
|
|
39
|
+
{ path: 'layout.children*.titleKey', params: 'optional' },
|
|
40
|
+
{ path: 'layout.children*.textKey', params: 'optional' },
|
|
41
|
+
{ path: 'layout.children*.descriptionKey', params: 'none' },
|
|
42
|
+
{ path: 'layout.children*.readouts.labelKey', params: 'none' },
|
|
43
|
+
{ path: 'rules.messageKey', params: 'optional' },
|
|
44
|
+
{ path: 'rules.gate.items.messageKey', params: 'optional' },
|
|
45
|
+
{ path: 'rules.reasons.messageKey', params: 'optional' },
|
|
46
|
+
// An alternative's label names the alternative for a reader. It states no arguments of its own,
|
|
47
|
+
// so a message that interpolates anything would render with a missing argument on every record.
|
|
48
|
+
{ path: 'rules.suggests.labelKey', params: 'none' },
|
|
49
|
+
{ path: 'fields+.options.suggests.labelKey', params: 'none' },
|
|
50
|
+
];
|
|
51
|
+
/** A path pattern split into its owner chain and the member the key is read from. */
|
|
52
|
+
function parseSlot(slot) {
|
|
53
|
+
const segments = slot.path.split('.');
|
|
54
|
+
const member = segments.pop();
|
|
55
|
+
if (member === undefined)
|
|
56
|
+
throw new Error(`message slot \`${slot.path}\` names no member`);
|
|
57
|
+
return {
|
|
58
|
+
owners: segments.map((segment) => {
|
|
59
|
+
if (segment.endsWith('*')) {
|
|
60
|
+
return { member: segment.slice(0, -1), nested: true, atLeastOne: false };
|
|
61
|
+
}
|
|
62
|
+
if (segment.endsWith('+')) {
|
|
63
|
+
return { member: segment.slice(0, -1), nested: true, atLeastOne: true };
|
|
64
|
+
}
|
|
65
|
+
return { member: segment, nested: false, atLeastOne: false };
|
|
66
|
+
}),
|
|
67
|
+
member,
|
|
68
|
+
params: slot.params,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Whether a member chain reaches a slot owner. A nested segment matches its member repeated
|
|
73
|
+
* zero or more times, and the rest of the pattern is tried at each length so a deeper chain
|
|
74
|
+
* cannot be cut short by a greedy match.
|
|
75
|
+
*/
|
|
76
|
+
function matchesOwners(owners, chain) {
|
|
77
|
+
const match = (at, depth) => {
|
|
78
|
+
if (at === owners.length)
|
|
79
|
+
return depth === chain.length;
|
|
80
|
+
const owner = owners[at];
|
|
81
|
+
if (owner === undefined)
|
|
82
|
+
return false;
|
|
83
|
+
if (!owner.nested) {
|
|
84
|
+
return chain[depth] === owner.member && match(at + 1, depth + 1);
|
|
85
|
+
}
|
|
86
|
+
// Zero or more: `fields*` is every declaration at any depth, and `layout.children*` is a
|
|
87
|
+
// layout node whether or not it nests children.
|
|
88
|
+
let end = depth;
|
|
89
|
+
while (chain[end] === owner.member)
|
|
90
|
+
end += 1;
|
|
91
|
+
const floor = owner.atLeastOne ? depth + 1 : depth;
|
|
92
|
+
for (let next = end; next >= floor; next -= 1) {
|
|
93
|
+
if (match(at + 1, next))
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
96
|
+
return false;
|
|
97
|
+
};
|
|
98
|
+
return match(0, 0);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Every message key the document names, in document order, tagged by whether the owning
|
|
102
|
+
* declaration binds the message's arguments.
|
|
103
|
+
*
|
|
104
|
+
* One walk, no per-slot traversal: the member chain is tracked as the tree is visited (list
|
|
105
|
+
* elements keep their owning member's chain, so indices never appear in it), and each table row
|
|
106
|
+
* decides which members of the object being visited are slots.
|
|
107
|
+
*/
|
|
108
|
+
export function messageKeyUses(document) {
|
|
109
|
+
const patterns = MESSAGE_SLOTS.map(parseSlot);
|
|
110
|
+
const uses = [];
|
|
111
|
+
const visit = (value, chain, path) => {
|
|
112
|
+
if (Array.isArray(value)) {
|
|
113
|
+
value.forEach((element, index) => visit(element, chain, `${path}[${String(index)}]`));
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
if (!isRecord(value))
|
|
117
|
+
return;
|
|
118
|
+
for (const pattern of patterns) {
|
|
119
|
+
if (!matchesOwners(pattern.owners, chain))
|
|
120
|
+
continue;
|
|
121
|
+
if (!Object.hasOwn(value, pattern.member))
|
|
122
|
+
continue;
|
|
123
|
+
const key = value[pattern.member];
|
|
124
|
+
if (typeof key !== 'string')
|
|
125
|
+
continue;
|
|
126
|
+
uses.push({ path: `${path}.${pattern.member}`, key, params: pattern.params });
|
|
127
|
+
}
|
|
128
|
+
for (const [member, child] of Object.entries(value)) {
|
|
129
|
+
if (!isRecord(child) && !Array.isArray(child))
|
|
130
|
+
continue;
|
|
131
|
+
visit(child, [...chain, member], `${path}.${member}`);
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
visit(document, [], '$');
|
|
135
|
+
return uses;
|
|
136
|
+
}
|
|
137
|
+
//# sourceMappingURL=slots.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slots.js","sourceRoot":"","sources":["../../src/messages/slots.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AA0BlD;;;;GAIG;AACH,MAAM,CAAC,MAAM,aAAa,GAA2B;IACnD,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE;IACpC,EAAE,IAAI,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,EAAE;IAC5C,EAAE,IAAI,EAAE,wBAAwB,EAAE,MAAM,EAAE,MAAM,EAAE;IAClD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,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;YACtF,OAAO;QACT,CAAC;QACD,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;YAAE,OAAO;QAC7B,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;YAC/B,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC;gBAAE,SAAS;YACpD,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC;gBAAE,SAAS;YACpD,MAAM,GAAG,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YAClC,IAAI,OAAO,GAAG,KAAK,QAAQ;gBAAE,SAAS;YACtC,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,GAAG,IAAI,IAAI,OAAO,CAAC,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;QAChF,CAAC;QACD,KAAK,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YACpD,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;gBAAE,SAAS;YACxD,KAAK,CAAC,KAAK,EAAE,CAAC,GAAG,KAAK,EAAE,MAAM,CAAC,EAAE,GAAG,IAAI,IAAI,MAAM,EAAE,CAAC,CAAC;QACxD,CAAC;IACH,CAAC,CAAC;IACF,KAAK,CAAC,QAAQ,EAAE,EAAE,EAAE,GAAG,CAAC,CAAC;IACzB,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["/**\n * The one table of message slots: every member of a schema document whose value is a message\n * key, and whether the owning declaration binds that message's arguments.\n *\n * A slot is params-bearing when its owner declares a parameter block of expressions that bind\n * the message's arguments: `params` on a rule, gate item, screen reason or layout node, and\n * `unavailableParams` on an option. A params-less slot states\n * presentation text with nothing to bind, so a message in it that interpolates anything would\n * render with a missing argument on every record; refusing that at publish time\n * (`MESSAGE_BINDING`) is the only place it can be refused.\n *\n * The table is the single answer to \"which members name a message\": the unresolved-key check,\n * the params-less `{param}` refusal and the documentation drift test all read it, so a slot\n * added here is checked everywhere and a slot missing here cannot quietly escape. The table is\n * published on `@azx-pbc/axiom-compiler/testing`, not on the host door: it is the compiler's own\n * walk, and the drift gate is its consumer.\n */\nimport { isRecord } from '@azx-pbc/axiom-runtime';\n\n/** One member a schema document names a message through. */\nexport interface MessageSlot {\n /**\n * The path to the slot from the document root, with list indices dropped, so\n * `$.fields[0].options[2].labelKey` is `fields.options.labelKey`.\n *\n * A member written with a trailing `*` matches that member repeated zero or more times;\n * a trailing `+` matches it one or more times. `layout.children*` admits a top-level\n * layout node; `fields+` requires at least one enclosing field. The last segment is the\n * member the key is read from; the segments before it are its owners.\n */\n readonly path: string;\n /**\n * Whether the slot's owner binds the message's arguments in a parameter block.\n *\n * `none`: the slot states presentation text and has nothing to bind, so a message in it may\n * not interpolate anything and the params-less check refuses it. `optional`: the owner may\n * bind the message's arguments, so the check that compiles that declaration reports an\n * argument it does not bind, naming the declaration, and the params-less check leaves the\n * slot alone.\n */\n readonly params: 'none' | 'optional';\n}\n\n/**\n * Every message slot of a schema document, `spec/semantics/model-v1.md`.\n *\n * A later layout or screen member adds its row here rather than another walk of the document.\n */\nexport const MESSAGE_SLOTS: readonly MessageSlot[] = [\n { path: 'titleKey', params: 'none' },\n { path: 'fields+.labelKey', params: 'none' },\n { path: 'fields+.descriptionKey', params: 'none' },\n { path: 'fields+.placeholderKey', params: 'none' },\n { path: 'fields+.requiredMessageKey', params: 'none' },\n { path: 'fields+.minimumMessageKey', params: 'none' },\n { path: 'fields+.maximumMessageKey', params: 'none' },\n { path: 'fields+.minLengthMessageKey', params: 'none' },\n { path: 'fields+.maxLengthMessageKey', params: 'none' },\n { path: 'fields+.maxScaleMessageKey', params: 'none' },\n { path: 'fields+.options.labelKey', params: 'none' },\n // An option's availability states the sentence a reader sees when the code may not be chosen,\n // with its arguments in `unavailableParams`, so the slot binds them like a rule's message.\n { path: 'fields+.options.unavailableMessageKey', params: 'optional' },\n { path: 'layout.children*.titleKey', params: 'optional' },\n { path: 'layout.children*.textKey', params: 'optional' },\n { path: 'layout.children*.descriptionKey', params: 'none' },\n { path: 'layout.children*.readouts.labelKey', params: 'none' },\n { path: 'rules.messageKey', params: 'optional' },\n { path: 'rules.gate.items.messageKey', params: 'optional' },\n { path: 'rules.reasons.messageKey', params: 'optional' },\n // An alternative's label names the alternative for a reader. It states no arguments of its own,\n // so a message that interpolates anything would render with a missing argument on every record.\n { path: 'rules.suggests.labelKey', params: 'none' },\n { path: 'fields+.options.suggests.labelKey', params: 'none' },\n];\n\n/** One reference to a declared message, and the slot that makes it. */\nexport interface MessageKeyUse {\n /** Where in the document, as `$.fields[0].labelKey`. */\n readonly path: string;\n readonly key: string;\n /**\n * The slot's declared class: `optional` when the owning declaration binds the message's\n * arguments in `params`, `none` when the slot has nothing to bind.\n *\n * A use is not resolved against the entry it belongs to. The check that compiles a rule or a\n * gate item refuses an argument that declaration does not bind and names the declaration, so\n * a second refusal here would report one cause twice at one path.\n */\n readonly params: 'none' | 'optional';\n}\n\n/** One row of `MESSAGE_SLOTS`, resolved into the chain it matches and the member it reads. */\ninterface SlotPattern {\n readonly owners: readonly {\n readonly member: string;\n readonly nested: boolean;\n readonly atLeastOne: boolean;\n }[];\n readonly member: string;\n readonly params: 'none' | 'optional';\n}\n\n/** A path pattern split into its owner chain and the member the key is read from. */\nfunction parseSlot(slot: MessageSlot): SlotPattern {\n const segments = slot.path.split('.');\n const member = segments.pop();\n if (member === undefined) throw new Error(`message slot \\`${slot.path}\\` names no member`);\n return {\n owners: segments.map((segment) => {\n if (segment.endsWith('*')) {\n return { member: segment.slice(0, -1), nested: true, atLeastOne: false };\n }\n if (segment.endsWith('+')) {\n return { member: segment.slice(0, -1), nested: true, atLeastOne: true };\n }\n return { member: segment, nested: false, atLeastOne: false };\n }),\n member,\n params: slot.params,\n };\n}\n\n/**\n * Whether a member chain reaches a slot owner. A nested segment matches its member repeated\n * zero or more times, and the rest of the pattern is tried at each length so a deeper chain\n * cannot be cut short by a greedy match.\n */\nfunction matchesOwners(owners: SlotPattern['owners'], chain: readonly string[]): boolean {\n const match = (at: number, depth: number): boolean => {\n if (at === owners.length) return depth === chain.length;\n const owner = owners[at];\n if (owner === undefined) return false;\n if (!owner.nested) {\n return chain[depth] === owner.member && match(at + 1, depth + 1);\n }\n // Zero or more: `fields*` is every declaration at any depth, and `layout.children*` is a\n // layout node whether or not it nests children.\n let end = depth;\n while (chain[end] === owner.member) end += 1;\n const floor = owner.atLeastOne ? depth + 1 : depth;\n for (let next = end; next >= floor; next -= 1) {\n if (match(at + 1, next)) return true;\n }\n return false;\n };\n return match(0, 0);\n}\n\n/**\n * Every message key the document names, in document order, tagged by whether the owning\n * declaration binds the message's arguments.\n *\n * One walk, no per-slot traversal: the member chain is tracked as the tree is visited (list\n * elements keep their owning member's chain, so indices never appear in it), and each table row\n * decides which members of the object being visited are slots.\n */\nexport function messageKeyUses(document: Record<string, unknown>): readonly MessageKeyUse[] {\n const patterns = MESSAGE_SLOTS.map(parseSlot);\n const uses: MessageKeyUse[] = [];\n const visit = (value: unknown, chain: readonly string[], path: string): void => {\n if (Array.isArray(value)) {\n value.forEach((element, index) => visit(element, chain, `${path}[${String(index)}]`));\n return;\n }\n if (!isRecord(value)) return;\n for (const pattern of patterns) {\n if (!matchesOwners(pattern.owners, chain)) continue;\n if (!Object.hasOwn(value, pattern.member)) continue;\n const key = value[pattern.member];\n if (typeof key !== 'string') continue;\n uses.push({ path: `${path}.${pattern.member}`, key, params: pattern.params });\n }\n for (const [member, child] of Object.entries(value)) {\n if (!isRecord(child) && !Array.isArray(child)) continue;\n visit(child, [...chain, member], `${path}.${member}`);\n }\n };\n visit(document, [], '$');\n return uses;\n}\n"]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { CompileOptions } from '../compile/types.js';
|
|
2
|
+
import type { OverlayCompileResult, OverlaySource } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Compiles one base document and an ordered set of overlays into one artifact
|
|
5
|
+
* (`spec/semantics/evolution-v1.md` `[EVOL-4.1.1]`–`[EVOL-4.1.4]`).
|
|
6
|
+
*
|
|
7
|
+
* The base is inspected by the same ingestion and closed-metaschema walk `compile()` uses.
|
|
8
|
+
* Every overlay's text is read by the same restricted-JSON reader, then composed over the
|
|
9
|
+
* document in the order supplied — base, `overlays[0]`, `overlays[1]`, and so on — and the
|
|
10
|
+
* composed document is inspected and compiled once, so a later layer's expressions may name a
|
|
11
|
+
* field, rule, message or context root an earlier layer added.
|
|
12
|
+
*
|
|
13
|
+
* An empty `overlays` list returns exactly the artifact `compile(base, options)` returns: no
|
|
14
|
+
* `composition` member is added, so the bytes and `behaviorHash` are unchanged.
|
|
15
|
+
*
|
|
16
|
+
* A non-empty list adds `composition: { baseVersion, overlays }` to the artifact. The runtime
|
|
17
|
+
* copies that member into every evaluation report and hashes it, so the report names the exact
|
|
18
|
+
* configuration that produced it. The same value is returned beside the artifact for a build
|
|
19
|
+
* step that prints the version report without reading the artifact.
|
|
20
|
+
*
|
|
21
|
+
* A refusal names the overlay and the field, rule, message or table that caused it. Two
|
|
22
|
+
* refusals go beyond the literal `[EVOL-4.1.2]` wording on purpose: a removal or rename of any
|
|
23
|
+
* field an earlier layer publishes is refused, not only one the base document's own `covers`
|
|
24
|
+
* declarations name, because a host's retained signatures are not visible to the compiler. The
|
|
25
|
+
* narrower literal reading would let an overlay remove a field a retained signature covers and
|
|
26
|
+
* the compiler would have no way to know.
|
|
27
|
+
*/
|
|
28
|
+
export declare function compileOverlay(base: string, overlays: readonly OverlaySource[], options?: CompileOptions): OverlayCompileResult;
|
|
29
|
+
//# sourceMappingURL=compile-overlay.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compile-overlay.d.ts","sourceRoot":"","sources":["../../src/overlay/compile-overlay.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAkB,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAM1E,OAAO,KAAK,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAsCtE;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,SAAS,aAAa,EAAE,EAClC,OAAO,GAAE,cAAmB,GAC3B,oBAAoB,CA2DtB"}
|