@ghostry/fabricator 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. package/README.md +1 -7
  2. package/dist/esm/Error/index.js +8 -0
  3. package/dist/esm/Instance/Core.js +8 -17
  4. package/dist/esm/Instance/Stack/Async.js +10 -0
  5. package/dist/esm/Instance/Stack/Sync.js +16 -0
  6. package/dist/esm/Primitive/bigint/Registry.js +12 -12
  7. package/dist/esm/Primitive/boolean/Registry.js +2 -1
  8. package/dist/esm/Primitive/date/Registry.js +15 -14
  9. package/dist/esm/Primitive/null/Registry.js +2 -1
  10. package/dist/esm/Primitive/number/Registry.js +18 -17
  11. package/dist/esm/Primitive/symbol/Registry.js +2 -1
  12. package/dist/esm/Primitive/undefined/Registry.js +2 -1
  13. package/dist/esm/Random/CallSite.js +27 -13
  14. package/dist/esm/Utility/Core.js +6 -1
  15. package/dist/esm/index.js +4 -2
  16. package/dist/esm/internal.js +2 -1
  17. package/dist/types/Adapter/Core.d.ts +29 -32
  18. package/dist/types/Adapter/Types.d.ts +78 -88
  19. package/dist/types/Bound.d.ts +15 -15
  20. package/dist/types/Distribution/index.d.ts +54 -61
  21. package/dist/types/Enumeration/Enumerate.d.ts +21 -23
  22. package/dist/types/Enumeration/Plan.d.ts +22 -26
  23. package/dist/types/Enumeration/Types.d.ts +38 -43
  24. package/dist/types/Error/index.d.ts +94 -76
  25. package/dist/types/Fabricator/Constructor.d.ts +23 -25
  26. package/dist/types/Fabricator/Types.d.ts +73 -81
  27. package/dist/types/Instance/Core.d.ts +54 -73
  28. package/dist/types/Instance/Stack/Async.d.ts +14 -0
  29. package/dist/types/Instance/Stack/Sync.d.ts +14 -0
  30. package/dist/types/Instance/Types.d.ts +91 -89
  31. package/dist/types/Primitive/always/Schema.d.ts +8 -8
  32. package/dist/types/Primitive/always/Types.d.ts +7 -7
  33. package/dist/types/Primitive/array/Registry.d.ts +10 -8
  34. package/dist/types/Primitive/array/Schema.d.ts +4 -5
  35. package/dist/types/Primitive/array/Types.d.ts +6 -6
  36. package/dist/types/Primitive/bigint/Registry.d.ts +6 -6
  37. package/dist/types/Primitive/bigint/Schema.d.ts +8 -8
  38. package/dist/types/Primitive/bigint/Types.d.ts +5 -5
  39. package/dist/types/Primitive/boolean/Outcomes.d.ts +8 -8
  40. package/dist/types/Primitive/boolean/Registry.d.ts +2 -12
  41. package/dist/types/Primitive/boolean/Schema.d.ts +8 -8
  42. package/dist/types/Primitive/boolean/Types.d.ts +3 -3
  43. package/dist/types/Primitive/choice/Fabricator.d.ts +6 -7
  44. package/dist/types/Primitive/choice/Registry.d.ts +13 -13
  45. package/dist/types/Primitive/choice/Schema.d.ts +6 -6
  46. package/dist/types/Primitive/choice/Types.d.ts +11 -11
  47. package/dist/types/Primitive/date/Registry.d.ts +25 -48
  48. package/dist/types/Primitive/date/Schema.d.ts +9 -10
  49. package/dist/types/Primitive/date/Types.d.ts +4 -4
  50. package/dist/types/Primitive/enum/Registry.d.ts +13 -13
  51. package/dist/types/Primitive/enum/Schema.d.ts +5 -5
  52. package/dist/types/Primitive/enum/Types.d.ts +17 -19
  53. package/dist/types/Primitive/namespace.d.ts +10 -10
  54. package/dist/types/Primitive/null/Registry.d.ts +2 -2
  55. package/dist/types/Primitive/null/Schema.d.ts +2 -2
  56. package/dist/types/Primitive/null/Types.d.ts +3 -3
  57. package/dist/types/Primitive/nullable/Fabricator.d.ts +7 -7
  58. package/dist/types/Primitive/nullable/Schema.d.ts +13 -13
  59. package/dist/types/Primitive/nullable/Types.d.ts +9 -10
  60. package/dist/types/Primitive/nullish/Fabricator.d.ts +12 -13
  61. package/dist/types/Primitive/nullish/Schema.d.ts +8 -8
  62. package/dist/types/Primitive/nullish/Types.d.ts +12 -13
  63. package/dist/types/Primitive/number/Registry.d.ts +20 -38
  64. package/dist/types/Primitive/number/Schema.d.ts +11 -12
  65. package/dist/types/Primitive/number/Types.d.ts +13 -13
  66. package/dist/types/Primitive/number/defaults.d.ts +3 -3
  67. package/dist/types/Primitive/object/Fabricator.d.ts +15 -15
  68. package/dist/types/Primitive/object/Registry.d.ts +8 -8
  69. package/dist/types/Primitive/object/Schema.d.ts +10 -10
  70. package/dist/types/Primitive/object/Types.d.ts +20 -22
  71. package/dist/types/Primitive/object/compute/Fabricator.d.ts +4 -5
  72. package/dist/types/Primitive/object/compute/Schema.d.ts +4 -4
  73. package/dist/types/Primitive/object/compute/Types.d.ts +19 -20
  74. package/dist/types/Primitive/object/omittable/Fabricator.d.ts +10 -10
  75. package/dist/types/Primitive/object/omittable/Outcomes.d.ts +2 -2
  76. package/dist/types/Primitive/object/omittable/Schema.d.ts +11 -11
  77. package/dist/types/Primitive/object/omittable/Types.d.ts +14 -15
  78. package/dist/types/Primitive/object/optional/Fabricator.d.ts +16 -18
  79. package/dist/types/Primitive/object/optional/Outcomes.d.ts +2 -2
  80. package/dist/types/Primitive/object/optional/Schema.d.ts +4 -4
  81. package/dist/types/Primitive/object/optional/Types.d.ts +17 -17
  82. package/dist/types/Primitive/opaque/Registry.d.ts +3 -3
  83. package/dist/types/Primitive/opaque/Schema.d.ts +8 -9
  84. package/dist/types/Primitive/record/Registry.d.ts +8 -6
  85. package/dist/types/Primitive/record/Schema.d.ts +9 -11
  86. package/dist/types/Primitive/record/Types.d.ts +25 -25
  87. package/dist/types/Primitive/recursive/Fabricator.d.ts +16 -17
  88. package/dist/types/Primitive/recursive/Registry.d.ts +6 -7
  89. package/dist/types/Primitive/recursive/Schema.d.ts +8 -8
  90. package/dist/types/Primitive/recursive/Terminate.d.ts +13 -14
  91. package/dist/types/Primitive/recursive/Types.d.ts +31 -31
  92. package/dist/types/Primitive/recursive/self/Fabricator.d.ts +11 -12
  93. package/dist/types/Primitive/recursive/self/Schema.d.ts +10 -10
  94. package/dist/types/Primitive/recursive/self/Types.d.ts +7 -8
  95. package/dist/types/Primitive/string/Constants.d.ts +12 -13
  96. package/dist/types/Primitive/string/Fabricator.d.ts +2 -2
  97. package/dist/types/Primitive/string/Registry.d.ts +10 -16
  98. package/dist/types/Primitive/string/Schema.d.ts +5 -5
  99. package/dist/types/Primitive/string/Types.d.ts +17 -17
  100. package/dist/types/Primitive/symbol/Fabricator.d.ts +2 -2
  101. package/dist/types/Primitive/symbol/Registry.d.ts +4 -11
  102. package/dist/types/Primitive/symbol/Schema.d.ts +6 -6
  103. package/dist/types/Primitive/symbol/Types.d.ts +2 -2
  104. package/dist/types/Primitive/tuple/Fabricator.d.ts +7 -8
  105. package/dist/types/Primitive/tuple/Schema.d.ts +5 -5
  106. package/dist/types/Primitive/tuple/Types.d.ts +24 -25
  107. package/dist/types/Primitive/undefinable/Fabricator.d.ts +7 -7
  108. package/dist/types/Primitive/undefinable/Schema.d.ts +13 -13
  109. package/dist/types/Primitive/undefinable/Types.d.ts +10 -10
  110. package/dist/types/Primitive/undefined/Registry.d.ts +2 -2
  111. package/dist/types/Primitive/undefined/Schema.d.ts +4 -4
  112. package/dist/types/Primitive/undefined/Types.d.ts +3 -3
  113. package/dist/types/Random/CallSite.d.ts +63 -44
  114. package/dist/types/Random/Generator/sfc32.d.ts +4 -4
  115. package/dist/types/Random/Types.d.ts +214 -236
  116. package/dist/types/Random/index.d.ts +63 -70
  117. package/dist/types/Schema/Core.d.ts +19 -21
  118. package/dist/types/Schema/Registry.d.ts +3 -3
  119. package/dist/types/Schema/Types.d.ts +41 -48
  120. package/dist/types/Types.d.ts +39 -45
  121. package/dist/types/Utility/Core.d.ts +18 -9
  122. package/dist/types/index.d.ts +110 -108
  123. package/dist/types/internal.d.ts +68 -37
  124. package/package.json +17 -5
