@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
@@ -2,35 +2,33 @@ import type { Adaptations } from "../../Adapter/Types";
2
2
  import type { Produce } from "../../Random/Types";
3
3
  import type { Adaptation, Kind, Meta, Produces } from "../../Types";
4
4
  /**
5
- * The values an `enum` can draw from — any value at all, for the same
6
- * reason `always.Value` is unconstrained (see its doc).
5
+ * The values an `enum` can draw from — any value at all, for the same reason
6
+ * `always.Value` is unconstrained (see its doc).
7
7
  *
8
- * What still separates `enum` from `choice`: an `enum` draws one of these
9
- * exact *values*; a `choice` draws one of these *schemas* and fabricates
10
- * from it.
8
+ * What still separates `enum` from `choice`: an `enum` draws one of these exact
9
+ * _values_; a `choice` draws one of these _schemas_ and fabricates from it.
11
10
  */
12
11
  export type Item = unknown;
13
12
  /**
14
- * A *tuple* of `[weight, item]` pairs, one per position — not a flattened
15
- * `ReadonlyArray<[number, Item]>`, which would remember only the union of
16
- * every member's type and lose how many members there were (two identical
17
- * member types would collapse to one union member). The real tuple is what
18
- * lets `Adapter/TypeBox` mirror TypeBox's `Union<T>` — which collapses to a
19
- * bare schema for a single member and only wraps in `TUnion<T>` for two or
20
- * more — instead of mapping each member independently and losing the union
21
- * wrapper.
13
+ * A _tuple_ of `[weight, item]` pairs, one per position — not a flattened
14
+ * `ReadonlyArray<[number, Item]>`, which would remember only the union of every
15
+ * member's type and lose how many members there were (two identical member
16
+ * types would collapse to one union member). The real tuple is what lets
17
+ * `Adapter/TypeBox` mirror TypeBox's `Union<T>` — which collapses to a bare
18
+ * schema for a single member and only wraps in `TUnion<T>` for two or more —
19
+ * instead of mapping each member independently and losing the union wrapper.
22
20
  *
23
- * Identical shape to `choice.Items`; the two kinds differ only in what sits
24
- * on the right of each pair (a value here, a Schema there).
21
+ * Identical shape to `choice.Items`; the two kinds differ only in what sits on
22
+ * the right of each pair (a value here, a Schema there).
25
23
  */
26
24
  export type Items = ReadonlyArray<readonly [number, Item]>;
27
25
  export type Fabricated<$Items extends Items = Items> = $Items[number][1];
28
26
  /**
29
27
  * Always stored as weighted pairs — `.uniform(...)` (`Registry.ts`) is
30
- * `.weighted(...)` with every item given weight `1`, so there is only one
31
- * shape to fabricate from. `produce` layers an opaque production via
32
- * `.as()`, carried alongside `items` rather than replacing it, so a prior
33
- * member set survives `.as()` for future validation.
28
+ * `.weighted(...)` with every item given weight `1`, so there is only one shape
29
+ * to fabricate from. `produce` layers an opaque production via `.as()`, carried
30
+ * alongside `items` rather than replacing it, so a prior member set survives
31
+ * `.as()` for future validation.
34
32
  */
35
33
  export type Meta<$Items extends Items = Items> = {
36
34
  items: $Items;
@@ -2,19 +2,19 @@
2
2
  * The kind modules as a single namespace object — `Primitive.boolean`,
3
3
  * `Primitive.object.compute`, and so on.
4
4
  *
5
- * Each kind's `Types.ts` must stay type-only. A value export in the same
6
- * file as `export type Fabricated = boolean` (or `string`) makes that
7
- * module a value module; `export * as boolean` here then resolves
8
- * `boolean` to this namespace rather than the TypeScript primitive, which
9
- * drops `[Kind]`/`[Meta]` off `Core`. Named outcome lists and string's
10
- * character tables live in `Outcomes.ts`.
5
+ * Each kind's `Types.ts` must stay type-only. A value export in the same file
6
+ * as `export type Fabricated = boolean` (or `string`) makes that module a value
7
+ * module; `export * as boolean` here then resolves `boolean` to this namespace
8
+ * rather than the TypeScript primitive, which drops `[Kind]`/`[Meta]` off
9
+ * `Core`. Named outcome lists and string's character tables live in
10
+ * `Outcomes.ts`.
11
11
  *
12
- * A top-level `import * as boolean` is the same trap without needing a
13
- * cycle through this file. Prefer `import { Primitive }`.
12
+ * A top-level `import * as boolean` is the same trap without needing a cycle
13
+ * through this file. Prefer `import { Primitive }`.
14
14
  *
15
15
  * Consumed as `import { Primitive }` from `./index` (or from
16
- * `@ghostry/fabricator/internal`). Do not add this object to the
17
- * registry: `T.Primitive` is not a builder.
16
+ * `@ghostry/fabricator/internal`). Do not add this object to the registry:
17
+ * `T.Primitive` is not a builder.
18
18
  */
