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
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { invert, isKeyOf } from "@arktype/util";
|
|
2
|
+
import { BasePrimitiveConstraint } from "../constraint.js";
|
|
3
|
+
export class BaseRange extends BasePrimitiveConstraint {
|
|
4
|
+
boundOperandKind = operandKindsByBoundKind[this.kind];
|
|
5
|
+
compiledActual = this.boundOperandKind === "value"
|
|
6
|
+
? `data`
|
|
7
|
+
: this.boundOperandKind === "length"
|
|
8
|
+
? `data.length`
|
|
9
|
+
: `data.valueOf()`;
|
|
10
|
+
comparator = compileComparator(this.kind, this.exclusive);
|
|
11
|
+
numericLimit = this.rule.valueOf();
|
|
12
|
+
expression = `${this.comparator}${this.rule}`;
|
|
13
|
+
compiledCondition = `${this.compiledActual} ${this.comparator} ${this.numericLimit}`;
|
|
14
|
+
compiledNegation = `${this.compiledActual} ${negatedComparators[this.comparator]} ${this.numericLimit}`;
|
|
15
|
+
// we need to compute stringLimit before errorContext, which references it
|
|
16
|
+
// transitively through description for date bounds
|
|
17
|
+
stringLimit = this.boundOperandKind === "date"
|
|
18
|
+
? dateLimitToString(this.numericLimit)
|
|
19
|
+
: `${this.numericLimit}`;
|
|
20
|
+
errorContext = this.createErrorContext(this.inner);
|
|
21
|
+
limitKind = this.comparator["0"] === "<" ? "upper" : "lower";
|
|
22
|
+
isStricterThan(r) {
|
|
23
|
+
const thisLimitIsStricter = this.limitKind === "upper"
|
|
24
|
+
? this.numericLimit < r.numericLimit
|
|
25
|
+
: this.numericLimit > r.numericLimit;
|
|
26
|
+
return (thisLimitIsStricter ||
|
|
27
|
+
(this.numericLimit === r.numericLimit &&
|
|
28
|
+
this.exclusive === true &&
|
|
29
|
+
!r.exclusive));
|
|
30
|
+
}
|
|
31
|
+
overlapsRange(r) {
|
|
32
|
+
if (this.isStricterThan(r))
|
|
33
|
+
return false;
|
|
34
|
+
if (this.numericLimit === r.numericLimit && (this.exclusive || r.exclusive))
|
|
35
|
+
return false;
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
overlapIsUnit(r) {
|
|
39
|
+
return (this.numericLimit === r.numericLimit && !this.exclusive && !r.exclusive);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
export const negatedComparators = {
|
|
43
|
+
"<": ">=",
|
|
44
|
+
"<=": ">",
|
|
45
|
+
">": "<=",
|
|
46
|
+
">=": "<"
|
|
47
|
+
};
|
|
48
|
+
export const boundKindPairsByLower = {
|
|
49
|
+
min: "max",
|
|
50
|
+
minLength: "maxLength",
|
|
51
|
+
after: "before"
|
|
52
|
+
};
|
|
53
|
+
export const boundKindPairsByUpper = invert(boundKindPairsByLower);
|
|
54
|
+
export const parseExclusiveKey = {
|
|
55
|
+
// omit key with value false since it is the default
|
|
56
|
+
parse: (flag) => flag || undefined
|
|
57
|
+
};
|
|
58
|
+
export const parseDateLimit = (limit) => typeof limit === "string" || typeof limit === "number"
|
|
59
|
+
? new Date(limit)
|
|
60
|
+
: limit;
|
|
61
|
+
export const operandKindsByBoundKind = {
|
|
62
|
+
min: "value",
|
|
63
|
+
max: "value",
|
|
64
|
+
minLength: "length",
|
|
65
|
+
maxLength: "length",
|
|
66
|
+
after: "date",
|
|
67
|
+
before: "date"
|
|
68
|
+
};
|
|
69
|
+
export const compileComparator = (kind, exclusive) => `${isKeyOf(kind, boundKindPairsByLower) ? ">" : "<"}${exclusive ? "" : "="}`;
|
|
70
|
+
export const dateLimitToString = (limit) => typeof limit === "string" ? limit : new Date(limit).toLocaleString();
|
|
71
|
+
export const writeUnboundableMessage = (root) => `Bounded expression ${root} must be a number, string, Array, or Date`;
|
|
72
|
+
//# sourceMappingURL=range.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"range.js","sourceRoot":"","sources":["../../../constraints/refinements/range.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,MAAM,EACN,OAAO,EAIP,MAAM,eAAe,CAAA;AAItB,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAA;AAE1D,MAAM,OAAgB,SAEpB,SAAQ,uBAA0B;IAC1B,gBAAgB,GAAG,uBAAuB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACrD,cAAc,GACtB,IAAI,CAAC,gBAAgB,KAAK,OAAO;QAChC,CAAC,CAAC,MAAM;QACR,CAAC,CAAC,IAAI,CAAC,gBAAgB,KAAK,QAAQ;YACpC,CAAC,CAAC,aAAa;YACf,CAAC,CAAC,gBAAgB,CAAA;IACX,UAAU,GAAG,iBA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AQ;IACnB,KAAK,EAAE,MAAM;IACb,MAAM,EAAE,MAAM;CACyC,CAAA;AAExD,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAChC,IAAe,EACf,SAA8B,EAC7B,EAAE,CACH,GAAG,OAAO,CAAC,IAAI,EAAE,qBAAqB,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,GAClD,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAClB,EAAW,CAAA;AAQZ,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,KAAuB,EAAU,EAAE,CACpE,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,cAAc,EAAE,CAAA;AAErE,MAAM,CAAC,MAAM,uBAAuB,GAAG,CACtC,IAAU,EACsB,EAAE,CAClC,sBAAsB,IAAI,2CAA2C,CAAA"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { BaseMeta, declareNode } from "../../shared/declare.js";
|
|
2
|
+
import { BasePrimitiveConstraint } from "../constraint.js";
|
|
3
|
+
export interface RegexInner extends BaseMeta {
|
|
4
|
+
readonly rule: string;
|
|
5
|
+
readonly flags?: string;
|
|
6
|
+
}
|
|
7
|
+
export type NormalizedRegexSchema = RegexInner;
|
|
8
|
+
export type RegexSchema = NormalizedRegexSchema | string | RegExp;
|
|
9
|
+
export type RegexDeclaration = declareNode<{
|
|
10
|
+
kind: "regex";
|
|
11
|
+
schema: RegexSchema;
|
|
12
|
+
normalizedSchema: NormalizedRegexSchema;
|
|
13
|
+
inner: RegexInner;
|
|
14
|
+
intersectionIsOpen: true;
|
|
15
|
+
prerequisite: string;
|
|
16
|
+
errorContext: RegexInner;
|
|
17
|
+
}>;
|
|
18
|
+
export declare class RegexNode extends BasePrimitiveConstraint<RegexDeclaration> {
|
|
19
|
+
static implementation: import("../../shared/implement.js").nodeImplementationOf<{
|
|
20
|
+
reducibleTo: "regex";
|
|
21
|
+
childKind: never;
|
|
22
|
+
kind: "regex";
|
|
23
|
+
schema: RegexSchema;
|
|
24
|
+
normalizedSchema: RegexInner;
|
|
25
|
+
inner: RegexInner;
|
|
26
|
+
intersectionIsOpen: true;
|
|
27
|
+
prerequisite: string;
|
|
28
|
+
errorContext: RegexInner & import("../../shared/declare.js").BaseErrorContext<"regex">;
|
|
29
|
+
}>;
|
|
30
|
+
readonly instance: RegExp;
|
|
31
|
+
readonly expression: string;
|
|
32
|
+
traverseAllows: (string: string) => boolean;
|
|
33
|
+
readonly compiledCondition: string;
|
|
34
|
+
readonly compiledNegation: string;
|
|
35
|
+
readonly impliedBasis: import("../../main.js").Type<string, import("../../keywords/tsPrimitive.js").tsPrimitive.exports>;
|
|
36
|
+
readonly errorContext: {
|
|
37
|
+
code: "regex";
|
|
38
|
+
readonly rule: string;
|
|
39
|
+
readonly flags?: string;
|
|
40
|
+
readonly description?: string;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=regex.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"regex.d.ts","sourceRoot":"","sources":["../../../constraints/refinements/regex.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AACpE,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAA;AAE1D,MAAM,WAAW,UAAW,SAAQ,QAAQ;IAC3C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CACvB;AAED,MAAM,MAAM,qBAAqB,GAAG,UAAU,CAAA;AAE9C,MAAM,MAAM,WAAW,GAAG,qBAAqB,GAAG,MAAM,GAAG,MAAM,CAAA;AAEjE,MAAM,MAAM,gBAAgB,GAAG,WAAW,CAAC;IAC1C,IAAI,EAAE,OAAO,CAAA;IACb,MAAM,EAAE,WAAW,CAAA;IACnB,gBAAgB,EAAE,qBAAqB,CAAA;IACvC,KAAK,EAAE,UAAU,CAAA;IACjB,kBAAkB,EAAE,IAAI,CAAA;IACxB,YAAY,EAAE,MAAM,CAAA;IACpB,YAAY,EAAE,UAAU,CAAA;CACxB,CAAC,CAAA;AAEF,qBAAa,SAAU,SAAQ,uBAAuB,CAAC,gBAAgB,CAAC;IACvE,MAAM,CAAC,cAAc;;;;;;;;;;OAyBnB;IAEF,QAAQ,CAAC,QAAQ,SAAoC;IACrD,QAAQ,CAAC,UAAU,SAAqB;IACxC,cAAc,8BAAyC;IAEvD,QAAQ,CAAC,iBAAiB,SAAkC;IAC5D,QAAQ,CAAC,gBAAgB,SAA+B;IACxD,QAAQ,CAAC,YAAY,oGAAyB;IAC9C,QAAQ,CAAC,YAAY;;;;;MAAsC;CAC3D"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { BasePrimitiveConstraint } from "../constraint.js";
|
|
2
|
+
export class RegexNode extends BasePrimitiveConstraint {
|
|
3
|
+
static implementation = this.implement({
|
|
4
|
+
collapsibleKey: "rule",
|
|
5
|
+
keys: {
|
|
6
|
+
rule: {},
|
|
7
|
+
flags: {}
|
|
8
|
+
},
|
|
9
|
+
normalize: (schema) => typeof schema === "string"
|
|
10
|
+
? { rule: schema }
|
|
11
|
+
: schema instanceof RegExp
|
|
12
|
+
? schema.flags
|
|
13
|
+
? { rule: schema.source, flags: schema.flags }
|
|
14
|
+
: { rule: schema.source }
|
|
15
|
+
: schema,
|
|
16
|
+
hasAssociatedError: true,
|
|
17
|
+
intersectionIsOpen: true,
|
|
18
|
+
intersections: {
|
|
19
|
+
// for now, non-equal regex are naively intersected
|
|
20
|
+
regex: () => null
|
|
21
|
+
},
|
|
22
|
+
defaults: {
|
|
23
|
+
description(node) {
|
|
24
|
+
return `matched by ${node.rule}`;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
instance = new RegExp(this.rule, this.flags);
|
|
29
|
+
expression = `${this.instance}`;
|
|
30
|
+
traverseAllows = this.instance.test.bind(this.instance);
|
|
31
|
+
compiledCondition = `${this.expression}.test(data)`;
|
|
32
|
+
compiledNegation = `!${this.compiledCondition}`;
|
|
33
|
+
impliedBasis = this.$.keywords.string;
|
|
34
|
+
errorContext = this.createErrorContext(this.inner);
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=regex.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"regex.js","sourceRoot":"","sources":["../../../constraints/refinements/regex.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAA;AAqB1D,MAAM,OAAO,SAAU,SAAQ,uBAAyC;IACvE,MAAM,CAAC,cAAc,GAAG,IAAI,CAAC,SAAS,CAAC;QACtC,cAAc,EAAE,MAAM;QACtB,IAAI,EAAE;YACL,IAAI,EAAE,EAAE;YACR,KAAK,EAAE,EAAE;SACT;QACD,SAAS,EAAE,CAAC,MAAM,EAAE,EAAE,CACrB,OAAO,MAAM,KAAK,QAAQ;YACzB,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE;YAClB,CAAC,CAAC,MAAM,YAAY,MAAM;gBAC1B,CAAC,CAAC,MAAM,CAAC,KAAK;oBACb,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE;oBAC9C,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE;gBAC1B,CAAC,CAAC,MAAM;QACV,kBAAkB,EAAE,IAAI;QACxB,kBAAkB,EAAE,IAAI;QACxB,aAAa,EAAE;YACd,mDAAmD;YACnD,KAAK,EAAE,GAAG,EAAE,CAAC,IAAI;SACjB;QACD,QAAQ,EAAE;YACT,WAAW,CAAC,IAAI;gBACf,OAAO,cAAc,IAAI,CAAC,IAAI,EAAE,CAAA;YACjC,CAAC;SACD;KACD,CAAC,CAAA;IAEO,QAAQ,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,CAAA;IAC5C,UAAU,GAAG,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAA;IACxC,cAAc,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IAE9C,iBAAiB,GAAG,GAAG,IAAI,CAAC,UAAU,aAAa,CAAA;IACnD,gBAAgB,GAAG,IAAI,IAAI,CAAC,iBAAiB,EAAE,CAAA;IAC/C,YAAY,GAAG,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAA;IACrC,YAAY,GAAG,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const rangeKinds: readonly ["max", "min", "maxLength", "minLength", "before", "after"];
|
|
2
|
+
export type RangeKind = (typeof rangeKinds)[number];
|
|
3
|
+
export declare const boundKinds: readonly ["length", "max", "min", "maxLength", "minLength", "before", "after"];
|
|
4
|
+
export type BoundKind = (typeof boundKinds)[number];
|
|
5
|
+
//# sourceMappingURL=shared.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../../constraints/refinements/shared.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU,sEAOb,CAAA;AAEV,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,CAAC,CAAA;AAEnD,eAAO,MAAM,UAAU,gFAAqC,CAAA;AAE5D,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../constraints/refinements/shared.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,UAAU,GAAG;IACzB,KAAK;IACL,KAAK;IACL,WAAW;IACX,WAAW;IACX,QAAQ;IACR,OAAO;CACE,CAAA;AAIV,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,QAAQ,EAAE,GAAG,UAAU,CAAU,CAAA"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { Constructor, ErrorMessage, List, NonEnumerableDomain, conform, describe } from "@arktype/util";
|
|
2
|
+
import type { Node, TypeNode } from "./base.js";
|
|
3
|
+
import type { isSchemaCast, schema } from "./builtins/builtins.js";
|
|
4
|
+
import type { Prerequisite } from "./kinds.js";
|
|
5
|
+
import type { ConstraintKind } from "./shared/implement.js";
|
|
6
|
+
import type { instantiateBasis } from "./types/basis.js";
|
|
7
|
+
import type { DomainNode, DomainSchema } from "./types/domain.js";
|
|
8
|
+
import type { IntersectionNode, IntersectionSchema } from "./types/intersection.js";
|
|
9
|
+
import type { Morph, MorphChildDefinition, MorphChildKind, MorphSchema, Out, inferMorphOut } from "./types/morph.js";
|
|
10
|
+
import type { ProtoNode, ProtoSchema } from "./types/proto.js";
|
|
11
|
+
import type { NormalizedUnionSchema, UnionChildNode } from "./types/union.js";
|
|
12
|
+
import type { UnitSchema } from "./types/unit.js";
|
|
13
|
+
export type validateAliases<aliases> = {
|
|
14
|
+
[k in keyof aliases]: "branches" extends keyof aliases[k] ? conform<aliases[k], NormalizedUnionSchema> : aliases[k] extends readonly [...infer branches] ? {
|
|
15
|
+
[i in keyof branches]: validateSchemaBranch<branches[i], aliases>;
|
|
16
|
+
} : validateSchemaBranch<aliases[k], aliases>;
|
|
17
|
+
};
|
|
18
|
+
export type instantiateAliases<aliases> = {
|
|
19
|
+
[k in keyof aliases]: isSchemaCast<aliases[k]> extends true ? aliases[k] extends schema.cast<infer to, infer kind> ? TypeNode<to, kind> : never : aliases[k] extends NormalizedUnionSchema ? instantiateSchemaBranches<aliases[k]["branches"]> : aliases[k] extends readonly [...infer branches] ? instantiateSchemaBranches<branches> : instantiateSchemaBranch<aliases[k]>;
|
|
20
|
+
} & unknown;
|
|
21
|
+
export type validateSchemaBranch<def, $> = isSchemaCast<def> extends true ? def : keyof def & ("morph" | "in" | "out") extends never ? validateMorphChild<def> : validateMorphSchema<def>;
|
|
22
|
+
export type instantiateSchemaBranches<branches extends List> = branches["length"] extends 0 ? TypeNode<never, "union"> : branches["length"] extends 1 ? instantiateSchemaBranch<branches[0]> : TypeNode<instantiateSchemaBranch<branches[number]>["infer"]>;
|
|
23
|
+
export type instantiateSchemaBranch<def> = isSchemaCast<def> extends true ? def extends schema.cast<infer to, infer kind> ? TypeNode<to, kind> : never : def extends MorphSchema ? instantiateMorphSchema<def> : def extends MorphChildDefinition ? instantiateMorphChild<def> : UnionChildNode;
|
|
24
|
+
type NonIntersectableBasisSchema = NonEnumerableDomain | Constructor | UnitSchema;
|
|
25
|
+
export type validateMorphChild<def> = [def] extends [
|
|
26
|
+
NonIntersectableBasisSchema
|
|
27
|
+
] ? def : validateIntersectionSchema<def>;
|
|
28
|
+
export type instantiateMorphChild<def> = def extends NonIntersectableBasisSchema ? instantiateBasis<def> : def extends IntersectionSchema ? instantiateIntersectionSchema<def> : Node<MorphChildKind>;
|
|
29
|
+
export type validateMorphSchema<def> = {
|
|
30
|
+
[k in keyof def]: k extends "in" | "out" ? validateMorphChild<def[k]> : k extends keyof MorphSchema ? MorphSchema[k] : `'${k & string}' is not a valid morph schema key`;
|
|
31
|
+
};
|
|
32
|
+
export type instantiateMorphSchema<def> = def extends MorphSchema ? TypeNode<(In: def["in"] extends {} ? instantiateMorphChild<def["in"]>["infer"] : unknown) => def["out"] extends {} ? Out<instantiateMorphChild<def["out"]>["infer"]> : def["morph"] extends Morph<any, infer o> | readonly [...unknown[], Morph<any, infer o>] ? Out<inferMorphOut<o>> : never, "morph"> : never;
|
|
33
|
+
type exactBasisMessageOnError<def, expected> = {
|
|
34
|
+
[k in keyof def]: k extends keyof expected ? conform<def[k], expected[k]> : ErrorMessage<k extends ConstraintKind ? `${k} has a prerequisite of ${describe<Prerequisite<k>>}` : `'${k & string}' is not on an intersection schema`>;
|
|
35
|
+
};
|
|
36
|
+
export type validateIntersectionSchema<schema> = exactBasisMessageOnError<schema, IntersectionSchema<inferBasisOf<schema>>>;
|
|
37
|
+
type inferBasisOf<schema> = "proto" extends keyof schema ? instantiateBasis<conform<schema["proto"], ProtoSchema>>["infer"] : "domain" extends keyof schema ? instantiateBasis<conform<schema["domain"], DomainSchema>>["infer"] : unknown;
|
|
38
|
+
export type instantiateIntersectionSchema<def> = keyof def & ConstraintKind extends never ? "proto" extends keyof def ? ProtoNode<inferBasisOf<def>> : "domain" extends keyof def ? DomainNode<inferBasisOf<def>> : IntersectionNode : IntersectionNode<inferBasisOf<def>>;
|
|
39
|
+
export {};
|
|
40
|
+
//# sourceMappingURL=inference.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inference.d.ts","sourceRoot":"","sources":["../inference.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,WAAW,EACX,YAAY,EACZ,IAAI,EACJ,mBAAmB,EACnB,OAAO,EACP,QAAQ,EACR,MAAM,eAAe,CAAA;AACtB,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAC/C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAClE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAC9C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAC3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AACxD,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AACjE,OAAO,KAAK,EACX,gBAAgB,EAChB,kBAAkB,EAClB,MAAM,yBAAyB,CAAA;AAChC,OAAO,KAAK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,CAAC,CAAC,CAAC,CAAC,GAC5B,YAAY,CACZ,CAAC,SAAS,cAAc,GACrB,GAAG,CAAC,0BAA0B,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,EAAE,GACzD,IAAI,CAAC,GAAG,MAAM,oCAAoC,CACpD;CACJ,CAAA;AAED,MAAM,MAAM,0BAA0B,CAAC,MAAM,IAAI,wBAAwB,CACxE,MAAM,EACN,kBAAkB,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CACxC,CAAA;AAED,KAAK,YAAY,CAAC,MAAM,IAAI,OAAO,SAAS,MAAM,MAAM,GACrD,gBAAgB,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,GAChE,QAAQ,SAAS,MAAM,MAAM,GAC7B,gBAAgB,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,GAClE,OAAO,CAAA;AAEV,MAAM,MAAM,6BAA6B,CAAC,GAAG,IAAI,MAAM,GAAG,GACzD,cAAc,SAAS,KAAK,GAC1B,OAAO,SAAS,MAAM,GAAG,GACxB,SAAS,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,GAC5B,QAAQ,SAAS,MAAM,GAAG,GAC1B,UAAU,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,GAC7B,gBAAgB,GACjB,gBAAgB,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAA"}
|
package/out/inference.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
export {};
|
|
2
|
+
// export type inferPropsInput<input extends PropsInput> =
|
|
3
|
+
// input extends PropsInputTuple<infer named, infer indexed>
|
|
4
|
+
// ? inferIndexed<indexed, inferNamedProps<named, indexed>>
|
|
5
|
+
// : input extends NamedPropsInput
|
|
6
|
+
// ? inferNamedProps<input, []>
|
|
7
|
+
// : never
|
|
8
|
+
// type inferIndexed<
|
|
9
|
+
// indexed extends readonly IndexedPropInput[],
|
|
10
|
+
// result = unknown
|
|
11
|
+
// > = indexed extends readonly [
|
|
12
|
+
// infer entry extends IndexedPropInput,
|
|
13
|
+
// ...infer tail extends IndexedPropInput[]
|
|
14
|
+
// ]
|
|
15
|
+
// ? inferIndexed<
|
|
16
|
+
// tail,
|
|
17
|
+
// entry["key"] extends { readonly regex: VariadicIndexMatcherLiteral }
|
|
18
|
+
// ? result extends List
|
|
19
|
+
// ? [...result, ...inferTypeInput<entry["value"]>[]]
|
|
20
|
+
// : never
|
|
21
|
+
// : entry["key"] extends {
|
|
22
|
+
// readonly regex: NonVariadicIndexMatcherLiteral
|
|
23
|
+
// }
|
|
24
|
+
// ? inferTypeInput<entry["value"]>[]
|
|
25
|
+
// : Record<
|
|
26
|
+
// Extract<inferTypeInput<entry["key"]>, PropertyKey>,
|
|
27
|
+
// inferTypeInput<entry["value"]>
|
|
28
|
+
// >
|
|
29
|
+
// >
|
|
30
|
+
// : result
|
|
31
|
+
// type inferNamedProps<
|
|
32
|
+
// named extends NamedPropsInput,
|
|
33
|
+
// indexed extends readonly IndexedPropInput[]
|
|
34
|
+
// > = [named, indexed[0]["key"]] extends
|
|
35
|
+
// | [TupleLengthProps, unknown]
|
|
36
|
+
// | [unknown, { readonly regex: VariadicIndexMatcherLiteral }]
|
|
37
|
+
// ? inferNonVariadicTupleProps<named> &
|
|
38
|
+
// inferObjectLiteralProps<Omit<named, "length" | NumberLiteral | number>>
|
|
39
|
+
// : inferObjectLiteralProps<named>
|
|
40
|
+
// type inferObjectLiteralProps<named extends NamedPropsInput> = {} extends named
|
|
41
|
+
// ? unknown
|
|
42
|
+
// : evaluate<
|
|
43
|
+
// {
|
|
44
|
+
// [k in requiredKeyOf<named>]: inferPropValue<named[k]["value"]>
|
|
45
|
+
// } & {
|
|
46
|
+
// [k in optionalKeyOf<named>]?: inferPropValue<named[k]["value"]>
|
|
47
|
+
// }
|
|
48
|
+
// >
|
|
49
|
+
// type inferPropValue<value extends PropValueInput> = value extends Thunk<
|
|
50
|
+
// infer ret
|
|
51
|
+
// >
|
|
52
|
+
// ? inferResolvedPropValue<ret>
|
|
53
|
+
// : inferResolvedPropValue<value>
|
|
54
|
+
// type inferResolvedPropValue<value> = value extends TypeNode<infer t>
|
|
55
|
+
// ? t
|
|
56
|
+
// : inferTypeInput<Extract<value, TypeInput>>
|
|
57
|
+
// type stringifiedNumericKeyOf<t> = `${Extract<keyof t, number | NumberLiteral>}`
|
|
58
|
+
// type inferNonVariadicTupleProps<
|
|
59
|
+
// named extends NamedPropsInput,
|
|
60
|
+
// result extends unknown[] = []
|
|
61
|
+
// > = `${result["length"]}` extends stringifiedNumericKeyOf<named>
|
|
62
|
+
// ? inferNonVariadicTupleProps<
|
|
63
|
+
// named,
|
|
64
|
+
// [...result, inferPropValue<named[`${result["length"]}`]["value"]>]
|
|
65
|
+
// >
|
|
66
|
+
// : result
|
|
67
|
+
// type TupleLengthProps<length extends number = number> = {
|
|
68
|
+
// readonly length: {
|
|
69
|
+
// readonly prerequisite: true
|
|
70
|
+
// readonly value: { readonly basis: readonly ["===", length] }
|
|
71
|
+
// }
|
|
72
|
+
// }
|
|
73
|
+
//# sourceMappingURL=inference.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inference.js","sourceRoot":"","sources":["../inference.ts"],"names":[],"mappings":";AAmJA,0DAA0D;AAC1D,6DAA6D;AAC7D,6DAA6D;AAC7D,oCAAoC;AACpC,iCAAiC;AACjC,YAAY;AAEZ,qBAAqB;AACrB,gDAAgD;AAChD,oBAAoB;AACpB,iCAAiC;AACjC,yCAAyC;AACzC,4CAA4C;AAC5C,IAAI;AACJ,mBAAmB;AACnB,WAAW;AACX,0EAA0E;AAC1E,4BAA4B;AAC5B,0DAA0D;AAC1D,eAAe;AACf,+BAA+B;AAC/B,uDAAuD;AACvD,UAAU;AACV,yCAAyC;AACzC,gBAAgB;AAChB,4DAA4D;AAC5D,uCAAuC;AACvC,UAAU;AACV,OAAO;AACP,YAAY;AAEZ,wBAAwB;AACxB,kCAAkC;AAClC,+CAA+C;AAC/C,yCAAyC;AACzC,iCAAiC;AACjC,gEAAgE;AAChE,yCAAyC;AACzC,6EAA6E;AAC7E,oCAAoC;AAEpC,iFAAiF;AACjF,aAAa;AACb,eAAe;AACf,OAAO;AACP,qEAAqE;AACrE,WAAW;AACX,sEAAsE;AACtE,OAAO;AACP,OAAO;AAEP,2EAA2E;AAC3E,aAAa;AACb,IAAI;AACJ,iCAAiC;AACjC,mCAAmC;AAEnC,uEAAuE;AACvE,OAAO;AACP,+CAA+C;AAE/C,kFAAkF;AAElF,mCAAmC;AACnC,kCAAkC;AAClC,iCAAiC;AACjC,mEAAmE;AACnE,iCAAiC;AACjC,YAAY;AACZ,wEAAwE;AACxE,OAAO;AACP,YAAY;AAEZ,4DAA4D;AAC5D,sBAAsB;AACtB,gCAAgC;AAChC,iEAAiE;AACjE,KAAK;AACL,IAAI"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { MatchParser } from "../match.js";
|
|
2
|
+
import type { NodeParser, SchemaParser } from "../schema.js";
|
|
3
|
+
import type { Module, Scope, ScopeParser } from "../scope.js";
|
|
4
|
+
import type { inferred } from "../shared/inference.js";
|
|
5
|
+
import type { DeclarationParser, DefinitionParser, Generic, TypeParser } from "../type.js";
|
|
6
|
+
import "./internal.js";
|
|
7
|
+
import { type tsPrimitive } from "./tsPrimitive.js";
|
|
8
|
+
import { type jsObject } from "./jsObject.js";
|
|
9
|
+
import { type parsing } from "./parsing.js";
|
|
10
|
+
import { type validation } from "./validation.js";
|
|
11
|
+
/** Root scopes can be inferred automatically from node definitions, but
|
|
12
|
+
* explicitly typing them can improve responsiveness */
|
|
13
|
+
export type RootScope<exports> = Scope<{
|
|
14
|
+
exports: exports;
|
|
15
|
+
locals: {};
|
|
16
|
+
ambient: {};
|
|
17
|
+
}>;
|
|
18
|
+
export type ArkResolutions = {
|
|
19
|
+
exports: Ark;
|
|
20
|
+
locals: {};
|
|
21
|
+
ambient: Ark;
|
|
22
|
+
};
|
|
23
|
+
export type ParsingResolutions = {
|
|
24
|
+
exports: parsing.infer;
|
|
25
|
+
locals: {};
|
|
26
|
+
ambient: {};
|
|
27
|
+
};
|
|
28
|
+
export type TsGenericsResolutions<$ = Ark> = {
|
|
29
|
+
exports: TsGenericsExports<$>;
|
|
30
|
+
locals: {};
|
|
31
|
+
ambient: {};
|
|
32
|
+
};
|
|
33
|
+
type TsGenericsExports<$ = Ark> = {
|
|
34
|
+
Record: Generic<[
|
|
35
|
+
"K",
|
|
36
|
+
"V"
|
|
37
|
+
], {
|
|
38
|
+
"[K]": "V";
|
|
39
|
+
}, $>;
|
|
40
|
+
};
|
|
41
|
+
export declare const tsGenerics: Module<TsGenericsResolutions<Ark>>;
|
|
42
|
+
export declare const ark: Scope<ArkResolutions>;
|
|
43
|
+
export declare const keywords: Module<ArkResolutions>;
|
|
44
|
+
export interface Ark extends tsPrimitive.infer, jsObject.infer, validation.infer, TsGenericsExports {
|
|
45
|
+
parse: Module<ParsingResolutions>;
|
|
46
|
+
}
|
|
47
|
+
export declare const scope: ScopeParser<Ark, Ark>;
|
|
48
|
+
export declare const type: TypeParser<Ark>;
|
|
49
|
+
export declare const match: MatchParser<Ark>;
|
|
50
|
+
export declare const schema: SchemaParser<Ark>;
|
|
51
|
+
export declare const node: NodeParser<Ark>;
|
|
52
|
+
export declare const define: DefinitionParser<Ark>;
|
|
53
|
+
export declare const declare: DeclarationParser<Ark>;
|
|
54
|
+
export declare namespace type {
|
|
55
|
+
type cast<to> = {
|
|
56
|
+
[inferred]?: to;
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
export {};
|
|
60
|
+
//# sourceMappingURL=ark.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ark.d.ts","sourceRoot":"","sources":["../../keywords/ark.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,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CAAC,GAAG,GAAG,IAAI;IACjC,MAAM,EAAE,OAAO,CACd;QAAC,GAAG;QAAE,GAAG;KAAC,EACV;QACC,KAAK,EAAE,GAAG,CAAA;KACV,EAGD,CAAC,CACD,CAAA;CACD,CAAA;AAED,eAAO,MAAM,UAAU,oCAAsC,CAAA;AAE7D,eAAO,MAAM,GAAG,EAAE,KAAK,CAAC,cAAc,CAShB,CAAA;AAEtB,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,cAAc,CAAgB,CAAA;AAI5D,MAAM,WAAW,GAChB,SAAQ,WAAW,CAAC,KAAK,EACxB,QAAQ,CAAC,KAAK,EACd,UAAU,CAAC,KAAK,EAChB,iBAAiB;IAClB,KAAK,EAAE,MAAM,CAAC,kBAAkB,CAAC,CAAA;CACjC;AAED,eAAO,MAAM,KAAK,EAAE,WAAW,CAAC,GAAG,EAAE,GAAG,CAAsB,CAAA;AAE9D,eAAO,MAAM,IAAI,EAAE,UAAU,CAAC,GAAG,CAAY,CAAA;AAE7C,eAAO,MAAM,KAAK,EAAE,WAAW,CAAC,GAAG,CAAa,CAAA;AAEhD,eAAO,MAAM,MAAM,EAAE,YAAY,CAAC,GAAG,CAAc,CAAA;AAEnD,eAAO,MAAM,IAAI,EAAE,UAAU,CAAC,GAAG,CAAY,CAAA;AAE7C,eAAO,MAAM,MAAM,EAAE,gBAAgB,CAAC,GAAG,CAAc,CAAA;AAEvD,eAAO,MAAM,OAAO,EAAE,iBAAiB,CAAC,GAAG,CAAe,CAAA;AAE1D,yBAAiB,IAAI,CAAC;IACrB,KAAY,IAAI,CAAC,EAAE,IAAI;QACtB,CAAC,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAA;KACf,CAAA;CACD"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// we don't need these for the base scope, but we import them here so we
|
|
2
|
+
// register the keywords for internal use
|
|
3
|
+
import "./internal.js";
|
|
4
|
+
// this needs to be imported before `jsObects` so jsObects can bootstrap corrrectly
|
|
5
|
+
import { tsPrimitiveKeywords } from "./tsPrimitive.js";
|
|
6
|
+
import { jsObjectKeywords } from "./jsObject.js";
|
|
7
|
+
import { parsingKeywords } from "./parsing.js";
|
|
8
|
+
import { root } from "./root.js";
|
|
9
|
+
import { validationKeywords } from "./validation.js";
|
|
10
|
+
export const tsGenerics = {};
|
|
11
|
+
export const ark = root
|
|
12
|
+
.scope({
|
|
13
|
+
...tsPrimitiveKeywords,
|
|
14
|
+
...jsObjectKeywords,
|
|
15
|
+
...validationKeywords,
|
|
16
|
+
// TODO: fix
|
|
17
|
+
...tsGenerics,
|
|
18
|
+
parse: parsingKeywords
|
|
19
|
+
})
|
|
20
|
+
.toAmbient();
|
|
21
|
+
export const keywords = ark.export();
|
|
22
|
+
export const scope = ark.scope;
|
|
23
|
+
export const type = ark.type;
|
|
24
|
+
export const match = ark.match;
|
|
25
|
+
export const schema = ark.schema;
|
|
26
|
+
export const node = ark.node;
|
|
27
|
+
export const define = ark.define;
|
|
28
|
+
export const declare = ark.declare;
|
|
29
|
+
//# sourceMappingURL=ark.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ark.js","sourceRoot":"","sources":["../../keywords/ark.ts"],"names":[],"mappings":"AAUA,wEAAwE;AACxE,yCAAyC;AACzC,OAAO,eAAe,CAAA;AACtB,mFAAmF;AACnF,OAAO,EAAE,mBAAmB,EAAoB,MAAM,kBAAkB,CAAA;AAExE,OAAO,EAAE,gBAAgB,EAAiB,MAAM,eAAe,CAAA;AAC/D,OAAO,EAAE,eAAe,EAAgB,MAAM,cAAc,CAAA;AAC5D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,kBAAkB,EAAmB,MAAM,iBAAiB,CAAA;AAsCrE,MAAM,CAAC,MAAM,UAAU,GAAG,EAAmC,CAAA;AAE7D,MAAM,CAAC,MAAM,GAAG,GAA0B,IAAI;KAC5C,KAAK,CAAC;IACN,GAAG,mBAAmB;IACtB,GAAG,gBAAgB;IACnB,GAAG,kBAAkB;IACrB,YAAY;IACZ,GAAG,UAAU;IACb,KAAK,EAAE,eAAe;CACtB,CAAC;KACD,SAAS,EAAW,CAAA;AAEtB,MAAM,CAAC,MAAM,QAAQ,GAA2B,GAAG,CAAC,MAAM,EAAE,CAAA;AAY5D,MAAM,CAAC,MAAM,KAAK,GAA0B,GAAG,CAAC,KAAc,CAAA;AAE9D,MAAM,CAAC,MAAM,IAAI,GAAoB,GAAG,CAAC,IAAI,CAAA;AAE7C,MAAM,CAAC,MAAM,KAAK,GAAqB,GAAG,CAAC,KAAK,CAAA;AAEhD,MAAM,CAAC,MAAM,MAAM,GAAsB,GAAG,CAAC,MAAM,CAAA;AAEnD,MAAM,CAAC,MAAM,IAAI,GAAoB,GAAG,CAAC,IAAI,CAAA;AAE7C,MAAM,CAAC,MAAM,MAAM,GAA0B,GAAG,CAAC,MAAM,CAAA;AAEvD,MAAM,CAAC,MAAM,OAAO,GAA2B,GAAG,CAAC,OAAO,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Key } from "@arktype/util";
|
|
2
|
+
import type { Module, Scope, rootResolutions } from "../scope.js";
|
|
3
|
+
export declare namespace internalPrimitive {
|
|
4
|
+
interface exports {
|
|
5
|
+
lengthBoundable: string | unknown[];
|
|
6
|
+
propertyKey: Key;
|
|
7
|
+
}
|
|
8
|
+
type resolutions = rootResolutions<exports>;
|
|
9
|
+
type infer = (typeof internalPrimitive)["infer"];
|
|
10
|
+
}
|
|
11
|
+
export declare const internalPrimitive: Scope<internalPrimitive.resolutions>;
|
|
12
|
+
export declare const internalPrimitiveKeywords: Module<internalPrimitive.resolutions>;
|
|
13
|
+
//# sourceMappingURL=internal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../keywords/internal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAGjE,yBAAiB,iBAAiB,CAAC;IAClC,UAAiB,OAAO;QACvB,eAAe,EAAE,MAAM,GAAG,OAAO,EAAE,CAAA;QACnC,WAAW,EAAE,GAAG,CAAA;KAChB;IAED,KAAY,WAAW,GAAG,eAAe,CAAC,OAAO,CAAC,CAAA;IAElD,KAAY,KAAK,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,OAAO,CAAC,CAAA;CACvD;AAED,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,iBAAiB,CAAC,WAAW,CAUjE,CAAA;AAEF,eAAO,MAAM,yBAAyB,EAAE,MAAM,CAAC,iBAAiB,CAAC,WAAW,CACjD,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { root } from "./root.js";
|
|
2
|
+
export const internalPrimitive = root.scope({
|
|
3
|
+
lengthBoundable: root.schema(["string", Array]),
|
|
4
|
+
propertyKey: root.schema(["string", "symbol"])
|
|
5
|
+
}, {
|
|
6
|
+
prereducedAliases: true,
|
|
7
|
+
registerKeywords: true
|
|
8
|
+
});
|
|
9
|
+
export const internalPrimitiveKeywords = internalPrimitive.export();
|
|
10
|
+
//# sourceMappingURL=internal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../keywords/internal.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAahC,MAAM,CAAC,MAAM,iBAAiB,GAC7B,IAAI,CAAC,KAAK,CACT;IACC,eAAe,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IAC/C,WAAW,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;CAC9C,EACD;IACC,iBAAiB,EAAE,IAAI;IACvB,gBAAgB,EAAE,IAAI;CACtB,CACD,CAAA;AAEF,MAAM,CAAC,MAAM,yBAAyB,GACrC,iBAAiB,CAAC,MAAM,EAAE,CAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Module, rootResolutions, Scope } from "../scope.js";
|
|
2
|
+
export declare namespace jsObject {
|
|
3
|
+
interface exports {
|
|
4
|
+
Array: unknown[];
|
|
5
|
+
Function: Function;
|
|
6
|
+
Date: Date;
|
|
7
|
+
Error: Error;
|
|
8
|
+
Map: Map<unknown, unknown>;
|
|
9
|
+
RegExp: RegExp;
|
|
10
|
+
Set: Set<unknown>;
|
|
11
|
+
WeakMap: WeakMap<object, unknown>;
|
|
12
|
+
WeakSet: WeakSet<object>;
|
|
13
|
+
Promise: Promise<unknown>;
|
|
14
|
+
}
|
|
15
|
+
type resolutions = rootResolutions<exports>;
|
|
16
|
+
type infer = (typeof jsObject)["infer"];
|
|
17
|
+
}
|
|
18
|
+
export declare const jsObject: Scope<jsObject.resolutions>;
|
|
19
|
+
export declare const jsObjectKeywords: Module<jsObject.resolutions>;
|
|
20
|
+
//# sourceMappingURL=jsObject.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsObject.d.ts","sourceRoot":"","sources":["../../keywords/jsObject.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAGjE,yBAAiB,QAAQ,CAAC;IACzB,UAAiB,OAAO;QACvB,KAAK,EAAE,OAAO,EAAE,CAAA;QAChB,QAAQ,EAAE,QAAQ,CAAA;QAClB,IAAI,EAAE,IAAI,CAAA;QACV,KAAK,EAAE,KAAK,CAAA;QACZ,GAAG,EAAE,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;QAC1B,MAAM,EAAE,MAAM,CAAA;QACd,GAAG,EAAE,GAAG,CAAC,OAAO,CAAC,CAAA;QACjB,OAAO,EAAE,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;QACjC,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,CAAA;QACxB,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,CAAA;KACzB;IAED,KAAY,WAAW,GAAG,eAAe,CAAC,OAAO,CAAC,CAAA;IAElD,KAAY,KAAK,GAAG,CAAC,OAAO,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAA;CAC9C;AAED,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,WAAW,CAchD,CAAA;AAED,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAqB,CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { root } from "./root.js";
|
|
2
|
+
export const jsObject = root.scope({
|
|
3
|
+
Array: root.schema(Array),
|
|
4
|
+
Function: root.schema(Function),
|
|
5
|
+
Date: root.schema(Date),
|
|
6
|
+
Error: root.schema(Error),
|
|
7
|
+
Map: root.schema(Map),
|
|
8
|
+
RegExp: root.schema(RegExp),
|
|
9
|
+
Set: root.schema(Set),
|
|
10
|
+
WeakMap: root.schema(WeakMap),
|
|
11
|
+
WeakSet: root.schema(WeakSet),
|
|
12
|
+
Promise: root.schema(Promise)
|
|
13
|
+
}, { prereducedAliases: true, registerKeywords: true });
|
|
14
|
+
export const jsObjectKeywords = jsObject.export();
|
|
15
|
+
//# sourceMappingURL=jsObject.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsObject.js","sourceRoot":"","sources":["../../keywords/jsObject.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAqBhC,MAAM,CAAC,MAAM,QAAQ,GAAgC,IAAI,CAAC,KAAK,CAC9D;IACC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;IACzB,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC;IAC/B,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;IACvB,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;IACzB,GAAG,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC;IACrB,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;IAC3B,GAAG,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC;IACrB,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC;IAC7B,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC;IAC7B,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC;CAC7B,EACD,EAAE,iBAAiB,EAAE,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,CACnD,CAAA;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAiC,QAAQ,CAAC,MAAM,EAAE,CAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
import type { Module, Scope, rootResolutions } from "../scope.js";
|
|
3
|
+
import type { Out } from "../types/morph.js";
|
|
4
|
+
export declare namespace parsing {
|
|
5
|
+
interface exports {
|
|
6
|
+
url: (In: string) => Out<URL>;
|
|
7
|
+
number: (In: string) => Out<number>;
|
|
8
|
+
integer: (In: string) => Out<number>;
|
|
9
|
+
date: (In: string) => Out<Date>;
|
|
10
|
+
json: (In: string) => Out<unknown>;
|
|
11
|
+
}
|
|
12
|
+
type resolutions = rootResolutions<exports>;
|
|
13
|
+
type infer = (typeof parsing)["infer"];
|
|
14
|
+
}
|
|
15
|
+
export declare const parsing: Scope<parsing.resolutions>;
|
|
16
|
+
export declare const parsingKeywords: Module<parsing.resolutions>;
|
|
17
|
+
//# sourceMappingURL=parsing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parsing.d.ts","sourceRoot":"","sources":["../../keywords/parsing.ts"],"names":[],"mappings":";AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AACjE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAA;AAyD5C,yBAAiB,OAAO,CAAC;IACxB,UAAiB,OAAO;QACvB,GAAG,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,GAAG,CAAC,GAAG,CAAC,CAAA;QAC7B,MAAM,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,GAAG,CAAC,MAAM,CAAC,CAAA;QACnC,OAAO,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,GAAG,CAAC,MAAM,CAAC,CAAA;QACpC,IAAI,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,GAAG,CAAC,IAAI,CAAC,CAAA;QAC/B,IAAI,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,GAAG,CAAC,OAAO,CAAC,CAAA;KAClC;IAED,KAAY,WAAW,GAAG,eAAe,CAAC,OAAO,CAAC,CAAA;IAElD,KAAY,KAAK,GAAG,CAAC,OAAO,OAAO,CAAC,CAAC,OAAO,CAAC,CAAA;CAC7C;AAED,eAAO,MAAM,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,WAAW,CAAe,CAAA;AAE9D,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,OAAO,CAAC,WAAW,CAAe,CAAA"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { wellFormedIntegerMatcher, wellFormedNumberMatcher } from "@arktype/util";
|
|
2
|
+
import { root } from "./root.js";
|
|
3
|
+
import { parsedDate } from "./utils/date.js";
|
|
4
|
+
const number = root.schema({
|
|
5
|
+
in: {
|
|
6
|
+
domain: "string",
|
|
7
|
+
regex: wellFormedNumberMatcher,
|
|
8
|
+
description: "a well-formed numeric string"
|
|
9
|
+
},
|
|
10
|
+
morphs: (s) => parseFloat(s)
|
|
11
|
+
});
|
|
12
|
+
const integer = root.schema({
|
|
13
|
+
in: {
|
|
14
|
+
domain: "string",
|
|
15
|
+
regex: wellFormedIntegerMatcher
|
|
16
|
+
},
|
|
17
|
+
morphs: (s) => {
|
|
18
|
+
// if (!isWellFormedInteger(s)) {
|
|
19
|
+
// return errors.mustBe("a well-formed integer string")
|
|
20
|
+
// }
|
|
21
|
+
// const parsed = parseInt(s)
|
|
22
|
+
// return Number.isSafeInteger(parsed)
|
|
23
|
+
// ? parsed
|
|
24
|
+
// : errors.mustBe(
|
|
25
|
+
// "an integer in the range Number.MIN_SAFE_INTEGER to Number.MAX_SAFE_INTEGER"
|
|
26
|
+
// )
|
|
27
|
+
return parseInt(s);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
const url = root.schema({
|
|
31
|
+
in: {
|
|
32
|
+
domain: "string",
|
|
33
|
+
description: "a valid URL"
|
|
34
|
+
},
|
|
35
|
+
morphs: (s) => {
|
|
36
|
+
return new URL(s);
|
|
37
|
+
// try {
|
|
38
|
+
// return new URL(s)
|
|
39
|
+
// } catch {
|
|
40
|
+
// return state.mustBe("a valid URL", s, state.basePath)
|
|
41
|
+
// }
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
const json = root.schema({
|
|
45
|
+
in: {
|
|
46
|
+
domain: "string",
|
|
47
|
+
description: "a JSON-parsable string"
|
|
48
|
+
},
|
|
49
|
+
morphs: (s) => JSON.parse(s)
|
|
50
|
+
});
|
|
51
|
+
const date = parsedDate;
|
|
52
|
+
export const parsing = {};
|
|
53
|
+
export const parsingKeywords = {};
|
|
54
|
+
// Scope.root.scope({
|
|
55
|
+
// url,
|
|
56
|
+
// number,
|
|
57
|
+
// integer,
|
|
58
|
+
// date,
|
|
59
|
+
// json
|
|
60
|
+
// })
|
|
61
|
+
//# sourceMappingURL=parsing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parsing.js","sourceRoot":"","sources":["../../keywords/parsing.ts"],"names":[],"mappings":"AAAA,OAA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AAI,CAAC,KAAK,CAAC,CAAC,CAAC;CAC7C,CAAC,CAAA;AAEF,MAAM,IAAI,GAAG,UAAU,CAAA;AAgBvB,MAAM,CAAC,MAAM,OAAO,GAA+B,EAAW,CAAA;AAE9D,MAAM,CAAC,MAAM,eAAe,GAAgC,EAAW,CAAA;AAEvE,sBAAsB;AACtB,QAAQ;AACR,WAAW;AACX,YAAY;AACZ,SAAS;AACT,QAAQ;AACR,KAAK"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"root.d.ts","sourceRoot":"","sources":["../../keywords/root.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAEnC,eAAO,MAAM,IAAI,EAAE,KAAK,CAAC;IACxB,OAAO,EAAE,EAAE,CAAA;IACX,MAAM,EAAE,EAAE,CAAA;IACV,OAAO,EAAE,EAAE,CAAA;CACX,CAAiB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"root.js","sourceRoot":"","sources":["../../keywords/root.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAEnC,MAAM,CAAC,MAAM,IAAI,GAIZ,IAAI,KAAK,CAAC,EAAE,CAAC,CAAA;AAElB,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA"}
|