@@ -3,38 +3,35 @@ import type { AnySchema, ValueOf } from "../Schema/Types";
3
3
  import type { Children, Kind, Meta } from "../Types";
4
4
  import type { PlainObject } from "../Utility/Types";
5
5
  /**
6
- * How a composite with more than one child combines their widths.
7
- * `"product"` is the cartesian product — width is the product of every
8
- * child's width; `at(index)` mixed-radix decodes to a full combination
9
- * (`combinatorial`). `"cycle"` (`coverage`) takes the widest child as
10
- * the composite's width, cycling narrower children to fill it — see
11
- * CLAUDE.md's "sum vs product" note for why cycling only ever applies
12
- * to `object`/`tuple` and never to a sum node (`choice`, the presence
13
- * wrappers), which always total their children's widths regardless of
14
- * strategy.
6
+ * How a composite with more than one child combines their widths. `"product"`
7
+ * is the cartesian product — width is the product of every child's width;
8
+ * `at(index)` mixed-radix decodes to a full combination (`combinatorial`).
9
+ * `"cycle"` (`coverage`) takes the widest child as the composite's width,
10
+ * cycling narrower children to fill it — see CLAUDE.md's "sum vs product" note
11
+ * for why cycling only ever applies to `object`/`tuple` and never to a sum node
12
+ * (`choice`, the presence wrappers), which always total their children's widths
13
+ * regardless of strategy.
15
14
  */
