@ghostry/fabricator 0.0.1 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (139) hide show
  1. package/README.md +18 -12
  2. package/dist/esm/Adapter/Core.js +3 -3
  3. package/dist/esm/Enumeration/Enumerate.js +16 -13
  4. package/dist/esm/Error/index.js +16 -8
  5. package/dist/esm/Fabricator/Constructor.js +12 -14
  6. package/dist/esm/Harnessing/Core.js +30 -0
  7. package/dist/esm/Harnessing/Salt.js +12 -0
  8. package/dist/esm/Harnessing/Types.js +1 -0
  9. package/dist/esm/Instance/Core.js +25 -41
  10. package/dist/esm/Instance/Stack/Async.js +10 -0
  11. package/dist/esm/Instance/Stack/Sync.js +16 -0
  12. package/dist/esm/Primitive/bigint/Registry.js +12 -12
  13. package/dist/esm/Primitive/boolean/Registry.js +2 -1
  14. package/dist/esm/Primitive/date/Registry.js +15 -14
  15. package/dist/esm/Primitive/null/Registry.js +2 -1
  16. package/dist/esm/Primitive/number/Registry.js +18 -17
  17. package/dist/esm/Primitive/recursive/Fabricator.js +1 -1
  18. package/dist/esm/Primitive/symbol/Registry.js +2 -1
  19. package/dist/esm/Primitive/undefined/Registry.js +2 -1
  20. package/dist/esm/Random/index.js +24 -79
  21. package/dist/esm/Utility/Core.js +6 -1
  22. package/dist/esm/adapting.js +2 -0
  23. package/dist/esm/harnessing.js +1 -0
  24. package/dist/esm/index.js +5 -4
  25. package/dist/esm/internal.js +2 -2
  26. package/dist/types/Adapter/Core.d.ts +30 -33
  27. package/dist/types/Adapter/Types.d.ts +78 -88
  28. package/dist/types/Bound.d.ts +15 -15
  29. package/dist/types/Distribution/index.d.ts +54 -61
  30. package/dist/types/Enumeration/Enumerate.d.ts +24 -24
  31. package/dist/types/Enumeration/Plan.d.ts +22 -26
  32. package/dist/types/Enumeration/Types.d.ts +38 -43
  33. package/dist/types/Error/index.d.ts +103 -89
  34. package/dist/types/Fabricator/Constructor.d.ts +24 -26
  35. package/dist/types/Fabricator/Types.d.ts +73 -81
  36. package/dist/types/Harnessing/Core.d.ts +43 -0
  37. package/dist/types/Harnessing/Salt.d.ts +31 -0
  38. package/dist/types/Harnessing/Types.d.ts +79 -0
  39. package/dist/types/Instance/Core.d.ts +38 -74
  40. package/dist/types/Instance/Stack/Async.d.ts +14 -0
  41. package/dist/types/Instance/Stack/Sync.d.ts +14 -0
  42. package/dist/types/Instance/Types.d.ts +98 -102
  43. package/dist/types/Primitive/always/Schema.d.ts +8 -8
  44. package/dist/types/Primitive/always/Types.d.ts +7 -7
  45. package/dist/types/Primitive/array/Registry.d.ts +10 -8
  46. package/dist/types/Primitive/array/Schema.d.ts +4 -5
  47. package/dist/types/Primitive/array/Types.d.ts +6 -6
  48. package/dist/types/Primitive/bigint/Registry.d.ts +6 -6
  49. package/dist/types/Primitive/bigint/Schema.d.ts +8 -8
  50. package/dist/types/Primitive/bigint/Types.d.ts +5 -5
  51. package/dist/types/Primitive/boolean/Outcomes.d.ts +8 -8
  52. package/dist/types/Primitive/boolean/Registry.d.ts +2 -12
  53. package/dist/types/Primitive/boolean/Schema.d.ts +8 -8
  54. package/dist/types/Primitive/boolean/Types.d.ts +3 -3
  55. package/dist/types/Primitive/choice/Fabricator.d.ts +6 -7
  56. package/dist/types/Primitive/choice/Registry.d.ts +13 -13
  57. package/dist/types/Primitive/choice/Schema.d.ts +6 -6
  58. package/dist/types/Primitive/choice/Types.d.ts +11 -11
  59. package/dist/types/Primitive/date/Registry.d.ts +25 -48
  60. package/dist/types/Primitive/date/Schema.d.ts +9 -10
  61. package/dist/types/Primitive/date/Types.d.ts +4 -4
  62. package/dist/types/Primitive/enum/Registry.d.ts +13 -13
  63. package/dist/types/Primitive/enum/Schema.d.ts +5 -5
  64. package/dist/types/Primitive/enum/Types.d.ts +17 -19
  65. package/dist/types/Primitive/namespace.d.ts +10 -10
  66. package/dist/types/Primitive/null/Registry.d.ts +2 -2
  67. package/dist/types/Primitive/null/Schema.d.ts +2 -2
  68. package/dist/types/Primitive/null/Types.d.ts +3 -3
  69. package/dist/types/Primitive/nullable/Fabricator.d.ts +7 -7
  70. package/dist/types/Primitive/nullable/Schema.d.ts +13 -13
  71. package/dist/types/Primitive/nullable/Types.d.ts +9 -10
  72. package/dist/types/Primitive/nullish/Fabricator.d.ts +12 -13
  73. package/dist/types/Primitive/nullish/Schema.d.ts +8 -8
  74. package/dist/types/Primitive/nullish/Types.d.ts +12 -13
  75. package/dist/types/Primitive/number/Registry.d.ts +20 -38
  76. package/dist/types/Primitive/number/Schema.d.ts +11 -12
  77. package/dist/types/Primitive/number/Types.d.ts +13 -13
  78. package/dist/types/Primitive/number/defaults.d.ts +3 -3
  79. package/dist/types/Primitive/object/Fabricator.d.ts +15 -15
  80. package/dist/types/Primitive/object/Registry.d.ts +8 -8
  81. package/dist/types/Primitive/object/Schema.d.ts +10 -10
  82. package/dist/types/Primitive/object/Types.d.ts +20 -22
  83. package/dist/types/Primitive/object/compute/Fabricator.d.ts +4 -5
  84. package/dist/types/Primitive/object/compute/Schema.d.ts +4 -4
  85. package/dist/types/Primitive/object/compute/Types.d.ts +19 -20
  86. package/dist/types/Primitive/object/omittable/Fabricator.d.ts +10 -10
  87. package/dist/types/Primitive/object/omittable/Outcomes.d.ts +2 -2
  88. package/dist/types/Primitive/object/omittable/Schema.d.ts +11 -11
  89. package/dist/types/Primitive/object/omittable/Types.d.ts +14 -15
  90. package/dist/types/Primitive/object/optional/Fabricator.d.ts +16 -18
  91. package/dist/types/Primitive/object/optional/Outcomes.d.ts +2 -2
  92. package/dist/types/Primitive/object/optional/Schema.d.ts +4 -4
  93. package/dist/types/Primitive/object/optional/Types.d.ts +17 -17
  94. package/dist/types/Primitive/opaque/Registry.d.ts +3 -3
  95. package/dist/types/Primitive/opaque/Schema.d.ts +8 -9
  96. package/dist/types/Primitive/record/Registry.d.ts +8 -6
  97. package/dist/types/Primitive/record/Schema.d.ts +9 -11
  98. package/dist/types/Primitive/record/Types.d.ts +25 -25
  99. package/dist/types/Primitive/recursive/Fabricator.d.ts +20 -21
  100. package/dist/types/Primitive/recursive/Registry.d.ts +6 -7
  101. package/dist/types/Primitive/recursive/Schema.d.ts +8 -8
  102. package/dist/types/Primitive/recursive/Terminate.d.ts +13 -14
  103. package/dist/types/Primitive/recursive/Types.d.ts +31 -31
  104. package/dist/types/Primitive/recursive/self/Fabricator.d.ts +11 -12
  105. package/dist/types/Primitive/recursive/self/Schema.d.ts +10 -10
  106. package/dist/types/Primitive/recursive/self/Types.d.ts +7 -8
  107. package/dist/types/Primitive/string/Constants.d.ts +12 -13
  108. package/dist/types/Primitive/string/Fabricator.d.ts +2 -2
  109. package/dist/types/Primitive/string/Registry.d.ts +10 -16
  110. package/dist/types/Primitive/string/Schema.d.ts +5 -5
  111. package/dist/types/Primitive/string/Types.d.ts +17 -17
  112. package/dist/types/Primitive/symbol/Fabricator.d.ts +2 -2
  113. package/dist/types/Primitive/symbol/Registry.d.ts +4 -11
  114. package/dist/types/Primitive/symbol/Schema.d.ts +6 -6
  115. package/dist/types/Primitive/symbol/Types.d.ts +2 -2
  116. package/dist/types/Primitive/tuple/Fabricator.d.ts +7 -8
  117. package/dist/types/Primitive/tuple/Schema.d.ts +5 -5
  118. package/dist/types/Primitive/tuple/Types.d.ts +24 -25
  119. package/dist/types/Primitive/undefinable/Fabricator.d.ts +7 -7
  120. package/dist/types/Primitive/undefinable/Schema.d.ts +13 -13
  121. package/dist/types/Primitive/undefinable/Types.d.ts +10 -10
  122. package/dist/types/Primitive/undefined/Registry.d.ts +2 -2
  123. package/dist/types/Primitive/undefined/Schema.d.ts +4 -4
  124. package/dist/types/Primitive/undefined/Types.d.ts +3 -3
  125. package/dist/types/Random/Generator/sfc32.d.ts +4 -4
  126. package/dist/types/Random/Types.d.ts +151 -293
  127. package/dist/types/Random/index.d.ts +56 -81
  128. package/dist/types/Schema/Core.d.ts +19 -21
  129. package/dist/types/Schema/Registry.d.ts +3 -3
  130. package/dist/types/Schema/Types.d.ts +41 -48
  131. package/dist/types/Types.d.ts +39 -45
  132. package/dist/types/Utility/Core.d.ts +18 -9
  133. package/dist/types/adapting.d.ts +32 -0
  134. package/dist/types/harnessing.d.ts +30 -0
  135. package/dist/types/index.d.ts +95 -128
  136. package/dist/types/internal.d.ts +53 -40
  137. package/package.json +39 -7
  138. package/dist/esm/Random/CallSite.js +0 -56
  139. package/dist/types/Random/CallSite.d.ts +0 -59
