arktype 2.0.0-rc.0 → 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 (147) hide show
  1. package/out/config.d.ts +1 -1
  2. package/out/generic.d.ts +55 -53
  3. package/out/generic.js +9 -11
  4. package/out/index.d.ts +5 -5
  5. package/out/index.js +3 -2
  6. package/out/keywords/{builtin.d.ts → builtins.d.ts} +9 -5
  7. package/out/keywords/{builtin.js → builtins.js} +2 -2
  8. package/out/keywords/constructors/Array.d.ts +12 -8
  9. package/out/keywords/constructors/Array.js +7 -7
  10. package/out/keywords/constructors/Date.d.ts +32 -0
  11. package/out/keywords/constructors/FormData.d.ts +12 -6
  12. package/out/keywords/constructors/FormData.js +19 -6
  13. package/out/keywords/constructors/TypedArray.d.ts +18 -14
  14. package/out/keywords/constructors/TypedArray.js +2 -2
  15. package/out/keywords/constructors/constructors.d.ts +21 -32
  16. package/out/keywords/constructors/constructors.js +13 -28
  17. package/out/keywords/inference.d.ts +227 -0
  18. package/out/keywords/keywords.d.ts +61 -0
  19. package/out/keywords/keywords.js +26 -0
  20. package/out/keywords/number/epoch.d.ts +1 -2
  21. package/out/keywords/number/epoch.js +2 -2
  22. package/out/keywords/number/integer.js +2 -2
  23. package/out/keywords/number/number.d.ts +37 -9
  24. package/out/keywords/number/number.js +17 -5
  25. package/out/keywords/string/alpha.d.ts +1 -1
  26. package/out/keywords/string/alphanumeric.d.ts +1 -1
  27. package/out/keywords/string/capitalize.d.ts +11 -10
  28. package/out/keywords/string/capitalize.js +4 -4
  29. package/out/keywords/string/creditCard.d.ts +1 -1
  30. package/out/keywords/string/creditCard.js +2 -2
  31. package/out/keywords/string/date.d.ts +27 -26
  32. package/out/keywords/string/date.js +16 -16
  33. package/out/keywords/string/digits.d.ts +1 -1
  34. package/out/keywords/string/email.d.ts +1 -1
  35. package/out/keywords/string/integer.d.ts +11 -10
  36. package/out/keywords/string/integer.js +7 -7
  37. package/out/keywords/string/ip.d.ts +12 -12
  38. package/out/keywords/string/ip.js +5 -5
  39. package/out/keywords/string/json.d.ts +12 -10
  40. package/out/keywords/string/json.js +24 -16
  41. package/out/keywords/string/lower.d.ts +11 -10
  42. package/out/keywords/string/lower.js +4 -4
  43. package/out/keywords/string/normalize.d.ts +63 -47
  44. package/out/keywords/string/normalize.js +14 -14
  45. package/out/keywords/string/numeric.d.ts +11 -10
  46. package/out/keywords/string/numeric.js +7 -7
  47. package/out/keywords/string/semver.d.ts +1 -1
  48. package/out/keywords/string/string.d.ts +78 -26
  49. package/out/keywords/string/string.js +5 -5
  50. package/out/keywords/string/trim.d.ts +11 -10
  51. package/out/keywords/string/trim.js +4 -4
  52. package/out/keywords/string/upper.d.ts +11 -10
  53. package/out/keywords/string/upper.js +4 -4
  54. package/out/keywords/string/url.d.ts +11 -10
  55. package/out/keywords/string/url.js +8 -8
  56. package/out/keywords/string/uuid.d.ts +27 -23
  57. package/out/keywords/string/uuid.js +3 -3
  58. package/out/keywords/ts.d.ts +44 -22
  59. package/out/keywords/ts.js +20 -14
  60. package/out/keywords/utils.d.ts +1 -1
  61. package/out/keywords/utils.js +1 -1
  62. package/out/{subtypes → methods}/array.d.ts +6 -6
  63. package/out/methods/base.d.ts +96 -0
  64. package/out/{subtypes → methods}/date.d.ts +5 -5
  65. package/out/{subtypes → methods}/instantiate.d.ts +5 -4
  66. package/out/methods/morph.d.ts +12 -0
  67. package/out/{subtypes → methods}/number.d.ts +6 -6
  68. package/out/methods/object.d.ts +81 -0
  69. package/out/{subtypes → methods}/string.d.ts +7 -7
  70. package/out/{subtypes → methods}/validator.d.ts +2 -2
  71. package/out/module.d.ts +2 -2
  72. package/out/parser/{semantic → ast}/bounds.d.ts +6 -4
  73. package/out/parser/ast/default.d.ts +8 -0
  74. package/out/parser/ast/infer.d.ts +39 -0
  75. package/out/parser/ast/utils.d.ts +4 -0
  76. package/out/parser/ast/validate.d.ts +26 -0
  77. package/out/parser/definition.d.ts +9 -12
  78. package/out/parser/objectLiteral.d.ts +11 -25
  79. package/out/parser/objectLiteral.js +6 -24
  80. package/out/parser/{string/reduce → reduce}/dynamic.d.ts +5 -7
  81. package/out/parser/{string/reduce → reduce}/dynamic.js +5 -6
  82. package/out/parser/{string/reduce → reduce}/shared.d.ts +1 -1
  83. package/out/parser/{string/reduce → reduce}/static.d.ts +1 -1
  84. package/out/parser/{string/shift → shift}/operand/date.d.ts +3 -1
  85. package/out/parser/{string/shift → shift}/operand/enclosed.d.ts +4 -1
  86. package/out/parser/{string/shift → shift}/operand/enclosed.js +7 -3
  87. package/out/parser/{string/shift → shift}/operand/unenclosed.d.ts +7 -8
  88. package/out/parser/{string/shift → shift}/operand/unenclosed.js +7 -3
  89. package/out/parser/{string/shift → shift}/operator/bounds.d.ts +7 -6
  90. package/out/parser/{string/shift → shift}/operator/default.d.ts +3 -6
  91. package/out/parser/{string/shift → shift}/operator/default.js +1 -6
  92. package/out/parser/{string/shift → shift}/operator/operator.js +2 -2
  93. package/out/parser/{string/shift → shift}/scanner.d.ts +6 -2
  94. package/out/parser/{string/shift → shift}/scanner.js +7 -5
  95. package/out/parser/{string/string.d.ts → string.d.ts} +8 -8
  96. package/out/parser/{string/string.js → string.js} +2 -0
  97. package/out/parser/tuple.d.ts +54 -43
  98. package/out/parser/tuple.js +36 -30
  99. package/out/scope.d.ts +41 -34
  100. package/out/scope.js +48 -27
  101. package/out/type.d.ts +25 -20
  102. package/out/type.js +23 -14
  103. package/package.json +3 -3
  104. package/out/intersect.d.ts +0 -28
  105. package/out/keys.d.ts +0 -16
  106. package/out/keywords/ark.d.ts +0 -33
  107. package/out/keywords/ark.js +0 -18
  108. package/out/keywords/ast.d.ts +0 -193
  109. package/out/parser/semantic/default.d.ts +0 -8
  110. package/out/parser/semantic/default.js +0 -1
  111. package/out/parser/semantic/infer.d.ts +0 -33
  112. package/out/parser/semantic/utils.d.ts +0 -4
  113. package/out/parser/semantic/validate.d.ts +0 -29
  114. package/out/subtypes/base.d.ts +0 -84
  115. package/out/subtypes/morph.d.ts +0 -13
  116. package/out/subtypes/object.d.ts +0 -33
  117. /package/out/{intersect.js → keywords/constructors/Date.js} +0 -0
  118. /package/out/keywords/{ast.js → inference.js} +0 -0
  119. /package/out/{subtypes → methods}/array.js +0 -0
  120. /package/out/{subtypes → methods}/base.js +0 -0
  121. /package/out/{subtypes → methods}/date.js +0 -0
  122. /package/out/{subtypes → methods}/instantiate.js +0 -0
  123. /package/out/{subtypes → methods}/morph.js +0 -0
  124. /package/out/{subtypes → methods}/number.js +0 -0
  125. /package/out/{subtypes → methods}/object.js +0 -0
  126. /package/out/{subtypes → methods}/string.js +0 -0
  127. /package/out/{subtypes → methods}/validator.js +0 -0
  128. /package/out/parser/{semantic → ast}/bounds.js +0 -0
  129. /package/out/{keys.js → parser/ast/default.js} +0 -0
  130. /package/out/parser/{semantic → ast}/divisor.d.ts +0 -0
  131. /package/out/parser/{semantic → ast}/divisor.js +0 -0
  132. /package/out/parser/{semantic → ast}/infer.js +0 -0
  133. /package/out/parser/{semantic → ast}/keyof.d.ts +0 -0
  134. /package/out/parser/{semantic → ast}/keyof.js +0 -0
  135. /package/out/parser/{semantic → ast}/utils.js +0 -0
  136. /package/out/parser/{semantic → ast}/validate.js +0 -0
  137. /package/out/parser/{string/reduce → reduce}/shared.js +0 -0
  138. /package/out/parser/{string/reduce → reduce}/static.js +0 -0
  139. /package/out/parser/{string/shift → shift}/operand/date.js +0 -0
  140. /package/out/parser/{string/shift → shift}/operand/genericArgs.d.ts +0 -0
  141. /package/out/parser/{string/shift → shift}/operand/genericArgs.js +0 -0
  142. /package/out/parser/{string/shift → shift}/operand/operand.d.ts +0 -0
  143. /package/out/parser/{string/shift → shift}/operand/operand.js +0 -0
  144. /package/out/parser/{string/shift → shift}/operator/bounds.js +0 -0
  145. /package/out/parser/{string/shift → shift}/operator/divisor.d.ts +0 -0
  146. /package/out/parser/{string/shift → shift}/operator/divisor.js +0 -0
  147. /package/out/parser/{string/shift → shift}/operator/operator.d.ts +0 -0
