arktype 2.2.6 → 2.2.8

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.
@@ -111,39 +111,39 @@ export declare namespace lower {
111
111
  export declare const normalizedForms: readonly ["NFC", "NFD", "NFKC", "NFKD"];
112
112
  export type NormalizedForm = (typeof normalizedForms)[number];
113
113
  export declare const NFC: Module<{
114
- root: unknown;
115
114
  preformatted: unknown;
115
+ root: unknown;
116
116
  }>;
117
117
  export declare const NFD: Module<{
118
- root: unknown;
119
118
  preformatted: unknown;
119
+ root: unknown;
120
120
  }>;
121
121
  export declare const NFKC: Module<{
122
- root: unknown;
123
122
  preformatted: unknown;
123
+ root: unknown;
124
124
  }>;
125
125
  export declare const NFKD: Module<{
126
- root: unknown;
127
126
  preformatted: unknown;
127
+ root: unknown;
128
128
  }>;
129
129
  export declare const normalize: Module<{
130
- root: unknown;
131
130
  NFC: Submodule<{
132
- root: unknown;
133
131
  preformatted: unknown;
132
+ root: unknown;
134
133
  }>;
135
134
  NFD: Submodule<{
136
- root: unknown;
137
135
  preformatted: unknown;
136
+ root: unknown;
138
137
  }>;
139
138
  NFKC: Submodule<{
140
- root: unknown;
141
139
  preformatted: unknown;
140
+ root: unknown;
142
141
  }>;
143
142
  NFKD: Submodule<{
144
- root: unknown;
145
143
  preformatted: unknown;
144
+ root: unknown;
146
145
  }>;
146
+ root: unknown;
147
147
  }>;
148
148
  export declare namespace normalize {
149
149
  type module = Module<submodule>;
@@ -221,12 +221,12 @@ export declare namespace url {
221
221
  }
222
222
  export declare const uuid: Module<{
223
223
  root: string;
224
- v4: unknown;
225
- v6: unknown;
226
224
  v1: unknown;
227
225
  v2: unknown;
228
226
  v3: unknown;
227
+ v4: unknown;
229
228
  v5: unknown;
229
+ v6: unknown;
230
230
  v7: unknown;
231
231
  v8: unknown;
232
232
  }>;
@@ -249,10 +249,9 @@ export declare namespace uuid {
249
249
  }
250
250
  }
251
251
  export declare const string: Module<{
252
- root: unknown;
253
252
  alpha: unknown;
254
253
  alphanumeric: unknown;
255
- hex: unknown;
254
+ base58: unknown;
256
255
  base64: Submodule<{
257
256
  root: unknown;
258
257
  url: unknown;
@@ -262,43 +261,45 @@ export declare const string: Module<{
262
261
  date: Submodule<stringDate.submodule>;
263
262
  digits: unknown;
264
263
  email: unknown;
264
+ hex: unknown;
265
265
  integer: Submodule<stringInteger.submodule>;
266
266
  ip: Submodule<ip.submodule>;
267
267
  json: Submodule<stringJson.submodule>;
268
268
  lower: Submodule<lower.submodule>;
269
269
  normalize: Submodule<{
270
- root: unknown;
271
270
  NFC: Submodule<{
272
- root: unknown;
273
271
  preformatted: unknown;
272
+ root: unknown;
274
273
  }>;
275
274
  NFD: Submodule<{
276
- root: unknown;
277
275
  preformatted: unknown;
276
+ root: unknown;
278
277
  }>;
279
278
  NFKC: Submodule<{
280
- root: unknown;
281
279
  preformatted: unknown;
280
+ root: unknown;
282
281
  }>;
283
282
  NFKD: Submodule<{
284
- root: unknown;
285
283
  preformatted: unknown;
284
+ root: unknown;
286
285
  }>;
286
+ root: unknown;
287
287
  }>;
288
288
  numeric: Submodule<stringNumeric.submodule>;
289
289
  regex: unknown;
290
+ root: unknown;
290
291
  semver: unknown;
291
292
  trim: Submodule<trim.submodule>;
292
293
  upper: Submodule<upper.submodule>;
293
294
  url: Submodule<url.submodule>;
294
295
  uuid: Submodule<{
295
296
  root: string;
296
- v4: unknown;
297
- v6: unknown;
298
297
  v1: unknown;
299
298
  v2: unknown;
300
299
  v3: unknown;
300
+ v4: unknown;
301
301
  v5: unknown;
302
+ v6: unknown;
302
303
  v7: unknown;
303
304
  v8: unknown;
304
305
  }>;
@@ -311,6 +312,7 @@ export declare namespace string {
311
312
  alpha: string;
312
313
  alphanumeric: string;
313
314
  hex: string;
315
+ base58: string;
314
316
  base64: base64.submodule;
315
317
  capitalize: capitalize.submodule;
316
318
  creditCard: string;
@@ -31,6 +31,7 @@ export const stringInteger = Scope.module({
31
31
  name: "string.integer"
32
32
  });
33
33
  const hex = regexStringNode(/^[\dA-Fa-f]+$/, "hex characters only");
34
+ const base58 = regexStringNode(/^[1-9A-HJ-NP-Za-km-z]+$/, "base58-encoded");
34
35
  const base64 = Scope.module({
35
36
  root: regexStringNode(/^(?:[\d+/A-Za-z]{4})*(?:[\d+/A-Za-z]{2}==|[\d+/A-Za-z]{3}=)?$/, "base64-encoded"),
36
37
  url: regexStringNode(/^(?:[\w-]{4})*(?:[\w-]{2}(?:==|%3D%3D)?|[\w-]{3}(?:=|%3D)?)?$/, "base64url-encoded")
@@ -145,7 +146,9 @@ const epoch = Scope.module({
145
146
  root: epochRoot,
146
147
  parse: rootSchema({
147
148
  in: epochRoot,
148
- morphs: (s) => new Date(s),
149
+ // parse as a number so the string is treated as milliseconds
150
+ // rather than passed to the Date string parser
151
+ morphs: (s) => new Date(Number.parseInt(s)),
149
152
  declaredOut: intrinsic.Date
150
153
  })
151
154
  }, {
@@ -423,15 +426,15 @@ export const uuid = Scope.module({
423
426
  ],
424
427
  "#nil": "'00000000-0000-0000-0000-000000000000'",
425
428
  "#max": "'ffffffff-ffff-ffff-ffff-ffffffffffff'",
426
- "#versioned": /^[\da-f]{8}-[\da-f]{4}-[1-8][\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,
427
- v1: regexStringNode(/^[\da-f]{8}-[\da-f]{4}-1[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i, "a UUIDv1"),
428
- v2: regexStringNode(/^[\da-f]{8}-[\da-f]{4}-2[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i, "a UUIDv2"),
429
- v3: regexStringNode(/^[\da-f]{8}-[\da-f]{4}-3[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i, "a UUIDv3"),
430
- v4: regexStringNode(/^[\da-f]{8}-[\da-f]{4}-4[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i, "a UUIDv4"),
431
- v5: regexStringNode(/^[\da-f]{8}-[\da-f]{4}-5[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i, "a UUIDv5"),
432
- v6: regexStringNode(/^[\da-f]{8}-[\da-f]{4}-6[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i, "a UUIDv6"),
433
- v7: regexStringNode(/^[\da-f]{8}-[\da-f]{4}-7[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i, "a UUIDv7"),
434
- v8: regexStringNode(/^[\da-f]{8}-[\da-f]{4}-8[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i, "a UUIDv8")
429
+ "#versioned": /^[\dA-Fa-f]{8}-[\dA-Fa-f]{4}-[1-8][\dA-Fa-f]{3}-[89ABab][\dA-Fa-f]{3}-[\dA-Fa-f]{12}$/,
430
+ v1: regexStringNode(/^[\dA-Fa-f]{8}-[\dA-Fa-f]{4}-1[\dA-Fa-f]{3}-[89ABab][\dA-Fa-f]{3}-[\dA-Fa-f]{12}$/, "a UUIDv1"),
431
+ v2: regexStringNode(/^[\dA-Fa-f]{8}-[\dA-Fa-f]{4}-2[\dA-Fa-f]{3}-[89ABab][\dA-Fa-f]{3}-[\dA-Fa-f]{12}$/, "a UUIDv2"),
432
+ v3: regexStringNode(/^[\dA-Fa-f]{8}-[\dA-Fa-f]{4}-3[\dA-Fa-f]{3}-[89ABab][\dA-Fa-f]{3}-[\dA-Fa-f]{12}$/, "a UUIDv3"),
433
+ v4: regexStringNode(/^[\dA-Fa-f]{8}-[\dA-Fa-f]{4}-4[\dA-Fa-f]{3}-[89ABab][\dA-Fa-f]{3}-[\dA-Fa-f]{12}$/, "a UUIDv4"),
434
+ v5: regexStringNode(/^[\dA-Fa-f]{8}-[\dA-Fa-f]{4}-5[\dA-Fa-f]{3}-[89ABab][\dA-Fa-f]{3}-[\dA-Fa-f]{12}$/, "a UUIDv5"),
435
+ v6: regexStringNode(/^[\dA-Fa-f]{8}-[\dA-Fa-f]{4}-6[\dA-Fa-f]{3}-[89ABab][\dA-Fa-f]{3}-[\dA-Fa-f]{12}$/, "a UUIDv6"),
436
+ v7: regexStringNode(/^[\dA-Fa-f]{8}-[\dA-Fa-f]{4}-7[\dA-Fa-f]{3}-[89ABab][\dA-Fa-f]{3}-[\dA-Fa-f]{12}$/, "a UUIDv7"),
437
+ v8: regexStringNode(/^[\dA-Fa-f]{8}-[\dA-Fa-f]{4}-8[\dA-Fa-f]{3}-[89ABab][\dA-Fa-f]{3}-[\dA-Fa-f]{12}$/, "a UUIDv8")
435
438
  }, {
436
439
  name: "string.uuid"
437
440
  });
@@ -440,6 +443,7 @@ export const string = Scope.module({
440
443
  alpha: regexStringNode(/^[A-Za-z]*$/, "only letters"),
441
444
  alphanumeric: regexStringNode(/^[\dA-Za-z]*$/, "only letters and digits 0-9"),
442
445
  hex,
446
+ base58,
443
447
  base64,
444
448
  capitalize,
445
449
  creditCard,
@@ -21,8 +21,8 @@ export declare namespace arkTsKeywords {
21
21
  };
22
22
  }
23
23
  export declare const unknown: Module<{
24
- root: unknown;
25
24
  any: unknown;
25
+ root: unknown;
26
26
  }>;
27
27
  export declare namespace unknown {
28
28
  type submodule = Submodule<$>;
@@ -43,11 +43,11 @@ export declare namespace json {
43
43
  };
44
44
  }
45
45
  export declare const object: Module<{
46
- root: unknown;
47
46
  json: Submodule<{
48
47
  root: unknown;
49
48
  stringify: unknown;
50
49
  }>;
50
+ root: unknown;
51
51
  }>;
52
52
  export declare namespace object {
53
53
  type submodule = Submodule<$>;
@@ -22,9 +22,9 @@ export declare const enclosingChar: {
22
22
  };
23
23
  export declare const enclosingLiteralTokens: {
24
24
  readonly "d'": "'";
25
- readonly 'd"': "\"";
25
+ readonly 'd"': '"';
26
26
  readonly "'": "'";
27
- readonly '"': "\"";
27
+ readonly '"': '"';
28
28
  };
29
29
  export type EnclosingLiteralTokens = typeof enclosingLiteralTokens;
30
30
  export type EnclosingLiteralStartToken = keyof EnclosingLiteralTokens;
@@ -35,12 +35,12 @@ export declare const enclosingRegexTokens: {
35
35
  export type EnclosingRegexTokens = typeof enclosingRegexTokens;
36
36
  export type EnclosingRegexToken = keyof EnclosingRegexTokens;
37
37
  export declare const enclosingTokens: {
38
- readonly "/": "/";
39
- readonly "x/": "/";
40
38
  readonly "d'": "'";
41
- readonly 'd"': "\"";
39
+ readonly 'd"': '"';
42
40
  readonly "'": "'";
43
- readonly '"': "\"";
41
+ readonly '"': '"';
42
+ readonly "/": "/";
43
+ readonly "x/": "/";
44
44
  };
45
45
  export type EnclosingTokens = typeof enclosingTokens;
46
46
  export type EnclosingStartToken = keyof EnclosingTokens;
@@ -8,7 +8,7 @@ export const parseOperator = (s) => {
8
8
  return (lookahead === "" ? s.finalize("")
9
9
  : lookahead === "[" ?
10
10
  s.scanner.shift() === "]" ?
11
- s.setRoot(s.root.array())
11
+ s.setRoot(s.root.rawArray())
12
12
  : s.error(incompleteArrayTokenMessage)
13
13
  : lookahead === "|" ?
14
14
  s.scanner.lookahead === ">" ?
@@ -9,7 +9,7 @@ export const parseString = (def, ctx) => {
9
9
  if (def.endsWith("[]")) {
10
10
  const possibleElementResolution = ctx.$.maybeResolveRoot(def.slice(0, -2));
11
11
  if (possibleElementResolution)
12
- return possibleElementResolution.array();
12
+ return possibleElementResolution.rawArray();
13
13
  }
14
14
  const s = new RuntimeState(new Scanner(def), ctx);
15
15
  const node = fullStringParse(s);
@@ -43,24 +43,24 @@ declare const postfixParsers: {
43
43
  export type TuplePostfixOperator = keyof typeof postfixParsers;
44
44
  declare const infixParsers: {
45
45
  "&": IndexOneParser<"&">;
46
- "|": IndexOneParser<"|">;
47
- "|>": IndexOneParser<"|>">;
48
- "=": IndexOneParser<"=">;
49
46
  ":": IndexOneParser<":">;
47
+ "=": IndexOneParser<"=">;
50
48
  "=>": IndexOneParser<"=>">;
51
49
  "@": IndexOneParser<"@">;
50
+ "|": IndexOneParser<"|">;
51
+ "|>": IndexOneParser<"|>">;
52
52
  };
53
53
  export type TupleInfixOperator = keyof typeof infixParsers;
54
54
  declare const indexOneParsers: {
55
55
  "&": IndexOneParser<"&">;
56
- "|": IndexOneParser<"|">;
57
- "|>": IndexOneParser<"|>">;
58
- "=": IndexOneParser<"=">;
59
56
  ":": IndexOneParser<":">;
57
+ "=": IndexOneParser<"=">;
60
58
  "=>": IndexOneParser<"=>">;
61
- "@": IndexOneParser<"@">;
62
59
  "?": IndexOneParser<"?">;
60
+ "@": IndexOneParser<"@">;
63
61
  "[]": IndexOneParser<"[]">;
62
+ "|": IndexOneParser<"|">;
63
+ "|>": IndexOneParser<"|>">;
64
64
  };
65
65
  export type IndexOneOperator = keyof typeof indexOneParsers;
66
66
  export type InfixExpression = readonly [unknown, InfixToken, ...unknown[]];
@@ -70,9 +70,9 @@ type IndexZeroExpression<token extends string = IndexZeroOperator> = readonly [
70
70
  ...unknown[]
71
71
  ];
72
72
  declare const indexZeroParsers: {
73
- keyof: IndexZeroParser<"keyof">;
74
- instanceof: IndexZeroParser<"instanceof">;
75
73
  "===": IndexZeroParser<"===">;
74
+ instanceof: IndexZeroParser<"instanceof">;
75
+ keyof: IndexZeroParser<"keyof">;
76
76
  };
77
77
  export type IndexZeroOperator = keyof typeof indexZeroParsers;
78
78
  export declare const writeInvalidConstructorMessage: <actual extends Domain | BuiltinObjectKind>(actual: actual) => string;
@@ -20,7 +20,7 @@ const parseBranchTuple = (def, ctx) => {
20
20
  return result.throw();
21
21
  return result;
22
22
  };
23
- const parseArrayTuple = (def, ctx) => ctx.$.parseOwnDefinitionFormat(def[0], ctx).array();
23
+ const parseArrayTuple = (def, ctx) => ctx.$.parseOwnDefinitionFormat(def[0], ctx).rawArray();
24
24
  export const parseMorphTuple = (def, ctx) => {
25
25
  if (typeof def[2] !== "function") {
26
26
  return throwParseError(writeMalformedFunctionalExpressionMessage("=>", def[2]));
package/out/scope.js CHANGED
@@ -98,7 +98,7 @@ export class InternalScope extends BaseScope {
98
98
  }
99
99
  type = new InternalTypeParser(this);
100
100
  static scope = ((def, config = {}) => new InternalScope(def, config));
101
- static module = ((def, config = {}) => this.scope(def, config).export());
101
+ static module = ((def, config = {}) => InternalScope.scope(def, config).export());
102
102
  }
103
103
  export const scope = Object.assign(InternalScope.scope, {
104
104
  define: (def) => def
package/out/type.d.ts CHANGED
@@ -21,7 +21,9 @@ export interface TypeParser<$ = {}> extends Ark.boundTypeAttachments<$> {
21
21
  */
22
22
  <const def, r = type.instantiate<def, $>>(def: type.validate<def, $>): r extends infer _ ? _ : never;
23
23
  /**
24
- * Create a {@link Generic} from a parameter string and body definition.
24
+ * Create a {@link Generic} from a parameter string and body definition, or a
25
+ * {@link Type} from a [tuple expression](http://localhost:3000/docs/expressions)
26
+ * spread as this function's arguments.
25
27
  *
26
28
  * @param params A string like "<t, n extends number>" specifying the
27
29
  * {@link Generic}'s parameters and any associated constraints via `extends`.
@@ -31,15 +33,9 @@ export interface TypeParser<$ = {}> extends Ark.boundTypeAttachments<$> {
31
33
  * from its {@link Scope}.
32
34
  *
33
35
  * @example const BoxOf = type("<t extends string | number>", { contents: "t" })
34
- */
35
- <const params extends ParameterString, const def, r = Generic<parseValidGenericParams<params, $>, def, $>>(params: validateParameterString<params, $>, def: type.validate<def, $, baseGenericConstraints<parseValidGenericParams<params, $>>>): r extends infer _ ? _ : never;
36
- /**
37
- * Create a {@link Type} from a [tuple expression](http://localhost:3000/docs/expressions)
38
- * spread as this function's arguments.
39
- *
40
36
  * @example type("string", "|", { foo: "number" })
41
37
  */
42
- <const zero, const one, const rest extends array, r = type.instantiate<[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, ArgTwoOperator>, ..._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 "|>" ? [type.validate<rest[0], $>] : one extends "@" ? [TypeMeta.MappableInput, NodeSelector?] : [type.validate<rest[0], $>] : []): r extends infer _ ? _ : never;
38
+ <const zero, const one, const rest extends array, r = zero extends ParameterString ? Generic<parseValidGenericParams<zero, $>, one, $> : type.instantiate<[zero, one, ...rest], $>>(_0: zero extends ParameterString ? validateParameterString<zero, $> : zero extends IndexZeroOperator ? zero : type.validate<zero, $>, _1: zero extends ParameterString ? type.validate<one, $, baseGenericConstraints<parseValidGenericParams<zero, $>>> : zero extends "keyof" ? type.validate<one, $> : zero extends "instanceof" ? conform<one, Constructor> : zero extends "===" ? conform<one, unknown> : conform<one, ArgTwoOperator>, ..._2: zero extends ParameterString ? [] : 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 "|>" ? [type.validate<rest[0], $>] : one extends "@" ? [TypeMeta.MappableInput, NodeSelector?] : [type.validate<rest[0], $>] : []): r extends infer _ ? _ : never;
43
39
  /**
44
40
  * An alias of the {@link ArkErrors} class, an instance of which is returned when a {@link Type}
45
41
  * is invoked with invalid input.
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.2.6",
4
+ "version": "2.2.8",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
@@ -38,9 +38,9 @@
38
38
  "out"
39
39
  ],
40
40
  "dependencies": {
41
- "@ark/util": "0.56.5",
42
- "@ark/schema": "0.56.5",
43
- "arkregex": "0.0.11"
41
+ "@ark/schema": "0.56.7",
42
+ "@ark/util": "0.56.7",
43
+ "arkregex": "0.0.13"
44
44
  },
45
45
  "publishConfig": {
46
46
  "access": "public"