19
19
  export * as always from "./always";
20
20
  export * as array from "./array";
@@ -1,3 +1,3 @@
1
1
  import { Schema } from "./Schema";
2
- declare const _default: Schema<{}>;
3
- export default _default;
2
+ declare const registry: Schema;
3
+ export default registry;
@@ -8,8 +8,8 @@ import type { Core, Meta as ThisMeta } from "./Types";
8
8
  */
9
9
  export interface Schema<$Adaptations extends Adaptations = {}> extends Core<ThisMeta, $Adaptations> {
10
10
  /**
11
- * Override what this schema maps to in one or more external schema
12
- * libraries — see `string/Schema.ts`'s `adapt` for the full contract.
11
+ * Override what this schema maps to in one or more external schema libraries
12
+ * — see `string/Schema.ts`'s `adapt` for the full contract.
13
13
  */
14
14
  adapt: <const $Adapter extends Adapter, $Returnable extends ReturnType<$Adapter["convert"]>>(adapter: $Adapter, produce: (adapting: Adapting<Schema<$Adaptations>>) => $Returnable) => Schema<WithAdaptations<$Adaptations, AdaptationEntry<$Adapter, $Returnable>>>;
15
15
  }
@@ -2,9 +2,9 @@ import type { Adaptations } from "../../Adapter/Types";
2
2
  import type { Adaptation, Kind, Meta, Produces } from "../../Types";
3
3
  export type Fabricated = null;
4
4
  /**
5
- * Nothing to configure: `null` has exactly one possible value, so there is
6
- * no `.as()` (see `always/Types.ts` for the same reasoning) and no other
7
- * knob to carry.
5
+ * Nothing to configure: `null` has exactly one possible value, so there is no
6
+ * `.as()` (see `always/Types.ts` for the same reasoning) and no other knob to
7
+ * carry.
8
8
  */
9
9
  export type Meta = Record<string, never>;