@@ -1,6 +1,6 @@
1
- import { ArkErrors, intrinsic, rootNode } from "@ark/schema";
1
+ import { ArkErrors, intrinsic, rootSchema } from "@ark/schema";
2
2
  import { number } from "../number/number.js";
3
- import { submodule } from "../utils.js";
3
+ import { arkModule } from "../utils.js";
4
4
  import { integer } from "./integer.js";
5
5
  import { regexStringNode } from "./utils.js";
6
6
  const dayDelimiterMatcher = /^[./-]$/;
@@ -40,14 +40,14 @@ export const tryParseDatePattern = (data, opts) => {
40
40
  return writeFormattedExpected(opts.format);
41
41
  };
42
42
  const isParsableDate = (s) => !Number.isNaN(new Date(s).valueOf());
43
- const parsableDate = rootNode({
43
+ const parsableDate = rootSchema({
44
44
  domain: "string",
45
45
  predicate: {
46
46
  meta: "a parsable date",
47
47
  predicate: isParsableDate
48
48
  }
49
49
  }).assertHasKind("intersection");
50
- const epoch$root = integer.$root.internal
50
+ const epochRoot = integer.root.internal
51
51
  .narrow((s, ctx) => {
52
52
  // we know this is safe since it has already
53
53
  // been validated as an integer string
@@ -63,26 +63,26 @@ const epoch$root = integer.$root.internal
63
63
  description: "an integer string representing a safe Unix timestamp"
64
64
  })
65
65
  .assertHasKind("intersection");
66
- const epoch = submodule({
67
- $root: epoch$root,
68
- parse: rootNode({
69
- in: epoch$root,
66
+ const epoch = arkModule({
67
+ root: epochRoot,
68
+ parse: rootSchema({
69
+ in: epochRoot,
70
70
  morphs: (s) => new Date(s),
71
71
  declaredOut: intrinsic.Date
72
72
  })
73
73
  });
74
- const iso$root = regexStringNode(iso8601Matcher, "an ISO 8601 (YYYY-MM-DDTHH:mm:ss.sssZ) date").internal.assertHasKind("intersection");
75
- const iso = submodule({
76
- $root: iso$root,
77
- parse: rootNode({
78
- in: iso$root,
74
+ const isoRoot = regexStringNode(iso8601Matcher, "an ISO 8601 (YYYY-MM-DDTHH:mm:ss.sssZ) date").internal.assertHasKind("intersection");
75
+ const iso = arkModule({
76
+ root: isoRoot,
77
+ parse: rootSchema({
78
+ in: isoRoot,
79
79
  morphs: (s) => new Date(s),
80
80
  declaredOut: intrinsic.Date
81
81
  })
82
82
  });
83
- export const date = submodule({
84
- $root: parsableDate,
85
- parse: rootNode({
83
+ export const stringDate = arkModule({
84
+ root: parsableDate,
85
+ parse: rootSchema({
86
86
  declaredIn: parsableDate,
87
87
  in: "string",
88
88
  morphs: (s, ctx) => {
@@ -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 digits = constrain<string, Branded<"digits">>;
4
4
  }
@@ -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 email = constrain<string, Branded<"email">>;
4
4
  }
@@ -1,15 +1,16 @@
1
- import type { Submodule } from "../../module.ts";
2
- import type { Branded, constrain, To } from "../ast.ts";
1
+ import type { Module, Submodule } from "../../module.ts";
2
+ import type { Branded, constrain, To } from "../inference.ts";
3
3
  import type { number } from "../number/number.ts";
4
4
  declare namespace string {
5
5
  type integer = constrain<string, Branded<"integer">>;
6
6
  }
7
- export declare const integer: import("../../module.ts").Module<{
8
- $root: object;
9
- parse: object;
10
- }>;
11
- export type integer = Submodule<{
12
- $root: string.integer;
13
- parse: (In: string.integer) => To<number.divisibleBy<1>>;
14
- }>;
7
+ export declare const integer: stringInteger.module;
8
+ export declare namespace stringInteger {
9
+ type module = Module<submodule>;
10
+ type submodule = Submodule<$>;
11
+ type $ = {
12
+ root: string.integer;
13
+ parse: (In: string.integer) => To<number.divisibleBy<1>>;
14
+ };
15
+ }
15
16
  export {};
@@ -1,12 +1,12 @@
1
- import { intrinsic, rootNode } from "@ark/schema";
1
+ import { intrinsic, rootSchema } from "@ark/schema";
2
2
  import { wellFormedIntegerMatcher } 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(wellFormedIntegerMatcher, "a well-formed integer string");
6
- export const integer = submodule({
7
- $root,
8
- parse: rootNode({
9
- in: $root,
5
+ const root = regexStringNode(wellFormedIntegerMatcher, "a well-formed integer string");
6
+ export const integer = arkModule({
7
+ root,
8
+ parse: rootSchema({
9
+ in: root,
10
10
  morphs: (s, ctx) => {
11
11
  const parsed = Number.parseInt(s);
12
12
  return Number.isSafeInteger(parsed) ? parsed : (ctx.error("an integer in the range Number.MIN_SAFE_INTEGER to Number.MAX_SAFE_INTEGER"));
@@ -1,5 +1,5 @@
1
- import type { Submodule } from "../../module.ts";
2
- import type { Branded, constrain } from "../ast.ts";
1
+ import type { Module, Submodule } from "../../module.ts";
2
+ import type { Branded, constrain } from "../inference.ts";
3
3
  declare namespace string {
4
4
  type ip = constrain<string, Branded<"ip">>;
5
5
  namespace ip {
@@ -7,14 +7,14 @@ declare namespace string {
7
7
  type v6 = constrain<string, Branded<"ip.v6">>;
8
8
  }
9
9
  }
10
- export declare const ip: import("../../module.ts").Module<{
11
- $root: unknown;
12
- v4: object;
13
- v6: object;
14
- }>;
15
- export type ip = Submodule<{
16
- $root: string.ip;
17
- v4: string.ip.v4;
18
- v6: string.ip.v6;
19
- }>;
10
+ export declare const ip: ip.module;
11
+ export declare namespace ip {
12
+ type module = Module<submodule>;
13
+ type submodule = Submodule<$>;
14
+ type $ = {
15
+ root: string.ip;
16
+ v4: string.ip.v4;
17
+ v6: string.ip.v6;
18
+ };
19
+ }
20
20
  export {};
@@ -1,6 +1,7 @@
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/isIP.js
4
+ // Adjusted to incorporate unmerged fix in https://github.com/validatorjs/validator.js/pull/2083
4
5
  const ipv4Segment = "(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])";
5
6
  const ipv4Address = `(${ipv4Segment}[.]){3}${ipv4Segment}`;
6
7
  const ipv4Matcher = new RegExp(`^${ipv4Address}$`);
@@ -14,10 +15,9 @@ const ipv6Matcher = new RegExp("^(" +
14
15
  `(?:${ipv6Segment}:){2}(?:(:${ipv6Segment}){0,3}:${ipv4Address}|(:${ipv6Segment}){1,5}|:)|` +
15
16
  `(?:${ipv6Segment}:){1}(?:(:${ipv6Segment}){0,4}:${ipv4Address}|(:${ipv6Segment}){1,6}|:)|` +
16
17
  `(?::((?::${ipv6Segment}){0,5}:${ipv4Address}|(?::${ipv6Segment}){1,7}|:))` +
17
- ")(%[0-9a-zA-Z-.:]{1,})?$");
18
- // Based on https://github.com/validatorjs/validator.js/blob/master/src/lib/isUUID.js
19
- export const ip = submodule({
20
- $root: ["v4 | v6", "@", "an IP address"],
18
+ ")(%[0-9a-zA-Z.]{1,})?$");
19
+ export const ip = arkModule({
20
+ root: ["v4 | v6", "@", "an IP address"],
21
21
  v4: regexStringNode(ipv4Matcher, "an IPv4 address"),
22
22
  v6: regexStringNode(ipv6Matcher, "an IPv6 address")
23
23
  });
@@ -1,14 +1,16 @@
1
- import type { Submodule } from "../../module.ts";
2
- import type { Branded, To, constrain } from "../ast.ts";
1
+ import type { Module, Submodule } from "../../module.ts";
2
+ import type { Branded, To, constrain } from "../inference.ts";
3
3
  declare namespace string {
4
4
  type json = constrain<string, Branded<"json">>;
5
5
  }
6
- export declare const json: import("../../module.ts").Module<{
7
- $root: object;
8
- parse: object;
9
- }>;
10
- export type json = Submodule<{
11
- $root: string.json;
12
- parse: (In: string.json) => To<object>;
13
- }>;
6
+ export declare const writeJsonSyntaxErrorProblem: (error: unknown) => string;
7
+ export declare const json: stringJson.module;
8
+ export declare namespace stringJson {
9
+ type module = Module<submodule>;
10
+ type submodule = Submodule<$>;
11
+ type $ = {
12
+ root: string.json;
13
+ parse: (In: string.json) => To<object>;
14
+ };
15
+ }
14
16
  export {};
@@ -1,25 +1,33 @@
1
- import { intrinsic, rootNode } from "@ark/schema";
2
- import { submodule } from "../utils.js";
1
+ import { intrinsic, rootSchema } from "@ark/schema";
2
+ import { arkModule } from "../utils.js";
3
3
  const jsonStringDescription = "a JSON string";
4
- const isParsableJson = (s) => {
5
- try {
6
- JSON.parse(s);
7
- return true;
8
- }
9
- catch {
10
- return false;
11
- }
4
+ export const writeJsonSyntaxErrorProblem = (error) => {
5
+ if (!(error instanceof SyntaxError))
6
+ throw error;
7
+ return `must be ${jsonStringDescription} (${error})`;
12
8
  };
13
- const $root = rootNode({
9
+ const root = rootSchema({
14
10
  domain: "string",
15
11
  predicate: {
16
12
  meta: jsonStringDescription,
17
- predicate: isParsableJson
13
+ predicate: (s, ctx) => {
14
+ try {
15
+ JSON.parse(s);
16
+ return true;
17
+ }
18
+ catch (e) {
19
+ return ctx.reject({
20
+ code: "predicate",
21
+ expected: jsonStringDescription,
22
+ problem: writeJsonSyntaxErrorProblem(e)
23
+ });
24
+ }
25
+ }
18
26
  }
19
27
  });
20
- export const json = submodule({
21
- $root,
22
- parse: rootNode({
28
+ export const json = arkModule({
29
+ root,
30
+ parse: rootSchema({
23
31
  in: "string",
24
32
  morphs: (s, ctx) => {
25
33
  if (s.length === 0) {
@@ -36,7 +44,7 @@ export const json = submodule({
36
44
  return ctx.error({
37
45
  code: "predicate",
38
46
  expected: jsonStringDescription,
39
- problem: `must be ${jsonStringDescription} (${e})`
47
+ problem: writeJsonSyntaxErrorProblem(e)
40
48
  });
41
49
  }
42
50
  },
@@ -1,14 +1,15 @@
1
- import type { Submodule } from "../../module.ts";
2
- import type { Branded, constrain, To } from "../ast.ts";
1
+ import type { Module, Submodule } from "../../module.ts";
2
+ import type { Branded, constrain, To } from "../inference.ts";
3
3
  declare namespace string {
4
4
  type lowercase = constrain<string, Branded<"lowercase">>;
5
5
  }
6
- export type lower = Submodule<{
7
- $root: (In: string) => To<string.lowercase>;
8
- preformatted: string.lowercase;
9
- }>;
10
- export declare const lower: import("../../module.ts").Module<{
11
- $root: object;
12
- preformatted: object;
13
- }>;
6
+ export declare const lower: lower.module;
7
+ export declare namespace lower {
8
+ type module = Module<submodule>;
9
+ type submodule = Submodule<$>;
10
+ type $ = {
11
+ root: (In: string) => To<string.lowercase>;
12
+ preformatted: string.lowercase;
13
+ };
14
+ }
14
15
  export {};
@@ -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 lowercase letters");
5
- export const lower = submodule({
6
- $root: rootNode({
5
+ export const lower = arkModule({
6
+ root: rootSchema({
7
7
  in: "string",
8
8
  morphs: (s) => s.toLowerCase(),
9
9
  declaredOut: preformatted
@@ -1,5 +1,5 @@
1
- import type { Submodule } from "../../module.ts";
2
- import type { Branded, constrain, To } from "../ast.ts";
1
+ import type { Module, Submodule } from "../../module.ts";
2
+ import type { Branded, constrain, To } from "../inference.ts";
3
3
  declare namespace string {
4
4
  type normalized = normalized.NFC;
5
5
  namespace normalized {
@@ -11,62 +11,78 @@ declare namespace string {
11
11
  }
12
12
  export declare const normalizedForms: readonly ["NFC", "NFD", "NFKC", "NFKD"];
13
13
  export type NormalizedForm = (typeof normalizedForms)[number];
14
- export type NFC = Submodule<{
15
- $root: (In: string) => To<string.normalized.NFC>;
16
- preformatted: string.normalized.NFC;
14
+ export declare const NFC: Module<{
15
+ root: unknown;
16
+ preformatted: unknown;
17
17
  }>;
18
- export declare const NFC: import("../../module.ts").Module<{
19
- $root: object;
20
- preformatted: object;
18
+ export declare const NFD: Module<{
19
+ root: unknown;
20
+ preformatted: unknown;
21
21
  }>;
22
- export type NFD = Submodule<{
23
- $root: (In: string) => To<string.normalized.NFD>;
24
- preformatted: string.normalized.NFD;
22
+ export declare const NFKC: Module<{
23
+ root: unknown;
24
+ preformatted: unknown;
25
25
  }>;
26
- export declare const NFD: import("../../module.ts").Module<{
27
- $root: object;
28
- preformatted: object;
26
+ export declare const NFKD: Module<{
27
+ root: unknown;
28
+ preformatted: unknown;
29
29
  }>;
30
- export type NFKC = Submodule<{
31
- $root: (In: string) => To<string.normalized.NFKC>;
32
- preformatted: string.normalized.NFKC;
33
- }>;
34
- export declare const NFKC: import("../../module.ts").Module<{
35
- $root: object;
36
- preformatted: object;
37
- }>;
38
- export type NFKD = Submodule<{
39
- $root: (In: string) => To<string.normalized.NFKD>;
40
- preformatted: string.normalized.NFKD;
41
- }>;
42
- export declare const NFKD: import("../../module.ts").Module<{
43
- $root: object;
44
- preformatted: object;
45
- }>;
46
- export declare const normalize: import("../../module.ts").Module<{
47
- $root: object;
30
+ export declare const normalize: Module<{
31
+ root: unknown;
48
32
  NFC: Submodule<{
49
- $root: object;
50
- preformatted: object;
33
+ root: unknown;
34
+ preformatted: unknown;
51
35
  }>;
52
36
  NFD: Submodule<{
53
- $root: object;
54
- preformatted: object;
37
+ root: unknown;
38
+ preformatted: unknown;
55
39
  }>;
56
40
  NFKC: Submodule<{
57
- $root: object;
58
- preformatted: object;
41
+ root: unknown;
42
+ preformatted: unknown;
59
43
  }>;
60
44
  NFKD: Submodule<{
61
- $root: object;
62
- preformatted: object;
45
+ root: unknown;
46
+ preformatted: unknown;
63
47
  }>;
64
48
  }>;
65
- export type normalize = Submodule<{
66
- $root: (In: string) => To<string.normalized.NFC>;
67
- NFC: NFC;
68
- NFD: NFD;
69
- NFKC: NFKC;
70
- NFKD: NFKD;
71
- }>;
49
+ export declare namespace normalize {
50
+ type module = Module<submodule>;
51
+ type submodule = Submodule<$>;
52
+ type $ = {
53
+ root: (In: string) => To<string.normalized.NFC>;
54
+ NFC: NFC.submodule;
55
+ NFD: NFD.submodule;
56
+ NFKC: NFKC.submodule;
57
+ NFKD: NFKD.submodule;
58
+ };
59
+ namespace NFC {
60
+ type submodule = Submodule<$>;
61
+ type $ = {
62
+ root: (In: string) => To<string.normalized.NFC>;
63
+ preformatted: string.normalized.NFC;
64
+ };
65
+ }
66
+ namespace NFD {
67
+ type submodule = Submodule<$>;
68
+ type $ = {
69
+ root: (In: string) => To<string.normalized.NFD>;
70
+ preformatted: string.normalized.NFD;
71
+ };
72
+ }
73
+ namespace NFKC {
74
+ type submodule = Submodule<$>;
75
+ type $ = {
76
+ root: (In: string) => To<string.normalized.NFKC>;
77
+ preformatted: string.normalized.NFKC;
78
+ };
79
+ }
80
+ namespace NFKD {
81
+ type submodule = Submodule<$>;
82
+ type $ = {
83
+ root: (In: string) => To<string.normalized.NFKD>;
84
+ preformatted: string.normalized.NFKD;
85
+ };
86
+ }
87
+ }
72
88
  export {};
@@ -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,14 +1,15 @@
1
- import type { Submodule } from "../../module.ts";
2
- import type { Branded, constrain, To } from "../ast.ts";
1
+ import type { Module, Submodule } from "../../module.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
  }
6
- export declare const numeric: import("../../module.ts").Module<{
7
- $root: object;
8
- parse: object;
9
- }>;
10
- export type numeric = Submodule<{
11
- $root: string.numeric;
12
- parse: (In: string.numeric) => To<number>;
13
- }>;
6
+ export declare const numeric: stringNumeric.module;
7
+ export declare namespace stringNumeric {
8
+ type module = Module<submodule>;
9
+ type submodule = Submodule<$>;
10
+ type $ = {
11
+ root: string.numeric;
12
+ parse: (In: string.numeric) => To<number>;
13
+ };
14
+ }
14
15
  export {};
@@ -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
  }