@ghostry/fabricator 0.0.1 → 0.0.3

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 (139) hide show
  1. package/README.md +18 -12
  2. package/dist/esm/Adapter/Core.js +3 -3
  3. package/dist/esm/Enumeration/Enumerate.js +16 -13
  4. package/dist/esm/Error/index.js +16 -8
  5. package/dist/esm/Fabricator/Constructor.js +12 -14
  6. package/dist/esm/Harnessing/Core.js +30 -0
  7. package/dist/esm/Harnessing/Salt.js +12 -0
  8. package/dist/esm/Harnessing/Types.js +1 -0
  9. package/dist/esm/Instance/Core.js +25 -41
  10. package/dist/esm/Instance/Stack/Async.js +10 -0
  11. package/dist/esm/Instance/Stack/Sync.js +16 -0
  12. package/dist/esm/Primitive/bigint/Registry.js +12 -12
  13. package/dist/esm/Primitive/boolean/Registry.js +2 -1
  14. package/dist/esm/Primitive/date/Registry.js +15 -14
  15. package/dist/esm/Primitive/null/Registry.js +2 -1
  16. package/dist/esm/Primitive/number/Registry.js +18 -17
  17. package/dist/esm/Primitive/recursive/Fabricator.js +1 -1
  18. package/dist/esm/Primitive/symbol/Registry.js +2 -1
  19. package/dist/esm/Primitive/undefined/Registry.js +2 -1
  20. package/dist/esm/Random/index.js +24 -79
  21. package/dist/esm/Utility/Core.js +6 -1
  22. package/dist/esm/adapting.js +2 -0
  23. package/dist/esm/harnessing.js +1 -0
  24. package/dist/esm/index.js +5 -4
  25. package/dist/esm/internal.js +2 -2
  26. package/dist/types/Adapter/Core.d.ts +30 -33
  27. package/dist/types/Adapter/Types.d.ts +78 -88
  28. package/dist/types/Bound.d.ts +15 -15
  29. package/dist/types/Distribution/index.d.ts +54 -61
  30. package/dist/types/Enumeration/Enumerate.d.ts +24 -24
  31. package/dist/types/Enumeration/Plan.d.ts +22 -26
  32. package/dist/types/Enumeration/Types.d.ts +38 -43
  33. package/dist/types/Error/index.d.ts +103 -89
  34. package/dist/types/Fabricator/Constructor.d.ts +24 -26
  35. package/dist/types/Fabricator/Types.d.ts +73 -81
  36. package/dist/types/Harnessing/Core.d.ts +43 -0
  37. package/dist/types/Harnessing/Salt.d.ts +31 -0
  38. package/dist/types/Harnessing/Types.d.ts +79 -0
  39. package/dist/types/Instance/Core.d.ts +38 -74
  40. package/dist/types/Instance/Stack/Async.d.ts +14 -0
  41. package/dist/types/Instance/Stack/Sync.d.ts +14 -0
  42. package/dist/types/Instance/Types.d.ts +98 -102
  43. package/dist/types/Primitive/always/Schema.d.ts +8 -8
  44. package/dist/types/Primitive/always/Types.d.ts +7 -7
  45. package/dist/types/Primitive/array/Registry.d.ts +10 -8
  46. package/dist/types/Primitive/array/Schema.d.ts +4 -5
  47. package/dist/types/Primitive/array/Types.d.ts +6 -6
  48. package/dist/types/Primitive/bigint/Registry.d.ts +6 -6
  49. package/dist/types/Primitive/bigint/Schema.d.ts +8 -8
  50. package/dist/types/Primitive/bigint/Types.d.ts +5 -5
  51. package/dist/types/Primitive/boolean/Outcomes.d.ts +8 -8
  52. package/dist/types/Primitive/boolean/Registry.d.ts +2 -12
  53. package/dist/types/Primitive/boolean/Schema.d.ts +8 -8
  54. package/dist/types/Primitive/boolean/Types.d.ts +3 -3
  55. package/dist/types/Primitive/choice/Fabricator.d.ts +6 -7
  56. package/dist/types/Primitive/choice/Registry.d.ts +13 -13
  57. package/dist/types/Primitive/choice/Schema.d.ts +6 -6
  58. package/dist/types/Primitive/choice/Types.d.ts +11 -11
  59. package/dist/types/Primitive/date/Registry.d.ts +25 -48
  60. package/dist/types/Primitive/date/Schema.d.ts +9 -10
  61. package/dist/types/Primitive/date/Types.d.ts +4 -4
  62. package/dist/types/Primitive/enum/Registry.d.ts +13 -13
  63. package/dist/types/Primitive/enum/Schema.d.ts +5 -5
  64. package/dist/types/Primitive/enum/Types.d.ts +17 -19
  65. package/dist/types/Primitive/namespace.d.ts +10 -10
  66. package/dist/types/Primitive/null/Registry.d.ts +2 -2
  67. package/dist/types/Primitive/null/Schema.d.ts +2 -2
  68. package/dist/types/Primitive/null/Types.d.ts +3 -3
  69. package/dist/types/Primitive/nullable/Fabricator.d.ts +7 -7
  70. package/dist/types/Primitive/nullable/Schema.d.ts +13 -13
  71. package/dist/types/Primitive/nullable/Types.d.ts +9 -10
  72. package/dist/types/Primitive/nullish/Fabricator.d.ts +12 -13
  73. package/dist/types/Primitive/nullish/Schema.d.ts +8 -8
  74. package/dist/types/Primitive/nullish/Types.d.ts +12 -13
  75. package/dist/types/Primitive/number/Registry.d.ts +20 -38
  76. package/dist/types/Primitive/number/Schema.d.ts +11 -12
  77. package/dist/types/Primitive/number/Types.d.ts +13 -13
  78. package/dist/types/Primitive/number/defaults.d.ts +3 -3
  79. package/dist/types/Primitive/object/Fabricator.d.ts +15 -15
  80. package/dist/types/Primitive/object/Registry.d.ts +8 -8
  81. package/dist/types/Primitive/object/Schema.d.ts +10 -10
  82. package/dist/types/Primitive/object/Types.d.ts +20 -22
  83. package/dist/types/Primitive/object/compute/Fabricator.d.ts +4 -5
  84. package/dist/types/Primitive/object/compute/Schema.d.ts +4 -4
  85. package/dist/types/Primitive/object/compute/Types.d.ts +19 -20
  86. package/dist/types/Primitive/object/omittable/Fabricator.d.ts +10 -10
  87. package/dist/types/Primitive/object/omittable/Outcomes.d.ts +2 -2
  88. package/dist/types/Primitive/object/omittable/Schema.d.ts +11 -11
  89. package/dist/types/Primitive/object/omittable/Types.d.ts +14 -15
  90. package/dist/types/Primitive/object/optional/Fabricator.d.ts +16 -18
  91. package/dist/types/Primitive/object/optional/Outcomes.d.ts +2 -2
  92. package/dist/types/Primitive/object/optional/Schema.d.ts +4 -4
  93. package/dist/types/Primitive/object/optional/Types.d.ts +17 -17
  94. package/dist/types/Primitive/opaque/Registry.d.ts +3 -3
  95. package/dist/types/Primitive/opaque/Schema.d.ts +8 -9
  96. package/dist/types/Primitive/record/Registry.d.ts +8 -6
  97. package/dist/types/Primitive/record/Schema.d.ts +9 -11
  98. package/dist/types/Primitive/record/Types.d.ts +25 -25
  99. package/dist/types/Primitive/recursive/Fabricator.d.ts +20 -21
  100. package/dist/types/Primitive/recursive/Registry.d.ts +6 -7
  101. package/dist/types/Primitive/recursive/Schema.d.ts +8 -8
  102. package/dist/types/Primitive/recursive/Terminate.d.ts +13 -14
  103. package/dist/types/Primitive/recursive/Types.d.ts +31 -31
  104. package/dist/types/Primitive/recursive/self/Fabricator.d.ts +11 -12
  105. package/dist/types/Primitive/recursive/self/Schema.d.ts +10 -10
  106. package/dist/types/Primitive/recursive/self/Types.d.ts +7 -8
  107. package/dist/types/Primitive/string/Constants.d.ts +12 -13
  108. package/dist/types/Primitive/string/Fabricator.d.ts +2 -2
  109. package/dist/types/Primitive/string/Registry.d.ts +10 -16
  110. package/dist/types/Primitive/string/Schema.d.ts +5 -5
  111. package/dist/types/Primitive/string/Types.d.ts +17 -17
  112. package/dist/types/Primitive/symbol/Fabricator.d.ts +2 -2
  113. package/dist/types/Primitive/symbol/Registry.d.ts +4 -11
  114. package/dist/types/Primitive/symbol/Schema.d.ts +6 -6
  115. package/dist/types/Primitive/symbol/Types.d.ts +2 -2
  116. package/dist/types/Primitive/tuple/Fabricator.d.ts +7 -8
  117. package/dist/types/Primitive/tuple/Schema.d.ts +5 -5
  118. package/dist/types/Primitive/tuple/Types.d.ts +24 -25
  119. package/dist/types/Primitive/undefinable/Fabricator.d.ts +7 -7
  120. package/dist/types/Primitive/undefinable/Schema.d.ts +13 -13
  121. package/dist/types/Primitive/undefinable/Types.d.ts +10 -10
  122. package/dist/types/Primitive/undefined/Registry.d.ts +2 -2
  123. package/dist/types/Primitive/undefined/Schema.d.ts +4 -4
  124. package/dist/types/Primitive/undefined/Types.d.ts +3 -3
  125. package/dist/types/Random/Generator/sfc32.d.ts +4 -4
  126. package/dist/types/Random/Types.d.ts +151 -293
  127. package/dist/types/Random/index.d.ts +56 -81
  128. package/dist/types/Schema/Core.d.ts +19 -21
  129. package/dist/types/Schema/Registry.d.ts +3 -3
  130. package/dist/types/Schema/Types.d.ts +41 -48
  131. package/dist/types/Types.d.ts +39 -45
  132. package/dist/types/Utility/Core.d.ts +18 -9
  133. package/dist/types/adapting.d.ts +32 -0
  134. package/dist/types/harnessing.d.ts +30 -0
  135. package/dist/types/index.d.ts +95 -128
  136. package/dist/types/internal.d.ts +53 -40
  137. package/package.json +39 -7
  138. package/dist/esm/Random/CallSite.js +0 -56
  139. package/dist/types/Random/CallSite.d.ts +0 -59