16
15
  export type Strategy = "product" | "cycle";
17
16
  /**
18
- * A fresh, reproducible permutation of `0..width-1` each call — one
19
- * per width-`>1` node `plan()` visits, in walk order, so two nodes of
20
- * the same width never receive the same permutation (which would
21
- * otherwise iterate them in lockstep — see CLAUDE.md's note on why a
22
- * constant phase offset isn't enough). Only consulted under `"cycle"`;
23
- * `"product"`'s mixed-radix decode already visits every combination,
24
- * so permuting there would only reorder identical output. Built in
25
- * `Enumerate.ts` (which can reach `Random/`), then threaded through
26
- * `plan()` as data — `Plan.ts` stays a total function and never
27
- * imports randomness.
17
+ * A fresh, reproducible permutation of `0..width-1` each call — one per
18
+ * width-`>1` node `plan()` visits, in walk order, so two nodes of the same
19
+ * width never receive the same permutation (which would otherwise iterate them
20
+ * in lockstep — see CLAUDE.md's note on why a constant phase offset isn't
21
+ * enough). Only consulted under `"cycle"`; `"product"`'s mixed-radix decode
22
+ * already visits every combination, so permuting there would only reorder
23
+ * identical output. Built in `Enumerate.ts` (which can reach `Random/`), then
24
+ * threaded through `plan()` as data `Plan.ts` stays a total function and
25
+ * never imports randomness.
28
26
  */
