arktype 2.0.0-dev.3 → 2.0.0-dev.5
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 +123 -215
- package/__tests__/badDefinitionType.test.ts +2 -2
- package/__tests__/bounds.test.ts +448 -349
- package/__tests__/config.test.ts +8 -6
- package/__tests__/cyclic.test.ts +1 -1
- package/__tests__/dateLiteral.test.ts +2 -2
- package/__tests__/discrimination.test.ts +1 -1
- package/__tests__/divisor.test.ts +23 -19
- package/__tests__/enclosed.test.ts +7 -2
- package/__tests__/errors.test.ts +115 -0
- package/__tests__/expressions.test.ts +14 -20
- package/__tests__/generic.test.ts +4 -5
- package/__tests__/group.test.ts +8 -3
- package/__tests__/instanceof.test.ts +7 -7
- package/__tests__/intersection.test.ts +62 -38
- package/__tests__/keyTraversal.test.ts +0 -2
- package/__tests__/keyof.test.ts +15 -13
- package/__tests__/keywords.test.ts +29 -25
- package/__tests__/literal.test.ts +26 -8
- package/__tests__/match.test.ts +28 -16
- package/__tests__/morph.test.ts +187 -172
- package/__tests__/narrow.test.ts +38 -39
- package/__tests__/objectLiteral.test.ts +106 -76
- package/__tests__/realWorld.test.ts +62 -0
- package/__tests__/schema.bench.ts +14 -0
- package/__tests__/schema.test.ts +60 -0
- package/__tests__/scope.bench.ts +1 -1
- package/__tests__/scope.test.ts +8 -6
- package/__tests__/submodule.test.ts +2 -2
- package/__tests__/traverse.test.ts +34 -31
- package/__tests__/typeMethods.test.ts +2 -3
- package/__tests__/typeReference.test.ts +3 -3
- package/__tests__/unenclosed.test.ts +9 -3
- package/__tests__/union.test.ts +127 -55
- package/__tests__/unit.test.ts +61 -0
- package/base.ts +520 -0
- package/config.ts +25 -0
- package/constraints/ast.ts +288 -0
- package/constraints/constraint.ts +91 -0
- package/constraints/predicate.ts +102 -0
- package/constraints/props/index.ts +93 -0
- package/constraints/props/prop.ts +146 -0
- package/constraints/props/props.ts +148 -0
- package/constraints/props/sequence.ts +473 -0
- package/constraints/props/shared.ts +5 -0
- package/constraints/refinements/after.ts +68 -0
- package/constraints/refinements/before.ts +75 -0
- package/constraints/refinements/divisor.ts +76 -0
- package/constraints/refinements/exactLength.ts +75 -0
- package/constraints/refinements/kinds.ts +31 -0
- package/constraints/refinements/max.ts +61 -0
- package/constraints/refinements/maxLength.ts +66 -0
- package/constraints/refinements/min.ts +54 -0
- package/constraints/refinements/minLength.ts +63 -0
- package/constraints/refinements/range.ts +181 -0
- package/constraints/refinements/regex.ts +59 -0
- package/{ark.ts → keywords/ark.ts} +40 -30
- package/keywords/internal.ts +29 -0
- package/keywords/jsObject.ts +39 -0
- package/keywords/parsing.ts +87 -0
- package/keywords/root.ts +9 -0
- package/keywords/tsGenerics.ts +28 -0
- package/keywords/tsPrimitive.ts +52 -0
- package/keywords/utils/creditCard.ts +37 -0
- package/keywords/utils/date.ts +112 -0
- package/keywords/validation.ts +115 -0
- package/kinds.ts +115 -0
- package/main.ts +7 -8
- package/match.ts +30 -34
- package/out/ark.d.ts +5 -1
- package/out/ark.d.ts.map +1 -1
- package/out/ark.js +4 -1
- package/out/ark.js.map +1 -1
- package/out/base.d.ts +129 -0
- package/out/base.d.ts.map +1 -0
- package/out/base.js +274 -0
- package/out/base.js.map +1 -0
- package/out/builtins/builtins.d.ts +19 -0
- package/out/builtins/builtins.d.ts.map +1 -0
- package/out/builtins/builtins.js +12 -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 +15 -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 +59 -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 +20 -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 +36 -0
- package/out/builtins/utils/creditCard.js.map +1 -0
- package/out/builtins/utils/date.d.ts +22 -0
- package/out/builtins/utils/date.d.ts.map +1 -0
- package/out/builtins/utils/date.js +53 -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 +70 -0
- package/out/builtins/validation.js.map +1 -0
- package/out/config.d.ts +6 -0
- package/out/config.d.ts.map +1 -0
- package/out/config.js +17 -0
- package/out/config.js.map +1 -0
- package/out/constraints/ast.d.ts +176 -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 +70 -0
- package/out/constraints/constraint.d.ts.map +1 -0
- package/out/constraints/constraint.js +21 -0
- package/out/constraints/constraint.js.map +1 -0
- package/out/constraints/predicate.d.ts +46 -0
- package/out/constraints/predicate.d.ts.map +1 -0
- package/out/constraints/predicate.js +47 -0
- package/out/constraints/predicate.js.map +1 -0
- package/out/constraints/props/index.d.ts +36 -0
- package/out/constraints/props/index.d.ts.map +1 -0
- package/out/constraints/props/index.js +48 -0
- package/out/constraints/props/index.js.map +1 -0
- package/out/constraints/props/optional.d.ts +34 -0
- package/out/constraints/props/optional.d.ts.map +1 -0
- package/out/constraints/props/optional.js +55 -0
- package/out/constraints/props/optional.js.map +1 -0
- package/out/constraints/props/prop.d.ts +46 -0
- package/out/constraints/props/prop.d.ts.map +1 -0
- package/out/constraints/props/prop.js +104 -0
- package/out/constraints/props/prop.js.map +1 -0
- package/out/constraints/props/props.d.ts +34 -0
- package/out/constraints/props/props.d.ts.map +1 -0
- package/out/constraints/props/props.js +106 -0
- package/out/constraints/props/props.js.map +1 -0
- package/out/constraints/props/required.d.ts +43 -0
- package/out/constraints/props/required.d.ts.map +1 -0
- package/out/constraints/props/required.js +76 -0
- package/out/constraints/props/required.js.map +1 -0
- package/out/constraints/props/sequence.d.ts +64 -0
- package/out/constraints/props/sequence.d.ts.map +1 -0
- package/out/constraints/props/sequence.js +327 -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 +25 -0
- package/out/constraints/refinements/after.d.ts.map +1 -0
- package/out/constraints/refinements/after.js +35 -0
- package/out/constraints/refinements/after.js.map +1 -0
- package/out/constraints/refinements/before.d.ts +25 -0
- package/out/constraints/refinements/before.d.ts.map +1 -0
- package/out/constraints/refinements/before.js +41 -0
- package/out/constraints/refinements/before.js.map +1 -0
- package/out/constraints/refinements/divisor.d.ts +42 -0
- package/out/constraints/refinements/divisor.d.ts.map +1 -0
- package/out/constraints/refinements/divisor.js +41 -0
- package/out/constraints/refinements/divisor.js.map +1 -0
- package/out/constraints/refinements/exactLength.d.ts +41 -0
- package/out/constraints/refinements/exactLength.d.ts.map +1 -0
- package/out/constraints/refinements/exactLength.js +44 -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 +42 -0
- package/out/constraints/refinements/length.d.ts.map +1 -0
- package/out/constraints/refinements/length.js +45 -0
- package/out/constraints/refinements/length.js.map +1 -0
- package/out/constraints/refinements/max.d.ts +24 -0
- package/out/constraints/refinements/max.d.ts.map +1 -0
- package/out/constraints/refinements/max.js +31 -0
- package/out/constraints/refinements/max.js.map +1 -0
- package/out/constraints/refinements/maxLength.d.ts +24 -0
- package/out/constraints/refinements/maxLength.d.ts.map +1 -0
- package/out/constraints/refinements/maxLength.js +34 -0
- package/out/constraints/refinements/maxLength.js.map +1 -0
- package/out/constraints/refinements/min.d.ts +24 -0
- package/out/constraints/refinements/min.d.ts.map +1 -0
- package/out/constraints/refinements/min.js +25 -0
- package/out/constraints/refinements/min.js.map +1 -0
- package/out/constraints/refinements/minLength.d.ts +24 -0
- package/out/constraints/refinements/minLength.d.ts.map +1 -0
- package/out/constraints/refinements/minLength.js +32 -0
- package/out/constraints/refinements/minLength.js.map +1 -0
- package/out/constraints/refinements/range.d.ts +90 -0
- package/out/constraints/refinements/range.d.ts.map +1 -0
- package/out/constraints/refinements/range.js +72 -0
- package/out/constraints/refinements/range.js.map +1 -0
- package/out/constraints/refinements/regex.d.ts +43 -0
- package/out/constraints/refinements/regex.d.ts.map +1 -0
- package/out/constraints/refinements/regex.js +36 -0
- package/out/constraints/refinements/regex.js.map +1 -0
- package/out/constraints/refinements/shared.d.ts +5 -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/inference.d.ts +40 -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 +60 -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 +10 -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 +15 -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 +61 -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 +22 -0
- package/out/keywords/tsPrimitive.js.map +1 -0
- package/out/keywords/utils/creditCard.d.ts +8 -0
- package/out/keywords/utils/creditCard.d.ts.map +1 -0
- package/out/keywords/utils/creditCard.js +36 -0
- package/out/keywords/utils/creditCard.js.map +1 -0
- package/out/keywords/utils/date.d.ts +25 -0
- package/out/keywords/utils/date.d.ts.map +1 -0
- package/out/keywords/utils/date.js +53 -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 +76 -0
- package/out/keywords/validation.js.map +1 -0
- package/out/kinds.d.ts +72 -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 +5 -4
- package/out/main.d.ts.map +1 -1
- package/out/main.js +2 -3
- package/out/main.js.map +1 -1
- package/out/match.d.ts +17 -18
- package/out/match.d.ts.map +1 -1
- package/out/match.js +3 -4
- package/out/match.js.map +1 -1
- package/out/parse.d.ts +23 -0
- package/out/parse.d.ts.map +1 -0
- package/out/parse.js +148 -0
- package/out/parse.js.map +1 -0
- package/out/parser/definition.d.ts +8 -9
- package/out/parser/definition.d.ts.map +1 -1
- package/out/parser/definition.js +8 -9
- package/out/parser/definition.js.map +1 -1
- package/out/parser/objectLiteral.d.ts +44 -11
- package/out/parser/objectLiteral.d.ts.map +1 -1
- package/out/parser/objectLiteral.js +47 -35
- package/out/parser/objectLiteral.js.map +1 -1
- package/out/parser/semantic/bounds.d.ts +8 -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 +4 -6
- package/out/parser/semantic/divisor.d.ts.map +1 -1
- package/out/parser/semantic/infer.d.ts +28 -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 +1 -1
- package/out/parser/semantic/validate.d.ts.map +1 -1
- package/out/parser/semantic/validate.js.map +1 -1
- package/out/parser/string/reduce/dynamic.d.ts +13 -11
- package/out/parser/string/reduce/dynamic.d.ts.map +1 -1
- package/out/parser/string/reduce/dynamic.js +15 -9
- package/out/parser/string/reduce/dynamic.js.map +1 -1
- package/out/parser/string/reduce/shared.d.ts +2 -3
- 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 +20 -19
- package/out/parser/string/reduce/static.d.ts.map +1 -1
- package/out/parser/string/shift/operand/date.d.ts +3 -2
- package/out/parser/string/shift/operand/date.d.ts.map +1 -1
- package/out/parser/string/shift/operand/date.js.map +1 -1
- package/out/parser/string/shift/operand/enclosed.d.ts +1 -1
- 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 +4 -4
- package/out/parser/string/shift/operand/genericArgs.d.ts.map +1 -1
- package/out/parser/string/shift/operand/genericArgs.js.map +1 -1
- package/out/parser/string/shift/operand/operand.d.ts +2 -2
- package/out/parser/string/shift/operand/operand.d.ts.map +1 -1
- package/out/parser/string/shift/operand/operand.js.map +1 -1
- package/out/parser/string/shift/operand/unenclosed.d.ts +5 -6
- package/out/parser/string/shift/operand/unenclosed.d.ts.map +1 -1
- package/out/parser/string/shift/operand/unenclosed.js +5 -5
- package/out/parser/string/shift/operand/unenclosed.js.map +1 -1
- package/out/parser/string/shift/operator/bounds.d.ts +17 -12
- package/out/parser/string/shift/operator/bounds.d.ts.map +1 -1
- package/out/parser/string/shift/operator/bounds.js +28 -25
- package/out/parser/string/shift/operator/bounds.js.map +1 -1
- package/out/parser/string/shift/operator/divisor.d.ts +1 -1
- 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/scanner.d.ts.map +1 -1
- package/out/parser/string/string.d.ts +3 -3
- 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 +95 -33
- package/out/parser/tuple.d.ts.map +1 -1
- package/out/parser/tuple.js +45 -48
- package/out/parser/tuple.js.map +1 -1
- package/out/schema.d.ts +44 -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 +110 -0
- package/out/schemaScope.d.ts.map +1 -0
- package/out/schemaScope.js +212 -0
- package/out/schemaScope.js.map +1 -0
- package/out/scope.d.ts +98 -26
- package/out/scope.d.ts.map +1 -1
- package/out/scope.js +185 -45
- 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 +67 -0
- package/out/shared/compile.js.map +1 -0
- package/out/shared/context.d.ts +29 -0
- package/out/shared/context.d.ts.map +1 -0
- package/out/shared/context.js +48 -0
- package/out/shared/context.js.map +1 -0
- package/out/shared/declare.d.ts +53 -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 +79 -0
- package/out/shared/disjoint.d.ts.map +1 -0
- package/out/shared/disjoint.js +82 -0
- package/out/shared/disjoint.js.map +1 -0
- package/out/shared/errors.d.ts +59 -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 +170 -0
- package/out/shared/implement.d.ts.map +1 -0
- package/out/shared/implement.js +69 -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 +15 -0
- package/out/shared/intersections.d.ts.map +1 -0
- package/out/shared/intersections.js.map +1 -0
- package/out/shared/traversal.d.ts +44 -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 +8 -0
- package/out/shared/utils.d.ts.map +1 -0
- package/out/shared/utils.js +10 -0
- package/out/shared/utils.js.map +1 -0
- package/out/type.d.ts +10 -38
- package/out/type.d.ts.map +1 -1
- package/out/type.js +20 -106
- package/out/type.js.map +1 -1
- package/out/types/basis.d.ts +24 -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 +20 -0
- package/out/types/discriminate.d.ts.map +1 -0
- package/out/types/discriminate.js +114 -0
- package/out/types/discriminate.js.map +1 -0
- package/out/types/domain.d.ts +40 -0
- package/out/types/domain.d.ts.map +1 -0
- package/out/types/domain.js +38 -0
- package/out/types/domain.js.map +1 -0
- package/out/types/intersection.d.ts +67 -0
- package/out/types/intersection.d.ts.map +1 -0
- package/out/types/intersection.js +350 -0
- package/out/types/intersection.js.map +1 -0
- package/out/types/morph.d.ts +79 -0
- package/out/types/morph.d.ts.map +1 -0
- package/out/types/morph.js +95 -0
- package/out/types/morph.js.map +1 -0
- package/out/types/proto.d.ts +42 -0
- package/out/types/proto.d.ts.map +1 -0
- package/out/types/proto.js +48 -0
- package/out/types/proto.js.map +1 -0
- package/out/types/type.d.ts +61 -0
- package/out/types/type.d.ts.map +1 -0
- package/out/types/type.js +111 -0
- package/out/types/type.js.map +1 -0
- package/out/types/union.d.ts +48 -0
- package/out/types/union.d.ts.map +1 -0
- package/out/types/union.js +337 -0
- package/out/types/union.js.map +1 -0
- package/out/types/unit.d.ts +40 -0
- package/out/types/unit.d.ts.map +1 -0
- package/out/types/unit.js +48 -0
- package/out/types/unit.js.map +1 -0
- package/out/util.d.ts +5 -2
- package/out/util.d.ts.map +1 -1
- package/out/util.js.map +1 -1
- package/package.json +6 -3
- package/parse.ts +221 -0
- package/parser/definition.ts +24 -23
- package/parser/objectLiteral.ts +128 -88
- package/parser/semantic/bounds.ts +18 -9
- package/parser/semantic/divisor.ts +12 -10
- package/parser/semantic/infer.ts +152 -0
- package/parser/semantic/utils.ts +5 -13
- package/parser/semantic/validate.ts +1 -2
- package/parser/string/reduce/dynamic.ts +42 -30
- package/parser/string/reduce/shared.ts +1 -3
- package/parser/string/reduce/static.ts +22 -22
- package/parser/string/shift/operand/date.ts +9 -5
- package/parser/string/shift/operand/enclosed.ts +11 -5
- package/parser/string/shift/operand/genericArgs.ts +6 -6
- package/parser/string/shift/operand/operand.ts +1 -2
- package/parser/string/shift/operand/unenclosed.ts +14 -20
- package/parser/string/shift/operator/bounds.ts +59 -54
- package/parser/string/shift/operator/divisor.ts +2 -2
- package/parser/string/shift/scanner.ts +10 -10
- package/parser/string/string.ts +4 -4
- package/parser/tuple.ts +224 -202
- package/schema.ts +263 -0
- package/scope.ts +358 -81
- package/shared/compile.ts +92 -0
- package/shared/declare.ts +75 -0
- package/shared/disjoint.ts +203 -0
- package/shared/errors.ts +204 -0
- package/shared/implement.ts +327 -0
- package/shared/inference.ts +9 -0
- package/shared/intersections.ts +53 -0
- package/shared/traversal.ts +146 -0
- package/shared/utils.ts +30 -0
- package/type.ts +23 -183
- package/types/basis.ts +62 -0
- package/types/discriminate.ts +168 -0
- package/types/domain.ts +79 -0
- package/types/intersection.ts +539 -0
- package/types/morph.ts +263 -0
- package/types/proto.ts +89 -0
- package/types/type.ts +319 -0
- package/types/union.ts +451 -0
- package/types/unit.ts +78 -0
- package/util.ts +5 -2
- package/__tests__/astUtils.test.ts +0 -17
- package/__tests__/jsdoc.test.ts +0 -64
- package/__tests__/nodeDefinitions.test.ts +0 -190
- 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.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/out/{parser/semantic → shared}/intersections.js +0 -0
package/match.ts
CHANGED
|
@@ -1,21 +1,18 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
AnonymousConstraintKey,
|
|
3
|
-
Morph,
|
|
4
|
-
distill,
|
|
5
|
-
intersectConstrainables,
|
|
6
|
-
is
|
|
7
|
-
} from "@arktype/schema"
|
|
8
1
|
import type {
|
|
9
2
|
ErrorMessage,
|
|
10
3
|
UnknownUnion,
|
|
11
4
|
isDisjoint,
|
|
12
5
|
numericStringKeyOf,
|
|
13
|
-
|
|
6
|
+
override,
|
|
14
7
|
unionToTuple,
|
|
15
8
|
valueOf
|
|
16
9
|
} from "@arktype/util"
|
|
10
|
+
import type { Narrowed } from "./constraints/ast.js"
|
|
17
11
|
import type { Scope } from "./scope.js"
|
|
18
|
-
import
|
|
12
|
+
import type { inferIntersection } from "./shared/intersections.js"
|
|
13
|
+
import type { inferTypeRoot, validateTypeRoot } from "./type.js"
|
|
14
|
+
import type { Morph, distillOut } from "./types/morph.js"
|
|
15
|
+
import type { Type } from "./types/type.js"
|
|
19
16
|
|
|
20
17
|
type MatchParserContext = {
|
|
21
18
|
thens: readonly ((In: unknown) => unknown)[]
|
|
@@ -46,22 +43,25 @@ type matcherInputs<ctx extends MatchParserContext> = Parameters<
|
|
|
46
43
|
ctx["thens"][number]
|
|
47
44
|
>[0]
|
|
48
45
|
|
|
49
|
-
type AnonymouslyRefined = {
|
|
50
|
-
[k in AnonymousConstraintKey]: { [_ in k]: true }
|
|
51
|
-
}[AnonymousConstraintKey]
|
|
52
|
-
|
|
53
46
|
type getHandledBranches<ctx extends MatchParserContext> = Exclude<
|
|
54
47
|
matcherInputs<ctx>,
|
|
55
|
-
|
|
48
|
+
// TODO: add other anon
|
|
49
|
+
Narrowed
|
|
56
50
|
>
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
51
|
+
|
|
52
|
+
type getUnhandledBranches<ctx extends MatchParserContext> = distillOut<
|
|
53
|
+
Exclude<
|
|
54
|
+
unknown extends ctx["exhaustiveOver"]
|
|
55
|
+
? UnknownUnion
|
|
56
|
+
: ctx["exhaustiveOver"],
|
|
57
|
+
getHandledBranches<ctx>
|
|
58
|
+
>
|
|
60
59
|
>
|
|
60
|
+
|
|
61
61
|
type addBranches<
|
|
62
62
|
ctx extends MatchParserContext,
|
|
63
63
|
branches extends unknown[]
|
|
64
|
-
> =
|
|
64
|
+
> = override<ctx, { thens: [...ctx["thens"], ...branches] }>
|
|
65
65
|
|
|
66
66
|
type validateWhenDefinition<
|
|
67
67
|
def,
|
|
@@ -74,19 +74,15 @@ type validateWhenDefinition<
|
|
|
74
74
|
|
|
75
75
|
// infer the types handled by a match branch, which is identical to `inferTypeRoot` while properly
|
|
76
76
|
// excluding cases that are already handled by other branches
|
|
77
|
-
type inferMatchBranch<
|
|
78
|
-
def,
|
|
79
|
-
ctx extends MatchParserContext
|
|
80
|
-
> = intersectConstrainables<
|
|
81
|
-
getUnhandledBranches<ctx>,
|
|
82
|
-
inferTypeRoot<def, ctx["$"]>
|
|
77
|
+
type inferMatchBranch<def, ctx extends MatchParserContext> = distillOut<
|
|
78
|
+
inferIntersection<getUnhandledBranches<ctx>, inferTypeRoot<def, ctx["$"]>>
|
|
83
79
|
>
|
|
84
80
|
|
|
85
81
|
export type ChainableMatchParser<ctx extends MatchParserContext> = {
|
|
86
82
|
// chainable methods
|
|
87
83
|
when: <def, ret>(
|
|
88
84
|
when: validateWhenDefinition<def, ctx>,
|
|
89
|
-
then: (In:
|
|
85
|
+
then: (In: inferMatchBranch<def, ctx>) => ret
|
|
90
86
|
) => ChainableMatchParser<
|
|
91
87
|
addBranches<ctx, [(In: inferMatchBranch<def, ctx>) => ret]>
|
|
92
88
|
>
|
|
@@ -113,24 +109,24 @@ type MatchParserDefaultInvocation<ctx extends MatchParserContext> = {
|
|
|
113
109
|
|
|
114
110
|
type validateCases<cases, ctx extends MatchParserContext> = {
|
|
115
111
|
[def in keyof cases | keyof ctx["$"] | "default"]?: def extends "default"
|
|
116
|
-
? (In:
|
|
112
|
+
? (In: getUnhandledBranches<ctx>) => unknown
|
|
117
113
|
: def extends validateWhenDefinition<def, ctx>
|
|
118
|
-
? (In:
|
|
114
|
+
? (In: inferMatchBranch<def, ctx>) => unknown
|
|
119
115
|
: validateWhenDefinition<def, ctx>
|
|
120
116
|
}
|
|
121
117
|
|
|
122
118
|
type errorCases<cases, ctx extends MatchParserContext> = {
|
|
123
119
|
[def in keyof cases]?: def extends "default"
|
|
124
|
-
? (In:
|
|
120
|
+
? (In: getUnhandledBranches<ctx>) => unknown
|
|
125
121
|
: def extends validateWhenDefinition<def, ctx>
|
|
126
|
-
? (In:
|
|
122
|
+
? (In: inferMatchBranch<def, ctx>) => unknown
|
|
127
123
|
: validateWhenDefinition<def, ctx>
|
|
128
124
|
} & {
|
|
129
125
|
[k in Exclude<keyof ctx["$"], keyof cases>]?: (
|
|
130
|
-
In:
|
|
126
|
+
In: distillOut<inferIntersection<getUnhandledBranches<ctx>, ctx["$"][k]>>
|
|
131
127
|
) => unknown
|
|
132
128
|
} & {
|
|
133
|
-
default?: (In:
|
|
129
|
+
default?: (In: getUnhandledBranches<ctx>) => unknown
|
|
134
130
|
}
|
|
135
131
|
|
|
136
132
|
export type CaseMatchParser<ctx extends MatchParserContext> = {
|
|
@@ -176,14 +172,14 @@ export type MatchInvocation<ctx extends MatchInvocationContext> = <
|
|
|
176
172
|
: ReturnType<ctx["thens"][i]>
|
|
177
173
|
}[numericStringKeyOf<ctx["thens"]>]
|
|
178
174
|
|
|
179
|
-
export const createMatchParser = <$>(
|
|
175
|
+
export const createMatchParser = <$>($: Scope): MatchParser<$> => {
|
|
180
176
|
const matchParser = (isRestricted: boolean) => {
|
|
181
177
|
const handledCases: { when: Type; then: Morph }[] = []
|
|
182
178
|
let defaultCase: ((x: unknown) => unknown) | null = null
|
|
183
179
|
|
|
184
180
|
const parser = {
|
|
185
181
|
when: (when: unknown, then: Morph) => {
|
|
186
|
-
handledCases.push({ when:
|
|
182
|
+
handledCases.push({ when: $.parseTypeRoot(when, {}), then })
|
|
187
183
|
|
|
188
184
|
return parser
|
|
189
185
|
},
|
|
@@ -203,7 +199,7 @@ export const createMatchParser = <$>(scope: Scope): MatchParser<$> => {
|
|
|
203
199
|
// return [{ in: when.root, morph: then }]
|
|
204
200
|
// })
|
|
205
201
|
// if (defaultCase) {
|
|
206
|
-
// branches.push({ in: new Type("unknown",
|
|
202
|
+
// branches.push({ in: new Type("unknown", $), morph: defaultCase })
|
|
207
203
|
// }
|
|
208
204
|
// const matchers = schema.union({
|
|
209
205
|
// branches,
|
package/out/ark.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import { JsObjects
|
|
1
|
+
import { JsObjects } from "./builtins/jsObjects.js";
|
|
2
|
+
import { Parsing } from "./builtins/parsing.js";
|
|
3
|
+
import { TsKeywords } from "./builtins/tsKeywords.js";
|
|
4
|
+
import { Validation } from "./builtins/validation.js";
|
|
2
5
|
import type { MatchParser } from "./match.js";
|
|
3
6
|
import { Scope, type Module, type ScopeParser } from "./scope.js";
|
|
7
|
+
import type { inferred } from "./shared/inference.js";
|
|
4
8
|
import type { DeclarationParser, DefinitionParser, Generic, TypeParser } from "./type.js";
|
|
5
9
|
/** Root scopes can be inferred automatically from node definitions, but
|
|
6
10
|
* explicitly typing them can improve responsiveness */
|
package/out/ark.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ark.d.ts","sourceRoot":"","sources":["../ark.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"ark.d.ts","sourceRoot":"","sources":["../ark.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAA;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAC7C,OAAO,EAAE,KAAK,EAAE,KAAK,MAAM,EAAE,KAAK,WAAW,EAAE,MAAM,YAAY,CAAA;AACjE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AACrD,OAAO,KAAK,EACX,iBAAiB,EACjB,gBAAgB,EAChB,OAAO,EACP,UAAU,EACV,MAAM,WAAW,CAAA;AAElB;uDACuD;AACvD,MAAM,MAAM,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AAY,CAAA;AAG7C,eAAO,MAAM,KAAK,EAAE,WAAW,CAAC,GAAG,CAAsB,CAAA;AAEzD,yBAAiB,IAAI,CAAC;IACrB,KAAY,IAAI,CAAC,EAAE,IAAI;QACtB,CAAC,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAA;KACf,CAAA;CACD;AAED,eAAO,MAAM,MAAM,EAAE,gBAAgB,CAAC,GAAG,CAAc,CAAA;AAEvD,eAAO,MAAM,OAAO,EAAE,iBAAiB,CAAC,GAAG,CAAe,CAAA"}
|
package/out/ark.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import { JsObjects
|
|
1
|
+
import { JsObjects } from "./builtins/jsObjects.js";
|
|
2
|
+
import { Parsing } from "./builtins/parsing.js";
|
|
3
|
+
import { TsKeywords } from "./builtins/tsKeywords.js";
|
|
4
|
+
import { Validation } from "./builtins/validation.js";
|
|
2
5
|
import { Scope } from "./scope.js";
|
|
3
6
|
export const tsGenerics = {};
|
|
4
7
|
export const ark = Scope.root({
|
package/out/ark.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ark.js","sourceRoot":"","sources":["../ark.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"ark.js","sourceRoot":"","sources":["../ark.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAA;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAErD,OAAO,EAAE,KAAK,EAAiC,MAAM,YAAY,CAAA;AA6CjE,MAAM,CAAC,MAAM,UAAU,GAAG,EAAmC,CAAA;AAE7D,MAAM,CAAC,MAAM,GAAG,GAA0B,KAAK,CAAC,IAAI,CAAC;IACpD,GAAG,UAAU,CAAC,WAAW;IACzB,GAAG,SAAS,CAAC,WAAW;IACxB,GAAG,UAAU,CAAC,WAAW;IACzB,YAAY;IACZ,GAAG,UAAU;IACb,KAAK,EAAE,OAAO,CAAC,WAA+C;CAC9D,CAAC,CAAC,SAAS,EAAW,CAAA;AAEvB,MAAM,CAAC,MAAM,QAAQ,GAA2B,GAAG,CAAC,MAAM,EAAE,CAAA;AAY5D,MAAM,CAAC,MAAM,KAAK,GAAyB,GAAG,CAAC,KAAc,CAAA;AAE7D,MAAM,CAAC,MAAM,IAAI,GAAoB,GAAG,CAAC,IAAI,CAAA;AAE7C,qBAAqB;AACrB,MAAM,CAAC,MAAM,KAAK,GAAqB,GAAG,CAAC,KAAc,CAAA;AAQzD,MAAM,CAAC,MAAM,MAAM,GAA0B,GAAG,CAAC,MAAM,CAAA;AAEvD,MAAM,CAAC,MAAM,OAAO,GAA2B,GAAG,CAAC,OAAO,CAAA"}
|
package/out/base.d.ts
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { Callable, type Constructor, type Entry, type Guardable, type Json, type JsonData, type conform, type evaluate } from "@arktype/util";
|
|
2
|
+
import type { PredicateNode } from "./constraints/predicate.js";
|
|
3
|
+
import type { IndexNode } from "./constraints/props/index.js";
|
|
4
|
+
import type { PropNode } from "./constraints/props/prop.js";
|
|
5
|
+
import type { SequenceNode } from "./constraints/props/sequence.js";
|
|
6
|
+
import type { DivisorNode } from "./constraints/refinements/divisor.js";
|
|
7
|
+
import type { BoundNodesByKind } from "./constraints/refinements/kinds.js";
|
|
8
|
+
import type { RegexNode } from "./constraints/refinements/regex.js";
|
|
9
|
+
import type { Declaration, Inner, Schema, ioKindOf, reducibleKindOf } from "./kinds.js";
|
|
10
|
+
import type { Resolutions, Scope } from "./scope.js";
|
|
11
|
+
import type { NodeCompiler } from "./shared/compile.js";
|
|
12
|
+
import type { BaseAttachmentsOf, BaseErrorContext, BaseMeta, BaseNodeDeclaration } from "./shared/declare.js";
|
|
13
|
+
import type { ArkResult } from "./shared/errors.js";
|
|
14
|
+
import { precedenceOfKind, type BasisKind, type ConstraintKind, type NodeKind, type PropKind, type RefinementKind, type TypeKind, type UnknownIntersectionResult, type UnknownNodeImplementation, type nodeImplementationInputOf, type nodeImplementationOf } from "./shared/implement.js";
|
|
15
|
+
import { inferred } from "./shared/inference.js";
|
|
16
|
+
import { type TraverseAllows, type TraverseApply } from "./shared/traversal.js";
|
|
17
|
+
import type { DomainNode } from "./types/domain.js";
|
|
18
|
+
import type { IntersectionNode } from "./types/intersection.js";
|
|
19
|
+
import type { MorphNode, distillConstrainableIn, distillConstrainableOut, distillIn, distillOut } from "./types/morph.js";
|
|
20
|
+
import type { ProtoNode } from "./types/proto.js";
|
|
21
|
+
import type { Type } from "./types/type.js";
|
|
22
|
+
import type { UnionNode } from "./types/union.js";
|
|
23
|
+
import type { UnitNode } from "./types/unit.js";
|
|
24
|
+
import { arkKind } from "./util.js";
|
|
25
|
+
export interface BaseAttachments {
|
|
26
|
+
alias?: string;
|
|
27
|
+
readonly kind: NodeKind;
|
|
28
|
+
readonly reference: string;
|
|
29
|
+
readonly inner: Record<string, any>;
|
|
30
|
+
readonly entries: readonly Entry<string>[];
|
|
31
|
+
readonly json: object;
|
|
32
|
+
readonly typeJson: object;
|
|
33
|
+
readonly collapsibleJson: JsonData;
|
|
34
|
+
readonly children: UnknownNode[];
|
|
35
|
+
readonly innerId: string;
|
|
36
|
+
readonly typeId: string;
|
|
37
|
+
readonly $: Scope;
|
|
38
|
+
}
|
|
39
|
+
export interface NarrowedAttachments<d extends BaseNodeDeclaration> extends BaseAttachments {
|
|
40
|
+
kind: d["kind"];
|
|
41
|
+
inner: d["inner"];
|
|
42
|
+
json: Json;
|
|
43
|
+
typeJson: Json;
|
|
44
|
+
collapsibleJson: JsonData;
|
|
45
|
+
children: Node<d["childKind"]>[];
|
|
46
|
+
}
|
|
47
|
+
export type NodeSubclass<d extends BaseNodeDeclaration = BaseNodeDeclaration> = {
|
|
48
|
+
new (attachments: never): BaseNode<any, d>;
|
|
49
|
+
readonly implementation: nodeImplementationOf<d>;
|
|
50
|
+
};
|
|
51
|
+
export type UnknownNode = BaseNode<any, BaseNodeDeclaration>;
|
|
52
|
+
type subclassKind<self> = self extends Constructor<{
|
|
53
|
+
kind: infer kind extends NodeKind;
|
|
54
|
+
}> ? kind : never;
|
|
55
|
+
type subclassDeclaration<self> = Declaration<subclassKind<self>>;
|
|
56
|
+
export declare abstract class BaseNode<t, d extends BaseNodeDeclaration> extends Callable<(data: unknown) => ArkResult<distillIn<t>, distillOut<t>>, BaseAttachmentsOf<d>> {
|
|
57
|
+
attachments: BaseAttachments;
|
|
58
|
+
constructor(attachments: BaseAttachments);
|
|
59
|
+
infer: distillOut<t>;
|
|
60
|
+
[inferred]: t;
|
|
61
|
+
readonly [arkKind] = "node";
|
|
62
|
+
protected static implement<self>(this: self, implementation: nodeImplementationInputOf<subclassDeclaration<self>>): nodeImplementationOf<subclassDeclaration<self>>;
|
|
63
|
+
protected readonly impl: UnknownNodeImplementation;
|
|
64
|
+
readonly includesMorph: boolean;
|
|
65
|
+
readonly includesContextDependentPredicate: boolean;
|
|
66
|
+
readonly referencesByName: Record<string, UnknownNode>;
|
|
67
|
+
readonly references: readonly UnknownNode[];
|
|
68
|
+
readonly contributesReferencesByName: Record<string, UnknownNode>;
|
|
69
|
+
readonly contributesReferences: readonly UnknownNode[];
|
|
70
|
+
readonly precedence: precedenceOfKind<d["kind"]>;
|
|
71
|
+
jit: boolean;
|
|
72
|
+
private descriptionCache?;
|
|
73
|
+
get description(): string;
|
|
74
|
+
private compiledErrorContextCache;
|
|
75
|
+
get compiledErrorContext(): string;
|
|
76
|
+
allows: (data: d["prerequisite"]) => data is this["in"]["infer"];
|
|
77
|
+
parse(data: d["prerequisite"]): ArkResult<this["in"]["infer"], this["infer"]>;
|
|
78
|
+
abstract traverseAllows: TraverseAllows<d["prerequisite"]>;
|
|
79
|
+
abstract traverseApply: TraverseApply<d["prerequisite"]>;
|
|
80
|
+
abstract compile(js: NodeCompiler): void;
|
|
81
|
+
abstract expression: string;
|
|
82
|
+
private inCache?;
|
|
83
|
+
get in(): Node<ioKindOf<d["kind"]>, distillConstrainableIn<t>>;
|
|
84
|
+
private outCache?;
|
|
85
|
+
get out(): Node<ioKindOf<d["kind"]>, distillConstrainableOut<t>>;
|
|
86
|
+
private getIo;
|
|
87
|
+
protected createErrorContext<from>(from: from): evaluate<BaseErrorContext<d["kind"]> & from>;
|
|
88
|
+
toJSON(): Json;
|
|
89
|
+
equals(other: UnknownNode): boolean;
|
|
90
|
+
hasKind<kind extends NodeKind>(kind: kind): this is Node<kind>;
|
|
91
|
+
isBasis(): this is Node<BasisKind>;
|
|
92
|
+
isConstraint(): this is ConstraintNode;
|
|
93
|
+
isRefinement(): this is Node<RefinementKind>;
|
|
94
|
+
isProp(): this is Node<PropKind>;
|
|
95
|
+
isType(): this is Type;
|
|
96
|
+
hasUnit<value>(value: unknown): this is UnitNode<value>;
|
|
97
|
+
get intersectionIsOpen(): d["intersectionIsOpen"];
|
|
98
|
+
get nestableExpression(): string;
|
|
99
|
+
private static intersectionCache;
|
|
100
|
+
protected intersectInternal(this: UnknownNode, r: UnknownNode): UnknownIntersectionResult;
|
|
101
|
+
firstReference<narrowed>(filter: Guardable<UnknownNode, conform<narrowed, UnknownNode>>): narrowed | undefined;
|
|
102
|
+
firstReferenceOrThrow<narrowed extends UnknownNode>(filter: Guardable<UnknownNode, narrowed>): narrowed;
|
|
103
|
+
firstReferenceOfKind<kind extends NodeKind>(kind: kind): Node<kind> | undefined;
|
|
104
|
+
firstReferenceOfKindOrThrow<kind extends NodeKind>(kind: kind): Node<kind>;
|
|
105
|
+
bindScope<resolutions extends Resolutions>($: Scope<resolutions>): Node<d["kind"], t, resolutions>;
|
|
106
|
+
transform(mapper: DeepNodeTransformation, shouldTransform: (node: UnknownNode) => boolean): Node<reducibleKindOf<this["kind"]>>;
|
|
107
|
+
configureShallowDescendants(configOrDescription: BaseMeta | string): this;
|
|
108
|
+
}
|
|
109
|
+
export type DeepNodeTransformation = <kind extends NodeKind>(kind: kind, inner: Inner<kind>) => Inner<kind>;
|
|
110
|
+
interface NodesByKind<t = any, $ = any> extends BoundNodesByKind {
|
|
111
|
+
union: UnionNode<t, $>;
|
|
112
|
+
morph: MorphNode<t, $>;
|
|
113
|
+
intersection: IntersectionNode<t, $>;
|
|
114
|
+
unit: UnitNode<t, $>;
|
|
115
|
+
proto: ProtoNode<t, $>;
|
|
116
|
+
domain: DomainNode<t, $>;
|
|
117
|
+
divisor: DivisorNode;
|
|
118
|
+
regex: RegexNode;
|
|
119
|
+
predicate: PredicateNode;
|
|
120
|
+
prop: PropNode;
|
|
121
|
+
index: IndexNode;
|
|
122
|
+
sequence: SequenceNode;
|
|
123
|
+
}
|
|
124
|
+
export type Node<kind extends NodeKind, t = any, $ = any> = NodesByKind<t, $>[kind];
|
|
125
|
+
export type TypeSchema<kind extends TypeKind = TypeKind> = Schema<kind>;
|
|
126
|
+
export declare const typeKindOfSchema: (schema: unknown) => TypeKind;
|
|
127
|
+
export type ConstraintNode<kind extends ConstraintKind = ConstraintKind> = Node<kind>;
|
|
128
|
+
export {};
|
|
129
|
+
//# sourceMappingURL=base.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../base.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,QAAQ,EAQR,KAAK,WAAW,EAEhB,KAAK,KAAK,EACV,KAAK,SAAS,EACd,KAAK,IAAI,EACT,KAAK,QAAQ,EAEb,KAAK,OAAO,EACZ,KAAK,QAAQ,EAEb,MAAM,eAAe,CAAA;AACtB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAC/D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAA;AAC7D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCA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IACxB,IAAI,EAAE,QAAQ,CAAA;IACd,KAAK,EAAE,SAAS,CAAA;IAChB,QAAQ,EAAE,YAAY,CAAA;CACtB;AAED,MAAM,MAAM,IAAI,CAAC,IAAI,SAAS,QAAQ,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,GAAG,IAAI,WAAW,CACtE,CAAC,EACD,CAAC,CACD,CAAC,IAAI,CAAC,CAAA;AAEP,MAAM,MAAM,UAAU,CAAC,IAAI,SAAS,QAAQ,GAAG,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,CAAA;AAEvE,eAAO,MAAM,gBAAgB,WAAY,OAAO,KAAG,QAiClD,CAAA;AAED,MAAM,MAAM,cAAc,CAAC,IAAI,SAAS,cAAc,GAAG,cAAc,IACtE,IAAI,CAAC,IAAI,CAAC,CAAA"}
|
package/out/base.js
ADDED
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
import { Callable, compileSerializedValue, includes, isArray, morph, printable, throwError, throwParseError } from "@arktype/util";
|
|
2
|
+
import { Disjoint } from "./shared/disjoint.js";
|
|
3
|
+
import { basisKinds, constraintKinds, discriminatingIntersectionKeys, precedenceOfKind, propKinds, refinementKinds, typeKinds } from "./shared/implement.js";
|
|
4
|
+
import { inferred } from "./shared/inference.js";
|
|
5
|
+
import { TraversalContext } from "./shared/traversal.js";
|
|
6
|
+
import { arkKind, hasArkKind } from "./util.js";
|
|
7
|
+
export class BaseNode extends Callable {
|
|
8
|
+
attachments;
|
|
9
|
+
constructor(attachments) {
|
|
10
|
+
super((data) => {
|
|
11
|
+
const ctx = new TraversalContext(data, this.$.resolvedConfig);
|
|
12
|
+
this.traverseApply(data, ctx);
|
|
13
|
+
return ctx.finalize();
|
|
14
|
+
}, { attach: attachments });
|
|
15
|
+
this.attachments = attachments;
|
|
16
|
+
this.contributesReferencesByName =
|
|
17
|
+
this.reference in this.referencesByName
|
|
18
|
+
? this.referencesByName
|
|
19
|
+
: { ...this.referencesByName, [this.reference]: this };
|
|
20
|
+
this.contributesReferences = Object.values(this.contributesReferencesByName);
|
|
21
|
+
}
|
|
22
|
+
[arkKind] = "node";
|
|
23
|
+
static implement(_) {
|
|
24
|
+
const implementation = _;
|
|
25
|
+
if (implementation.hasAssociatedError) {
|
|
26
|
+
implementation.defaults.expected ??= (ctx) => "description" in ctx
|
|
27
|
+
? ctx.description
|
|
28
|
+
: // TODO: does passing ctx here work? or will some expect node?
|
|
29
|
+
implementation.defaults.description(ctx);
|
|
30
|
+
implementation.defaults.actual ??= (data) => printable(data);
|
|
31
|
+
implementation.defaults.problem ??= (ctx) => `must be ${ctx.expected}${ctx.actual ? ` (was ${ctx.actual})` : ""}`;
|
|
32
|
+
implementation.defaults.message ??= (ctx) => {
|
|
33
|
+
if (ctx.path.length === 0)
|
|
34
|
+
return ctx.problem;
|
|
35
|
+
const problemWithLocation = `${ctx.propString} ${ctx.problem}`;
|
|
36
|
+
if (problemWithLocation[0] === "[") {
|
|
37
|
+
// clarify paths like [1], [0][1], and ["key!"] that could be confusing
|
|
38
|
+
return `value at ${problemWithLocation}`;
|
|
39
|
+
}
|
|
40
|
+
return problemWithLocation;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
return implementation;
|
|
44
|
+
}
|
|
45
|
+
impl = this.constructor
|
|
46
|
+
.implementation;
|
|
47
|
+
includesMorph = this.kind === "morph" || this.children.some((child) => child.includesMorph);
|
|
48
|
+
includesContextDependentPredicate =
|
|
49
|
+
// if a predicate accepts exactly one arg, we can safely skip passing context
|
|
50
|
+
(this.hasKind("predicate") && this.inner.predicate.length !== 1) ||
|
|
51
|
+
this.children.some((child) => child.includesContextDependentPredicate);
|
|
52
|
+
referencesByName = this.children.reduce((result, child) => Object.assign(result, child.contributesReferencesByName), {});
|
|
53
|
+
references = Object.values(this.referencesByName);
|
|
54
|
+
contributesReferencesByName;
|
|
55
|
+
contributesReferences;
|
|
56
|
+
precedence = precedenceOfKind(this.kind);
|
|
57
|
+
jit = false;
|
|
58
|
+
descriptionCache;
|
|
59
|
+
get description() {
|
|
60
|
+
this.descriptionCache ??=
|
|
61
|
+
this.inner.description ??
|
|
62
|
+
this.$.resolvedConfig[this.kind].description?.(this);
|
|
63
|
+
return this.descriptionCache;
|
|
64
|
+
}
|
|
65
|
+
compiledErrorContextCache;
|
|
66
|
+
get compiledErrorContext() {
|
|
67
|
+
if (!this.compiledErrorContextCache) {
|
|
68
|
+
if ("errorContext" in this) {
|
|
69
|
+
let result = "{ ";
|
|
70
|
+
for (const [k, v] of Object.entries(this.errorContext)) {
|
|
71
|
+
result += `${k}: ${compileSerializedValue(v)}, `;
|
|
72
|
+
}
|
|
73
|
+
this.compiledErrorContextCache = result + " }";
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
this.compiledErrorContextCache = "{}";
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return this.compiledErrorContextCache;
|
|
80
|
+
}
|
|
81
|
+
allows = (data) => {
|
|
82
|
+
const ctx = new TraversalContext(data, this.$.resolvedConfig);
|
|
83
|
+
return this.traverseAllows(data, ctx);
|
|
84
|
+
};
|
|
85
|
+
parse(data) {
|
|
86
|
+
return this(data);
|
|
87
|
+
}
|
|
88
|
+
inCache;
|
|
89
|
+
get in() {
|
|
90
|
+
this.inCache ??= this.getIo("in");
|
|
91
|
+
return this.inCache;
|
|
92
|
+
}
|
|
93
|
+
outCache;
|
|
94
|
+
get out() {
|
|
95
|
+
this.outCache ??= this.getIo("out");
|
|
96
|
+
return this.outCache;
|
|
97
|
+
}
|
|
98
|
+
getIo(kind) {
|
|
99
|
+
if (!this.includesMorph) {
|
|
100
|
+
return this;
|
|
101
|
+
}
|
|
102
|
+
const ioInner = {};
|
|
103
|
+
for (const [k, v] of this.entries) {
|
|
104
|
+
const keyDefinition = this.impl.keys[k];
|
|
105
|
+
if (keyDefinition.meta) {
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
if (keyDefinition.child) {
|
|
109
|
+
const childValue = v;
|
|
110
|
+
ioInner[k] = isArray(childValue)
|
|
111
|
+
? childValue.map((child) => child[kind])
|
|
112
|
+
: childValue[kind];
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
ioInner[k] = v;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return this.$.node(this.kind, ioInner);
|
|
119
|
+
}
|
|
120
|
+
createErrorContext(from) {
|
|
121
|
+
return Object.freeze({
|
|
122
|
+
code: this.kind,
|
|
123
|
+
description: this.description,
|
|
124
|
+
...from
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
toJSON() {
|
|
128
|
+
return this.json;
|
|
129
|
+
}
|
|
130
|
+
equals(other) {
|
|
131
|
+
return this.typeId === other.typeId;
|
|
132
|
+
}
|
|
133
|
+
hasKind(kind) {
|
|
134
|
+
return this.kind === kind;
|
|
135
|
+
}
|
|
136
|
+
isBasis() {
|
|
137
|
+
return includes(basisKinds, this.kind);
|
|
138
|
+
}
|
|
139
|
+
isConstraint() {
|
|
140
|
+
return includes(constraintKinds, this.kind);
|
|
141
|
+
}
|
|
142
|
+
isRefinement() {
|
|
143
|
+
return includes(refinementKinds, this.kind);
|
|
144
|
+
}
|
|
145
|
+
isProp() {
|
|
146
|
+
return includes(propKinds, this.kind);
|
|
147
|
+
}
|
|
148
|
+
isType() {
|
|
149
|
+
return includes(typeKinds, this.kind);
|
|
150
|
+
}
|
|
151
|
+
hasUnit(value) {
|
|
152
|
+
return this.hasKind("unit") && this.allows(value);
|
|
153
|
+
}
|
|
154
|
+
get intersectionIsOpen() {
|
|
155
|
+
return this.impl.intersectionIsOpen;
|
|
156
|
+
}
|
|
157
|
+
get nestableExpression() {
|
|
158
|
+
return this.children.length > 1 &&
|
|
159
|
+
this.children.some((child) => !child.isBasis && !child.isProp())
|
|
160
|
+
? `(${this.expression})`
|
|
161
|
+
: this.expression;
|
|
162
|
+
}
|
|
163
|
+
static intersectionCache = {};
|
|
164
|
+
intersectInternal(r) {
|
|
165
|
+
const lrCacheKey = `${this.typeId}&${r.typeId}`;
|
|
166
|
+
if (BaseNode.intersectionCache[lrCacheKey]) {
|
|
167
|
+
return BaseNode.intersectionCache[lrCacheKey];
|
|
168
|
+
}
|
|
169
|
+
const rlCacheKey = `${r.typeId}&${this.typeId}`;
|
|
170
|
+
if (BaseNode.intersectionCache[rlCacheKey]) {
|
|
171
|
+
// if the cached result was a Disjoint and the operands originally
|
|
172
|
+
// appeared in the opposite order, we need to invert it to match
|
|
173
|
+
const rlResult = BaseNode.intersectionCache[rlCacheKey];
|
|
174
|
+
const lrResult = rlResult instanceof Disjoint ? rlResult.invert() : rlResult;
|
|
175
|
+
// add the lr result to the cache directly to bypass this check in the future
|
|
176
|
+
BaseNode.intersectionCache[lrCacheKey] = lrResult;
|
|
177
|
+
return lrResult;
|
|
178
|
+
}
|
|
179
|
+
if (this.equals(r)) {
|
|
180
|
+
return this;
|
|
181
|
+
}
|
|
182
|
+
const leftmostKind = this.precedence < r.precedence ? this.kind : r.kind;
|
|
183
|
+
const implementation = this.impl.intersections[r.kind] ?? r.impl.intersections[this.kind];
|
|
184
|
+
let result = implementation === undefined
|
|
185
|
+
? // should be two ConstraintNodes that have no relation
|
|
186
|
+
// this could also happen if a user directly intersects a Type and a ConstraintNode,
|
|
187
|
+
// but that is not allowed by the external function signature
|
|
188
|
+
null
|
|
189
|
+
: leftmostKind === this.kind
|
|
190
|
+
? implementation(this, r, this.$)
|
|
191
|
+
: implementation(r, this, this.$);
|
|
192
|
+
if (result instanceof BaseNode) {
|
|
193
|
+
// if the result equals one of the operands, preserve its metadata by
|
|
194
|
+
// returning the original reference
|
|
195
|
+
if (this.equals(result))
|
|
196
|
+
result = this;
|
|
197
|
+
else if (r.equals(result))
|
|
198
|
+
result = r;
|
|
199
|
+
}
|
|
200
|
+
BaseNode.intersectionCache[lrCacheKey] = result;
|
|
201
|
+
return result;
|
|
202
|
+
}
|
|
203
|
+
firstReference(filter) {
|
|
204
|
+
return this.references.find(filter);
|
|
205
|
+
}
|
|
206
|
+
firstReferenceOrThrow(filter) {
|
|
207
|
+
return (this.firstReference(filter) ??
|
|
208
|
+
throwError(`${this.reference} had no references matching predicate ${filter}`));
|
|
209
|
+
}
|
|
210
|
+
firstReferenceOfKind(kind) {
|
|
211
|
+
return this.firstReference((node) => node.kind === kind);
|
|
212
|
+
}
|
|
213
|
+
firstReferenceOfKindOrThrow(kind) {
|
|
214
|
+
return (this.firstReference((node) => node.kind === kind) ??
|
|
215
|
+
throwError(`${this.reference} had no ${kind} references`));
|
|
216
|
+
}
|
|
217
|
+
bindScope($) {
|
|
218
|
+
if (this.$ === $)
|
|
219
|
+
return this;
|
|
220
|
+
return new this.constructor({ ...this.attachments, $ });
|
|
221
|
+
}
|
|
222
|
+
transform(mapper, shouldTransform) {
|
|
223
|
+
if (!shouldTransform(this)) {
|
|
224
|
+
return this;
|
|
225
|
+
}
|
|
226
|
+
const innerWithTransformedChildren = morph(this.inner, (k, v) => [
|
|
227
|
+
k,
|
|
228
|
+
this.impl.keys[k].child
|
|
229
|
+
? isArray(v)
|
|
230
|
+
? v.map((node) => node.transform(mapper, shouldTransform))
|
|
231
|
+
: v.transform(mapper, shouldTransform)
|
|
232
|
+
: v
|
|
233
|
+
]);
|
|
234
|
+
return this.$.node(this.kind, mapper(this.kind, innerWithTransformedChildren));
|
|
235
|
+
}
|
|
236
|
+
configureShallowDescendants(configOrDescription) {
|
|
237
|
+
const config = typeof configOrDescription === "string"
|
|
238
|
+
? { description: configOrDescription }
|
|
239
|
+
: configOrDescription;
|
|
240
|
+
return this.transform((kind, inner) => ({ ...inner, ...config }), (node) => !node.isProp());
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
export const typeKindOfSchema = (schema) => {
|
|
244
|
+
switch (typeof schema) {
|
|
245
|
+
case "string":
|
|
246
|
+
return "domain";
|
|
247
|
+
case "function":
|
|
248
|
+
return hasArkKind(schema, "node")
|
|
249
|
+
? schema.isType()
|
|
250
|
+
? schema.kind
|
|
251
|
+
: throwParseError(`${schema.kind} constraint ${schema.expression} cannot be used as a root type`)
|
|
252
|
+
: "proto";
|
|
253
|
+
case "object":
|
|
254
|
+
// throw at end of function
|
|
255
|
+
if (schema === null)
|
|
256
|
+
break;
|
|
257
|
+
if ("morphs" in schema)
|
|
258
|
+
return "morph";
|
|
259
|
+
if ("branches" in schema || isArray(schema))
|
|
260
|
+
return "union";
|
|
261
|
+
if ("unit" in schema)
|
|
262
|
+
return "unit";
|
|
263
|
+
const schemaKeys = Object.keys(schema);
|
|
264
|
+
if (schemaKeys.length === 0 ||
|
|
265
|
+
schemaKeys.some((k) => k in discriminatingIntersectionKeys))
|
|
266
|
+
return "intersection";
|
|
267
|
+
if ("proto" in schema)
|
|
268
|
+
return "proto";
|
|
269
|
+
if ("domain" in schema)
|
|
270
|
+
return "domain";
|
|
271
|
+
}
|
|
272
|
+
return throwParseError(`${printable(schema)} is not a valid type schema`);
|
|
273
|
+
};
|
|
274
|
+
//# sourceMappingURL=base.js.map
|
package/out/base.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.js","sourceRoot":"","sources":["../base.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,QAAQ,EACR,sBAAsB,EACtB,QAAQ,EACR,OAAO,EACP,KAAK,EACL,SAAS,EACT,UAAU,EACV,eAAe,EAWf,MAAM,eAAe,CAAA;AAuBtB,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAE/C,OAAO,EACN,UAAU,EACV,eAAe,EACf,8BAA8B,EAC9B,gBAAgB,EAChB,SAAS,EACT,eAAe,EACf,SAAS,EAWT,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAChD,OAAO,EACN,gBAAgB,EAGhB,MAAM,uBAAuB,CAAA;AAc9B,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AA2C/C,MAAM,OAAgB,QAGpB,SAAQ,QAGT;IACmB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CAAC;gBACvB,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,8BAA8B,CAAC;gBAE3D,OAAO,cAAc,CAAA;YACtB,IAAI,OAAO,IAAI,MAAM;gBAAE,OAAO,OAAO,CAAA;YACrC,IAAI,QAAQ,IAAI,MAAM;gBAAE,OAAO,QAAQ,CAAA;IACzC,CAAC;IACD,OAAO,eAAe,CAAC,GAAG,SAAS,CAAC,MAAM,CAAC,6BAA6B,CAAC,CAAA;AAC1E,CAAC,CAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ScopeNode } from "../schemaScope.js";
|
|
2
|
+
import type { TypeKind } from "../shared/implement.js";
|
|
3
|
+
import type { inferred } from "../shared/inference.js";
|
|
4
|
+
import { JsObjects } from "./jsObjects.js";
|
|
5
|
+
import { TsKeywords } from "./tsKeywords.js";
|
|
6
|
+
import { Validation } from "./validation.js";
|
|
7
|
+
export declare const builtins: ScopeNode<ArkResolutions>;
|
|
8
|
+
export declare const nodes: ArkResolutions;
|
|
9
|
+
export declare const schema: import("../schemaScope.js").SchemaParser<ArkResolutions>;
|
|
10
|
+
export declare namespace schema {
|
|
11
|
+
type cast<to, kind extends TypeKind = TypeKind> = {
|
|
12
|
+
[inferred]?: to;
|
|
13
|
+
kind?: kind;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export type isSchemaCast<def> = typeof inferred | "kind" extends keyof def ? true : false;
|
|
17
|
+
export interface ArkResolutions extends TsKeywords.resolutions, JsObjects.resolutions, Validation.resolutions {
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=builtins.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builtins.d.ts","sourceRoot":"","sources":["../../builtins/builtins.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAC7C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAA;AACtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAA;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAE5C,eAAO,MAAM,QAAQ,EAAE,SAAS,CAAC,cAAc,CAOrC,CAAA;AAEV,eAAO,MAAM,KAAK,gBAAuB,CAAA;AAEzC,eAAO,MAAM,MAAM,0DAAkB,CAAA;AAErC,yBAAiB,MAAM,CAAC;IACvB,KAAY,IAAI,CAAC,EAAE,EAAE,IAAI,SAAS,QAAQ,GAAG,QAAQ,IAAI;QACxD,CAAC,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAA;QACf,IAAI,CAAC,EAAE,IAAI,CAAA;KACX,CAAA;CACD;AAED,MAAM,MAAM,YAAY,CAAC,GAAG,IAAI,OAAO,QAAQ,GAAG,MAAM,SAAS,MAAM,GAAG,GACvE,IAAI,GACJ,KAAK,CAAA;AAIR,MAAM,WAAW,cAChB,SAAQ,UAAU,CAAC,WAAW,EAC7B,SAAS,CAAC,WAAW,EACrB,UAAU,CAAC,WAAW;CAAG"}
|