@versionzero/schema 1.0.0
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 +177 -0
- package/README.md +246 -0
- package/package.json +84 -0
- package/src/compilation/handler-compilation.js +28 -0
- package/src/compilation/metadata-compilation.js +35 -0
- package/src/compilation/schema-compilation.js +142 -0
- package/src/compilation/selection-compilation.js +84 -0
- package/src/compilation/union-compilation.js +510 -0
- package/src/compilation/values-compilation.js +35 -0
- package/src/compiled-schema.js +1709 -0
- package/src/constants.js +1 -0
- package/src/core-library/index.js +32 -0
- package/src/core-library/processors/aggregation-operators.js +75 -0
- package/src/core-library/processors/alpha-constraint.js +20 -0
- package/src/core-library/processors/alphanum-constraint.js +20 -0
- package/src/core-library/processors/array-operator.js +51 -0
- package/src/core-library/processors/assert-constraint.js +75 -0
- package/src/core-library/processors/base64-constraint.js +26 -0
- package/src/core-library/processors/camel-case-operator.js +24 -0
- package/src/core-library/processors/capitalize-operator.js +16 -0
- package/src/core-library/processors/cardnum-constraint.js +193 -0
- package/src/core-library/processors/ceil-operator.js +44 -0
- package/src/core-library/processors/collapse-operator.js +29 -0
- package/src/core-library/processors/compact-operator.js +34 -0
- package/src/core-library/processors/compile-operator.js +65 -0
- package/src/core-library/processors/concat-operator.js +51 -0
- package/src/core-library/processors/conditional-operators.js +301 -0
- package/src/core-library/processors/constant-case-operator.js +16 -0
- package/src/core-library/processors/data-size-operator.js +86 -0
- package/src/core-library/processors/date-object-operator.js +54 -0
- package/src/core-library/processors/date-operator.js +67 -0
- package/src/core-library/processors/date-range-constraint.js +76 -0
- package/src/core-library/processors/defined-constraint.js +30 -0
- package/src/core-library/processors/each-operator.js +57 -0
- package/src/core-library/processors/email-constraint.js +112 -0
- package/src/core-library/processors/entries-operator.js +25 -0
- package/src/core-library/processors/eq-constraint.js +37 -0
- package/src/core-library/processors/filter-operator.js +74 -0
- package/src/core-library/processors/find-schema-operator.js +45 -0
- package/src/core-library/processors/flatten-operator.js +40 -0
- package/src/core-library/processors/floor-operator.js +47 -0
- package/src/core-library/processors/get-operator.js +44 -0
- package/src/core-library/processors/group-by-operator.js +84 -0
- package/src/core-library/processors/has-prefix-constraint.js +37 -0
- package/src/core-library/processors/has-suffix-constraint.js +35 -0
- package/src/core-library/processors/hex-constraint.js +20 -0
- package/src/core-library/processors/hostname-constraint.js +22 -0
- package/src/core-library/processors/http-url-constraint.js +27 -0
- package/src/core-library/processors/in-constraint.js +66 -0
- package/src/core-library/processors/index-by-operator.js +98 -0
- package/src/core-library/processors/index.js +131 -0
- package/src/core-library/processors/input-operator.js +23 -0
- package/src/core-library/processors/instanceof-constraint.js +38 -0
- package/src/core-library/processors/integer-constraint.js +22 -0
- package/src/core-library/processors/invoke-operator.js +33 -0
- package/src/core-library/processors/ipv4-constraint.js +188 -0
- package/src/core-library/processors/ipv6-constraint.js +205 -0
- package/src/core-library/processors/is-array-constraint.js +21 -0
- package/src/core-library/processors/is-date-constraint.js +22 -0
- package/src/core-library/processors/is-number-constraint.js +21 -0
- package/src/core-library/processors/is-object-constraint.js +21 -0
- package/src/core-library/processors/is-string-constraint.js +21 -0
- package/src/core-library/processors/join-operator.js +41 -0
- package/src/core-library/processors/json-constraint.js +22 -0
- package/src/core-library/processors/json-decode-operator.js +25 -0
- package/src/core-library/processors/json-encode-operator.js +35 -0
- package/src/core-library/processors/kebab-case-operator.js +23 -0
- package/src/core-library/processors/keys-operator.js +20 -0
- package/src/core-library/processors/length-constraint.js +85 -0
- package/src/core-library/processors/lookup-operator.js +84 -0
- package/src/core-library/processors/lowercase-operator.js +14 -0
- package/src/core-library/processors/map-operator.js +84 -0
- package/src/core-library/processors/match-operator.js +64 -0
- package/src/core-library/processors/matches-constraint.js +54 -0
- package/src/core-library/processors/math-operators.js +151 -0
- package/src/core-library/processors/merge-deep-operator.js +61 -0
- package/src/core-library/processors/merge-operator.js +54 -0
- package/src/core-library/processors/metadata-operator.js +100 -0
- package/src/core-library/processors/negative-constraint.js +23 -0
- package/src/core-library/processors/never-constraint.js +69 -0
- package/src/core-library/processors/non-empty-constraint.js +59 -0
- package/src/core-library/processors/not-constraint.js +71 -0
- package/src/core-library/processors/number-operator.js +24 -0
- package/src/core-library/processors/numeric-constraint.js +22 -0
- package/src/core-library/processors/object-operator.js +38 -0
- package/src/core-library/processors/omit-operator.js +57 -0
- package/src/core-library/processors/parallel-operator.js +64 -0
- package/src/core-library/processors/pascal-case-operator.js +16 -0
- package/src/core-library/processors/phone-constraint.js +235 -0
- package/src/core-library/processors/pick-operator.js +62 -0
- package/src/core-library/processors/pipeline-operator.js +63 -0
- package/src/core-library/processors/port-constraint.js +22 -0
- package/src/core-library/processors/positive-constraint.js +23 -0
- package/src/core-library/processors/process-operator.js +55 -0
- package/src/core-library/processors/property-operator.js +49 -0
- package/src/core-library/processors/range-constraint.js +72 -0
- package/src/core-library/processors/reference-operator.js +79 -0
- package/src/core-library/processors/require-constraint.js +74 -0
- package/src/core-library/processors/reverse-operator.js +20 -0
- package/src/core-library/processors/round-operator.js +53 -0
- package/src/core-library/processors/schema-handler-operators.js +54 -0
- package/src/core-library/processors/semver-constraint.js +282 -0
- package/src/core-library/processors/sequence-processors.js +406 -0
- package/src/core-library/processors/sort-operator.js +52 -0
- package/src/core-library/processors/split-operator.js +43 -0
- package/src/core-library/processors/string-extra-operators.js +141 -0
- package/src/core-library/processors/string-operator.js +34 -0
- package/src/core-library/processors/target-operator.js +30 -0
- package/src/core-library/processors/template-operator.js +60 -0
- package/src/core-library/processors/title-case-operator.js +17 -0
- package/src/core-library/processors/trim-operator.js +14 -0
- package/src/core-library/processors/truthy-constraint.js +35 -0
- package/src/core-library/processors/type-operator.js +24 -0
- package/src/core-library/processors/unique-operator.js +21 -0
- package/src/core-library/processors/uppercase-operator.js +14 -0
- package/src/core-library/processors/url-constraint.js +31 -0
- package/src/core-library/processors/url-decode-operator.js +50 -0
- package/src/core-library/processors/url-encode-operator.js +44 -0
- package/src/core-library/processors/uuid-constraint.js +31 -0
- package/src/core-library/processors/values-operator.js +20 -0
- package/src/core-library/schemas/any-schema.js +23 -0
- package/src/core-library/schemas/array-schema.js +8 -0
- package/src/core-library/schemas/boolean-schema.js +10 -0
- package/src/core-library/schemas/date-schema.js +12 -0
- package/src/core-library/schemas/function-schema.js +40 -0
- package/src/core-library/schemas/number-schema.js +9 -0
- package/src/core-library/schemas/object-schema.js +10 -0
- package/src/core-library/schemas/root-schema.js +21 -0
- package/src/core-library/schemas/string-schema.js +9 -0
- package/src/core-library-node/index.js +47 -0
- package/src/core-library-node/processors/base64-decode-operator.js +20 -0
- package/src/core-library-node/processors/base64-encode-operator.js +20 -0
- package/src/core-library-node/processors/buffer-operator.js +39 -0
- package/src/core-library-node/processors/directory-constraint.js +35 -0
- package/src/core-library-node/processors/executable-constraint.js +34 -0
- package/src/core-library-node/processors/file-constraint.js +34 -0
- package/src/core-library-node/processors/file-size-constraint.js +94 -0
- package/src/core-library-node/processors/is-buffer-constraint.js +21 -0
- package/src/core-library-node/processors/reachable-constraint.js +28 -0
- package/src/core-library-node/processors/readable-constraint.js +34 -0
- package/src/core-library-node/processors/writable-constraint.js +59 -0
- package/src/core-library-node/schemas/buffer-schema.js +10 -0
- package/src/errors.js +209 -0
- package/src/executor/array-executor.js +78 -0
- package/src/executor/conditional-executor.js +134 -0
- package/src/executor/each-executor.js +68 -0
- package/src/executor/executor.js +123 -0
- package/src/executor/object-executor.js +98 -0
- package/src/executor/parallel-executor.js +43 -0
- package/src/executor/pipeline-executor.js +65 -0
- package/src/executor/sequence-executor.js +206 -0
- package/src/executor/serial-executor.js +24 -0
- package/src/executor/step-executor.js +68 -0
- package/src/helpers/case.js +124 -0
- package/src/helpers/data-size.js +144 -0
- package/src/helpers/debug-sink.js +15 -0
- package/src/helpers/deep.js +280 -0
- package/src/helpers/format.js +121 -0
- package/src/helpers/has-string-properties.js +30 -0
- package/src/helpers/index.js +16 -0
- package/src/helpers/object.js +115 -0
- package/src/helpers/parse-date.js +75 -0
- package/src/helpers/path.js +28 -0
- package/src/helpers/regex.js +18 -0
- package/src/helpers/stringify.js +309 -0
- package/src/helpers/to-data.js +64 -0
- package/src/helpers/truthy.js +55 -0
- package/src/index.js +29 -0
- package/src/schema-compiler.js +531 -0
- package/src/schema-location.js +200 -0
- package/src/schema-resolver.js +546 -0
- package/src/schema.js +1182 -0
- package/src/traversal/executors/check-condition.js +42 -0
- package/src/traversal/executors/check-input.js +27 -0
- package/src/traversal/executors/check-required.js +19 -0
- package/src/traversal/executors/check-schema.js +45 -0
- package/src/traversal/executors/defaults.js +21 -0
- package/src/traversal/executors/enter-existing.js +25 -0
- package/src/traversal/executors/enter-input.js +25 -0
- package/src/traversal/executors/enter.js +37 -0
- package/src/traversal/executors/exit.js +74 -0
- package/src/traversal/executors/finalize.js +64 -0
- package/src/traversal/executors/index.js +42 -0
- package/src/traversal/executors/normalize.js +38 -0
- package/src/traversal/executors/prepare-existing.js +27 -0
- package/src/traversal/executors/prepare-pending.js +54 -0
- package/src/traversal/executors/resolve-union.js +50 -0
- package/src/traversal/executors/serialize.js +48 -0
- package/src/traversal/executors/transform-early.js +51 -0
- package/src/traversal/executors/transform.js +68 -0
- package/src/traversal/executors/traversal-state-executor.js +46 -0
- package/src/traversal/executors/validate.js +63 -0
- package/src/traversal/traversal-context.js +231 -0
- package/src/traversal/traversal-state.js +809 -0
- package/src/types.js +102 -0
- package/src/value-processor/composed-value-processor.js +43 -0
- package/src/value-processor/defined-value-processor.js +72 -0
- package/src/value-processor/function-value-processor.js +68 -0
- package/src/value-processor/parameterized-value-processor.js +45 -0
- package/src/value-processor/parameters-value-processor.js +178 -0
- package/src/value-processor/spec.js +89 -0
- package/src/value-processor/value-processor.js +105 -0
- package/types/compilation/handler-compilation.d.ts +13 -0
- package/types/compilation/metadata-compilation.d.ts +6 -0
- package/types/compilation/schema-compilation.d.ts +32 -0
- package/types/compilation/selection-compilation.d.ts +9 -0
- package/types/compilation/union-compilation.d.ts +42 -0
- package/types/compilation/values-compilation.d.ts +12 -0
- package/types/compiled-schema.d.ts +883 -0
- package/types/constants.d.ts +1 -0
- package/types/core-library/index.d.ts +7 -0
- package/types/core-library/processors/aggregation-operators.d.ts +24 -0
- package/types/core-library/processors/alpha-constraint.d.ts +9 -0
- package/types/core-library/processors/alphanum-constraint.d.ts +9 -0
- package/types/core-library/processors/array-operator.d.ts +12 -0
- package/types/core-library/processors/assert-constraint.d.ts +30 -0
- package/types/core-library/processors/base64-constraint.d.ts +11 -0
- package/types/core-library/processors/camel-case-operator.d.ts +17 -0
- package/types/core-library/processors/capitalize-operator.d.ts +11 -0
- package/types/core-library/processors/cardnum-constraint.d.ts +51 -0
- package/types/core-library/processors/ceil-operator.d.ts +30 -0
- package/types/core-library/processors/collapse-operator.d.ts +24 -0
- package/types/core-library/processors/compact-operator.d.ts +29 -0
- package/types/core-library/processors/compile-operator.d.ts +34 -0
- package/types/core-library/processors/concat-operator.d.ts +23 -0
- package/types/core-library/processors/conditional-operators.d.ts +219 -0
- package/types/core-library/processors/constant-case-operator.d.ts +9 -0
- package/types/core-library/processors/data-size-operator.d.ts +31 -0
- package/types/core-library/processors/date-object-operator.d.ts +16 -0
- package/types/core-library/processors/date-operator.d.ts +21 -0
- package/types/core-library/processors/date-range-constraint.d.ts +26 -0
- package/types/core-library/processors/defined-constraint.d.ts +20 -0
- package/types/core-library/processors/each-operator.d.ts +34 -0
- package/types/core-library/processors/email-constraint.d.ts +54 -0
- package/types/core-library/processors/entries-operator.d.ts +13 -0
- package/types/core-library/processors/eq-constraint.d.ts +20 -0
- package/types/core-library/processors/filter-operator.d.ts +35 -0
- package/types/core-library/processors/find-schema-operator.d.ts +28 -0
- package/types/core-library/processors/flatten-operator.d.ts +26 -0
- package/types/core-library/processors/floor-operator.d.ts +33 -0
- package/types/core-library/processors/get-operator.d.ts +31 -0
- package/types/core-library/processors/group-by-operator.d.ts +36 -0
- package/types/core-library/processors/has-prefix-constraint.d.ts +22 -0
- package/types/core-library/processors/has-suffix-constraint.d.ts +20 -0
- package/types/core-library/processors/hex-constraint.d.ts +9 -0
- package/types/core-library/processors/hostname-constraint.d.ts +11 -0
- package/types/core-library/processors/http-url-constraint.d.ts +9 -0
- package/types/core-library/processors/in-constraint.d.ts +27 -0
- package/types/core-library/processors/index-by-operator.d.ts +26 -0
- package/types/core-library/processors/index.d.ts +8 -0
- package/types/core-library/processors/input-operator.d.ts +20 -0
- package/types/core-library/processors/instanceof-constraint.d.ts +23 -0
- package/types/core-library/processors/integer-constraint.d.ts +9 -0
- package/types/core-library/processors/invoke-operator.d.ts +12 -0
- package/types/core-library/processors/ipv4-constraint.d.ts +37 -0
- package/types/core-library/processors/ipv6-constraint.d.ts +34 -0
- package/types/core-library/processors/is-array-constraint.d.ts +10 -0
- package/types/core-library/processors/is-date-constraint.d.ts +10 -0
- package/types/core-library/processors/is-number-constraint.d.ts +10 -0
- package/types/core-library/processors/is-object-constraint.d.ts +10 -0
- package/types/core-library/processors/is-string-constraint.d.ts +10 -0
- package/types/core-library/processors/join-operator.d.ts +29 -0
- package/types/core-library/processors/json-constraint.d.ts +10 -0
- package/types/core-library/processors/json-decode-operator.d.ts +9 -0
- package/types/core-library/processors/json-encode-operator.d.ts +27 -0
- package/types/core-library/processors/kebab-case-operator.d.ts +16 -0
- package/types/core-library/processors/keys-operator.d.ts +9 -0
- package/types/core-library/processors/length-constraint.d.ts +34 -0
- package/types/core-library/processors/lookup-operator.d.ts +36 -0
- package/types/core-library/processors/lowercase-operator.d.ts +9 -0
- package/types/core-library/processors/map-operator.d.ts +38 -0
- package/types/core-library/processors/match-operator.d.ts +34 -0
- package/types/core-library/processors/matches-constraint.d.ts +29 -0
- package/types/core-library/processors/math-operators.d.ts +91 -0
- package/types/core-library/processors/merge-deep-operator.d.ts +32 -0
- package/types/core-library/processors/merge-operator.d.ts +26 -0
- package/types/core-library/processors/metadata-operator.d.ts +56 -0
- package/types/core-library/processors/negative-constraint.d.ts +13 -0
- package/types/core-library/processors/never-constraint.d.ts +26 -0
- package/types/core-library/processors/non-empty-constraint.d.ts +28 -0
- package/types/core-library/processors/not-constraint.d.ts +28 -0
- package/types/core-library/processors/number-operator.d.ts +9 -0
- package/types/core-library/processors/numeric-constraint.d.ts +10 -0
- package/types/core-library/processors/object-operator.d.ts +10 -0
- package/types/core-library/processors/omit-operator.d.ts +24 -0
- package/types/core-library/processors/parallel-operator.d.ts +41 -0
- package/types/core-library/processors/pascal-case-operator.d.ts +9 -0
- package/types/core-library/processors/phone-constraint.d.ts +65 -0
- package/types/core-library/processors/pick-operator.d.ts +27 -0
- package/types/core-library/processors/pipeline-operator.d.ts +40 -0
- package/types/core-library/processors/port-constraint.d.ts +11 -0
- package/types/core-library/processors/positive-constraint.d.ts +13 -0
- package/types/core-library/processors/process-operator.d.ts +37 -0
- package/types/core-library/processors/property-operator.d.ts +34 -0
- package/types/core-library/processors/range-constraint.d.ts +30 -0
- package/types/core-library/processors/reference-operator.d.ts +38 -0
- package/types/core-library/processors/require-constraint.d.ts +29 -0
- package/types/core-library/processors/reverse-operator.d.ts +9 -0
- package/types/core-library/processors/round-operator.d.ts +34 -0
- package/types/core-library/processors/schema-handler-operators.d.ts +28 -0
- package/types/core-library/processors/semver-constraint.d.ts +43 -0
- package/types/core-library/processors/sequence-processors.d.ts +213 -0
- package/types/core-library/processors/sort-operator.d.ts +31 -0
- package/types/core-library/processors/split-operator.d.ts +33 -0
- package/types/core-library/processors/string-extra-operators.d.ts +83 -0
- package/types/core-library/processors/string-operator.d.ts +10 -0
- package/types/core-library/processors/target-operator.d.ts +27 -0
- package/types/core-library/processors/template-operator.d.ts +31 -0
- package/types/core-library/processors/title-case-operator.d.ts +12 -0
- package/types/core-library/processors/trim-operator.d.ts +9 -0
- package/types/core-library/processors/truthy-constraint.d.ts +23 -0
- package/types/core-library/processors/type-operator.d.ts +11 -0
- package/types/core-library/processors/unique-operator.d.ts +10 -0
- package/types/core-library/processors/uppercase-operator.d.ts +9 -0
- package/types/core-library/processors/url-constraint.d.ts +20 -0
- package/types/core-library/processors/url-decode-operator.d.ts +31 -0
- package/types/core-library/processors/url-encode-operator.d.ts +36 -0
- package/types/core-library/processors/uuid-constraint.d.ts +20 -0
- package/types/core-library/processors/values-operator.d.ts +9 -0
- package/types/core-library/schemas/any-schema.d.ts +2 -0
- package/types/core-library/schemas/array-schema.d.ts +2 -0
- package/types/core-library/schemas/boolean-schema.d.ts +2 -0
- package/types/core-library/schemas/date-schema.d.ts +2 -0
- package/types/core-library/schemas/function-schema.d.ts +2 -0
- package/types/core-library/schemas/number-schema.d.ts +2 -0
- package/types/core-library/schemas/object-schema.d.ts +2 -0
- package/types/core-library/schemas/root-schema.d.ts +2 -0
- package/types/core-library/schemas/string-schema.d.ts +2 -0
- package/types/core-library-node/index.d.ts +12 -0
- package/types/core-library-node/processors/base64-decode-operator.d.ts +9 -0
- package/types/core-library-node/processors/base64-encode-operator.d.ts +9 -0
- package/types/core-library-node/processors/buffer-operator.d.ts +15 -0
- package/types/core-library-node/processors/directory-constraint.d.ts +14 -0
- package/types/core-library-node/processors/executable-constraint.d.ts +17 -0
- package/types/core-library-node/processors/file-constraint.d.ts +13 -0
- package/types/core-library-node/processors/file-size-constraint.d.ts +43 -0
- package/types/core-library-node/processors/is-buffer-constraint.d.ts +10 -0
- package/types/core-library-node/processors/reachable-constraint.d.ts +13 -0
- package/types/core-library-node/processors/readable-constraint.d.ts +17 -0
- package/types/core-library-node/processors/writable-constraint.d.ts +18 -0
- package/types/core-library-node/schemas/buffer-schema.d.ts +2 -0
- package/types/errors.d.ts +58 -0
- package/types/executor/array-executor.d.ts +17 -0
- package/types/executor/conditional-executor.d.ts +45 -0
- package/types/executor/each-executor.d.ts +15 -0
- package/types/executor/executor.d.ts +84 -0
- package/types/executor/object-executor.d.ts +14 -0
- package/types/executor/parallel-executor.d.ts +27 -0
- package/types/executor/pipeline-executor.d.ts +11 -0
- package/types/executor/sequence-executor.d.ts +32 -0
- package/types/executor/serial-executor.d.ts +16 -0
- package/types/executor/step-executor.d.ts +14 -0
- package/types/helpers/case.d.ts +30 -0
- package/types/helpers/data-size.d.ts +25 -0
- package/types/helpers/debug-sink.d.ts +9 -0
- package/types/helpers/deep.d.ts +33 -0
- package/types/helpers/format.d.ts +14 -0
- package/types/helpers/has-string-properties.d.ts +5 -0
- package/types/helpers/index.d.ts +13 -0
- package/types/helpers/object.d.ts +46 -0
- package/types/helpers/parse-date.d.ts +6 -0
- package/types/helpers/path.d.ts +13 -0
- package/types/helpers/regex.d.ts +7 -0
- package/types/helpers/stringify.d.ts +33 -0
- package/types/helpers/to-data.d.ts +13 -0
- package/types/helpers/truthy.d.ts +26 -0
- package/types/index.d.ts +6 -0
- package/types/schema-compiler.d.ts +49 -0
- package/types/schema-location.d.ts +64 -0
- package/types/schema-resolver.d.ts +145 -0
- package/types/schema.d.ts +586 -0
- package/types/traversal/executors/check-condition.d.ts +8 -0
- package/types/traversal/executors/check-input.d.ts +6 -0
- package/types/traversal/executors/check-required.d.ts +6 -0
- package/types/traversal/executors/check-schema.d.ts +7 -0
- package/types/traversal/executors/defaults.d.ts +8 -0
- package/types/traversal/executors/enter-existing.d.ts +6 -0
- package/types/traversal/executors/enter-input.d.ts +8 -0
- package/types/traversal/executors/enter.d.ts +7 -0
- package/types/traversal/executors/exit.d.ts +6 -0
- package/types/traversal/executors/finalize.d.ts +6 -0
- package/types/traversal/executors/index.d.ts +15 -0
- package/types/traversal/executors/normalize.d.ts +7 -0
- package/types/traversal/executors/prepare-existing.d.ts +6 -0
- package/types/traversal/executors/prepare-pending.d.ts +6 -0
- package/types/traversal/executors/resolve-union.d.ts +6 -0
- package/types/traversal/executors/serialize.d.ts +11 -0
- package/types/traversal/executors/transform-early.d.ts +6 -0
- package/types/traversal/executors/transform.d.ts +6 -0
- package/types/traversal/executors/traversal-state-executor.d.ts +19 -0
- package/types/traversal/executors/validate.d.ts +6 -0
- package/types/traversal/traversal-context.d.ts +67 -0
- package/types/traversal/traversal-state.d.ts +97 -0
- package/types/types.d.ts +218 -0
- package/types/value-processor/composed-value-processor.d.ts +17 -0
- package/types/value-processor/defined-value-processor.d.ts +16 -0
- package/types/value-processor/function-value-processor.d.ts +15 -0
- package/types/value-processor/parameterized-value-processor.d.ts +14 -0
- package/types/value-processor/parameters-value-processor.d.ts +28 -0
- package/types/value-processor/spec.d.ts +22 -0
- package/types/value-processor/value-processor.d.ts +92 -0
|
@@ -0,0 +1,883 @@
|
|
|
1
|
+
/** @import { TraversalContextOptions } from './traversal/traversal-context.js' */
|
|
2
|
+
/** @import { ISchema, ISchemaOptions, ISchemaMetadata, SchemaData } from './types.js' */
|
|
3
|
+
/** @typedef {ISchemaMetadata} CompiledSchemaMetadata */
|
|
4
|
+
/** @typedef {ISchemaOptions} CompiledSchemaOptions */
|
|
5
|
+
/**
|
|
6
|
+
* @typedef {object} CompiledSchemaHandlers
|
|
7
|
+
* @property {Array<ValueProcessor>} [normalizers]
|
|
8
|
+
* @property {Array<ValueProcessor>} [conditions]
|
|
9
|
+
* @property {Array<ValueProcessor>} [transformers]
|
|
10
|
+
* @property {Array<ValueProcessor>} [finalizers]
|
|
11
|
+
* @property {Array<ValueProcessor>} [validators]
|
|
12
|
+
* @property {Array<ValueProcessor>} [serializers]
|
|
13
|
+
* @property {Array<ValueProcessor>} [discriminators]
|
|
14
|
+
*/
|
|
15
|
+
/** @typedef {{[key:string]:CompiledSchema}} CompiledSchemaProperties */
|
|
16
|
+
/** @typedef {{[key:string]:CompiledSchema}} CompiledSchemaUnionSchemas */
|
|
17
|
+
/**
|
|
18
|
+
* @typedef {object} SharedOptions
|
|
19
|
+
* @property {SchemaLocation} [location]
|
|
20
|
+
* @property {TraversalContext|TraversalContextOptions} [context]
|
|
21
|
+
*/
|
|
22
|
+
/** @typedef {SharedOptions & {[key:string]: any}} ValidateOptions */
|
|
23
|
+
/** @typedef {SharedOptions & {[key:string]: any}} SerializeOptions */
|
|
24
|
+
/** @typedef {SharedOptions & {assignments?:Map<string,any>} & {[key:string]: any}} ProcessOptions */
|
|
25
|
+
/** @typedef {SharedOptions & {[key:string]: any}} ProcessAssignmentsOptions */
|
|
26
|
+
/**
|
|
27
|
+
* CompiledSchema - the resolved version of a schema usable for processing input values into output values
|
|
28
|
+
*
|
|
29
|
+
* The SchemaResolver compiler takes an input Schema and constructs a CompiledSchema:
|
|
30
|
+
* - The base schema hierarchy is resolved and flattened.
|
|
31
|
+
* - Handlers have their input specifications converted into value processor executors.
|
|
32
|
+
* - Unions may trigger property hoisting and discriminator synthesis.
|
|
33
|
+
* - Core options are converted to standardized forms.
|
|
34
|
+
* - Metadata is expanded by introspecting the resolved schema.
|
|
35
|
+
* - Errors are thrown if the input Schema is invalid, inconsistent, or missing required data.
|
|
36
|
+
*
|
|
37
|
+
* @augments {ISchema}
|
|
38
|
+
*/
|
|
39
|
+
export class CompiledSchema {
|
|
40
|
+
/** @internal */
|
|
41
|
+
static __TOKEN: symbol;
|
|
42
|
+
/**
|
|
43
|
+
* CompiledSchema constructor - do not call directly (use SchemaResolver.compile())
|
|
44
|
+
*
|
|
45
|
+
* @param {symbol} token - magic to reduce shenanigans
|
|
46
|
+
*/
|
|
47
|
+
constructor(token: symbol);
|
|
48
|
+
/**
|
|
49
|
+
* Options contains information that changes schema parsing and processing.
|
|
50
|
+
*
|
|
51
|
+
* @type {CompiledSchemaOptions}
|
|
52
|
+
*/
|
|
53
|
+
get options(): CompiledSchemaOptions;
|
|
54
|
+
/**
|
|
55
|
+
* Metadata contains information for describing the schema behavior to users and hints for tools.
|
|
56
|
+
*
|
|
57
|
+
* @type {CompiledSchemaMetadata}
|
|
58
|
+
*/
|
|
59
|
+
get metadata(): CompiledSchemaMetadata;
|
|
60
|
+
/**
|
|
61
|
+
* Properties are named child schemas, defining a hierarchical schema structure.
|
|
62
|
+
*
|
|
63
|
+
* This is an (inefficient) cache for compatibility with the ISchema "interface".
|
|
64
|
+
*
|
|
65
|
+
* @type {CompiledSchemaProperties}
|
|
66
|
+
*/
|
|
67
|
+
get properties(): CompiledSchemaProperties;
|
|
68
|
+
/**
|
|
69
|
+
*
|
|
70
|
+
* @type {IteratorObject<[string, CompiledSchema]>}
|
|
71
|
+
*/
|
|
72
|
+
get propertyEntries(): IteratorObject<[string, CompiledSchema]>;
|
|
73
|
+
/**
|
|
74
|
+
* Handlers are associated with asynchronous value processors.
|
|
75
|
+
*
|
|
76
|
+
* The "friendly" handler definitions from the source Schema are each compiled into asynchronous functions
|
|
77
|
+
* that run as a pipeline.
|
|
78
|
+
*
|
|
79
|
+
* All handlers have the same async signature, receiving:
|
|
80
|
+
* 1. a value to be processed by the current schema
|
|
81
|
+
* 2. a reference to the top-level aggregate target being built or processed by the entire schema hierarchy
|
|
82
|
+
* 3. a location defining the current schema and the traversal path to where it was encountered
|
|
83
|
+
* 5. any (unmanaged / developer defined) options passed to whatever invoked the handler processing
|
|
84
|
+
*
|
|
85
|
+
* The compiled handlers may vary in their return types and exception handling behavior.
|
|
86
|
+
*
|
|
87
|
+
* @type {CompiledSchemaHandlers}
|
|
88
|
+
*/
|
|
89
|
+
get handlers(): CompiledSchemaHandlers;
|
|
90
|
+
/**
|
|
91
|
+
* Get a value processor by handler name
|
|
92
|
+
*
|
|
93
|
+
* Handler definitions are compiled into a single value processor pipeline per handler name.
|
|
94
|
+
*
|
|
95
|
+
* @param {string} handlerName
|
|
96
|
+
* @returns {ValueProcessor|undefined}
|
|
97
|
+
* @internal
|
|
98
|
+
*/
|
|
99
|
+
getValueProcessor(handlerName: string): ValueProcessor | undefined;
|
|
100
|
+
/**
|
|
101
|
+
*
|
|
102
|
+
* @param {string} handlerName
|
|
103
|
+
* @param {ValueProcessor} valueProcessor
|
|
104
|
+
* @returns {ValueProcessor}
|
|
105
|
+
* @internal
|
|
106
|
+
*/
|
|
107
|
+
_setValueProcessor(handlerName: string, valueProcessor: ValueProcessor): ValueProcessor;
|
|
108
|
+
/**
|
|
109
|
+
* If this schema defines a union, return the schema member elements of the union.
|
|
110
|
+
*
|
|
111
|
+
* Unions use a discriminator handler to attempt to resolve to one of the unionSchema member elements
|
|
112
|
+
* based on either the value being processed or the overall aggregated data. The key of the
|
|
113
|
+
* unionSchema in this collection is sometimes used as part of this process.
|
|
114
|
+
*
|
|
115
|
+
* Once the discriminator succeeds, the active schema switches to the resolved unionSchema.
|
|
116
|
+
*
|
|
117
|
+
* @type {CompiledSchemaUnionSchemas}
|
|
118
|
+
*/
|
|
119
|
+
get unionSchemas(): CompiledSchemaUnionSchemas;
|
|
120
|
+
/**
|
|
121
|
+
*
|
|
122
|
+
* @type {IteratorObject<[string, CompiledSchema]>}
|
|
123
|
+
*/
|
|
124
|
+
get unionSchemaEntries(): IteratorObject<[string, CompiledSchema]>;
|
|
125
|
+
/**
|
|
126
|
+
* Extract this schema as a raw data object usable for cloning this schema.
|
|
127
|
+
*
|
|
128
|
+
* Note that the data may include handler functions, so it cannot be assumed to be serializable to JSON!
|
|
129
|
+
*
|
|
130
|
+
* @returns {SchemaData|undefined}
|
|
131
|
+
*/
|
|
132
|
+
toData(): SchemaData | undefined;
|
|
133
|
+
/**
|
|
134
|
+
* Return true if this schema has any child schemas.
|
|
135
|
+
*
|
|
136
|
+
* @type {boolean}
|
|
137
|
+
*/
|
|
138
|
+
get hasChildren(): boolean;
|
|
139
|
+
/**
|
|
140
|
+
* Return true if this schema should be treated as a container.
|
|
141
|
+
*
|
|
142
|
+
* Any schema that has children is a container, but also those explicitly marked as a container.
|
|
143
|
+
*
|
|
144
|
+
* @returns {boolean}
|
|
145
|
+
*/
|
|
146
|
+
get isContainer(): boolean;
|
|
147
|
+
/**
|
|
148
|
+
* Return true if this schema supports wildcard properties.
|
|
149
|
+
*
|
|
150
|
+
* @type {boolean}
|
|
151
|
+
*/
|
|
152
|
+
get hasWildcard(): boolean;
|
|
153
|
+
/**
|
|
154
|
+
* Return true if this schema defines an array.
|
|
155
|
+
*
|
|
156
|
+
* Arrays sometimes need special treatment; the built-in 'array' base schema sets this option.
|
|
157
|
+
*
|
|
158
|
+
* @type {boolean}
|
|
159
|
+
*/
|
|
160
|
+
get isArray(): boolean;
|
|
161
|
+
/**
|
|
162
|
+
* Return true if this schema defines a function value.
|
|
163
|
+
*
|
|
164
|
+
* Functions passed to most operations are interpreted as dynamic values (called to retrieve actual value).
|
|
165
|
+
* This setting overrides that behavior, and forces a passed function to be treated as a simple value.
|
|
166
|
+
*
|
|
167
|
+
* @type {boolean}
|
|
168
|
+
*/
|
|
169
|
+
get isFunction(): boolean;
|
|
170
|
+
/**
|
|
171
|
+
* Return true if this schema defines a union.
|
|
172
|
+
* Unions adopt the behavior of one of their unionSchema member elements based on a discriminator handler function.
|
|
173
|
+
*
|
|
174
|
+
* @type {boolean}
|
|
175
|
+
*/
|
|
176
|
+
get isUnion(): boolean;
|
|
177
|
+
/**
|
|
178
|
+
* Return true if this schema is used to select union keys.
|
|
179
|
+
*
|
|
180
|
+
* (This doesn't guarantee that there is a matching discriminator on the parent that uses it!)
|
|
181
|
+
* todo - convert this option into a generated normalizer that enforces union key values at runtime?
|
|
182
|
+
*
|
|
183
|
+
* @type {boolean}
|
|
184
|
+
*/
|
|
185
|
+
get isUnionKey(): boolean;
|
|
186
|
+
/**
|
|
187
|
+
* Return true if the schema acts as a selector.
|
|
188
|
+
*
|
|
189
|
+
* Selectors control the activation or deactivation of peer selection schemas using a conditional handler
|
|
190
|
+
* synthesized during compilation.
|
|
191
|
+
*
|
|
192
|
+
* @type {boolean}
|
|
193
|
+
*/
|
|
194
|
+
get isSelector(): boolean;
|
|
195
|
+
/**
|
|
196
|
+
* Return true if this schema contains a selector as a child.
|
|
197
|
+
* @type {boolean}
|
|
198
|
+
*/
|
|
199
|
+
get hasChildSelector(): boolean;
|
|
200
|
+
/**
|
|
201
|
+
* Return true if this schema is a selection conditionally activated by a peer selector.
|
|
202
|
+
*
|
|
203
|
+
* @type {boolean}
|
|
204
|
+
*/
|
|
205
|
+
get isSelection(): boolean;
|
|
206
|
+
/**
|
|
207
|
+
* Return true if this schema contains a selection as a child.
|
|
208
|
+
* @type {boolean}
|
|
209
|
+
*/
|
|
210
|
+
get hasChildSelection(): boolean;
|
|
211
|
+
/**
|
|
212
|
+
* Get the selector value that triggers this selection. The default value for a selection is its own property name.
|
|
213
|
+
*
|
|
214
|
+
* @type {string|boolean|undefined}
|
|
215
|
+
*/
|
|
216
|
+
get selection(): string | boolean | undefined;
|
|
217
|
+
/**
|
|
218
|
+
* Return the legal (normalized) values this schema accepts, if defined.
|
|
219
|
+
*
|
|
220
|
+
* (This acts as an "upstream" check before calling any transform handlers.)
|
|
221
|
+
*
|
|
222
|
+
* @type {Array<NonNullable<any>>|undefined}
|
|
223
|
+
*/
|
|
224
|
+
get values(): Array<NonNullable<any>> | undefined;
|
|
225
|
+
/**
|
|
226
|
+
* Returns true if this schema defines any values it accepts.
|
|
227
|
+
*
|
|
228
|
+
* @type {boolean}
|
|
229
|
+
*/
|
|
230
|
+
get hasValues(): boolean;
|
|
231
|
+
/**
|
|
232
|
+
* Returns whether this schema enforces strict/lax checking.
|
|
233
|
+
*
|
|
234
|
+
* - returns true if the schema uses strict checking
|
|
235
|
+
* - returns false if the schema uses lax checking
|
|
236
|
+
* - if undefined, it depends on the traversal context and the behavior of individual processors
|
|
237
|
+
*
|
|
238
|
+
* This setting is useful for preventing validation errors when transforms return new objects
|
|
239
|
+
* that contain extra properties that don't match the schema.
|
|
240
|
+
*
|
|
241
|
+
* In most contexts (e.g. assignment processing and validation) strict processing is the default.
|
|
242
|
+
* Setting lax mode changes several behaviors:
|
|
243
|
+
* - If a union is marked lax, it is not an error to fail to resolve the union
|
|
244
|
+
* - If a leaf schema is marked lax, it is not an error if a value fails to assign to it
|
|
245
|
+
*
|
|
246
|
+
* Lax mode does *not* mean that errors during normalization
|
|
247
|
+
*
|
|
248
|
+
* @type {boolean|undefined}
|
|
249
|
+
*/
|
|
250
|
+
get strict(): boolean | undefined;
|
|
251
|
+
/**
|
|
252
|
+
* Returns true if the value defined by this schema is required to exist in the output to be valid.
|
|
253
|
+
*
|
|
254
|
+
* Under the normal pathways, this is a shallow requirement:
|
|
255
|
+
* - Each schema checks its own input; if the required flag is set, the input must not be undefined.
|
|
256
|
+
* - If the input value is defined and the schema defines child properties, the input will be traversed
|
|
257
|
+
* and recursively checked against the child property schemas.
|
|
258
|
+
* - If the input value is undefined, child property schemas are NOT checked.
|
|
259
|
+
*
|
|
260
|
+
* If the "deep" flag is set on the schema, this behavior changes:
|
|
261
|
+
* - If the input value is undefined on a schema with "deep" set, child properties ARE checked.
|
|
262
|
+
*
|
|
263
|
+
* If a schema sets a default value, it will generally satisfy the required setting (unless set to a
|
|
264
|
+
* value function that returns undefined!)
|
|
265
|
+
*
|
|
266
|
+
* @type {boolean}
|
|
267
|
+
*/
|
|
268
|
+
get required(): boolean;
|
|
269
|
+
/**
|
|
270
|
+
* Returns the default value this schema provides if the input is undefined.
|
|
271
|
+
*
|
|
272
|
+
* This is normally interpreted as a "shallow" default;
|
|
273
|
+
* - If the schema being actively processed has a default value and the input value is undefined, the default is used.
|
|
274
|
+
* - If the schema being actively processed defines child properties, and is passed an input value that does not
|
|
275
|
+
* contain a value for a specific child that defines a default, the child's default will be used.
|
|
276
|
+
* - If the schema being actively processed defines child properties, but is passed an undefined input value,
|
|
277
|
+
* the child property schemas will not be traversed, and thus any child defaults will not take effect.
|
|
278
|
+
*
|
|
279
|
+
* This last behavior changes if the "deep" schema option is set:
|
|
280
|
+
* - If the schema being actively processed defines child properties is passed an undefined input value when
|
|
281
|
+
* the "deep" option is enabled, child property schemas will be traversed and any defaults will be used.
|
|
282
|
+
*
|
|
283
|
+
* The default may also be set to a value function:
|
|
284
|
+
* `async (value: any, target: any, location:SchemaLocation, options: Object): any`
|
|
285
|
+
* that will be called during the normalization phase. This can be useful for late binding, remote lookups,
|
|
286
|
+
* side effects, or lazy evaluation of expensive values.
|
|
287
|
+
*
|
|
288
|
+
* @type {any|undefined}
|
|
289
|
+
*/
|
|
290
|
+
get default(): any | undefined;
|
|
291
|
+
/**
|
|
292
|
+
* Returns whether this schema should be deeply traversed even when the input is empty.
|
|
293
|
+
*
|
|
294
|
+
* This is useful for triggering required/defaults settings. (Note that a schema with
|
|
295
|
+
* child properties that is marked required is deep by default, because that's almost
|
|
296
|
+
* always what is wanted/expected.)
|
|
297
|
+
*
|
|
298
|
+
* Returns undefined if unset, signaling that the traversal context will decide.
|
|
299
|
+
*
|
|
300
|
+
* @type {boolean|undefined}
|
|
301
|
+
*/
|
|
302
|
+
get deep(): boolean | undefined;
|
|
303
|
+
/**
|
|
304
|
+
* Return true if the schema always returns an inherited or referenced value.
|
|
305
|
+
*
|
|
306
|
+
* Referenced properties never accept a direct assignment, and will always return the value
|
|
307
|
+
* corresponding to the first matching property name found higher in the schema.
|
|
308
|
+
*
|
|
309
|
+
* @type {boolean}
|
|
310
|
+
*/
|
|
311
|
+
get isReference(): boolean;
|
|
312
|
+
/**
|
|
313
|
+
* Returns true if this schema defines a value that can be assumed to always exist and be valid.
|
|
314
|
+
*
|
|
315
|
+
* The implicit setting implies that values passed to this schema should not be visited or validated.
|
|
316
|
+
*
|
|
317
|
+
* @type {boolean}
|
|
318
|
+
*/
|
|
319
|
+
get isImplicit(): boolean;
|
|
320
|
+
/**
|
|
321
|
+
* Returns true if the container allows incremental assignment to children.
|
|
322
|
+
* Deprecated - use "opaque" as a more accurate signal of intent.
|
|
323
|
+
*
|
|
324
|
+
* @type {boolean}
|
|
325
|
+
* @deprecated
|
|
326
|
+
*/
|
|
327
|
+
get allowIncremental(): boolean;
|
|
328
|
+
/**
|
|
329
|
+
* Returns true if the schema defines a value whose internals are hidden after transformation.
|
|
330
|
+
*
|
|
331
|
+
* Opaque schemas will typically need a custom validator that understands the post-transform contract.
|
|
332
|
+
*
|
|
333
|
+
* Transformation of opaque schemas is delayed until all known child assignments have been staged into a
|
|
334
|
+
* pending container. Once an opaque schema is transformed, it no longer accepts assignments. (This
|
|
335
|
+
* may cause sequencing issues with late-resolved conditional assignments!)
|
|
336
|
+
*
|
|
337
|
+
* @type {boolean}
|
|
338
|
+
*/
|
|
339
|
+
get isOpaque(): boolean;
|
|
340
|
+
/**
|
|
341
|
+
* Check if the provided value (and/or current output target) passes the schema conditional check.
|
|
342
|
+
*
|
|
343
|
+
* Schemas that don't have a condition handler defined will always succeed.
|
|
344
|
+
*
|
|
345
|
+
* Failed conditions will be repeatedly re-checked during assignment processing until the final pass.
|
|
346
|
+
* Errors encountered while checking conditions are caught and simply result in a failed condition.
|
|
347
|
+
*
|
|
348
|
+
* (This is an executor function that may return synchronous or asynchronous results.)
|
|
349
|
+
*
|
|
350
|
+
* @param {any} value
|
|
351
|
+
* @param {any} [target]
|
|
352
|
+
* @param {SchemaLocation} [location]
|
|
353
|
+
* @param {object} [options]
|
|
354
|
+
* @returns {boolean|Promise<boolean>}
|
|
355
|
+
* @internal
|
|
356
|
+
*/
|
|
357
|
+
_checkCondition(value: any, target?: any, location?: SchemaLocation, options?: object): boolean | Promise<boolean>;
|
|
358
|
+
/**
|
|
359
|
+
* Check if the provided value (and/or current output target) passes the schema conditional check.
|
|
360
|
+
*
|
|
361
|
+
* Failed conditions will be repeatedly re-checked during assignment processing until the final pass.
|
|
362
|
+
* Errors encountered while checking conditions are caught and simply result in a failed condition.
|
|
363
|
+
*
|
|
364
|
+
* (This an async wrapper around the internal `_checkCondition` executor function.)
|
|
365
|
+
*
|
|
366
|
+
* @param {any} value
|
|
367
|
+
* @param {any} [target]
|
|
368
|
+
* @param {SchemaLocation} [location]
|
|
369
|
+
* @param {object} [options]
|
|
370
|
+
* @returns {Promise<boolean>}
|
|
371
|
+
* @internal
|
|
372
|
+
*/
|
|
373
|
+
checkCondition(value: any, target?: any, location?: SchemaLocation, options?: object): Promise<boolean>;
|
|
374
|
+
/**
|
|
375
|
+
* Return true if this schema is conditional
|
|
376
|
+
*
|
|
377
|
+
* @returns {boolean}
|
|
378
|
+
*/
|
|
379
|
+
get hasConditions(): boolean;
|
|
380
|
+
/**
|
|
381
|
+
* Return true if this schema requires finalization
|
|
382
|
+
*
|
|
383
|
+
* @returns {boolean}
|
|
384
|
+
*/
|
|
385
|
+
get requiresFinalization(): boolean;
|
|
386
|
+
_checkValue(value: any, ErrorClass: any): any;
|
|
387
|
+
/**
|
|
388
|
+
* Use the registered discriminator to return a matching union schema, or undefined if the union cannot be resolved.
|
|
389
|
+
* Discriminator functions must return either one of the unionSchema members, a unionSchema key, or undefined.
|
|
390
|
+
*
|
|
391
|
+
* (This is an executor function that may return synchronous or asynchronous results.)
|
|
392
|
+
*
|
|
393
|
+
* @param {any} value
|
|
394
|
+
* @param {any} [target]
|
|
395
|
+
* @param {SchemaLocation} [location]
|
|
396
|
+
* @param {object} [options]
|
|
397
|
+
* @returns {CompiledSchema|undefined|Promise<CompiledSchema|undefined>}
|
|
398
|
+
* @internal
|
|
399
|
+
*/
|
|
400
|
+
_discriminateUnion(value: any, target?: any, location?: SchemaLocation, options?: object): CompiledSchema | undefined | Promise<CompiledSchema | undefined>;
|
|
401
|
+
/**
|
|
402
|
+
* Use the registered discriminator to return a matching union schema, or undefined if the union cannot be resolved.
|
|
403
|
+
* Discriminator functions must return either one of the unionSchema members, a unionSchema key, or undefined.
|
|
404
|
+
*
|
|
405
|
+
* (This an async wrapper around the internal `_discriminateUnion` executor function.)
|
|
406
|
+
*
|
|
407
|
+
* @param {any} value
|
|
408
|
+
* @param {any} [target]
|
|
409
|
+
* @param {SchemaLocation} [location]
|
|
410
|
+
* @param {object} [options]
|
|
411
|
+
* @returns {Promise<CompiledSchema|undefined>}
|
|
412
|
+
* @internal
|
|
413
|
+
*/
|
|
414
|
+
discriminateUnion(value: any, target?: any, location?: SchemaLocation, options?: object): Promise<CompiledSchema | undefined>;
|
|
415
|
+
/**
|
|
416
|
+
* Ensure the input is of an expected shape that can be handled by this schema.
|
|
417
|
+
*
|
|
418
|
+
* Runs all normalizer value processors in a pipeline until completion or an error is thrown.
|
|
419
|
+
* As external data may originate in the form of strings or JSON structures, the main task of
|
|
420
|
+
* a normalizer is to "canonicalize" these inputs:
|
|
421
|
+
* - The normalized output should be accepted by the transformer handler.
|
|
422
|
+
* - Normalizers should usually pass through valid transformed values unchanged.
|
|
423
|
+
* - By contract, when passed "true", a container schema should construct an "empty"
|
|
424
|
+
* container (e.g. {} or []). (Even a schema that defines transformation to a
|
|
425
|
+
* complex class should have a normalized empty container format to use for construction).
|
|
426
|
+
*
|
|
427
|
+
* The normalize process will throw an exception if the input is incompatible.
|
|
428
|
+
*
|
|
429
|
+
* Unlike other handlers, normalizers should generally not depend on the overall
|
|
430
|
+
* target state, as they are sometimes invoked in isolation (even during compilation!)
|
|
431
|
+
* and thus shouldn't assume the "undefined means retry later" behavior of other handlers.
|
|
432
|
+
*
|
|
433
|
+
* Also note that normalizeValue does not recursively examine child properties.
|
|
434
|
+
*
|
|
435
|
+
* (This is an executor function that may return synchronous or asynchronous results.)
|
|
436
|
+
*
|
|
437
|
+
* @param {any} value - value to normalize
|
|
438
|
+
* @param {any} [target] - top level output target being built (avoid using for normalizers!)
|
|
439
|
+
* @param {SchemaLocation} [location] - path to this value in the output target
|
|
440
|
+
* @param {object} [options] - optional tweaks to normalizer behavior
|
|
441
|
+
* @returns {any|Promise<any>}
|
|
442
|
+
* @internal
|
|
443
|
+
*/
|
|
444
|
+
_normalizeValue(value: any, target?: any, location?: SchemaLocation, options?: object): any | Promise<any>;
|
|
445
|
+
/**
|
|
446
|
+
* Ensure the input is of an expected shape that can be handled by this schema.
|
|
447
|
+
*
|
|
448
|
+
* Runs all normalizer value processors in a pipeline until completion or an error is thrown.
|
|
449
|
+
* As many external input values will originate in the form of strings or JSON
|
|
450
|
+
* structures, the main task of a normalizer is to "canonicalize" these inputs:
|
|
451
|
+
* - The normalized output should be accepted by the transformer handler.
|
|
452
|
+
* - Normalizers should usually pass through valid transformed values unchanged.
|
|
453
|
+
* - By contract, when passed "true", a container schema should construct an "empty"
|
|
454
|
+
* container (e.g. {} or []). (Even a schema that defines transformation to a
|
|
455
|
+
* complex class should have a normalized empty container format to use for construction).
|
|
456
|
+
*
|
|
457
|
+
* The normalize process will throw an exception if the input is incompatible.
|
|
458
|
+
*
|
|
459
|
+
* Unlike other handlers, normalizers should generally not depend on the overall
|
|
460
|
+
* target state, as they are sometimes invoked in isolation (even during compilation!)
|
|
461
|
+
* and thus shouldn't assume the "undefined means retry later" behavior of other handlers.
|
|
462
|
+
*
|
|
463
|
+
* Also note that normalizeValue does not recursively examine child properties.
|
|
464
|
+
*
|
|
465
|
+
* (This an async wrapper around the internal `_normalizeValue` executor function.)
|
|
466
|
+
*
|
|
467
|
+
* @param {any} value - value to normalize
|
|
468
|
+
* @param {any} [target] - top level output target being built (avoid using for normalizers!)
|
|
469
|
+
* @param {SchemaLocation} [location] - path to this value in the output target
|
|
470
|
+
* @param {object} [options] - optional tweaks to normalizer behavior
|
|
471
|
+
* @returns {Promise<any>}
|
|
472
|
+
* @internal
|
|
473
|
+
*/
|
|
474
|
+
normalizeValue(value: any, target?: any, location?: SchemaLocation, options?: object): Promise<any>;
|
|
475
|
+
/**
|
|
476
|
+
* Transform a normalized input value for the final target based on this schema and provided context.
|
|
477
|
+
*
|
|
478
|
+
* Runs all transformer value processors in a pipeline until one returns undefined or throws an error.
|
|
479
|
+
* - The input to the pipeline is assumed to be normalized.
|
|
480
|
+
* - An error may be thrown if the input cannot be transformed.
|
|
481
|
+
* - If a transformer depends upon the overall target, it may return undefined to signal
|
|
482
|
+
* that the transform should be retried when the target is updated.
|
|
483
|
+
*
|
|
484
|
+
* A schema's transform is allowed to enforce validation internally, or it can delegate this to
|
|
485
|
+
* a finalizer or validator. In any case, the output from the transform is not guaranteed to be valid.
|
|
486
|
+
* (Note that conditions and unions are not checked if you call this directly.)
|
|
487
|
+
*
|
|
488
|
+
* Child properties are not traversed in this call, and are presumed to already have been transformed.
|
|
489
|
+
*
|
|
490
|
+
* (This is an executor function that may return synchronous or asynchronous results.)
|
|
491
|
+
*
|
|
492
|
+
* @param {any} value - input value to transform
|
|
493
|
+
* @param {any} [target] - global target in case the transformer depends on it
|
|
494
|
+
* @param {SchemaLocation} [location] - the traversal location of the schema
|
|
495
|
+
* @param {object} [options] - any tweaks to the transformer behavior
|
|
496
|
+
* @returns {any|Promise<any>} - transformed value
|
|
497
|
+
* @internal
|
|
498
|
+
*/
|
|
499
|
+
_transformValue(value: any, target?: any, location?: SchemaLocation, options?: object): any | Promise<any>;
|
|
500
|
+
/**
|
|
501
|
+
* Transform a normalized input value for the final target based on this schema and provided context.
|
|
502
|
+
*
|
|
503
|
+
* Runs all transformer value processors in a pipeline until one returns undefined or throws an error.
|
|
504
|
+
* - The input to the pipeline is assumed to be normalized.
|
|
505
|
+
* - An error may be thrown if the input cannot be transformed.
|
|
506
|
+
* - If a transformer depends upon the overall target, it may return undefined to signal
|
|
507
|
+
* that the transform should be retried when the target is updated.
|
|
508
|
+
*
|
|
509
|
+
* A schema's transform is allowed to enforce validation internally, or it can delegate this to
|
|
510
|
+
* a finalizer or validator. In any case, the output from the transform is not guaranteed to be valid.
|
|
511
|
+
* (Note that conditions and unions are not checked if you call this directly.)
|
|
512
|
+
*
|
|
513
|
+
* Child properties are not traversed in this call, and are presumed to already have been transformed.
|
|
514
|
+
*
|
|
515
|
+
* (This an async wrapper around the internal `_transformValue` executor function.)
|
|
516
|
+
*
|
|
517
|
+
* @param {any} value - input value to transform
|
|
518
|
+
* @param {any} [target] - global target in case the transformer depends on it
|
|
519
|
+
* @param {SchemaLocation} [location] - the traversal location of the schema
|
|
520
|
+
* @param {object} [options] - any tweaks to the transformer behavior
|
|
521
|
+
* @returns {Promise<any>} - transformed value
|
|
522
|
+
* @internal
|
|
523
|
+
*/
|
|
524
|
+
transformValue(value: any, target?: any, location?: SchemaLocation, options?: object): Promise<any>;
|
|
525
|
+
/**
|
|
526
|
+
* Finalize a transformed input value by running any necessary post-processing steps.
|
|
527
|
+
*
|
|
528
|
+
* Runs all finalizer value processors in a pipeline until one returns undefined or throws an error.
|
|
529
|
+
* - The input to the pipeline is be assumed to be transformed.
|
|
530
|
+
* - Finalizers are generally only required for incremental schemas that need to check child values.
|
|
531
|
+
* - A finalizer on the root schema (or that checks for the root path, if the root schema is shared)
|
|
532
|
+
* can act as an "entire output" finalizer.
|
|
533
|
+
*
|
|
534
|
+
* (This is an executor function that may return synchronous or asynchronous results.)
|
|
535
|
+
*
|
|
536
|
+
* @param {any} value - input value to finalize
|
|
537
|
+
* @param {any} [target] - global target in case the finalizer depends on it
|
|
538
|
+
* @param {SchemaLocation} [location] - the traversal location of the schema
|
|
539
|
+
* @param {object} [options] - any tweaks to the finalizer behavior
|
|
540
|
+
* @returns {any|Promise<any>} - finalized value
|
|
541
|
+
* @internal
|
|
542
|
+
*/
|
|
543
|
+
_finalizeValue(value: any, target?: any, location?: SchemaLocation, options?: object): any | Promise<any>;
|
|
544
|
+
/**
|
|
545
|
+
* Finalize a transformed input value by running any necessary post-processing steps.
|
|
546
|
+
*
|
|
547
|
+
* Runs all finalizer value processors in a pipeline until one returns undefined or throws an error.
|
|
548
|
+
* - The input to the pipeline is be assumed to be transformed.
|
|
549
|
+
* - Finalizers are generally only required for incremental schemas that need to check child values.
|
|
550
|
+
* - A finalizer on the root schema (or that checks for the root path, if the root schema is shared)
|
|
551
|
+
* can act as an "entire output" finalizer.
|
|
552
|
+
*
|
|
553
|
+
* (This an async wrapper around the internal `_finalizeValue` executor function.)
|
|
554
|
+
*
|
|
555
|
+
* @param {any} value - input value to transform
|
|
556
|
+
* @param {any} [target] - global target in case the transformer depends on it
|
|
557
|
+
* @param {SchemaLocation} [location] - the traversal location of the schema
|
|
558
|
+
* @param {object} [options] - any tweaks to the transformer behavior
|
|
559
|
+
* @returns {Promise<any>} - transformed value
|
|
560
|
+
* @internal
|
|
561
|
+
*/
|
|
562
|
+
finalizeValue(value: any, target?: any, location?: SchemaLocation, options?: object): Promise<any>;
|
|
563
|
+
/**
|
|
564
|
+
* Validate the provided input value.
|
|
565
|
+
*
|
|
566
|
+
* Runs all validator value processors in a pipeline until one throws an error.
|
|
567
|
+
* Validators can return a different value from the input (presumably "more valid",
|
|
568
|
+
* e.g. strings trimmed, case made consistent, etc.) but must throw if the input is invalid.
|
|
569
|
+
*
|
|
570
|
+
* Children are not traversed in this call.
|
|
571
|
+
*
|
|
572
|
+
* (This is an executor function that may return synchronous or asynchronous results.)
|
|
573
|
+
*
|
|
574
|
+
* @param {any} value - value to validate
|
|
575
|
+
* @param {any} [target] - complete output target
|
|
576
|
+
* @param {SchemaLocation} [location] - traversal location of this schema
|
|
577
|
+
* @param {object} [options] - options to tweak validation behavior
|
|
578
|
+
* @returns {any|Promise<any>}
|
|
579
|
+
* @internal
|
|
580
|
+
*/
|
|
581
|
+
_validateValue(value: any, target?: any, location?: SchemaLocation, options?: object): any | Promise<any>;
|
|
582
|
+
/**
|
|
583
|
+
* Validate the provided input value.
|
|
584
|
+
*
|
|
585
|
+
* Runs all validator value processors in a pipeline until one throws an error.
|
|
586
|
+
* Validators can return a different value from the input (presumably "more valid",
|
|
587
|
+
* e.g. strings trimmed, case made consistent, etc.) but must throw if the input is invalid.
|
|
588
|
+
*
|
|
589
|
+
* Children are not traversed in this call.
|
|
590
|
+
*
|
|
591
|
+
* @param {any} value - value to validate
|
|
592
|
+
* @param {any} [target] - complete output target
|
|
593
|
+
* @param {SchemaLocation} [location] - traversal location of this schema
|
|
594
|
+
* @param {object} [options] - options to tweak validation behavior
|
|
595
|
+
* @returns {Promise<any>}
|
|
596
|
+
* @internal
|
|
597
|
+
*/
|
|
598
|
+
validateValue(value: any, target?: any, location?: SchemaLocation, options?: object): Promise<any>;
|
|
599
|
+
/**
|
|
600
|
+
* Serialize the provided input value.
|
|
601
|
+
*
|
|
602
|
+
* (This is an executor function that may return synchronous or asynchronous results.)
|
|
603
|
+
*
|
|
604
|
+
* @param {any} value - value to serialize
|
|
605
|
+
* @param {any} [target] - entire output being serialized
|
|
606
|
+
* @param {SchemaLocation} [location] - traversal location to current schema
|
|
607
|
+
* @param {object} [options] - options to tweak serialization behavior
|
|
608
|
+
* @returns {any|Promise<any>}
|
|
609
|
+
* @internal
|
|
610
|
+
*/
|
|
611
|
+
_serializeValue(value: any, target?: any, location?: SchemaLocation, options?: object): any | Promise<any>;
|
|
612
|
+
/**
|
|
613
|
+
* Serialize the provided input value.
|
|
614
|
+
*
|
|
615
|
+
* @param {any} value - value to serialize
|
|
616
|
+
* @param {any} [target] - entire output being serialized
|
|
617
|
+
* @param {SchemaLocation} [location] - traversal location to current schema
|
|
618
|
+
* @param {object} [options] - options to tweak serialization behavior
|
|
619
|
+
* @returns {Promise<any>}
|
|
620
|
+
* @internal
|
|
621
|
+
*/
|
|
622
|
+
serializeValue(value: any, target?: any, location?: SchemaLocation, options?: object): Promise<any>;
|
|
623
|
+
/**
|
|
624
|
+
* Throw an exception if this schema seems able to handle a given input value.
|
|
625
|
+
*
|
|
626
|
+
* @param {any} value
|
|
627
|
+
*/
|
|
628
|
+
ensureAccepts(value: any): void;
|
|
629
|
+
/**
|
|
630
|
+
* @param {any} value
|
|
631
|
+
* @returns {boolean}
|
|
632
|
+
*/
|
|
633
|
+
checkAccepts(value: any): boolean;
|
|
634
|
+
/**
|
|
635
|
+
* Return a validated output if and only if the input fully matches the schema definition.
|
|
636
|
+
*
|
|
637
|
+
* Note: depending on the processors used for validation, the input value may be mutated during validation!
|
|
638
|
+
* (todo - create an option that prevents this from happening?)
|
|
639
|
+
*
|
|
640
|
+
* @param {any} value - input value to validate
|
|
641
|
+
* @param {ValidateOptions} [options] - any tweaks to the validator behavior
|
|
642
|
+
* @returns {any|Promise<any>} - validated value
|
|
643
|
+
* @internal
|
|
644
|
+
*/
|
|
645
|
+
_validate(value: any, options?: ValidateOptions): any | Promise<any>;
|
|
646
|
+
/**
|
|
647
|
+
* Return a validated output if and only if the input fully matches the schema definition.
|
|
648
|
+
*
|
|
649
|
+
* Note: depending on the processors used for validation, the input value may be mutated during validation!
|
|
650
|
+
* (todo - create an option that prevents this from happening?)
|
|
651
|
+
*
|
|
652
|
+
* @param {any} value - input value to validate
|
|
653
|
+
* @param {ValidateOptions} [options] - any tweaks to the validator behavior
|
|
654
|
+
* @returns {Promise<any>} - validated value
|
|
655
|
+
*/
|
|
656
|
+
validate(value: any, options?: ValidateOptions): Promise<any>;
|
|
657
|
+
/**
|
|
658
|
+
* Process an input value to an output value based on this schema.
|
|
659
|
+
*
|
|
660
|
+
* Errors are thrown if:
|
|
661
|
+
* - the input value doesn't match the schema
|
|
662
|
+
* - a value processor throws an error
|
|
663
|
+
* - a value cannot be processed (value processors return undefined) after repeated attempts
|
|
664
|
+
* - a union cannot be resolved
|
|
665
|
+
*
|
|
666
|
+
* If an output target is provided, it is assumed to already be valid.
|
|
667
|
+
* A few traversal options are supported; pass in a TraversalContext instance for full customization.
|
|
668
|
+
*
|
|
669
|
+
* (This is an executor function that may return synchronous or asynchronous results.)
|
|
670
|
+
*
|
|
671
|
+
* @param {any} input - the value to process
|
|
672
|
+
* @param {any} [target] - preexisting output value to build upon, if any
|
|
673
|
+
* @param {ProcessOptions} [options] - options to customize the traversal
|
|
674
|
+
* @returns {any|Promise<any>} - returns the output value
|
|
675
|
+
* @internal
|
|
676
|
+
*/
|
|
677
|
+
_process(input: any, target?: any, options?: ProcessOptions): any | Promise<any>;
|
|
678
|
+
/**
|
|
679
|
+
* Process an input value to an output value based on this schema.
|
|
680
|
+
*
|
|
681
|
+
* Errors are thrown if:
|
|
682
|
+
* - the input value doesn't match the schema
|
|
683
|
+
* - a value processor throws an error
|
|
684
|
+
* - a value cannot be processed (value processors return undefined) after repeated attempts
|
|
685
|
+
* - a union cannot be resolved
|
|
686
|
+
*
|
|
687
|
+
* If an output target is provided, it is assumed to already be valid.
|
|
688
|
+
* A few traversal options are supported; pass in a TraversalContext instance for full customization.
|
|
689
|
+
*
|
|
690
|
+
* (This is an async wrapper around the internal `_process` executor function.)
|
|
691
|
+
*
|
|
692
|
+
* Note: this method makes `CompiledSchema` look somewhat like a `FunctionValueProcessor`, but it has a
|
|
693
|
+
* slightly different signature.
|
|
694
|
+
*
|
|
695
|
+
* @param {any} input - the value to process
|
|
696
|
+
* @param {any} [target] - preexisting output value to build upon, if any
|
|
697
|
+
* @param {ProcessOptions} [options] - options to customize the traversal
|
|
698
|
+
* @returns {Promise<any>} - returns the output value
|
|
699
|
+
*/
|
|
700
|
+
process(input: any, target?: any, options?: ProcessOptions): Promise<any>;
|
|
701
|
+
/**
|
|
702
|
+
* Process input path/value assignments into an output value based on the schema.
|
|
703
|
+
*
|
|
704
|
+
* Paths are dotted references into the schema hierarchy. Assignment values are normalized, transformed,
|
|
705
|
+
* validated, and then used to build the output value.
|
|
706
|
+
*
|
|
707
|
+
* If a value for the output target is provided, it is assumed to already be valid.
|
|
708
|
+
*
|
|
709
|
+
* Errors are thrown if:
|
|
710
|
+
* - unexpected paths are provided that don't match the schema
|
|
711
|
+
* - a value is incompatible with the schema referenced by the path
|
|
712
|
+
* - a value processor throws an error
|
|
713
|
+
* - a value cannot be processed (value processors return undefined) after repeated attempts
|
|
714
|
+
* - a union cannot be resolved
|
|
715
|
+
*
|
|
716
|
+
* (This an async convenience wrapper around the internal `_process` executor function.)
|
|
717
|
+
*
|
|
718
|
+
* @param {Map<string,any>} assignments - path/value associations
|
|
719
|
+
* @param {any} [target] - preexisting output value to build upon, if any
|
|
720
|
+
* @param {ProcessAssignmentsOptions} [options] - options to customize the traversal
|
|
721
|
+
* @returns {Promise<any>} - returns the output value
|
|
722
|
+
*/
|
|
723
|
+
processAssignments(assignments: Map<string, any>, target?: any, options?: ProcessAssignmentsOptions): Promise<any>;
|
|
724
|
+
/**
|
|
725
|
+
* Serialize the config data as if you were going to use the result for a config file.
|
|
726
|
+
*
|
|
727
|
+
* Runs all serialization processors in a pipeline. By default, if any processor returns undefined or throws an error,
|
|
728
|
+
* serialization of that value returns undefined and will be omitted from the output. If you set the "strict"
|
|
729
|
+
* option, errors are re-thrown.
|
|
730
|
+
*
|
|
731
|
+
* Serializers attempt to convert resolved values back to an input-friendly value, first via the "serialize"
|
|
732
|
+
* schema option, or alternatively by trusting that each value is either already compatible, or implements toJSON().
|
|
733
|
+
*
|
|
734
|
+
* @param {any} value
|
|
735
|
+
* @param {SerializeOptions} [options]
|
|
736
|
+
* @returns {Promise<NonNullable<any>>}
|
|
737
|
+
*/
|
|
738
|
+
serialize(value: any, options?: SerializeOptions): Promise<NonNullable<any>>;
|
|
739
|
+
/**
|
|
740
|
+
* Given a reference to a union schema member, return the matching key, or undefined if it cannot be found.
|
|
741
|
+
*
|
|
742
|
+
* @param {CompiledSchema} unionSchema
|
|
743
|
+
* @returns {string|undefined}
|
|
744
|
+
*/
|
|
745
|
+
findUnionKey(unionSchema: CompiledSchema): string | undefined;
|
|
746
|
+
/**
|
|
747
|
+
* Given a union key or schema, retrieve the matching union schema, or undefined if it cannot be found or is invalid
|
|
748
|
+
*
|
|
749
|
+
* @param {string|CompiledSchema} lookup
|
|
750
|
+
* @returns {CompiledSchema|undefined}
|
|
751
|
+
*/
|
|
752
|
+
getUnionSchema(lookup: string | CompiledSchema): CompiledSchema | undefined;
|
|
753
|
+
/**
|
|
754
|
+
* @param {string} key
|
|
755
|
+
* @param {CompiledSchema} unionSchema
|
|
756
|
+
* @returns {CompiledSchema}
|
|
757
|
+
* @internal
|
|
758
|
+
*/
|
|
759
|
+
_setUnionSchema(key: string, unionSchema: CompiledSchema): CompiledSchema;
|
|
760
|
+
/**
|
|
761
|
+
* Find the schema at a given path, falling back to the wildcard schema if one exists.
|
|
762
|
+
*
|
|
763
|
+
* The root schema may be found at '', the empty string. Array members are referenced with dotted integer indexes.
|
|
764
|
+
* Note that find() does not check union members; use SchemaLocation for finding schemas resolved during traversal.
|
|
765
|
+
*
|
|
766
|
+
* @param {string} path
|
|
767
|
+
* @returns {undefined|CompiledSchema}
|
|
768
|
+
*/
|
|
769
|
+
find(path: string): undefined | CompiledSchema;
|
|
770
|
+
/**
|
|
771
|
+
* toAssignments - attempt to convert input data to a map of assignments.
|
|
772
|
+
*
|
|
773
|
+
* @param {any} object - input
|
|
774
|
+
* @param {string} prefix - prefix to add to any path generated
|
|
775
|
+
* @returns {Map<string, any>} - output map of path-to-value associations
|
|
776
|
+
*/
|
|
777
|
+
toAssignments(object: any, prefix?: string): Map<string, any>;
|
|
778
|
+
/**
|
|
779
|
+
* Invoke a provided visitor function on every schema node; if visitor returns false (explicitly), abort early.
|
|
780
|
+
*
|
|
781
|
+
* @param {(schema:CompiledSchema, path:string) => any} visitor - visitor function
|
|
782
|
+
* @param {{onlySerializable?:boolean}} [options]
|
|
783
|
+
* @returns {boolean} - returns true if visitors all returned true, false if any exited early
|
|
784
|
+
*/
|
|
785
|
+
visitSchema(visitor: (schema: CompiledSchema, path: string) => any, options?: {
|
|
786
|
+
onlySerializable?: boolean;
|
|
787
|
+
}): boolean;
|
|
788
|
+
/**
|
|
789
|
+
* Compute all possible schema paths (including union schema properties)
|
|
790
|
+
*
|
|
791
|
+
* @returns {Set<string>}
|
|
792
|
+
*/
|
|
793
|
+
getPropertyPaths(): Set<string>;
|
|
794
|
+
/**
|
|
795
|
+
* Return a named property schema (possibly via wildcard)
|
|
796
|
+
*
|
|
797
|
+
* @param {string} propertyName
|
|
798
|
+
* @returns {CompiledSchema|undefined}
|
|
799
|
+
*/
|
|
800
|
+
getPropertySchema(propertyName: string): CompiledSchema | undefined;
|
|
801
|
+
/**
|
|
802
|
+
* Associate a schema with a property name. Only for use during compilation.
|
|
803
|
+
*
|
|
804
|
+
* @param {string} propertyName
|
|
805
|
+
* @param {CompiledSchema} propertySchema
|
|
806
|
+
* @returns {CompiledSchema}
|
|
807
|
+
*
|
|
808
|
+
* @internal
|
|
809
|
+
*/
|
|
810
|
+
_setPropertySchema(propertyName: string, propertySchema: CompiledSchema): CompiledSchema;
|
|
811
|
+
/**
|
|
812
|
+
* Return all child schemas that have a particular option tag
|
|
813
|
+
*
|
|
814
|
+
* @param {string} tag
|
|
815
|
+
* @returns {CompiledSchema[]}
|
|
816
|
+
* @deprecated
|
|
817
|
+
*/
|
|
818
|
+
getTagged(tag: string): CompiledSchema[];
|
|
819
|
+
/**
|
|
820
|
+
* Get the first child schema that has a particular option tag
|
|
821
|
+
*
|
|
822
|
+
* @param {string} tag
|
|
823
|
+
* @returns {CompiledSchema|undefined}
|
|
824
|
+
* @deprecated
|
|
825
|
+
*/
|
|
826
|
+
getFirstTagged(tag: string): CompiledSchema | undefined;
|
|
827
|
+
/**
|
|
828
|
+
* Return true if the path is legal within the schema (including all union schemas)
|
|
829
|
+
*
|
|
830
|
+
* @param {string} path
|
|
831
|
+
* @returns {boolean}
|
|
832
|
+
*/
|
|
833
|
+
isValidPath(path: string): boolean;
|
|
834
|
+
/**
|
|
835
|
+
* Write-protect this schema at the end of compilation.
|
|
836
|
+
* @param {Set<CompiledSchema>} [seen]
|
|
837
|
+
* @internal
|
|
838
|
+
*/
|
|
839
|
+
_freeze(seen?: Set<CompiledSchema>): void;
|
|
840
|
+
#private;
|
|
841
|
+
}
|
|
842
|
+
export type CompiledSchemaMetadata = ISchemaMetadata;
|
|
843
|
+
export type CompiledSchemaOptions = ISchemaOptions;
|
|
844
|
+
export type CompiledSchemaHandlers = {
|
|
845
|
+
normalizers?: ValueProcessor[] | undefined;
|
|
846
|
+
conditions?: ValueProcessor[] | undefined;
|
|
847
|
+
transformers?: ValueProcessor[] | undefined;
|
|
848
|
+
finalizers?: ValueProcessor[] | undefined;
|
|
849
|
+
validators?: ValueProcessor[] | undefined;
|
|
850
|
+
serializers?: ValueProcessor[] | undefined;
|
|
851
|
+
discriminators?: ValueProcessor[] | undefined;
|
|
852
|
+
};
|
|
853
|
+
export type CompiledSchemaProperties = {
|
|
854
|
+
[key: string]: CompiledSchema;
|
|
855
|
+
};
|
|
856
|
+
export type CompiledSchemaUnionSchemas = {
|
|
857
|
+
[key: string]: CompiledSchema;
|
|
858
|
+
};
|
|
859
|
+
export type SharedOptions = {
|
|
860
|
+
location?: SchemaLocation | undefined;
|
|
861
|
+
context?: TraversalContext | TraversalContextOptions | undefined;
|
|
862
|
+
};
|
|
863
|
+
export type ValidateOptions = SharedOptions & {
|
|
864
|
+
[key: string]: any;
|
|
865
|
+
};
|
|
866
|
+
export type SerializeOptions = SharedOptions & {
|
|
867
|
+
[key: string]: any;
|
|
868
|
+
};
|
|
869
|
+
export type ProcessOptions = SharedOptions & {
|
|
870
|
+
assignments?: Map<string, any>;
|
|
871
|
+
} & {
|
|
872
|
+
[key: string]: any;
|
|
873
|
+
};
|
|
874
|
+
export type ProcessAssignmentsOptions = SharedOptions & {
|
|
875
|
+
[key: string]: any;
|
|
876
|
+
};
|
|
877
|
+
import { ValueProcessor } from './value-processor/value-processor.js';
|
|
878
|
+
import type { SchemaData } from './types.js';
|
|
879
|
+
import { SchemaLocation } from './schema-location.js';
|
|
880
|
+
import type { ISchemaMetadata } from './types.js';
|
|
881
|
+
import type { ISchemaOptions } from './types.js';
|
|
882
|
+
import { TraversalContext } from './traversal/traversal-context.js';
|
|
883
|
+
import type { TraversalContextOptions } from './traversal/traversal-context.js';
|