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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { RawSchema } from "@arktype/schema";
|
|
2
2
|
import type { ErrorMessage, join } from "@arktype/util";
|
|
3
3
|
import type { DynamicState } from "../../reduce/dynamic.js";
|
|
4
4
|
import { writeUnclosedGroupMessage } from "../../reduce/shared.js";
|
|
@@ -8,22 +8,22 @@ export type ParsedArgs<result extends unknown[] = unknown[], unscanned extends s
|
|
|
8
8
|
result: result;
|
|
9
9
|
unscanned: unscanned;
|
|
10
10
|
};
|
|
11
|
-
export declare const parseGenericArgs: (name: string, params: string[], s: DynamicState) => ParsedArgs<
|
|
12
|
-
export type parseGenericArgs<name extends string, params extends string[], unscanned extends string, $, args> =
|
|
13
|
-
declare const
|
|
14
|
-
type
|
|
11
|
+
export declare const parseGenericArgs: (name: string, params: string[], s: DynamicState) => ParsedArgs<RawSchema[]>;
|
|
12
|
+
export type parseGenericArgs<name extends string, params extends string[], unscanned extends string, $, args> = $parseGenericArgs<name, params, unscanned, $, args, [], []>;
|
|
13
|
+
declare const $parseGenericArgs: (name: string, params: string[], s: DynamicState, argDefs: string[], argNodes: RawSchema[]) => ParsedArgs<RawSchema[]>;
|
|
14
|
+
type $parseGenericArgs<name extends string, params extends string[], unscanned extends string, $, args, argDefs extends string[], argAsts extends unknown[]> = parseUntilFinalizer<state.initialize<unscanned>, $, args> extends (infer finalArgState extends StaticState) ? {
|
|
15
15
|
defs: [
|
|
16
16
|
...argDefs,
|
|
17
17
|
finalArgState["scanned"] extends `${infer def}${"," | ">"}` ? def : finalArgState["scanned"]
|
|
18
18
|
];
|
|
19
19
|
asts: [...argAsts, finalArgState["root"]];
|
|
20
20
|
unscanned: finalArgState["unscanned"];
|
|
21
|
-
} extends {
|
|
21
|
+
} extends ({
|
|
22
22
|
defs: infer nextDefs extends string[];
|
|
23
23
|
asts: infer nextAsts extends unknown[];
|
|
24
24
|
unscanned: infer nextUnscanned extends string;
|
|
25
|
-
} ? finalArgState["finalizer"] extends ">" ? nextAsts["length"] extends params["length"] ? ParsedArgs<nextAsts, nextUnscanned> : state.error<writeInvalidGenericArgsMessage<name, params, nextDefs>> : finalArgState["finalizer"] extends "," ?
|
|
26
|
-
export declare const writeInvalidGenericArgsMessage: <name extends string, params extends string[], argDefs extends string[]>(name: name, params: params, argDefs: argDefs) =>
|
|
27
|
-
export type writeInvalidGenericArgsMessage<name extends string, params extends string[], argDefs extends string[]> = `${name}<${join<params, ", ">}> requires exactly ${params["length"]} args (got ${argDefs["length"]}${argDefs["length"] extends 0 ? "" : `: ${join<argDefs, ",">}`})`;
|
|
25
|
+
}) ? finalArgState["finalizer"] extends ">" ? nextAsts["length"] extends params["length"] ? ParsedArgs<nextAsts, nextUnscanned> : state.error<writeInvalidGenericArgsMessage<name, params, nextDefs>> : finalArgState["finalizer"] extends "," ? $parseGenericArgs<name, params, nextUnscanned, $, args, nextDefs, nextAsts> : finalArgState["finalizer"] extends ErrorMessage ? finalArgState : state.error<writeUnclosedGroupMessage<">">> : never : never;
|
|
26
|
+
export declare const writeInvalidGenericArgsMessage: <name extends string, params extends string[], argDefs extends string[]>(name: name, params: params, argDefs: argDefs) => `${name}<${join<params, ", ", "">}> requires exactly ${params["length"]} args (got ${argDefs["length"]}${argDefs["length"] extends 0 ? "" : `: ${join<argDefs, ",", "">}`})`;
|
|
27
|
+
export type writeInvalidGenericArgsMessage<name extends string, params extends string[], argDefs extends string[]> = `${name}<${join<params, ", ">}> requires exactly ${params["length"]} args (got ${argDefs["length"]}${argDefs["length"] extends (0) ? "" : `: ${join<argDefs, ",">}`})`;
|
|
28
28
|
export {};
|
|
29
29
|
//# sourceMappingURL=genericArgs.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"genericArgs.d.ts","sourceRoot":"","sources":["../../../../../parser/string/shift/operand/genericArgs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"genericArgs.d.ts","sourceRoot":"","sources":["../../../../../parser/string/shift/operand/genericArgs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAChD,OAAO,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,eAAe,CAAA;AACvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAC3D,OAAO,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAA;AAClE,OAAO,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAA;AAChE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAE1D,MAAM,MAAM,UAAU,CACrB,MAAM,SAAS,OAAO,EAAE,GAAG,OAAO,EAAE,EACpC,SAAS,SAAS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AAQ,SAAS,MAAM,EAAE,CAAA;IACrC,IAAI,EAAE,MAAM,QAAQ,SAAS,OAAO,EAAE,CAAA;IACtC,SAAS,EAAE,MAAM,aAAa,SAAS,MAAM,CAAA;CAC7C,CACD,GACA,aAAa,CAAC,WAAW,CAAC,SAAS,GAAG,GACrC,QAAQ,CAAC,QAAQ,CAAC,SAAS,MAAM,CAAC,QAAQ,CAAC,GAC1C,UAAU,CAAC,QAAQ,EAAE,aAAa,CAAC,GAClC,KAAK,CAAC,KAAK,CAAC,8BAA8B,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,GACpE,aAAa,CAAC,WAAW,CAAC,SAAS,GAAG,GACvC,iBAAiB,CAChB,IAAI,EACJ,MAAM,EACN,aAAa,EACb,CAAC,EACD,IAAI,EACJ,QAAQ,EACR,QAAQ,CACR,GACA,aAAa,CAAC,WAAW,CAAC,SAAS,YAAY,GAAG,aAAa,GAC/D,KAAK,CAAC,KAAK,CAAC,yBAAyB,CAAC,GAAG,CAAC,CAAC,GAC5C,KAAK,GACN,KAAK,CAAA;AAER,eAAO,MAAM,8BAA8B,wSAa9B,CAAA;AAEb,MAAM,MAAM,8BAA8B,CACzC,IAAI,SAAS,MAAM,EACnB,MAAM,SAAS,MAAM,EAAE,EACvB,OAAO,SAAS,MAAM,EAAE,IACrB,GAAG,IAAI,IAAI,IAAI,CAClB,MAAM,EACN,IAAI,CACJ,sBAAsB,MAAM,CAAC,QAAQ,CAAC,cAAc,OAAO,CAAC,QAAQ,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,SAAS,CAClG,CAAC,CACD,GACA,EAAE,GACD,KAAK,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,EAAE,GAAG,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { writeUnclosedGroupMessage } from "../../reduce/shared.js";
|
|
2
|
-
export const parseGenericArgs = (name, params, s) =>
|
|
3
|
-
const
|
|
2
|
+
export const parseGenericArgs = (name, params, s) => $parseGenericArgs(name, params, s, [], []);
|
|
3
|
+
const $parseGenericArgs = (name, params, s, argDefs, argNodes) => {
|
|
4
4
|
const argState = s.parseUntilFinalizer();
|
|
5
5
|
// remove the finalizing token from the argDef
|
|
6
6
|
argDefs.push(argState.scanner.scanned.slice(0, -1));
|
|
@@ -12,14 +12,12 @@ const parseGenericArgsRecurse = (name, params, s, argDefs, argNodes) => {
|
|
|
12
12
|
unscanned: argState.scanner.unscanned
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
|
-
|
|
16
|
-
return argState.error(writeInvalidGenericArgsMessage(name, params, argDefs));
|
|
17
|
-
}
|
|
15
|
+
return argState.error(writeInvalidGenericArgsMessage(name, params, argDefs));
|
|
18
16
|
}
|
|
19
|
-
|
|
20
|
-
return
|
|
17
|
+
if (argState.finalizer === ",") {
|
|
18
|
+
return $parseGenericArgs(name, params, s, argDefs, argNodes);
|
|
21
19
|
}
|
|
22
20
|
return argState.error(writeUnclosedGroupMessage(">"));
|
|
23
21
|
};
|
|
24
|
-
export const writeInvalidGenericArgsMessage = (name, params, argDefs) => `${name}<${params.join(", ")}> requires exactly ${params.length} args (got ${argDefs.length}${argDefs.length === 0 ? "" :
|
|
22
|
+
export const writeInvalidGenericArgsMessage = (name, params, argDefs) => `${name}<${params.join(", ")}> requires exactly ${params.length} args (got ${argDefs.length}${argDefs.length === 0 ? "" : `: ${argDefs.join(", ")}`})`;
|
|
25
23
|
//# sourceMappingURL=genericArgs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"genericArgs.js","sourceRoot":"","sources":["../../../../../parser/string/shift/operand/genericArgs.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAA;AAYlE,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC/B,IAAY,EACZ,MAAgB,EAChB,CAAe,
|
|
1
|
+
{"version":3,"file":"genericArgs.js","sourceRoot":"","sources":["../../../../../parser/string/shift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CAAC,MAAM,8BAA8B,GAAG,CAK7C,IAAU,EACV,MAAc,EACd,OAAgB,EACwC,EAAE,CAC1D,GAAG,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,sBAC3B,MAAM,CAAC,MACR,cAAc,OAAO,CAAC,MAAM,GAC3B,OAAO,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EACpD,GAAY,CAAA"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { DynamicState } from "../../reduce/dynamic.js";
|
|
2
|
-
import type {
|
|
2
|
+
import type { StaticState, state } from "../../reduce/static.js";
|
|
3
3
|
import type { BaseCompletions } from "../../string.js";
|
|
4
4
|
import { Scanner } from "../scanner.js";
|
|
5
|
-
import {
|
|
5
|
+
import { type EnclosingQuote, type EnclosingStartToken, parseEnclosed } from "./enclosed.js";
|
|
6
6
|
import { parseUnenclosed } from "./unenclosed.js";
|
|
7
7
|
export declare const parseOperand: (s: DynamicState) => void;
|
|
8
|
-
export type parseOperand<s extends StaticState, $, args> = s["unscanned"] extends Scanner.shift<infer lookahead, infer unscanned> ? lookahead extends "(" ? state.reduceGroupOpen<s, unscanned> : lookahead extends
|
|
8
|
+
export type parseOperand<s extends StaticState, $, args> = s["unscanned"] extends Scanner.shift<infer lookahead, infer unscanned> ? lookahead extends "(" ? state.reduceGroupOpen<s, unscanned> : lookahead extends EnclosingStartToken ? parseEnclosed<s, lookahead, unscanned> : lookahead extends Scanner.WhiteSpaceToken ? parseOperand<state.scanTo<s, unscanned>, $, args> : lookahead extends "d" ? unscanned extends (Scanner.shift<infer enclosing extends EnclosingQuote, infer nextUnscanned>) ? parseEnclosed<s, `d${enclosing}`, nextUnscanned> : parseUnenclosed<s, $, args> : parseUnenclosed<s, $, args> : state.completion<`${s["scanned"]}${BaseCompletions<$, args>}`>;
|
|
9
9
|
//# sourceMappingURL=operand.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operand.d.ts","sourceRoot":"","sources":["../../../../../parser/string/shift/operand/operand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAC3D,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"operand.d.ts","sourceRoot":"","sources":["../../../../../parser/string/shift/operand/operand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAC3D,OAAO,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAA;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EACN,KAAK,cAAc,EACnB,KAAK,mBAAmB,EAExB,aAAa,EACb,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,eAAe,EAA8B,MAAM,iBAAiB,CAAA;AAE7E,eAAO,MAAM,YAAY,MAAO,YAAY,KAAG,IAU1B,CAAA;AAErB,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,WAAW,EAAE,CAAC,EAAE,IAAI,IACtD,CAAC,CAAC,WAAW,CAAC,SAAS,OAAO,CAAC,KAAK,CAAC,MAAM,SAAS,EAAE,MAAM,SAAS,CAAC,GACrE,SAAS,SAAS,GAAG,GAAG,KAAK,CAAC,eAAe,CAAC,CAAC,EAAE,SAAS,CAAC,GACzD,SAAS,SAAS,mBAAmB,GACtC,aAAa,CAAC,CAAC,EAAE,SAAS,EAAE,SAAS,CAAC,GACrC,SAAS,SAAS,OAAO,CAAC,eAAe,GAC1C,YAAY,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,SAAS,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,GAChD,SAAS,SAAS,GAAG,GACtB,SAAS,SAAS,CACjB,OAAO,CAAC,KAAK,CACZ,MAAM,SAAS,SAAS,cAAc,EACtC,MAAM,aAAa,CACnB,CACD,GACA,aAAa,CAAC,CAAC,EAAE,IAAI,SAAS,EAAE,EAAE,aAAa,CAAC,GAC/C,eAAe,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,GAC5B,eAAe,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,GAC5B,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,GAAG,eAAe,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,CAAC,CAAA"}
|
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
import { Scanner } from "../scanner.js";
|
|
2
2
|
import { enclosingChar, parseEnclosed } from "./enclosed.js";
|
|
3
3
|
import { parseUnenclosed, writeMissingOperandMessage } from "./unenclosed.js";
|
|
4
|
-
export const parseOperand = (s) => s.scanner.lookahead === ""
|
|
5
|
-
? s.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
: s.scanner.lookahead === "d"
|
|
13
|
-
? s.shiftedByOne().scanner.lookaheadIsIn(enclosingChar)
|
|
14
|
-
? parseEnclosed(s, `d${s.scanner.shift()}`)
|
|
4
|
+
export const parseOperand = (s) => s.scanner.lookahead === "" ? s.error(writeMissingOperandMessage(s))
|
|
5
|
+
: s.scanner.lookahead === "(" ? s.shiftedByOne().reduceGroupOpen()
|
|
6
|
+
: s.scanner.lookaheadIsIn(enclosingChar) ? parseEnclosed(s, s.scanner.shift())
|
|
7
|
+
: s.scanner.lookaheadIsIn(Scanner.whiteSpaceTokens) ?
|
|
8
|
+
parseOperand(s.shiftedByOne())
|
|
9
|
+
: s.scanner.lookahead === "d" ?
|
|
10
|
+
s.shiftedByOne().scanner.lookaheadIsIn(enclosingChar) ?
|
|
11
|
+
parseEnclosed(s, `d${s.scanner.shift()}`)
|
|
15
12
|
: parseUnenclosed(s)
|
|
16
13
|
: parseUnenclosed(s);
|
|
17
14
|
//# sourceMappingURL=operand.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operand.js","sourceRoot":"","sources":["../../../../../parser/string/shift/operand/operand.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,
|
|
1
|
+
{"version":3,"file":"operand.js","sourceRoot":"","sources":["../../../../../parser/string/shift/operand/operand.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EAGN,aAAa,EACb,aAAa,EACb,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,eAAe,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAA;AAE7E,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAe,EAAQ,EAAE,CACrD,CAAC,CAAC,OAAO,CAAC,SAAS,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAC,CAAC,CAAC;IACnE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,YAAY,EAAE,CAAC,eAAe,EAAE;QAClE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;YAC9E,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC;gBACpD,YAAY,CAAC,CAAC,CAAC,YAAY,EAAE,CAAC;gBAC/B,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,KAAK,GAAG,CAAC,CAAC;oBAC9B,CAAC,CAAC,YAAY,EAAE,CAAC,OAAO,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC,CAAC;wBACtD,aAAa,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAyB,CAAC;wBACjE,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC;oBACrB,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAA"}
|
|
@@ -1,34 +1,27 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import { type BigintLiteral, type Completion, type ErrorMessage, type join
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
5
|
-
import type { GenericInstantiationAst } from "../../../semantic/
|
|
1
|
+
import { type GenericProps, RawSchema, type SchemaModule, type writeNonSubmoduleDotMessage, writeUnresolvableMessage } from "@arktype/schema";
|
|
2
|
+
import { type BigintLiteral, type Completion, type ErrorMessage, type join } from "@arktype/util";
|
|
3
|
+
import type { Generic } from "../../../../generic.js";
|
|
4
|
+
import type { Module } from "../../../../module.js";
|
|
5
|
+
import type { GenericInstantiationAst } from "../../../semantic/infer.js";
|
|
6
6
|
import type { DynamicState } from "../../reduce/dynamic.js";
|
|
7
|
-
import type {
|
|
7
|
+
import type { StaticState, state } from "../../reduce/static.js";
|
|
8
8
|
import type { BaseCompletions } from "../../string.js";
|
|
9
9
|
import type { Scanner } from "../scanner.js";
|
|
10
|
-
import { parseGenericArgs, writeInvalidGenericArgsMessage
|
|
10
|
+
import { type ParsedArgs, parseGenericArgs, writeInvalidGenericArgsMessage } from "./genericArgs.js";
|
|
11
11
|
export declare const parseUnenclosed: (s: DynamicState) => void;
|
|
12
|
-
export type parseUnenclosed<s extends StaticState, $, args> = Scanner.shiftUntilNextTerminator<s["unscanned"]> extends Scanner.shiftResult<infer token, infer unscanned> ? token extends "keyof" ? state.addPrefix<s, "keyof", unscanned> : tryResolve<s, token, $, args> extends infer result ? result extends ErrorMessage<infer message> ? state.error<message> : result extends keyof $ ? $[result] extends GenericProps ? parseGenericInstantiation<token, $[result], state.scanTo<s, unscanned>, $, args> : state.setRoot<s, result, unscanned> : state.setRoot<s, result, unscanned> : never : never;
|
|
13
|
-
export declare const parseGenericInstantiation: (name: string, g: Generic, s: DynamicState) =>
|
|
14
|
-
export type parseGenericInstantiation<name extends string, g extends GenericProps, s extends StaticState, $, args> = Scanner.skipWhitespace<s["unscanned"]> extends `<${infer unscanned}` ? parseGenericArgs<name, g["
|
|
15
|
-
type tryResolve<s extends StaticState, token extends string, $, args> = token extends keyof $ ? token : token extends keyof args ? token : token extends
|
|
16
|
-
export declare const writeNonSubmoduleDotMessage: <name extends string>(name: name) => `'${name}' must reference a module to be accessed using dot syntax`;
|
|
17
|
-
type writeNonSubmoduleDotMessage<name extends string> = `'${name}' must reference a module to be accessed using dot syntax`;
|
|
18
|
-
export declare const writeMissingSubmoduleAccessMessage: <name extends string>(name: name) => `Reference to submodule '${name}' must specify an alias`;
|
|
19
|
-
export type writeMissingSubmoduleAccessMessage<name extends string> = `Reference to submodule '${name}' must specify an alias`;
|
|
12
|
+
export type parseUnenclosed<s extends StaticState, $, args> = Scanner.shiftUntilNextTerminator<s["unscanned"]> extends (Scanner.shiftResult<infer token, infer unscanned>) ? token extends "keyof" ? state.addPrefix<s, "keyof", unscanned> : tryResolve<s, token, $, args> extends infer result ? result extends ErrorMessage<infer message> ? state.error<message> : result extends keyof $ ? $[result] extends GenericProps ? parseGenericInstantiation<token, $[result], state.scanTo<s, unscanned>, $, args> : state.setRoot<s, result, unscanned> : state.setRoot<s, result, unscanned> : never : never;
|
|
13
|
+
export declare const parseGenericInstantiation: (name: string, g: Generic, s: DynamicState) => RawSchema;
|
|
14
|
+
export type parseGenericInstantiation<name extends string, g extends GenericProps, s extends StaticState, $, args> = Scanner.skipWhitespace<s["unscanned"]> extends `<${infer unscanned}` ? parseGenericArgs<name, g["params"], unscanned, $, args> extends (infer result) ? result extends ParsedArgs<infer argAsts, infer nextUnscanned> ? state.setRoot<s, GenericInstantiationAst<g, argAsts>, nextUnscanned> : result : never : state.error<writeInvalidGenericArgsMessage<name, g["params"], []>>;
|
|
15
|
+
type tryResolve<s extends StaticState, token extends string, $, args> = token extends keyof $ ? token : `#${token}` extends keyof $ ? token : token extends keyof args ? token : token extends `${number}` ? token : token extends BigintLiteral ? token : token extends (`${infer submodule extends keyof $ & string}.${infer reference}`) ? $[submodule] extends (SchemaModule<infer sub$> | Module<infer sub$>) ? reference extends keyof sub$ ? token : unknown extends sub$ ? ErrorMessage<writeNonSubmoduleDotMessage<submodule>> : unresolvableError<s, reference, $[submodule], args, [submodule]> : ErrorMessage<writeNonSubmoduleDotMessage<submodule>> : unresolvableError<s, token, $, args, []>;
|
|
20
16
|
/** Provide valid completions for the current token, or fallback to an
|
|
21
17
|
* unresolvable error if there are none */
|
|
22
18
|
export type unresolvableError<s extends StaticState, token extends string, $, args, submodulePath extends string[]> = validReferenceFromToken<token, $, args, submodulePath> extends never ? ErrorMessage<writeUnresolvableMessage<qualifiedReference<token, submodulePath>>> : Completion<`${s["scanned"]}${qualifiedReference<validReferenceFromToken<token, $, args, submodulePath>, submodulePath>}`>;
|
|
23
19
|
type qualifiedReference<reference extends string, submodulePath extends string[]> = join<[...submodulePath, reference], ".">;
|
|
24
20
|
type validReferenceFromToken<token extends string, $, args, submodulePath extends string[]> = Extract<submodulePath extends [] ? BaseCompletions<$, args> : keyof $, `${token}${string}`>;
|
|
25
|
-
export declare const
|
|
26
|
-
type writeUnresolvableMessage<token extends string> = `'${token}' is unresolvable`;
|
|
27
|
-
export declare const writeMissingOperandMessage: <s extends DynamicState>(s: s) => string;
|
|
28
|
-
export type writeMissingOperandMessage<s extends StaticState, operator extends string | undefined = state.previousOperator<s>> = operator extends string ? writeMissingRightOperandMessage<operator, s["unscanned"]> : writeExpressionExpectedMessage<s["unscanned"]>;
|
|
21
|
+
export declare const writeMissingOperandMessage: (s: DynamicState) => string;
|
|
29
22
|
export type writeMissingRightOperandMessage<token extends string, unscanned extends string = ""> = `Token '${token}' requires a right operand${unscanned extends "" ? "" : ` before '${unscanned}'`}`;
|
|
30
23
|
export declare const writeMissingRightOperandMessage: <token extends string, unscanned extends string>(token: token, unscanned?: unscanned) => `Token '${token}' requires a right operand${unscanned extends "" ? "" : ` before '${unscanned}'`}`;
|
|
31
|
-
export declare const writeExpressionExpectedMessage: <unscanned extends string>(unscanned: unscanned) =>
|
|
24
|
+
export declare const writeExpressionExpectedMessage: <unscanned extends string>(unscanned: unscanned) => `Expected an expression${unscanned extends "" ? "" : ` before '${unscanned}'`}`;
|
|
32
25
|
export type writeExpressionExpectedMessage<unscanned extends string> = `Expected an expression${unscanned extends "" ? "" : ` before '${unscanned}'`}`;
|
|
33
26
|
export {};
|
|
34
27
|
//# sourceMappingURL=unenclosed.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unenclosed.d.ts","sourceRoot":"","sources":["../../../../../parser/string/shift/operand/unenclosed.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"unenclosed.d.ts","sourceRoot":"","sources":["../../../../../parser/string/shift/operand/unenclosed.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,YAAY,EAEjB,SAAS,EACT,KAAK,YAAY,EAEjB,KAAK,2BAA2B,EAChC,wBAAwB,EACxB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACN,KAAK,aAAa,EAClB,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,KAAK,IAAI,EAKT,MAAM,eAAe,CAAA;AACtB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AACrD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AACnD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAA;AAEzE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAC3D,OAAO,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAA;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACtD,O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6B,SAAS,SAAS,EAAE,GAAG,EAAE,GACvE,YAAY,SAAS,GAAG,EAAE,CAAA;AAE5B,eAAO,MAAM,+BAA+B,6LASzC,CAAA;AAEH,eAAO,MAAM,8BAA8B,qIAGmC,CAAA;AAE9E,MAAM,MAAM,8BAA8B,CAAC,SAAS,SAAS,MAAM,IAClE,yBAAyB,SAAS,SAAS,EAAE,GAAG,EAAE,GAChD,YAAY,SAAS,GAAG,EAAE,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RawSchema, hasArkKind, writeUnresolvableMessage } from "@arktype/schema";
|
|
2
2
|
import { printable, throwParseError, tryParseNumber, tryParseWellFormedBigint } from "@arktype/util";
|
|
3
|
-
import {
|
|
3
|
+
import { writePrefixedPrivateReferenceMessage } from "../../../semantic/validate.js";
|
|
4
4
|
import { parseGenericArgs, writeInvalidGenericArgsMessage } from "./genericArgs.js";
|
|
5
5
|
export const parseUnenclosed = (s) => {
|
|
6
6
|
const token = s.scanner.shiftUntilNextTerminator();
|
|
@@ -15,52 +15,47 @@ export const parseGenericInstantiation = (name, g, s) => {
|
|
|
15
15
|
s.scanner.shiftUntilNonWhitespace();
|
|
16
16
|
const lookahead = s.scanner.shift();
|
|
17
17
|
if (lookahead !== "<") {
|
|
18
|
-
return s.error(writeInvalidGenericArgsMessage(name, g.
|
|
18
|
+
return s.error(writeInvalidGenericArgsMessage(name, g.params, []));
|
|
19
19
|
}
|
|
20
|
-
const parsedArgs = parseGenericArgs(name, g.
|
|
20
|
+
const parsedArgs = parseGenericArgs(name, g.params, s);
|
|
21
21
|
const remainingChars = parsedArgs.unscanned.length;
|
|
22
22
|
// set the scanner position to where the args scanner left off
|
|
23
23
|
s.scanner.jumpToIndex(remainingChars === 0 ? s.scanner.length : -remainingChars);
|
|
24
|
-
return g(...parsedArgs.result)
|
|
24
|
+
return g(...parsedArgs.result);
|
|
25
25
|
};
|
|
26
26
|
const unenclosedToNode = (s, token) => maybeParseReference(s, token) ??
|
|
27
27
|
maybeParseUnenclosedLiteral(s, token) ??
|
|
28
|
-
s.error(token === ""
|
|
29
|
-
?
|
|
30
|
-
|
|
28
|
+
s.error(token === "" ? writeMissingOperandMessage(s)
|
|
29
|
+
: token[0] === "#" ?
|
|
30
|
+
writePrefixedPrivateReferenceMessage(token)
|
|
31
|
+
: writeUnresolvableMessage(token));
|
|
31
32
|
const maybeParseReference = (s, token) => {
|
|
32
|
-
if (s.ctx.args?.[token])
|
|
33
|
-
return s.ctx.args[token];
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
if (resolution instanceof
|
|
37
|
-
return resolution;
|
|
38
|
-
|
|
39
|
-
if (resolution === undefined) {
|
|
33
|
+
if (s.ctx.args?.[token])
|
|
34
|
+
return s.ctx.args[token].raw;
|
|
35
|
+
const resolution = s.ctx.$.maybeResolve(token);
|
|
36
|
+
// TODO: centralize member creation
|
|
37
|
+
if (resolution instanceof RawSchema)
|
|
38
|
+
return resolution.bindScope(s.ctx.$);
|
|
39
|
+
if (resolution === undefined)
|
|
40
40
|
return;
|
|
41
|
-
|
|
42
|
-
if (hasArkKind(resolution, "generic")) {
|
|
41
|
+
if (hasArkKind(resolution, "generic"))
|
|
43
42
|
return parseGenericInstantiation(token, resolution, s);
|
|
44
|
-
}
|
|
45
43
|
return throwParseError(`Unexpected resolution ${printable(resolution)}`);
|
|
46
44
|
};
|
|
47
45
|
const maybeParseUnenclosedLiteral = (s, token) => {
|
|
48
46
|
const maybeNumber = tryParseNumber(token, { strict: true });
|
|
49
47
|
if (maybeNumber !== undefined) {
|
|
50
|
-
return
|
|
48
|
+
return s.ctx.$.node("unit", { unit: maybeNumber });
|
|
51
49
|
}
|
|
52
50
|
const maybeBigint = tryParseWellFormedBigint(token);
|
|
53
51
|
if (maybeBigint !== undefined) {
|
|
54
|
-
return
|
|
52
|
+
return s.ctx.$.node("unit", { unit: maybeBigint });
|
|
55
53
|
}
|
|
56
54
|
};
|
|
57
|
-
export const writeNonSubmoduleDotMessage = (name) => `'${name}' must reference a module to be accessed using dot syntax`;
|
|
58
|
-
export const writeMissingSubmoduleAccessMessage = (name) => `Reference to submodule '${name}' must specify an alias`;
|
|
59
|
-
export const writeUnresolvableMessage = (token) => `'${token}' is unresolvable`;
|
|
60
55
|
export const writeMissingOperandMessage = (s) => {
|
|
61
56
|
const operator = s.previousOperator();
|
|
62
|
-
return operator
|
|
63
|
-
|
|
57
|
+
return operator ?
|
|
58
|
+
writeMissingRightOperandMessage(operator, s.scanner.unscanned)
|
|
64
59
|
: writeExpressionExpectedMessage(s.scanner.unscanned);
|
|
65
60
|
};
|
|
66
61
|
export const writeMissingRightOperandMessage = (token, unscanned = "") => `Token '${token}' requires a right operand${unscanned ? ` before '${unscanned}'` : ""}`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unenclosed.js","sourceRoot":"","sources":["../../../../../parser/string/shift/operand/unenclosed.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"unenclosed.js","sourceRoot":"","sources":["../../../../../parser/string/shift/operand/unenclosed.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,SAAS,EAET,UAAU,EAEV,wBAAwB,EACxB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAKN,SAAS,EACT,eAAe,EACf,cAAc,EACd,wBAAwB,EACxB,MAAM,eAAe,CAAA;AAItB,OAAO,EAAE,oCAAoC,EAAE,MAAM,+BAA+B,CAAA;AAKpF,OAAO,EAEN,gBAAgB,EAChB,8BAA8B,EAC9B,MAAM,kBAAkB,CAAA;AAEzB,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAe,EAAQ,EAAE;IACxD,MAAM,KAAK,GAAG,CAAC,CAAC,OAAO,CAAC,wBAAwB,EAAE,CAAA;IAClD,IAAI,KAAK,KAAK,OAAO,EAAE,CAAC;QACvB,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,CAAA;IACrB,CAAC;SAAM,CAAC;QACP,CAAC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IACnD,CAAC;AACF,CAAC,CAAA;AA0DD,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,CAAe,EAAU,EAAE;IACrE,MAAM,QAAQ,GAAG,CAAC,CAAC,gBAAgB,EAAE,CAAA;IACrC,OAAO,QAAQ,CAAC,CAAC;QACf,+BAA+B,CAAC,QAAQ,EAAE,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC;QAC/D,CAAC,CAAC,8BAA8B,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;AACvD,CAAC,CAAA;AAQD,MAAM,CAAC,MAAM,+BAA+B,GAAG,CAI9C,KAAY,EACZ,YAAY,EAAe,EACyB,EAAE,CACtD,UAAU,KAAK,6BACd,SAAS,CAAC,CAAC,CAAE,YAAY,SAAS,GAAW,CAAC,CAAC,CAAC,EACjD,EAAE,CAAA;AAEH,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAC7C,SAAoB,EACwB,EAAE,CAC9C,yBAAyB,SAAS,CAAC,CAAC,CAAC,YAAY,SAAS,GAAG,CAAC,CAAC,CAAC,EAAE,EAAW,CAAA"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { type BoundKind, type
|
|
1
|
+
import { type BoundKind, type LimitLiteral, type RawSchema } from "@arktype/schema";
|
|
2
2
|
import { type keySet } from "@arktype/util";
|
|
3
3
|
import type { astToString } from "../../../semantic/utils.js";
|
|
4
4
|
import type { DynamicState, DynamicStateWithRoot } from "../../reduce/dynamic.js";
|
|
5
|
-
import {
|
|
5
|
+
import { type Comparator, type InvertedComparators, type MaxComparator, writeUnpairableComparatorMessage } from "../../reduce/shared.js";
|
|
6
6
|
import type { StaticState, state } from "../../reduce/static.js";
|
|
7
7
|
import type { parseOperand } from "../operand/operand.js";
|
|
8
8
|
import type { Scanner } from "../scanner.js";
|
|
9
|
-
export declare const parseBound: (s: DynamicStateWithRoot, start: ComparatorStartChar) =>
|
|
10
|
-
export type parseBound<s extends StaticState, start extends ComparatorStartChar, unscanned extends string, $, args> = shiftComparator<start, unscanned> extends infer shiftResultOrError ? shiftResultOrError extends Scanner.shiftResult<infer comparator extends Comparator, infer nextUnscanned> ? s["root"] extends `${infer limit extends LimitLiteral}` ? state.reduceLeftBound<s, limit, comparator, nextUnscanned> : parseRightBound<state.scanTo<s, nextUnscanned>, comparator, $, args> : shiftResultOrError : never;
|
|
9
|
+
export declare const parseBound: (s: DynamicStateWithRoot, start: ComparatorStartChar) => void;
|
|
10
|
+
export type parseBound<s extends StaticState, start extends ComparatorStartChar, unscanned extends string, $, args> = shiftComparator<start, unscanned> extends infer shiftResultOrError ? shiftResultOrError extends (Scanner.shiftResult<infer comparator extends Comparator, infer nextUnscanned>) ? s["root"] extends `${infer limit extends LimitLiteral}` ? state.reduceLeftBound<s, limit, comparator, nextUnscanned> : parseRightBound<state.scanTo<s, nextUnscanned>, comparator, $, args> : shiftResultOrError : never;
|
|
11
11
|
declare const oneCharComparators: {
|
|
12
12
|
readonly "<": true;
|
|
13
13
|
readonly ">": true;
|
|
@@ -17,17 +17,20 @@ export type ComparatorStartChar = Comparator extends `${infer char}${string}` ?
|
|
|
17
17
|
export declare const comparatorStartChars: keySet<ComparatorStartChar>;
|
|
18
18
|
declare const shiftComparator: (s: DynamicState, start: ComparatorStartChar) => Comparator;
|
|
19
19
|
type shiftComparator<start extends ComparatorStartChar, unscanned extends string> = unscanned extends `=${infer nextUnscanned}` ? [`${start}=`, nextUnscanned] : start extends OneCharComparator ? [start, unscanned] : state.error<singleEqualsMessage>;
|
|
20
|
-
export declare const
|
|
21
|
-
export
|
|
22
|
-
export declare const writeIncompatibleRangeMessage: (l: BoundKind, r: BoundKind) => string;
|
|
23
|
-
export declare const writeLimitMismatchMessage: (root: string, limitValue: LimitSchemaValue) => string;
|
|
24
|
-
export declare const getBoundKinds: (comparator: Comparator, limit: LimitSchemaValue, root: TypeNode) => BoundKind[];
|
|
20
|
+
export declare const writeIncompatibleRangeMessage: (l: BoundKind, r: BoundKind) => "Bound kinds exactLength and exactLength are incompatible" | "Bound kinds exactLength and max are incompatible" | "Bound kinds exactLength and min are incompatible" | "Bound kinds exactLength and maxLength are incompatible" | "Bound kinds exactLength and minLength are incompatible" | "Bound kinds exactLength and before are incompatible" | "Bound kinds exactLength and after are incompatible" | "Bound kinds max and exactLength are incompatible" | "Bound kinds max and max are incompatible" | "Bound kinds max and min are incompatible" | "Bound kinds max and maxLength are incompatible" | "Bound kinds max and minLength are incompatible" | "Bound kinds max and before are incompatible" | "Bound kinds max and after are incompatible" | "Bound kinds min and exactLength are incompatible" | "Bound kinds min and max are incompatible" | "Bound kinds min and min are incompatible" | "Bound kinds min and maxLength are incompatible" | "Bound kinds min and minLength are incompatible" | "Bound kinds min and before are incompatible" | "Bound kinds min and after are incompatible" | "Bound kinds maxLength and exactLength are incompatible" | "Bound kinds maxLength and max are incompatible" | "Bound kinds maxLength and min are incompatible" | "Bound kinds maxLength and maxLength are incompatible" | "Bound kinds maxLength and minLength are incompatible" | "Bound kinds maxLength and before are incompatible" | "Bound kinds maxLength and after are incompatible" | "Bound kinds minLength and exactLength are incompatible" | "Bound kinds minLength and max are incompatible" | "Bound kinds minLength and min are incompatible" | "Bound kinds minLength and maxLength are incompatible" | "Bound kinds minLength and minLength are incompatible" | "Bound kinds minLength and before are incompatible" | "Bound kinds minLength and after are incompatible" | "Bound kinds before and exactLength are incompatible" | "Bound kinds before and max are incompatible" | "Bound kinds before and min are incompatible" | "Bound kinds before and maxLength are incompatible" | "Bound kinds before and minLength are incompatible" | "Bound kinds before and before are incompatible" | "Bound kinds before and after are incompatible" | "Bound kinds after and exactLength are incompatible" | "Bound kinds after and max are incompatible" | "Bound kinds after and min are incompatible" | "Bound kinds after and maxLength are incompatible" | "Bound kinds after and minLength are incompatible" | "Bound kinds after and before are incompatible" | "Bound kinds after and after are incompatible";
|
|
21
|
+
export declare const getBoundKinds: (comparator: Comparator, limit: LimitLiteral, root: RawSchema, boundKind: BoundExpressionKind) => BoundKind[];
|
|
25
22
|
export declare const singleEqualsMessage = "= is not a valid comparator. Use == to check for equality";
|
|
26
23
|
type singleEqualsMessage = typeof singleEqualsMessage;
|
|
27
|
-
export declare const parseRightBound: (s: DynamicStateWithRoot, comparator: Comparator) =>
|
|
24
|
+
export declare const parseRightBound: (s: DynamicStateWithRoot, comparator: Comparator) => void;
|
|
28
25
|
export type parseRightBound<s extends StaticState, comparator extends Comparator, $, args> = parseOperand<s, $, args> extends infer nextState extends StaticState ? nextState["root"] extends `${infer limit extends LimitLiteral}` ? s["branches"]["leftBound"] extends {} ? comparator extends MaxComparator ? state.reduceRange<s, s["branches"]["leftBound"]["limit"], s["branches"]["leftBound"]["comparator"], comparator, limit, nextState["unscanned"]> : state.error<writeUnpairableComparatorMessage<comparator>> : state.reduceSingleBound<s, comparator, limit, nextState["unscanned"]> : state.error<writeInvalidLimitMessage<comparator, astToString<nextState["root"]>, "right">> : never;
|
|
29
|
-
export declare const writeInvalidLimitMessage: <comparator extends "==" | "<" | "<=" | ">" | ">=", limit extends string | number, boundKind extends BoundExpressionKind>(comparator: comparator, limit: limit, boundKind: boundKind) => `Comparator ${
|
|
30
|
-
|
|
26
|
+
export declare const writeInvalidLimitMessage: <comparator extends "==" | "<" | "<=" | ">" | ">=", limit extends string | number, boundKind extends BoundExpressionKind>(comparator: comparator, limit: limit, boundKind: boundKind) => `Comparator ${boundKind extends "left" ? {
|
|
27
|
+
readonly "<": ">";
|
|
28
|
+
readonly ">": "<";
|
|
29
|
+
readonly "<=": ">=";
|
|
30
|
+
readonly ">=": "<=";
|
|
31
|
+
readonly "==": "==";
|
|
32
|
+
}[comparator] : comparator} must be ${boundKind extends "left" ? "preceded" : "followed"} by a corresponding literal (was '${limit}')`;
|
|
33
|
+
export type writeInvalidLimitMessage<comparator extends Comparator, limit extends string | number, boundKind extends BoundExpressionKind> = `Comparator ${boundKind extends "left" ? InvertedComparators[comparator] : comparator} must be ${boundKind extends "left" ? "preceded" : "followed"} by a corresponding literal (was '${limit}')`;
|
|
31
34
|
export type BoundExpressionKind = "left" | "right";
|
|
32
35
|
export {};
|
|
33
36
|
//# sourceMappingURL=bounds.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bounds.d.ts","sourceRoot":"","sources":["../../../../../parser/string/shift/operator/bounds.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"bounds.d.ts","sourceRoot":"","sources":["../../../../../parser/string/shift/operator/bounds.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,SAAS,EAEd,KAAK,YAAY,EAEjB,KAAK,SAAS,EAKd,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAW,KAAK,MAAM,EAAmB,MAAM,eAAe,CAAA;AACrE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AAC7D,OAAO,KAAK,EACX,YAAY,EACZ,oBAAoB,EACpB,MAAM,yBAAyB,CAAA;AAChC,OAAO,EACN,KAAK,UAAU,EACf,KAAK,mBAAmB,EACxB,KAAK,aAAa,EAIlB,gCAAgC,EAChC,MAAM,wBAAwB,CAAA;AAC/B,OAAO,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAA;AAEhE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACzD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAE5C,eAAO,MAAM,UAAU,MACnB,oBAAoB,SAChB,mBAAmB,KACxB,IAkBF,CAAA;AAED,MAAM,MAAM,UAAU,CACrB,CAAC,SAAS,WAAW,EACrB,KAAK,SAAS,mBAAmB,EACjC,SAAS,SAAS,MAAM,EACxB,CAAC,EACD,IAAI,IAEJ,eAAe,CAAC,KAAK,EAAE,SAAS,CAAC,SAAS,MAAM,kBAAkB,GACjE,kBAAkB,SAAS,CAC1B,OAAO,CAAC,WAAW,CAClB,MAAM,UAAU,SAAS,UAAU,EACnC,MAAM,aAAa,CACnB,CACD,G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@@ -1,18 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { isKeyOf, throwParseError
|
|
3
|
-
import { maxComparators, writeUnpairableComparatorMessage } from "../../reduce/shared.js";
|
|
1
|
+
import { internalKeywords, jsObjects, tsKeywords, writeUnboundableMessage } from "@arktype/schema";
|
|
2
|
+
import { isKeyOf, throwParseError } from "@arktype/util";
|
|
3
|
+
import { invertedComparators, maxComparators, writeUnpairableComparatorMessage } from "../../reduce/shared.js";
|
|
4
4
|
import { extractDateLiteralSource, isDateLiteral } from "../operand/date.js";
|
|
5
5
|
export const parseBound = (s, start) => {
|
|
6
6
|
const comparator = shiftComparator(s, start);
|
|
7
|
-
if (s.root.
|
|
7
|
+
if (s.root.hasKind("unit")) {
|
|
8
8
|
if (typeof s.root.unit === "number") {
|
|
9
|
+
s.reduceLeftBound(s.root.unit, comparator);
|
|
9
10
|
s.unsetRoot();
|
|
10
|
-
return
|
|
11
|
+
return;
|
|
11
12
|
}
|
|
12
13
|
if (s.root.unit instanceof Date) {
|
|
13
|
-
s.unsetRoot();
|
|
14
14
|
const literal = `d'${s.root.description ?? s.root.unit.toISOString()}'`;
|
|
15
|
-
|
|
15
|
+
s.unsetRoot();
|
|
16
|
+
s.reduceLeftBound(literal, comparator);
|
|
17
|
+
return;
|
|
16
18
|
}
|
|
17
19
|
}
|
|
18
20
|
return parseRightBound(s, comparator);
|
|
@@ -26,49 +28,39 @@ export const comparatorStartChars = {
|
|
|
26
28
|
">": 1,
|
|
27
29
|
"=": 1
|
|
28
30
|
};
|
|
29
|
-
const shiftComparator = (s, start) => s.scanner.lookaheadIs("=")
|
|
30
|
-
?
|
|
31
|
-
: isKeyOf(start, oneCharComparators)
|
|
32
|
-
? start
|
|
31
|
+
const shiftComparator = (s, start) => s.scanner.lookaheadIs("=") ? `${start}${s.scanner.shift()}`
|
|
32
|
+
: isKeyOf(start, oneCharComparators) ? start
|
|
33
33
|
: s.error(singleEqualsMessage);
|
|
34
|
-
export const writeUnboundableMessage = (root) => `Bounded expression ${root} must be a number, string, Array, or Date`;
|
|
35
34
|
export const writeIncompatibleRangeMessage = (l, r) => `Bound kinds ${l} and ${r} are incompatible`;
|
|
36
|
-
export const
|
|
37
|
-
|
|
38
|
-
if (root.extends(keywords.number)) {
|
|
35
|
+
export const getBoundKinds = (comparator, limit, root, boundKind) => {
|
|
36
|
+
if (root.extends(tsKeywords.number)) {
|
|
39
37
|
if (typeof limit !== "number") {
|
|
40
|
-
return throwParseError(
|
|
38
|
+
return throwParseError(writeInvalidLimitMessage(comparator, limit, boundKind));
|
|
41
39
|
}
|
|
42
|
-
return comparator === "=="
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
? ["min"]
|
|
46
|
-
: ["max"];
|
|
40
|
+
return (comparator === "==" ? ["min", "max"]
|
|
41
|
+
: comparator[0] === ">" ? ["min"]
|
|
42
|
+
: ["max"]);
|
|
47
43
|
}
|
|
48
|
-
if (root.extends(
|
|
44
|
+
if (root.extends(internalKeywords.lengthBoundable)) {
|
|
49
45
|
if (typeof limit !== "number") {
|
|
50
|
-
return throwParseError(
|
|
46
|
+
return throwParseError(writeInvalidLimitMessage(comparator, limit, boundKind));
|
|
51
47
|
}
|
|
52
|
-
return comparator === "=="
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
? ["minLength"]
|
|
56
|
-
: ["maxLength"];
|
|
48
|
+
return (comparator === "==" ? ["minLength", "maxLength"]
|
|
49
|
+
: comparator[0] === ">" ? ["minLength"]
|
|
50
|
+
: ["maxLength"]);
|
|
57
51
|
}
|
|
58
|
-
if (root.extends(
|
|
52
|
+
if (root.extends(jsObjects.Date)) {
|
|
59
53
|
// allow either numeric or date limits
|
|
60
|
-
return comparator === "=="
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
? ["after"]
|
|
64
|
-
: ["before"];
|
|
54
|
+
return (comparator === "==" ? ["after", "before"]
|
|
55
|
+
: comparator[0] === ">" ? ["after"]
|
|
56
|
+
: ["before"]);
|
|
65
57
|
}
|
|
66
|
-
return throwParseError(writeUnboundableMessage(root.
|
|
58
|
+
return throwParseError(writeUnboundableMessage(root.expression));
|
|
67
59
|
};
|
|
68
|
-
export const singleEqualsMessage =
|
|
60
|
+
export const singleEqualsMessage = "= is not a valid comparator. Use == to check for equality";
|
|
69
61
|
const openLeftBoundToSchema = (leftBound) => ({
|
|
70
|
-
|
|
71
|
-
|
|
62
|
+
rule: isDateLiteral(leftBound.limit) ?
|
|
63
|
+
extractDateLiteralSource(leftBound.limit)
|
|
72
64
|
: leftBound.limit,
|
|
73
65
|
exclusive: leftBound.comparator.length === 1
|
|
74
66
|
});
|
|
@@ -77,19 +69,21 @@ export const parseRightBound = (s, comparator) => {
|
|
|
77
69
|
const previousRoot = s.unsetRoot();
|
|
78
70
|
const previousScannerIndex = s.scanner.location;
|
|
79
71
|
s.parseOperand();
|
|
72
|
+
const limitNode = s.unsetRoot();
|
|
80
73
|
// after parsing the next operand, use the locations to get the
|
|
81
74
|
// token from which it was parsed
|
|
82
75
|
const limitToken = s.scanner.sliceChars(previousScannerIndex, s.scanner.location);
|
|
83
|
-
s.
|
|
84
|
-
|
|
85
|
-
(
|
|
86
|
-
|
|
87
|
-
|
|
76
|
+
s.root = previousRoot;
|
|
77
|
+
if (!limitNode.hasKind("unit") ||
|
|
78
|
+
(typeof limitNode.unit !== "number" && !(limitNode.unit instanceof Date))) {
|
|
79
|
+
return s.error(writeInvalidLimitMessage(comparator, limitToken, "right"));
|
|
80
|
+
}
|
|
81
|
+
const limit = limitNode.unit;
|
|
88
82
|
// apply the newly-parsed right bound
|
|
89
83
|
const exclusive = comparator.length === 1;
|
|
90
84
|
// if the comparator is ==, both the min and max of that pair will be applied
|
|
91
|
-
for (const kind of getBoundKinds(comparator, limit, previousRoot)) {
|
|
92
|
-
s.constrainRoot(kind, { limit, exclusive });
|
|
85
|
+
for (const kind of getBoundKinds(comparator, typeof limit === "number" ? limit : limitToken, previousRoot, "right")) {
|
|
86
|
+
s.constrainRoot(kind, { rule: limit, exclusive });
|
|
93
87
|
}
|
|
94
88
|
if (!s.branches.leftBound) {
|
|
95
89
|
return;
|
|
@@ -98,9 +92,9 @@ export const parseRightBound = (s, comparator) => {
|
|
|
98
92
|
if (!isKeyOf(comparator, maxComparators)) {
|
|
99
93
|
return s.error(writeUnpairableComparatorMessage(comparator));
|
|
100
94
|
}
|
|
101
|
-
const lowerBoundKind = getBoundKinds(s.branches.leftBound.comparator, s.branches.leftBound.limit, previousRoot);
|
|
95
|
+
const lowerBoundKind = getBoundKinds(s.branches.leftBound.comparator, s.branches.leftBound.limit, previousRoot, "left");
|
|
102
96
|
s.constrainRoot(lowerBoundKind[0], openLeftBoundToSchema(s.branches.leftBound));
|
|
103
|
-
|
|
97
|
+
s.branches.leftBound = null;
|
|
104
98
|
};
|
|
105
|
-
export const writeInvalidLimitMessage = (comparator, limit, boundKind) => `Comparator ${comparator} must be ${boundKind === "left" ? "preceded" : "followed"} by a corresponding literal (was '${limit}')`;
|
|
99
|
+
export const writeInvalidLimitMessage = (comparator, limit, boundKind) => `Comparator ${boundKind === "left" ? invertedComparators[comparator] : comparator} must be ${boundKind === "left" ? "preceded" : "followed"} by a corresponding literal (was '${limit}')`;
|
|
106
100
|
//# sourceMappingURL=bounds.js.map
|