@ghostry/fabricator 0.0.13 → 0.0.15

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 (234) hide show
  1. package/dist/esm/Bound.js +74 -1
  2. package/dist/esm/Distribution/index.js +103 -2
  3. package/dist/esm/Enumeration/Enumerate.js +10 -5
  4. package/dist/esm/Enumeration/Plan.js +2 -2
  5. package/dist/esm/Error/index.js +96 -27
  6. package/dist/esm/Fabricator/Constructor.js +7 -5
  7. package/dist/esm/Instance/Core.js +3 -0
  8. package/dist/esm/Primitive/array/Admits.js +18 -0
  9. package/dist/esm/Primitive/array/Fabricator.js +20 -2
  10. package/dist/esm/Primitive/array/Registry.js +32 -0
  11. package/dist/esm/Primitive/array/Schema.js +8 -0
  12. package/dist/esm/Primitive/bigint/Admits.js +11 -0
  13. package/dist/esm/Primitive/bigint/Fabricator.js +16 -23
  14. package/dist/esm/Primitive/bigint/Registry.js +17 -6
  15. package/dist/esm/Primitive/bigint/Schema.js +8 -0
  16. package/dist/esm/Primitive/date/Admits.js +22 -0
  17. package/dist/esm/Primitive/date/Defaults.js +27 -1
  18. package/dist/esm/Primitive/date/Fabricator.js +32 -34
  19. package/dist/esm/Primitive/date/Registry.js +80 -13
  20. package/dist/esm/Primitive/date/Schema.js +8 -0
  21. package/dist/esm/Primitive/enum/Fabricator.js +14 -2
  22. package/dist/esm/Primitive/enum/Registry.js +38 -25
  23. package/dist/esm/Primitive/index.js +1 -0
  24. package/dist/esm/Primitive/number/Admits.js +27 -0
  25. package/dist/esm/Primitive/number/Fabricator.js +18 -9
  26. package/dist/esm/Primitive/number/Registry.js +55 -4
  27. package/dist/esm/Primitive/number/Schema.js +10 -3
  28. package/dist/esm/Primitive/object/Fabricator.js +2 -0
  29. package/dist/esm/Primitive/record/Admits.js +42 -0
  30. package/dist/esm/Primitive/record/Fabricator.js +49 -19
  31. package/dist/esm/Primitive/record/Registry.js +29 -0
  32. package/dist/esm/Primitive/record/Schema.js +8 -0
  33. package/dist/esm/Primitive/recursive/Fabricator.js +3 -2
  34. package/dist/esm/Primitive/recursive/Terminate.js +16 -2
  35. package/dist/esm/Primitive/string/Admits.js +26 -0
  36. package/dist/esm/Primitive/string/Capacity.js +81 -0
  37. package/dist/esm/Primitive/string/Fabricator.js +23 -43
  38. package/dist/esm/Primitive/string/Registry.js +31 -9
  39. package/dist/esm/Primitive/string/Schema.js +10 -3
  40. package/dist/esm/Primitive/string/Sources.js +41 -0
  41. package/dist/esm/Primitive/unique/Registry.js +22 -0
  42. package/dist/esm/Primitive/unique/index.js +2 -0
  43. package/dist/esm/Types.js +2 -1
  44. package/dist/esm/Unique/Capacity.js +85 -0
  45. package/dist/esm/Unique/Distinct.js +187 -0
  46. package/dist/esm/Unique/Key.js +70 -0
  47. package/dist/esm/Unique/Override.js +23 -0
  48. package/dist/esm/Unique/Strategy.js +173 -0
  49. package/dist/esm/internal.js +1 -0
  50. package/dist/types/Adapter/Core.d.ts +2 -2
  51. package/dist/types/Adapter/Types.d.ts +1 -1
  52. package/dist/types/Bound.d.ts +67 -1
  53. package/dist/types/Distribution/index.d.ts +83 -1
  54. package/dist/types/Enumeration/Enumerate.d.ts +3 -3
  55. package/dist/types/Enumeration/Plan.d.ts +1 -1
  56. package/dist/types/Enumeration/Types.d.ts +14 -5
  57. package/dist/types/Error/index.d.ts +283 -0
  58. package/dist/types/Fabricator/Constructor.d.ts +9 -5
  59. package/dist/types/Fabricator/Fabricate.d.ts +5 -5
  60. package/dist/types/Fabricator/Types.d.ts +19 -6
  61. package/dist/types/Harnessing/Core.d.ts +3 -3
  62. package/dist/types/Harnessing/Salt.d.ts +1 -1
  63. package/dist/types/Harnessing/Types.d.ts +2 -2
  64. package/dist/types/Instance/Core.d.ts +4 -4
  65. package/dist/types/Instance/Stack/Async.d.ts +1 -1
  66. package/dist/types/Instance/Stack/Sync.d.ts +1 -1
  67. package/dist/types/Instance/Stack/Visible.d.ts +2 -2
  68. package/dist/types/Instance/Types.d.ts +19 -5
  69. package/dist/types/Primitive/always/Fabricator.d.ts +6 -6
  70. package/dist/types/Primitive/always/Registry.d.ts +2 -2
  71. package/dist/types/Primitive/always/Schema.d.ts +4 -4
  72. package/dist/types/Primitive/always/Types.d.ts +2 -2
  73. package/dist/types/Primitive/always/index.d.ts +5 -5
  74. package/dist/types/Primitive/array/Admits.d.ts +7 -0
  75. package/dist/types/Primitive/array/Fabricator.d.ts +7 -7
  76. package/dist/types/Primitive/array/Registry.d.ts +40 -3
  77. package/dist/types/Primitive/array/Schema.d.ts +10 -5
  78. package/dist/types/Primitive/array/Types.d.ts +37 -5
  79. package/dist/types/Primitive/array/index.d.ts +5 -5
  80. package/dist/types/Primitive/bigint/Admits.d.ts +7 -0
  81. package/dist/types/Primitive/bigint/Fabricator.d.ts +8 -6
  82. package/dist/types/Primitive/bigint/Registry.d.ts +24 -4
  83. package/dist/types/Primitive/bigint/Schema.d.ts +13 -5
  84. package/dist/types/Primitive/bigint/Types.d.ts +30 -6
  85. package/dist/types/Primitive/bigint/index.d.ts +5 -5
  86. package/dist/types/Primitive/boolean/Fabricator.d.ts +6 -6
  87. package/dist/types/Primitive/boolean/Registry.d.ts +2 -2
  88. package/dist/types/Primitive/boolean/Schema.d.ts +5 -5
  89. package/dist/types/Primitive/boolean/Types.d.ts +3 -3
  90. package/dist/types/Primitive/boolean/index.d.ts +6 -6
  91. package/dist/types/Primitive/choice/Fabricator.d.ts +6 -6
  92. package/dist/types/Primitive/choice/Registry.d.ts +2 -2
  93. package/dist/types/Primitive/choice/Schema.d.ts +5 -5
  94. package/dist/types/Primitive/choice/Types.d.ts +4 -4
  95. package/dist/types/Primitive/choice/index.d.ts +5 -5
  96. package/dist/types/Primitive/date/Admits.d.ts +7 -0
  97. package/dist/types/Primitive/date/Defaults.d.ts +22 -1
  98. package/dist/types/Primitive/date/Fabricator.d.ts +8 -6
  99. package/dist/types/Primitive/date/Registry.d.ts +49 -13
  100. package/dist/types/Primitive/date/Schema.d.ts +14 -5
  101. package/dist/types/Primitive/date/Types.d.ts +57 -8
  102. package/dist/types/Primitive/date/index.d.ts +5 -5
  103. package/dist/types/Primitive/derive/Fabricator.d.ts +7 -7
  104. package/dist/types/Primitive/derive/Registry.d.ts +2 -2
  105. package/dist/types/Primitive/derive/Schema.d.ts +6 -6
  106. package/dist/types/Primitive/derive/Types.d.ts +6 -6
  107. package/dist/types/Primitive/derive/index.d.ts +5 -5
  108. package/dist/types/Primitive/enum/Fabricator.d.ts +8 -6
  109. package/dist/types/Primitive/enum/Registry.d.ts +22 -2
  110. package/dist/types/Primitive/enum/Schema.d.ts +5 -5
  111. package/dist/types/Primitive/enum/Types.d.ts +8 -3
  112. package/dist/types/Primitive/enum/index.d.ts +5 -5
  113. package/dist/types/Primitive/index.d.ts +28 -27
  114. package/dist/types/Primitive/namespace.d.ts +21 -21
  115. package/dist/types/Primitive/null/Fabricator.d.ts +6 -6
  116. package/dist/types/Primitive/null/Registry.d.ts +1 -1
  117. package/dist/types/Primitive/null/Schema.d.ts +4 -4
  118. package/dist/types/Primitive/null/Types.d.ts +2 -2
  119. package/dist/types/Primitive/null/index.d.ts +5 -5
  120. package/dist/types/Primitive/nullable/Fabricator.d.ts +6 -6
  121. package/dist/types/Primitive/nullable/Registry.d.ts +2 -2
  122. package/dist/types/Primitive/nullable/Schema.d.ts +6 -6
  123. package/dist/types/Primitive/nullable/Types.d.ts +5 -5
  124. package/dist/types/Primitive/nullable/index.d.ts +6 -6
  125. package/dist/types/Primitive/nullish/Fabricator.d.ts +6 -6
  126. package/dist/types/Primitive/nullish/Registry.d.ts +2 -2
  127. package/dist/types/Primitive/nullish/Schema.d.ts +6 -6
  128. package/dist/types/Primitive/nullish/Types.d.ts +5 -5
  129. package/dist/types/Primitive/nullish/index.d.ts +6 -6
  130. package/dist/types/Primitive/number/Admits.d.ts +9 -0
  131. package/dist/types/Primitive/number/Defaults.d.ts +1 -1
  132. package/dist/types/Primitive/number/Fabricator.d.ts +8 -6
  133. package/dist/types/Primitive/number/Registry.d.ts +45 -4
  134. package/dist/types/Primitive/number/Schema.d.ts +14 -6
  135. package/dist/types/Primitive/number/Types.d.ts +36 -14
  136. package/dist/types/Primitive/number/index.d.ts +5 -5
  137. package/dist/types/Primitive/object/Fabricator.d.ts +6 -6
  138. package/dist/types/Primitive/object/Registry.d.ts +4 -4
  139. package/dist/types/Primitive/object/Schema.d.ts +8 -8
  140. package/dist/types/Primitive/object/Types.d.ts +6 -6
  141. package/dist/types/Primitive/object/compute/Fabricator.d.ts +7 -7
  142. package/dist/types/Primitive/object/compute/Registry.d.ts +2 -2
  143. package/dist/types/Primitive/object/compute/Schema.d.ts +7 -7
  144. package/dist/types/Primitive/object/compute/Types.d.ts +3 -3
  145. package/dist/types/Primitive/object/compute/index.d.ts +5 -5
  146. package/dist/types/Primitive/object/index.d.ts +8 -8
  147. package/dist/types/Primitive/object/omit/Registry.d.ts +2 -2
  148. package/dist/types/Primitive/object/omit/index.d.ts +2 -2
  149. package/dist/types/Primitive/object/omittable/Fabricator.d.ts +6 -6
  150. package/dist/types/Primitive/object/omittable/Registry.d.ts +2 -2
  151. package/dist/types/Primitive/object/omittable/Schema.d.ts +6 -6
  152. package/dist/types/Primitive/object/omittable/Types.d.ts +5 -5
  153. package/dist/types/Primitive/object/omittable/index.d.ts +6 -6
  154. package/dist/types/Primitive/object/optional/Fabricator.d.ts +6 -6
  155. package/dist/types/Primitive/object/optional/Registry.d.ts +2 -2
  156. package/dist/types/Primitive/object/optional/Schema.d.ts +6 -6
  157. package/dist/types/Primitive/object/optional/Types.d.ts +5 -5
  158. package/dist/types/Primitive/object/optional/index.d.ts +6 -6
  159. package/dist/types/Primitive/object/pick/Registry.d.ts +2 -2
  160. package/dist/types/Primitive/object/pick/index.d.ts +2 -2
  161. package/dist/types/Primitive/opaque/Fabricator.d.ts +6 -6
  162. package/dist/types/Primitive/opaque/Registry.d.ts +2 -2
  163. package/dist/types/Primitive/opaque/Schema.d.ts +4 -4
  164. package/dist/types/Primitive/opaque/Types.d.ts +3 -3
  165. package/dist/types/Primitive/opaque/index.d.ts +5 -5
  166. package/dist/types/Primitive/record/Admits.d.ts +18 -0
  167. package/dist/types/Primitive/record/Fabricator.d.ts +7 -7
  168. package/dist/types/Primitive/record/Registry.d.ts +20 -3
  169. package/dist/types/Primitive/record/Schema.d.ts +12 -5
  170. package/dist/types/Primitive/record/Types.d.ts +64 -10
  171. package/dist/types/Primitive/record/index.d.ts +5 -5
  172. package/dist/types/Primitive/recursive/Fabricator.d.ts +6 -6
  173. package/dist/types/Primitive/recursive/Registry.d.ts +4 -4
  174. package/dist/types/Primitive/recursive/Schema.d.ts +4 -4
  175. package/dist/types/Primitive/recursive/Terminate.d.ts +8 -1
  176. package/dist/types/Primitive/recursive/Types.d.ts +3 -3
  177. package/dist/types/Primitive/recursive/index.d.ts +6 -6
  178. package/dist/types/Primitive/recursive/self/Fabricator.d.ts +5 -5
  179. package/dist/types/Primitive/recursive/self/Registry.d.ts +1 -1
  180. package/dist/types/Primitive/recursive/self/Schema.d.ts +4 -4
  181. package/dist/types/Primitive/recursive/self/Types.d.ts +2 -2
  182. package/dist/types/Primitive/recursive/self/index.d.ts +5 -5
  183. package/dist/types/Primitive/string/Admits.d.ts +8 -0
  184. package/dist/types/Primitive/string/Capacity.d.ts +36 -0
  185. package/dist/types/Primitive/string/Constants.d.ts +1 -1
  186. package/dist/types/Primitive/string/Fabricator.d.ts +8 -6
  187. package/dist/types/Primitive/string/Registry.d.ts +29 -8
  188. package/dist/types/Primitive/string/Schema.d.ts +32 -6
  189. package/dist/types/Primitive/string/Sources.d.ts +16 -0
  190. package/dist/types/Primitive/string/Types.d.ts +39 -19
  191. package/dist/types/Primitive/string/index.d.ts +6 -6
  192. package/dist/types/Primitive/symbol/Fabricator.d.ts +6 -6
  193. package/dist/types/Primitive/symbol/Registry.d.ts +2 -2
  194. package/dist/types/Primitive/symbol/Schema.d.ts +5 -5
  195. package/dist/types/Primitive/symbol/Types.d.ts +3 -3
  196. package/dist/types/Primitive/symbol/index.d.ts +5 -5
  197. package/dist/types/Primitive/tuple/Fabricator.d.ts +6 -6
  198. package/dist/types/Primitive/tuple/Registry.d.ts +2 -2
  199. package/dist/types/Primitive/tuple/Schema.d.ts +5 -5
  200. package/dist/types/Primitive/tuple/Types.d.ts +4 -4
  201. package/dist/types/Primitive/tuple/index.d.ts +5 -5
  202. package/dist/types/Primitive/undefinable/Fabricator.d.ts +6 -6
  203. package/dist/types/Primitive/undefinable/Registry.d.ts +2 -2
  204. package/dist/types/Primitive/undefinable/Schema.d.ts +6 -6
  205. package/dist/types/Primitive/undefinable/Types.d.ts +5 -5
  206. package/dist/types/Primitive/undefinable/index.d.ts +6 -6
  207. package/dist/types/Primitive/undefined/Fabricator.d.ts +6 -6
  208. package/dist/types/Primitive/undefined/Registry.d.ts +1 -1
  209. package/dist/types/Primitive/undefined/Schema.d.ts +4 -4
  210. package/dist/types/Primitive/undefined/Types.d.ts +2 -2
  211. package/dist/types/Primitive/undefined/index.d.ts +5 -5
  212. package/dist/types/Primitive/unique/Registry.d.ts +39 -0
  213. package/dist/types/Primitive/unique/index.d.ts +2 -0
  214. package/dist/types/Random/Generator/sfc32.d.ts +1 -1
  215. package/dist/types/Random/Types.d.ts +1 -1
  216. package/dist/types/Random/index.d.ts +1 -1
  217. package/dist/types/Schema/Core.d.ts +5 -5
  218. package/dist/types/Schema/Registry.d.ts +3 -3
  219. package/dist/types/Schema/Satisfies.d.ts +3 -3
  220. package/dist/types/Schema/Types.d.ts +5 -5
  221. package/dist/types/Types.d.ts +11 -2
  222. package/dist/types/Unique/Capacity.d.ts +29 -0
  223. package/dist/types/Unique/Distinct.d.ts +95 -0
  224. package/dist/types/Unique/Key.d.ts +29 -0
  225. package/dist/types/Unique/Override.d.ts +16 -0
  226. package/dist/types/Unique/Strategy.d.ts +135 -0
  227. package/dist/types/Utility/Core.d.ts +2 -2
  228. package/dist/types/Utility/DeepMerge.d.ts +2 -2
  229. package/dist/types/Utility/ShallowMerge.d.ts +2 -2
  230. package/dist/types/adapting.d.ts +3 -3
  231. package/dist/types/harnessing.d.ts +2 -2
  232. package/dist/types/index.d.ts +40 -27
  233. package/dist/types/internal.d.ts +16 -15
  234. package/package.json +2 -2
