arktype 2.0.0-dev.4 → 2.0.0-dev.6

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 (479) hide show
  1. package/__tests__/array.test.ts +176 -236
  2. package/__tests__/badDefinitionType.test.ts +10 -3
  3. package/__tests__/basis.test.ts +6 -2
  4. package/__tests__/bounds.test.ts +282 -352
  5. package/__tests__/cast.test.ts +7 -2
  6. package/__tests__/completions.test.ts +8 -3
  7. package/__tests__/config.test.ts +16 -8
  8. package/__tests__/cyclic.test.ts +141 -137
  9. package/__tests__/dateLiteral.test.ts +8 -4
  10. package/__tests__/declared.test.ts +2 -2
  11. package/__tests__/discrimination.test.ts +1 -1
  12. package/__tests__/divisor.test.ts +45 -25
  13. package/__tests__/enclosed.test.ts +39 -25
  14. package/__tests__/examples.test.ts +56 -56
  15. package/__tests__/expressions.test.ts +184 -112
  16. package/__tests__/generic.test.ts +307 -288
  17. package/__tests__/group.test.ts +67 -54
  18. package/__tests__/imports.test.ts +44 -37
  19. package/__tests__/instanceof.test.ts +17 -15
  20. package/__tests__/intersection.test.ts +50 -46
  21. package/__tests__/keyTraversal.test.ts +6 -3
  22. package/__tests__/keyof.test.ts +68 -52
  23. package/__tests__/keywords.test.ts +149 -136
  24. package/__tests__/literal.test.ts +38 -15
  25. package/__tests__/match.test.ts +234 -224
  26. package/__tests__/morph.test.ts +300 -269
  27. package/__tests__/narrow.test.ts +46 -42
  28. package/__tests__/objectLiteral.test.ts +228 -210
  29. package/__tests__/realWorld.test.ts +63 -0
  30. package/__tests__/regex.test.ts +17 -7
  31. package/__tests__/scope.bench.ts +1 -1
  32. package/__tests__/scope.test.ts +65 -18
  33. package/__tests__/serialization.test.ts +19 -0
  34. package/__tests__/string.test.ts +11 -7
  35. package/__tests__/submodule.test.ts +26 -39
  36. package/__tests__/this.test.ts +83 -57
  37. package/__tests__/thunk.test.ts +13 -7
  38. package/__tests__/traverse.test.ts +50 -37
  39. package/__tests__/tsGenerics.test.ts +12 -12
  40. package/__tests__/type.test.ts +38 -0
  41. package/__tests__/typeReference.test.ts +7 -7
  42. package/__tests__/unenclosed.test.ts +116 -100
  43. package/__tests__/union.test.ts +171 -104
  44. package/ark.ts +18 -65
  45. package/generic.ts +67 -0
  46. package/main.ts +6 -18
  47. package/match.ts +53 -67
  48. package/module.ts +15 -0
  49. package/out/ark.d.ts +12 -36
  50. package/out/ark.d.ts.map +1 -1
  51. package/out/ark.js +9 -17
  52. package/out/ark.js.map +1 -1
  53. package/out/base.d.ts +205 -0
  54. package/out/base.d.ts.map +1 -0
  55. package/out/base.js +320 -0
  56. package/out/base.js.map +1 -0
  57. package/out/builtins/builtins.d.ts +23 -0
  58. package/out/builtins/builtins.d.ts.map +1 -0
  59. package/out/builtins/builtins.js +15 -0
  60. package/out/builtins/builtins.js.map +1 -0
  61. package/out/builtins/jsObjects.d.ts +19 -0
  62. package/out/builtins/jsObjects.d.ts.map +1 -0
  63. package/out/builtins/jsObjects.js +18 -0
  64. package/out/builtins/jsObjects.js.map +1 -0
  65. package/out/builtins/parsing.d.ts +16 -0
  66. package/out/builtins/parsing.d.ts.map +1 -0
  67. package/out/builtins/parsing.js +62 -0
  68. package/out/builtins/parsing.js.map +1 -0
  69. package/out/builtins/tsGenerics.d.ts +2 -0
  70. package/out/builtins/tsGenerics.d.ts.map +1 -0
  71. package/out/builtins/tsGenerics.js +26 -0
  72. package/out/builtins/tsGenerics.js.map +1 -0
  73. package/out/builtins/tsKeywords.d.ts +23 -0
  74. package/out/builtins/tsKeywords.d.ts.map +1 -0
  75. package/out/builtins/tsKeywords.js +23 -0
  76. package/out/builtins/tsKeywords.js.map +1 -0
  77. package/out/builtins/utils/creditCard.d.ts +3 -0
  78. package/out/builtins/utils/creditCard.d.ts.map +1 -0
  79. package/out/builtins/utils/creditCard.js +35 -0
  80. package/out/builtins/utils/creditCard.js.map +1 -0
  81. package/out/builtins/utils/date.d.ts +41 -0
  82. package/out/builtins/utils/date.d.ts.map +1 -0
  83. package/out/builtins/utils/date.js +56 -0
  84. package/out/builtins/utils/date.js.map +1 -0
  85. package/out/builtins/validation.d.ts +19 -0
  86. package/out/builtins/validation.d.ts.map +1 -0
  87. package/out/builtins/validation.js +74 -0
  88. package/out/builtins/validation.js.map +1 -0
  89. package/out/config.d.ts +9 -0
  90. package/out/config.d.ts.map +1 -0
  91. package/out/config.js +18 -0
  92. package/out/config.js.map +1 -0
  93. package/out/constraints/ast.d.ts +287 -0
  94. package/out/constraints/ast.d.ts.map +1 -0
  95. package/out/constraints/ast.js +2 -0
  96. package/out/constraints/ast.js.map +1 -0
  97. package/out/constraints/constraint.d.ts +200 -0
  98. package/out/constraints/constraint.d.ts.map +1 -0
  99. package/out/constraints/constraint.js +25 -0
  100. package/out/constraints/constraint.js.map +1 -0
  101. package/out/constraints/predicate.d.ts +64 -0
  102. package/out/constraints/predicate.d.ts.map +1 -0
  103. package/out/constraints/predicate.js +52 -0
  104. package/out/constraints/predicate.js.map +1 -0
  105. package/out/constraints/props/index.d.ts +42 -0
  106. package/out/constraints/props/index.d.ts.map +1 -0
  107. package/out/constraints/props/index.js +56 -0
  108. package/out/constraints/props/index.js.map +1 -0
  109. package/out/constraints/props/optional.d.ts +37 -0
  110. package/out/constraints/props/optional.d.ts.map +1 -0
  111. package/out/constraints/props/optional.js +56 -0
  112. package/out/constraints/props/optional.js.map +1 -0
  113. package/out/constraints/props/prop.d.ts +49 -0
  114. package/out/constraints/props/prop.d.ts.map +1 -0
  115. package/out/constraints/props/prop.js +106 -0
  116. package/out/constraints/props/prop.js.map +1 -0
  117. package/out/constraints/props/props.d.ts +37 -0
  118. package/out/constraints/props/props.d.ts.map +1 -0
  119. package/out/constraints/props/props.js +121 -0
  120. package/out/constraints/props/props.js.map +1 -0
  121. package/out/constraints/props/required.d.ts +46 -0
  122. package/out/constraints/props/required.d.ts.map +1 -0
  123. package/out/constraints/props/required.js +81 -0
  124. package/out/constraints/props/required.js.map +1 -0
  125. package/out/constraints/props/sequence.d.ts +82 -0
  126. package/out/constraints/props/sequence.d.ts.map +1 -0
  127. package/out/constraints/props/sequence.js +376 -0
  128. package/out/constraints/props/sequence.js.map +1 -0
  129. package/out/constraints/props/shared.d.ts +3 -0
  130. package/out/constraints/props/shared.d.ts.map +1 -0
  131. package/out/constraints/props/shared.js +4 -0
  132. package/out/constraints/props/shared.js.map +1 -0
  133. package/out/constraints/refinements/after.d.ts +33 -0
  134. package/out/constraints/refinements/after.d.ts.map +1 -0
  135. package/out/constraints/refinements/after.js +36 -0
  136. package/out/constraints/refinements/after.js.map +1 -0
  137. package/out/constraints/refinements/before.d.ts +33 -0
  138. package/out/constraints/refinements/before.d.ts.map +1 -0
  139. package/out/constraints/refinements/before.js +43 -0
  140. package/out/constraints/refinements/before.js.map +1 -0
  141. package/out/constraints/refinements/divisor.d.ts +52 -0
  142. package/out/constraints/refinements/divisor.d.ts.map +1 -0
  143. package/out/constraints/refinements/divisor.js +52 -0
  144. package/out/constraints/refinements/divisor.js.map +1 -0
  145. package/out/constraints/refinements/exactLength.d.ts +45 -0
  146. package/out/constraints/refinements/exactLength.d.ts.map +1 -0
  147. package/out/constraints/refinements/exactLength.js +52 -0
  148. package/out/constraints/refinements/exactLength.js.map +1 -0
  149. package/out/constraints/refinements/kinds.d.ts +29 -0
  150. package/out/constraints/refinements/kinds.d.ts.map +1 -0
  151. package/out/constraints/refinements/kinds.js +17 -0
  152. package/out/constraints/refinements/kinds.js.map +1 -0
  153. package/out/constraints/refinements/length.d.ts +48 -0
  154. package/out/constraints/refinements/length.d.ts.map +1 -0
  155. package/out/constraints/refinements/length.js +53 -0
  156. package/out/constraints/refinements/length.js.map +1 -0
  157. package/out/constraints/refinements/max.d.ts +31 -0
  158. package/out/constraints/refinements/max.d.ts.map +1 -0
  159. package/out/constraints/refinements/max.js +35 -0
  160. package/out/constraints/refinements/max.js.map +1 -0
  161. package/out/constraints/refinements/maxLength.d.ts +32 -0
  162. package/out/constraints/refinements/maxLength.d.ts.map +1 -0
  163. package/out/constraints/refinements/maxLength.js +36 -0
  164. package/out/constraints/refinements/maxLength.js.map +1 -0
  165. package/out/constraints/refinements/min.d.ts +31 -0
  166. package/out/constraints/refinements/min.d.ts.map +1 -0
  167. package/out/constraints/refinements/min.js +28 -0
  168. package/out/constraints/refinements/min.js.map +1 -0
  169. package/out/constraints/refinements/minLength.d.ts +32 -0
  170. package/out/constraints/refinements/minLength.d.ts.map +1 -0
  171. package/out/constraints/refinements/minLength.js +33 -0
  172. package/out/constraints/refinements/minLength.js.map +1 -0
  173. package/out/constraints/refinements/range.d.ts +119 -0
  174. package/out/constraints/refinements/range.d.ts.map +1 -0
  175. package/out/constraints/refinements/range.js +89 -0
  176. package/out/constraints/refinements/range.js.map +1 -0
  177. package/out/constraints/refinements/regex.d.ts +47 -0
  178. package/out/constraints/refinements/regex.d.ts.map +1 -0
  179. package/out/constraints/refinements/regex.js +37 -0
  180. package/out/constraints/refinements/regex.js.map +1 -0
  181. package/out/constraints/refinements/shared.d.ts +20 -0
  182. package/out/constraints/refinements/shared.d.ts.map +1 -0
  183. package/out/constraints/refinements/shared.js +10 -0
  184. package/out/constraints/refinements/shared.js.map +1 -0
  185. package/out/generic.d.ts +22 -0
  186. package/out/generic.d.ts.map +1 -0
  187. package/out/generic.js +23 -0
  188. package/out/generic.js.map +1 -0
  189. package/out/inference.d.ts +137 -0
  190. package/out/inference.d.ts.map +1 -0
  191. package/out/inference.js +73 -0
  192. package/out/inference.js.map +1 -0
  193. package/out/keywords/ark.d.ts +70 -0
  194. package/out/keywords/ark.d.ts.map +1 -0
  195. package/out/keywords/ark.js +29 -0
  196. package/out/keywords/ark.js.map +1 -0
  197. package/out/keywords/internal.d.ts +13 -0
  198. package/out/keywords/internal.d.ts.map +1 -0
  199. package/out/keywords/internal.js +13 -0
  200. package/out/keywords/internal.js.map +1 -0
  201. package/out/keywords/jsObject.d.ts +20 -0
  202. package/out/keywords/jsObject.d.ts.map +1 -0
  203. package/out/keywords/jsObject.js +18 -0
  204. package/out/keywords/jsObject.js.map +1 -0
  205. package/out/keywords/parsing.d.ts +17 -0
  206. package/out/keywords/parsing.d.ts.map +1 -0
  207. package/out/keywords/parsing.js +64 -0
  208. package/out/keywords/parsing.js.map +1 -0
  209. package/out/keywords/root.d.ts +7 -0
  210. package/out/keywords/root.d.ts.map +1 -0
  211. package/out/keywords/root.js +4 -0
  212. package/out/keywords/root.js.map +1 -0
  213. package/out/keywords/tsGenerics.d.ts +2 -0
  214. package/out/keywords/tsGenerics.d.ts.map +1 -0
  215. package/out/keywords/tsGenerics.js +26 -0
  216. package/out/keywords/tsGenerics.js.map +1 -0
  217. package/out/keywords/tsPrimitive.d.ts +24 -0
  218. package/out/keywords/tsPrimitive.d.ts.map +1 -0
  219. package/out/keywords/tsPrimitive.js +25 -0
  220. package/out/keywords/tsPrimitive.js.map +1 -0
  221. package/out/keywords/utils/creditCard.d.ts +11 -0
  222. package/out/keywords/utils/creditCard.d.ts.map +1 -0
  223. package/out/keywords/utils/creditCard.js +35 -0
  224. package/out/keywords/utils/creditCard.js.map +1 -0
  225. package/out/keywords/utils/date.d.ts +45 -0
  226. package/out/keywords/utils/date.d.ts.map +1 -0
  227. package/out/keywords/utils/date.js +56 -0
  228. package/out/keywords/utils/date.js.map +1 -0
  229. package/out/keywords/validation.d.ts +20 -0
  230. package/out/keywords/validation.d.ts.map +1 -0
  231. package/out/keywords/validation.js +80 -0
  232. package/out/keywords/validation.js.map +1 -0
  233. package/out/kinds.d.ts +102 -0
  234. package/out/kinds.d.ts.map +1 -0
  235. package/out/kinds.js +29 -0
  236. package/out/kinds.js.map +1 -0
  237. package/out/main.d.ts +6 -6
  238. package/out/main.d.ts.map +1 -1
  239. package/out/main.js +4 -3
  240. package/out/main.js.map +1 -1
  241. package/out/match.d.ts +18 -23
  242. package/out/match.d.ts.map +1 -1
  243. package/out/match.js +3 -4
  244. package/out/match.js.map +1 -1
  245. package/out/module.d.ts +11 -0
  246. package/out/module.d.ts.map +1 -0
  247. package/out/module.js +4 -0
  248. package/out/module.js.map +1 -0
  249. package/out/parse.d.ts +29 -0
  250. package/out/parse.d.ts.map +1 -0
  251. package/out/parse.js +161 -0
  252. package/out/parse.js.map +1 -0
  253. package/out/parser/definition.d.ts +9 -12
  254. package/out/parser/definition.d.ts.map +1 -1
  255. package/out/parser/definition.js +10 -12
  256. package/out/parser/definition.js.map +1 -1
  257. package/out/parser/generic.d.ts +3 -4
  258. package/out/parser/generic.d.ts.map +1 -1
  259. package/out/parser/generic.js +6 -8
  260. package/out/parser/generic.js.map +1 -1
  261. package/out/parser/objectLiteral.d.ts +44 -12
  262. package/out/parser/objectLiteral.d.ts.map +1 -1
  263. package/out/parser/objectLiteral.js +43 -36
  264. package/out/parser/objectLiteral.js.map +1 -1
  265. package/out/parser/semantic/bounds.d.ts +9 -6
  266. package/out/parser/semantic/bounds.d.ts.map +1 -1
  267. package/out/parser/semantic/bounds.js.map +1 -1
  268. package/out/parser/semantic/divisor.d.ts +5 -6
  269. package/out/parser/semantic/divisor.d.ts.map +1 -1
  270. package/out/parser/semantic/infer.d.ts +25 -0
  271. package/out/parser/semantic/infer.d.ts.map +1 -0
  272. package/out/parser/semantic/infer.js +2 -0
  273. package/out/parser/semantic/infer.js.map +1 -0
  274. package/out/parser/semantic/utils.d.ts +3 -6
  275. package/out/parser/semantic/utils.d.ts.map +1 -1
  276. package/out/parser/semantic/validate.d.ts +14 -12
  277. package/out/parser/semantic/validate.d.ts.map +1 -1
  278. package/out/parser/semantic/validate.js +1 -0
  279. package/out/parser/semantic/validate.js.map +1 -1
  280. package/out/parser/string/reduce/dynamic.d.ts +13 -12
  281. package/out/parser/string/reduce/dynamic.d.ts.map +1 -1
  282. package/out/parser/string/reduce/dynamic.js +27 -17
  283. package/out/parser/string/reduce/dynamic.js.map +1 -1
  284. package/out/parser/string/reduce/shared.d.ts +1 -2
  285. package/out/parser/string/reduce/shared.d.ts.map +1 -1
  286. package/out/parser/string/reduce/shared.js.map +1 -1
  287. package/out/parser/string/reduce/static.d.ts +26 -22
  288. package/out/parser/string/reduce/static.d.ts.map +1 -1
  289. package/out/parser/string/shift/operand/date.d.ts +2 -1
  290. package/out/parser/string/shift/operand/date.d.ts.map +1 -1
  291. package/out/parser/string/shift/operand/date.js +2 -2
  292. package/out/parser/string/shift/operand/date.js.map +1 -1
  293. package/out/parser/string/shift/operand/enclosed.d.ts +2 -2
  294. package/out/parser/string/shift/operand/enclosed.d.ts.map +1 -1
  295. package/out/parser/string/shift/operand/enclosed.js +6 -4
  296. package/out/parser/string/shift/operand/enclosed.js.map +1 -1
  297. package/out/parser/string/shift/operand/genericArgs.d.ts +9 -9
  298. package/out/parser/string/shift/operand/genericArgs.d.ts.map +1 -1
  299. package/out/parser/string/shift/operand/genericArgs.js +6 -8
  300. package/out/parser/string/shift/operand/genericArgs.js.map +1 -1
  301. package/out/parser/string/shift/operand/operand.d.ts +3 -3
  302. package/out/parser/string/shift/operand/operand.d.ts.map +1 -1
  303. package/out/parser/string/shift/operand/operand.js +8 -11
  304. package/out/parser/string/shift/operand/operand.js.map +1 -1
  305. package/out/parser/string/shift/operand/unenclosed.d.ts +13 -20
  306. package/out/parser/string/shift/operand/unenclosed.d.ts.map +1 -1
  307. package/out/parser/string/shift/operand/unenclosed.js +21 -26
  308. package/out/parser/string/shift/operand/unenclosed.js.map +1 -1
  309. package/out/parser/string/shift/operator/bounds.d.ts +15 -12
  310. package/out/parser/string/shift/operator/bounds.d.ts.map +1 -1
  311. package/out/parser/string/shift/operator/bounds.js +42 -48
  312. package/out/parser/string/shift/operator/bounds.js.map +1 -1
  313. package/out/parser/string/shift/operator/divisor.d.ts +1 -2
  314. package/out/parser/string/shift/operator/divisor.d.ts.map +1 -1
  315. package/out/parser/string/shift/operator/divisor.js.map +1 -1
  316. package/out/parser/string/shift/operator/operator.d.ts +1 -1
  317. package/out/parser/string/shift/operator/operator.d.ts.map +1 -1
  318. package/out/parser/string/shift/operator/operator.js +12 -18
  319. package/out/parser/string/shift/operator/operator.js.map +1 -1
  320. package/out/parser/string/shift/scanner.d.ts +2 -1
  321. package/out/parser/string/shift/scanner.d.ts.map +1 -1
  322. package/out/parser/string/shift/scanner.js +12 -11
  323. package/out/parser/string/shift/scanner.js.map +1 -1
  324. package/out/parser/string/string.d.ts +8 -5
  325. package/out/parser/string/string.d.ts.map +1 -1
  326. package/out/parser/string/string.js.map +1 -1
  327. package/out/parser/tuple.d.ts +96 -37
  328. package/out/parser/tuple.d.ts.map +1 -1
  329. package/out/parser/tuple.js +61 -66
  330. package/out/parser/tuple.js.map +1 -1
  331. package/out/schema.d.ts +175 -0
  332. package/out/schema.d.ts.map +1 -0
  333. package/out/schema.js +73 -0
  334. package/out/schema.js.map +1 -0
  335. package/out/schemaScope.d.ts +180 -0
  336. package/out/schemaScope.d.ts.map +1 -0
  337. package/out/schemaScope.js +235 -0
  338. package/out/schemaScope.js.map +1 -0
  339. package/out/scope.d.ts +42 -114
  340. package/out/scope.d.ts.map +1 -1
  341. package/out/scope.js +51 -181
  342. package/out/scope.js.map +1 -1
  343. package/out/shared/compile.d.ts +22 -0
  344. package/out/shared/compile.d.ts.map +1 -0
  345. package/out/shared/compile.js +79 -0
  346. package/out/shared/compile.js.map +1 -0
  347. package/out/shared/context.d.ts +54 -0
  348. package/out/shared/context.d.ts.map +1 -0
  349. package/out/shared/context.js +53 -0
  350. package/out/shared/context.js.map +1 -0
  351. package/out/shared/declare.d.ts +69 -0
  352. package/out/shared/declare.d.ts.map +1 -0
  353. package/out/shared/declare.js +2 -0
  354. package/out/shared/declare.js.map +1 -0
  355. package/out/shared/disjoint.d.ts +91 -0
  356. package/out/shared/disjoint.d.ts.map +1 -0
  357. package/out/shared/disjoint.js +110 -0
  358. package/out/shared/disjoint.js.map +1 -0
  359. package/out/shared/errors.d.ts +99 -0
  360. package/out/shared/errors.d.ts.map +1 -0
  361. package/out/shared/errors.js +108 -0
  362. package/out/shared/errors.js.map +1 -0
  363. package/out/shared/implement.d.ts +363 -0
  364. package/out/shared/implement.d.ts.map +1 -0
  365. package/out/shared/implement.js +68 -0
  366. package/out/shared/implement.js.map +1 -0
  367. package/out/shared/inference.d.ts +6 -0
  368. package/out/shared/inference.d.ts.map +1 -0
  369. package/out/shared/inference.js +5 -0
  370. package/out/shared/inference.js.map +1 -0
  371. package/out/shared/intersections.d.ts +60 -0
  372. package/out/shared/intersections.d.ts.map +1 -0
  373. package/out/shared/intersections.js +2 -0
  374. package/out/shared/intersections.js.map +1 -0
  375. package/out/shared/traversal.d.ts +62 -0
  376. package/out/shared/traversal.d.ts.map +1 -0
  377. package/out/shared/traversal.js +97 -0
  378. package/out/shared/traversal.js.map +1 -0
  379. package/out/shared/utils.d.ts +24 -0
  380. package/out/shared/utils.d.ts.map +1 -0
  381. package/out/shared/utils.js +15 -0
  382. package/out/shared/utils.js.map +1 -0
  383. package/out/type.d.ts +23 -59
  384. package/out/type.d.ts.map +1 -1
  385. package/out/type.js +2 -137
  386. package/out/type.js.map +1 -1
  387. package/out/types/basis.d.ts +47 -0
  388. package/out/types/basis.d.ts.map +1 -0
  389. package/out/types/basis.js +15 -0
  390. package/out/types/basis.js.map +1 -0
  391. package/out/types/discriminate.d.ts +34 -0
  392. package/out/types/discriminate.d.ts.map +1 -0
  393. package/out/types/discriminate.js +120 -0
  394. package/out/types/discriminate.js.map +1 -0
  395. package/out/types/domain.d.ts +57 -0
  396. package/out/types/domain.d.ts.map +1 -0
  397. package/out/types/domain.js +41 -0
  398. package/out/types/domain.js.map +1 -0
  399. package/out/types/intersection.d.ts +127 -0
  400. package/out/types/intersection.d.ts.map +1 -0
  401. package/out/types/intersection.js +379 -0
  402. package/out/types/intersection.js.map +1 -0
  403. package/out/types/morph.d.ts +157 -0
  404. package/out/types/morph.d.ts.map +1 -0
  405. package/out/types/morph.js +99 -0
  406. package/out/types/morph.js.map +1 -0
  407. package/out/types/proto.d.ts +51 -0
  408. package/out/types/proto.d.ts.map +1 -0
  409. package/out/types/proto.js +60 -0
  410. package/out/types/proto.js.map +1 -0
  411. package/out/types/type.d.ts +143 -0
  412. package/out/types/type.d.ts.map +1 -0
  413. package/out/types/type.js +123 -0
  414. package/out/types/type.js.map +1 -0
  415. package/out/types/union.d.ts +71 -0
  416. package/out/types/union.d.ts.map +1 -0
  417. package/out/types/union.js +379 -0
  418. package/out/types/union.js.map +1 -0
  419. package/out/types/unit.d.ts +45 -0
  420. package/out/types/unit.d.ts.map +1 -0
  421. package/out/types/unit.js +56 -0
  422. package/out/types/unit.js.map +1 -0
  423. package/out/util.d.ts +30 -18
  424. package/out/util.d.ts.map +1 -1
  425. package/out/util.js +8 -7
  426. package/out/util.js.map +1 -1
  427. package/package.json +7 -3
  428. package/parser/definition.ts +73 -89
  429. package/parser/generic.ts +35 -36
  430. package/parser/objectLiteral.ts +143 -117
  431. package/parser/semantic/bounds.ts +33 -32
  432. package/parser/semantic/divisor.ts +8 -10
  433. package/parser/semantic/infer.ts +141 -0
  434. package/parser/semantic/utils.ts +12 -23
  435. package/parser/semantic/validate.ts +82 -73
  436. package/parser/string/reduce/dynamic.ts +61 -46
  437. package/parser/string/reduce/shared.ts +1 -3
  438. package/parser/string/reduce/static.ts +65 -67
  439. package/parser/string/shift/operand/date.ts +12 -8
  440. package/parser/string/shift/operand/enclosed.ts +22 -17
  441. package/parser/string/shift/operand/genericArgs.ts +46 -45
  442. package/parser/string/shift/operand/operand.ts +32 -38
  443. package/parser/string/shift/operand/unenclosed.ts +106 -147
  444. package/parser/string/shift/operator/bounds.ts +114 -106
  445. package/parser/string/shift/operator/divisor.ts +12 -14
  446. package/parser/string/shift/operator/operator.ts +35 -46
  447. package/parser/string/shift/scanner.ts +49 -46
  448. package/parser/string/string.ts +28 -32
  449. package/parser/tuple.ts +288 -308
  450. package/scope.ts +183 -425
  451. package/type.ts +82 -281
  452. package/__tests__/astUtils.test.ts +0 -17
  453. package/__tests__/jsdoc.test.ts +0 -64
  454. package/__tests__/nodeDefinitions.test.ts +0 -190
  455. package/__tests__/typeMethods.test.ts +0 -69
  456. package/out/arkConfig.d.ts +0 -2
  457. package/out/arkConfig.d.ts.map +0 -1
  458. package/out/arkConfig.js +0 -10
  459. package/out/arkConfig.js.map +0 -1
  460. package/out/parser/semantic/intersections.d.ts +0 -14
  461. package/out/parser/semantic/intersections.d.ts.map +0 -1
  462. package/out/parser/semantic/intersections.js +0 -2
  463. package/out/parser/semantic/intersections.js.map +0 -1
  464. package/out/parser/semantic/semantic.d.ts +0 -32
  465. package/out/parser/semantic/semantic.d.ts.map +0 -1
  466. package/out/parser/semantic/semantic.js +0 -2
  467. package/out/parser/semantic/semantic.js.map +0 -1
  468. package/out/parser/shared.d.ts +0 -62
  469. package/out/parser/shared.d.ts.map +0 -1
  470. package/out/parser/shared.js +0 -56
  471. package/out/parser/shared.js.map +0 -1
  472. package/out/test.d.ts +0 -2
  473. package/out/test.d.ts.map +0 -1
  474. package/out/test.js +0 -7
  475. package/out/test.js.map +0 -1
  476. package/out/tsconfig.build.tsbuildinfo +0 -1
  477. package/parser/semantic/semantic.ts +0 -143
  478. package/parser/shared.ts +0 -170
  479. package/util.ts +0 -36
