arktype 2.0.0-rc.1 → 2.0.0-rc.10

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 (141) hide show
  1. package/out/config.d.ts +1 -1
  2. package/out/generic.d.ts +47 -48
  3. package/out/generic.js +6 -8
  4. package/out/index.d.ts +4 -4
  5. package/out/index.js +2 -2
  6. package/out/keywords/builtins.js +2 -2
  7. package/out/keywords/constructors/Array.d.ts +2 -2
  8. package/out/keywords/constructors/Array.js +7 -7
  9. package/out/keywords/constructors/Date.d.ts +32 -0
  10. package/out/keywords/constructors/FormData.d.ts +2 -2
  11. package/out/keywords/constructors/FormData.js +8 -8
  12. package/out/keywords/constructors/TypedArray.js +2 -2
  13. package/out/keywords/constructors/constructors.d.ts +0 -1
  14. package/out/keywords/constructors/constructors.js +2 -2
  15. package/out/keywords/inference.d.ts +227 -0
  16. package/out/keywords/keywords.d.ts +61 -0
  17. package/out/keywords/{ark.js → keywords.js} +10 -8
  18. package/out/keywords/number/epoch.d.ts +1 -2
  19. package/out/keywords/number/epoch.js +2 -2
  20. package/out/keywords/number/integer.js +2 -2
  21. package/out/keywords/number/number.d.ts +32 -6
  22. package/out/keywords/number/number.js +17 -5
  23. package/out/keywords/string/alpha.d.ts +1 -1
  24. package/out/keywords/string/alphanumeric.d.ts +1 -1
  25. package/out/keywords/string/capitalize.d.ts +2 -2
  26. package/out/keywords/string/capitalize.js +4 -4
  27. package/out/keywords/string/creditCard.d.ts +1 -1
  28. package/out/keywords/string/creditCard.js +2 -2
  29. package/out/keywords/string/date.d.ts +4 -8
  30. package/out/keywords/string/date.js +16 -16
  31. package/out/keywords/string/digits.d.ts +1 -1
  32. package/out/keywords/string/email.d.ts +1 -1
  33. package/out/keywords/string/integer.d.ts +2 -2
  34. package/out/keywords/string/integer.js +7 -7
  35. package/out/keywords/string/ip.d.ts +2 -2
  36. package/out/keywords/string/ip.js +5 -5
  37. package/out/keywords/string/json.d.ts +3 -2
  38. package/out/keywords/string/json.js +24 -16
  39. package/out/keywords/string/lower.d.ts +2 -2
  40. package/out/keywords/string/lower.js +4 -4
  41. package/out/keywords/string/normalize.d.ts +23 -27
  42. package/out/keywords/string/normalize.js +14 -14
  43. package/out/keywords/string/numeric.d.ts +2 -2
  44. package/out/keywords/string/numeric.js +7 -7
  45. package/out/keywords/string/semver.d.ts +1 -1
  46. package/out/keywords/string/string.d.ts +39 -42
  47. package/out/keywords/string/string.js +3 -3
  48. package/out/keywords/string/trim.d.ts +2 -2
  49. package/out/keywords/string/trim.js +4 -4
  50. package/out/keywords/string/upper.d.ts +2 -2
  51. package/out/keywords/string/upper.js +4 -4
  52. package/out/keywords/string/url.d.ts +2 -2
  53. package/out/keywords/string/url.js +8 -8
  54. package/out/keywords/string/uuid.d.ts +11 -11
  55. package/out/keywords/string/uuid.js +3 -3
  56. package/out/keywords/ts.d.ts +11 -0
  57. package/out/keywords/ts.js +7 -3
  58. package/out/keywords/utils.d.ts +1 -1
  59. package/out/keywords/utils.js +1 -1
  60. package/out/{subtypes → methods}/array.d.ts +6 -6
  61. package/out/methods/base.d.ts +96 -0
  62. package/out/{subtypes → methods}/date.d.ts +5 -5
  63. package/out/{subtypes → methods}/instantiate.d.ts +5 -4
  64. package/out/methods/morph.d.ts +12 -0
  65. package/out/{subtypes → methods}/number.d.ts +6 -6
  66. package/out/methods/object.d.ts +81 -0
  67. package/out/{subtypes → methods}/string.d.ts +7 -7
  68. package/out/{subtypes → methods}/validator.d.ts +2 -2
  69. package/out/module.d.ts +2 -2
  70. package/out/parser/{semantic → ast}/bounds.d.ts +3 -3
  71. package/out/parser/ast/default.d.ts +8 -0
  72. package/out/parser/{semantic → ast}/infer.d.ts +11 -11
  73. package/out/parser/{semantic → ast}/utils.d.ts +1 -1
  74. package/out/parser/{semantic → ast}/validate.d.ts +6 -6
  75. package/out/parser/definition.d.ts +8 -9
  76. package/out/parser/objectLiteral.d.ts +11 -37
  77. package/out/parser/objectLiteral.js +6 -24
  78. package/out/parser/{string/reduce → reduce}/dynamic.d.ts +5 -7
  79. package/out/parser/{string/reduce → reduce}/dynamic.js +5 -6
  80. package/out/parser/{string/reduce → reduce}/shared.d.ts +1 -1
  81. package/out/parser/{string/reduce → reduce}/static.d.ts +1 -1
  82. package/out/parser/{string/shift → shift}/operand/date.d.ts +3 -1
  83. package/out/parser/{string/shift → shift}/operand/enclosed.d.ts +3 -2
  84. package/out/parser/{string/shift → shift}/operand/enclosed.js +7 -3
  85. package/out/parser/{string/shift → shift}/operand/unenclosed.d.ts +3 -3
  86. package/out/parser/{string/shift → shift}/operand/unenclosed.js +7 -3
  87. package/out/parser/{string/shift → shift}/operator/bounds.d.ts +3 -3
  88. package/out/parser/{string/shift → shift}/operator/default.d.ts +3 -6
  89. package/out/parser/{string/shift → shift}/operator/default.js +1 -6
  90. package/out/parser/{string/shift → shift}/scanner.d.ts +3 -1
  91. package/out/parser/{string/shift → shift}/scanner.js +5 -3
  92. package/out/parser/{string/string.d.ts → string.d.ts} +6 -7
  93. package/out/parser/{string/string.js → string.js} +2 -0
  94. package/out/parser/tuple.d.ts +54 -43
  95. package/out/parser/tuple.js +36 -30
  96. package/out/scope.d.ts +32 -39
  97. package/out/scope.js +43 -35
  98. package/out/type.d.ts +24 -21
  99. package/out/type.js +14 -10
  100. package/package.json +3 -3
  101. package/out/intersect.d.ts +0 -28
  102. package/out/keys.d.ts +0 -16
  103. package/out/keywords/ark.d.ts +0 -39
  104. package/out/keywords/ast.d.ts +0 -193
  105. package/out/parser/semantic/default.d.ts +0 -9
  106. package/out/parser/semantic/default.js +0 -1
  107. package/out/subtypes/base.d.ts +0 -85
  108. package/out/subtypes/morph.d.ts +0 -13
  109. package/out/subtypes/object.d.ts +0 -33
  110. /package/out/{intersect.js → keywords/constructors/Date.js} +0 -0
  111. /package/out/keywords/{ast.js → inference.js} +0 -0
  112. /package/out/{subtypes → methods}/array.js +0 -0
  113. /package/out/{subtypes → methods}/base.js +0 -0
  114. /package/out/{subtypes → methods}/date.js +0 -0
  115. /package/out/{subtypes → methods}/instantiate.js +0 -0
  116. /package/out/{subtypes → methods}/morph.js +0 -0
  117. /package/out/{subtypes → methods}/number.js +0 -0
  118. /package/out/{subtypes → methods}/object.js +0 -0
  119. /package/out/{subtypes → methods}/string.js +0 -0
  120. /package/out/{subtypes → methods}/validator.js +0 -0
  121. /package/out/parser/{semantic → ast}/bounds.js +0 -0
  122. /package/out/{keys.js → parser/ast/default.js} +0 -0
  123. /package/out/parser/{semantic → ast}/divisor.d.ts +0 -0
  124. /package/out/parser/{semantic → ast}/divisor.js +0 -0
  125. /package/out/parser/{semantic → ast}/infer.js +0 -0
  126. /package/out/parser/{semantic → ast}/keyof.d.ts +0 -0
  127. /package/out/parser/{semantic → ast}/keyof.js +0 -0
  128. /package/out/parser/{semantic → ast}/utils.js +0 -0
  129. /package/out/parser/{semantic → ast}/validate.js +0 -0
  130. /package/out/parser/{string/reduce → reduce}/shared.js +0 -0
  131. /package/out/parser/{string/reduce → reduce}/static.js +0 -0
  132. /package/out/parser/{string/shift → shift}/operand/date.js +0 -0
  133. /package/out/parser/{string/shift → shift}/operand/genericArgs.d.ts +0 -0
  134. /package/out/parser/{string/shift → shift}/operand/genericArgs.js +0 -0
  135. /package/out/parser/{string/shift → shift}/operand/operand.d.ts +0 -0
  136. /package/out/parser/{string/shift → shift}/operand/operand.js +0 -0
  137. /package/out/parser/{string/shift → shift}/operator/bounds.js +0 -0
  138. /package/out/parser/{string/shift → shift}/operator/divisor.d.ts +0 -0
  139. /package/out/parser/{string/shift → shift}/operator/divisor.js +0 -0
  140. /package/out/parser/{string/shift → shift}/operator/operator.d.ts +0 -0
  141. /package/out/parser/{string/shift → shift}/operator/operator.js +0 -0
