@ghostry/fabricator 0.0.1

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 (319) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +47 -0
  3. package/dist/esm/Adapter/Core.js +47 -0
  4. package/dist/esm/Adapter/Types.js +1 -0
  5. package/dist/esm/Bound.js +81 -0
  6. package/dist/esm/Distribution/index.js +200 -0
  7. package/dist/esm/Enumeration/Enumerate.js +103 -0
  8. package/dist/esm/Enumeration/Plan.js +286 -0
  9. package/dist/esm/Enumeration/Types.js +1 -0
  10. package/dist/esm/Error/index.js +201 -0
  11. package/dist/esm/Fabricator/Constructor.js +328 -0
  12. package/dist/esm/Fabricator/Types.js +1 -0
  13. package/dist/esm/Instance/Core.js +119 -0
  14. package/dist/esm/Instance/Types.js +1 -0
  15. package/dist/esm/Primitive/always/Fabricator.js +13 -0
  16. package/dist/esm/Primitive/always/Registry.js +11 -0
  17. package/dist/esm/Primitive/always/Schema.js +10 -0
  18. package/dist/esm/Primitive/always/Types.js +1 -0
  19. package/dist/esm/Primitive/always/index.js +5 -0
  20. package/dist/esm/Primitive/array/Fabricator.js +45 -0
  21. package/dist/esm/Primitive/array/Registry.js +26 -0
  22. package/dist/esm/Primitive/array/Schema.js +17 -0
  23. package/dist/esm/Primitive/array/Types.js +1 -0
  24. package/dist/esm/Primitive/array/index.js +5 -0
  25. package/dist/esm/Primitive/bigint/Fabricator.js +54 -0
  26. package/dist/esm/Primitive/bigint/Registry.js +31 -0
  27. package/dist/esm/Primitive/bigint/Schema.js +17 -0
  28. package/dist/esm/Primitive/bigint/Types.js +1 -0
  29. package/dist/esm/Primitive/bigint/index.js +5 -0
  30. package/dist/esm/Primitive/boolean/Fabricator.js +44 -0
  31. package/dist/esm/Primitive/boolean/Outcomes.js +5 -0
  32. package/dist/esm/Primitive/boolean/Registry.js +11 -0
  33. package/dist/esm/Primitive/boolean/Schema.js +33 -0
  34. package/dist/esm/Primitive/boolean/Types.js +1 -0
  35. package/dist/esm/Primitive/boolean/index.js +6 -0
  36. package/dist/esm/Primitive/choice/Fabricator.js +37 -0
  37. package/dist/esm/Primitive/choice/Registry.js +38 -0
  38. package/dist/esm/Primitive/choice/Schema.js +17 -0
  39. package/dist/esm/Primitive/choice/Types.js +1 -0
  40. package/dist/esm/Primitive/choice/index.js +5 -0
  41. package/dist/esm/Primitive/date/Fabricator.js +86 -0
  42. package/dist/esm/Primitive/date/Registry.js +61 -0
  43. package/dist/esm/Primitive/date/Schema.js +17 -0
  44. package/dist/esm/Primitive/date/Types.js +1 -0
  45. package/dist/esm/Primitive/date/index.js +5 -0
  46. package/dist/esm/Primitive/enum/Fabricator.js +33 -0
  47. package/dist/esm/Primitive/enum/Registry.js +33 -0
  48. package/dist/esm/Primitive/enum/Schema.js +17 -0
  49. package/dist/esm/Primitive/enum/Types.js +1 -0
  50. package/dist/esm/Primitive/enum/index.js +5 -0
  51. package/dist/esm/Primitive/index.js +24 -0
  52. package/dist/esm/Primitive/namespace.js +21 -0
  53. package/dist/esm/Primitive/null/Fabricator.js +14 -0
  54. package/dist/esm/Primitive/null/Registry.js +8 -0
  55. package/dist/esm/Primitive/null/Schema.js +10 -0
  56. package/dist/esm/Primitive/null/Types.js +1 -0
  57. package/dist/esm/Primitive/null/index.js +5 -0
  58. package/dist/esm/Primitive/nullable/Fabricator.js +58 -0
  59. package/dist/esm/Primitive/nullable/Outcomes.js +5 -0
  60. package/dist/esm/Primitive/nullable/Registry.js +13 -0
  61. package/dist/esm/Primitive/nullable/Schema.js +36 -0
  62. package/dist/esm/Primitive/nullable/Types.js +1 -0
  63. package/dist/esm/Primitive/nullable/index.js +6 -0
  64. package/dist/esm/Primitive/nullish/Fabricator.js +64 -0
  65. package/dist/esm/Primitive/nullish/Outcomes.js +6 -0
  66. package/dist/esm/Primitive/nullish/Registry.js +13 -0
  67. package/dist/esm/Primitive/nullish/Schema.js +36 -0
  68. package/dist/esm/Primitive/nullish/Types.js +1 -0
  69. package/dist/esm/Primitive/nullish/index.js +6 -0
  70. package/dist/esm/Primitive/number/Fabricator.js +73 -0
  71. package/dist/esm/Primitive/number/Registry.js +59 -0
  72. package/dist/esm/Primitive/number/Schema.js +18 -0
  73. package/dist/esm/Primitive/number/Types.js +1 -0
  74. package/dist/esm/Primitive/number/defaults.js +21 -0
  75. package/dist/esm/Primitive/number/index.js +5 -0
  76. package/dist/esm/Primitive/object/Fabricator.js +77 -0
  77. package/dist/esm/Primitive/object/Registry.js +146 -0
  78. package/dist/esm/Primitive/object/Schema.js +18 -0
  79. package/dist/esm/Primitive/object/Types.js +1 -0
  80. package/dist/esm/Primitive/object/compute/Fabricator.js +24 -0
  81. package/dist/esm/Primitive/object/compute/Registry.js +15 -0
  82. package/dist/esm/Primitive/object/compute/Schema.js +13 -0
  83. package/dist/esm/Primitive/object/compute/Types.js +1 -0
  84. package/dist/esm/Primitive/object/compute/index.js +5 -0
  85. package/dist/esm/Primitive/object/index.js +9 -0
  86. package/dist/esm/Primitive/object/omittable/Fabricator.js +57 -0
  87. package/dist/esm/Primitive/object/omittable/Outcomes.js +5 -0
  88. package/dist/esm/Primitive/object/omittable/Registry.js +13 -0
  89. package/dist/esm/Primitive/object/omittable/Schema.js +36 -0
  90. package/dist/esm/Primitive/object/omittable/Types.js +1 -0
  91. package/dist/esm/Primitive/object/omittable/index.js +6 -0
  92. package/dist/esm/Primitive/object/optional/Fabricator.js +55 -0
  93. package/dist/esm/Primitive/object/optional/Outcomes.js +6 -0
  94. package/dist/esm/Primitive/object/optional/Registry.js +13 -0
  95. package/dist/esm/Primitive/object/optional/Schema.js +36 -0
  96. package/dist/esm/Primitive/object/optional/Types.js +1 -0
  97. package/dist/esm/Primitive/object/optional/index.js +6 -0
  98. package/dist/esm/Primitive/opaque/Fabricator.js +19 -0
  99. package/dist/esm/Primitive/opaque/Registry.js +11 -0
  100. package/dist/esm/Primitive/opaque/Schema.js +10 -0
  101. package/dist/esm/Primitive/opaque/Types.js +1 -0
  102. package/dist/esm/Primitive/opaque/index.js +5 -0
  103. package/dist/esm/Primitive/record/Fabricator.js +55 -0
  104. package/dist/esm/Primitive/record/Registry.js +26 -0
  105. package/dist/esm/Primitive/record/Schema.js +17 -0
  106. package/dist/esm/Primitive/record/Types.js +1 -0
  107. package/dist/esm/Primitive/record/index.js +5 -0
  108. package/dist/esm/Primitive/recursive/Fabricator.js +33 -0
  109. package/dist/esm/Primitive/recursive/Registry.js +20 -0
  110. package/dist/esm/Primitive/recursive/Schema.js +10 -0
  111. package/dist/esm/Primitive/recursive/Terminate.js +236 -0
  112. package/dist/esm/Primitive/recursive/Types.js +1 -0
  113. package/dist/esm/Primitive/recursive/index.js +7 -0
  114. package/dist/esm/Primitive/recursive/self/Fabricator.js +15 -0
  115. package/dist/esm/Primitive/recursive/self/Registry.js +9 -0
  116. package/dist/esm/Primitive/recursive/self/Schema.js +10 -0
  117. package/dist/esm/Primitive/recursive/self/Types.js +1 -0
  118. package/dist/esm/Primitive/recursive/self/index.js +5 -0
  119. package/dist/esm/Primitive/string/Constants.js +73 -0
  120. package/dist/esm/Primitive/string/Fabricator.js +109 -0
  121. package/dist/esm/Primitive/string/Registry.js +25 -0
  122. package/dist/esm/Primitive/string/Schema.js +18 -0
  123. package/dist/esm/Primitive/string/Types.js +1 -0
  124. package/dist/esm/Primitive/string/index.js +6 -0
  125. package/dist/esm/Primitive/symbol/Fabricator.js +33 -0
  126. package/dist/esm/Primitive/symbol/Registry.js +17 -0
  127. package/dist/esm/Primitive/symbol/Schema.js +17 -0
  128. package/dist/esm/Primitive/symbol/Types.js +1 -0
  129. package/dist/esm/Primitive/symbol/index.js +5 -0
  130. package/dist/esm/Primitive/tuple/Fabricator.js +33 -0
  131. package/dist/esm/Primitive/tuple/Registry.js +13 -0
  132. package/dist/esm/Primitive/tuple/Schema.js +17 -0
  133. package/dist/esm/Primitive/tuple/Types.js +1 -0
  134. package/dist/esm/Primitive/tuple/index.js +5 -0
  135. package/dist/esm/Primitive/undefinable/Fabricator.js +58 -0
  136. package/dist/esm/Primitive/undefinable/Outcomes.js +5 -0
  137. package/dist/esm/Primitive/undefinable/Registry.js +13 -0
  138. package/dist/esm/Primitive/undefinable/Schema.js +36 -0
  139. package/dist/esm/Primitive/undefinable/Types.js +1 -0
  140. package/dist/esm/Primitive/undefinable/index.js +6 -0
  141. package/dist/esm/Primitive/undefined/Fabricator.js +16 -0
  142. package/dist/esm/Primitive/undefined/Registry.js +8 -0
  143. package/dist/esm/Primitive/undefined/Schema.js +10 -0
  144. package/dist/esm/Primitive/undefined/Types.js +1 -0
  145. package/dist/esm/Primitive/undefined/index.js +5 -0
  146. package/dist/esm/Random/CallSite.js +56 -0
  147. package/dist/esm/Random/Generator/sfc32.js +16 -0
  148. package/dist/esm/Random/Types.js +1 -0
  149. package/dist/esm/Random/index.js +151 -0
  150. package/dist/esm/Schema/Core.js +68 -0
  151. package/dist/esm/Schema/Registry.js +17 -0
  152. package/dist/esm/Schema/Types.js +1 -0
  153. package/dist/esm/Types.js +11 -0
  154. package/dist/esm/Utility/Core.js +36 -0
  155. package/dist/esm/Utility/DeepMerge.js +18 -0
  156. package/dist/esm/Utility/Digest.js +28 -0
  157. package/dist/esm/Utility/ShallowMerge.js +13 -0
  158. package/dist/esm/Utility/Types.js +1 -0
  159. package/dist/esm/index.js +11 -0
  160. package/dist/esm/internal.js +5 -0
  161. package/dist/types/Adapter/Core.d.ts +64 -0
  162. package/dist/types/Adapter/Types.d.ts +145 -0
  163. package/dist/types/Bound.d.ts +68 -0
  164. package/dist/types/Distribution/index.d.ts +157 -0
  165. package/dist/types/Enumeration/Enumerate.d.ts +35 -0
  166. package/dist/types/Enumeration/Plan.d.ts +44 -0
  167. package/dist/types/Enumeration/Types.d.ts +86 -0
  168. package/dist/types/Error/index.d.ts +541 -0
  169. package/dist/types/Fabricator/Constructor.d.ts +43 -0
  170. package/dist/types/Fabricator/Types.d.ts +150 -0
  171. package/dist/types/Instance/Core.d.ts +98 -0
  172. package/dist/types/Instance/Types.d.ts +167 -0
  173. package/dist/types/Primitive/always/Fabricator.d.ts +19 -0
  174. package/dist/types/Primitive/always/Registry.d.ts +3 -0
  175. package/dist/types/Primitive/always/Schema.d.ts +19 -0
  176. package/dist/types/Primitive/always/Types.d.ts +23 -0
  177. package/dist/types/Primitive/always/index.d.ts +5 -0
  178. package/dist/types/Primitive/array/Fabricator.d.ts +22 -0
  179. package/dist/types/Primitive/array/Registry.d.ts +18 -0
  180. package/dist/types/Primitive/array/Schema.d.ts +23 -0
  181. package/dist/types/Primitive/array/Types.d.ts +44 -0
  182. package/dist/types/Primitive/array/index.d.ts +5 -0
  183. package/dist/types/Primitive/bigint/Fabricator.d.ts +19 -0
  184. package/dist/types/Primitive/bigint/Registry.d.ts +19 -0
  185. package/dist/types/Primitive/bigint/Schema.d.ts +27 -0
  186. package/dist/types/Primitive/bigint/Types.d.ts +33 -0
  187. package/dist/types/Primitive/bigint/index.d.ts +5 -0
  188. package/dist/types/Primitive/boolean/Fabricator.d.ts +19 -0
  189. package/dist/types/Primitive/boolean/Outcomes.d.ts +12 -0
  190. package/dist/types/Primitive/boolean/Registry.d.ts +14 -0
  191. package/dist/types/Primitive/boolean/Schema.d.ts +28 -0
  192. package/dist/types/Primitive/boolean/Types.d.ts +26 -0
  193. package/dist/types/Primitive/boolean/index.d.ts +6 -0
  194. package/dist/types/Primitive/choice/Fabricator.d.ts +32 -0
  195. package/dist/types/Primitive/choice/Registry.d.ts +38 -0
  196. package/dist/types/Primitive/choice/Schema.d.ts +24 -0
  197. package/dist/types/Primitive/choice/Types.d.ts +35 -0
  198. package/dist/types/Primitive/choice/index.d.ts +5 -0
  199. package/dist/types/Primitive/date/Fabricator.d.ts +19 -0
  200. package/dist/types/Primitive/date/Registry.d.ts +82 -0
  201. package/dist/types/Primitive/date/Schema.d.ts +28 -0
  202. package/dist/types/Primitive/date/Types.d.ts +34 -0
  203. package/dist/types/Primitive/date/index.d.ts +5 -0
  204. package/dist/types/Primitive/enum/Fabricator.d.ts +19 -0
  205. package/dist/types/Primitive/enum/Registry.d.ts +39 -0
  206. package/dist/types/Primitive/enum/Schema.d.ts +23 -0
  207. package/dist/types/Primitive/enum/Types.d.ts +44 -0
  208. package/dist/types/Primitive/enum/index.d.ts +5 -0
  209. package/dist/types/Primitive/index.d.ts +28 -0
  210. package/dist/types/Primitive/namespace.d.ts +38 -0
  211. package/dist/types/Primitive/null/Fabricator.d.ts +19 -0
  212. package/dist/types/Primitive/null/Registry.d.ts +3 -0
  213. package/dist/types/Primitive/null/Schema.d.ts +16 -0
  214. package/dist/types/Primitive/null/Types.d.ts +15 -0
  215. package/dist/types/Primitive/null/index.d.ts +5 -0
  216. package/dist/types/Primitive/nullable/Fabricator.d.ts +31 -0
  217. package/dist/types/Primitive/nullable/Outcomes.d.ts +9 -0
  218. package/dist/types/Primitive/nullable/Registry.d.ts +3 -0
  219. package/dist/types/Primitive/nullable/Schema.d.ts +36 -0
  220. package/dist/types/Primitive/nullable/Types.d.ts +48 -0
  221. package/dist/types/Primitive/nullable/index.d.ts +6 -0
  222. package/dist/types/Primitive/nullish/Fabricator.d.ts +36 -0
  223. package/dist/types/Primitive/nullish/Outcomes.d.ts +9 -0
  224. package/dist/types/Primitive/nullish/Registry.d.ts +3 -0
  225. package/dist/types/Primitive/nullish/Schema.d.ts +36 -0
  226. package/dist/types/Primitive/nullish/Types.d.ts +58 -0
  227. package/dist/types/Primitive/nullish/index.d.ts +6 -0
  228. package/dist/types/Primitive/number/Fabricator.d.ts +19 -0
  229. package/dist/types/Primitive/number/Registry.d.ts +52 -0
  230. package/dist/types/Primitive/number/Schema.d.ts +32 -0
  231. package/dist/types/Primitive/number/Types.d.ts +56 -0
  232. package/dist/types/Primitive/number/defaults.d.ts +18 -0
  233. package/dist/types/Primitive/number/index.d.ts +5 -0
  234. package/dist/types/Primitive/object/Fabricator.d.ts +56 -0
  235. package/dist/types/Primitive/object/Registry.d.ts +23 -0
  236. package/dist/types/Primitive/object/Schema.d.ts +41 -0
  237. package/dist/types/Primitive/object/Types.d.ts +85 -0
  238. package/dist/types/Primitive/object/compute/Fabricator.d.ts +31 -0
  239. package/dist/types/Primitive/object/compute/Registry.d.ts +4 -0
  240. package/dist/types/Primitive/object/compute/Schema.d.ts +21 -0
  241. package/dist/types/Primitive/object/compute/Types.d.ts +56 -0
  242. package/dist/types/Primitive/object/compute/index.d.ts +5 -0
  243. package/dist/types/Primitive/object/index.d.ts +8 -0
  244. package/dist/types/Primitive/object/omittable/Fabricator.d.ts +37 -0
  245. package/dist/types/Primitive/object/omittable/Outcomes.d.ts +9 -0
  246. package/dist/types/Primitive/object/omittable/Registry.d.ts +3 -0
  247. package/dist/types/Primitive/object/omittable/Schema.d.ts +32 -0
  248. package/dist/types/Primitive/object/omittable/Types.d.ts +57 -0
  249. package/dist/types/Primitive/object/omittable/index.d.ts +6 -0
  250. package/dist/types/Primitive/object/optional/Fabricator.d.ts +45 -0
  251. package/dist/types/Primitive/object/optional/Outcomes.d.ts +9 -0
  252. package/dist/types/Primitive/object/optional/Registry.d.ts +3 -0
  253. package/dist/types/Primitive/object/optional/Schema.d.ts +32 -0
  254. package/dist/types/Primitive/object/optional/Types.d.ts +72 -0
  255. package/dist/types/Primitive/object/optional/index.d.ts +6 -0
  256. package/dist/types/Primitive/opaque/Fabricator.d.ts +19 -0
  257. package/dist/types/Primitive/opaque/Registry.d.ts +12 -0
  258. package/dist/types/Primitive/opaque/Schema.d.ts +22 -0
  259. package/dist/types/Primitive/opaque/Types.d.ts +18 -0
  260. package/dist/types/Primitive/opaque/index.d.ts +5 -0
  261. package/dist/types/Primitive/record/Fabricator.d.ts +25 -0
  262. package/dist/types/Primitive/record/Registry.d.ts +17 -0
  263. package/dist/types/Primitive/record/Schema.d.ts +27 -0
  264. package/dist/types/Primitive/record/Types.d.ts +85 -0
  265. package/dist/types/Primitive/record/index.d.ts +5 -0
  266. package/dist/types/Primitive/recursive/Fabricator.d.ts +47 -0
  267. package/dist/types/Primitive/recursive/Registry.d.ts +22 -0
  268. package/dist/types/Primitive/recursive/Schema.d.ts +21 -0
  269. package/dist/types/Primitive/recursive/Terminate.d.ts +20 -0
  270. package/dist/types/Primitive/recursive/Types.d.ts +82 -0
  271. package/dist/types/Primitive/recursive/index.d.ts +6 -0
  272. package/dist/types/Primitive/recursive/self/Fabricator.d.ts +29 -0
  273. package/dist/types/Primitive/recursive/self/Registry.d.ts +7 -0
  274. package/dist/types/Primitive/recursive/self/Schema.d.ts +20 -0
  275. package/dist/types/Primitive/recursive/self/Types.d.ts +28 -0
  276. package/dist/types/Primitive/recursive/self/index.d.ts +5 -0
  277. package/dist/types/Primitive/string/Constants.d.ts +58 -0
  278. package/dist/types/Primitive/string/Fabricator.d.ts +24 -0
  279. package/dist/types/Primitive/string/Registry.d.ts +44 -0
  280. package/dist/types/Primitive/string/Schema.d.ts +65 -0
  281. package/dist/types/Primitive/string/Types.d.ts +77 -0
  282. package/dist/types/Primitive/string/index.d.ts +6 -0
  283. package/dist/types/Primitive/symbol/Fabricator.d.ts +24 -0
  284. package/dist/types/Primitive/symbol/Registry.d.ts +16 -0
  285. package/dist/types/Primitive/symbol/Schema.d.ts +24 -0
  286. package/dist/types/Primitive/symbol/Types.d.ts +19 -0
  287. package/dist/types/Primitive/symbol/index.d.ts +5 -0
  288. package/dist/types/Primitive/tuple/Fabricator.d.ts +37 -0
  289. package/dist/types/Primitive/tuple/Registry.d.ts +3 -0
  290. package/dist/types/Primitive/tuple/Schema.d.ts +24 -0
  291. package/dist/types/Primitive/tuple/Types.d.ts +53 -0
  292. package/dist/types/Primitive/tuple/index.d.ts +5 -0
  293. package/dist/types/Primitive/undefinable/Fabricator.d.ts +31 -0
  294. package/dist/types/Primitive/undefinable/Outcomes.d.ts +9 -0
  295. package/dist/types/Primitive/undefinable/Registry.d.ts +3 -0
  296. package/dist/types/Primitive/undefinable/Schema.d.ts +36 -0
  297. package/dist/types/Primitive/undefinable/Types.d.ts +48 -0
  298. package/dist/types/Primitive/undefinable/index.d.ts +6 -0
  299. package/dist/types/Primitive/undefined/Fabricator.d.ts +19 -0
  300. package/dist/types/Primitive/undefined/Registry.d.ts +3 -0
  301. package/dist/types/Primitive/undefined/Schema.d.ts +16 -0
  302. package/dist/types/Primitive/undefined/Types.d.ts +15 -0
  303. package/dist/types/Primitive/undefined/index.d.ts +5 -0
  304. package/dist/types/Random/CallSite.d.ts +59 -0
  305. package/dist/types/Random/Generator/sfc32.d.ts +10 -0
  306. package/dist/types/Random/Types.d.ts +384 -0
  307. package/dist/types/Random/index.d.ts +107 -0
  308. package/dist/types/Schema/Core.d.ts +44 -0
  309. package/dist/types/Schema/Registry.d.ts +20 -0
  310. package/dist/types/Schema/Types.d.ts +70 -0
  311. package/dist/types/Types.d.ts +78 -0
  312. package/dist/types/Utility/Core.d.ts +35 -0
  313. package/dist/types/Utility/DeepMerge.d.ts +14 -0
  314. package/dist/types/Utility/Digest.d.ts +9 -0
  315. package/dist/types/Utility/ShallowMerge.d.ts +6 -0
  316. package/dist/types/Utility/Types.d.ts +4 -0
  317. package/dist/types/index.d.ts +186 -0
  318. package/dist/types/internal.d.ts +64 -0
  319. package/package.json +53 -0