10
10
  export type Core<$Meta extends Meta = Meta, $Adaptations extends Adaptations = {}> = {
@@ -19,13 +19,13 @@ export type Fabricator<$Schema extends {
19
19
  fabricate: () => Fabricated<$Schema[typeof Meta]["definition"]>;
20
20
  };
21
21
  /**
22
- * A presence roll on this field's private stream, drawn only when the
23
- * wrapped value is needed — a `null` roll never advances `source`'s stream,
24
- * and since `source` is already dispatched into its own independent stream
25
- * by `Constructor.ts` regardless of this roll, skipping its draw here can
26
- * never perturb any other field's reproducibility (see
22
+ * A presence roll on this field's private stream, drawn only when the wrapped
23
+ * value is needed — a `null` roll never advances `source`'s stream, and since
24
+ * `source` is already dispatched into its own independent stream by
25
+ * `Constructor.ts` regardless of this roll, skipping its draw here can never
26
+ * perturb any other field's reproducibility (see
27
27
  * `object/omittable/Fabricator.ts`, and CLAUDE.md's "Randomness"). 50/50 by
28
- * default; `.weighted(...)` (`Schema.ts`) reweights either outcome relative
29
- * to that same default of `1`.
28
+ * default; `.weighted(...)` (`Schema.ts`) reweights either outcome relative to
29
+ * that same default of `1`.
30
30
  */
31
31
  export declare function Fabricator<$Definition extends Definition>(context: FabricatorContext<Schema<$Definition>>, source: BaseFabricator<any>): Fabricator<Schema<$Definition>>;
@@ -10,25 +10,25 @@ import type { Core, Definition, Fabricated, Weights } from "./Types";
10
10
  export interface Schema<$Definition extends Definition = Definition, $Adaptations extends Adaptations = {}> extends Core<$Definition, $Adaptations> {
11
11
  /**
12
12
  * Layer an opaque production on this schema's existing `[Meta]` — carrying
13
- * `definition` forward, not discarding it, so a later `.as(...)` (or
14
- * future validation of `produce`) still has it to check against.
15
- * `produce` may return `null`, so custom logic composes the same way the
16
- * built-in roll does.
13
+ * `definition` forward, not discarding it, so a later `.as(...)` (or future
14
+ * validation of `produce`) still has it to check against. `produce` may
15
+ * return `null`, so custom logic composes the same way the built-in roll
16
+ * does.
17
17
  */
18
18
  as: (produce: Produce<Fabricated<$Definition>>) => Schema<$Definition, $Adaptations>;
19
19
  /**
20
- * Reweight the built-in 50/50 roll. Keys are optional — an omitted key
21
- * keeps baseline weight `1`, the same weight the 50/50 split already uses
22
- * — but that baseline is still relative to whatever else is specified, so
23
- * `.weighted({ null: 0.1 })` shifts both outcomes' shares, not just
24
- * `null`'s (see `Types.ts`'s `Weights`). Chaining `.weighted(...)` merges
25
- * into previous weights rather than replacing them, the same layering
26
- * `.as(...)` uses for `produce`.
20
+ * Reweight the built-in 50/50 roll. Keys are optional — an omitted key keeps
21
+ * baseline weight `1`, the same weight the 50/50 split already uses — but
22
+ * that baseline is still relative to whatever else is specified, so
23
+ * `.weighted({ null: 0.1 })` shifts both outcomes' shares, not just `null`'s
24
+ * (see `Types.ts`'s `Weights`). Chaining `.weighted(...)` merges into
25
+ * previous weights rather than replacing them, the same layering `.as(...)`
26
+ * uses for `produce`.
27
27
  */
28
28
  weighted: (weights: Weights) => Schema<$Definition, $Adaptations>;
29
29
  /**
30
- * Override what this schema maps to in one or more external schema
31
- * libraries — see `string/Schema.ts`'s `adapt` for the full contract.
30
+ * Override what this schema maps to in one or more external schema libraries
31
+ * — see `string/Schema.ts`'s `adapt` for the full contract.
32
32
  */
33
33
  adapt: <const $Adapter extends Adapter, $Returnable extends ReturnType<$Adapter["convert"]>>(adapter: $Adapter, produce: (adapting: Adapting<Schema<$Definition, $Adaptations>>) => $Returnable) => Schema<$Definition, WithAdaptations<$Adaptations, AdaptationEntry<$Adapter, $Returnable>>>;
34
34
  }
@@ -7,19 +7,18 @@ export type Definition = AnySchema;
7
7
  export type Fabricated<$Definition extends Definition, $Bindings extends unknown[] = []> = ValueOf<$Definition, $Bindings> | null;
8
8
  export type { Outcome } from "./Outcomes";
9
9
  /**
10
- * Relative weights for `.weighted(...)`, keyed by `Outcome`. Keys optional —
11
- * an omitted key falls back to baseline `1`, the same weight the 50/50
12
- * split already uses. Values are relative, exactly like `weighted()`
10
+ * Relative weights for `.weighted(...)`, keyed by `Outcome`. Keys optional — an
11
+ * omitted key falls back to baseline `1`, the same weight the 50/50 split
12
+ * already uses. Values are relative, exactly like `weighted()`
13
13
  * (`Distribution/index.ts`) — they need not sum to one, and are fed to
14
14
  * `weighted()` unchanged alongside each unspecified key's baseline `1`.
15
15
  *
16
- * Specifying one outcome's weight shifts the *other* outcome's resulting
17
- * probability too, even though its weight stays at `1` — its share of the
18
- * total still moves, since the total changed. `.weighted({ null: 0.1 })` is
19
- * not "10% null, 90% present" — with `value` at default `1`, the split is
20
- * `0.1 / 1.1 ≈ 9.1%` null, `≈90.9%` value. No independent "absolute
21
- * probability" mode; weights are only meaningful relative to the full set
22
- * in play.
16
+ * Specifying one outcome's weight shifts the _other_ outcome's resulting
17
+ * probability too, even though its weight stays at `1` — its share of the total
18
+ * still moves, since the total changed. `.weighted({ null: 0.1 })` is not "10%
19
+ * null, 90% present" — with `value` at default `1`, the split is `0.1 / 1.1 ≈
20
+ * 9.1%` null, `≈90.9%` value. No independent "absolute probability" mode;
21
+ * weights are only meaningful relative to the full set in play.
23
22
  */
24
23
  export type Weights = {
25
24
  null: number;
@@ -19,18 +19,17 @@ export type Fabricator<$Schema extends {
19
19
  fabricate: () => Fabricated<$Schema[typeof Meta]["definition"]>;
20
20
  };
21
21
  /**
22
- * Three-way roll: `null`, `undefined`, or the wrapped value — on this
23
- * field's private stream; `source` is drawn only when "value" wins. Uniform
24
- * (1/3 each) by default; not achievable by composing
25
- * `nullable(T.undefinable(inner))`'s two independent 50/50 rolls (that is
26
- * 50/25/25, not 33/33/33), hence the dedicated three-way `weighted()` here
27
- * — see `object/optional/Fabricator.ts` and CLAUDE.md's "Why `T.optional`
28
- * isn't `omittable(undefinable(inner))`". `.weighted(...)` (`Schema.ts`)
29
- * reweights individual outcomes relative to that same default of `1`; an
30
- * unspecified outcome keeps it. Skipping `source`'s draw on the two
31
- * non-"value" outcomes is safe for the same reason as
32
- * `object/omittable/Fabricator.ts`: `source` already has its own
33
- * independent stream, minted at build time regardless of this roll (see
34
- * CLAUDE.md's "Randomness").
22
+ * Three-way roll: `null`, `undefined`, or the wrapped value — on this field's
23
+ * private stream; `source` is drawn only when "value" wins. Uniform (1/3 each)
24
+ * by default; not achievable by composing `nullable(T.undefinable(inner))`'s
25
+ * two independent 50/50 rolls (that is 50/25/25, not 33/33/33), hence the
26
+ * dedicated three-way `weighted()` here — see `object/optional/Fabricator.ts`
27
+ * and CLAUDE.md's "Why `T.optional` isn't `omittable(undefinable(inner))`".
28
+ * `.weighted(...)` (`Schema.ts`) reweights individual outcomes relative to that
29
+ * same default of `1`; an unspecified outcome keeps it. Skipping `source`'s
30
+ * draw on the two non-"value" outcomes is safe for the same reason as
31
+ * `object/omittable/Fabricator.ts`: `source` already has its own independent
32
+ * stream, minted at build time regardless of this roll (see CLAUDE.md's
33
+ * "Randomness").
35
34
  */
36
35
  export declare function Fabricator<$Definition extends Definition>(context: FabricatorContext<Schema<$Definition>>, source: BaseFabricator<any>): Fabricator<Schema<$Definition>>;
@@ -4,16 +4,16 @@ import type { Produce } from "../../Random/Types";
4
4
  import type { AnySchema } from "../../Schema/Types";
5
5
  import type { Core, Definition, Fabricated, Weights } from "./Types";
6
6
  /**
7
- * The buildable recipe for a `nullish`: a single wrapped Schema, drawn (or
8
- * not) each fabrication.
7
+ * The buildable recipe for a `nullish`: a single wrapped Schema, drawn (or not)
8
+ * each fabrication.
9
9
  */
10
10
  export interface Schema<$Definition extends Definition = Definition, $Adaptations extends Adaptations = {}> extends Core<$Definition, $Adaptations> {
11
11
  /**
12
12
  * Layer an opaque production on this schema's existing `[Meta]` — carrying
13
- * `definition` forward, not discarding it, so a later `.as(...)` (or
14
- * future validation of `produce`) still has it to check against.
15
- * `produce` may return `null` or `undefined`, so custom logic composes
16
- * the same way the built-in three-way roll does.
13
+ * `definition` forward, not discarding it, so a later `.as(...)` (or future
14
+ * validation of `produce`) still has it to check against. `produce` may
15
+ * return `null` or `undefined`, so custom logic composes the same way the
16
+ * built-in three-way roll does.
17
17
  */
18
18
  as: (produce: Produce<Fabricated<$Definition>>) => Schema<$Definition, $Adaptations>;
19
19
  /**
@@ -27,8 +27,8 @@ export interface Schema<$Definition extends Definition = Definition, $Adaptation
27
27
  */
28
28
  weighted: (weights: Weights) => Schema<$Definition, $Adaptations>;
29
29
  /**
30
- * Override what this schema maps to in one or more external schema
31
- * libraries — see `string/Schema.ts`'s `adapt` for the full contract.
30
+ * Override what this schema maps to in one or more external schema libraries
31
+ * — see `string/Schema.ts`'s `adapt` for the full contract.
32
32
  */
33
33
  adapt: <const $Adapter extends Adapter, $Returnable extends ReturnType<$Adapter["convert"]>>(adapter: $Adapter, produce: (adapting: Adapting<Schema<$Definition, $Adaptations>>) => $Returnable) => Schema<$Definition, WithAdaptations<$Adaptations, AdaptationEntry<$Adapter, $Returnable>>>;
34
34
  }
@@ -3,27 +3,26 @@ import type { Produce } from "../../Random/Types";
3
3
  import type { AnySchema, ValueOf } from "../../Schema/Types";
4
4
  import type { Adaptation, Kind, Meta, Produces } from "../../Types";
5
5
  /**
6
- * The wrapped schema — the value type produced when the roll lands on
7
- * neither `null` nor `undefined`.
6
+ * The wrapped schema — the value type produced when the roll lands on neither
7
+ * `null` nor `undefined`.
8
8
  */
9
9
  export type Definition = AnySchema;
10
10
  export type Fabricated<$Definition extends Definition, $Bindings extends unknown[] = []> = ValueOf<$Definition, $Bindings> | null | undefined;
11
11
  export type { Outcome } from "./Outcomes";
12
12
  /**
13
- * Relative weights for `.weighted(...)`, keyed by `Outcome`. Keys optional —
14
- * an omitted key falls back to baseline `1`, the same weight the uniform
15
- * 1/3 split already uses. Values are relative, exactly like `weighted()`
13
+ * Relative weights for `.weighted(...)`, keyed by `Outcome`. Keys optional — an
14
+ * omitted key falls back to baseline `1`, the same weight the uniform 1/3 split
15
+ * already uses. Values are relative, exactly like `weighted()`
16
16
  * (`Distribution/index.ts`) — they need not sum to one, and are fed to
17
17
  * `weighted()` unchanged alongside each unspecified key's baseline `1`.
18
18
  *
19
- * Specifying one outcome's weight shifts *every* outcome's resulting
20
- * probability, not just the named one — unspecified ones stay at weight `1`
21
- * but their share of the total still moves, since the total changed.
22
- * `.weighted({ null: 0.1 })` on `T.nullish` is not "10% null, other two
23
- * still 33%" — with `undefined`/`value` at default `1`, the split is
24
- * `0.1 / 2.1 ≈ 4.8%` null and `≈47.6%` each for the other two. No
25
- * independent "absolute probability" mode; weights are only meaningful
26
- * relative to the full set in play.
19
+ * Specifying one outcome's weight shifts _every_ outcome's resulting
20
+ * probability, not just the named one — unspecified ones stay at weight `1` but
21
+ * their share of the total still moves, since the total changed. `.weighted({
22
+ * null: 0.1 })` on `T.nullish` is not "10% null, other two still 33%" — with
23
+ * `undefined`/`value` at default `1`, the split is `0.1 / 2.1 ≈ 4.8%` null and
24
+ * `≈47.6%` each for the other two. No independent "absolute probability" mode;
25
+ * weights are only meaningful relative to the full set in play.
27
26
  */
28
27
  export type Weights = {
29
28
  null: number;
@@ -1,52 +1,34 @@
1
1
  import type { Adaptations } from "../../Adapter/Types";
2
- import { Adaptation, Kind, Meta, Produces } from "../../Types";
2
+ import { default as bigint } from "../bigint";
3
3
  import { Schema } from "./Schema";
4
- import type { Fabricated, InputWhereby, Whereby } from "./Types";
5
- declare const _default: {
6
- [Kind]: "number";
7
- [Meta]: {};
8
- [Produces]?: Fabricated;
9
- [Adaptation]?: Adaptations;
10
- as: (produce: import("../../Random/Types").Produce<Fabricated>, hints?: import("./Types").JsonSchema) => Schema<{}, Adaptations>;
11
- adapt: <const $Adapter extends import("../..").Adapter, $Returnable extends ReturnType<$Adapter["convert"]>>(adapter: $Adapter, produce: (adapting: import("../..").Adapting<Schema<{}, Adaptations>>) => $Returnable) => Schema<{}, import("../../Adapter/Types").WithAdaptations<Adaptations, import("../../Adapter/Core").AdaptationEntry<$Adapter, $Returnable>>>;
4
+ import type { InputWhereby, Whereby } from "./Types";
5
+ type ThisRegistry = Schema<{}, Adaptations> & {
6
+ /**
7
+ * A `number` drawn from `[min, max]`, either end optional. Pass a
8
+ * `distribution` to shape how values cluster within the range; without one,
9
+ * every value is equally likely.
10
+ */
12
11
  whereby: (whereby: InputWhereby) => Schema<{
13
12
  whereby: Whereby;
14
- }, {}>;
15
- integer: {
16
- [Kind]: "number";
17
- [Meta]: {
18
- integer: true;
19
- };
20
- [Produces]?: Fabricated;
21
- [Adaptation]?: {};
22
- as: (produce: import("../../Random/Types").Produce<Fabricated>, hints?: import("./Types").JsonSchema) => Schema<{
23
- integer: true;
24
- }, {}>;
25
- adapt: <const $Adapter extends import("../..").Adapter, $Returnable extends ReturnType<$Adapter["convert"]>>(adapter: $Adapter, produce: (adapting: import("../..").Adapting<Schema<{
26
- integer: true;
27
- }, {}>>) => $Returnable) => Schema<{
28
- integer: true;
29
- }, import("../../Adapter/Types").WithAdaptations<{}, import("../../Adapter/Core").AdaptationEntry<$Adapter, $Returnable>>>;
13
+ }>;
14
+ /** The same surface, restricted to integers. */
15
+ integer: Schema<{
16
+ integer: true;
17
+ }> & {
30
18
  whereby: (whereby: InputWhereby) => Schema<{
31
19
  integer: true;
32
20
  whereby: Whereby;
33
- }, {}>;
21
+ }>;
34
22
  /**
35
- * A monotonically increasing counter starting at 1, fresh per `construct()`.
23
+ * A monotonically increasing counter starting at 1, fresh per
24
+ * `construct()`.
36
25
  */
37
26
  sequence: Schema<{
38
27
  sequence: true;
39
28
  integer: true;
40
- }, {}>;
41
- big: {
42
- [Kind]: "bigint";
43
- whereby: (whereby: import("../bigint").InputWhereby) => import("../bigint").Schema<{
44
- whereby: import("../bigint").Whereby;
45
- }, {}>;
46
- as: (produce: import("../../Random/Types").Produce<import("../bigint").Fabricated>) => import("../bigint").Schema<{
47
- produce: import("../../Random/Types").Produce<bigint>;
48
- }, {}>;
49
- };
29
+ }>;
30
+ big: typeof bigint;
50
31
  };
51
32
  };
52
- export default _default;
33
+ declare const registry: ThisRegistry;
34
+ export default registry;
@@ -3,17 +3,16 @@ import type { Adaptations, Adapter, Adapting, WithAdaptations } from "../../Adap
3
3
  import type { Produce } from "../../Random/Types";
4
4
  import type { Core, Fabricated, JsonSchema, Meta as ThisMeta } from "./Types";
5
5
  /**
6
- * Buildable `number` recipe: a range/distribution (`whereby`, absent for
7
- * the full-range bare form), `integer` for whole-number semantics, a
8
- * `sequence` counter, or opaque production via `as`. `construct()` derives
9
- * `fabricate` from this data — no variant carries its own closure until
10
- * it's built.
6
+ * Buildable `number` recipe: a range/distribution (`whereby`, absent for the
7
+ * full-range bare form), `integer` for whole-number semantics, a `sequence`
8
+ * counter, or opaque production via `as`. `construct()` derives `fabricate`
9
+ * from this data — no variant carries its own closure until it's built.
11
10
  *
12
- * `$Meta` is generic (defaulting to the full `Meta` union) so builder
13
- * return types stay narrow — e.g. `T.number.integer.sequence` types as
14
- * `Schema<{ sequence: true; integer: true }>`, not the widened `Schema`, so
15
- * a downstream conditional (`ToTypeBox`) can still tell an integer schema
16
- * apart from a bare one.
11
+ * `$Meta` is generic (defaulting to the full `Meta` union) so builder return
12
+ * types stay narrow — e.g. `T.number.integer.sequence` types as `Schema<{
13
+ * sequence: true; integer: true }>`, not the widened `Schema`, so a downstream
14
+ * conditional (`ToTypeBox`) can still tell an integer schema apart from a bare
15
+ * one.
17
16
  */
18
17
  export interface Schema<$Meta extends ThisMeta = ThisMeta, $Adaptations extends Adaptations = {}> extends Core<$Meta, $Adaptations> {
19
18
  /**
@@ -24,8 +23,8 @@ export interface Schema<$Meta extends ThisMeta = ThisMeta, $Adaptations extends
24
23
  */
25
24
  as: (produce: Produce<Fabricated>, hints?: JsonSchema) => Schema<$Meta, $Adaptations>;
26
25
  /**
27
- * Override what this schema maps to in one or more external schema
28
- * libraries — see `string/Schema.ts`'s `adapt` for the full contract.
26
+ * Override what this schema maps to in one or more external schema libraries
27
+ * — see `string/Schema.ts`'s `adapt` for the full contract.
29
28
  */
30
29
  adapt: <const $Adapter extends Adapter, $Returnable extends ReturnType<$Adapter["convert"]>>(adapter: $Adapter, produce: (adapting: Adapting<Schema<$Meta, $Adaptations>>) => $Returnable) => Schema<$Meta, WithAdaptations<$Adaptations, AdaptationEntry<$Adapter, $Returnable>>>;
31
30
  }
@@ -4,9 +4,9 @@ import type { Distribution } from "../../Distribution";
4
4
  import type { Produce } from "../../Random/Types";
5
5
  import type { Adaptation, Kind, Meta, Produces } from "../../Types";
6
6
  /**
7
- * Call-site `{ min, max }` — scalars are inclusive. Either end may be
8
- * omitted; a missing end is unbounded (the same policy as a bare
9
- * `T.number`), not a default of `0`.
7
+ * Call-site `{ min, max }` — scalars are inclusive. Either end may be omitted;
8
+ * a missing end is unbounded (the same policy as a bare `T.number`), not a
9
+ * default of `0`.
10
10
  */
11
11
  export type InputWhereby = {
12
12
  min?: InputBound<number> | undefined;
@@ -14,8 +14,8 @@ export type InputWhereby = {
14
14
  distribution?: Distribution | undefined;
15
15
  };
16
16
  /**
17
- * Stored `{ min, max }` — each present end is a canonical {@link Bound}.
18
- * An omitted end stays omitted (fabricate fills the unbounded cap; adapters
17
+ * Stored `{ min, max }` — each present end is a canonical {@link Bound}. An
18
+ * omitted end stays omitted (fabricate fills the unbounded cap; adapters
19
19
  * forward only the ends that were named).
20
20
  */
21
21
  export type Whereby = {
@@ -27,19 +27,19 @@ export type Fabricated = number;
27
27
  /**
28
28
  * JSON-Schema keywords that constrain a number value — carried as neutral,
29
29
  * schema-library-agnostic hints (see the builder's `as`). The numeric range
30
- * lives on `whereby` as {@link Bound}s, which adapters forward; `hints`
31
- * holds only the orthogonal constraints not expressible there.
30
+ * lives on `whereby` as {@link Bound}s, which adapters forward; `hints` holds
31
+ * only the orthogonal constraints not expressible there.
32
32
  */
33
33
  export type JsonSchema = {
34
34
  multipleOf?: number;
35
35
  };
36
36
  /**
37
- * A ranged number — `whereby` is absent on the full-range form, `integer`
38
- * (a literal, not widened to `boolean`) selects whole-number semantics, or
39
- * a sequence counter (`sequence`, always paired with `integer: true`, since
40
- * a counter only ever yields whole numbers), optionally overridden by an
41
- * opaque `as` production — carried alongside the rest rather than replacing
42
- * it, so a prior scoping survives `as` for future validation.
37
+ * A ranged number — `whereby` is absent on the full-range form, `integer` (a
38
+ * literal, not widened to `boolean`) selects whole-number semantics, or a
39
+ * sequence counter (`sequence`, always paired with `integer: true`, since a
40
+ * counter only ever yields whole numbers), optionally overridden by an opaque
41
+ * `as` production — carried alongside the rest rather than replacing it, so a
42
+ * prior scoping survives `as` for future validation.
43
43
  */
44
44
  export type Meta = {
45
45
  whereby?: Whereby;
@@ -1,8 +1,8 @@
1
1
  import type { Bound } from "../../Bound";
2
2
  /**
3
- * Inclusive caps a missing `whereby` end draws against. Not stored on the
4
- * bare schema — `T.number` / `T.number.integer` carry no `whereby` until
5
- * one is named, and an omitted end stays omitted on `[Meta]`.
3
+ * Inclusive caps a missing `whereby` end draws against. Not stored on the bare
4
+ * schema — `T.number` / `T.number.integer` carry no `whereby` until one is
5
+ * named, and an omitted end stays omitted on `[Meta]`.
6
6
  */
7
7
  export declare const unboundedContinuous: {
8
8
  min: Bound<number>;
@@ -22,8 +22,8 @@ export type Fabricator<$Schema extends {
22
22
  * never drawing fresh (see `Fabricator()` below). `config.validate` defaults
23
23
  * to `true`, delegated to `schema.override(overrides)`'s existing recursive
24
24
  * checks (result unused); `{ validate: false }` skips that — used internally
25
- * when recursing into an already-validated nested override, also available
26
- * to a caller who already knows their overrides are valid.
25
+ * when recursing into an already-validated nested override, also available to
26
+ * a caller who already knows their overrides are valid.
27
27
  */
28
28
  fabricate: (overrides?: Override<$Schema[typeof Meta]["definition"]>, config?: {
29
29
  validate?: boolean;
@@ -36,21 +36,21 @@ export type Fields = Record<string, BaseFabricator<unknown>>;
36
36
  * built by `Constructor.ts` — which owns recursion into nested Schemas, so
37
37
  * `object` never calls `construct()` and there's no import cycle with
38
38
  * `Constructor.ts`. Schema-baked `.override()`-marked fields (`[Fixed]` in
39
- * `Types.ts`) are already resolved into literal-valued `fields` entries
40
- * before they reach here. `fabricate`'s `overrides` (below) is a separate
41
- * per-call mechanism; the two compose.
39
+ * `Types.ts`) are already resolved into literal-valued `fields` entries before
40
+ * they reach here. `fabricate`'s `overrides` (below) is a separate per-call
41
+ * mechanism; the two compose.
42
42
  *
43
43
  * `schema` is echoed as `.schema` unchanged — callers wanting a
44
- * `toSchema`-normalized Fabricator (no `extend`/`refine`/`override`) pass
45
- * that; `Constructor.ts`'s `make` passes `object.rehydrate(...)` so a
46
- * top-level built Fabricator's `.schema` still composes.
44
+ * `toSchema`-normalized Fabricator (no `extend`/`refine`/`override`) pass that;
45
+ * `Constructor.ts`'s `make` passes `object.rehydrate(...)` so a top-level built
46
+ * Fabricator's `.schema` still composes.
47
47
  *
48
- * A compute-kind field (from `.refine()`) needs the rest of the object
49
- * already fabricated (`object/compute/Fabricator.ts`), which isn't available
50
- * until every ordinary field has resolved. Two phases: ordinary fields
51
- * first, then compute fields against the accumulated result, in definition
52
- * order (a compute field can see an earlier compute field's value, not a
53
- * later one) — unless covered by `overrides`, in which case it resolves in
54
- * phase 1 like any other overridden field.
48
+ * A compute-kind field (from `.refine()`) needs the rest of the object already
49
+ * fabricated (`object/compute/Fabricator.ts`), which isn't available until
50
+ * every ordinary field has resolved. Two phases: ordinary fields first, then
51
+ * compute fields against the accumulated result, in definition order (a compute
52
+ * field can see an earlier compute field's value, not a later one) — unless
53
+ * covered by `overrides`, in which case it resolves in phase 1 like any other
54
+ * overridden field.
55
55
  */
56
56
  export declare function Fabricator<$Definition extends Definition>(context: FabricatorContext<Schema<$Definition>>, fields: Fields): Fabricator<Schema<$Definition>>;
@@ -4,20 +4,20 @@ import { Schema } from "./Schema";
4
4
  import type { Definition, Meta as ThisMeta } from "./Types";
5
5
  /**
6
6
  * Rebuild a full `object` Schema — with `extend`/`refine` restored — from
7
- * anything already reduced to this kind's `[Meta]` (a bare Schema, or a
8
- * built Fabricator normalized via `toSchema`). `toSchema` alone only keeps
7
+ * anything already reduced to this kind's `[Meta]` (a bare Schema, or a built
8
+ * Fabricator normalized via `toSchema`). `toSchema` alone only keeps
9
9
  * `[Kind]`/`[Meta]`, enough to fabricate from but not to derive a subtype —
10
10
  * this is what lets a built Fabricator's `.schema` still compose via
11
11
  * `extend`/`refine` (`Constructor.ts`'s `make`). Reattaches `produce` via
12
- * `.as(...)` when present, so a `toSchema`-stripped, `.as(...)`-produced
13
- * schema doesn't lose its custom producer — and carries `[Adaptation]` for
14
- * the same reason: without it, `.override(...)` on a nested adapted
15
- * `object` field (which round-trips through here) and a built Fabricator's
16
- * `.schema` would both silently come back unadapted.
12
+ * `.as(...)` when present, so a `toSchema`-stripped, `.as(...)`-produced schema
13
+ * doesn't lose its custom producer — and carries `[Adaptation]` for the same
14
+ * reason: without it, `.override(...)` on a nested adapted `object` field
15
+ * (which round-trips through here) and a built Fabricator's `.schema` would
16
+ * both silently come back unadapted.
17
17
  */
18
18
  export declare function rehydrate<$Definition extends Definition, $Adaptations extends Adaptations = {}>(schema: {
19
19
  [Meta]: ThisMeta<$Definition>;
20
20
  readonly [Adaptation]?: $Adaptations;
21
21
  }): Schema<$Definition, $Adaptations>;
22
+ declare const _default: <const $Definition extends Definition>(definition: $Definition) => Schema<$Definition>;
22
23
  export default _default;
23
- declare function _default<const $Definition extends Definition>(definition: $Definition): Schema<$Definition>;
@@ -17,25 +17,25 @@ export interface Schema<$Definition extends Definition = Definition, $Adaptation
17
17
  * Layer an opaque production on this schema's existing `[Meta]` — carrying
18
18
  * `definition`/`refinements` forward, not discarding them, so
19
19
  * `extend`/`refine`/`override` keep working (they drop the custom producer
20
- * again, falling back to definition-based fabrication) and a later
21
- * `.as(...)` (or future validation of `produce`) still has the definition
22
- * to check against.
20
+ * again, falling back to definition-based fabrication) and a later `.as(...)`
21
+ * (or future validation of `produce`) still has the definition to check
22
+ * against.
23
23
  */
24
24
  as: (produce: Produce<Fabricated<$Definition>>) => Schema<$Definition, $Adaptations>;
25
25
  /**
26
- * Override what this schema maps to in one or more external schema
27
- * libraries — see `string/Schema.ts`'s `adapt` for the full contract.
28
- * Carried through `extend`/`refine`/`override`, which all reduce to a
29
- * fresh `make(...)` (`Registry.ts`) over this same schema.
26
+ * Override what this schema maps to in one or more external schema libraries
27
+ * — see `string/Schema.ts`'s `adapt` for the full contract. Carried through
28
+ * `extend`/`refine`/`override`, which all reduce to a fresh `make(...)`
29
+ * (`Registry.ts`) over this same schema.
30
30
  */
31
31
  adapt: <const $Adapter extends Adapter, $Returnable extends ReturnType<$Adapter["convert"]>>(adapter: $Adapter, produce: (adapting: Adapting<Schema<$Definition, $Adaptations>>) => $Returnable) => Schema<$Definition, WithAdaptations<$Adaptations, AdaptationEntry<$Adapter, $Returnable>>>;
32
32
  }
33
33
  /**
34
- * Unlike every other kind, `adapt` is *not* added here but by `Registry.ts`'s
34
+ * Unlike every other kind, `adapt` is _not_ added here but by `Registry.ts`'s
35
35
  * `make` alongside `extend`/`refine`/`override`: those three rebuild from
36
36
  * `definition`/`refinements` rather than deriving from this object, so the
37
- * adaptation map has to be threaded through `make` itself or chaining one
38
- * of them would drop it (see `make`'s `adapt`).
37
+ * adaptation map has to be threaded through `make` itself or chaining one of
38
+ * them would drop it (see `make`'s `adapt`).
39
39
  */
40
40
  export declare function Schema<$Definition extends Definition, $Adaptations extends Adaptations = {}>(schema: Omit<Schema<$Definition, $Adaptations>, "as">): Schema<$Definition, $Adaptations>;
41
41
  export declare function isObjectSchema(candidate: AnySchema): candidate is Schema;