@@ -1,6 +1,5 @@
1
1
  import type { Module, Submodule } from "../../module.ts";
2
- import type { type } from "../ark.ts";
3
- import type { Branded, constrain, To } from "../ast.ts";
2
+ import type { Branded, constrain, To } from "../inference.ts";
4
3
  declare namespace string {
5
4
  type normalized = normalized.NFC;
6
5
  namespace normalized {
@@ -13,78 +12,75 @@ declare namespace string {
13
12
  export declare const normalizedForms: readonly ["NFC", "NFD", "NFKC", "NFKD"];
14
13
  export type NormalizedForm = (typeof normalizedForms)[number];
15
14
  export declare const NFC: Module<{
16
- $root: object;
17
- preformatted: object;
15
+ root: unknown;
16
+ preformatted: unknown;
18
17
  }>;
19
18
  export declare const NFD: Module<{
20
- $root: object;
21
- preformatted: object;
19
+ root: unknown;
20
+ preformatted: unknown;
22
21
  }>;
23
22
  export declare const NFKC: Module<{
24
- $root: object;
25
- preformatted: object;
23
+ root: unknown;
24
+ preformatted: unknown;
26
25
  }>;
27
26
  export declare const NFKD: Module<{
28
- $root: object;
29
- preformatted: object;
27
+ root: unknown;
28
+ preformatted: unknown;
30
29
  }>;
31
30
  export declare const normalize: Module<{
32
- $root: object;
31
+ root: unknown;
33
32
  NFC: Submodule<{
34
- $root: object;
35
- preformatted: object;
33
+ root: unknown;
34
+ preformatted: unknown;
36
35
  }>;
37
36
  NFD: Submodule<{
38
- $root: object;
39
- preformatted: object;
37
+ root: unknown;
38
+ preformatted: unknown;
40
39
  }>;
41
40
  NFKC: Submodule<{
42
- $root: object;
43
- preformatted: object;
41
+ root: unknown;
42
+ preformatted: unknown;
44
43
  }>;
45
44
  NFKD: Submodule<{
46
- $root: object;
47
- preformatted: object;
45
+ root: unknown;
46
+ preformatted: unknown;
48
47
  }>;
49
48
  }>;
50
49
  export declare namespace normalize {
51
50
  type module = Module<submodule>;
52
51
  type submodule = Submodule<$>;
53
52
  type $ = {
54
- $root: (In: string) => To<string.normalized.NFC>;
53
+ root: (In: string) => To<string.normalized.NFC>;
55
54
  NFC: NFC.submodule;
56
55
  NFD: NFD.submodule;
57
56
  NFKC: NFKC.submodule;
58
57
  NFKD: NFKD.submodule;
59
58
  };
60
- type shallowResolutions = {
61
- [k in keyof $ as `string.normalize.${k}`]: $[k] extends type.cast<infer t> ? t : $[k];
62
- };
63
59
  namespace NFC {
64
60
  type submodule = Submodule<$>;
65
61
  type $ = {
66
- $root: (In: string) => To<string.normalized.NFC>;
62
+ root: (In: string) => To<string.normalized.NFC>;
67
63
  preformatted: string.normalized.NFC;
68
64
  };
69
65
  }
70
66
  namespace NFD {
71
67
  type submodule = Submodule<$>;
72
68
  type $ = {
73
- $root: (In: string) => To<string.normalized.NFD>;
69
+ root: (In: string) => To<string.normalized.NFD>;
74
70
  preformatted: string.normalized.NFD;
75
71
  };
76
72
  }
77
73
  namespace NFKC {
78
74
  type submodule = Submodule<$>;
79
75
  type $ = {
80
- $root: (In: string) => To<string.normalized.NFKC>;
76
+ root: (In: string) => To<string.normalized.NFKC>;
81
77
  preformatted: string.normalized.NFKC;
82
78
  };
83
79
  }
84
80
  namespace NFKD {
85
81
  type submodule = Submodule<$>;
86
82
  type $ = {
87
- $root: (In: string) => To<string.normalized.NFKD>;
83
+ root: (In: string) => To<string.normalized.NFKD>;
88
84
  preformatted: string.normalized.NFKD;
89
85
  };
90
86
  }
@@ -1,10 +1,10 @@
1
- import { rootNode } from "@ark/schema";
1
+ import { rootSchema } from "@ark/schema";
2
2
  import { flatMorph } from "@ark/util";
3
- import { submodule } from "../utils.js";
3
+ import { arkModule } from "../utils.js";
4
4
  export const normalizedForms = ["NFC", "NFD", "NFKC", "NFKD"];
5
5
  const preformattedNodes = flatMorph(normalizedForms, (i, form) => [
6
6
  form,
7
- rootNode({
7
+ rootSchema({
8
8
  domain: "string",
9
9
  predicate: (s) => s.normalize(form) === s,
10
10
  meta: `${form}-normalized unicode`
@@ -12,30 +12,30 @@ const preformattedNodes = flatMorph(normalizedForms, (i, form) => [
12
12
  ]);
13
13
  const normalizeNodes = flatMorph(normalizedForms, (i, form) => [
14
14
  form,
15
- rootNode({
15
+ rootSchema({
16
16
  in: "string",
17
17
  morphs: (s) => s.normalize(form),
18
18
  declaredOut: preformattedNodes[form]
19
19
  })
20
20
  ]);
21
- export const NFC = submodule({
22
- $root: normalizeNodes.NFC,
21
+ export const NFC = arkModule({
22
+ root: normalizeNodes.NFC,
23
23
  preformatted: preformattedNodes.NFC
24
24
  });
25
- export const NFD = submodule({
26
- $root: normalizeNodes.NFD,
25
+ export const NFD = arkModule({
26
+ root: normalizeNodes.NFD,
27
27
  preformatted: preformattedNodes.NFD
28
28
  });
29
- export const NFKC = submodule({
30
- $root: normalizeNodes.NFKC,
29
+ export const NFKC = arkModule({
30
+ root: normalizeNodes.NFKC,
31
31
  preformatted: preformattedNodes.NFKC
32
32
  });
33
- export const NFKD = submodule({
34
- $root: normalizeNodes.NFKD,
33
+ export const NFKD = arkModule({
34
+ root: normalizeNodes.NFKD,
35
35
  preformatted: preformattedNodes.NFKD
36
36
  });
37
- export const normalize = submodule({
38
- $root: "NFC",
37
+ export const normalize = arkModule({
38
+ root: "NFC",
39
39
  NFC,
40
40
  NFD,
41
41
  NFKC,
@@ -1,5 +1,5 @@
1
1
  import type { Module, Submodule } from "../../module.ts";
2
- import type { Branded, constrain, To } from "../ast.ts";
2
+ import type { Branded, constrain, To } from "../inference.ts";
3
3
  declare namespace string {
4
4
  type numeric = constrain<string, Branded<"numeric">>;
5
5
  }
@@ -8,7 +8,7 @@ export declare namespace stringNumeric {
8
8
  type module = Module<submodule>;
9
9
  type submodule = Submodule<$>;
10
10
  type $ = {
11
- $root: string.numeric;
11
+ root: string.numeric;
12
12
  parse: (In: string.numeric) => To<number>;
13
13
  };
14
14
  }
@@ -1,12 +1,12 @@
1
- import { intrinsic, rootNode } from "@ark/schema";
1
+ import { intrinsic, rootSchema } from "@ark/schema";
2
2
  import { wellFormedNumberMatcher } from "@ark/util";
3
- import { submodule } from "../utils.js";
3
+ import { arkModule } from "../utils.js";
4
4
  import { regexStringNode } from "./utils.js";
5
- const $root = regexStringNode(wellFormedNumberMatcher, "a well-formed numeric string");
6
- export const numeric = submodule({
7
- $root,
8
- parse: rootNode({
9
- in: $root,
5
+ const root = regexStringNode(wellFormedNumberMatcher, "a well-formed numeric string");
6
+ export const numeric = arkModule({
7
+ root,
8
+ parse: rootSchema({
9
+ in: root,
10
10
  morphs: (s) => Number.parseFloat(s),
11
11
  declaredOut: intrinsic.number
12
12
  })
@@ -1,4 +1,4 @@
1
- import type { Branded, constrain } from "../ast.ts";
1
+ import type { Branded, constrain } from "../inference.ts";
2
2
  declare namespace string {
3
3
  type semver = constrain<string, Branded<"semver">>;
4
4
  }
@@ -1,7 +1,5 @@
1
- import { type Constraint, type NodeSchema } from "@ark/schema";
2
1
  import type { Module, Submodule } from "../../module.ts";
3
- import type { type } from "../ark.ts";
4
- import type { AtLeastLength, AtMostLength, Branded, Constraints, ExactlyLength, LessThanLength, Matching, MoreThanLength, Narrowed, constrain, normalizePrimitiveConstraintRoot } from "../ast.ts";
2
+ import type { AtLeastLength, AtMostLength, Branded, Constraints, Default, ExactlyLength, LessThanLength, MoreThanLength, Narrowed, Optional, constrain, constraint } from "../inference.ts";
5
3
  import { alpha } from "./alpha.ts";
6
4
  import { alphanumeric } from "./alphanumeric.ts";
7
5
  import { capitalize } from "./capitalize.ts";
@@ -21,54 +19,57 @@ import { upper } from "./upper.ts";
21
19
  import { url } from "./url.ts";
22
20
  import { uuid } from "./uuid.ts";
23
21
  export declare const string: Module<{
22
+ root: unknown;
24
23
  trim: Submodule<trim.submodule>;
25
24
  normalize: Submodule<{
26
- $root: object;
25
+ root: unknown;
27
26
  NFC: Submodule<{
28
- $root: object;
29
- preformatted: object;
27
+ root: unknown;
28
+ preformatted: unknown;
30
29
  }>;
31
30
  NFD: Submodule<{
32
- $root: object;
33
- preformatted: object;
31
+ root: unknown;
32
+ preformatted: unknown;
34
33
  }>;
35
34
  NFKC: Submodule<{
36
- $root: object;
37
- preformatted: object;
35
+ root: unknown;
36
+ preformatted: unknown;
38
37
  }>;
39
38
  NFKD: Submodule<{
40
- $root: object;
41
- preformatted: object;
39
+ root: unknown;
40
+ preformatted: unknown;
42
41
  }>;
43
42
  }>;
43
+ alpha: unknown;
44
+ alphanumeric: unknown;
44
45
  json: Submodule<stringJson.submodule>;
45
- $root: object;
46
+ creditCard: unknown;
46
47
  integer: Submodule<stringInteger.submodule>;
47
- alpha: object;
48
- alphanumeric: object;
49
- digits: object;
48
+ date: Submodule<stringDate.submodule>;
49
+ digits: unknown;
50
+ email: unknown;
51
+ ip: Submodule<ip.submodule>;
50
52
  numeric: Submodule<stringNumeric.submodule>;
51
- creditCard: object;
52
- email: object;
53
+ semver: unknown;
54
+ url: Submodule<url.submodule>;
53
55
  uuid: Submodule<{
54
- $root: string.matching<string> | "00000000-0000-0000-0000-000000000000" | "ffffffff-ffff-ffff-ffff-ffffffffffff";
55
- v4: object;
56
- v6: object;
57
- v1: object;
58
- v2: object;
59
- v3: object;
60
- v5: object;
61
- v7: object;
62
- v8: object;
56
+ root: string.matching<string> | "00000000-0000-0000-0000-000000000000" | "ffffffff-ffff-ffff-ffff-ffffffffffff";
57
+ v4: unknown;
58
+ v6: unknown;
59
+ v1: unknown;
60
+ v2: unknown;
61
+ v3: unknown;
62
+ v5: unknown;
63
+ v7: unknown;
64
+ v8: unknown;
63
65
  }>;
64
- semver: object;
65
- ip: Submodule<ip.submodule>;
66
- date: Submodule<stringDate.submodule>;
67
- capitalize: Submodule<capitalize.submodule>;
68
- lower: Submodule<lower.submodule>;
69
66
  upper: Submodule<upper.submodule>;
70
- url: Submodule<url.submodule>;
67
+ lower: Submodule<lower.submodule>;
68
+ capitalize: Submodule<capitalize.submodule>;
71
69
  }>;
70
+ export type Matching<rule> = {
71
+ matching: constraint<rule>;
72
+ };
72
73
  export declare namespace string {
73
74
  type atLeastLength<rule> = constrain<string, AtLeastLength<rule>>;
74
75
  type moreThanLength<rule> = constrain<string, MoreThanLength<rule>>;
@@ -77,17 +78,15 @@ export declare namespace string {
77
78
  type exactlyLength<rule> = constrain<string, ExactlyLength<rule>>;
78
79
  type matching<rule> = constrain<string, Matching<rule>>;
79
80
  type narrowed = constrain<string, Narrowed>;
81
+ type optional = constrain<string, Optional>;
82
+ type defaultsTo<rule> = constrain<string, Default<rule>>;
80
83
  type branded<rule> = constrain<string, Branded<rule>>;
81
84
  type is<constraints extends Constraints> = constrain<string, constraints>;
82
- type parseConstraint<kind extends Constraint.PrimitiveKind, schema extends NodeSchema<kind>> = normalizePrimitiveConstraintRoot<schema> extends infer rule ? kind extends "minLength" ? schema extends {
83
- exclusive: true;
84
- } ? moreThanLength<rule> : atLeastLength<rule> : kind extends "maxLength" ? schema extends {
85
- exclusive: true;
86
- } ? lessThanLength<rule> : atMostLength<rule> : kind extends "pattern" ? matching<rule & string> : kind extends "exactLength" ? exactlyLength<rule> : narrowed : never;
85
+ type withConstraint<constraint> = constraint extends ExactlyLength<infer rule> ? exactlyLength<rule> : constraint extends MoreThanLength<infer rule> ? moreThanLength<rule> : constraint extends AtLeastLength<infer rule> ? atLeastLength<rule> : constraint extends AtMostLength<infer rule> ? atMostLength<rule> : constraint extends LessThanLength<infer rule> ? lessThanLength<rule> : constraint extends Matching<infer rule> ? matching<rule> : constraint extends Optional ? optional : constraint extends Default<infer rule> ? defaultsTo<rule> : constraint extends Narrowed ? narrowed : never;
87
86
  type module = Module<string.submodule>;
88
87
  type submodule = Submodule<$>;
89
88
  type $ = {
90
- $root: string;
89
+ root: string;
91
90
  alpha: alpha;
92
91
  alphanumeric: alphanumeric;
93
92
  digits: digits;
@@ -100,13 +99,11 @@ export declare namespace string {
100
99
  ip: ip.submodule;
101
100
  json: stringJson.submodule;
102
101
  date: stringDate.submodule;
102
+ url: url.submodule;
103
103
  trim: trim.submodule;
104
104
  normalize: normalize.submodule;
105
105
  capitalize: capitalize.submodule;
106
106
  lower: lower.submodule;
107
107
  upper: upper.submodule;
108
108
  };
109
- type shallowResolutions = {
110
- [k in keyof $ as `string.${k}`]: $[k] extends type.cast<infer t> ? t : $[k];
111
- };
112
109
  }
@@ -1,5 +1,5 @@
1
1
  import { intrinsic } from "@ark/schema";
2
- import { submodule } from "../utils.js";
2
+ import { arkModule } from "../utils.js";
3
3
  import { alpha } from "./alpha.js";
4
4
  import { alphanumeric } from "./alphanumeric.js";
5
5
  import { capitalize } from "./capitalize.js";
@@ -18,8 +18,8 @@ import { trim } from "./trim.js";
18
18
  import { upper } from "./upper.js";
19
19
  import { url } from "./url.js";
20
20
  import { uuid } from "./uuid.js";
21
- export const string = submodule({
22
- $root: intrinsic.string,
21
+ export const string = arkModule({
22
+ root: intrinsic.string,
23
23
  numeric,
24
24
  integer,
25
25
  alpha,
@@ -1,5 +1,5 @@
1
1
  import type { Module, Submodule } from "../../module.ts";
2
- import type { Branded, constrain, To } from "../ast.ts";
2
+ import type { Branded, constrain, To } from "../inference.ts";
3
3
  declare namespace string {
4
4
  type trimmed = constrain<string, Branded<"trimmed">>;
5
5
  }
@@ -8,7 +8,7 @@ export declare namespace trim {
8
8
  type module = Module<submodule>;
9
9
  type submodule = Submodule<$>;
10
10
  type $ = {
11
- $root: (In: string) => To<string.trimmed>;
11
+ root: (In: string) => To<string.trimmed>;
12
12
  preformatted: string.trimmed;
13
13
  };
14
14
  }
@@ -1,11 +1,11 @@
1
- import { rootNode } from "@ark/schema";
2
- import { submodule } from "../utils.js";
1
+ import { rootSchema } from "@ark/schema";
2
+ import { arkModule } from "../utils.js";
3
3
  import { regexStringNode } from "./utils.js";
4
4
  const preformatted = regexStringNode(
5
5
  // no leading or trailing whitespace
6
6
  /^\S.*\S$|^\S?$/, "trimmed");
7
- export const trim = submodule({
8
- $root: rootNode({
7
+ export const trim = arkModule({
8
+ root: rootSchema({
9
9
  in: "string",
10
10
  morphs: (s) => s.trim(),
11
11
  declaredOut: preformatted
@@ -1,5 +1,5 @@
1
1
  import type { Module, Submodule } from "../../module.ts";
2
- import type { Branded, constrain, To } from "../ast.ts";
2
+ import type { Branded, constrain, To } from "../inference.ts";
3
3
  declare namespace string {
4
4
  type uppercase = constrain<string, Branded<"uppercase">>;
5
5
  }
@@ -8,7 +8,7 @@ export declare namespace upper {
8
8
  type module = Module<submodule>;
9
9
  type submodule = Submodule<$>;
10
10
  type $ = {
11
- $root: (In: string) => To<string.uppercase>;
11
+ root: (In: string) => To<string.uppercase>;
12
12
  preformatted: string.uppercase;
13
13
  };
14
14
  }
@@ -1,9 +1,9 @@
1
- import { rootNode } from "@ark/schema";
2
- import { submodule } from "../utils.js";
1
+ import { rootSchema } from "@ark/schema";
2
+ import { arkModule } from "../utils.js";
3
3
  import { regexStringNode } from "./utils.js";
4
4
  const preformatted = regexStringNode(/^[A-Z]*$/, "only uppercase letters");
5
- export const upper = submodule({
6
- $root: rootNode({
5
+ export const upper = arkModule({
6
+ root: rootSchema({
7
7
  in: "string",
8
8
  morphs: (s) => s.toUpperCase(),
9
9
  declaredOut: preformatted
@@ -1,5 +1,5 @@
1
1
  import type { Module, Submodule } from "../../module.ts";
2
- import type { Branded, constrain, To } from "../ast.ts";
2
+ import type { Branded, constrain, To } from "../inference.ts";
3
3
  declare namespace string {
4
4
  type url = constrain<string, Branded<"url">>;
5
5
  }
@@ -8,7 +8,7 @@ export declare namespace url {
8
8
  type module = Module<submodule>;
9
9
  type submodule = Submodule<$>;
10
10
  type $ = {
11
- $root: string.url;
11
+ root: string.url;
12
12
  parse: (In: string.url) => To<URL>;
13
13
  };
14
14
  }
@@ -1,5 +1,5 @@
1
- import { rootNode } from "@ark/schema";
2
- import { submodule } from "../utils.js";
1
+ import { rootSchema } from "@ark/schema";
2
+ import { arkModule } from "../utils.js";
3
3
  const isParsableUrl = (s) => {
4
4
  if (URL.canParse)
5
5
  return URL.canParse(s);
@@ -12,17 +12,17 @@ const isParsableUrl = (s) => {
12
12
  return false;
13
13
  }
14
14
  };
15
- const $root = rootNode({
15
+ const root = rootSchema({
16
16
  domain: "string",
17
17
  predicate: {
18
18
  meta: "a URL string",
19
19
  predicate: isParsableUrl
20
20
  }
21
21
  });
22
- export const url = submodule({
23
- $root,
24
- parse: rootNode({
25
- declaredIn: $root,
22
+ export const url = arkModule({
23
+ root,
24
+ parse: rootSchema({
25
+ declaredIn: root,
26
26
  in: "string",
27
27
  morphs: (s, ctx) => {
28
28
  try {
@@ -32,6 +32,6 @@ export const url = submodule({
32
32
  return ctx.error("a URL string");
33
33
  }
34
34
  },
35
- declaredOut: rootNode(URL)
35
+ declaredOut: rootSchema(URL)
36
36
  })
37
37
  });
@@ -1,15 +1,15 @@
1
1
  import type { Module, Submodule } from "../../module.ts";
2
- import type { Branded, constrain } from "../ast.ts";
2
+ import type { Branded, constrain } from "../inference.ts";
3
3
  export declare const uuid: Module<{
4
- $root: import("./string.ts").string.matching<string> | "00000000-0000-0000-0000-000000000000" | "ffffffff-ffff-ffff-ffff-ffffffffffff";
5
- v4: object;
6
- v6: object;
7
- v1: object;
8
- v2: object;
9
- v3: object;
10
- v5: object;
11
- v7: object;
12
- v8: object;
4
+ root: import("./string.ts").string.matching<string> | "00000000-0000-0000-0000-000000000000" | "ffffffff-ffff-ffff-ffff-ffffffffffff";
5
+ v4: unknown;
6
+ v6: unknown;
7
+ v1: unknown;
8
+ v2: unknown;
9
+ v3: unknown;
10
+ v5: unknown;
11
+ v7: unknown;
12
+ v8: unknown;
13
13
  }>;
14
14
  declare namespace string {
15
15
  type uuid = constrain<string, Branded<"uuid">>;
@@ -28,7 +28,7 @@ export declare namespace uuid {
28
28
  type module = Module<submodule>;
29
29
  type submodule = Submodule<$>;
30
30
  type $ = {
31
- $root: string.uuid;
31
+ root: string.uuid;
32
32
  v1: string.uuid.v1;
33
33
  v2: string.uuid.v2;
34
34
  v3: string.uuid.v3;
@@ -1,10 +1,10 @@
1
- import { submodule } from "../utils.js";
1
+ import { arkModule } from "../utils.js";
2
2
  import { regexStringNode } from "./utils.js";
3
3
  // Based on https://github.com/validatorjs/validator.js/blob/master/src/lib/isUUID.js
4
- export const uuid = submodule({
4
+ export const uuid = arkModule({
5
5
  // the meta tuple expression ensures the error message does not delegate
6
6
  // to the individual branches, which are too detailed
7
- $root: ["versioned | nil | max", "@", "a UUID"],
7
+ root: ["versioned | nil | max", "@", "a UUID"],
8
8
  "#nil": "'00000000-0000-0000-0000-000000000000'",
9
9
  "#max": "'ffffffff-ffff-ffff-ffff-ffffffffffff'",
10
10
  "#versioned": /[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}/i,
@@ -19,6 +19,17 @@ export declare namespace arkTsKeywords {
19
19
  undefined: undefined;
20
20
  };
21
21
  }
22
+ export declare const unknown: Module<{
23
+ root: unknown;
24
+ any: unknown;
25
+ }>;
26
+ export declare namespace unknown {
27
+ type submodule = Submodule<$>;
28
+ type $ = {
29
+ root: unknown;
30
+ any: any;
31
+ };
32
+ }
22
33
  declare class RecordHkt extends Hkt<[Key, unknown]> {
23
34
  body: Record<this[0], this[1]>;
24
35
  }
@@ -1,7 +1,7 @@
1
1
  import { genericNode, intrinsic } from "@ark/schema";
2
2
  import { Hkt } from "@ark/util";
3
- import { submodule } from "./utils.js";
4
- export const arkTsKeywords = submodule({
3
+ import { arkModule } from "./utils.js";
4
+ export const arkTsKeywords = arkModule({
5
5
  bigint: intrinsic.bigint,
6
6
  boolean: intrinsic.boolean,
7
7
  false: intrinsic.false,
@@ -15,6 +15,10 @@ export const arkTsKeywords = submodule({
15
15
  unknown: intrinsic.unknown,
16
16
  undefined: intrinsic.undefined
17
17
  });
18
+ export const unknown = arkModule({
19
+ root: intrinsic.unknown,
20
+ any: intrinsic.unknown
21
+ });
18
22
  class RecordHkt extends Hkt {
19
23
  }
20
24
  const Record = genericNode(["K", intrinsic.key], "V")(args => ({
@@ -42,7 +46,7 @@ const Exclude = genericNode("T", "U")(args => args.T.exclude(args.U), ExcludeHkt
42
46
  class ExtractHkt extends Hkt {
43
47
  }
44
48
  const Extract = genericNode("T", "U")(args => args.T.extract(args.U), ExtractHkt);
45
- export const arkTsGenerics = submodule({
49
+ export const arkTsGenerics = arkModule({
46
50
  Record,
47
51
  Pick,
48
52
  Omit,
@@ -1 +1 @@
1
- export declare const submodule: import("../scope.ts").ModuleParser;
1
+ export declare const arkModule: import("../scope.ts").ModuleParser;
@@ -1,2 +1,2 @@
1
1
  import { module } from "../scope.js";
2
- export const submodule = module;
2
+ export const arkModule = module;
@@ -1,13 +1,13 @@
1
1
  import type { ExactLength, ExclusiveNumericRangeSchema, exclusivizeRangeSchema, InclusiveNumericRangeSchema } from "@ark/schema";
2
- import type { applyConstraint } from "../keywords/ast.ts";
2
+ import type { applyConstraintSchema } from "../keywords/inference.ts";
3
3
  import type { ObjectType } from "./object.ts";
4
4
  interface Type<
5
5
  /** @ts-ignore cast variance */
6
6
  out t extends readonly unknown[] = readonly unknown[], $ = {}> extends ObjectType<t, $> {
7
- atLeastLength<const schema extends InclusiveNumericRangeSchema>(schema: schema): Type<applyConstraint<t, "minLength", schema>, $>;
8
- atMostLength<const schema extends InclusiveNumericRangeSchema>(schema: schema): Type<applyConstraint<t, "maxLength", schema>, $>;
9
- moreThanLength<const schema extends ExclusiveNumericRangeSchema>(schema: schema): Type<applyConstraint<t, "minLength", exclusivizeRangeSchema<schema>>, $>;
10
- lessThanLength<const schema extends ExclusiveNumericRangeSchema>(schema: schema): Type<applyConstraint<t, "maxLength", exclusivizeRangeSchema<schema>>, $>;
11
- exactlyLength<const schema extends ExactLength.Schema>(schema: schema): Type<applyConstraint<t, "exactLength", schema>, $>;
7
+ atLeastLength<const schema extends InclusiveNumericRangeSchema>(schema: schema): Type<applyConstraintSchema<t, "minLength", schema>, $>;
8
+ atMostLength<const schema extends InclusiveNumericRangeSchema>(schema: schema): Type<applyConstraintSchema<t, "maxLength", schema>, $>;
9
+ moreThanLength<const schema extends ExclusiveNumericRangeSchema>(schema: schema): Type<applyConstraintSchema<t, "minLength", exclusivizeRangeSchema<schema>>, $>;
10
+ lessThanLength<const schema extends ExclusiveNumericRangeSchema>(schema: schema): Type<applyConstraintSchema<t, "maxLength", exclusivizeRangeSchema<schema>>, $>;
11
+ exactlyLength<const schema extends ExactLength.Schema>(schema: schema): Type<applyConstraintSchema<t, "exactLength", schema>, $>;
12
12
  }
13
13
  export type { Type as ArrayType };