@@ -1,14 +1,14 @@
1
1
  import type { Adaptations } from "../../Adapter/Types";
2
2
  import type { Adaptation, Kind, Meta, Produces } from "../../Types";
3
3
  /**
4
- * Any value at all. Deliberately unconstrained: fabricating a fixed value
5
- * needs nothing of it. A `string | number | boolean` cap would be TypeBox's
6
- * `TLiteralValue` leaking into the primitive. Narrowing back to what a
7
- * given external schema library can express is that library's adapter's
8
- * job — see `Adapter/TypeBox`'s `toConst`.
4
+ * Any value at all. Deliberately unconstrained: fabricating a fixed value needs
5
+ * nothing of it. A `string | number | boolean` cap would be TypeBox's
6
+ * `TLiteralValue` leaking into the primitive. Narrowing back to what a given
7
+ * external schema library can express is that library's adapter's job — see
8
+ * `Adapter/TypeBox`'s `toConst`.
9
9
  *
10
- * Kept as a named alias: it is the public name for this kind's domain, and
11
- * both `Registry.ts` and `Schema.ts` use it as a bound.
10
+ * Kept as a named alias: it is the public name for this kind's domain, and both
11
+ * `Registry.ts` and `Schema.ts` use it as a bound.
12
12
  */
13
13
  export type Value = unknown;
