arktype 2.0.0-dev.4 → 2.0.0-dev.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__tests__/array.test.ts +176 -236
- package/__tests__/badDefinitionType.test.ts +10 -3
- package/__tests__/basis.test.ts +6 -2
- package/__tests__/bounds.test.ts +282 -352
- package/__tests__/cast.test.ts +7 -2
- package/__tests__/completions.test.ts +8 -3
- package/__tests__/config.test.ts +16 -8
- package/__tests__/cyclic.test.ts +141 -137
- package/__tests__/dateLiteral.test.ts +8 -4
- package/__tests__/declared.test.ts +2 -2
- package/__tests__/discrimination.test.ts +1 -1
- package/__tests__/divisor.test.ts +45 -25
- package/__tests__/enclosed.test.ts +39 -25
- package/__tests__/examples.test.ts +56 -56
- package/__tests__/expressions.test.ts +184 -112
- package/__tests__/generic.test.ts +307 -288
- package/__tests__/group.test.ts +67 -54
- package/__tests__/imports.test.ts +44 -37
- package/__tests__/instanceof.test.ts +17 -15
- package/__tests__/intersection.test.ts +50 -46
- package/__tests__/keyTraversal.test.ts +6 -3
- package/__tests__/keyof.test.ts +68 -52
- package/__tests__/keywords.test.ts +149 -136
- package/__tests__/literal.test.ts +38 -15
- package/__tests__/match.test.ts +234 -224
- package/__tests__/morph.test.ts +300 -269
- package/__tests__/narrow.test.ts +46 -42
- package/__tests__/objectLiteral.test.ts +228 -210
- package/__tests__/realWorld.test.ts +63 -0
- package/__tests__/regex.test.ts +17 -7
- package/__tests__/scope.bench.ts +1 -1
- package/__tests__/scope.test.ts +65 -18
- package/__tests__/serialization.test.ts +19 -0
- package/__tests__/string.test.ts +11 -7
- package/__tests__/submodule.test.ts +26 -39
- package/__tests__/this.test.ts +83 -57
- package/__tests__/thunk.test.ts +13 -7
- package/__tests__/traverse.test.ts +50 -37
- package/__tests__/tsGenerics.test.ts +12 -12
- package/__tests__/type.test.ts +38 -0
- package/__tests__/typeReference.test.ts +7 -7
- package/__tests__/unenclosed.test.ts +116 -100
- package/__tests__/union.test.ts +171 -104
- package/ark.ts +18 -65
- package/generic.ts +67 -0
- package/main.ts +6 -18
- package/match.ts +53 -67
- package/module.ts +15 -0
- package/out/ark.d.ts +12 -36
- package/out/ark.d.ts.map +1 -1
- package/out/ark.js +9 -17
- package/out/ark.js.map +1 -1
- package/out/base.d.ts +205 -0
- package/out/base.d.ts.map +1 -0
- package/out/base.js +320 -0
- package/out/base.js.map +1 -0
- package/out/builtins/builtins.d.ts +23 -0
- package/out/builtins/builtins.d.ts.map +1 -0
- package/out/builtins/builtins.js +15 -0
- package/out/builtins/builtins.js.map +1 -0
- package/out/builtins/jsObjects.d.ts +19 -0
- package/out/builtins/jsObjects.d.ts.map +1 -0
- package/out/builtins/jsObjects.js +18 -0
- package/out/builtins/jsObjects.js.map +1 -0
- package/out/builtins/parsing.d.ts +16 -0
- package/out/builtins/parsing.d.ts.map +1 -0
- package/out/builtins/parsing.js +62 -0
- package/out/builtins/parsing.js.map +1 -0
- package/out/builtins/tsGenerics.d.ts +2 -0
- package/out/builtins/tsGenerics.d.ts.map +1 -0
- package/out/builtins/tsGenerics.js +26 -0
- package/out/builtins/tsGenerics.js.map +1 -0
- package/out/builtins/tsKeywords.d.ts +23 -0
- package/out/builtins/tsKeywords.d.ts.map +1 -0
- package/out/builtins/tsKeywords.js +23 -0
- package/out/builtins/tsKeywords.js.map +1 -0
- package/out/builtins/utils/creditCard.d.ts +3 -0
- package/out/builtins/utils/creditCard.d.ts.map +1 -0
- package/out/builtins/utils/creditCard.js +35 -0
- package/out/builtins/utils/creditCard.js.map +1 -0
- package/out/builtins/utils/date.d.ts +41 -0
- package/out/builtins/utils/date.d.ts.map +1 -0
- package/out/builtins/utils/date.js +56 -0
- package/out/builtins/utils/date.js.map +1 -0
- package/out/builtins/validation.d.ts +19 -0
- package/out/builtins/validation.d.ts.map +1 -0
- package/out/builtins/validation.js +74 -0
- package/out/builtins/validation.js.map +1 -0
- package/out/config.d.ts +9 -0
- package/out/config.d.ts.map +1 -0
- package/out/config.js +18 -0
- package/out/config.js.map +1 -0
- package/out/constraints/ast.d.ts +287 -0
- package/out/constraints/ast.d.ts.map +1 -0
- package/out/constraints/ast.js +2 -0
- package/out/constraints/ast.js.map +1 -0
- package/out/constraints/constraint.d.ts +200 -0
- package/out/constraints/constraint.d.ts.map +1 -0
- package/out/constraints/constraint.js +25 -0
- package/out/constraints/constraint.js.map +1 -0
- package/out/constraints/predicate.d.ts +64 -0
- package/out/constraints/predicate.d.ts.map +1 -0
- package/out/constraints/predicate.js +52 -0
- package/out/constraints/predicate.js.map +1 -0
- package/out/constraints/props/index.d.ts +42 -0
- package/out/constraints/props/index.d.ts.map +1 -0
- package/out/constraints/props/index.js +56 -0
- package/out/constraints/props/index.js.map +1 -0
- package/out/constraints/props/optional.d.ts +37 -0
- package/out/constraints/props/optional.d.ts.map +1 -0
- package/out/constraints/props/optional.js +56 -0
- package/out/constraints/props/optional.js.map +1 -0
- package/out/constraints/props/prop.d.ts +49 -0
- package/out/constraints/props/prop.d.ts.map +1 -0
- package/out/constraints/props/prop.js +106 -0
- package/out/constraints/props/prop.js.map +1 -0
- package/out/constraints/props/props.d.ts +37 -0
- package/out/constraints/props/props.d.ts.map +1 -0
- package/out/constraints/props/props.js +121 -0
- package/out/constraints/props/props.js.map +1 -0
- package/out/constraints/props/required.d.ts +46 -0
- package/out/constraints/props/required.d.ts.map +1 -0
- package/out/constraints/props/required.js +81 -0
- package/out/constraints/props/required.js.map +1 -0
- package/out/constraints/props/sequence.d.ts +82 -0
- package/out/constraints/props/sequence.d.ts.map +1 -0
- package/out/constraints/props/sequence.js +376 -0
- package/out/constraints/props/sequence.js.map +1 -0
- package/out/constraints/props/shared.d.ts +3 -0
- package/out/constraints/props/shared.d.ts.map +1 -0
- package/out/constraints/props/shared.js +4 -0
- package/out/constraints/props/shared.js.map +1 -0
- package/out/constraints/refinements/after.d.ts +33 -0
- package/out/constraints/refinements/after.d.ts.map +1 -0
- package/out/constraints/refinements/after.js +36 -0
- package/out/constraints/refinements/after.js.map +1 -0
- package/out/constraints/refinements/before.d.ts +33 -0
- package/out/constraints/refinements/before.d.ts.map +1 -0
- package/out/constraints/refinements/before.js +43 -0
- package/out/constraints/refinements/before.js.map +1 -0
- package/out/constraints/refinements/divisor.d.ts +52 -0
- package/out/constraints/refinements/divisor.d.ts.map +1 -0
- package/out/constraints/refinements/divisor.js +52 -0
- package/out/constraints/refinements/divisor.js.map +1 -0
- package/out/constraints/refinements/exactLength.d.ts +45 -0
- package/out/constraints/refinements/exactLength.d.ts.map +1 -0
- package/out/constraints/refinements/exactLength.js +52 -0
- package/out/constraints/refinements/exactLength.js.map +1 -0
- package/out/constraints/refinements/kinds.d.ts +29 -0
- package/out/constraints/refinements/kinds.d.ts.map +1 -0
- package/out/constraints/refinements/kinds.js +17 -0
- package/out/constraints/refinements/kinds.js.map +1 -0
- package/out/constraints/refinements/length.d.ts +48 -0
- package/out/constraints/refinements/length.d.ts.map +1 -0
- package/out/constraints/refinements/length.js +53 -0
- package/out/constraints/refinements/length.js.map +1 -0
- package/out/constraints/refinements/max.d.ts +31 -0
- package/out/constraints/refinements/max.d.ts.map +1 -0
- package/out/constraints/refinements/max.js +35 -0
- package/out/constraints/refinements/max.js.map +1 -0
- package/out/constraints/refinements/maxLength.d.ts +32 -0
- package/out/constraints/refinements/maxLength.d.ts.map +1 -0
- package/out/constraints/refinements/maxLength.js +36 -0
- package/out/constraints/refinements/maxLength.js.map +1 -0
- package/out/constraints/refinements/min.d.ts +31 -0
- package/out/constraints/refinements/min.d.ts.map +1 -0
- package/out/constraints/refinements/min.js +28 -0
- package/out/constraints/refinements/min.js.map +1 -0
- package/out/constraints/refinements/minLength.d.ts +32 -0
- package/out/constraints/refinements/minLength.d.ts.map +1 -0
- package/out/constraints/refinements/minLength.js +33 -0
- package/out/constraints/refinements/minLength.js.map +1 -0
- package/out/constraints/refinements/range.d.ts +119 -0
- package/out/constraints/refinements/range.d.ts.map +1 -0
- package/out/constraints/refinements/range.js +89 -0
- package/out/constraints/refinements/range.js.map +1 -0
- package/out/constraints/refinements/regex.d.ts +47 -0
- package/out/constraints/refinements/regex.d.ts.map +1 -0
- package/out/constraints/refinements/regex.js +37 -0
- package/out/constraints/refinements/regex.js.map +1 -0
- package/out/constraints/refinements/shared.d.ts +20 -0
- package/out/constraints/refinements/shared.d.ts.map +1 -0
- package/out/constraints/refinements/shared.js +10 -0
- package/out/constraints/refinements/shared.js.map +1 -0
- package/out/generic.d.ts +22 -0
- package/out/generic.d.ts.map +1 -0
- package/out/generic.js +23 -0
- package/out/generic.js.map +1 -0
- package/out/inference.d.ts +137 -0
- package/out/inference.d.ts.map +1 -0
- package/out/inference.js +73 -0
- package/out/inference.js.map +1 -0
- package/out/keywords/ark.d.ts +70 -0
- package/out/keywords/ark.d.ts.map +1 -0
- package/out/keywords/ark.js +29 -0
- package/out/keywords/ark.js.map +1 -0
- package/out/keywords/internal.d.ts +13 -0
- package/out/keywords/internal.d.ts.map +1 -0
- package/out/keywords/internal.js +13 -0
- package/out/keywords/internal.js.map +1 -0
- package/out/keywords/jsObject.d.ts +20 -0
- package/out/keywords/jsObject.d.ts.map +1 -0
- package/out/keywords/jsObject.js +18 -0
- package/out/keywords/jsObject.js.map +1 -0
- package/out/keywords/parsing.d.ts +17 -0
- package/out/keywords/parsing.d.ts.map +1 -0
- package/out/keywords/parsing.js +64 -0
- package/out/keywords/parsing.js.map +1 -0
- package/out/keywords/root.d.ts +7 -0
- package/out/keywords/root.d.ts.map +1 -0
- package/out/keywords/root.js +4 -0
- package/out/keywords/root.js.map +1 -0
- package/out/keywords/tsGenerics.d.ts +2 -0
- package/out/keywords/tsGenerics.d.ts.map +1 -0
- package/out/keywords/tsGenerics.js +26 -0
- package/out/keywords/tsGenerics.js.map +1 -0
- package/out/keywords/tsPrimitive.d.ts +24 -0
- package/out/keywords/tsPrimitive.d.ts.map +1 -0
- package/out/keywords/tsPrimitive.js +25 -0
- package/out/keywords/tsPrimitive.js.map +1 -0
- package/out/keywords/utils/creditCard.d.ts +11 -0
- package/out/keywords/utils/creditCard.d.ts.map +1 -0
- package/out/keywords/utils/creditCard.js +35 -0
- package/out/keywords/utils/creditCard.js.map +1 -0
- package/out/keywords/utils/date.d.ts +45 -0
- package/out/keywords/utils/date.d.ts.map +1 -0
- package/out/keywords/utils/date.js +56 -0
- package/out/keywords/utils/date.js.map +1 -0
- package/out/keywords/validation.d.ts +20 -0
- package/out/keywords/validation.d.ts.map +1 -0
- package/out/keywords/validation.js +80 -0
- package/out/keywords/validation.js.map +1 -0
- package/out/kinds.d.ts +102 -0
- package/out/kinds.d.ts.map +1 -0
- package/out/kinds.js +29 -0
- package/out/kinds.js.map +1 -0
- package/out/main.d.ts +6 -6
- package/out/main.d.ts.map +1 -1
- package/out/main.js +4 -3
- package/out/main.js.map +1 -1
- package/out/match.d.ts +18 -23
- package/out/match.d.ts.map +1 -1
- package/out/match.js +3 -4
- package/out/match.js.map +1 -1
- package/out/module.d.ts +11 -0
- package/out/module.d.ts.map +1 -0
- package/out/module.js +4 -0
- package/out/module.js.map +1 -0
- package/out/parse.d.ts +29 -0
- package/out/parse.d.ts.map +1 -0
- package/out/parse.js +161 -0
- package/out/parse.js.map +1 -0
- package/out/parser/definition.d.ts +9 -12
- package/out/parser/definition.d.ts.map +1 -1
- package/out/parser/definition.js +10 -12
- package/out/parser/definition.js.map +1 -1
- package/out/parser/generic.d.ts +3 -4
- package/out/parser/generic.d.ts.map +1 -1
- package/out/parser/generic.js +6 -8
- package/out/parser/generic.js.map +1 -1
- package/out/parser/objectLiteral.d.ts +44 -12
- package/out/parser/objectLiteral.d.ts.map +1 -1
- package/out/parser/objectLiteral.js +43 -36
- package/out/parser/objectLiteral.js.map +1 -1
- package/out/parser/semantic/bounds.d.ts +9 -6
- package/out/parser/semantic/bounds.d.ts.map +1 -1
- package/out/parser/semantic/bounds.js.map +1 -1
- package/out/parser/semantic/divisor.d.ts +5 -6
- package/out/parser/semantic/divisor.d.ts.map +1 -1
- package/out/parser/semantic/infer.d.ts +25 -0
- package/out/parser/semantic/infer.d.ts.map +1 -0
- package/out/parser/semantic/infer.js +2 -0
- package/out/parser/semantic/infer.js.map +1 -0
- package/out/parser/semantic/utils.d.ts +3 -6
- package/out/parser/semantic/utils.d.ts.map +1 -1
- package/out/parser/semantic/validate.d.ts +14 -12
- package/out/parser/semantic/validate.d.ts.map +1 -1
- package/out/parser/semantic/validate.js +1 -0
- package/out/parser/semantic/validate.js.map +1 -1
- package/out/parser/string/reduce/dynamic.d.ts +13 -12
- package/out/parser/string/reduce/dynamic.d.ts.map +1 -1
- package/out/parser/string/reduce/dynamic.js +27 -17
- package/out/parser/string/reduce/dynamic.js.map +1 -1
- package/out/parser/string/reduce/shared.d.ts +1 -2
- package/out/parser/string/reduce/shared.d.ts.map +1 -1
- package/out/parser/string/reduce/shared.js.map +1 -1
- package/out/parser/string/reduce/static.d.ts +26 -22
- package/out/parser/string/reduce/static.d.ts.map +1 -1
- package/out/parser/string/shift/operand/date.d.ts +2 -1
- package/out/parser/string/shift/operand/date.d.ts.map +1 -1
- package/out/parser/string/shift/operand/date.js +2 -2
- package/out/parser/string/shift/operand/date.js.map +1 -1
- package/out/parser/string/shift/operand/enclosed.d.ts +2 -2
- package/out/parser/string/shift/operand/enclosed.d.ts.map +1 -1
- package/out/parser/string/shift/operand/enclosed.js +6 -4
- package/out/parser/string/shift/operand/enclosed.js.map +1 -1
- package/out/parser/string/shift/operand/genericArgs.d.ts +9 -9
- package/out/parser/string/shift/operand/genericArgs.d.ts.map +1 -1
- package/out/parser/string/shift/operand/genericArgs.js +6 -8
- package/out/parser/string/shift/operand/genericArgs.js.map +1 -1
- package/out/parser/string/shift/operand/operand.d.ts +3 -3
- package/out/parser/string/shift/operand/operand.d.ts.map +1 -1
- package/out/parser/string/shift/operand/operand.js +8 -11
- package/out/parser/string/shift/operand/operand.js.map +1 -1
- package/out/parser/string/shift/operand/unenclosed.d.ts +13 -20
- package/out/parser/string/shift/operand/unenclosed.d.ts.map +1 -1
- package/out/parser/string/shift/operand/unenclosed.js +21 -26
- package/out/parser/string/shift/operand/unenclosed.js.map +1 -1
- package/out/parser/string/shift/operator/bounds.d.ts +15 -12
- package/out/parser/string/shift/operator/bounds.d.ts.map +1 -1
- package/out/parser/string/shift/operator/bounds.js +42 -48
- package/out/parser/string/shift/operator/bounds.js.map +1 -1
- package/out/parser/string/shift/operator/divisor.d.ts +1 -2
- package/out/parser/string/shift/operator/divisor.d.ts.map +1 -1
- package/out/parser/string/shift/operator/divisor.js.map +1 -1
- package/out/parser/string/shift/operator/operator.d.ts +1 -1
- package/out/parser/string/shift/operator/operator.d.ts.map +1 -1
- package/out/parser/string/shift/operator/operator.js +12 -18
- package/out/parser/string/shift/operator/operator.js.map +1 -1
- package/out/parser/string/shift/scanner.d.ts +2 -1
- package/out/parser/string/shift/scanner.d.ts.map +1 -1
- package/out/parser/string/shift/scanner.js +12 -11
- package/out/parser/string/shift/scanner.js.map +1 -1
- package/out/parser/string/string.d.ts +8 -5
- package/out/parser/string/string.d.ts.map +1 -1
- package/out/parser/string/string.js.map +1 -1
- package/out/parser/tuple.d.ts +96 -37
- package/out/parser/tuple.d.ts.map +1 -1
- package/out/parser/tuple.js +61 -66
- package/out/parser/tuple.js.map +1 -1
- package/out/schema.d.ts +175 -0
- package/out/schema.d.ts.map +1 -0
- package/out/schema.js +73 -0
- package/out/schema.js.map +1 -0
- package/out/schemaScope.d.ts +180 -0
- package/out/schemaScope.d.ts.map +1 -0
- package/out/schemaScope.js +235 -0
- package/out/schemaScope.js.map +1 -0
- package/out/scope.d.ts +42 -114
- package/out/scope.d.ts.map +1 -1
- package/out/scope.js +51 -181
- package/out/scope.js.map +1 -1
- package/out/shared/compile.d.ts +22 -0
- package/out/shared/compile.d.ts.map +1 -0
- package/out/shared/compile.js +79 -0
- package/out/shared/compile.js.map +1 -0
- package/out/shared/context.d.ts +54 -0
- package/out/shared/context.d.ts.map +1 -0
- package/out/shared/context.js +53 -0
- package/out/shared/context.js.map +1 -0
- package/out/shared/declare.d.ts +69 -0
- package/out/shared/declare.d.ts.map +1 -0
- package/out/shared/declare.js +2 -0
- package/out/shared/declare.js.map +1 -0
- package/out/shared/disjoint.d.ts +91 -0
- package/out/shared/disjoint.d.ts.map +1 -0
- package/out/shared/disjoint.js +110 -0
- package/out/shared/disjoint.js.map +1 -0
- package/out/shared/errors.d.ts +99 -0
- package/out/shared/errors.d.ts.map +1 -0
- package/out/shared/errors.js +108 -0
- package/out/shared/errors.js.map +1 -0
- package/out/shared/implement.d.ts +363 -0
- package/out/shared/implement.d.ts.map +1 -0
- package/out/shared/implement.js +68 -0
- package/out/shared/implement.js.map +1 -0
- package/out/shared/inference.d.ts +6 -0
- package/out/shared/inference.d.ts.map +1 -0
- package/out/shared/inference.js +5 -0
- package/out/shared/inference.js.map +1 -0
- package/out/shared/intersections.d.ts +60 -0
- package/out/shared/intersections.d.ts.map +1 -0
- package/out/shared/intersections.js +2 -0
- package/out/shared/intersections.js.map +1 -0
- package/out/shared/traversal.d.ts +62 -0
- package/out/shared/traversal.d.ts.map +1 -0
- package/out/shared/traversal.js +97 -0
- package/out/shared/traversal.js.map +1 -0
- package/out/shared/utils.d.ts +24 -0
- package/out/shared/utils.d.ts.map +1 -0
- package/out/shared/utils.js +15 -0
- package/out/shared/utils.js.map +1 -0
- package/out/type.d.ts +23 -59
- package/out/type.d.ts.map +1 -1
- package/out/type.js +2 -137
- package/out/type.js.map +1 -1
- package/out/types/basis.d.ts +47 -0
- package/out/types/basis.d.ts.map +1 -0
- package/out/types/basis.js +15 -0
- package/out/types/basis.js.map +1 -0
- package/out/types/discriminate.d.ts +34 -0
- package/out/types/discriminate.d.ts.map +1 -0
- package/out/types/discriminate.js +120 -0
- package/out/types/discriminate.js.map +1 -0
- package/out/types/domain.d.ts +57 -0
- package/out/types/domain.d.ts.map +1 -0
- package/out/types/domain.js +41 -0
- package/out/types/domain.js.map +1 -0
- package/out/types/intersection.d.ts +127 -0
- package/out/types/intersection.d.ts.map +1 -0
- package/out/types/intersection.js +379 -0
- package/out/types/intersection.js.map +1 -0
- package/out/types/morph.d.ts +157 -0
- package/out/types/morph.d.ts.map +1 -0
- package/out/types/morph.js +99 -0
- package/out/types/morph.js.map +1 -0
- package/out/types/proto.d.ts +51 -0
- package/out/types/proto.d.ts.map +1 -0
- package/out/types/proto.js +60 -0
- package/out/types/proto.js.map +1 -0
- package/out/types/type.d.ts +143 -0
- package/out/types/type.d.ts.map +1 -0
- package/out/types/type.js +123 -0
- package/out/types/type.js.map +1 -0
- package/out/types/union.d.ts +71 -0
- package/out/types/union.d.ts.map +1 -0
- package/out/types/union.js +379 -0
- package/out/types/union.js.map +1 -0
- package/out/types/unit.d.ts +45 -0
- package/out/types/unit.d.ts.map +1 -0
- package/out/types/unit.js +56 -0
- package/out/types/unit.js.map +1 -0
- package/out/util.d.ts +30 -18
- package/out/util.d.ts.map +1 -1
- package/out/util.js +8 -7
- package/out/util.js.map +1 -1
- package/package.json +7 -3
- package/parser/definition.ts +73 -89
- package/parser/generic.ts +35 -36
- package/parser/objectLiteral.ts +143 -117
- package/parser/semantic/bounds.ts +33 -32
- package/parser/semantic/divisor.ts +8 -10
- package/parser/semantic/infer.ts +141 -0
- package/parser/semantic/utils.ts +12 -23
- package/parser/semantic/validate.ts +82 -73
- package/parser/string/reduce/dynamic.ts +61 -46
- package/parser/string/reduce/shared.ts +1 -3
- package/parser/string/reduce/static.ts +65 -67
- package/parser/string/shift/operand/date.ts +12 -8
- package/parser/string/shift/operand/enclosed.ts +22 -17
- package/parser/string/shift/operand/genericArgs.ts +46 -45
- package/parser/string/shift/operand/operand.ts +32 -38
- package/parser/string/shift/operand/unenclosed.ts +106 -147
- package/parser/string/shift/operator/bounds.ts +114 -106
- package/parser/string/shift/operator/divisor.ts +12 -14
- package/parser/string/shift/operator/operator.ts +35 -46
- package/parser/string/shift/scanner.ts +49 -46
- package/parser/string/string.ts +28 -32
- package/parser/tuple.ts +288 -308
- package/scope.ts +183 -425
- package/type.ts +82 -281
- package/__tests__/astUtils.test.ts +0 -17
- package/__tests__/jsdoc.test.ts +0 -64
- package/__tests__/nodeDefinitions.test.ts +0 -190
- package/__tests__/typeMethods.test.ts +0 -69
- package/out/arkConfig.d.ts +0 -2
- package/out/arkConfig.d.ts.map +0 -1
- package/out/arkConfig.js +0 -10
- package/out/arkConfig.js.map +0 -1
- package/out/parser/semantic/intersections.d.ts +0 -14
- package/out/parser/semantic/intersections.d.ts.map +0 -1
- package/out/parser/semantic/intersections.js +0 -2
- package/out/parser/semantic/intersections.js.map +0 -1
- package/out/parser/semantic/semantic.d.ts +0 -32
- package/out/parser/semantic/semantic.d.ts.map +0 -1
- package/out/parser/semantic/semantic.js +0 -2
- package/out/parser/semantic/semantic.js.map +0 -1
- package/out/parser/shared.d.ts +0 -62
- package/out/parser/shared.d.ts.map +0 -1
- package/out/parser/shared.js +0 -56
- package/out/parser/shared.js.map +0 -1
- package/out/test.d.ts +0 -2
- package/out/test.d.ts.map +0 -1
- package/out/test.js +0 -7
- package/out/test.js.map +0 -1
- package/out/tsconfig.build.tsbuildinfo +0 -1
- package/parser/semantic/semantic.ts +0 -143
- package/parser/shared.ts +0 -170
- package/util.ts +0 -36
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { evaluate, merge } from "@arktype/util"
|
|
2
|
+
import type { NarrowedAttachments, Node } from "../base.js"
|
|
3
|
+
import type { reducibleKindOf } from "../kinds.js"
|
|
4
|
+
import type { Disjoint } from "./disjoint.js"
|
|
5
|
+
import type { NodeKind } from "./implement.js"
|
|
6
|
+
export interface BaseMeta {
|
|
7
|
+
readonly description?: string
|
|
8
|
+
}
|
|
9
|
+
export declare const metaKeys: {
|
|
10
|
+
[k in keyof BaseMeta]: 1
|
|
11
|
+
}
|
|
12
|
+
interface DeclarationInput {
|
|
13
|
+
kind: NodeKind
|
|
14
|
+
schema: unknown
|
|
15
|
+
normalizedSchema: BaseMeta
|
|
16
|
+
inner: BaseMeta
|
|
17
|
+
reducibleTo?: NodeKind
|
|
18
|
+
intersectionIsOpen?: true
|
|
19
|
+
errorContext?: object
|
|
20
|
+
prerequisite?: unknown
|
|
21
|
+
childKind?: NodeKind
|
|
22
|
+
}
|
|
23
|
+
export interface BaseErrorContext<kind extends NodeKind = NodeKind> {
|
|
24
|
+
code: kind
|
|
25
|
+
}
|
|
26
|
+
export type defaultErrorContext<d extends DeclarationInput> = evaluate<
|
|
27
|
+
BaseErrorContext<d["kind"]> & d["inner"]
|
|
28
|
+
>
|
|
29
|
+
export type declareNode<
|
|
30
|
+
d extends {
|
|
31
|
+
[k in keyof d]: k extends keyof DeclarationInput
|
|
32
|
+
? DeclarationInput[k]
|
|
33
|
+
: never
|
|
34
|
+
} & DeclarationInput
|
|
35
|
+
> = merge<
|
|
36
|
+
{
|
|
37
|
+
intersectionIsOpen: false
|
|
38
|
+
prerequisite: prerequisiteOf<d>
|
|
39
|
+
childKind: never
|
|
40
|
+
reducibleTo: d["kind"]
|
|
41
|
+
errorContext: null
|
|
42
|
+
},
|
|
43
|
+
d & {
|
|
44
|
+
errorContext: d["errorContext"] extends {}
|
|
45
|
+
? BaseErrorContext<d["kind"]>
|
|
46
|
+
: null
|
|
47
|
+
}
|
|
48
|
+
>
|
|
49
|
+
type prerequisiteOf<d extends DeclarationInput> = "prerequisite" extends keyof d
|
|
50
|
+
? d["prerequisite"]
|
|
51
|
+
: unknown
|
|
52
|
+
export type BaseAttachmentsOf<d extends BaseNodeDeclaration> =
|
|
53
|
+
NarrowedAttachments<d> & d["inner"]
|
|
54
|
+
export type BaseNodeDeclaration = {
|
|
55
|
+
kind: NodeKind
|
|
56
|
+
schema: unknown
|
|
57
|
+
normalizedSchema: BaseMeta
|
|
58
|
+
inner: BaseMeta
|
|
59
|
+
reducibleTo: NodeKind
|
|
60
|
+
prerequisite: any
|
|
61
|
+
intersectionIsOpen: boolean
|
|
62
|
+
childKind: NodeKind
|
|
63
|
+
errorContext: BaseErrorContext | null
|
|
64
|
+
}
|
|
65
|
+
export type ownIntersectionResult<d extends BaseNodeDeclaration> =
|
|
66
|
+
| Node<reducibleKindOf<d["kind"]>>
|
|
67
|
+
| Disjoint
|
|
68
|
+
export {}
|
|
69
|
+
//# sourceMappingURL=declare.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"declare.d.ts","sourceRoot":"","sources":["../../shared/declare.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AACpD,OAAO,KAAK,EAAE,mBAAmB,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAClD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAC7C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAE9C,MAAM,WAAW,QAAQ;IACxB,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAC7B;AAED,eAAO,MAAM,QAAQ,EAAE;KAAG,CAAC,IAAI,MAAM,QAAQ,GAAG,CAAC;CAAuB,CAAA;AAExE,UAAU,gBAAgB;IACzB,IAAI,EAAE,QAAQ,CAAA;IACd,MAAM,EAAE,OAAO,CAAA;IACf,gBAAgB,EAAE,QAAQ,CAAA;IAC1B,KAAK,EAAE,QAAQ,CAAA;IACf,WAAW,CAAC,EAAE,QAAQ,CAAA;IACtB,kBAAkB,CAAC,EAAE,IAAI,CAAA;IACzB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,SAAS,CAAC,EAAE,QAAQ,CAAA;CACpB;AAED,MAAM,WAAW,gBAAgB,CAAC,IAAI,SAAS,QAAQ,GAAG,QAAQ;IACjE,IAAI,EAAE,IAAI,CAAA;CACV;AAED,MAAM,MAAM,mBAAmB,CAAC,CAAC,SAAS,gBAAgB,IAAI,QAAQ,CACrE,gBAAgB,CAA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SAAS,mBAAmB,IAC5D,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAChC,QAAQ,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"declare.js","sourceRoot":"","sources":["../../shared/declare.ts"],"names":[],"mappings":"AAUA,MAAM,CAAC,MAAM,QAAQ,GAAiC,EAAE,WAAW,EAAE,CAAC,EAAE,CAAA"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { type entryOf } from "@arktype/util"
|
|
2
|
+
import type { Node } from "../base.js"
|
|
3
|
+
import type {
|
|
4
|
+
BoundKind,
|
|
5
|
+
IntersectionChildKind,
|
|
6
|
+
kindRightOf
|
|
7
|
+
} from "./implement.js"
|
|
8
|
+
type DisjointKinds = {
|
|
9
|
+
domain?: {
|
|
10
|
+
l: Node<"domain">
|
|
11
|
+
r: Node<"domain">
|
|
12
|
+
}
|
|
13
|
+
unit?: {
|
|
14
|
+
l: Node<"unit">
|
|
15
|
+
r: Node<"unit">
|
|
16
|
+
}
|
|
17
|
+
proto?: {
|
|
18
|
+
l: Node<"proto">
|
|
19
|
+
r: Node<"proto">
|
|
20
|
+
}
|
|
21
|
+
presence?:
|
|
22
|
+
| {
|
|
23
|
+
l: true
|
|
24
|
+
r: false
|
|
25
|
+
}
|
|
26
|
+
| {
|
|
27
|
+
l: false
|
|
28
|
+
r: true
|
|
29
|
+
}
|
|
30
|
+
range?: {
|
|
31
|
+
l: Node<BoundKind>
|
|
32
|
+
r: Node<BoundKind>
|
|
33
|
+
}
|
|
34
|
+
assignability?:
|
|
35
|
+
| {
|
|
36
|
+
l: unknown
|
|
37
|
+
r: Node<IntersectionChildKind>
|
|
38
|
+
}
|
|
39
|
+
| {
|
|
40
|
+
l: Node<IntersectionChildKind>
|
|
41
|
+
r: unknown
|
|
42
|
+
}
|
|
43
|
+
union?: {
|
|
44
|
+
l: readonly Node<kindRightOf<"union">>[]
|
|
45
|
+
r: readonly Node<kindRightOf<"union">>[]
|
|
46
|
+
}
|
|
47
|
+
indiscriminableMorphs?: {
|
|
48
|
+
l: Node<"union">
|
|
49
|
+
r: Node<"union">
|
|
50
|
+
}
|
|
51
|
+
interesectedMorphs?: {
|
|
52
|
+
l: Node<"morph">
|
|
53
|
+
r: Node<"morph">
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
export type DisjointKindEntries = entryOf<DisjointKinds>[]
|
|
57
|
+
export type SerializedPath = `[${string}]`
|
|
58
|
+
export type DisjointsSources = {
|
|
59
|
+
[k in `${SerializedPath}`]: DisjointsAtPath
|
|
60
|
+
}
|
|
61
|
+
export type DisjointsAtPath = {
|
|
62
|
+
[kind in DisjointKind]?: DisjointKinds[kind]
|
|
63
|
+
}
|
|
64
|
+
export type DisjointSourceEntry = entryOf<DisjointsSources>
|
|
65
|
+
export type FlatDisjointEntry = {
|
|
66
|
+
path: SerializedPath
|
|
67
|
+
kind: DisjointKind
|
|
68
|
+
disjoint: Required<DisjointKinds>[DisjointKind]
|
|
69
|
+
}
|
|
70
|
+
export type DisjointKind = keyof DisjointKinds
|
|
71
|
+
export declare class Disjoint {
|
|
72
|
+
sources: DisjointsSources
|
|
73
|
+
constructor(sources: DisjointsSources)
|
|
74
|
+
clone(): Disjoint
|
|
75
|
+
static from<kind extends DisjointKind>(
|
|
76
|
+
kind: kind,
|
|
77
|
+
l: Required<DisjointKinds>[kind]["l"],
|
|
78
|
+
r: Required<DisjointKinds>[kind]["r"]
|
|
79
|
+
): Disjoint
|
|
80
|
+
static fromEntries(entries: DisjointKindEntries): Disjoint
|
|
81
|
+
get flat(): FlatDisjointEntry[]
|
|
82
|
+
describeReasons(): string
|
|
83
|
+
isEmpty(): boolean
|
|
84
|
+
throw(): never
|
|
85
|
+
invert(): Disjoint
|
|
86
|
+
add(input: Disjoint): void
|
|
87
|
+
withPrefixKey(key: string): Disjoint
|
|
88
|
+
toString(): string
|
|
89
|
+
}
|
|
90
|
+
export {}
|
|
91
|
+
//# sourceMappingURL=disjoint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"disjoint.d.ts","sourceRoot":"","sources":["../../shared/disjoint.ts"],"names":[],"mappings":"AAAA,OAAO,EAQN,KAAK,OAAO,EACZ,MAAM,eAAe,CAAA;AACtB,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAEtC,OAAO,KAAK,EACX,SAAS,EACT,qBAAqB,EACrB,WAAW,EACX,MAAM,gBAAgB,CAAA;AAEvB,KAAK,aAAa,GAAG;IACpB,MAAM,CAAC,EAAE;QACR,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAA;QACjB,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAA;KACjB,CAAA;IACD,IAAI,CAAC,EAAE;QACN,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;QACf,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;KACf,CAAA;IACD,KAAK,CAAC,EAAE;QACP,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,CAAA;QAChB,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,CAAA;KAChB,CAAA;IAED,QAAQ,CAAC,EACN;QACA,CAAC,EAAE,IAAI,CAAA;QACP,CAAC,EAAE,KAAK,CAAA;KACP,GACD;QACA,CAAC,EAAE,KAAK,CAAA;QACR,CAAC,EAAE,IAAI,CAAA;KACN,CAAA;IACJ,KAAK,CAAC,EAAE;QACP,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,CAAA;QAClB,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,CAAA;KAClB,CAAA;IACD,aAAa,CAAC,EACX;QACA,CAAC,EAAE,OAAO,CAAA;QACV,CAAC,EAAE,IAAI,CAAC,qBAAqB,CAAC,CAAA;KAC7B,GACD;QACA,CAAC,EAAE,IAAI,CAAC,qBAAqB,CAAC,CAAA;QAC9B,CAAC,EAAE,OAAO,CAAA;KACT,CAAA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YAAY,EACpC,IAAI,EAAE,IAAI,EACV,CAAC,EAAE,QAAQ,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,EACrC,CAAC,EAAE,QAAQ,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,GACnC,QAAQ;IAWX,MAAM,CAAC,WAAW,CAAC,OAAO,EAAE,mBAAmB,GAAG,QAAQ;IAS1D,IAAI,IAAI,IAAI,iBAAiB,EAAE,CAQ9B;IAED,eAAe,IAAI,MAAM;IAqBzB,OAAO,IAAI,OAAO;IAIlB,KAAK,IAAI,KAAK;IAId,MAAM,IAAI,QAAQ;IAclB,GAAG,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI;IAM1B,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ;IAYpC,QAAQ,IAAI,MAAM;CAGlB"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import {
|
|
2
|
+
entriesOf,
|
|
3
|
+
flatMorph,
|
|
4
|
+
fromEntries,
|
|
5
|
+
isArray,
|
|
6
|
+
printable,
|
|
7
|
+
throwInternalError,
|
|
8
|
+
throwParseError
|
|
9
|
+
} from "@arktype/util"
|
|
10
|
+
import { hasArkKind } from "../util.js"
|
|
11
|
+
export class Disjoint {
|
|
12
|
+
sources
|
|
13
|
+
constructor(sources) {
|
|
14
|
+
this.sources = sources
|
|
15
|
+
}
|
|
16
|
+
clone() {
|
|
17
|
+
return new Disjoint(this.sources)
|
|
18
|
+
}
|
|
19
|
+
static from(kind, l, r) {
|
|
20
|
+
return new Disjoint({
|
|
21
|
+
"[]": {
|
|
22
|
+
[kind]: {
|
|
23
|
+
l,
|
|
24
|
+
r
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
})
|
|
28
|
+
}
|
|
29
|
+
static fromEntries(entries) {
|
|
30
|
+
if (!entries.length) {
|
|
31
|
+
return throwInternalError(
|
|
32
|
+
`Unexpected attempt to create a disjoint from no entries`
|
|
33
|
+
)
|
|
34
|
+
}
|
|
35
|
+
return new Disjoint({ "[]": fromEntries(entries) })
|
|
36
|
+
}
|
|
37
|
+
get flat() {
|
|
38
|
+
return entriesOf(this.sources).flatMap(([path, disjointKinds]) =>
|
|
39
|
+
entriesOf(disjointKinds).map(([kind, disjoint]) => ({
|
|
40
|
+
path,
|
|
41
|
+
kind,
|
|
42
|
+
disjoint
|
|
43
|
+
}))
|
|
44
|
+
)
|
|
45
|
+
}
|
|
46
|
+
describeReasons() {
|
|
47
|
+
const reasons = this.flat
|
|
48
|
+
if (reasons.length === 1) {
|
|
49
|
+
const { path, disjoint } = reasons[0]
|
|
50
|
+
const pathString = JSON.parse(path).join(".")
|
|
51
|
+
return `Intersection${
|
|
52
|
+
pathString && ` at ${pathString}`
|
|
53
|
+
} of ${describeReason(disjoint.l)} and ${describeReason(
|
|
54
|
+
disjoint.r
|
|
55
|
+
)} results in an unsatisfiable type`
|
|
56
|
+
}
|
|
57
|
+
return `The following intersections result in unsatisfiable types:\n• ${reasons
|
|
58
|
+
.map(
|
|
59
|
+
({ path, disjoint }) =>
|
|
60
|
+
`${path}: ${describeReason(
|
|
61
|
+
disjoint.l
|
|
62
|
+
)} and ${describeReason(disjoint.r)}`
|
|
63
|
+
)
|
|
64
|
+
.join("\n• ")}`
|
|
65
|
+
}
|
|
66
|
+
isEmpty() {
|
|
67
|
+
return this.flat.length === 0
|
|
68
|
+
}
|
|
69
|
+
throw() {
|
|
70
|
+
return throwParseError(this.describeReasons())
|
|
71
|
+
}
|
|
72
|
+
invert() {
|
|
73
|
+
const invertedEntries = entriesOf(this.sources).map(
|
|
74
|
+
([path, disjoints]) => [
|
|
75
|
+
path,
|
|
76
|
+
flatMorph(disjoints, (kind, disjoint) => [
|
|
77
|
+
kind,
|
|
78
|
+
{ l: disjoint.r, r: disjoint.l }
|
|
79
|
+
])
|
|
80
|
+
]
|
|
81
|
+
)
|
|
82
|
+
return new Disjoint(fromEntries(invertedEntries))
|
|
83
|
+
}
|
|
84
|
+
add(input) {
|
|
85
|
+
entriesOf(input.sources).forEach(([path, disjoints]) =>
|
|
86
|
+
Object.assign(this.sources[path] ?? {}, disjoints)
|
|
87
|
+
)
|
|
88
|
+
}
|
|
89
|
+
withPrefixKey(key) {
|
|
90
|
+
const entriesWithPrefix = entriesOf(this.sources).map(
|
|
91
|
+
([path, disjoints]) => {
|
|
92
|
+
const segments = JSON.parse(path)
|
|
93
|
+
segments.unshift(key)
|
|
94
|
+
const pathWithPrefix = JSON.stringify(segments)
|
|
95
|
+
return [pathWithPrefix, disjoints]
|
|
96
|
+
}
|
|
97
|
+
)
|
|
98
|
+
return new Disjoint(fromEntries(entriesWithPrefix))
|
|
99
|
+
}
|
|
100
|
+
toString() {
|
|
101
|
+
return printable(this.sources)
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
const describeReason = (value) =>
|
|
105
|
+
hasArkKind(value, "node")
|
|
106
|
+
? value.expression
|
|
107
|
+
: isArray(value)
|
|
108
|
+
? value.map(describeReason).join(" | ")
|
|
109
|
+
: String(value)
|
|
110
|
+
//# sourceMappingURL=disjoint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"disjoint.js","sourceRoot":"","sources":["../../shared/disjoint.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,SAAS,EACT,SAAS,EACT,WAAW,EACX,OAAO,EACP,SAAS,EACT,kBAAkB,EAClB,eAAe,EAEf,MAAM,eAAe,CAAA;AAEtB,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AA+EvC,MAAM,OAAO,QAAQ;IACD;IAAnB,YAAmB,OAAyB;QAAzB,YAAO,GAAP,OAAO,CAAkB;IAAG,CAAC;IAEhD,KAAK;QACJ,OAAO,IAAI,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IAClC,CAAC;IAED,MAAM,CAAC,IAAI,CACV,IAAU,EACV,CAAqC,EACrC,CAAqC;QAErC,OAAO,IAAI,QAAQ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AA;YAC7C,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;YACrB,MAAM,cAAc,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAkB,CAAA;YAChE,OAAO,CAAC,cAAc,EAAE,SAAS,CAAC,CAAA;QACnC,CAAC,CACD,CAAA;QACD,OAAO,IAAI,QAAQ,CAAC,WAAW,CAAC,iBAAiB,CAAC,CAAC,CAAA;IACpD,CAAC;IAED,QAAQ;QACP,OAAO,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IAC/B,CAAC;CACD;AAED,MAAM,cAAc,GAAG,CAAC,KAAc,EAAU,EAAE,CACjD,UAAU,CAAC,KAAK,EAAE,MAAM,CAAC;IACxB,CAAC,CAAC,KAAK,CAAC,UAAU;IAClB,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC;QAChB,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC;QACvC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ReadonlyArray,
|
|
3
|
+
type evaluate,
|
|
4
|
+
type optionalizeKeys,
|
|
5
|
+
type propwiseXor
|
|
6
|
+
} from "@arktype/util"
|
|
7
|
+
import type { Prerequisite, errorContext } from "../kinds.js"
|
|
8
|
+
import type { NodeKind } from "./implement.js"
|
|
9
|
+
import type { TraversalContext } from "./traversal.js"
|
|
10
|
+
import { type TraversalPath } from "./utils.js"
|
|
11
|
+
export declare const throwArkError: (
|
|
12
|
+
message?: string | undefined,
|
|
13
|
+
options?: ErrorOptions | undefined
|
|
14
|
+
) => never
|
|
15
|
+
export declare class ArkError extends TypeError {
|
|
16
|
+
toString(): string
|
|
17
|
+
throw(): never
|
|
18
|
+
}
|
|
19
|
+
export type ArkTypeError<code extends ArkErrorCode = ArkErrorCode> = ArkError &
|
|
20
|
+
ArkErrorContext<code>
|
|
21
|
+
export declare const ArkTypeError: new <
|
|
22
|
+
code extends ArkErrorCode = ArkErrorCode
|
|
23
|
+
>(
|
|
24
|
+
context: ArkErrorContext<code>
|
|
25
|
+
) => ArkTypeError<code>
|
|
26
|
+
export declare class ArkErrors extends ReadonlyArray<ArkTypeError> {
|
|
27
|
+
protected ctx: TraversalContext
|
|
28
|
+
constructor(ctx: TraversalContext)
|
|
29
|
+
byPath: Record<string, ArkTypeError>
|
|
30
|
+
count: number
|
|
31
|
+
private mutable
|
|
32
|
+
add(error: ArkTypeError): void
|
|
33
|
+
get summary(): string
|
|
34
|
+
toString(): string
|
|
35
|
+
throw(): never
|
|
36
|
+
}
|
|
37
|
+
export declare const createError: (
|
|
38
|
+
ctx: TraversalContext,
|
|
39
|
+
input: ArkErrorInput
|
|
40
|
+
) => ArkTypeError
|
|
41
|
+
export interface DerivableErrorContext<data = unknown> {
|
|
42
|
+
expected: string
|
|
43
|
+
actual: string | null
|
|
44
|
+
problem: string
|
|
45
|
+
message: string
|
|
46
|
+
data: data
|
|
47
|
+
path: TraversalPath
|
|
48
|
+
propString: string
|
|
49
|
+
}
|
|
50
|
+
export type ArkErrorCode = {
|
|
51
|
+
[kind in NodeKind]: errorContext<kind> extends null ? never : kind
|
|
52
|
+
}[NodeKind]
|
|
53
|
+
export type ArkErrorContext<code extends ArkErrorCode = ArkErrorCode> =
|
|
54
|
+
errorContext<code> & DerivableErrorContext<Prerequisite<code>>
|
|
55
|
+
export type MessageContext<code extends ArkErrorCode = ArkErrorCode> = Omit<
|
|
56
|
+
ArkErrorContext<code>,
|
|
57
|
+
"message"
|
|
58
|
+
>
|
|
59
|
+
export type ProblemContext<code extends ArkErrorCode = ArkErrorCode> = Omit<
|
|
60
|
+
MessageContext<code>,
|
|
61
|
+
"problem"
|
|
62
|
+
>
|
|
63
|
+
type ErrorInputByCode = {
|
|
64
|
+
[code in ArkErrorCode]: optionalizeKeys<
|
|
65
|
+
ArkErrorContext<code>,
|
|
66
|
+
keyof DerivableErrorContext
|
|
67
|
+
>
|
|
68
|
+
}
|
|
69
|
+
export type CustomErrorInput = evaluate<
|
|
70
|
+
{
|
|
71
|
+
code?: undefined
|
|
72
|
+
} & Partial<DerivableErrorContext>
|
|
73
|
+
>
|
|
74
|
+
export type ArkErrorInput =
|
|
75
|
+
| string
|
|
76
|
+
| ErrorInputByCode[ArkErrorCode]
|
|
77
|
+
| CustomErrorInput
|
|
78
|
+
export type ProblemWriter<code extends ArkErrorCode = ArkErrorCode> = (
|
|
79
|
+
context: ProblemContext<code>
|
|
80
|
+
) => string
|
|
81
|
+
export type MessageWriter<code extends ArkErrorCode = ArkErrorCode> = (
|
|
82
|
+
context: MessageContext<code>
|
|
83
|
+
) => string
|
|
84
|
+
export type getAssociatedDataForError<code extends ArkErrorCode> =
|
|
85
|
+
code extends NodeKind ? Prerequisite<code> : unknown
|
|
86
|
+
export type ExpectedWriter<code extends ArkErrorCode = ArkErrorCode> = (
|
|
87
|
+
source: errorContext<code>
|
|
88
|
+
) => string
|
|
89
|
+
export type ActualWriter<code extends ArkErrorCode = ArkErrorCode> = (
|
|
90
|
+
data: getAssociatedDataForError<code>
|
|
91
|
+
) => string | null
|
|
92
|
+
export type ArkResult<data = unknown, out = data> = propwiseXor<{
|
|
93
|
+
data: data;
|
|
94
|
+
out: out;
|
|
95
|
+
}, {
|
|
96
|
+
errors: ArkErrors;
|
|
97
|
+
}>;
|
|
98
|
+
export {}
|
|
99
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../shared/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,aAAa,EAEb,KAAK,QAAQ,EACb,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,MAAM,eAAe,CAAA;AACtB,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE7D,OAAO,KAAK,EAAE,QAAQ,EAAE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AS,QAAQ,GAAG,YAAY,CAAC,IAAI,CAAC,GAAG,OAAO,CAAA;AAErD,MAAM,MAAM,cAAc,CAAC,IAAI,SAAS,YAAY,GAAG,YAAY,IAAI,CACtE,MAAM,EAAE,YAAY,CAAC,IAAI,CAAC,KACtB,MAAM,CAAA;AAEX,MAAM,MAAM,YAAY,CAAC,IAAI,SAAS,YAAY,GAAG,YAAY,IAAI,CACpE,IAAI,EAAE,yBAAyB,CAAC,IAAI,CAAC,KACjC,MAAM,GAAG,IAAI,CAAA;AAElB,MAAM,MAAM,SAAS,CAAC,IAAI,GAAG,OAAO,EAAE,GAAG,GAAG,IAAI,IAAI,WAAW,CAC9D;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,GAAG,EAAE,GAAG,CAAA;CAAE,EACxB;IAAE,MAAM,EAAE,SAAS,CAAA;CAAE,CACrB,CAAA"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { ReadonlyArray, hasDefinedKey } from "@arktype/util"
|
|
2
|
+
import { arkKind } from "../util.js"
|
|
3
|
+
import { pathToPropString } from "./utils.js"
|
|
4
|
+
export const throwArkError = (...args) => {
|
|
5
|
+
throw new ArkError(...args)
|
|
6
|
+
}
|
|
7
|
+
export class ArkError extends TypeError {
|
|
8
|
+
toString() {
|
|
9
|
+
return this.message
|
|
10
|
+
}
|
|
11
|
+
throw() {
|
|
12
|
+
throw this
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export const ArkTypeError = class extends ArkError {
|
|
16
|
+
[arkKind] = "error"
|
|
17
|
+
constructor(context) {
|
|
18
|
+
super(context.message)
|
|
19
|
+
Object.assign(this, context)
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export class ArkErrors extends ReadonlyArray {
|
|
23
|
+
ctx
|
|
24
|
+
constructor(ctx) {
|
|
25
|
+
super()
|
|
26
|
+
this.ctx = ctx
|
|
27
|
+
}
|
|
28
|
+
byPath = {}
|
|
29
|
+
count = 0
|
|
30
|
+
mutable = this
|
|
31
|
+
add(error) {
|
|
32
|
+
const pathKey = error.path.join(".")
|
|
33
|
+
const existing = this.byPath[pathKey]
|
|
34
|
+
if (existing) {
|
|
35
|
+
const errorIntersection = createError(this.ctx, {
|
|
36
|
+
code: "intersection",
|
|
37
|
+
errors:
|
|
38
|
+
existing.code === "intersection"
|
|
39
|
+
? [...existing.errors, error]
|
|
40
|
+
: [existing, error]
|
|
41
|
+
})
|
|
42
|
+
const existingIndex = this.indexOf(existing)
|
|
43
|
+
// If existing is found (which it always should be unless this was externally mutated),
|
|
44
|
+
// replace it with the new problem intersection. In case it isn't for whatever reason,
|
|
45
|
+
// just append the intersection.
|
|
46
|
+
this.mutable[existingIndex === -1 ? this.length : existingIndex] =
|
|
47
|
+
errorIntersection
|
|
48
|
+
this.byPath[pathKey] = errorIntersection
|
|
49
|
+
} else {
|
|
50
|
+
this.byPath[pathKey] = error
|
|
51
|
+
this.mutable.push(error)
|
|
52
|
+
}
|
|
53
|
+
this.count++
|
|
54
|
+
}
|
|
55
|
+
get summary() {
|
|
56
|
+
return this.toString()
|
|
57
|
+
}
|
|
58
|
+
toString() {
|
|
59
|
+
return this.join("\n")
|
|
60
|
+
}
|
|
61
|
+
throw() {
|
|
62
|
+
throw new ArkError(`${this}`, { cause: this })
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
export const createError = (ctx, input) => {
|
|
66
|
+
let errCtx
|
|
67
|
+
const data = ctx.data
|
|
68
|
+
const nodeConfig = ctx.config.predicate
|
|
69
|
+
if (typeof input === "string") {
|
|
70
|
+
errCtx = {
|
|
71
|
+
code: "predicate",
|
|
72
|
+
path: [...ctx.path],
|
|
73
|
+
propString: pathToPropString(ctx.path),
|
|
74
|
+
data,
|
|
75
|
+
actual: nodeConfig.actual(data),
|
|
76
|
+
expected: input
|
|
77
|
+
}
|
|
78
|
+
errCtx.problem = nodeConfig.problem(errCtx)
|
|
79
|
+
errCtx.message = nodeConfig.message(errCtx)
|
|
80
|
+
} else {
|
|
81
|
+
const code = input.code ?? "predicate"
|
|
82
|
+
const nodeConfig = ctx.config[code]
|
|
83
|
+
const expected = input.expected ?? nodeConfig.expected?.(input)
|
|
84
|
+
const path = input.path ?? [...ctx.path]
|
|
85
|
+
errCtx = {
|
|
86
|
+
...input,
|
|
87
|
+
// prioritize these over the raw user provided values so we can
|
|
88
|
+
// check for keys with values like undefined
|
|
89
|
+
code,
|
|
90
|
+
path,
|
|
91
|
+
propString: pathToPropString(path),
|
|
92
|
+
data: "data" in input ? input.data : data,
|
|
93
|
+
actual:
|
|
94
|
+
input.actual !== undefined
|
|
95
|
+
? input.actual
|
|
96
|
+
: nodeConfig.actual?.(data),
|
|
97
|
+
expected
|
|
98
|
+
}
|
|
99
|
+
errCtx.problem = hasDefinedKey(input, "problem")
|
|
100
|
+
? input.problem
|
|
101
|
+
: nodeConfig.problem(errCtx)
|
|
102
|
+
errCtx.message = hasDefinedKey(input, "message")
|
|
103
|
+
? input.message
|
|
104
|
+
: nodeConfig.message(errCtx)
|
|
105
|
+
}
|
|
106
|
+
return new ArkTypeError(errCtx)
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../shared/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,aAAa,EACb,aAAa,EAIb,MAAM,eAAe,CAAA;AAEtB,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAGpC,OAAO,EAAE,gBAAgB,EAAsB,MAAM,YAAY,CAAA;AAEjE,MAAM,CAAC,MAAM,aAAa,GAAG,CAC5B,GAAG,IAA4C,EACvC,EAAE;IACV,MAAM,IAAI,QAAQ,CAAC,GAAG,IAAI,CAAC,CAAA;AAC5B,CAAC,CAAA;AAED,MAAM,OAAO,QAAS,SAAQ,SAAS;IACtC,QAAQ;QACP,OAAO,IAAI,CAAC,OAAO,CAAA;IACpB,CAAC;IAED,KAAK;QAC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