@@ -0,0 +1,379 @@
1
+ import {
2
+ append,
3
+ appendUnique,
4
+ conflatenateAll,
5
+ entriesOf,
6
+ isArray,
7
+ isEmptyObject,
8
+ omit,
9
+ pick,
10
+ splitByKeys,
11
+ throwInternalError
12
+ } from "@arktype/util"
13
+ import { BaseNode } from "../base.js"
14
+ import { PropsGroup } from "../constraints/props/props.js"
15
+ import { metaKeys } from "../shared/declare.js"
16
+ import { Disjoint } from "../shared/disjoint.js"
17
+ import { constraintKeys, propKeys } from "../shared/implement.js"
18
+ import { BaseType, defineRightwardIntersections } from "./type.js"
19
+ const intersectionChildKeyParser = (kind) => (input, ctx) => {
20
+ if (isArray(input)) {
21
+ if (input.length === 0) {
22
+ // Omit empty lists as input
23
+ return
24
+ }
25
+ return input
26
+ .map((schema) => ctx.$.node(kind, schema))
27
+ .sort((l, r) => (l.innerId < r.innerId ? -1 : 1))
28
+ }
29
+ const node = ctx.$.node(kind, input)
30
+ return node.intersectionIsOpen ? [node] : node
31
+ }
32
+ // readonly literalKeys = this.named.map((prop) => prop.key.name)
33
+ // readonly namedKeyOf = cached(() => node.unit(...this.literalKeys))
34
+ // readonly indexedKeyOf = cached(
35
+ // () =>
36
+ // new Type(
37
+ // this.indexed.flatMap((entry) => entry.key.branches),
38
+ // this.meta
39
+ // )
40
+ // )
41
+ // readonly keyof = cached(() => this.namedKeyOf().or(this.indexedKeyOf()))
42
+ // get(key: string | Type) {
43
+ // return typeof key === "string"
44
+ // ? this.named.find((entry) => entry.value.branches)?.value
45
+ // : this.indexed.find((entry) => entry.key.equals(key))?.value
46
+ // }
47
+ const intersectIntersections = (reduced, raw, $) => {
48
+ // avoid treating adding instance keys as keys of lRoot, rRoot
49
+ if (reduced instanceof IntersectionNode) reduced = reduced.inner
50
+ if (raw instanceof IntersectionNode) raw = raw.inner
51
+ const [reducedConstraintsInner, reducedRoot] = splitByKeys(
52
+ reduced,
53
+ constraintKeys
54
+ )
55
+ const [rawConstraintsInner, rawRoot] = splitByKeys(raw, constraintKeys)
56
+ // since intersection with a left operand of unknown is leveraged for
57
+ // reduction, check for the case where r is empty so we can preserve
58
+ // metadata and save some time
59
+ const root = isEmptyObject(reduced)
60
+ ? rawRoot
61
+ : intersectRootKeys(reducedRoot, rawRoot)
62
+ if (root instanceof Disjoint) return root
63
+ const lConstraints = flattenConstraints(reducedConstraintsInner)
64
+ const rConstraints = flattenConstraints(rawConstraintsInner)
65
+ return intersectConstraints({
66
+ root,
67
+ l: lConstraints,
68
+ r: rConstraints,
69
+ types: [],
70
+ $
71
+ })
72
+ }
73
+ export class IntersectionNode extends BaseType {
74
+ static implementation = this.implement({
75
+ hasAssociatedError: true,
76
+ normalize: (schema) => schema,
77
+ keys: {
78
+ domain: {
79
+ child: true,
80
+ parse: intersectionChildKeyParser("domain")
81
+ },
82
+ proto: {
83
+ child: true,
84
+ parse: intersectionChildKeyParser("proto")
85
+ },
86
+ divisor: {
87
+ child: true,
88
+ parse: intersectionChildKeyParser("divisor")
89
+ },
90
+ max: {
91
+ child: true,
92
+ parse: intersectionChildKeyParser("max")
93
+ },
94
+ min: {
95
+ child: true,
96
+ parse: intersectionChildKeyParser("min")
97
+ },
98
+ maxLength: {
99
+ child: true,
100
+ parse: intersectionChildKeyParser("maxLength")
101
+ },
102
+ minLength: {
103
+ child: true,
104
+ parse: intersectionChildKeyParser("minLength")
105
+ },
106
+ exactLength: {
107
+ child: true,
108
+ parse: intersectionChildKeyParser("exactLength")
109
+ },
110
+ before: {
111
+ child: true,
112
+ parse: intersectionChildKeyParser("before")
113
+ },
114
+ after: {
115
+ child: true,
116
+ parse: intersectionChildKeyParser("after")
117
+ },
118
+ regex: {
119
+ child: true,
120
+ parse: intersectionChildKeyParser("regex")
121
+ },
122
+ predicate: {
123
+ child: true,
124
+ parse: intersectionChildKeyParser("predicate")
125
+ },
126
+ prop: {
127
+ child: true,
128
+ parse: intersectionChildKeyParser("prop")
129
+ },
130
+ index: {
131
+ child: true,
132
+ parse: intersectionChildKeyParser("index")
133
+ },
134
+ sequence: {
135
+ child: true,
136
+ parse: intersectionChildKeyParser("sequence")
137
+ },
138
+ onExtraneousKey: {
139
+ parse: (def) => (def === "ignore" ? undefined : def)
140
+ }
141
+ },
142
+ // leverage reduction logic from intersection and identity to ensure initial
143
+ // parse result is reduced
144
+ reduce: (inner, $) =>
145
+ // we cast union out of the result here since that only occurs when intersecting two sequences
146
+ // that cannot occur when reducing a single intersection schema using unknown
147
+ intersectIntersections({}, inner, $),
148
+ defaults: {
149
+ description(node) {
150
+ return node.children.length === 0
151
+ ? "unknown"
152
+ : node.props?.description ??
153
+ node.children
154
+ .map((child) => child.description)
155
+ .join(" and ")
156
+ },
157
+ expected(source) {
158
+ return (
159
+ " • " + source.errors.map((e) => e.expected).join("\n • ")
160
+ )
161
+ },
162
+ problem(ctx) {
163
+ return `must be...\n${ctx.expected}`
164
+ }
165
+ },
166
+ intersections: {
167
+ intersection: intersectIntersections,
168
+ ...defineRightwardIntersections("intersection", (l, r, $) => {
169
+ // if l is unknown, return r
170
+ if (l.children.length === 0) return r
171
+ const basis = l.basis?.intersect(r) ?? r
172
+ return basis instanceof Disjoint
173
+ ? basis
174
+ : l?.basis?.equals(basis)
175
+ ? // if the basis doesn't change, return the original intesection
176
+ l
177
+ : // given we've already precluded l being unknown, the result must
178
+ // be an intersection with the new basis result integrated
179
+ $.node(
180
+ "intersection",
181
+ Object.assign(omit(l.inner, metaKeys), {
182
+ [basis.kind]: basis
183
+ }),
184
+ { prereduced: true }
185
+ )
186
+ })
187
+ }
188
+ })
189
+ basis = this.domain ?? this.proto
190
+ refinements = this.children.filter((node) => node.isRefinement())
191
+ props = maybeCreatePropsGroup(this.inner, this.$)
192
+ traversables = conflatenateAll(
193
+ this.basis,
194
+ this.refinements,
195
+ this.props,
196
+ this.predicate
197
+ )
198
+ expression =
199
+ this.props?.expression ||
200
+ this.children.map((node) => node.nestableExpression).join(" & ") ||
201
+ "unknown"
202
+ traverseAllows = (data, ctx) =>
203
+ this.traversables.every((traversable) =>
204
+ traversable.traverseAllows(data, ctx)
205
+ )
206
+ traverseApply = (data, ctx) => {
207
+ if (this.basis) {
208
+ this.basis.traverseApply(data, ctx)
209
+ if (ctx.hasError()) return
210
+ }
211
+ if (this.refinements.length) {
212
+ for (let i = 0; i < this.refinements.length - 1; i++) {
213
+ this.refinements[i].traverseApply(data, ctx)
214
+ if (ctx.failFast && ctx.hasError()) return
215
+ }
216
+ this.refinements.at(-1).traverseApply(data, ctx)
217
+ if (ctx.hasError()) return
218
+ }
219
+ if (this.props) {
220
+ this.props.traverseApply(data, ctx)
221
+ if (ctx.hasError()) return
222
+ }
223
+ if (this.predicate) {
224
+ for (let i = 0; i < this.predicate.length - 1; i++) {
225
+ this.predicate[i].traverseApply(data, ctx)
226
+ if (ctx.failFast && ctx.hasError()) return
227
+ }
228
+ this.predicate.at(-1).traverseApply(data, ctx)
229
+ }
230
+ }
231
+ compile(js) {
232
+ if (js.traversalKind === "Allows") {
233
+ this.traversables.forEach((traversable) =>
234
+ traversable instanceof BaseNode
235
+ ? js.check(traversable)
236
+ : traversable.compile(js)
237
+ )
238
+ js.return(true)
239
+ return
240
+ }
241
+ const returnIfFail = () => js.if("ctx.hasError()", () => js.return())
242
+ const returnIfFailFast = () =>
243
+ js.if("ctx.failFast && ctx.hasError()", () => js.return())
244
+ if (this.basis) {
245
+ js.check(this.basis)
246
+ // we only have to return conditionally if this is not the last check
247
+ if (this.traversables.length > 1) returnIfFail()
248
+ }
249
+ if (this.refinements.length) {
250
+ for (let i = 0; i < this.refinements.length - 1; i++) {
251
+ js.check(this.refinements[i])
252
+ returnIfFailFast()
253
+ }
254
+ js.check(this.refinements.at(-1))
255
+ if (this.props || this.predicate) returnIfFail()
256
+ }
257
+ if (this.props) {
258
+ this.props.compile(js)
259
+ if (this.predicate) returnIfFail()
260
+ }
261
+ if (this.predicate) {
262
+ for (let i = 0; i < this.predicate.length - 1; i++) {
263
+ js.check(this.predicate[i])
264
+ // since predicates can be chained, we have to fail immediately
265
+ // if one fails
266
+ returnIfFail()
267
+ }
268
+ js.check(this.predicate.at(-1))
269
+ }
270
+ }
271
+ rawKeyOf() {
272
+ return this.basis
273
+ ? this.props
274
+ ? this.basis.rawKeyOf().or(this.props.rawKeyOf())
275
+ : this.basis.rawKeyOf()
276
+ : this.props?.rawKeyOf() ?? this.$.keywords.never
277
+ }
278
+ }
279
+ const maybeCreatePropsGroup = (inner, $) => {
280
+ const propsInput = pick(inner, propKeys)
281
+ return isEmptyObject(propsInput) ? undefined : new PropsGroup(propsInput, $)
282
+ }
283
+ const intersectRootKeys = (l, r) => {
284
+ const result = {}
285
+ const lBasis = l.proto ?? l.domain
286
+ const rBasis = r.proto ?? r.domain
287
+ const resultBasis = lBasis
288
+ ? rBasis
289
+ ? lBasis.intersect(rBasis)
290
+ : lBasis
291
+ : rBasis
292
+ if (resultBasis) {
293
+ if (resultBasis instanceof Disjoint) {
294
+ return resultBasis
295
+ }
296
+ if (resultBasis.kind === "domain" || resultBasis.kind === "proto") {
297
+ result[resultBasis.kind] = resultBasis
298
+ } else {
299
+ return throwInternalError(
300
+ `Unexpected intersection basis intersection ${resultBasis}`
301
+ )
302
+ }
303
+ }
304
+ if (l.onExtraneousKey || r.onExtraneousKey) {
305
+ result.onExtraneousKey =
306
+ l.onExtraneousKey === "throw" || r.onExtraneousKey === "throw"
307
+ ? "throw"
308
+ : "prune"
309
+ }
310
+ return result
311
+ }
312
+ const intersectConstraints = (s) => {
313
+ if (!s.r.length) {
314
+ let result = s.$.node(
315
+ "intersection",
316
+ Object.assign(s.root, unflattenConstraints(s.l)),
317
+ { prereduced: true }
318
+ )
319
+ for (const type of s.types) {
320
+ if (result instanceof Disjoint) {
321
+ return result
322
+ }
323
+ result = type.intersect(result)
324
+ }
325
+ return result
326
+ }
327
+ const head = s.r.shift()
328
+ let matched = false
329
+ for (let i = 0; i < s.l.length; i++) {
330
+ const result = s.l[i].intersect(head)
331
+ if (result === null) continue
332
+ if (result instanceof Disjoint) return result
333
+ if (!matched) {
334
+ if (result.isType()) s.types.push(result)
335
+ else s.l[i] = result
336
+ matched = true
337
+ } else if (!s.l.includes(result)) {
338
+ return throwInternalError(
339
+ `Unexpectedly encountered multiple distinct intersection results for refinement ${result}`
340
+ )
341
+ }
342
+ }
343
+ if (!matched) {
344
+ s.l.push(head)
345
+ }
346
+ head.impliedSiblings?.forEach((node) => appendUnique(s.r, node))
347
+ return intersectConstraints(s)
348
+ }
349
+ const flattenConstraints = (inner) => {
350
+ const result = entriesOf(inner)
351
+ .flatMap(([k, v]) => (k in constraintKeys ? v : []))
352
+ .sort((l, r) =>
353
+ l.precedence < r.precedence
354
+ ? -1
355
+ : l.precedence > r.precedence
356
+ ? 1
357
+ : l.innerId < r.innerId
358
+ ? -1
359
+ : 1
360
+ )
361
+ return result
362
+ }
363
+ const unflattenConstraints = (constraints) => {
364
+ const inner = {}
365
+ for (const constraint of constraints) {
366
+ if (constraint.intersectionIsOpen) {
367
+ inner[constraint.kind] = append(inner[constraint.kind], constraint)
368
+ } else {
369
+ if (inner[constraint.kind]) {
370
+ return throwInternalError(
371
+ `Unexpected intersection of closed refinements of kind ${constraint.kind}`
372
+ )
373
+ }
374
+ inner[constraint.kind] = constraint
375
+ }
376
+ }
377
+ return inner
378
+ }
379
+ //# sourceMappingURL=intersection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"intersection.js","sourceRoot":"","sources":["../../types/intersection.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,MAAM,EACN,YAAY,EACZ,eAAe,EACf,SAAS,EACT,OAAO,EACP,aAAa,EACb,IAAI,EACJ,IAAI,EACJ,WAAW,EACX,kBAAkB,EAIlB,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,QAAQ,EAAkC,MAAM,YAAY,CAAA;AACrE,OAAO,EACN,UAAU,EAGV,MAAM,+BAA+B,CAAA;AAKtC,OAAO,EAAE,QAAQ,EAAmC,MAAM,sBAAsB,CAAA;AAChF,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAEhD,OAAO,EACN,cAAc,EACd,QAAQ,EAOR,MAAM,wBAAwB,CAAA;AAI/B,OAAO,EAAE,QAAQ,EAAE,4BAA4B,EAAa,MAAM,WAAW,CAAA;AAgC7E,MAAM,0BAA0B,GAC/B,CAAqC,IAAU,EAAE,EAAE,CACnD,CACC,KAA6B,EAC7B,GAAuB,EAC2B,EAAE;IACpD,IAAI,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACpB,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACxB,4BAA4B;YAC5B,OAAM;QACP,CAAC;QACD,OAAO,KAAK;aACV,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,MAAe,CAAC,CAAC;aAClD,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EA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C,CAAA"}
@@ -0,0 +1,157 @@
1
+ import {
2
+ type BuiltinObjectKind,
3
+ type BuiltinObjects,
4
+ type Primitive,
5
+ type array,
6
+ type listable
7
+ } from "@arktype/util"
8
+ import type { Node } from "../base.js"
9
+ import type { of } from "../constraints/ast.js"
10
+ import type { Schema } from "../kinds.js"
11
+ import type { StaticArkOption } from "../scope.js"
12
+ import type { NodeCompiler } from "../shared/compile.js"
13
+ import type { BaseMeta, declareNode } from "../shared/declare.js"
14
+ import type { ArkResult, ArkTypeError } from "../shared/errors.js"
15
+ import { type nodeImplementationOf } from "../shared/implement.js"
16
+ import type {
17
+ TraversalContext,
18
+ TraverseAllows,
19
+ TraverseApply
20
+ } from "../shared/traversal.js"
21
+ import { BaseType, type Type, type typeKindRightOf } from "./type.js"
22
+ export type MorphChildKind = typeKindRightOf<"morph">
23
+ export declare const morphChildKinds: readonly [
24
+ "intersection",
25
+ "unit",
26
+ "proto",
27
+ "domain"
28
+ ]
29
+ export type MorphChildNode = Node<MorphChildKind>
30
+ export type MorphChildDefinition = Schema<MorphChildKind>
31
+ export type Morph<i = any, o = unknown> = (In: i, ctx: TraversalContext) => o
32
+ export type Out<o = any> = ["=>", o]
33
+ export type MorphAst<i = any, o = any> = (In: i) => Out<o>
34
+ export interface MorphInner extends BaseMeta {
35
+ readonly in: MorphChildNode
36
+ readonly out: MorphChildNode
37
+ readonly morphs: readonly Morph[]
38
+ }
39
+ export interface MorphSchema extends BaseMeta {
40
+ readonly in: MorphChildDefinition
41
+ readonly out?: MorphChildDefinition
42
+ readonly morphs: listable<Morph>
43
+ }
44
+ export type MorphDeclaration = declareNode<{
45
+ kind: "morph"
46
+ schema: MorphSchema
47
+ normalizedSchema: MorphSchema
48
+ inner: MorphInner
49
+ childKind: MorphChildKind
50
+ }>
51
+ export declare class MorphNode<t = any, $ = any> extends BaseType<
52
+ t,
53
+ MorphDeclaration,
54
+ $
55
+ > {
56
+ static implementation: nodeImplementationOf<MorphDeclaration>
57
+ readonly expression: string
58
+ readonly serializedMorphs: `$ark.${string}`[]
59
+ traverseAllows: TraverseAllows
60
+ traverseApply: TraverseApply
61
+ compile(js: NodeCompiler): void
62
+ get in(): Node<MorphChildKind, distillConstrainableIn<t>>
63
+ get out(): Node<MorphChildKind, distillConstrainableOut<t>>
64
+ rawKeyOf(): Type
65
+ }
66
+ export type inferMorphOut<out> = out extends ArkResult<unknown, infer innerOut>
67
+ ? out extends null
68
+ ? out
69
+ : innerOut
70
+ : Exclude<out, ArkTypeError>
71
+ export type distillIn<t> = includesMorphs<t> extends true
72
+ ? distillRecurse<t, "in", "base">
73
+ : t
74
+ export type distillOut<t> = includesMorphs<t> extends true
75
+ ? distillRecurse<t, "out", "base">
76
+ : t
77
+ export type distillConstrainableIn<t> = includesMorphs<t> extends true
78
+ ? distillRecurse<t, "in", "constrainable">
79
+ : t
80
+ export type distillConstrainableOut<t> = includesMorphs<t> extends true
81
+ ? distillRecurse<t, "out", "constrainable">
82
+ : t
83
+ export type includesMorphs<t> = [
84
+ t,
85
+ distillRecurse<t, "in", "base">,
86
+ t,
87
+ distillRecurse<t, "out", "base">
88
+ ] extends [
89
+ distillRecurse<t, "in", "base">,
90
+ t,
91
+ distillRecurse<t, "out", "base">,
92
+ t
93
+ ]
94
+ ? false
95
+ : true
96
+ type distillRecurse<
97
+ t,
98
+ io extends "in" | "out",
99
+ distilledKind extends "base" | "constrainable"
100
+ > = unknown extends t
101
+ ? unknown
102
+ : t extends MorphAst<infer i, infer o>
103
+ ? io extends "in"
104
+ ? i
105
+ : o
106
+ : t extends of<infer base, any>
107
+ ? distilledKind extends "base"
108
+ ? distillRecurse<base, io, distilledKind>
109
+ : t
110
+ : t extends TerminallyInferredObjectKind | Primitive
111
+ ? t
112
+ : t extends array
113
+ ? distillArray<t, io, distilledKind, []>
114
+ : {
115
+ [k in keyof t]: distillRecurse<
116
+ t[k],
117
+ io,
118
+ distilledKind
119
+ >
120
+ }
121
+ type distillArray<
122
+ t extends array,
123
+ io extends "in" | "out",
124
+ constraints extends "base" | "constrainable",
125
+ prefix extends array
126
+ > = t extends readonly [infer head, ...infer tail]
127
+ ? distillArray<
128
+ tail,
129
+ io,
130
+ constraints,
131
+ [...prefix, distillRecurse<head, io, constraints>]
132
+ >
133
+ : [...prefix, ...distillPostfix<t, io, constraints>]
134
+ type distillPostfix<
135
+ t extends array,
136
+ io extends "in" | "out",
137
+ constraints extends "base" | "constrainable",
138
+ postfix extends array = []
139
+ > = t extends readonly [...infer init, infer last]
140
+ ? distillPostfix<
141
+ init,
142
+ io,
143
+ constraints,
144
+ [distillRecurse<last, io, constraints>, ...postfix]
145
+ >
146
+ : [
147
+ ...{
148
+ [i in keyof t]: distillRecurse<t[i], io, constraints>
149
+ },
150
+ ...postfix
151
+ ]
152
+ /** Objects we don't want to expand during inference like Date or Promise */
153
+ type TerminallyInferredObjectKind =
154
+ | StaticArkOption<"preserve">
155
+ | BuiltinObjects[Exclude<BuiltinObjectKind, "Array">]
156
+ export {}
157
+ //# sourceMappingURL=morph.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"morph.d.ts","sourceRoot":"","sources":["../../types/morph.ts"],"names":[],"mappings":"AAAA,OAAO,EAIN,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,SAAS,EACd,KAAK,KAAK,EACV,KAAK,QAAQ,EACb,MAAM,eAAe,CAAA;AACtB,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AACtC,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,uBAAuB,CAAA;AAC/C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACxD,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAEjE,OAAO,KAAK,EAAE,SAAS,EAAE,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iB,EAAE,OAAO,CAAC,CAAC,CAAA"}
@@ -0,0 +1,99 @@
1
+ import { listFrom, reference, throwParseError } from "@arktype/util"
2
+ import { Disjoint } from "../shared/disjoint.js"
3
+ import { basisKinds } from "../shared/implement.js"
4
+ import { BaseType, defineRightwardIntersections } from "./type.js"
5
+ export const morphChildKinds = ["intersection", ...basisKinds]
6
+ export class MorphNode extends BaseType {
7
+ // TODO: recursively extract in?
8
+ static implementation = this.implement({
9
+ hasAssociatedError: false,
10
+ keys: {
11
+ in: {
12
+ child: true,
13
+ parse: (schema, ctx) =>
14
+ ctx.$.node(schema, { allowedKinds: morphChildKinds })
15
+ },
16
+ out: {
17
+ child: true,
18
+ parse: (schema, ctx) =>
19
+ ctx.$.node(schema, { allowedKinds: morphChildKinds })
20
+ },
21
+ morphs: {
22
+ parse: listFrom,
23
+ serialize: (morphs) => morphs.map(reference)
24
+ }
25
+ },
26
+ normalize: (schema) => schema,
27
+ defaults: {
28
+ description(node) {
29
+ return `a morph from ${node.in.description} to ${node.out.description}`
30
+ }
31
+ },
32
+ intersections: {
33
+ morph: (l, r, $) => {
34
+ if (l.morphs.some((morph, i) => morph !== r.morphs[i])) {
35
+ // TODO: is this always a parse error? what about for union reduction etc.
36
+ // TODO: check in for union reduction
37
+ return throwParseError(`Invalid intersection of morphs`)
38
+ }
39
+ const inTersection = l.in.intersect(r.in)
40
+ if (inTersection instanceof Disjoint) {
41
+ return inTersection
42
+ }
43
+ const outTersection = l.out.intersect(r.out)
44
+ if (outTersection instanceof Disjoint) {
45
+ return outTersection
46
+ }
47
+ return $.node("morph", {
48
+ morphs: l.morphs,
49
+ in: inTersection,
50
+ out: outTersection
51
+ })
52
+ },
53
+ ...defineRightwardIntersections("morph", (l, r, $) => {
54
+ const inTersection = l.in.intersect(r)
55
+ return inTersection instanceof Disjoint
56
+ ? inTersection
57
+ : inTersection.kind === "union"
58
+ ? $.node(
59
+ "union",
60
+ inTersection.branches.map((branch) => ({
61
+ ...l.inner,
62
+ in: branch
63
+ }))
64
+ )
65
+ : $.node("morph", {
66
+ ...l.inner,
67
+ in: inTersection
68
+ })
69
+ })
70
+ }
71
+ })
72
+ expression = `(In: ${this.in.expression}) => Out<${this.out.expression}>`
73
+ serializedMorphs = this.morphs.map((morph) => reference(morph))
74
+ traverseAllows = (data, ctx) => this.in.traverseAllows(data, ctx)
75
+ traverseApply = (data, ctx) => {
76
+ this.morphs.forEach((morph) => ctx.queueMorph(morph))
77
+ this.in.traverseApply(data, ctx)
78
+ }
79
+ compile(js) {
80
+ if (js.traversalKind === "Allows") {
81
+ js.return(js.invoke(this.in))
82
+ return
83
+ }
84
+ this.serializedMorphs.forEach((name) =>
85
+ js.line(`ctx.queueMorph(${name})`)
86
+ )
87
+ js.line(js.invoke(this.in))
88
+ }
89
+ get in() {
90
+ return this.inner.in
91
+ }
92
+ get out() {
93
+ return this.inner.out ?? this.$.keywords.unknown
94
+ }
95
+ rawKeyOf() {
96
+ return this.in.rawKeyOf()
97
+ }
98
+ }
99
+ //# sourceMappingURL=morph.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"morph.js","sourceRoot":"","sources":["../../types/morph.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,QAAQ,EACR,SAAS,EACT,eAAe,EAMf,MAAM,eAAe,CAAA;AAOtB,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAEhD,OAAO,EAAE,UAAU,EAA6B,MAAM,wBAAwB,CAAA;AAM9E,OAAO,EACN,QAAQ,EACR,4BAA4B,EAG5B,MAAM,WAAW,CAAA;AAIlB,MAAM,CAAC,MAAM,eAAe,GAAG;IAC9B,cAAc;IACd,GAAG,UAAU;CACgC,CAAA;AAgC9C,MAAM,OAAO,SAA4B,SAAQ,QAIhD;IACA,gCAAgC;IAChC,MAAM,CAAC,cAAc,GACpB,IAAI,CAAC,SAAS,CAAC;QACd,kBAAkB,EAAE,KAAK;QACzB,IAAI,EAAE;YACL,EAAE,EAAE;gBACH,KAAK,EAA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