14
14
  export type Fabricated<$Value extends Value> = $Value;
@@ -1,18 +1,20 @@
1
1
  import type { Produce } from "../../Random/Types";
2
2
  import { Schema } from "./Schema";
3
3
  import type { Definition, Fabricated, InputWhereby } from "./Types";
4
- export default function <const $Definition extends Definition>(definition: $Definition): {
4
+ type ThisRegistry<$Definition extends Definition> = {
5
5
  /**
6
- * An array of `definition`, repeated `whereby.length` times — either a
7
- * fixed count, or uniformly across `[length.min, length.max]` with
8
- * `length.min` defaulting to inclusive 0, so an empty array is a
9
- * legitimate outcome when no `min` is given. Exclusive ends use a Bound
10
- * object; a bare `length: N` is stored as min = max = N inclusive.
6
+ * An array of `definition`, repeated `whereby.length` times — either a fixed
7
+ * count, or uniformly across `[length.min, length.max]` with `length.min`
8
+ * defaulting to inclusive 0, so an empty array is a legitimate outcome when
9
+ * no `min` is given. Exclusive ends use a Bound object; a bare `length: N` is
10
+ * stored as min = max = N inclusive.
11
11
  */
12
12
  whereby: (whereby: InputWhereby) => Schema<$Definition>;
13
13
  /**
14
- * An array whose production is `produce`, in full, instead of drawn
15
- * element by element.
14
+ * An array whose production is `produce`, in full, instead of drawn element
15
+ * by element.
16
16
  */
17
17
  as: (produce: Produce<Fabricated<$Definition>>) => Schema<$Definition>;
18
18
  };
19
+ export default function <const $Definition extends Definition>(definition: $Definition): ThisRegistry<$Definition>;
20
+ export {};
@@ -9,14 +9,13 @@ import type { Core, Definition, Fabricated } from "./Types";
9
9
  export interface Schema<$Definition extends Definition = Definition, $Adaptations extends Adaptations = {}> extends Core<$Definition, $Adaptations> {
10
10
  /**
11
11
  * Layer an opaque production on this schema's existing `[Meta]` — carrying
12
- * `whereby`/`definition` forward, not discarding them, so a later
13
- * `.as(...)` (or future validation of `produce`) still has them to check
14
- * against.
12
+ * `whereby`/`definition` forward, not discarding them, so a later `.as(...)`
13
+ * (or future validation of `produce`) still has them to check against.
15
14
  */
16
15
  as: (produce: Produce<Fabricated<$Definition>>) => Schema<$Definition, $Adaptations>;
17
16
  /**
18
- * Override what this schema maps to in one or more external schema
19
- * libraries — see `string/Schema.ts`'s `adapt` for the full contract.
17
+ * Override what this schema maps to in one or more external schema libraries
18
+ * — see `string/Schema.ts`'s `adapt` for the full contract.
20
19
  */
21
20
  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>>>;
22
21
  }
@@ -19,12 +19,12 @@ export type Whereby = {
19
19
  };
20
20
  /**
21
21
  * `whereby` (a length spec — no natural bound to fuzz to, so unlike
22
- * `number`/`date` there's no bare form), optionally overridden by an
23
- * opaque `as` production, carried alongside `whereby` rather than replacing
24
- * it (when `whereby` was already set) so a prior length spec survives `as`
25
- * for future validation. `definition` stays required regardless — it's
26
- * known at `T.array(...)` call time and describes the element shape TypeBox
27
- * derives either way.
22
+ * `number`/`date` there's no bare form), optionally overridden by an opaque
23
+ * `as` production, carried alongside `whereby` rather than replacing it (when
24
+ * `whereby` was already set) so a prior length spec survives `as` for future
25
+ * validation. `definition` stays required regardless — it's known at
26
+ * `T.array(...)` call time and describes the element shape TypeBox derives
27
+ * either way.
28
28
  */
29
29
  export type Meta<$Definition extends Definition = Definition> = {
30
30
  definition: $Definition;
@@ -4,16 +4,16 @@ import { Schema } from "./Schema";
4
4
  import type { Fabricated, InputWhereby, Whereby } from "./Types";
5
5
  declare const _default: {
6
6
  /**
7
- * The builder carries the primitive's `[Kind]` so it can be named directly
8
- * as a `compute` source — which derives its schema by kind — without
9
- * first satisfying a `whereby`.
7
+ * The builder carries the primitive's `[Kind]` so it can be named directly as
8
+ * a `compute` source — which derives its schema by kind — without first
9
+ * satisfying a `whereby`.
10
10
  */
11
11
  [Kind]: "bigint";
12
12
  whereby: (whereby: InputWhereby) => Schema<{
13
13
  whereby: Whereby;
14
- }, {}>;
14
+ }>;
15
15
  as: (produce: Produce<Fabricated>) => Schema<{
16
- produce: Produce<bigint>;
17
- }, {}>;
16
+ produce: Produce<Fabricated>;
17
+ }>;
18
18
  };
19
19
  export default _default;
@@ -3,13 +3,13 @@ import type { Adaptations, Adapter, Adapting, WithAdaptations } from "../../Adap
3
3
  import type { Produce } from "../../Random/Types";
4
4
  import type { Core, Fabricated, Meta as ThisMeta } from "./Types";
