@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,422 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Writing a command's verdict: diagnostics an author reads, and the artifact it asked for.
|
|
3
|
+
*
|
|
4
|
+
* A diagnostic line always begins with the document it came from, so a run over several files
|
|
5
|
+
* never leaves a message whose subject the reader has to guess.
|
|
6
|
+
*/
|
|
7
|
+
import { mkdtemp, open, rename, rm, stat } from 'node:fs/promises';
|
|
8
|
+
import { dirname, join } from 'node:path';
|
|
9
|
+
import process from 'node:process';
|
|
10
|
+
import { assertNever, canonicalizeRestricted } from '@azx-pbc/axiom-runtime';
|
|
11
|
+
import { datasetDiagnosticRepair } from '../datasets/repair.js';
|
|
12
|
+
import { parseDocumentPath } from '../document-path.js';
|
|
13
|
+
import { documentFormatOf } from '../ingest/document.js';
|
|
14
|
+
import { ingestDocument } from '../ingest/yaml-document.js';
|
|
15
|
+
import { schemaDiagnosticRepair } from '../schema/repair.js';
|
|
16
|
+
import { noun } from './count.js';
|
|
17
|
+
import { displayPath, STDIO_PATH } from './read.js';
|
|
18
|
+
import { causeText, jsonTerminalText, jsonText, printErrorLine, printLine } from './terminal.js';
|
|
19
|
+
import { EXIT_OK, EXIT_USAGE } from './usage.js';
|
|
20
|
+
/**
|
|
21
|
+
* The grouping key for one per-key locale line, or `undefined` when the line stands alone.
|
|
22
|
+
*
|
|
23
|
+
* A misspelt locale in a catalogue is one mistake repeated under every message key, so the
|
|
24
|
+
* validator's structured entries stay one per key while the report states it once. The cause
|
|
25
|
+
* text participates as well as `(code, locale, expected)`: two lines that name different
|
|
26
|
+
* defects must never be folded into one just because they share a locale.
|
|
27
|
+
*/
|
|
28
|
+
function localeGroupKey(diagnostic) {
|
|
29
|
+
if (diagnostic.code !== 'MESSAGE_LOCALE')
|
|
30
|
+
return undefined;
|
|
31
|
+
if (diagnostic.messageKey === undefined || diagnostic.expected === undefined)
|
|
32
|
+
return undefined;
|
|
33
|
+
return JSON.stringify([
|
|
34
|
+
diagnostic.code,
|
|
35
|
+
diagnostic.locale ?? '',
|
|
36
|
+
diagnostic.expected,
|
|
37
|
+
diagnostic.detail,
|
|
38
|
+
]);
|
|
39
|
+
}
|
|
40
|
+
/** The diagnostics as the lines to print, with a repeated locale spelling stated once. */
|
|
41
|
+
function diagnosticEntries(diagnostics) {
|
|
42
|
+
const entries = [];
|
|
43
|
+
const groups = new Map();
|
|
44
|
+
for (const diagnostic of diagnostics) {
|
|
45
|
+
const key = localeGroupKey(diagnostic);
|
|
46
|
+
if (key === undefined) {
|
|
47
|
+
entries.push({ diagnostic, keyCount: 1 });
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
const group = groups.get(key);
|
|
51
|
+
if (group === undefined) {
|
|
52
|
+
groups.set(key, { index: entries.length, count: 1 });
|
|
53
|
+
entries.push({ diagnostic, keyCount: 1 });
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
group.count += 1;
|
|
57
|
+
const first = entries[group.index];
|
|
58
|
+
if (first !== undefined)
|
|
59
|
+
entries[group.index] = { diagnostic: first.diagnostic, keyCount: group.count };
|
|
60
|
+
}
|
|
61
|
+
return entries;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* How much of an offending line a diagnostic quotes, on each side of the caret.
|
|
65
|
+
*
|
|
66
|
+
* A document's line is as long as its author made it — one 50 MB JSON body is one line — and the
|
|
67
|
+
* excerpt used to be the whole line plus `' '.repeat(column)`, so an over-long line made the
|
|
68
|
+
* command write twice the document to stderr. The window is a report, not a proof: enough text
|
|
69
|
+
* either side to read the mistake, in a line a CI log can carry.
|
|
70
|
+
*/
|
|
71
|
+
const EXCERPT_WINDOW = 160;
|
|
72
|
+
const EXCERPT_ELLIPSIS = '…';
|
|
73
|
+
/**
|
|
74
|
+
* `line N, column M` and the offending line with a caret under `offset`, for a diagnostic
|
|
75
|
+
* whose offset indexes the document the command read or the expression slot the path names.
|
|
76
|
+
*
|
|
77
|
+
* A document offset becomes a line, a column and the line itself. An expression offset
|
|
78
|
+
* indexes the source in one slot, not the file, so the same window is drawn over the slot
|
|
79
|
+
* text the path resolves to instead of over the document. The caller passes the parsed
|
|
80
|
+
* document through `slotSource`, which fails soft: a path that names no string slot, or a
|
|
81
|
+
* document that cannot be parsed, renders no excerpt rather than a caret at the wrong member.
|
|
82
|
+
*
|
|
83
|
+
* The quoted line is clamped to `EXCERPT_WINDOW` code units either side of the offset, so the
|
|
84
|
+
* bytes a hostile document can make this write are a constant per diagnostic rather than twice
|
|
85
|
+
* the line's length. The column still names the position in the real line; only the quote is a
|
|
86
|
+
* window into it, and an ellipsis marks each clipped end.
|
|
87
|
+
*/
|
|
88
|
+
function sourceExcerpt(source, offset) {
|
|
89
|
+
const bounded = Math.min(Math.max(offset, 0), source.length);
|
|
90
|
+
const lineStart = source.lastIndexOf('\n', bounded - 1) + 1;
|
|
91
|
+
const lineEnd = source.indexOf('\n', bounded);
|
|
92
|
+
const line = source.slice(lineStart, lineEnd === -1 ? source.length : lineEnd).replace(/\r$/, '');
|
|
93
|
+
const lineNumber = source.slice(0, lineStart).split('\n').length;
|
|
94
|
+
const column = bounded - lineStart + 1;
|
|
95
|
+
const from = Math.max(0, column - 1 - EXCERPT_WINDOW);
|
|
96
|
+
const to = Math.min(line.length, column - 1 + EXCERPT_WINDOW);
|
|
97
|
+
const head = from > 0 ? EXCERPT_ELLIPSIS : '';
|
|
98
|
+
const tail = to < line.length ? EXCERPT_ELLIPSIS : '';
|
|
99
|
+
const quoted = `${head}${line.slice(from, to)}${tail}`;
|
|
100
|
+
// The caret sits under the offset within the quoted window, so the padding is bounded by the
|
|
101
|
+
// window and the leading ellipsis it accounts for.
|
|
102
|
+
const caretColumn = head.length + (column - 1 - from);
|
|
103
|
+
return [
|
|
104
|
+
` line ${String(lineNumber)}, column ${String(column)}`,
|
|
105
|
+
` ${quoted}`,
|
|
106
|
+
` ${' '.repeat(Math.min(caretColumn, quoted.length))}^`,
|
|
107
|
+
];
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* The expression source the diagnostic path names, or `undefined` when there is none.
|
|
111
|
+
*
|
|
112
|
+
* An expression slot is authored as document text, so the excerpt is drawn from the slot
|
|
113
|
+
* value rather than from the whole document. The walk reads an already-parsed document by
|
|
114
|
+
* the path the compiler rendered, checking own properties only so prototype names never
|
|
115
|
+
* resolve as slots. Only a string slot is an excerpt source: a compiled node, a missing
|
|
116
|
+
* member or a non-string value renders no excerpt. Nothing here changes an offset; the
|
|
117
|
+
* excerpt is display only.
|
|
118
|
+
*/
|
|
119
|
+
function slotSource(document, path) {
|
|
120
|
+
const parsed = parseDocumentPath(path);
|
|
121
|
+
if (!parsed.ok)
|
|
122
|
+
return undefined;
|
|
123
|
+
let current = document;
|
|
124
|
+
for (const segment of parsed.segments) {
|
|
125
|
+
if (typeof segment === 'number') {
|
|
126
|
+
if (!Array.isArray(current))
|
|
127
|
+
return undefined;
|
|
128
|
+
current = current[segment];
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
if (typeof current !== 'object' || current === null || Array.isArray(current)) {
|
|
132
|
+
return undefined;
|
|
133
|
+
}
|
|
134
|
+
if (!Object.hasOwn(current, segment))
|
|
135
|
+
return undefined;
|
|
136
|
+
current = Reflect.get(current, segment);
|
|
137
|
+
}
|
|
138
|
+
return typeof current === 'string' ? current : undefined;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* How many times `reportSchemaDiagnostics` parsed a document from source text to draw
|
|
142
|
+
* expression excerpts. Counted rather than timed, so tests verify one parse per report
|
|
143
|
+
* without a wall-clock assertion.
|
|
144
|
+
*/
|
|
145
|
+
let excerptParseCount = 0;
|
|
146
|
+
/** Process-lifetime count of source parses performed for expression excerpts. */
|
|
147
|
+
export function excerptDocumentParses() {
|
|
148
|
+
return excerptParseCount;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* The candidate spelling a diagnostic carries, unless its cause already states one.
|
|
152
|
+
*
|
|
153
|
+
* A suggestion travels twice: as prose in `detail` for an expression refusal, and as the
|
|
154
|
+
* structured `suggestions` list an editor offers. Printing the list unconditionally would
|
|
155
|
+
* repeat "did you mean f_amount?" on the same line. A diagnostic with a canonical `expected`
|
|
156
|
+
* form already states the repair and its candidates, so the list adds only noise there; the
|
|
157
|
+
* list is the repair for a cause — a misspelt root member, a field source — that names none.
|
|
158
|
+
*/
|
|
159
|
+
function suggestionText(diagnostic) {
|
|
160
|
+
const suggestions = diagnostic.suggestions;
|
|
161
|
+
if (suggestions === undefined || suggestions.length === 0)
|
|
162
|
+
return '';
|
|
163
|
+
if (diagnostic.expected !== undefined)
|
|
164
|
+
return '';
|
|
165
|
+
if (/\bdid you mean\b/iu.test(diagnostic.detail))
|
|
166
|
+
return '';
|
|
167
|
+
return `did you mean ${suggestions.map((name) => `\`${name}\``).join(' or ')}?`;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Appends a repair clause to a cause. A cause that already ended a sentence — a validator
|
|
171
|
+
* message usually does — starts the clause as its own sentence; every other cause joins it
|
|
172
|
+
* with the semicolon the report uses between a fact and its repair.
|
|
173
|
+
*/
|
|
174
|
+
function withRepair(detail, clause) {
|
|
175
|
+
if (clause === '')
|
|
176
|
+
return detail;
|
|
177
|
+
return detail.endsWith('.')
|
|
178
|
+
? `${detail} ${clause.charAt(0).toUpperCase()}${clause.slice(1)}`
|
|
179
|
+
: `${detail}; ${clause}`;
|
|
180
|
+
}
|
|
181
|
+
/** One diagnostic line, without the document prefix, with the repair the diagnostic carries. */
|
|
182
|
+
function diagnosticText(diagnostic) {
|
|
183
|
+
const expected = diagnostic.expected === undefined ? '' : `expected \`${diagnostic.expected}\``;
|
|
184
|
+
let text = `${diagnostic.path}: ${diagnostic.code}: ${diagnostic.detail}`;
|
|
185
|
+
text = withRepair(text, suggestionText(diagnostic));
|
|
186
|
+
text = withRepair(text, expected);
|
|
187
|
+
return withRepair(text, unstatedRepair(diagnostic));
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* The repair the code's row states, unless the detail already states it.
|
|
191
|
+
*
|
|
192
|
+
* A specific cause that ends with the action — a duplicate that says which identifier to
|
|
193
|
+
* choose — stays one sentence. A cause that is only a fact — a metaschema keyword, an
|
|
194
|
+
* ingestion parser's message, a count — receives the code's repair here, so a terminal line
|
|
195
|
+
* never leaves an author without an action.
|
|
196
|
+
*/
|
|
197
|
+
function unstatedRepair(diagnostic) {
|
|
198
|
+
if (diagnostic.repairStated === true)
|
|
199
|
+
return '';
|
|
200
|
+
// A suggestion is already the repair for a misspelt name: printing the code's generic action
|
|
201
|
+
// beside `did you mean \`fields\`?` would state the same fix twice in different words.
|
|
202
|
+
if (diagnostic.suggestions !== undefined && diagnostic.suggestions.length > 0)
|
|
203
|
+
return '';
|
|
204
|
+
const { anchor, repair } = schemaDiagnosticRepair(diagnostic.code);
|
|
205
|
+
return diagnostic.detail.toLowerCase().includes(anchor.toLowerCase()) ? '' : repair;
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Prints a compile's warnings on the diagnostics stream, without changing the exit code.
|
|
209
|
+
*
|
|
210
|
+
* A warning is advice, not a refusal, so the line is written to stderr beside a
|
|
211
|
+
* successful check or compile and the command still exits 0. The detail already names the
|
|
212
|
+
* replacement or the declaration that removes the finding; printing it here is what makes the
|
|
213
|
+
* warning visible to an author who never reads the `CompileSuccess` object.
|
|
214
|
+
*/
|
|
215
|
+
export function reportCompileWarnings(target, warnings) {
|
|
216
|
+
for (const warning of warnings) {
|
|
217
|
+
printErrorLine(`${displayPath(target)}: ${warning.path}: ${warning.code}: ${warning.detail}`);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Prints a schema's diagnostics, bounded by the cap the operator named.
|
|
222
|
+
*
|
|
223
|
+
* The bound is on the report only — the diagnostics arrive exhaustive from `compile()` —
|
|
224
|
+
* and a capped report ends by naming how many were withheld, so an operator always knows
|
|
225
|
+
* whether the list they read is the whole verdict. `source` is the text the command read, so
|
|
226
|
+
* a documented position becomes a line, a column and the line itself.
|
|
227
|
+
*/
|
|
228
|
+
export function reportSchemaDiagnostics(target, source, diagnostics, cap, options = {}) {
|
|
229
|
+
const format = options.format ?? documentFormatOf(target);
|
|
230
|
+
let excerptDocument = options.document !== undefined
|
|
231
|
+
? { status: 'parsed', value: options.document }
|
|
232
|
+
: { status: 'unparsed' };
|
|
233
|
+
const entries = diagnosticEntries(diagnostics);
|
|
234
|
+
const shown = cap === 'all' ? entries : entries.slice(0, cap);
|
|
235
|
+
for (const entry of shown) {
|
|
236
|
+
const suffix = entry.keyCount > 1 ? `; affects ${String(entry.keyCount)} message keys` : '';
|
|
237
|
+
printErrorLine(`${target}: ${diagnosticText(entry.diagnostic)}${suffix}`);
|
|
238
|
+
const offset = entry.diagnostic.offset;
|
|
239
|
+
if (offset === undefined)
|
|
240
|
+
continue;
|
|
241
|
+
if (entry.diagnostic.offsetSource === 'document') {
|
|
242
|
+
for (const line of sourceExcerpt(source, offset))
|
|
243
|
+
printErrorLine(line);
|
|
244
|
+
continue;
|
|
245
|
+
}
|
|
246
|
+
// An expression offset is drawn over the slot text, using the same clamp. The document is
|
|
247
|
+
// parsed at most once per report (and zero times when the caller passed the ingested tree).
|
|
248
|
+
// A path that names no string slot renders no excerpt; the diagnostic line above still
|
|
249
|
+
// carries the path, the code and the repair.
|
|
250
|
+
if (entry.diagnostic.offsetSource === 'expression') {
|
|
251
|
+
if (excerptDocument.status === 'unparsed') {
|
|
252
|
+
excerptParseCount += 1;
|
|
253
|
+
const ingested = ingestDocument(source, format);
|
|
254
|
+
excerptDocument = ingested.ok
|
|
255
|
+
? { status: 'parsed', value: ingested.value }
|
|
256
|
+
: { status: 'unavailable' };
|
|
257
|
+
}
|
|
258
|
+
if (excerptDocument.status !== 'parsed')
|
|
259
|
+
continue;
|
|
260
|
+
const slot = slotSource(excerptDocument.value, entry.diagnostic.path);
|
|
261
|
+
if (slot === undefined)
|
|
262
|
+
continue;
|
|
263
|
+
for (const line of sourceExcerpt(slot, offset))
|
|
264
|
+
printErrorLine(line);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
const shownCount = shown.reduce((total, entry) => total + entry.keyCount, 0);
|
|
268
|
+
const withheld = diagnostics.length - shownCount;
|
|
269
|
+
if (withheld > 0) {
|
|
270
|
+
printErrorLine(`${target}: … and ${String(withheld)} more ${noun(withheld, 'diagnostic')} withheld; run again with --max-diagnostics=all to see them`);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
/** Where an author looks for a dataset problem: the table row and the declared column. */
|
|
274
|
+
function datasetLocation(diagnostic) {
|
|
275
|
+
const parts = [];
|
|
276
|
+
if (diagnostic.row !== undefined)
|
|
277
|
+
parts.push(`row ${String(diagnostic.row)}`);
|
|
278
|
+
if (diagnostic.column !== undefined)
|
|
279
|
+
parts.push(`column ${diagnostic.column}`);
|
|
280
|
+
return parts.length === 0 ? 'table' : parts.join(', ');
|
|
281
|
+
}
|
|
282
|
+
/** Prints dataset diagnostics, each with the document, position and member path at fault. */
|
|
283
|
+
export function reportDatasetDiagnostics(target, diagnostics) {
|
|
284
|
+
for (const diagnostic of diagnostics) {
|
|
285
|
+
const { anchor, repair } = datasetDiagnosticRepair(diagnostic.code);
|
|
286
|
+
const action = diagnostic.detail.toLowerCase().includes(anchor.toLowerCase())
|
|
287
|
+
? ''
|
|
288
|
+
: `; ${repair}`;
|
|
289
|
+
printErrorLine(`${target}: ${datasetLocation(diagnostic)}: ${diagnostic.code}: ${diagnostic.detail}${action} [${diagnostic.path}]`);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Emits a command's JSON artifact to `--out`, or to stdout when the operator named no file.
|
|
294
|
+
* A file is data and gets the document itself; a terminal gets the spelling whose code
|
|
295
|
+
* points cannot act on it. `--out -` is the explicit spelling of the stdout default.
|
|
296
|
+
* The file is staged beside its destination and renamed into place, so a failed write
|
|
297
|
+
* cannot leave a truncated artifact or let a planted symlink redirect the bytes, and an output
|
|
298
|
+
* that names an input is refused by the file's own identity rather than by how its path is
|
|
299
|
+
* spelled — a symlinked directory or a hard link is refused too, rather than replacing the
|
|
300
|
+
* document the command just read.
|
|
301
|
+
*/
|
|
302
|
+
export async function emitJson(out, value, inputs = []) {
|
|
303
|
+
// A terminal gets the escaped spelling; a file gets the document itself, which is what a tool
|
|
304
|
+
// reading the artifact expects. `--out -` names the terminal, not a file called `-`.
|
|
305
|
+
const toTerminal = out === undefined || out === STDIO_PATH;
|
|
306
|
+
const text = toTerminal ? `${jsonText(value)}\n` : `${JSON.stringify(value, null, 2)}\n`;
|
|
307
|
+
return emitText(out, text, inputs);
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Emits a value as restricted-JCS canonical text, so two runs that decided the same thing write
|
|
311
|
+
* the same bytes. Those bytes make publish proposals comparable, never authenticated: a later
|
|
312
|
+
* gate re-derives its verdict from the artifact, the suites and the tables rather than letting
|
|
313
|
+
* the file stand in for the run.
|
|
314
|
+
*
|
|
315
|
+
* A file gets those canonical bytes. `--out -` names the terminal, and a report interpolates what
|
|
316
|
+
* an untrusted document declared — a vector's `expected`, a suite's refusal — so the stream gets
|
|
317
|
+
* the same bytes with each code point a terminal acts on spelled as its JSON escape: a legal
|
|
318
|
+
* spelling of the same report, which is what a caller piping it onward parses back.
|
|
319
|
+
*/
|
|
320
|
+
export async function emitCanonicalJson(out, value, inputs = []) {
|
|
321
|
+
const canonical = `${canonicalizeRestricted(value)}\n`;
|
|
322
|
+
const toTerminal = out === undefined || out === STDIO_PATH;
|
|
323
|
+
return emitText(out, toTerminal ? jsonTerminalText(canonical) : canonical, inputs);
|
|
324
|
+
}
|
|
325
|
+
/** The Node error code carried by a filesystem failure, when present. */
|
|
326
|
+
function errorCode(cause) {
|
|
327
|
+
if (typeof cause !== 'object' || cause === null || !('code' in cause))
|
|
328
|
+
return undefined;
|
|
329
|
+
return typeof cause.code === 'string' ? cause.code : undefined;
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* The file one path reaches now, as its `(device, inode)` identity, distinguishing an absent
|
|
333
|
+
* path (`ENOENT`) from any other `stat` failure (`EACCES`, `ELOOP`, `ENOTDIR`, and so on).
|
|
334
|
+
*
|
|
335
|
+
* `stat` follows every symlink, so two spellings of one file (a symlinked directory, a hard
|
|
336
|
+
* link, a relative name) answer with the same identity. Only `ENOENT` means nothing exists at
|
|
337
|
+
* the path; any other failure must fail closed rather than disable the input-replacement guard.
|
|
338
|
+
*/
|
|
339
|
+
async function fileIdentity(target) {
|
|
340
|
+
try {
|
|
341
|
+
const info = await stat(target);
|
|
342
|
+
return { status: 'found', identity: `${String(info.dev)}:${String(info.ino)}` };
|
|
343
|
+
}
|
|
344
|
+
catch (cause) {
|
|
345
|
+
if (errorCode(cause) === 'ENOENT')
|
|
346
|
+
return { status: 'absent' };
|
|
347
|
+
return { status: 'error', cause };
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
/** Writes `text` to the named destination or standard output. */
|
|
351
|
+
async function emitText(out, text, inputs) {
|
|
352
|
+
if (out === undefined || out === STDIO_PATH) {
|
|
353
|
+
process.stdout.write(text);
|
|
354
|
+
return EXIT_OK;
|
|
355
|
+
}
|
|
356
|
+
// A destination that already names a document this run read would replace it, however the
|
|
357
|
+
// path is spelled: a symlinked directory or a hard link hides the same file behind another
|
|
358
|
+
// name, which a comparison of the written paths cannot see. `-` is a stream, not a path, so
|
|
359
|
+
// it is never an input a destination could replace. Any non-ENOENT stat failure fails closed
|
|
360
|
+
// so an unverified destination or input cannot bypass the guard.
|
|
361
|
+
const destination = await fileIdentity(out);
|
|
362
|
+
switch (destination.status) {
|
|
363
|
+
case 'error':
|
|
364
|
+
printErrorLine(`axiom-cli: cannot write ${out}: ${causeText(destination.cause)}`);
|
|
365
|
+
return EXIT_USAGE;
|
|
366
|
+
case 'absent':
|
|
367
|
+
break;
|
|
368
|
+
case 'found': {
|
|
369
|
+
for (const input of inputs) {
|
|
370
|
+
if (input === STDIO_PATH)
|
|
371
|
+
continue;
|
|
372
|
+
const identity = await fileIdentity(input);
|
|
373
|
+
switch (identity.status) {
|
|
374
|
+
case 'absent':
|
|
375
|
+
continue;
|
|
376
|
+
case 'found':
|
|
377
|
+
if (identity.identity === destination.identity) {
|
|
378
|
+
printErrorLine(`axiom-cli: --out ${out} would replace an input document`);
|
|
379
|
+
return EXIT_USAGE;
|
|
380
|
+
}
|
|
381
|
+
continue;
|
|
382
|
+
case 'error':
|
|
383
|
+
printErrorLine(`axiom-cli: cannot verify whether --out ${out} would replace input ${input}: ${causeText(identity.cause)}`);
|
|
384
|
+
return EXIT_USAGE;
|
|
385
|
+
default:
|
|
386
|
+
return assertNever(identity);
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
break;
|
|
390
|
+
}
|
|
391
|
+
default:
|
|
392
|
+
return assertNever(destination);
|
|
393
|
+
}
|
|
394
|
+
// The bytes are staged in a directory nobody can predict, created exclusively, and flushed
|
|
395
|
+
// before the rename: a symlink planted at a guessable name cannot redirect the write, and a
|
|
396
|
+
// failed flush cannot leave a truncated artifact in place of the verdict.
|
|
397
|
+
let staging;
|
|
398
|
+
try {
|
|
399
|
+
staging = await mkdtemp(join(dirname(out), '.axiom-out-'));
|
|
400
|
+
const temporary = join(staging, 'artifact');
|
|
401
|
+
const handle = await open(temporary, 'wx');
|
|
402
|
+
try {
|
|
403
|
+
await handle.writeFile(text, 'utf8');
|
|
404
|
+
await handle.sync();
|
|
405
|
+
}
|
|
406
|
+
finally {
|
|
407
|
+
await handle.close();
|
|
408
|
+
}
|
|
409
|
+
await rename(temporary, out);
|
|
410
|
+
}
|
|
411
|
+
catch (cause) {
|
|
412
|
+
printErrorLine(`axiom-cli: cannot write ${out}: ${causeText(cause)}`);
|
|
413
|
+
return EXIT_USAGE;
|
|
414
|
+
}
|
|
415
|
+
finally {
|
|
416
|
+
if (staging !== undefined)
|
|
417
|
+
await rm(staging, { recursive: true, force: true });
|
|
418
|
+
}
|
|
419
|
+
printLine(`wrote ${out}`);
|
|
420
|
+
return EXIT_OK;
|
|
421
|
+
}
|
|
422
|
+
//# sourceMappingURL=render.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render.js","sourceRoot":"","sources":["../../src/cli/render.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH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AAO,WAAW,CAAC,QAAQ,CAAC,CAAC;gBACjC,CAAC;YACH,CAAC;YACD,MAAM;QACR,CAAC;QACD;YACE,OAAO,WAAW,CAAC,WAAW,CAAC,CAAC;IACpC,CAAC;IACD,2FAA2F;IAC3F,4FAA4F;IAC5F,0EAA0E;IAC1E,IAAI,OAA2B,CAAC;IAChC,IAAI,CAAC;QACH,OAAO,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,aAAa,CAAC,CAAC,CAAC;QAC3D,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;QAC5C,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;QAC3C,IAAI,CAAC;YACH,MAAM,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;YACrC,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;QACtB,CAAC;gBAAS,CAAC;YACT,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;QACvB,CAAC;QACD,MAAM,MAAM,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;IAC/B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,cAAc,CAAC,2BAA2B,GAAG,KAAK,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACtE,OAAO,UAAU,CAAC;IACpB,CAAC;YAAS,CAAC;QACT,IAAI,OAAO,KAAK,SAAS;YAAE,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACjF,CAAC;IACD,SAAS,CAAC,SAAS,GAAG,EAAE,CAAC,CAAC;IAC1B,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["/**\n * Writing a command's verdict: diagnostics an author reads, and the artifact it asked for.\n *\n * A diagnostic line always begins with the document it came from, so a run over several files\n * never leaves a message whose subject the reader has to guess.\n */\nimport { mkdtemp, open, rename, rm, stat } from 'node:fs/promises';\nimport { dirname, join } from 'node:path';\nimport process from 'node:process';\nimport { assertNever, canonicalizeRestricted } from '@azx-pbc/axiom-runtime';\nimport type { CompileWarning } from '../compile/warning.js';\nimport type { DatasetDiagnostic } from '../datasets/index.js';\nimport { datasetDiagnosticRepair } from '../datasets/repair.js';\nimport { parseDocumentPath } from '../document-path.js';\nimport { documentFormatOf } from '../ingest/document.js';\nimport type { DocumentFormat } from '../ingest/document.js';\nimport { ingestDocument } from '../ingest/yaml-document.js';\nimport { schemaDiagnosticRepair } from '../schema/repair.js';\nimport type { SchemaDiagnostic } from '../schema/validate.js';\nimport type { DiagnosticCap } from './args.js';\nimport { noun } from './count.js';\nimport { displayPath, STDIO_PATH } from './read.js';\nimport { causeText, jsonTerminalText, jsonText, printErrorLine, printLine } from './terminal.js';\nimport { EXIT_OK, EXIT_USAGE } from './usage.js';\n\n/** One printed reason, and how many catalogue keys it stands for when locale lines are grouped. */\ninterface DiagnosticEntry {\n readonly diagnostic: SchemaDiagnostic;\n readonly keyCount: number;\n}\n\n/**\n * The grouping key for one per-key locale line, or `undefined` when the line stands alone.\n *\n * A misspelt locale in a catalogue is one mistake repeated under every message key, so the\n * validator's structured entries stay one per key while the report states it once. The cause\n * text participates as well as `(code, locale, expected)`: two lines that name different\n * defects must never be folded into one just because they share a locale.\n */\nfunction localeGroupKey(diagnostic: SchemaDiagnostic): string | undefined {\n if (diagnostic.code !== 'MESSAGE_LOCALE') return undefined;\n if (diagnostic.messageKey === undefined || diagnostic.expected === undefined) return undefined;\n return JSON.stringify([\n diagnostic.code,\n diagnostic.locale ?? '',\n diagnostic.expected,\n diagnostic.detail,\n ]);\n}\n\n/** The diagnostics as the lines to print, with a repeated locale spelling stated once. */\nfunction diagnosticEntries(diagnostics: readonly SchemaDiagnostic[]): readonly DiagnosticEntry[] {\n const entries: { diagnostic: SchemaDiagnostic; keyCount: number }[] = [];\n const groups = new Map<string, { index: number; count: number }>();\n for (const diagnostic of diagnostics) {\n const key = localeGroupKey(diagnostic);\n if (key === undefined) {\n entries.push({ diagnostic, keyCount: 1 });\n continue;\n }\n const group = groups.get(key);\n if (group === undefined) {\n groups.set(key, { index: entries.length, count: 1 });\n entries.push({ diagnostic, keyCount: 1 });\n continue;\n }\n group.count += 1;\n const first = entries[group.index];\n if (first !== undefined)\n entries[group.index] = { diagnostic: first.diagnostic, keyCount: group.count };\n }\n return entries;\n}\n\n/**\n * How much of an offending line a diagnostic quotes, on each side of the caret.\n *\n * A document's line is as long as its author made it — one 50 MB JSON body is one line — and the\n * excerpt used to be the whole line plus `' '.repeat(column)`, so an over-long line made the\n * command write twice the document to stderr. The window is a report, not a proof: enough text\n * either side to read the mistake, in a line a CI log can carry.\n */\nconst EXCERPT_WINDOW = 160;\nconst EXCERPT_ELLIPSIS = '…';\n\n/**\n * `line N, column M` and the offending line with a caret under `offset`, for a diagnostic\n * whose offset indexes the document the command read or the expression slot the path names.\n *\n * A document offset becomes a line, a column and the line itself. An expression offset\n * indexes the source in one slot, not the file, so the same window is drawn over the slot\n * text the path resolves to instead of over the document. The caller passes the parsed\n * document through `slotSource`, which fails soft: a path that names no string slot, or a\n * document that cannot be parsed, renders no excerpt rather than a caret at the wrong member.\n *\n * The quoted line is clamped to `EXCERPT_WINDOW` code units either side of the offset, so the\n * bytes a hostile document can make this write are a constant per diagnostic rather than twice\n * the line's length. The column still names the position in the real line; only the quote is a\n * window into it, and an ellipsis marks each clipped end.\n */\nfunction sourceExcerpt(source: string, offset: number): readonly string[] {\n const bounded = Math.min(Math.max(offset, 0), source.length);\n const lineStart = source.lastIndexOf('\\n', bounded - 1) + 1;\n const lineEnd = source.indexOf('\\n', bounded);\n const line = source.slice(lineStart, lineEnd === -1 ? source.length : lineEnd).replace(/\\r$/, '');\n const lineNumber = source.slice(0, lineStart).split('\\n').length;\n const column = bounded - lineStart + 1;\n const from = Math.max(0, column - 1 - EXCERPT_WINDOW);\n const to = Math.min(line.length, column - 1 + EXCERPT_WINDOW);\n const head = from > 0 ? EXCERPT_ELLIPSIS : '';\n const tail = to < line.length ? EXCERPT_ELLIPSIS : '';\n const quoted = `${head}${line.slice(from, to)}${tail}`;\n // The caret sits under the offset within the quoted window, so the padding is bounded by the\n // window and the leading ellipsis it accounts for.\n const caretColumn = head.length + (column - 1 - from);\n return [\n ` line ${String(lineNumber)}, column ${String(column)}`,\n ` ${quoted}`,\n ` ${' '.repeat(Math.min(caretColumn, quoted.length))}^`,\n ];\n}\n\n/**\n * The expression source the diagnostic path names, or `undefined` when there is none.\n *\n * An expression slot is authored as document text, so the excerpt is drawn from the slot\n * value rather than from the whole document. The walk reads an already-parsed document by\n * the path the compiler rendered, checking own properties only so prototype names never\n * resolve as slots. Only a string slot is an excerpt source: a compiled node, a missing\n * member or a non-string value renders no excerpt. Nothing here changes an offset; the\n * excerpt is display only.\n */\nfunction slotSource(document: unknown, path: string): string | undefined {\n const parsed = parseDocumentPath(path);\n if (!parsed.ok) return undefined;\n let current: unknown = document;\n for (const segment of parsed.segments) {\n if (typeof segment === 'number') {\n if (!Array.isArray(current)) return undefined;\n current = current[segment];\n continue;\n }\n if (typeof current !== 'object' || current === null || Array.isArray(current)) {\n return undefined;\n }\n if (!Object.hasOwn(current, segment)) return undefined;\n current = Reflect.get(current, segment);\n }\n return typeof current === 'string' ? current : undefined;\n}\n\n/** Lazily resolved document tree used to extract expression slots during one diagnostic report. */\ntype ExcerptDocument =\n | { readonly status: 'unparsed' }\n | { readonly status: 'parsed'; readonly value: unknown }\n | { readonly status: 'unavailable' };\n\n/**\n * How many times `reportSchemaDiagnostics` parsed a document from source text to draw\n * expression excerpts. Counted rather than timed, so tests verify one parse per report\n * without a wall-clock assertion.\n */\nlet excerptParseCount = 0;\n\n/** Process-lifetime count of source parses performed for expression excerpts. */\nexport function excerptDocumentParses(): number {\n return excerptParseCount;\n}\n\n/** Optional context a caller already holds when rendering schema diagnostics. */\nexport interface DiagnosticReportOptions {\n /** Authoring spelling of `source`, when the caller already decided it from the path. */\n readonly format?: DocumentFormat;\n /** Already-ingested document tree, so expression excerpts never re-parse `source`. */\n readonly document?: unknown;\n}\n\n/**\n * The candidate spelling a diagnostic carries, unless its cause already states one.\n *\n * A suggestion travels twice: as prose in `detail` for an expression refusal, and as the\n * structured `suggestions` list an editor offers. Printing the list unconditionally would\n * repeat \"did you mean f_amount?\" on the same line. A diagnostic with a canonical `expected`\n * form already states the repair and its candidates, so the list adds only noise there; the\n * list is the repair for a cause — a misspelt root member, a field source — that names none.\n */\nfunction suggestionText(diagnostic: SchemaDiagnostic): string {\n const suggestions = diagnostic.suggestions;\n if (suggestions === undefined || suggestions.length === 0) return '';\n if (diagnostic.expected !== undefined) return '';\n if (/\\bdid you mean\\b/iu.test(diagnostic.detail)) return '';\n return `did you mean ${suggestions.map((name) => `\\`${name}\\``).join(' or ')}?`;\n}\n\n/**\n * Appends a repair clause to a cause. A cause that already ended a sentence — a validator\n * message usually does — starts the clause as its own sentence; every other cause joins it\n * with the semicolon the report uses between a fact and its repair.\n */\nfunction withRepair(detail: string, clause: string): string {\n if (clause === '') return detail;\n return detail.endsWith('.')\n ? `${detail} ${clause.charAt(0).toUpperCase()}${clause.slice(1)}`\n : `${detail}; ${clause}`;\n}\n\n/** One diagnostic line, without the document prefix, with the repair the diagnostic carries. */\nfunction diagnosticText(diagnostic: SchemaDiagnostic): string {\n const expected = diagnostic.expected === undefined ? '' : `expected \\`${diagnostic.expected}\\``;\n let text = `${diagnostic.path}: ${diagnostic.code}: ${diagnostic.detail}`;\n text = withRepair(text, suggestionText(diagnostic));\n text = withRepair(text, expected);\n return withRepair(text, unstatedRepair(diagnostic));\n}\n\n/**\n * The repair the code's row states, unless the detail already states it.\n *\n * A specific cause that ends with the action — a duplicate that says which identifier to\n * choose — stays one sentence. A cause that is only a fact — a metaschema keyword, an\n * ingestion parser's message, a count — receives the code's repair here, so a terminal line\n * never leaves an author without an action.\n */\nfunction unstatedRepair(diagnostic: SchemaDiagnostic): string {\n if (diagnostic.repairStated === true) return '';\n // A suggestion is already the repair for a misspelt name: printing the code's generic action\n // beside `did you mean \\`fields\\`?` would state the same fix twice in different words.\n if (diagnostic.suggestions !== undefined && diagnostic.suggestions.length > 0) return '';\n const { anchor, repair } = schemaDiagnosticRepair(diagnostic.code);\n return diagnostic.detail.toLowerCase().includes(anchor.toLowerCase()) ? '' : repair;\n}\n\n/**\n * Prints a compile's warnings on the diagnostics stream, without changing the exit code.\n *\n * A warning is advice, not a refusal, so the line is written to stderr beside a\n * successful check or compile and the command still exits 0. The detail already names the\n * replacement or the declaration that removes the finding; printing it here is what makes the\n * warning visible to an author who never reads the `CompileSuccess` object.\n */\nexport function reportCompileWarnings(target: string, warnings: readonly CompileWarning[]): void {\n for (const warning of warnings) {\n printErrorLine(`${displayPath(target)}: ${warning.path}: ${warning.code}: ${warning.detail}`);\n }\n}\n\n/**\n * Prints a schema's diagnostics, bounded by the cap the operator named.\n *\n * The bound is on the report only — the diagnostics arrive exhaustive from `compile()` —\n * and a capped report ends by naming how many were withheld, so an operator always knows\n * whether the list they read is the whole verdict. `source` is the text the command read, so\n * a documented position becomes a line, a column and the line itself.\n */\nexport function reportSchemaDiagnostics(\n target: string,\n source: string,\n diagnostics: readonly SchemaDiagnostic[],\n cap: DiagnosticCap,\n options: DiagnosticReportOptions = {},\n): void {\n const format = options.format ?? documentFormatOf(target);\n let excerptDocument: ExcerptDocument =\n options.document !== undefined\n ? { status: 'parsed', value: options.document }\n : { status: 'unparsed' };\n const entries = diagnosticEntries(diagnostics);\n const shown = cap === 'all' ? entries : entries.slice(0, cap);\n for (const entry of shown) {\n const suffix = entry.keyCount > 1 ? `; affects ${String(entry.keyCount)} message keys` : '';\n printErrorLine(`${target}: ${diagnosticText(entry.diagnostic)}${suffix}`);\n const offset = entry.diagnostic.offset;\n if (offset === undefined) continue;\n if (entry.diagnostic.offsetSource === 'document') {\n for (const line of sourceExcerpt(source, offset)) printErrorLine(line);\n continue;\n }\n // An expression offset is drawn over the slot text, using the same clamp. The document is\n // parsed at most once per report (and zero times when the caller passed the ingested tree).\n // A path that names no string slot renders no excerpt; the diagnostic line above still\n // carries the path, the code and the repair.\n if (entry.diagnostic.offsetSource === 'expression') {\n if (excerptDocument.status === 'unparsed') {\n excerptParseCount += 1;\n const ingested = ingestDocument(source, format);\n excerptDocument = ingested.ok\n ? { status: 'parsed', value: ingested.value }\n : { status: 'unavailable' };\n }\n if (excerptDocument.status !== 'parsed') continue;\n const slot = slotSource(excerptDocument.value, entry.diagnostic.path);\n if (slot === undefined) continue;\n for (const line of sourceExcerpt(slot, offset)) printErrorLine(line);\n }\n }\n const shownCount = shown.reduce((total, entry) => total + entry.keyCount, 0);\n const withheld = diagnostics.length - shownCount;\n if (withheld > 0) {\n printErrorLine(\n `${target}: … and ${String(withheld)} more ${noun(withheld, 'diagnostic')} withheld; run again with --max-diagnostics=all to see them`,\n );\n }\n}\n\n/** Where an author looks for a dataset problem: the table row and the declared column. */\nfunction datasetLocation(diagnostic: DatasetDiagnostic): string {\n const parts: string[] = [];\n if (diagnostic.row !== undefined) parts.push(`row ${String(diagnostic.row)}`);\n if (diagnostic.column !== undefined) parts.push(`column ${diagnostic.column}`);\n return parts.length === 0 ? 'table' : parts.join(', ');\n}\n\n/** Prints dataset diagnostics, each with the document, position and member path at fault. */\nexport function reportDatasetDiagnostics(\n target: string,\n diagnostics: readonly DatasetDiagnostic[],\n): void {\n for (const diagnostic of diagnostics) {\n const { anchor, repair } = datasetDiagnosticRepair(diagnostic.code);\n const action = diagnostic.detail.toLowerCase().includes(anchor.toLowerCase())\n ? ''\n : `; ${repair}`;\n printErrorLine(\n `${target}: ${datasetLocation(diagnostic)}: ${diagnostic.code}: ${diagnostic.detail}${action} [${diagnostic.path}]`,\n );\n }\n}\n\n/**\n * Emits a command's JSON artifact to `--out`, or to stdout when the operator named no file.\n * A file is data and gets the document itself; a terminal gets the spelling whose code\n * points cannot act on it. `--out -` is the explicit spelling of the stdout default.\n * The file is staged beside its destination and renamed into place, so a failed write\n * cannot leave a truncated artifact or let a planted symlink redirect the bytes, and an output\n * that names an input is refused by the file's own identity rather than by how its path is\n * spelled — a symlinked directory or a hard link is refused too, rather than replacing the\n * document the command just read.\n */\nexport async function emitJson(\n out: string | undefined,\n value: unknown,\n inputs: readonly string[] = [],\n): Promise<number> {\n // A terminal gets the escaped spelling; a file gets the document itself, which is what a tool\n // reading the artifact expects. `--out -` names the terminal, not a file called `-`.\n const toTerminal = out === undefined || out === STDIO_PATH;\n const text = toTerminal ? `${jsonText(value)}\\n` : `${JSON.stringify(value, null, 2)}\\n`;\n return emitText(out, text, inputs);\n}\n\n/**\n * Emits a value as restricted-JCS canonical text, so two runs that decided the same thing write\n * the same bytes. Those bytes make publish proposals comparable, never authenticated: a later\n * gate re-derives its verdict from the artifact, the suites and the tables rather than letting\n * the file stand in for the run.\n *\n * A file gets those canonical bytes. `--out -` names the terminal, and a report interpolates what\n * an untrusted document declared — a vector's `expected`, a suite's refusal — so the stream gets\n * the same bytes with each code point a terminal acts on spelled as its JSON escape: a legal\n * spelling of the same report, which is what a caller piping it onward parses back.\n */\nexport async function emitCanonicalJson(\n out: string | undefined,\n value: unknown,\n inputs: readonly string[] = [],\n): Promise<number> {\n const canonical = `${canonicalizeRestricted(value)}\\n`;\n const toTerminal = out === undefined || out === STDIO_PATH;\n return emitText(out, toTerminal ? jsonTerminalText(canonical) : canonical, inputs);\n}\n\n/** Outcome of resolving one filesystem path to its `(device, inode)` identity. */\ntype FileIdentityResult =\n | { readonly status: 'found'; readonly identity: string }\n | { readonly status: 'absent' }\n | { readonly status: 'error'; readonly cause: unknown };\n\n/** The Node error code carried by a filesystem failure, when present. */\nfunction errorCode(cause: unknown): string | undefined {\n if (typeof cause !== 'object' || cause === null || !('code' in cause)) return undefined;\n return typeof cause.code === 'string' ? cause.code : undefined;\n}\n\n/**\n * The file one path reaches now, as its `(device, inode)` identity, distinguishing an absent\n * path (`ENOENT`) from any other `stat` failure (`EACCES`, `ELOOP`, `ENOTDIR`, and so on).\n *\n * `stat` follows every symlink, so two spellings of one file (a symlinked directory, a hard\n * link, a relative name) answer with the same identity. Only `ENOENT` means nothing exists at\n * the path; any other failure must fail closed rather than disable the input-replacement guard.\n */\nasync function fileIdentity(target: string): Promise<FileIdentityResult> {\n try {\n const info = await stat(target);\n return { status: 'found', identity: `${String(info.dev)}:${String(info.ino)}` };\n } catch (cause) {\n if (errorCode(cause) === 'ENOENT') return { status: 'absent' };\n return { status: 'error', cause };\n }\n}\n\n/** Writes `text` to the named destination or standard output. */\nasync function emitText(\n out: string | undefined,\n text: string,\n inputs: readonly string[],\n): Promise<number> {\n if (out === undefined || out === STDIO_PATH) {\n process.stdout.write(text);\n return EXIT_OK;\n }\n // A destination that already names a document this run read would replace it, however the\n // path is spelled: a symlinked directory or a hard link hides the same file behind another\n // name, which a comparison of the written paths cannot see. `-` is a stream, not a path, so\n // it is never an input a destination could replace. Any non-ENOENT stat failure fails closed\n // so an unverified destination or input cannot bypass the guard.\n const destination = await fileIdentity(out);\n switch (destination.status) {\n case 'error':\n printErrorLine(`axiom-cli: cannot write ${out}: ${causeText(destination.cause)}`);\n return EXIT_USAGE;\n case 'absent':\n break;\n case 'found': {\n for (const input of inputs) {\n if (input === STDIO_PATH) continue;\n const identity = await fileIdentity(input);\n switch (identity.status) {\n case 'absent':\n continue;\n case 'found':\n if (identity.identity === destination.identity) {\n printErrorLine(`axiom-cli: --out ${out} would replace an input document`);\n return EXIT_USAGE;\n }\n continue;\n case 'error':\n printErrorLine(\n `axiom-cli: cannot verify whether --out ${out} would replace input ${input}: ${causeText(identity.cause)}`,\n );\n return EXIT_USAGE;\n default:\n return assertNever(identity);\n }\n }\n break;\n }\n default:\n return assertNever(destination);\n }\n // The bytes are staged in a directory nobody can predict, created exclusively, and flushed\n // before the rename: a symlink planted at a guessable name cannot redirect the write, and a\n // failed flush cannot leave a truncated artifact in place of the verdict.\n let staging: string | undefined;\n try {\n staging = await mkdtemp(join(dirname(out), '.axiom-out-'));\n const temporary = join(staging, 'artifact');\n const handle = await open(temporary, 'wx');\n try {\n await handle.writeFile(text, 'utf8');\n await handle.sync();\n } finally {\n await handle.close();\n }\n await rename(temporary, out);\n } catch (cause) {\n printErrorLine(`axiom-cli: cannot write ${out}: ${causeText(cause)}`);\n return EXIT_USAGE;\n } finally {\n if (staging !== undefined) await rm(staging, { recursive: true, force: true });\n }\n printLine(`wrote ${out}`);\n return EXIT_OK;\n}\n"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reading a schema together with the tables and declarations it names, and compiling the
|
|
3
|
+
* three into one verdict.
|
|
4
|
+
*
|
|
5
|
+
* The steps are separate because their failures have different exit codes: an unreadable
|
|
6
|
+
* file or a mispaired declaration is a misuse (2), while a document the language refuses is a
|
|
7
|
+
* failed compile (1). `loadSchema` carries the code of whichever step refused, so a caller
|
|
8
|
+
* never has to re-derive it.
|
|
9
|
+
*/
|
|
10
|
+
import type { Tier } from '@azx-pbc/axiom-runtime';
|
|
11
|
+
import type { CompileSuccess } from '../compile.js';
|
|
12
|
+
import type { CompiledDataset } from '../datasets/index.js';
|
|
13
|
+
import type { DiagnosticCap } from './args.js';
|
|
14
|
+
export type SchemaLoad = {
|
|
15
|
+
readonly ok: true;
|
|
16
|
+
readonly compiled: CompileSuccess;
|
|
17
|
+
readonly datasets: readonly CompiledDataset[];
|
|
18
|
+
} | {
|
|
19
|
+
readonly ok: false;
|
|
20
|
+
readonly exitCode: number;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Reads a schema and its datasets and compiles them, reporting every reason it could not.
|
|
24
|
+
* A failure carries the exit code of the step that refused, so a misuse stays a misuse
|
|
25
|
+
* instead of being reported as a document that failed to compile.
|
|
26
|
+
*/
|
|
27
|
+
export declare function loadSchema(target: string, datasetFiles: readonly string[], declarationFiles: readonly string[], usage: string, cap: DiagnosticCap, compileTarget?: Tier, producerVersion?: string | null): Promise<SchemaLoad>;
|
|
28
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/cli/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAEnD,OAAO,KAAK,EAAkB,cAAc,EAAE,MAAM,eAAe,CAAC;AACpE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAI5D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAM/C,MAAM,MAAM,UAAU,GAClB;IACE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAClB,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC;IAClC,QAAQ,CAAC,QAAQ,EAAE,SAAS,eAAe,EAAE,CAAC;CAC/C,GACD;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC;AAEtD;;;;GAIG;AACH,wBAAsB,UAAU,CAC9B,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,SAAS,MAAM,EAAE,EAC/B,gBAAgB,EAAE,SAAS,MAAM,EAAE,EACnC,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,aAAa,EAClB,aAAa,CAAC,EAAE,IAAI,EACpB,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,GAC9B,OAAO,CAAC,UAAU,CAAC,CAmCrB"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { compileInspected } from '../compile.js';
|
|
2
|
+
import { documentFormatOf } from '../ingest/document.js';
|
|
3
|
+
import { inspectSchemaDocument } from '../schema/validate.js';
|
|
4
|
+
import { inspectYamlDocument } from '../schema/validate-yaml.js';
|
|
5
|
+
import { loadDatasets } from './dataset.js';
|
|
6
|
+
import { displayPath, readText } from './read.js';
|
|
7
|
+
import { reportCompileWarnings, reportSchemaDiagnostics } from './render.js';
|
|
8
|
+
import { EXIT_FAILED } from './usage.js';
|
|
9
|
+
/**
|
|
10
|
+
* Reads a schema and its datasets and compiles them, reporting every reason it could not.
|
|
11
|
+
* A failure carries the exit code of the step that refused, so a misuse stays a misuse
|
|
12
|
+
* instead of being reported as a document that failed to compile.
|
|
13
|
+
*/
|
|
14
|
+
export async function loadSchema(target, datasetFiles, declarationFiles, usage, cap, compileTarget, producerVersion) {
|
|
15
|
+
const read = await readText(target);
|
|
16
|
+
if (!read.ok)
|
|
17
|
+
return { ok: false, exitCode: read.exitCode };
|
|
18
|
+
const loaded = await loadDatasets(datasetFiles, declarationFiles, usage);
|
|
19
|
+
if (!loaded.ok)
|
|
20
|
+
return { ok: false, exitCode: loaded.exitCode };
|
|
21
|
+
const declarations = loaded.datasets.map((dataset) => dataset.declaration);
|
|
22
|
+
// `undefined` stamps the release this compiler was built as; `null` is the caller's explicit
|
|
23
|
+
// opt-out for bytes that measure behaviour rather than release identity, which is what the
|
|
24
|
+
// committed corpus fixtures are. Among the command-line commands only `compile` spells it,
|
|
25
|
+
// because only `compile` writes an artifact whose bytes another gate compares.
|
|
26
|
+
const options = {
|
|
27
|
+
...(compileTarget === undefined ? {} : { target: compileTarget }),
|
|
28
|
+
...(declarations.length === 0 ? {} : { datasets: declarations }),
|
|
29
|
+
...(producerVersion === undefined ? {} : { producerVersion }),
|
|
30
|
+
};
|
|
31
|
+
// The format is the file's extension and nothing else: a `.yaml`/`.yml` document runs the
|
|
32
|
+
// YAML front door, every other name keeps the JSON meaning `compile()` has always had.
|
|
33
|
+
// Inspecting first lets diagnostic reporting reuse the already-parsed tree for expression
|
|
34
|
+
// excerpts without re-parsing the document.
|
|
35
|
+
const format = documentFormatOf(target);
|
|
36
|
+
const inspection = format === 'yaml' ? inspectYamlDocument(read.text) : inspectSchemaDocument(read.text);
|
|
37
|
+
const compiled = compileInspected(inspection, options);
|
|
38
|
+
if (!compiled.ok) {
|
|
39
|
+
reportSchemaDiagnostics(displayPath(target), read.text, compiled.diagnostics, cap, inspection.ok ? { format, document: inspection.document } : { format });
|
|
40
|
+
return { ok: false, exitCode: EXIT_FAILED };
|
|
41
|
+
}
|
|
42
|
+
if (compiled.warnings.length > 0)
|
|
43
|
+
reportCompileWarnings(target, compiled.warnings);
|
|
44
|
+
return { ok: true, compiled, datasets: loaded.datasets };
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/cli/schema.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAGjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAEjE,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAClD,OAAO,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAC7E,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAUzC;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,MAAc,EACd,YAA+B,EAC/B,gBAAmC,EACnC,KAAa,EACb,GAAkB,EAClB,aAAoB,EACpB,eAA+B;IAE/B,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC,CAAC;IACpC,IAAI,CAAC,IAAI,CAAC,EAAE;QAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC;IAC5D,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,YAAY,EAAE,gBAAgB,EAAE,KAAK,CAA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AC,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CACvE,CAAC;QACF,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC;IAC9C,CAAC;IACD,IAAI,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC;QAAE,qBAAqB,CAAC,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACnF,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,CAAC;AAC3D,CAAC","sourcesContent":["/**\n * Reading a schema together with the tables and declarations it names, and compiling the\n * three into one verdict.\n *\n * The steps are separate because their failures have different exit codes: an unreadable\n * file or a mispaired declaration is a misuse (2), while a document the language refuses is a\n * failed compile (1). `loadSchema` carries the code of whichever step refused, so a caller\n * never has to re-derive it.\n */\nimport type { Tier } from '@azx-pbc/axiom-runtime';\nimport { compileInspected } from '../compile.js';\nimport type { CompileOptions, CompileSuccess } from '../compile.js';\nimport type { CompiledDataset } from '../datasets/index.js';\nimport { documentFormatOf } from '../ingest/document.js';\nimport { inspectSchemaDocument } from '../schema/validate.js';\nimport { inspectYamlDocument } from '../schema/validate-yaml.js';\nimport type { DiagnosticCap } from './args.js';\nimport { loadDatasets } from './dataset.js';\nimport { displayPath, readText } from './read.js';\nimport { reportCompileWarnings, reportSchemaDiagnostics } from './render.js';\nimport { EXIT_FAILED } from './usage.js';\n\nexport type SchemaLoad =\n | {\n readonly ok: true;\n readonly compiled: CompileSuccess;\n readonly datasets: readonly CompiledDataset[];\n }\n | { readonly ok: false; readonly exitCode: number };\n\n/**\n * Reads a schema and its datasets and compiles them, reporting every reason it could not.\n * A failure carries the exit code of the step that refused, so a misuse stays a misuse\n * instead of being reported as a document that failed to compile.\n */\nexport async function loadSchema(\n target: string,\n datasetFiles: readonly string[],\n declarationFiles: readonly string[],\n usage: string,\n cap: DiagnosticCap,\n compileTarget?: Tier,\n producerVersion?: string | null,\n): Promise<SchemaLoad> {\n const read = await readText(target);\n if (!read.ok) return { ok: false, exitCode: read.exitCode };\n const loaded = await loadDatasets(datasetFiles, declarationFiles, usage);\n if (!loaded.ok) return { ok: false, exitCode: loaded.exitCode };\n const declarations = loaded.datasets.map((dataset) => dataset.declaration);\n // `undefined` stamps the release this compiler was built as; `null` is the caller's explicit\n // opt-out for bytes that measure behaviour rather than release identity, which is what the\n // committed corpus fixtures are. Among the command-line commands only `compile` spells it,\n // because only `compile` writes an artifact whose bytes another gate compares.\n const options: CompileOptions = {\n ...(compileTarget === undefined ? {} : { target: compileTarget }),\n ...(declarations.length === 0 ? {} : { datasets: declarations }),\n ...(producerVersion === undefined ? {} : { producerVersion }),\n };\n // The format is the file's extension and nothing else: a `.yaml`/`.yml` document runs the\n // YAML front door, every other name keeps the JSON meaning `compile()` has always had.\n // Inspecting first lets diagnostic reporting reuse the already-parsed tree for expression\n // excerpts without re-parsing the document.\n const format = documentFormatOf(target);\n const inspection =\n format === 'yaml' ? inspectYamlDocument(read.text) : inspectSchemaDocument(read.text);\n const compiled = compileInspected(inspection, options);\n if (!compiled.ok) {\n reportSchemaDiagnostics(\n displayPath(target),\n read.text,\n compiled.diagnostics,\n cap,\n inspection.ok ? { format, document: inspection.document } : { format },\n );\n return { ok: false, exitCode: EXIT_FAILED };\n }\n if (compiled.warnings.length > 0) reportCompileWarnings(target, compiled.warnings);\n return { ok: true, compiled, datasets: loaded.datasets };\n}\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ScenarioSuiteReport } from '../scenarios/report.js';
|
|
2
|
+
import type { LoadedSuite } from './suites.js';
|
|
3
|
+
/** One run's suite lines, split into what always prints and what the cap bounds. */
|
|
4
|
+
export interface SuiteReport {
|
|
5
|
+
/** One line per suite: assertions run, passed, failed, and the suite's own verdict. */
|
|
6
|
+
readonly summaries: readonly string[];
|
|
7
|
+
/** One line per assertion that did not hold, in suite then document order. */
|
|
8
|
+
readonly failures: readonly string[];
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Builds the lines a run prints for the suites it executed.
|
|
12
|
+
*
|
|
13
|
+
* A suite the run named but could not execute is stated with the reason the run refused before
|
|
14
|
+
* executing it. A missing report with no reason is a caller defect — the command must say why —
|
|
15
|
+
* so it throws instead of dropping the suite from the transcript.
|
|
16
|
+
*/
|
|
17
|
+
export declare function suiteReport(suites: readonly LoadedSuite[], reports: readonly ScenarioSuiteReport[], notRun?: string): SuiteReport;
|
|
18
|
+
//# sourceMappingURL=suite-report.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"suite-report.d.ts","sourceRoot":"","sources":["../../src/cli/suite-report.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAElE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,oFAAoF;AACpF,MAAM,WAAW,WAAW;IAC1B,uFAAuF;IACvF,QAAQ,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC,8EAA8E;IAC9E,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;CACtC;AA8BD;;;;;;GAMG;AACH,wBAAgB,WAAW,CACzB,MAAM,EAAE,SAAS,WAAW,EAAE,EAC9B,OAAO,EAAE,SAAS,mBAAmB,EAAE,EACvC,MAAM,CAAC,EAAE,MAAM,GACd,WAAW,CAsBb"}
|