arktype 1.0.28-alpha → 1.1.0-dev-2

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 (364) hide show
  1. package/dist/main.d.ts +11 -0
  2. package/dist/main.d.ts.map +1 -0
  3. package/dist/main.js +8 -0
  4. package/dist/main.js.map +1 -0
  5. package/dist/match.d.ts +46 -0
  6. package/dist/match.d.ts.map +1 -0
  7. package/dist/match.js +23 -0
  8. package/dist/match.js.map +1 -0
  9. package/dist/parser/definition.d.ts +32 -0
  10. package/dist/parser/definition.d.ts.map +1 -0
  11. package/dist/parser/definition.js +29 -0
  12. package/dist/parser/definition.js.map +1 -0
  13. package/dist/parser/generic.d.ts +44 -0
  14. package/dist/parser/generic.d.ts.map +1 -0
  15. package/dist/parser/generic.js +46 -0
  16. package/dist/parser/generic.js.map +1 -0
  17. package/dist/parser/objectLiteral.d.ts +24 -0
  18. package/dist/parser/objectLiteral.d.ts.map +1 -0
  19. package/dist/parser/objectLiteral.js +38 -0
  20. package/dist/parser/objectLiteral.js.map +1 -0
  21. package/dist/parser/semantic/bounds.d.ts +13 -0
  22. package/dist/parser/semantic/bounds.d.ts.map +1 -0
  23. package/dist/parser/semantic/bounds.js +2 -0
  24. package/dist/parser/semantic/bounds.js.map +1 -0
  25. package/dist/parser/semantic/divisor.d.ts +9 -0
  26. package/dist/parser/semantic/divisor.d.ts.map +1 -0
  27. package/dist/parser/semantic/divisor.js +2 -0
  28. package/dist/parser/semantic/divisor.js.map +1 -0
  29. package/dist/parser/semantic/intersections.d.ts +15 -0
  30. package/dist/parser/semantic/intersections.d.ts.map +1 -0
  31. package/dist/parser/semantic/intersections.js +2 -0
  32. package/dist/parser/semantic/intersections.js.map +1 -0
  33. package/dist/parser/semantic/semantic.d.ts +22 -0
  34. package/dist/parser/semantic/semantic.d.ts.map +1 -0
  35. package/dist/parser/semantic/semantic.js +2 -0
  36. package/dist/parser/semantic/semantic.js.map +1 -0
  37. package/dist/parser/semantic/utils.d.ts +8 -0
  38. package/dist/parser/semantic/utils.d.ts.map +1 -0
  39. package/dist/parser/semantic/utils.js +2 -0
  40. package/dist/parser/semantic/utils.js.map +1 -0
  41. package/dist/parser/semantic/validate.d.ts +24 -0
  42. package/dist/parser/semantic/validate.d.ts.map +1 -0
  43. package/dist/parser/semantic/validate.js +2 -0
  44. package/dist/parser/semantic/validate.js.map +1 -0
  45. package/dist/parser/shared.d.ts +48 -0
  46. package/dist/parser/shared.d.ts.map +1 -0
  47. package/dist/parser/shared.js +41 -0
  48. package/dist/parser/shared.js.map +1 -0
  49. package/dist/parser/string/reduce/dynamic.d.ts +40 -0
  50. package/dist/parser/string/reduce/dynamic.d.ts.map +1 -0
  51. package/dist/parser/string/reduce/dynamic.js +122 -0
  52. package/dist/parser/string/reduce/dynamic.js.map +1 -0
  53. package/dist/parser/string/reduce/shared.d.ts +29 -0
  54. package/dist/parser/string/reduce/shared.d.ts.map +1 -0
  55. package/dist/parser/string/reduce/shared.js +7 -0
  56. package/dist/parser/string/reduce/shared.js.map +1 -0
  57. package/dist/parser/string/reduce/static.d.ts +177 -0
  58. package/dist/parser/string/reduce/static.d.ts.map +1 -0
  59. package/dist/parser/string/reduce/static.js +2 -0
  60. package/dist/parser/string/reduce/static.js.map +1 -0
  61. package/dist/parser/string/shift/operand/date.d.ts +11 -0
  62. package/dist/parser/string/shift/operand/date.d.ts.map +1 -0
  63. package/dist/parser/string/shift/operand/date.js +26 -0
  64. package/dist/parser/string/shift/operand/date.js.map +1 -0
  65. package/dist/parser/string/shift/operand/enclosed.d.ts +49 -0
  66. package/dist/parser/string/shift/operand/enclosed.d.ts.map +1 -0
  67. package/dist/parser/string/shift/operand/enclosed.js +50 -0
  68. package/dist/parser/string/shift/operand/enclosed.js.map +1 -0
  69. package/dist/parser/string/shift/operand/operand.d.ts +9 -0
  70. package/dist/parser/string/shift/operand/operand.d.ts.map +1 -0
  71. package/dist/parser/string/shift/operand/operand.js +17 -0
  72. package/dist/parser/string/shift/operand/operand.js.map +1 -0
  73. package/dist/parser/string/shift/operand/unenclosed.d.ts +36 -0
  74. package/dist/parser/string/shift/operand/unenclosed.d.ts.map +1 -0
  75. package/dist/parser/string/shift/operand/unenclosed.js +68 -0
  76. package/dist/parser/string/shift/operand/unenclosed.js.map +1 -0
  77. package/dist/parser/string/shift/operator/bounds.d.ts +55 -0
  78. package/dist/parser/string/shift/operator/bounds.d.ts.map +1 -0
  79. package/dist/parser/string/shift/operator/bounds.js +95 -0
  80. package/dist/parser/string/shift/operator/bounds.js.map +1 -0
  81. package/dist/parser/string/shift/operator/divisor.d.ts +9 -0
  82. package/dist/parser/string/shift/operator/divisor.d.ts.map +1 -0
  83. package/dist/parser/string/shift/operator/divisor.js +13 -0
  84. package/dist/parser/string/shift/operator/divisor.js.map +1 -0
  85. package/dist/parser/string/shift/operator/operator.d.ts +13 -0
  86. package/dist/parser/string/shift/operator/operator.d.ts.map +1 -0
  87. package/dist/parser/string/shift/operator/operator.js +29 -0
  88. package/dist/parser/string/shift/operator/operator.js.map +1 -0
  89. package/dist/parser/string/shift/scanner.d.ts +71 -0
  90. package/dist/parser/string/shift/scanner.d.ts.map +1 -0
  91. package/dist/parser/string/shift/scanner.js +99 -0
  92. package/dist/parser/string/shift/scanner.js.map +1 -0
  93. package/dist/parser/string/string.d.ts +26 -0
  94. package/dist/parser/string/string.d.ts.map +1 -0
  95. package/dist/parser/string/string.js +31 -0
  96. package/dist/parser/string/string.js.map +1 -0
  97. package/dist/parser/tuple.d.ts +73 -0
  98. package/dist/parser/tuple.d.ts.map +1 -0
  99. package/dist/parser/tuple.js +134 -0
  100. package/dist/parser/tuple.js.map +1 -0
  101. package/dist/scope.d.ts +159 -0
  102. package/dist/scope.d.ts.map +1 -0
  103. package/dist/scope.js +248 -0
  104. package/dist/scope.js.map +1 -0
  105. package/dist/scopes/ark.d.ts +38 -0
  106. package/dist/scopes/ark.d.ts.map +1 -0
  107. package/dist/scopes/ark.js +24 -0
  108. package/dist/scopes/ark.js.map +1 -0
  109. package/dist/scopes/jsObjects.d.ts +19 -0
  110. package/dist/scopes/jsObjects.d.ts.map +1 -0
  111. package/dist/scopes/jsObjects.js +15 -0
  112. package/dist/scopes/jsObjects.js.map +1 -0
  113. package/dist/scopes/parsing.d.ts +18 -0
  114. package/dist/scopes/parsing.d.ts.map +1 -0
  115. package/dist/scopes/parsing.js +61 -0
  116. package/dist/scopes/parsing.js.map +1 -0
  117. package/dist/scopes/tsGenerics.d.ts +17 -0
  118. package/dist/scopes/tsGenerics.d.ts.map +1 -0
  119. package/dist/scopes/tsGenerics.js +13 -0
  120. package/dist/scopes/tsGenerics.js.map +1 -0
  121. package/dist/scopes/tsKeywords.d.ts +24 -0
  122. package/dist/scopes/tsKeywords.d.ts.map +1 -0
  123. package/dist/scopes/tsKeywords.js +20 -0
  124. package/dist/scopes/tsKeywords.js.map +1 -0
  125. package/dist/scopes/utils/creditCard.d.ts +3 -0
  126. package/dist/scopes/utils/creditCard.d.ts.map +1 -0
  127. package/dist/{mjs/scopes/validation → scopes/utils}/creditCard.js +14 -12
  128. package/dist/scopes/utils/creditCard.js.map +1 -0
  129. package/dist/{types/scopes/validation → scopes/utils}/date.d.ts +3 -2
  130. package/dist/scopes/utils/date.d.ts.map +1 -0
  131. package/dist/{mjs/scopes/validation → scopes/utils}/date.js +24 -19
  132. package/dist/scopes/utils/date.js.map +1 -0
  133. package/dist/scopes/validation.d.ts +20 -0
  134. package/dist/scopes/validation.d.ts.map +1 -0
  135. package/dist/scopes/validation.js +57 -0
  136. package/dist/scopes/validation.js.map +1 -0
  137. package/dist/type.d.ts +101 -0
  138. package/dist/type.d.ts.map +1 -0
  139. package/dist/type.js +138 -0
  140. package/dist/type.js.map +1 -0
  141. package/main.ts +20 -0
  142. package/match.ts +137 -0
  143. package/package.json +41 -108
  144. package/parser/definition.ts +156 -0
  145. package/parser/generic.ts +208 -0
  146. package/parser/objectLiteral.ts +120 -0
  147. package/parser/semantic/bounds.ts +63 -0
  148. package/parser/semantic/divisor.ts +13 -0
  149. package/parser/semantic/intersections.ts +47 -0
  150. package/parser/semantic/semantic.ts +107 -0
  151. package/parser/semantic/utils.ts +26 -0
  152. package/parser/semantic/validate.ts +105 -0
  153. package/parser/shared.ts +141 -0
  154. package/parser/string/reduce/dynamic.ts +181 -0
  155. package/parser/string/reduce/shared.ts +73 -0
  156. package/parser/string/reduce/static.ts +300 -0
  157. package/parser/string/shift/operand/date.ts +57 -0
  158. package/parser/string/shift/operand/enclosed.ts +119 -0
  159. package/parser/string/shift/operand/operand.ts +48 -0
  160. package/parser/string/shift/operand/unenclosed.ts +282 -0
  161. package/parser/string/shift/operator/bounds.ts +229 -0
  162. package/parser/string/shift/operator/divisor.ts +36 -0
  163. package/parser/string/shift/operator/operator.ts +82 -0
  164. package/parser/string/shift/scanner.ts +209 -0
  165. package/parser/string/string.ts +93 -0
  166. package/parser/tuple.ts +475 -0
  167. package/scope.ts +573 -0
  168. package/scopes/ark.ts +64 -0
  169. package/scopes/jsObjects.ts +29 -0
  170. package/scopes/parsing.ts +81 -0
  171. package/scopes/tsGenerics.ts +28 -0
  172. package/scopes/tsKeywords.ts +39 -0
  173. package/scopes/utils/creditCard.ts +37 -0
  174. package/scopes/utils/date.ts +108 -0
  175. package/scopes/validation.ts +81 -0
  176. package/type.ts +403 -0
  177. package/LICENSE +0 -7
  178. package/README.md +0 -351
  179. package/dist/cjs/main.js +0 -38
  180. package/dist/cjs/nodes/branch.js +0 -140
  181. package/dist/cjs/nodes/compose.js +0 -163
  182. package/dist/cjs/nodes/discriminate.js +0 -265
  183. package/dist/cjs/nodes/node.js +0 -139
  184. package/dist/cjs/nodes/predicate.js +0 -86
  185. package/dist/cjs/nodes/rules/class.js +0 -25
  186. package/dist/cjs/nodes/rules/collapsibleSet.js +0 -48
  187. package/dist/cjs/nodes/rules/divisor.js +0 -29
  188. package/dist/cjs/nodes/rules/props.js +0 -167
  189. package/dist/cjs/nodes/rules/range.js +0 -105
  190. package/dist/cjs/nodes/rules/regex.js +0 -26
  191. package/dist/cjs/nodes/rules/rules.js +0 -123
  192. package/dist/cjs/package.json +0 -3
  193. package/dist/cjs/parse/ast/ast.js +0 -4
  194. package/dist/cjs/parse/ast/bound.js +0 -16
  195. package/dist/cjs/parse/ast/config.js +0 -13
  196. package/dist/cjs/parse/ast/distributableFunction.js +0 -48
  197. package/dist/cjs/parse/ast/divisor.js +0 -9
  198. package/dist/cjs/parse/ast/intersection.js +0 -30
  199. package/dist/cjs/parse/ast/keyof.js +0 -111
  200. package/dist/cjs/parse/ast/morph.js +0 -58
  201. package/dist/cjs/parse/ast/narrow.js +0 -22
  202. package/dist/cjs/parse/ast/node.js +0 -4
  203. package/dist/cjs/parse/ast/tuple.js +0 -94
  204. package/dist/cjs/parse/ast/union.js +0 -9
  205. package/dist/cjs/parse/ast/utils.js +0 -4
  206. package/dist/cjs/parse/definition.js +0 -61
  207. package/dist/cjs/parse/record.js +0 -37
  208. package/dist/cjs/parse/string/reduce/dynamic.js +0 -167
  209. package/dist/cjs/parse/string/reduce/shared.js +0 -23
  210. package/dist/cjs/parse/string/reduce/static.js +0 -4
  211. package/dist/cjs/parse/string/shift/operand/enclosed.js +0 -54
  212. package/dist/cjs/parse/string/shift/operand/operand.js +0 -11
  213. package/dist/cjs/parse/string/shift/operand/unenclosed.js +0 -53
  214. package/dist/cjs/parse/string/shift/operator/bounds.js +0 -87
  215. package/dist/cjs/parse/string/shift/operator/divisor.js +0 -35
  216. package/dist/cjs/parse/string/shift/operator/operator.js +0 -26
  217. package/dist/cjs/parse/string/shift/scanner.js +0 -114
  218. package/dist/cjs/parse/string/string.js +0 -43
  219. package/dist/cjs/scopes/ark.js +0 -45
  220. package/dist/cjs/scopes/cache.js +0 -52
  221. package/dist/cjs/scopes/expressions.js +0 -29
  222. package/dist/cjs/scopes/jsObjects.js +0 -93
  223. package/dist/cjs/scopes/scope.js +0 -323
  224. package/dist/cjs/scopes/tsKeywords.js +0 -113
  225. package/dist/cjs/scopes/type.js +0 -50
  226. package/dist/cjs/scopes/validation/creditCard.js +0 -47
  227. package/dist/cjs/scopes/validation/date.js +0 -62
  228. package/dist/cjs/scopes/validation/validation.js +0 -108
  229. package/dist/cjs/traverse/problems.js +0 -281
  230. package/dist/cjs/traverse/traverse.js +0 -390
  231. package/dist/cjs/utils/chainableNoOpProxy.js +0 -23
  232. package/dist/cjs/utils/data.js +0 -53
  233. package/dist/cjs/utils/domains.js +0 -30
  234. package/dist/cjs/utils/errors.js +0 -26
  235. package/dist/cjs/utils/freeze.js +0 -15
  236. package/dist/cjs/utils/generics.js +0 -63
  237. package/dist/cjs/utils/numericLiterals.js +0 -75
  238. package/dist/cjs/utils/objectKinds.js +0 -69
  239. package/dist/cjs/utils/paths.js +0 -32
  240. package/dist/cjs/utils/serialize.js +0 -74
  241. package/dist/cjs/utils/unionToTuple.js +0 -4
  242. package/dist/mjs/main.js +0 -8
  243. package/dist/mjs/nodes/branch.js +0 -123
  244. package/dist/mjs/nodes/compose.js +0 -141
  245. package/dist/mjs/nodes/discriminate.js +0 -250
  246. package/dist/mjs/nodes/node.js +0 -117
  247. package/dist/mjs/nodes/predicate.js +0 -69
  248. package/dist/mjs/nodes/rules/class.js +0 -11
  249. package/dist/mjs/nodes/rules/collapsibleSet.js +0 -34
  250. package/dist/mjs/nodes/rules/divisor.js +0 -15
  251. package/dist/mjs/nodes/rules/props.js +0 -149
  252. package/dist/mjs/nodes/rules/range.js +0 -86
  253. package/dist/mjs/nodes/rules/regex.js +0 -11
  254. package/dist/mjs/nodes/rules/rules.js +0 -106
  255. package/dist/mjs/package.json +0 -3
  256. package/dist/mjs/parse/ast/ast.js +0 -1
  257. package/dist/mjs/parse/ast/bound.js +0 -2
  258. package/dist/mjs/parse/ast/config.js +0 -9
  259. package/dist/mjs/parse/ast/distributableFunction.js +0 -34
  260. package/dist/mjs/parse/ast/divisor.js +0 -1
  261. package/dist/mjs/parse/ast/intersection.js +0 -16
  262. package/dist/mjs/parse/ast/keyof.js +0 -103
  263. package/dist/mjs/parse/ast/morph.js +0 -44
  264. package/dist/mjs/parse/ast/narrow.js +0 -14
  265. package/dist/mjs/parse/ast/node.js +0 -1
  266. package/dist/mjs/parse/ast/tuple.js +0 -80
  267. package/dist/mjs/parse/ast/union.js +0 -1
  268. package/dist/mjs/parse/ast/utils.js +0 -1
  269. package/dist/mjs/parse/definition.js +0 -46
  270. package/dist/mjs/parse/record.js +0 -29
  271. package/dist/mjs/parse/string/reduce/dynamic.js +0 -159
  272. package/dist/mjs/parse/string/reduce/shared.js +0 -6
  273. package/dist/mjs/parse/string/reduce/static.js +0 -1
  274. package/dist/mjs/parse/string/shift/operand/enclosed.js +0 -39
  275. package/dist/mjs/parse/string/shift/operand/operand.js +0 -3
  276. package/dist/mjs/parse/string/shift/operand/unenclosed.js +0 -36
  277. package/dist/mjs/parse/string/shift/operator/bounds.js +0 -70
  278. package/dist/mjs/parse/string/shift/operator/divisor.js +0 -21
  279. package/dist/mjs/parse/string/shift/operator/operator.js +0 -13
  280. package/dist/mjs/parse/string/shift/scanner.js +0 -106
  281. package/dist/mjs/parse/string/string.js +0 -28
  282. package/dist/mjs/scopes/ark.js +0 -28
  283. package/dist/mjs/scopes/cache.js +0 -38
  284. package/dist/mjs/scopes/expressions.js +0 -89
  285. package/dist/mjs/scopes/jsObjects.js +0 -82
  286. package/dist/mjs/scopes/scope.js +0 -303
  287. package/dist/mjs/scopes/tsKeywords.js +0 -116
  288. package/dist/mjs/scopes/type.js +0 -35
  289. package/dist/mjs/scopes/validation/validation.js +0 -112
  290. package/dist/mjs/traverse/problems.js +0 -260
  291. package/dist/mjs/traverse/traverse.js +0 -373
  292. package/dist/mjs/utils/chainableNoOpProxy.js +0 -15
  293. package/dist/mjs/utils/data.js +0 -38
  294. package/dist/mjs/utils/domains.js +0 -15
  295. package/dist/mjs/utils/errors.js +0 -10
  296. package/dist/mjs/utils/freeze.js +0 -7
  297. package/dist/mjs/utils/generics.js +0 -38
  298. package/dist/mjs/utils/numericLiterals.js +0 -72
  299. package/dist/mjs/utils/objectKinds.js +0 -55
  300. package/dist/mjs/utils/paths.js +0 -18
  301. package/dist/mjs/utils/serialize.js +0 -58
  302. package/dist/mjs/utils/unionToTuple.js +0 -1
  303. package/dist/tsconfig.temp.tsbuildinfo +0 -1
  304. package/dist/types/main.d.ts +0 -15
  305. package/dist/types/nodes/branch.d.ts +0 -29
  306. package/dist/types/nodes/compose.d.ts +0 -98
  307. package/dist/types/nodes/discriminate.d.ts +0 -26
  308. package/dist/types/nodes/node.d.ts +0 -69
  309. package/dist/types/nodes/predicate.d.ts +0 -18
  310. package/dist/types/nodes/rules/class.d.ts +0 -4
  311. package/dist/types/nodes/rules/collapsibleSet.d.ts +0 -4
  312. package/dist/types/nodes/rules/divisor.d.ts +0 -3
  313. package/dist/types/nodes/rules/props.d.ts +0 -43
  314. package/dist/types/nodes/rules/range.d.ts +0 -34
  315. package/dist/types/nodes/rules/regex.d.ts +0 -5
  316. package/dist/types/nodes/rules/rules.d.ts +0 -33
  317. package/dist/types/parse/ast/ast.d.ts +0 -24
  318. package/dist/types/parse/ast/bound.d.ts +0 -27
  319. package/dist/types/parse/ast/config.d.ts +0 -15
  320. package/dist/types/parse/ast/distributableFunction.d.ts +0 -18
  321. package/dist/types/parse/ast/divisor.d.ts +0 -13
  322. package/dist/types/parse/ast/intersection.d.ts +0 -31
  323. package/dist/types/parse/ast/keyof.d.ts +0 -10
  324. package/dist/types/parse/ast/morph.d.ts +0 -18
  325. package/dist/types/parse/ast/narrow.d.ts +0 -21
  326. package/dist/types/parse/ast/node.d.ts +0 -35
  327. package/dist/types/parse/ast/tuple.d.ts +0 -41
  328. package/dist/types/parse/ast/union.d.ts +0 -17
  329. package/dist/types/parse/ast/utils.d.ts +0 -7
  330. package/dist/types/parse/definition.d.ts +0 -30
  331. package/dist/types/parse/record.d.ts +0 -26
  332. package/dist/types/parse/string/reduce/dynamic.d.ts +0 -34
  333. package/dist/types/parse/string/reduce/shared.d.ts +0 -25
  334. package/dist/types/parse/string/reduce/static.d.ts +0 -130
  335. package/dist/types/parse/string/shift/operand/enclosed.d.ts +0 -28
  336. package/dist/types/parse/string/shift/operand/operand.d.ts +0 -9
  337. package/dist/types/parse/string/shift/operand/unenclosed.d.ts +0 -18
  338. package/dist/types/parse/string/shift/operator/bounds.d.ts +0 -21
  339. package/dist/types/parse/string/shift/operator/divisor.d.ts +0 -13
  340. package/dist/types/parse/string/shift/operator/operator.d.ts +0 -13
  341. package/dist/types/parse/string/shift/scanner.d.ts +0 -89
  342. package/dist/types/parse/string/string.d.ts +0 -25
  343. package/dist/types/scopes/ark.d.ts +0 -209
  344. package/dist/types/scopes/cache.d.ts +0 -14
  345. package/dist/types/scopes/expressions.d.ts +0 -136
  346. package/dist/types/scopes/jsObjects.d.ts +0 -26
  347. package/dist/types/scopes/scope.d.ts +0 -99
  348. package/dist/types/scopes/tsKeywords.d.ts +0 -50
  349. package/dist/types/scopes/type.d.ts +0 -67
  350. package/dist/types/scopes/validation/creditCard.d.ts +0 -2
  351. package/dist/types/scopes/validation/validation.d.ts +0 -49
  352. package/dist/types/traverse/problems.d.ts +0 -88
  353. package/dist/types/traverse/traverse.d.ts +0 -55
  354. package/dist/types/utils/chainableNoOpProxy.d.ts +0 -14
  355. package/dist/types/utils/data.d.ts +0 -13
  356. package/dist/types/utils/domains.d.ts +0 -32
  357. package/dist/types/utils/errors.d.ts +0 -6
  358. package/dist/types/utils/freeze.d.ts +0 -2
  359. package/dist/types/utils/generics.d.ts +0 -125
  360. package/dist/types/utils/numericLiterals.d.ts +0 -46
  361. package/dist/types/utils/objectKinds.d.ts +0 -84
  362. package/dist/types/utils/paths.d.ts +0 -9
  363. package/dist/types/utils/serialize.d.ts +0 -37
  364. package/dist/types/utils/unionToTuple.d.ts +0 -11
