arktype 2.0.0-rc.8 → 2.0.0-rc.9
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/out/config.d.ts +1 -1
- package/out/generic.d.ts +6 -6
- package/out/generic.js +2 -2
- package/out/index.d.ts +1 -1
- package/out/index.js +1 -1
- package/out/keywords/constructors/Array.d.ts +1 -1
- package/out/keywords/constructors/Date.d.ts +1 -1
- package/out/keywords/constructors/FormData.d.ts +1 -1
- package/out/keywords/{ast.d.ts → inference.d.ts} +42 -20
- package/out/keywords/{ark.d.ts → keywords.d.ts} +3 -3
- package/out/keywords/{ark.js → keywords.js} +7 -7
- package/out/keywords/number/number.d.ts +1 -1
- package/out/keywords/string/alpha.d.ts +1 -1
- package/out/keywords/string/alphanumeric.d.ts +1 -1
- package/out/keywords/string/capitalize.d.ts +1 -1
- package/out/keywords/string/creditCard.d.ts +1 -1
- package/out/keywords/string/date.d.ts +1 -1
- package/out/keywords/string/digits.d.ts +1 -1
- package/out/keywords/string/email.d.ts +1 -1
- package/out/keywords/string/integer.d.ts +1 -1
- package/out/keywords/string/ip.d.ts +1 -1
- package/out/keywords/string/json.d.ts +1 -1
- package/out/keywords/string/lower.d.ts +1 -1
- package/out/keywords/string/normalize.d.ts +1 -1
- package/out/keywords/string/numeric.d.ts +1 -1
- package/out/keywords/string/semver.d.ts +1 -1
- package/out/keywords/string/string.d.ts +7 -7
- package/out/keywords/string/trim.d.ts +1 -1
- package/out/keywords/string/upper.d.ts +1 -1
- package/out/keywords/string/url.d.ts +1 -1
- package/out/keywords/string/uuid.d.ts +1 -1
- package/out/methods/array.d.ts +1 -1
- package/out/methods/base.d.ts +24 -23
- package/out/methods/date.d.ts +1 -1
- package/out/methods/instantiate.d.ts +3 -3
- package/out/methods/morph.d.ts +3 -4
- package/out/methods/number.d.ts +1 -1
- package/out/methods/object.d.ts +55 -30
- package/out/methods/string.d.ts +1 -1
- package/out/methods/validator.d.ts +1 -1
- package/out/parser/{semantic → ast}/bounds.d.ts +3 -3
- package/out/parser/{semantic → ast}/default.d.ts +2 -2
- package/out/parser/{semantic → ast}/infer.d.ts +4 -6
- package/out/parser/{semantic → ast}/utils.d.ts +1 -1
- package/out/parser/{semantic → ast}/validate.d.ts +4 -4
- package/out/parser/definition.d.ts +3 -3
- package/out/parser/objectLiteral.d.ts +3 -3
- package/out/parser/{string/reduce → reduce}/dynamic.d.ts +2 -2
- package/out/parser/{string/reduce → reduce}/shared.d.ts +1 -1
- package/out/parser/{string/reduce → reduce}/static.d.ts +1 -1
- package/out/parser/{string/shift → shift}/operand/date.d.ts +1 -1
- package/out/parser/{string/shift → shift}/operand/enclosed.d.ts +3 -3
- package/out/parser/{string/shift → shift}/operand/unenclosed.d.ts +3 -3
- package/out/parser/{string/shift → shift}/operand/unenclosed.js +1 -1
- package/out/parser/{string/shift → shift}/operator/bounds.d.ts +3 -3
- package/out/parser/{string/shift → shift}/operator/default.d.ts +1 -1
- package/out/parser/{string/string.d.ts → string.d.ts} +3 -3
- package/out/parser/tuple.d.ts +7 -8
- package/out/parser/tuple.js +1 -1
- package/out/scope.d.ts +2 -2
- package/out/scope.js +4 -4
- package/out/type.d.ts +5 -5
- package/out/type.js +1 -1
- package/package.json +3 -3
- package/out/intersect.d.ts +0 -26
- package/out/intersect.js +0 -1
- package/out/keys.d.ts +0 -18
- package/out/keys.js +0 -1
- /package/out/keywords/{ast.js → inference.js} +0 -0
- /package/out/parser/{semantic → ast}/bounds.js +0 -0
- /package/out/parser/{semantic → ast}/default.js +0 -0
- /package/out/parser/{semantic → ast}/divisor.d.ts +0 -0
- /package/out/parser/{semantic → ast}/divisor.js +0 -0
- /package/out/parser/{semantic → ast}/infer.js +0 -0
- /package/out/parser/{semantic → ast}/keyof.d.ts +0 -0
- /package/out/parser/{semantic → ast}/keyof.js +0 -0
- /package/out/parser/{semantic → ast}/utils.js +0 -0
- /package/out/parser/{semantic → ast}/validate.js +0 -0
- /package/out/parser/{string/reduce → reduce}/dynamic.js +0 -0
- /package/out/parser/{string/reduce → reduce}/shared.js +0 -0
- /package/out/parser/{string/reduce → reduce}/static.js +0 -0
- /package/out/parser/{string/shift → shift}/operand/date.js +0 -0
- /package/out/parser/{string/shift → shift}/operand/enclosed.js +0 -0
- /package/out/parser/{string/shift → shift}/operand/genericArgs.d.ts +0 -0
- /package/out/parser/{string/shift → shift}/operand/genericArgs.js +0 -0
- /package/out/parser/{string/shift → shift}/operand/operand.d.ts +0 -0
- /package/out/parser/{string/shift → shift}/operand/operand.js +0 -0
- /package/out/parser/{string/shift → shift}/operator/bounds.js +0 -0
- /package/out/parser/{string/shift → shift}/operator/default.js +0 -0
- /package/out/parser/{string/shift → shift}/operator/divisor.d.ts +0 -0
- /package/out/parser/{string/shift → shift}/operator/divisor.js +0 -0
- /package/out/parser/{string/shift → shift}/operator/operator.d.ts +0 -0
- /package/out/parser/{string/shift → shift}/operator/operator.js +0 -0
- /package/out/parser/{string/shift → shift}/scanner.d.ts +0 -0
- /package/out/parser/{string/shift → shift}/scanner.js +0 -0
- /package/out/parser/{string/string.js → string.js} +0 -0
package/out/methods/object.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { arkGet, arkKeyOf, toArkKey } from "
|
|
3
|
-
import type {
|
|
1
|
+
import type { BaseMappedPropInner, OptionalMappedPropInner, Prop } from "@ark/schema";
|
|
2
|
+
import type { anyOrNever, arkGet, arkIndexableOf, arkKeyOf, array, ErrorType, inferred, intersectUnion, Json, Key, listable, merge, optionalKeyOf, show, toArkKey } from "@ark/util";
|
|
3
|
+
import type { Default, InferredDefault, InferredOptional } from "../keywords/inference.ts";
|
|
4
|
+
import type { type } from "../keywords/keywords.ts";
|
|
4
5
|
import type { ArrayType } from "./array.ts";
|
|
5
6
|
import type { instantiateType } from "./instantiate.ts";
|
|
6
7
|
import type { ValidatorType } from "./validator.ts";
|
|
@@ -12,46 +13,70 @@ interface Type<out t extends object = object, $ = {}> extends ValidatorType<t, $
|
|
|
12
13
|
readonly [k in keyof t]: t[k];
|
|
13
14
|
}, $>;
|
|
14
15
|
keyof(): instantiateType<arkKeyOf<t>, $>;
|
|
15
|
-
get<k1 extends
|
|
16
|
-
get<k1 extends
|
|
17
|
-
get<k1 extends
|
|
16
|
+
get<const k1 extends arkIndexableOf<t>>(k1: k1 | type.cast<k1>): instantiateType<arkGet<t, k1>, $> extends infer r ? r : never;
|
|
17
|
+
get<const k1 extends arkIndexableOf<t>, const k2 extends arkIndexableOf<arkGet<t, k1>>>(k1: k1 | type.cast<k1>, k2: k2 | type.cast<k2>): instantiateType<arkGet<arkGet<t, k1>, k2>, $> extends infer r ? r : never;
|
|
18
|
+
get<const k1 extends arkIndexableOf<t>, const k2 extends arkIndexableOf<arkGet<t, k1>>, const k3 extends arkIndexableOf<arkGet<arkGet<t, k1>, k2>>>(k1: k1 | type.cast<k1>, k2: k2 | type.cast<k2>, k3: k3 | type.cast<k3>): instantiateType<arkGet<arkGet<arkGet<t, k1>, k2>, k3>, $> extends infer r ? r : never;
|
|
18
19
|
pick<const key extends arkKeyOf<t> = never>(...keys: (key | type.cast<key>)[]): Type<{
|
|
19
20
|
[k in keyof t as Extract<toArkKey<t, k>, key>]: t[k];
|
|
20
21
|
}, $>;
|
|
21
22
|
omit<const key extends arkKeyOf<t> = never>(...keys: (key | type.cast<key>)[]): Type<{
|
|
22
23
|
[k in keyof t as Exclude<toArkKey<t, k>, key>]: t[k];
|
|
23
24
|
}, $>;
|
|
24
|
-
merge<const def, r = type.infer<def, $>>(def: type.validate<def, $> & (r extends object ? unknown : ErrorType<"Merged type must be an object", [actual: r]>)): Type<merge<t, r & object
|
|
25
|
+
merge<const def, r = type.infer<def, $>>(def: type.validate<def, $> & (r extends object ? unknown : ErrorType<"Merged type must be an object", [actual: r]>)): Type<merge<t, NoInfer<r & object>>, $>;
|
|
25
26
|
required(): Type<{
|
|
26
27
|
[k in keyof t]-?: t[k];
|
|
27
28
|
}, $>;
|
|
28
29
|
partial(): Type<{
|
|
29
30
|
[k in keyof t]?: t[k];
|
|
30
31
|
}, $>;
|
|
31
|
-
map<transformed extends listable<
|
|
32
|
+
map<transformed extends listable<MappedTypeProp>>(flatMapEntry: (entry: typePropOf<t, $>) => transformed): Type<constructMapped<t, transformed>, $>;
|
|
33
|
+
props: array<typePropOf<t, $>>;
|
|
32
34
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
35
|
+
type typePropOf<o, $> = {
|
|
36
|
+
[k in keyof o]-?: typeProp<o, k, $>;
|
|
37
|
+
}[keyof o] & unknown;
|
|
38
|
+
type typeProp<o, k extends keyof o, $, t = o[k] & ({} | null)> = t extends InferredDefault<infer v, infer defaultValue> ? DefaultedTypeProp<k & Key, v, defaultValue, $> : BaseTypeProp<k extends optionalKeyOf<o> ? "optional" : t extends InferredOptional ? [
|
|
39
|
+
t
|
|
40
|
+
] extends [anyOrNever] ? "required" : "optional" : "required", k & Key, t, $>;
|
|
41
|
+
export interface BaseTypeProp<kind extends Prop.Kind = Prop.Kind, k extends Key = Key,
|
|
42
|
+
/** @ts-ignore cast variance */
|
|
43
|
+
out v = unknown, $ = {}> {
|
|
44
|
+
kind: kind;
|
|
45
|
+
key: k;
|
|
46
|
+
value: instantiateType<v, $>;
|
|
47
|
+
meta: ArkEnv.meta;
|
|
48
|
+
toJSON: () => Json;
|
|
49
|
+
}
|
|
50
|
+
export interface DefaultedTypeProp<k extends Key = Key, v = unknown, defaultValue = v, $ = {}> extends BaseTypeProp<"optional", k, v, $> {
|
|
51
|
+
default: defaultValue;
|
|
52
|
+
}
|
|
53
|
+
type MappedTypeProp<k extends Key = Key, v = unknown> = BaseMappedTypeProp<k, v> | OptionalMappedTypeProp<k, v>;
|
|
54
|
+
type BaseMappedTypeProp<k extends Key, v> = merge<BaseMappedPropInner, {
|
|
55
|
+
key: k;
|
|
56
|
+
value: type.cast<v>;
|
|
57
|
+
}>;
|
|
58
|
+
type OptionalMappedTypeProp<k extends Key, v> = merge<OptionalMappedPropInner, {
|
|
59
|
+
key: k;
|
|
60
|
+
value: type.cast<v>;
|
|
61
|
+
default?: v;
|
|
62
|
+
}>;
|
|
63
|
+
type constructMapped<t, transformed extends listable<MappedTypeProp>> = show<intersectUnion<fromTypeProps<t, transformed extends array ? transformed : [transformed]>>>;
|
|
64
|
+
type fromTypeProps<t, props extends array<MappedTypeProp>> = show<{
|
|
65
|
+
[prop in props[number] as Extract<applyHomomorphicOptionality<t, prop>, {
|
|
66
|
+
kind: "required";
|
|
67
|
+
}>["key"]]: prop["value"][inferred];
|
|
68
|
+
} & {
|
|
69
|
+
[prop in props[number] as Extract<applyHomomorphicOptionality<t, prop>, {
|
|
70
|
+
kind: "optional";
|
|
71
|
+
default?: never;
|
|
72
|
+
}>["key"]]?: prop["value"][inferred];
|
|
49
73
|
} & {
|
|
50
|
-
[
|
|
74
|
+
[prop in props[number] as Extract<applyHomomorphicOptionality<t, prop>, {
|
|
75
|
+
kind: "optional";
|
|
76
|
+
default: unknown;
|
|
77
|
+
}>["key"]]: (In?: prop["value"][inferred]) => Default<prop["default" & keyof prop]>;
|
|
51
78
|
}>;
|
|
52
|
-
type applyHomomorphicOptionality<t,
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
entry[2] extends string ? entry[2] : entry[0] extends optionalKeyOf<t> ? "optional" : "required"
|
|
56
|
-
];
|
|
79
|
+
type applyHomomorphicOptionality<t, prop extends MappedTypeProp> = prop["kind"] extends string ? prop : prop & {
|
|
80
|
+
kind: prop["key"] extends optionalKeyOf<t> ? "optional" : "required";
|
|
81
|
+
};
|
|
57
82
|
export type { Type as ObjectType };
|
package/out/methods/string.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ExactLength, ExclusiveNumericRangeSchema, exclusivizeRangeSchema, InclusiveNumericRangeSchema, Pattern } from "@ark/schema";
|
|
2
|
-
import type { applyConstraintSchema } from "../keywords/
|
|
2
|
+
import type { applyConstraintSchema } from "../keywords/inference.ts";
|
|
3
3
|
import type { ValidatorType } from "./validator.ts";
|
|
4
4
|
/** @ts-ignore cast variance */
|
|
5
5
|
interface Type<out t extends string = string, $ = {}> extends ValidatorType<t, $> {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Predicate, PredicateCast } from "@ark/schema";
|
|
2
|
-
import type { applyConstraintSchema } from "../keywords/
|
|
2
|
+
import type { applyConstraintSchema } from "../keywords/inference.ts";
|
|
3
3
|
import type { BaseType } from "./base.ts";
|
|
4
4
|
import type { instantiateType } from "./instantiate.ts";
|
|
5
5
|
/** @ts-ignore cast variance */
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { writeUnboundableMessage } from "@ark/schema";
|
|
2
2
|
import type { ErrorMessage, array, typeToString } from "@ark/util";
|
|
3
|
-
import type { LimitLiteral } from "../../keywords/
|
|
4
|
-
import type { Comparator } from "../
|
|
5
|
-
import type { BoundExpressionKind, writeInvalidLimitMessage } from "../
|
|
3
|
+
import type { LimitLiteral } from "../../keywords/inference.ts";
|
|
4
|
+
import type { Comparator } from "../reduce/shared.ts";
|
|
5
|
+
import type { BoundExpressionKind, writeInvalidLimitMessage } from "../shift/operator/bounds.ts";
|
|
6
6
|
import type { inferAstIn } from "./infer.ts";
|
|
7
7
|
import type { astToString } from "./utils.ts";
|
|
8
8
|
import type { validateAst } from "./validate.ts";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { writeUnassignableDefaultValueMessage } from "@ark/schema";
|
|
2
2
|
import type { ErrorMessage } from "@ark/util";
|
|
3
|
-
import type { type } from "../../keywords/
|
|
4
|
-
import type { UnitLiteral } from "../
|
|
3
|
+
import type { type } from "../../keywords/keywords.ts";
|
|
4
|
+
import type { UnitLiteral } from "../shift/operator/default.ts";
|
|
5
5
|
import type { inferAstOut } from "./infer.ts";
|
|
6
6
|
import type { astToString } from "./utils.ts";
|
|
7
7
|
import type { validateAst } from "./validate.ts";
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import type { GenericAst } from "@ark/schema";
|
|
2
|
-
import type { Hkt, array } from "@ark/util";
|
|
3
|
-
import type { inferIntersection } from "../../intersect.ts";
|
|
4
|
-
import type { arkKeyOf } from "../../keys.ts";
|
|
5
|
-
import type { type } from "../../keywords/ark.ts";
|
|
6
|
-
import type { Default, LimitLiteral, Optional, applyConstraint, applyConstraintSchema, distill, normalizeLimit } from "../../keywords/ast.ts";
|
|
2
|
+
import type { Hkt, arkKeyOf, array } from "@ark/util";
|
|
7
3
|
import type { Date } from "../../keywords/constructors/Date.ts";
|
|
4
|
+
import type { Default, LimitLiteral, Optional, applyConstraint, applyConstraintSchema, distill, inferIntersection, normalizeLimit } from "../../keywords/inference.ts";
|
|
5
|
+
import type { type } from "../../keywords/keywords.ts";
|
|
8
6
|
import type { UnparsedScope } from "../../scope.ts";
|
|
9
7
|
import type { inferDefinition } from "../definition.ts";
|
|
10
|
-
import type { Comparator, MinComparator } from "../
|
|
8
|
+
import type { Comparator, MinComparator } from "../reduce/shared.ts";
|
|
11
9
|
export type inferAstRoot<ast, $, args> = ast extends array ? inferExpression<ast, $, args> : never;
|
|
12
10
|
export type inferAstIn<ast, $, args> = distill.In<inferAstRoot<ast, $, args>>;
|
|
13
11
|
export type inferAstOut<ast, $, args> = distill.Out<inferAstRoot<ast, $, args>>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { Stringifiable } from "@ark/util";
|
|
2
|
-
import type { Comparator } from "../
|
|
2
|
+
import type { Comparator } from "../reduce/shared.ts";
|
|
3
3
|
import type { DefAst, InferredAst, InfixExpression, PostfixExpression } from "./infer.ts";
|
|
4
4
|
export type astToString<ast> = ast extends InferredAst | DefAst ? ast[2] : 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,10 +1,10 @@
|
|
|
1
1
|
import type { arkKind, GenericParamAst, PrivateDeclaration, writeMissingSubmoduleAccessMessage, writeUnsatisfiedParameterConstraintMessage } from "@ark/schema";
|
|
2
2
|
import type { anyOrNever, array, BigintLiteral, charsAfterFirst, Completion, ErrorMessage, NumberLiteral, typeToString, writeMalformedNumericLiteralMessage } from "@ark/util";
|
|
3
3
|
import type { Generic } from "../../generic.ts";
|
|
4
|
-
import type { Comparator } from "../
|
|
5
|
-
import type { writeInvalidGenericArgCountMessage } from "../
|
|
6
|
-
import type { UnitLiteral } from "../
|
|
7
|
-
import type { parseString } from "../string
|
|
4
|
+
import type { Comparator } from "../reduce/shared.ts";
|
|
5
|
+
import type { writeInvalidGenericArgCountMessage } from "../shift/operand/genericArgs.ts";
|
|
6
|
+
import type { UnitLiteral } from "../shift/operator/default.ts";
|
|
7
|
+
import type { parseString } from "../string.ts";
|
|
8
8
|
import type { validateRange } from "./bounds.ts";
|
|
9
9
|
import type { validateDefault } from "./default.ts";
|
|
10
10
|
import type { validateDivisor } from "./divisor.ts";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { type BaseParseContext, type BaseRoot } from "@ark/schema";
|
|
2
2
|
import { type ErrorMessage, type Fn, type Primitive, type anyOrNever, type array, type defined, type equals, type ifEmptyObjectLiteral, type objectKindOrDomainOf, type optionalKeyOf, type requiredKeyOf, type show } from "@ark/util";
|
|
3
|
-
import type { type } from "../keywords/
|
|
3
|
+
import type { type } from "../keywords/keywords.ts";
|
|
4
4
|
import type { string } from "../keywords/string/string.ts";
|
|
5
|
+
import type { validateString } from "./ast/validate.ts";
|
|
5
6
|
import { type inferObjectLiteral, type validateObjectLiteral } from "./objectLiteral.ts";
|
|
6
|
-
import type {
|
|
7
|
-
import type { BaseCompletions, inferString } from "./string/string.ts";
|
|
7
|
+
import type { BaseCompletions, inferString } from "./string.ts";
|
|
8
8
|
import { type TupleExpression, type inferTuple, type validateTuple } from "./tuple.ts";
|
|
9
9
|
export declare const parseObject: (def: object, ctx: BaseParseContext) => BaseRoot;
|
|
10
10
|
export type inferDefinition<def, $, args> = [
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { type BaseParseContext, type BaseRoot, type Index, type Optional, type Required, type UndeclaredKeyBehavior, type writeInvalidPropertyKeyMessage } from "@ark/schema";
|
|
2
2
|
import { type anyOrNever, type Dict, type ErrorMessage, type ErrorType, type EscapeToken, type Key, type listable, type merge, type show } from "@ark/util";
|
|
3
|
-
import type { constrain } from "../keywords/
|
|
3
|
+
import type { constrain } from "../keywords/inference.ts";
|
|
4
|
+
import type { astToString } from "./ast/utils.ts";
|
|
5
|
+
import type { validateString } from "./ast/validate.ts";
|
|
4
6
|
import type { inferDefinition, validateDefinition } from "./definition.ts";
|
|
5
|
-
import type { astToString } from "./semantic/utils.ts";
|
|
6
|
-
import type { validateString } from "./semantic/validate.ts";
|
|
7
7
|
export declare const parseObjectLiteral: (def: Dict, ctx: BaseParseContext) => BaseRoot;
|
|
8
8
|
export declare const writeInvalidUndeclaredBehaviorMessage: (actual: unknown) => string;
|
|
9
9
|
export declare const nonLeadingSpreadError = "Spread operator may only be used as the first key in an object";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { BaseParseContext, BaseRoot } from "@ark/schema";
|
|
2
2
|
import { type requireKeys } from "@ark/util";
|
|
3
|
-
import type { LimitLiteral } from "
|
|
4
|
-
import type { InfixOperator } from "
|
|
3
|
+
import type { LimitLiteral } from "../../keywords/inference.ts";
|
|
4
|
+
import type { InfixOperator } from "../ast/infer.ts";
|
|
5
5
|
import type { Scanner } from "../shift/scanner.ts";
|
|
6
6
|
import { type Comparator, type MinComparator, type OpenLeftBound, type StringifiablePrefixOperator } from "./shared.ts";
|
|
7
7
|
type BranchState = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Completion, ErrorMessage, defined } from "@ark/util";
|
|
2
|
-
import type { LimitLiteral } from "
|
|
2
|
+
import type { LimitLiteral } from "../../keywords/inference.ts";
|
|
3
3
|
import type { Scanner } from "../shift/scanner.ts";
|
|
4
4
|
import type { Comparator, InvertedComparators, MaxComparator, MinComparator, OpenLeftBound, StringifiablePrefixOperator, writeMultipleLeftBoundsMessage, writeOpenRangeMessage, writeUnclosedGroupMessage, writeUnmatchedGroupCloseMessage, writeUnpairableComparatorMessage } from "./shared.ts";
|
|
5
5
|
export type StaticState = {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DateLiteral } from "
|
|
1
|
+
import type { DateLiteral } from "../../../keywords/inference.ts";
|
|
2
2
|
export declare const isDateLiteral: (value: unknown) => value is DateLiteral;
|
|
3
3
|
export declare const isValidDate: (d: Date) => boolean;
|
|
4
4
|
export declare const extractDateLiteralSource: <literal extends DateLiteral>(literal: literal) => extractDateLiteralSource<literal>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type { InferredAst } from "
|
|
1
|
+
import type { Date } from "../../../keywords/constructors/Date.ts";
|
|
2
|
+
import type { string } from "../../../keywords/inference.ts";
|
|
3
|
+
import type { InferredAst } from "../../ast/infer.ts";
|
|
4
4
|
import type { DynamicState } from "../../reduce/dynamic.ts";
|
|
5
5
|
import type { StaticState, state } from "../../reduce/static.ts";
|
|
6
6
|
import type { Scanner } from "../scanner.ts";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { writeUnresolvableMessage, type BaseRoot, type GenericAst, type GenericRoot, type arkKind, type genericParamNames, type resolvableReferenceIn, type writeNonSubmoduleDotMessage } from "@ark/schema";
|
|
2
2
|
import { type BigintLiteral, type NumberLiteral, type join, type lastOf } from "@ark/util";
|
|
3
|
-
import type { ArkAmbient } from "
|
|
4
|
-
import type { resolutionToAst } from "
|
|
5
|
-
import type { GenericInstantiationAst, InferredAst } from "
|
|
3
|
+
import type { ArkAmbient } from "../../../config.ts";
|
|
4
|
+
import type { resolutionToAst } from "../../../scope.ts";
|
|
5
|
+
import type { GenericInstantiationAst, InferredAst } from "../../ast/infer.ts";
|
|
6
6
|
import type { DynamicState } from "../../reduce/dynamic.ts";
|
|
7
7
|
import type { StaticState, state } from "../../reduce/static.ts";
|
|
8
8
|
import type { BaseCompletions } from "../../string.ts";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { hasArkKind, writeUnresolvableMessage } from "@ark/schema";
|
|
2
2
|
import { printable, throwParseError, tryParseWellFormedBigint, tryParseWellFormedNumber } from "@ark/util";
|
|
3
|
-
import { writePrefixedPrivateReferenceMessage } from "
|
|
3
|
+
import { writePrefixedPrivateReferenceMessage } from "../../ast/validate.js";
|
|
4
4
|
import { parseGenericArgs, writeInvalidGenericArgCountMessage } from "./genericArgs.js";
|
|
5
5
|
export const parseUnenclosed = (s) => {
|
|
6
6
|
const token = s.scanner.shiftUntilNextTerminator();
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type BaseRoot, type BoundKind } from "@ark/schema";
|
|
2
2
|
import { type keySet } from "@ark/util";
|
|
3
|
-
import type { DateLiteral } from "
|
|
4
|
-
import type { InferredAst } from "
|
|
5
|
-
import type { astToString } from "
|
|
3
|
+
import type { DateLiteral } from "../../../keywords/inference.ts";
|
|
4
|
+
import type { InferredAst } from "../../ast/infer.ts";
|
|
5
|
+
import type { astToString } from "../../ast/utils.ts";
|
|
6
6
|
import type { DynamicState, DynamicStateWithRoot } from "../../reduce/dynamic.ts";
|
|
7
7
|
import { writeUnpairableComparatorMessage, type Comparator, type InvertedComparators, type MaxComparator } from "../../reduce/shared.ts";
|
|
8
8
|
import type { state, StaticState } from "../../reduce/static.ts";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { BaseRoot } from "@ark/schema";
|
|
2
2
|
import type { BigintLiteral, ErrorMessage, NumberLiteral, trim } from "@ark/util";
|
|
3
|
-
import type { DateLiteral } from "
|
|
3
|
+
import type { DateLiteral } from "../../../keywords/inference.ts";
|
|
4
4
|
import type { DynamicStateWithRoot } from "../../reduce/dynamic.ts";
|
|
5
5
|
import type { StringLiteral } from "../operand/enclosed.ts";
|
|
6
6
|
type UnitLiteralKeyword = "null" | "undefined" | "true" | "false";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { BaseRoot, resolvableReferenceIn } from "@ark/schema";
|
|
2
2
|
import { type ErrorMessage } from "@ark/util";
|
|
3
|
-
import type { ArkAmbient } from "
|
|
4
|
-
import type { resolutionToAst } from "
|
|
5
|
-
import type { inferAstRoot } from "
|
|
3
|
+
import type { ArkAmbient } from "../config.ts";
|
|
4
|
+
import type { resolutionToAst } from "../scope.ts";
|
|
5
|
+
import type { inferAstRoot } from "./ast/infer.ts";
|
|
6
6
|
import type { DynamicState, DynamicStateWithRoot } from "./reduce/dynamic.ts";
|
|
7
7
|
import type { StringifiablePrefixOperator } from "./reduce/shared.ts";
|
|
8
8
|
import type { state, StaticState } from "./reduce/static.ts";
|
package/out/parser/tuple.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { type BaseParseContext, type BaseRoot, type MetaSchema, type Morph, type Predicate } from "@ark/schema";
|
|
2
2
|
import { type anyOrNever, type array, type BuiltinObjectKind, type conform, type Constructor, type Domain, type ErrorMessage, type show } from "@ark/util";
|
|
3
|
-
import type { inferIntersection } from "../
|
|
4
|
-
import type { type } from "../keywords/
|
|
5
|
-
import type {
|
|
3
|
+
import type { applyConstraint, Default, distill, inferIntersection, inferMorphOut, inferPredicate, InferredOptional, Optional, Out } from "../keywords/inference.ts";
|
|
4
|
+
import type { type } from "../keywords/keywords.ts";
|
|
5
|
+
import type { InfixOperator, PostfixExpression } from "./ast/infer.ts";
|
|
6
6
|
import type { inferDefinition, validateDefinition } from "./definition.ts";
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import type { BaseCompletions } from "./string/string.ts";
|
|
7
|
+
import { writeMissingRightOperandMessage } from "./shift/operand/unenclosed.ts";
|
|
8
|
+
import type { BaseCompletions } from "./string.ts";
|
|
10
9
|
export declare const parseTuple: (def: array, ctx: BaseParseContext) => BaseRoot;
|
|
11
10
|
export declare const parseTupleLiteral: (def: array, ctx: BaseParseContext) => BaseRoot;
|
|
12
11
|
type InfixExpression = readonly [unknown, InfixOperator, ...unknown[]];
|
|
@@ -46,7 +45,7 @@ type preparseNextElement<s extends SequenceParseState, $, args> = s["unscanned"]
|
|
|
46
45
|
inferred: t;
|
|
47
46
|
optional: false;
|
|
48
47
|
spread: true;
|
|
49
|
-
}> : [t] extends [
|
|
48
|
+
}> : [t] extends [InferredOptional<infer base>] ? PreparsedElement.from<{
|
|
50
49
|
head: head;
|
|
51
50
|
tail: tail;
|
|
52
51
|
inferred: base;
|
|
@@ -66,7 +65,7 @@ type preparseNextElement<s extends SequenceParseState, $, args> = s["unscanned"]
|
|
|
66
65
|
inferred: t;
|
|
67
66
|
optional: false;
|
|
68
67
|
spread: false;
|
|
69
|
-
}> : [t] extends [
|
|
68
|
+
}> : [t] extends [InferredOptional<infer base>] ? PreparsedElement.from<{
|
|
70
69
|
head: head;
|
|
71
70
|
tail: tail;
|
|
72
71
|
inferred: base;
|
package/out/parser/tuple.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { $ark, Disjoint, intersectNodesRoot, makeRootAndArrayPropertiesMutable } from "@ark/schema";
|
|
2
2
|
import { append, isEmptyObject, objectKindOrDomainOf, throwParseError } from "@ark/util";
|
|
3
|
-
import { writeMissingRightOperandMessage } from "./
|
|
3
|
+
import { writeMissingRightOperandMessage } from "./shift/operand/unenclosed.js";
|
|
4
4
|
export const parseTuple = (def, ctx) => maybeParseTupleExpression(def, ctx) ?? parseTupleLiteral(def, ctx);
|
|
5
5
|
export const parseTupleLiteral = (def, ctx) => {
|
|
6
6
|
let sequences = [{}];
|
package/out/scope.d.ts
CHANGED
|
@@ -2,10 +2,10 @@ import { BaseScope, type AliasDefEntry, type ArkScopeConfig, type BaseNode, type
|
|
|
2
2
|
import { type ErrorType, type Json, type anyOrNever, type array, type flattenListable, type noSuggest, type nominal } from "@ark/util";
|
|
3
3
|
import type { ArkSchemaRegistry } from "./config.ts";
|
|
4
4
|
import { type GenericDeclaration, type GenericParser, type ParameterString, type baseGenericConstraints, type parseGenericParams, type parseValidGenericParams } from "./generic.ts";
|
|
5
|
-
import type { Ark, type } from "./keywords/
|
|
5
|
+
import type { Ark, type } from "./keywords/keywords.ts";
|
|
6
6
|
import type { BoundModule, Module, Submodule, instantiateExport } from "./module.ts";
|
|
7
|
+
import type { DefAst, InferredAst } from "./parser/ast/infer.ts";
|
|
7
8
|
import { type inferDefinition, type validateDefinition } from "./parser/definition.ts";
|
|
8
|
-
import type { DefAst, InferredAst } from "./parser/semantic/infer.ts";
|
|
9
9
|
import { InternalTypeParser, type DeclarationParser, type DefinitionParser, type EnumeratedTypeParser, type SchemaParser, type TypeParser, type UnitTypeParser } from "./type.ts";
|
|
10
10
|
export type ScopeParser = <const def>(def: scope.validate<def>, config?: ArkScopeConfig) => Scope<scope.infer<def>>;
|
|
11
11
|
export type ModuleParser = <const def>(def: scope.validate<def>, config?: ArkScopeConfig) => scope.infer<def> extends infer $ ? Module<{
|
package/out/scope.js
CHANGED
|
@@ -2,10 +2,10 @@ import { $ark, BaseScope, hasArkKind, parseGeneric } from "@ark/schema";
|
|
|
2
2
|
import { domainOf, flatMorph, hasDomain, isThunk, throwParseError } from "@ark/util";
|
|
3
3
|
import { parseGenericParamName } from "./generic.js";
|
|
4
4
|
import { parseObject, writeBadDefinitionTypeMessage } from "./parser/definition.js";
|
|
5
|
-
import { DynamicState } from "./parser/
|
|
6
|
-
import { writeUnexpectedCharacterMessage } from "./parser/
|
|
7
|
-
import { Scanner } from "./parser/
|
|
8
|
-
import { fullStringParse } from "./parser/string
|
|
5
|
+
import { DynamicState } from "./parser/reduce/dynamic.js";
|
|
6
|
+
import { writeUnexpectedCharacterMessage } from "./parser/shift/operator/operator.js";
|
|
7
|
+
import { Scanner } from "./parser/shift/scanner.js";
|
|
8
|
+
import { fullStringParse } from "./parser/string.js";
|
|
9
9
|
import { InternalTypeParser } from "./type.js";
|
|
10
10
|
export const $arkTypeRegistry = $ark;
|
|
11
11
|
export class InternalScope extends BaseScope {
|
package/out/type.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ArkErrors, BaseRoot, type BaseParseOptions, type MetaSchema, type Morph, type Predicate, type RootSchema } from "@ark/schema";
|
|
2
2
|
import { Callable, Hkt, type Constructor, type array, type conform } from "@ark/util";
|
|
3
3
|
import type { Generic, GenericParser, ParameterString, baseGenericConstraints, parseValidGenericParams, validateParameterString } from "./generic.ts";
|
|
4
|
-
import type {
|
|
5
|
-
import type {
|
|
4
|
+
import type { distill } from "./keywords/inference.ts";
|
|
5
|
+
import type { Ark, keywords, type } from "./keywords/keywords.ts";
|
|
6
6
|
import type { BaseType } from "./methods/base.ts";
|
|
7
7
|
import type { instantiateType } from "./methods/instantiate.ts";
|
|
8
8
|
import type { validateDeclared, validateDefinition } from "./parser/definition.ts";
|
|
@@ -14,11 +14,11 @@ export interface TypeParser<$ = {}> extends Ark.boundTypeAttachments<$> {
|
|
|
14
14
|
<const def, r = Type<type.infer<def, $>, $>>(def: type.validate<def, $>): r;
|
|
15
15
|
<const params extends ParameterString, const def>(params: validateParameterString<params, $>, def: validateDefinition<def, $, baseGenericConstraints<parseValidGenericParams<params, $>>>): Generic<parseValidGenericParams<params, $>, def, $>;
|
|
16
16
|
<const zero, const one, const rest extends array, r = Type<type.infer<[zero, one, ...rest], $>, $>>(_0: zero extends IndexZeroOperator ? zero : type.validate<zero, $>, _1: zero extends "keyof" ? type.validate<one, $> : zero extends "instanceof" ? conform<one, Constructor> : zero extends "===" ? conform<one, unknown> : conform<one, IndexOneOperator>, ..._2: zero extends "===" ? rest : zero extends "instanceof" ? conform<rest, readonly Constructor[]> : one extends TupleInfixOperator ? one extends ":" ? [Predicate<distill.In<type.infer<zero, $>>>] : one extends "=>" ? [Morph<distill.Out<type.infer<zero, $>>, unknown>] : one extends "@" ? [MetaSchema] : [type.validate<rest[0], $>] : []): r;
|
|
17
|
-
$: Scope<$>;
|
|
18
|
-
raw(def: unknown): BaseType<any, $>;
|
|
19
17
|
errors: typeof ArkErrors;
|
|
20
18
|
hkt: typeof Hkt;
|
|
21
|
-
|
|
19
|
+
keywords: typeof keywords;
|
|
20
|
+
$: Scope<$>;
|
|
21
|
+
raw(def: unknown): BaseType<any, $>;
|
|
22
22
|
module: ModuleParser;
|
|
23
23
|
scope: ScopeParser;
|
|
24
24
|
define: DefinitionParser<$>;
|
package/out/type.js
CHANGED
|
@@ -13,7 +13,7 @@ export class InternalTypeParser extends Callable {
|
|
|
13
13
|
generic: $.generic,
|
|
14
14
|
schema: $.schema,
|
|
15
15
|
// this won't be defined during bootstrapping, but externally always will be
|
|
16
|
-
|
|
16
|
+
keywords: $.ambient,
|
|
17
17
|
unit: $.unit,
|
|
18
18
|
enumerated: $.enumerated
|
|
19
19
|
},
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "arktype",
|
|
3
3
|
"description": "TypeScript's 1:1 validator, optimized from editor to runtime",
|
|
4
|
-
"version": "2.0.0-rc.
|
|
4
|
+
"version": "2.0.0-rc.9",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "David Blass",
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
"out"
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@ark/schema": "0.
|
|
38
|
-
"@ark/util": "0.
|
|
37
|
+
"@ark/schema": "0.11.0",
|
|
38
|
+
"@ark/util": "0.11.0"
|
|
39
39
|
},
|
|
40
40
|
"publishConfig": {
|
|
41
41
|
"access": "public"
|
package/out/intersect.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { anyOrNever, array, Hkt, intersectArrays, show } from "@ark/util";
|
|
2
|
-
import type { constrain, Constraints, MorphAst, parseConstraints, To } from "./keywords/ast.ts";
|
|
3
|
-
export type inferIntersection<l, r> = _inferIntersection<l, r, false>;
|
|
4
|
-
export type inferPipe<l, r> = _inferIntersection<l, r, true>;
|
|
5
|
-
type _inferIntersection<l, r, piped extends boolean> = [
|
|
6
|
-
l & r
|
|
7
|
-
] extends [infer t extends anyOrNever] ? t : l extends MorphAst<infer lIn, infer lOut> ? r extends MorphAst<any, infer rOut> ? piped extends true ? (In: lIn) => rOut : never : piped extends true ? (In: lIn) => To<r> : (In: _inferIntersection<lIn, r, false>) => lOut : r extends MorphAst<infer rIn, infer rOut> ? (In: _inferIntersection<rIn, l, false>) => rOut : parseConstraints<l> extends ([
|
|
8
|
-
infer lBase,
|
|
9
|
-
infer lConstraints extends Constraints
|
|
10
|
-
]) ? parseConstraints<r> extends ([
|
|
11
|
-
infer rBase,
|
|
12
|
-
infer rConstraints extends Constraints
|
|
13
|
-
]) ? constrain<_inferIntersection<lBase, rBase, piped>, lConstraints & rConstraints> : constrain<_inferIntersection<lBase, r, piped>, lConstraints> : parseConstraints<r> extends ([
|
|
14
|
-
infer rBase,
|
|
15
|
-
infer rConstraints extends Constraints
|
|
16
|
-
]) ? constrain<_inferIntersection<l, rBase, piped>, rConstraints> : [l, r] extends [object, object] ? intersectObjects<l, r, piped> extends infer result ? result : never : l & r;
|
|
17
|
-
interface MorphableIntersection<piped extends boolean> extends Hkt<[unknown, unknown]> {
|
|
18
|
-
body: _inferIntersection<this[0], this[1], piped>;
|
|
19
|
-
}
|
|
20
|
-
type intersectObjects<l, r, piped extends boolean> = l extends array ? r extends array ? intersectArrays<l, r, MorphableIntersection<piped>> : // for an intersection with exactly one array operand like { name: string } & string[],
|
|
21
|
-
l & r : r extends array ? l & r : show<{
|
|
22
|
-
[k in keyof l]: k extends keyof r ? _inferIntersection<l[k], r[k], piped> : l[k];
|
|
23
|
-
} & {
|
|
24
|
-
[k in keyof r]: k extends keyof l ? _inferIntersection<l[k], r[k], piped> : r[k];
|
|
25
|
-
}>;
|
|
26
|
-
export {};
|
package/out/intersect.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/out/keys.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { array, join, Key, NonNegativeIntegerLiteral, typeToString } from "@ark/util";
|
|
2
|
-
import type { type } from "./keywords/ark.ts";
|
|
3
|
-
import type { termOrType } from "./keywords/ast.ts";
|
|
4
|
-
export type toArkKey<o, k extends keyof o> = k extends number ? [
|
|
5
|
-
o,
|
|
6
|
-
number
|
|
7
|
-
] extends [array, k] ? NonNegativeIntegerLiteral : `${k}` : k;
|
|
8
|
-
export type arkKeyOf<o> = [
|
|
9
|
-
o
|
|
10
|
-
] extends [array] ? (number extends o["length"] ? NonNegativeIntegerLiteral : never) | {
|
|
11
|
-
[k in keyof o]-?: k extends `${infer index extends number}` ? index | k : never;
|
|
12
|
-
}[keyof o & `${number}`] : {
|
|
13
|
-
[k in keyof o]-?: k extends number ? k | `${k}` : k;
|
|
14
|
-
}[keyof o];
|
|
15
|
-
export type arkGet<o, k extends arkKeyOf<o>> = o[Extract<k extends NonNegativeIntegerLiteral ? number : k, keyof o>];
|
|
16
|
-
export type TypeKey = termOrType<Key>;
|
|
17
|
-
export type typeKeyToString<k extends TypeKey> = typeToString<k extends type.cast<infer t> ? t : k>;
|
|
18
|
-
export type writeInvalidKeysMessage<o extends string, keys extends array<string>> = `Key${keys["length"] extends 1 ? "" : "s"} ${join<keys, ", ">} ${keys["length"] extends 1 ? "does" : "do"} not exist on ${o}`;
|
package/out/keys.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|