@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,107 +1,100 @@
1
1
  import type { Algorithm, Attribution, Layered, NumberGenerator, Options, RandomSource, ResolvedAttribution, Seed, Stream, Trace } from "./Types";
2
2
  /**
3
- * Build the library's built-in PRNG from a seed. The same seed always
4
- * yields the same stream. Seeds may be numbers or strings; both are
5
- * stringified and hashed to fully seed sfc32's state.
3
+ * Build the library's built-in PRNG from a seed. The same seed always yields
4
+ * the same stream. Seeds may be numbers or strings; both are stringified and
5
+ * hashed to fully seed sfc32's state.
6
6
  */
7
7
  export declare function defaultAlgorithm(seed: string): NumberGenerator;
8
8
  /**
9
- * Mint a fresh seed value — a uint32 label. Not used as
10
- * `initialize()`'s default (an omitted seed is empty; wall-clock
11
- * `clock` is the default entropy); kept for callers that want a
12
- * generated mixer, and for tests that need one.
9
+ * Mint a fresh seed value — a uint32 label. Not used as `initialize()`'s
10
+ * default (an omitted seed is empty; wall-clock `clock` is the default
11
+ * entropy); kept for callers that want a generated mixer, and for tests that
12
+ * need one.
13
13
  */
14
14
  export declare function randomSeed(): string;
15
15
  /**
16
- * Derive the explicit `"seeded"` clock — an epoch-millisecond instant,
17
- * drawn across the full representable `Date` span — from an instance's
18
- * own `algorithm`/`seed`. The unconfigured default is wall-clock time
19
- * (`Instance/Core.ts`'s `overlay`); this is the opt-in that makes
20
- * `seed` alone the reproducibility unit, at the cost of an implausible
21
- * "now". A throwaway two-element encoding
22
- * (`JSON.stringify([seed, "clock"])`), *not* routed through
23
- * `RandomSource`/`Trace`: after the clock is folded into stream
24
- * derivation, a forked source's own stream derivation requires a clock,
25
- * so deriving the clock from a fork would be circular. Kept below that
26
- * layer, which also keeps this collision-free with every leaf's
27
- * `encode(trace)` that encoding is always seven elements, this is
28
- * always two, and the two can never produce the same JSON array.
29
- * `Math.trunc`ed because a `Date`'s precision is whole milliseconds.
16
+ * Derive the explicit `"seeded"` clock — an epoch-millisecond instant, drawn
17
+ * across the full representable `Date` span — from an instance's own
18
+ * `algorithm`/`seed`. The unconfigured default is wall-clock time
19
+ * (`Instance/Core.ts`'s `overlay`); this is the opt-in that makes `seed` alone
20
+ * the reproducibility unit, at the cost of an implausible "now". A throwaway
21
+ * two-element encoding (`JSON.stringify([seed, "clock"])`), _not_ routed
22
+ * through `RandomSource`/`Trace`: after the clock is folded into stream
23
+ * derivation, a forked source's own stream derivation requires a clock, so
24
+ * deriving the clock from a fork would be circular. Kept below that layer,
25
+ * which also keeps this collision-free with every leaf's `encode(trace)` that
26
+ * encoding is always seven elements, this is always two, and the two can never
27
+ * produce the same JSON array. `Math.trunc`ed because a `Date`'s precision is
28
+ * whole milliseconds.
30
29
  */
31
30
  export declare function deriveClock(algorithm: Algorithm, seed: ReadonlyArray<string>): number;