@@ -1,18 +1,17 @@
1
1
  /**
2
2
  * Every error this library throws is a named subclass of
3
- * {@link FabricatorError}, kept in one dependency-free module:
4
- * `instanceof FabricatorError` catches everything the library raises, and no
5
- * error definition can pull a primitive's module graph into an unrelated
6
- * import.
3
+ * {@link FabricatorError}, kept in one dependency-free module: `instanceof
4
+ * FabricatorError` catches everything the library raises, and no error
5
+ * definition can pull a primitive's module graph into an unrelated import.
7
6
  *
8
- * Kind tags are plain `string`, not the `Kind` union from
9
- * `Primitive/index.ts` — that second reason, and because several of these
10
- * errors exist precisely because the kind in hand was *not* a member of it.
7
+ * Kind tags are plain `string`, not the `Kind` union from `Primitive/index.ts`
8
+ * — that second reason, and because several of these errors exist precisely
9
+ * because the kind in hand was _not_ a member of it.
11
10
  *
12
11
  * Context is `public readonly` constructor parameters, but the message still
13
- * stands on its own: a consumer reading only `.message` should not need a
14
- * field to understand the failure. Fields are for programmatic access, and
15
- * for detail too bulky to inline.
12
+ * stands on its own: a consumer reading only `.message` should not need a field
13
+ * to understand the failure. Fields are for programmatic access, and for detail
14
+ * too bulky to inline.
16
15
  */
