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,97 @@
1
+ import { deepClone } from "@arktype/util"
2
+ import { ArkErrors, createError } from "./errors.js"
3
+ export class TraversalContext {
4
+ root
5
+ config
6
+ path = []
7
+ morphs = []
8
+ errors = new ArkErrors(this)
9
+ branches = []
10
+ // Qualified
11
+ seen = {}
12
+ constructor(root, config) {
13
+ this.root = root
14
+ this.config = config
15
+ }
16
+ get currentBranch() {
17
+ return this.branches.at(-1)
18
+ }
19
+ queueMorph(morph) {
20
+ const input = { path: [...this.path], morph }
21
+ this.currentBranch?.morphs.push(input) ?? this.morphs.push(input)
22
+ }
23
+ finalize() {
24
+ if (this.hasError()) {
25
+ return { errors: this.errors }
26
+ }
27
+ const data = this.root
28
+ let out = data
29
+ if (this.morphs.length) {
30
+ out = deepClone(this.root)
31
+ for (let i = 0; i < this.morphs.length; i++) {
32
+ const { path, morph } = this.morphs[i]
33
+ if (path.length === 0) {
34
+ this.path = []
35
+ // if the morph applies to the root, just assign to it directly
36
+ const result = morph(out, this)
37
+ if (this.hasError()) return { errors: this.errors }
38
+ out = result
39
+ continue
40
+ }
41
+ // find the object on which the key to be morphed exists
42
+ let parent = out
43
+ for (
44
+ let pathIndex = 0;
45
+ pathIndex < path.length - 1;
46
+ pathIndex++
47
+ )
48
+ parent = parent[path[pathIndex]]
49
+ // apply the morph function and assign the result to the corresponding property
50
+ const key = path.at(-1)
51
+ this.path = path
52
+ const result = morph(parent[key], this)
53
+ if (this.hasError()) return { errors: this.errors }
54
+ else parent[key] = result
55
+ }
56
+ }
57
+ return { data, out }
58
+ }
59
+ hasError() {
60
+ return this.currentBranch
61
+ ? this.currentBranch.error !== undefined
62
+ : this.errors.count !== 0
63
+ }
64
+ get failFast() {
65
+ return this.branches.length !== 0
66
+ }
67
+ error(input) {
68
+ const error = createError(this, input)
69
+ if (this.currentBranch) {
70
+ this.currentBranch.error = error
71
+ } else {
72
+ this.errors.add(error)
73
+ }
74
+ return error
75
+ }
76
+ get data() {
77
+ let result = this.root
78
+ for (const segment of this.path) {
79
+ result = result?.[segment]
80
+ }
81
+ return result
82
+ }
83
+ invalid(input) {
84
+ this.error(input)
85
+ return false
86
+ }
87
+ pushBranch() {
88
+ this.branches.push({
89
+ error: undefined,
90
+ morphs: []
91
+ })
92
+ }
93
+ popBranch() {
94
+ return this.branches.pop()
95
+ }
96
+ }
97
+ //# sourceMappingURL=traversal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"traversal.js","sourceRoot":"","sources":["../../shared/traversal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAGzC,OAAO,EACN,SAAS,EACT,WAAW,EAKX,MAAM,aAAa,CAAA;AAapB,MAAM,OAAO,gBAAgB;IAUpB;IACA;IAVR,IAAI,GAAkB,EAAE,CAAA;IACxB,MAAM,GAAkB,EAAE,CAAA;IAC1B,MAAM,GAAc,IAAI,SAAS,CAAC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IAAI,EAAE,KAAK,CAAC,CAAA;QACtC,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;YACxB,IAAI,CAAC,aAAa,CAAC,KAAK,GAAG,KAAK,CAAA;QACjC,CAAC;aAAM,CAAC;YACP,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;QACvB,CAAC;QACD,OAAO,KAAK,CAAA;IACb,CAAC;IAED,IAAI,IAAI;QACP,IAAI,MAAM,GAAQ,IAAI,CAAC,IAAI,CAAA;QAC3B,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;YACjC,MAAM,GAAG,MAAM,EAAE,CAAC,OAAO,CAAC,CAAA;QAC3B,CAAC;QACD,OAAO,MAAM,CAAA;IACd,CAAC;IAED,OAAO,CAAC,KAAoB;QAC3B,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QACjB,OAAO,KAAK,CAAA;IACb,CAAC;IAED,UAAU;QACT,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;YAClB,KAAK,EAAE,SAAS;YAChB,MAAM,EAAE,EAAE;SACV,CAAC,CAAA;IACH,CAAC;IAED,SAAS;QACR,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAG,CAAA;IAC5B,CAAC;CACD"}
@@ -0,0 +1,24 @@
1
+ import { type array, type mutable } from "@arktype/util"
2
+ export declare const makeRootAndArrayPropertiesMutable: <o extends object>(
3
+ o: o
4
+ ) => {
5
+ -readonly [k in keyof o]: o[k] extends array | undefined
6
+ ? o[k] extends infer T
7
+ ? T extends o[k]
8
+ ? T extends object
9
+ ? T extends (...args: never[]) => unknown
10
+ ? T
11
+ : { -readonly [k_1 in keyof T]: T[k_1] }
12
+ : T
13
+ : never
14
+ : never
15
+ : o[k]
16
+ }
17
+ export type makeRootAndArrayPropertiesMutable<inner> = {
18
+ -readonly [k in keyof inner]: inner[k] extends array | undefined
19
+ ? mutable<inner[k]>
20
+ : inner[k]
21
+ } & unknown
22
+ export type TraversalPath = PropertyKey[]
23
+ export declare const pathToPropString: (path: TraversalPath) => string
24
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../shared/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAIN,KAAK,KAAK,EACV,KAAK,OAAO,EACZ,MAAM,eAAe,CAAA;AAEtB,eAAO,MAAM,iCAAiC,yQAKyB,CAAA;AAEvE,MAAM,MAAM,iCAAiC,CAAC,KAAK,IAAI;IACtD,CAAC,UAAU,CAAC,IAAI,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,SAAS,KAAK,GAAG,SAAS,GAC7D,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GACjB,KAAK,CAAC,CAAC,CAAC;CACX,GAAG,OAAO,CAAA;AAEX,MAAM,MAAM,aAAa,GAAG,WAAW,EAAE,CAAA;AAEzC,eAAO,MAAM,gBAAgB,2BAA0B,MAMtD,CAAA"}
@@ -0,0 +1,15 @@
1
+ import { flatMorph, isArray, literalPropAccess } from "@arktype/util"
2
+ export const makeRootAndArrayPropertiesMutable = (o) =>
3
+ // TODO: this cast should not be required, but it seems TS is referencing
4
+ // the wrong parameters here?
5
+ flatMorph(o, (k, v) => [k, isArray(v) ? [...v] : v])
6
+ export const pathToPropString = (path) => {
7
+ const propAccessChain = path.reduce(
8
+ (s, segment) => s + literalPropAccess(segment),
9
+ ""
10
+ )
11
+ return propAccessChain[0] === "."
12
+ ? propAccessChain.slice(1)
13
+ : propAccessChain
14
+ }
15
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../shared/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,SAAS,EACT,OAAO,EACP,iBAAiB,EAGjB,MAAM,eAAe,CAAA;AAEtB,MAAM,CAAC,MAAM,iCAAiC,GAAG,CAChD,CAAI,EACmC,EAAE;AACzC,yEAAyE;AACzE,6BAA6B;AAC7B,SAAS,CAAC,CAAU,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAU,CAAA;AAUvE,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,IAAmB,EAAU,EAAE;IAC/D,MAAM,eAAe,GAAG,IAAI,CAAC,MAAM,CAClC,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC,GAAG,iBAAiB,CAAC,OAAO,CAAC,EAC9C,EAAE,CACF,CAAA;IACD,OAAO,eAAe,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,eAAe,CAAA;AAC/E,CAAC,CAAA"}
package/out/type.d.ts CHANGED
@@ -1,73 +1,37 @@
1
- import { inferred, type ArkResult, type BaseMeta, type Morph, type Out, type Predicate, type TypeNode, type distill, type extractIn, type extractOut, type includesMorphs, type inferIntersection, type inferMorphOut, type inferNarrow } from "@arktype/schema";
2
- import { Callable, type Constructor, type Json, type conform } from "@arktype/util";
1
+ import { type BaseMeta, type Morph, type NodeDef, type Out, type Predicate, type PrimitiveConstraintKind, type Schema, type ambient, type constrain, type constraintKindOf, type distillConstrainableIn, type distillConstrainableOut, type distillIn, type distillOut, type includesMorphs, type inferIntersection, type inferMorphOut, type inferNarrow } from "@arktype/schema";
2
+ import type { Constructor, array, conform } from "@arktype/util";
3
+ import type { Generic, validateParameterString } from "./generic.js";
3
4
  import type { inferDefinition, validateDeclared, validateDefinition } from "./parser/definition.js";
