arktype 1.0.15-alpha → 1.0.17-alpha

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 (247) hide show
  1. package/README.md +3 -3
  2. package/dist/cjs/package.json +3 -0
  3. package/dist/cjs/src/main.js +38 -0
  4. package/dist/cjs/src/nodes/branch.js +140 -0
  5. package/dist/cjs/src/nodes/compose.js +157 -0
  6. package/dist/{nodes → cjs/src/nodes}/discriminate.js +92 -100
  7. package/dist/cjs/src/nodes/node.js +139 -0
  8. package/dist/cjs/src/nodes/predicate.js +86 -0
  9. package/dist/cjs/src/nodes/rules/class.js +25 -0
  10. package/dist/cjs/src/nodes/rules/collapsibleSet.js +48 -0
  11. package/dist/cjs/src/nodes/rules/divisor.js +29 -0
  12. package/dist/cjs/src/nodes/rules/props.js +160 -0
  13. package/dist/cjs/src/nodes/rules/range.js +105 -0
  14. package/dist/cjs/src/nodes/rules/regex.js +26 -0
  15. package/dist/cjs/src/nodes/rules/rules.js +123 -0
  16. package/dist/cjs/src/parse/ast/ast.js +4 -0
  17. package/dist/cjs/src/parse/ast/bound.js +16 -0
  18. package/dist/cjs/src/parse/ast/config.js +13 -0
  19. package/dist/cjs/src/parse/ast/distributableFunction.js +48 -0
  20. package/dist/cjs/src/parse/ast/divisor.js +9 -0
  21. package/dist/cjs/src/parse/ast/intersection.js +30 -0
  22. package/dist/cjs/src/parse/ast/keyof.js +111 -0
  23. package/dist/cjs/src/parse/ast/morph.js +58 -0
  24. package/dist/cjs/src/parse/ast/narrow.js +22 -0
  25. package/dist/cjs/src/parse/ast/node.js +4 -0
  26. package/dist/cjs/src/parse/ast/tuple.js +94 -0
  27. package/dist/cjs/src/parse/ast/union.js +9 -0
  28. package/dist/cjs/src/parse/ast/utils.js +4 -0
  29. package/dist/cjs/src/parse/definition.js +61 -0
  30. package/dist/cjs/src/parse/record.js +37 -0
  31. package/dist/cjs/src/parse/string/reduce/dynamic.js +167 -0
  32. package/dist/cjs/src/parse/string/reduce/shared.js +23 -0
  33. package/dist/cjs/src/parse/string/reduce/static.js +4 -0
  34. package/dist/cjs/src/parse/string/shift/operand/enclosed.js +54 -0
  35. package/dist/cjs/src/parse/string/shift/operand/operand.js +11 -0
  36. package/dist/cjs/src/parse/string/shift/operand/unenclosed.js +53 -0
  37. package/dist/cjs/src/parse/string/shift/operator/bounds.js +87 -0
  38. package/dist/cjs/src/parse/string/shift/operator/divisor.js +35 -0
  39. package/dist/cjs/src/parse/string/shift/operator/operator.js +26 -0
  40. package/dist/cjs/src/parse/string/shift/scanner.js +114 -0
  41. package/dist/cjs/src/parse/string/string.js +43 -0
  42. package/dist/cjs/src/scopes/ark.js +45 -0
  43. package/dist/cjs/src/scopes/cache.js +52 -0
  44. package/dist/cjs/src/scopes/expressions.js +29 -0
  45. package/dist/cjs/src/scopes/jsObjects.js +93 -0
  46. package/dist/cjs/src/scopes/scope.js +323 -0
  47. package/dist/cjs/src/scopes/tsKeywords.js +113 -0
  48. package/dist/cjs/src/scopes/type.js +50 -0
  49. package/dist/cjs/src/scopes/validation/creditCard.js +47 -0
  50. package/dist/cjs/src/scopes/validation/date.js +62 -0
  51. package/dist/cjs/src/scopes/validation/validation.js +108 -0
  52. package/dist/cjs/src/traverse/problems.js +281 -0
  53. package/dist/cjs/src/traverse/traverse.js +390 -0
  54. package/dist/cjs/src/utils/chainableNoOpProxy.js +23 -0
  55. package/dist/cjs/src/utils/data.js +53 -0
  56. package/dist/cjs/src/utils/domains.js +30 -0
  57. package/dist/cjs/src/utils/errors.js +26 -0
  58. package/dist/cjs/src/utils/freeze.js +15 -0
  59. package/dist/cjs/src/utils/generics.js +63 -0
  60. package/dist/cjs/src/utils/numericLiterals.js +75 -0
  61. package/dist/cjs/src/utils/objectKinds.js +69 -0
  62. package/dist/cjs/src/utils/paths.js +32 -0
  63. package/dist/cjs/src/utils/serialize.js +74 -0
  64. package/dist/cjs/src/utils/unionToTuple.js +4 -0
  65. package/dist/mjs/package.json +3 -0
  66. package/dist/mjs/src/main.js +8 -0
  67. package/dist/mjs/src/nodes/branch.js +123 -0
  68. package/dist/mjs/src/nodes/compose.js +135 -0
  69. package/dist/mjs/src/nodes/discriminate.js +247 -0
  70. package/dist/mjs/src/nodes/node.js +117 -0
  71. package/dist/mjs/src/nodes/predicate.js +69 -0
  72. package/dist/mjs/src/nodes/rules/class.js +11 -0
  73. package/dist/mjs/src/nodes/rules/collapsibleSet.js +34 -0
  74. package/dist/mjs/src/nodes/rules/divisor.js +15 -0
  75. package/dist/mjs/src/nodes/rules/props.js +142 -0
  76. package/dist/mjs/src/nodes/rules/range.js +86 -0
  77. package/dist/mjs/src/nodes/rules/regex.js +11 -0
  78. package/dist/mjs/src/nodes/rules/rules.js +106 -0
  79. package/dist/mjs/src/parse/ast/ast.js +1 -0
  80. package/dist/mjs/src/parse/ast/bound.js +2 -0
  81. package/dist/mjs/src/parse/ast/config.js +9 -0
  82. package/dist/mjs/src/parse/ast/distributableFunction.js +34 -0
  83. package/dist/mjs/src/parse/ast/divisor.js +1 -0
  84. package/dist/mjs/src/parse/ast/intersection.js +16 -0
  85. package/dist/mjs/src/parse/ast/keyof.js +103 -0
  86. package/dist/mjs/src/parse/ast/morph.js +44 -0
  87. package/dist/mjs/src/parse/ast/narrow.js +14 -0
  88. package/dist/mjs/src/parse/ast/node.js +1 -0
  89. package/dist/mjs/src/parse/ast/tuple.js +80 -0
  90. package/dist/mjs/src/parse/ast/union.js +1 -0
  91. package/dist/mjs/src/parse/ast/utils.js +1 -0
  92. package/dist/mjs/src/parse/definition.js +46 -0
  93. package/dist/mjs/src/parse/record.js +29 -0
  94. package/dist/mjs/src/parse/string/reduce/dynamic.js +159 -0
  95. package/dist/mjs/src/parse/string/reduce/shared.js +6 -0
  96. package/dist/mjs/src/parse/string/reduce/static.js +1 -0
  97. package/dist/mjs/src/parse/string/shift/operand/enclosed.js +39 -0
  98. package/dist/mjs/src/parse/string/shift/operand/operand.js +3 -0
  99. package/dist/mjs/src/parse/string/shift/operand/unenclosed.js +36 -0
  100. package/dist/mjs/src/parse/string/shift/operator/bounds.js +70 -0
  101. package/dist/mjs/src/parse/string/shift/operator/divisor.js +21 -0
  102. package/dist/mjs/src/parse/string/shift/operator/operator.js +13 -0
  103. package/dist/mjs/src/parse/string/shift/scanner.js +106 -0
  104. package/dist/mjs/src/parse/string/string.js +28 -0
  105. package/dist/mjs/src/scopes/ark.js +28 -0
  106. package/dist/mjs/src/scopes/cache.js +38 -0
  107. package/dist/{scopes → mjs/src/scopes}/expressions.js +9 -20
  108. package/dist/mjs/src/scopes/jsObjects.js +82 -0
  109. package/dist/mjs/src/scopes/scope.js +303 -0
  110. package/dist/mjs/src/scopes/tsKeywords.js +116 -0
  111. package/dist/mjs/src/scopes/type.js +35 -0
  112. package/dist/{scopes → mjs/src/scopes}/validation/creditCard.js +11 -15
  113. package/dist/{scopes → mjs/src/scopes}/validation/date.js +16 -21
  114. package/dist/mjs/src/scopes/validation/validation.js +112 -0
  115. package/dist/mjs/src/traverse/problems.js +260 -0
  116. package/dist/mjs/src/traverse/traverse.js +373 -0
  117. package/dist/{utils → mjs/src/utils}/chainableNoOpProxy.js +2 -6
  118. package/dist/mjs/src/utils/data.js +38 -0
  119. package/dist/mjs/src/utils/domains.js +15 -0
  120. package/dist/mjs/src/utils/errors.js +10 -0
  121. package/dist/mjs/src/utils/freeze.js +7 -0
  122. package/dist/mjs/src/utils/generics.js +38 -0
  123. package/dist/mjs/src/utils/numericLiterals.js +72 -0
  124. package/dist/mjs/src/utils/objectKinds.js +55 -0
  125. package/dist/{utils → mjs/src/utils}/paths.js +3 -8
  126. package/dist/mjs/src/utils/serialize.js +58 -0
  127. package/dist/mjs/src/utils/unionToTuple.js +1 -0
  128. package/dist/tsconfig.temp.tsbuildinfo +1 -1
  129. package/dist/{utils → types/utils}/generics.d.ts +2 -2
  130. package/package.json +14 -5
  131. package/dist/main.js +0 -29
  132. package/dist/nodes/branch.js +0 -135
  133. package/dist/nodes/compose.js +0 -99
  134. package/dist/nodes/node.js +0 -134
  135. package/dist/nodes/predicate.js +0 -88
  136. package/dist/nodes/rules/class.js +0 -23
  137. package/dist/nodes/rules/collapsibleSet.js +0 -34
  138. package/dist/nodes/rules/divisor.js +0 -19
  139. package/dist/nodes/rules/props.js +0 -130
  140. package/dist/nodes/rules/range.js +0 -108
  141. package/dist/nodes/rules/regex.js +0 -17
  142. package/dist/nodes/rules/rules.js +0 -102
  143. package/dist/parse/ast/ast.js +0 -2
  144. package/dist/parse/ast/bound.js +0 -7
  145. package/dist/parse/ast/config.js +0 -14
  146. package/dist/parse/ast/distributableFunction.js +0 -40
  147. package/dist/parse/ast/divisor.js +0 -5
  148. package/dist/parse/ast/intersection.js +0 -21
  149. package/dist/parse/ast/keyof.js +0 -107
  150. package/dist/parse/ast/morph.js +0 -50
  151. package/dist/parse/ast/narrow.js +0 -17
  152. package/dist/parse/ast/node.js +0 -2
  153. package/dist/parse/ast/tuple.js +0 -72
  154. package/dist/parse/ast/union.js +0 -5
  155. package/dist/parse/ast/utils.js +0 -2
  156. package/dist/parse/definition.js +0 -47
  157. package/dist/parse/record.js +0 -31
  158. package/dist/parse/string/reduce/dynamic.js +0 -159
  159. package/dist/parse/string/reduce/shared.js +0 -13
  160. package/dist/parse/string/reduce/static.js +0 -2
  161. package/dist/parse/string/shift/operand/enclosed.js +0 -37
  162. package/dist/parse/string/shift/operand/operand.js +0 -15
  163. package/dist/parse/string/shift/operand/unenclosed.js +0 -45
  164. package/dist/parse/string/shift/operator/bounds.js +0 -83
  165. package/dist/parse/string/shift/operator/divisor.js +0 -23
  166. package/dist/parse/string/shift/operator/operator.js +0 -34
  167. package/dist/parse/string/shift/scanner.js +0 -97
  168. package/dist/parse/string/string.js +0 -35
  169. package/dist/scopes/ark.js +0 -27
  170. package/dist/scopes/cache.js +0 -28
  171. package/dist/scopes/jsObjects.js +0 -20
  172. package/dist/scopes/scope.js +0 -184
  173. package/dist/scopes/tsKeywords.js +0 -49
  174. package/dist/scopes/type.js +0 -40
  175. package/dist/scopes/validation/validation.js +0 -74
  176. package/dist/traverse/problems.js +0 -234
  177. package/dist/traverse/traverse.js +0 -330
  178. package/dist/utils/data.js +0 -39
  179. package/dist/utils/domains.js +0 -27
  180. package/dist/utils/errors.js +0 -17
  181. package/dist/utils/freeze.js +0 -16
  182. package/dist/utils/generics.js +0 -53
  183. package/dist/utils/numericLiterals.js +0 -88
  184. package/dist/utils/objectKinds.js +0 -69
  185. package/dist/utils/serialize.js +0 -71
  186. package/dist/utils/unionToTuple.js +0 -2
  187. /package/dist/{main.d.ts → types/main.d.ts} +0 -0
  188. /package/dist/{nodes → types/nodes}/branch.d.ts +0 -0
  189. /package/dist/{nodes → types/nodes}/compose.d.ts +0 -0
  190. /package/dist/{nodes → types/nodes}/discriminate.d.ts +0 -0
  191. /package/dist/{nodes → types/nodes}/node.d.ts +0 -0
  192. /package/dist/{nodes → types/nodes}/predicate.d.ts +0 -0
  193. /package/dist/{nodes → types/nodes}/rules/class.d.ts +0 -0
  194. /package/dist/{nodes → types/nodes}/rules/collapsibleSet.d.ts +0 -0
  195. /package/dist/{nodes → types/nodes}/rules/divisor.d.ts +0 -0
  196. /package/dist/{nodes → types/nodes}/rules/props.d.ts +0 -0
  197. /package/dist/{nodes → types/nodes}/rules/range.d.ts +0 -0
  198. /package/dist/{nodes → types/nodes}/rules/regex.d.ts +0 -0
  199. /package/dist/{nodes → types/nodes}/rules/rules.d.ts +0 -0
  200. /package/dist/{parse → types/parse}/ast/ast.d.ts +0 -0
  201. /package/dist/{parse → types/parse}/ast/bound.d.ts +0 -0
  202. /package/dist/{parse → types/parse}/ast/config.d.ts +0 -0
  203. /package/dist/{parse → types/parse}/ast/distributableFunction.d.ts +0 -0
  204. /package/dist/{parse → types/parse}/ast/divisor.d.ts +0 -0
  205. /package/dist/{parse → types/parse}/ast/intersection.d.ts +0 -0
  206. /package/dist/{parse → types/parse}/ast/keyof.d.ts +0 -0
  207. /package/dist/{parse → types/parse}/ast/morph.d.ts +0 -0
  208. /package/dist/{parse → types/parse}/ast/narrow.d.ts +0 -0
  209. /package/dist/{parse → types/parse}/ast/node.d.ts +0 -0
  210. /package/dist/{parse → types/parse}/ast/tuple.d.ts +0 -0
  211. /package/dist/{parse → types/parse}/ast/union.d.ts +0 -0
  212. /package/dist/{parse → types/parse}/ast/utils.d.ts +0 -0
  213. /package/dist/{parse → types/parse}/definition.d.ts +0 -0
  214. /package/dist/{parse → types/parse}/record.d.ts +0 -0
  215. /package/dist/{parse → types/parse}/string/reduce/dynamic.d.ts +0 -0
  216. /package/dist/{parse → types/parse}/string/reduce/shared.d.ts +0 -0
  217. /package/dist/{parse → types/parse}/string/reduce/static.d.ts +0 -0
  218. /package/dist/{parse → types/parse}/string/shift/operand/enclosed.d.ts +0 -0
  219. /package/dist/{parse → types/parse}/string/shift/operand/operand.d.ts +0 -0
  220. /package/dist/{parse → types/parse}/string/shift/operand/unenclosed.d.ts +0 -0
  221. /package/dist/{parse → types/parse}/string/shift/operator/bounds.d.ts +0 -0
  222. /package/dist/{parse → types/parse}/string/shift/operator/divisor.d.ts +0 -0
  223. /package/dist/{parse → types/parse}/string/shift/operator/operator.d.ts +0 -0
  224. /package/dist/{parse → types/parse}/string/shift/scanner.d.ts +0 -0
  225. /package/dist/{parse → types/parse}/string/string.d.ts +0 -0
  226. /package/dist/{scopes → types/scopes}/ark.d.ts +0 -0
  227. /package/dist/{scopes → types/scopes}/cache.d.ts +0 -0
  228. /package/dist/{scopes → types/scopes}/expressions.d.ts +0 -0
  229. /package/dist/{scopes → types/scopes}/jsObjects.d.ts +0 -0
  230. /package/dist/{scopes → types/scopes}/scope.d.ts +0 -0
  231. /package/dist/{scopes → types/scopes}/tsKeywords.d.ts +0 -0
  232. /package/dist/{scopes → types/scopes}/type.d.ts +0 -0
  233. /package/dist/{scopes → types/scopes}/validation/creditCard.d.ts +0 -0
  234. /package/dist/{scopes → types/scopes}/validation/date.d.ts +0 -0
  235. /package/dist/{scopes → types/scopes}/validation/validation.d.ts +0 -0
  236. /package/dist/{traverse → types/traverse}/problems.d.ts +0 -0
  237. /package/dist/{traverse → types/traverse}/traverse.d.ts +0 -0
  238. /package/dist/{utils → types/utils}/chainableNoOpProxy.d.ts +0 -0
  239. /package/dist/{utils → types/utils}/data.d.ts +0 -0
  240. /package/dist/{utils → types/utils}/domains.d.ts +0 -0
  241. /package/dist/{utils → types/utils}/errors.d.ts +0 -0
  242. /package/dist/{utils → types/utils}/freeze.d.ts +0 -0
  243. /package/dist/{utils → types/utils}/numericLiterals.d.ts +0 -0
  244. /package/dist/{utils → types/utils}/objectKinds.d.ts +0 -0
  245. /package/dist/{utils → types/utils}/paths.d.ts +0 -0
  246. /package/dist/{utils → types/utils}/serialize.d.ts +0 -0
  247. /package/dist/{utils → types/utils}/unionToTuple.d.ts +0 -0
