arktype 1.0.28-alpha → 1.1.0-dev-2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (364) hide show
  1. package/dist/main.d.ts +11 -0
  2. package/dist/main.d.ts.map +1 -0
  3. package/dist/main.js +8 -0
  4. package/dist/main.js.map +1 -0
  5. package/dist/match.d.ts +46 -0
  6. package/dist/match.d.ts.map +1 -0
  7. package/dist/match.js +23 -0
  8. package/dist/match.js.map +1 -0
  9. package/dist/parser/definition.d.ts +32 -0
  10. package/dist/parser/definition.d.ts.map +1 -0
  11. package/dist/parser/definition.js +29 -0
  12. package/dist/parser/definition.js.map +1 -0
  13. package/dist/parser/generic.d.ts +44 -0
  14. package/dist/parser/generic.d.ts.map +1 -0
  15. package/dist/parser/generic.js +46 -0
  16. package/dist/parser/generic.js.map +1 -0
  17. package/dist/parser/objectLiteral.d.ts +24 -0
  18. package/dist/parser/objectLiteral.d.ts.map +1 -0
  19. package/dist/parser/objectLiteral.js +38 -0
  20. package/dist/parser/objectLiteral.js.map +1 -0
  21. package/dist/parser/semantic/bounds.d.ts +13 -0
  22. package/dist/parser/semantic/bounds.d.ts.map +1 -0
  23. package/dist/parser/semantic/bounds.js +2 -0
  24. package/dist/parser/semantic/bounds.js.map +1 -0
  25. package/dist/parser/semantic/divisor.d.ts +9 -0
  26. package/dist/parser/semantic/divisor.d.ts.map +1 -0
  27. package/dist/parser/semantic/divisor.js +2 -0
  28. package/dist/parser/semantic/divisor.js.map +1 -0
  29. package/dist/parser/semantic/intersections.d.ts +15 -0
  30. package/dist/parser/semantic/intersections.d.ts.map +1 -0
  31. package/dist/parser/semantic/intersections.js +2 -0
  32. package/dist/parser/semantic/intersections.js.map +1 -0
  33. package/dist/parser/semantic/semantic.d.ts +22 -0
  34. package/dist/parser/semantic/semantic.d.ts.map +1 -0
  35. package/dist/parser/semantic/semantic.js +2 -0
  36. package/dist/parser/semantic/semantic.js.map +1 -0
  37. package/dist/parser/semantic/utils.d.ts +8 -0
  38. package/dist/parser/semantic/utils.d.ts.map +1 -0
  39. package/dist/parser/semantic/utils.js +2 -0
  40. package/dist/parser/semantic/utils.js.map +1 -0
  41. package/dist/parser/semantic/validate.d.ts +24 -0
  42. package/dist/parser/semantic/validate.d.ts.map +1 -0
  43. package/dist/parser/semantic/validate.js +2 -0
  44. package/dist/parser/semantic/validate.js.map +1 -0
  45. package/dist/parser/shared.d.ts +48 -0
  46. package/dist/parser/shared.d.ts.map +1 -0
  47. package/dist/parser/shared.js +41 -0
  48. package/dist/parser/shared.js.map +1 -0
  49. package/dist/parser/string/reduce/dynamic.d.ts +40 -0
  50. package/dist/parser/string/reduce/dynamic.d.ts.map +1 -0
  51. package/dist/parser/string/reduce/dynamic.js +122 -0
  52. package/dist/parser/string/reduce/dynamic.js.map +1 -0
  53. package/dist/parser/string/reduce/shared.d.ts +29 -0
  54. package/dist/parser/string/reduce/shared.d.ts.map +1 -0
  55. package/dist/parser/string/reduce/shared.js +7 -0
  56. package/dist/parser/string/reduce/shared.js.map +1 -0
  57. package/dist/parser/string/reduce/static.d.ts +177 -0
  58. package/dist/parser/string/reduce/static.d.ts.map +1 -0
  59. package/dist/parser/string/reduce/static.js +2 -0
  60. package/dist/parser/string/reduce/static.js.map +1 -0
  61. package/dist/parser/string/shift/operand/date.d.ts +11 -0
  62. package/dist/parser/string/shift/operand/date.d.ts.map +1 -0
  63. package/dist/parser/string/shift/operand/date.js +26 -0
  64. package/dist/parser/string/shift/operand/date.js.map +1 -0
  65. package/dist/parser/string/shift/operand/enclosed.d.ts +49 -0
  66. package/dist/parser/string/shift/operand/enclosed.d.ts.map +1 -0
  67. package/dist/parser/string/shift/operand/enclosed.js +50 -0
  68. package/dist/parser/string/shift/operand/enclosed.js.map +1 -0
  69. package/dist/parser/string/shift/operand/operand.d.ts +9 -0
  70. package/dist/parser/string/shift/operand/operand.d.ts.map +1 -0
  71. package/dist/parser/string/shift/operand/operand.js +17 -0
  72. package/dist/parser/string/shift/operand/operand.js.map +1 -0
  73. package/dist/parser/string/shift/operand/unenclosed.d.ts +36 -0
  74. package/dist/parser/string/shift/operand/unenclosed.d.ts.map +1 -0
  75. package/dist/parser/string/shift/operand/unenclosed.js +68 -0
  76. package/dist/parser/string/shift/operand/unenclosed.js.map +1 -0
  77. package/dist/parser/string/shift/operator/bounds.d.ts +55 -0
  78. package/dist/parser/string/shift/operator/bounds.d.ts.map +1 -0
  79. package/dist/parser/string/shift/operator/bounds.js +95 -0
  80. package/dist/parser/string/shift/operator/bounds.js.map +1 -0
  81. package/dist/parser/string/shift/operator/divisor.d.ts +9 -0
  82. package/dist/parser/string/shift/operator/divisor.d.ts.map +1 -0
  83. package/dist/parser/string/shift/operator/divisor.js +13 -0
  84. package/dist/parser/string/shift/operator/divisor.js.map +1 -0
  85. package/dist/parser/string/shift/operator/operator.d.ts +13 -0
  86. package/dist/parser/string/shift/operator/operator.d.ts.map +1 -0
  87. package/dist/parser/string/shift/operator/operator.js +29 -0
  88. package/dist/parser/string/shift/operator/operator.js.map +1 -0
  89. package/dist/parser/string/shift/scanner.d.ts +71 -0
  90. package/dist/parser/string/shift/scanner.d.ts.map +1 -0
  91. package/dist/parser/string/shift/scanner.js +99 -0
  92. package/dist/parser/string/shift/scanner.js.map +1 -0
  93. package/dist/parser/string/string.d.ts +26 -0
  94. package/dist/parser/string/string.d.ts.map +1 -0
  95. package/dist/parser/string/string.js +31 -0
  96. package/dist/parser/string/string.js.map +1 -0
  97. package/dist/parser/tuple.d.ts +73 -0
  98. package/dist/parser/tuple.d.ts.map +1 -0
  99. package/dist/parser/tuple.js +134 -0
  100. package/dist/parser/tuple.js.map +1 -0
  101. package/dist/scope.d.ts +159 -0
  102. package/dist/scope.d.ts.map +1 -0
  103. package/dist/scope.js +248 -0
  104. package/dist/scope.js.map +1 -0
  105. package/dist/scopes/ark.d.ts +38 -0
  106. package/dist/scopes/ark.d.ts.map +1 -0
  107. package/dist/scopes/ark.js +24 -0
  108. package/dist/scopes/ark.js.map +1 -0
  109. package/dist/scopes/jsObjects.d.ts +19 -0
  110. package/dist/scopes/jsObjects.d.ts.map +1 -0
  111. package/dist/scopes/jsObjects.js +15 -0
  112. package/dist/scopes/jsObjects.js.map +1 -0
  113. package/dist/scopes/parsing.d.ts +18 -0
  114. package/dist/scopes/parsing.d.ts.map +1 -0
  115. package/dist/scopes/parsing.js +61 -0
  116. package/dist/scopes/parsing.js.map +1 -0
  117. package/dist/scopes/tsGenerics.d.ts +17 -0
  118. package/dist/scopes/tsGenerics.d.ts.map +1 -0
  119. package/dist/scopes/tsGenerics.js +13 -0
  120. package/dist/scopes/tsGenerics.js.map +1 -0
  121. package/dist/scopes/tsKeywords.d.ts +24 -0
  122. package/dist/scopes/tsKeywords.d.ts.map +1 -0
  123. package/dist/scopes/tsKeywords.js +20 -0
  124. package/dist/scopes/tsKeywords.js.map +1 -0
  125. package/dist/scopes/utils/creditCard.d.ts +3 -0
  126. package/dist/scopes/utils/creditCard.d.ts.map +1 -0
  127. package/dist/{mjs/scopes/validation → scopes/utils}/creditCard.js +14 -12
  128. package/dist/scopes/utils/creditCard.js.map +1 -0
  129. package/dist/{types/scopes/validation → scopes/utils}/date.d.ts +3 -2
  130. package/dist/scopes/utils/date.d.ts.map +1 -0
  131. package/dist/{mjs/scopes/validation → scopes/utils}/date.js +24 -19
  132. package/dist/scopes/utils/date.js.map +1 -0
  133. package/dist/scopes/validation.d.ts +20 -0
  134. package/dist/scopes/validation.d.ts.map +1 -0
  135. package/dist/scopes/validation.js +57 -0
  136. package/dist/scopes/validation.js.map +1 -0
  137. package/dist/type.d.ts +101 -0
  138. package/dist/type.d.ts.map +1 -0
  139. package/dist/type.js +138 -0
  140. package/dist/type.js.map +1 -0
  141. package/main.ts +20 -0
  142. package/match.ts +137 -0
  143. package/package.json +41 -108
  144. package/parser/definition.ts +156 -0
  145. package/parser/generic.ts +208 -0
  146. package/parser/objectLiteral.ts +120 -0
  147. package/parser/semantic/bounds.ts +63 -0
  148. package/parser/semantic/divisor.ts +13 -0
  149. package/parser/semantic/intersections.ts +47 -0
  150. package/parser/semantic/semantic.ts +107 -0
  151. package/parser/semantic/utils.ts +26 -0
  152. package/parser/semantic/validate.ts +105 -0
  153. package/parser/shared.ts +141 -0
  154. package/parser/string/reduce/dynamic.ts +181 -0
  155. package/parser/string/reduce/shared.ts +73 -0
  156. package/parser/string/reduce/static.ts +300 -0
  157. package/parser/string/shift/operand/date.ts +57 -0
  158. package/parser/string/shift/operand/enclosed.ts +119 -0
  159. package/parser/string/shift/operand/operand.ts +48 -0
  160. package/parser/string/shift/operand/unenclosed.ts +282 -0
  161. package/parser/string/shift/operator/bounds.ts +229 -0
  162. package/parser/string/shift/operator/divisor.ts +36 -0
  163. package/parser/string/shift/operator/operator.ts +82 -0
  164. package/parser/string/shift/scanner.ts +209 -0
  165. package/parser/string/string.ts +93 -0
  166. package/parser/tuple.ts +475 -0
  167. package/scope.ts +573 -0
  168. package/scopes/ark.ts +64 -0
  169. package/scopes/jsObjects.ts +29 -0
  170. package/scopes/parsing.ts +81 -0
  171. package/scopes/tsGenerics.ts +28 -0
  172. package/scopes/tsKeywords.ts +39 -0
  173. package/scopes/utils/creditCard.ts +37 -0
  174. package/scopes/utils/date.ts +108 -0
  175. package/scopes/validation.ts +81 -0
  176. package/type.ts +403 -0
  177. package/LICENSE +0 -7
  178. package/README.md +0 -351
  179. package/dist/cjs/main.js +0 -38
  180. package/dist/cjs/nodes/branch.js +0 -140
  181. package/dist/cjs/nodes/compose.js +0 -163
  182. package/dist/cjs/nodes/discriminate.js +0 -265
  183. package/dist/cjs/nodes/node.js +0 -139
  184. package/dist/cjs/nodes/predicate.js +0 -86
  185. package/dist/cjs/nodes/rules/class.js +0 -25
  186. package/dist/cjs/nodes/rules/collapsibleSet.js +0 -48
  187. package/dist/cjs/nodes/rules/divisor.js +0 -29
  188. package/dist/cjs/nodes/rules/props.js +0 -167
  189. package/dist/cjs/nodes/rules/range.js +0 -105
  190. package/dist/cjs/nodes/rules/regex.js +0 -26
  191. package/dist/cjs/nodes/rules/rules.js +0 -123
  192. package/dist/cjs/package.json +0 -3
  193. package/dist/cjs/parse/ast/ast.js +0 -4
  194. package/dist/cjs/parse/ast/bound.js +0 -16
  195. package/dist/cjs/parse/ast/config.js +0 -13
  196. package/dist/cjs/parse/ast/distributableFunction.js +0 -48
  197. package/dist/cjs/parse/ast/divisor.js +0 -9
  198. package/dist/cjs/parse/ast/intersection.js +0 -30
  199. package/dist/cjs/parse/ast/keyof.js +0 -111
  200. package/dist/cjs/parse/ast/morph.js +0 -58
  201. package/dist/cjs/parse/ast/narrow.js +0 -22
  202. package/dist/cjs/parse/ast/node.js +0 -4
  203. package/dist/cjs/parse/ast/tuple.js +0 -94
  204. package/dist/cjs/parse/ast/union.js +0 -9
  205. package/dist/cjs/parse/ast/utils.js +0 -4
  206. package/dist/cjs/parse/definition.js +0 -61
  207. package/dist/cjs/parse/record.js +0 -37
  208. package/dist/cjs/parse/string/reduce/dynamic.js +0 -167
  209. package/dist/cjs/parse/string/reduce/shared.js +0 -23
  210. package/dist/cjs/parse/string/reduce/static.js +0 -4
  211. package/dist/cjs/parse/string/shift/operand/enclosed.js +0 -54
  212. package/dist/cjs/parse/string/shift/operand/operand.js +0 -11
  213. package/dist/cjs/parse/string/shift/operand/unenclosed.js +0 -53
  214. package/dist/cjs/parse/string/shift/operator/bounds.js +0 -87
  215. package/dist/cjs/parse/string/shift/operator/divisor.js +0 -35
  216. package/dist/cjs/parse/string/shift/operator/operator.js +0 -26
  217. package/dist/cjs/parse/string/shift/scanner.js +0 -114
  218. package/dist/cjs/parse/string/string.js +0 -43
  219. package/dist/cjs/scopes/ark.js +0 -45
  220. package/dist/cjs/scopes/cache.js +0 -52
  221. package/dist/cjs/scopes/expressions.js +0 -29
  222. package/dist/cjs/scopes/jsObjects.js +0 -93
  223. package/dist/cjs/scopes/scope.js +0 -323
  224. package/dist/cjs/scopes/tsKeywords.js +0 -113
  225. package/dist/cjs/scopes/type.js +0 -50
  226. package/dist/cjs/scopes/validation/creditCard.js +0 -47
  227. package/dist/cjs/scopes/validation/date.js +0 -62
  228. package/dist/cjs/scopes/validation/validation.js +0 -108
  229. package/dist/cjs/traverse/problems.js +0 -281
  230. package/dist/cjs/traverse/traverse.js +0 -390
  231. package/dist/cjs/utils/chainableNoOpProxy.js +0 -23
  232. package/dist/cjs/utils/data.js +0 -53
  233. package/dist/cjs/utils/domains.js +0 -30
  234. package/dist/cjs/utils/errors.js +0 -26
  235. package/dist/cjs/utils/freeze.js +0 -15
  236. package/dist/cjs/utils/generics.js +0 -63
  237. package/dist/cjs/utils/numericLiterals.js +0 -75
  238. package/dist/cjs/utils/objectKinds.js +0 -69
  239. package/dist/cjs/utils/paths.js +0 -32
  240. package/dist/cjs/utils/serialize.js +0 -74
  241. package/dist/cjs/utils/unionToTuple.js +0 -4
  242. package/dist/mjs/main.js +0 -8
  243. package/dist/mjs/nodes/branch.js +0 -123
  244. package/dist/mjs/nodes/compose.js +0 -141
  245. package/dist/mjs/nodes/discriminate.js +0 -250
  246. package/dist/mjs/nodes/node.js +0 -117
  247. package/dist/mjs/nodes/predicate.js +0 -69
  248. package/dist/mjs/nodes/rules/class.js +0 -11
  249. package/dist/mjs/nodes/rules/collapsibleSet.js +0 -34
  250. package/dist/mjs/nodes/rules/divisor.js +0 -15
  251. package/dist/mjs/nodes/rules/props.js +0 -149
  252. package/dist/mjs/nodes/rules/range.js +0 -86
  253. package/dist/mjs/nodes/rules/regex.js +0 -11
  254. package/dist/mjs/nodes/rules/rules.js +0 -106
  255. package/dist/mjs/package.json +0 -3
  256. package/dist/mjs/parse/ast/ast.js +0 -1
  257. package/dist/mjs/parse/ast/bound.js +0 -2
  258. package/dist/mjs/parse/ast/config.js +0 -9
  259. package/dist/mjs/parse/ast/distributableFunction.js +0 -34
  260. package/dist/mjs/parse/ast/divisor.js +0 -1
  261. package/dist/mjs/parse/ast/intersection.js +0 -16
  262. package/dist/mjs/parse/ast/keyof.js +0 -103
  263. package/dist/mjs/parse/ast/morph.js +0 -44
  264. package/dist/mjs/parse/ast/narrow.js +0 -14
  265. package/dist/mjs/parse/ast/node.js +0 -1
  266. package/dist/mjs/parse/ast/tuple.js +0 -80
  267. package/dist/mjs/parse/ast/union.js +0 -1
  268. package/dist/mjs/parse/ast/utils.js +0 -1
  269. package/dist/mjs/parse/definition.js +0 -46
  270. package/dist/mjs/parse/record.js +0 -29
  271. package/dist/mjs/parse/string/reduce/dynamic.js +0 -159
  272. package/dist/mjs/parse/string/reduce/shared.js +0 -6
  273. package/dist/mjs/parse/string/reduce/static.js +0 -1
  274. package/dist/mjs/parse/string/shift/operand/enclosed.js +0 -39
  275. package/dist/mjs/parse/string/shift/operand/operand.js +0 -3
  276. package/dist/mjs/parse/string/shift/operand/unenclosed.js +0 -36
  277. package/dist/mjs/parse/string/shift/operator/bounds.js +0 -70
  278. package/dist/mjs/parse/string/shift/operator/divisor.js +0 -21
  279. package/dist/mjs/parse/string/shift/operator/operator.js +0 -13
  280. package/dist/mjs/parse/string/shift/scanner.js +0 -106
  281. package/dist/mjs/parse/string/string.js +0 -28
  282. package/dist/mjs/scopes/ark.js +0 -28
  283. package/dist/mjs/scopes/cache.js +0 -38
  284. package/dist/mjs/scopes/expressions.js +0 -89
  285. package/dist/mjs/scopes/jsObjects.js +0 -82
  286. package/dist/mjs/scopes/scope.js +0 -303
  287. package/dist/mjs/scopes/tsKeywords.js +0 -116
  288. package/dist/mjs/scopes/type.js +0 -35
  289. package/dist/mjs/scopes/validation/validation.js +0 -112
  290. package/dist/mjs/traverse/problems.js +0 -260
  291. package/dist/mjs/traverse/traverse.js +0 -373
  292. package/dist/mjs/utils/chainableNoOpProxy.js +0 -15
  293. package/dist/mjs/utils/data.js +0 -38
  294. package/dist/mjs/utils/domains.js +0 -15
  295. package/dist/mjs/utils/errors.js +0 -10
  296. package/dist/mjs/utils/freeze.js +0 -7
  297. package/dist/mjs/utils/generics.js +0 -38
  298. package/dist/mjs/utils/numericLiterals.js +0 -72
  299. package/dist/mjs/utils/objectKinds.js +0 -55
  300. package/dist/mjs/utils/paths.js +0 -18
  301. package/dist/mjs/utils/serialize.js +0 -58
  302. package/dist/mjs/utils/unionToTuple.js +0 -1
  303. package/dist/tsconfig.temp.tsbuildinfo +0 -1
  304. package/dist/types/main.d.ts +0 -15
  305. package/dist/types/nodes/branch.d.ts +0 -29
  306. package/dist/types/nodes/compose.d.ts +0 -98
  307. package/dist/types/nodes/discriminate.d.ts +0 -26
  308. package/dist/types/nodes/node.d.ts +0 -69
  309. package/dist/types/nodes/predicate.d.ts +0 -18
  310. package/dist/types/nodes/rules/class.d.ts +0 -4
  311. package/dist/types/nodes/rules/collapsibleSet.d.ts +0 -4
  312. package/dist/types/nodes/rules/divisor.d.ts +0 -3
  313. package/dist/types/nodes/rules/props.d.ts +0 -43
  314. package/dist/types/nodes/rules/range.d.ts +0 -34
  315. package/dist/types/nodes/rules/regex.d.ts +0 -5
  316. package/dist/types/nodes/rules/rules.d.ts +0 -33
  317. package/dist/types/parse/ast/ast.d.ts +0 -24
  318. package/dist/types/parse/ast/bound.d.ts +0 -27
  319. package/dist/types/parse/ast/config.d.ts +0 -15
  320. package/dist/types/parse/ast/distributableFunction.d.ts +0 -18
  321. package/dist/types/parse/ast/divisor.d.ts +0 -13
  322. package/dist/types/parse/ast/intersection.d.ts +0 -31
  323. package/dist/types/parse/ast/keyof.d.ts +0 -10
  324. package/dist/types/parse/ast/morph.d.ts +0 -18
  325. package/dist/types/parse/ast/narrow.d.ts +0 -21
  326. package/dist/types/parse/ast/node.d.ts +0 -35
  327. package/dist/types/parse/ast/tuple.d.ts +0 -41
  328. package/dist/types/parse/ast/union.d.ts +0 -17
  329. package/dist/types/parse/ast/utils.d.ts +0 -7
  330. package/dist/types/parse/definition.d.ts +0 -30
  331. package/dist/types/parse/record.d.ts +0 -26
  332. package/dist/types/parse/string/reduce/dynamic.d.ts +0 -34
  333. package/dist/types/parse/string/reduce/shared.d.ts +0 -25
  334. package/dist/types/parse/string/reduce/static.d.ts +0 -130
  335. package/dist/types/parse/string/shift/operand/enclosed.d.ts +0 -28
  336. package/dist/types/parse/string/shift/operand/operand.d.ts +0 -9
  337. package/dist/types/parse/string/shift/operand/unenclosed.d.ts +0 -18
  338. package/dist/types/parse/string/shift/operator/bounds.d.ts +0 -21
  339. package/dist/types/parse/string/shift/operator/divisor.d.ts +0 -13
  340. package/dist/types/parse/string/shift/operator/operator.d.ts +0 -13
  341. package/dist/types/parse/string/shift/scanner.d.ts +0 -89
  342. package/dist/types/parse/string/string.d.ts +0 -25
  343. package/dist/types/scopes/ark.d.ts +0 -209
  344. package/dist/types/scopes/cache.d.ts +0 -14
  345. package/dist/types/scopes/expressions.d.ts +0 -136
  346. package/dist/types/scopes/jsObjects.d.ts +0 -26
  347. package/dist/types/scopes/scope.d.ts +0 -99
  348. package/dist/types/scopes/tsKeywords.d.ts +0 -50
  349. package/dist/types/scopes/type.d.ts +0 -67
  350. package/dist/types/scopes/validation/creditCard.d.ts +0 -2
  351. package/dist/types/scopes/validation/validation.d.ts +0 -49
  352. package/dist/types/traverse/problems.d.ts +0 -88
  353. package/dist/types/traverse/traverse.d.ts +0 -55
  354. package/dist/types/utils/chainableNoOpProxy.d.ts +0 -14
  355. package/dist/types/utils/data.d.ts +0 -13
  356. package/dist/types/utils/domains.d.ts +0 -32
  357. package/dist/types/utils/errors.d.ts +0 -6
  358. package/dist/types/utils/freeze.d.ts +0 -2
  359. package/dist/types/utils/generics.d.ts +0 -125
  360. package/dist/types/utils/numericLiterals.d.ts +0 -46
  361. package/dist/types/utils/objectKinds.d.ts +0 -84
  362. package/dist/types/utils/paths.d.ts +0 -9
  363. package/dist/types/utils/serialize.d.ts +0 -37
  364. package/dist/types/utils/unionToTuple.d.ts +0 -11