@@ -1,53 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: all[name]
9
- });
10
- }
11
- _export(exports, {
12
- sizeOf: ()=>sizeOf,
13
- unitsOf: ()=>unitsOf,
14
- DataWrapper: ()=>DataWrapper
15
- });
16
- const _domainsJs = require("./domains.js");
17
- const _serializeJs = require("./serialize.js");
18
- function _defineProperty(obj, key, value) {
19
- if (key in obj) {
20
- Object.defineProperty(obj, key, {
21
- value: value,
22
- enumerable: true,
23
- configurable: true,
24
- writable: true
25
- });
26
- } else {
27
- obj[key] = value;
28
- }
29
- return obj;
30
- }
31
- const sizeOf = (data)=>typeof data === "string" || Array.isArray(data) ? data.length : typeof data === "number" ? data : 0;
32
- const unitsOf = (data)=>typeof data === "string" ? "characters" : Array.isArray(data) ? "items long" : "";
33
- class DataWrapper {
34
- toString() {
35
- return (0, _serializeJs.stringify)(this.value);
36
- }
37
- get domain() {
38
- return (0, _domainsJs.domainOf)(this.value);
39
- }
40
- get size() {
41
- return sizeOf(this.value);
42
- }
43
- get units() {
44
- return unitsOf(this.value);
45
- }
46
- get className() {
47
- return Object(this.value).constructor.name;
48
- }
49
- constructor(value){
50
- _defineProperty(this, "value", void 0);
51
- this.value = value;
52
- }
53
- }
@@ -1,30 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: all[name]
9
- });
10
- }
11
- _export(exports, {
12
- hasDomain: ()=>hasDomain,
13
- domainOf: ()=>domainOf,
14
- domainDescriptions: ()=>domainDescriptions
15
- });
16
- const hasDomain = (data, domain)=>domainOf(data) === domain;
17
- const domainOf = (data)=>{
18
- const builtinType = typeof data;
19
- return builtinType === "object" ? data === null ? "null" : "object" : builtinType === "function" ? "object" : builtinType;
20
- };
21
- const domainDescriptions = {
22
- bigint: "a bigint",
23
- boolean: "boolean",
24
- null: "null",
25
- number: "a number",
26
- object: "an object",
27
- string: "a string",
28
- symbol: "a symbol",
29
- undefined: "undefined"
30
- };
@@ -1,26 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: all[name]
9
- });
10
- }
11
- _export(exports, {
12
- InternalArktypeError: ()=>InternalArktypeError,
13
- throwInternalError: ()=>throwInternalError,
14
- ParseError: ()=>ParseError,
15
- throwParseError: ()=>throwParseError
16
- });
17
- class InternalArktypeError extends Error {
18
- }
19
- const throwInternalError = (message)=>{
20
- throw new InternalArktypeError(message);
21
- };
22
- class ParseError extends Error {
23
- }
24
- const throwParseError = (message)=>{
25
- throw new ParseError(message);
26
- };
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "deepFreeze", {
6
- enumerable: true,
7
- get: ()=>deepFreeze
8
- });
9
- const deepFreeze = (value)=>Object.isFrozen(value) ? value : Array.isArray(value) ? Object.freeze(value.map(deepFreeze)) : deepFreezeDictionary(value);
10
- const deepFreezeDictionary = (value)=>{
11
- for(const k in value){
12
- deepFreeze(value[k]);
13
- }
14
- return value;
15
- };
@@ -1,63 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: all[name]
9
- });
10
- }
11
- _export(exports, {
12
- asConst: ()=>asConst,
13
- isKeyOf: ()=>isKeyOf,
14
- entriesOf: ()=>entriesOf,
15
- objectKeysOf: ()=>objectKeysOf,
16
- prototypeKeysOf: ()=>prototypeKeysOf,
17
- hasKey: ()=>hasKey,
18
- hasSingleKey: ()=>hasSingleKey,
19
- keyCount: ()=>keyCount,
20
- hasKeys: ()=>hasKeys,
21
- nominal: ()=>nominal,
22
- getNominalId: ()=>getNominalId,
23
- hasNominalId: ()=>hasNominalId,
24
- listFrom: ()=>listFrom
25
- });
26
- const _domainsJs = require("./domains.js");
27
- const asConst = (t)=>t;
28
- const isKeyOf = (k, obj)=>k in obj;
29
- const entriesOf = (o)=>Object.entries(o);
30
- const objectKeysOf = (o)=>Object.keys(o);
31
- const prototypeKeysOf = (value)=>{
32
- const result = [];
33
- while(value !== Object.prototype && value !== null && value !== undefined){
34
- for (const k of Object.getOwnPropertyNames(value)){
35
- if (!result.includes(k)) {
36
- result.push(k);
37
- }
38
- }
39
- for (const symbol of Object.getOwnPropertySymbols(value)){
40
- if (!result.includes(symbol)) {
41
- result.push(symbol);
42
- }
43
- }
44
- value = Object.getPrototypeOf(value);
45
- }
46
- return result;
47
- };
48
- const hasKey = (o, k)=>{
49
- const valueAtKey = o?.[k];
50
- return valueAtKey !== undefined && valueAtKey !== null;
51
- };
52
- const hasSingleKey = (o, k)=>k in o && Object.keys(o).length === 1;
53
- const keyCount = (o)=>Object.keys(o).length;
54
- const hasKeys = (value)=>(0, _domainsJs.hasDomain)(value, "object") ? Object.keys(value).length !== 0 : false;
55
- const id = Symbol("id");
56
- const nominal = (o, name)=>Object.assign(o, {
57
- [id]: name
58
- });
59
- const getNominalId = (data)=>(0, _domainsJs.hasDomain)(data, "object") && id in data ? data[id] : undefined;
60
- const hasNominalId = (data, name)=>getNominalId(data) === name;
61
- const listFrom = (data)=>Array.isArray(data) ? data : [
62
- data
63
- ];
@@ -1,75 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: all[name]
9
- });
10
- }
11
- _export(exports, {
12
- wellFormedNumberMatcher: ()=>wellFormedNumberMatcher,
13
- wellFormedIntegerMatcher: ()=>wellFormedIntegerMatcher,
14
- isWellFormedInteger: ()=>isWellFormedInteger,
15
- wellFormedNonNegativeIntegerMatcher: ()=>wellFormedNonNegativeIntegerMatcher,
16
- writeMalformedNumericLiteralMessage: ()=>writeMalformedNumericLiteralMessage,
17
- tryParseWellFormedNumber: ()=>tryParseWellFormedNumber,
18
- tryParseWellFormedInteger: ()=>tryParseWellFormedInteger,
19
- tryParseWellFormedBigint: ()=>tryParseWellFormedBigint
20
- });
21
- const _errorsJs = require("./errors.js");
22
- const wellFormedNumberMatcher = /^(?!^-0$)-?(?:0|[1-9]\d*)(?:\.\d*[1-9])?$/;
23
- const isWellFormedNumber = (s)=>wellFormedNumberMatcher.test(s);
24
- const numberLikeMatcher = /^-?\d*\.?\d*$/;
25
- const isNumberLike = (s)=>s.length !== 0 && numberLikeMatcher.test(s);
26
- const wellFormedIntegerMatcher = /^(?:0|(?:-?[1-9]\d*))$/;
27
- const isWellFormedInteger = (s)=>wellFormedIntegerMatcher.test(s);
28
- const wellFormedNonNegativeIntegerMatcher = /^(?:0|(?:[1-9]\d*))$/;
29
- const integerLikeMatcher = /^-?\d+$/;
30
- const isIntegerLike = (s)=>integerLikeMatcher.test(s);
31
- const numericLiteralDescriptions = {
32
- number: "a number",
33
- bigint: "a bigint",
34
- integer: "an integer"
35
- };
36
- const writeMalformedNumericLiteralMessage = (def, kind)=>`'${def}' was parsed as ${numericLiteralDescriptions[kind]} but could not be narrowed to a literal value. Avoid unnecessary leading or trailing zeros and other abnormal notation`;
37
- const isWellFormed = (def, kind)=>kind === "number" ? isWellFormedNumber(def) : isWellFormedInteger(def);
38
- const parseKind = (def, kind)=>kind === "number" ? Number(def) : Number.parseInt(def);
39
- const isKindLike = (def, kind)=>kind === "number" ? isNumberLike(def) : isIntegerLike(def);
40
- const tryParseWellFormedNumber = (token, errorOnFail)=>parseWellFormed(token, "number", errorOnFail);
41
- const tryParseWellFormedInteger = (token, errorOnFail)=>parseWellFormed(token, "integer", errorOnFail);
42
- const parseWellFormed = (token, kind, errorOnFail)=>{
43
- const value = parseKind(token, kind);
44
- if (!Number.isNaN(value)) {
45
- if (isWellFormed(token, kind)) {
46
- return value;
47
- }
48
- if (isKindLike(token, kind)) {
49
- // If the definition looks like the correct numeric kind but is
50
- // not well-formed, always throw.
51
- return (0, _errorsJs.throwParseError)(writeMalformedNumericLiteralMessage(token, kind));
52
- }
53
- }
54
- return errorOnFail ? (0, _errorsJs.throwParseError)(errorOnFail === true ? `Failed to parse ${numericLiteralDescriptions[kind]} from '${token}'` : errorOnFail) : undefined;
55
- };
56
- const tryParseWellFormedBigint = (def)=>{
57
- if (def[def.length - 1] !== "n") {
58
- return;
59
- }
60
- const maybeIntegerLiteral = def.slice(0, -1);
61
- let value;
62
- try {
63
- value = BigInt(maybeIntegerLiteral);
64
- } catch {
65
- return;
66
- }
67
- if (wellFormedIntegerMatcher.test(maybeIntegerLiteral)) {
68
- return value;
69
- }
70
- if (integerLikeMatcher.test(maybeIntegerLiteral)) {
71
- // If the definition looks like a bigint but is
72
- // not well-formed, throw.
73
- return (0, _errorsJs.throwParseError)(writeMalformedNumericLiteralMessage(def, "bigint"));
74
- }
75
- };
@@ -1,69 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: all[name]
9
- });
10
- }
11
- _export(exports, {
12
- defaultObjectKinds: ()=>defaultObjectKinds,
13
- objectKindOf: ()=>objectKindOf,
14
- hasObjectKind: ()=>hasObjectKind,
15
- isArray: ()=>isArray,
16
- objectKindDescriptions: ()=>objectKindDescriptions,
17
- getExactConstructorObjectKind: ()=>getExactConstructorObjectKind
18
- });
19
- const _domainsJs = require("./domains.js");
20
- const _genericsJs = require("./generics.js");
21
- const defaultObjectKinds = {
22
- Array,
23
- Date,
24
- Error,
25
- Function,
26
- Map,
27
- RegExp,
28
- Set,
29
- Object,
30
- String,
31
- Number,
32
- Boolean,
33
- WeakMap,
34
- WeakSet,
35
- Promise
36
- };
37
- const objectKindOf = (data, kinds)=>{
38
- if ((0, _domainsJs.domainOf)(data) !== "object") {
39
- return undefined;
40
- }
41
- const kindSet = kinds ?? defaultObjectKinds;
42
- let prototype = Object.getPrototypeOf(data);
43
- while(prototype?.constructor && (!kindSet[prototype.constructor.name] || !(data instanceof kindSet[prototype.constructor.name]))){
44
- prototype = Object.getPrototypeOf(prototype);
45
- }
46
- return prototype?.constructor?.name;
47
- };
48
- const hasObjectKind = (data, kind, kinds)=>objectKindOf(data, kinds) === kind;
49
- const isArray = (data)=>Array.isArray(data);
50
- const objectKindDescriptions = {
51
- Object: "an object",
52
- Array: "an array",
53
- Function: "a function",
54
- Date: "a Date",
55
- RegExp: "a RegExp",
56
- Error: "an Error",
57
- Map: "a Map",
58
- Set: "a Set",
59
- String: "a String object",
60
- Number: "a Number object",
61
- Boolean: "a Boolean object",
62
- Promise: "a Promise",
63
- WeakMap: "a WeakMap",
64
- WeakSet: "a WeakSet"
65
- };
66
- const getExactConstructorObjectKind = (constructor)=>{
67
- const constructorName = Object(constructor).name;
68
- return constructorName && (0, _genericsJs.isKeyOf)(constructorName, defaultObjectKinds) && defaultObjectKinds[constructorName] === constructor ? constructorName : undefined;
69
- };
@@ -1,32 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: all[name]
9
- });
10
- }
11
- _export(exports, {
12
- Path: ()=>Path,
13
- getPath: ()=>getPath
14
- });
15
- class Path extends Array {
16
- static fromString(s, delimiter = "/") {
17
- return s === delimiter ? new Path() : new Path(...s.split(delimiter));
18
- }
19
- toString(delimiter = "/") {
20
- return this.length ? this.join(delimiter) : delimiter;
21
- }
22
- }
23
- const getPath = (root, path)=>{
24
- let result = root;
25
- for (const segment of path){
26
- if (typeof result !== "object" || result === null) {
27
- return undefined;
28
- }
29
- result = result[segment];
30
- }
31
- return result;
32
- };
@@ -1,74 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: all[name]
9
- });
10
- }
11
- _export(exports, {
12
- snapshot: ()=>snapshot,
13
- stringify: ()=>stringify,
14
- serializePrimitive: ()=>serializePrimitive,
15
- deserializePrimitive: ()=>deserializePrimitive
16
- });
17
- const _domainsJs = require("./domains.js");
18
- const _genericsJs = require("./generics.js");
19
- const _numericLiteralsJs = require("./numericLiterals.js");
20
- const snapshot = (data, opts = {})=>serializeRecurse(data, opts, []);
21
- const stringify = (data, indent)=>{
22
- switch((0, _domainsJs.domainOf)(data)){
23
- case "object":
24
- return JSON.stringify(serializeRecurse(data, stringifyOpts, []), null, indent);
25
- case "symbol":
26
- return stringifyOpts.onSymbol(data);
27
- default:
28
- return serializePrimitive(data);
29
- }
30
- };
31
- const stringifyOpts = {
32
- onCycle: ()=>"(cycle)",
33
- onSymbol: (v)=>`(symbol${v.description && ` ${v.description}`})`,
34
- onFunction: (v)=>`(function${v.name && ` ${v.name}`})`
35
- };
36
- const serializeRecurse = (data, context, seen)=>{
37
- switch((0, _domainsJs.domainOf)(data)){
38
- case "object":
39
- if (typeof data === "function") {
40
- return stringifyOpts.onFunction(data);
41
- }
42
- if (seen.includes(data)) {
43
- return "(cycle)";
44
- }
45
- const nextSeen = [
46
- ...seen,
47
- data
48
- ];
49
- if (Array.isArray(data)) {
50
- return data.map((item)=>serializeRecurse(item, context, nextSeen));
51
- }
52
- const result = {};
53
- for(const k in data){
54
- result[k] = serializeRecurse(data[k], context, nextSeen);
55
- }
56
- return result;
57
- case "symbol":
58
- return stringifyOpts.onSymbol(data);
59
- case "bigint":
60
- return `${data}n`;
61
- case "undefined":
62
- return "undefined";
63
- default:
64
- return data;
65
- }
66
- };
67
- const serializePrimitive = (value)=>typeof value === "string" ? `'${value}'` : typeof value === "bigint" ? `${value}n` : `${value}`;
68
- const deserializePrimitive = (serialized)=>(0, _genericsJs.isKeyOf)(serialized, serializedKeywords) ? serializedKeywords[serialized] : serialized[0] === "'" ? serialized.slice(1, -1) : (0, _numericLiteralsJs.tryParseWellFormedBigint)(serialized) ?? (0, _numericLiteralsJs.tryParseWellFormedNumber)(serialized, true);
69
- const serializedKeywords = {
70
- true: true,
71
- false: false,
72
- undefined,
73
- null: null
74
- };
@@ -1,4 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
package/dist/mjs/main.js DELETED
@@ -1,8 +0,0 @@
1
- export { scope } from "./scopes/scope.js";
2
- export { type, ark, arkScope } from "./scopes/ark.js";
3
- export { arrayOf, instanceOf, intersection, keyOf, morph, narrow, union, valueOf } from "./scopes/expressions.js";
4
- export { jsObjectsScope } from "./scopes/jsObjects.js";
5
- export { tsKeywordsScope } from "./scopes/tsKeywords.js";
6
- export { validationScope } from "./scopes/validation/validation.js";
7
- export { Problems, Problem } from "./traverse/problems.js";
8
- export { parseConfigTuple } from "./parse/ast/config.js";
@@ -1,123 +0,0 @@
1
- import { writeImplicitNeverMessage } from "../parse/ast/intersection.js";
2
- import { domainOf, hasDomain } from "../utils/domains.js";
3
- import { throwInternalError, throwParseError } from "../utils/errors.js";
4
- import { isDisjoint, isEquality } from "./compose.js";
5
- import { flattenRules, rulesIntersection } from "./rules/rules.js";
6
- export const isBranchComparison = (comparison)=>comparison?.lBranches !== undefined;
7
- export const compareBranches = (lConditions, rConditions, state)=>{
8
- const result = {
9
- lBranches: lConditions,
10
- rBranches: rConditions,
11
- lExtendsR: [],
12
- rExtendsL: [],
13
- equalities: [],
14
- distinctIntersections: []
15
- };
16
- const pairs = rConditions.map((condition)=>({
17
- condition,
18
- distinct: []
19
- }));
20
- lConditions.forEach((l, lIndex)=>{
21
- let lImpliesR = false;
22
- const distinct = pairs.map((rPairs, rIndex)=>{
23
- if (lImpliesR || !rPairs.distinct) {
24
- return null;
25
- }
26
- const r = rPairs.condition;
27
- const subresult = branchIntersection(l, r, state);
28
- if (isDisjoint(subresult)) {
29
- // doesn't tell us about any redundancies or add a distinct pair
30
- return null;
31
- } else if (subresult === l) {
32
- result.lExtendsR.push(lIndex);
33
- // If l is a subtype of the current r branch, intersections
34
- // with the remaining branches of r won't lead to distinct
35
- // branches, so we set a flag indicating we can skip them.
36
- lImpliesR = true;
37
- return null;
38
- } else if (subresult === r) {
39
- result.rExtendsL.push(rIndex);
40
- // If r is a subtype of the current l branch, it is removed
41
- // from pairsByR because future intersections won't lead to
42
- // distinct branches.
43
- rPairs.distinct = null;
44
- return null;
45
- } else if (isEquality(subresult)) {
46
- // Combination of l and r subtype cases.
47
- result.equalities.push([
48
- lIndex,
49
- rIndex
50
- ]);
51
- lImpliesR = true;
52
- rPairs.distinct = null;
53
- return null;
54
- } else if (hasDomain(subresult, "object")) {
55
- // Neither branch is a subtype of the other, return
56
- // the result of the intersection as a candidate
57
- // branch for the final union
58
- return subresult;
59
- }
60
- return throwInternalError(`Unexpected predicate intersection result of type '${domainOf(subresult)}'`);
61
- });
62
- if (!lImpliesR) {
63
- for(let i = 0; i < pairs.length; i++){
64
- if (distinct[i]) {
65
- pairs[i].distinct?.push(distinct[i]);
66
- }
67
- }
68
- }
69
- });
70
- result.distinctIntersections = pairs.flatMap((pairs)=>pairs.distinct ?? []);
71
- return result;
72
- };
73
- export const isTransformationBranch = (branch)=>"rules" in branch;
74
- export const flattenBranch = (branch, ctx)=>{
75
- if (isTransformationBranch(branch)) {
76
- const result = flattenRules(branch.rules, ctx);
77
- if (branch.morph) {
78
- if (typeof branch.morph === "function") {
79
- result.push([
80
- "morph",
81
- branch.morph
82
- ]);
83
- } else {
84
- for (const morph of branch.morph){
85
- result.push([
86
- "morph",
87
- morph
88
- ]);
89
- }
90
- }
91
- }
92
- return result;
93
- }
94
- return flattenRules(branch, ctx);
95
- };
96
- const rulesOf = (branch)=>branch.rules ?? branch;
97
- export const branchIntersection = (l, r, state)=>{
98
- const lRules = rulesOf(l);
99
- const rRules = rulesOf(r);
100
- const rulesResult = rulesIntersection(lRules, rRules, state);
101
- if ("morph" in l) {
102
- if ("morph" in r) {
103
- if (l.morph === r.morph) {
104
- return isEquality(rulesResult) || isDisjoint(rulesResult) ? rulesResult : {
105
- rules: rulesResult,
106
- morph: l.morph
107
- };
108
- }
109
- return state.lastOperator === "&" ? throwParseError(writeImplicitNeverMessage(state.path, "Intersection", "of morphs")) : {};
110
- }
111
- return isDisjoint(rulesResult) ? rulesResult : {
112
- rules: isEquality(rulesResult) ? l.rules : rulesResult,
113
- morph: l.morph
114
- };
115
- }
116
- if ("morph" in r) {
117
- return isDisjoint(rulesResult) ? rulesResult : {
118
- rules: isEquality(rulesResult) ? r.rules : rulesResult,
119
- morph: r.morph
120
- };
121
- }
122
- return rulesResult;
123
- };