@azx-pbc/axiom-compiler 0.0.0-stage → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +415 -2
- package/dist/article.d.ts +12 -0
- package/dist/article.d.ts.map +1 -0
- package/dist/article.js +16 -0
- package/dist/article.js.map +1 -0
- package/dist/cli/args.d.ts +101 -0
- package/dist/cli/args.d.ts.map +1 -0
- package/dist/cli/args.js +158 -0
- package/dist/cli/args.js.map +1 -0
- package/dist/cli/check.d.ts +2 -0
- package/dist/cli/check.d.ts.map +1 -0
- package/dist/cli/check.js +33 -0
- package/dist/cli/check.js.map +1 -0
- package/dist/cli/compile.d.ts +2 -0
- package/dist/cli/compile.d.ts.map +1 -0
- package/dist/cli/compile.js +43 -0
- package/dist/cli/compile.js.map +1 -0
- package/dist/cli/count.d.ts +15 -0
- package/dist/cli/count.d.ts.map +1 -0
- package/dist/cli/count.js +21 -0
- package/dist/cli/count.js.map +1 -0
- package/dist/cli/dataset.d.ts +28 -0
- package/dist/cli/dataset.d.ts.map +1 -0
- package/dist/cli/dataset.js +115 -0
- package/dist/cli/dataset.js.map +1 -0
- package/dist/cli/diff.d.ts +2 -0
- package/dist/cli/diff.d.ts.map +1 -0
- package/dist/cli/diff.js +297 -0
- package/dist/cli/diff.js.map +1 -0
- package/dist/cli/explain.d.ts +2 -0
- package/dist/cli/explain.d.ts.map +1 -0
- package/dist/cli/explain.js +95 -0
- package/dist/cli/explain.js.map +1 -0
- package/dist/cli/fields.d.ts +11 -0
- package/dist/cli/fields.d.ts.map +1 -0
- package/dist/cli/fields.js +13 -0
- package/dist/cli/fields.js.map +1 -0
- package/dist/cli/main.d.ts +2 -0
- package/dist/cli/main.d.ts.map +1 -0
- package/dist/cli/main.js +40 -0
- package/dist/cli/main.js.map +1 -0
- package/dist/cli/read.d.ts +56 -0
- package/dist/cli/read.d.ts.map +1 -0
- package/dist/cli/read.js +179 -0
- package/dist/cli/read.js.map +1 -0
- package/dist/cli/render.d.ts +58 -0
- package/dist/cli/render.d.ts.map +1 -0
- package/dist/cli/render.js +422 -0
- package/dist/cli/render.js.map +1 -0
- package/dist/cli/schema.d.ts +28 -0
- package/dist/cli/schema.d.ts.map +1 -0
- package/dist/cli/schema.js +46 -0
- package/dist/cli/schema.js.map +1 -0
- package/dist/cli/suite-report.d.ts +18 -0
- package/dist/cli/suite-report.d.ts.map +1 -0
- package/dist/cli/suite-report.js +58 -0
- package/dist/cli/suite-report.js.map +1 -0
- package/dist/cli/suites.d.ts +25 -0
- package/dist/cli/suites.d.ts.map +1 -0
- package/dist/cli/suites.js +67 -0
- package/dist/cli/suites.js.map +1 -0
- package/dist/cli/terminal.d.ts +45 -0
- package/dist/cli/terminal.d.ts.map +1 -0
- package/dist/cli/terminal.js +119 -0
- package/dist/cli/terminal.js.map +1 -0
- package/dist/cli/test.d.ts +12 -0
- package/dist/cli/test.d.ts.map +1 -0
- package/dist/cli/test.js +199 -0
- package/dist/cli/test.js.map +1 -0
- package/dist/cli/usage.d.ts +15 -0
- package/dist/cli/usage.d.ts.map +1 -0
- package/dist/cli/usage.js +95 -0
- package/dist/cli/usage.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +51 -0
- package/dist/cli.js.map +1 -0
- package/dist/compile/artifact-members.d.ts +57 -0
- package/dist/compile/artifact-members.d.ts.map +1 -0
- package/dist/compile/artifact-members.js +130 -0
- package/dist/compile/artifact-members.js.map +1 -0
- package/dist/compile/artifact.d.ts +20 -0
- package/dist/compile/artifact.d.ts.map +1 -0
- package/dist/compile/artifact.js +87 -0
- package/dist/compile/artifact.js.map +1 -0
- package/dist/compile/compilation.d.ts +46 -0
- package/dist/compile/compilation.d.ts.map +1 -0
- package/dist/compile/compilation.js +4 -0
- package/dist/compile/compilation.js.map +1 -0
- package/dist/compile/computed.d.ts +22 -0
- package/dist/compile/computed.d.ts.map +1 -0
- package/dist/compile/computed.js +245 -0
- package/dist/compile/computed.js.map +1 -0
- package/dist/compile/condition-warnings.d.ts +12 -0
- package/dist/compile/condition-warnings.d.ts.map +1 -0
- package/dist/compile/condition-warnings.js +26 -0
- package/dist/compile/condition-warnings.js.map +1 -0
- package/dist/compile/conditions.d.ts +18 -0
- package/dist/compile/conditions.d.ts.map +1 -0
- package/dist/compile/conditions.js +22 -0
- package/dist/compile/conditions.js.map +1 -0
- package/dist/compile/cross-checks.d.ts +67 -0
- package/dist/compile/cross-checks.d.ts.map +1 -0
- package/dist/compile/cross-checks.js +238 -0
- package/dist/compile/cross-checks.js.map +1 -0
- package/dist/compile/datasets.d.ts +52 -0
- package/dist/compile/datasets.d.ts.map +1 -0
- package/dist/compile/datasets.js +183 -0
- package/dist/compile/datasets.js.map +1 -0
- package/dist/compile/dead-weight.d.ts +26 -0
- package/dist/compile/dead-weight.d.ts.map +1 -0
- package/dist/compile/dead-weight.js +244 -0
- package/dist/compile/dead-weight.js.map +1 -0
- package/dist/compile/declaration-rules.d.ts +54 -0
- package/dist/compile/declaration-rules.d.ts.map +1 -0
- package/dist/compile/declaration-rules.js +510 -0
- package/dist/compile/declaration-rules.js.map +1 -0
- package/dist/compile/declarations.d.ts +44 -0
- package/dist/compile/declarations.d.ts.map +1 -0
- package/dist/compile/declarations.js +160 -0
- package/dist/compile/declarations.js.map +1 -0
- package/dist/compile/document.d.ts +4 -0
- package/dist/compile/document.d.ts.map +1 -0
- package/dist/compile/document.js +13 -0
- package/dist/compile/document.js.map +1 -0
- package/dist/compile/expression.d.ts +38 -0
- package/dist/compile/expression.d.ts.map +1 -0
- package/dist/compile/expression.js +288 -0
- package/dist/compile/expression.js.map +1 -0
- package/dist/compile/hashes.d.ts +26 -0
- package/dist/compile/hashes.d.ts.map +1 -0
- package/dist/compile/hashes.js +96 -0
- package/dist/compile/hashes.js.map +1 -0
- package/dist/compile/item-targets.d.ts +12 -0
- package/dist/compile/item-targets.d.ts.map +1 -0
- package/dist/compile/item-targets.js +287 -0
- package/dist/compile/item-targets.js.map +1 -0
- package/dist/compile/messages.d.ts +8 -0
- package/dist/compile/messages.d.ts.map +1 -0
- package/dist/compile/messages.js +62 -0
- package/dist/compile/messages.js.map +1 -0
- package/dist/compile/option-availability.d.ts +51 -0
- package/dist/compile/option-availability.d.ts.map +1 -0
- package/dist/compile/option-availability.js +171 -0
- package/dist/compile/option-availability.js.map +1 -0
- package/dist/compile/option-codes.d.ts +27 -0
- package/dist/compile/option-codes.d.ts.map +1 -0
- package/dist/compile/option-codes.js +212 -0
- package/dist/compile/option-codes.js.map +1 -0
- package/dist/compile/references.d.ts +14 -0
- package/dist/compile/references.d.ts.map +1 -0
- package/dist/compile/references.js +126 -0
- package/dist/compile/references.js.map +1 -0
- package/dist/compile/rows-from.d.ts +27 -0
- package/dist/compile/rows-from.d.ts.map +1 -0
- package/dist/compile/rows-from.js +164 -0
- package/dist/compile/rows-from.js.map +1 -0
- package/dist/compile/rules.d.ts +58 -0
- package/dist/compile/rules.d.ts.map +1 -0
- package/dist/compile/rules.js +327 -0
- package/dist/compile/rules.js.map +1 -0
- package/dist/compile/suggestions.d.ts +52 -0
- package/dist/compile/suggestions.d.ts.map +1 -0
- package/dist/compile/suggestions.js +633 -0
- package/dist/compile/suggestions.js.map +1 -0
- package/dist/compile/targets.d.ts +22 -0
- package/dist/compile/targets.d.ts.map +1 -0
- package/dist/compile/targets.js +125 -0
- package/dist/compile/targets.js.map +1 -0
- package/dist/compile/types.d.ts +84 -0
- package/dist/compile/types.d.ts.map +1 -0
- package/dist/compile/types.js +2 -0
- package/dist/compile/types.js.map +1 -0
- package/dist/compile/warning.d.ts +45 -0
- package/dist/compile/warning.d.ts.map +1 -0
- package/dist/compile/warning.js +2 -0
- package/dist/compile/warning.js.map +1 -0
- package/dist/compile-yaml.d.ts +23 -0
- package/dist/compile-yaml.d.ts.map +1 -0
- package/dist/compile-yaml.js +30 -0
- package/dist/compile-yaml.js.map +1 -0
- package/dist/compile.d.ts +78 -0
- package/dist/compile.d.ts.map +1 -0
- package/dist/compile.js +372 -0
- package/dist/compile.js.map +1 -0
- package/dist/csv/limits.d.ts +43 -0
- package/dist/csv/limits.d.ts.map +1 -0
- package/dist/csv/limits.js +51 -0
- package/dist/csv/limits.js.map +1 -0
- package/dist/csv/scalar.d.ts +33 -0
- package/dist/csv/scalar.d.ts.map +1 -0
- package/dist/csv/scalar.js +77 -0
- package/dist/csv/scalar.js.map +1 -0
- package/dist/datasets/csv.d.ts +46 -0
- package/dist/datasets/csv.d.ts.map +1 -0
- package/dist/datasets/csv.js +293 -0
- package/dist/datasets/csv.js.map +1 -0
- package/dist/datasets/declaration.d.ts +16 -0
- package/dist/datasets/declaration.d.ts.map +1 -0
- package/dist/datasets/declaration.js +104 -0
- package/dist/datasets/declaration.js.map +1 -0
- package/dist/datasets/diagnostics.d.ts +65 -0
- package/dist/datasets/diagnostics.d.ts.map +1 -0
- package/dist/datasets/diagnostics.js +2 -0
- package/dist/datasets/diagnostics.js.map +1 -0
- package/dist/datasets/diff.d.ts +46 -0
- package/dist/datasets/diff.d.ts.map +1 -0
- package/dist/datasets/diff.js +84 -0
- package/dist/datasets/diff.js.map +1 -0
- package/dist/datasets/document.d.ts +12 -0
- package/dist/datasets/document.d.ts.map +1 -0
- package/dist/datasets/document.js +382 -0
- package/dist/datasets/document.js.map +1 -0
- package/dist/datasets/index.d.ts +43 -0
- package/dist/datasets/index.d.ts.map +1 -0
- package/dist/datasets/index.js +68 -0
- package/dist/datasets/index.js.map +1 -0
- package/dist/datasets/repair.d.ts +26 -0
- package/dist/datasets/repair.d.ts.map +1 -0
- package/dist/datasets/repair.js +60 -0
- package/dist/datasets/repair.js.map +1 -0
- package/dist/document-path.d.ts +62 -0
- package/dist/document-path.d.ts.map +1 -0
- package/dist/document-path.js +200 -0
- package/dist/document-path.js.map +1 -0
- package/dist/expr/boundary.d.ts +8 -0
- package/dist/expr/boundary.d.ts.map +1 -0
- package/dist/expr/boundary.js +243 -0
- package/dist/expr/boundary.js.map +1 -0
- package/dist/expr/compile-expr.d.ts +35 -0
- package/dist/expr/compile-expr.d.ts.map +1 -0
- package/dist/expr/compile-expr.js +66 -0
- package/dist/expr/compile-expr.js.map +1 -0
- package/dist/expr/deprecation.d.ts +23 -0
- package/dist/expr/deprecation.d.ts.map +1 -0
- package/dist/expr/deprecation.js +28 -0
- package/dist/expr/deprecation.js.map +1 -0
- package/dist/expr/diagnostics.d.ts +31 -0
- package/dist/expr/diagnostics.d.ts.map +1 -0
- package/dist/expr/diagnostics.js +34 -0
- package/dist/expr/diagnostics.js.map +1 -0
- package/dist/expr/lexer.d.ts +49 -0
- package/dist/expr/lexer.d.ts.map +1 -0
- package/dist/expr/lexer.js +277 -0
- package/dist/expr/lexer.js.map +1 -0
- package/dist/expr/lint-warnings.d.ts +11 -0
- package/dist/expr/lint-warnings.d.ts.map +1 -0
- package/dist/expr/lint-warnings.js +20 -0
- package/dist/expr/lint-warnings.js.map +1 -0
- package/dist/expr/lint.d.ts +41 -0
- package/dist/expr/lint.d.ts.map +1 -0
- package/dist/expr/lint.js +1034 -0
- package/dist/expr/lint.js.map +1 -0
- package/dist/expr/parse/aggregates.d.ts +13 -0
- package/dist/expr/parse/aggregates.d.ts.map +1 -0
- package/dist/expr/parse/aggregates.js +48 -0
- package/dist/expr/parse/aggregates.js.map +1 -0
- package/dist/expr/parse/budget.d.ts +11 -0
- package/dist/expr/parse/budget.d.ts.map +1 -0
- package/dist/expr/parse/budget.js +57 -0
- package/dist/expr/parse/budget.js.map +1 -0
- package/dist/expr/parse/grammar.d.ts +9 -0
- package/dist/expr/parse/grammar.d.ts.map +1 -0
- package/dist/expr/parse/grammar.js +699 -0
- package/dist/expr/parse/grammar.js.map +1 -0
- package/dist/expr/parse/literals.d.ts +20 -0
- package/dist/expr/parse/literals.d.ts.map +1 -0
- package/dist/expr/parse/literals.js +132 -0
- package/dist/expr/parse/literals.js.map +1 -0
- package/dist/expr/parse/stream.d.ts +60 -0
- package/dist/expr/parse/stream.d.ts.map +1 -0
- package/dist/expr/parse/stream.js +151 -0
- package/dist/expr/parse/stream.js.map +1 -0
- package/dist/expr/parser.d.ts +45 -0
- package/dist/expr/parser.d.ts.map +1 -0
- package/dist/expr/parser.js +110 -0
- package/dist/expr/parser.js.map +1 -0
- package/dist/expr/print/spell.d.ts +78 -0
- package/dist/expr/print/spell.d.ts.map +1 -0
- package/dist/expr/print/spell.js +592 -0
- package/dist/expr/print/spell.js.map +1 -0
- package/dist/expr/print.d.ts +20 -0
- package/dist/expr/print.d.ts.map +1 -0
- package/dist/expr/print.js +102 -0
- package/dist/expr/print.js.map +1 -0
- package/dist/expr/suggest.d.ts +26 -0
- package/dist/expr/suggest.d.ts.map +1 -0
- package/dist/expr/suggest.js +77 -0
- package/dist/expr/suggest.js.map +1 -0
- package/dist/expr/typecheck/aggregates.d.ts +8 -0
- package/dist/expr/typecheck/aggregates.d.ts.map +1 -0
- package/dist/expr/typecheck/aggregates.js +334 -0
- package/dist/expr/typecheck/aggregates.js.map +1 -0
- package/dist/expr/typecheck/arithmetic.d.ts +6 -0
- package/dist/expr/typecheck/arithmetic.d.ts.map +1 -0
- package/dist/expr/typecheck/arithmetic.js +258 -0
- package/dist/expr/typecheck/arithmetic.js.map +1 -0
- package/dist/expr/typecheck/arity.d.ts +38 -0
- package/dist/expr/typecheck/arity.d.ts.map +1 -0
- package/dist/expr/typecheck/arity.js +173 -0
- package/dist/expr/typecheck/arity.js.map +1 -0
- package/dist/expr/typecheck/calls.d.ts +6 -0
- package/dist/expr/typecheck/calls.d.ts.map +1 -0
- package/dist/expr/typecheck/calls.js +137 -0
- package/dist/expr/typecheck/calls.js.map +1 -0
- package/dist/expr/typecheck/comparison.d.ts +13 -0
- package/dist/expr/typecheck/comparison.d.ts.map +1 -0
- package/dist/expr/typecheck/comparison.js +200 -0
- package/dist/expr/typecheck/comparison.js.map +1 -0
- package/dist/expr/typecheck/compound.d.ts +24 -0
- package/dist/expr/typecheck/compound.d.ts.map +1 -0
- package/dist/expr/typecheck/compound.js +175 -0
- package/dist/expr/typecheck/compound.js.map +1 -0
- package/dist/expr/typecheck/context.d.ts +44 -0
- package/dist/expr/typecheck/context.d.ts.map +1 -0
- package/dist/expr/typecheck/context.js +2 -0
- package/dist/expr/typecheck/context.js.map +1 -0
- package/dist/expr/typecheck/datasets.d.ts +17 -0
- package/dist/expr/typecheck/datasets.d.ts.map +1 -0
- package/dist/expr/typecheck/datasets.js +136 -0
- package/dist/expr/typecheck/datasets.js.map +1 -0
- package/dist/expr/typecheck/digest.d.ts +7 -0
- package/dist/expr/typecheck/digest.d.ts.map +1 -0
- package/dist/expr/typecheck/digest.js +44 -0
- package/dist/expr/typecheck/digest.js.map +1 -0
- package/dist/expr/typecheck/fold.d.ts +41 -0
- package/dist/expr/typecheck/fold.d.ts.map +1 -0
- package/dist/expr/typecheck/fold.js +71 -0
- package/dist/expr/typecheck/fold.js.map +1 -0
- package/dist/expr/typecheck/gate-folds.d.ts +22 -0
- package/dist/expr/typecheck/gate-folds.d.ts.map +1 -0
- package/dist/expr/typecheck/gate-folds.js +40 -0
- package/dist/expr/typecheck/gate-folds.js.map +1 -0
- package/dist/expr/typecheck/guards.d.ts +6 -0
- package/dist/expr/typecheck/guards.d.ts.map +1 -0
- package/dist/expr/typecheck/guards.js +38 -0
- package/dist/expr/typecheck/guards.js.map +1 -0
- package/dist/expr/typecheck/member.d.ts +17 -0
- package/dist/expr/typecheck/member.d.ts.map +1 -0
- package/dist/expr/typecheck/member.js +46 -0
- package/dist/expr/typecheck/member.js.map +1 -0
- package/dist/expr/typecheck/money.d.ts +8 -0
- package/dist/expr/typecheck/money.d.ts.map +1 -0
- package/dist/expr/typecheck/money.js +49 -0
- package/dist/expr/typecheck/money.js.map +1 -0
- package/dist/expr/typecheck/numeric.d.ts +8 -0
- package/dist/expr/typecheck/numeric.d.ts.map +1 -0
- package/dist/expr/typecheck/numeric.js +84 -0
- package/dist/expr/typecheck/numeric.js.map +1 -0
- package/dist/expr/typecheck/operands.d.ts +27 -0
- package/dist/expr/typecheck/operands.d.ts.map +1 -0
- package/dist/expr/typecheck/operands.js +106 -0
- package/dist/expr/typecheck/operands.js.map +1 -0
- package/dist/expr/typecheck/paths.d.ts +21 -0
- package/dist/expr/typecheck/paths.d.ts.map +1 -0
- package/dist/expr/typecheck/paths.js +321 -0
- package/dist/expr/typecheck/paths.js.map +1 -0
- package/dist/expr/typecheck/records.d.ts +24 -0
- package/dist/expr/typecheck/records.d.ts.map +1 -0
- package/dist/expr/typecheck/records.js +53 -0
- package/dist/expr/typecheck/records.js.map +1 -0
- package/dist/expr/typecheck/sequences.d.ts +15 -0
- package/dist/expr/typecheck/sequences.d.ts.map +1 -0
- package/dist/expr/typecheck/sequences.js +55 -0
- package/dist/expr/typecheck/sequences.js.map +1 -0
- package/dist/expr/typecheck/strings.d.ts +8 -0
- package/dist/expr/typecheck/strings.d.ts.map +1 -0
- package/dist/expr/typecheck/strings.js +188 -0
- package/dist/expr/typecheck/strings.js.map +1 -0
- package/dist/expr/typecheck/temporal.d.ts +7 -0
- package/dist/expr/typecheck/temporal.d.ts.map +1 -0
- package/dist/expr/typecheck/temporal.js +80 -0
- package/dist/expr/typecheck/temporal.js.map +1 -0
- package/dist/expr/typecheck/types.d.ts +163 -0
- package/dist/expr/typecheck/types.d.ts.map +1 -0
- package/dist/expr/typecheck/types.js +404 -0
- package/dist/expr/typecheck/types.js.map +1 -0
- package/dist/expr/typecheck.d.ts +75 -0
- package/dist/expr/typecheck.d.ts.map +1 -0
- package/dist/expr/typecheck.js +242 -0
- package/dist/expr/typecheck.js.map +1 -0
- package/dist/expr/undecided.d.ts +13 -0
- package/dist/expr/undecided.d.ts.map +1 -0
- package/dist/expr/undecided.js +58 -0
- package/dist/expr/undecided.js.map +1 -0
- package/dist/expr/values/code-points.d.ts +13 -0
- package/dist/expr/values/code-points.d.ts.map +1 -0
- package/dist/expr/values/code-points.js +25 -0
- package/dist/expr/values/code-points.js.map +1 -0
- package/dist/expr/values/inline.d.ts +77 -0
- package/dist/expr/values/inline.d.ts.map +1 -0
- package/dist/expr/values/inline.js +404 -0
- package/dist/expr/values/inline.js.map +1 -0
- package/dist/expr/values/interval.d.ts +19 -0
- package/dist/expr/values/interval.d.ts.map +1 -0
- package/dist/expr/values/interval.js +1180 -0
- package/dist/expr/values/interval.js.map +1 -0
- package/dist/index.d.ts +163 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +128 -0
- package/dist/index.js.map +1 -0
- package/dist/ingest/document.d.ts +58 -0
- package/dist/ingest/document.d.ts.map +1 -0
- package/dist/ingest/document.js +83 -0
- package/dist/ingest/document.js.map +1 -0
- package/dist/ingest/yaml-document.d.ts +15 -0
- package/dist/ingest/yaml-document.d.ts.map +1 -0
- package/dist/ingest/yaml-document.js +42 -0
- package/dist/ingest/yaml-document.js.map +1 -0
- package/dist/ingest/yaml.d.ts +51 -0
- package/dist/ingest/yaml.d.ts.map +1 -0
- package/dist/ingest/yaml.js +340 -0
- package/dist/ingest/yaml.js.map +1 -0
- package/dist/layout/compile.d.ts +6 -0
- package/dist/layout/compile.d.ts.map +1 -0
- package/dist/layout/compile.js +224 -0
- package/dist/layout/compile.js.map +1 -0
- package/dist/layout/context.d.ts +12 -0
- package/dist/layout/context.d.ts.map +1 -0
- package/dist/layout/context.js +26 -0
- package/dist/layout/context.js.map +1 -0
- package/dist/layout/grammar.d.ts +34 -0
- package/dist/layout/grammar.d.ts.map +1 -0
- package/dist/layout/grammar.js +171 -0
- package/dist/layout/grammar.js.map +1 -0
- package/dist/layout/read.d.ts +54 -0
- package/dist/layout/read.d.ts.map +1 -0
- package/dist/layout/read.js +101 -0
- package/dist/layout/read.js.map +1 -0
- package/dist/layout/shape.d.ts +34 -0
- package/dist/layout/shape.d.ts.map +1 -0
- package/dist/layout/shape.js +149 -0
- package/dist/layout/shape.js.map +1 -0
- package/dist/messages/compile.d.ts +47 -0
- package/dist/messages/compile.d.ts.map +1 -0
- package/dist/messages/compile.js +202 -0
- package/dist/messages/compile.js.map +1 -0
- package/dist/messages/locale.d.ts +18 -0
- package/dist/messages/locale.d.ts.map +1 -0
- package/dist/messages/locale.js +33 -0
- package/dist/messages/locale.js.map +1 -0
- package/dist/messages/slots.d.ts +54 -0
- package/dist/messages/slots.d.ts.map +1 -0
- package/dist/messages/slots.js +137 -0
- package/dist/messages/slots.js.map +1 -0
- package/dist/overlay/compile-overlay.d.ts +29 -0
- package/dist/overlay/compile-overlay.d.ts.map +1 -0
- package/dist/overlay/compile-overlay.js +120 -0
- package/dist/overlay/compile-overlay.js.map +1 -0
- package/dist/overlay/compose.d.ts +26 -0
- package/dist/overlay/compose.d.ts.map +1 -0
- package/dist/overlay/compose.js +674 -0
- package/dist/overlay/compose.js.map +1 -0
- package/dist/overlay/types.d.ts +41 -0
- package/dist/overlay/types.d.ts.map +1 -0
- package/dist/overlay/types.js +2 -0
- package/dist/overlay/types.js.map +1 -0
- package/dist/publish/classify.d.ts +50 -0
- package/dist/publish/classify.d.ts.map +1 -0
- package/dist/publish/classify.js +85 -0
- package/dist/publish/classify.js.map +1 -0
- package/dist/publish/environment.d.ts +15 -0
- package/dist/publish/environment.d.ts.map +1 -0
- package/dist/publish/environment.js +2 -0
- package/dist/publish/environment.js.map +1 -0
- package/dist/publish/migrations.d.ts +108 -0
- package/dist/publish/migrations.d.ts.map +1 -0
- package/dist/publish/migrations.js +166 -0
- package/dist/publish/migrations.js.map +1 -0
- package/dist/publish/observation.d.ts +29 -0
- package/dist/publish/observation.d.ts.map +1 -0
- package/dist/publish/observation.js +43 -0
- package/dist/publish/observation.js.map +1 -0
- package/dist/publish/readiness.d.ts +197 -0
- package/dist/publish/readiness.d.ts.map +1 -0
- package/dist/publish/readiness.js +239 -0
- package/dist/publish/readiness.js.map +1 -0
- package/dist/publish/vectors.d.ts +50 -0
- package/dist/publish/vectors.d.ts.map +1 -0
- package/dist/publish/vectors.js +306 -0
- package/dist/publish/vectors.js.map +1 -0
- package/dist/publish/verify.d.ts +146 -0
- package/dist/publish/verify.d.ts.map +1 -0
- package/dist/publish/verify.js +548 -0
- package/dist/publish/verify.js.map +1 -0
- package/dist/scenarios/branch.d.ts +36 -0
- package/dist/scenarios/branch.d.ts.map +1 -0
- package/dist/scenarios/branch.js +30 -0
- package/dist/scenarios/branch.js.map +1 -0
- package/dist/scenarios/capture.d.ts +89 -0
- package/dist/scenarios/capture.d.ts.map +1 -0
- package/dist/scenarios/capture.js +443 -0
- package/dist/scenarios/capture.js.map +1 -0
- package/dist/scenarios/classifier.d.ts +20 -0
- package/dist/scenarios/classifier.d.ts.map +1 -0
- package/dist/scenarios/classifier.js +88 -0
- package/dist/scenarios/classifier.js.map +1 -0
- package/dist/scenarios/credit.d.ts +33 -0
- package/dist/scenarios/credit.d.ts.map +1 -0
- package/dist/scenarios/credit.js +330 -0
- package/dist/scenarios/credit.js.map +1 -0
- package/dist/scenarios/csv.d.ts +34 -0
- package/dist/scenarios/csv.d.ts.map +1 -0
- package/dist/scenarios/csv.js +1047 -0
- package/dist/scenarios/csv.js.map +1 -0
- package/dist/scenarios/data-identity.d.ts +39 -0
- package/dist/scenarios/data-identity.d.ts.map +1 -0
- package/dist/scenarios/data-identity.js +28 -0
- package/dist/scenarios/data-identity.js.map +1 -0
- package/dist/scenarios/document.d.ts +148 -0
- package/dist/scenarios/document.d.ts.map +1 -0
- package/dist/scenarios/document.js +513 -0
- package/dist/scenarios/document.js.map +1 -0
- package/dist/scenarios/environment.d.ts +64 -0
- package/dist/scenarios/environment.d.ts.map +1 -0
- package/dist/scenarios/environment.js +106 -0
- package/dist/scenarios/environment.js.map +1 -0
- package/dist/scenarios/evidence.d.ts +128 -0
- package/dist/scenarios/evidence.d.ts.map +1 -0
- package/dist/scenarios/evidence.js +179 -0
- package/dist/scenarios/evidence.js.map +1 -0
- package/dist/scenarios/expectations.d.ts +63 -0
- package/dist/scenarios/expectations.d.ts.map +1 -0
- package/dist/scenarios/expectations.js +490 -0
- package/dist/scenarios/expectations.js.map +1 -0
- package/dist/scenarios/references.d.ts +15 -0
- package/dist/scenarios/references.d.ts.map +1 -0
- package/dist/scenarios/references.js +239 -0
- package/dist/scenarios/references.js.map +1 -0
- package/dist/scenarios/report.d.ts +216 -0
- package/dist/scenarios/report.d.ts.map +1 -0
- package/dist/scenarios/report.js +54 -0
- package/dist/scenarios/report.js.map +1 -0
- package/dist/scenarios/runner.d.ts +55 -0
- package/dist/scenarios/runner.d.ts.map +1 -0
- package/dist/scenarios/runner.js +205 -0
- package/dist/scenarios/runner.js.map +1 -0
- package/dist/scenarios/vocabulary.d.ts +19 -0
- package/dist/scenarios/vocabulary.d.ts.map +1 -0
- package/dist/scenarios/vocabulary.js +56 -0
- package/dist/scenarios/vocabulary.js.map +1 -0
- package/dist/schema/catalogue.d.ts +54 -0
- package/dist/schema/catalogue.d.ts.map +1 -0
- package/dist/schema/catalogue.js +221 -0
- package/dist/schema/catalogue.js.map +1 -0
- package/dist/schema/check.d.ts +22 -0
- package/dist/schema/check.d.ts.map +1 -0
- package/dist/schema/check.js +30 -0
- package/dist/schema/check.js.map +1 -0
- package/dist/schema/closed.d.ts +19 -0
- package/dist/schema/closed.d.ts.map +1 -0
- package/dist/schema/closed.js +33 -0
- package/dist/schema/closed.js.map +1 -0
- package/dist/schema/collapse.d.ts +27 -0
- package/dist/schema/collapse.d.ts.map +1 -0
- package/dist/schema/collapse.js +143 -0
- package/dist/schema/collapse.js.map +1 -0
- package/dist/schema/controls.d.ts +46 -0
- package/dist/schema/controls.d.ts.map +1 -0
- package/dist/schema/controls.js +75 -0
- package/dist/schema/controls.js.map +1 -0
- package/dist/schema/dataset-declaration.d.ts +11 -0
- package/dist/schema/dataset-declaration.d.ts.map +1 -0
- package/dist/schema/dataset-declaration.js +11 -0
- package/dist/schema/dataset-declaration.js.map +1 -0
- package/dist/schema/declaration-warnings.d.ts +14 -0
- package/dist/schema/declaration-warnings.d.ts.map +1 -0
- package/dist/schema/declaration-warnings.js +77 -0
- package/dist/schema/declaration-warnings.js.map +1 -0
- package/dist/schema/declarations.d.ts +41 -0
- package/dist/schema/declarations.d.ts.map +1 -0
- package/dist/schema/declarations.js +1299 -0
- package/dist/schema/declarations.js.map +1 -0
- package/dist/schema/diagnostic.d.ts +118 -0
- package/dist/schema/diagnostic.d.ts.map +1 -0
- package/dist/schema/diagnostic.js +39 -0
- package/dist/schema/diagnostic.js.map +1 -0
- package/dist/schema/document.d.ts +93 -0
- package/dist/schema/document.d.ts.map +1 -0
- package/dist/schema/document.js +507 -0
- package/dist/schema/document.js.map +1 -0
- package/dist/schema/fields.d.ts +11 -0
- package/dist/schema/fields.d.ts.map +1 -0
- package/dist/schema/fields.js +265 -0
- package/dist/schema/fields.js.map +1 -0
- package/dist/schema/gates.d.ts +4 -0
- package/dist/schema/gates.d.ts.map +1 -0
- package/dist/schema/gates.js +68 -0
- package/dist/schema/gates.js.map +1 -0
- package/dist/schema/located.d.ts +27 -0
- package/dist/schema/located.d.ts.map +1 -0
- package/dist/schema/located.js +56 -0
- package/dist/schema/located.js.map +1 -0
- package/dist/schema/measurement.d.ts +9 -0
- package/dist/schema/measurement.d.ts.map +1 -0
- package/dist/schema/measurement.js +38 -0
- package/dist/schema/measurement.js.map +1 -0
- package/dist/schema/member-wording.d.ts +35 -0
- package/dist/schema/member-wording.d.ts.map +1 -0
- package/dist/schema/member-wording.js +286 -0
- package/dist/schema/member-wording.js.map +1 -0
- package/dist/schema/metaschema.d.ts +20 -0
- package/dist/schema/metaschema.d.ts.map +1 -0
- package/dist/schema/metaschema.js +476 -0
- package/dist/schema/metaschema.js.map +1 -0
- package/dist/schema/pointer.d.ts +31 -0
- package/dist/schema/pointer.d.ts.map +1 -0
- package/dist/schema/pointer.js +73 -0
- package/dist/schema/pointer.js.map +1 -0
- package/dist/schema/primary.d.ts +29 -0
- package/dist/schema/primary.d.ts.map +1 -0
- package/dist/schema/primary.js +48 -0
- package/dist/schema/primary.js.map +1 -0
- package/dist/schema/publish-vector.d.ts +17 -0
- package/dist/schema/publish-vector.d.ts.map +1 -0
- package/dist/schema/publish-vector.js +34 -0
- package/dist/schema/publish-vector.js.map +1 -0
- package/dist/schema/repair.d.ts +34 -0
- package/dist/schema/repair.d.ts.map +1 -0
- package/dist/schema/repair.js +163 -0
- package/dist/schema/repair.js.map +1 -0
- package/dist/schema/schema-v1.generated.d.ts +14 -0
- package/dist/schema/schema-v1.generated.d.ts.map +1 -0
- package/dist/schema/schema-v1.generated.js +7089 -0
- package/dist/schema/schema-v1.generated.js.map +1 -0
- package/dist/schema/screens.d.ts +4 -0
- package/dist/schema/screens.d.ts.map +1 -0
- package/dist/schema/screens.js +28 -0
- package/dist/schema/screens.js.map +1 -0
- package/dist/schema/test-values.d.ts +12 -0
- package/dist/schema/test-values.d.ts.map +1 -0
- package/dist/schema/test-values.js +97 -0
- package/dist/schema/test-values.js.map +1 -0
- package/dist/schema/unions.d.ts +46 -0
- package/dist/schema/unions.d.ts.map +1 -0
- package/dist/schema/unions.js +131 -0
- package/dist/schema/unions.js.map +1 -0
- package/dist/schema/validate-yaml.d.ts +14 -0
- package/dist/schema/validate-yaml.d.ts.map +1 -0
- package/dist/schema/validate-yaml.js +17 -0
- package/dist/schema/validate-yaml.js.map +1 -0
- package/dist/schema/validate.d.ts +46 -0
- package/dist/schema/validate.d.ts.map +1 -0
- package/dist/schema/validate.js +186 -0
- package/dist/schema/validate.js.map +1 -0
- package/dist/testing.d.ts +21 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +28 -0
- package/dist/testing.js.map +1 -0
- package/dist/vocabulary.d.ts +6 -0
- package/dist/vocabulary.d.ts.map +1 -0
- package/dist/vocabulary.js +26 -0
- package/dist/vocabulary.js.map +1 -0
- package/package.json +66 -3
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { CsvDatasetDeclaration } from '../datasets/index.js';
|
|
2
|
+
/** The argument that names standard input or standard output rather than a file. */
|
|
3
|
+
export declare const STDIO_PATH = "-";
|
|
4
|
+
/** How a document is named in a diagnostic; a stream has no path to repeat. */
|
|
5
|
+
export declare function displayPath(target: string): string;
|
|
6
|
+
/**
|
|
7
|
+
* How one read is bounded, when its format declares a bound.
|
|
8
|
+
*
|
|
9
|
+
* A CSV front-end states an input-byte limit; a JSON document does not, so a caller reading one
|
|
10
|
+
* passes no options rather than inventing a number the document contract does not state.
|
|
11
|
+
*/
|
|
12
|
+
export interface TextReadOptions {
|
|
13
|
+
readonly maxBytes?: number | undefined;
|
|
14
|
+
}
|
|
15
|
+
export type TextRead = {
|
|
16
|
+
readonly ok: true;
|
|
17
|
+
readonly text: string;
|
|
18
|
+
} | {
|
|
19
|
+
readonly ok: false;
|
|
20
|
+
readonly exitCode: number;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Reads one file as UTF-8 text, or reports why it cannot. `-` reads standard input.
|
|
24
|
+
*
|
|
25
|
+
* The bytes on disk are decoded, not a repaired reading of them: `readFile` with an encoding
|
|
26
|
+
* replaces every malformed sequence with U+FFFD, which lets a corrupted file pass as a valid
|
|
27
|
+
* document. A fatal decoder refuses instead, so a verdict always binds the bytes that were
|
|
28
|
+
* actually there. RFC 8259 section 8.1 permits ignoring one leading byte-order mark, so exactly
|
|
29
|
+
* one is stripped, and only at the start.
|
|
30
|
+
*
|
|
31
|
+
* A caller whose format declares a byte bound passes `maxBytes`. A regular file is stat'd first,
|
|
32
|
+
* so one already over the bound is refused without opening it; the read is still streamed, so a
|
|
33
|
+
* file that grows after the stat is refused at the crossing rather than decoded whole. A path
|
|
34
|
+
* with no trustworthy size — a FIFO, a device, `/dev/stdin` under a directory name — is capped
|
|
35
|
+
* as it is read. A JSON document declares no bound, so its callers pass no options.
|
|
36
|
+
*/
|
|
37
|
+
export declare function readText(target: string, options?: TextReadOptions): Promise<TextRead>;
|
|
38
|
+
export type DeclarationRead = {
|
|
39
|
+
readonly ok: true;
|
|
40
|
+
readonly value: CsvDatasetDeclaration;
|
|
41
|
+
} | {
|
|
42
|
+
readonly ok: false;
|
|
43
|
+
readonly exitCode: number;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Reads one CSV declaration.
|
|
47
|
+
*
|
|
48
|
+
* The text is parsed as restricted JSON, then narrowed to the members the CSV front-end
|
|
49
|
+
* dereferences. A declaration is a JSON document, which declares no byte bound, so it is read
|
|
50
|
+
* whole. That narrowing is the whole boundary this reader owns: the CSV front-end validates
|
|
51
|
+
* the assembled table against the closed dataset metaschema with no rows before it reads a
|
|
52
|
+
* single cell, so a semantic defect is refused there with its own path rather than guessed at
|
|
53
|
+
* here.
|
|
54
|
+
*/
|
|
55
|
+
export declare function readDeclaration(target: string): Promise<DeclarationRead>;
|
|
56
|
+
//# sourceMappingURL=read.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../../src/cli/read.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAIlE,oFAAoF;AACpF,eAAO,MAAM,UAAU,MAAM,CAAC;AAE9B,+EAA+E;AAC/E,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAElD;AAED;;;;;GAKG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACxC;AAED,MAAM,MAAM,QAAQ,GAChB;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC5C;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC;AAyFtD;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,eAAoB,GAAG,OAAO,CAAC,QAAQ,CAAC,CAgC/F;AAED,MAAM,MAAM,eAAe,GACvB;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,qBAAqB,CAAA;CAAE,GAC5D;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC;AAOtD;;;;;;;;;GASG;AACH,wBAAsB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAiB9E"}
|
package/dist/cli/read.js
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reading the documents a caller named, and the one stream a name cannot address.
|
|
3
|
+
*
|
|
4
|
+
* `-` is standard input, not a file called `-`: a Unix-shaped command line reads a document
|
|
5
|
+
* from a pipe, and the alternative — resolving the character as a path — makes a script that
|
|
6
|
+
* pipes a schema in fail with a confusing `ENOENT`. Standard input can be drained once, so a
|
|
7
|
+
* command that needs two documents from it is refused by name rather than silently handed an
|
|
8
|
+
* empty second document.
|
|
9
|
+
*/
|
|
10
|
+
import { createReadStream } from 'node:fs';
|
|
11
|
+
import { readFile, stat } from 'node:fs/promises';
|
|
12
|
+
import process from 'node:process';
|
|
13
|
+
import { TextDecoder } from 'node:util';
|
|
14
|
+
import { JsonIngestError, parseRestrictedJson } from '@azx-pbc/axiom-runtime';
|
|
15
|
+
import { narrowCsvDatasetDeclaration } from '../datasets/index.js';
|
|
16
|
+
import { causeText, printErrorLine } from './terminal.js';
|
|
17
|
+
import { EXIT_FAILED, EXIT_USAGE } from './usage.js';
|
|
18
|
+
/** The argument that names standard input or standard output rather than a file. */
|
|
19
|
+
export const STDIO_PATH = '-';
|
|
20
|
+
/** How a document is named in a diagnostic; a stream has no path to repeat. */
|
|
21
|
+
export function displayPath(target) {
|
|
22
|
+
return target === STDIO_PATH ? '<stdin>' : target;
|
|
23
|
+
}
|
|
24
|
+
/** Whether this run has already drained standard input. */
|
|
25
|
+
let standardInputRead = false;
|
|
26
|
+
/** A byte limit as the report states it: the exact count, and its readable size when whole MiB. */
|
|
27
|
+
function byteLimit(limit) {
|
|
28
|
+
const mebibytes = limit / (1024 * 1024);
|
|
29
|
+
return Number.isInteger(mebibytes) && mebibytes >= 1
|
|
30
|
+
? `${String(limit)}-byte (${String(mebibytes)} MiB)`
|
|
31
|
+
: `${String(limit)}-byte`;
|
|
32
|
+
}
|
|
33
|
+
/** The refusal for a file whose size the stat already proved over the declared bound. */
|
|
34
|
+
function refuseFileTooLarge(target, size, limit) {
|
|
35
|
+
printErrorLine(`${displayPath(target)}: the file is ${String(size)} bytes, over the ${byteLimit(limit)} input limit`);
|
|
36
|
+
return { ok: false, exitCode: EXIT_USAGE };
|
|
37
|
+
}
|
|
38
|
+
/** The refusal for a stream that crossed the declared bound while it was being read. */
|
|
39
|
+
function refuseStreamTooLarge(target, limit) {
|
|
40
|
+
printErrorLine(`${displayPath(target)}: the input exceeds the ${byteLimit(limit)} input limit at byte ${String(limit + 1)}`);
|
|
41
|
+
return { ok: false, exitCode: EXIT_USAGE };
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Reads a stream as one UTF-8 document, with the declared byte bound enforced as it arrives.
|
|
45
|
+
*
|
|
46
|
+
* The bound is checked before a chunk is decoded, so an over-size source is refused without
|
|
47
|
+
* materialising its text. A stream has no trustworthy size to stat — standard input and a
|
|
48
|
+
* device both report zero — so the crossing is the only place its bound can be enforced.
|
|
49
|
+
*/
|
|
50
|
+
async function readStream(stream, target, maxBytes) {
|
|
51
|
+
const decoder = new TextDecoder('utf-8', { fatal: true });
|
|
52
|
+
// The encoder only measures a string chunk; a byte chunk is consumed as it arrived. Both are
|
|
53
|
+
// what the decoder below will see, so the bound counts the same bytes the text does.
|
|
54
|
+
const encoder = new TextEncoder();
|
|
55
|
+
let text = '';
|
|
56
|
+
let bytes = 0;
|
|
57
|
+
try {
|
|
58
|
+
for await (const chunk of stream) {
|
|
59
|
+
const size = typeof chunk === 'string' ? encoder.encode(chunk).byteLength : chunk.byteLength;
|
|
60
|
+
if (maxBytes !== undefined && bytes + size > maxBytes) {
|
|
61
|
+
return refuseStreamTooLarge(target, maxBytes);
|
|
62
|
+
}
|
|
63
|
+
bytes += size;
|
|
64
|
+
text += typeof chunk === 'string' ? chunk : decoder.decode(chunk, { stream: true });
|
|
65
|
+
}
|
|
66
|
+
text += decoder.decode();
|
|
67
|
+
}
|
|
68
|
+
catch (cause) {
|
|
69
|
+
if (cause instanceof TypeError) {
|
|
70
|
+
printErrorLine(`${displayPath(target)}: JSON_INGEST_ERROR: the bytes are not valid UTF-8; save the file as UTF-8 and run again`);
|
|
71
|
+
return { ok: false, exitCode: EXIT_USAGE };
|
|
72
|
+
}
|
|
73
|
+
printErrorLine(`axiom-cli: cannot read ${displayPath(target)}: ${causeText(cause)}`);
|
|
74
|
+
return { ok: false, exitCode: EXIT_USAGE };
|
|
75
|
+
}
|
|
76
|
+
return { ok: true, text: text.startsWith('\uFEFF') ? text.slice(1) : text };
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Reads standard input as one UTF-8 document, or reports why it cannot.
|
|
80
|
+
*
|
|
81
|
+
* `TextDecoder` runs with `fatal: true` for the same reason a file read does: a malformed
|
|
82
|
+
* sequence is a refusal, not a replacement character that lets a corrupted document pass as
|
|
83
|
+
* valid. A second `-` is a usage error rather than an empty read, because the first document
|
|
84
|
+
* consumed the stream.
|
|
85
|
+
*/
|
|
86
|
+
async function readStandardInput(maxBytes) {
|
|
87
|
+
if (standardInputRead) {
|
|
88
|
+
printErrorLine('axiom-cli: `-` is standard input, and this run already read it; name a file for the second document');
|
|
89
|
+
return { ok: false, exitCode: EXIT_USAGE };
|
|
90
|
+
}
|
|
91
|
+
standardInputRead = true;
|
|
92
|
+
return readStream(process.stdin, STDIO_PATH, maxBytes);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Reads one file as UTF-8 text, or reports why it cannot. `-` reads standard input.
|
|
96
|
+
*
|
|
97
|
+
* The bytes on disk are decoded, not a repaired reading of them: `readFile` with an encoding
|
|
98
|
+
* replaces every malformed sequence with U+FFFD, which lets a corrupted file pass as a valid
|
|
99
|
+
* document. A fatal decoder refuses instead, so a verdict always binds the bytes that were
|
|
100
|
+
* actually there. RFC 8259 section 8.1 permits ignoring one leading byte-order mark, so exactly
|
|
101
|
+
* one is stripped, and only at the start.
|
|
102
|
+
*
|
|
103
|
+
* A caller whose format declares a byte bound passes `maxBytes`. A regular file is stat'd first,
|
|
104
|
+
* so one already over the bound is refused without opening it; the read is still streamed, so a
|
|
105
|
+
* file that grows after the stat is refused at the crossing rather than decoded whole. A path
|
|
106
|
+
* with no trustworthy size — a FIFO, a device, `/dev/stdin` under a directory name — is capped
|
|
107
|
+
* as it is read. A JSON document declares no bound, so its callers pass no options.
|
|
108
|
+
*/
|
|
109
|
+
export async function readText(target, options = {}) {
|
|
110
|
+
const { maxBytes } = options;
|
|
111
|
+
if (target === STDIO_PATH)
|
|
112
|
+
return readStandardInput(maxBytes);
|
|
113
|
+
if (maxBytes !== undefined) {
|
|
114
|
+
try {
|
|
115
|
+
const info = await stat(target);
|
|
116
|
+
if (info.isFile() && info.size > maxBytes) {
|
|
117
|
+
return refuseFileTooLarge(target, info.size, maxBytes);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
catch (cause) {
|
|
121
|
+
printErrorLine(`axiom-cli: cannot read ${target}: ${causeText(cause)}`);
|
|
122
|
+
return { ok: false, exitCode: EXIT_USAGE };
|
|
123
|
+
}
|
|
124
|
+
return readStream(createReadStream(target), target, maxBytes);
|
|
125
|
+
}
|
|
126
|
+
let bytes;
|
|
127
|
+
try {
|
|
128
|
+
bytes = await readFile(target);
|
|
129
|
+
}
|
|
130
|
+
catch (cause) {
|
|
131
|
+
printErrorLine(`axiom-cli: cannot read ${target}: ${causeText(cause)}`);
|
|
132
|
+
return { ok: false, exitCode: EXIT_USAGE };
|
|
133
|
+
}
|
|
134
|
+
let text;
|
|
135
|
+
try {
|
|
136
|
+
text = new TextDecoder('utf-8', { fatal: true }).decode(bytes);
|
|
137
|
+
}
|
|
138
|
+
catch {
|
|
139
|
+
printErrorLine(`${target}: JSON_INGEST_ERROR: the bytes are not valid UTF-8; save the file as UTF-8 and run again`);
|
|
140
|
+
return { ok: false, exitCode: EXIT_USAGE };
|
|
141
|
+
}
|
|
142
|
+
return { ok: true, text: text.startsWith('\uFEFF') ? text.slice(1) : text };
|
|
143
|
+
}
|
|
144
|
+
/** The text of an ingest refusal, naming the member at fault. */
|
|
145
|
+
function ingestDetail(error) {
|
|
146
|
+
return `${error.path === '' ? '$' : error.path}: JSON_INGEST_ERROR: ${error.message}`;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Reads one CSV declaration.
|
|
150
|
+
*
|
|
151
|
+
* The text is parsed as restricted JSON, then narrowed to the members the CSV front-end
|
|
152
|
+
* dereferences. A declaration is a JSON document, which declares no byte bound, so it is read
|
|
153
|
+
* whole. That narrowing is the whole boundary this reader owns: the CSV front-end validates
|
|
154
|
+
* the assembled table against the closed dataset metaschema with no rows before it reads a
|
|
155
|
+
* single cell, so a semantic defect is refused there with its own path rather than guessed at
|
|
156
|
+
* here.
|
|
157
|
+
*/
|
|
158
|
+
export async function readDeclaration(target) {
|
|
159
|
+
const read = await readText(target);
|
|
160
|
+
if (!read.ok)
|
|
161
|
+
return { ok: false, exitCode: read.exitCode };
|
|
162
|
+
let parsed;
|
|
163
|
+
try {
|
|
164
|
+
parsed = parseRestrictedJson(read.text);
|
|
165
|
+
}
|
|
166
|
+
catch (cause) {
|
|
167
|
+
if (!(cause instanceof JsonIngestError))
|
|
168
|
+
throw cause;
|
|
169
|
+
printErrorLine(`${displayPath(target)}: ${ingestDetail(cause)}`);
|
|
170
|
+
return { ok: false, exitCode: EXIT_FAILED };
|
|
171
|
+
}
|
|
172
|
+
const narrowed = narrowCsvDatasetDeclaration(parsed);
|
|
173
|
+
if (!narrowed.ok) {
|
|
174
|
+
printErrorLine(`${displayPath(target)}: ${narrowed.path}: DATASET_INVALID: ${narrowed.detail}`);
|
|
175
|
+
return { ok: false, exitCode: EXIT_FAILED };
|
|
176
|
+
}
|
|
177
|
+
return { ok: true, value: narrowed.declaration };
|
|
178
|
+
}
|
|
179
|
+
//# sourceMappingURL=read.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read.js","sourceRoot":"","sources":["../../src/cli/read.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC9E,OAAO,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AAEnE,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAErD,oFAAoF;AACpF,MAAM,CAAC,MAAM,UAAU,GAAG,GAAG,CAAC;AAE9B,+EAA+E;AAC/E,MAAM,UAAU,WAAW,CAAC,MAAc;IACxC,OAAO,MAAM,KAAK,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC;AACpD,CAAC;AAgBD,2DAA2D;AAC3D,IAAI,iBAAiB,GAAG,KAAK,CAAC;AAE9B,mGAAmG;AACnG,SAAS,SAAS,CAAC,KAAa;IAC9B,MAAM,SAAS,GAAG,KAAK,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC;IACxC,OAAO,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,SAAS,IAAI,CAAC;QAClD,CAAC,CAAC,GAAG,MAAM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C;YAAE,MAAM,KAAK,CAAC;QACrD,cAAc,CAAC,GAAG,WAAW,CAAC,MAAM,CAAC,KAAK,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACjE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC;IAC9C,CAAC;IACD,MAAM,QAAQ,GAAG,2BAA2B,CAAC,MAAM,CAAC,CAAC;IACrD,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,cAAc,CAAC,GAAG,WAAW,CAAC,MAAM,CAAC,KAAK,QAAQ,CAAC,IAAI,sBAAsB,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;QAChG,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC;IAC9C,CAAC;IACD,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,CAAC,WAAW,EAAE,CAAC;AACnD,CAAC","sourcesContent":["/**\n * Reading the documents a caller named, and the one stream a name cannot address.\n *\n * `-` is standard input, not a file called `-`: a Unix-shaped command line reads a document\n * from a pipe, and the alternative — resolving the character as a path — makes a script that\n * pipes a schema in fail with a confusing `ENOENT`. Standard input can be drained once, so a\n * command that needs two documents from it is refused by name rather than silently handed an\n * empty second document.\n */\nimport { createReadStream } from 'node:fs';\nimport { readFile, stat } from 'node:fs/promises';\nimport process from 'node:process';\nimport { TextDecoder } from 'node:util';\nimport { JsonIngestError, parseRestrictedJson } from '@azx-pbc/axiom-runtime';\nimport { narrowCsvDatasetDeclaration } from '../datasets/index.js';\nimport type { CsvDatasetDeclaration } from '../datasets/index.js';\nimport { causeText, printErrorLine } from './terminal.js';\nimport { EXIT_FAILED, EXIT_USAGE } from './usage.js';\n\n/** The argument that names standard input or standard output rather than a file. */\nexport const STDIO_PATH = '-';\n\n/** How a document is named in a diagnostic; a stream has no path to repeat. */\nexport function displayPath(target: string): string {\n return target === STDIO_PATH ? '<stdin>' : target;\n}\n\n/**\n * How one read is bounded, when its format declares a bound.\n *\n * A CSV front-end states an input-byte limit; a JSON document does not, so a caller reading one\n * passes no options rather than inventing a number the document contract does not state.\n */\nexport interface TextReadOptions {\n readonly maxBytes?: number | undefined;\n}\n\nexport type TextRead =\n | { readonly ok: true; readonly text: string }\n | { readonly ok: false; readonly exitCode: number };\n\n/** Whether this run has already drained standard input. */\nlet standardInputRead = false;\n\n/** A byte limit as the report states it: the exact count, and its readable size when whole MiB. */\nfunction byteLimit(limit: number): string {\n const mebibytes = limit / (1024 * 1024);\n return Number.isInteger(mebibytes) && mebibytes >= 1\n ? `${String(limit)}-byte (${String(mebibytes)} MiB)`\n : `${String(limit)}-byte`;\n}\n\n/** The refusal for a file whose size the stat already proved over the declared bound. */\nfunction refuseFileTooLarge(target: string, size: number, limit: number): TextRead {\n printErrorLine(\n `${displayPath(target)}: the file is ${String(size)} bytes, over the ${byteLimit(limit)} input limit`,\n );\n return { ok: false, exitCode: EXIT_USAGE };\n}\n\n/** The refusal for a stream that crossed the declared bound while it was being read. */\nfunction refuseStreamTooLarge(target: string, limit: number): TextRead {\n printErrorLine(\n `${displayPath(target)}: the input exceeds the ${byteLimit(limit)} input limit at byte ${String(limit + 1)}`,\n );\n return { ok: false, exitCode: EXIT_USAGE };\n}\n\n/**\n * Reads a stream as one UTF-8 document, with the declared byte bound enforced as it arrives.\n *\n * The bound is checked before a chunk is decoded, so an over-size source is refused without\n * materialising its text. A stream has no trustworthy size to stat — standard input and a\n * device both report zero — so the crossing is the only place its bound can be enforced.\n */\nasync function readStream(\n stream: AsyncIterable<string | Uint8Array>,\n target: string,\n maxBytes: number | undefined,\n): Promise<TextRead> {\n const decoder = new TextDecoder('utf-8', { fatal: true });\n // The encoder only measures a string chunk; a byte chunk is consumed as it arrived. Both are\n // what the decoder below will see, so the bound counts the same bytes the text does.\n const encoder = new TextEncoder();\n let text = '';\n let bytes = 0;\n try {\n for await (const chunk of stream) {\n const size = typeof chunk === 'string' ? encoder.encode(chunk).byteLength : chunk.byteLength;\n if (maxBytes !== undefined && bytes + size > maxBytes) {\n return refuseStreamTooLarge(target, maxBytes);\n }\n bytes += size;\n text += typeof chunk === 'string' ? chunk : decoder.decode(chunk, { stream: true });\n }\n text += decoder.decode();\n } catch (cause) {\n if (cause instanceof TypeError) {\n printErrorLine(\n `${displayPath(target)}: JSON_INGEST_ERROR: the bytes are not valid UTF-8; save the file as UTF-8 and run again`,\n );\n return { ok: false, exitCode: EXIT_USAGE };\n }\n printErrorLine(`axiom-cli: cannot read ${displayPath(target)}: ${causeText(cause)}`);\n return { ok: false, exitCode: EXIT_USAGE };\n }\n return { ok: true, text: text.startsWith('\\uFEFF') ? text.slice(1) : text };\n}\n\n/**\n * Reads standard input as one UTF-8 document, or reports why it cannot.\n *\n * `TextDecoder` runs with `fatal: true` for the same reason a file read does: a malformed\n * sequence is a refusal, not a replacement character that lets a corrupted document pass as\n * valid. A second `-` is a usage error rather than an empty read, because the first document\n * consumed the stream.\n */\nasync function readStandardInput(maxBytes: number | undefined): Promise<TextRead> {\n if (standardInputRead) {\n printErrorLine(\n 'axiom-cli: `-` is standard input, and this run already read it; name a file for the second document',\n );\n return { ok: false, exitCode: EXIT_USAGE };\n }\n standardInputRead = true;\n return readStream(process.stdin, STDIO_PATH, maxBytes);\n}\n\n/**\n * Reads one file as UTF-8 text, or reports why it cannot. `-` reads standard input.\n *\n * The bytes on disk are decoded, not a repaired reading of them: `readFile` with an encoding\n * replaces every malformed sequence with U+FFFD, which lets a corrupted file pass as a valid\n * document. A fatal decoder refuses instead, so a verdict always binds the bytes that were\n * actually there. RFC 8259 section 8.1 permits ignoring one leading byte-order mark, so exactly\n * one is stripped, and only at the start.\n *\n * A caller whose format declares a byte bound passes `maxBytes`. A regular file is stat'd first,\n * so one already over the bound is refused without opening it; the read is still streamed, so a\n * file that grows after the stat is refused at the crossing rather than decoded whole. A path\n * with no trustworthy size — a FIFO, a device, `/dev/stdin` under a directory name — is capped\n * as it is read. A JSON document declares no bound, so its callers pass no options.\n */\nexport async function readText(target: string, options: TextReadOptions = {}): Promise<TextRead> {\n const { maxBytes } = options;\n if (target === STDIO_PATH) return readStandardInput(maxBytes);\n if (maxBytes !== undefined) {\n try {\n const info = await stat(target);\n if (info.isFile() && info.size > maxBytes) {\n return refuseFileTooLarge(target, info.size, maxBytes);\n }\n } catch (cause) {\n printErrorLine(`axiom-cli: cannot read ${target}: ${causeText(cause)}`);\n return { ok: false, exitCode: EXIT_USAGE };\n }\n return readStream(createReadStream(target), target, maxBytes);\n }\n let bytes: Uint8Array;\n try {\n bytes = await readFile(target);\n } catch (cause) {\n printErrorLine(`axiom-cli: cannot read ${target}: ${causeText(cause)}`);\n return { ok: false, exitCode: EXIT_USAGE };\n }\n let text: string;\n try {\n text = new TextDecoder('utf-8', { fatal: true }).decode(bytes);\n } catch {\n printErrorLine(\n `${target}: JSON_INGEST_ERROR: the bytes are not valid UTF-8; save the file as UTF-8 and run again`,\n );\n return { ok: false, exitCode: EXIT_USAGE };\n }\n return { ok: true, text: text.startsWith('\\uFEFF') ? text.slice(1) : text };\n}\n\nexport type DeclarationRead =\n | { readonly ok: true; readonly value: CsvDatasetDeclaration }\n | { readonly ok: false; readonly exitCode: number };\n\n/** The text of an ingest refusal, naming the member at fault. */\nfunction ingestDetail(error: JsonIngestError): string {\n return `${error.path === '' ? '$' : error.path}: JSON_INGEST_ERROR: ${error.message}`;\n}\n\n/**\n * Reads one CSV declaration.\n *\n * The text is parsed as restricted JSON, then narrowed to the members the CSV front-end\n * dereferences. A declaration is a JSON document, which declares no byte bound, so it is read\n * whole. That narrowing is the whole boundary this reader owns: the CSV front-end validates\n * the assembled table against the closed dataset metaschema with no rows before it reads a\n * single cell, so a semantic defect is refused there with its own path rather than guessed at\n * here.\n */\nexport async function readDeclaration(target: string): Promise<DeclarationRead> {\n const read = await readText(target);\n if (!read.ok) return { ok: false, exitCode: read.exitCode };\n let parsed: unknown;\n try {\n parsed = parseRestrictedJson(read.text);\n } catch (cause) {\n if (!(cause instanceof JsonIngestError)) throw cause;\n printErrorLine(`${displayPath(target)}: ${ingestDetail(cause)}`);\n return { ok: false, exitCode: EXIT_FAILED };\n }\n const narrowed = narrowCsvDatasetDeclaration(parsed);\n if (!narrowed.ok) {\n printErrorLine(`${displayPath(target)}: ${narrowed.path}: DATASET_INVALID: ${narrowed.detail}`);\n return { ok: false, exitCode: EXIT_FAILED };\n }\n return { ok: true, value: narrowed.declaration };\n}\n"]}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { CompileWarning } from '../compile/warning.js';
|
|
2
|
+
import type { DatasetDiagnostic } from '../datasets/index.js';
|
|
3
|
+
import type { DocumentFormat } from '../ingest/document.js';
|
|
4
|
+
import type { SchemaDiagnostic } from '../schema/validate.js';
|
|
5
|
+
import type { DiagnosticCap } from './args.js';
|
|
6
|
+
/** Process-lifetime count of source parses performed for expression excerpts. */
|
|
7
|
+
export declare function excerptDocumentParses(): number;
|
|
8
|
+
/** Optional context a caller already holds when rendering schema diagnostics. */
|
|
9
|
+
export interface DiagnosticReportOptions {
|
|
10
|
+
/** Authoring spelling of `source`, when the caller already decided it from the path. */
|
|
11
|
+
readonly format?: DocumentFormat;
|
|
12
|
+
/** Already-ingested document tree, so expression excerpts never re-parse `source`. */
|
|
13
|
+
readonly document?: unknown;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Prints a compile's warnings on the diagnostics stream, without changing the exit code.
|
|
17
|
+
*
|
|
18
|
+
* A warning is advice, not a refusal, so the line is written to stderr beside a
|
|
19
|
+
* successful check or compile and the command still exits 0. The detail already names the
|
|
20
|
+
* replacement or the declaration that removes the finding; printing it here is what makes the
|
|
21
|
+
* warning visible to an author who never reads the `CompileSuccess` object.
|
|
22
|
+
*/
|
|
23
|
+
export declare function reportCompileWarnings(target: string, warnings: readonly CompileWarning[]): void;
|
|
24
|
+
/**
|
|
25
|
+
* Prints a schema's diagnostics, bounded by the cap the operator named.
|
|
26
|
+
*
|
|
27
|
+
* The bound is on the report only — the diagnostics arrive exhaustive from `compile()` —
|
|
28
|
+
* and a capped report ends by naming how many were withheld, so an operator always knows
|
|
29
|
+
* whether the list they read is the whole verdict. `source` is the text the command read, so
|
|
30
|
+
* a documented position becomes a line, a column and the line itself.
|
|
31
|
+
*/
|
|
32
|
+
export declare function reportSchemaDiagnostics(target: string, source: string, diagnostics: readonly SchemaDiagnostic[], cap: DiagnosticCap, options?: DiagnosticReportOptions): void;
|
|
33
|
+
/** Prints dataset diagnostics, each with the document, position and member path at fault. */
|
|
34
|
+
export declare function reportDatasetDiagnostics(target: string, diagnostics: readonly DatasetDiagnostic[]): void;
|
|
35
|
+
/**
|
|
36
|
+
* Emits a command's JSON artifact to `--out`, or to stdout when the operator named no file.
|
|
37
|
+
* A file is data and gets the document itself; a terminal gets the spelling whose code
|
|
38
|
+
* points cannot act on it. `--out -` is the explicit spelling of the stdout default.
|
|
39
|
+
* The file is staged beside its destination and renamed into place, so a failed write
|
|
40
|
+
* cannot leave a truncated artifact or let a planted symlink redirect the bytes, and an output
|
|
41
|
+
* that names an input is refused by the file's own identity rather than by how its path is
|
|
42
|
+
* spelled — a symlinked directory or a hard link is refused too, rather than replacing the
|
|
43
|
+
* document the command just read.
|
|
44
|
+
*/
|
|
45
|
+
export declare function emitJson(out: string | undefined, value: unknown, inputs?: readonly string[]): Promise<number>;
|
|
46
|
+
/**
|
|
47
|
+
* Emits a value as restricted-JCS canonical text, so two runs that decided the same thing write
|
|
48
|
+
* the same bytes. Those bytes make publish proposals comparable, never authenticated: a later
|
|
49
|
+
* gate re-derives its verdict from the artifact, the suites and the tables rather than letting
|
|
50
|
+
* the file stand in for the run.
|
|
51
|
+
*
|
|
52
|
+
* A file gets those canonical bytes. `--out -` names the terminal, and a report interpolates what
|
|
53
|
+
* an untrusted document declared — a vector's `expected`, a suite's refusal — so the stream gets
|
|
54
|
+
* the same bytes with each code point a terminal acts on spelled as its JSON escape: a legal
|
|
55
|
+
* spelling of the same report, which is what a caller piping it onward parses back.
|
|
56
|
+
*/
|
|
57
|
+
export declare function emitCanonicalJson(out: string | undefined, value: unknown, inputs?: readonly string[]): Promise<number>;
|
|
58
|
+
//# sourceMappingURL=render.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/cli/render.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAI9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAG5D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAiJ/C,iFAAiF;AACjF,wBAAgB,qBAAqB,IAAI,MAAM,CAE9C;AAED,iFAAiF;AACjF,MAAM,WAAW,uBAAuB;IACtC,wFAAwF;IACxF,QAAQ,CAAC,MAAM,CAAC,EAAE,cAAc,CAAC;IACjC,sFAAsF;IACtF,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;CAC7B;AAyDD;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,cAAc,EAAE,GAAG,IAAI,CAI/F;AAED;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,SAAS,gBAAgB,EAAE,EACxC,GAAG,EAAE,aAAa,EAClB,OAAO,GAAE,uBAA4B,GACpC,IAAI,CA0CN;AAUD,6FAA6F;AAC7F,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,SAAS,iBAAiB,EAAE,GACxC,IAAI,CAUN;AAED;;;;;;;;;GASG;AACH,w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