32
31
  /**
33
32
  * Collapse a {@link Trace} into one string to hash — and, since
34
- * `toStreamFromTrace` hashes exactly this output, the *definition* of
35
- * that leaf's stream seed. Concatenating fields with a delimiter would
36
- * collide when a path/kind/seed part contains that delimiter
37
- * (`file="a b", kind="c"` vs `file="a", kind="b c"`) — silently: two
38
- * leaves that should draw independently would share one stream.
39
- * `JSON.stringify` as an array makes every field's and slot's
40
- * boundaries unambiguous regardless of content or nesting depth.
41
- * `undefined` (`file`, `ordinal`) is the right "this slot doesn't
42
- * apply" rather than a sentinel string: `JSON.stringify` writes it as
43
- * `null` in an array position, one unambiguous value, with no chance
44
- * of colliding with a real file path or index.
33
+ * `toStreamFromTrace` hashes exactly this output, the _definition_ of that
34
+ * leaf's stream seed. Concatenating fields with a delimiter would collide when
35
+ * a path/kind/seed part contains that delimiter (`file="a b", kind="c"` vs
36
+ * `file="a", kind="b c"`) — silently: two leaves that should draw independently
37
+ * would share one stream. `JSON.stringify` as an array makes every field's and
38
+ * slot's boundaries unambiguous regardless of content or nesting depth.
39
+ * `undefined` (`file`, `ordinal`) is the right "this slot doesn't apply" rather
40
+ * than a sentinel string: `JSON.stringify` writes it as `null` in an array
41
+ * position, one unambiguous value, with no chance of colliding with a real file
42
+ * path or index.
45
43
  */
46
44
  export declare function encode(trace: Trace): string;
47
45
  /**
48
- * Normalize a caller-supplied {@link Seed} to its parts: a single string
49
- * becomes a one-element array, an array passes through unchanged, and a
50
- * missing seed is empty — unless {@link envSeed} supplies one. No
51
- * generated fallback: an omitted seed is not a second source of
52
- * entropy beside the instance clock.
46
+ * Normalize a caller-supplied {@link Seed} to its parts: a single string becomes
47
+ * a one-element array, an array passes through unchanged, and a missing seed is
48
+ * empty — unless {@link envSeed} supplies one. No generated fallback: an omitted
49
+ * seed is not a second source of entropy beside the instance clock.
53
50
  */
54
51
  export declare function normalizeSeed(seed: Seed | undefined): ReadonlyArray<string>;
55
52
  /**
56
53
  * Tag a seed as composing onto whatever base is in effect, rather than
57
- * replacing it — the reading a bare `seed` has everywhere else in this
58
- * library. Mirrors `replace()`'s `[Replace]` tagging: the `[Layer]`
59
- * directive is read (and, at every level that accepts one, consumed) by
60
- * whoever resolves the seed against its base, so a caller never names
61
- * the symbol.
54
+ * replacing it — the reading a bare `seed` has everywhere else in this library.
55
+ * Mirrors `replace()`'s `[Replace]` tagging: the `[Layer]` directive is read
56
+ * (and, at every level that accepts one, consumed) by whoever resolves the seed
57
+ * against its base, so a caller never names the symbol.
62
58
  */
63
59
  export declare function layer(seed: Seed): Layered;
64
60
  export declare function isLayered(value: unknown): value is Layered;
65
61
  /**
66
62
  * Collapse a caller-facing {@link Attribution} to the
67
- * {@link ResolvedAttribution} the stream machinery uses. `"call site"`
68
- * must resolve *here*, and only here: `resolveCallerFile()` reads the
69
- * live stack, and `toRandomSource` runs synchronously inside
70
- * `initialize()`, so this is the one moment the first external frame
71
- * genuinely is the file that called `initialize()`. Resolving lazily —
72
- * on first construction, or again inside `fork` would capture
73
- * whichever file happened to call `new Fabricator(...)`, or whichever
74
- * internal mechanism happened to trigger a fork.
63
+ * {@link ResolvedAttribution} the stream machinery uses. `"call site"` must
64
+ * resolve _here_, and only here: `resolveCallerFile()` reads the live stack,
65
+ * and `toRandomSource` runs synchronously inside `initialize()`, so this is the
66
+ * one moment the first external frame genuinely is the file that called
67
+ * `initialize()`. Resolving lazily — on first construction, or again inside
68
+ * `fork` would capture whichever file happened to call `new Fabricator(...)`,
69
+ * or whichever internal mechanism happened to trigger a fork.
75
70
  *
76
- * A directory, not the file itself, becomes the root: rooting at the
77
- * file would relativize that one file to `""` while every sibling still
78
- * carried a full relative path from a directory one level up, an
79
- * arbitrary asymmetry with no reason to prefer it.
71
+ * A directory, not the file itself, becomes the root: rooting at the file would
72
+ * relativize that one file to `""` while every sibling still carried a full
73
+ * relative path from a directory one level up, an arbitrary asymmetry with no
74
+ * reason to prefer it.
80
75
  */
