@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,586 @@
|
|
|
1
|
+
/** @import { ValueProcessor, ValueProcessorFunction, ValueProcessorSpec } from './value-processor/value-processor.js' */
|
|
2
|
+
/** @import { ISchemaMetadata, ISchemaOptions, SchemaData, ISchema, } from './types.js' */
|
|
3
|
+
/** @typedef {ISchemaOptions} SchemaOptions */
|
|
4
|
+
/** @typedef {ISchemaMetadata} SchemaMetadata */
|
|
5
|
+
/** @typedef {{[key:string]: ISchema}} SchemaProperties */
|
|
6
|
+
/** @typedef {{[key:string]: ISchema}} SchemaUnionSchemas */
|
|
7
|
+
/**
|
|
8
|
+
* @typedef {object} SchemaHandlers
|
|
9
|
+
* @property {Array<ValueProcessorSpec>} [normalizers]
|
|
10
|
+
* @property {Array<ValueProcessorSpec>} [transformers]
|
|
11
|
+
* @property {Array<ValueProcessorSpec>} [finalizers]
|
|
12
|
+
* @property {Array<ValueProcessorSpec>} [validators]
|
|
13
|
+
* @property {Array<ValueProcessorSpec>} [serializers]
|
|
14
|
+
* @property {Array<ValueProcessorSpec>} [conditions]
|
|
15
|
+
* @property {Array<ValueProcessorSpec>} [discriminators]
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Schema - allows the definition of structure and rules for data
|
|
19
|
+
*
|
|
20
|
+
* Essentially acts as a fluent builder; must be compiled by SchemaCompiler for use.
|
|
21
|
+
*
|
|
22
|
+
* @typedef {import("./types.js").ISchema} ISchema
|
|
23
|
+
* @augments {ISchema}
|
|
24
|
+
*/
|
|
25
|
+
export class Schema {
|
|
26
|
+
/**
|
|
27
|
+
* Create a new Schema from something schema-shaped
|
|
28
|
+
*
|
|
29
|
+
* @param {ISchema|SchemaData|string} model
|
|
30
|
+
* @param {Map<any,any>} [seen]
|
|
31
|
+
* @returns {Schema}
|
|
32
|
+
*/
|
|
33
|
+
static createFromModel(model: ISchema | SchemaData | string, seen?: Map<any, any>): Schema;
|
|
34
|
+
/**
|
|
35
|
+
* Static schema factory (useful for aliasing to reduce typing!)
|
|
36
|
+
*
|
|
37
|
+
* Prefer using fluent setters over passing options/metadata to this call
|
|
38
|
+
*
|
|
39
|
+
* @param {string|ISchema|SchemaData|Schema|CompiledSchema} [base] - schema
|
|
40
|
+
* @param {object} [options] - schema options
|
|
41
|
+
* @param {ISchemaMetadata} [metadata] - schema metadata
|
|
42
|
+
* @returns {Schema}
|
|
43
|
+
*/
|
|
44
|
+
static create(base?: string | ISchema | SchemaData | Schema | CompiledSchema, options?: object, metadata?: ISchemaMetadata): Schema;
|
|
45
|
+
/**
|
|
46
|
+
* Static schema factory for special schemas that ignore assignments and produce a single defined value
|
|
47
|
+
*
|
|
48
|
+
* Prefer using fluent setters over passing options/metadata to this call
|
|
49
|
+
*
|
|
50
|
+
* @param {any} literalValue - the value this schema will always emit
|
|
51
|
+
* @param {object} [options] - additional options
|
|
52
|
+
* @param {ISchemaMetadata} [metadata] - additional metadata
|
|
53
|
+
* @returns {Schema}
|
|
54
|
+
*/
|
|
55
|
+
static literal(literalValue: any, options?: object, metadata?: ISchemaMetadata): Schema;
|
|
56
|
+
/**
|
|
57
|
+
* Static schema factory for creating a schema that inherits its value from the first parent with the property name.
|
|
58
|
+
* If no property name is provided, the inherit schema's property name is used, so it will look for the same name
|
|
59
|
+
* higher in the schema hierarchy.
|
|
60
|
+
*
|
|
61
|
+
* TODO - restore compilation hook for checking whether this is a legal setup
|
|
62
|
+
*
|
|
63
|
+
* @returns {Schema}
|
|
64
|
+
* @param {string} [propertyName]
|
|
65
|
+
* @internal
|
|
66
|
+
*/
|
|
67
|
+
static inherit(propertyName?: string): Schema;
|
|
68
|
+
/**
|
|
69
|
+
* Static schema factory for creating a schema that gets its value from another location based on a path.
|
|
70
|
+
*
|
|
71
|
+
* By default, `path` is interpreted as an absolute path from the root. If the `relative` flag is
|
|
72
|
+
* set or navigation metacharacters start the path, it will be relative to the current schema.
|
|
73
|
+
* - An absolute path prefixed with `/` starts at the root.
|
|
74
|
+
* - A path prefixed with `^` navigates up one level from the current schema path.
|
|
75
|
+
*
|
|
76
|
+
* TODO - restore hook for checking whether the provided path is known at compilation time
|
|
77
|
+
*
|
|
78
|
+
* @param {string} path
|
|
79
|
+
* @param {boolean} [relative]
|
|
80
|
+
* @returns {Schema}
|
|
81
|
+
* @internal
|
|
82
|
+
*/
|
|
83
|
+
static reference(path: string, relative?: boolean): Schema;
|
|
84
|
+
/**
|
|
85
|
+
* Construct a Schema.
|
|
86
|
+
*
|
|
87
|
+
* Pass a string name of a registered schema to resolve as the base, or pass a schema-shaped object to extend.
|
|
88
|
+
*
|
|
89
|
+
* Prefer the fluent setters over passing in options/metadata or attributes.
|
|
90
|
+
*
|
|
91
|
+
* @param {string|ISchema|SchemaData} [base] - schema type or base to extend
|
|
92
|
+
* @param {object} [options] - schema options (also supports "attribute" shorthand syntax, but prefer being explicit)
|
|
93
|
+
* @param {ISchemaMetadata} [metadata] - schema metadata
|
|
94
|
+
*/
|
|
95
|
+
constructor(base?: string | ISchema | SchemaData, options?: object, metadata?: ISchemaMetadata);
|
|
96
|
+
set base(base: string | undefined);
|
|
97
|
+
/**
|
|
98
|
+
* Name of a schema registered in SchemaResolver that this schema extends
|
|
99
|
+
*
|
|
100
|
+
* @type {string|undefined}
|
|
101
|
+
*/
|
|
102
|
+
get base(): string | undefined;
|
|
103
|
+
/**
|
|
104
|
+
* Properties are named child schemas.
|
|
105
|
+
*
|
|
106
|
+
* Use the property setter rather than direct access to ensure data consistency.
|
|
107
|
+
*
|
|
108
|
+
* @type {SchemaProperties}
|
|
109
|
+
*/
|
|
110
|
+
get properties(): SchemaProperties;
|
|
111
|
+
/**
|
|
112
|
+
* Handlers are grouped lists of value processors.
|
|
113
|
+
*
|
|
114
|
+
* Assign using the individual value processor setters.
|
|
115
|
+
*
|
|
116
|
+
* @type {SchemaHandlers}
|
|
117
|
+
*/
|
|
118
|
+
get handlers(): SchemaHandlers;
|
|
119
|
+
/**
|
|
120
|
+
* Options are settings that define how the schema behaves.
|
|
121
|
+
*
|
|
122
|
+
* @returns {SchemaOptions}
|
|
123
|
+
*/
|
|
124
|
+
get options(): SchemaOptions;
|
|
125
|
+
/**
|
|
126
|
+
* Metadata defines settings that describe how the schema should interact with users.
|
|
127
|
+
*
|
|
128
|
+
* @type {SchemaMetadata}
|
|
129
|
+
*/
|
|
130
|
+
get metadata(): SchemaMetadata;
|
|
131
|
+
/**
|
|
132
|
+
* Unions are sets of alternative schemas; a discriminator selects which to use.
|
|
133
|
+
*
|
|
134
|
+
* @type {SchemaUnionSchemas}
|
|
135
|
+
*/
|
|
136
|
+
get unionSchemas(): SchemaUnionSchemas;
|
|
137
|
+
/**
|
|
138
|
+
* Extract the contents of this schema and its children as a regular object.
|
|
139
|
+
*
|
|
140
|
+
* @returns {SchemaData}
|
|
141
|
+
*/
|
|
142
|
+
toData(): SchemaData;
|
|
143
|
+
/**
|
|
144
|
+
* Attributes were initially a convenient shorthand for constructing schemas, but now just add confusion.
|
|
145
|
+
*
|
|
146
|
+
* @deprecated
|
|
147
|
+
* @param {string} attributeName
|
|
148
|
+
* @param {any} attributeValue
|
|
149
|
+
* @returns {Schema}
|
|
150
|
+
* @internal
|
|
151
|
+
*/
|
|
152
|
+
_setAttribute(attributeName: string, attributeValue: any): Schema;
|
|
153
|
+
/**
|
|
154
|
+
* Attributes were initially a convenient shorthand for constructing schemas, but now just add confusion.
|
|
155
|
+
*
|
|
156
|
+
* @deprecated
|
|
157
|
+
* @param {object} attributes
|
|
158
|
+
* @returns {Schema}
|
|
159
|
+
* @internal
|
|
160
|
+
*/
|
|
161
|
+
_setAttributes(attributes?: object): Schema;
|
|
162
|
+
/**
|
|
163
|
+
* Attach a named child schema
|
|
164
|
+
*
|
|
165
|
+
* @param {string} propertyName - property name
|
|
166
|
+
* @param {Schema|CompiledSchema|string|undefined} propertySchema - schema to associate with the property, undefined to delete current
|
|
167
|
+
* @returns {Schema} - returns self for fluent chaining
|
|
168
|
+
*/
|
|
169
|
+
property(propertyName: string, propertySchema: Schema | CompiledSchema | string | undefined): Schema;
|
|
170
|
+
/**
|
|
171
|
+
* Bulk-add properties
|
|
172
|
+
*
|
|
173
|
+
* @param {SchemaProperties} properties - property name
|
|
174
|
+
* @param {symbol} [policy] - specify whether to overwrite or only initialize
|
|
175
|
+
* @returns {Schema} - returns self for fluent chaining
|
|
176
|
+
* @internal
|
|
177
|
+
*/
|
|
178
|
+
addProperties(properties: SchemaProperties, policy?: symbol): Schema;
|
|
179
|
+
/**
|
|
180
|
+
* Define a schema option
|
|
181
|
+
*
|
|
182
|
+
* Options are settings that define how the schema behaves.
|
|
183
|
+
*
|
|
184
|
+
* @param {string} option - option
|
|
185
|
+
* @param {any} [value] - option value
|
|
186
|
+
* @returns {Schema} - returns self for fluent chaining
|
|
187
|
+
*/
|
|
188
|
+
option(option: string, value?: any): Schema;
|
|
189
|
+
/**
|
|
190
|
+
* Bulk add options
|
|
191
|
+
*
|
|
192
|
+
* @param {object} options
|
|
193
|
+
* @param {symbol} [policy]
|
|
194
|
+
* @returns {Schema}
|
|
195
|
+
* @internal
|
|
196
|
+
*/
|
|
197
|
+
addOptions(options: object, policy?: symbol): Schema;
|
|
198
|
+
/**
|
|
199
|
+
* Helper function for the fluent handler api calls
|
|
200
|
+
*
|
|
201
|
+
* @param {string} handlerName
|
|
202
|
+
* @param {Array<ValueProcessorSpec>} specs
|
|
203
|
+
* @param {symbol} [policy]
|
|
204
|
+
* @returns {Schema}
|
|
205
|
+
* @private
|
|
206
|
+
*/
|
|
207
|
+
private handler;
|
|
208
|
+
/**
|
|
209
|
+
* Bulk add handlers
|
|
210
|
+
*
|
|
211
|
+
* @param {object} handlers
|
|
212
|
+
* @param {symbol} [policy]
|
|
213
|
+
* @returns {Schema}
|
|
214
|
+
* @internal
|
|
215
|
+
*/
|
|
216
|
+
addHandlers(handlers: object, policy?: symbol): Schema;
|
|
217
|
+
/**
|
|
218
|
+
* Define schema metadata (like options, but for humans and ConfigurationSource hints) - todo: locale-aware
|
|
219
|
+
*
|
|
220
|
+
* (Note: named "meta" instead of "metadata" to differentiate from the object getter)
|
|
221
|
+
*
|
|
222
|
+
* @param {string} meta - metadata key
|
|
223
|
+
* @param {any} [value] - option value
|
|
224
|
+
* @returns {Schema} - returns self for fluent chaining
|
|
225
|
+
*/
|
|
226
|
+
meta(meta: string, value?: any): Schema;
|
|
227
|
+
/**
|
|
228
|
+
* Bulk-add metadata
|
|
229
|
+
*
|
|
230
|
+
* @param {object} metadata
|
|
231
|
+
* @param {symbol} [policy]
|
|
232
|
+
* @returns {Schema}
|
|
233
|
+
* @internal
|
|
234
|
+
*/
|
|
235
|
+
addMetadata(metadata: object, policy?: symbol): Schema;
|
|
236
|
+
/**
|
|
237
|
+
* The discriminator handler returns the key or schema of the union member that should be used
|
|
238
|
+
* This function appends a single value processor to the handler pipeline.
|
|
239
|
+
*
|
|
240
|
+
* @param {ValueProcessorSpec} spec
|
|
241
|
+
* @returns {Schema} - returns self for fluent chaining
|
|
242
|
+
*/
|
|
243
|
+
unionDiscriminator(spec: ValueProcessorSpec): Schema;
|
|
244
|
+
/**
|
|
245
|
+
* The discriminator handler returns the key or schema of the union member that should be used
|
|
246
|
+
* This function applies multiple value processors to the handler pipeline.
|
|
247
|
+
* (Note that it would be highly unusual to want more than one!)
|
|
248
|
+
*
|
|
249
|
+
* @param {Array<ValueProcessorSpec>} specs
|
|
250
|
+
* @param {symbol} [policy]
|
|
251
|
+
* @returns {Schema} - returns self for fluent chaining
|
|
252
|
+
*/
|
|
253
|
+
unionDiscriminators(specs: Array<ValueProcessorSpec>, policy?: symbol): Schema;
|
|
254
|
+
/**
|
|
255
|
+
* Add a schema as an alternative member of this schema's union.
|
|
256
|
+
*
|
|
257
|
+
* @param {string} key - union schema key (used by some discriminators to select this schema)
|
|
258
|
+
* @param {Schema|CompiledSchema} unionSchema - schema that the discriminator selects, or true/false override if a group
|
|
259
|
+
* @returns {Schema}
|
|
260
|
+
*/
|
|
261
|
+
unionSchema(key: string, unionSchema: Schema | CompiledSchema): Schema;
|
|
262
|
+
/**
|
|
263
|
+
* Bulk-add union schemas
|
|
264
|
+
*
|
|
265
|
+
* @param {SchemaUnionSchemas} unionSchemas
|
|
266
|
+
* @param {symbol} [policy]
|
|
267
|
+
* @returns {Schema}
|
|
268
|
+
* @internal
|
|
269
|
+
*/
|
|
270
|
+
addUnionSchemas(unionSchemas: SchemaUnionSchemas, policy?: symbol): Schema;
|
|
271
|
+
/**
|
|
272
|
+
* Mark this schema as containing (and only permitting) storage of union keys.
|
|
273
|
+
*
|
|
274
|
+
* @param {boolean} [value]
|
|
275
|
+
* @returns {Schema}
|
|
276
|
+
*/
|
|
277
|
+
unionKey(value?: boolean): Schema;
|
|
278
|
+
/**
|
|
279
|
+
* Mark this schema as a selector.
|
|
280
|
+
*
|
|
281
|
+
* Selectors are a convenience wrapper for controlling selection conditions that only are true when
|
|
282
|
+
* the selector contains the correct selection value.
|
|
283
|
+
*
|
|
284
|
+
* @param {boolean} [value]
|
|
285
|
+
* @returns {Schema}
|
|
286
|
+
*/
|
|
287
|
+
selector(value?: boolean): Schema;
|
|
288
|
+
/**
|
|
289
|
+
* Mark this schema as a selection.
|
|
290
|
+
*
|
|
291
|
+
* A selection schema automatically creates a condition that only activates the schema if the corresponding
|
|
292
|
+
* selector has the correct value.
|
|
293
|
+
*
|
|
294
|
+
* With the default argument, the selection schema condition uses the property name as the selector value.
|
|
295
|
+
*
|
|
296
|
+
* @param {NonNullable<any>} [value]
|
|
297
|
+
* @returns {Schema}
|
|
298
|
+
*/
|
|
299
|
+
selection(value?: NonNullable<any>): Schema;
|
|
300
|
+
/**
|
|
301
|
+
* Mark this schema as defining a required value (or not)
|
|
302
|
+
*
|
|
303
|
+
* Schema requirements are enforced during validation.
|
|
304
|
+
*
|
|
305
|
+
* Requirements are shallow; this can be changed via the deep() option.
|
|
306
|
+
*
|
|
307
|
+
* @param {boolean} [value]
|
|
308
|
+
* @returns {Schema}
|
|
309
|
+
*/
|
|
310
|
+
required(value?: boolean): Schema;
|
|
311
|
+
/**
|
|
312
|
+
* Mark this schema as defining an optional value (or not); the default is optional.
|
|
313
|
+
*
|
|
314
|
+
* (Syntactic sugar to negate required())
|
|
315
|
+
* Schema requirements are enforced during validation.
|
|
316
|
+
*
|
|
317
|
+
* Requirements are shallow; this can be changed via the deep() option.
|
|
318
|
+
*
|
|
319
|
+
* @param {boolean} [value]
|
|
320
|
+
* @returns {Schema}
|
|
321
|
+
*/
|
|
322
|
+
optional(value?: boolean): Schema;
|
|
323
|
+
/**
|
|
324
|
+
* Define a default value for this schema to use if there is no input.
|
|
325
|
+
*
|
|
326
|
+
* Defaults are shallow and will not cause children of undefined inputs to populate;
|
|
327
|
+
* this can be changed via the deep() option.
|
|
328
|
+
*
|
|
329
|
+
* @param {NonNullable<any>|ValueProcessorFunction|ValueProcessor} value
|
|
330
|
+
* @returns {Schema}
|
|
331
|
+
*/
|
|
332
|
+
default(value: NonNullable<any> | ValueProcessorFunction | ValueProcessor): Schema;
|
|
333
|
+
/**
|
|
334
|
+
* Indicate that this schema should be deeply traversed even if the input is empty
|
|
335
|
+
* (e.g. to enable deep defaults and requirements)
|
|
336
|
+
*
|
|
337
|
+
* @param {boolean} [value]
|
|
338
|
+
* @returns {Schema}
|
|
339
|
+
*/
|
|
340
|
+
deep(value?: boolean): Schema;
|
|
341
|
+
/**
|
|
342
|
+
* Mark this array/string as allowing empty values.
|
|
343
|
+
*
|
|
344
|
+
* @param {boolean} [value]
|
|
345
|
+
* @returns {Schema}
|
|
346
|
+
*/
|
|
347
|
+
allowEmpty(value?: boolean): Schema;
|
|
348
|
+
/**
|
|
349
|
+
* Mark this schema as allowing incremental assignment to children.
|
|
350
|
+
*
|
|
351
|
+
* (The default is true for any schema with children, so most of the time you'd be disabling it.)
|
|
352
|
+
*
|
|
353
|
+
* Deprecated; use the "opaque" option as it more clearly indicates the actual intent.
|
|
354
|
+
*
|
|
355
|
+
* @param {boolean} [value]
|
|
356
|
+
* @returns {Schema}
|
|
357
|
+
* @deprecated
|
|
358
|
+
*/
|
|
359
|
+
allowIncremental(value?: boolean): Schema;
|
|
360
|
+
/**
|
|
361
|
+
* Mark this schema as defining a value whose internal structure is hidden after transformation.
|
|
362
|
+
*
|
|
363
|
+
* This has implications both for assignment processing and validation.
|
|
364
|
+
*
|
|
365
|
+
* Deep property assignments usually result in any mid-path containers being automatically created
|
|
366
|
+
* (normalized and transformed) and property values are incrementally assigned.
|
|
367
|
+
*
|
|
368
|
+
* Opaque schemas do not allow incremental assignments, so they only create normalized mid-path containers
|
|
369
|
+
* that are staged until all relevant assignments are complete. The transform is then run, and passed
|
|
370
|
+
* the staged normalized container contents as input.
|
|
371
|
+
*
|
|
372
|
+
* Validators for opaque schemas only run on the value itself, and do not traverse into any child properties.
|
|
373
|
+
* Opaque schemas thus generally require custom validators that know how to properly handle the value.
|
|
374
|
+
*
|
|
375
|
+
* @param {boolean} [value]
|
|
376
|
+
* @returns {Schema}
|
|
377
|
+
*/
|
|
378
|
+
opaque(value?: boolean): Schema;
|
|
379
|
+
/**
|
|
380
|
+
* Mark this schema as requiring strict enforcement (the default)
|
|
381
|
+
*
|
|
382
|
+
* Strict mode means that the data cannot have any extra data, and exactly matches the schema definition.
|
|
383
|
+
* Lax mode allows a more "fuzzy" interpretation of the data, but the data still must pass all value processors
|
|
384
|
+
* including the validation phases. (To prevent exceptions during validation, wrap the processors in a
|
|
385
|
+
* $filter, which will just return undefined.)
|
|
386
|
+
*
|
|
387
|
+
* @param {boolean} [value]
|
|
388
|
+
* @returns {Schema}
|
|
389
|
+
*/
|
|
390
|
+
strict(value?: boolean): Schema;
|
|
391
|
+
/**
|
|
392
|
+
* Syntactic sugar for the opposite of strict
|
|
393
|
+
*
|
|
394
|
+
* @param {boolean} [value]
|
|
395
|
+
* @returns {Schema}
|
|
396
|
+
*/
|
|
397
|
+
lax(value?: boolean): Schema;
|
|
398
|
+
/**
|
|
399
|
+
* Mark this schema as implicit in the transformed output (so no need to assign or check)
|
|
400
|
+
*
|
|
401
|
+
* @param {boolean} [value]
|
|
402
|
+
* @returns {Schema}
|
|
403
|
+
*/
|
|
404
|
+
implicit(value?: boolean): Schema;
|
|
405
|
+
/**
|
|
406
|
+
* Define a legal input value this schema will accept.
|
|
407
|
+
*
|
|
408
|
+
* Values will be normalized for comparison.
|
|
409
|
+
*
|
|
410
|
+
* @param {NonNullable<any>} v
|
|
411
|
+
* @returns {Schema}
|
|
412
|
+
*/
|
|
413
|
+
value(v: NonNullable<any>): Schema;
|
|
414
|
+
/**
|
|
415
|
+
* Define a list of one or more legal values this schema will accept
|
|
416
|
+
*
|
|
417
|
+
* Values will be normalized for comparison.
|
|
418
|
+
*
|
|
419
|
+
* @param {Array<NonNullable<any>>} va
|
|
420
|
+
* @param {symbol} [policy]
|
|
421
|
+
* @returns {Schema}
|
|
422
|
+
*/
|
|
423
|
+
values(va?: Array<NonNullable<any>>, policy?: symbol): Schema;
|
|
424
|
+
/**
|
|
425
|
+
* The condition handler determines if the schema should be processed at all.
|
|
426
|
+
* This function appends a single value processor to the handler pipeline
|
|
427
|
+
*
|
|
428
|
+
* @param {ValueProcessorSpec} spec
|
|
429
|
+
* @returns {Schema}
|
|
430
|
+
*/
|
|
431
|
+
condition(spec: ValueProcessorSpec): Schema;
|
|
432
|
+
/**
|
|
433
|
+
* The condition handler determines if the schema should be processed at all.
|
|
434
|
+
* This call applies one or more value processors to the handler pipeline (default policy = append)
|
|
435
|
+
*
|
|
436
|
+
* @param {Array<ValueProcessorSpec>} specs
|
|
437
|
+
* @param {symbol} [policy]
|
|
438
|
+
* @returns {Schema}
|
|
439
|
+
*/
|
|
440
|
+
conditions(specs: Array<ValueProcessorSpec>, policy?: symbol): Schema;
|
|
441
|
+
/**
|
|
442
|
+
* The normalizer handler ensures input is in a format that the transformer can handle.
|
|
443
|
+
* This call appends a single value processor to the handler pipeline.
|
|
444
|
+
*
|
|
445
|
+
* @param {ValueProcessorSpec} spec
|
|
446
|
+
* @returns {Schema}
|
|
447
|
+
*/
|
|
448
|
+
normalizer(spec: ValueProcessorSpec): Schema;
|
|
449
|
+
/**
|
|
450
|
+
* The normalizer handler ensures input is in a format that the transformer can handle.
|
|
451
|
+
* This call applies one or more value processors to the handler pipeline.
|
|
452
|
+
*
|
|
453
|
+
* @param {Array<ValueProcessorSpec>} specs
|
|
454
|
+
* @param {symbol} [policy]
|
|
455
|
+
* @returns {Schema}
|
|
456
|
+
*/
|
|
457
|
+
normalizers(specs: Array<ValueProcessorSpec>, policy?: symbol): Schema;
|
|
458
|
+
/**
|
|
459
|
+
* The transformer handler converts a normalized input value into the final output value for the schema.
|
|
460
|
+
* This call appends a single value processor to the handler pipeline.
|
|
461
|
+
*
|
|
462
|
+
* @param {ValueProcessorSpec} spec
|
|
463
|
+
* @returns {Schema}
|
|
464
|
+
*/
|
|
465
|
+
transformer(spec: ValueProcessorSpec): Schema;
|
|
466
|
+
/**
|
|
467
|
+
* The transformer handler converts a normalized input value into the final output value for the schema.
|
|
468
|
+
* This call applies one or more value processors to the handler pipeline.
|
|
469
|
+
*
|
|
470
|
+
* @param {Array<ValueProcessorSpec>} specs
|
|
471
|
+
* @param {symbol} [policy]
|
|
472
|
+
* @returns {Schema}
|
|
473
|
+
*/
|
|
474
|
+
transformers(specs: Array<ValueProcessorSpec>, policy?: symbol): Schema;
|
|
475
|
+
/**
|
|
476
|
+
* The finalizer handler performs any required post-processing of a transformed value.
|
|
477
|
+
*
|
|
478
|
+
* @param {ValueProcessorSpec} spec
|
|
479
|
+
* @returns {Schema}
|
|
480
|
+
*/
|
|
481
|
+
finalizer(spec: ValueProcessorSpec): Schema;
|
|
482
|
+
/**
|
|
483
|
+
* The finalizer handler does any required post-processing of a transformed value.
|
|
484
|
+
* This call applies one or more value processors to the handler pipeline.
|
|
485
|
+
*
|
|
486
|
+
* @param {Array<ValueProcessorSpec>} specs
|
|
487
|
+
* @param {symbol} [policy]
|
|
488
|
+
* @returns {Schema}
|
|
489
|
+
*/
|
|
490
|
+
finalizers(specs: Array<ValueProcessorSpec>, policy?: symbol): Schema;
|
|
491
|
+
/**
|
|
492
|
+
* The validator handler ensures an input value matches the schema, and returns a (potentially enhanced) fully validated output value.
|
|
493
|
+
* This call appends a single value processor to the handler pipeline.
|
|
494
|
+
*
|
|
495
|
+
* @param {ValueProcessorSpec} spec
|
|
496
|
+
* @returns {Schema}
|
|
497
|
+
*/
|
|
498
|
+
validator(spec: ValueProcessorSpec): Schema;
|
|
499
|
+
/**
|
|
500
|
+
* The validator handler ensures an input value matches the schema, and returns a (potentially enhanced) fully validated output value.
|
|
501
|
+
* This call applies one or more value processors to the handler pipeline.
|
|
502
|
+
*
|
|
503
|
+
* @param {Array<ValueProcessorSpec>} specs
|
|
504
|
+
* @param {symbol} [policy]
|
|
505
|
+
* @returns {Schema}
|
|
506
|
+
*/
|
|
507
|
+
validators(specs: Array<ValueProcessorSpec>, policy?: symbol): Schema;
|
|
508
|
+
/**
|
|
509
|
+
* The serialize handler restores a configuration value to its pre-transform normalized form.
|
|
510
|
+
* This call appends a single value processor to the handler pipeline.
|
|
511
|
+
*
|
|
512
|
+
* @param {ValueProcessorSpec} spec
|
|
513
|
+
* @returns {Schema}
|
|
514
|
+
*/
|
|
515
|
+
serializer(spec: ValueProcessorSpec): Schema;
|
|
516
|
+
/**
|
|
517
|
+
* The serialize handler restores a configuration value to its pre-transform normalized form.
|
|
518
|
+
* This call applies one or more value processors to the handler pipeline.
|
|
519
|
+
*
|
|
520
|
+
* @param {Array<ValueProcessorSpec>} specs
|
|
521
|
+
* @param {symbol} [policy]
|
|
522
|
+
* @returns {Schema}
|
|
523
|
+
*/
|
|
524
|
+
serializers(specs: Array<ValueProcessorSpec>, policy?: symbol): Schema;
|
|
525
|
+
/**
|
|
526
|
+
* Use another schema to extend the current one without overwriting.
|
|
527
|
+
*
|
|
528
|
+
* @param {ISchema|SchemaData} otherSchema - source schema
|
|
529
|
+
* @param {Map<any,any>} [seen]
|
|
530
|
+
* @returns {Schema} - returns self
|
|
531
|
+
*/
|
|
532
|
+
extend(otherSchema: ISchema | SchemaData, seen?: Map<any, any>): Schema;
|
|
533
|
+
/**
|
|
534
|
+
* Make a copy of this schema
|
|
535
|
+
*
|
|
536
|
+
* @returns {Schema}
|
|
537
|
+
*/
|
|
538
|
+
clone(): Schema;
|
|
539
|
+
#private;
|
|
540
|
+
}
|
|
541
|
+
/**
|
|
542
|
+
* Policies for fine-grained control of composite schema internals
|
|
543
|
+
*/
|
|
544
|
+
export type SchemaPolicy = symbol;
|
|
545
|
+
/**
|
|
546
|
+
* Policies for fine-grained control of composite schema internals
|
|
547
|
+
* @readonly
|
|
548
|
+
* @enum {symbol}
|
|
549
|
+
*/
|
|
550
|
+
export const SchemaPolicy: Readonly<{
|
|
551
|
+
INITIALIZE: symbol;
|
|
552
|
+
OVERWRITE: symbol;
|
|
553
|
+
APPEND: symbol;
|
|
554
|
+
PREPEND: symbol;
|
|
555
|
+
}>;
|
|
556
|
+
export type SchemaOptions = ISchemaOptions;
|
|
557
|
+
export type SchemaMetadata = ISchemaMetadata;
|
|
558
|
+
export type SchemaProperties = {
|
|
559
|
+
[key: string]: ISchema;
|
|
560
|
+
};
|
|
561
|
+
export type SchemaUnionSchemas = {
|
|
562
|
+
[key: string]: ISchema;
|
|
563
|
+
};
|
|
564
|
+
export type SchemaHandlers = {
|
|
565
|
+
normalizers?: any[] | undefined;
|
|
566
|
+
transformers?: any[] | undefined;
|
|
567
|
+
finalizers?: any[] | undefined;
|
|
568
|
+
validators?: any[] | undefined;
|
|
569
|
+
serializers?: any[] | undefined;
|
|
570
|
+
conditions?: any[] | undefined;
|
|
571
|
+
discriminators?: any[] | undefined;
|
|
572
|
+
};
|
|
573
|
+
/**
|
|
574
|
+
* Schema - allows the definition of structure and rules for data
|
|
575
|
+
*
|
|
576
|
+
* Essentially acts as a fluent builder; must be compiled by SchemaCompiler for use.
|
|
577
|
+
*/
|
|
578
|
+
export type ISchema = import("./types.js").ISchema;
|
|
579
|
+
import type { SchemaData } from './types.js';
|
|
580
|
+
import { CompiledSchema } from './compiled-schema.js';
|
|
581
|
+
import type { ValueProcessorSpec } from './value-processor/value-processor.js';
|
|
582
|
+
import type { ValueProcessorFunction } from './value-processor/value-processor.js';
|
|
583
|
+
import type { ValueProcessor } from './value-processor/value-processor.js';
|
|
584
|
+
import type { ISchema } from './types.js';
|
|
585
|
+
import type { ISchemaMetadata } from './types.js';
|
|
586
|
+
import type { ISchemaOptions } from './types.js';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check whether we have a passing condition.
|
|
3
|
+
*
|
|
4
|
+
* @param {TraversalState} state
|
|
5
|
+
* @returns {TraversalState|null|undefined|Promise<TraversalState|null|undefined>}
|
|
6
|
+
*/
|
|
7
|
+
export function checkCondition(state: TraversalState): TraversalState | null | undefined | Promise<TraversalState | null | undefined>;
|
|
8
|
+
import { TraversalState } from '../traversal-state.js';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* If the input is undefined but the schema defines a default, use that value
|
|
3
|
+
*
|
|
4
|
+
* @param {TraversalState} state
|
|
5
|
+
* @returns {TraversalState}
|
|
6
|
+
*/
|
|
7
|
+
export function defaults(state: TraversalState): TraversalState;
|
|
8
|
+
import { TraversalState } from "../traversal-state.js";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {TraversalState} state
|
|
3
|
+
* @returns {TraversalState|null|undefined|Promise<TraversalState|null|undefined>}
|
|
4
|
+
*/
|
|
5
|
+
export function exit(state: TraversalState): TraversalState | null | undefined | Promise<TraversalState | null | undefined>;
|
|
6
|
+
import { TraversalState } from '../traversal-state.js';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {TraversalState} state
|
|
3
|
+
* @returns {TraversalState|undefined|Promise<TraversalState|undefined>}
|
|
4
|
+
*/
|
|
5
|
+
export function finalize(state: TraversalState): TraversalState | undefined | Promise<TraversalState | undefined>;
|
|
6
|
+
import { TraversalState } from '../traversal-state.js';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export const PROCESS_ENTER: Executor<TraversalState>;
|
|
2
|
+
export const PROCESS_EXIT: Executor<TraversalState>;
|
|
3
|
+
export const PROCESS_EXECUTOR: TraversalStateExecutor;
|
|
4
|
+
export const VALIDATE_ENTER: Executor<TraversalState>;
|
|
5
|
+
export const VALIDATE_EXIT: Executor<TraversalState>;
|
|
6
|
+
export const VALIDATE_EXECUTOR: TraversalStateExecutor;
|
|
7
|
+
export const SERIALIZE_ENTER: Executor<TraversalState>;
|
|
8
|
+
export const SERIALIZE_EXIT: Executor<TraversalState>;
|
|
9
|
+
export const SERIALIZE_EXECUTOR: TraversalStateExecutor;
|
|
10
|
+
export const PRELOAD_ENTER: Executor<TraversalState>;
|
|
11
|
+
export const PRELOAD_EXIT: Executor<TraversalState>;
|
|
12
|
+
export const PRELOAD_EXECUTOR: TraversalStateExecutor;
|
|
13
|
+
import { Executor } from "../../executor/executor.js";
|
|
14
|
+
import { TraversalState } from "../traversal-state.js";
|
|
15
|
+
import { TraversalStateExecutor } from './traversal-state-executor.js';
|