4
- import { parseGenericParams, type GenericParamsParseError } from "./parser/generic.js";
5
+ import type { parseGenericParams } from "./parser/generic.js";
5
6
  import type { IndexOneOperator, IndexZeroOperator, TupleInfixOperator } from "./parser/tuple.js";
6
7
  import type { Scope, bindThis } from "./scope.js";
7
- import { arkKind } from "./util.js";
8
8
  export type TypeParser<$> = {
9
9
  <const def>(def: validateTypeRoot<def, $>): Type<inferTypeRoot<def, $>, $>;
10
- <const zero, const one, const rest extends readonly unknown[]>(_0: zero extends IndexZeroOperator ? zero : validateTypeRoot<zero, $>, _1: zero extends "keyof" ? validateTypeRoot<one, $> : zero extends "instanceof" ? conform<one, Constructor> : zero extends "===" ? conform<one, unknown> : conform<one, IndexOneOperator>, ..._2: zero extends "===" ? rest : zero extends "instanceof" ? conform<rest, readonly Constructor[]> : one extends TupleInfixOperator ? one extends ":" ? [Predicate<extractIn<inferTypeRoot<zero, $>>>] : one extends "=>" ? [
11
- Morph<extractOut<inferTypeRoot<zero, $>>, unknown>
12
- ] : one extends "@" ? [string | BaseMeta] : [validateTypeRoot<rest[0], $>] : []): Type<inferTypeRoot<[zero, one, ...rest], $>, $>;
10
+ <const zero, const one, const rest extends array>(_0: zero extends IndexZeroOperator ? zero : validateTypeRoot<zero, $>, _1: zero extends "keyof" ? validateTypeRoot<one, $> : zero extends "instanceof" ? conform<one, Constructor> : zero extends "===" ? conform<one, unknown> : conform<one, IndexOneOperator>, ..._2: zero extends "===" ? rest : zero extends "instanceof" ? conform<rest, readonly Constructor[]> : one extends TupleInfixOperator ? one extends ":" ? [Predicate<distillIn<inferTypeRoot<zero, $>>>] : one extends "=>" ? [Morph<distillOut<inferTypeRoot<zero, $>>, unknown>] : one extends "@" ? [string | BaseMeta] : [validateTypeRoot<rest[0], $>] : []): Type<inferTypeRoot<[zero, one, ...rest], $>, $>;
13
11
  <params extends string, const def>(params: `<${validateParameterString<params>}>`, def: validateDefinition<def, $, {
14
12
  [param in parseGenericParams<params>[number]]: unknown;
15
13
  }>): Generic<parseGenericParams<params>, def, $>;
16
14
  };
