@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
@@ -1,43 +1,41 @@
1
1
  import type { Adaptation, Meta } from "../Types";
2
2
  /**
3
- * One adapter's override for one schema, *as stored* in `[Adaptation]` —
4
- * the loosest signature the mechanism needs. An adapter states its real
5
- * return type on {@link Adapter.convert}, and `.adapt(...)` checks a
6
- * supplied adaptation against that; nothing here reads either end.
3
+ * One adapter's override for one schema, _as stored_ in `[Adaptation]` — the
4
+ * loosest signature the mechanism needs. An adapter states its real return type
5
+ * on {@link Adapter.convert}, and `.adapt(...)` checks a supplied adaptation
6
+ * against that; nothing here reads either end.
7
7
  *
8
- * Not the shape a caller writes: a kind's `.adapt(...)` takes a producer
9
- * of {@link Adapting}, which `Adapter/Core.ts`'s `withAdaptations`/
10
- * `mergeAdaptations` wrap into this one entry point-side. The stored
11
- * form stays schema-taking so `patched`/`layer` treat an incoming
12
- * producer and a prior layered entry as one type, and so
13
- * `AdaptationEntry`'s `(schema: any) => $Returnable` is an accurate
14
- * account of what a schema carries.
8
+ * Not the shape a caller writes: a kind's `.adapt(...)` takes a producer of
9
+ * {@link Adapting}, which `Adapter/Core.ts`'s `withAdaptations`/
10
+ * `mergeAdaptations` wrap into this one entry point-side. The stored form stays
11
+ * schema-taking so `patched`/`layer` treat an incoming producer and a prior
12
+ * layered entry as one type, and so `AdaptationEntry`'s `(schema: any) =>
13
+ * $Returnable` is an accurate account of what a schema carries.
15
14
  */
16
15
  export type SchemaAdaptation = (schema: any) => unknown;
17
16
  /**
18
- * What a kind's `.adapt(adapter, produce)` hands its producer: the schema
19
- * being adapted, and that schema's `[Meta]` — one object rather than two
20
- * parameters, so destructuring picks whichever half is needed and neither
21
- * is reachable only through a well-known symbol.
17
+ * What a kind's `.adapt(adapter, produce)` hands its producer: the schema being
18
+ * adapted, and that schema's `[Meta]` — one object rather than two parameters,
19
+ * so destructuring picks whichever half is needed and neither is reachable only
20
+ * through a well-known symbol.
22
21
  *
23
- * `schema` carries whichever adaptation for this same adapter it
24
- * replaced, absent at the bottom of the stack (see `Adapter/Core.ts`'s
25
- * `layer`) — so `toTypeBox(schema)` inside a producer resolves to the
26
- * previous layer, or to the kind's ordinary mapping when there is none.
27
- * `meta` is read off that same substituted schema, so the two keys
28
- * describe one object.
22
+ * `schema` carries whichever adaptation for this same adapter it replaced,
23
+ * absent at the bottom of the stack (see `Adapter/Core.ts`'s `layer`) — so
24
+ * `toTypeBox(schema)` inside a producer resolves to the previous layer, or to
25
+ * the kind's ordinary mapping when there is none. `meta` is read off that same
26
+ * substituted schema, so the two keys describe one object.
29
27
  *
30
- * `meta`'s shape is the kind's own config blob, derived by indexed
31
- * access rather than named separately so no kind states its own `Meta`
32
- * twice in an `adapt` signature. **Readable but not stabilized**: an
33
- * adaptation may read it; a kind stays free to restructure it — nothing
34
- * outside a kind's own files should *interpret* another kind's `[Meta]`.
28
+ * `meta`'s shape is the kind's own config blob, derived by indexed access
29
+ * rather than named separately so no kind states its own `Meta` twice in an
30
+ * `adapt` signature. **Readable but not stabilized**: an adaptation may read
31
+ * it; a kind stays free to restructure it — nothing outside a kind's own files
32
+ * should _interpret_ another kind's `[Meta]`.
35
33
  *
36
34
  * A kind with no bare-form default carries no `[Meta]` at runtime until
37
35
  * configured (`string`/`bigint`'s registry exports — see "Anatomy of a
38
- * primitive"), so `meta` can be `undefined` there despite this type.
39
- * Same imprecision `Schema<$Meta>` already states, and why the TypeBox
40
- * adapter reads `[Meta]` defensively for those kinds.
36
+ * primitive"), so `meta` can be `undefined` there despite this type. Same
37
+ * imprecision `Schema<$Meta>` already states, and why the TypeBox adapter reads
38
+ * `[Meta]` defensively for those kinds.
41
39
  */
