arktype 1.0.28-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.
Files changed (194) hide show
  1. package/dist/main.d.ts +1018 -0
  2. package/dist/main.js +1450 -0
  3. package/package.json +36 -108
  4. package/LICENSE +0 -7
  5. package/README.md +0 -351
  6. package/dist/cjs/main.js +0 -38
  7. package/dist/cjs/nodes/branch.js +0 -140
  8. package/dist/cjs/nodes/compose.js +0 -163
  9. package/dist/cjs/nodes/discriminate.js +0 -265
  10. package/dist/cjs/nodes/node.js +0 -139
  11. package/dist/cjs/nodes/predicate.js +0 -86
  12. package/dist/cjs/nodes/rules/class.js +0 -25
  13. package/dist/cjs/nodes/rules/collapsibleSet.js +0 -48
  14. package/dist/cjs/nodes/rules/divisor.js +0 -29
  15. package/dist/cjs/nodes/rules/props.js +0 -167
  16. package/dist/cjs/nodes/rules/range.js +0 -105
  17. package/dist/cjs/nodes/rules/regex.js +0 -26
  18. package/dist/cjs/nodes/rules/rules.js +0 -123
  19. package/dist/cjs/package.json +0 -3
  20. package/dist/cjs/parse/ast/ast.js +0 -4
  21. package/dist/cjs/parse/ast/bound.js +0 -16
  22. package/dist/cjs/parse/ast/config.js +0 -13
  23. package/dist/cjs/parse/ast/distributableFunction.js +0 -48
  24. package/dist/cjs/parse/ast/divisor.js +0 -9
  25. package/dist/cjs/parse/ast/intersection.js +0 -30
  26. package/dist/cjs/parse/ast/keyof.js +0 -111
  27. package/dist/cjs/parse/ast/morph.js +0 -58
  28. package/dist/cjs/parse/ast/narrow.js +0 -22
  29. package/dist/cjs/parse/ast/node.js +0 -4
  30. package/dist/cjs/parse/ast/tuple.js +0 -94
  31. package/dist/cjs/parse/ast/union.js +0 -9
  32. package/dist/cjs/parse/ast/utils.js +0 -4
  33. package/dist/cjs/parse/definition.js +0 -61
  34. package/dist/cjs/parse/record.js +0 -37
  35. package/dist/cjs/parse/string/reduce/dynamic.js +0 -167
  36. package/dist/cjs/parse/string/reduce/shared.js +0 -23
  37. package/dist/cjs/parse/string/reduce/static.js +0 -4
  38. package/dist/cjs/parse/string/shift/operand/enclosed.js +0 -54
  39. package/dist/cjs/parse/string/shift/operand/operand.js +0 -11
  40. package/dist/cjs/parse/string/shift/operand/unenclosed.js +0 -53
  41. package/dist/cjs/parse/string/shift/operator/bounds.js +0 -87
  42. package/dist/cjs/parse/string/shift/operator/divisor.js +0 -35
  43. package/dist/cjs/parse/string/shift/operator/operator.js +0 -26
  44. package/dist/cjs/parse/string/shift/scanner.js +0 -114
  45. package/dist/cjs/parse/string/string.js +0 -43
  46. package/dist/cjs/scopes/ark.js +0 -45
  47. package/dist/cjs/scopes/cache.js +0 -52
  48. package/dist/cjs/scopes/expressions.js +0 -29
  49. package/dist/cjs/scopes/jsObjects.js +0 -93
  50. package/dist/cjs/scopes/scope.js +0 -323
  51. package/dist/cjs/scopes/tsKeywords.js +0 -113
  52. package/dist/cjs/scopes/type.js +0 -50
  53. package/dist/cjs/scopes/validation/creditCard.js +0 -47
  54. package/dist/cjs/scopes/validation/date.js +0 -62
  55. package/dist/cjs/scopes/validation/validation.js +0 -108
  56. package/dist/cjs/traverse/problems.js +0 -281
  57. package/dist/cjs/traverse/traverse.js +0 -390
  58. package/dist/cjs/utils/chainableNoOpProxy.js +0 -23
  59. package/dist/cjs/utils/data.js +0 -53
  60. package/dist/cjs/utils/domains.js +0 -30
  61. package/dist/cjs/utils/errors.js +0 -26
  62. package/dist/cjs/utils/freeze.js +0 -15
  63. package/dist/cjs/utils/generics.js +0 -63
  64. package/dist/cjs/utils/numericLiterals.js +0 -75
  65. package/dist/cjs/utils/objectKinds.js +0 -69
  66. package/dist/cjs/utils/paths.js +0 -32
  67. package/dist/cjs/utils/serialize.js +0 -74
  68. package/dist/cjs/utils/unionToTuple.js +0 -4
  69. package/dist/mjs/main.js +0 -8
  70. package/dist/mjs/nodes/branch.js +0 -123
  71. package/dist/mjs/nodes/compose.js +0 -141
  72. package/dist/mjs/nodes/discriminate.js +0 -250
  73. package/dist/mjs/nodes/node.js +0 -117
  74. package/dist/mjs/nodes/predicate.js +0 -69
  75. package/dist/mjs/nodes/rules/class.js +0 -11
  76. package/dist/mjs/nodes/rules/collapsibleSet.js +0 -34
  77. package/dist/mjs/nodes/rules/divisor.js +0 -15
  78. package/dist/mjs/nodes/rules/props.js +0 -149
  79. package/dist/mjs/nodes/rules/range.js +0 -86
  80. package/dist/mjs/nodes/rules/regex.js +0 -11
  81. package/dist/mjs/nodes/rules/rules.js +0 -106
  82. package/dist/mjs/package.json +0 -3
  83. package/dist/mjs/parse/ast/ast.js +0 -1
  84. package/dist/mjs/parse/ast/bound.js +0 -2
  85. package/dist/mjs/parse/ast/config.js +0 -9
  86. package/dist/mjs/parse/ast/distributableFunction.js +0 -34
  87. package/dist/mjs/parse/ast/divisor.js +0 -1
  88. package/dist/mjs/parse/ast/intersection.js +0 -16
  89. package/dist/mjs/parse/ast/keyof.js +0 -103
  90. package/dist/mjs/parse/ast/morph.js +0 -44
  91. package/dist/mjs/parse/ast/narrow.js +0 -14
  92. package/dist/mjs/parse/ast/node.js +0 -1
  93. package/dist/mjs/parse/ast/tuple.js +0 -80
  94. package/dist/mjs/parse/ast/union.js +0 -1
  95. package/dist/mjs/parse/ast/utils.js +0 -1
  96. package/dist/mjs/parse/definition.js +0 -46
  97. package/dist/mjs/parse/record.js +0 -29
  98. package/dist/mjs/parse/string/reduce/dynamic.js +0 -159
  99. package/dist/mjs/parse/string/reduce/shared.js +0 -6
  100. package/dist/mjs/parse/string/reduce/static.js +0 -1
  101. package/dist/mjs/parse/string/shift/operand/enclosed.js +0 -39
  102. package/dist/mjs/parse/string/shift/operand/operand.js +0 -3
  103. package/dist/mjs/parse/string/shift/operand/unenclosed.js +0 -36
  104. package/dist/mjs/parse/string/shift/operator/bounds.js +0 -70
  105. package/dist/mjs/parse/string/shift/operator/divisor.js +0 -21
  106. package/dist/mjs/parse/string/shift/operator/operator.js +0 -13
  107. package/dist/mjs/parse/string/shift/scanner.js +0 -106
  108. package/dist/mjs/parse/string/string.js +0 -28
  109. package/dist/mjs/scopes/ark.js +0 -28
  110. package/dist/mjs/scopes/cache.js +0 -38
  111. package/dist/mjs/scopes/expressions.js +0 -89
  112. package/dist/mjs/scopes/jsObjects.js +0 -82
  113. package/dist/mjs/scopes/scope.js +0 -303
  114. package/dist/mjs/scopes/tsKeywords.js +0 -116
  115. package/dist/mjs/scopes/type.js +0 -35
  116. package/dist/mjs/scopes/validation/creditCard.js +0 -34
  117. package/dist/mjs/scopes/validation/date.js +0 -48
  118. package/dist/mjs/scopes/validation/validation.js +0 -112
  119. package/dist/mjs/traverse/problems.js +0 -260
  120. package/dist/mjs/traverse/traverse.js +0 -373
  121. package/dist/mjs/utils/chainableNoOpProxy.js +0 -15
  122. package/dist/mjs/utils/data.js +0 -38
  123. package/dist/mjs/utils/domains.js +0 -15
  124. package/dist/mjs/utils/errors.js +0 -10
  125. package/dist/mjs/utils/freeze.js +0 -7
  126. package/dist/mjs/utils/generics.js +0 -38
  127. package/dist/mjs/utils/numericLiterals.js +0 -72
  128. package/dist/mjs/utils/objectKinds.js +0 -55
  129. package/dist/mjs/utils/paths.js +0 -18
  130. package/dist/mjs/utils/serialize.js +0 -58
  131. package/dist/mjs/utils/unionToTuple.js +0 -1
  132. package/dist/tsconfig.temp.tsbuildinfo +0 -1
  133. package/dist/types/main.d.ts +0 -15
  134. package/dist/types/nodes/branch.d.ts +0 -29
  135. package/dist/types/nodes/compose.d.ts +0 -98
  136. package/dist/types/nodes/discriminate.d.ts +0 -26
  137. package/dist/types/nodes/node.d.ts +0 -69
  138. package/dist/types/nodes/predicate.d.ts +0 -18
  139. package/dist/types/nodes/rules/class.d.ts +0 -4
  140. package/dist/types/nodes/rules/collapsibleSet.d.ts +0 -4
  141. package/dist/types/nodes/rules/divisor.d.ts +0 -3
  142. package/dist/types/nodes/rules/props.d.ts +0 -43
  143. package/dist/types/nodes/rules/range.d.ts +0 -34
  144. package/dist/types/nodes/rules/regex.d.ts +0 -5
  145. package/dist/types/nodes/rules/rules.d.ts +0 -33
  146. package/dist/types/parse/ast/ast.d.ts +0 -24
  147. package/dist/types/parse/ast/bound.d.ts +0 -27
  148. package/dist/types/parse/ast/config.d.ts +0 -15
  149. package/dist/types/parse/ast/distributableFunction.d.ts +0 -18
  150. package/dist/types/parse/ast/divisor.d.ts +0 -13
  151. package/dist/types/parse/ast/intersection.d.ts +0 -31
  152. package/dist/types/parse/ast/keyof.d.ts +0 -10
  153. package/dist/types/parse/ast/morph.d.ts +0 -18
  154. package/dist/types/parse/ast/narrow.d.ts +0 -21
  155. package/dist/types/parse/ast/node.d.ts +0 -35
  156. package/dist/types/parse/ast/tuple.d.ts +0 -41
  157. package/dist/types/parse/ast/union.d.ts +0 -17
  158. package/dist/types/parse/ast/utils.d.ts +0 -7
  159. package/dist/types/parse/definition.d.ts +0 -30
  160. package/dist/types/parse/record.d.ts +0 -26
  161. package/dist/types/parse/string/reduce/dynamic.d.ts +0 -34
  162. package/dist/types/parse/string/reduce/shared.d.ts +0 -25
  163. package/dist/types/parse/string/reduce/static.d.ts +0 -130
  164. package/dist/types/parse/string/shift/operand/enclosed.d.ts +0 -28
  165. package/dist/types/parse/string/shift/operand/operand.d.ts +0 -9
  166. package/dist/types/parse/string/shift/operand/unenclosed.d.ts +0 -18
  167. package/dist/types/parse/string/shift/operator/bounds.d.ts +0 -21
  168. package/dist/types/parse/string/shift/operator/divisor.d.ts +0 -13
  169. package/dist/types/parse/string/shift/operator/operator.d.ts +0 -13
  170. package/dist/types/parse/string/shift/scanner.d.ts +0 -89
  171. package/dist/types/parse/string/string.d.ts +0 -25
  172. package/dist/types/scopes/ark.d.ts +0 -209
  173. package/dist/types/scopes/cache.d.ts +0 -14
  174. package/dist/types/scopes/expressions.d.ts +0 -136
  175. package/dist/types/scopes/jsObjects.d.ts +0 -26
  176. package/dist/types/scopes/scope.d.ts +0 -99
  177. package/dist/types/scopes/tsKeywords.d.ts +0 -50
  178. package/dist/types/scopes/type.d.ts +0 -67
  179. package/dist/types/scopes/validation/creditCard.d.ts +0 -2
  180. package/dist/types/scopes/validation/date.d.ts +0 -23
  181. package/dist/types/scopes/validation/validation.d.ts +0 -49
  182. package/dist/types/traverse/problems.d.ts +0 -88
  183. package/dist/types/traverse/traverse.d.ts +0 -55
  184. package/dist/types/utils/chainableNoOpProxy.d.ts +0 -14
  185. package/dist/types/utils/data.d.ts +0 -13
  186. package/dist/types/utils/domains.d.ts +0 -32
  187. package/dist/types/utils/errors.d.ts +0 -6
  188. package/dist/types/utils/freeze.d.ts +0 -2
  189. package/dist/types/utils/generics.d.ts +0 -125
  190. package/dist/types/utils/numericLiterals.d.ts +0 -46
  191. package/dist/types/utils/objectKinds.d.ts +0 -84
  192. package/dist/types/utils/paths.d.ts +0 -9
  193. package/dist/types/utils/serialize.d.ts +0 -37
  194. 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 {};