arktype 1.0.27-alpha → 1.1.0-dev-1
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/dist/main.d.ts +1018 -0
- package/dist/main.js +1450 -0
- package/package.json +36 -108
- package/LICENSE +0 -7
- package/README.md +0 -351
- package/dist/cjs/main.js +0 -38
- package/dist/cjs/nodes/branch.js +0 -140
- package/dist/cjs/nodes/compose.js +0 -163
- package/dist/cjs/nodes/discriminate.js +0 -265
- package/dist/cjs/nodes/node.js +0 -139
- package/dist/cjs/nodes/predicate.js +0 -86
- package/dist/cjs/nodes/rules/class.js +0 -25
- package/dist/cjs/nodes/rules/collapsibleSet.js +0 -48
- package/dist/cjs/nodes/rules/divisor.js +0 -29
- package/dist/cjs/nodes/rules/props.js +0 -167
- package/dist/cjs/nodes/rules/range.js +0 -105
- package/dist/cjs/nodes/rules/regex.js +0 -26
- package/dist/cjs/nodes/rules/rules.js +0 -123
- package/dist/cjs/package.json +0 -3
- package/dist/cjs/parse/ast/ast.js +0 -4
- package/dist/cjs/parse/ast/bound.js +0 -16
- package/dist/cjs/parse/ast/config.js +0 -13
- package/dist/cjs/parse/ast/distributableFunction.js +0 -48
- package/dist/cjs/parse/ast/divisor.js +0 -9
- package/dist/cjs/parse/ast/intersection.js +0 -30
- package/dist/cjs/parse/ast/keyof.js +0 -111
- package/dist/cjs/parse/ast/morph.js +0 -58
- package/dist/cjs/parse/ast/narrow.js +0 -22
- package/dist/cjs/parse/ast/node.js +0 -4
- package/dist/cjs/parse/ast/tuple.js +0 -94
- package/dist/cjs/parse/ast/union.js +0 -9
- package/dist/cjs/parse/ast/utils.js +0 -4
- package/dist/cjs/parse/definition.js +0 -61
- package/dist/cjs/parse/record.js +0 -37
- package/dist/cjs/parse/string/reduce/dynamic.js +0 -167
- package/dist/cjs/parse/string/reduce/shared.js +0 -23
- package/dist/cjs/parse/string/reduce/static.js +0 -4
- package/dist/cjs/parse/string/shift/operand/enclosed.js +0 -54
- package/dist/cjs/parse/string/shift/operand/operand.js +0 -11
- package/dist/cjs/parse/string/shift/operand/unenclosed.js +0 -53
- package/dist/cjs/parse/string/shift/operator/bounds.js +0 -87
- package/dist/cjs/parse/string/shift/operator/divisor.js +0 -35
- package/dist/cjs/parse/string/shift/operator/operator.js +0 -26
- package/dist/cjs/parse/string/shift/scanner.js +0 -114
- package/dist/cjs/parse/string/string.js +0 -43
- package/dist/cjs/scopes/ark.js +0 -45
- package/dist/cjs/scopes/cache.js +0 -52
- package/dist/cjs/scopes/expressions.js +0 -29
- package/dist/cjs/scopes/jsObjects.js +0 -93
- package/dist/cjs/scopes/scope.js +0 -323
- package/dist/cjs/scopes/tsKeywords.js +0 -113
- package/dist/cjs/scopes/type.js +0 -50
- package/dist/cjs/scopes/validation/creditCard.js +0 -47
- package/dist/cjs/scopes/validation/date.js +0 -62
- package/dist/cjs/scopes/validation/validation.js +0 -108
- package/dist/cjs/traverse/problems.js +0 -281
- package/dist/cjs/traverse/traverse.js +0 -390
- package/dist/cjs/utils/chainableNoOpProxy.js +0 -23
- package/dist/cjs/utils/data.js +0 -53
- package/dist/cjs/utils/domains.js +0 -30
- package/dist/cjs/utils/errors.js +0 -26
- package/dist/cjs/utils/freeze.js +0 -15
- package/dist/cjs/utils/generics.js +0 -63
- package/dist/cjs/utils/numericLiterals.js +0 -75
- package/dist/cjs/utils/objectKinds.js +0 -69
- package/dist/cjs/utils/paths.js +0 -32
- package/dist/cjs/utils/serialize.js +0 -74
- package/dist/cjs/utils/unionToTuple.js +0 -4
- package/dist/mjs/main.js +0 -8
- package/dist/mjs/nodes/branch.js +0 -123
- package/dist/mjs/nodes/compose.js +0 -141
- package/dist/mjs/nodes/discriminate.js +0 -250
- package/dist/mjs/nodes/node.js +0 -117
- package/dist/mjs/nodes/predicate.js +0 -69
- package/dist/mjs/nodes/rules/class.js +0 -11
- package/dist/mjs/nodes/rules/collapsibleSet.js +0 -34
- package/dist/mjs/nodes/rules/divisor.js +0 -15
- package/dist/mjs/nodes/rules/props.js +0 -149
- package/dist/mjs/nodes/rules/range.js +0 -86
- package/dist/mjs/nodes/rules/regex.js +0 -11
- package/dist/mjs/nodes/rules/rules.js +0 -106
- package/dist/mjs/package.json +0 -3
- package/dist/mjs/parse/ast/ast.js +0 -1
- package/dist/mjs/parse/ast/bound.js +0 -2
- package/dist/mjs/parse/ast/config.js +0 -9
- package/dist/mjs/parse/ast/distributableFunction.js +0 -34
- package/dist/mjs/parse/ast/divisor.js +0 -1
- package/dist/mjs/parse/ast/intersection.js +0 -16
- package/dist/mjs/parse/ast/keyof.js +0 -103
- package/dist/mjs/parse/ast/morph.js +0 -44
- package/dist/mjs/parse/ast/narrow.js +0 -14
- package/dist/mjs/parse/ast/node.js +0 -1
- package/dist/mjs/parse/ast/tuple.js +0 -80
- package/dist/mjs/parse/ast/union.js +0 -1
- package/dist/mjs/parse/ast/utils.js +0 -1
- package/dist/mjs/parse/definition.js +0 -46
- package/dist/mjs/parse/record.js +0 -29
- package/dist/mjs/parse/string/reduce/dynamic.js +0 -159
- package/dist/mjs/parse/string/reduce/shared.js +0 -6
- package/dist/mjs/parse/string/reduce/static.js +0 -1
- package/dist/mjs/parse/string/shift/operand/enclosed.js +0 -39
- package/dist/mjs/parse/string/shift/operand/operand.js +0 -3
- package/dist/mjs/parse/string/shift/operand/unenclosed.js +0 -36
- package/dist/mjs/parse/string/shift/operator/bounds.js +0 -70
- package/dist/mjs/parse/string/shift/operator/divisor.js +0 -21
- package/dist/mjs/parse/string/shift/operator/operator.js +0 -13
- package/dist/mjs/parse/string/shift/scanner.js +0 -106
- package/dist/mjs/parse/string/string.js +0 -28
- package/dist/mjs/scopes/ark.js +0 -28
- package/dist/mjs/scopes/cache.js +0 -38
- package/dist/mjs/scopes/expressions.js +0 -89
- package/dist/mjs/scopes/jsObjects.js +0 -82
- package/dist/mjs/scopes/scope.js +0 -303
- package/dist/mjs/scopes/tsKeywords.js +0 -116
- package/dist/mjs/scopes/type.js +0 -35
- package/dist/mjs/scopes/validation/creditCard.js +0 -34
- package/dist/mjs/scopes/validation/date.js +0 -48
- package/dist/mjs/scopes/validation/validation.js +0 -112
- package/dist/mjs/traverse/problems.js +0 -260
- package/dist/mjs/traverse/traverse.js +0 -373
- package/dist/mjs/utils/chainableNoOpProxy.js +0 -15
- package/dist/mjs/utils/data.js +0 -38
- package/dist/mjs/utils/domains.js +0 -15
- package/dist/mjs/utils/errors.js +0 -10
- package/dist/mjs/utils/freeze.js +0 -7
- package/dist/mjs/utils/generics.js +0 -38
- package/dist/mjs/utils/numericLiterals.js +0 -72
- package/dist/mjs/utils/objectKinds.js +0 -55
- package/dist/mjs/utils/paths.js +0 -18
- package/dist/mjs/utils/serialize.js +0 -58
- package/dist/mjs/utils/unionToTuple.js +0 -1
- package/dist/tsconfig.temp.tsbuildinfo +0 -1
- package/dist/types/main.d.ts +0 -15
- package/dist/types/nodes/branch.d.ts +0 -29
- package/dist/types/nodes/compose.d.ts +0 -98
- package/dist/types/nodes/discriminate.d.ts +0 -26
- package/dist/types/nodes/node.d.ts +0 -69
- package/dist/types/nodes/predicate.d.ts +0 -18
- package/dist/types/nodes/rules/class.d.ts +0 -4
- package/dist/types/nodes/rules/collapsibleSet.d.ts +0 -4
- package/dist/types/nodes/rules/divisor.d.ts +0 -3
- package/dist/types/nodes/rules/props.d.ts +0 -43
- package/dist/types/nodes/rules/range.d.ts +0 -34
- package/dist/types/nodes/rules/regex.d.ts +0 -5
- package/dist/types/nodes/rules/rules.d.ts +0 -33
- package/dist/types/parse/ast/ast.d.ts +0 -24
- package/dist/types/parse/ast/bound.d.ts +0 -27
- package/dist/types/parse/ast/config.d.ts +0 -15
- package/dist/types/parse/ast/distributableFunction.d.ts +0 -18
- package/dist/types/parse/ast/divisor.d.ts +0 -13
- package/dist/types/parse/ast/intersection.d.ts +0 -31
- package/dist/types/parse/ast/keyof.d.ts +0 -10
- package/dist/types/parse/ast/morph.d.ts +0 -17
- package/dist/types/parse/ast/narrow.d.ts +0 -21
- package/dist/types/parse/ast/node.d.ts +0 -35
- package/dist/types/parse/ast/tuple.d.ts +0 -41
- package/dist/types/parse/ast/union.d.ts +0 -17
- package/dist/types/parse/ast/utils.d.ts +0 -7
- package/dist/types/parse/definition.d.ts +0 -30
- package/dist/types/parse/record.d.ts +0 -26
- package/dist/types/parse/string/reduce/dynamic.d.ts +0 -34
- package/dist/types/parse/string/reduce/shared.d.ts +0 -25
- package/dist/types/parse/string/reduce/static.d.ts +0 -130
- package/dist/types/parse/string/shift/operand/enclosed.d.ts +0 -28
- package/dist/types/parse/string/shift/operand/operand.d.ts +0 -9
- package/dist/types/parse/string/shift/operand/unenclosed.d.ts +0 -18
- package/dist/types/parse/string/shift/operator/bounds.d.ts +0 -21
- package/dist/types/parse/string/shift/operator/divisor.d.ts +0 -13
- package/dist/types/parse/string/shift/operator/operator.d.ts +0 -13
- package/dist/types/parse/string/shift/scanner.d.ts +0 -89
- package/dist/types/parse/string/string.d.ts +0 -25
- package/dist/types/scopes/ark.d.ts +0 -208
- package/dist/types/scopes/cache.d.ts +0 -14
- package/dist/types/scopes/expressions.d.ts +0 -136
- package/dist/types/scopes/jsObjects.d.ts +0 -26
- package/dist/types/scopes/scope.d.ts +0 -99
- package/dist/types/scopes/tsKeywords.d.ts +0 -50
- package/dist/types/scopes/type.d.ts +0 -67
- package/dist/types/scopes/validation/creditCard.d.ts +0 -2
- package/dist/types/scopes/validation/date.d.ts +0 -23
- package/dist/types/scopes/validation/validation.d.ts +0 -49
- package/dist/types/traverse/problems.d.ts +0 -88
- package/dist/types/traverse/traverse.d.ts +0 -55
- package/dist/types/utils/chainableNoOpProxy.d.ts +0 -14
- package/dist/types/utils/data.d.ts +0 -13
- package/dist/types/utils/domains.d.ts +0 -32
- package/dist/types/utils/errors.d.ts +0 -6
- package/dist/types/utils/freeze.d.ts +0 -2
- package/dist/types/utils/generics.d.ts +0 -125
- package/dist/types/utils/numericLiterals.d.ts +0 -46
- package/dist/types/utils/objectKinds.d.ts +0 -84
- package/dist/types/utils/paths.d.ts +0 -9
- package/dist/types/utils/serialize.d.ts +0 -37
- package/dist/types/utils/unionToTuple.d.ts +0 -11
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import type { constructor, instanceOf, isTopType } from "./generics.js";
|
|
2
|
-
export declare const defaultObjectKinds: {
|
|
3
|
-
readonly Array: ArrayConstructor;
|
|
4
|
-
readonly Date: DateConstructor;
|
|
5
|
-
readonly Error: ErrorConstructor;
|
|
6
|
-
readonly Function: FunctionConstructor;
|
|
7
|
-
readonly Map: MapConstructor;
|
|
8
|
-
readonly RegExp: RegExpConstructor;
|
|
9
|
-
readonly Set: SetConstructor;
|
|
10
|
-
readonly Object: ObjectConstructor;
|
|
11
|
-
readonly String: StringConstructor;
|
|
12
|
-
readonly Number: NumberConstructor;
|
|
13
|
-
readonly Boolean: BooleanConstructor;
|
|
14
|
-
readonly WeakMap: WeakMapConstructor;
|
|
15
|
-
readonly WeakSet: WeakSetConstructor;
|
|
16
|
-
readonly Promise: PromiseConstructor;
|
|
17
|
-
};
|
|
18
|
-
export type InferredObjectKinds = {
|
|
19
|
-
[kind in DefaultObjectKind]: inferObjectKind<kind>;
|
|
20
|
-
};
|
|
21
|
-
export type inferObjectKind<kind extends keyof kinds, kinds extends ObjectKindSet = DefaultObjectKindSet> = kind extends "Function" ? (...args: any[]) => unknown : kind extends "Object" ? Record<string, unknown> : instanceOf<kinds[kind]>;
|
|
22
|
-
export type BuiltinClassName = Exclude<DefaultObjectKind, "Object" | "Function" | "Array">;
|
|
23
|
-
type BuiltinClassesByName = {
|
|
24
|
-
[kind in BuiltinClassName]: instanceOf<DefaultObjectKindSet[kind]>;
|
|
25
|
-
};
|
|
26
|
-
export type BuiltinClass = BuiltinClassesByName[BuiltinClassName];
|
|
27
|
-
export type ObjectKindSet = Record<string, constructor>;
|
|
28
|
-
export type DefaultObjectKindSet = typeof defaultObjectKinds;
|
|
29
|
-
export type DefaultObjectKind = keyof DefaultObjectKindSet;
|
|
30
|
-
export type objectKindOf<data, kinds extends ObjectKindSet = DefaultObjectKindSet> = isTopType<data> extends true ? undefined | keyof kinds : data extends object ? object extends data ? keyof kinds : {
|
|
31
|
-
[kind in keyof kinds]: kinds[kind] extends constructor<data> ? kind : data extends (...args: any[]) => unknown ? "Function" : "Object";
|
|
32
|
-
}[keyof kinds] : undefined;
|
|
33
|
-
export declare const objectKindOf: <data, kinds extends ObjectKindSet = {
|
|
34
|
-
readonly Array: ArrayConstructor;
|
|
35
|
-
readonly Date: DateConstructor;
|
|
36
|
-
readonly Error: ErrorConstructor;
|
|
37
|
-
readonly Function: FunctionConstructor;
|
|
38
|
-
readonly Map: MapConstructor;
|
|
39
|
-
readonly RegExp: RegExpConstructor;
|
|
40
|
-
readonly Set: SetConstructor;
|
|
41
|
-
readonly Object: ObjectConstructor;
|
|
42
|
-
readonly String: StringConstructor;
|
|
43
|
-
readonly Number: NumberConstructor;
|
|
44
|
-
readonly Boolean: BooleanConstructor;
|
|
45
|
-
readonly WeakMap: WeakMapConstructor;
|
|
46
|
-
readonly WeakSet: WeakSetConstructor;
|
|
47
|
-
readonly Promise: PromiseConstructor;
|
|
48
|
-
}>(data: data, kinds?: kinds | undefined) => objectKindOf<data, kinds> | undefined;
|
|
49
|
-
export declare const hasObjectKind: <kind extends keyof kinds, kinds extends ObjectKindSet = {
|
|
50
|
-
readonly Array: ArrayConstructor;
|
|
51
|
-
readonly Date: DateConstructor;
|
|
52
|
-
readonly Error: ErrorConstructor;
|
|
53
|
-
readonly Function: FunctionConstructor;
|
|
54
|
-
readonly Map: MapConstructor;
|
|
55
|
-
readonly RegExp: RegExpConstructor;
|
|
56
|
-
readonly Set: SetConstructor;
|
|
57
|
-
readonly Object: ObjectConstructor;
|
|
58
|
-
readonly String: StringConstructor;
|
|
59
|
-
readonly Number: NumberConstructor;
|
|
60
|
-
readonly Boolean: BooleanConstructor;
|
|
61
|
-
readonly WeakMap: WeakMapConstructor;
|
|
62
|
-
readonly WeakSet: WeakSetConstructor;
|
|
63
|
-
readonly Promise: PromiseConstructor;
|
|
64
|
-
}>(data: unknown, kind: kind, kinds?: kinds | undefined) => data is inferObjectKind<kind, kinds>;
|
|
65
|
-
export declare const isArray: <data>(data: data) => data is Extract<data, readonly unknown[]>;
|
|
66
|
-
/** Each defaultObjectKind's completion for the phrase "Must be _____" */
|
|
67
|
-
export declare const objectKindDescriptions: {
|
|
68
|
-
readonly Object: "an object";
|
|
69
|
-
readonly Array: "an array";
|
|
70
|
-
readonly Function: "a function";
|
|
71
|
-
readonly Date: "a Date";
|
|
72
|
-
readonly RegExp: "a RegExp";
|
|
73
|
-
readonly Error: "an Error";
|
|
74
|
-
readonly Map: "a Map";
|
|
75
|
-
readonly Set: "a Set";
|
|
76
|
-
readonly String: "a String object";
|
|
77
|
-
readonly Number: "a Number object";
|
|
78
|
-
readonly Boolean: "a Boolean object";
|
|
79
|
-
readonly Promise: "a Promise";
|
|
80
|
-
readonly WeakMap: "a WeakMap";
|
|
81
|
-
readonly WeakSet: "a WeakSet";
|
|
82
|
-
};
|
|
83
|
-
export declare const getExactConstructorObjectKind: (constructor: unknown) => DefaultObjectKind | undefined;
|
|
84
|
-
export {};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { arraySubclassToReadonly } from "./generics.js";
|
|
2
|
-
export declare class Path extends Array<string> {
|
|
3
|
-
static fromString(s: string, delimiter?: string): Path;
|
|
4
|
-
toString(delimiter?: string): string;
|
|
5
|
-
}
|
|
6
|
-
export type ReadonlyPath = arraySubclassToReadonly<Path>;
|
|
7
|
-
export type pathToString<segments extends string[], delimiter extends string = "/"> = segments extends [] ? "/" : join<segments, delimiter>;
|
|
8
|
-
export type join<segments extends string[], delimiter extends string = "/", result extends string = ""> = segments extends [infer head extends string, ...infer tail extends string[]] ? join<tail, delimiter, result extends "" ? head : `${result}${delimiter}${head}`> : result;
|
|
9
|
-
export declare const getPath: (root: unknown, path: string[]) => unknown;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import type { inferDomain, Primitive } from "./domains.js";
|
|
2
|
-
import type { isTopType, List } from "./generics.js";
|
|
3
|
-
import type { BigintLiteral, NumberLiteral } from "./numericLiterals.js";
|
|
4
|
-
export type SerializationOptions = {
|
|
5
|
-
onCycle?: (value: object) => string;
|
|
6
|
-
onSymbol?: (value: symbol) => string;
|
|
7
|
-
onFunction?: (value: Function) => string;
|
|
8
|
-
};
|
|
9
|
-
export declare const snapshot: <t>(data: t, opts?: SerializationOptions) => snapshot<t, []>;
|
|
10
|
-
export type snapshot<t, depth extends 1[] = []> = isTopType<t> extends true ? unknown : t extends Primitive ? snapshotPrimitive<t> : t extends Function ? `(function${string})` : depth["length"] extends 10 ? unknown : t extends List<infer item> ? List<snapshot<item, [...depth, 1]>> : {
|
|
11
|
-
[k in keyof t]: snapshot<t[k], [...depth, 1]>;
|
|
12
|
-
};
|
|
13
|
-
type snapshotPrimitive<t> = t extends undefined ? "(undefined)" : t extends bigint ? `${t}n` : t extends symbol ? `(symbol${string})` : t;
|
|
14
|
-
export declare const stringify: (data: unknown, indent?: number) => string;
|
|
15
|
-
type SerializedString = `'${string}'`;
|
|
16
|
-
export type SerializedPrimitives = {
|
|
17
|
-
string: SerializedString;
|
|
18
|
-
number: NumberLiteral;
|
|
19
|
-
bigint: BigintLiteral;
|
|
20
|
-
boolean: "true" | "false";
|
|
21
|
-
null: "null";
|
|
22
|
-
undefined: "undefined";
|
|
23
|
-
};
|
|
24
|
-
export type SerializedPrimitive = SerializedPrimitives[keyof SerializedPrimitives];
|
|
25
|
-
export type SerializablePrimitive = inferDomain<keyof SerializedPrimitives>;
|
|
26
|
-
export declare const serializePrimitive: <value extends string | number | bigint | boolean | null | undefined>(value: value) => serializePrimitive<value>;
|
|
27
|
-
export type serializePrimitive<value extends SerializablePrimitive> = value extends string ? `'${value}'` : value extends bigint ? `${value}n` : `${value}`;
|
|
28
|
-
export declare const deserializePrimitive: <serialized extends SerializedPrimitive>(serialized: serialized) => deserializePrimitive<serialized>;
|
|
29
|
-
export type deserializePrimitive<serialized extends SerializedPrimitive> = serialized extends keyof SerializedKeywords ? SerializedKeywords[serialized] : serialized extends SerializedString ? string : serialized extends BigintLiteral ? bigint : number;
|
|
30
|
-
declare const serializedKeywords: {
|
|
31
|
-
readonly true: true;
|
|
32
|
-
readonly false: false;
|
|
33
|
-
readonly undefined: undefined;
|
|
34
|
-
readonly null: null;
|
|
35
|
-
};
|
|
36
|
-
type SerializedKeywords = typeof serializedKeywords;
|
|
37
|
-
export {};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { conform } from "./generics.js";
|
|
2
|
-
import type { join } from "./paths.js";
|
|
3
|
-
export type stringifyUnion<t extends string> = join<unionToTuple<t>, ", ">;
|
|
4
|
-
export type unionToTuple<t> = unionToTupleRecurse<t, []> extends infer result ? conform<result, t[]> : never;
|
|
5
|
-
type unionToTupleRecurse<t, result extends unknown[]> = getLastBranch<t> extends infer current ? {
|
|
6
|
-
0: unionToTupleRecurse<Exclude<t, current>, [current, ...result]>;
|
|
7
|
-
1: result;
|
|
8
|
-
}[[t] extends [never] ? 1 : 0] : never;
|
|
9
|
-
type getLastBranch<t> = intersectUnion<t extends unknown ? (x: t) => void : never> extends (x: infer branch) => void ? branch : never;
|
|
10
|
-
type intersectUnion<t> = (t extends unknown ? (k: t) => void : never) extends (k: infer intersection) => void ? intersection : never;
|
|
11
|
-
export {};
|