17
15
  export type DeclarationParser<$> = <preinferred>() => {
18
- type: <def>(def: validateDeclared<preinferred, def, $, bindThis<def>>) => Type<preinferred, $>;
16
+ type: <def>(def: validateDeclared<preinferred, def, $ & ambient, bindThis<def>>) => Type<preinferred, $>;
19
17
  };
20
- export declare const createTypeParser: <$>(scope: Scope) => TypeParser<$>;
21
- export type DefinitionParser<$> = <def>(def: validateDefinition<def, $, bindThis<def>>) => def;
22
- export declare class Type<t = unknown, $ = any> extends Callable<(data: unknown) => ArkResult<distill<extractOut<t>>>> {
23
- definition: unknown;
24
- scope: Scope;
25
- [inferred]: t;
26
- infer: distill<extractOut<t>>;
27
- root: TypeNode<t>;
28
- allows: this["root"]["allows"];
29
- description: string;
30
- json: Json;
31
- constructor(definition: unknown, scope: Scope);
32
- configure(configOrDescription: BaseMeta | string): this;
33
- describe(description: string): this;
34
- from(literal: this["in"]["infer"]): this["in"]["infer"];
35
- and<def>(def: validateTypeRoot<def, $>): Type<inferIntersection<t, inferTypeRoot<def, $>>, $>;
36
- or<def>(def: validateTypeRoot<def, $>): Type<t | inferTypeRoot<def, $>, $>;
37
- morph<morph extends Morph<this["infer"]>>(morph: morph): Type<(In: this["in"]["infer"]) => Out<inferMorphOut<ReturnType<morph>>>, $>;
38
- morph<morph extends Morph<this["infer"]>, def>(morph: morph, outValidator: validateTypeRoot<def, $>): Type<(In: this["in"]["infer"]) => Out<extractOut<inferTypeRoot<def, $>>>, $>;
39
- narrow<def extends Predicate<extractOut<t>>>(def: def): Type<includesMorphs<t> extends true ? (In: this["in"]["infer"]) => Out<inferNarrow<this["infer"], def>> : inferNarrow<this["infer"], def>, $>;
18
+ export interface Type<
19
+ /** @ts-expect-error allow instantiation assignment to the base type */
20
+ out t = unknown, $ = any> extends Schema<t, $> {
21
+ and: (<def>(def: validateTypeRoot<def, $>) => Type<inferIntersection<t, inferTypeRoot<def, $>>, $>) & Schema<t, $>["and"];
22
+ or: (<def>(def: validateTypeRoot<def, $>) => Type<t | inferTypeRoot<def, $>, $>) & Schema<t, $>["or"];
23
+ get in(): Type<distillConstrainableIn<t>, $>;
24
+ get out(): Type<distillConstrainableOut<t>, $>;
40
25
  array(): Type<t[], $>;
41
- keyof(): Type<keyof this["in"]["infer"], $>;
42
- assert(data: unknown): this["infer"];
43
- equals<def>(other: validateTypeRoot<def, $>): this is Type<inferTypeRoot<def, $>, $>;
44
- extends<def>(other: validateTypeRoot<def, $>): this is Type<inferTypeRoot<def, $>, $>;
45
- private inCache?;
46
- get in(): Type<extractIn<t>, $>;
47
- outCache?: Type<extractOut<t>, $>;
48
- get out(): Type<extractOut<t>, $>;
49
- toString(): string;
26
+ morph: (<morph extends Morph<this["infer"]>, outValidatorDef = never>(morph: morph, outValidator?: validateTypeRoot<outValidatorDef, $>) => Type<(In: distillConstrainableIn<t>) => Out<[
27
+ outValidatorDef
28
+ ] extends [never] ? inferMorphOut<morph> : distillConstrainableOut<inferTypeRoot<outValidatorDef, $>>>, $>) & Schema<t, $>["morph"];
29
+ narrow<def extends Predicate<distillConstrainableOut<t>>>(def: def): Type<includesMorphs<t> extends true ? (In: distillIn<t>) => Out<inferNarrow<this["infer"], def>> : inferNarrow<this["infer"], def>, $>;
30
+ constrain<kind extends PrimitiveConstraintKind, const def extends NodeDef<kind>>(kind: conform<kind, constraintKindOf<this["in"]["infer"]>>, def: def): Type<constrain<t, kind, def>, $>;
50
31
  }
51
- export type validateTypeRoot<def, $> = validateDefinition<def, $, bindThis<def>>;
52
- export type inferTypeRoot<def, $> = inferDefinition<def, $, bindThis<def>>;
53
- type validateParameterString<params extends string> = parseGenericParams<params> extends GenericParamsParseError<infer message> ? message : params;
54
- export declare const validateUninstantiatedGeneric: (g: Generic) => Generic<string[], unknown, any>;
55
- export declare const generic: (parameters: string[], definition: unknown, scope: Scope) => Generic<string[], unknown, any>;
56
- export type GenericProps<params extends string[] = string[], def = unknown, $ = any> = {
57
- [arkKind]: "generic";
58
- $: $;
59
- parameters: params;
60
- definition: def;
61
- scope: Scope;
62
- };
63
- export type BoundArgs = Record<string, TypeNode>;
64
- export type Generic<params extends string[] = string[], def = unknown, $ = any> = {
65
- <args>(...args: conform<args, {
66
- [i in keyof params]: validateTypeRoot<args[i & keyof args], $>;
67
- }>): Type<inferDefinition<def, $, bindGenericInstantiation<params, $, args>>, $>;
68
- } & GenericProps<params, def, $>;
69
- type bindGenericInstantiation<params extends string[], $, args> = {
70
- [i in keyof params & `${number}` as params[i]]: inferTypeRoot<args[i & keyof args], $>;
71
- };
72
- export {};
32
+ export type TypeConstructor<t = unknown, $ = any> = new (def: unknown, $: Scope<$>) => Type<t, $>;
33
+ export declare const Type: TypeConstructor;
34
+ export type DefinitionParser<$> = <def>(def: validateTypeRoot<def, $>) => def;
35
+ export type validateTypeRoot<def, $ = {}> = validateDefinition<def, $ & ambient, bindThis<def>>;
36
+ export type inferTypeRoot<def, $ = {}> = inferDefinition<def, $ & ambient, bindThis<def>>;
73
37
  //# sourceMappingURL=type.d.ts.map
package/out/type.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../type.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,QAAQ,EAER,KAAK,SAAS,EACd,KAAK,QAAQ,EACb,KAAK,KAAK,EACV,KAAK,GAAG,EACR,KAAK,SAAS,EACd,KAAK,QAAQ,EACb,KAAK,OAAO,EACZ,KAAK,SAAS,EACd,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACN,QAAQ,EAER,KAAK,WAAW,EAChB,KAAK,IAAI,EACT,KAAK,OAAO,EACZ,MAAM,eAAe,CAAA;AACtB,OAAO,KAAK,EACX,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EAClB,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EACN,kBAAkB,EAClB,KAAK,uBAAuB,EAC5B,MAAM,qBAAqB,CAAA;AAE5B,OAAO,KAAK,EACX,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,MAAM,mBAAmB,CAAA;AAC1B,OAAO,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ACb,CAAA"}
package/out/type.js CHANGED
@@ -1,138 +1,3 @@
1
- import { inferred, keywords } from "@arktype/schema";
2
- import { Callable, morph } from "@arktype/util";
3
- import { parseGenericParams } from "./parser/generic.js";
4
- import { configureShallowDescendants } from "./parser/shared.js";
5
- import { arkKind } from "./util.js";
6
- export const createTypeParser = (scope) => {
7
- const parser = (...args) => {
8
- if (args.length === 1) {
9
- // treat as a simple definition
10
- return new Type(args[0], scope);
11
- }
12
- if (args.length === 2 &&
13
- typeof args[0] === "string" &&
14
- args[0][0] === "<" &&
15
- args[0].at(-1) === ">") {
16
- // if there are exactly two args, the first of which looks like <${string}>,
17
- // treat as a generic
18
- const params = parseGenericParams(args[0].slice(1, -1));
19
- const def = args[1];
20
- return validateUninstantiatedGeneric(generic(params, def, scope));
21
- }
22
- // otherwise, treat as a tuple expression. technically, this also allows
23
- // non-expression tuple definitions to be parsed, but it's not a supported
24
- // part of the API as specified by the associated types
25
- return new Type(args, scope);
26
- };
27
- return parser;
28
- };
29
- export class Type extends Callable {
30
- definition;
31
- scope;
32
- root;
33
- allows;
34
- description;
35
- json;
36
- constructor(definition, scope) {
37
- const root = parseTypeRoot(definition, scope);
38
- super(root.apply, root);
39
- this.definition = definition;
40
- this.scope = scope;
41
- this.root = root;
42
- this.allows = root.allows;
43
- this.json = root.json;
44
- this.description = this.root.description;
45
- }
46
- configure(configOrDescription) {
47
- return new Type(configureShallowDescendants(this.root, configOrDescription), this.scope);
48
- }
49
- describe(description) {
50
- return this.configure(description);
51
- }
52
- // TODO: should return out
53
- from(literal) {
54
- return literal;
55
- }
56
- // TODO: Morph intersections, ordering
57
- and(def) {
58
- return new Type(this.root.and(parseTypeRoot(def, this.scope)), this.scope);
59
- }
60
- or(def) {
61
- return new Type(this.root.or(parseTypeRoot(def, this.scope)), this.scope);
62
- }
63
- morph(morph, outValidator) {
64
- // TODO: tuple expression for out validator
65
- outValidator;
66
- return this;
67
- // return new Type(
68
- // this.root.constrain("morph", morph),
69
- // this.scope
70
- // ) as never
71
- }
72
- // TODO: based on below, should maybe narrow morph output if used after
73
- narrow(def) {
74
- return new Type(this.root.constrain("predicate", def), this.scope);
75
- }
76
- array() {
77
- return new Type(this.root.array(), this.scope);
78
- }
79
- keyof() {
80
- return new Type(this.root.keyof(), this.scope);
81
- }
82
- assert(data) {
83
- const result = this.call(null, data);
84
- return result.errors ? result.errors.throw() : result.out;
85
- }
86
- equals(other) {
87
- return this.root.equals(parseTypeRoot(other, this.scope));
88
- }
89
- extends(other) {
90
- return this.root.extends(parseTypeRoot(other, this.scope));
91
- }
92
- inCache;
93
- get in() {
94
- this.inCache ??= new Type(this.root.in, this.scope);
95
- return this.inCache;
96
- }
97
- outCache;
98
- get out() {
99
- this.outCache ??= new Type(this.root.out, this.scope);
100
- return this.outCache;
101
- }
102
- toString() {
103
- return this.description;
104
- }
105
- }
106
- const parseTypeRoot = (def, scope, args) => scope.parseDefinition(def, {
107
- args: args ?? scope.bindThis(),
108
- baseName: "type"
109
- });
110
- export const validateUninstantiatedGeneric = (g) => {
111
- // the unconstrained instantiation of the generic is not used for now
112
- // other than to eagerly validate that the def does not contain any errors
113
- g.scope.parseDefinition(g.definition,
114
- // once we support constraints on generic parameters, we'd use
115
- // the base type here: https://github.com/arktypeio/arktype/issues/796
116
- {
117
- baseName: "generic",
118
- args: morph(g.parameters, (_, name) => [name, keywords.unknown])
119
- });
120
- return g;
121
- };
122
- export const generic = (parameters, definition, scope) => {
123
- return Object.assign((...args) => {
124
- const argNodes = morph(parameters, (i, param) => [
125
- param,
126
- parseTypeRoot(args[i], scope)
127
- ]);
128
- const root = parseTypeRoot(definition, scope, argNodes);
129
- return new Type(root, scope);
130
- }, {
131
- [arkKind]: "generic",
132
- parameters,
133
- definition,
134
- scope
135
- // $ is only needed at compile-time
136
- });
137
- };
1
+ import { RawSchema } from "@arktype/schema";
2
+ export const Type = RawSchema;
138
3
  //# sourceMappingURL=type.js.map
package/out/type.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,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AAM,CAAC,MAAM,CACnB,CAAC,GAAG,IAAe,EAAE,EAAE;QACtB,MAAM,QAAQ,GAAG,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC;YAChD,KAAK;YACL,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC;SAC7B,CAAC,CAAA;QACF,MAAM,IAAI,GAAG,aAAa,CAAC,UAAU,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAA;QACvD,OAAO,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;IAC7B,CAAC,EACD;QACC,CAAC,OAAO,CAAC,EAAE,SAAS;QACpB,UAAU;QACV,UAAU;QACV,KAAK;QACL,mCAAmC;KACD,CACb,CAAA;AACxB,CAAC,CAAA"}
1
+ {"version":3,"file":"type.js","sourceRoot":"","sources":["../type.ts"],"names":[],"mappings":"AAAA,OAAO,EAON,SAAS,EAaT,MAAM,iBAAiB,CAAA;AAmHxB,MAAM,CAAC,MAAM,IAAI,GAAoB,SAAkB,CAAA"}
@@ -0,0 +1,47 @@
1
+ import type {
2
+ Constructor,
3
+ Key,
4
+ NonEnumerableDomain,
5
+ inferDomain,
6
+ instanceOf,
7
+ isAny
8
+ } from "@arktype/util"
9
+ import type { Schema } from "../kinds.js"
10
+ import type { NodeCompiler } from "../shared/compile.js"
11
+ import type { BasisKind } from "../shared/implement.js"
12
+ import type { TraverseApply } from "../shared/traversal.js"
13
+ import type { DomainSchema } from "./domain.js"
14
+ import type { ProtoSchema } from "./proto.js"
15
+ import { BaseType, type BaseTypeDeclaration, type Type } from "./type.js"
16
+ import type { UnitSchema } from "./unit.js"
17
+ export interface BaseBasisDeclaration extends BaseTypeDeclaration {
18
+ kind: BasisKind
19
+ }
20
+ export declare abstract class BaseBasis<
21
+ t,
22
+ d extends BaseBasisDeclaration,
23
+ $
24
+ > extends BaseType<t, d, $> {
25
+ abstract readonly expression: string
26
+ abstract readonly compiledCondition: string
27
+ abstract readonly compiledNegation: string
28
+ abstract readonly errorContext: d["errorContext"]
29
+ abstract literalKeys: Key[]
30
+ rawKeyOf(): Type
31
+ traverseApply: TraverseApply<d["prerequisite"]>
32
+ compile(js: NodeCompiler): void
33
+ }
34
+ export type inferBasis<def extends Schema<BasisKind>> = isAny<def> extends true
35
+ ? any
36
+ : def extends NonEnumerableDomain
37
+ ? inferDomain<def>
38
+ : def extends Constructor<infer instance>
39
+ ? instance
40
+ : def extends DomainSchema<infer domain>
41
+ ? inferDomain<domain>
42
+ : def extends ProtoSchema<infer proto>
43
+ ? instanceOf<proto>
44
+ : def extends UnitSchema<infer is>
45
+ ? is
46
+ : never
47
+ //# sourceMappingURL=basis.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"basis.d.ts","sourceRoot":"","sources":["../../types/basis.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,WAAW,EACX,GAAG,EACH,mBAAmB,EACnB,WAAW,EACX,UAAU,EACV,KAAK,EACL,MAAM,eAAe,CAAA;AACtB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACxD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AACvD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAC7C,OAAO,EAAE,QAAQ,EAAE,KAAK,mBAAmB,EAAE,KAAK,IAAI,EAAE,MAAM,WAAW,CAAA;AACzE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAE3C,MAAM,WAAW,oBAAqB,SAAQ,mBAAmB;IAChE,IAAI,EAAE,SAAS,CAAA;CACf;AAED,8BAAsB,SAAS,CAC9B,CAAC,EACD,CAAC,SAAS,oBAAoB,EAC9B,CAAC,CACA,SAAQ,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IAC1B,QAAQ,CAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IACpC,QAAQ,CAAC,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAA;IAC3C,QAAQ,CAAC,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAA;IAC1C,QAAQ,CAAC,QAAQ,CAAC,YAAY,EAAE,CAAC,CAAC,cAAc,CAAC,CAAA;IACjD,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE,CAAA;IAE3B,QAAQ,IAAI,IAAI;IAIhB,aAAa,EAAE,aAAa,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAI9C;IAED,OAAO,CAAC,EAAE,EAAE,YAAY,GAAG,IAAI;CAG/B;AAED,MAAM,MAAM,UAAU,CAAC,GAAG,SAAS,MAAM,CAAC,SAAS,CAAC,IAEnD,KAAK,CAAC,GAAG,CAAC,SAAS,IAAI,GACpB,GAAG,GACH,GAAG,SAAS,mBAAmB,GAC/B,WAAW,CAAC,GAAG,CAAC,GAChB,GAAG,SAAS,WAAW,CAAC,MAAM,QAAQ,CAAC,GACvC,QAAQ,GACR,GAAG,SAAS,YAAY,CAAC,MAAM,MAAM,CAAC,GACtC,WAAW,CAAC,MAAM,CAAC,GACnB,GAAG,SAAS,WAAW,CAAC,MAAM,KAAK,CAAC,GACpC,UAAU,CAAC,KAAK,CAAC,GACjB,GAAG,SAAS,UAAU,CAAC,MAAM,EAAE,CAAC,GAChC,EAAE,GACF,KAAK,CAAA"}
@@ -0,0 +1,15 @@
1
+ import { BaseType } from "./type.js"
2
+ export class BaseBasis extends BaseType {
3
+ rawKeyOf() {
4
+ return this.$.parseUnits(...this.literalKeys)
5
+ }
6
+ traverseApply = (data, ctx) => {
7
+ if (!this.traverseAllows(data, ctx)) {
8
+ ctx.error(this.errorContext)
9
+ }
10
+ }
11
+ compile(js) {
12
+ js.compilePrimitive(this)
13
+ }
14
+ }
15
+ //# sourceMappingURL=basis.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"basis.js","sourceRoot":"","sources":["../../types/basis.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,QAAQ,EAAuC,MAAM,WAAW,CAAA;AAOzE,MAAM,OAAgB,SAIpB,SAAQ,QAAiB;IAO1B,QAAQ;QACP,OAAO,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,CAAA;IAC9C,CAAC;IAED,aAAa,GAAqC,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE;QAC/D,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE,CAAC;YACrC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,YAAqB,CAAC,CAAA;QACtC,CAAC;IACF,CAAC,CAAA;IAED,OAAO,CAAC,EAAgB;QACvB,EAAE,CAAC,gBAAgB,CAAC,IAAa,CAAC,CAAA;IACnC,CAAC;CACD"}
@@ -0,0 +1,34 @@
1
+ import {
2
+ type Domain,
3
+ type SerializedPrimitive,
4
+ type evaluate
5
+ } from "@arktype/util"
6
+ import type { UnionChildNode } from "./union.js"
7
+ export type CaseKey<kind extends DiscriminantKind = DiscriminantKind> =
8
+ DiscriminantKind extends kind ? string : DiscriminantKinds[kind] | "default"
9
+ export type Discriminant<kind extends DiscriminantKind = DiscriminantKind> =
10
+ Readonly<{
11
+ readonly path: string[]
12
+ readonly kind: kind
13
+ readonly cases: DiscriminatedCases<kind>
14
+ readonly isPureRootLiteral: boolean
15
+ }>
16
+ export type DiscriminatedCases<
17
+ kind extends DiscriminantKind = DiscriminantKind
18
+ > = Readonly<{
19
+ [caseKey in CaseKey<kind>]: Discriminant | UnionChildNode[]
20
+ }>
21
+ export type DiscriminantKinds = {
22
+ domain: Domain
23
+ value: SerializedPrimitive
24
+ }
25
+ export type DiscriminantKind = evaluate<keyof DiscriminantKinds>
26
+ export declare const discriminate: (
27
+ branches: readonly UnionChildNode[]
28
+ ) => Discriminant | null
29
+ export declare const writeUndiscriminableMorphUnionMessage: <
30
+ path extends string
31
+ >(
32
+ path: path
33
+ ) => `${string} union including one or more morphs must be discriminable`
34
+ //# sourceMappingURL=discriminate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"discriminate.d.ts","sourceRoot":"","sources":["../../types/discriminate.ts"],"names":[],"mappings":"AAAA,OAAO,EAKN,KAAK,MAAM,EACX,KAAK,mBAAmB,EACxB,KAAK,QAAQ,EAGb,MAAM,eAAe,CAAA;AAEtB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAEhD,MAAM,MAAM,OAAO,CAAC,IAAI,SAAS,gBAAgB,GAAG,gBAAgB,IACnE,gBAAgB,SAAS,IAAI,GAAG,MAAM,GAAG,iBAAiB,CAAC,IAAI,CAAC,GAAG,SAAS,CAAA;AAE7E,MAAM,MAAM,YAAY,CAAC,IAAI,SAAS,gBAAgB,GAAG,gBAAgB,IACxE,QAAQ,CAAC;IACR,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,CAAA;IACvB,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAA;IACnB,QAAQ,CAAC,KAAK,EAAE,kBAAkB,CAAC,IAAI,CAAC,CAAA;IAExC,QAAQ,CAAC,iBAAiB,EAAE,OAAO,CAAA;CACnC,CAAC,CAAA;AAEH,MAAM,MAAM,kBAAkB,CAC7B,IAAI,SAAS,gBAAgB,GAAG,gBAAgB,IAC7C,QAAQ,CAAC;KACX,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,YAAY,GAAG,cAAc,EAAE;CAC3D,CAAC,CAAA;AAQF,MAAM,MAAM,iBAAiB,GAAG;IAC/B,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,mBAAmB,CAAA;CAC1B,CAAA;AAOD,MAAM,MAAM,gBAAgB,GAAG,QAAQ,CAAC,MAAM,iBAAiB,CAAC,CAAA;AAehE,eAAO,MAAM,YAAY,aACd,SAAS,cAAc,EAAE,KACjC,YAAY,GAAG,IA8FjB,CAAA;AAGD,eAAO,MAAM,qCAAqC,2GAKmB,CAAA"}