arktype 2.0.0-dev.1 → 2.0.0-dev.10
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 +270 -151
- 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 +95 -167
- package/__tests__/dateLiteral.test.ts +8 -4
- package/__tests__/declared.test.ts +7 -6
- package/__tests__/discrimination.test.ts +1 -1
- package/__tests__/divisor.test.ts +46 -22
- 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 +62 -49
- package/__tests__/instanceof.test.ts +25 -23
- package/__tests__/intersection.test.ts +52 -48
- package/__tests__/keyTraversal.test.ts +77 -73
- package/__tests__/keyof.test.ts +68 -52
- package/__tests__/keywords.test.ts +164 -138
- package/__tests__/literal.test.ts +60 -21
- package/__tests__/match.bench.ts +31 -0
- package/__tests__/match.test.ts +222 -22
- package/__tests__/narrow.test.ts +52 -54
- package/__tests__/objectLiteral.test.ts +347 -205
- package/__tests__/operator.bench.ts +4 -4
- package/__tests__/pipe.test.ts +501 -0
- 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 +257 -23
- 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 +76 -54
- package/__tests__/tsGenerics.test.ts +12 -12
- package/__tests__/type.test.ts +36 -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 +21 -65
- package/generic.ts +69 -0
- package/main.ts +6 -18
- package/match.ts +195 -93
- package/module.ts +15 -0
- package/out/ark.d.ts +15 -39
- package/out/ark.js +9 -18
- package/out/ark.js.map +1 -1
- package/out/generic.d.ts +21 -0
- package/out/generic.js +24 -0
- package/out/generic.js.map +1 -0
- package/out/main.d.ts +6 -7
- package/out/main.js +4 -3
- package/out/main.js.map +1 -1
- package/out/match.d.ts +57 -34
- package/out/match.js +51 -17
- package/out/match.js.map +1 -1
- package/out/module.d.ts +10 -0
- package/out/module.js +3 -0
- package/out/module.js.map +1 -0
- package/out/parser/definition.d.ts +11 -13
- package/out/parser/definition.js +10 -13
- package/out/parser/definition.js.map +1 -1
- package/out/parser/generic.d.ts +5 -7
- package/out/parser/generic.js +7 -11
- package/out/parser/generic.js.map +1 -1
- package/out/parser/objectLiteral.d.ts +45 -14
- package/out/parser/objectLiteral.js +61 -52
- package/out/parser/objectLiteral.js.map +1 -1
- package/out/parser/semantic/bounds.d.ts +10 -8
- package/out/parser/semantic/bounds.js +0 -1
- package/out/parser/semantic/bounds.js.map +1 -1
- package/out/parser/semantic/divisor.d.ts +5 -7
- package/out/parser/semantic/divisor.js +0 -1
- package/out/parser/semantic/infer.d.ts +24 -0
- package/out/parser/semantic/infer.js +1 -0
- package/out/parser/semantic/infer.js.map +1 -0
- package/out/parser/semantic/utils.d.ts +3 -7
- package/out/parser/semantic/utils.js +0 -1
- package/out/parser/semantic/validate.d.ts +15 -14
- package/out/parser/semantic/validate.js +1 -1
- package/out/parser/semantic/validate.js.map +1 -1
- package/out/parser/string/reduce/dynamic.d.ts +13 -13
- package/out/parser/string/reduce/dynamic.js +31 -26
- package/out/parser/string/reduce/dynamic.js.map +1 -1
- package/out/parser/string/reduce/shared.d.ts +6 -20
- package/out/parser/string/reduce/shared.js +0 -1
- package/out/parser/string/reduce/shared.js.map +1 -1
- package/out/parser/string/reduce/static.d.ts +27 -24
- package/out/parser/string/reduce/static.js +0 -1
- package/out/parser/string/shift/operand/date.d.ts +3 -3
- package/out/parser/string/shift/operand/date.js +4 -7
- package/out/parser/string/shift/operand/date.js.map +1 -1
- package/out/parser/string/shift/operand/enclosed.d.ts +4 -19
- package/out/parser/string/shift/operand/enclosed.js +12 -13
- package/out/parser/string/shift/operand/enclosed.js.map +1 -1
- package/out/parser/string/shift/operand/genericArgs.d.ts +9 -10
- package/out/parser/string/shift/operand/genericArgs.js +6 -10
- package/out/parser/string/shift/operand/genericArgs.js.map +1 -1
- package/out/parser/string/shift/operand/operand.d.ts +3 -4
- package/out/parser/string/shift/operand/operand.js +8 -12
- package/out/parser/string/shift/operand/operand.js.map +1 -1
- package/out/parser/string/shift/operand/unenclosed.d.ts +15 -22
- package/out/parser/string/shift/operand/unenclosed.js +24 -36
- package/out/parser/string/shift/operand/unenclosed.js.map +1 -1
- package/out/parser/string/shift/operator/bounds.d.ts +9 -13
- package/out/parser/string/shift/operator/bounds.js +43 -54
- package/out/parser/string/shift/operator/bounds.js.map +1 -1
- package/out/parser/string/shift/operator/divisor.d.ts +2 -4
- package/out/parser/string/shift/operator/divisor.js +1 -3
- package/out/parser/string/shift/operator/divisor.js.map +1 -1
- package/out/parser/string/shift/operator/operator.d.ts +2 -3
- package/out/parser/string/shift/operator/operator.js +12 -19
- package/out/parser/string/shift/operator/operator.js.map +1 -1
- package/out/parser/string/shift/scanner.d.ts +2 -2
- package/out/parser/string/shift/scanner.js +14 -16
- package/out/parser/string/shift/scanner.js.map +1 -1
- package/out/parser/string/string.d.ts +8 -6
- package/out/parser/string/string.js +1 -3
- package/out/parser/string/string.js.map +1 -1
- package/out/parser/tuple.d.ts +102 -43
- package/out/parser/tuple.js +119 -87
- package/out/parser/tuple.js.map +1 -1
- package/out/scope.d.ts +43 -120
- package/out/scope.js +39 -209
- package/out/scope.js.map +1 -1
- package/out/type.d.ts +43 -64
- package/out/type.js +30 -131
- package/out/type.js.map +1 -1
- package/package.json +7 -3
- package/parser/definition.ts +77 -93
- package/parser/generic.ts +38 -40
- package/parser/objectLiteral.ts +172 -136
- 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 +81 -73
- package/parser/string/reduce/dynamic.ts +67 -55
- package/parser/string/reduce/shared.ts +1 -3
- package/parser/string/reduce/static.ts +67 -69
- package/parser/string/shift/operand/date.ts +15 -14
- package/parser/string/shift/operand/enclosed.ts +30 -25
- 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 +107 -158
- package/parser/string/shift/operator/bounds.ts +118 -112
- package/parser/string/shift/operator/divisor.ts +14 -17
- package/parser/string/shift/operator/operator.ts +35 -46
- package/parser/string/shift/scanner.ts +51 -50
- package/parser/string/string.ts +30 -35
- package/parser/tuple.ts +375 -307
- package/scope.ts +170 -453
- package/type.ts +193 -274
- package/__tests__/astUtils.test.ts +0 -17
- package/__tests__/cyclic.test.ts +0 -144
- package/__tests__/jsdoc.test.ts +0 -64
- package/__tests__/morph.test.ts +0 -409
- package/__tests__/nodeDefinitions.test.ts +0 -190
- package/__tests__/typeMethods.test.ts +0 -69
- package/out/ark.d.ts.map +0 -1
- 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/main.d.ts.map +0 -1
- package/out/match.d.ts.map +0 -1
- package/out/parser/definition.d.ts.map +0 -1
- package/out/parser/generic.d.ts.map +0 -1
- package/out/parser/objectLiteral.d.ts.map +0 -1
- package/out/parser/semantic/bounds.d.ts.map +0 -1
- package/out/parser/semantic/divisor.d.ts.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 -33
- 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/semantic/utils.d.ts.map +0 -1
- package/out/parser/semantic/validate.d.ts.map +0 -1
- package/out/parser/shared.d.ts +0 -54
- package/out/parser/shared.d.ts.map +0 -1
- package/out/parser/shared.js +0 -47
- package/out/parser/shared.js.map +0 -1
- package/out/parser/string/reduce/dynamic.d.ts.map +0 -1
- package/out/parser/string/reduce/shared.d.ts.map +0 -1
- package/out/parser/string/reduce/static.d.ts.map +0 -1
- package/out/parser/string/shift/operand/date.d.ts.map +0 -1
- package/out/parser/string/shift/operand/enclosed.d.ts.map +0 -1
- package/out/parser/string/shift/operand/genericArgs.d.ts.map +0 -1
- package/out/parser/string/shift/operand/operand.d.ts.map +0 -1
- package/out/parser/string/shift/operand/unenclosed.d.ts.map +0 -1
- package/out/parser/string/shift/operator/bounds.d.ts.map +0 -1
- package/out/parser/string/shift/operator/divisor.d.ts.map +0 -1
- package/out/parser/string/shift/operator/operator.d.ts.map +0 -1
- package/out/parser/string/shift/scanner.d.ts.map +0 -1
- package/out/parser/string/string.d.ts.map +0 -1
- package/out/parser/tuple.d.ts.map +0 -1
- package/out/scope.d.ts.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/out/type.d.ts.map +0 -1
- package/out/util.d.ts +0 -19
- package/out/util.d.ts.map +0 -1
- package/out/util.js +0 -7
- package/out/util.js.map +0 -1
- package/parser/semantic/intersections.ts +0 -46
- package/parser/semantic/semantic.ts +0 -144
- package/parser/shared.ts +0 -152
- package/util.ts +0 -36
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"objectLiteral.js","sourceRoot":"","sources":["../../parser/objectLite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AU,EAAE;YACpD,CAAC,CAAC;gBACA,KAAK,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;gBACvB,IAAI,EAAE,UAAU;aAChB;QACH,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC;YACvC,EAAE,KAAK,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE;YAC3C,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,WAAW,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC;gBACzE,EAAE,KAAK,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE;gBAC1C,CAAC,CAAC,GAAG,KAAK,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE;oBAClD,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,KAAK,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,CAAA;AAqC7D,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAC5C,GAAQ,EAC6B,EAAE,CACvC,8DAA8D,GAAG,GAAG,CAAA"}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { ErrorMessage } from "@arktype/util";
|
|
3
|
-
import type { Comparator, InvertedComparators
|
|
4
|
-
import type { BoundExpressionKind, writeInvalidLimitMessage
|
|
5
|
-
import type {
|
|
1
|
+
import type { LimitLiteral, writeUnboundableMessage } from "@arktype/schema";
|
|
2
|
+
import type { ErrorMessage, array } from "@arktype/util";
|
|
3
|
+
import type { Comparator, InvertedComparators } from "../string/reduce/shared.js";
|
|
4
|
+
import type { BoundExpressionKind, writeInvalidLimitMessage } from "../string/shift/operator/bounds.js";
|
|
5
|
+
import type { inferAstIn } from "./infer.js";
|
|
6
6
|
import type { astToString } from "./utils.js";
|
|
7
7
|
import type { validateAst } from "./validate.js";
|
|
8
8
|
export type validateRange<l, comparator extends Comparator, r, $, args> = l extends LimitLiteral ? validateBound<r, InvertedComparators[comparator], l, "left", $, args> : l extends [infer leftAst, Comparator, unknown] ? ErrorMessage<writeDoubleRightBoundMessage<astToString<leftAst>>> : validateBound<l, comparator, r & LimitLiteral, "right", $, args>;
|
|
9
|
-
export type validateBound<boundedAst, comparator extends Comparator, limit extends LimitLiteral, boundKind extends BoundExpressionKind, $, args> =
|
|
10
|
-
|
|
9
|
+
export type validateBound<boundedAst, comparator extends Comparator, limit extends LimitLiteral, boundKind extends BoundExpressionKind, $, args> = inferAstIn<boundedAst, $, args> extends infer bounded ? isNumericallyBoundable<bounded> extends true ? limit extends number ? validateAst<boundedAst, $, args> : ErrorMessage<writeInvalidLimitMessage<comparator, limit, boundKind>> : bounded extends Date ? validateAst<boundedAst, $, args> : ErrorMessage<writeUnboundableMessage<astToString<boundKind extends "left" ? boundedAst[0 & keyof boundedAst] : boundedAst>>> : never;
|
|
10
|
+
type isNumericallyBoundable<bounded> = [
|
|
11
|
+
bounded
|
|
12
|
+
] extends [number] ? true : [bounded] extends [string] ? true : [bounded] extends [array] ? true : false;
|
|
13
|
+
export declare const writeDoubleRightBoundMessage: <root extends string>(root: root) => writeDoubleRightBoundMessage<root>;
|
|
11
14
|
type writeDoubleRightBoundMessage<root extends string> = `Expression ${root} must have at most one right bound`;
|
|
12
15
|
export {};
|
|
13
|
-
//# sourceMappingURL=bounds.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bounds.js","sourceRoot":"","sources":["../../../parser/semantic/bounds.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bounds.js","sourceRoot":"","sources":["../../../parser/semantic/bounds.ts"],"names":[],"mappings":"AAuDA,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAC3C,IAAU,EAC2B,EAAE,CACvC,cAAc,IAAI,oCAAoC,CAAA"}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import type { writeIndivisibleMessage } from "@arktype/schema";
|
|
1
|
+
import type { Schema, writeIndivisibleMessage } from "@arktype/schema";
|
|
2
2
|
import type { ErrorMessage } from "@arktype/util";
|
|
3
|
-
import type {
|
|
4
|
-
import type { astToString } from "./utils.js";
|
|
3
|
+
import type { inferAstIn } from "./infer.js";
|
|
5
4
|
import type { validateAst } from "./validate.js";
|
|
6
|
-
export type validateDivisor<l, $, args> =
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
//# sourceMappingURL=divisor.d.ts.map
|
|
5
|
+
export type validateDivisor<l, $, args> = inferAstIn<l, $, args> extends infer data ? [
|
|
6
|
+
data
|
|
7
|
+
] extends [number] ? validateAst<l, $, args> : ErrorMessage<writeIndivisibleMessage<Schema<data>>> : never;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Date, DateLiteral, GenericProps, LimitLiteral, RegexLiteral, constrain, distillIn, inferIntersection, normalizeLimit, string } from "@arktype/schema";
|
|
2
|
+
import type { BigintLiteral, array } from "@arktype/util";
|
|
3
|
+
import type { UnparsedScope, resolve, tryInferSubmoduleReference } from "../../scope.js";
|
|
4
|
+
import type { inferDefinition } from "../definition.js";
|
|
5
|
+
import type { Comparator, MinComparator } from "../string/reduce/shared.js";
|
|
6
|
+
import type { StringLiteral } from "../string/shift/operand/enclosed.js";
|
|
7
|
+
export type inferAstRoot<ast, $, args> = inferConstrainableAst<ast, $, args>;
|
|
8
|
+
export type inferAstIn<ast, $, args> = distillIn<inferAstRoot<ast, $, args>>;
|
|
9
|
+
export type inferConstrainableAst<ast, $, args> = ast extends array ? inferExpression<ast, $, args> : ast extends string ? inferTerminal<ast, $, args> : never;
|
|
10
|
+
export type GenericInstantiationAst<generic extends GenericProps = GenericProps, argAsts extends unknown[] = unknown[]> = [generic, "<>", argAsts];
|
|
11
|
+
export type inferExpression<ast extends array, $, args> = ast extends GenericInstantiationAst<infer generic, infer argAsts> ? inferDefinition<generic["def"], generic["$"]["$"] extends UnparsedScope ? $ : generic["$"]["$"], {
|
|
12
|
+
[i in keyof generic["params"] & `${number}` as generic["params"][i]]: inferConstrainableAst<argAsts[i & keyof argAsts], $, args>;
|
|
13
|
+
}> : ast[1] extends "[]" ? inferConstrainableAst<ast[0], $, args>[] : ast[1] extends "|" ? inferConstrainableAst<ast[0], $, args> | inferConstrainableAst<ast[2], $, args> : ast[1] extends "&" ? inferIntersection<inferConstrainableAst<ast[0], $, args>, inferConstrainableAst<ast[2], $, args>> : ast[1] extends Comparator ? ast[0] extends LimitLiteral ? constrainBound<inferConstrainableAst<ast[2], $, args>, ast[1], ast[0]> : constrainBound<inferConstrainableAst<ast[0], $, args>, ast[1], ast[2]> : ast[1] extends "%" ? constrain<inferConstrainableAst<ast[0], $, args>, "divisor", ast[2] & number> : ast[0] extends "keyof" ? keyof inferConstrainableAst<ast[1], $, args> : never;
|
|
14
|
+
export type constrainBound<constrainableIn, comparator extends Comparator, limit> = distillIn<constrainableIn> extends infer In ? comparator extends "==" ? In extends number ? limit : In extends Date ? Date.literal<normalizeLimit<limit>> : constrain<constrainableIn, "exactLength", limit & number> : constrain<constrainableIn, In extends number ? comparator extends MinComparator ? "min" : "max" : In extends string | array ? comparator extends MinComparator ? "minLength" : "maxLength" : comparator extends MinComparator ? "after" : "before", {
|
|
15
|
+
rule: normalizeLimit<limit>;
|
|
16
|
+
exclusive: comparator extends ">" | "<" ? true : false;
|
|
17
|
+
}> : never;
|
|
18
|
+
export type PrefixOperator = "keyof" | "instanceof" | "===" | "node";
|
|
19
|
+
export type PrefixExpression<operator extends PrefixOperator = PrefixOperator, operand = unknown> = [operator, operand];
|
|
20
|
+
export type PostfixOperator = "[]";
|
|
21
|
+
export type PostfixExpression<operator extends PostfixOperator = PostfixOperator, operand = unknown> = readonly [operand, operator];
|
|
22
|
+
export type InfixOperator = "|" | "&" | Comparator | "%" | ":" | "=>" | "@";
|
|
23
|
+
export type InfixExpression<operator extends InfixOperator = InfixOperator, l = unknown, r = unknown> = [l, operator, r];
|
|
24
|
+
export type inferTerminal<token extends string, $, args> = token extends keyof args | keyof $ ? resolve<token, $, args> : `#${token}` extends keyof $ ? resolve<`#${token}`, $, args> : token extends StringLiteral<infer text> ? text : token extends `${infer n extends number}` ? n : token extends BigintLiteral<infer b> ? b : token extends RegexLiteral<infer source> ? string.matching<source> : token extends DateLiteral<infer source> ? Date.literal<source> : tryInferSubmoduleReference<$, token>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"infer.js","sourceRoot":"","sources":["../../../parser/semantic/infer.ts"],"names":[],"mappings":""}
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Stringifiable } from "@arktype/util";
|
|
2
2
|
import type { Comparator } from "../string/reduce/shared.js";
|
|
3
|
-
import type { InfixExpression, PostfixExpression } from "./
|
|
4
|
-
export type astToString<ast> = `
|
|
5
|
-
type astToStringRecurse<ast> = ast extends PostfixExpression<infer operator, infer operand> ? operator extends "[]" ? `${groupAst<operand>}[]` : never : ast extends InfixExpression<infer operator, infer l, infer r> ? operator extends "&" | "|" | "%" | Comparator ? `${groupAst<l>}${operator}${groupAst<r>}` : never : ast extends Stringifiable ? `${ast extends bigint ? `${ast}n` : ast}` : "...";
|
|
6
|
-
type groupAst<ast> = ast extends List ? ast[1] extends "[]" ? astToStringRecurse<ast> : `(${astToStringRecurse<ast>})` : astToStringRecurse<ast>;
|
|
7
|
-
export {};
|
|
8
|
-
//# sourceMappingURL=utils.d.ts.map
|
|
3
|
+
import type { InfixExpression, PostfixExpression } from "./infer.js";
|
|
4
|
+
export type astToString<ast> = ast extends PostfixExpression<infer operator, infer operand> ? operator extends "[]" ? `${astToString<operand>}[]` : never : ast extends InfixExpression<infer operator, infer l, infer r> ? operator extends "&" | "|" | "%" | Comparator ? `${astToString<l>} ${operator} ${astToString<r>}` : never : ast extends Stringifiable ? `${ast extends bigint ? `${ast}n` : ast}` : "...";
|
|
@@ -1,24 +1,25 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type { GenericProps } from "../../type.js";
|
|
1
|
+
import type { arkKind, GenericProps, PrivateDeclaration, writeMissingSubmoduleAccessMessage } from "@arktype/schema";
|
|
2
|
+
import type { BigintLiteral, charsAfterFirst, Completion, ErrorMessage, isAnyOrNever, writeMalformedNumericLiteralMessage } from "@arktype/util";
|
|
4
3
|
import type { Comparator } from "../string/reduce/shared.js";
|
|
5
4
|
import type { writeInvalidGenericArgsMessage } from "../string/shift/operand/genericArgs.js";
|
|
6
|
-
import type { writeMissingSubmoduleAccessMessage } from "../string/shift/operand/unenclosed.js";
|
|
7
5
|
import type { parseString } from "../string/string.js";
|
|
8
6
|
import type { validateRange } from "./bounds.js";
|
|
9
7
|
import type { validateDivisor } from "./divisor.js";
|
|
10
|
-
import type { GenericInstantiationAst, InfixExpression, PostfixExpression } from "./
|
|
8
|
+
import type { GenericInstantiationAst, InfixExpression, PostfixExpression } from "./infer.js";
|
|
11
9
|
import type { astToString } from "./utils.js";
|
|
12
|
-
export type validateAst<ast, $, args> = ast extends string ? validateStringAst<ast, $> : ast extends PostfixExpression<infer operator, infer operand> ? operator extends "[]" ? validateAst<operand, $, args> : never : ast extends InfixExpression<infer operator, infer l, infer r> ? operator extends "&" | "|" ? validateInfix<ast, $, args> : operator extends Comparator ? validateRange<l, operator, r, $, args> : operator extends "%" ? validateDivisor<l, $, args> : undefined : ast extends readonly ["keyof", infer operand] ? validateAst<operand, $, args> : ast extends GenericInstantiationAst ? validateGenericArgs<ast[
|
|
10
|
+
export type validateAst<ast, $, args> = ast extends string ? validateStringAst<ast, $> : ast extends PostfixExpression<infer operator, infer operand> ? operator extends "[]" ? validateAst<operand, $, args> : never : ast extends InfixExpression<infer operator, infer l, infer r> ? operator extends "&" | "|" ? validateInfix<ast, $, args> : operator extends Comparator ? validateRange<l, operator, r, $, args> : operator extends "%" ? validateDivisor<l, $, args> : undefined : ast extends readonly ["keyof", infer operand] ? validateAst<operand, $, args> : ast extends GenericInstantiationAst ? validateGenericArgs<ast[2], $, args> : ErrorMessage<writeUnexpectedExpressionMessage<astToString<ast>>> & {
|
|
11
|
+
ast: ast;
|
|
12
|
+
};
|
|
13
13
|
type writeUnexpectedExpressionMessage<expression extends string> = `Unexpectedly failed to parse the expression resulting from ${expression}`;
|
|
14
|
-
type validateGenericArgs<argAsts extends unknown[], $, args> = argAsts extends [
|
|
15
|
-
|
|
16
|
-
...infer tail
|
|
17
|
-
] ? validateAst<head, $, args> extends ErrorMessage<infer message> ? ErrorMessage<message> : validateGenericArgs<tail, $, args> : undefined;
|
|
18
|
-
export declare const writeUnsatisfiableExpressionError: <expression extends string>(expression: expression) => `${expression} results in an unsatisfiable type`;
|
|
14
|
+
type validateGenericArgs<argAsts extends unknown[], $, args> = argAsts extends [infer head, ...infer tail] ? validateAst<head, $, args> extends ErrorMessage<infer message> ? ErrorMessage<message> : validateGenericArgs<tail, $, args> : undefined;
|
|
15
|
+
export declare const writeUnsatisfiableExpressionError: <expression extends string>(expression: expression) => writeUnsatisfiableExpressionError<expression>;
|
|
19
16
|
export type writeUnsatisfiableExpressionError<expression extends string> = `${expression} results in an unsatisfiable type`;
|
|
20
|
-
|
|
21
|
-
export type
|
|
17
|
+
export declare const writePrefixedPrivateReferenceMessage: <def extends `#${string}`>(def: def) => writePrefixedPrivateReferenceMessage<def>;
|
|
18
|
+
export type writePrefixedPrivateReferenceMessage<def extends PrivateDeclaration> = `Private type references should not include '#'. Use '${charsAfterFirst<def>}' instead.`;
|
|
19
|
+
type validateStringAst<def extends string, $> = def extends `${infer n extends number}` ? number extends n ? ErrorMessage<writeMalformedNumericLiteralMessage<def, "number">> : undefined : def extends BigintLiteral<infer b> ? bigint extends b ? ErrorMessage<writeMalformedNumericLiteralMessage<def, "bigint">> : undefined : maybeExtractAlias<def, $> extends infer alias extends keyof $ ? isAnyOrNever<$[alias]> extends true ? def : def extends PrivateDeclaration ? ErrorMessage<writePrefixedPrivateReferenceMessage<def>> : $[alias] extends GenericProps ? ErrorMessage<writeInvalidGenericArgsMessage<def, $[alias]["params"], []>> : $[alias] extends {
|
|
20
|
+
[arkKind]: "module";
|
|
21
|
+
} ? ErrorMessage<writeMissingSubmoduleAccessMessage<def>> : undefined : def extends ErrorMessage ? def : undefined;
|
|
22
|
+
export type maybeExtractAlias<def extends string, $> = def extends keyof $ ? def : `#${def}` extends keyof $ ? `#${def}` : null;
|
|
23
|
+
export type validateString<def extends string, $, args> = validateAst<parseString<def, $, args>, $, args> extends (infer result extends ErrorMessage) ? result extends Completion<infer text> ? text : result : def;
|
|
22
24
|
type validateInfix<ast extends InfixExpression, $, args> = validateAst<ast[0], $, args> extends ErrorMessage<infer message> ? ErrorMessage<message> : validateAst<ast[2], $, args> extends ErrorMessage<infer message> ? ErrorMessage<message> : undefined;
|
|
23
25
|
export {};
|
|
24
|
-
//# sourceMappingURL=validate.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const writeUnsatisfiableExpressionError = (expression) => `${expression} results in an unsatisfiable type`;
|
|
2
|
-
|
|
2
|
+
export const writePrefixedPrivateReferenceMessage = (def) => `Private type references should not include '#'. Use '${def.slice(1)}' instead.`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../../parser/semantic/validate.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../../parser/semantic/validate.ts"],"names":[],"mappings":"AAsDA,MAAM,CAAC,MAAM,iCAAiC,GAAG,CAChD,UAAsB,EAC0B,EAAE,CAClD,GAAG,UAAU,mCAAmC,CAAA;AAKjD,MAAM,CAAC,MAAM,oCAAoC,GAAG,CAGnD,GAAQ,EACoC,EAAE,CAC9C,wDAAwD,GAAG,CAAC,KAAK,CAAC,CAAC,CAAyB,YAAY,CAAA"}
|
|
@@ -1,32 +1,33 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { LimitLiteral, RawSchema } from "@arktype/schema";
|
|
2
2
|
import { type requireKeys } from "@arktype/util";
|
|
3
3
|
import type { ParseContext } from "../../../scope.js";
|
|
4
|
+
import type { InfixOperator } from "../../semantic/infer.js";
|
|
4
5
|
import { Scanner } from "../shift/scanner.js";
|
|
5
|
-
import { type Comparator, type
|
|
6
|
+
import { type Comparator, type MinComparator, type OpenLeftBound, type StringifiablePrefixOperator } from "./shared.js";
|
|
6
7
|
type BranchState = {
|
|
7
8
|
prefixes: StringifiablePrefixOperator[];
|
|
8
|
-
leftBound
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
leftBound: OpenLeftBound | null;
|
|
10
|
+
intersection: RawSchema | null;
|
|
11
|
+
union: RawSchema | null;
|
|
11
12
|
};
|
|
12
13
|
export type DynamicStateWithRoot = requireKeys<DynamicState, "root">;
|
|
13
14
|
export declare class DynamicState {
|
|
14
15
|
readonly ctx: ParseContext;
|
|
15
16
|
readonly scanner: Scanner;
|
|
16
|
-
root:
|
|
17
|
+
root: RawSchema<any> | undefined;
|
|
17
18
|
branches: BranchState;
|
|
18
19
|
finalizer: Scanner.FinalizingLookahead | undefined;
|
|
19
20
|
groups: BranchState[];
|
|
20
21
|
constructor(def: string, ctx: ParseContext);
|
|
21
22
|
error(message: string): never;
|
|
22
23
|
hasRoot(): this is DynamicStateWithRoot;
|
|
24
|
+
setRoot(root: RawSchema): void;
|
|
23
25
|
unsetRoot(): this["root"];
|
|
24
|
-
constrainRoot(...args: Parameters<
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
reduceLeftBound(limit: LimitLiteral, comparator: Comparator): undefined;
|
|
26
|
+
constrainRoot(...args: Parameters<RawSchema<any>["constrain"]>): void;
|
|
27
|
+
finalize(finalizer: Scanner.FinalizingLookahead): void;
|
|
28
|
+
reduceLeftBound(limit: LimitLiteral, comparator: Comparator): void;
|
|
28
29
|
finalizeBranches(): void;
|
|
29
|
-
finalizeGroup():
|
|
30
|
+
finalizeGroup(): void;
|
|
30
31
|
addPrefix(prefix: StringifiablePrefixOperator): void;
|
|
31
32
|
applyPrefixes(): void;
|
|
32
33
|
pushRootToBranch(token: "|" | "&"): void;
|
|
@@ -35,8 +36,7 @@ export declare class DynamicState {
|
|
|
35
36
|
parseOperand(): void;
|
|
36
37
|
private assertRangeUnset;
|
|
37
38
|
reduceGroupOpen(): void;
|
|
38
|
-
previousOperator():
|
|
39
|
+
previousOperator(): MinComparator | StringifiablePrefixOperator | InfixOperator | undefined;
|
|
39
40
|
shiftedByOne(): this;
|
|
40
41
|
}
|
|
41
42
|
export {};
|
|
42
|
-
//# sourceMappingURL=dynamic.d.ts.map
|
|
@@ -7,9 +7,13 @@ import { invertedComparators, minComparators, writeMultipleLeftBoundsMessage, wr
|
|
|
7
7
|
export class DynamicState {
|
|
8
8
|
ctx;
|
|
9
9
|
scanner;
|
|
10
|
+
// set root type to `any` so that all constraints can be applied
|
|
10
11
|
root;
|
|
11
12
|
branches = {
|
|
12
|
-
prefixes: []
|
|
13
|
+
prefixes: [],
|
|
14
|
+
leftBound: null,
|
|
15
|
+
intersection: null,
|
|
16
|
+
union: null
|
|
13
17
|
};
|
|
14
18
|
finalizer;
|
|
15
19
|
groups = [];
|
|
@@ -23,29 +27,27 @@ export class DynamicState {
|
|
|
23
27
|
hasRoot() {
|
|
24
28
|
return this.root !== undefined;
|
|
25
29
|
}
|
|
30
|
+
setRoot(root) {
|
|
31
|
+
this.root = root;
|
|
32
|
+
}
|
|
26
33
|
unsetRoot() {
|
|
27
34
|
const value = this.root;
|
|
28
35
|
this.root = undefined;
|
|
29
36
|
return value;
|
|
30
37
|
}
|
|
31
38
|
constrainRoot(...args) {
|
|
32
|
-
this.root = this.root.constrain(
|
|
33
|
-
}
|
|
34
|
-
setRoot(root) {
|
|
35
|
-
this.root = root;
|
|
39
|
+
this.root = this.root.constrain(args[0], args[1]);
|
|
36
40
|
}
|
|
37
41
|
finalize(finalizer) {
|
|
38
|
-
if (this.groups.length)
|
|
42
|
+
if (this.groups.length)
|
|
39
43
|
return this.error(writeUnclosedGroupMessage(")"));
|
|
40
|
-
}
|
|
41
44
|
this.finalizeBranches();
|
|
42
45
|
this.finalizer = finalizer;
|
|
43
46
|
}
|
|
44
47
|
reduceLeftBound(limit, comparator) {
|
|
45
48
|
const invertedComparator = invertedComparators[comparator];
|
|
46
|
-
if (!isKeyOf(invertedComparator, minComparators))
|
|
49
|
+
if (!isKeyOf(invertedComparator, minComparators))
|
|
47
50
|
return this.error(writeUnpairableComparatorMessage(comparator));
|
|
48
|
-
}
|
|
49
51
|
if (this.branches.leftBound) {
|
|
50
52
|
return this.error(writeMultipleLeftBoundsMessage(this.branches.leftBound.limit, this.branches.leftBound.comparator, limit, invertedComparator));
|
|
51
53
|
}
|
|
@@ -56,24 +58,22 @@ export class DynamicState {
|
|
|
56
58
|
}
|
|
57
59
|
finalizeBranches() {
|
|
58
60
|
this.assertRangeUnset();
|
|
59
|
-
if (this.branches
|
|
61
|
+
if (this.branches.union) {
|
|
60
62
|
this.pushRootToBranch("|");
|
|
61
|
-
this.root = this.branches
|
|
63
|
+
this.root = this.branches.union;
|
|
62
64
|
}
|
|
63
|
-
else if (this.branches
|
|
65
|
+
else if (this.branches.intersection) {
|
|
64
66
|
this.pushRootToBranch("&");
|
|
65
|
-
this.root = this.branches
|
|
67
|
+
this.root = this.branches.intersection;
|
|
66
68
|
}
|
|
67
|
-
else
|
|
69
|
+
else
|
|
68
70
|
this.applyPrefixes();
|
|
69
|
-
}
|
|
70
71
|
}
|
|
71
72
|
finalizeGroup() {
|
|
72
73
|
this.finalizeBranches();
|
|
73
74
|
const topBranchState = this.groups.pop();
|
|
74
|
-
if (!topBranchState)
|
|
75
|
+
if (!topBranchState)
|
|
75
76
|
return this.error(writeUnmatchedGroupCloseMessage(this.scanner.unscanned));
|
|
76
|
-
}
|
|
77
77
|
this.branches = topBranchState;
|
|
78
78
|
}
|
|
79
79
|
addPrefix(prefix) {
|
|
@@ -83,8 +83,8 @@ export class DynamicState {
|
|
|
83
83
|
while (this.branches.prefixes.length) {
|
|
84
84
|
const lastPrefix = this.branches.prefixes.pop();
|
|
85
85
|
this.root =
|
|
86
|
-
lastPrefix === "keyof"
|
|
87
|
-
|
|
86
|
+
lastPrefix === "keyof" ?
|
|
87
|
+
this.root.keyof()
|
|
88
88
|
: throwInternalError(`Unexpected prefix '${lastPrefix}'`);
|
|
89
89
|
}
|
|
90
90
|
}
|
|
@@ -92,11 +92,12 @@ export class DynamicState {
|
|
|
92
92
|
this.assertRangeUnset();
|
|
93
93
|
this.applyPrefixes();
|
|
94
94
|
const root = this.root;
|
|
95
|
-
this.branches
|
|
95
|
+
this.branches.intersection = this.branches.intersection?.and(root) ?? root;
|
|
96
96
|
if (token === "|") {
|
|
97
|
-
this.branches
|
|
98
|
-
this.branches
|
|
99
|
-
|
|
97
|
+
this.branches.union =
|
|
98
|
+
this.branches.union?.or(this.branches.intersection) ??
|
|
99
|
+
this.branches.intersection;
|
|
100
|
+
this.branches.intersection = null;
|
|
100
101
|
}
|
|
101
102
|
this.root = undefined;
|
|
102
103
|
}
|
|
@@ -117,17 +118,21 @@ export class DynamicState {
|
|
|
117
118
|
reduceGroupOpen() {
|
|
118
119
|
this.groups.push(this.branches);
|
|
119
120
|
this.branches = {
|
|
120
|
-
prefixes: []
|
|
121
|
+
prefixes: [],
|
|
122
|
+
leftBound: null,
|
|
123
|
+
union: null,
|
|
124
|
+
intersection: null
|
|
121
125
|
};
|
|
122
126
|
}
|
|
123
127
|
previousOperator() {
|
|
124
128
|
return (this.branches.leftBound?.comparator ??
|
|
125
129
|
this.branches.prefixes.at(-1) ??
|
|
126
|
-
(this.branches
|
|
130
|
+
(this.branches.intersection ? "&"
|
|
131
|
+
: this.branches.union ? "|"
|
|
132
|
+
: undefined));
|
|
127
133
|
}
|
|
128
134
|
shiftedByOne() {
|
|
129
135
|
this.scanner.shift();
|
|
130
136
|
return this;
|
|
131
137
|
}
|
|
132
138
|
}
|
|
133
|
-
//# sourceMappingURL=dynamic.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dynamic.js","sourceRoot":"","sources":["../../../../parser/string/reduce/dynamic.ts"],"names":[],"mappings":"AACA,OAAO,EACN,OAAO,
|
|
1
|
+
{"version":3,"file":"dynamic.js","sourceRoot":"","sources":["../../../../parser/string/reduce/dynamic.ts"],"names":[],"mappings":"AACA,OAAO,EACN,OAAO,EAEP,kBAAkB,EAClB,eAAe,EACf,MAAM,eAAe,CAAA;AAGtB,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAA;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAA;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AAClD,OAAO,EAKN,mBAAmB,EACnB,cAAc,EACd,8BAA8B,EAC9B,qBAAqB,EACrB,yBAAyB,EACzB,+BAA+B,EAC/B,gCAAgC,EAChC,MAAM,aAAa,CAAA;AAWpB,MAAM,OAAO,YAAY;IAeP;IAdR,OAAO,CAAS;IACzB,gEAAgE;IAChE,IAAI,CAA4B;IAChC,QAAQ,GAAgB;QACvB,QAAQ,EAAE,EAAE;QACZ,SAAS,EAAE,IAAI;QACf,YAAY,EAAE,IAAI;QAClB,KAAK,EAAE,IAAI;KACX,CAAA;IACD,SAAS,CAAyC;IAClD,MAAM,GAAkB,EAAE,CAAA;IAE1B,YACC,GAAW,EACK,GAAiB;QAAjB,QAAG,GAAH,GAAG,CAAc;QAEjC,IAAI,CAAC,OAAO,GA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AAK,EAC7B,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,UAAU,CAClC,CACD,CAAA;QACF,CAAC;IACF,CAAC;IAED,eAAe;QACd,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QAC/B,IAAI,CAAC,QAAQ,GAAG;YACf,QAAQ,EAAE,EAAE;YACZ,SAAS,EAAE,IAAI;YACf,KAAK,EAAE,IAAI;YACX,YAAY,EAAE,IAAI;SAClB,CAAA;IACF,CAAC;IAED,gBAAgB;QAKf,OAAO,CACN,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,UAAU;YACnC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;YAC7B,CAAC,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC,GAAG;gBACjC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG;oBAC3B,CAAC,CAAC,SAAS,CAAC,CACZ,CAAA;IACF,CAAC;IAED,YAAY;QACX,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAA;QACpB,OAAO,IAAI,CAAA;IACZ,CAAC;CACD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { LimitLiteral } from "@arktype/schema";
|
|
2
2
|
export type StringifiablePrefixOperator = "keyof";
|
|
3
3
|
export declare const minComparators: {
|
|
4
4
|
readonly ">": true;
|
|
@@ -26,31 +26,17 @@ export declare const invertedComparators: {
|
|
|
26
26
|
readonly "==": "==";
|
|
27
27
|
};
|
|
28
28
|
export type InvertedComparators = typeof invertedComparators;
|
|
29
|
-
export type LimitLiteral = number | DateLiteral;
|
|
30
29
|
export type OpenLeftBound = {
|
|
31
30
|
limit: LimitLiteral;
|
|
32
31
|
comparator: MinComparator;
|
|
33
32
|
};
|
|
34
|
-
export declare const writeUnmatchedGroupCloseMessage: <unscanned extends string>(unscanned: unscanned) =>
|
|
33
|
+
export declare const writeUnmatchedGroupCloseMessage: <unscanned extends string>(unscanned: unscanned) => writeUnmatchedGroupCloseMessage<unscanned>;
|
|
35
34
|
export type writeUnmatchedGroupCloseMessage<unscanned extends string> = `Unmatched )${unscanned extends "" ? "" : ` before ${unscanned}`}`;
|
|
36
|
-
export declare const writeUnclosedGroupMessage: <missingChar extends string>(missingChar: missingChar) =>
|
|
35
|
+
export declare const writeUnclosedGroupMessage: <missingChar extends string>(missingChar: missingChar) => writeUnclosedGroupMessage<missingChar>;
|
|
37
36
|
export type writeUnclosedGroupMessage<missingChar extends string> = `Missing ${missingChar}`;
|
|
38
|
-
export declare const writeOpenRangeMessage: <min extends LimitLiteral, comparator extends ">" | ">=">(min: min, comparator: comparator) =>
|
|
37
|
+
export declare const writeOpenRangeMessage: <min extends LimitLiteral, comparator extends ">" | ">=">(min: min, comparator: comparator) => writeOpenRangeMessage<min, comparator>;
|
|
39
38
|
export type writeOpenRangeMessage<min extends LimitLiteral, comparator extends MinComparator> = `Left bounds are only valid when paired with right bounds (try ...${comparator}${min})`;
|
|
40
39
|
export type writeUnpairableComparatorMessage<comparator extends Comparator> = `Left-bounded expressions must specify their limits using < or <= (was ${comparator})`;
|
|
41
|
-
export declare const writeUnpairableComparatorMessage: <comparator extends "==" | "<" | "<=" | ">" | ">=">(comparator: comparator) =>
|
|
42
|
-
export declare const writeMultipleLeftBoundsMessage: <openLimit extends LimitLiteral, openComparator extends ">" | ">=", limit extends LimitLiteral, comparator extends ">" | ">=">(openLimit: openLimit, openComparator: openComparator, limit: limit, comparator: comparator) =>
|
|
43
|
-
readonly "<": ">";
|
|
44
|
-
readonly ">": "<";
|
|
45
|
-
readonly "<=": ">=";
|
|
46
|
-
readonly ">=": "<=";
|
|
47
|
-
readonly "==": "==";
|
|
48
|
-
}[openComparator]}, ${limit}${{
|
|
49
|
-
readonly "<": ">";
|
|
50
|
-
readonly ">": "<";
|
|
51
|
-
readonly "<=": ">=";
|
|
52
|
-
readonly ">=": "<=";
|
|
53
|
-
readonly "==": "==";
|
|
54
|
-
}[comparator]})`;
|
|
40
|
+
export declare const writeUnpairableComparatorMessage: <comparator extends "==" | "<" | "<=" | ">" | ">=">(comparator: comparator) => writeUnpairableComparatorMessage<comparator>;
|
|
41
|
+
export declare const writeMultipleLeftBoundsMessage: <openLimit extends LimitLiteral, openComparator extends ">" | ">=", limit extends LimitLiteral, comparator extends ">" | ">=">(openLimit: openLimit, openComparator: openComparator, limit: limit, comparator: comparator) => writeMultipleLeftBoundsMessage<openLimit, openComparator, limit, comparator>;
|
|
55
42
|
export type writeMultipleLeftBoundsMessage<openLimit extends LimitLiteral, openComparator extends MinComparator, limit extends LimitLiteral, comparator extends MinComparator> = `An expression may have at most one left bound (parsed ${openLimit}${InvertedComparators[openComparator]}, ${limit}${InvertedComparators[comparator]})`;
|
|
56
|
-
//# sourceMappingURL=shared.d.ts.map
|
|
@@ -23,4 +23,3 @@ export const writeUnclosedGroupMessage = (missingChar) => `Missing ${missingChar
|
|
|
23
23
|
export const writeOpenRangeMessage = (min, comparator) => `Left bounds are only valid when paired with right bounds (try ...${comparator}${min})`;
|
|
24
24
|
export const writeUnpairableComparatorMessage = (comparator) => `Left-bounded expressions must specify their limits using < or <= (was ${comparator})`;
|
|
25
25
|
export const writeMultipleLeftBoundsMessage = (openLimit, openComparator, limit, comparator) => `An expression may have at most one left bound (parsed ${openLimit}${invertedComparators[openComparator]}, ${limit}${invertedComparators[comparator]})`;
|
|
26
|
-
//# sourceMappingURL=shared.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../../parser/string/reduce/shared.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,MAAM,cAAc,GAAG;IAC7B,GAAG,EAAE,IAAI;IACT,IAAI,EAAE,IAAI;CACD,CAAA;AAIV,MAAM,CAAC,MAAM,cAAc,GAAG;IAC7B,GAAG,EAAE,IAAI;IACT,I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GAAG,GAAG,CAAA;AAUxF,MAAM,CAAC,MAAM,gCAAgC,GAAG,CAC/C,UAAsB,EACyB,EAAE,CACjD,yEAAyE,UAAU,GAAG,CAAA;AAEvF,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAM7C,SAAoB,EACpB,cAA8B,EAC9B,KAAY,EACZ,UAAsB,EAMrB,EAAE,CACH,yDAAyD,SAAS,GAAG,mBAAmB,CAAC,cAAc,CAAC,KAAK,KAAK,GAAG,mBAAmB,CAAC,UAAU,CAAC,GAAG,CAAA"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { LimitLiteral } from "@arktype/schema";
|
|
2
|
+
import type { Completion, ErrorMessage, defined } from "@arktype/util";
|
|
2
3
|
import type { Scanner } from "../shift/scanner.js";
|
|
3
|
-
import type { Comparator, InvertedComparators,
|
|
4
|
+
import type { Comparator, InvertedComparators, MaxComparator, MinComparator, OpenLeftBound, StringifiablePrefixOperator, writeMultipleLeftBoundsMessage, writeOpenRangeMessage, writeUnclosedGroupMessage, writeUnmatchedGroupCloseMessage, writeUnpairableComparatorMessage } from "./shared.js";
|
|
4
5
|
export type StaticState = {
|
|
5
6
|
root: unknown;
|
|
6
7
|
branches: BranchState;
|
|
@@ -9,13 +10,13 @@ export type StaticState = {
|
|
|
9
10
|
scanned: string;
|
|
10
11
|
unscanned: string;
|
|
11
12
|
};
|
|
12
|
-
export type AutocompletePrefix = `${StringifiablePrefixOperator} `;
|
|
13
13
|
type BranchState = {
|
|
14
14
|
prefixes: StringifiablePrefixOperator[];
|
|
15
15
|
leftBound: OpenLeftBound | undefined;
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
intersection: unknown;
|
|
17
|
+
union: unknown;
|
|
18
18
|
};
|
|
19
|
+
export type AutocompletePrefix = `${StringifiablePrefixOperator} `;
|
|
19
20
|
export declare namespace state {
|
|
20
21
|
export type initialize<def extends string> = from<{
|
|
21
22
|
root: undefined;
|
|
@@ -44,8 +45,8 @@ export declare namespace state {
|
|
|
44
45
|
type initialBranches = branchesFrom<{
|
|
45
46
|
prefixes: [];
|
|
46
47
|
leftBound: undefined;
|
|
47
|
-
|
|
48
|
-
|
|
48
|
+
intersection: undefined;
|
|
49
|
+
union: undefined;
|
|
49
50
|
}>;
|
|
50
51
|
type updateScanned<previousScanned extends string, previousUnscanned extends string, updatedUnscanned extends string> = previousUnscanned extends `${infer justScanned}${updatedUnscanned}` ? `${previousScanned}${justScanned}` : previousScanned;
|
|
51
52
|
export type setRoot<s extends StaticState, root, unscanned extends string> = from<{
|
|
@@ -61,8 +62,8 @@ export declare namespace state {
|
|
|
61
62
|
branches: {
|
|
62
63
|
prefixes: [...s["branches"]["prefixes"], prefix];
|
|
63
64
|
leftBound: s["branches"]["leftBound"];
|
|
64
|
-
|
|
65
|
-
|
|
65
|
+
intersection: s["branches"]["intersection"];
|
|
66
|
+
union: s["branches"]["union"];
|
|
66
67
|
};
|
|
67
68
|
groups: s["groups"];
|
|
68
69
|
finalizer: s["finalizer"];
|
|
@@ -74,8 +75,8 @@ export declare namespace state {
|
|
|
74
75
|
branches: {
|
|
75
76
|
prefixes: [];
|
|
76
77
|
leftBound: undefined;
|
|
77
|
-
|
|
78
|
-
|
|
78
|
+
intersection: token extends "&" ? mergeToIntersection<s> : undefined;
|
|
79
|
+
union: token extends "|" ? mergeToUnion<s> : s["branches"]["union"];
|
|
79
80
|
};
|
|
80
81
|
groups: s["groups"];
|
|
81
82
|
finalizer: s["finalizer"];
|
|
@@ -90,8 +91,8 @@ export declare namespace state {
|
|
|
90
91
|
limit: limit;
|
|
91
92
|
comparator: InvertedComparators[comparator];
|
|
92
93
|
};
|
|
93
|
-
|
|
94
|
-
|
|
94
|
+
intersection: s["branches"]["intersection"];
|
|
95
|
+
union: s["branches"]["union"];
|
|
95
96
|
};
|
|
96
97
|
groups: s["groups"];
|
|
97
98
|
finalizer: s["finalizer"];
|
|
@@ -103,30 +104,33 @@ export declare namespace state {
|
|
|
103
104
|
branches: {
|
|
104
105
|
prefixes: s["branches"]["prefixes"];
|
|
105
106
|
leftBound: undefined;
|
|
106
|
-
|
|
107
|
-
|
|
107
|
+
intersection: s["branches"]["intersection"];
|
|
108
|
+
union: s["branches"]["union"];
|
|
108
109
|
};
|
|
109
110
|
groups: s["groups"];
|
|
110
111
|
finalizer: s["finalizer"];
|
|
111
112
|
scanned: updateScanned<s["scanned"], s["unscanned"], unscanned>;
|
|
112
113
|
unscanned: unscanned;
|
|
113
114
|
}>;
|
|
114
|
-
export type reduceSingleBound<s extends StaticState, comparator extends Comparator, limit extends
|
|
115
|
+
export type reduceSingleBound<s extends StaticState, comparator extends Comparator, limit extends number | string, unscanned extends string> = state.from<{
|
|
115
116
|
root: [s["root"], comparator, limit];
|
|
116
117
|
branches: {
|
|
117
118
|
prefixes: s["branches"]["prefixes"];
|
|
118
119
|
leftBound: undefined;
|
|
119
|
-
|
|
120
|
-
|
|
120
|
+
intersection: s["branches"]["intersection"];
|
|
121
|
+
union: s["branches"]["union"];
|
|
121
122
|
};
|
|
122
123
|
groups: s["groups"];
|
|
123
124
|
finalizer: s["finalizer"];
|
|
124
125
|
scanned: updateScanned<s["scanned"], s["unscanned"], unscanned>;
|
|
125
126
|
unscanned: unscanned;
|
|
126
127
|
}>;
|
|
127
|
-
type mergeToUnion<s extends StaticState> = s["branches"]["
|
|
128
|
-
type mergeToIntersection<s extends StaticState> = s["branches"]["
|
|
129
|
-
type mergePrefixes<s extends StaticState, remaining extends unknown[] = s["branches"]["prefixes"]> = remaining extends [infer head, ...infer tail] ? [
|
|
128
|
+
type mergeToUnion<s extends StaticState> = s["branches"]["union"] extends undefined ? mergeToIntersection<s> : [s["branches"]["union"], "|", mergeToIntersection<s>];
|
|
129
|
+
type mergeToIntersection<s extends StaticState> = s["branches"]["intersection"] extends undefined ? mergePrefixes<s> : [s["branches"]["intersection"], "&", mergePrefixes<s>];
|
|
130
|
+
type mergePrefixes<s extends StaticState, remaining extends unknown[] = s["branches"]["prefixes"]> = remaining extends [infer head, ...infer tail] ? [
|
|
131
|
+
head,
|
|
132
|
+
mergePrefixes<s, tail>
|
|
133
|
+
] : s["root"];
|
|
130
134
|
type popGroup<stack extends BranchState[], top extends BranchState> = [
|
|
131
135
|
...stack,
|
|
132
136
|
top
|
|
@@ -156,10 +160,10 @@ export declare namespace state {
|
|
|
156
160
|
unscanned: s["unscanned"];
|
|
157
161
|
}> : state.error<writeUnclosedGroupMessage<")">>;
|
|
158
162
|
type openRangeError<range extends defined<BranchState["leftBound"]>> = state.error<writeOpenRangeMessage<range["limit"], range["comparator"]>>;
|
|
159
|
-
export type previousOperator<s extends StaticState> = s["branches"]["leftBound"] extends {} ? s["branches"]["leftBound"]["comparator"] : s["branches"]["prefixes"] extends [
|
|
163
|
+
export type previousOperator<s extends StaticState> = s["branches"]["leftBound"] extends {} ? s["branches"]["leftBound"]["comparator"] : s["branches"]["prefixes"] extends ([
|
|
160
164
|
...unknown[],
|
|
161
165
|
infer tail extends string
|
|
162
|
-
] ? tail : s["branches"]["
|
|
166
|
+
]) ? tail : s["branches"]["intersection"] extends {} ? "&" : s["branches"]["union"] extends {} ? "|" : undefined;
|
|
163
167
|
export type scanTo<s extends StaticState, unscanned extends string> = from<{
|
|
164
168
|
root: s["root"];
|
|
165
169
|
branches: s["branches"];
|
|
@@ -173,4 +177,3 @@ export declare namespace state {
|
|
|
173
177
|
export {};
|
|
174
178
|
}
|
|
175
179
|
export {};
|
|
176
|
-
//# sourceMappingURL=static.d.ts.map
|