42
40
  export type Adapting<$Schema extends {
43
41
  [Meta]: unknown;
@@ -46,70 +44,64 @@ export type Adapting<$Schema extends {
46
44
  readonly meta: $Schema[typeof Meta];
47
45
  };
48
46
  /**
49
- * What a Schema's `[Adaptation]` holds: each adapter's override, under
50
- * that adapter's own key.
47
+ * What a Schema's `[Adaptation]` holds: each adapter's override, under that
48
+ * adapter's own key.
51
49
  *
52
- * Open rather than a closed registry of known libraries: an adapter is
53
- * a value (see {@link Adapter}), not a name this package knows. Nothing
54
- * has to be declared for a third party's adapter to work, and two
55
- * adapters for different versions of the same library collide with
56
- * nothing.
50
+ * Open rather than a closed registry of known libraries: an adapter is a value
51
+ * (see {@link Adapter}), not a name this package knows. Nothing has to be
52
+ * declared for a third party's adapter to work, and two adapters for different
53
+ * versions of the same library collide with nothing.
57
54
  */
58
55
  export type Adaptations = {
59
56
  readonly [key: string]: SchemaAdaptation;
60
57
  };
61
58
  /**
62
59
  * An {@link Adaptations} update as `withAdaptations` accepts it. Identical
63
- * except that an explicitly-`undefined` entry *removes* that adapter's
64
- * override — how the layering hands an adaptation the schema it is
65
- * adapting with its own entry replaced by the previous one, or absent
66
- * at the bottom of the stack.
60
+ * except that an explicitly-`undefined` entry _removes_ that adapter's override
61
+ * — how the layering hands an adaptation the schema it is adapting with its own
62
+ * entry replaced by the previous one, or absent at the bottom of the stack.
67
63
  *
68
- * Not what a kind's `.adapt(...)` accepts: removal is an internal need
69
- * of the layering, and letting a caller express it would produce a
70
- * `[Adaptation]` type that `exactOptionalPropertyTypes` rejects against
71
- * {@link Adaptations}.
64
+ * Not what a kind's `.adapt(...)` accepts: removal is an internal need of the
65
+ * layering, and letting a caller express it would produce a `[Adaptation]` type
66
+ * that `exactOptionalPropertyTypes` rejects against {@link Adaptations}.
72
67
  */
73
68
  export type Patch = {
74
69
  readonly [key: string]: SchemaAdaptation | undefined;
75
70
  };
76
71
  /**
77
72
  * How an adapter recurses into a nested schema — handed to
78
- * {@link Adapter.convert} by `Adapter/Core.ts`'s `drive` rather than
79
- * being the adapter's own private recursion, so every nested node goes
80
- * back through the adaptation lookup, not only the outermost one.
73
+ * {@link Adapter.convert} by `Adapter/Core.ts`'s `drive` rather than being the
74
+ * adapter's own private recursion, so every nested node goes back through the
75
+ * adaptation lookup, not only the outermost one.
81
76
  *
82
- * `$Context` is the adapter's own, and opaque here: an adapter that
83
- * needs to carry something down its recursion (the enclosing
84
- * `T.recursive`'s placeholder, say) threads it through unchanged.
85
- * `$Returnable` is likewise the adapter's own — stated so a nested
86
- * node's result drops straight into a composite
87
- * (`Type.Array(recurse(element, context))`) with no cast at any call
77
+ * `$Context` is the adapter's own, and opaque here: an adapter that needs to
78
+ * carry something down its recursion (the enclosing `T.recursive`'s
79
+ * placeholder, say) threads it through unchanged. `$Returnable` is likewise the
80
+ * adapter's own — stated so a nested node's result drops straight into a
81
+ * composite (`Type.Array(recurse(element, context))`) with no cast at any call
88
82
  * site.
89
83
  */
90
84
  export type Recurse<$Context, $Returnable> = (schema: any, context: $Context) => $Returnable;
91
85
  /**
92
- * An adapter to one external schema library: a plain value, imported
93
- * directly by whoever adapts a schema (`schema.adapt(typebox, ...)`)
94
- * and by whoever converts one. Nothing to register — no global
95
- * interface to declaration-merge, and no name chosen anywhere but here.
86
+ * An adapter to one external schema library: a plain value, imported directly
87
+ * by whoever adapts a schema (`schema.adapt(typebox, ...)`) and by whoever
88
+ * converts one. Nothing to register — no global interface to declaration-merge,
89
+ * and no name chosen anywhere but here.
96
90
  *
97
- * `key` is the adapter's `[Adaptation]` namespace. Read off the value
98
- * as a literal type, so a wrong one is an import error rather than an
99
- * entry nothing looks up. Give it something collision-proof — a package
100
- * specifier, versioned when a library's major rewrite means two
101
- * adapters can coexist.
91
+ * `key` is the adapter's `[Adaptation]` namespace. Read off the value as a
92
+ * literal type, so a wrong one is an import error rather than an entry nothing
93
+ * looks up. Give it something collision-proof — a package specifier, versioned
94
+ * when a library's major rewrite means two adapters can coexist.
102
95
  *
103
- * `convert`'s declared return type is this adapter's external bound:
104
- * the type every `.adapt(...)` against it must produce, and why an
105
- * adaptation that returns the wrong thing fails at the call site.
96
+ * `convert`'s declared return type is this adapter's external bound: the type
97
+ * every `.adapt(...)` against it must produce, and why an adaptation that
98
+ * returns the wrong thing fails at the call site.
106
99
  *
107
- * Deliberately *not* carrying the adapter's type-level mapping. An
108
- * adapter package declares its own conversion entry point with its own
109
- * return type (`toTypeBox<$S>(schema: $S): ToTypeBox<$S>`), so nothing
110
- * has to compute a type-level mapping out of a stored value — which
111
- * would need the interface-member-lookup encoding `ValueOf`'s
112
- * `$Bindings` uses, for no gain.
100
+ * Deliberately _not_ carrying the adapter's type-level mapping. An adapter
101
+ * package declares its own conversion entry point with its own return type
102
+ * (`toTypeBox<$S>(schema: $S): ToTypeBox<$S>`), so nothing has to compute a
103
+ * type-level mapping out of a stored value — which would need the
104
+ * interface-member-lookup encoding `ValueOf`'s `$Bindings` uses, for no gain.
113
105
  */
114
106
  export interface Adapter<$Key extends string = string, $Context = unknown, $Returnable = unknown> {
115
107
  readonly key: $Key;
@@ -119,27 +111,25 @@ export interface Adapter<$Key extends string = string, $Context = unknown, $Retu
119
111
  * The adaptations a Schema (or a built Fabricator, which carries them
120
112
  * identically) declares, or `{}` for one that declares none.
121
113
  *
122
- * The two steps — extract the map, then match against it — are
123
- * load-bearing, and why no adapter matches
124
- * `{ [Adaptation]?: Record<Key, ...> }` directly. Every kind's `Core`
125
- * declares `[Adaptation]` as *optional*, and a conditional matching an
126
- * optional property against a schema that lacks it entirely still
127
- * *succeeds*, inferring `unknown` (the same behavior `ValueOf` relies
128
- * on for `[Produces]`) so a direct match would resolve every
129
- * unadapted schema to whatever the adapter's adaptation branch
130
- * produces. Constraining the `infer` sends that case here, to `{}`,
131
- * which then fails each adapter's `Record<Key, ...>` check as it
132
- * should.
114
+ * The two steps — extract the map, then match against it — are load-bearing,
115
+ * and why no adapter matches `{ [Adaptation]?: Record<Key, ...> }` directly.
116
+ * Every kind's `Core` declares `[Adaptation]` as _optional_, and a conditional
117
+ * matching an optional property against a schema that lacks it entirely still
118
+ * _succeeds_, inferring `unknown` (the same behavior `ValueOf` relies on for
119
+ * `[Produces]`) so a direct match would resolve every unadapted schema to
120
+ * whatever the adapter's adaptation branch produces. Constraining the `infer`
121
+ * sends that case here, to `{}`, which then fails each adapter's `Record<Key,
122
+ * ...>` check as it should.
133
123
  */
134
124
  export type AdaptationsOf<$Schema> = $Schema extends {
135
125
  [Adaptation]?: infer $Adaptations extends Adaptations;
136
126
  } ? $Adaptations : {};
137
127
  /**
138
- * `$Prior` with `$Map` applied: an adapter named in `$Map` takes its new
139
- * entry; one it doesn't name is carried forward. `Omit` first (rather
140
- * than a plain `$Prior & $Map`) so a replaced entry is genuinely
141
- * replaced — intersecting two call signatures for the same adapter
142
- * would produce an overload, from which an adapter's `infer` would
143
- * read whichever member TypeScript happens to resolve last.
128
+ * `$Prior` with `$Map` applied: an adapter named in `$Map` takes its new entry;
129
+ * one it doesn't name is carried forward. `Omit` first (rather than a plain
130
+ * `$Prior & $Map`) so a replaced entry is genuinely replaced — intersecting two
131
+ * call signatures for the same adapter would produce an overload, from which an
132
+ * adapter's `infer` would read whichever member TypeScript happens to resolve
133
+ * last.
144
134
  */
145
135
  export type WithAdaptations<$Prior extends Adaptations, $Map extends Adaptations> = Omit<$Prior, keyof $Map> & $Map;
@@ -1,16 +1,16 @@
1
1
  /**
2
2
  * Canonical endpoint stored on `[Meta].whereby`. Call sites still accept a
3
- * scalar (inclusive) via {@link InputBound}; `.whereby()` runs {@link toBound}
4
- * so adapters always see this shape — never a scalar/object union.
3
+ * scalar (inclusive) via {@link InputBound}; `.whereby()` runs {@link toBound} so
4
+ * adapters always see this shape — never a scalar/object union.
5
5
  */
6
6
  export type Bound<$T> = {
7
7
  value: $T;
8
8
  exclusive: boolean;
9
9
  };
10
10
  /**
11
- * What `.whereby({ min, max })` accepts: a scalar is inclusive, an object
12
- * names an endpoint policy. `exclusive` is required on the object form so
13
- * that form exists only to state one.
11
+ * What `.whereby({ min, max })` accepts: a scalar is inclusive, an object names
12
+ * an endpoint policy. `exclusive` is required on the object form so that form
13
+ * exists only to state one.
14
14
  */
15
15
  export type InputBound<$T> = $T | Bound<$T>;
16
16
  /**
@@ -20,8 +20,8 @@ export type InputBound<$T> = $T | Bound<$T>;
20
20
  */
21
21
  export declare function toBound<$T>(input: InputBound<$T>): Bound<$T>;
22
22
  /**
23
- * Inclusive integer interval implied by a discrete Bound pair. Exclusive min
24
- * is `value + 1`, exclusive max is `value - 1` — the same unit the length/
23
+ * Inclusive integer interval implied by a discrete Bound pair. Exclusive min is
24
+ * `value + 1`, exclusive max is `value - 1` — the same unit the length/
25
25
  * integer/bigint draws already use. Empty iff `min > max`.
26
26
  */
27
27
  export declare function effectiveDiscrete(min: Bound<number>, max: Bound<number>): {
@@ -37,15 +37,15 @@ export declare function assertNonemptyDiscreteBigint(label: string, min: Bound<b
37
37
  /**
38
38
  * Continuous emptiness: inverted bounds, a point range with either end
39
39
  * exclusive, or both ends exclusive with no float strictly between them.
40
- * Sampling still uses the closed interval and {@link constrainContinuous}
41
- * steps off an exclusive endpoint — this check is what makes that step
42
- * always have somewhere to land.
40
+ * Sampling still uses the closed interval and {@link constrainContinuous} steps
41
+ * off an exclusive endpoint — this check is what makes that step always have
42
+ * somewhere to land.
43
43
  */
44
44
  export declare function assertNonemptyContinuous(label: string, min: Bound<number>, max: Bound<number>): void;
45
45
  /**
46
- * One ulp toward `toward` from `value`. Approximate, and enough to leave
47
- * an exclusive endpoint without rejection-looping a truncated distribution
48
- * that clamped onto it.
46
+ * One ulp toward `toward` from `value`. Approximate, and enough to leave an
47
+ * exclusive endpoint without rejection-looping a truncated distribution that
48
+ * clamped onto it.
49
49
  */
50
50
  export declare function towardInterior(value: number, toward: number): number;
51
51
  /**
@@ -56,8 +56,8 @@ export declare function towardInterior(value: number, toward: number): number;
56
56
  export declare function constrainContinuous(next: () => number, min: Bound<number>, max: Bound<number>): () => number;
57
57
  export declare function epochBound(bound: Bound<Date>): Bound<number>;
58
58
  /**
59
- * Array/string `length`: a bare number is an exact count; an omitted `min`
60
- * is inclusive `0`. Always stored as a Bound pair so adapters have one path.
59
+ * Array/string `length`: a bare number is an exact count; an omitted `min` is
60
+ * inclusive `0`. Always stored as a Bound pair so adapters have one path.
61
61
  */
62
62
  export declare function toLengthRange(length: number | {
63
63
  max: InputBound<number>;
@@ -1,13 +1,12 @@
1
1
  import type { Stream } from "../Random/Types";
2
2
  /**
3
- * How randomly generated values cluster within a `{ min, max }` range.
4
- * Without one, generation is uniform — every value in the range is
5
- * equally likely.
3
+ * How randomly generated values cluster within a `{ min, max }` range. Without
4
+ * one, generation is uniform — every value in the range is equally likely.
6
5
  *
7
- * Each variant is a tagged object so distributions stay
8
- * introspectable and serializable. The `custom` variant is the escape
9
- * hatch: a shaping function `(u) => p` mapping a uniform draw in
10
- * `[0, 1)` to a position in `[0, 1)` within the range.
6
+ * Each variant is a tagged object so distributions stay introspectable and
7
+ * serializable. The `custom` variant is the escape hatch: a shaping function
8
+ * `(u) => p` mapping a uniform draw in `[0, 1)` to a position in `[0, 1)`
9
+ * within the range.
11
10
  */
12
11
  export type Distribution = Distribution.Uniform | Distribution.Normal | Distribution.Skew | Distribution.Triangular | Distribution.Logarithmic | Distribution.Multi | Distribution.Custom;
13
12
  export type Range = {
@@ -25,9 +24,9 @@ export declare namespace Distribution {
25
24
  spread?: number | undefined;
26
25
  };
27
26
  /**
28
- * Bell curve truncated to the range. `mean` defaults to the range's
29
- * center; `spread` (standard deviation) defaults to a sixth of the
30
- * span, placing the bounds at roughly ±3σ before truncation.
27
+ * Bell curve truncated to the range. `mean` defaults to the range's center;
28
+ * `spread` (standard deviation) defaults to a sixth of the span, placing the
29
+ * bounds at roughly ±3σ before truncation.
31
30
  */
32
31
  const normal: (params?: {
33
32
  mean?: number;
@@ -38,8 +37,8 @@ export declare namespace Distribution {
38
37
  exponent: number;
39
38
  };
40
39
  /**
41
- * Power curve. `exponent > 1` biases toward `min`, `exponent < 1`
42
- * biases toward `max`, and `exponent === 1` is uniform.
40
+ * Power curve. `exponent > 1` biases toward `min`, `exponent < 1` biases
41
+ * toward `max`, and `exponent === 1` is uniform.
43
42
  */
44
43
  const skew: (exponent: number) => Distribution;
45
44
  type Triangular = {
@@ -56,10 +55,9 @@ export declare namespace Distribution {
56
55
  kind: "logarithmic";
57
56
  };
58
57
  /**
59
- * Log-uniform (reciprocal): density proportional to `1/x`, so values
60
- * spread evenly across orders of magnitude and cluster toward `min`.
61
- * Requires a strictly positive range — the logarithm is undefined at
62
- * or below zero.
58
+ * Log-uniform (reciprocal): density proportional to `1/x`, so values spread
59
+ * evenly across orders of magnitude and cluster toward `min`. Requires a
60
+ * strictly positive range — the logarithm is undefined at or below zero.
63
61
  */
64
62
  const logarithmic: () => Distribution;
65
63
  type Multi = {
@@ -70,11 +68,10 @@ export declare namespace Distribution {
70
68
  }>;
71
69
  };
72
70
  /**
73
- * A weighted blend of component distributions, each drawn over the
74
- * same range. Localized components with distinct centers (e.g. two
75
- * `normal`s at different means) produce the separate peaks of a
76
- * multimodal distribution. Weights are relative — they need not sum
77
- * to 1.
71
+ * A weighted blend of component distributions, each drawn over the same
72
+ * range. Localized components with distinct centers (e.g. two `normal`s at
73
+ * different means) produce the separate peaks of a multimodal distribution.
74
+ * Weights are relative — they need not sum to 1.
78
75
  */
79
76
  const multi: (components: ReadonlyArray<{
80
77
  weight: number;
@@ -85,73 +82,69 @@ export declare namespace Distribution {
85
82
  shape: (u: number) => number;
86
83
  };
87
84
  /**
88
- * Escape hatch: `shape` maps a uniform draw in `[0, 1)` to a
89
- * position in `[0, 1)` within the range (an inverse CDF). The output
90
- * is clamped to `[0, 1]` so the result always lands within the
91
- * bounds.
85
+ * Escape hatch: `shape` maps a uniform draw in `[0, 1)` to a position in `[0,
86
+ * 1)` within the range (an inverse CDF). The output is clamped to `[0, 1]` so
87
+ * the result always lands within the bounds.
92
88
  */
93
89
  const custom: (shape: (u: number) => number) => Distribution;
94
90
  }
95
91
  /**
96
- * Build a sampler that draws values within `range` following
97
- * `distribution`. Each call consumes one fresh uniform draw and, by
98
- * construction, returns a value within `[min, max]` — distributions
99
- * with mass outside the range (e.g. a normal's tails) are truncated
100
- * via their inverse CDF rather than rejected or clamped.
92
+ * Build a sampler that draws values within `range` following `distribution`.
93
+ * Each call consumes one fresh uniform draw and, by construction, returns a
94
+ * value within `[min, max]` — distributions with mass outside the range (e.g. a
95
+ * normal's tails) are truncated via their inverse CDF rather than rejected or
96
+ * clamped.
101
97
  */
102
98
  export declare function sampler(distribution: Distribution, range: Range, stream: Stream): () => number;
103
99
  export declare function sample<$T>(list: ReadonlyArray<$T>, stream: Stream): $T;
104
100
  /**
105
101
  * Fisher–Yates (Durstenfeld) shuffle: a new array holding `items` in a
106
- * uniformly random order — every permutation is equally likely. Does
107
- * not mutate `items`, matching `sample`/`weighted`'s read-only
108
- * convention.
102
+ * uniformly random order — every permutation is equally likely. Does not mutate
103
+ * `items`, matching `sample`/`weighted`'s read-only convention.
109
104
  */
110
105
  export declare function shuffle<$T>(items: ReadonlyArray<$T>, stream: Stream): $T[];
111
106
  /**
112
- * `weighted()`'s own inclusion rule: whether this entry stays in the
113
- * draw table. `0` is valid and disables the outcome; negative/`NaN`
114
- * are rejected earlier by {@link isValidWeight}. Exposed so
115
- * `Enumeration/Plan.ts` and the construction guards share one
116
- * definition of "will this be drawn" rather than each writing
117
- * `weight > 0`.
107
+ * `weighted()`'s own inclusion rule: whether this entry stays in the draw
108
+ * table. `0` is valid and disables the outcome; negative/`NaN` are rejected
109
+ * earlier by {@link isValidWeight}. Exposed so `Enumeration/Plan.ts` and the
110
+ * construction guards share one definition of "will this be drawn" rather than
111
+ * each writing `weight > 0`.
118
112
  */
119
113
  export declare function isDrawable(weight: number): boolean;
120
114
  /**
121
- * Whether a weight is *expressible* at all, as opposed to whether it is
122
- * drawable. `0` is valid and disables the outcome; a negative weight or
123
- * `NaN` is a mistake. `Infinity` is rejected because it cannot be summed
124
- * into a usable draw table — every cumulative bound becomes `Infinity`,
125
- * so `weighted()`'s `x < weight` scan matches nothing.
115
+ * Whether a weight is _expressible_ at all, as opposed to whether it is
116
+ * drawable. `0` is valid and disables the outcome; a negative weight or `NaN`
117
+ * is a mistake. `Infinity` is rejected because it cannot be summed into a
118
+ * usable draw table — every cumulative bound becomes `Infinity`, so
119
+ * `weighted()`'s `x < weight` scan matches nothing.
126
120
  */
127
121
  export declare function isValidWeight(weight: number): boolean;
128
122
  /**
129
- * Outcomes that still have a positive weight after applying the
130
- * baseline of `1` for any unspecified (missing or explicitly
131
- * `undefined`) key. The one home of that `?? 1` default, so
132
- * `assertDrawableKeyedWeights` and `Enumeration/Plan.ts` cannot drift.
123
+ * Outcomes that still have a positive weight after applying the baseline of `1`
124
+ * for any unspecified (missing or explicitly `undefined`) key. The one home of
125
+ * that `?? 1` default, so `assertDrawableKeyedWeights` and
126
+ * `Enumeration/Plan.ts` cannot drift.
133
127
  */
134
128
  export declare function drawableOutcomes<$Outcome extends string>(outcomes: ReadonlyArray<$Outcome>, weights: Readonly<Record<string, number | undefined>> | undefined): ReadonlyArray<$Outcome>;
135
129
  /**
136
- * Two-stage guard for a `[weight, item]` list (`enum`/`choice`'s
137
- * `.weighted()` registries). Stage 1 rejects any entry that is not
138
- * {@link isValidWeight}; stage 2 rejects a list with no
139
- * {@link isDrawable} entry left. `label` names the call site
140
- * (`"T.enum.weighted"`/`"T.choice.weighted"`), `noun` the kind of
130
+ * Two-stage guard for a `[weight, item]` list (`enum`/`choice`'s `.weighted()`
131
+ * registries). Stage 1 rejects any entry that is not {@link isValidWeight};
132
+ * stage 2 rejects a list with no {@link isDrawable} entry left. `label` names
133
+ * the call site (`"T.enum.weighted"`/`"T.choice.weighted"`), `noun` the kind of
141
134
  * entry (`"member"`/`"option"`).
142
135
  */
143
136
  export declare function assertDrawableWeights(label: string, noun: string, items: ReadonlyArray<readonly [number, unknown]>): void;
144
137
  /**
145
- * The same two-stage guard as {@link assertDrawableWeights}, for the
146
- * kinds whose `.weighted(...)` weighs a *fixed, named* outcome set
147
- * (`boolean`'s `true`/`false`; `nullable`/`nullish`/`undefinable`/
138
+ * The same two-stage guard as {@link assertDrawableWeights}, for the kinds
139
+ * whose `.weighted(...)` weighs a _fixed, named_ outcome set (`boolean`'s
140
+ * `true`/`false`; `nullable`/`nullish`/`undefinable`/
148
141
  * `object.omittable`/`object.optional`'s presence outcomes) rather than a
149
- * caller-supplied list. Stage 2 must see the kind's **full** outcome list
150
- * — an omitted key still defaults to `1` — hence `outcomes`.
142
+ * caller-supplied list. Stage 2 must see the kind's **full** outcome list — an
143
+ * omitted key still defaults to `1` — hence `outcomes`.
151
144
  *
152
- * An explicitly-`undefined` value means "unspecified" — `Weights`'
153
- * keys are all optional and fall back to a baseline of `1` — so it is
154
- * skipped in stage 1 and defaulted in stage 2.
145
+ * An explicitly-`undefined` value means "unspecified" — `Weights`' keys are all
146
+ * optional and fall back to a baseline of `1` — so it is skipped in stage 1 and
147
+ * defaulted in stage 2.
155
148
  */
156
149
  export declare function assertDrawableKeyedWeights<$Outcome extends string>(label: string, outcomes: ReadonlyArray<$Outcome>, weights: Readonly<Record<string, number | undefined>>): void;
157
150
  export declare function weighted<const $Item>(weights: ReadonlyArray<readonly [number, $Item]>, stream: Stream, label: string): () => $Item;
@@ -2,32 +2,30 @@ import type { Stack } from "../Instance/Types";
2
2
  import type { RandomSource } from "../Random/Types";
3
3
  import type { Enumerable, Limits } from "./Types";
4
4
  /**
5
- * Typed `combinatorial`/`coverage` boundary, closing over one
6
- * instance's `source` and its already-validated `limits` — same shape
7
- * as `Constructor(source, stack)`. No separate `clock`: `source`
8
- * already carries its resolved clock (`Random/Types.ts`'s
9
- * `Options.clock`), so `Constructor`'s `toConstructionContext` reads
10
- * it off whichever root a construction resolves against. `plan`/
11
- * `resolve` (`./Plan.ts`) do the untyped recursive work; this is the
12
- * one precisely-typed layer, mirroring `Constructor.ts`'s `make`/
5
+ * Typed `combinatorial`/`coverage` boundary, closing over one instance's
6
+ * `source` and its already-validated `limits` — same shape as
7
+ * `Constructor(source, stack)`. No separate `clock`: `source` already carries
8
+ * its resolved clock (`Random/Types.ts`'s `Options.clock`), so `Constructor`'s
9
+ * `toConstructionContext` reads it off whichever root a construction resolves
10
+ * against. `plan`/ `resolve` (`./Plan.ts`) do the untyped recursive work; this
11
+ * is the one precisely-typed layer, mirroring `Constructor.ts`'s `make`/
13
12
  * `construct` split.
14
13
  *
15
- * Two derived seeds — one per API — each an independent, deterministic
16
- * fork off the *effective* source's seed (`effectiveSource()` below —
17
- * the active `wrap` frame's, or this instance's `source`; read fresh
18
- * on every `combinatorial(...)`/`coverage(...)` call, not once when
19
- * `enumerables()` was built, so the same `combinatorial` reference
20
- * behaves differently inside an active `wrap`).
21
- * `new Fabricator(schema, { seed })` (see `Constructor.ts`'s
14
+ * Two derived seeds — one per API — each an independent, deterministic fork off
15
+ * the _effective_ source's seed (`effectiveSource()` below — the active `wrap`
16
+ * frame's, or this instance's `source`; read fresh on every
17
+ * `combinatorial(...)`/`coverage(...)` call, not once when `enumerables()` was
18
+ * built, so the same `combinatorial` reference behaves differently inside an
19
+ * active `wrap`). `new Fabricator(schema, { seed })` (see `Constructor.ts`'s
22
20
  * `construct()`) forks a fully isolated `RandomSource` and opens an
23
- * `"unattributed"` scope, so `resolveCallerFile()` is never called —
24
- * the lazy-generator attribution hazard a plain `function*` would
25
- * invite simply doesn't arise — the instance's construction counters
26
- * are never touched, and the same seed reproduces regardless of which
27
- * file `combinatorial(...)`/`coverage(...)` is called from. Each
28
- * `fork()` starts from a fresh source, so reusing one seed across many
29
- * builds (different schemas, or the same schema rebuilt per iteration)
30
- * never lets one build's draws leak into another's.
21
+ * `"unattributed"` scope, so `resolveCallerFile()` is never called — the
22
+ * lazy-generator attribution hazard a plain `function*` would invite simply
23
+ * doesn't arise — the instance's construction counters are never touched, and
24
+ * the same seed reproduces regardless of which file
25
+ * `combinatorial(...)`/`coverage(...)` is called from. Each `fork()` starts
26
+ * from a fresh source, so reusing one seed across many builds (different
27
+ * schemas, or the same schema rebuilt per iteration) never lets one build's
28
+ * draws leak into another's.
31
29
  */
32
30
  export declare function enumerables(source: RandomSource, limits: Limits, stack: Stack): {
33
31
  combinatorial: Enumerable;
@@ -7,38 +7,34 @@ type Planning = {
7
7
  orderer: Orderer;
8
8
  };
9
9
  /**
10
- * Enumerable shape of a built Fabricator tree: how many distinct
11
- * combinations, and how to reproduce the `index`-th as a `Pin`.
12
- * Exhaustive kind dispatch lives in `axisFor`; this wrapper applies
13
- * `"cycle"` permutation uniformly, once, to whatever axis `axisFor`
14
- * computes so every recursive call (`axisFor` cases call back into
15
- * `plan`, never `axisFor` directly) gets its *own* independent
16
- * permutation, decorrelating equal-width siblings without any
17
- * per-kind case needing to know strategy beyond `Strategy`'s own
18
- * widen/narrow rules.
10
+ * Enumerable shape of a built Fabricator tree: how many distinct combinations,
11
+ * and how to reproduce the `index`-th as a `Pin`. Exhaustive kind dispatch
12
+ * lives in `axisFor`; this wrapper applies `"cycle"` permutation uniformly,
13
+ * once, to whatever axis `axisFor` computes — so every recursive call
14
+ * (`axisFor` cases call back into `plan`, never `axisFor` directly) gets its
15
+ * _own_ independent permutation, decorrelating equal-width siblings without any
16
+ * per-kind case needing to know strategy beyond `Strategy`'s own widen/narrow
17
+ * rules.
19
18
  *
20
- * Width is a function of schema shape *and* weights: a zero-weighted
21
- * outcome is not fabricable, so `axisFor` filters through `isDrawable`
22
- * / `drawableOutcomes` rather than treating the declared branch set as
23
- * the axis. Without that, `coverage()` would pin a value `fabricate()`
24
- * can never produce. Defaulting of unspecified keyed weights goes
25
- * through `drawableOutcomes` so the `?? 1` baseline is never
26
- * re-implemented here.
19
+ * Width is a function of schema shape _and_ weights: a zero-weighted outcome is
20
+ * not fabricable, so `axisFor` filters through `isDrawable` /
21
+ * `drawableOutcomes` rather than treating the declared branch set as the axis.
22
+ * Without that, `coverage()` would pin a value `fabricate()` can never produce.
23
+ * Defaulting of unspecified keyed weights goes through `drawableOutcomes` so
24
+ * the `?? 1` baseline is never re-implemented here.
27
25
  *
28
26
  * Skipped for width-1 axes (nothing to permute) and under `"product"`
29
- * (mixed-radix decode already visits every combination, so permuting
30
- * would only reorder identical output — see `Orderer`). `orders` is
31
- * therefore only ever read when `strategy === "cycle"` and is safe to
32
- * omit otherwise.
27
+ * (mixed-radix decode already visits every combination, so permuting would only
28
+ * reorder identical output — see `Orderer`). `orders` is therefore only ever
29
+ * read when `strategy === "cycle"` and is safe to omit otherwise.
33
30
  */
34
31
  export declare function plan(node: Resolvable, planning: Planning): Axis;
35
32
  /**
36
- * Reproduce the value a `Pin` describes against the built Fabricator
37
- * it was planned from. `pin === undefined` is universal — `plan()`
38
- * gave this node a width-1 axis, so there is nothing to pin and it
39
- * fabricates normally. Every other case only arises for kinds
40
- * `plan()` treats as enumerable axes, so this switch does not need to
41
- * be exhaustive the way `plan()`'s is.
33
+ * Reproduce the value a `Pin` describes against the built Fabricator it was
34
+ * planned from. `pin === undefined` is universal — `plan()` gave this node a
35
+ * width-1 axis, so there is nothing to pin and it fabricates normally. Every
36
+ * other case only arises for kinds `plan()` treats as enumerable axes, so this
37
+ * switch does not need to be exhaustive the way `plan()`'s is.
42
38
  */
43
39
  export declare function resolve(node: Resolvable, pin: Pin): unknown;
44
40
  export {};