@@ -1,71 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.deserializePrimitive = exports.serializePrimitive = exports.stringify = exports.snapshot = void 0;
4
- const domains_js_1 = require("./domains.js");
5
- const generics_js_1 = require("./generics.js");
6
- const numericLiterals_js_1 = require("./numericLiterals.js");
7
- const snapshot = (data, opts = {}) => serializeRecurse(data, opts, []);
8
- exports.snapshot = snapshot;
9
- const stringify = (data, indent) => {
10
- switch ((0, domains_js_1.domainOf)(data)) {
11
- case "object":
12
- return JSON.stringify(serializeRecurse(data, stringifyOpts, []), null, indent);
13
- case "symbol":
14
- return stringifyOpts.onSymbol(data);
15
- default:
16
- return (0, exports.serializePrimitive)(data);
17
- }
18
- };
19
- exports.stringify = stringify;
20
- const stringifyOpts = {
21
- onCycle: () => "(cycle)",
22
- onSymbol: (v) => `(symbol${v.description && ` ${v.description}`})`,
23
- onFunction: (v) => `(function${v.name && ` ${v.name}`})`
24
- };
25
- const serializeRecurse = (data, context, seen) => {
26
- switch ((0, domains_js_1.domainOf)(data)) {
27
- case "object":
28
- if (typeof data === "function") {
29
- return stringifyOpts.onFunction(data);
30
- }
31
- if (seen.includes(data)) {
32
- return "(cycle)";
33
- }
34
- const nextSeen = [...seen, data];
35
- if (Array.isArray(data)) {
36
- return data.map((item) => serializeRecurse(item, context, nextSeen));
37
- }
38
- const result = {};
39
- for (const k in data) {
40
- result[k] = serializeRecurse(data[k], context, nextSeen);
41
- }
42
- return result;
43
- case "symbol":
44
- return stringifyOpts.onSymbol(data);
45
- case "bigint":
46
- return `${data}n`;
47
- case "undefined":
48
- return "undefined";
49
- default:
50
- return data;
51
- }
52
- };
53
- const serializePrimitive = (value) => (typeof value === "string"
54
- ? `'${value}'`
55
- : typeof value === "bigint"
56
- ? `${value}n`
57
- : `${value}`);
58
- exports.serializePrimitive = serializePrimitive;
59
- const deserializePrimitive = (serialized) => ((0, generics_js_1.isKeyOf)(serialized, serializedKeywords)
60
- ? serializedKeywords[serialized]
61
- : serialized[0] === "'"
62
- ? serialized.slice(1, -1)
63
- : (0, numericLiterals_js_1.tryParseWellFormedBigint)(serialized) ??
64
- (0, numericLiterals_js_1.tryParseWellFormedNumber)(serialized, true));
65
- exports.deserializePrimitive = deserializePrimitive;
66
- const serializedKeywords = {
67
- true: true,
68
- false: false,
69
- undefined,
70
- null: null
71
- };
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes