@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,44 @@
1
+ import type { Adaptations } from "../Adapter/Types";
2
+ import type { Kind as SchemaKind } from "../Primitive";
3
+ import { Adaptation, Kind, Meta, type Produces } from "../Types";
4
+ import { type PlainObject } from "../Utility/Types";
5
+ /**
6
+ * Normalize a Schema, a builder namespace, or an already-built
7
+ * Fabricator into a clean, storable Schema — keeping only `[Kind]`/
8
+ * `[Meta]`/`[Adaptation]` and discarding `fabricate` and any
9
+ * builder-method properties. This is what lets `object`/`array` fields,
10
+ * and registry `.extend()` registrations, accept any of the three
11
+ * interchangeably while only ever storing inert data: a built
12
+ * Fabricator's `[Meta]` is exactly the Schema it came from.
13
+ *
14
+ * `[Adaptation]` is carried rather than dropped because it is a
15
+ * property of the schema itself, not of the builder that produced it:
16
+ * a field adapted with `.adapt(adapter, produce)` has to still be
17
+ * adapted once normalized into its enclosing `object`/`array`, which
18
+ * is where every adapter actually reads it from (see
19
+ * `Adapter/TypeBox`'s `build`, which walks `[Meta].definition`).
20
+ *
21
+ * `$SchemaProduces` is threaded through in the type only (never read
22
+ * or written at runtime) so `ValueOf` stays precise across a
23
+ * `toSchema` call — dropping it would make every normalized field
24
+ * (e.g. every `object`/`array` element) fall back to `unknown`.
25
+ */
26
+ export declare function toSchema<$Kind extends string, $Meta extends PlainObject, $Produces = unknown, $Adaptations extends Adaptations = Adaptations>(value: {
27
+ [Kind]: $Kind;
28
+ [Meta]: $Meta;
29
+ [Produces]?: $Produces;
30
+ [Adaptation]?: $Adaptations;
31
+ }): {
32
+ [Kind]: $Kind;
33
+ [Meta]: $Meta;
34
+ readonly [Produces]?: $Produces;
35
+ readonly [Adaptation]?: $Adaptations;
36
+ };
37
+ /**
38
+ * Whether `value`'s basic JS shape is compatible with `kind` (one of
39
+ * this library's `[Kind]` literals, e.g. `"string"`, `"object"`,
40
+ * `"date"`). Stops at "is this the right *kind of value*" (right JS
41
+ * type/shape), not deeper schema constraints like a number's `whereby`
42
+ * range, a string's length, or a weighted-enum's member set.
43
+ */
44
+ export declare function violatesKind(kind: SchemaKind, value: unknown): boolean;
@@ -0,0 +1,20 @@
1
+ import * as primitives from "../Primitive";
2
+ import { deepMerge, type DeepMerge } from "../Utility/DeepMerge";
3
+ import { type PlainObject } from "../Utility/Types";
4
+ /**
5
+ * `Primitive/index.ts` also exports the kind-module namespace as
6
+ * `Primitive` (`Primitive.boolean.Schema`, …). That is not a builder —
7
+ * omitting it here is what keeps `T.Primitive` from existing.
8
+ */
9
+ type Builders = Omit<typeof primitives, "Primitive">;
10
+ type RegistryInterface<$Registry> = {
11
+ extend: <const $Extension extends PlainObject>(types: (params: {
12
+ T: $Registry;
13
+ augment: typeof deepMerge;
14
+ }) => $Extension) => Registry<DeepMerge<$Registry, $Extension>>;
15
+ };
16
+ export type Registry<$Registry> = {
17
+ [$K in keyof $Registry as $K extends keyof RegistryInterface<$Registry> ? never : $K]: $Registry[$K];
18
+ } & RegistryInterface<$Registry>;
19
+ export declare const registry: Registry<Builders>;
20
+ export {};
@@ -0,0 +1,70 @@
1
+ import type { Adaptations } from "../Adapter/Types";
2
+ import type { Kind as SchemaKind } from "../Primitive";
3
+ import type { Adaptation, Kind, Meta, Produces } from "../Types";
4
+ import type { PlainObject } from "../Utility/Types";
5
+ /**
6
+ * The broadest Schema constraint: some kind, some config. Used by
7
+ * compound kinds (`object`/`array`) for their nested fields instead of
8
+ * the library-wide Schema union `Primitive/index.ts` assembles — that
9
+ * union imports every kind's `Core.ts`, so importing it back from
10
+ * within a kind's own `Core.ts` would cycle. Mirrors how
11
+ * `array.Definition` uses the equally generic `NaiveFabricator<any>`
12
+ * for the same reason.
13
+ */
14
+ export type AnySchema = {
15
+ [Kind]: SchemaKind;
16
+ [Meta]: PlainObject;
17
+ [Adaptation]?: Adaptations;
18
+ };
19
+ /**
20
+ * Extract the value a Schema fabricates to, via the phantom,
21
+ * runtime-absent `[Produces]` marker every kind's `Schema` carries.
22
+ * This is what lets `object`/`array`'s per-field type extraction work
23
+ * uniformly across every kind without importing and enumerating them
24
+ * (which would cycle, since `object`/`array` can nest any kind,
25
+ * including each other) — the same role `fabricate: () => $T` already
26
+ * plays for `NaiveFabricator<infer $T>`, one step earlier, before a
27
+ * Schema has been built. `[Produces]` is always optional (never
28
+ * assigned at runtime — see `DeepMerge`'s handling of optional-only
29
+ * keys for why that matters).
30
+ *
31
+ * `$Bindings` is threaded down into every composite kind's children
32
+ * (each `Core` is an `interface` carrying an optional `bindings`, and
33
+ * forwards `NonNullable<this["bindings"]>` into its own `[Produces]`).
34
+ * It is a substitution slot for a self-reference, not a parameter of
35
+ * the schema the way `$Definition`/`$Value` are — every composite
36
+ * forwards it unread, so whatever `self` node is buried arbitrarily
37
+ * deep still receives it. A node whose `[Produces]` reads
38
+ * `bindings[0]` (`recursive.self.Core`) can then close a type-level
39
+ * fixed point, which is what makes a self-referential schema resolve
40
+ * rather than collapse to `unknown`. Mirrors TypeBox's
41
+ * `Static<T, P> = (T & { params: P })['static']`, renamed because
42
+ * "params" reads as configuration and this is closer to a
43
+ * de-Bruijn-style resolution environment — kept as a tuple, as
44
+ * TypeBox's is, so a second bound self-reference could occupy index 1
45
+ * later without restructuring, though nothing today defines what that
46
+ * would mean. `test/ValueOfBindings.types.test.ts` is the only thing
47
+ * asserting any of it.
48
+ *
49
+ * Three details here are load-bearing, and each looks simplifiable:
50
+ *
51
+ * - **Indexed access, not a conditional `infer`.** Writing this as
52
+ * `($Schema & { bindings: $Bindings }) extends { [Produces]?: infer $T } ? ...`
53
+ * fails with `TS2615` — the bindings do not collapse, and the error
54
+ * surfaces as `unknown[] & [...]`.
55
+ * - **`Required<>`, never `Exclude<..., undefined>`.** Both strip the
56
+ * `| undefined` that indexing an optional property adds, but
57
+ * `Exclude` also strips the *legitimate* `undefined` out of
58
+ * `nullish`/`undefinable`/`object.optional`/`undefined`'s own value
59
+ * types.
60
+ * - **The `extends` guard belongs inside, not on the parameter.**
61
+ * Constraining `$Schema` instead would force `[Produces]` onto
62
+ * `AnySchema` (which deliberately omits it), and that shifts
63
+ * variance enough to break `.as`'s contravariant parameter check in
64
+ * `Fabrication.types.test.ts`.
65
+ */
66
+ export type ValueOf<$Schema, $Bindings extends unknown[] = []> = $Schema extends {
67
+ readonly [Produces]?: unknown;
68
+ } ? Required<$Schema & {
69
+ bindings: $Bindings;
70
+ }>[typeof Produces] : unknown;
@@ -0,0 +1,78 @@
1
+ import type { Fabricator } from "./Fabricator/Types";
2
+ import type { AnySchema } from "./Schema/Types";
3
+ export declare const Kind: unique symbol;
4
+ export declare const Meta: unique symbol;
5
+ export declare const Produces: unique symbol;
6
+ export declare const Replace: unique symbol;
7
+ export declare const Fixed: unique symbol;
8
+ /**
9
+ * Tags a `Seed` as composing onto whatever base is in effect, rather
10
+ * than replacing it — the reading a bare `seed` has everywhere else in
11
+ * this library. `layer()` (`Random/index.ts`) is the only producer; a
12
+ * caller never names this symbol, mirroring `[Replace]`. Unlike every
13
+ * other symbol in this file, it tags a config value (a `Seed`), not a
14
+ * Schema or Fabricator — see `Random/Types.ts`'s `Layered`.
15
+ */
16
+ export declare const Layer: unique symbol;
17
+ /**
18
+ * The Fabricators that exist at build time — whatever
19
+ * `Constructor.ts`'s `make` already constructed for this node's nested
20
+ * schemas before handing them to the kind's own `Fabricator()` factory.
21
+ * Every composite kind whose construction receives already-dispatched
22
+ * Fabricators carries this: `object` (its `Fields` map), `tuple`
23
+ * (`elements`, in slot order), `choice` (the dispatched options, in
24
+ * `[Meta].items` order — weights stay in `[Meta]`), `array` (the single
25
+ * shared `element`), `record` (`{ key, value }`), and each of
26
+ * `nullable`/`nullish`/`undefinable`/`object.omittable`/`object.optional`
27
+ * (the single wrapped `source`).
28
+ *
29
+ * The payload shape is kind-private, exactly as `[Meta]` is — nothing
30
+ * outside a kind's own files interprets another kind's `[Children]`
31
+ * shape.
32
+ *
33
+ * `recursive` carries none: its expansions are a function of draws
34
+ * made *during* `fabricate()` (`recursive/Fabricator.ts`), one
35
+ * throwaway Fabricator per `self` occurrence, so there is no stable
36
+ * child at build time to point at. `body`/`terminal` are already on
37
+ * `[Meta]` as ordinary sub-Schemas for anything that needs to
38
+ * introspect them.
39
+ */
40
+ export declare const Children: unique symbol;
41
+ /**
42
+ * A per-library map of external-schema overrides
43
+ * (`{ typebox: (schema) => TSchema }`), written by every kind's
44
+ * `.adapt(adapter, produce)` builder method and read only by
45
+ * `src/Adapter/*` — completely inert for fabrication, which never
46
+ * looks at it. A map rather than a single function so one schema can
47
+ * map to several external libraries at once; see `Adapter/Types.ts`
48
+ * for the registry of supported libraries, and `Adapter/TypeBox`'s
49
+ * `ToTypeBox`/`convert` for the reading end.
50
+ */
51
+ export declare const Adaptation: unique symbol;
52
+ /**
53
+ * A public sentinel with two uses that share one meaning — "this key
54
+ * does not appear in the fabricated object": `object.omittable`'s and
55
+ * `object.optional`'s Fabricators return it internally when their roll
56
+ * lands on absence (read by `object/Fabricator.ts`'s fabricate loop,
57
+ * never surfaced to a caller fabricating normally), and it is also the
58
+ * value a caller passes in `.override(...)`/`.fabricate(overrides)` to
59
+ * force an omittable or optional field off — `{ a: undefined }`
60
+ * present-as-`undefined` is not expressible this way, since that would
61
+ * conflate with a genuinely present-but-`undefined` value (see
62
+ * `Primitive/undefined`, and `Primitive/object/optional`, which
63
+ * distinguishes the two outcomes).
64
+ */
65
+ export declare const Omitted: unique symbol;
66
+ /**
67
+ * Everything `construct()`/`toTypeBox()` accept as a starting point: a
68
+ * not-yet-built Schema, or something already built into a Fabricator.
69
+ */
70
+ export type Buildable = AnySchema | Fabricator<any>;
71
+ /**
72
+ * The span of valid `Date` time values: ±8.64e15 ms from the epoch. An
73
+ * ECMAScript spec fact (`Date`'s own representable range), not a
74
+ * `date`-kind detail — lives here rather than in `Primitive/date/` so
75
+ * `Random/index.ts`'s `deriveClock` can use it without importing from
76
+ * `Primitive/`.
77
+ */
78
+ export declare const MAX_TIME = 8640000000000000;
@@ -0,0 +1,35 @@
1
+ import { Replace } from "../Types";
2
+ import { type PlainObject } from "./Types";
3
+ /**
4
+ * Syntactic sugar for an IIFE.
5
+ */
6
+ export declare function inline<$T>(fn: () => $T): $T;
7
+ export declare function never(_: never): never;
8
+ /**
9
+ * @see https://github.com/microsoft/TypeScript/issues/17002
10
+ */
11
+ export declare function isArray(candidate: unknown): candidate is Array<unknown> | ReadonlyArray<unknown>;
12
+ export declare function isPollutionKey(key: string): boolean;
13
+ /**
14
+ * A plain `{}`/`Object.create(null)` object — not an array, `Date`,
15
+ * class instance, etc.
16
+ */
17
+ export declare function isPlainObject(value: unknown): value is PlainObject;
18
+ /**
19
+ * Keys worth carrying across a merge. String keys are subject to the
20
+ * prototype-pollution guard; symbol keys (e.g. a fabricator's
21
+ * `[Kind]`/`[Meta]`) are carried through — dropping them would strip a
22
+ * primitive's identity when it is extended — except `Replace`, which is
23
+ * a directive consumed here rather than data to propagate.
24
+ */
25
+ export declare function mergeableKeys(source: PlainObject): Array<string | symbol>;
26
+ /**
27
+ * Tag an object so a subsequent deep or shallow merge replaces the
28
+ * left-hand operand wholesale instead of merging into it. The
29
+ * `[Replace]` directive is consumed by the merge and does not appear
30
+ * on the result, so callers can wrap a replacement value without ever
31
+ * naming the symbol.
32
+ */
33
+ export declare function replace<$T extends PlainObject>(value: $T): $T & {
34
+ [Replace]: true;
35
+ };
@@ -0,0 +1,14 @@
1
+ import { Replace } from "../Types";
2
+ import type { PlainObject, Pretty } from "./Types";
3
+ export type DeepMerge<$A, $B> = $B extends {
4
+ [Replace]: true;
5
+ } ? Pretty<Omit<$B, typeof Replace>> : Pretty<{
6
+ [$K in Exclude<keyof $A | keyof $B, typeof Replace>]: $A extends {
7
+ [_ in $K]?: infer $AV;
8
+ } ? $B extends {
9
+ [_ in $K]?: infer $BV;
10
+ } ? $AV extends PlainObject ? $BV extends PlainObject ? DeepMerge<$AV, $BV> : $BV : $BV : $AV : $B extends {
11
+ [_ in $K]?: infer $BV;
12
+ } ? $BV : never;
13
+ }>;
14
+ export declare function deepMerge<$A extends PlainObject, $B extends PlainObject>(a: $A, b: $B): DeepMerge<$A, $B>;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Hash an arbitrary string into four 32-bit seed words via cyrb128, so any
3
+ * `string` seed can fully seed sfc32's 128 bits of state. A good hash here
4
+ * matters: it decorrelates similar seeds (`"1"` vs `"2"`) so they produce
5
+ * unrelated streams rather than near-identical ones.
6
+ *
7
+ * @see https://stackoverflow.com/a/47593316
8
+ */
9
+ export declare function cyrb128(str: string): [number, number, number, number];
@@ -0,0 +1,6 @@
1
+ import { Replace } from "../Types";
2
+ import type { PlainObject, Pretty } from "./Types";
3
+ export type ShallowMerge<$A, $B> = $B extends {
4
+ [Replace]: true;
5
+ } ? Pretty<Omit<$B, typeof Replace>> : Pretty<Omit<$A, keyof $B> & Omit<$B, typeof Replace>>;
6
+ export declare function shallowMerge<$A extends PlainObject, $B extends PlainObject>(a: $A, b: $B): ShallowMerge<$A, $B>;
@@ -0,0 +1,4 @@
1
+ export type Pretty<$T> = {
2
+ [$K in keyof $T]: $T[$K];
3
+ } & {};
4
+ export type PlainObject<$T = unknown> = Record<string | symbol, $T>;
@@ -0,0 +1,186 @@
1
+ import type { Limits } from "./Enumeration/Types";
2
+ import type { Instance } from "./Instance/Types";
3
+ import type { Algorithm, Attribution, Seed } from "./Random/Types";
4
+ import { registry } from "./Schema/Registry";
5
+ import type { PlainObject } from "./Utility/Types";
6
+ export declare function initialize<const $Registry extends PlainObject = typeof registry>(config?: Partial<{
7
+ /** The registry of type definers to use — `registry` itself. */
8
+ types: $Registry;
9
+ /**
10
+ * Optional mixer composed into every stream beside `clock`. Accepts
11
+ * a single string, or several — several lets a seed be composed out
12
+ * of independent, meaningful parts (a user id, a scenario label)
13
+ * without hand-joining them first. If omitted, the seed is empty
14
+ * (unless `FABRICATOR_SEED` / `SEED` / `RANDOM_SEED` supplies one):
15
+ * wall-clock `clock` is the default entropy, so an unconfigured
16
+ * instance varies by run and replays from `context.clock` alone.
17
+ * Pass a seed when two instances should share a clock but draw
18
+ * different universes, or when `clock: "seeded"` should make the
19
+ * seed itself the reproducibility unit.
20
+ */
21
+ seed?: Seed;
22
+ /**
23
+ * Bring your own PRNG: a factory that, given a seed, returns a
24
+ * source of randomness — a `() => number` in `[0, 1)`, a drop-in
25
+ * for `Math.random`. Defaults to the built-in `sfc32` generator.
26
+ */
27
+ algorithm?: Algorithm;
28
+ /**
29
+ * How this instance attributes a construction's randomness to the
30
+ * file it was written in:
31
+ *
32
+ * - `{ kind: "rooted", root }` expresses every file relative to
33
+ * `root` (an absolute path or a `file://` URL), so the same seed
34
+ * reproduces the same data on a checkout at a different absolute
35
+ * path.
36
+ * - `{ kind: "call site" }`, the default, is `"rooted"` at the
37
+ * directory of whichever file called `initialize()`.
38
+ * - `{ kind: "none" }` attributes nothing: every construction of a
39
+ * given kind anywhere in the instance shares one stream, keyed
40
+ * by kind alone.
41
+ *
42
+ * See [Reproducibility](https://ghostry-dev.github.io/fabricator/guides/reproducibility)
43
+ * for the trade-offs between the three.
44
+ */
45
+ attribution?: Attribution;
46
+ /**
47
+ * Instance-wide numeric ceilings. `combinatorial` bounds how many
48
+ * instances `combinatorial(...)` may enumerate — the check is
49
+ * eager, it throws at call time before any instance is produced.
50
+ * Defaults to 1024 if omitted. `coverage(...)` carries no entry
51
+ * here: its count is the widest single axis, so there is nothing
52
+ * for a limit to protect against.
53
+ */
54
+ limits?: Limits;
55
+ /**
56
+ * What `T.date.past`/`T.date.future` (and any producer reading
57
+ * `ProduceContext.clock`) resolve "now" against — and, because it
58
+ * sits in every leaf's trace, the default entropy for the instance.
59
+ * Defaults to the wall-clock instant of this `initialize()` call, so
60
+ * an unconfigured run has realistic dates and varies by process, and
61
+ * replays from `context.clock` (with the same empty or supplied
62
+ * `seed`). Pass a fixed `Date` to freeze "now" (and the rest of the
63
+ * run, unless `seed` also differs). Pass `"seeded"` to derive "now"
64
+ * from the instance seed instead — an instant drawn across the whole
65
+ * representable `Date` span, so an implausible date is the expected
66
+ * outcome of that policy, not a bug. `"seeded"` is what makes `seed`
67
+ * alone the reproducibility unit.
68
+ */
69
+ clock?: Date | "seeded";
70
+ }>): Instance<$Registry>;
71
+ export { Omitted } from "./Types";
72
+ /**
73
+ * Tags a `Seed` — for `new Fabricator(schema, { seed })`, or `fork`'s
74
+ * own `Overlay.seed` — as composing onto whatever base is in effect,
75
+ * rather than replacing it outright.
76
+ */
77
+ export { layer } from "./Random";
78
+ /**
79
+ * `layer(...)`'s return type, so a caller building one programmatically
80
+ * can name it — the same rationale as the existing `Seed`/`Attribution`
81
+ * exports.
82
+ */
83
+ export type { Layered } from "./Random/Types";
84
+ /**
85
+ * Every failure this library raises is an instance of this class — see
86
+ * `src/Error/index.ts` for the full hierarchy. Only the base is
87
+ * public; subclasses are distinguished by `.name`.
88
+ */
89
+ export { FabricatorError } from "./Error";
90
+ /**
91
+ * The adapter contract, exported because an adapter is a separate
92
+ * package rather than something registered here: `Adapter`/`Recurse`
93
+ * are what one declares, `drive` is what its conversion entry point
94
+ * calls, and `Adaptation`/`AdaptationsOf` are how it reads what a
95
+ * Schema declared — `[Adaptation]` at runtime, `AdaptationsOf` at the
96
+ * type level, keyed by its own `key` in both cases.
97
+ *
98
+ * This package names no external schema library and depends on none:
99
+ * every mapping, and every dependency it needs, belongs to the
100
+ * adapter.
101
+ *
102
+ * `Adapting` is the odd one out, facing whoever *writes* an adaptation
103
+ * rather than whoever implements an adapter: it is the parameter type
104
+ * of every kind's `.adapt(adapter, produce)` producer, so a caller
105
+ * writing that producer as a named function can name it — the same
106
+ * reason `Stream` is exported below.
107
+ */
108
+ export { drive } from "./Adapter/Core";
109
+ export type { Adaptations, AdaptationsOf, Adapter, Adapting, Recurse, } from "./Adapter/Types";
110
+ export { Adaptation } from "./Types";
111
+ /**
112
+ * The default registry of type definers, exported so it can be
113
+ * extended via `registry.extend(({ T }) => ({ ... }))` before being
114
+ * passed to `initialize({ types })`.
115
+ */
116
+ export { registry } from "./Schema/Registry";
117
+ /**
118
+ * Canonical `{ value, exclusive }` endpoint stored on `whereby` min/max,
119
+ * plus the call-site union that still accepts a scalar (inclusive). Exported
120
+ * so a named `.whereby(...)` argument or an `.adapt` producer reading `meta`
121
+ * can type it — the same rationale as `Stream`.
122
+ */
123
+ export type { Bound, InputBound } from "./Bound";
124
+ export { toBound, effectiveDiscrete } from "./Bound";
125
+ /**
126
+ * Public because it is the type of `ProduceContext`'s `random` member
127
+ * — the seeded stream every kind's `.as(produce)` and `T.opaque`'s
128
+ * producer are handed — so a caller writing either as a named function
129
+ * can name it.
130
+ */
131
+ export type { Stream } from "./Random/Types";
132
+ /**
133
+ * What every kind's `.as(produce)` producer is called with — a single
134
+ * curated object rather than a positional argument list, so a caller
135
+ * writing the producer as a named function can name its parameter.
136
+ * `T.opaque`'s producer takes the same shape.
137
+ */
138
+ export type { ProduceContext } from "./Random/Types";
139
+ /**
140
+ * The shape `initialize({ seed })` and `new Fabricator(schema, { seed })`
141
+ * both accept — a single string, or several — so a caller building one
142
+ * programmatically (rather than as an inline literal) can name the
143
+ * type.
144
+ */
145
+ export type { Seed } from "./Random/Types";
146
+ /**
147
+ * The shape `initialize({ attribution })` accepts, so a caller building
148
+ * one programmatically — a rooted policy derived from an env var, say
149
+ * — can name the type.
150
+ */
151
+ export type { Attribution } from "./Random/Types";
152
+ /**
153
+ * Reads the value type a built Fabricator produces straight off its
154
+ * `fabricate` signature — `Fabrication<typeof Product>` instead of
155
+ * `ReturnType<typeof Product.fabricate>`.
156
+ */
157
+ export type { Fabrication } from "./Fabricator/Types";
158
+ /**
159
+ * Reads the value type a Schema (not yet built) will eventually
160
+ * produce, via its phantom `[Produces]` marker. Mostly useful for a
161
+ * helper that accepts a Schema before it's built into a Fabricator.
162
+ */
163
+ export type { ValueOf } from "./Schema/Types";
164
+ /**
165
+ * `fabricator.trace`'s type — otherwise unnameable by a caller
166
+ * wanting to hold onto one, the same reason `Stream` is exported
167
+ * above.
168
+ */
169
+ export type { Trace } from "./Random/Types";
170
+ /**
171
+ * How `file` and `ordinal` on a {@link Trace} were resolved — recorded
172
+ * so a captured trace is self-describing, including `"counted"`
173
+ * (replayed for a node taken from inside a `T.recursive` expansion;
174
+ * not a variant you choose when building).
175
+ */
176
+ export type { RootKind } from "./Random/Types";
177
+ /**
178
+ * `fork`/`wrap`'s own config shapes, so a caller building an overlay
179
+ * programmatically (rather than as an inline literal) can name them —
180
+ * the same rationale as the existing `Seed`/`Attribution` exports.
181
+ * `Config` is what `initialize`'s own parameter is a `Partial` of;
182
+ * `Overlay` is what `fork`/`wrap` accept; `Context` is
183
+ * `instance.context`'s own type, so a caller writing a helper that
184
+ * reads it can name the parameter.
185
+ */
186
+ export type { Config, Context, Overlay } from "./Instance/Types";
@@ -0,0 +1,64 @@
1
+ /**
2
+ * The "adapter-authoring SDK" entry point — published as the
3
+ * `@ghostry/fabricator/internal` package export, deliberately *not*
4
+ * re-exported from `./index.ts`. An external adapter package (e.g.
5
+ * `@ghostry/fabricator-adapter-typebox-v0`) needs to walk a Schema/
6
+ * Fabricator structurally and dispatch on each primitive kind's `Core`
7
+ * shape — see "Match `Core`, never `Schema`, in a dispatch" — which
8
+ * the end-user-facing `.` export has no reason to carry.
9
+ *
10
+ * Also this package's own white-box test suite's route to source: a
11
+ * test file imports through `@ghostry/fabricator`/
12
+ * `@ghostry/fabricator/internal` rather than a relative `../src/...`
13
+ * path specifically so it resolves through the built `dist/` (see the
14
+ * "Random", "Schema", and "Enumeration" groups below) — the same
15
+ * reason an adapter needs this entry point, applied to this package's
16
+ * own tests instead of an external one.
17
+ *
18
+ * Everything here is curated, not incidental. When wiring a new leaf
19
+ * kind into the rest of the system, add its module to
20
+ * `Primitive/namespace.ts` (re-exported here as `Primitive`), or no
21
+ * adapter can reach that kind's `Core` type.
22
+ */
23
+ export type { Fabrication, NaiveFabricator } from "./Fabricator/Types";
24
+ export { Children, Kind, Meta, Produces, type Buildable } from "./Types";
25
+ export { isPlainObject } from "./Utility/Core";
26
+ export type * as Primitive from "./Primitive/namespace";
27
+ /**
28
+ * `Schema/Types.ts`'s own value-type resolution, needed by tests
29
+ * asserting `ValueOf<...>` directly rather than through a built
30
+ * Fabricator's `Fabrication<...>`.
31
+ */
32
+ export type { ValueOf } from "./Schema/Types";
33
+ /**
34
+ * `Constructor` is `Instance.Fabricator`'s own type — public in effect
35
+ * (every `initialize()` caller receives one), just never named
36
+ * directly by the `.` export, which only ever describes it inline.
37
+ */
38
+ export type { Constructor } from "./Fabricator/Constructor";
39
+ /**
40
+ * The enumeration planner's own shapes — `combinatorial`/`coverage`
41
+ * (the `.` export's public entry points) are built on `plan`/`resolve`,
42
+ * which a test asserting `axisFor`'s per-kind width/strategy decisions
43
+ * needs directly.
44
+ */
45
+ export { plan, resolve } from "./Enumeration/Plan";
46
+ export type { Axis, Enumerable, Pin, Resolvable } from "./Enumeration/Types";
47
+ /**
48
+ * The randomness layer underneath
49
+ * `initialize({ seed, algorithm, attribution })` and a Fabricator's
50
+ * `.trace` — needed by tests exercising stream attribution and
51
+ * construction directly, beneath the level `initialize()` itself
52
+ * exposes.
53
+ */
54
+ export { defaultAlgorithm, encode, randomSeed, toRandomSource, toStream, toStreamFromTrace, } from "./Random";
55
+ export type { Algorithm, ConstructionTrace, ConstructorOptions, ResolvedAttribution, RootKind, RootPins, Seed, Trace, } from "./Random/Types";
56
+ /**
57
+ * `Random/CallSite.ts`'s pure string helpers. Exported for this
58
+ * package's own tests: the percent-encoded, `file://`-prefixed, and
59
+ * backslashed spellings they exist to fold together cannot be produced
60
+ * by running the suite from an ordinary POSIX checkout, so they have
61
+ * to be driven with synthetic frame strings instead of real stack
62
+ * frames.
63
+ */
64
+ export { directoryOf, normalizeLocation, relativize } from "./Random/CallSite";
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "@ghostry/fabricator",
3
+ "version": "0.0.1",
4
+ "license": "MIT",
5
+ "description": "Fabricate typed data from composable schemas.",
6
+ "keywords": [
7
+ "factory"
8
+ ],
9
+ "author": {
10
+ "name": "Patrick Rebsch"
11
+ },
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://github.com/ghostry-dev/fabricator",
15
+ "directory": "pkg/fabricator"
16
+ },
17
+ "homepage": "https://github.com/ghostry-dev/fabricator",
18
+ "bugs": "https://github.com/ghostry-dev/fabricator/issues",
19
+ "type": "module",
20
+ "types": "./dist/types/index.d.ts",
21
+ "module": "./dist/esm/index.js",
22
+ "exports": {
23
+ ".": {
24
+ "types": "./dist/types/index.d.ts",
25
+ "import": "./dist/esm/index.js",
26
+ "default": "./dist/esm/index.js"
27
+ },
28
+ "./internal": {
29
+ "types": "./dist/types/internal.d.ts",
30
+ "import": "./dist/esm/internal.js",
31
+ "default": "./dist/esm/internal.js"
32
+ }
33
+ },
34
+ "publishConfig": {
35
+ "access": "public",
36
+ "provenance": true
37
+ },
38
+ "scripts": {
39
+ "build:reset": "rm -rf ./dist",
40
+ "build:compile": "bunx --no-install --bun rslib build --config ./rslib.config.ts",
41
+ "build:compile:rsdoctor": "RSDOCTOR=true bunx --no-install --bun rslib build --config ./rslib.config.ts",
42
+ "build:clean": "find ./dist -type f -name '*.tsbuildinfo' -delete",
43
+ "build": "bun run build:reset && bun run build:compile && bun run build:clean",
44
+ "build:rsdoctor": "bun run build:reset && bun run build:compile:rsdoctor && bun run build:clean",
45
+ "check": "tsc --noEmit",
46
+ "check:ts5": "bun --bun ../../node_modules/typescript-5/lib/tsc.js --noEmit",
47
+ "prettier": "bunx --no-install --bun prettier .",
48
+ "test": "bun run check && bun run check:ts5 && bun test"
49
+ },
50
+ "files": [
51
+ "dist"
52
+ ]
53
+ }