81
76
  export declare function resolveAttribution(attribution: Attribution | undefined): ResolvedAttribution;
82
77
  export declare function toStream(algorithm: Algorithm, seed: string): Stream;
83
78
  /**
84
79
  * A leaf's stream: `toStream(algorithm, encode(trace))`. This is the
85
- * composition that *defines* a leaf's stream seed — the invariant
80
+ * composition that _defines_ a leaf's stream seed — the invariant
86
81
  * `toStream(algorithm, encode(trace)).seed === stream.seed`. Not a
87
- * {@link RandomSource} member: derivation depends on no per-source
88
- * state (a fork shares only the algorithm), so it is a free function
89
- * of `(algorithm, trace)`. `toRoot` is the only stateful member.
82
+ * {@link RandomSource} member: derivation depends on no per-source state (a
83
+ * fork shares only the algorithm), so it is a free function of `(algorithm,
84
+ * trace)`. `toRoot` is the only stateful member.
90
85
  *
91
- * {@link deriveClock} cannot route through this: a {@link Trace}
92
- * carries `clock`, and `deriveClock` is what produces it. That
93
- * circularity is why `deriveClock` stays below the
94
- * `RandomSource`/`Trace` layer, with a two-element encoding that can
95
- * never collide with `encode`'s seven.
86
+ * {@link deriveClock} cannot route through this: a {@link Trace} carries
87
+ * `clock`, and `deriveClock` is what produces it. That circularity is why
88
+ * `deriveClock` stays below the `RandomSource`/`Trace` layer, with a
89
+ * two-element encoding that can never collide with `encode`'s seven.
96
90
  */
97
91
  export declare function toStreamFromTrace(algorithm: Algorithm, trace: Trace): Stream;
98
92
  /**
99
- * Create a fresh, self-contained {@link RandomSource} — the randomness
100
- * state a single `initialize()` instance owns for its lifetime.
101
- * `options.clock` is baked in here, once, as a plain number — the
102
- * `"seeded"` policy is already resolved by the caller
103
- * (`Instance/Core.ts`'s `resolveClock`) before a source is ever built,
104
- * so every root this source resolves carries the identical instant, and
105
- * `fork` threads it forward unchanged.
93
+ * Create a fresh, self-contained {@link RandomSource} — the randomness state a
94
+ * single `initialize()` instance owns for its lifetime. `options.clock` is
95
+ * baked in here, once, as a plain number — the `"seeded"` policy is already
96
+ * resolved by the caller (`Instance/Core.ts`'s `resolveClock`) before a source
97
+ * is ever built, so every root this source resolves carries the identical
98
+ * instant, and `fork` threads it forward unchanged.
106
99
  */
107
100
  export declare function toRandomSource(options: Options): RandomSource;
@@ -3,25 +3,23 @@ import type { Kind as SchemaKind } from "../Primitive";
3
3
  import { Adaptation, Kind, Meta, type Produces } from "../Types";
4
4
  import { type PlainObject } from "../Utility/Types";
