arktype 2.0.0-dev.8 → 2.0.0-rc.0

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 (562) hide show
  1. package/LICENSE +7 -0
  2. package/out/config.d.ts +25 -9
  3. package/out/config.js +2 -18
  4. package/out/generic.d.ts +154 -19
  5. package/out/generic.js +37 -24
  6. package/out/index.d.ts +7 -0
  7. package/out/index.js +6 -0
  8. package/out/intersect.d.ts +28 -0
  9. package/out/intersect.js +1 -0
  10. package/out/keys.d.ts +16 -0
  11. package/out/keys.js +1 -0
  12. package/out/keywords/ark.d.ts +29 -66
  13. package/out/keywords/ark.js +18 -29
  14. package/out/keywords/ast.d.ts +193 -0
  15. package/out/keywords/ast.js +2 -0
  16. package/out/keywords/builtin.d.ts +13 -0
  17. package/out/keywords/builtin.js +10 -0
  18. package/out/keywords/constructors/Array.d.ts +16 -0
  19. package/out/keywords/constructors/Array.js +19 -0
  20. package/out/keywords/constructors/FormData.d.ts +9 -0
  21. package/out/keywords/constructors/FormData.js +25 -0
  22. package/out/keywords/constructors/TypedArray.d.ts +15 -0
  23. package/out/keywords/constructors/TypedArray.js +14 -0
  24. package/out/keywords/constructors/constructors.d.ts +41 -0
  25. package/out/keywords/constructors/constructors.js +31 -0
  26. package/out/keywords/number/epoch.d.ts +10 -0
  27. package/out/keywords/number/epoch.js +26 -0
  28. package/out/keywords/number/integer.d.ts +3 -0
  29. package/out/keywords/number/integer.js +5 -0
  30. package/out/keywords/number/number.d.ts +26 -0
  31. package/out/keywords/number/number.js +9 -0
  32. package/out/keywords/string/alpha.d.ts +7 -0
  33. package/out/keywords/string/alpha.js +2 -0
  34. package/out/keywords/string/alphanumeric.d.ts +7 -0
  35. package/out/keywords/string/alphanumeric.js +2 -0
  36. package/out/keywords/string/capitalize.d.ts +14 -0
  37. package/out/keywords/string/capitalize.js +12 -0
  38. package/out/keywords/string/creditCard.d.ts +8 -0
  39. package/out/keywords/string/creditCard.js +37 -0
  40. package/out/keywords/string/date.d.ts +54 -0
  41. package/out/keywords/string/date.js +98 -0
  42. package/out/keywords/string/digits.d.ts +7 -0
  43. package/out/keywords/string/digits.js +2 -0
  44. package/out/keywords/string/email.d.ts +7 -0
  45. package/out/keywords/string/email.js +4 -0
  46. package/out/keywords/string/integer.d.ts +15 -0
  47. package/out/keywords/string/integer.js +16 -0
  48. package/out/keywords/string/ip.d.ts +20 -0
  49. package/out/keywords/string/ip.js +23 -0
  50. package/out/keywords/string/json.d.ts +14 -0
  51. package/out/keywords/string/json.js +45 -0
  52. package/out/keywords/string/lower.d.ts +14 -0
  53. package/out/keywords/string/lower.js +12 -0
  54. package/out/keywords/string/normalize.d.ts +72 -0
  55. package/out/keywords/string/normalize.js +43 -0
  56. package/out/keywords/string/numeric.d.ts +14 -0
  57. package/out/keywords/string/numeric.js +13 -0
  58. package/out/keywords/string/semver.d.ts +7 -0
  59. package/out/keywords/string/semver.js +4 -0
  60. package/out/keywords/string/string.d.ts +57 -0
  61. package/out/keywords/string/string.js +41 -0
  62. package/out/keywords/string/trim.d.ts +14 -0
  63. package/out/keywords/string/trim.js +14 -0
  64. package/out/keywords/string/upper.d.ts +14 -0
  65. package/out/keywords/string/upper.js +12 -0
  66. package/out/keywords/string/url.d.ts +14 -0
  67. package/out/keywords/string/url.js +37 -0
  68. package/out/keywords/string/utils.d.ts +2 -0
  69. package/out/keywords/string/utils.js +10 -0
  70. package/out/keywords/string/uuid.d.ts +38 -0
  71. package/out/keywords/string/uuid.js +19 -0
  72. package/out/keywords/ts.d.ts +53 -0
  73. package/out/keywords/ts.js +51 -0
  74. package/out/keywords/utils.d.ts +1 -0
  75. package/out/keywords/utils.js +2 -0
  76. package/out/module.d.ts +21 -10
  77. package/out/module.js +3 -4
  78. package/out/parser/definition.d.ts +21 -17
  79. package/out/parser/definition.js +5 -6
  80. package/out/parser/objectLiteral.d.ts +54 -37
  81. package/out/parser/objectLiteral.js +75 -43
  82. package/out/parser/semantic/bounds.d.ts +11 -11
  83. package/out/parser/semantic/bounds.js +0 -1
  84. package/out/parser/semantic/default.d.ts +8 -0
  85. package/out/parser/semantic/default.js +1 -0
  86. package/out/parser/semantic/divisor.d.ts +5 -6
  87. package/out/parser/semantic/divisor.js +0 -1
  88. package/out/parser/semantic/infer.d.ts +21 -13
  89. package/out/parser/semantic/infer.js +0 -1
  90. package/out/parser/semantic/keyof.d.ts +7 -0
  91. package/out/parser/semantic/keyof.js +1 -0
  92. package/out/parser/semantic/utils.d.ts +3 -4
  93. package/out/parser/semantic/utils.js +0 -1
  94. package/out/parser/semantic/validate.d.ts +21 -18
  95. package/out/parser/semantic/validate.js +0 -2
  96. package/out/parser/string/reduce/dynamic.d.ts +16 -15
  97. package/out/parser/string/reduce/dynamic.js +8 -8
  98. package/out/parser/string/reduce/shared.d.ts +17 -30
  99. package/out/parser/string/reduce/shared.js +4 -3
  100. package/out/parser/string/reduce/static.d.ts +22 -24
  101. package/out/parser/string/reduce/static.js +0 -1
  102. package/out/parser/string/shift/operand/date.d.ts +3 -6
  103. package/out/parser/string/shift/operand/date.js +1 -2
  104. package/out/parser/string/shift/operand/enclosed.d.ts +5 -16
  105. package/out/parser/string/shift/operand/enclosed.js +5 -5
  106. package/out/parser/string/shift/operand/genericArgs.d.ts +13 -14
  107. package/out/parser/string/shift/operand/genericArgs.js +7 -13
  108. package/out/parser/string/shift/operand/operand.d.ts +8 -8
  109. package/out/parser/string/shift/operand/operand.js +5 -7
  110. package/out/parser/string/shift/operand/unenclosed.d.ts +31 -19
  111. package/out/parser/string/shift/operand/unenclosed.js +10 -15
  112. package/out/parser/string/shift/operator/bounds.d.ts +15 -27
  113. package/out/parser/string/shift/operator/bounds.js +11 -17
  114. package/out/parser/string/shift/operator/default.d.ts +19 -0
  115. package/out/parser/string/shift/operator/default.js +17 -0
  116. package/out/parser/string/shift/operator/divisor.d.ts +4 -5
  117. package/out/parser/string/shift/operator/divisor.js +1 -2
  118. package/out/parser/string/shift/operator/operator.d.ts +8 -8
  119. package/out/parser/string/shift/operator/operator.js +1 -2
  120. package/out/parser/string/shift/scanner.d.ts +26 -31
  121. package/out/parser/string/shift/scanner.js +23 -21
  122. package/out/parser/string/string.d.ts +14 -12
  123. package/out/parser/string/string.js +5 -3
  124. package/out/parser/tuple.d.ts +22 -21
  125. package/out/parser/tuple.js +12 -24
  126. package/out/scope.d.ts +102 -55
  127. package/out/scope.js +61 -60
  128. package/out/subtypes/array.d.ts +13 -0
  129. package/out/subtypes/array.js +1 -0
  130. package/out/subtypes/base.d.ts +84 -0
  131. package/out/subtypes/base.js +1 -0
  132. package/out/subtypes/date.d.ts +11 -0
  133. package/out/subtypes/date.js +1 -0
  134. package/out/subtypes/instantiate.d.ts +16 -0
  135. package/out/subtypes/instantiate.js +1 -0
  136. package/out/subtypes/morph.d.ts +13 -0
  137. package/out/subtypes/morph.js +1 -0
  138. package/out/subtypes/number.d.ts +12 -0
  139. package/out/subtypes/number.js +1 -0
  140. package/out/subtypes/object.d.ts +33 -0
  141. package/out/subtypes/object.js +1 -0
  142. package/out/subtypes/string.d.ts +13 -0
  143. package/out/subtypes/string.js +1 -0
  144. package/out/subtypes/validator.d.ts +11 -0
  145. package/out/subtypes/validator.js +1 -0
  146. package/out/type.d.ts +30 -50
  147. package/out/type.js +19 -15
  148. package/package.json +46 -43
  149. package/__tests__/array.test.ts +0 -391
  150. package/__tests__/badDefinitionType.test.ts +0 -58
  151. package/__tests__/basis.test.ts +0 -50
  152. package/__tests__/bounds.test.ts +0 -318
  153. package/__tests__/cast.test.ts +0 -37
  154. package/__tests__/completions.test.ts +0 -51
  155. package/__tests__/config.test.ts +0 -85
  156. package/__tests__/cyclic.test.ts +0 -148
  157. package/__tests__/dateLiteral.test.ts +0 -36
  158. package/__tests__/declared.test.ts +0 -124
  159. package/__tests__/discrimination.test.ts +0 -74
  160. package/__tests__/divisor.test.ts +0 -114
  161. package/__tests__/enclosed.test.ts +0 -107
  162. package/__tests__/examples.test.ts +0 -56
  163. package/__tests__/expressions.test.ts +0 -210
  164. package/__tests__/generateBenchData.ts +0 -89
  165. package/__tests__/generated/cyclic.ts +0 -3058
  166. package/__tests__/generic.test.ts +0 -313
  167. package/__tests__/group.test.ts +0 -85
  168. package/__tests__/hkt.test.ts +0 -22
  169. package/__tests__/imports.test.ts +0 -120
  170. package/__tests__/instanceof.test.ts +0 -104
  171. package/__tests__/intersection.test.ts +0 -108
  172. package/__tests__/keyTraversal.test.ts +0 -77
  173. package/__tests__/keyof.test.ts +0 -150
  174. package/__tests__/keywords.test.ts +0 -214
  175. package/__tests__/literal.test.ts +0 -74
  176. package/__tests__/match.bench.ts +0 -31
  177. package/__tests__/match.test.ts +0 -234
  178. package/__tests__/methods.bench.ts +0 -22
  179. package/__tests__/narrow.test.ts +0 -100
  180. package/__tests__/object.bench.ts +0 -28
  181. package/__tests__/objectLiteral.test.ts +0 -319
  182. package/__tests__/operand.bench.ts +0 -45
  183. package/__tests__/operator.bench.ts +0 -130
  184. package/__tests__/pipe.test.ts +0 -501
  185. package/__tests__/realWorld.test.ts +0 -63
  186. package/__tests__/regex.test.ts +0 -68
  187. package/__tests__/scope.bench.ts +0 -39
  188. package/__tests__/scope.test.ts +0 -177
  189. package/__tests__/serialization.test.ts +0 -19
  190. package/__tests__/string.test.ts +0 -52
  191. package/__tests__/submodule.test.ts +0 -86
  192. package/__tests__/this.test.ts +0 -83
  193. package/__tests__/thunk.test.ts +0 -86
  194. package/__tests__/traverse.test.ts +0 -133
  195. package/__tests__/tsGenerics.test.ts +0 -12
  196. package/__tests__/type.test.ts +0 -36
  197. package/__tests__/typeReference.test.ts +0 -39
  198. package/__tests__/unenclosed.test.ts +0 -136
  199. package/__tests__/union.test.ts +0 -214
  200. package/ark.ts +0 -47
  201. package/generic.ts +0 -69
  202. package/main.ts +0 -6
  203. package/match.ts +0 -218
  204. package/module.ts +0 -15
  205. package/out/ark.d.ts +0 -29
  206. package/out/ark.d.ts.map +0 -1
  207. package/out/ark.js +0 -11
  208. package/out/ark.js.map +0 -1
  209. package/out/base.d.ts +0 -205
  210. package/out/base.d.ts.map +0 -1
  211. package/out/base.js +0 -320
  212. package/out/base.js.map +0 -1
  213. package/out/builtins/builtins.d.ts +0 -23
  214. package/out/builtins/builtins.d.ts.map +0 -1
  215. package/out/builtins/builtins.js +0 -15
  216. package/out/builtins/builtins.js.map +0 -1
  217. package/out/builtins/jsObjects.d.ts +0 -19
  218. package/out/builtins/jsObjects.d.ts.map +0 -1
  219. package/out/builtins/jsObjects.js +0 -18
  220. package/out/builtins/jsObjects.js.map +0 -1
  221. package/out/builtins/parsing.d.ts +0 -16
  222. package/out/builtins/parsing.d.ts.map +0 -1
  223. package/out/builtins/parsing.js +0 -62
  224. package/out/builtins/parsing.js.map +0 -1
  225. package/out/builtins/tsGenerics.d.ts +0 -2
  226. package/out/builtins/tsGenerics.d.ts.map +0 -1
  227. package/out/builtins/tsGenerics.js +0 -26
  228. package/out/builtins/tsGenerics.js.map +0 -1
  229. package/out/builtins/tsKeywords.d.ts +0 -23
  230. package/out/builtins/tsKeywords.d.ts.map +0 -1
  231. package/out/builtins/tsKeywords.js +0 -23
  232. package/out/builtins/tsKeywords.js.map +0 -1
  233. package/out/builtins/utils/creditCard.d.ts +0 -3
  234. package/out/builtins/utils/creditCard.d.ts.map +0 -1
  235. package/out/builtins/utils/creditCard.js +0 -35
  236. package/out/builtins/utils/creditCard.js.map +0 -1
  237. package/out/builtins/utils/date.d.ts +0 -41
  238. package/out/builtins/utils/date.d.ts.map +0 -1
  239. package/out/builtins/utils/date.js +0 -56
  240. package/out/builtins/utils/date.js.map +0 -1
  241. package/out/builtins/validation.d.ts +0 -19
  242. package/out/builtins/validation.d.ts.map +0 -1
  243. package/out/builtins/validation.js +0 -74
  244. package/out/builtins/validation.js.map +0 -1
  245. package/out/config.d.ts.map +0 -1
  246. package/out/config.js.map +0 -1
  247. package/out/constraints/ast.d.ts +0 -287
  248. package/out/constraints/ast.d.ts.map +0 -1
  249. package/out/constraints/ast.js +0 -2
  250. package/out/constraints/ast.js.map +0 -1
  251. package/out/constraints/constraint.d.ts +0 -200
  252. package/out/constraints/constraint.d.ts.map +0 -1
  253. package/out/constraints/constraint.js +0 -25
  254. package/out/constraints/constraint.js.map +0 -1
  255. package/out/constraints/predicate.d.ts +0 -64
  256. package/out/constraints/predicate.d.ts.map +0 -1
  257. package/out/constraints/predicate.js +0 -52
  258. package/out/constraints/predicate.js.map +0 -1
  259. package/out/constraints/props/index.d.ts +0 -42
  260. package/out/constraints/props/index.d.ts.map +0 -1
  261. package/out/constraints/props/index.js +0 -56
  262. package/out/constraints/props/index.js.map +0 -1
  263. package/out/constraints/props/optional.d.ts +0 -37
  264. package/out/constraints/props/optional.d.ts.map +0 -1
  265. package/out/constraints/props/optional.js +0 -56
  266. package/out/constraints/props/optional.js.map +0 -1
  267. package/out/constraints/props/prop.d.ts +0 -49
  268. package/out/constraints/props/prop.d.ts.map +0 -1
  269. package/out/constraints/props/prop.js +0 -106
  270. package/out/constraints/props/prop.js.map +0 -1
  271. package/out/constraints/props/props.d.ts +0 -37
  272. package/out/constraints/props/props.d.ts.map +0 -1
  273. package/out/constraints/props/props.js +0 -121
  274. package/out/constraints/props/props.js.map +0 -1
  275. package/out/constraints/props/required.d.ts +0 -46
  276. package/out/constraints/props/required.d.ts.map +0 -1
  277. package/out/constraints/props/required.js +0 -81
  278. package/out/constraints/props/required.js.map +0 -1
  279. package/out/constraints/props/sequence.d.ts +0 -82
  280. package/out/constraints/props/sequence.d.ts.map +0 -1
  281. package/out/constraints/props/sequence.js +0 -376
  282. package/out/constraints/props/sequence.js.map +0 -1
  283. package/out/constraints/props/shared.d.ts +0 -3
  284. package/out/constraints/props/shared.d.ts.map +0 -1
  285. package/out/constraints/props/shared.js +0 -4
  286. package/out/constraints/props/shared.js.map +0 -1
  287. package/out/constraints/refinements/after.d.ts +0 -33
  288. package/out/constraints/refinements/after.d.ts.map +0 -1
  289. package/out/constraints/refinements/after.js +0 -36
  290. package/out/constraints/refinements/after.js.map +0 -1
  291. package/out/constraints/refinements/before.d.ts +0 -33
  292. package/out/constraints/refinements/before.d.ts.map +0 -1
  293. package/out/constraints/refinements/before.js +0 -43
  294. package/out/constraints/refinements/before.js.map +0 -1
  295. package/out/constraints/refinements/divisor.d.ts +0 -52
  296. package/out/constraints/refinements/divisor.d.ts.map +0 -1
  297. package/out/constraints/refinements/divisor.js +0 -52
  298. package/out/constraints/refinements/divisor.js.map +0 -1
  299. package/out/constraints/refinements/exactLength.d.ts +0 -45
  300. package/out/constraints/refinements/exactLength.d.ts.map +0 -1
  301. package/out/constraints/refinements/exactLength.js +0 -52
  302. package/out/constraints/refinements/exactLength.js.map +0 -1
  303. package/out/constraints/refinements/kinds.d.ts +0 -29
  304. package/out/constraints/refinements/kinds.d.ts.map +0 -1
  305. package/out/constraints/refinements/kinds.js +0 -17
  306. package/out/constraints/refinements/kinds.js.map +0 -1
  307. package/out/constraints/refinements/length.d.ts +0 -48
  308. package/out/constraints/refinements/length.d.ts.map +0 -1
  309. package/out/constraints/refinements/length.js +0 -53
  310. package/out/constraints/refinements/length.js.map +0 -1
  311. package/out/constraints/refinements/max.d.ts +0 -31
  312. package/out/constraints/refinements/max.d.ts.map +0 -1
  313. package/out/constraints/refinements/max.js +0 -35
  314. package/out/constraints/refinements/max.js.map +0 -1
  315. package/out/constraints/refinements/maxLength.d.ts +0 -32
  316. package/out/constraints/refinements/maxLength.d.ts.map +0 -1
  317. package/out/constraints/refinements/maxLength.js +0 -36
  318. package/out/constraints/refinements/maxLength.js.map +0 -1
  319. package/out/constraints/refinements/min.d.ts +0 -31
  320. package/out/constraints/refinements/min.d.ts.map +0 -1
  321. package/out/constraints/refinements/min.js +0 -28
  322. package/out/constraints/refinements/min.js.map +0 -1
  323. package/out/constraints/refinements/minLength.d.ts +0 -32
  324. package/out/constraints/refinements/minLength.d.ts.map +0 -1
  325. package/out/constraints/refinements/minLength.js +0 -33
  326. package/out/constraints/refinements/minLength.js.map +0 -1
  327. package/out/constraints/refinements/range.d.ts +0 -119
  328. package/out/constraints/refinements/range.d.ts.map +0 -1
  329. package/out/constraints/refinements/range.js +0 -89
  330. package/out/constraints/refinements/range.js.map +0 -1
  331. package/out/constraints/refinements/regex.d.ts +0 -47
  332. package/out/constraints/refinements/regex.d.ts.map +0 -1
  333. package/out/constraints/refinements/regex.js +0 -37
  334. package/out/constraints/refinements/regex.js.map +0 -1
  335. package/out/constraints/refinements/shared.d.ts +0 -20
  336. package/out/constraints/refinements/shared.d.ts.map +0 -1
  337. package/out/constraints/refinements/shared.js +0 -10
  338. package/out/constraints/refinements/shared.js.map +0 -1
  339. package/out/generic.d.ts.map +0 -1
  340. package/out/generic.js.map +0 -1
  341. package/out/inference.d.ts +0 -137
  342. package/out/inference.d.ts.map +0 -1
  343. package/out/inference.js +0 -73
  344. package/out/inference.js.map +0 -1
  345. package/out/keywords/ark.d.ts.map +0 -1
  346. package/out/keywords/ark.js.map +0 -1
  347. package/out/keywords/internal.d.ts +0 -13
  348. package/out/keywords/internal.d.ts.map +0 -1
  349. package/out/keywords/internal.js +0 -13
  350. package/out/keywords/internal.js.map +0 -1
  351. package/out/keywords/jsObject.d.ts +0 -20
  352. package/out/keywords/jsObject.d.ts.map +0 -1
  353. package/out/keywords/jsObject.js +0 -18
  354. package/out/keywords/jsObject.js.map +0 -1
  355. package/out/keywords/parsing.d.ts +0 -17
  356. package/out/keywords/parsing.d.ts.map +0 -1
  357. package/out/keywords/parsing.js +0 -64
  358. package/out/keywords/parsing.js.map +0 -1
  359. package/out/keywords/root.d.ts +0 -7
  360. package/out/keywords/root.d.ts.map +0 -1
  361. package/out/keywords/root.js +0 -4
  362. package/out/keywords/root.js.map +0 -1
  363. package/out/keywords/tsGenerics.d.ts +0 -2
  364. package/out/keywords/tsGenerics.d.ts.map +0 -1
  365. package/out/keywords/tsGenerics.js +0 -26
  366. package/out/keywords/tsGenerics.js.map +0 -1
  367. package/out/keywords/tsPrimitive.d.ts +0 -24
  368. package/out/keywords/tsPrimitive.d.ts.map +0 -1
  369. package/out/keywords/tsPrimitive.js +0 -25
  370. package/out/keywords/tsPrimitive.js.map +0 -1
  371. package/out/keywords/utils/creditCard.d.ts +0 -11
  372. package/out/keywords/utils/creditCard.d.ts.map +0 -1
  373. package/out/keywords/utils/creditCard.js +0 -35
  374. package/out/keywords/utils/creditCard.js.map +0 -1
  375. package/out/keywords/utils/date.d.ts +0 -45
  376. package/out/keywords/utils/date.d.ts.map +0 -1
  377. package/out/keywords/utils/date.js +0 -56
  378. package/out/keywords/utils/date.js.map +0 -1
  379. package/out/keywords/validation.d.ts +0 -20
  380. package/out/keywords/validation.d.ts.map +0 -1
  381. package/out/keywords/validation.js +0 -80
  382. package/out/keywords/validation.js.map +0 -1
  383. package/out/kinds.d.ts +0 -102
  384. package/out/kinds.d.ts.map +0 -1
  385. package/out/kinds.js +0 -29
  386. package/out/kinds.js.map +0 -1
  387. package/out/main.d.ts +0 -7
  388. package/out/main.d.ts.map +0 -1
  389. package/out/main.js +0 -6
  390. package/out/main.js.map +0 -1
  391. package/out/match.d.ts +0 -72
  392. package/out/match.d.ts.map +0 -1
  393. package/out/match.js +0 -53
  394. package/out/match.js.map +0 -1
  395. package/out/module.d.ts.map +0 -1
  396. package/out/module.js.map +0 -1
  397. package/out/parse.d.ts +0 -29
  398. package/out/parse.d.ts.map +0 -1
  399. package/out/parse.js +0 -161
  400. package/out/parse.js.map +0 -1
  401. package/out/parser/definition.d.ts.map +0 -1
  402. package/out/parser/definition.js.map +0 -1
  403. package/out/parser/generic.d.ts +0 -17
  404. package/out/parser/generic.d.ts.map +0 -1
  405. package/out/parser/generic.js +0 -16
  406. package/out/parser/generic.js.map +0 -1
  407. package/out/parser/objectLiteral.d.ts.map +0 -1
  408. package/out/parser/objectLiteral.js.map +0 -1
  409. package/out/parser/semantic/bounds.d.ts.map +0 -1
  410. package/out/parser/semantic/bounds.js.map +0 -1
  411. package/out/parser/semantic/divisor.d.ts.map +0 -1
  412. package/out/parser/semantic/divisor.js.map +0 -1
  413. package/out/parser/semantic/infer.d.ts.map +0 -1
  414. package/out/parser/semantic/infer.js.map +0 -1
  415. package/out/parser/semantic/utils.d.ts.map +0 -1
  416. package/out/parser/semantic/utils.js.map +0 -1
  417. package/out/parser/semantic/validate.d.ts.map +0 -1
  418. package/out/parser/semantic/validate.js.map +0 -1
  419. package/out/parser/string/reduce/dynamic.d.ts.map +0 -1
  420. package/out/parser/string/reduce/dynamic.js.map +0 -1
  421. package/out/parser/string/reduce/shared.d.ts.map +0 -1
  422. package/out/parser/string/reduce/shared.js.map +0 -1
  423. package/out/parser/string/reduce/static.d.ts.map +0 -1
  424. package/out/parser/string/reduce/static.js.map +0 -1
  425. package/out/parser/string/shift/operand/date.d.ts.map +0 -1
  426. package/out/parser/string/shift/operand/date.js.map +0 -1
  427. package/out/parser/string/shift/operand/enclosed.d.ts.map +0 -1
  428. package/out/parser/string/shift/operand/enclosed.js.map +0 -1
  429. package/out/parser/string/shift/operand/genericArgs.d.ts.map +0 -1
  430. package/out/parser/string/shift/operand/genericArgs.js.map +0 -1
  431. package/out/parser/string/shift/operand/operand.d.ts.map +0 -1
  432. package/out/parser/string/shift/operand/operand.js.map +0 -1
  433. package/out/parser/string/shift/operand/unenclosed.d.ts.map +0 -1
  434. package/out/parser/string/shift/operand/unenclosed.js.map +0 -1
  435. package/out/parser/string/shift/operator/bounds.d.ts.map +0 -1
  436. package/out/parser/string/shift/operator/bounds.js.map +0 -1
  437. package/out/parser/string/shift/operator/divisor.d.ts.map +0 -1
  438. package/out/parser/string/shift/operator/divisor.js.map +0 -1
  439. package/out/parser/string/shift/operator/operator.d.ts.map +0 -1
  440. package/out/parser/string/shift/operator/operator.js.map +0 -1
  441. package/out/parser/string/shift/scanner.d.ts.map +0 -1
  442. package/out/parser/string/shift/scanner.js.map +0 -1
  443. package/out/parser/string/string.d.ts.map +0 -1
  444. package/out/parser/string/string.js.map +0 -1
  445. package/out/parser/tuple.d.ts.map +0 -1
  446. package/out/parser/tuple.js.map +0 -1
  447. package/out/schema.d.ts +0 -175
  448. package/out/schema.d.ts.map +0 -1
  449. package/out/schema.js +0 -73
  450. package/out/schema.js.map +0 -1
  451. package/out/schemaScope.d.ts +0 -180
  452. package/out/schemaScope.d.ts.map +0 -1
  453. package/out/schemaScope.js +0 -235
  454. package/out/schemaScope.js.map +0 -1
  455. package/out/scope.d.ts.map +0 -1
  456. package/out/scope.js.map +0 -1
  457. package/out/shared/compile.d.ts +0 -22
  458. package/out/shared/compile.d.ts.map +0 -1
  459. package/out/shared/compile.js +0 -79
  460. package/out/shared/compile.js.map +0 -1
  461. package/out/shared/context.d.ts +0 -54
  462. package/out/shared/context.d.ts.map +0 -1
  463. package/out/shared/context.js +0 -53
  464. package/out/shared/context.js.map +0 -1
  465. package/out/shared/declare.d.ts +0 -69
  466. package/out/shared/declare.d.ts.map +0 -1
  467. package/out/shared/declare.js +0 -2
  468. package/out/shared/declare.js.map +0 -1
  469. package/out/shared/disjoint.d.ts +0 -91
  470. package/out/shared/disjoint.d.ts.map +0 -1
  471. package/out/shared/disjoint.js +0 -110
  472. package/out/shared/disjoint.js.map +0 -1
  473. package/out/shared/errors.d.ts +0 -99
  474. package/out/shared/errors.d.ts.map +0 -1
  475. package/out/shared/errors.js +0 -108
  476. package/out/shared/errors.js.map +0 -1
  477. package/out/shared/implement.d.ts +0 -363
  478. package/out/shared/implement.d.ts.map +0 -1
  479. package/out/shared/implement.js +0 -68
  480. package/out/shared/implement.js.map +0 -1
  481. package/out/shared/inference.d.ts +0 -6
  482. package/out/shared/inference.d.ts.map +0 -1
  483. package/out/shared/inference.js +0 -5
  484. package/out/shared/inference.js.map +0 -1
  485. package/out/shared/intersections.d.ts +0 -60
  486. package/out/shared/intersections.d.ts.map +0 -1
  487. package/out/shared/intersections.js +0 -2
  488. package/out/shared/intersections.js.map +0 -1
  489. package/out/shared/traversal.d.ts +0 -62
  490. package/out/shared/traversal.d.ts.map +0 -1
  491. package/out/shared/traversal.js +0 -97
  492. package/out/shared/traversal.js.map +0 -1
  493. package/out/shared/utils.d.ts +0 -24
  494. package/out/shared/utils.d.ts.map +0 -1
  495. package/out/shared/utils.js +0 -15
  496. package/out/shared/utils.js.map +0 -1
  497. package/out/type.d.ts.map +0 -1
  498. package/out/type.js.map +0 -1
  499. package/out/types/basis.d.ts +0 -47
  500. package/out/types/basis.d.ts.map +0 -1
  501. package/out/types/basis.js +0 -15
  502. package/out/types/basis.js.map +0 -1
  503. package/out/types/discriminate.d.ts +0 -34
  504. package/out/types/discriminate.d.ts.map +0 -1
  505. package/out/types/discriminate.js +0 -120
  506. package/out/types/discriminate.js.map +0 -1
  507. package/out/types/domain.d.ts +0 -57
  508. package/out/types/domain.d.ts.map +0 -1
  509. package/out/types/domain.js +0 -41
  510. package/out/types/domain.js.map +0 -1
  511. package/out/types/intersection.d.ts +0 -127
  512. package/out/types/intersection.d.ts.map +0 -1
  513. package/out/types/intersection.js +0 -379
  514. package/out/types/intersection.js.map +0 -1
  515. package/out/types/morph.d.ts +0 -157
  516. package/out/types/morph.d.ts.map +0 -1
  517. package/out/types/morph.js +0 -99
  518. package/out/types/morph.js.map +0 -1
  519. package/out/types/proto.d.ts +0 -51
  520. package/out/types/proto.d.ts.map +0 -1
  521. package/out/types/proto.js +0 -60
  522. package/out/types/proto.js.map +0 -1
  523. package/out/types/type.d.ts +0 -143
  524. package/out/types/type.d.ts.map +0 -1
  525. package/out/types/type.js +0 -123
  526. package/out/types/type.js.map +0 -1
  527. package/out/types/union.d.ts +0 -71
  528. package/out/types/union.d.ts.map +0 -1
  529. package/out/types/union.js +0 -379
  530. package/out/types/union.js.map +0 -1
  531. package/out/types/unit.d.ts +0 -45
  532. package/out/types/unit.d.ts.map +0 -1
  533. package/out/types/unit.js +0 -56
  534. package/out/types/unit.js.map +0 -1
  535. package/out/util.d.ts +0 -31
  536. package/out/util.d.ts.map +0 -1
  537. package/out/util.js +0 -8
  538. package/out/util.js.map +0 -1
  539. package/parser/definition.ts +0 -143
  540. package/parser/generic.ts +0 -66
  541. package/parser/objectLiteral.ts +0 -217
  542. package/parser/semantic/bounds.ts +0 -62
  543. package/parser/semantic/divisor.ts +0 -11
  544. package/parser/semantic/infer.ts +0 -141
  545. package/parser/semantic/utils.ts +0 -15
  546. package/parser/semantic/validate.ts +0 -117
  547. package/parser/string/reduce/dynamic.ts +0 -208
  548. package/parser/string/reduce/shared.ts +0 -99
  549. package/parser/string/reduce/static.ts +0 -296
  550. package/parser/string/shift/operand/date.ts +0 -55
  551. package/parser/string/shift/operand/enclosed.ts +0 -123
  552. package/parser/string/shift/operand/genericArgs.ts +0 -128
  553. package/parser/string/shift/operand/operand.ts +0 -42
  554. package/parser/string/shift/operand/unenclosed.ts +0 -218
  555. package/parser/string/shift/operator/bounds.ts +0 -270
  556. package/parser/string/shift/operator/divisor.ts +0 -33
  557. package/parser/string/shift/operator/operator.ts +0 -71
  558. package/parser/string/shift/scanner.ts +0 -210
  559. package/parser/string/string.ts +0 -85
  560. package/parser/tuple.ts +0 -542
  561. package/scope.ts +0 -285
  562. package/type.ts +0 -265