29
27
  export type Orderer = (width: bigint) => ReadonlyArray<bigint>;
30
28
  /**
31
- * Recipe for one enumerated combination against a built Fabricator
32
- * tree: `undefined` for a drawn (not chosen) node — fabricate
33
- * normally; `{ value }` for a literal (enum member, boolean, `null`,
34
- * `undefined`, `Omitted`); `{ slots }`/`{ fields }` for a
35
- * tuple/object, recursing per position/key; `{ branch, inner }` for a
36
- * choice's chosen option, or a presence wrapper's "present" arm,
37
- * recursing into whichever child was picked.
29
+ * Recipe for one enumerated combination against a built Fabricator tree:
30
+ * `undefined` for a drawn (not chosen) node — fabricate normally; `{ value }`
31
+ * for a literal (enum member, boolean, `null`, `undefined`, `Omitted`); `{
32
+ * slots }`/`{ fields }` for a tuple/object, recursing per position/key; `{
33
+ * branch, inner }` for a choice's chosen option, or a presence wrapper's
34
+ * "present" arm, recursing into whichever child was picked.
38
35
  */
39
36
  export type Pin = undefined | {
40
37
  value: unknown;
@@ -47,35 +44,33 @@ export type Pin = undefined | {
47
44
  inner: Pin;
48
45
  };
49
46
  /**
50
- * One enumerable dimension: how many distinct outcomes, and the `Pin`
51
- * for the `index`-th (`0 <= index < width`). Widths are `bigint` so a
52
- * schema with many combined axes can be counted exactly — a `number`
53
- * would silently lose precision past `Number.MAX_SAFE_INTEGER` and
54
- * eventually overflow to `Infinity`, which would make a combinatorial
55
- * limit's error message state a false count.
47
+ * One enumerable dimension: how many distinct outcomes, and the `Pin` for the
48
+ * `index`-th (`0 <= index < width`). Widths are `bigint` so a schema with many
49
+ * combined axes can be counted exactly — a `number` would silently lose
50
+ * precision past `Number.MAX_SAFE_INTEGER` and eventually overflow to
51
+ * `Infinity`, which would make a combinatorial limit's error message state a
52
+ * false count.
56
53
  */
57
54
  export type Axis = {
58
55
  readonly width: bigint;
59
56
  readonly at: (index: bigint) => Pin;
60
57
  };
61
58
  /**
62
- * Resolved, already-validated enumeration limits — `initialize()` is
63
- * where `limits.combinatorial` is defaulted and checked
64
- * (`Number.isSafeInteger(limit) && limit >= 1`), so `Enumerate()`
65
- * always receives a value it can trust without re-validating.
66
- * `coverage` carries no limit here: its count is the widest single
67
- * axis, linear in the schema as written rather than a product, so
59
+ * Resolved, already-validated enumeration limits — `initialize()` is where
60
+ * `limits.combinatorial` is defaulted and checked (`Number.isSafeInteger(limit)
61
+ * && limit >= 1`), so `Enumerate()` always receives a value it can trust
62
+ * without re-validating. `coverage` carries no limit here: its count is the
63
+ * widest single axis, linear in the schema as written rather than a product, so
68
64
  * there is nothing for a limit to protect against.
69
65
  */
70
66
  export type Limits = {
71
67
  combinatorial: number;
72
68
  };
73
69
  /**
74
- * The shape both `combinatorial` and `coverage` share — strategy and
75
- * limit differ internally, neither visible here. Takes a Schema, not
76
- * a built Fabricator: `AnySchema` excludes `Fabricator<any>` (which
77
- * carries no `[Produces]`), so `ValueOf` can't silently degrade to
78
- * `unknown`.
70
+ * The shape both `combinatorial` and `coverage` share — strategy and limit
71
+ * differ internally, neither visible here. Takes a Schema, not a built
72
+ * Fabricator: `AnySchema` excludes `Fabricator<any>` (which carries no
73
+ * `[Produces]`), so `ValueOf` can't silently degrade to `unknown`.
79
74
  */
80
75
  export type Enumerable = <const $Schema extends AnySchema>(schema: $Schema) => Iterable<ValueOf<$Schema>>;
81
76
  export type Resolvable = {
@@ -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,12 +46,12 @@ 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.
49
+ * `initialize({ attribution: { kind: "rooted", root } })` when `root` is not
50
+ * an absolute path or a `file://` URL. A relative root can never prefix a
51
+ * resolved caller file, so `relativize` would leave every file unchanged
52
+ * the option would look configured while silently doing nothing. Thrown
53
+ * eagerly at `initialize()`, not deferred to wherever that would first become
54
+ * observable.
56
55
  */
57
56
  class InvalidAttributionRootError extends FabricatorError {
58
57
  /**
@@ -66,9 +65,9 @@ export declare namespace FabricatorError {
66
65
  root: string);
67
66
  }
68
67
  /**
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.
68
+ * A `self` placeholder resolved with no `T.recursive` expanding around it
69
+ * only reachable by holding a `self` reference outside the `T.recursive(...)`
70
+ * callback it was handed to.
72
71
  */
73
72
  class DetachedSelfError extends FabricatorError {
74
73
  /**
@@ -82,36 +81,37 @@ export declare namespace FabricatorError {
82
81
  during: Phase);
83
82
  }
84
83
  /**
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.
84
+ * `T.recursive(body).whereby({ depth })` with no `terminal`, when `body` has
85
+ * a `self` that is not behind a kind that can stop recursing — a required
86
+ * object field, a tuple slot, the body itself, or a `choice` whose every
87
+ * option still contains `self`. Thrown at `.whereby()`, not at fabricate
88
+ * time. An explicit `terminal` is the way out.
90
89
  */
91
90
  class UnterminableRecursiveError extends FabricatorError {
92
91
  /**
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.
92
+ * Structural path from the recursive body to the unterminable `self` (or
93
+ * to the `choice` that had no remaining non-`self` option), as field
94
+ * names / slot indices.
96
95
  */
97
96
  readonly path: ReadonlyArray<string>;
98
97
  constructor(
99
98
  /**
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.
99
+ * Structural path from the recursive body to the unterminable `self` (or
100
+ * to the `choice` that had no remaining non-`self` option), as field
101
+ * names / slot indices.
103
102
  */
104
103
  path: ReadonlyArray<string>);
105
104
  }
106
105
  /**
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.
106
+ * A walk reached a node whose `[Kind]` it has no case for — a Schema built by
107
+ * hand or cast past the type system, or a kind added to `Primitive/index.ts`
108
+ * without wiring it into every dispatch site.
110
109
  */
111
110
  class UnknownKindError extends FabricatorError {
112
111
  /**
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.
112
+ * The unrecognized `[Kind]` tag, stringified — it may be any value at
113
+ * all, since reaching this error means the type system was already
114
+ * bypassed.
115
115
  */
116
116
  readonly kind: string;
117
117
  /**
@@ -120,8 +120,9 @@ export declare namespace FabricatorError {
120
120
  readonly during: Phase;
121
121
  constructor(
122
122
  /**
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.
123
+ * The unrecognized `[Kind]` tag, stringified — it may be any value at
124
+ * all, since reaching this error means the type system was already
125
+ * bypassed.
125
126
  */
126
127
  kind: string,
127
128
  /**
@@ -154,10 +155,9 @@ export declare namespace FabricatorError {
154
155
  noun: string);
155
156
  }
156
157
  /**
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).
158
+ * An object's definition names a key that would reach `Object.prototype` — a
159
+ * developer-written key, where throwing is actionable (contrast `record`'s
160
+ * _drawn_ keys, written with `Object.defineProperty` instead of rejected).
161
161
  */
162
162
  class PrototypePollutionError extends FabricatorError {
163
163
  /**
@@ -179,8 +179,8 @@ export declare namespace FabricatorError {
179
179
  constructor();
180
180
  }
181
181
  /**
182
- * A `.refine()`-computed field's resolver returned a value of the wrong
183
- * shape for the source schema it was declared against.
182
+ * A `.refine()`-computed field's resolver returned a value of the wrong shape
183
+ * for the source schema it was declared against.
184
184
  */
185
185
  class ComputeResultMismatchError extends FabricatorError {
186
186
  /**
@@ -202,8 +202,8 @@ export declare namespace FabricatorError {
202
202
  value: unknown);
203
203
  }
204
204
  /**
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.
205
+ * An override names a field the object schema does not define — most often a
206
+ * typo, which is why the known fields are listed.
207
207
  */
208
208
  class UnknownOverrideFieldError extends FabricatorError {
209
209
  /**
@@ -225,8 +225,8 @@ export declare namespace FabricatorError {
225
225
  available: ReadonlyArray<string>);
226
226
  }
227
227
  /**
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
228
+ * An override value does not fit the field it is meant to replace. Raised for
229
+ * every field shape — a plain field, a nested object, and each presence
230
230
  * wrapper unwrapped to its inner kind — the same failure in each case.
231
231
  */
232
232
  class InvalidOverrideValueError extends FabricatorError {
@@ -236,7 +236,7 @@ export declare namespace FabricatorError {
236
236
  readonly field: string;
237
237
  /**
238
238
  * 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
239
+ * _inner_ kind, since the wrapper's own absent/null outcomes are accepted
240
240
  * separately.
241
241
  */
242
242
  readonly kind: string;
@@ -251,7 +251,7 @@ export declare namespace FabricatorError {
251
251
  field: string,
252
252
  /**
253
253
  * 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
254
+ * _inner_ kind, since the wrapper's own absent/null outcomes are accepted
255
255
  * separately.
256
256
  */
257
257
  kind: string,
@@ -261,9 +261,8 @@ export declare namespace FabricatorError {
261
261
  value: unknown);
262
262
  }
263
263
  /**
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.
264
+ * Thrown when `Omitted` is passed to override a field that has no absent
265
+ * outcome. Only `T.omittable`/`T.optional` fields can be forced off.
267
266
  */
268
267
  class IllegalOmittedOverrideError extends FabricatorError {
269
268
  /**
@@ -310,8 +309,8 @@ export declare namespace FabricatorError {
310
309
  width: bigint);
311
310
  }
312
311
  /**
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.
312
+ * `resolve()` handed a pin for a kind `plan()` never produces one for — the
313
+ * two must stay in agreement; internal invariant, not caller-reachable.
315
314
  */
316
315
  class UnpinnableKindError extends FabricatorError {
317
316
  /**
@@ -352,8 +351,8 @@ export declare namespace FabricatorError {
352
351
  }
353
352
  /**
354
353
  * 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.
354
+ * being adapted to — a symbol key, for TypeBox, whose `Type.Record` silently
355
+ * yields a schema nothing can satisfy rather than raising.
357
356
  */
358
357
  class UnrepresentableRecordKeyError extends FabricatorError {
359
358
  /**
@@ -367,10 +366,10 @@ export declare namespace FabricatorError {
367
366
  kind: string);
368
367
  }
369
368
  /**
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).
369
+ * A `{ min, max }` range contains no fabricable value — inverted bounds, a
370
+ * point range with an exclusive end, or a discrete exclusive pair whose
371
+ * effective integers are none. Thrown at `.whereby()` (or at construction for
372
+ * `T.date.past`/`future`, whose other end is the instance clock).
374
373
  */
375
374
  class EmptyRangeError extends FabricatorError {
376
375
  /**
@@ -413,8 +412,8 @@ export declare namespace FabricatorError {
413
412
  }
414
413
  /**
415
414
  * 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.
415
+ * distribution's density is proportional to `1/x`, so it is undefined at or
416
+ * below zero.
418
417
  */
419
418
  class InvalidDistributionBoundError extends FabricatorError {
420
419
  /**
@@ -444,8 +443,8 @@ export declare namespace FabricatorError {
444
443
  max: number);
445
444
  }
446
445
  /**
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.
446
+ * Which entry of a `.weighted(...)` call carried the bad weight: a position
447
+ * in a caller-supplied list, or one of a fixed, named outcome set.
449
448
  */
450
449
  type WeightEntry = {
451
450
  readonly kind: "index";
@@ -456,10 +455,10 @@ export declare namespace FabricatorError {
456
455
  readonly name: string;
457
456
  };
458
457
  /**
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}.
458
+ * A `.weighted(...)` call gives an outcome a weight that is not expressible:
459
+ * negative, `NaN`, or `Infinity`. Zero is valid — it disables the outcome —
460
+ * so this is not "anything `weighted()` would drop." An empty drawable set is
461
+ * {@link NoDrawableOutcomesError}.
463
462
  */
464
463
  class InvalidWeightError extends FabricatorError {
465
464
  /**
@@ -489,9 +488,9 @@ export declare namespace FabricatorError {
489
488
  entry: WeightEntry);
490
489
  }
491
490
  /**
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.
491
+ * A weighted draw table has nothing left to pick: every weight is zero (or
492
+ * the list was empty of drawable entries). Zeroing an outcome disables it, so
493
+ * at least one must keep a positive weight.
495
494
  */
496
495
  class NoDrawableOutcomesError extends FabricatorError {
497
496
  /**
@@ -515,9 +514,9 @@ export declare namespace FabricatorError {
515
514
  noun: string);
516
515
  }
517
516
  /**
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.
517
+ * `new Fabricator(schema, trace)` when `trace.kind` names a different kind
518
+ * than `schema`. A trace reproduces the node it was taken from, so its kind
519
+ * must match the schema it is replayed against.
521
520
  */
522
521
  class TraceKindMismatchError extends FabricatorError {
523
522
  /**
@@ -538,4 +537,23 @@ export declare namespace FabricatorError {
538
537
  */
539
538
  given: string);
540
539
  }
540
+ /**
541
+ * `wrap(overlay, block)` handed an `async` block while the lineage's ambient
542
+ * carrier is the synchronous one (`Instance/Stack/Sync.ts`).
543
+ *
544
+ * Its frame cannot outlive the block's first `await`, so a build reached
545
+ * after one would resolve against the base instance rather than the wrap —
546
+ * plausible data, quietly drawn from the wrong configuration. Raised instead
547
+ * of allowing that, which is why it fires even when `block` only ever uses
548
+ * `scope`: whether a later build reads the ambient frame is not knowable from
549
+ * here.
550
+ *
551
+ * Reachable only where `#stack` resolved to `default` — a runtime with no
552
+ * `node:async_hooks`, in practice a browser bundle — or where `initialize({
553
+ * stack })` supplied a synchronous carrier explicitly. Node, Bun, and Deno
554
+ * all resolve to the `AsyncLocalStorage` carrier and never raise this.
555
+ */
556
+ class SynchronousStackError extends FabricatorError {
557
+ constructor();
558
+ }
541
559
  }
@@ -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
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, { seed
15
+ * })` to pin this one build to an explicit seed, independent of the file it's
17
16
  * constructed in (see `construct()` for what `options.seed` 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
+ * seed/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;