package/dist/esm/Bound.js CHANGED
@@ -58,6 +58,31 @@ function constrainContinuous(next, min, max) {
58
58
  return value;
59
59
  };
60
60
  }
61
+ function toBigintBound(label, end, input) {
62
+ const bound = toBound(input);
63
+ if ("bigint" == typeof bound.value) return {
64
+ value: bound.value,
65
+ exclusive: bound.exclusive
66
+ };
67
+ if (!Number.isSafeInteger(bound.value)) throw new FabricatorError.InvalidBoundError(label, end, bound.value, "a bigint, or a number that is a safe integer");
68
+ return {
69
+ value: BigInt(bound.value),
70
+ exclusive: bound.exclusive
71
+ };
72
+ }
73
+ function toDateBound(label, end, input) {
74
+ const bound = toBound(input);
75
+ if (bound.value instanceof Date) return {
76
+ value: bound.value,
77
+ exclusive: bound.exclusive
78
+ };
79
+ const date = new Date(bound.value);
80
+ if (date.valueOf() !== bound.value) throw new FabricatorError.InvalidBoundError(label, end, bound.value, "a Date, or an integer number of epoch milliseconds within ±8.64e15");
81
+ return {
82
+ value: date,
83
+ exclusive: bound.exclusive
84
+ };
85
+ }
61
86
  function epochBound(bound) {
62
87
  return {
63
88
  value: bound.value.getTime(),
@@ -83,4 +108,52 @@ function toLengthRange(length, label) {
83
108
  distribution: length.distribution
84
109
  };
85
110
  }
86
- export { assertNonemptyContinuous, assertNonemptyDiscrete, assertNonemptyDiscreteBigint, constrainContinuous, effectiveDiscrete, effectiveDiscreteBigint, epochBound, toBound, toLengthRange, towardInterior };
111
+ const continuousWithin = (inner, outer, end)=>{
112
+ if (inner.value === outer.value) return inner.exclusive || !outer.exclusive;
113
+ return "min" === end ? inner.value > outer.value : inner.value < outer.value;
114
+ };
115
+ const discreteWithin = (inner, outer, end)=>"min" === end ? discreteEnd(inner, end) >= discreteEnd(outer, end) : discreteEnd(inner, end) <= discreteEnd(outer, end);
116
+ const bigintWithin = (inner, outer, end)=>"min" === end ? bigintEnd(inner, end) >= bigintEnd(outer, end) : bigintEnd(inner, end) <= bigintEnd(outer, end);
117
+ const dateWithin = (inner, outer, end)=>discreteWithin(epochBound(inner), epochBound(outer), end);
118
+ function discreteEnd(bound, end) {
119
+ if (!bound.exclusive) return bound.value;
120
+ return "min" === end ? bound.value + 1 : bound.value - 1;
121
+ }
122
+ function bigintEnd(bound, end) {
123
+ if (!bound.exclusive) return bound.value;
124
+ return "min" === end ? bound.value + BigInt(1) : bound.value - BigInt(1);
125
+ }
126
+ function toFiniteBound(label, end, input) {
127
+ const bound = toBound(input);
128
+ if (!Number.isFinite(bound.value)) throw new FabricatorError.InvalidBoundError(label, end, bound.value, `a finite number, or ${"min" === end ? "-Infinity" : "Infinity"} for no limit`);
129
+ return bound;
130
+ }
131
+ function toAdmittedEnds(label, path, current, fabricable, input, convert, within) {
132
+ const resolved = {};
133
+ for (const end of [
134
+ "min",
135
+ "max"
136
+ ]){
137
+ const bound = toAdmittedEnd(end, current[end], null == input ? void 0 : input[end], convert);
138
+ if (void 0 !== bound) resolved[end] = bound;
139
+ }
140
+ if (void 0 !== fabricable) assertWidens(label, path, resolved, fabricable, within);
141
+ return resolved;
142
+ }
143
+ function toAdmittedEnd(end, current, given, convert) {
144
+ if (void 0 === given) return current;
145
+ if (toBound(given).value === ("min" === end ? -1 / 0 : 1 / 0)) return;
146
+ return convert(end, given);
147
+ }
148
+ function assertWidens(label, path, admitted, fabricable, within) {
149
+ for (const end of [
150
+ "min",
151
+ "max"
152
+ ]){
153
+ const outer = admitted[end];
154
+ if (void 0 === outer) continue;
155
+ const inner = fabricable[end];
156
+ if (void 0 === inner || !within(inner, outer, end)) throw new FabricatorError.AdmitsExcludesDrawError(label, void 0 === path ? end : `${path}.${end}`, outer, inner);
157
+ }
158
+ }
159
+ export { assertNonemptyContinuous, assertNonemptyDiscrete, assertNonemptyDiscreteBigint, bigintWithin, constrainContinuous, continuousWithin, dateWithin, discreteWithin, effectiveDiscrete, effectiveDiscreteBigint, epochBound, toAdmittedEnds, toBigintBound, toBound, toDateBound, toFiniteBound, toLengthRange, towardInterior };
@@ -142,7 +142,7 @@ function normalInv(p) {
142
142
  const q = Math.sqrt(-2 * Math.log(1 - p));
143
143
  return -(((((-0.007784894002430293 * q - 3.223964580411365e-1) * q - 2.400758277161838) * q - 2.549732539343734) * q + 4.374664141464968) * q + 2.938163982698783) / ((((7.784695709041462e-3 * q + 3.224671290700398e-1) * q + 2.445134137142996) * q + 3.754408661907416) * q + 1);
144
144
  }
145
- function sample(list, stream) {
145
+ function Distribution_sample(list, stream) {
146
146
  if (0 === list.length) throw new FabricatorError.EmptyItemsError("sample", "item");
147
147
  const index = discreteSampler(void 0, {
148
148
  min: 0,
@@ -163,6 +163,107 @@ function shuffle(items, stream) {
163
163
  }
164
164
  return shuffled;
165
165
  }
166
+ function withoutReplacement(entries, stream) {
167
+ const drawable = entries.filter(([weight])=>isDrawable(weight));
168
+ const weights = drawable.map(([weight])=>weight);
169
+ const items = drawable.map(([, item])=>item);
170
+ const uniform = weights.every((weight)=>weight === weights[0]);
171
+ function pick() {
172
+ if (uniform) return discreteSampler(void 0, {
173
+ min: 0,
174
+ max: items.length - 1
175
+ }, stream)();
176
+ const total = weights.reduce((sum, weight)=>sum + weight, 0);
177
+ const target = stream.next() * total;
178
+ let cumulative = 0;
179
+ for(let i = 0; i < weights.length; i++){
180
+ cumulative += weights[i];
181
+ if (target < cumulative) return i;
182
+ }
183
+ return weights.length - 1;
184
+ }
185
+ function remove(index) {
186
+ weights.splice(index, 1);
187
+ return items.splice(index, 1)[0];
188
+ }
189
+ return {
190
+ get remaining () {
191
+ return items.length;
192
+ },
193
+ draw: ()=>remove(pick()),
194
+ discard: (matches)=>{
195
+ const index = items.findIndex(matches);
196
+ if (-1 !== index) remove(index);
197
+ }
198
+ };
199
+ }
200
+ function permutation(range, stream) {
201
+ const { min } = range;
202
+ const size = range.max - min + 1;
203
+ const displaced = new Map();
204
+ let i = 0;
205
+ return {
206
+ get remaining () {
207
+ return size - i;
208
+ },
209
+ next: ()=>{
210
+ var _displaced_get, _displaced_get1;
211
+ const j = discreteSampler(void 0, {
212
+ min: i,
213
+ max: size - 1
214
+ }, stream)();
215
+ const value = null != (_displaced_get = displaced.get(j)) ? _displaced_get : j;
216
+ displaced.set(j, null != (_displaced_get1 = displaced.get(i)) ? _displaced_get1 : i);
217
+ displaced.delete(i);
218
+ i++;
219
+ return min + value;
220
+ }
221
+ };
222
+ }
223
+ function bigintPermutation(range, stream) {
224
+ const { min } = range;
225
+ const size = range.max - min + BigInt(1);
226
+ const displaced = new Map();
227
+ let i = BigInt(0);
228
+ return {
229
+ get remaining () {
230
+ return size - i;
231
+ },
232
+ next: ()=>{
233
+ var _displaced_get, _displaced_get1;
234
+ const j = bigintSampler({
235
+ min: i,
236
+ max: size - BigInt(1)
237
+ }, stream)();
238
+ const value = null != (_displaced_get = displaced.get(j)) ? _displaced_get : j;
239
+ displaced.set(j, null != (_displaced_get1 = displaced.get(i)) ? _displaced_get1 : i);
240
+ displaced.delete(i);
241
+ i++;
242
+ return min + value;
243
+ }
244
+ };
245
+ }
246
+ function bigintSampler(range, stream) {
247
+ const { min, max } = range;
248
+ const span = max - min + BigInt(1);
249
+ const byteBits = 8;
250
+ const bitWidth = span.toString(2).length;
251
+ const byteWidth = Math.ceil(bitWidth / byteBits);
252
+ const bitMask = (BigInt(1) << BigInt(bitWidth)) - BigInt(1);
253
+ return ()=>{
254
+ const buffer = new Uint8Array(byteWidth);
255
+ const sample = ()=>{
256
+ for(let i = 0; i < buffer.length; i++)buffer[i] = Math.floor(256 * stream.next());
257
+ let value = BigInt(0);
258
+ for (const byte of buffer)value = value << BigInt(byteBits) | BigInt(byte);
259
+ return value & bitMask;
260
+ };
261
+ while(true){
262
+ const candidate = sample();
263
+ if (candidate < span) return min + candidate;
264
+ }
265
+ };
266
+ }
166
267
  function isDrawable(weight) {
167
268
  return weight > 0;
168
269
  }
@@ -238,4 +339,4 @@ function toAliasTable(weights) {
238
339
  };
239
340
  }
240
341
  var Distribution_Distribution;
241
- export { Distribution_Distribution as Distribution, assertDrawableKeyedWeights, assertDrawableWeights, discreteSampler, drawableOutcomes, isDrawable, isValidWeight, normalCdf, normalInv, sample, sampler, shuffle, weighted };
342
+ export { Distribution_Distribution as Distribution, Distribution_sample as sample, assertDrawableKeyedWeights, assertDrawableWeights, bigintPermutation, bigintSampler, discreteSampler, drawableOutcomes, isDrawable, isValidWeight, normalCdf, normalInv, permutation, sampler, shuffle, weighted, withoutReplacement };
@@ -5,12 +5,15 @@ import { toEffectiveSource } from "../Instance/Stack/Visible.js";
5
5
  import { toStreamFromTrace } from "../Random/index.js";
6
6
  import { plan, resolve } from "./Plan.js";
7
7
  function enumerables(source, limits, stack, ancestry) {
8
- const Fabricator = Constructor(source, stack, ancestry);
8
+ const Fabricator = Constructor(source, stack, ancestry, "cycle");
9
9
  function effectiveSource() {
10
10
  return toEffectiveSource(source, stack, ancestry);
11
11
  }
12
- function iterable(rebuild) {
12
+ function iterable(rebuild, size) {
13
13
  return {
14
+ get size () {
15
+ return size();
16
+ },
14
17
  [Symbol.iterator] () {
15
18
  const { built, axis } = rebuild();
16
19
  const width = Number(axis.width);
@@ -55,7 +58,7 @@ function enumerables(source, limits, stack, ancestry) {
55
58
  strategy: "product"
56
59
  })
57
60
  };
58
- });
61
+ }, ()=>probe.width);
59
62
  }
60
63
  function coverage(schema) {
61
64
  const base = effectiveSource();
@@ -68,7 +71,7 @@ function enumerables(source, limits, stack, ancestry) {
68
71
  "coverage",
69
72
  "order"
70
73
  ];
71
- return iterable(()=>{
74
+ const rebuild = ()=>{
72
75
  const built = new Fabricator(schema, {
73
76
  salt: coverageSalt,
74
77
  ordinal: null
@@ -80,7 +83,9 @@ function enumerables(source, limits, stack, ancestry) {
80
83
  orderer: orderer(base, orderSalt)
81
84
  })
82
85
  };
83
- });
86
+ };
87
+ const probe = rebuild().axis;
88
+ return iterable(rebuild, ()=>probe.width);
84
89
  }
85
90
  return {
86
91
  combinatorial,
@@ -96,8 +96,8 @@ function plan(node, planning) {
96
96
  }
97
97
  }
98
98
  function axisFor(node, planning) {
99
- var _node_Meta;
100
- if (null == (_node_Meta = node[Meta]) ? void 0 : _node_Meta.produce) return leaf();
99
+ var _node_Meta, _node_Meta1;
100
+ if ((null == (_node_Meta = node[Meta]) ? void 0 : _node_Meta.produce) || (null == (_node_Meta1 = node[Meta]) ? void 0 : _node_Meta1.unique)) return leaf();
101
101
  const kind = node[Kind];
102
102
  switch(kind){
103
103
  case "enum":
@@ -11,7 +11,7 @@ function _define_property(obj, key, value) {
11
11
  class Error_FabricatorError extends Error {
12
12
  constructor(){
13
13
  super();
14
- this.name = "FabricatorError";
14
+ this.name = "@ghostry/fabricator:FabricatorError";
15
15
  }
16
16
  }
17
17
  (function(FabricatorError) {
@@ -26,7 +26,7 @@ class Error_FabricatorError extends Error {
26
26
  class InvalidCombinatorialLimitError extends FabricatorError {
27
27
  constructor(limit){
28
28
  super(), _define_property(this, "limit", void 0), this.limit = limit;
29
- this.name = "InvalidCombinatorialLimitError";
29
+ this.name = "@ghostry/fabricator:InvalidCombinatorialLimitError";
30
30
  this.message = `initialize({ limits: { combinatorial } }) requires a positive safe integer; received ${String(limit)}.`;
31
31
  }
32
32
  }
@@ -34,7 +34,7 @@ class Error_FabricatorError extends Error {
34
34
  class InvalidClockError extends FabricatorError {
35
35
  constructor(clock){
36
36
  super(), _define_property(this, "clock", void 0), this.clock = clock;
37
- this.name = "InvalidClockError";
37
+ this.name = "@ghostry/fabricator:InvalidClockError";
38
38
  this.message = `clock requires a valid Date or an integer number of epoch milliseconds within ±8.64e15; received ${String(clock)}.`;
39
39
  }
40
40
  }
@@ -42,7 +42,7 @@ class Error_FabricatorError extends Error {
42
42
  class DetachedSelfError extends FabricatorError {
43
43
  constructor(during){
44
44
  super(), _define_property(this, "during", void 0), this.during = during;
45
- this.name = "DetachedSelfError";
45
+ this.name = "@ghostry/fabricator:DetachedSelfError";
46
46
  this.message = `\`self\` was used outside any active \`T.recursive\` while ${phrase(during)} — it can only appear inside the body (or terminal) passed to \`T.recursive(...)\`, and a \`self\` captured out of that callback cannot be reused elsewhere.`;
47
47
  }
48
48
  }
@@ -50,16 +50,25 @@ class Error_FabricatorError extends Error {
50
50
  class UnterminableRecursiveError extends FabricatorError {
51
51
  constructor(path){
52
52
  super(), _define_property(this, "path", void 0), this.path = path;
53
- this.name = "UnterminableRecursiveError";
53
+ this.name = "@ghostry/fabricator:UnterminableRecursiveError";
54
54
  const where = 0 === path.length ? "the recursive body itself" : `"${path.join(".")}"`;
55
55
  this.message = `T.recursive cannot derive a terminal: self at ${where} is not behind a kind that can stop recursing. Wrap it in an array, record, choice, omittable, optional, nullable, nullish, or undefinable, or pass an explicit terminal.`;
56
56
  }
57
57
  }
58
58
  FabricatorError.UnterminableRecursiveError = UnterminableRecursiveError;
59
+ class UnsatisfiableRecursiveBoundError extends FabricatorError {
60
+ constructor(path, key, min){
61
+ super(), _define_property(this, "path", void 0), _define_property(this, "key", void 0), _define_property(this, "min", void 0), this.path = path, this.key = key, this.min = min;
62
+ this.name = "@ghostry/fabricator:UnsatisfiableRecursiveBoundError";
63
+ const where = 0 === path.length ? "the recursive body itself" : `"${path.join(".")}"`;
64
+ this.message = `T.recursive: the collection of self at ${where} states ${key}.min ${min}, but every branch ends at the depth limit with it empty, so no finite tree satisfies it. Add \`.admits({ ${key}: { min: 0 } })\` to that collection to keep drawing at least ${min} below the limit while stating no minimum, or pass an explicit terminal.`;
65
+ }
66
+ }
67
+ FabricatorError.UnsatisfiableRecursiveBoundError = UnsatisfiableRecursiveBoundError;
59
68
  class UnknownKindError extends FabricatorError {
60
69
  constructor(kind, during){
61
70
  super(), _define_property(this, "kind", void 0), _define_property(this, "during", void 0), this.kind = kind, this.during = during;
62
- this.name = "UnknownKindError";
71
+ this.name = "@ghostry/fabricator:UnknownKindError";
63
72
  this.message = `Cannot dispatch a Schema of unknown kind "${kind}" while ${phrase(during)}.`;
64
73
  }
65
74
  }
@@ -67,7 +76,7 @@ class Error_FabricatorError extends Error {
67
76
  class EmptyItemsError extends FabricatorError {
68
77
  constructor(label, noun){
69
78
  super(), _define_property(this, "label", void 0), _define_property(this, "noun", void 0), this.label = label, this.noun = noun;
70
- this.name = "EmptyItemsError";
79
+ this.name = "@ghostry/fabricator:EmptyItemsError";
71
80
  this.message = `${label} requires at least one ${noun}.`;
72
81
  }
73
82
  }
@@ -75,7 +84,7 @@ class Error_FabricatorError extends Error {
75
84
  class PrototypePollutionError extends FabricatorError {
76
85
  constructor(key){
77
86
  super(), _define_property(this, "key", void 0), this.key = key;
78
- this.name = "PrototypePollutionError";
87
+ this.name = "@ghostry/fabricator:PrototypePollutionError";
79
88
  this.message = `Potential prototype pollution blocked for key: ${key}. An object schema cannot define a field named \`__proto__\`, \`constructor\`, or \`prototype\`.`;
80
89
  }
81
90
  }
@@ -83,7 +92,7 @@ class Error_FabricatorError extends Error {
83
92
  class DetachedComputeError extends FabricatorError {
84
93
  constructor(){
85
94
  super();
86
- this.name = "DetachedComputeError";
95
+ this.name = "@ghostry/fabricator:DetachedComputeError";
87
96
  this.message = "A `.refine()`-computed field can only be fabricated as part of its parent object, which supplies the already-fabricated fields its resolver reads.";
88
97
  }
89
98
  }
@@ -91,7 +100,7 @@ class Error_FabricatorError extends Error {
91
100
  class ComputeResultMismatchError extends FabricatorError {
92
101
  constructor(kind, value){
93
102
  super(), _define_property(this, "kind", void 0), _define_property(this, "value", void 0), this.kind = kind, this.value = value;
94
- this.name = "ComputeResultMismatchError";
103
+ this.name = "@ghostry/fabricator:ComputeResultMismatchError";
95
104
  this.message = `A \`.refine()\`-computed field's resolver returned a value of type ${typeof value} that does not match its "${kind}" source schema.`;
96
105
  }
97
106
  }
@@ -99,7 +108,7 @@ class Error_FabricatorError extends Error {
99
108
  class DeriveResultMismatchError extends FabricatorError {
100
109
  constructor(kind, value){
101
110
  super(), _define_property(this, "kind", void 0), _define_property(this, "value", void 0), this.kind = kind, this.value = value;
102
- this.name = "DeriveResultMismatchError";
111
+ this.name = "@ghostry/fabricator:DeriveResultMismatchError";
103
112
  this.message = `A T.derive resolver returned a value of type ${typeof value} that does not match its \`to\` schema ("${kind}").`;
104
113
  }
105
114
  }
@@ -107,7 +116,7 @@ class Error_FabricatorError extends Error {
107
116
  class UnknownFieldError extends FabricatorError {
108
117
  constructor(field, available, operation){
109
118
  super(), _define_property(this, "field", void 0), _define_property(this, "available", void 0), _define_property(this, "operation", void 0), this.field = field, this.available = available, this.operation = operation;
110
- this.name = "UnknownFieldError";
119
+ this.name = "@ghostry/fabricator:UnknownFieldError";
111
120
  this.message = `Cannot ${operation} unknown field: "${field}". This object schema defines ` + (0 === available.length ? "no fields." : `${available.map((k)=>`"${k}"`).join(", ")}.`);
112
121
  }
113
122
  }
@@ -115,7 +124,7 @@ class Error_FabricatorError extends Error {
115
124
  class ComputeDependencyCycleError extends FabricatorError {
116
125
  constructor(fields){
117
126
  super(), _define_property(this, "fields", void 0), this.fields = fields;
118
- this.name = "ComputeDependencyCycleError";
127
+ this.name = "@ghostry/fabricator:ComputeDependencyCycleError";
119
128
  this.message = `Computed fields depend on each other in a cycle: ${fields.map((k)=>`"${k}"`).join(" -> ")}.`;
120
129
  }
121
130
  }
@@ -123,7 +132,7 @@ class Error_FabricatorError extends Error {
123
132
  class InvalidOverrideValueError extends FabricatorError {
124
133
  constructor(field, kind, value){
125
134
  super(), _define_property(this, "field", void 0), _define_property(this, "kind", void 0), _define_property(this, "value", void 0), this.field = field, this.kind = kind, this.value = value;
126
- this.name = "InvalidOverrideValueError";
135
+ this.name = "@ghostry/fabricator:InvalidOverrideValueError";
127
136
  this.message = `Cannot override field "${field}": a value of type ${typeof value} does not match its "${kind}" schema.`;
128
137
  }
129
138
  }
@@ -131,7 +140,7 @@ class Error_FabricatorError extends Error {
131
140
  class IllegalOmittedOverrideError extends FabricatorError {
132
141
  constructor(field, kind){
133
142
  super(), _define_property(this, "field", void 0), _define_property(this, "kind", void 0), this.field = field, this.kind = kind;
134
- this.name = "IllegalOmittedOverrideError";
143
+ this.name = "@ghostry/fabricator:IllegalOmittedOverrideError";
135
144
  this.message = `Cannot override field "${field}" with Omitted: a "${kind}" field is neither omittable nor optional, so it has no absent outcome to select.`;
136
145
  }
137
146
  }
@@ -139,7 +148,7 @@ class Error_FabricatorError extends Error {
139
148
  class EnumerationIndexError extends FabricatorError {
140
149
  constructor(index, width){
141
150
  super(), _define_property(this, "index", void 0), _define_property(this, "width", void 0), this.index = index, this.width = width;
142
- this.name = "EnumerationIndexError";
151
+ this.name = "@ghostry/fabricator:EnumerationIndexError";
143
152
  this.message = `Enumeration index ${index} is out of range for an axis of width ${width}.`;
144
153
  }
145
154
  }
@@ -147,7 +156,7 @@ class Error_FabricatorError extends Error {
147
156
  class UnpinnableKindError extends FabricatorError {
148
157
  constructor(kind){
149
158
  super(), _define_property(this, "kind", void 0), this.kind = kind;
150
- this.name = "UnpinnableKindError";
159
+ this.name = "@ghostry/fabricator:UnpinnableKindError";
151
160
  this.message = `resolve() received a pin for kind "${kind}", which plan() never gives one to.`;
152
161
  }
153
162
  }
@@ -155,7 +164,7 @@ class Error_FabricatorError extends Error {
155
164
  class CombinatorialLimitExceededError extends FabricatorError {
156
165
  constructor(width, limit){
157
166
  super(), _define_property(this, "width", void 0), _define_property(this, "limit", void 0), this.width = width, this.limit = limit;
158
- this.name = "CombinatorialLimitExceededError";
167
+ this.name = "@ghostry/fabricator:CombinatorialLimitExceededError";
159
168
  this.message = `combinatorial(...) would enumerate ${width} instances which is over the configured limit of ${limit}. Raise it with initialize({ limits: { combinatorial } }), or use coverage(...), which needs only as many instances as the widest single axis.`;
160
169
  }
161
170
  }
@@ -163,7 +172,7 @@ class Error_FabricatorError extends Error {
163
172
  class UnrepresentableRecordKeyError extends FabricatorError {
164
173
  constructor(kind){
165
174
  super(), _define_property(this, "kind", void 0), this.kind = kind;
166
- this.name = "UnrepresentableRecordKeyError";
175
+ this.name = "@ghostry/fabricator:UnrepresentableRecordKeyError";
167
176
  this.message = `Cannot map a "record" schema keyed by "${kind}" to an external schema: the target has no record with keys of that type. Use .adapt(adapter, ...) to supply one.`;
168
177
  }
169
178
  }
@@ -171,11 +180,29 @@ class Error_FabricatorError extends Error {
171
180
  class EmptyRangeError extends FabricatorError {
172
181
  constructor(label, min, max){
173
182
  super(), _define_property(this, "label", void 0), _define_property(this, "min", void 0), _define_property(this, "max", void 0), this.label = label, this.min = min, this.max = max;
174
- this.name = "EmptyRangeError";
183
+ this.name = "@ghostry/fabricator:EmptyRangeError";
175
184
  this.message = `${label} produces an empty range (min=${describeBound(min)}, max=${describeBound(max)}).`;
176
185
  }
177
186
  }
178
187
  FabricatorError.EmptyRangeError = EmptyRangeError;
188
+ class InvalidBoundError extends FabricatorError {
189
+ constructor(label, end, value, expected){
190
+ super(), _define_property(this, "label", void 0), _define_property(this, "end", void 0), _define_property(this, "value", void 0), _define_property(this, "expected", void 0), this.label = label, this.end = end, this.value = value, this.expected = expected;
191
+ this.name = "@ghostry/fabricator:InvalidBoundError";
192
+ this.message = `${label}: ${end} must be ${expected}; received ${String(value)}.`;
193
+ }
194
+ }
195
+ FabricatorError.InvalidBoundError = InvalidBoundError;
196
+ class AdmitsExcludesDrawError extends FabricatorError {
197
+ constructor(label, end, admitted, fabricated){
198
+ super(), _define_property(this, "label", void 0), _define_property(this, "end", void 0), _define_property(this, "admitted", void 0), _define_property(this, "fabricated", void 0), this.label = label, this.end = end, this.admitted = admitted, this.fabricated = fabricated;
199
+ this.name = "@ghostry/fabricator:AdmitsExcludesDrawError";
200
+ const drawn = void 0 === fabricated ? "an unbounded end" : `${end}=${describeBound(fabricated)}`;
201
+ const unlimited = end.endsWith("min") ? "-Infinity" : "Infinity";
202
+ this.message = `${label}: ${end}=${describeBound(admitted)} excludes values the schema fabricates, which reach ${drawn}. Admitted ends may only widen the fabricated range; pass ${unlimited} for no limit.`;
203
+ }
204
+ }
205
+ FabricatorError.AdmitsExcludesDrawError = AdmitsExcludesDrawError;
179
206
  function describeBound(bound) {
180
207
  const value = String(bound.value);
181
208
  return bound.exclusive ? `{ value: ${value}, exclusive: true }` : value;
@@ -183,7 +210,7 @@ class Error_FabricatorError extends Error {
183
210
  class InvalidDistributionBoundError extends FabricatorError {
184
211
  constructor(distribution, min, max){
185
212
  super(), _define_property(this, "distribution", void 0), _define_property(this, "min", void 0), _define_property(this, "max", void 0), this.distribution = distribution, this.min = min, this.max = max;
186
- this.name = "InvalidDistributionBoundError";
213
+ this.name = "@ghostry/fabricator:InvalidDistributionBoundError";
187
214
  this.message = `The ${distribution} distribution requires min > 0 (received min=${min}, max=${max}); its density is proportional to 1/x and undefined at or below zero.`;
188
215
  }
189
216
  }
@@ -191,7 +218,7 @@ class Error_FabricatorError extends Error {
191
218
  class InvalidWeightError extends FabricatorError {
192
219
  constructor(label, weight, entry){
193
220
  super(), _define_property(this, "label", void 0), _define_property(this, "weight", void 0), _define_property(this, "entry", void 0), this.label = label, this.weight = weight, this.entry = entry;
194
- this.name = "InvalidWeightError";
221
+ this.name = "@ghostry/fabricator:InvalidWeightError";
195
222
  const where = "index" === entry.kind ? `${entry.noun} at index ${entry.index}` : `"${entry.name}"`;
196
223
  this.message = `${label} requires every weight to be a finite number ≥ 0; ${where} has weight ${weight}. Zero disables an outcome; a negative weight, NaN, or Infinity is invalid.`;
197
224
  }
@@ -200,7 +227,7 @@ class Error_FabricatorError extends Error {
200
227
  class NoDrawableOutcomesError extends FabricatorError {
201
228
  constructor(label, noun){
202
229
  super(), _define_property(this, "label", void 0), _define_property(this, "noun", void 0), this.label = label, this.noun = noun;
203
- this.name = "NoDrawableOutcomesError";
230
+ this.name = "@ghostry/fabricator:NoDrawableOutcomesError";
204
231
  this.message = `${label} leaves no drawable ${noun}. Zeroing an outcome disables it, so at least one must keep a positive weight.`;
205
232
  }
206
233
  }
@@ -208,7 +235,7 @@ class Error_FabricatorError extends Error {
208
235
  class TraceKindMismatchError extends FabricatorError {
209
236
  constructor(expected, given){
210
237
  super(), _define_property(this, "expected", void 0), _define_property(this, "given", void 0), this.expected = expected, this.given = given;
211
- this.name = "TraceKindMismatchError";
238
+ this.name = "@ghostry/fabricator:TraceKindMismatchError";
212
239
  this.message = `Cannot build from a trace for kind "${given}": this schema's kind is "${expected}". A trace reproduces the node it was taken from, so its kind must match the schema it is replayed against.`;
213
240
  }
214
241
  }
@@ -216,7 +243,7 @@ class Error_FabricatorError extends Error {
216
243
  class FabricateArgumentError extends FabricatorError {
217
244
  constructor(argument){
218
245
  super(), _define_property(this, "argument", void 0), this.argument = argument;
219
- this.name = "FabricateArgumentError";
246
+ this.name = "@ghostry/fabricator:FabricateArgumentError";
220
247
  this.message = describe(argument);
221
248
  function describe(given) {
222
249
  if ("object" == typeof given && null !== given && "fabricate" in given) return "fabricate(...) takes a Schema, not a built Fabricator. Call `.fabricate()` on the Fabricator you have, or pass its `.schema` to fabricate(...).";
@@ -228,7 +255,7 @@ class Error_FabricatorError extends Error {
228
255
  class SynchronousStackError extends FabricatorError {
229
256
  constructor(){
230
257
  super();
231
- this.name = "SynchronousStackError";
258
+ this.name = "@ghostry/fabricator:SynchronousStackError";
232
259
  this.message = "`wrap` received an async block, but this instance's ambient stack cannot carry a frame across `await` — a build after the first `await` would silently resolve against the base instance. This runtime has no `node:async_hooks`, so `#stack` resolved to the synchronous carrier; either keep the block synchronous, or pass an async-capable carrier as `initialize({ stack })`.";
233
260
  }
234
261
  }
@@ -236,10 +263,52 @@ class Error_FabricatorError extends Error {
236
263
  class HarnessingProviderError extends FabricatorError {
237
264
  constructor(){
238
265
  super();
239
- this.name = "HarnessingProviderError";
266
+ this.name = "@ghostry/fabricator:HarnessingProviderError";
240
267
  this.message = "The `fabricator` provider was called outside its integration's frame, so there is no per-test scope to provide. A composer must run each integration's providers inside the frame it opened, passing forward what that frame's wrapper established, as `@ghostry/harness` does.";
241
268
  }
242
269
  }
243
270
  FabricatorError.HarnessingProviderError = HarnessingProviderError;
271
+ function within(collection) {
272
+ switch(collection){
273
+ case void 0:
274
+ return "";
275
+ case "array":
276
+ return " It is the element of a T.array, which reuses one element across every array it makes, so its values stay distinct across all of them. For members distinct within each array, use T.unique.array.";
277
+ case "record":
278
+ return " It is the key of a T.record, which reuses one key across every record it makes, so its keys stay distinct across all of them. For keys distinct within each record, use T.unique.record.";
279
+ }
280
+ }
281
+ class UniqueExhaustedError extends FabricatorError {
282
+ constructor(kind, capacity, collection){
283
+ super(), _define_property(this, "kind", void 0), _define_property(this, "capacity", void 0), _define_property(this, "collection", void 0), this.kind = kind, this.capacity = capacity, this.collection = collection;
284
+ this.name = "@ghostry/fabricator:UniqueExhaustedError";
285
+ this.message = `A unique "${kind}" has produced all ${capacity} of its distinct values, so another draw cannot be unique. Widen its domain, or build a fresh Fabricator to start over.` + within(collection);
286
+ }
287
+ }
288
+ FabricatorError.UniqueExhaustedError = UniqueExhaustedError;
289
+ class UniqueRedrawsError extends FabricatorError {
290
+ constructor(label, redraws, produced, collection){
291
+ super(), _define_property(this, "label", void 0), _define_property(this, "redraws", void 0), _define_property(this, "produced", void 0), _define_property(this, "collection", void 0), this.label = label, this.redraws = redraws, this.produced = produced, this.collection = collection;
292
+ this.name = "@ghostry/fabricator:UniqueRedrawsError";
293
+ this.message = `${label} gave up after ${redraws} redraws without finding a value it had not already produced (it had produced ${produced}). The domain is used up, or its remaining values are too rare to find. Widen the domain, or raise \`redraws\` if its distribution is skewed.` + within(collection);
294
+ }
295
+ }
296
+ FabricatorError.UniqueRedrawsError = UniqueRedrawsError;
297
+ class UniqueCapacityError extends FabricatorError {
298
+ constructor(label, capacity, requested){
299
+ super(), _define_property(this, "label", void 0), _define_property(this, "capacity", void 0), _define_property(this, "requested", void 0), this.label = label, this.capacity = capacity, this.requested = requested;
300
+ this.name = "@ghostry/fabricator:UniqueCapacityError";
301
+ this.message = `${label} may draw up to ${requested} distinct members, but its member schema has only ${capacity} distinct values. Lower the maximum, or widen the member schema.`;
302
+ }
303
+ }
304
+ FabricatorError.UniqueCapacityError = UniqueCapacityError;
305
+ class InvalidRedrawsError extends FabricatorError {
306
+ constructor(label, redraws){
307
+ super(), _define_property(this, "label", void 0), _define_property(this, "redraws", void 0), this.label = label, this.redraws = redraws;
308
+ this.name = "@ghostry/fabricator:InvalidRedrawsError";
309
+ this.message = `${label} got redraws: ${redraws}, which is not a count of retries. Pass a whole number, 0 or more.`;
310
+ }
311
+ }
312
+ FabricatorError.InvalidRedrawsError = InvalidRedrawsError;
244
313
  })(Error_FabricatorError || (Error_FabricatorError = {}));
245
314
  export { Error_FabricatorError as FabricatorError };
@@ -5,13 +5,14 @@ import { isLayered, normalizeSalt, toRandomSource } from "../Random/index.js";
5
5
  import { toSchema } from "../Schema/Core.js";
6
6
  import { Adaptation, Fixed, Kind, Layer, Meta } from "../Types.js";
7
7
  import { inline } from "../Utility/Core.js";
8
- function Constructor(source, stack, ancestry) {
8
+ function Constructor(source, stack, ancestry, exhaustion = "throw") {
9
9
  function make(schema, path, context) {
10
10
  schema = toSchema(schema);
11
11
  const kind = schema[Kind];
12
12
  const common = {
13
13
  algorithm: context.algorithm,
14
- trace: context.toTrace(path, kind)
14
+ trace: context.toTrace(path, kind),
15
+ exhaustion: context.exhaustion
15
16
  };
16
17
  switch(kind){
17
18
  case "number":
@@ -298,7 +299,7 @@ function Constructor(source, stack, ancestry) {
298
299
  function construct(schema, options = {}) {
299
300
  var _options_path;
300
301
  if ("string" == typeof options.kind && options.kind !== schema[Kind]) throw new FabricatorError.TraceKindMismatchError(schema[Kind], options.kind);
301
- const context = toConstructionContext(source, options, stack, ancestry);
302
+ const context = toConstructionContext(source, options, stack, ancestry, exhaustion);
302
303
  const made = make(schema, null != (_options_path = options.path) ? _options_path : [], context);
303
304
  const adaptations = schema[Adaptation];
304
305
  return adaptations ? {
@@ -308,7 +309,7 @@ function Constructor(source, stack, ancestry) {
308
309
  }
309
310
  return construct;
310
311
  }
311
- function toConstructionContext(source, options, stack, ancestry) {
312
+ function toConstructionContext(source, options, stack, ancestry, exhaustion) {
312
313
  const { source: resolved, trace } = resolveScope(source, options, stack, ancestry);
313
314
  return {
314
315
  toTrace: (path, kind)=>({
@@ -321,7 +322,8 @@ function toConstructionContext(source, options, stack, ancestry) {
321
322
  salt,
322
323
  algorithm: resolved.algorithm,
323
324
  clock: trace.clock
324
- })
325
+ }),
326
+ exhaustion
325
327
  };
326
328
  }
327
329
  function resolveScope(source, options, stack, ancestry) {
@@ -1,4 +1,5 @@
1
1
  import { enumerables } from "../Enumeration/Enumerate.js";
2
+ import { toCapacity } from "../Unique/Capacity.js";
2
3
  import { FabricatorError } from "../Error/index.js";
3
4
  import { Constructor } from "../Fabricator/Constructor.js";
4
5
  import { Fabricate } from "../Fabricator/Fabricate.js";
@@ -67,6 +68,7 @@ function instantiate(config, stack, parent) {
67
68
  });
68
69
  const Fabricator = Constructor(source, stack, ancestry);
69
70
  const { combinatorial, coverage } = enumerables(source, config.limits, stack, ancestry);
71
+ const capacity = (schema)=>toCapacity(schema, "trace" in schema ? schema.trace.clock : context.clock);
70
72
  const fabricatorCache = null != (_ref = null == parent ? void 0 : parent.fabricatorCache) ? _ref : new WeakMap();
71
73
  const fabricate = Fabricate(Fabricator, source, stack, ancestry, fabricatorCache);
72
74
  function derive(over) {
@@ -136,6 +138,7 @@ function instantiate(config, stack, parent) {
136
138
  fabricate,
137
139
  combinatorial,
138
140
  coverage,
141
+ capacity,
139
142
  salt: source.salt,
140
143
  fork,
141
144
  wrap,