5
5
  /**
6
- * Buildable `bigint` recipe: a range (`whereby` — required, like `string`;
7
- * no natural bound to fuzz to), or opaque production via `as`.
6
+ * Buildable `bigint` recipe: a range (`whereby` — required, like `string`; no
7
+ * natural bound to fuzz to), or opaque production via `as`.
8
8
  *
9
- * `$Meta` is generic (defaulting to the full `Meta` union) so builder
10
- * return types stay narrow — see `number/Schema.ts`. `$Adaptations` is
11
- * threaded through every builder method for the same reason — see
12
- * `string/Schema.ts`'s `adapt`.
9
+ * `$Meta` is generic (defaulting to the full `Meta` union) so builder return
10
+ * types stay narrow — see `number/Schema.ts`. `$Adaptations` is threaded
11
+ * through every builder method for the same reason — see `string/Schema.ts`'s
12
+ * `adapt`.
13
13
  */
14
14
  export interface Schema<$Meta extends ThisMeta = ThisMeta, $Adaptations extends Adaptations = {}> extends Core<$Meta, $Adaptations> {
15
15
  /**
@@ -19,8 +19,8 @@ export interface Schema<$Meta extends ThisMeta = ThisMeta, $Adaptations extends
19
19
  */
20
20
  as: (produce: Produce<Fabricated>) => Schema<$Meta, $Adaptations>;
21
21
  /**
22
- * Override what this schema maps to in one or more external schema
23
- * libraries — see `string/Schema.ts`'s `adapt` for the full contract.
22
+ * Override what this schema maps to in one or more external schema libraries
23
+ * — see `string/Schema.ts`'s `adapt` for the full contract.
24
24
  */
25
25
  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>>>;
26
26
  }
@@ -12,11 +12,11 @@ export type Whereby = {
12
12
  };
13
13
  export type Fabricated = bigint;
14
14
  /**
15
- * A ranged bigint, drawn via `whereby` — no natural bound to fuzz to, so
16
- * unlike `number`/`date` there's no bare form — optionally overridden by
17
- * an opaque `as` production, carried alongside `whereby` rather than
18
- * replacing it (when `whereby` was already set) so a prior range survives
19
- * `as` for future validation.
15
+ * A ranged bigint, drawn via `whereby` — no natural bound to fuzz to, so unlike
16
+ * `number`/`date` there's no bare form — optionally overridden by an opaque
17
+ * `as` production, carried alongside `whereby` rather than replacing it (when
18
+ * `whereby` was already set) so a prior range survives `as` for future
19
+ * validation.
20
20
  */