@@ -1 +0,0 @@
1
- {"version":3,"file":"intersection.d.ts","sourceRoot":"","sources":["../../types/intersection.ts"],"names":[],"mappings":"AAAA,OAAO,EAYN,KAAK,QAAQ,EACb,KAAK,QAAQ,EACb,MAAM,eAAe,CAAA;AACtB,OAAO,EAAiC,KAAK,IAAI,EAAE,MAAM,YAAY,CAAA;AACrE,OAAO,EACN,UAAU,EACV,KAAK,qBAAqB,EAC1B,KAAK,wBAAwB,EAC7B,MAAM,+BAA+B,CAAA;AACtC,OAAO,KAAK,EAAE,KAAK,EAAgB,YAAY,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAG5E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACxD,OAAO,EAAY,KAAK,QAAQ,EAAE,KAAK,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAEhF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AACvD,OA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AM,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAA;AAE/E,KAAK,2BAA2B,CAAC,CAAC,SAAS,0BAA0B,IACpE,CAAC,SAAS,qBAAqB,GAC5B,8BAA8B,CAAC,CAAC,CAAC,GACjC,qCAAqC,CAAC,CAAC,GACvC,kCAAkC,CAAC,CAAA;AAEvC,KAAK,6BAA6B,CAAC,CAAC,SAAS,qBAAqB,IACjE,CAAC,SAAS,YAAY,GAAG,SAAS,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC,CAAA;AAEtD,KAAK,0BAA0B,CAAC,CAAC,SAAS,0BAA0B,IACnE,CAAC,SAAS,qBAAqB,GAC5B,6BAA6B,CAAC,CAAC,CAAC,GAChC,oCAAoC,CAAC,CAAC,GACtC,kCAAkC,CAAC,CAAA;AAEvC,MAAM,MAAM,mBAAmB,CAAC,CAAC,IAAI;KACnC,CAAC,IAAI,4BAA4B,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,2BAA2B,CAAC,CAAC,CAAC;CACvE,CAAA"}
@@ -1,379 +0,0 @@
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
@@ -1 +0,0 @@
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,kBAA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UAAU;YAC7B,CAAC,CAAC,CAAC;YACH,CAAC,CAAC,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC,OAAO;gBACvB,CAAC,CAAC,CAAC,CAAC;gBACJ,CAAC,CAAC,CAAC,CACJ,CAAA;IAEF,OAAO,MAAM,CAAA;AACd,CAAC,CAAA;AAED,MAAM,oBAAoB,GAAG,CAC5B,WAAkC,EACd,EAAE;IACtB,MAAM,KAAK,GAAiC,EAAE,CAAA;IAC9C,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;QACtC,IAAI,UAAU,CAAC,kBAAkB,EAAE,CAAC;YACnC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,MAAM,CAC9B,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,EACtB,UAAU,CACD,CAAA;QACX,CAAC;aAAM,CAAC;YACP,IAAI,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC5B,OAAO,kBAAkB,CACxB,yDAAyD,UAAU,CAAC,IAAI,EAAE,CAC1E,CAAA;YACF,CAAC;YACD,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,UAAmB,CAAA;QAC7C,CAAC;IACF,CAAC;IACD,OAAO,KAAK,CAAA;AACb,CAAC,CAAA"}
@@ -1,157 +0,0 @@
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
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CAAC,SAAS,KAAK,EACf,EAAE,SAAS,IAAI,GAAG,KAAK,EACvB,WAAW,SAAS,MAAM,GAAG,eAAe,EAC5C,OAAO,SAAS,KAAK,GAAG,EAAE,IACvB,CAAC,SAAS,SAAS,CAAC,GAAG,MAAM,IAAI,EAAE,MAAM,IAAI,CAAC,GAC/C,cAAc,CACd,IAAI,EACJ,EAAE,EACF,WAAW,EACX;IAAC,cAAc,CAAC,IAAI,EAAE,EAAE,EAAE,WAAW,CAAC;IAAE,GAAG,OAAO;CAAC,CAClD,GACD,CAAC,GAAG;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,WAAW,CAAC;CAAE,EAAE,GAAG,OAAO,CAAC,CAAA;AAE7E,4EAA4E;AAC5E,KAAK,4BAA4B,GAC9B,eAAe,CAAC,UAAU,CAAC,GAC3B,cAAc,CAAC,OAAO,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAC,CAAA"}
@@ -1,99 +0,0 @@
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
@@ -1 +0,0 @@
1
- {"version":3,"file":"morph.js","sourceRoot":"","sources":["../../types/morph.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,QAAQ,EACR,S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