arktype 0.1.3 → 0.2.0

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 (74) hide show
  1. package/README.md +1 -1
  2. package/dist/api.cjs +4 -3
  3. package/dist/api.d.ts +3 -2
  4. package/dist/api.mjs +2 -1
  5. package/dist/cjs/nodes/node.js +20 -2
  6. package/dist/cjs/nodes/predicate.js +2 -0
  7. package/dist/cjs/nodes/rules/regex.js +4 -42
  8. package/dist/cjs/nodes/rules/rules.js +16 -12
  9. package/dist/cjs/parse/definition.js +2 -2
  10. package/dist/cjs/parse/string/ast.js +1 -1
  11. package/dist/cjs/parse/tuple/keyof.js +6 -7
  12. package/dist/cjs/parse/tuple/morph.js +7 -6
  13. package/dist/cjs/scopes/cache.js +39 -0
  14. package/dist/cjs/scopes/jsObjects.js +133 -0
  15. package/dist/cjs/scopes/scope.js +244 -0
  16. package/dist/cjs/scopes/standard.js +44 -0
  17. package/dist/cjs/scopes/tsKeywords.js +113 -0
  18. package/dist/cjs/scopes/type.js +70 -0
  19. package/dist/cjs/scopes/validation.js +64 -0
  20. package/dist/cjs/traverse/problems.js +50 -74
  21. package/dist/cjs/traverse/traverse.js +25 -3
  22. package/dist/cjs/utils/numericLiterals.js +1 -0
  23. package/dist/mjs/nodes/node.js +20 -2
  24. package/dist/mjs/nodes/predicate.js +1 -0
  25. package/dist/mjs/nodes/rules/regex.js +3 -41
  26. package/dist/mjs/nodes/rules/rules.js +17 -13
  27. package/dist/mjs/parse/definition.js +1 -1
  28. package/dist/mjs/parse/string/ast.js +1 -1
  29. package/dist/mjs/parse/tuple/keyof.js +6 -7
  30. package/dist/mjs/parse/tuple/morph.js +7 -6
  31. package/dist/mjs/scopes/cache.js +25 -0
  32. package/dist/mjs/scopes/jsObjects.js +119 -0
  33. package/dist/mjs/{main.js → scopes/scope.js} +23 -349
  34. package/dist/mjs/scopes/standard.js +27 -0
  35. package/dist/mjs/scopes/tsKeywords.js +99 -0
  36. package/dist/mjs/scopes/type.js +56 -0
  37. package/dist/mjs/scopes/validation.js +51 -0
  38. package/dist/mjs/traverse/problems.js +49 -73
  39. package/dist/mjs/traverse/traverse.js +26 -4
  40. package/dist/mjs/utils/numericLiterals.js +1 -1
  41. package/dist/tsconfig.temp.tsbuildinfo +1 -1
  42. package/dist/types/nodes/compose.d.ts +1 -1
  43. package/dist/types/nodes/infer.d.ts +4 -4
  44. package/dist/types/nodes/node.d.ts +11 -7
  45. package/dist/types/nodes/predicate.d.ts +43 -54
  46. package/dist/types/nodes/rules/range.d.ts +1 -1
  47. package/dist/types/nodes/rules/regex.d.ts +1 -11
  48. package/dist/types/nodes/rules/rules.d.ts +2 -10
  49. package/dist/types/parse/definition.d.ts +1 -1
  50. package/dist/types/parse/record.d.ts +2 -2
  51. package/dist/types/parse/string/ast.d.ts +5 -4
  52. package/dist/types/parse/string/reduce/dynamic.d.ts +1 -1
  53. package/dist/types/parse/string/reduce/shared.d.ts +1 -1
  54. package/dist/types/parse/string/reduce/static.d.ts +1 -1
  55. package/dist/types/parse/string/shift/operand/unenclosed.d.ts +1 -1
  56. package/dist/types/parse/string/shift/operator/bounds.d.ts +1 -1
  57. package/dist/types/parse/tuple/keyof.d.ts +8 -0
  58. package/dist/types/parse/tuple/morph.d.ts +1 -1
  59. package/dist/types/parse/tuple/narrow.d.ts +1 -1
  60. package/dist/types/parse/tuple/tuple.d.ts +7 -13
  61. package/dist/types/scopes/cache.d.ts +14 -0
  62. package/dist/types/scopes/jsObjects.d.ts +36 -0
  63. package/dist/types/scopes/scope.d.ts +76 -0
  64. package/dist/types/scopes/standard.d.ts +280 -0
  65. package/dist/types/scopes/tsKeywords.d.ts +32 -0
  66. package/dist/types/scopes/type.d.ts +53 -0
  67. package/dist/types/scopes/validation.d.ts +21 -0
  68. package/dist/types/traverse/problems.d.ts +29 -32
  69. package/dist/types/traverse/traverse.d.ts +10 -8
  70. package/dist/types/utils/generics.d.ts +2 -1
  71. package/dist/types/utils/numericLiterals.d.ts +1 -0
  72. package/package.json +2 -2
  73. package/dist/cjs/main.js +0 -574
  74. package/dist/types/main.d.ts +0 -321