5
5
  /**
6
- * Normalize a Schema, a builder namespace, or an already-built
7
- * Fabricator into a clean, storable Schema — keeping only `[Kind]`/
8
- * `[Meta]`/`[Adaptation]` and discarding `fabricate` and any
9
- * builder-method properties. This is what lets `object`/`array` fields,
10
- * and registry `.extend()` registrations, accept any of the three
11
- * interchangeably while only ever storing inert data: a built
6
+ * Normalize a Schema, a builder namespace, or an already-built Fabricator into
7
+ * a clean, storable Schema — keeping only `[Kind]`/ `[Meta]`/`[Adaptation]` and
8
+ * discarding `fabricate` and any builder-method properties. This is what lets
9
+ * `object`/`array` fields, and registry `.extend()` registrations, accept any
10
+ * of the three interchangeably while only ever storing inert data: a built
12
11
  * Fabricator's `[Meta]` is exactly the Schema it came from.
13
12
  *
14
- * `[Adaptation]` is carried rather than dropped because it is a
15
- * property of the schema itself, not of the builder that produced it:
16
- * a field adapted with `.adapt(adapter, produce)` has to still be
17
- * adapted once normalized into its enclosing `object`/`array`, which
18
- * is where every adapter actually reads it from (see
19
- * `Adapter/TypeBox`'s `build`, which walks `[Meta].definition`).
13
+ * `[Adaptation]` is carried rather than dropped because it is a property of the
14
+ * schema itself, not of the builder that produced it: a field adapted with
15
+ * `.adapt(adapter, produce)` has to still be adapted once normalized into its
16
+ * enclosing `object`/`array`, which is where every adapter actually reads it
17
+ * from (see `Adapter/TypeBox`'s `build`, which walks `[Meta].definition`).
20
18
  *
21
- * `$SchemaProduces` is threaded through in the type only (never read
22
- * or written at runtime) so `ValueOf` stays precise across a
23
- * `toSchema` call dropping it would make every normalized field
24
- * (e.g. every `object`/`array` element) fall back to `unknown`.
19
+ * `$SchemaProduces` is threaded through in the type only (never read or written
20
+ * at runtime) so `ValueOf` stays precise across a `toSchema` call — dropping it
21
+ * would make every normalized field (e.g. every `object`/`array` element) fall
22
+ * back to `unknown`.
25
23
  */