@@ -0,0 +1,58 @@
1
+ import type { CodepointRange } from "./Types";
2
+ /**
3
+ * Unicode code point ranges for spanning the codespace — a fuzzing aid
4
+ * for exercising input far outside ordinary text. Use a preset or build
5
+ * an arbitrary inclusive range with `range(from, to)`.
6
+ *
7
+ * Lives here rather than `Types.ts` so that file stays type-only. A
8
+ * value export alongside `export type Fabricated = string` makes the
9
+ * module a value module, and `export * as string` in
10
+ * `Primitive/namespace.ts` then resolves `string` to the namespace —
11
+ * a cycle that drops `[Kind]`/`[Meta]` off `Core`.
12
+ */
13
+ export declare const unicode: {
14
+ /**
15
+ * All Unicode scalar values: the codespace minus the surrogate block
16
+ * (U+D800–U+DFFF). Always well-formed UTF-16, so it round-trips cleanly
17
+ * through encoders, URLs, and datastores.
18
+ *
19
+ * This is the default composition for strings.
20
+ */
21
+ scalars: {
22
+ from: number;
23
+ to: number;
24
+ }[];
25
+ /**
26
+ * The entire Unicode codespace, U+0000–U+10FFFF, including the surrogate
27
+ * block — so it can yield lone surrogates and thus ill-formed UTF-16.
28
+ * Opt in for lone surrogates and other ill-formed UTF-16 when fuzzing.
29
+ */
30
+ codespace: {
31
+ from: number;
32
+ to: number;
33
+ };
34
+ /** The Basic Multilingual Plane, U+0000–U+FFFF. */
35
+ bmp: {
36
+ from: number;
37
+ to: number;
38
+ };
39
+ /** Printable ASCII, U+0020–U+007E. */
40
+ ascii: {
41
+ from: number;
42
+ to: number;
43
+ };
44
+ /** An arbitrary inclusive code point range. */
45
+ range: (from: number, to: number) => CodepointRange;
46
+ };
47
+ /**
48
+ * The built-in character classes as code point ranges, each an alias for
49
+ * the code point ranges it spans. For use in the `[weight, source]` form
50
+ * of `composition` (e.g. mixing a class with a Unicode range).
51
+ */
52
+ export declare const classes: {
53
+ lowercase: ReadonlyArray<CodepointRange>;
54
+ uppercase: ReadonlyArray<CodepointRange>;
55
+ digit: ReadonlyArray<CodepointRange>;
56
+ symbol: ReadonlyArray<CodepointRange>;
57
+ space: ReadonlyArray<CodepointRange>;
58
+ };
@@ -0,0 +1,24 @@
1
+ import type { AdaptationsOf } from "../../Adapter/Types";
2
+ import type { FabricatorContext, NaiveFabricator } from "../../Fabricator/Types";
3
+ import type { Trace } from "../../Random/Types";
4
+ import { Kind, Meta, type Adaptation } from "../../Types";
5
+ import { Schema } from "./Schema";
6
+ import type { Fabricated, Meta as ThisMeta } from "./Types";
7
+ export type Fabrication<_ extends Fabricator> = Fabricated;
8
+ export type Fabricator<$Schema extends {
9
+ [Meta]: ThisMeta;
10
+ } = {
11
+ [Meta]: ThisMeta;
12
+ }> = NaiveFabricator<Fabricated> & {
13
+ [Kind]: "string";
14
+ [Meta]: $Schema[typeof Meta];
15
+ readonly trace: Trace;
16
+ readonly [Adaptation]?: AdaptationsOf<$Schema>;
17
+ schema: Schema<$Schema[typeof Meta], AdaptationsOf<$Schema>>;
18
+ };
19
+ /**
20
+ * Turn a `string` Schema into a live Fabricator — the one place this kind's
21
+ * character-generation logic actually runs. `Constructor.ts` calls this once per
22
+ * `construct()`, never from inside the returned `fabricate`.
23
+ */
24
+ export declare function Fabricator(context: FabricatorContext<Schema>): Fabricator;
@@ -0,0 +1,44 @@
1
+ import type { Produce } from "../../Random/Types";
2
+ import { Kind } from "../../Types";
3
+ import { Schema } from "./Schema";
4
+ import type { Fabricated, InputWhereby, JsonSchema } from "./Types";
5
+ declare const _default: {
6
+ /**
7
+ * The builder carries the primitive's `[Kind]` so it can be named directly
8
+ * as a `compute` source — which derives its schema by kind — without
9
+ * first satisfying a `whereby`.
10
+ */
11
+ [Kind]: "string";
12
+ /**
13
+ * Derive a custom string type: a `string` Schema whose production is
14
+ * `produce`, optionally tagged with a `format` hint that schema exporters
15
+ * (e.g. `toTypeBox`) read.
16
+ */
17
+ as: (produce: Produce<Fabricated>, hints?: JsonSchema) => Schema<{
18
+ produce: Produce<string>;
19
+ hints: JsonSchema | undefined;
20
+ }, {}>;
21
+ /**
22
+ * A string whose length falls uniformly within `[length.min, length.max]`;
23
+ * `length.min` defaults to inclusive 0. Exclusive ends use a Bound object.
24
+ * Pass `composition` to control which characters appear and in what
25
+ * proportion; without one, characters span all Unicode scalar values (the
26
+ * codespace minus surrogates, so always well-formed UTF-16).
27
+ *
28
+ * `length` counts UTF-16 code units, so the result's `.length` equals the
29
+ * chosen length exactly. When the composition cannot fill the final code
30
+ * units — e.g. only astral, two-unit characters remain for a one-unit gap —
31
+ * the gap is topped up with a well-formed BMP character outside the
32
+ * requested `composition`, inserted at a random character boundary.
33
+ */
34
+ whereby: (whereby: InputWhereby) => Schema<{
35
+ whereby: {
36
+ length: {
37
+ min: import("../..").Bound<number>;
38
+ max: import("../..").Bound<number>;
39
+ };
40
+ composition?: import("./Types").Composition;
41
+ };
42
+ }, {}>;
43
+ };
44
+ export default _default;
@@ -0,0 +1,65 @@
1
+ import { type AdaptationEntry } from "../../Adapter/Core";
2
+ import type { Adaptations, Adapter, Adapting, WithAdaptations } from "../../Adapter/Types";
3
+ import type { Produce } from "../../Random/Types";
4
+ import type { Core, Fabricated, JsonSchema, Meta as ThisMeta } from "./Types";
5
+ /**
6
+ * Buildable `string` recipe: length/composition (`whereby` — required, unlike
7
+ * `number`/`date`; no natural bound to fuzz a length to), or opaque
8
+ * production via `as`.
9
+ *
10
+ * `$Meta` is generic (defaulting to the full `Meta` union) so builder return
11
+ * types stay narrow — see `number/Schema.ts`. `$Adaptations` is generic for
12
+ * the same reason, threaded through every builder method so an adaptation
13
+ * survives chaining (see `adapt`).
14
+ */
15
+ export interface Schema<$Meta extends ThisMeta = ThisMeta, $Adaptations extends Adaptations = {}> extends Core<$Meta, $Adaptations> {
16
+ /**
17
+ * Layer an opaque production on this schema's existing `[Meta]` — carrying
18
+ * `whereby` forward, not discarding it, so a later `.as(...)` (or future
19
+ * validation of `produce`) still has it to check against.
20
+ */
21
+ as: (produce: Produce<Fabricated>, hints?: JsonSchema) => Schema<$Meta, $Adaptations>;
22
+ /**
23
+ * Override what this schema maps to in one external schema library, for a
24
+ * contract no native kind expresses — a `string` that is really an email, a
25
+ * `date` that must cross the wire as an ISO string. Canonical `adapt`; every
26
+ * other kind's method is the same and points here.
27
+ *
28
+ * `adapter` is the adapter itself, imported from its package
29
+ * (`schema.adapt(typebox, ...)`), not a name. The key this adaptation is
30
+ * filed under comes from it, so naming the wrong adapter is an import error
31
+ * rather than an entry nothing looks up. Several libraries = several chained
32
+ * calls; each replaces only its own adapter's entry.
33
+ *
34
+ * Additive to fabrication: only an adapter reads `[Adaptation]`, so the
35
+ * schema still produces exactly what it did. `Static<ToTypeBox<...>>` and
36
+ * `fabricate()` can therefore disagree — telling an external library
37
+ * something the fabricator doesn't honor is the point; keeping them
38
+ * compatible is the caller's business.
39
+ *
40
+ * Every other builder method carries the map forward, so `.adapt(...)`
41
+ * composes in any order with `.as(...)`/`.whereby(...)`/`.extend(...)`.
42
+ *
43
+ * `produce` receives an {@link Adapting} — `{ schema, meta }` for the schema
44
+ * being adapted. An adaptation deriving from this kind's config destructures
45
+ * `meta`; one building on what it replaces destructures `schema`. See that
46
+ * type; they describe one object, `meta` being that `schema`'s `[Meta]`.
47
+ *
48
+ * That schema carries whichever same-adapter adaptation it replaced
49
+ * (`Adapter/Core.ts`'s `layer`) — so `toTypeBox(schema)` inside one resolves
50
+ * to the previous layer, or this kind's ordinary mapping, and
51
+ * `Type.Intersect([toTypeBox(schema), extra])` reads as it looks. `[Kind]`,
52
+ * `[Meta]`, and `[Adaptation]` are always on it; builder methods are not,
53
+ * when the schema was normalized into an enclosing `object`/`array` field
54
+ * (`toSchema`).
55
+ *
56
+ * `$Returnable` is inferred from `produce`'s return position, not a
57
+ * constraint on the argument, so the adaptation keeps its precise type for
58
+ * the adapter to read off `[Adaptation]`. Bounding it by
59
+ * `ReturnType<$Adapter["convert"]>` rejects a producer returning something
60
+ * that adapter could never emit, at the call site rather than silently at
61
+ * conversion.
62
+ */
63
+ adapt: <const $Adapter extends Adapter, $Returnable extends ReturnType<$Adapter["convert"]>>(adapter: $Adapter, produce: (adapting: Adapting<Schema<$Meta, $Adaptations>>) => $Returnable) => Schema<$Meta, WithAdaptations<$Adaptations, AdaptationEntry<$Adapter, $Returnable>>>;
64
+ }
65
+ export declare function Schema<$Meta extends ThisMeta, $Adaptations extends Adaptations = {}>(schema: Core<$Meta, $Adaptations>): Schema<$Meta, $Adaptations>;
@@ -0,0 +1,77 @@
1
+ import type { Adaptations } from "../../Adapter/Types";
2
+ import type { Bound, InputBound } from "../../Bound";
3
+ import type { Produce } from "../../Random/Types";
4
+ import type { Adaptation, Kind, Meta, Produces } from "../../Types";
5
+ import type { classes } from "./Constants";
6
+ /** An inclusive range of Unicode code points. */
7
+ export type CodepointRange = {
8
+ from: number;
9
+ to: number;
10
+ };
11
+ /**
12
+ * The single mechanism every character is drawn from: one or more code
13
+ * point ranges. A literal string is accepted as shorthand for the ranges
14
+ * of its individual characters, so custom pools, the built-in classes, and
15
+ * the Unicode codespace are all the same thing under the hood.
16
+ */
17
+ export type CharacterSource = string | CodepointRange | ReadonlyArray<CodepointRange>;
18
+ export type CharacterClass = keyof typeof classes;
19
+ /**
20
+ * How a string's characters should be composed: a weighting over the
21
+ * built-in classes by name, or explicit `[weight, source]` pairs over
22
+ * arbitrary character sources. Each character independently picks a source
23
+ * by weight, then a code point uniformly across that source's ranges — so
24
+ * the weights describe expected composition, not per-character uniformity.
25
+ */
26
+ export type Composition = Partial<Record<CharacterClass, number>> | ReadonlyArray<[number, CharacterSource]>;
27
+ export type InputWhereby = {
28
+ length: {
29
+ max: InputBound<number>;
30
+ min?: InputBound<number> | undefined;
31
+ };
32
+ composition?: Composition;
33
+ };
34
+ export type Whereby = {
35
+ length: {
36
+ min: Bound<number>;
37
+ max: Bound<number>;
38
+ };
39
+ composition?: Composition;
40
+ };
41
+ export type Fabricated = string;
42
+ /**
43
+ * JSON-Schema keywords that constrain a string value — carried as neutral,
44
+ * schema-library-agnostic hints (see the builder's `as`). Adapters forward
45
+ * them to their target: `toTypeBox` to `Type.String(...)`, a future `toZod`
46
+ * to `z.string()` refinements, etc.
47
+ *
48
+ * Length lives on `whereby` as Bound pairs, which adapters forward as
49
+ * `minLength`/`maxLength`; `hints` never duplicates it — these are the
50
+ * orthogonal, non-length constraints.
51
+ */
52
+ export type JsonSchema = {
53
+ format?: string;
54
+ pattern?: string;
55
+ };
56
+ /**
57
+ * A length/composition, drawn via `whereby` — no natural bound to fuzz to,
58
+ * so unlike `number`/`date` there's no bare form — optionally overridden
59
+ * by an opaque `as` production, carried alongside `whereby` rather than
60
+ * replacing it (when `whereby` was already set) so a prior
61
+ * length/composition survives `as` for future validation.
62
+ */
63
+ export type Meta = {
64
+ whereby: Whereby;
65
+ hints?: JsonSchema | undefined;
66
+ produce?: never;
67
+ } | {
68
+ whereby?: Whereby;
69
+ hints?: JsonSchema | undefined;
70
+ produce: Produce<Fabricated>;
71
+ };
72
+ export type Core<$Meta extends Meta = Meta, $Adaptations extends Adaptations = {}> = {
73
+ [Kind]: "string";
74
+ [Meta]: $Meta;
75
+ readonly [Produces]?: Fabricated;
76
+ readonly [Adaptation]?: $Adaptations;
77
+ };
@@ -0,0 +1,6 @@
1
+ export * from "./Constants";
2
+ export * from "./Fabricator";
3
+ export * from "./Registry";
4
+ export { default } from "./Registry";
5
+ export * from "./Schema";
6
+ export * from "./Types";
@@ -0,0 +1,24 @@
1
+ import type { AdaptationsOf } from "../../Adapter/Types";
2
+ import type { FabricatorContext, NaiveFabricator } from "../../Fabricator/Types";
3
+ import type { Trace } from "../../Random/Types";
4
+ import { Kind, Meta, type Adaptation } from "../../Types";
5
+ import { Schema } from "./Schema";
6
+ import type { Fabricated, Meta as ThisMeta } from "./Types";
7
+ export type Fabrication<_ extends Fabricator> = Fabricated;
8
+ export type Fabricator<$Schema extends {
9
+ [Meta]: ThisMeta;
10
+ } = {
11
+ [Meta]: ThisMeta;
12
+ }> = NaiveFabricator<Fabricated> & {
13
+ [Kind]: "symbol";
14
+ [Meta]: $Schema[typeof Meta];
15
+ readonly trace: Trace;
16
+ readonly [Adaptation]?: AdaptationsOf<$Schema>;
17
+ schema: Schema<$Schema[typeof Meta], AdaptationsOf<$Schema>>;
18
+ };
19
+ /**
20
+ * A bare symbol draws no randomness at all — `Symbol(meta.key)` is
21
+ * deterministic — so only the `.as(...)`-overridden path ever obtains a
22
+ * stream. The bare path still records `trace`, like every other node.
23
+ */
24
+ export declare function Fabricator(context: FabricatorContext<Schema>): Fabricator;
@@ -0,0 +1,16 @@
1
+ import type { Adaptations } from "../../Adapter/Types";
2
+ import { Adaptation, Kind, Meta, Produces } from "../../Types";
3
+ import { Schema } from "./Schema";
4
+ import type { Fabricated } from "./Types";
5
+ declare const _default: {
6
+ [Kind]: "symbol";
7
+ [Meta]: {};
8
+ [Produces]?: Fabricated;
9
+ [Adaptation]?: Adaptations;
10
+ as: (produce: import("../../Random/Types").Produce<Fabricated>) => Schema<{}, Adaptations>;
11
+ adapt: <const $Adapter extends import("../..").Adapter, $Returnable extends ReturnType<$Adapter["convert"]>>(adapter: $Adapter, produce: (adapting: import("../..").Adapting<Schema<{}, Adaptations>>) => $Returnable) => Schema<{}, import("../../Adapter/Types").WithAdaptations<Adaptations, import("../../Adapter/Core").AdaptationEntry<$Adapter, $Returnable>>>;
12
+ keyed: (key: string) => Schema<{
13
+ key: string;
14
+ }, {}>;
15
+ };
16
+ export default _default;
@@ -0,0 +1,24 @@
1
+ import { type AdaptationEntry } from "../../Adapter/Core";
2
+ import type { Adaptations, Adapter, Adapting, WithAdaptations } from "../../Adapter/Types";
3
+ import type { Produce } from "../../Random/Types";
4
+ import type { Core, Fabricated, Meta as ThisMeta } from "./Types";
5
+ /**
6
+ * `$Meta` is generic (defaulting to the full `Meta` union) so builder
7
+ * return types stay narrow — see `number/Schema.ts`. `$Adaptations` is
8
+ * threaded through every builder method for the same reason — see
9
+ * `string/Schema.ts`'s `adapt`.
10
+ */
11
+ export interface Schema<$Meta extends ThisMeta = ThisMeta, $Adaptations extends Adaptations = {}> extends Core<$Meta, $Adaptations> {
12
+ /**
13
+ * Layer an opaque production on this schema's existing `[Meta]` — carrying
14
+ * `key` forward, not discarding it, so a later `.as(...)` (or future
15
+ * validation of `produce`) still has it to check against.
16
+ */
17
+ as: (produce: Produce<Fabricated>) => Schema<$Meta, $Adaptations>;
18
+ /**
19
+ * Override what this schema maps to in one or more external schema
20
+ * libraries — see `string/Schema.ts`'s `adapt` for the full contract.
21
+ */
22
+ adapt: <const $Adapter extends Adapter, $Returnable extends ReturnType<$Adapter["convert"]>>(adapter: $Adapter, produce: (adapting: Adapting<Schema<$Meta, $Adaptations>>) => $Returnable) => Schema<$Meta, WithAdaptations<$Adaptations, AdaptationEntry<$Adapter, $Returnable>>>;
23
+ }
24
+ export declare function Schema<$Meta extends ThisMeta, $Adaptations extends Adaptations = {}>(schema: Core<$Meta, $Adaptations>): Schema<$Meta, $Adaptations>;
@@ -0,0 +1,19 @@
1
+ import type { Adaptations } from "../../Adapter/Types";
2
+ import type { Produce } from "../../Random/Types";
3
+ import type { Adaptation, Kind, Meta, Produces } from "../../Types";
4
+ export type Fabricated = symbol;
5
+ /**
6
+ * A symbol keyed via `keyed`, or unkeyed if `key` is absent, optionally
7
+ * overridden by an opaque `as` production — carried alongside `key` rather
8
+ * than replacing it, so a prior keying survives `as` for future validation.
9
+ */
10
+ export type Meta = {
11
+ key?: string;
12
+ produce?: Produce<Fabricated>;
13
+ };
14
+ export type Core<$Meta extends Meta = Meta, $Adaptations extends Adaptations = {}> = {
15
+ [Kind]: "symbol";
16
+ [Meta]: $Meta;
17
+ readonly [Produces]?: Fabricated;
18
+ readonly [Adaptation]?: $Adaptations;
19
+ };
@@ -0,0 +1,5 @@
1
+ export * from "./Types";
2
+ export * from "./Schema";
3
+ export * from "./Fabricator";
4
+ export * from "./Registry";
5
+ export { default } from "./Registry";
@@ -0,0 +1,37 @@
1
+ import type { AdaptationsOf } from "../../Adapter/Types";
2
+ import type { FabricatorContext, NaiveFabricator } from "../../Fabricator/Types";
3
+ import type { Trace } from "../../Random/Types";
4
+ import { Children, Kind, Meta, type Adaptation } from "../../Types";
5
+ import { Schema } from "./Schema";
6
+ import type { Fabricated, Items, Meta as ThisMeta } from "./Types";
7
+ export type Fabrication<$Fabricator extends Fabricator> = $Fabricator extends Fabricator<infer $Schema extends {
8
+ [Meta]: ThisMeta;
9
+ }> ? Fabricated<$Schema[typeof Meta]["items"]> : never;
10
+ export type Fabricator<$Schema extends {
11
+ [Meta]: ThisMeta;
12
+ } = {
13
+ [Meta]: ThisMeta;
14
+ }> = NaiveFabricator<Fabricated<$Schema[typeof Meta]["items"]>> & {
15
+ [Kind]: "tuple";
16
+ [Meta]: $Schema[typeof Meta];
17
+ readonly trace: Trace;
18
+ [Children]: ReadonlyArray<NaiveFabricator<any>>;
19
+ readonly [Adaptation]?: AdaptationsOf<$Schema>;
20
+ schema: Schema<$Schema[typeof Meta]["items"], AdaptationsOf<$Schema>>;
21
+ };
22
+ /**
23
+ * `elements` are each slot's *already-dispatched* Fabricator, one per
24
+ * `[Meta].items` entry, built by `Constructor.ts`'s `make` before this call —
25
+ * mirrors `choice.Fabricator`'s `weightings`, one per option, rather than
26
+ * `array.Fabricator`'s single shared `element`. The `array`/`tuple`
27
+ * distinction: each slot gets its own private stream, so
28
+ * `T.tuple([T.number, T.number])` behaves like a two-field `object` of
29
+ * numbers, not a length-2 `array` of numbers (every element drawn
30
+ * sequentially off one shared stream).
31
+ *
32
+ * `toStreamFromTrace` is only consulted on the `.as(...)`-overridden path: an
33
+ * ordinary tuple draws no randomness of its own — every draw belongs to a
34
+ * slot, exactly like `object`. `trace` is still recorded so a nested
35
+ * tuple can be replayed from its own schema.
36
+ */
37
+ export declare function Fabricator<$Items extends Items>(context: FabricatorContext<Schema<$Items>>, elements: ReadonlyArray<NaiveFabricator<any>>): Fabricator<Schema<$Items>>;
@@ -0,0 +1,3 @@
1
+ import { Schema } from "./Schema";
2
+ import type { Items } from "./Types";
3
+ export default function <const $Items extends Items>(items: $Items): Schema<$Items>;
@@ -0,0 +1,24 @@
1
+ import { type AdaptationEntry } from "../../Adapter/Core";
2
+ import type { Adaptations, Adapter, Adapting, WithAdaptations } from "../../Adapter/Types";
3
+ import type { Produce } from "../../Random/Types";
4
+ import type { Core, Fabricated, Items } from "./Types";
5
+ /**
6
+ * Buildable `tuple` recipe: a fixed-length list of slot schemas, each
7
+ * fabricated independently — see `Fabricator.ts` for why that independence
8
+ * (one Fabricator per slot, not one reused across slots like `array`'s
9
+ * single element) is the defining difference from `array`.
10
+ */
11
+ export interface Schema<$Items extends Items = Items, $Adaptations extends Adaptations = {}> extends Core<$Items, $Adaptations> {
12
+ /**
13
+ * Layer an opaque production on this schema's existing `[Meta]` — carrying
14
+ * `items` forward, not discarding it, so a later `.as(...)` (or future
15
+ * validation of `produce`) still has it to check against.
16
+ */
17
+ as: (produce: Produce<Fabricated<$Items>>) => Schema<$Items, $Adaptations>;
18
+ /**
19
+ * Override what this schema maps to in one or more external schema
20
+ * libraries — see `string/Schema.ts`'s `adapt` for the full contract.
21
+ */
22
+ adapt: <const $Adapter extends Adapter, $Returnable extends ReturnType<$Adapter["convert"]>>(adapter: $Adapter, produce: (adapting: Adapting<Schema<$Items, $Adaptations>>) => $Returnable) => Schema<$Items, WithAdaptations<$Adaptations, AdaptationEntry<$Adapter, $Returnable>>>;
23
+ }
24
+ export declare function Schema<$Items extends Items, $Adaptations extends Adaptations = {}>(schema: Core<$Items, $Adaptations>): Schema<$Items, $Adaptations>;
@@ -0,0 +1,53 @@
1
+ import type { Adaptations } from "../../Adapter/Types";
2
+ import type { Produce } from "../../Random/Types";
3
+ import type { AnySchema, ValueOf } from "../../Schema/Types";
4
+ import type { Adaptation, Kind, Meta, Produces } from "../../Types";
5
+ /** The schema occupying a single tuple slot. */
6
+ export type Item = AnySchema;
7
+ /**
8
+ * A *tuple* of schemas, one per slot — not a flattened `ReadonlyArray`, for
9
+ * the same reason `choice.Items` isn't (see its doc): a widened array
10
+ * remembers only the union of every slot's type and loses arity and which
11
+ * slot held what. The real tuple is what lets `Fabricated` resolve to
12
+ * positional `[A, B]` rather than `(A | B)[]`, and `Adapter/TypeBox` produce
13
+ * a `TTuple` of the right length.
14
+ */
15
+ export type Items = ReadonlyArray<Item>;
16
+ /**
17
+ * Head/tail recursion, not a homomorphic `{ [$K in keyof $Items]: ... }`
18
+ * mapped type — the same trap `Adapter/TypeBox`'s `ChoiceOptions`/
19
+ * `TupleItems` avoid: `keyof` a still-abstract `ReadonlyArray<Item>` (this
20
+ * type's default, and what a kind-local `Fabrication<$Fabricator>` resolves
21
+ * against for the *bare*, unparameterized `Fabricator`) pulls in
22
+ * `"length"`/method keys that don't resolve to a sensible `ValueOf`. A
23
+ * homomorphic version type-checks for any concrete tuple but silently
24
+ * produces a malformed bare type, which then fails `.schema.as`'s
25
+ * contravariant parameter check against any concrete instantiation
26
+ * (`Fabrication.types.test.ts`). Matching a fixed-length tuple pattern at
27
+ * every step avoids it, as `TupleItems` does for `ToTypeBox`. The fallback
28
+ * (a genuinely widened, arity-less array) is a plain `Array<...>`, mirroring
29
+ * `array.Fabricated` for the same bare case.
30
+ */
31
+ export type Fabricated<$Items extends Items = Items, $Bindings extends unknown[] = []> = $Items extends readonly [] ? [] : $Items extends readonly [
32
+ infer $Head extends Item,
33
+ ...infer $Rest extends Items
34
+ ] ? [ValueOf<$Head, $Bindings>, ...Fabricated<$Rest, $Bindings>] : Array<ValueOf<$Items[number], $Bindings>>;
35
+ /**
36
+ * No `whereby`: arity is fixed at `T.tuple([...])` and there is nothing left
37
+ * to configure. Unlike `array`'s two-variant union this needs no
38
+ * "config or produce" split — `produce` is a plain optional layered on top,
39
+ * and `items` stays required so `extend`-less kinds still have the per-slot
40
+ * shapes `ToTypeBox` derives from (and future validation of `produce` would
41
+ * check against).
42
+ */
43
+ export type Meta<$Items extends Items = Items> = {
44
+ items: $Items;
45
+ produce?: Produce<Fabricated<$Items>>;
46
+ };
47
+ export interface Core<$Items extends Items = Items, $Adaptations extends Adaptations = {}> {
48
+ [Kind]: "tuple";
49
+ [Meta]: Meta<$Items>;
50
+ bindings?: unknown[];
51
+ readonly [Produces]?: Fabricated<$Items, NonNullable<this["bindings"]>>;
52
+ readonly [Adaptation]?: $Adaptations;
53
+ }
@@ -0,0 +1,5 @@
1
+ export * from "./Types";
2
+ export * from "./Schema";
3
+ export * from "./Fabricator";
4
+ export * from "./Registry";
5
+ export { default } from "./Registry";
@@ -0,0 +1,31 @@
1
+ import type { AdaptationsOf } from "../../Adapter/Types";
2
+ import type { Fabricator as BaseFabricator, FabricatorContext } from "../../Fabricator/Types";
3
+ import type { Trace } from "../../Random/Types";
4
+ import { Children, Kind, Meta, type Adaptation } from "../../Types";
5
+ import { Schema } from "./Schema";
6
+ import type { Definition, Fabricated, Meta as ThisMeta } from "./Types";
7
+ export type Fabrication<$Fabricator extends Fabricator> = $Fabricator extends Fabricator<infer $Schema> ? Fabricated<$Schema[typeof Meta]["definition"]> : never;
8
+ export type Fabricator<$Schema extends {
9
+ [Meta]: ThisMeta;
10
+ } = {
11
+ [Meta]: ThisMeta;
12
+ }> = {
13
+ [Kind]: "undefinable";
14
+ [Meta]: $Schema[typeof Meta];
15
+ readonly trace: Trace;
16
+ [Children]: BaseFabricator<any>;
17
+ readonly [Adaptation]?: AdaptationsOf<$Schema>;
18
+ schema: Schema<$Schema[typeof Meta]["definition"], AdaptationsOf<$Schema>>;
19
+ fabricate: () => Fabricated<$Schema[typeof Meta]["definition"]>;
20
+ };
21
+ /**
22
+ * A presence roll on this field's private stream, drawn only when the
23
+ * wrapped value is needed — an `undefined` roll never advances `source`'s
24
+ * stream, and since `source` is already dispatched into its own independent
25
+ * stream by `Constructor.ts` regardless of this roll, skipping its draw
26
+ * here can never perturb any other field's reproducibility (see
27
+ * `object/omittable/Fabricator.ts`, and CLAUDE.md's "Randomness"). 50/50 by
28
+ * default; `.weighted(...)` (`Schema.ts`) reweights either outcome relative
29
+ * to that same default of `1`.
30
+ */
31
+ export declare function Fabricator<$Definition extends Definition>(context: FabricatorContext<Schema<$Definition>>, source: BaseFabricator<any>): Fabricator<Schema<$Definition>>;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * The two outcomes an undefinable roll can land on. Also the key space
3
+ * `.weighted(...)` weighs — see `Types.ts`'s `Weights`.
4
+ *
5
+ * Lives here rather than `Types.ts` so that file stays type-only (see
6
+ * `boolean/Outcomes.ts`).
7
+ */
8
+ export declare const outcomes: readonly ["undefined", "value"];
9
+ export type Outcome = (typeof outcomes)[number];
@@ -0,0 +1,3 @@
1
+ import { Schema } from "./Schema";
2
+ import type { Definition } from "./Types";
3
+ export default function <const $Definition extends Definition>(definition: $Definition): Schema<$Definition>;
@@ -0,0 +1,36 @@
1
+ import { type AdaptationEntry } from "../../Adapter/Core";
2
+ import type { Adaptations, Adapter, Adapting, WithAdaptations } from "../../Adapter/Types";
3
+ import type { Produce } from "../../Random/Types";
4
+ import type { AnySchema } from "../../Schema/Types";
5
+ import type { Core, Definition, Fabricated, Weights } from "./Types";
6
+ /**
7
+ * The buildable recipe for an `undefinable`: a single wrapped Schema, drawn
8
+ * (or not) each fabrication.
9
+ */
10
+ export interface Schema<$Definition extends Definition = Definition, $Adaptations extends Adaptations = {}> extends Core<$Definition, $Adaptations> {
11
+ /**
12
+ * Layer an opaque production on this schema's existing `[Meta]` — carrying
13
+ * `definition` forward, not discarding it, so a later `.as(...)` (or
14
+ * future validation of `produce`) still has it to check against.
15
+ * `produce` may return `undefined`, so custom logic composes the same way
16
+ * the built-in roll does.
17
+ */
18
+ as: (produce: Produce<Fabricated<$Definition>>) => Schema<$Definition, $Adaptations>;
19
+ /**
20
+ * Reweight the built-in 50/50 roll. Keys are optional — an omitted key
21
+ * keeps baseline weight `1`, the same weight the 50/50 split already uses
22
+ * — but that baseline is still relative to whatever else is specified, so
23
+ * `.weighted({ undefined: 0.1 })` shifts both outcomes' shares, not just
24
+ * `undefined`'s (see `Types.ts`'s `Weights`). Chaining `.weighted(...)`
25
+ * merges into previous weights rather than replacing them, the same
26
+ * layering `.as(...)` uses for `produce`.
27
+ */
28
+ weighted: (weights: Weights) => Schema<$Definition, $Adaptations>;
29
+ /**
30
+ * Override what this schema maps to in one or more external schema
31
+ * libraries — see `string/Schema.ts`'s `adapt` for the full contract.
32
+ */
33
+ adapt: <const $Adapter extends Adapter, $Returnable extends ReturnType<$Adapter["convert"]>>(adapter: $Adapter, produce: (adapting: Adapting<Schema<$Definition, $Adaptations>>) => $Returnable) => Schema<$Definition, WithAdaptations<$Adaptations, AdaptationEntry<$Adapter, $Returnable>>>;
34
+ }
35
+ export declare function Schema<$Definition extends Definition, $Adaptations extends Adaptations = {}>(schema: Core<$Definition, $Adaptations>): Schema<$Definition, $Adaptations>;
36
+ export declare function isUndefinableSchema(candidate: AnySchema): candidate is Schema;
@@ -0,0 +1,48 @@
1
+ import type { Adaptations } from "../../Adapter/Types";
2
+ import type { Produce } from "../../Random/Types";
3
+ import type { AnySchema, ValueOf } from "../../Schema/Types";
4
+ import type { Adaptation, Kind, Meta, Produces } from "../../Types";
5
+ /** The wrapped schema — the value type produced when the roll isn't `undefined`. */
6
+ export type Definition = AnySchema;
7
+ export type Fabricated<$Definition extends Definition, $Bindings extends unknown[] = []> = ValueOf<$Definition, $Bindings> | undefined;
8
+ export type { Outcome } from "./Outcomes";
9
+ /**
10
+ * Relative weights for `.weighted(...)`, keyed by `Outcome`. Keys optional —
11
+ * an omitted key falls back to baseline `1`, the same weight the 50/50
12
+ * split already uses. Values are relative, exactly like `weighted()`
13
+ * (`Distribution/index.ts`) — they need not sum to one, and are fed to
14
+ * `weighted()` unchanged alongside each unspecified key's baseline `1`.
15
+ *
16
+ * Specifying one outcome's weight shifts the *other* outcome's resulting
17
+ * probability too, even though its weight stays at `1` — its share of the
18
+ * total still moves, since the total changed. `.weighted({ undefined: 0.1 })`
19
+ * is not "10% undefined, 90% present" — with `value` at default `1`, the
20
+ * split is `0.1 / 1.1 ≈ 9.1%` undefined, `≈90.9%` value. No independent
21
+ * "absolute probability" mode; weights are only meaningful relative to the
22
+ * full set in play.
23
+ */
24
+ export type Weights = {
25
+ undefined: number;
26
+ value?: number | undefined;
27
+ } | {
28
+ undefined?: number | undefined;
29
+ value: number;
30
+ };
31
+ /**
32
+ * `definition` stays required regardless of `produce` — an opaque `as`
33
+ * production layers on top rather than replacing it, so a prior definition
34
+ * survives `as` for future validation of `produce` (and so `ToTypeBox`'s
35
+ * structural derivation of the wrapped shape keeps working either way).
36
+ */
37
+ export type Meta<$Definition extends Definition = Definition> = {
38
+ definition: $Definition;
39
+ produce?: Produce<Fabricated<$Definition>>;
40
+ weights?: Weights;
41
+ };
42
+ export interface Core<$Definition extends Definition = Definition, $Adaptations extends Adaptations = {}> {
43
+ [Kind]: "undefinable";
44
+ [Meta]: Meta<$Definition>;
45
+ bindings?: unknown[];
46
+ readonly [Produces]?: Fabricated<$Definition, NonNullable<this["bindings"]>>;
47
+ readonly [Adaptation]?: $Adaptations;
48
+ }
@@ -0,0 +1,6 @@
1
+ export * from "./Fabricator";
2
+ export * from "./Outcomes";
3
+ export * from "./Registry";
4
+ export { default } from "./Registry";
5
+ export * from "./Schema";
6
+ export * from "./Types";