@@ -0,0 +1,280 @@
1
+ import type { InferredObjectKinds } from "../utils/objectKinds.js";
2
+ import type { Space } from "./scope.js";
3
+ import type { TypeParser } from "./type.js";
4
+ export declare const standardScope: import("./scope.js").Scope<[{
5
+ any: any;
6
+ bigint: bigint;
7
+ boolean: boolean;
8
+ false: false;
9
+ never: never;
10
+ null: null;
11
+ number: number;
12
+ object: object;
13
+ string: string;
14
+ symbol: symbol;
15
+ true: true;
16
+ unknown: unknown;
17
+ void: void;
18
+ undefined: undefined;
19
+ Function: (...args: any[]) => unknown;
20
+ Array: unknown[];
21
+ Date: Date;
22
+ Error: Error;
23
+ Map: Map<unknown, unknown>;
24
+ RegExp: RegExp;
25
+ Set: Set<unknown>;
26
+ Object: {
27
+ [x: string]: unknown;
28
+ };
29
+ String: String;
30
+ Number: Number;
31
+ Boolean: Boolean;
32
+ WeakMap: WeakMap<object, unknown>;
33
+ WeakSet: WeakSet<object>;
34
+ Promise: Promise<unknown>;
35
+ alpha: string;
36
+ alphanumeric: string;
37
+ lowercase: string;
38
+ uppercase: string;
39
+ creditCard: string;
40
+ email: string;
41
+ uuid: string;
42
+ integer: number;
43
+ }, {}, false]>;
44
+ export declare const standard: Space<{
45
+ any: any;
46
+ bigint: bigint;
47
+ boolean: boolean;
48
+ false: false;
49
+ never: never;
50
+ null: null;
51
+ number: number;
52
+ object: object;
53
+ string: string;
54
+ symbol: symbol;
55
+ true: true;
56
+ unknown: unknown;
57
+ void: void;
58
+ undefined: undefined;
59
+ Function: (...args: any[]) => unknown;
60
+ Array: unknown[];
61
+ Date: Date;
62
+ Error: Error;
63
+ Map: Map<unknown, unknown>;
64
+ RegExp: RegExp;
65
+ Set: Set<unknown>;
66
+ Object: {
67
+ [x: string]: unknown;
68
+ };
69
+ String: String;
70
+ Number: Number;
71
+ Boolean: Boolean;
72
+ WeakMap: WeakMap<object, unknown>;
73
+ WeakSet: WeakSet<object>;
74
+ Promise: Promise<unknown>;
75
+ alpha: string;
76
+ alphanumeric: string;
77
+ lowercase: string;
78
+ uppercase: string;
79
+ creditCard: string;
80
+ email: string;
81
+ uuid: string;
82
+ integer: number;
83
+ }>;
84
+ export declare const scopes: {
85
+ tsKeywords: import("./scope.js").Scope<[{
86
+ any: any;
87
+ bigint: bigint;
88
+ boolean: boolean;
89
+ false: false;
90
+ never: never;
91
+ null: null;
92
+ number: number;
93
+ object: object;
94
+ string: string;
95
+ symbol: symbol;
96
+ true: true;
97
+ unknown: unknown;
98
+ void: void;
99
+ undefined: undefined;
100
+ }, {}, false]>;
101
+ jsObjects: import("./scope.js").Scope<[{
102
+ Function: (...args: any[]) => unknown;
103
+ Array: unknown[];
104
+ Date: Date;
105
+ Error: Error;
106
+ Map: Map<unknown, unknown>;
107
+ RegExp: RegExp;
108
+ Set: Set<unknown>;
109
+ Object: {
110
+ [x: string]: unknown;
111
+ };
112
+ String: String;
113
+ Number: Number;
114
+ Boolean: Boolean;
115
+ WeakMap: WeakMap<object, unknown>;
116
+ WeakSet: WeakSet<object>;
117
+ Promise: Promise<unknown>;
118
+ }, {}, false]>;
119
+ validation: import("./scope.js").Scope<[{
120
+ alpha: string;
121
+ alphanumeric: string;
122
+ lowercase: string;
123
+ uppercase: string;
124
+ creditCard: string;
125
+ email: string;
126
+ uuid: string;
127
+ integer: number;
128
+ }, {}, false]>;
129
+ standard: import("./scope.js").Scope<[{
130
+ any: any;
131
+ bigint: bigint;
132
+ boolean: boolean;
133
+ false: false;
134
+ never: never;
135
+ null: null;
136
+ number: number;
137
+ object: object;
138
+ string: string;
139
+ symbol: symbol;
140
+ true: true;
141
+ unknown: unknown;
142
+ void: void;
143
+ undefined: undefined;
144
+ Function: (...args: any[]) => unknown;
145
+ Array: unknown[];
146
+ Date: Date;
147
+ Error: Error;
148
+ Map: Map<unknown, unknown>;
149
+ RegExp: RegExp;
150
+ Set: Set<unknown>;
151
+ Object: {
152
+ [x: string]: unknown;
153
+ };
154
+ String: String;
155
+ Number: Number;
156
+ Boolean: Boolean;
157
+ WeakMap: WeakMap<object, unknown>;
158
+ WeakSet: WeakSet<object>;
159
+ Promise: Promise<unknown>;
160
+ alpha: string;
161
+ alphanumeric: string;
162
+ lowercase: string;
163
+ uppercase: string;
164
+ creditCard: string;
165
+ email: string;
166
+ uuid: string;
167
+ integer: number;
168
+ }, {}, false]>;
169
+ };
170
+ export declare const spaces: {
171
+ tsKeywords: Space<{
172
+ any: any;
173
+ bigint: bigint;
174
+ boolean: boolean;
175
+ false: false;
176
+ never: never;
177
+ null: null;
178
+ number: number;
179
+ object: object;
180
+ string: string;
181
+ symbol: symbol;
182
+ true: true;
183
+ unknown: unknown;
184
+ void: void;
185
+ undefined: undefined;
186
+ }>;
187
+ jsObjects: Space<{
188
+ Function: (...args: any[]) => unknown;
189
+ Array: unknown[];
190
+ Date: Date;
191
+ Error: Error;
192
+ Map: Map<unknown, unknown>;
193
+ RegExp: RegExp;
194
+ Set: Set<unknown>;
195
+ Object: {
196
+ [x: string]: unknown;
197
+ };
198
+ String: String;
199
+ Number: Number;
200
+ Boolean: Boolean;
201
+ WeakMap: WeakMap<object, unknown>;
202
+ WeakSet: WeakSet<object>;
203
+ Promise: Promise<unknown>;
204
+ }>;
205
+ validation: Space<{
206
+ alpha: string;
207
+ alphanumeric: string;
208
+ lowercase: string;
209
+ uppercase: string;
210
+ creditCard: string;
211
+ email: string;
212
+ uuid: string;
213
+ integer: number;
214
+ }>;
215
+ standard: Space<{
216
+ any: any;
217
+ bigint: bigint;
218
+ boolean: boolean;
219
+ false: false;
220
+ never: never;
221
+ null: null;
222
+ number: number;
223
+ object: object;
224
+ string: string;
225
+ symbol: symbol;
226
+ true: true;
227
+ unknown: unknown;
228
+ void: void;
229
+ undefined: undefined;
230
+ Function: (...args: any[]) => unknown;
231
+ Array: unknown[];
232
+ Date: Date;
233
+ Error: Error;
234
+ Map: Map<unknown, unknown>;
235
+ RegExp: RegExp;
236
+ Set: Set<unknown>;
237
+ Object: {
238
+ [x: string]: unknown;
239
+ };
240
+ String: String;
241
+ Number: Number;
242
+ Boolean: Boolean;
243
+ WeakMap: WeakMap<object, unknown>;
244
+ WeakSet: WeakSet<object>;
245
+ Promise: Promise<unknown>;
246
+ alpha: string;
247
+ alphanumeric: string;
248
+ lowercase: string;
249
+ uppercase: string;
250
+ creditCard: string;
251
+ email: string;
252
+ uuid: string;
253
+ integer: number;
254
+ }>;
255
+ };
256
+ export type PrecompiledDefaults = {
257
+ any: any;
258
+ bigint: bigint;
259
+ boolean: boolean;
260
+ false: false;
261
+ never: never;
262
+ null: null;
263
+ number: number;
264
+ object: object;
265
+ string: string;
266
+ symbol: symbol;
267
+ true: true;
268
+ unknown: unknown;
269
+ void: void;
270
+ undefined: undefined;
271
+ integer: number;
272
+ alpha: string;
273
+ alphanumeric: string;
274
+ lowercase: string;
275
+ uppercase: string;
276
+ creditCard: string;
277
+ email: string;
278
+ uuid: string;
279
+ } & InferredObjectKinds;
280
+ export declare const type: TypeParser<PrecompiledDefaults>;
@@ -0,0 +1,32 @@
1
+ export declare const tsKeywordsScope: import("./scope.js").Scope<[{
2
+ any: any;
3
+ bigint: bigint;
4
+ boolean: boolean;
5
+ false: false;
6
+ never: never;
7
+ null: null;
8
+ number: number;
9
+ object: object;
10
+ string: string;
11
+ symbol: symbol;
12
+ true: true;
13
+ unknown: unknown;
14
+ void: void;
15
+ undefined: undefined;
16
+ }, {}, false]>;
17
+ export declare const tsKeywords: import("./scope.js").Space<{
18
+ any: any;
19
+ bigint: bigint;
20
+ boolean: boolean;
21
+ false: false;
22
+ never: never;
23
+ null: null;
24
+ number: number;
25
+ object: object;
26
+ string: string;
27
+ symbol: symbol;
28
+ true: true;
29
+ unknown: unknown;
30
+ void: void;
31
+ undefined: undefined;
32
+ }>;
@@ -0,0 +1,53 @@
1
+ import type { TraversalNode, TypeNode } from "../nodes/node.js";
2
+ import type { as, inferDefinition, validateDefinition } from "../parse/definition.js";
3
+ import type { ParsedMorph } from "../parse/tuple/morph.js";
4
+ import type { Problems, ProblemsConfig } from "../traverse/problems.js";
5
+ import type { defer, evaluateObject } from "../utils/generics.js";
6
+ import type { BuiltinClass } from "../utils/objectKinds.js";
7
+ import type { Scope } from "./scope.js";
8
+ export type TypeParser<$> = {
9
+ <def>(def: validateDefinition<def, $>): parseType<def, $>;
10
+ <def>(def: validateDefinition<def, $>, opts: TypeOptions): parseType<def, $>;
11
+ };
12
+ export type parseType<def, $> = def extends validateDefinition<def, $> ? Type<inferDefinition<def, $>> : never;
13
+ type TypeRoot<t = unknown> = {
14
+ [as]: t;
15
+ infer: asOut<t>;
16
+ node: TypeNode;
17
+ flat: TraversalNode;
18
+ meta: TypeMeta;
19
+ };
20
+ export type TypeOptions = evaluateObject<{
21
+ name?: string;
22
+ } & ProblemsConfig>;
23
+ export type TypeConfig = ProblemsConfig;
24
+ type TypeMeta = {
25
+ name: string;
26
+ id: QualifiedTypeName;
27
+ definition: unknown;
28
+ scope: Scope;
29
+ config: TypeConfig | undefined;
30
+ includesMorph: boolean;
31
+ };
32
+ export declare const initializeType: (definition: unknown, opts: TypeOptions | undefined, scope: Scope) => Type<unknown>;
33
+ export declare const isType: (value: unknown) => value is Type<unknown>;
34
+ export type CheckResult<t> = ValidCheckResult<t> | InvalidCheckResult;
35
+ type ValidCheckResult<t> = {
36
+ data: asIn<t>;
37
+ out: asOut<t>;
38
+ problems?: never;
39
+ };
40
+ type InvalidCheckResult = {
41
+ data: unknown;
42
+ problems: Problems;
43
+ out?: never;
44
+ };
45
+ type Checker<t> = (data: unknown) => CheckResult<t>;
46
+ export type Type<t = unknown> = defer<Checker<t> & TypeRoot<t>>;
47
+ export type QualifiedTypeName = `${string}.${string}`;
48
+ export type asIn<t> = asIo<t, "in">;
49
+ export type asOut<t> = asIo<t, "out">;
50
+ type asIo<t, io extends "in" | "out"> = t extends ParsedMorph<infer i, infer o> ? io extends "in" ? i : o : t extends object ? t extends Function | BuiltinClass ? t : {
51
+ [k in keyof t]: asIo<t[k], io>;
52
+ } : t;
53
+ export {};
@@ -0,0 +1,21 @@
1
+ export declare const isLuhnValid: (creditCardInput: string) => boolean;
2
+ export declare const validationScope: import("./scope.js").Scope<[{
3
+ alpha: string;
4
+ alphanumeric: string;
5
+ lowercase: string;
6
+ uppercase: string;
7
+ creditCard: string;
8
+ email: string;
9
+ uuid: string;
10
+ integer: number;
11
+ }, {}, false]>;
12
+ export declare const validation: import("./scope.js").Space<{
13
+ alpha: string;
14
+ alphanumeric: string;
15
+ lowercase: string;
16
+ uppercase: string;
17
+ creditCard: string;
18
+ email: string;
19
+ uuid: string;
20
+ integer: number;
21
+ }>;
@@ -10,24 +10,24 @@ export declare class ArkTypeError extends TypeError {
10
10
  cause: Problems;
11
11
  constructor(problems: Problems);
12
12
  }