17
16
  /**
18
17
  * Base error class from which more specific errors inherit.
@@ -28,8 +27,8 @@ export declare namespace FabricatorError {
28
27
  */
29
28
  type Phase = "construction" | "adaptation";
30
29
  /**
31
- * `initialize({ limits: { combinatorial } })` when the configured limit
32
- * could never be a meaningful instance count.
30
+ * `initialize({ limits: { combinatorial } })` when the configured limit could
31
+ * never be a meaningful instance count.
33
32
  */
34
33
  class InvalidCombinatorialLimitError extends FabricatorError {
35
34
  /**
@@ -47,28 +46,9 @@ export declare namespace FabricatorError {
47
46
  limit: unknown);
48
47
  }
49
48
  /**
50
- * `initialize({ attribution: { kind: "rooted", root } })` when `root` is
51
- * not an absolute path or a `file://` URL. A relative root can never prefix
52
- * a resolved caller file, so `relativize` would leave every file unchanged
53
- * — the option would look configured while silently doing nothing. Thrown
54
- * eagerly at `initialize()`, not deferred to wherever that would first
55
- * become observable.
56
- */
57
- class InvalidAttributionRootError extends FabricatorError {
58
- /**
59
- * The rejected root, as given.
60
- */
61
- readonly root: string;
62
- constructor(
63
- /**
64
- * The rejected root, as given.
65
- */
66
- root: string);
67
- }
68
- /**
69
- * A `self` placeholder resolved with no `T.recursive` expanding around it
70
- * — only reachable by holding a `self` reference outside the
71
- * `T.recursive(...)` callback it was handed to.
49
+ * A `self` placeholder resolved with no `T.recursive` expanding around it —
50
+ * only reachable by holding a `self` reference outside the `T.recursive(...)`
51
+ * callback it was handed to.
72
52
  */
73
53
  class DetachedSelfError extends FabricatorError {
74
54
  /**
@@ -82,36 +62,37 @@ export declare namespace FabricatorError {
82
62
  during: Phase);
83
63
  }
84
64
  /**
85
- * `T.recursive(body).whereby({ depth })` with no `terminal`, when `body`
86
- * has a `self` that is not behind a kind that can stop recursing — a
87
- * required object field, a tuple slot, the body itself, or a `choice`
88
- * whose every option still contains `self`. Thrown at `.whereby()`, not
89
- * at fabricate time. An explicit `terminal` is the way out.
65
+ * `T.recursive(body).whereby({ depth })` with no `terminal`, when `body` has
66
+ * a `self` that is not behind a kind that can stop recursing — a required
67
+ * object field, a tuple slot, the body itself, or a `choice` whose every
68
+ * option still contains `self`. Thrown at `.whereby()`, not at fabricate
69
+ * time. An explicit `terminal` is the way out.
90
70
  */
91
71
  class UnterminableRecursiveError extends FabricatorError {
92
72
  /**
93
- * Structural path from the recursive body to the unterminable
94
- * `self` (or to the `choice` that had no remaining non-`self`
95
- * option), as field names / slot indices.
73
+ * Structural path from the recursive body to the unterminable `self` (or
74
+ * to the `choice` that had no remaining non-`self` option), as field
75
+ * names / slot indices.
96
76
  */
97
77
  readonly path: ReadonlyArray<string>;
98
78
  constructor(
99
79
  /**
100
- * Structural path from the recursive body to the unterminable
101
- * `self` (or to the `choice` that had no remaining non-`self`
102
- * option), as field names / slot indices.
80
+ * Structural path from the recursive body to the unterminable `self` (or
81
+ * to the `choice` that had no remaining non-`self` option), as field
82
+ * names / slot indices.
103
83
  */
104
84
  path: ReadonlyArray<string>);
105
85
  }
106
86
  /**
107
- * A walk reached a node whose `[Kind]` it has no case for — a Schema built
108
- * by hand or cast past the type system, or a kind added to
109
- * `Primitive/index.ts` without wiring it into every dispatch site.
87
+ * A walk reached a node whose `[Kind]` it has no case for — a Schema built by
88
+ * hand or cast past the type system, or a kind added to `Primitive/index.ts`
89
+ * without wiring it into every dispatch site.
110
90
  */
111
91
  class UnknownKindError extends FabricatorError {
112
92
  /**
113
- * The unrecognized `[Kind]` tag, stringified — it may be any value at all,
114
- * since reaching this error means the type system was already bypassed.
93
+ * The unrecognized `[Kind]` tag, stringified — it may be any value at
94
+ * all, since reaching this error means the type system was already
95
+ * bypassed.
115
96
  */
116
97
  readonly kind: string;
117
98
  /**
@@ -120,8 +101,9 @@ export declare namespace FabricatorError {
120
101
  readonly during: Phase;
121
102
  constructor(
122
103
  /**
123
- * The unrecognized `[Kind]` tag, stringified — it may be any value at all,
124
- * since reaching this error means the type system was already bypassed.
104
+ * The unrecognized `[Kind]` tag, stringified — it may be any value at
105
+ * all, since reaching this error means the type system was already
106
+ * bypassed.
125
107
  */
126
108
  kind: string,
127
109
  /**
@@ -154,10 +136,9 @@ export declare namespace FabricatorError {
154
136
  noun: string);
155
137
  }
156
138
  /**
157
- * An object's definition names a key that would reach `Object.prototype` —
158
- * a developer-written key, where throwing is actionable (contrast
159
- * `record`'s *drawn* keys, written with `Object.defineProperty` instead of
160
- * rejected).
139
+ * An object's definition names a key that would reach `Object.prototype` — a
140
+ * developer-written key, where throwing is actionable (contrast `record`'s
141
+ * _drawn_ keys, written with `Object.defineProperty` instead of rejected).
161
142
  */
162
143
  class PrototypePollutionError extends FabricatorError {
163
144
  /**
@@ -179,8 +160,8 @@ export declare namespace FabricatorError {
179
160
  constructor();
180
161
  }
181
162
  /**
182
- * A `.refine()`-computed field's resolver returned a value of the wrong
183
- * shape for the source schema it was declared against.
163
+ * A `.refine()`-computed field's resolver returned a value of the wrong shape
164
+ * for the source schema it was declared against.
184
165
  */
185
166
  class ComputeResultMismatchError extends FabricatorError {
186
167
  /**
@@ -202,8 +183,8 @@ export declare namespace FabricatorError {
202
183
  value: unknown);
203
184
  }
204
185
  /**
205
- * An override names a field the object schema does not define — most
206
- * often a typo, which is why the known fields are listed.
186
+ * An override names a field the object schema does not define — most often a
187
+ * typo, which is why the known fields are listed.
207
188
  */
208
189
  class UnknownOverrideFieldError extends FabricatorError {
209
190
  /**
@@ -225,8 +206,8 @@ export declare namespace FabricatorError {
225
206
  available: ReadonlyArray<string>);
226
207
  }
227
208
  /**
228
- * An override value does not fit the field it is meant to replace. Raised
229
- * for every field shape — a plain field, a nested object, and each presence
209
+ * An override value does not fit the field it is meant to replace. Raised for
210
+ * every field shape — a plain field, a nested object, and each presence
230
211
  * wrapper unwrapped to its inner kind — the same failure in each case.
231
212
  */
232
213
  class InvalidOverrideValueError extends FabricatorError {
@@ -236,7 +217,7 @@ export declare namespace FabricatorError {
236
217
  readonly field: string;
237
218
  /**
238
219
  * The `[Kind]` the value was checked against — for a wrapper field, the
239
- * *inner* kind, since the wrapper's own absent/null outcomes are accepted
220
+ * _inner_ kind, since the wrapper's own absent/null outcomes are accepted
240
221
  * separately.
241
222
  */
242
223
  readonly kind: string;
@@ -251,7 +232,7 @@ export declare namespace FabricatorError {
251
232
  field: string,
252
233
  /**
253
234
  * The `[Kind]` the value was checked against — for a wrapper field, the
254
- * *inner* kind, since the wrapper's own absent/null outcomes are accepted
235
+ * _inner_ kind, since the wrapper's own absent/null outcomes are accepted
255
236
  * separately.
256
237
  */
257
238
  kind: string,
@@ -261,9 +242,8 @@ export declare namespace FabricatorError {
261
242
  value: unknown);
262
243
  }
263
244
  /**
264
- * Thrown when `Omitted` is passed to override a field that has no
265
- * absent outcome. Only `T.omittable`/`T.optional` fields can be forced
266
- * off.
245
+ * Thrown when `Omitted` is passed to override a field that has no absent
246
+ * outcome. Only `T.omittable`/`T.optional` fields can be forced off.
267
247
  */
268
248
  class IllegalOmittedOverrideError extends FabricatorError {
269
249
  /**
@@ -310,8 +290,8 @@ export declare namespace FabricatorError {
310
290
  width: bigint);
311
291
  }
312
292
  /**
313
- * `resolve()` handed a pin for a kind `plan()` never produces one for —
314
- * the two must stay in agreement; internal invariant, not caller-reachable.
293
+ * `resolve()` handed a pin for a kind `plan()` never produces one for — the
294
+ * two must stay in agreement; internal invariant, not caller-reachable.
315
295
  */
316
296
  class UnpinnableKindError extends FabricatorError {
317
297
  /**
@@ -352,8 +332,8 @@ export declare namespace FabricatorError {
352
332
  }
353
333
  /**
354
334
  * A `record`'s key schema has no counterpart in the external schema library
355
- * being adapted to — a symbol key, for TypeBox, whose `Type.Record`
356
- * silently yields a schema nothing can satisfy rather than raising.
335
+ * being adapted to — a symbol key, for TypeBox, whose `Type.Record` silently
336
+ * yields a schema nothing can satisfy rather than raising.
357
337
  */
358
338
  class UnrepresentableRecordKeyError extends FabricatorError {
359
339
  /**
@@ -367,10 +347,10 @@ export declare namespace FabricatorError {
367
347
  kind: string);
368
348
  }
369
349
  /**
370
- * A `{ min, max }` range contains no fabricable value — inverted bounds,
371
- * a point range with an exclusive end, or a discrete exclusive pair whose
372
- * effective integers are none. Thrown at `.whereby()` (or at construction
373
- * for `T.date.past`/`future`, whose other end is the instance clock).
350
+ * A `{ min, max }` range contains no fabricable value — inverted bounds, a
351
+ * point range with an exclusive end, or a discrete exclusive pair whose
352
+ * effective integers are none. Thrown at `.whereby()` (or at construction for
353
+ * `T.date.past`/`future`, whose other end is the instance clock).
374
354
  */
375
355
  class EmptyRangeError extends FabricatorError {
376
356
  /**
@@ -413,8 +393,8 @@ export declare namespace FabricatorError {
413
393
  }
414
394
  /**
415
395
  * A distribution's bounds fall outside its own domain — a `logarithmic`
416
- * distribution's density is proportional to `1/x`, so it is undefined at
417
- * or below zero.
396
+ * distribution's density is proportional to `1/x`, so it is undefined at or
397
+ * below zero.
418
398
  */
419
399
  class InvalidDistributionBoundError extends FabricatorError {
420
400
  /**
@@ -444,8 +424,8 @@ export declare namespace FabricatorError {
444
424
  max: number);
445
425
  }
446
426
  /**
447
- * Which entry of a `.weighted(...)` call carried the bad weight: a position in
448
- * a caller-supplied list, or one of a fixed, named outcome set.
427
+ * Which entry of a `.weighted(...)` call carried the bad weight: a position
428
+ * in a caller-supplied list, or one of a fixed, named outcome set.
449
429
  */
450
430
  type WeightEntry = {
451
431
  readonly kind: "index";
@@ -456,10 +436,10 @@ export declare namespace FabricatorError {
456
436
  readonly name: string;
457
437
  };
458
438
  /**
459
- * A `.weighted(...)` call gives an outcome a weight that is not
460
- * expressible: negative, `NaN`, or `Infinity`. Zero is valid — it
461
- * disables the outcome — so this is not "anything `weighted()` would
462
- * drop." An empty drawable set is {@link NoDrawableOutcomesError}.
439
+ * A `.weighted(...)` call gives an outcome a weight that is not expressible:
440
+ * negative, `NaN`, or `Infinity`. Zero is valid — it disables the outcome —
441
+ * so this is not "anything `weighted()` would drop." An empty drawable set is
442
+ * {@link NoDrawableOutcomesError}.
463
443
  */
464
444
  class InvalidWeightError extends FabricatorError {
465
445
  /**
@@ -489,9 +469,9 @@ export declare namespace FabricatorError {
489
469
  entry: WeightEntry);
490
470
  }
491
471
  /**
492
- * A weighted draw table has nothing left to pick: every weight is
493
- * zero (or the list was empty of drawable entries). Zeroing an
494
- * outcome disables it, so at least one must keep a positive weight.
472
+ * A weighted draw table has nothing left to pick: every weight is zero (or
473
+ * the list was empty of drawable entries). Zeroing an outcome disables it, so
474
+ * at least one must keep a positive weight.
495
475
  */
496
476
  class NoDrawableOutcomesError extends FabricatorError {
497
477
  /**
@@ -515,9 +495,9 @@ export declare namespace FabricatorError {
515
495
  noun: string);
516
496
  }
517
497
  /**
518
- * `new Fabricator(schema, trace)` when `trace.kind` names a different
519
- * kind than `schema`. A trace reproduces the node it was taken from,
520
- * so its kind must match the schema it is replayed against.
498
+ * `new Fabricator(schema, trace)` when `trace.kind` names a different kind
499
+ * than `schema`. A trace reproduces the node it was taken from, so its kind
500
+ * must match the schema it is replayed against.
521
501
  */
522
502
  class TraceKindMismatchError extends FabricatorError {
523
503
  /**
@@ -538,4 +518,38 @@ export declare namespace FabricatorError {
538
518
  */
539
519
  given: string);
540
520
  }
521
+ /**
522
+ * `wrap(overlay, block)` handed an `async` block while the lineage's ambient
523
+ * carrier is the synchronous one (`Instance/Stack/Sync.ts`).
524
+ *
525
+ * Its frame cannot outlive the block's first `await`, so a build reached
526
+ * after one would resolve against the base instance rather than the wrap —
527
+ * plausible data, quietly drawn from the wrong configuration. Raised instead
528
+ * of allowing that, which is why it fires even when `block` only ever uses
529
+ * `scope`: whether a later build reads the ambient frame is not knowable from
530
+ * here.
531
+ *
532
+ * Reachable only where `#stack` resolved to `default` — a runtime with no
533
+ * `node:async_hooks`, in practice a browser bundle — or where `initialize({
534
+ * stack })` supplied a synchronous carrier explicitly. Node, Bun, and Deno
535
+ * all resolve to the `AsyncLocalStorage` carrier and never raise this.
536
+ */
537
+ class SynchronousStackError extends FabricatorError {
538
+ constructor();
539
+ }
540
+ /**
541
+ * The `fabricator` provider of `integration(instance)`
542
+ * (`@ghostry/fabricator/harnessing`) was called outside that integration's
543
+ * own `around`.
544
+ *
545
+ * The provider hands back the per-test scope `around` just entered, so there
546
+ * is no scope for it to return anywhere else. `@ghostry/harness` never does
547
+ * this — it runs each provider inside its integration's `around` — so this
548
+ * means a composer that breaks the contract. Raised rather than returning the
549
+ * base instance, which would draw plausible data from the wrong configuration
550
+ * with no signal.
551
+ */
552
+ class HarnessingProviderError extends FabricatorError {
553
+ constructor();
554
+ }
541
555
  }
@@ -3,41 +3,39 @@ import type { ConstructorOptions, RandomSource } from "../Random/Types";
3
3
  import { type Buildable } from "../Types";
4
4
  import { type AsFabricator } from "./Types";
5
5
  /**
6
- * The type of `construct()` itself, as handed back by `Constructor` —
7
- * kept separate so `initialize`'s return type (`src/index.ts`) can name
8
- * it without re-deriving it from `Constructor`'s implementation.
6
+ * The type of `construct()` itself, as handed back by `Constructor` — kept
7
+ * separate so `initialize`'s return type (`src/index.ts`) can name it without
8
+ * re-deriving it from `Constructor`'s implementation.
9
9
  *
10
- * Both a call signature and a construct signature: `construct` is a
11
- * plain `function` that explicitly returns an object, so
12
- * `new construct(schema)` behaves identically to `construct(schema)` —
13
- * a `new` call's returned object always replaces the freshly-created
14
- * `this`. The construct signature lets callers spell
15
- * `new T.Fabricator(schema)` — or `new Fabricator(schema, { seed })` to
16
- * pin this one build to an explicit seed, independent of the file it's
17
- * constructed in (see `construct()` for what `options.seed` does).
10
+ * Both a call signature and a construct signature: `construct` is a plain
11
+ * `function` that explicitly returns an object, so `new construct(schema)`
12
+ * behaves identically to `construct(schema)` — a `new` call's returned object
13
+ * always replaces the freshly-created `this`. The construct signature lets
14
+ * callers spell `new T.Fabricator(schema)` — or `new Fabricator(schema, { salt
15
+ * })` to pin this one build's salt slot, leaving every other slot to resolve as
16
+ * usual (see `construct()` for what `options.salt` does).
18
17
  */
19
18
  export type Constructor = {
20
19
  new <const $Schema extends Buildable>(schema: $Schema, options?: ConstructorOptions): AsFabricator<$Schema>;
21
20
  };
22
21
  /**
23
- * Build the untyped recursive core — mirrors `Adapter/TypeBox/index.ts`'s
24
- * own internal `convert(schema: any)` — and the precisely-typed
25
- * `construct()` boundary around it, both closed over a single instance's
26
- * `source` so every fabricator this `construct()` produces draws from
27
- * that instance's own seed/streams and never another instance's.
22
+ * Build the untyped recursive core — mirrors `Adapter/TypeBox/index.ts`'s own
23
+ * internal `convert(schema: any)` — and the precisely-typed `construct()`
24
+ * boundary around it, both closed over a single instance's `source` so every
25
+ * fabricator this `construct()` produces draws from that instance's own
26
+ * salt/streams and never another instance's.
28
27
  *
29
28
  * `stack` is the instance's own lineage-wide ambient stack
30
29
  * (`Instance/Core.ts`'s `toStack()`) — passed straight through to
31
- * `resolveScope` on every `construct()` call, never read here directly,
32
- * so a build reached inside an active `wrap` resolves against that
33
- * frame automatically, with nothing threaded through by the caller.
30
+ * `resolveScope` on every `construct()` call, never read here directly, so a
31
+ * build reached inside an active `wrap` resolves against that frame
32
+ * automatically, with nothing threaded through by the caller.
34
33
  *
35
- * No separate `clock` parameter: `source` already carries its own
36
- * resolved clock intrinsically (`Random/Types.ts`'s `Options.clock`,
37
- * baked in when the source was built), and `resolveScope`'s chosen
38
- * source — the active `wrap` frame's, or this one — is exactly the
39
- * source whose clock a construction should resolve "now" against.
40
- * `toConstructionContext` reads it straight off the resolved root
41
- * rather than threading a second value alongside `source`.
34
+ * No separate `clock` parameter: `source` already carries its own resolved
35
+ * clock intrinsically (`Random/Types.ts`'s `Options.clock`, baked in when the
36
+ * source was built), and `resolveScope`'s chosen source — the active `wrap`
37
+ * frame's, or this one — is exactly the source whose clock a construction
38
+ * should resolve "now" against. `toConstructionContext` reads it straight off
39
+ * the resolved root rather than threading a second value alongside `source`.
42
40
  */
43
41
  export declare function Constructor(source: RandomSource, stack: Stack): Constructor;
@@ -5,35 +5,32 @@ import type { ValueOf } from "../Schema/Types";
5
5
  import type { Adaptation, Kind, Meta, Produces } from "../Types";
6
6
  import type { PlainObject } from "../Utility/Types";
7
7
  /**
8
- * Threaded through `Constructor.ts`'s `make` for every dispatch of one
9
- * `new Fabricator(...)` construction — every branch forwards it
10
- * (extending `path`, never `algorithm`/`self`) into its own nested
11
- * `make(...)` calls, so it reaches however deeply a leaf sits nested
12
- * through `array`/`object`/`tuple`/etc.
8
+ * Threaded through `Constructor.ts`'s `make` for every dispatch of one `new
9
+ * Fabricator(...)` construction — every branch forwards it (extending `path`,
10
+ * never `algorithm`/`self`) into its own nested `make(...)` calls, so it
11
+ * reaches however deeply a leaf sits nested through
12
+ * `array`/`object`/`tuple`/etc.
13
13
  *
14
- * `toTrace` records this node's {@link Trace} — a plain object literal,
15
- * no hashing. Hashing is paid only where a kind actually calls
16
- * `toStreamFromTrace(algorithm, trace)`. Bound once in `construct()` to
17
- * this one construction's already-resolved `RandomSource`/
18
- * `ConstructionTrace` pair (see `Constructor.ts`'s `resolveScope`) —
19
- * every leaf calls `toTrace` with only its own structural `path` and
20
- * kind, never re-resolving the construction's root itself.
21
- * `T.recursive` is the one kind that rebinds `toTrace`: each lazy
22
- * expansion opens its own scope on the node's own private forked
23
- * `RandomSource` (see `recursive/Fabricator.ts`), so a data-dependent
24
- * expansion count can never perturb, or be perturbed by, anything else
25
- * built from the same `initialize()` instance —
26
- * `RandomSource.fork` (`Random/Types.ts`) is the isolation primitive.
14
+ * `toTrace` records this node's {@link Trace} — a plain object literal, no
15
+ * hashing. Hashing is paid only where a kind actually calls
16
+ * `toStreamFromTrace(algorithm, trace)`. Bound once in `construct()` to this
17
+ * one construction's already-resolved `RandomSource`/ `ConstructionTrace` pair
18
+ * (see `Constructor.ts`'s `resolveScope`) — every leaf calls `toTrace` with
19
+ * only its own structural `path` and kind, never re-resolving the
20
+ * construction's root itself. `T.recursive` is the one kind that rebinds
21
+ * `toTrace`: each lazy expansion opens its own scope on the node's own private
22
+ * forked `RandomSource` (see `recursive/Fabricator.ts`), so a data-dependent
23
+ * expansion count can never perturb, or be perturbed by, anything else built
24
+ * from the same `initialize()` instance — `RandomSource.fork`
25
+ * (`Random/Types.ts`) is the isolation primitive.
27
26
  *
28
- * `algorithm` rather than the `RandomSource` itself: stream derivation
29
- * depends on no per-source state, and a leaf has no business with
30
- * `toRoot`/`fork`. `clock` is not a field of its own — it is always
31
- * `trace.clock`.
27
+ * `algorithm` rather than the `RandomSource` itself: stream derivation depends
28
+ * on no per-source state, and a leaf has no business with `toRoot`/`fork`.
29
+ * `clock` is not a field of its own — it is always `trace.clock`.
32
30
  *
33
- * `self` is what makes `case "recursive.self"` resolve to "recurse one
34
- * level deeper, right now" — absent outside any active recursion, which
35
- * is how `case "recursive.self"` detects and rejects a `self` node used
36
- * where none applies.
31
+ * `self` is what makes `case "recursive.self"` resolve to "recurse one level
32
+ * deeper, right now" — absent outside any active recursion, which is how `case
33
+ * "recursive.self"` detects and rejects a `self` node used where none applies.
37
34
  */
38
35
  export type ConstructionContext = {
39
36
  toTrace: (path: ReadonlyArray<string>, kind: string) => Trace;
@@ -41,22 +38,20 @@ export type ConstructionContext = {
41
38
  self?: (() => unknown) | undefined;
42
39
  };
43
40
  /**
44
- * What every kind's `Fabricator(...)` receives in place of a repeated
45
- * `(schema, algorithm, trace)` positional list — `Constructor.ts`'s
46
- * `make` builds one per dispatched node from its own
47
- * `ConstructionContext`. `trace` is already path-bound and built
48
- * eagerly, so a kind that never draws still records one without calling
49
- * `toStreamFromTrace`. Laziness is load-bearing: `toTrace` is a plain
50
- * object literal, and hashing is paid only where a kind actually calls
51
- * `toStreamFromTrace(algorithm, trace)`. The guard is the call site's
52
- * own `if (meta.produce)` branch (or the equivalent drawing path), not
53
- * an unevaluated closure. `algorithm` rather than the `RandomSource`:
54
- * derivation depends on no per-source state, and a leaf has no business
55
- * with `toRoot`/`fork`. No `clock`: it is `trace.clock`, always. A
56
- * kind-specific extra — an array's `element`, an object's `fields`, a
57
- * choice's `weightings` — still follows as its own trailing parameter:
58
- * those vary per kind and were never part of the shared prefix this
59
- * replaces.
41
+ * What every kind's `Fabricator(...)` receives in place of a repeated `(schema,
42
+ * algorithm, trace)` positional list — `Constructor.ts`'s `make` builds one per
43
+ * dispatched node from its own `ConstructionContext`. `trace` is already
44
+ * path-bound and built eagerly, so a kind that never draws still records one
45
+ * without calling `toStreamFromTrace`. Laziness is load-bearing: `toTrace` is a
46
+ * plain object literal, and hashing is paid only where a kind actually calls
47
+ * `toStreamFromTrace(algorithm, trace)`. The guard is the call site's own `if
48
+ * (meta.produce)` branch (or the equivalent drawing path), not an unevaluated
49
+ * closure. `algorithm` rather than the `RandomSource`: derivation depends on no
50
+ * per-source state, and a leaf has no business with `toRoot`/`fork`. No
51
+ * `clock`: it is `trace.clock`, always. A kind-specific extra — an array's
52
+ * `element`, an object's `fields`, a choice's `weightings` — still follows as
53
+ * its own trailing parameter: those vary per kind and were never part of the
54
+ * shared prefix this replaces.
60
55
  */
61
56
  export type FabricatorContext<$Schema> = {
62
57
  schema: $Schema;
@@ -64,18 +59,18 @@ export type FabricatorContext<$Schema> = {
64
59
  trace: Trace;
65
60
  };
66
61
  /**
67
- * The most basic interface for a typed Fabricator.
68
- * No type introspection is possible.
62
+ * The most basic interface for a typed Fabricator. No type introspection is
63
+ * possible.
69
64
  */
70
65
  export type NaiveFabricator<$T> = {
71
66
  fabricate: () => $T;
72
67
  };
73
68
  /**
74
- * What every kind's `construct()` produces: a `NaiveFabricator` that
75
- * also hands back the Schema it was built from, via the same
76
- * `[Kind]`/`[Meta]` a Schema itself carries — so a built Fabricator
77
- * can be passed back into `object`/`array`/a registry `.extend()`
78
- * anywhere a Schema is expected (see `toSchema`).
69
+ * What every kind's `construct()` produces: a `NaiveFabricator` that also hands
70
+ * back the Schema it was built from, via the same `[Kind]`/`[Meta]` a Schema
71
+ * itself carries — so a built Fabricator can be passed back into
72
+ * `object`/`array`/a registry `.extend()` anywhere a Schema is expected (see
73
+ * `toSchema`).
79
74
  */
80
75
  export type Fabricator<$T> = NaiveFabricator<$T> & {
81
76
  [Kind]: SchemaKind;
@@ -83,48 +78,45 @@ export type Fabricator<$T> = NaiveFabricator<$T> & {
83
78
  readonly trace: Trace;
84
79
  /**
85
80
  * Carried over from the Schema by `Constructor.ts`'s `make` — inert to
86
- * fabrication, but it has to survive building for an adapter handed a
87
- * built Fabricator to see what the Schema declared (see
88
- * `Adapter/Types.ts`).
81
+ * fabrication, but it has to survive building for an adapter handed a built
82
+ * Fabricator to see what the Schema declared (see `Adapter/Types.ts`).
89
83
  */
90
84
  readonly [Adaptation]?: Adaptations;
91
85
  };
92
86
  /**
93
87
  * The value type a built Fabricator produces — read directly off its
94
- * `fabricate` signature. Every kind's `construct()` output shares the
95
- * exact same shape (`NaiveFabricator<$T>` plus `[Kind]`/`[Meta]`, see
96
- * this file's `Fabricator<$T>`), so there's nothing to dispatch per
97
- * kind here — unlike `ValueOf`, which reads a Schema's phantom
98
- * `[Produces]` marker for the pre-`construct()` case, this only ever
99
- * needs to unwrap an already-uniform `fabricate: () => $T`.
88
+ * `fabricate` signature. Every kind's `construct()` output shares the exact
89
+ * same shape (`NaiveFabricator<$T>` plus `[Kind]`/`[Meta]`, see this file's
90
+ * `Fabricator<$T>`), so there's nothing to dispatch per kind here — unlike
91
+ * `ValueOf`, which reads a Schema's phantom `[Produces]` marker for the
92
+ * pre-`construct()` case, this only ever needs to unwrap an already-uniform
93
+ * `fabricate: () => $T`.
100
94
  */
101
95
  export type Fabrication<$Fabricator extends NaiveFabricator<any>> = $Fabricator extends NaiveFabricator<infer $T> ? $T : never;
102
96
  /**
103
- * Maps a Schema (or an already-built Fabricator of the same kind — see
104
- * the `object` branch, and every other branch below since each kind's
105
- * `Schema` also carries a required `as` method a built Fabricator never
106
- * has) to the precise, kind-specific `Fabricator<...>` type it builds
107
- * into. Mirrors `Adapter/TypeBox/index.ts`'s `ToTypeBox` dispatch.
108
- * Falls back to the loose base `Fabricator<ValueOf<$Schema>>` for
109
- * anything unmatched.
97
+ * Maps a Schema (or an already-built Fabricator of the same kind — see the
98
+ * `object` branch, and every other branch below since each kind's `Schema` also
99
+ * carries a required `as` method a built Fabricator never has) to the precise,
100
+ * kind-specific `Fabricator<...>` type it builds into. Mirrors
101
+ * `Adapter/TypeBox/index.ts`'s `ToTypeBox` dispatch. Falls back to the loose
102
+ * base `Fabricator<ValueOf<$Schema>>` for anything unmatched.
110
103
  *
111
- * No branch here needs to do anything about `[Adaptation]`: each
112
- * kind's own `Fabricator<$Schema>` reads it back off `$Schema` via
113
- * `AdaptationsOf`, so an adapted Schema's Fabricator carries the map
114
- * without this dispatch (or an intersection on top of it, which the
115
- * warning below would otherwise apply to) having to mention it.
116
- * `object.compute` is the one exception, taking its `$Adaptations`
117
- * explicitly because its Fabricator is parameterized by the computed
118
- * value and source rather than by the Schema.
104
+ * No branch here needs to do anything about `[Adaptation]`: each kind's own
105
+ * `Fabricator<$Schema>` reads it back off `$Schema` via `AdaptationsOf`, so an
106
+ * adapted Schema's Fabricator carries the map without this dispatch (or an
107
+ * intersection on top of it, which the warning below would otherwise apply to)
108
+ * having to mention it. `object.compute` is the one exception, taking its
109
+ * `$Adaptations` explicitly because its Fabricator is parameterized by the
110
+ * computed value and source rather than by the Schema.
119
111
  *
120
- * Every branch's own `Fabricator<$Schema>` type already carries a
121
- * `.schema` field (see each kind's `Core.ts`) — *not* added here via an
122
- * extra `& { schema: ... }` intersection: wrapping an already-named
123
- * type in a fresh intersection defeats a later `infer` over it (e.g.
124
- * each kind's own `Fabrication<$Fabricator>` helper, which narrows via
125
- * `extends Fabricator<infer $Schema>`) — TypeScript can't always
126
- * decompose the intersection back to recover `$Schema`, and silently
127
- * widens to the generic's constraint instead.
112
+ * Every branch's own `Fabricator<$Schema>` type already carries a `.schema`
113
+ * field (see each kind's `Core.ts`) — _not_ added here via an extra `& {
114
+ * schema: ... }` intersection: wrapping an already-named type in a fresh
115
+ * intersection defeats a later `infer` over it (e.g. each kind's own
116
+ * `Fabrication<$Fabricator>` helper, which narrows via `extends
117
+ * Fabricator<infer $Schema>`) — TypeScript can't always decompose the
118
+ * intersection back to recover `$Schema`, and silently widens to the generic's
119
+ * constraint instead.
128
120
  */
129
121
  export type AsFabricator<$Schema> =
130
122
  /**