@@ -1,13 +0,0 @@
1
- import type { error } from "../../../../utils/generics.js";
2
- import { tryParseWellFormedInteger } from "../../../../utils/numericLiterals.js";
3
- import type { DynamicState } from "../../reduce/dynamic.js";
4
- import type { state, StaticState } from "../../reduce/static.js";
5
- import type { Scanner } from "../scanner.js";
6
- export declare const parseDivisor: (s: DynamicState) => void;
7
- export type parseDivisor<s extends StaticState, unscanned extends string> = Scanner.shiftUntilNextTerminator<unscanned> extends Scanner.shiftResult<infer scanned, infer nextUnscanned> ? tryParseWellFormedInteger<scanned, writeInvalidDivisorMessage<scanned>> extends infer divisor ? divisor extends number ? divisor extends 0 ? error<writeInvalidDivisorMessage<0>> : state.setRoot<s, [
8
- s["root"],
9
- "%",
10
- `${divisor}`
11
- ], nextUnscanned> : error<divisor & string> : never : never;
12
- export declare const writeInvalidDivisorMessage: <divisor extends string | number>(divisor: divisor) => `% operator must be followed by a non-zero integer literal (was ${divisor})`;
13
- export type writeInvalidDivisorMessage<divisor extends string | number> = `% operator must be followed by a non-zero integer literal (was ${divisor})`;
@@ -1,13 +0,0 @@
1
- import type { error } from "../../../../utils/generics.js";
2
- import type { DynamicState } from "../../reduce/dynamic.js";
3
- import type { state, StaticState } from "../../reduce/static.js";
4
- import { Scanner } from "../scanner.js";
5
- import { parseBound } from "./bounds.js";
6
- import { parseDivisor } from "./divisor.js";
7
- export declare const parseOperator: (s: DynamicState) => void;
8
- export type parseOperator<s extends StaticState> = s["unscanned"] extends Scanner.shift<infer lookahead, infer unscanned> ? lookahead extends "[" ? unscanned extends Scanner.shift<"]", infer nextUnscanned> ? state.setRoot<s, [s["root"], "[]"], nextUnscanned> : error<incompleteArrayTokenMessage> : lookahead extends Scanner.BranchToken ? state.reduceBranch<s, lookahead, unscanned> : lookahead extends ")" ? state.finalizeGroup<s, unscanned> : lookahead extends Scanner.ComparatorStartChar ? parseBound<s, lookahead, unscanned> : lookahead extends "%" ? parseDivisor<s, unscanned> : lookahead extends " " ? parseOperator<state.scanTo<s, unscanned>> : error<writeUnexpectedCharacterMessage<lookahead>> : state.finalize<s>;
9
- export declare const writeUnexpectedCharacterMessage: <char extends string>(char: char) => `Unexpected character '${char}'`;
10
- type writeUnexpectedCharacterMessage<char extends string> = `Unexpected character '${char}'`;
11
- export declare const incompleteArrayTokenMessage = "Missing expected ']'";
12
- type incompleteArrayTokenMessage = typeof incompleteArrayTokenMessage;
13
- export {};
@@ -1,89 +0,0 @@
1
- import type { Dict } from "../../../utils/generics.js";
2
- export declare class Scanner<Lookahead extends string = string> {
3
- private chars;
4
- private i;
5
- finalized: boolean;
6
- constructor(def: string);
7
- /** Get lookahead and advance scanner by one */
8
- shift(): Lookahead;
9
- get lookahead(): Lookahead;
10
- shiftUntil(condition: Scanner.UntilCondition): string;
11
- shiftUntilNextTerminator(): string;
12
- get unscanned(): string;
13
- lookaheadIs<Char extends Lookahead>(char: Char): this is Scanner<Char>;
14
- lookaheadIsIn<Tokens extends Dict>(tokens: Tokens): this is Scanner<Extract<keyof Tokens, string>>;
15
- }
16
- export declare namespace Scanner {
17
- type UntilCondition = (scanner: Scanner, shifted: string) => boolean;
18
- type OnInputEndFn = (scanner: Scanner, shifted: string) => string;
19
- type ShiftUntilOptions = {
20
- onInputEnd?: OnInputEndFn;
21
- };
22
- const lookaheadIsTerminator: UntilCondition;
23
- const lookaheadIsNotWhitespace: UntilCondition;
24
- const comparatorStartChars: {
25
- readonly "<": true;
26
- readonly ">": true;
27
- readonly "=": true;
28
- };
29
- const terminatingChars: {
30
- readonly "|": true;
31
- readonly "&": true;
32
- readonly ")": true;
33
- readonly "[": true;
34
- readonly "%": true;
35
- readonly " ": true;
36
- readonly "<": true;
37
- readonly ">": true;
38
- readonly "=": true;
39
- };
40
- type TerminatingChar = keyof typeof Scanner.terminatingChars;
41
- const comparators: {
42
- readonly "<": true;
43
- readonly ">": true;
44
- readonly "<=": true;
45
- readonly ">=": true;
46
- readonly "==": true;
47
- };
48
- type Comparator = keyof typeof comparators;
49
- type ComparatorStartChar = keyof typeof comparatorStartChars;
50
- const oneCharComparators: {
51
- readonly "<": true;
52
- readonly ">": true;
53
- };
54
- type OneCharComparator = keyof typeof oneCharComparators;
55
- const comparatorDescriptions: {
56
- readonly "<": "less than";
57
- readonly ">": "more than";
58
- readonly "<=": "at most";
59
- readonly ">=": "at least";
60
- readonly "==": "exactly";
61
- };
62
- const invertedComparators: {
63
- readonly "<": ">";
64
- readonly ">": "<";
65
- readonly "<=": ">=";
66
- readonly ">=": "<=";
67
- readonly "==": "==";
68
- };
69
- type InvertedComparators = typeof invertedComparators;
70
- const branchTokens: {
71
- readonly "|": true;
72
- readonly "&": true;
73
- };
74
- type BranchToken = keyof typeof branchTokens;
75
- type InfixToken = BranchToken | Comparator | "%" | ":" | "=>" | "|>";
76
- type PostfixToken = "[]";
77
- type OperatorToken = InfixToken | PostfixToken;
78
- const escapeToken = "\\";
79
- type EscapeToken = typeof escapeToken;
80
- const whiteSpaceToken = " ";
81
- type WhiteSpaceToken = typeof whiteSpaceToken;
82
- type finalized = "{done}";
83
- type shift<Lookahead extends string, Unscanned extends string> = `${Lookahead}${Unscanned}`;
84
- type shiftUntil<unscanned extends string, terminator extends string, scanned extends string = ""> = unscanned extends Scanner.shift<infer lookahead, infer nextUnscanned> ? lookahead extends terminator ? scanned extends `${infer base}${EscapeToken}` ? shiftUntil<nextUnscanned, terminator, `${base}${lookahead}`> : [scanned, unscanned] : shiftUntil<nextUnscanned, terminator, `${scanned}${lookahead}`> : [scanned, ""];
85
- type shiftUntilNot<unscanned extends string, nonTerminator extends string, scanned extends string = ""> = unscanned extends Scanner.shift<infer lookahead, infer nextUnscanned> ? lookahead extends nonTerminator ? shiftUntilNot<nextUnscanned, nonTerminator, `${scanned}${lookahead}`> : [scanned, unscanned] : [scanned, ""];
86
- type shiftUntilNextTerminator<unscanned extends string> = shiftUntil<skipWhitespace<unscanned>, TerminatingChar>;
87
- type skipWhitespace<unscanned extends string> = shiftUntilNot<unscanned, WhiteSpaceToken>[1];
88
- type shiftResult<scanned extends string, unscanned extends string> = [scanned, unscanned];
89
- }
@@ -1,25 +0,0 @@
1
- import type { error } from "../../utils/generics.js";
2
- import type { inferAst } from "../ast/ast.js";
3
- import type { ParseContext } from "../definition.js";
4
- import { DynamicState } from "./reduce/dynamic.js";
5
- import type { state, StaticState } from "./reduce/static.js";
6
- import { parseOperand } from "./shift/operand/operand.js";
7
- import { parseOperator } from "./shift/operator/operator.js";
8
- import type { Scanner } from "./shift/scanner.js";
9
- export declare const parseString: (def: string, ctx: ParseContext) => import("../../nodes/node.js").Node;
10
- export type parseString<def extends string, $> = maybeNaiveParse<def, $>;
11
- export type inferString<def extends string, $> = inferAst<parseString<def, $>, $>;
12
- /**
13
- * Try to parse the definition from right to left using the most common syntax.
14
- * This can be much more efficient for simple definitions.
15
- */
16
- type maybeNaiveParse<def extends string, $> = def extends `${infer child}[]` ? child extends keyof $ ? [child, "[]"] : fullStringParse<def, $> : def extends keyof $ ? def : fullStringParse<def, $>;
17
- export declare const maybeNaiveParse: (def: string, ctx: ParseContext) => string | import("../../nodes/node.js").ResolvedNode<import("../../utils/generics.js").Dict> | undefined;
18
- export declare const fullStringParse: (def: string, ctx: ParseContext) => import("../../nodes/node.js").Node;
19
- type fullStringParse<def extends string, $> = loop<state.initialize<def>, $>;
20
- declare const loop: (s: DynamicState) => import("../../nodes/node.js").Node;
21
- type loop<s extends StaticState | error, $> = s extends StaticState ? loopValid<s, $> : s;
22
- type loopValid<s extends StaticState, $> = s["unscanned"] extends Scanner.finalized ? s["root"] : loop<next<s, $>, $>;
23
- declare const next: (s: DynamicState) => void;
24
- type next<s extends StaticState, $> = s["root"] extends undefined ? parseOperand<s, $> : parseOperator<s>;
25
- export {};
@@ -1,209 +0,0 @@
1
- import type { Out } from "../parse/ast/morph.js";
2
- import type { Space } from "./scope.js";
3
- import type { TypeParser } from "./type.js";
4
- export declare const arkScope: import("./scope.js").Scope<[{
5
- any: any;
6
- bigint: bigint;
7
- boolean: boolean;
8
- false: false;
9
- never: never;
10
- null: null;
11
- number: number;
12
- object: object;
13
- string: string;
14
- symbol: symbol;
15
- true: true;
16
- unknown: unknown;
17
- void: void;
18
- undefined: undefined;
19
- Function: (...args: any[]) => unknown;
20
- Date: Date;
21
- Error: Error;
22
- Map: Map<unknown, unknown>;
23
- RegExp: RegExp;
24
- Set: Set<unknown>;
25
- WeakMap: WeakMap<object, unknown>;
26
- WeakSet: WeakSet<object>;
27
- Promise: Promise<unknown>;
28
- alpha: string;
29
- alphanumeric: string;
30
- lowercase: string;
31
- uppercase: string;
32
- creditCard: string;
33
- email: string;
34
- uuid: string;
35
- parsedNumber: (In: string) => Out<number>;
36
- parsedInteger: (In: string) => Out<number>;
37
- parsedDate: (In: string) => Out<Date>;
38
- semver: string;
39
- json: (In: string) => Out<unknown>;
40
- integer: number;
41
- }, {}, false]>;
42
- export declare const ark: Space<PrecompiledDefaults>;
43
- export declare const scopes: {
44
- root: import("./scope.js").Scope<[{}, {}, false]>;
45
- tsKeywords: import("./scope.js").Scope<[{
46
- any: any;
47
- bigint: bigint;
48
- boolean: boolean;
49
- false: false;
50
- never: never;
51
- null: null;
52
- number: number;
53
- object: object;
54
- string: string;
55
- symbol: symbol;
56
- true: true;
57
- unknown: unknown;
58
- void: void;
59
- undefined: undefined;
60
- }, {}, false]>;
61
- jsObjects: import("./scope.js").Scope<[{
62
- Function: (...args: any[]) => unknown;
63
- Date: Date;
64
- Error: Error;
65
- Map: Map<unknown, unknown>;
66
- RegExp: RegExp;
67
- Set: Set<unknown>;
68
- WeakMap: WeakMap<object, unknown>;
69
- WeakSet: WeakSet<object>;
70
- Promise: Promise<unknown>;
71
- }, {}, false]>;
72
- validation: import("./scope.js").Scope<[{
73
- alpha: string;
74
- alphanumeric: string;
75
- lowercase: string;
76
- uppercase: string;
77
- creditCard: string;
78
- email: string;
79
- uuid: string;
80
- parsedNumber: (In: string) => Out<number>;
81
- parsedInteger: (In: string) => Out<number>;
82
- parsedDate: (In: string) => Out<Date>;
83
- semver: string;
84
- json: (In: string) => Out<unknown>;
85
- integer: number;
86
- }, {}, false]>;
87
- ark: import("./scope.js").Scope<[{
88
- any: any;
89
- bigint: bigint;
90
- boolean: boolean;
91
- false: false;
92
- never: never;
93
- null: null;
94
- number: number;
95
- object: object;
96
- string: string;
97
- symbol: symbol;
98
- true: true;
99
- unknown: unknown;
100
- void: void;
101
- undefined: undefined;
102
- Function: (...args: any[]) => unknown;
103
- Date: Date;
104
- Error: Error;
105
- Map: Map<unknown, unknown>;
106
- RegExp: RegExp;
107
- Set: Set<unknown>;
108
- WeakMap: WeakMap<object, unknown>;
109
- WeakSet: WeakSet<object>;
110
- Promise: Promise<unknown>;
111
- alpha: string;
112
- alphanumeric: string;
113
- lowercase: string;
114
- uppercase: string;
115
- creditCard: string;
116
- email: string;
117
- uuid: string;
118
- parsedNumber: (In: string) => Out<number>;
119
- parsedInteger: (In: string) => Out<number>;
120
- parsedDate: (In: string) => Out<Date>;
121
- semver: string;
122
- json: (In: string) => Out<unknown>;
123
- integer: number;
124
- }, {}, false]>;
125
- };
126
- export declare const spaces: {
127
- tsKeywords: Space<{
128
- any: any;
129
- bigint: bigint;
130
- boolean: boolean;
131
- false: false;
132
- never: never;
133
- null: null;
134
- number: number;
135
- object: object;
136
- string: string;
137
- symbol: symbol;
138
- true: true;
139
- unknown: unknown;
140
- void: void;
141
- undefined: undefined;
142
- }>;
143
- jsObjects: Space<{
144
- Function: (...args: any[]) => unknown;
145
- Date: Date;
146
- Error: Error;
147
- Map: Map<unknown, unknown>;
148
- RegExp: RegExp;
149
- Set: Set<unknown>;
150
- WeakMap: WeakMap<object, unknown>;
151
- WeakSet: WeakSet<object>;
152
- Promise: Promise<unknown>;
153
- }>;
154
- validation: Space<{
155
- alpha: string;
156
- alphanumeric: string;
157
- lowercase: string;
158
- uppercase: string;
159
- creditCard: string;
160
- email: string;
161
- uuid: string;
162
- parsedNumber: (In: string) => Out<number>;
163
- parsedInteger: (In: string) => Out<number>;
164
- parsedDate: (In: string) => Out<Date>;
165
- semver: string;
166
- json: (In: string) => Out<unknown>;
167
- integer: number;
168
- }>;
169
- ark: Space<PrecompiledDefaults>;
170
- };
171
- export type PrecompiledDefaults = {
172
- any: any;
173
- bigint: bigint;
174
- boolean: boolean;
175
- false: false;
176
- never: never;
177
- null: null;
178
- number: number;
179
- object: object;
180
- string: string;
181
- symbol: symbol;
182
- true: true;
183
- unknown: unknown;
184
- void: void;
185
- undefined: undefined;
186
- integer: number;
187
- alpha: string;
188
- alphanumeric: string;
189
- lowercase: string;
190
- uppercase: string;
191
- creditCard: string;
192
- email: string;
193
- uuid: string;
194
- semver: string;
195
- json: (In: string) => Out<unknown>;
196
- parsedNumber: (In: string) => Out<number>;
197
- parsedInteger: (In: string) => Out<number>;
198
- parsedDate: (In: string) => Out<Date>;
199
- Function: (...args: any[]) => unknown;
200
- Date: Date;
201
- Error: Error;
202
- Map: Map<unknown, unknown>;
203
- RegExp: RegExp;
204
- Set: Set<unknown>;
205
- WeakMap: WeakMap<object, unknown>;
206
- WeakSet: WeakSet<object>;
207
- Promise: Promise<unknown>;
208
- };
209
- export declare const type: TypeParser<PrecompiledDefaults>;
@@ -1,14 +0,0 @@
1
- export declare class Cache<item = unknown> {
2
- protected cache: {
3
- [name in string]?: item;
4
- };
5
- get root(): {
6
- readonly [name in string]?: item;
7
- };
8
- has(name: string): boolean;
9
- get(name: string): item | undefined;
10
- set(name: string, item: item): item;
11
- }
12
- export declare class FreezingCache<item = unknown> extends Cache<item> {
13
- set(name: string, item: item): item;
14
- }
@@ -1,136 +0,0 @@
1
- import type { distributable } from "../parse/ast/distributableFunction.js";
2
- import type { Morph } from "../parse/ast/morph.js";
3
- import type { Narrow } from "../parse/ast/narrow.js";
4
- import type { FunctionalTupleOperator, inferTupleExpression, TupleExpression, TuplePostfixOperator, UnparsedTupleExpressionInput, UnparsedTupleOperator } from "../parse/ast/tuple.js";
5
- import type { inferDefinition, validateDefinition } from "../parse/definition.js";
6
- import type { conform } from "../utils/generics.js";
7
- import type { PrecompiledDefaults } from "./ark.js";
8
- import type { asIn, asOut, Type, TypeOptions } from "./type.js";
9
- export type Expressions<$> = {
10
- intersection: BinaryExpressionParser<$, "&">;
11
- union: BinaryExpressionParser<$, "|">;
12
- arrayOf: UnaryExpressionParser<$, "[]">;
13
- keyOf: UnaryExpressionParser<$, "keyof">;
14
- node: UnvalidatedExpressionParser<$, "node">;
15
- instanceOf: UnvalidatedExpressionParser<$, "instanceof">;
16
- valueOf: UnvalidatedExpressionParser<$, "===">;
17
- narrow: FunctionalExpressionParser<$, "=>">;
18
- morph: FunctionalExpressionParser<$, "|>">;
19
- };
20
- type Ark = Expressions<PrecompiledDefaults>;
21
- /**
22
- * @operator {@link intersection | &}
23
- * @docgenTable
24
- * @string "L&R"
25
- * @tuple [L, "&", R]
26
- * @helper intersection(L,R)
27
- * @example string
28
- * const intersection = type("/@arktype\.io$/ & email")
29
- * @example tuple
30
- * const tupleIntersection = type(["/@arktype\.io$/", "&", "email"])
31
- * @example helper
32
- * const helperIntersection = intersection("/@arktype\.io$/","email")
33
- */
34
- export declare const intersection: Ark["intersection"];
35
- /**
36
- * @operator {@link union | |}
37
- * @docgenTable
38
- * @string "L|R"
39
- * @tuple [L, "|" , R]
40
- * @helper union(L,R)
41
- * @example string
42
- * const union = type("string|number")
43
- * @example tuple
44
- * const tupleUnion = type(["string", "|", "number"])
45
- * @example helper
46
- * const helperUnion = union("string", "number")
47
- */
48
- export declare const union: Ark["union"];
49
- /**
50
- * @operator {@link arrayOf}
51
- * @docgenTable
52
- * @string "T[]"
53
- * @tuple [T, "[]"]
54
- * @helper arrayOf(T)
55
- * @example string
56
- * const numberArray = type("number[]")
57
- * @example tuple
58
- * const tupleArray = type(["number", "[]"])
59
- * @example helper
60
- * const helperArray = arrayOf("number")
61
- */
62
- export declare const arrayOf: Ark["arrayOf"];
63
- /**
64
- * @operator {@link keyOf}
65
- * @docgenTable
66
- * @tuple "["keyOf", T]"
67
- * @helper keyOf(T)
68
- * @example tuple
69
- * const tupleKeyOf = type(["keyOf", {a:"string"}])
70
- * @example helper
71
- * const helperKeyOf = keyOf({a:"string"})
72
- */
73
- export declare const keyOf: Ark["keyOf"];
74
- /**
75
- * @operator {@link instanceOf}
76
- * @docgenTable
77
- * @tuple ["instanceOf", T]
78
- * @helper instanceOf(T)
79
- * @example tuple
80
- * const tupleInstanceOf = type(["instanceOf", Date])
81
- * @example helper
82
- * const helperInstanceOf = instanceOf(Date)
83
- */
84
- export declare const instanceOf: Ark["instanceOf"];
85
- /**
86
- * @operator {@link valueOf | ===}
87
- * @docgenTable
88
- * @tuple ["===", T]
89
- * @helper valueOf(T)
90
- * @example tuple
91
- * const tupleValueOf = type(["valueOf", {a:"string"}])
92
- * @example helper
93
- * const helperValueOf = valueOf({a:"string"})
94
- */
95
- export declare const valueOf: Ark["valueOf"];
96
- /**
97
- * @operator {@link narrow | =>}
98
- * @docgenTable
99
- * @tuple ["type", "=>" , condition]
100
- * @example tuple
101
- * const narrow = type( ["number", "=>" , (n) => n % 2 === 0])
102
- * @example
103
- * const isEven = (x: unknown): x is number => x % 2 === 0
104
- */
105
- export declare const narrow: Ark["narrow"];
106
- /**
107
- * @operator {@link morph | |>}
108
- * @docgenTable
109
- * @tuple [inputType, "|>", (data) => output]
110
- * @helper morph(inputType, (data) => output)
111
- * @example tuple
112
- * const tupleMorph = type( ["string", "|>" , (data) => `morphed ${data}`])
113
- * @example helper
114
- * const helperMorph = morph("string", (data) => `morphed ${data}`)
115
- */
116
- export declare const morph: Ark["morph"];
117
- export type BinaryExpressionParser<$, operator extends "&" | "|"> = {
118
- <l, r>(l: validateDefinition<l, $>, r: validateDefinition<r, $>): parseTupleExpression<[l, operator, r], $>;
119
- <l, r>(l: validateDefinition<l, $>, r: validateDefinition<r, $>, opts: TypeOptions): parseTupleExpression<[l, operator, r], $>;
120
- };
121
- export type UnaryExpressionParser<$, operator extends "keyof" | "[]"> = {
122
- <def>(def: validateDefinition<def, $>): parseTupleExpression<unaryToTupleExpression<def, operator>, $>;
123
- <def>(def: validateDefinition<def, $>, opts: TypeOptions): parseTupleExpression<unaryToTupleExpression<def, operator>, $>;
124
- };
125
- export type UnvalidatedExpressionParser<$, operator extends UnparsedTupleOperator> = {
126
- <def>(def: conform<def, UnparsedTupleExpressionInput<$>[operator]>): parseTupleExpression<[operator, def], $>;
127
- <def>(def: conform<def, UnparsedTupleExpressionInput<$>[operator]>, opts: TypeOptions): parseTupleExpression<[operator, def], $>;
128
- };
129
- export type FunctionalExpressionParser<$, operator extends FunctionalTupleOperator> = {
130
- <inDef, fn extends FunctionWithInferredInput<$, operator, inDef>>(inDef: validateDefinition<inDef, $>, fn: fn): parseTupleExpression<[inDef, operator, fn], $>;
131
- <inDef, fn extends FunctionWithInferredInput<$, operator, inDef>>(inDef: validateDefinition<inDef, $>, fn: fn, opts: TypeOptions): parseTupleExpression<[inDef, operator, fn], $>;
132
- };
133
- export type FunctionWithInferredInput<$, operator extends FunctionalTupleOperator, inDef> = operator extends "=>" ? distributable<Narrow<asIn<inferDefinition<inDef, $>>>> : Morph<asOut<inferDefinition<inDef, $>>>;
134
- type unaryToTupleExpression<def, operator extends "keyof" | "[]"> = operator extends TuplePostfixOperator ? [def, "[]"] : [operator, def];
135
- type parseTupleExpression<expression extends TupleExpression, $> = inferTupleExpression<expression, $> extends infer result ? [result] extends [never] ? never : Type<result> : never;
136
- export {};
@@ -1,26 +0,0 @@
1
- /**
2
- * @docgenScope
3
- * @docgenTable
4
- */
5
- export declare const jsObjectsScope: import("./scope.js").Scope<[{
6
- Function: (...args: any[]) => unknown;
7
- Date: Date;
8
- Error: Error;
9
- Map: Map<unknown, unknown>;
10
- RegExp: RegExp;
11
- Set: Set<unknown>;
12
- WeakMap: WeakMap<object, unknown>;
13
- WeakSet: WeakSet<object>;
14
- Promise: Promise<unknown>;
15
- }, {}, false]>;
16
- export declare const jsObjects: import("./scope.js").Space<{
17
- Function: (...args: any[]) => unknown;
18
- Date: Date;
19
- Error: Error;
20
- Map: Map<unknown, unknown>;
21
- RegExp: RegExp;
22
- Set: Set<unknown>;
23
- WeakMap: WeakMap<object, unknown>;
24
- WeakSet: WeakSet<object>;
25
- Promise: Promise<unknown>;
26
- }>;
@@ -1,99 +0,0 @@
1
- import type { Node, ResolvedNode, TypeNode } from "../nodes/node.js";
2
- import type { ConfigTuple } from "../parse/ast/config.js";
3
- import type { inferDefinition, ParseContext, validateDefinition } from "../parse/definition.js";
4
- import type { ProblemsConfig, ProblemWritersByCode } from "../traverse/problems.js";
5
- import type { Dict, error, evaluate, isAny, List, nominal } from "../utils/generics.js";
6
- import type { stringifyUnion } from "../utils/unionToTuple.js";
7
- import type { PrecompiledDefaults } from "./ark.js";
8
- import { FreezingCache } from "./cache.js";
9
- import type { Expressions } from "./expressions.js";
10
- import type { AnonymousTypeName, KeyCheckKind, QualifiedTypeName, Type, TypeParser } from "./type.js";
11
- type ScopeParser = {
12
- <aliases>(aliases: validateAliases<aliases, {}>): Scope<parseScope<aliases, {}>>;
13
- <aliases, opts extends ScopeOptions>(aliases: validateAliases<aliases, opts>, opts: validateOptions<opts>): Scope<parseScope<aliases, opts>>;
14
- };
15
- type validateAliases<aliases, opts extends ScopeOptions> = evaluate<{
16
- [name in keyof aliases]: name extends keyof preresolved<opts> ? writeDuplicateAliasesMessage<name & string> : validateDefinition<aliases[name], bootstrapScope<aliases, opts>>;
17
- }>;
18
- export type ScopeOptions = {
19
- imports?: Space[] | [];
20
- includes?: Space[] | [];
21
- standard?: boolean;
22
- name?: string;
23
- codes?: ProblemsConfig;
24
- keys?: KeyCheckKind;
25
- };
26
- export type ScopeConfig = evaluate<{
27
- keys: KeyCheckKind;
28
- codes: ProblemWritersByCode;
29
- }>;
30
- export declare const compileScopeOptions: (opts: ScopeOptions) => ScopeConfig;
31
- type validateOptions<opts extends ScopeOptions> = {
32
- [k in keyof opts]: k extends "imports" | "includes" ? mergeSpaces<opts[k], [
33
- k,
34
- "imports"
35
- ] extends ["includes", keyof opts] ? mergeSpaces<opts["includes"]> : {}> extends error<infer e> ? e : opts[k] : opts[k];
36
- };
37
- export type ScopeContext = Dict | ScopeContextTuple;
38
- type ScopeContextTuple = [exports: Dict, locals: Dict, standard?: false];
39
- type parseScope<aliases, opts extends ScopeOptions> = opts["standard"] extends false ? [inferExports<aliases, opts>, importsOf<opts>, false] : opts["imports"] extends Space[] ? [inferExports<aliases, opts>, importsOf<opts>] : inferExports<aliases, opts>;
40
- type importsOf<opts extends ScopeOptions> = unknown extends opts["imports"] ? {} : mergeSpaces<opts["imports"]>;
41
- type includesOf<opts extends ScopeOptions> = unknown extends opts["includes"] ? {} : mergeSpaces<opts["includes"]>;
42
- export type resolve<name extends keyof $, $> = isAny<$[name]> extends true ? any : $[name] extends alias<infer def> ? inferDefinition<def, $> : $[name];
43
- type exportsOf<context extends ScopeContext> = context extends [
44
- infer exports,
45
- ...unknown[]
46
- ] ? exports : context;
47
- type localsOf<context extends ScopeContext> = context extends List ? context["1"] & (context["2"] extends false ? {} : PrecompiledDefaults) : PrecompiledDefaults;
48
- type mergeSpaces<scopes, base extends Dict = {}> = scopes extends readonly [
49
- Space<infer head>,
50
- ...infer tail
51
- ] ? keyof base & keyof head extends never ? mergeSpaces<tail, base & head> : error<writeDuplicateAliasesMessage<stringifyUnion<keyof base & keyof head & string>>> : base;
52
- type preresolved<opts extends ScopeOptions> = includesOf<opts> & importsOf<opts> & (opts["standard"] extends false ? {} : PrecompiledDefaults);
53
- type alias<def = {}> = nominal<def, "alias">;
54
- type bootstrapScope<aliases, opts extends ScopeOptions> = {
55
- [k in keyof aliases]: alias<aliases[k]>;
56
- } & preresolved<opts>;
57
- type inferExports<aliases, opts extends ScopeOptions> = evaluate<{
58
- [k in keyof aliases]: inferDefinition<aliases[k], bootstrapScope<aliases, opts>>;
59
- } & includesOf<opts>>;
60
- export type Space<exports = Dict> = {
61
- [k in keyof exports]: Type<exports[k]>;
62
- };
63
- type resolutions<context extends ScopeContext> = localsOf<context> & exportsOf<context>;
64
- type name<context extends ScopeContext> = keyof resolutions<context> & string;
65
- export declare const isConfigTuple: (def: unknown) => def is ConfigTuple;
66
- export declare class Scope<context extends ScopeContext = any> {
67
- #private;
68
- aliases: Dict;
69
- name: string;
70
- config: ScopeConfig;
71
- parseCache: FreezingCache<Node>;
72
- constructor(aliases: Dict, opts?: ScopeOptions);
73
- getAnonymousQualifiedName(base: AnonymousTypeName): QualifiedTypeName;
74
- addAnonymousTypeReference(referencedType: Type, ctx: ParseContext): Node;
75
- get infer(): exportsOf<context>;
76
- compile(): Space<exportsOf<context>>;
77
- addParsedReferenceIfResolvable(name: name<context>, ctx: ParseContext): boolean;
78
- resolve(name: name<context>): Type;
79
- resolveNode(node: Node): ResolvedNode;
80
- resolveTypeNode(node: Node): TypeNode;
81
- expressions: Expressions<resolutions<context>>;
82
- intersection: import("./expressions.js").BinaryExpressionParser<resolutions<context>, "&">;
83
- union: import("./expressions.js").BinaryExpressionParser<resolutions<context>, "|">;
84
- arrayOf: import("./expressions.js").UnaryExpressionParser<resolutions<context>, "[]">;
85
- keyOf: import("./expressions.js").UnaryExpressionParser<resolutions<context>, "keyof">;
86
- valueOf: import("./expressions.js").UnvalidatedExpressionParser<resolutions<context>, "===">;
87
- instanceOf: import("./expressions.js").UnvalidatedExpressionParser<resolutions<context>, "instanceof">;
88
- narrow: import("./expressions.js").FunctionalExpressionParser<resolutions<context>, "=>">;
89
- morph: import("./expressions.js").FunctionalExpressionParser<resolutions<context>, "|>">;
90
- type: TypeParser<resolutions<context>>;
91
- isResolvable(name: string): unknown;
92
- }
93
- export declare const scope: ScopeParser;
94
- export declare const rootScope: Scope<[{}, {}, false]>;
95
- export declare const rootType: TypeParser<{}>;
96
- export declare const writeShallowCycleErrorMessage: (name: string, seen: string[]) => string;
97
- export declare const writeDuplicateAliasesMessage: <name_1 extends string>(name: name_1) => `Alias '${name_1}' is already defined`;
98
- type writeDuplicateAliasesMessage<name extends string> = `Alias '${name}' is already defined`;
99
- export {};