13
- export declare class Problem {
14
- code: ProblemCode;
13
+ export declare class Problem<code extends ProblemCode = any> {
14
+ code: code;
15
15
  path: Path;
16
- private data;
17
- private rule;
18
- private writers;
19
- constructor(code: ProblemCode, path: Path, data: ProblemDataInput, rule: ProblemRuleInput, writers: ProblemWriterConfig<any>);
16
+ protected data: ProblemData<code>;
17
+ protected source: ProblemSource<code>;
18
+ protected writers: ProblemWriters<code>;
19
+ parts?: Problem[];
20
+ constructor(code: code, path: Path, data: ProblemData<code>, source: ProblemSource<code>, writers: ProblemWriters<code>);
20
21
  toString(): string;
21
22
  get message(): string;
22
23
  get reason(): string;
23
24
  get mustBe(): string;
24
- get was(): string;
25
25
  }
26
26
  declare class ProblemArray extends Array<Problem> {
27
27
  private state;
28
28
  byPath: Record<string, Problem>;
29
29
  constructor(state: TraversalState);
30
- add<code extends ProblemCode>(code: code, data: ProblemDataInput<code>, input: ProblemRuleInput<code>): void;
30
+ add<code extends ProblemCode>(code: code, data: ProblemData<code>, source: ProblemSource<code>): void;
31
31
  get summary(): string;
32
32
  toString(): string;
33
33
  throw(): never;
@@ -38,7 +38,7 @@ export declare const Problems: new (state: TraversalState) => readonly Problem[]
38
38
  export type Problems = instanceOf<typeof Problems>;
39
39
  export declare const describeDomains: (domains: Domain[]) => string;
40
40
  export declare const describeBranches: (descriptions: string[]) => string;
41
- type ProblemRuleInputs = {
41
+ type ProblemSources = {
42
42
  divisor: number;
43
43
  class: constructor;
44
44
  domain: Domain;
@@ -46,29 +46,21 @@ type ProblemRuleInputs = {
46
46
  objectKind: DefaultObjectKind;
47
47
  missing: undefined;
48
48
  bound: FlatBound;
49
- regex: RegExp;
49
+ regex: string;
50
50
  value: unknown;
51
51
  valueBranches: unknown[];
52
- multi: string[];
52
+ multi: Problem[];
53
53
  branches: Problem[];
54
54
  };
55
- export type ProblemCode = evaluate<keyof ProblemRuleInputs>;
56
- export type ProblemRuleInput<code extends ProblemCode = ProblemCode> = ProblemRuleInputs[code];
57
- type ProblemDataInputs = {
55
+ export type ProblemCode = evaluate<keyof ProblemSources>;
56
+ export type ProblemSource<code extends ProblemCode = ProblemCode> = ProblemSources[code];
57
+ type ProblemDataByCode = {
58
58
  [code in ProblemCode]: code extends keyof ConstrainedRuleTraversalData ? ConstrainedRuleTraversalData[code] : unknown;
59
59
  };
60
- export type ProblemDataInput<code extends ProblemCode = ProblemCode> = ProblemDataInputs[code];
61
- export type ProblemOptions<code extends ProblemCode> = {
62
- mustBe?: RuleWriter<code>;
63
- was?: DataWriter<code>;
64
- reason?: ReasonWriter;
65
- message?: MessageWriter;
66
- };
67
- export type ProblemWriterConfig<code extends ProblemCode> = Required<ProblemOptions<code>>;
68
- export type RuleWriter<code extends ProblemCode> = (context: ProblemRuleInputs[code]) => string;
69
- export type DataWriter<code extends ProblemCode> = (data: DataWrapper<code extends keyof ConstrainedRuleTraversalData ? ConstrainedRuleTraversalData[code] : unknown>) => string;
70
- export type ReasonWriter = (rule: string, data: string) => string;
71
- export type MessageWriter = (reason: string, path: Path) => string;
60
+ export type ProblemData<code extends ProblemCode = ProblemCode> = ProblemDataByCode[code];
61
+ export type MustBeWriter<code extends ProblemCode> = (source: ProblemSources[code]) => string;
62
+ export type ReasonWriter<code extends ProblemCode = ProblemCode> = (mustBe: string, data: DataWrapper<code extends keyof ConstrainedRuleTraversalData ? ConstrainedRuleTraversalData[code] : unknown>) => string;
63
+ export type ContextWriter = (reason: string, path: Path) => string;
72
64
  export declare class DataWrapper<value = unknown> {
73
65
  value: value;
74
66
  constructor(value: value);
@@ -94,14 +86,19 @@ export declare class DataWrapper<value = unknown> {
94
86
  get units(): "" | "characters" | "items";
95
87
  get className(): any;
96
88
  }
97
- export declare const defaultProblemWriters: ProblemsConfig;
98
- export type ProblemsOptions = evaluateObject<{
99
- all?: ProblemOptions<ProblemCode>;
89
+ export declare const defaultProblemWriters: DefaultProblemsWriters;
90
+ export type ProblemOptions<code extends ProblemCode = ProblemCode> = {
91
+ mustBe?: MustBeWriter<code>;
92
+ writeReason?: ReasonWriter<code>;
93
+ addContext?: ContextWriter;
94
+ };
95
+ export type ProblemsConfig = evaluateObject<{
96
+ defaults?: ProblemOptions<ProblemCode>;
100
97
  } & {
101
98
  [code in ProblemCode]?: ProblemOptions<code>;
102
99
  }>;
103
- export type ProblemsConfig = {
104
- [code in ProblemCode]: ProblemWriterConfig<code>;
100
+ export type DefaultProblemsWriters = {
101
+ [code in ProblemCode]: ProblemWriters<code>;
105
102
  };
106
- export declare const compileProblemOptions: (opts: ProblemsOptions | undefined, base?: ProblemsConfig) => ProblemsConfig;
103
+ export type ProblemWriters<code extends ProblemCode> = Required<ProblemOptions<code>>;
107
104
  export {};
@@ -1,15 +1,15 @@
1
- import type { Type } from "../main.js";
2
1
  import type { TraversalEntry, TraversalKey, TraversalNode } from "../nodes/node.js";
2
+ import type { Type, TypeConfig } from "../scopes/type.js";
3
3
  import type { Dict, extend, List } from "../utils/generics.js";
4
4
  import { Path } from "../utils/paths.js";
5
5
  import type { SizedData } from "../utils/size.js";
6
- import type { Problem } from "./problems.js";
6
+ import type { Problem, ProblemCode, ProblemWriters } from "./problems.js";
7
7
  export declare class TraversalState {
8
8
  #private;
9
9
  type: Type;
10
10
  path: Path;
11
- problems: readonly Problem[] & {
12
- byPath: Record<string, Problem>;
11
+ problems: readonly Problem<any>[] & {
12
+ byPath: Record<string, Problem<any>>;
13
13
  add: <code extends keyof {
14
14
  divisor: number;
15
15
  class: import("../utils/generics.js").constructor;
@@ -36,17 +36,19 @@ export declare class TraversalState {
36
36
  objectKind: "Array" | "Date" | "Error" | "Function" | "Map" | "RegExp" | "Set" | "Object" | "String" | "Number" | "Boolean" | "WeakMap" | "WeakSet" | "Promise";
37
37
  missing: undefined;
38
38
  bound: import("../nodes/rules/range.js").FlatBound;
39
- regex: RegExp;
39
+ regex: string;
40
40
  value: unknown;
41
41
  valueBranches: unknown[];
42
- multi: string[];
43
- branches: Problem[];
44
- }>(code: code, data: import("./problems.js").ProblemDataInput<code>, input: import("./problems.js").ProblemRuleInput<code>) => void;
42
+ multi: Problem<any>[];
43
+ branches: Problem<any>[];
44
+ }>(code: code, data: import("./problems.js").ProblemData<code>, source: import("./problems.js").ProblemSource<code>) => void;
45
45
  summary: string;
46
46
  throw: () => never;
47
47
  };
48
+ configs: TypeConfig[];
48
49
  failFast: boolean;
49
50
  constructor(type: Type);
51
+ getConfigForProblemCode<code extends ProblemCode>(code: code): ProblemWriters<code>;
50
52
  traverseResolution(data: unknown, name: string): void;
51
53
  traverseBranches(data: unknown, branches: TraversalEntry[][]): void;
52
54
  }
@@ -39,7 +39,8 @@ export type entryOf<o> = {
39
39
  export type entriesOf<o extends object> = entryOf<o>[];
40
40
  export declare const entriesOf: <o extends object>(o: o) => entriesOf<o>;
41
41
  /** Mimics the result of Object.keys(...) */
42
- export type keyOf<o> = o extends object ? o extends readonly unknown[] ? any[] extends o ? `${number}` : keyof o & `${number}` : keyof o extends number ? `${keyof o}` : Exclude<keyof o, symbol> : never;
42
+ export type keyOf<o> = [o] extends [object] ? o extends readonly unknown[] ? any[] extends o ? `${number}` : keyof o & `${number}` : keyof o extends number ? `${keyof o}` : Exclude<keyof o, symbol> : never;
43
+ export type nonArrayKeyOf<o> = keyOf<o> extends infer result ? result extends `${number}` ? `${number}` extends result ? never : result : result : never;
43
44
  export declare const keysOf: <o extends object>(o: o) => keyOf<o>[];
44
45
  export type stringKeyOf<o> = keyof o & string;
45
46
  export declare const hasKey: <o, k extends string>(o: o, k: k) => o is o & { [_ in k]: {}; };
@@ -7,6 +7,7 @@ export type IntegerLiteral<Value extends bigint = bigint> = `${Value}`;
7
7
  * 2. The value may not be "-0"
8
8
  */
9
9
  export declare const wellFormedIntegerMatcher: RegExp;
10
+ export declare const isWellFormedInteger: (s: string) => boolean;
10
11
  type NumericLiteralKind = "number" | "bigint" | "integer";
11
12
  declare const numericLiteralDescriptions: {
12
13
  readonly number: "a number";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "arktype",
3
- "description": "Isomorphic type syntax for TS/JS",
4
- "version": "0.1.3",
3
+ "description": "Isomorphic types for TS/JS",
4
+ "version": "0.2.0",
5
5
  "author": {
6
6
  "name": "David Blass",
7
7
  "email": "david@arktype.io",