21
21
  export type Meta = {
22
22
  whereby: Whereby;
@@ -1,12 +1,12 @@
1
1
  /**
2
- * Weight *keys* for `.weighted(...)`, not the boolean values themselves.
3
- * Derived so `assertDrawableKeyedWeights` and `Enumeration/Plan.ts`
4
- * cannot drift from the named outcome set.
2
+ * Weight _keys_ for `.weighted(...)`, not the boolean values themselves.
3
+ * Derived so `assertDrawableKeyedWeights` and `Enumeration/Plan.ts` cannot
4
+ * drift from the named outcome set.
5
5
  *
6
- * Lives here rather than `Types.ts` so that file stays type-only. A
7
- * value export alongside `export type Fabricated = boolean` makes the
8
- * module a value module, and `export * as boolean` in
9
- * `Primitive/namespace.ts` then resolves `boolean` to the namespace —
10
- * a cycle that drops `[Kind]`/`[Meta]` off `Core`.
6
+ * Lives here rather than `Types.ts` so that file stays type-only. A value
7
+ * export alongside `export type Fabricated = boolean` makes the module a value
8
+ * module, and `export * as boolean` in `Primitive/namespace.ts` then resolves
9
+ * `boolean` to the namespace — a cycle that drops `[Kind]`/`[Meta]` off
10
+ * `Core`.
11
11
  */
12
12
  export declare const outcomes: readonly ["true", "false"];
@@ -1,14 +1,4 @@
1
1
  import type { Adaptations } from "../../Adapter/Types";
2
- import { Adaptation, Kind, Meta, Produces } from "../../Types";
3
2
  import { Schema } from "./Schema";
4
- import type { Fabricated } from "./Types";
5
- declare const _default: {
6
- [Kind]: "boolean";
7
- [Meta]: {};
8
- [Produces]?: Fabricated;
9
- [Adaptation]?: Adaptations;
10
- as: (produce: import("../../Random/Types").Produce<Fabricated>) => Schema<{}, Adaptations>;
11
- weighted: (weights: import("./Types").Weights) => Schema<{}, Adaptations>;
12
- 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>>>;
13
- };
14
- export default _default;
3
+ declare const registry: Schema<{}, Adaptations>;
4
+ export default registry;
@@ -3,13 +3,13 @@ import type { Adaptations, Adapter, Adapting, WithAdaptations } from "../../Adap
3
3
  import type { Produce } from "../../Random/Types";
4
4
  import type { Core, Fabricated, Meta as ThisMeta, Weights } from "./Types";
5
5
  /**
6
- * Buildable `boolean` recipe: an even coin flip, a weighted one
7
- * (`weights`), or opaque production via `as`.
6
+ * Buildable `boolean` recipe: an even coin flip, a weighted one (`weights`), or
7
+ * opaque production via `as`.
8
8
  *
9
- * `$Meta` is generic (defaulting to the full `Meta` union) so builder
10
- * return types stay narrow — see `number/Schema.ts`. `$Adaptations` is
11
- * threaded through every builder method for the same reason — see
12
- * `string/Schema.ts`'s `adapt`.
9
+ * `$Meta` is generic (defaulting to the full `Meta` union) so builder return
10
+ * types stay narrow — see `number/Schema.ts`. `$Adaptations` is threaded
11
+ * through every builder method for the same reason — see `string/Schema.ts`'s
12
+ * `adapt`.
13
13
  */
14
14
  export interface Schema<$Meta extends ThisMeta = ThisMeta, $Adaptations extends Adaptations = {}> extends Core<$Meta, $Adaptations> {
15
15
  /**
@@ -20,8 +20,8 @@ export interface Schema<$Meta extends ThisMeta = ThisMeta, $Adaptations extends
20
20
  as: (produce: Produce<Fabricated>) => Schema<$Meta, $Adaptations>;
21
21
  weighted: (weights: Weights) => Schema<$Meta, $Adaptations>;
22
22
  /**
23
- * Override what this schema maps to in one or more external schema
24
- * libraries — see `string/Schema.ts`'s `adapt` for the full contract.
23
+ * Override what this schema maps to in one or more external schema libraries
24
+ * — see `string/Schema.ts`'s `adapt` for the full contract.
25
25
  */
26
26
  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>>>;
27
27
  }
@@ -10,9 +10,9 @@ export type Weights = {
10
10
  false: number;
11
11
  };
12
12
  /**
13
- * An even coin flip, or a weighted one via `weights`, optionally overridden
14
- * by an opaque `as` production — carried alongside `weights` rather than
15
- * replacing it, so a prior weighting survives `as` for future validation.
13
+ * An even coin flip, or a weighted one via `weights`, optionally overridden by
14
+ * an opaque `as` production — carried alongside `weights` rather than replacing
15
+ * it, so a prior weighting survives `as` for future validation.
16
16
  */
17
17
  export type Meta = {
18
18
  produce?: Produce<Fabricated>;
@@ -20,13 +20,12 @@ export type Fabricator<$Schema extends {
20
20
  schema: Schema<$Schema[typeof Meta]["items"], AdaptationsOf<$Schema>>;
21
21
  };
22
22
  /**
23
- * `weightings` are each option's *already-dispatched* Fabricator, one per
23
+ * `weightings` are each option's _already-dispatched_ Fabricator, one per
24
24
  * `[Meta].items` entry, built by `Constructor.ts`'s `make` before this call —
25
- * mirrors `array.Fabricator`'s `element`, just one per option instead of
26
- * one shared across every element. The weighted pick happens on this
27
- * field's private stream; only the chosen option's `fabricate()` is called,
28
- * so an unpicked option never advances its stream (safe for the same reason
29
- * skipping `object.omittable`'s inner draw is — see CLAUDE.md's
30
- * "Randomness").
25
+ * mirrors `array.Fabricator`'s `element`, just one per option instead of one
26
+ * shared across every element. The weighted pick happens on this field's
27
+ * private stream; only the chosen option's `fabricate()` is called, so an
28
+ * unpicked option never advances its stream (safe for the same reason skipping
29
+ * `object.omittable`'s inner draw is — see CLAUDE.md's "Randomness").
31
30
  */
32
31
  export declare function Fabricator<$Items extends Items>(context: FabricatorContext<Schema<$Items>>, weightings: ReadonlyArray<readonly [number, NaiveFabricator<any>]>): Fabricator<Schema<$Items>>;
@@ -5,33 +5,33 @@ import type { Item, Items } from "./Types";
5
5
  * per-position option types (`{ [K in keyof $Items]: ... }` walks a tuple
6
6
  * position-by-position, unlike `ReadonlyArray<...>`'s `.map()`, which only
7
7
  * remembers the union of every element it saw). This is what lets
8
- * `Adapter/TypeBox` recover real arity later and mirror TypeBox's
9
- * `Union<T>` collapse-for-a-single-option — see `Types.ts`'s `Items`.
8
+ * `Adapter/TypeBox` recover real arity later and mirror TypeBox's `Union<T>`
9
+ * collapse-for-a-single-option — see `Types.ts`'s `Items`.
10
10
  */
11
11
  type Weighted<$Items extends ReadonlyArray<Item>> = {
12
12
  [$K in keyof $Items]: readonly [number, $Items[$K]];
13
13
  };
14
14
  /**
15
- * At least one element — a `choice` with no option has nothing to draw,
16
- * which would otherwise fail inside `weighted()` (`Distribution/index.ts`)
17
- * with an opaque `TypeError` at fabricate time (weight sum is `0`, so
18
- * `.find` returns `undefined` and `chosen![1]` throws). Rejecting emptiness
19
- * here is a construction-time compile error; the runtime check below is the
20
- * backstop for an `as any` call that bypasses it.
15
+ * At least one element — a `choice` with no option has nothing to draw, which
16
+ * would otherwise fail inside `weighted()` (`Distribution/index.ts`) with an
17
+ * opaque `TypeError` at fabricate time (weight sum is `0`, so `.find` returns
18
+ * `undefined` and `chosen![1]` throws). Rejecting emptiness here is a
19
+ * construction-time compile error; the runtime check below is the backstop for
20
+ * an `as any` call that bypasses it.
21
21
  */
22
22
  type NonEmpty<$T> = readonly [$T, ...$T[]];
23
23
  declare const _default: {
24
24
  /**
25
25
  * Equal probability across every option. Delegates to `weighted` with a
26
26
  * uniform weight of `1` per item — a plain `weighted()` draw is already a
27
- * uniform draw when every weight is equal, so there is no separate
28
- * unweighted code path to keep in sync.
27
+ * uniform draw when every weight is equal, so there is no separate unweighted
28
+ * code path to keep in sync.
29
29
  */
30
30
  uniform: <const $Items extends NonEmpty<Item>>(items: $Items) => Schema<Weighted<$Items>>;
31
31
  /**
32
- * Relative probability across options, given as `[weight, schema]` pairs
33
- * — the same tuple shape `weighted()` (`Distribution/index.ts`) itself
34
- * accepts, not an object keyed by option.
32
+ * Relative probability across options, given as `[weight, schema]` pairs —
33
+ * the same tuple shape `weighted()` (`Distribution/index.ts`) itself accepts,
34
+ * not an object keyed by option.
35
35
  */
36
36
  weighted: <const $Items extends NonEmpty<Items[number]>>(items: $Items) => Schema<$Items>;
37
37
  };
@@ -3,10 +3,10 @@ import type { Adaptations, Adapter, Adapting, WithAdaptations } from "../../Adap
3
3
  import type { Produce } from "../../Random/Types";
4
4
  import type { Core, Fabricated, Items } from "./Types";
5
5
  /**
6
- * Buildable `choice` recipe: a weighted set of option Schemas, one of which
7
- * is drawn (and only then dispatched into a value) each fabrication. No
8
- * bare form — see `Registry.ts`'s `uniform`/`weighted`, the only way to
9
- * reach this Schema.
6
+ * Buildable `choice` recipe: a weighted set of option Schemas, one of which is
7
+ * drawn (and only then dispatched into a value) each fabrication. No bare form
8
+ * — see `Registry.ts`'s `uniform`/`weighted`, the only way to reach this
9
+ * Schema.
10
10
  */
11
11
  export interface Schema<$Items extends Items = Items, $Adaptations extends Adaptations = {}> extends Core<$Items, $Adaptations> {
12
12
  /**
@@ -16,8 +16,8 @@ export interface Schema<$Items extends Items = Items, $Adaptations extends Adapt
16
16
  */
17
17
  as: (produce: Produce<Fabricated<$Items>>) => Schema<$Items, $Adaptations>;
18
18
  /**
19
- * Override what this schema maps to in one or more external schema
20
- * libraries — see `string/Schema.ts`'s `adapt` for the full contract.
19
+ * Override what this schema maps to in one or more external schema libraries
20
+ * — see `string/Schema.ts`'s `adapt` for the full contract.
21
21
  */
22
22
  adapt: <const $Adapter extends Adapter, $Returnable extends ReturnType<$Adapter["convert"]>>(adapter: $Adapter, produce: (adapting: Adapting<Schema<$Items, $Adaptations>>) => $Returnable) => Schema<$Items, WithAdaptations<$Adaptations, AdaptationEntry<$Adapter, $Returnable>>>;
23
23
  }
@@ -5,22 +5,22 @@ import type { Adaptation, Kind, Meta, Produces } from "../../Types";
5
5
  /** The schemas a `choice` can draw from. */
6
6
  export type Item = AnySchema;
7
7
  /**
8
- * A *tuple* of `[weight, option]` pairs, one per position — not a flattened
9
- * `ReadonlyArray<[number, Item]>`, which would remember only the union of
10
- * every option's type and lose how many options there were (two identical
11
- * option types would collapse to one union member). The real tuple is what
12
- * lets `Adapter/TypeBox` mirror TypeBox's `Union<T>` — which collapses to a
13
- * bare schema for a single option and only wraps in `TUnion<T>` for two or
14
- * more — instead of always wrapping regardless of count.
8
+ * A _tuple_ of `[weight, option]` pairs, one per position — not a flattened
9
+ * `ReadonlyArray<[number, Item]>`, which would remember only the union of every
10
+ * option's type and lose how many options there were (two identical option
11
+ * types would collapse to one union member). The real tuple is what lets
12
+ * `Adapter/TypeBox` mirror TypeBox's `Union<T>` — which collapses to a bare
13
+ * schema for a single option and only wraps in `TUnion<T>` for two or more —
14
+ * instead of always wrapping regardless of count.
15
15
  */
16
16
  export type Items = ReadonlyArray<readonly [number, Item]>;
17
17
  export type Fabricated<$Items extends Items = Items, $Bindings extends unknown[] = []> = ValueOf<$Items[number][1], $Bindings>;
18
18
  /**
19
19
  * Always stored as weighted pairs — `.uniform(...)` (`Registry.ts`) is
20
- * `.weighted(...)` with every item given weight `1`, so there is only one
21
- * shape to fabricate from. `produce` layers an opaque production via
22
- * `.as()`, carried alongside `items` rather than replacing it, so a prior
23
- * option set survives `.as()` for future validation.
20
+ * `.weighted(...)` with every item given weight `1`, so there is only one shape
21
+ * to fabricate from. `produce` layers an opaque production via `.as()`, carried
22
+ * alongside `items` rather than replacing it, so a prior option set survives
23
+ * `.as()` for future validation.
24
24
  */
25
25
  export type Meta<$Items extends Items = Items> = {
26
26
  items: $Items;
@@ -1,44 +1,32 @@
1
1
  import type { Adaptations } from "../../Adapter/Types";
2
2
  import { type InputBound } from "../../Bound";
3
3
  import { type Distribution } from "../../Distribution";
4
- import { Adaptation, Kind, Meta, Produces } from "../../Types";
5
4
  import { Schema } from "./Schema";
6
- import type { Fabricated, Whereby } from "./Types";
7
- declare const _default: {
8
- [Kind]: "date";
9
- [Meta]: {};
10
- [Produces]?: Fabricated;
11
- [Adaptation]?: Adaptations;
12
- as: (produce: import("../../Random/Types").Produce<Fabricated>) => Schema<{}, Adaptations>;
13
- 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>>>;
5
+ import type { Whereby } from "./Types";
6
+ type ThisRegistry = Schema<{}, Adaptations> & {
7
+ /**
8
+ * A `Date` drawn from `[min, max]`. Pass a `distribution` to shape how values
9
+ * cluster within the range; without one, every instant is equally likely.
10
+ */
14
11
  whereby: (whereby: {
15
12
  min: InputBound<Date>;
16
13
  max: InputBound<Date>;
17
14
  distribution?: Distribution | undefined;
18
15
  }) => Schema<{
19
16
  whereby: Whereby;
20
- }, {}>;
21
- /** Any `Date` from the earliest representable instant up to the present moment. */
22
- past: {
23
- [Kind]: "date";
24
- [Meta]: {
25
- mode: "past";
26
- };
27
- [Produces]?: Fabricated;
28
- [Adaptation]?: {};
29
- as: (produce: import("../../Random/Types").Produce<Fabricated>) => Schema<{
30
- mode: "past";
31
- }, {}>;
32
- adapt: <const $Adapter extends import("../..").Adapter, $Returnable extends ReturnType<$Adapter["convert"]>>(adapter: $Adapter, produce: (adapting: import("../..").Adapting<Schema<{
33
- mode: "past";
34
- }, {}>>) => $Returnable) => Schema<{
35
- mode: "past";
36
- }, import("../../Adapter/Types").WithAdaptations<{}, import("../../Adapter/Core").AdaptationEntry<$Adapter, $Returnable>>>;
17
+ }>;
18
+ /**
19
+ * Any `Date` from the earliest representable instant up to the present
20
+ * moment.
21
+ */
22
+ past: Schema<{
23
+ mode: "past";
24
+ }> & {
37
25
  /**
38
26
  * A past `Date` drawn from `[min, now]`. `min` defaults to the earliest
39
27
  * representable instant. The implicit `now` end stays inclusive. Pass a
40
- * `distribution` to shape how values cluster within the range; without
41
- * one, every instant is equally likely.
28
+ * `distribution` to shape how values cluster within the range; without one,
29
+ * every instant is equally likely.
42
30
  */
43
31
  whereby: (whereby: {
44
32
  min?: InputBound<Date> | undefined;
@@ -46,29 +34,17 @@ declare const _default: {
46
34
  }) => Schema<{
47
35
  mode: "past";
48
36
  whereby: Whereby;
49
- }, {}>;
37
+ }>;
50
38
  };
51
39
  /** Any `Date` from the present moment up to the latest representable instant. */
52
- future: {
53
- [Kind]: "date";
54
- [Meta]: {
55
- mode: "future";
56
- };
57
- [Produces]?: Fabricated;
58
- [Adaptation]?: {};
59
- as: (produce: import("../../Random/Types").Produce<Fabricated>) => Schema<{
60
- mode: "future";
61
- }, {}>;
62
- adapt: <const $Adapter extends import("../..").Adapter, $Returnable extends ReturnType<$Adapter["convert"]>>(adapter: $Adapter, produce: (adapting: import("../..").Adapting<Schema<{
63
- mode: "future";
64
- }, {}>>) => $Returnable) => Schema<{
65
- mode: "future";
66
- }, import("../../Adapter/Types").WithAdaptations<{}, import("../../Adapter/Core").AdaptationEntry<$Adapter, $Returnable>>>;
40
+ future: Schema<{
41
+ mode: "future";
42
+ }> & {
67
43
  /**
68
44
  * A future `Date` drawn from `[now, max]`. `max` defaults to the latest
69
45
  * representable instant. The implicit `now` end stays inclusive. Pass a
70
- * `distribution` to shape how values cluster within the range; without
71
- * one, every instant is equally likely.
46
+ * `distribution` to shape how values cluster within the range; without one,
47
+ * every instant is equally likely.
72
48
  */
73
49
  whereby: (whereby: {
74
50
  max?: InputBound<Date> | undefined;
@@ -76,7 +52,8 @@ declare const _default: {
76
52
  }) => Schema<{
77
53
  mode: "future";
78
54
  whereby: Whereby;
79
- }, {}>;
55
+ }>;
80
56
  };
81
57
  };
82
- export default _default;
58
+ declare const registry: ThisRegistry;
59
+ export default registry;
@@ -4,24 +4,23 @@ import type { Produce } from "../../Random/Types";
4
4
  import type { Core, Fabricated, Meta as ThisMeta } from "./Types";
5
5
  /**
6
6
  * Buildable `Date` recipe: a range/distribution (`whereby`, absent for the
7
- * full-range bare form), optionally scoped by `mode` to `"past"` (up to now)
8
- * or `"future"` (from now), or opaque production via `as`.
7
+ * full-range bare form), optionally scoped by `mode` to `"past"` (up to now) or
8
+ * `"future"` (from now), or opaque production via `as`.
9
9
  *
10
- * `$Meta` is generic (defaulting to the full `Meta` union) so builder
11
- * return types stay narrow — e.g. `T.date.past` types as
12
- * `Schema<{ mode: "past" }>`, not the widened `Schema` — see
13
- * `number/Schema.ts`.
10
+ * `$Meta` is generic (defaulting to the full `Meta` union) so builder return
11
+ * types stay narrow — e.g. `T.date.past` types as `Schema<{ mode: "past" }>`,
12
+ * not the widened `Schema` — see `number/Schema.ts`.
14
13
  */
15
14
  export interface Schema<$Meta extends ThisMeta = ThisMeta, $Adaptations extends Adaptations = {}> extends Core<$Meta, $Adaptations> {
16
15
  /**
17
16
  * Layer an opaque production on this schema's existing `[Meta]` — carrying
18
- * `mode`/`whereby` forward, not discarding them, so a later `.as(...)`
19
- * (or future validation of `produce`) still has them to check against.
17
+ * `mode`/`whereby` forward, not discarding them, so a later `.as(...)` (or
18
+ * future validation of `produce`) still has them to check against.
20
19
  */
21
20
  as: (produce: Produce<Fabricated>) => Schema<$Meta, $Adaptations>;
22
21
  /**
23
- * Override what this schema maps to in one or more external schema
24
- * libraries — see `string/Schema.ts`'s `adapt` for the full contract.
22
+ * Override what this schema maps to in one or more external schema libraries
23
+ * — see `string/Schema.ts`'s `adapt` for the full contract.
25
24
  */
26
25
  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>>>;
27
26
  }
@@ -16,10 +16,10 @@ export type Whereby = {
16
16
  export type Fabricated = Date;
17
17
  /**
18
18
  * A range/distribution (`whereby`, absent for the full-range bare form),
19
- * optionally scoped by `mode` to `"past"` (up to now) or `"future"` (from
20
- * now), optionally overridden by an opaque `as` production — carried
21
- * alongside the rest rather than replacing it, so a prior scoping survives
22
- * `as` for future validation.
19
+ * optionally scoped by `mode` to `"past"` (up to now) or `"future"` (from now),
20
+ * optionally overridden by an opaque `as` production — carried alongside the
21
+ * rest rather than replacing it, so a prior scoping survives `as` for future
22
+ * validation.
23
23
  */
24
24
  export type Meta = {
25
25
  mode?: "past" | "future";
@@ -5,34 +5,34 @@ import type { Item, Items } from "./Types";
5
5
  * per-position member types (`{ [K in keyof $Items]: ... }` walks a tuple
6
6
  * position-by-position, unlike `ReadonlyArray<...>`'s `.map()`, which only
7
7
  * remembers the union of every element it saw). This is what lets
8
- * `Adapter/TypeBox` recover real arity later and mirror TypeBox's
9
- * `Union<T>` collapse-for-a-single-member — see `Types.ts`'s `Items`. The
10
- * same helper `choice/Registry.ts` uses, for the same reason.
8
+ * `Adapter/TypeBox` recover real arity later and mirror TypeBox's `Union<T>`
9
+ * collapse-for-a-single-member — see `Types.ts`'s `Items`. The same helper
10
+ * `choice/Registry.ts` uses, for the same reason.
11
11
  */
12
12
  type Weighted<$Items extends ReadonlyArray<Item>> = {
13
13
  [$K in keyof $Items]: readonly [number, $Items[$K]];
14
14
  };
15
15
  /**
16
16
  * At least one element — an empty `enum` has no member to draw, which would
17
- * otherwise fail inside `weighted()` (`Distribution/index.ts`) with an
18
- * opaque `TypeError` at fabricate time (weight sum is `0`, so `.find`
19
- * returns `undefined` and `chosen![1]` throws). Rejecting emptiness here is
20
- * a construction-time compile error; the runtime check below is the
21
- * backstop for an `as any` call that bypasses it.
17
+ * otherwise fail inside `weighted()` (`Distribution/index.ts`) with an opaque
18
+ * `TypeError` at fabricate time (weight sum is `0`, so `.find` returns
19
+ * `undefined` and `chosen![1]` throws). Rejecting emptiness here is a
20
+ * construction-time compile error; the runtime check below is the backstop for
21
+ * an `as any` call that bypasses it.
22
22
  */
23
23
  type NonEmpty<$T> = readonly [$T, ...$T[]];
24
24
  declare const _default: {
25
25
  /**
26
26
  * Equal probability across every member. Delegates to `weighted` with a
27
27
  * uniform weight of `1` per item — a plain `weighted()` draw is already a
28
- * uniform draw when every weight is equal, so there is no separate
29
- * unweighted code path to keep in sync.
28
+ * uniform draw when every weight is equal, so there is no separate unweighted
29
+ * code path to keep in sync.
30
30
  */
31
31
  uniform: <const $Items extends NonEmpty<Item>>(items: $Items) => Schema<Weighted<$Items>>;
32
32
  /**
33
- * Relative probability across members, given as `[weight, item]` pairs —
34
- * the same tuple shape `weighted()` (`Distribution/index.ts`) itself
35
- * accepts, not an object keyed by member.
33
+ * Relative probability across members, given as `[weight, item]` pairs — the
34
+ * same tuple shape `weighted()` (`Distribution/index.ts`) itself accepts, not
35
+ * an object keyed by member.
36
36
  */
37
37
  weighted: <const $Items extends NonEmpty<Items[number]>>(items: $Items) => Schema<$Items>;
38
38
  };
@@ -3,9 +3,9 @@ import type { Adaptations, Adapter, Adapting, WithAdaptations } from "../../Adap
3
3
  import type { Produce } from "../../Random/Types";
4
4
  import type { Core, Fabricated, Items } from "./Types";
5
5
  /**
6
- * The buildable recipe for an `enum`: a weighted set of member values, one
7
- * of which is drawn each fabrication. There is no bare form — see
8
- * `Registry.ts`'s `uniform`/`weighted`, the only way to reach this Schema.
6
+ * The buildable recipe for an `enum`: a weighted set of member values, one of
7
+ * which is drawn each fabrication. There is no bare form — see `Registry.ts`'s
8
+ * `uniform`/`weighted`, the only way to reach this Schema.
9
9
  */
10
10
  export interface Schema<$Items extends Items = Items, $Adaptations extends Adaptations = {}> extends Core<$Items, $Adaptations> {
11
11
  /**
@@ -15,8 +15,8 @@ export interface Schema<$Items extends Items = Items, $Adaptations extends Adapt
15
15
  */
16
16
  as: (produce: Produce<Fabricated<$Items>>) => Schema<$Items, $Adaptations>;
17
17
  /**
18
- * Override what this schema maps to in one or more external schema
19
- * libraries — see `string/Schema.ts`'s `adapt` for the full contract.
18
+ * Override what this schema maps to in one or more external schema libraries
19
+ * — see `string/Schema.ts`'s `adapt` for the full contract.
20
20
  */
21
21
  adapt: <const $Adapter extends Adapter, $Returnable extends ReturnType<$Adapter["convert"]>>(adapter: $Adapter, produce: (adapting: Adapting<Schema<$Items, $Adaptations>>) => $Returnable) => Schema<$Items, WithAdaptations<$Adaptations, AdaptationEntry<$Adapter, $Returnable>>>;
22
22
  }