26
24
  export declare function toSchema<$Kind extends string, $Meta extends PlainObject, $Produces = unknown, $Adaptations extends Adaptations = Adaptations>(value: {
27
25
  [Kind]: $Kind;
@@ -35,10 +33,10 @@ export declare function toSchema<$Kind extends string, $Meta extends PlainObject
35
33
  readonly [Adaptation]?: $Adaptations;
36
34
  };
37
35
  /**
38
- * Whether `value`'s basic JS shape is compatible with `kind` (one of
39
- * this library's `[Kind]` literals, e.g. `"string"`, `"object"`,
40
- * `"date"`). Stops at "is this the right *kind of value*" (right JS
41
- * type/shape), not deeper schema constraints like a number's `whereby`
42
- * range, a string's length, or a weighted-enum's member set.
36
+ * Whether `value`'s basic JS shape is compatible with `kind` (one of this
37
+ * library's `[Kind]` literals, e.g. `"string"`, `"object"`, `"date"`). Stops at
38
+ * "is this the right _kind of value_" (right JS type/shape), not deeper schema
39
+ * constraints like a number's `whereby` range, a string's length, or a
40
+ * weighted-enum's member set.
43
41
  */
44
42
  export declare function violatesKind(kind: SchemaKind, value: unknown): boolean;
@@ -2,9 +2,9 @@ import * as primitives from "../Primitive";
2
2
  import { deepMerge, type DeepMerge } from "../Utility/DeepMerge";
3
3
  import { type PlainObject } from "../Utility/Types";
4
4
  /**
5
- * `Primitive/index.ts` also exports the kind-module namespace as
6
- * `Primitive` (`Primitive.boolean.Schema`, …). That is not a builder —
7
- * omitting it here is what keeps `T.Primitive` from existing.
5
+ * `Primitive/index.ts` also exports the kind-module namespace as `Primitive`
6
+ * (`Primitive.boolean.Schema`, …). That is not a builder — omitting it here is
7
+ * what keeps `T.Primitive` from existing.
8
8
  */
9
9
  type Builders = Omit<typeof primitives, "Primitive">;
10
10
  type RegistryInterface<$Registry> = {
@@ -3,13 +3,12 @@ import type { Kind as SchemaKind } from "../Primitive";
3
3
  import type { Adaptation, Kind, Meta, Produces } from "../Types";
4
4
  import type { PlainObject } from "../Utility/Types";
5
5
  /**
6
- * The broadest Schema constraint: some kind, some config. Used by
7
- * compound kinds (`object`/`array`) for their nested fields instead of
8
- * the library-wide Schema union `Primitive/index.ts` assembles — that
9
- * union imports every kind's `Core.ts`, so importing it back from
10
- * within a kind's own `Core.ts` would cycle. Mirrors how
11
- * `array.Definition` uses the equally generic `NaiveFabricator<any>`
12
- * for the same reason.
6
+ * The broadest Schema constraint: some kind, some config. Used by compound
7
+ * kinds (`object`/`array`) for their nested fields instead of the library-wide
8
+ * Schema union `Primitive/index.ts` assembles — that union imports every kind's
9
+ * `Core.ts`, so importing it back from within a kind's own `Core.ts` would
10
+ * cycle. Mirrors how `array.Definition` uses the equally generic
11
+ * `NaiveFabricator<any>` for the same reason.
13
12
  */
14
13
  export type AnySchema = {
15
14
  [Kind]: SchemaKind;
@@ -17,51 +16,45 @@ export type AnySchema = {
17
16
  [Adaptation]?: Adaptations;
18
17
  };
19
18
  /**
20
- * Extract the value a Schema fabricates to, via the phantom,
21
- * runtime-absent `[Produces]` marker every kind's `Schema` carries.
22
- * This is what lets `object`/`array`'s per-field type extraction work
23
- * uniformly across every kind without importing and enumerating them
24
- * (which would cycle, since `object`/`array` can nest any kind,
25
- * including each other) — the same role `fabricate: () => $T` already
26
- * plays for `NaiveFabricator<infer $T>`, one step earlier, before a
27
- * Schema has been built. `[Produces]` is always optional (never
28
- * assigned at runtime — see `DeepMerge`'s handling of optional-only
29
- * keys for why that matters).
19
+ * Extract the value a Schema fabricates to, via the phantom, runtime-absent
20
+ * `[Produces]` marker every kind's `Schema` carries. This is what lets
21
+ * `object`/`array`'s per-field type extraction work uniformly across every kind
22
+ * without importing and enumerating them (which would cycle, since
23
+ * `object`/`array` can nest any kind, including each other) — the same role
24
+ * `fabricate: () => $T` already plays for `NaiveFabricator<infer $T>`, one step
25
+ * earlier, before a Schema has been built. `[Produces]` is always optional
26
+ * (never assigned at runtime — see `DeepMerge`'s handling of optional-only keys
27
+ * for why that matters).
30
28
  *
31
- * `$Bindings` is threaded down into every composite kind's children
32
- * (each `Core` is an `interface` carrying an optional `bindings`, and
33
- * forwards `NonNullable<this["bindings"]>` into its own `[Produces]`).
34
- * It is a substitution slot for a self-reference, not a parameter of
35
- * the schema the way `$Definition`/`$Value` are — every composite
36
- * forwards it unread, so whatever `self` node is buried arbitrarily
37
- * deep still receives it. A node whose `[Produces]` reads
38
- * `bindings[0]` (`recursive.self.Core`) can then close a type-level
39
- * fixed point, which is what makes a self-referential schema resolve
40
- * rather than collapse to `unknown`. Mirrors TypeBox's
41
- * `Static<T, P> = (T & { params: P })['static']`, renamed because
42
- * "params" reads as configuration and this is closer to a
43
- * de-Bruijn-style resolution environment kept as a tuple, as
44
- * TypeBox's is, so a second bound self-reference could occupy index 1
45
- * later without restructuring, though nothing today defines what that
46
- * would mean. `test/ValueOfBindings.types.test.ts` is the only thing
47
- * asserting any of it.
29
+ * `$Bindings` is threaded down into every composite kind's children (each
30
+ * `Core` is an `interface` carrying an optional `bindings`, and forwards
31
+ * `NonNullable<this["bindings"]>` into its own `[Produces]`). It is a
32
+ * substitution slot for a self-reference, not a parameter of the schema the way
33
+ * `$Definition`/`$Value` are — every composite forwards it unread, so whatever
34
+ * `self` node is buried arbitrarily deep still receives it. A node whose
35
+ * `[Produces]` reads `bindings[0]` (`recursive.self.Core`) can then close a
36
+ * type-level fixed point, which is what makes a self-referential schema resolve
37
+ * rather than collapse to `unknown`. Mirrors TypeBox's `Static<T, P> = (T & {
38
+ * params: P })['static']`, renamed because "params" reads as configuration and
39
+ * this is closer to a de-Bruijn-style resolution environment kept as a tuple,
40
+ * as TypeBox's is, so a second bound self-reference could occupy index 1 later
41
+ * without restructuring, though nothing today defines what that would mean.
42
+ * `test/ValueOfBindings.types.test.ts` is the only thing asserting any of it.
48
43
  *
49
44
  * Three details here are load-bearing, and each looks simplifiable:
50
45
  *
51
- * - **Indexed access, not a conditional `infer`.** Writing this as
52
- * `($Schema & { bindings: $Bindings }) extends { [Produces]?: infer $T } ? ...`
53
- * fails with `TS2615` — the bindings do not collapse, and the error
54
- * surfaces as `unknown[] & [...]`.
55
- * - **`Required<>`, never `Exclude<..., undefined>`.** Both strip the
56
- * `| undefined` that indexing an optional property adds, but
57
- * `Exclude` also strips the *legitimate* `undefined` out of
58
- * `nullish`/`undefinable`/`object.optional`/`undefined`'s own value
59
- * types.
60
- * - **The `extends` guard belongs inside, not on the parameter.**
61
- * Constraining `$Schema` instead would force `[Produces]` onto
62
- * `AnySchema` (which deliberately omits it), and that shifts
63
- * variance enough to break `.as`'s contravariant parameter check in
64
- * `Fabrication.types.test.ts`.
46
+ * - **Indexed access, not a conditional `infer`.** Writing this as `($Schema & {
47
+ * bindings: $Bindings }) extends { [Produces]?: infer $T } ? ...` fails with
48
+ * `TS2615` — the bindings do not collapse, and the error surfaces as
49
+ * `unknown[] & [...]`.
50
+ * - **`Required<>`, never `Exclude<..., undefined>`.** Both strip the `|
51
+ * undefined` that indexing an optional property adds, but `Exclude` also
52
+ * strips the _legitimate_ `undefined` out of
53
+ * `nullish`/`undefinable`/`object.optional`/`undefined`'s own value types.
54
+ * - **The `extends` guard belongs inside, not on the parameter.** Constraining
55
+ * `$Schema` instead would force `[Produces]` onto `AnySchema` (which
56
+ * deliberately omits it), and that shifts variance enough to break `.as`'s
57
+ * contravariant parameter check in `Fabrication.types.test.ts`.
65
58
  */
66
59
  export type ValueOf<$Schema, $Bindings extends unknown[] = []> = $Schema extends {
67
60
  readonly [Produces]?: unknown;
@@ -6,60 +6,55 @@ export declare const Produces: unique symbol;
6
6
  export declare const Replace: unique symbol;
7
7
  export declare const Fixed: unique symbol;
8
8
  /**
9
- * Tags a `Seed` as composing onto whatever base is in effect, rather
10
- * than replacing it — the reading a bare `seed` has everywhere else in
11
- * this library. `layer()` (`Random/index.ts`) is the only producer; a
12
- * caller never names this symbol, mirroring `[Replace]`. Unlike every
13
- * other symbol in this file, it tags a config value (a `Seed`), not a
14
- * Schema or Fabricator — see `Random/Types.ts`'s `Layered`.
9
+ * Tags a `Seed` as composing onto whatever base is in effect, rather than
10
+ * replacing it — the reading a bare `seed` has everywhere else in this library.
11
+ * `layer()` (`Random/index.ts`) is the only producer; a caller never names this
12
+ * symbol, mirroring `[Replace]`. Unlike every other symbol in this file, it
13
+ * tags a config value (a `Seed`), not a Schema or Fabricator — see
14
+ * `Random/Types.ts`'s `Layered`.
15
15
  */
16
16
  export declare const Layer: unique symbol;
17
17
  /**
18
- * The Fabricators that exist at build time — whatever
19
- * `Constructor.ts`'s `make` already constructed for this node's nested
20
- * schemas before handing them to the kind's own `Fabricator()` factory.
21
- * Every composite kind whose construction receives already-dispatched
22
- * Fabricators carries this: `object` (its `Fields` map), `tuple`
23
- * (`elements`, in slot order), `choice` (the dispatched options, in
24
- * `[Meta].items` order — weights stay in `[Meta]`), `array` (the single
18
+ * The Fabricators that exist at build time — whatever `Constructor.ts`'s `make`
19
+ * already constructed for this node's nested schemas before handing them to the
20
+ * kind's own `Fabricator()` factory. Every composite kind whose construction
21
+ * receives already-dispatched Fabricators carries this: `object` (its `Fields`
22
+ * map), `tuple` (`elements`, in slot order), `choice` (the dispatched options,
23
+ * in `[Meta].items` order — weights stay in `[Meta]`), `array` (the single
25
24
  * shared `element`), `record` (`{ key, value }`), and each of
26
- * `nullable`/`nullish`/`undefinable`/`object.omittable`/`object.optional`
27
- * (the single wrapped `source`).
25
+ * `nullable`/`nullish`/`undefinable`/`object.omittable`/`object.optional` (the
26
+ * single wrapped `source`).
28
27
  *
29
- * The payload shape is kind-private, exactly as `[Meta]` is — nothing
30
- * outside a kind's own files interprets another kind's `[Children]`
31
- * shape.
28
+ * The payload shape is kind-private, exactly as `[Meta]` is — nothing outside a
29
+ * kind's own files interprets another kind's `[Children]` shape.
32
30
  *
33
- * `recursive` carries none: its expansions are a function of draws
34
- * made *during* `fabricate()` (`recursive/Fabricator.ts`), one
35
- * throwaway Fabricator per `self` occurrence, so there is no stable
36
- * child at build time to point at. `body`/`terminal` are already on
37
- * `[Meta]` as ordinary sub-Schemas for anything that needs to
38
- * introspect them.
31
+ * `recursive` carries none: its expansions are a function of draws made
32
+ * _during_ `fabricate()` (`recursive/Fabricator.ts`), one throwaway Fabricator
33
+ * per `self` occurrence, so there is no stable child at build time to point at.
34
+ * `body`/`terminal` are already on `[Meta]` as ordinary sub-Schemas for
35
+ * anything that needs to introspect them.
39
36
  */
40
37
  export declare const Children: unique symbol;
41
38
  /**
42
- * A per-library map of external-schema overrides
43
- * (`{ typebox: (schema) => TSchema }`), written by every kind's
44
- * `.adapt(adapter, produce)` builder method and read only by
45
- * `src/Adapter/*` completely inert for fabrication, which never
46
- * looks at it. A map rather than a single function so one schema can
47
- * map to several external libraries at once; see `Adapter/Types.ts`
48
- * for the registry of supported libraries, and `Adapter/TypeBox`'s
39
+ * A per-library map of external-schema overrides (`{ typebox: (schema) =>
40
+ * TSchema }`), written by every kind's `.adapt(adapter, produce)` builder
41
+ * method and read only by `src/Adapter/*` — completely inert for fabrication,
42
+ * which never looks at it. A map rather than a single function so one schema
43
+ * can map to several external libraries at once; see `Adapter/Types.ts` for the
44
+ * registry of supported libraries, and `Adapter/TypeBox`'s
49
45
  * `ToTypeBox`/`convert` for the reading end.
50
46
  */
51
47
  export declare const Adaptation: unique symbol;
52
48
  /**
53
- * A public sentinel with two uses that share one meaning — "this key
54
- * does not appear in the fabricated object": `object.omittable`'s and
55
- * `object.optional`'s Fabricators return it internally when their roll
56
- * lands on absence (read by `object/Fabricator.ts`'s fabricate loop,
57
- * never surfaced to a caller fabricating normally), and it is also the
58
- * value a caller passes in `.override(...)`/`.fabricate(overrides)` to
59
- * force an omittable or optional field off — `{ a: undefined }`
60
- * present-as-`undefined` is not expressible this way, since that would
61
- * conflate with a genuinely present-but-`undefined` value (see
62
- * `Primitive/undefined`, and `Primitive/object/optional`, which
49
+ * A public sentinel with two uses that share one meaning — "this key does not
50
+ * appear in the fabricated object": `object.omittable`'s and
51
+ * `object.optional`'s Fabricators return it internally when their roll lands on
52
+ * absence (read by `object/Fabricator.ts`'s fabricate loop, never surfaced to a
53
+ * caller fabricating normally), and it is also the value a caller passes in
54
+ * `.override(...)`/`.fabricate(overrides)` to force an omittable or optional
55
+ * field off — `{ a: undefined }` present-as-`undefined` is not expressible this
56
+ * way, since that would conflate with a genuinely present-but-`undefined` value
57
+ * (see `Primitive/undefined`, and `Primitive/object/optional`, which
63
58
  * distinguishes the two outcomes).
64
59
  */
65
60
  export declare const Omitted: unique symbol;
@@ -70,9 +65,8 @@ export declare const Omitted: unique symbol;
70
65
  export type Buildable = AnySchema | Fabricator<any>;
71
66
  /**
72
67
  * The span of valid `Date` time values: ±8.64e15 ms from the epoch. An
73
- * ECMAScript spec fact (`Date`'s own representable range), not a
74
- * `date`-kind detail — lives here rather than in `Primitive/date/` so
75
- * `Random/index.ts`'s `deriveClock` can use it without importing from
76
- * `Primitive/`.
68
+ * ECMAScript spec fact (`Date`'s own representable range), not a `date`-kind
69
+ * detail — lives here rather than in `Primitive/date/` so `Random/index.ts`'s
70
+ * `deriveClock` can use it without importing from `Primitive/`.
77
71
  */
78
72
  export declare const MAX_TIME = 8640000000000000;
@@ -5,30 +5,39 @@ import { type PlainObject } from "./Types";
5
5
  */
6
6
  export declare function inline<$T>(fn: () => $T): $T;
7
7
  export declare function never(_: never): never;
8
+ /**
9
+ * Does nothing, deliberately. For attaching a settled handler to a promise
10
+ * being abandoned, so it cannot surface as an unhandled rejection.
11
+ */
12
+ export declare function noop(): void;
13
+ /**
14
+ * Whether a value is thenable — the structural test, not `instanceof Promise`,
15
+ * since an `async` function's return may be any conforming implementation.
16
+ */
17
+ export declare function isThenable(value: unknown): value is PromiseLike<unknown>;
8
18
  /**
9
19
  * @see https://github.com/microsoft/TypeScript/issues/17002
10
20
  */
11
21
  export declare function isArray(candidate: unknown): candidate is Array<unknown> | ReadonlyArray<unknown>;
12
22
  export declare function isPollutionKey(key: string): boolean;
13
23
  /**
14
- * A plain `{}`/`Object.create(null)` object — not an array, `Date`,
15
- * class instance, etc.
24
+ * A plain `{}`/`Object.create(null)` object — not an array, `Date`, class
25
+ * instance, etc.
16
26
  */
17
27
  export declare function isPlainObject(value: unknown): value is PlainObject;
18
28
  /**
19
29
  * Keys worth carrying across a merge. String keys are subject to the
20
30
  * prototype-pollution guard; symbol keys (e.g. a fabricator's
21
31
  * `[Kind]`/`[Meta]`) are carried through — dropping them would strip a
22
- * primitive's identity when it is extended — except `Replace`, which is
23
- * a directive consumed here rather than data to propagate.
32
+ * primitive's identity when it is extended — except `Replace`, which is a
33
+ * directive consumed here rather than data to propagate.
24
34
  */
25
35
  export declare function mergeableKeys(source: PlainObject): Array<string | symbol>;
26
36
  /**
27
- * Tag an object so a subsequent deep or shallow merge replaces the
28
- * left-hand operand wholesale instead of merging into it. The
29
- * `[Replace]` directive is consumed by the merge and does not appear
30
- * on the result, so callers can wrap a replacement value without ever
31
- * naming the symbol.
37
+ * Tag an object so a subsequent deep or shallow merge replaces the left-hand
38
+ * operand wholesale instead of merging into it. The `[Replace]` directive is
39
+ * consumed by the merge and does not appear on the result, so callers can wrap
40
+ * a replacement value without ever naming the symbol.
32
41
  */
33
42
  export declare function replace<$T extends PlainObject>(value: $T): $T & {
34
43
  [Replace]: true;