@ghostry/fabricator 0.0.10 → 0.0.12

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 (86) hide show
  1. package/dist/esm/Distribution/index.js +1 -1
  2. package/dist/esm/Enumeration/Enumerate.js +2 -4
  3. package/dist/esm/Error/index.js +34 -6
  4. package/dist/esm/Fabricator/Constructor.js +40 -33
  5. package/dist/esm/Fabricator/Fabricate.js +28 -0
  6. package/dist/esm/Instance/Core.js +14 -2
  7. package/dist/esm/Instance/Stack/Visible.js +6 -1
  8. package/dist/esm/Primitive/date/Defaults.js +12 -0
  9. package/dist/esm/Primitive/date/Fabricator.js +5 -10
  10. package/dist/esm/Primitive/date/Registry.js +8 -4
  11. package/dist/esm/Primitive/index.js +2 -0
  12. package/dist/esm/Primitive/null/Registry.js +2 -3
  13. package/dist/esm/Primitive/number/Fabricator.js +1 -1
  14. package/dist/esm/Primitive/number/Registry.js +1 -1
  15. package/dist/esm/Primitive/object/Fabricator.js +33 -11
  16. package/dist/esm/Primitive/object/Registry.js +90 -10
  17. package/dist/esm/Primitive/object/compute/Fabricator.js +10 -3
  18. package/dist/esm/Primitive/object/compute/Registry.js +20 -3
  19. package/dist/esm/Primitive/object/omit/Registry.js +5 -0
  20. package/dist/esm/Primitive/object/omit/index.js +2 -0
  21. package/dist/esm/Primitive/object/pick/Registry.js +5 -0
  22. package/dist/esm/Primitive/object/pick/index.js +2 -0
  23. package/dist/esm/Primitive/recursive/Fabricator.js +1 -0
  24. package/dist/esm/Primitive/recursive/Terminate.js +21 -9
  25. package/dist/esm/Primitive/undefined/Registry.js +2 -3
  26. package/dist/esm/index.js +1 -0
  27. package/dist/esm/internal.js +2 -2
  28. package/dist/types/Adapter/Types.d.ts +3 -2
  29. package/dist/types/Distribution/index.d.ts +10 -0
  30. package/dist/types/Enumeration/Types.d.ts +3 -3
  31. package/dist/types/Error/index.d.ts +71 -6
  32. package/dist/types/Fabricator/Fabricate.d.ts +61 -0
  33. package/dist/types/Fabricator/Types.d.ts +21 -11
  34. package/dist/types/Harnessing/Core.d.ts +7 -7
  35. package/dist/types/Instance/Core.d.ts +15 -8
  36. package/dist/types/Instance/Stack/Visible.d.ts +10 -0
  37. package/dist/types/Instance/Types.d.ts +30 -15
  38. package/dist/types/Primitive/always/Types.d.ts +2 -2
  39. package/dist/types/Primitive/array/Types.d.ts +4 -4
  40. package/dist/types/Primitive/bigint/Types.d.ts +2 -2
  41. package/dist/types/Primitive/boolean/Types.d.ts +2 -2
  42. package/dist/types/Primitive/choice/Types.d.ts +4 -4
  43. package/dist/types/Primitive/date/Defaults.d.ts +11 -0
  44. package/dist/types/Primitive/date/Registry.d.ts +6 -8
  45. package/dist/types/Primitive/date/Types.d.ts +12 -2
  46. package/dist/types/Primitive/derive/Types.d.ts +2 -2
  47. package/dist/types/Primitive/enum/Types.d.ts +2 -2
  48. package/dist/types/Primitive/index.d.ts +2 -0
  49. package/dist/types/Primitive/null/Types.d.ts +2 -2
  50. package/dist/types/Primitive/nullable/Types.d.ts +4 -4
  51. package/dist/types/Primitive/nullish/Types.d.ts +4 -4
  52. package/dist/types/Primitive/number/Types.d.ts +2 -2
  53. package/dist/types/Primitive/object/Fabricator.d.ts +13 -5
  54. package/dist/types/Primitive/object/Registry.d.ts +17 -1
  55. package/dist/types/Primitive/object/Types.d.ts +28 -9
  56. package/dist/types/Primitive/object/compute/Fabricator.d.ts +9 -8
  57. package/dist/types/Primitive/object/compute/Registry.d.ts +7 -1
  58. package/dist/types/Primitive/object/compute/Schema.d.ts +20 -0
  59. package/dist/types/Primitive/object/compute/Types.d.ts +14 -4
  60. package/dist/types/Primitive/object/omit/Registry.d.ts +7 -0
  61. package/dist/types/Primitive/object/omit/index.d.ts +2 -0
  62. package/dist/types/Primitive/object/omittable/Types.d.ts +4 -4
  63. package/dist/types/Primitive/object/optional/Types.d.ts +4 -4
  64. package/dist/types/Primitive/object/pick/Registry.d.ts +8 -0
  65. package/dist/types/Primitive/object/pick/index.d.ts +2 -0
  66. package/dist/types/Primitive/opaque/Types.d.ts +2 -2
  67. package/dist/types/Primitive/record/Types.d.ts +11 -6
  68. package/dist/types/Primitive/recursive/Fabricator.d.ts +9 -7
  69. package/dist/types/Primitive/recursive/Types.d.ts +12 -8
  70. package/dist/types/Primitive/recursive/self/Schema.d.ts +4 -4
  71. package/dist/types/Primitive/recursive/self/Types.d.ts +7 -5
  72. package/dist/types/Primitive/string/Constants.d.ts +7 -31
  73. package/dist/types/Primitive/string/Types.d.ts +2 -2
  74. package/dist/types/Primitive/symbol/Types.d.ts +2 -2
  75. package/dist/types/Primitive/tuple/Types.d.ts +7 -7
  76. package/dist/types/Primitive/undefinable/Types.d.ts +4 -4
  77. package/dist/types/Primitive/undefined/Types.d.ts +2 -2
  78. package/dist/types/Schema/Core.d.ts +10 -6
  79. package/dist/types/Schema/Satisfies.d.ts +31 -23
  80. package/dist/types/Schema/Types.d.ts +31 -18
  81. package/dist/types/Types.d.ts +24 -0
  82. package/dist/types/index.d.ts +45 -18
  83. package/dist/types/internal.d.ts +24 -4
  84. package/package.json +5 -5
  85. /package/dist/esm/Primitive/number/{defaults.js → Defaults.js} +0 -0
  86. /package/dist/types/Primitive/number/{defaults.d.ts → Defaults.d.ts} +0 -0
@@ -1,6 +1,6 @@
1
1
  import type { Adaptations } from "../../../Adapter/Types";
2
- import type { AnySchema, ValueOf } from "../../../Schema/Types";
3
- import { Kind, type Adaptation, type Meta, type Produces } from "../../../Types";
2
+ import type { AnySchema, Fabricated as FabricatedBy } from "../../../Schema/Types";
3
+ import { Kind, type Adaptation, type Meta, type Produced, type Produces } from "../../../Types";
4
4
  /**
5
5
  * A builder that can mint a Schema via `as` — e.g. `T.string`, `T.bigint`.
6
6
  * `compute` accepts one alongside a plain Schema so a caller needn't satisfy a
@@ -24,7 +24,7 @@ export type Denoted<$Source> = $Source extends AnySchema ? $Source : $Source ext
24
24
  /**
25
25
  * The value a source resolves to: what the Schema it denotes fabricates to.
26
26
  */
27
- export type Resolved<$Source, $Bindings extends unknown[] = []> = ValueOf<Denoted<$Source>, $Bindings>;
27
+ export type Resolved<$Source, $Bindings extends unknown[] = []> = FabricatedBy<Denoted<$Source>, $Bindings>;
28
28
  /**
29
29
  * Source and resolver are stored raw — the source whether a Schema or a builder
30
30
  * (both carry a `[Kind]`, which is all schema derivation needs), and the
@@ -39,17 +39,27 @@ export type Resolved<$Source, $Bindings extends unknown[] = []> = ValueOf<Denote
39
39
  * Unlike every other kind's `Meta`, this one is generic over the _enclosing
40
40
  * object's_ fabricated type as well as the source — that is what the resolver
41
41
  * is handed.
42
+ *
43
+ * `dependencies` is always present, so every compute field has a known set of
44
+ * fields it reads: the keys named by `.from([...])`, or, without one, every key
45
+ * of the `.refine()` stage's base — exactly what the resolver's type lets it
46
+ * read. `object/Fabricator.ts` resolves compute fields in dependency order from
47
+ * it, and `T.pick`/`T.omit` (`object/Registry.ts`) keep exactly those fields
48
+ * fabricated. `narrowed` is whether the resolver is handed only its
49
+ * `dependencies` (from `.from`) or the whole object fabricated so far.
42
50
  */
43
51
  export type Meta<$Fabricated, $Source extends Source> = {
44
52
  source: $Source;
45
53
  resolve: (params: {
46
54
  fabricated: $Fabricated;
47
55
  }) => Resolved<$Source>;
56
+ dependencies: ReadonlyArray<string>;
57
+ narrowed: boolean;
48
58
  };
49
59
  export interface Core<$Fabricated, $Source extends Source, $Adaptations extends Adaptations = {}> {
50
60
  [Kind]: "object.compute";
51
61
  [Meta]: Meta<$Fabricated, $Source>;
52
62
  bindings?: unknown[];
53
- readonly [Produces]?: Resolved<$Source, NonNullable<this["bindings"]>>;
63
+ readonly [Produces]?: Produced<Resolved<$Source, NonNullable<this["bindings"]>>>;
54
64
  readonly [Adaptation]?: $Adaptations;
55
65
  }
@@ -0,0 +1,7 @@
1
+ import type { Schema } from "../Schema";
2
+ import type { DefinitionOf, Subsettable } from "../Types";
3
+ /**
4
+ * `T.omit(source, keys)`: an `object` Schema without `keys`. `T.pick`'s
5
+ * inverse, and not a kind either — see `subset` in `object/Registry.ts`.
6
+ */
7
+ export default function omit<$Source extends Subsettable, const $Keys extends ReadonlyArray<keyof DefinitionOf<$Source> & string>>(source: $Source, keys: $Keys): Schema<Omit<DefinitionOf<$Source>, $Keys[number]>>;
@@ -0,0 +1,2 @@
1
+ export * from "./Registry";
2
+ export { default } from "./Registry";
@@ -1,13 +1,13 @@
1
1
  import type { Adaptations } from "../../../Adapter/Types";
2
2
  import type { Produce } from "../../../Random/Types";
3
- import type { AnySchema, ValueOf } from "../../../Schema/Types";
4
- import { Kind, Meta, Omitted, type Adaptation, type Produces } from "../../../Types";
3
+ import type { AnySchema, Fabricated as FabricatedBy } from "../../../Schema/Types";
4
+ import { Kind, Meta, Omitted, type Adaptation, type Produced, type Produces } from "../../../Types";
5
5
  /**
6
6
  * The wrapped field's own Schema — the value type an omittable field produces
7
7
  * when its presence roll comes up present.
8
8
  */
9
9
  export type Definition = AnySchema;
10
- export type Fabricated<$Definition extends Definition, $Bindings extends unknown[] = []> = ValueOf<$Definition, $Bindings>;
10
+ export type Fabricated<$Definition extends Definition, $Bindings extends unknown[] = []> = FabricatedBy<$Definition, $Bindings>;
11
11
  /**
12
12
  * What an omittable field's Fabricator returns: the wrapped value, or `Omitted`
13
13
  * when it should not appear — whether from the built-in presence roll or, via
@@ -51,6 +51,6 @@ export interface Core<$Definition extends Definition = Definition, $Adaptations
51
51
  [Kind]: "object.omittable";
52
52
  [Meta]: Meta<$Definition>;
53
53
  bindings?: unknown[];
54
- readonly [Produces]?: Fabricated<$Definition, NonNullable<this["bindings"]>>;
54
+ readonly [Produces]?: Produced<Fabricated<$Definition, NonNullable<this["bindings"]>>>;
55
55
  readonly [Adaptation]?: $Adaptations;
56
56
  }
@@ -1,7 +1,7 @@
1
1
  import type { Adaptations } from "../../../Adapter/Types";
2
2
  import type { Produce } from "../../../Random/Types";
3
- import type { AnySchema, ValueOf } from "../../../Schema/Types";
4
- import { Kind, Meta, Omitted, type Adaptation, type Produces } from "../../../Types";
3
+ import type { AnySchema, Fabricated as FabricatedBy } from "../../../Schema/Types";
4
+ import { Kind, Meta, Omitted, type Adaptation, type Produced, type Produces } from "../../../Types";
5
5
  /**
6
6
  * The wrapped field's Schema — the value type when the roll is
7
7
  * present-with-a-value.
@@ -15,7 +15,7 @@ export type Definition = AnySchema;
15
15
  * `{ a?: T | undefined }` — a real `?:` (from `OmittableKeys`, which also
16
16
  * covers this kind) _and_ a real `| undefined`.
17
17
  */
18
- export type Fabricated<$Definition extends Definition, $Bindings extends unknown[] = []> = ValueOf<$Definition, $Bindings> | undefined;
18
+ export type Fabricated<$Definition extends Definition, $Bindings extends unknown[] = []> = FabricatedBy<$Definition, $Bindings> | undefined;
19
19
  /**
20
20
  * What an optional field's Fabricator returns: the wrapped value, `undefined`,
21
21
  * or `Omitted` when the key should not appear — whether from the built-in
@@ -67,6 +67,6 @@ export interface Core<$Definition extends Definition = Definition, $Adaptations
67
67
  [Kind]: "object.optional";
68
68
  [Meta]: Meta<$Definition>;
69
69
  bindings?: unknown[];
70
- readonly [Produces]?: Fabricated<$Definition, NonNullable<this["bindings"]>>;
70
+ readonly [Produces]?: Produced<Fabricated<$Definition, NonNullable<this["bindings"]>>>;
71
71
  readonly [Adaptation]?: $Adaptations;
72
72
  }
@@ -0,0 +1,8 @@
1
+ import type { Schema } from "../Schema";
2
+ import type { DefinitionOf, Subsettable } from "../Types";
3
+ /**
4
+ * `T.pick(source, keys)`: an `object` Schema with only `keys`, in source order.
5
+ * Not a kind — the result is an ordinary `object` Schema. See `subset` in
6
+ * `object/Registry.ts` for what is kept, hidden, and dropped.
7
+ */
8
+ export default function pick<$Source extends Subsettable, const $Keys extends ReadonlyArray<keyof DefinitionOf<$Source> & string>>(source: $Source, keys: $Keys): Schema<Pick<DefinitionOf<$Source>, $Keys[number]>>;
@@ -0,0 +1,2 @@
1
+ export * from "./Registry";
2
+ export { default } from "./Registry";
@@ -1,6 +1,6 @@
1
1
  import type { Adaptations } from "../../Adapter/Types";
2
2
  import type { Produce } from "../../Random/Types";
3
- import { Produces, type Adaptation, type Kind, type Meta } from "../../Types";
3
+ import { Produces, type Adaptation, type Kind, type Meta, type Produced } from "../../Types";
4
4
  export type Fabricated<$T> = $T;
5
5
  /**
6
6
  * A single required member, unlike the two-arm unions kinds with a `whereby`
@@ -13,6 +13,6 @@ export type Meta<$T = unknown> = {
13
13
  export type Core<$T = unknown, $Adaptations extends Adaptations = {}> = {
14
14
  [Kind]: "opaque";
15
15
  [Meta]: Meta<$T>;
16
- readonly [Produces]?: Fabricated<$T>;
16
+ readonly [Produces]?: Produced<Fabricated<$T>>;
17
17
  readonly [Adaptation]?: $Adaptations;
18
18
  };
@@ -1,7 +1,7 @@
1
1
  import type { Adaptations } from "../../Adapter/Types";
2
2
  import type { Produce } from "../../Random/Types";
3
- import type { AnySchema, ValueOf } from "../../Schema/Types";
4
- import { Produces, type Adaptation, type Kind, type Meta } from "../../Types";
3
+ import type { AnySchema, Fabricated as FabricatedBy } from "../../Schema/Types";
4
+ import { Produces, type Adaptation, type Kind, type Meta, type Produced } from "../../Types";
5
5
  /**
6
6
  * A Schema usable as a record's keys: any Schema whose fabricated value is a
7
7
  * legal JS property key. Constrained through the phantom `[Produces]` marker
@@ -13,9 +13,14 @@ import { Produces, type Adaptation, type Kind, type Meta } from "../../Types";
13
13
  * `symbol` is included deliberately: symbols are legal property keys. Excluding
14
14
  * them would arbitrarily narrow what a record can describe. They do not survive
15
15
  * `Adapter/TypeBox` — see its `record` case.
16
+ *
17
+ * Matched through the box (`Produced<…>`, `Types.ts`) so that a key schema
18
+ * which may produce `undefined` is rejected whatever the caller's
19
+ * `exactOptionalPropertyTypes` — unboxed and with the flag off, the optional
20
+ * slot already admits `undefined`.
16
21
  */
17
22
  export type Key = AnySchema & {
18
- readonly [Produces]?: string | symbol;
23
+ readonly [Produces]?: Produced<string | symbol>;
19
24
  };
20
25
  export type Value = AnySchema;
21
26
  /**
@@ -29,7 +34,7 @@ type IsKeyspaceOpen<$Key> = string extends $Key ? true : symbol extends $Key ? t
29
34
  * An open key (`string`, `symbol`, or both) is a plain index signature: no
30
35
  * `Partial` — an index signature never guarantees a key is present, and
31
36
  * wrapping one would only add a spurious `| undefined`. Carrying
32
- * `ValueOf<$Key>` rather than hardcoding `string` keeps a mixed `string |
37
+ * `FabricatedBy<$Key>` rather than hardcoding `string` keeps a mixed `string |
33
38
  * symbol` key as `Record<string | symbol, ...>` instead of silently dropping
34
39
  * the symbol half.
35
40
  *
@@ -38,7 +43,7 @@ type IsKeyspaceOpen<$Key> = string extends $Key ? true : symbol extends $Key ? t
38
43
  * a two-member key schema may produce only one. Every key present wants
39
44
  * `T.object({ ... })` — what a record over a finite key set degenerates to.
40
45
  */
41
- export type Fabricated<$Key extends Key = Key, $Value extends Value = Value, $Bindings extends unknown[] = []> = IsKeyspaceOpen<ValueOf<$Key, $Bindings>> extends true ? Record<ValueOf<$Key, $Bindings> & PropertyKey, ValueOf<$Value, $Bindings>> : Partial<Record<ValueOf<$Key, $Bindings> & PropertyKey, ValueOf<$Value, $Bindings>>>;
46
+ export type Fabricated<$Key extends Key = Key, $Value extends Value = Value, $Bindings extends unknown[] = []> = IsKeyspaceOpen<FabricatedBy<$Key, $Bindings>> extends true ? Record<FabricatedBy<$Key, $Bindings> & PropertyKey, FabricatedBy<$Value, $Bindings>> : Partial<Record<FabricatedBy<$Key, $Bindings> & PropertyKey, FabricatedBy<$Value, $Bindings>>>;
42
47
  /**
43
48
  * How many entries to attempt, uniformly across `[minTried, max]`.
44
49
  *
@@ -79,7 +84,7 @@ export interface Core<$Key extends Key = Key, $Value extends Value = Value, $Ada
79
84
  [Kind]: "record";
80
85
  [Meta]: Meta<$Key, $Value>;
81
86
  bindings?: unknown[];
82
- readonly [Produces]?: Fabricated<$Key, $Value, NonNullable<this["bindings"]>>;
87
+ readonly [Produces]?: Produced<Fabricated<$Key, $Value, NonNullable<this["bindings"]>>>;
83
88
  readonly [Adaptation]?: $Adaptations;
84
89
  }
85
90
  export {};
@@ -28,13 +28,15 @@ export type Fabricator<$Schema extends {
28
28
  * how deep this `fabricate()` goes — so no structural path distinguishes
29
29
  * sibling expansions at the same depth (an `array` of three `self` children
30
30
  * calls `fabricateAt` three times on one shared element Fabricator; the schema
31
- * does not tell them apart). `forkSource` mints an isolated `RandomSource`
32
- * salted from this node's draw, and each `fabricateAt` resolves a
33
- * `ConstructionTrace` on it (`RandomSource.toConstructionTrace`), recorded on
34
- * each expansion's `trace`. The private source's construction counter orders
35
- * expansions; nothing to increment here. Isolation also keeps this node's
36
- * data-dependent draws from perturbing (or being perturbed by) an unrelated
37
- * Fabricator from the same `initialize()` instance.
31
+ * does not tell them apart). `forkSource` — the outer construction's
32
+ * `ConstructionContext.fork`, carrying its resolved algorithm and clock — mints
33
+ * an isolated `RandomSource` salted from this node's draw, and each
34
+ * `fabricateAt` resolves a `ConstructionTrace` on it
35
+ * (`RandomSource.toConstructionTrace`), recorded on each expansion's `trace`.
36
+ * The private source's construction counter orders expansions; nothing to
37
+ * increment here. Isolation also keeps this node's data-dependent draws from
38
+ * perturbing (or being perturbed by) an unrelated Fabricator from the same
39
+ * `initialize()` instance.
38
40
  *
39
41
  * Each `self` gets its own independently-dispatched expansion — calling
40
42
  * `context.self` twice (two array slots) is two `fabricateAt` calls, each with
@@ -1,19 +1,21 @@
1
1
  import type { Adaptations } from "../../Adapter/Types";
2
- import type { AnySchema, ValueOf } from "../../Schema/Types";
3
- import { Produces, type Adaptation, type Kind, type Meta } from "../../Types";
2
+ import type { AnySchema, Fabricated as FabricatedBy } from "../../Schema/Types";
3
+ import { Produces, type Adaptation, type Kind, type Meta, type Produced } from "../../Types";
4
4
  /**
5
5
  * Fixed point of a recursive schema. A self-referential alias, normally
6
6
  * `TS2456` ("`RecursiveValue` circularly references itself") — legal _only_
7
- * because `ValueOf`'s second argument is read through an interface member
7
+ * because `FabricatedBy`'s second argument is read through an interface member
8
8
  * (`this["bindings"]` on every composite `Core`), which TypeScript defers. Do
9
9
  * not rewrite as a conditional; that reintroduces the error. See `AGENTS.md`'s
10
- * "`ValueOf`'s `$Bindings`".
10
+ * "`Fabricated<$Schema>`'s `$Bindings`".
11
11
  *
12
12
  * Wherever `self` sits in `$Body` (nested through `array`/`object`/`tuple`/
13
13
  * etc., each forwarding `this["bindings"]`), it reads `bindings[0]` —
14
14
  * `RecursiveValue<$Body>` itself, closing the loop.
15
15
  */
16
- export type RecursiveValue<$Body> = ValueOf<$Body, [RecursiveValue<$Body>]>;
16
+ export type RecursiveValue<$Body> = FabricatedBy<$Body, [
17
+ RecursiveValue<$Body>
18
+ ]>;
17
19
  export type Fabricated<$Body> = RecursiveValue<$Body>;
18
20
  /**
19
21
  * `terminal` is what `self` expands into at `depth.max`, in place of `body`.
@@ -24,7 +26,9 @@ export type Fabricated<$Body> = RecursiveValue<$Body>;
24
26
  * already rejects a wrong terminal (e.g. missing a required field `body` has),
25
27
  * and nothing downstream needs `terminal`'s precise type (`Core`'s `[Produces]`
26
28
  * depends only on `$Body`). A bare-vs-generic comparison rejects the same wrong
27
- * terminal either way.
29
+ * terminal either way. The constraint matches through the box (`Produced<…>`,
30
+ * `Types.ts`): unboxed, a caller compiling without `exactOptionalPropertyTypes`
31
+ * could pass a terminal producing `undefined` for any body at all.
28
32
  *
29
33
  * Omitted, `terminal` is derived from `body` (`Terminate.ts`): every `self`
30
34
  * behind a declining kind is rewritten into a stop (empty array/record,
@@ -52,7 +56,7 @@ export type Whereby<$Body> = {
52
56
  max: number;
53
57
  };
54
58
  terminal?: (AnySchema & {
55
- readonly [Produces]?: RecursiveValue<$Body>;
59
+ readonly [Produces]?: Produced<RecursiveValue<$Body>>;
56
60
  }) | undefined;
57
61
  };
58
62
  /**
@@ -77,6 +81,6 @@ export type Meta<$Body = unknown> = {
77
81
  export type Core<$Body = unknown, $Adaptations extends Adaptations = {}> = {
78
82
  [Kind]: "recursive";
79
83
  [Meta]: Meta<$Body>;
80
- readonly [Produces]?: Fabricated<$Body>;
84
+ readonly [Produces]?: Produced<Fabricated<$Body>>;
81
85
  readonly [Adaptation]?: $Adaptations;
82
86
  };
@@ -19,10 +19,10 @@ export interface Schema<$Adaptations extends Adaptations = {}> extends Core<$Ada
19
19
  /**
20
20
  * Check that this schema's fabricated value type is assignable to `$Target`.
21
21
  * Identity at runtime; the target is not carried into later chained calls —
22
- * see `object/Schema.ts`'s `satisfies`. Outside `ValueOf`'s `$Bindings`,
23
- * `Fabricated` is `unknown` — a `self` has no value of its own. Put
24
- * `.satisfies` on the enclosing `T.recursive(...).whereby(...)` to check the
25
- * tree.
22
+ * see `object/Schema.ts`'s `satisfies`. Outside `Schema/Types.ts`'s
23
+ * `$Bindings`, this kind's `Fabricated` is `unknown` — a `self` has no value
24
+ * of its own. Put `.satisfies` on the enclosing
25
+ * `T.recursive(...).whereby(...)` to check the tree.
26
26
  */
27
27
  satisfies<$Target>(this: this & SatisfiesThis<Fabricated, $Target>): Schema<$Adaptations>;
28
28
  adapt: <const $Adapter extends Adapter, $Returnable extends ReturnType<$Adapter["convert"]>>(adapter: $Adapter, produce: (adapting: Adapting<Schema<$Adaptations>>) => $Returnable) => Schema<WithAdaptations<$Adaptations, AdaptationEntry<$Adapter, $Returnable>>>;
@@ -1,10 +1,11 @@
1
1
  import type { Adaptations } from "../../../Adapter/Types";
2
- import { Produces, type Adaptation, type Kind, type Meta } from "../../../Types";
2
+ import { Produces, type Adaptation, type Produced, type Kind, type Meta } from "../../../Types";
3
3
  /**
4
4
  * The value a `self` reference resolves to at this position — whatever the
5
5
  * enclosing `T.recursive`'s current expansion binds it to. Reads `bindings[0]`,
6
6
  * the analogue of TypeBox's `TThis` reading `this['params'][0]`; see
7
- * `Schema/Types.ts`'s `ValueOf` for what `bindings` is and why it's a tuple.
7
+ * `Schema/Types.ts`'s `Fabricated` for what `bindings` is and why it's a
8
+ * tuple.
8
9
  *
9
10
  * Unlike every other kind, `self` has no type parameter of its own — its whole
10
11
  * value comes from outside, threaded in structurally by whatever composite
@@ -15,13 +16,14 @@ export type Fabricated<$Bindings extends unknown[] = []> = $Bindings[0];
15
16
  export type Meta = Record<string, never>;
16
17
  /**
17
18
  * An `interface`, not a `type` alias, so `this["bindings"]` resolves — the
18
- * entire mechanism this kind exists for. See `AGENTS.md`'s "`ValueOf`'s
19
- * `$Bindings`" section for why threading requires this.
19
+ * entire mechanism this kind exists for. See `AGENTS.md`'s
20
+ * "`Fabricated<$Schema>`'s `$Bindings`" section for why threading requires
21
+ * this.
20
22
  */
21
23
  export interface Core<$Adaptations extends Adaptations = {}> {
22
24
  [Kind]: "recursive.self";
23
25
  [Meta]: Meta;
24
26
  bindings?: unknown[];
25
- readonly [Produces]?: Fabricated<NonNullable<this["bindings"]>>;
27
+ readonly [Produces]?: Produced<Fabricated<NonNullable<this["bindings"]>>>;
26
28
  readonly [Adaptation]?: $Adaptations;
27
29
  }
@@ -8,39 +8,15 @@ import type { CodepointRange } from "./Types";
8
8
  * export alongside `export type Fabricated = string` makes the module a value
9
9
  * module, and `export * as string` in `Primitive/namespace.ts` then resolves
10
10
  * `string` to the namespace — a cycle that drops `[Kind]`/`[Meta]` off `Core`.
11
+ *
12
+ * Annotated member-by-member, like `classes`, because it is public API and JSR
13
+ * rejects an inferred `const` type there.
11
14
  */
12
15
  export declare const unicode: {
13
- /**
14
- * All Unicode scalar values: the codespace minus the surrogate block
15
- * (U+D800–U+DFFF). Always well-formed UTF-16, so it round-trips cleanly
16
- * through encoders, URLs, and datastores.
17
- *
18
- * This is the default composition for strings.
19
- */
20
- scalars: {
21
- from: number;
22
- to: number;
23
- }[];
24
- /**
25
- * The entire Unicode codespace, U+0000–U+10FFFF, including the surrogate
26
- * block — so it can yield lone surrogates and thus ill-formed UTF-16. Opt in
27
- * for lone surrogates and other ill-formed UTF-16 when fuzzing.
28
- */
29
- codespace: {
30
- from: number;
31
- to: number;
32
- };
33
- /** The Basic Multilingual Plane, U+0000–U+FFFF. */
34
- bmp: {
35
- from: number;
36
- to: number;
37
- };
38
- /** Printable ASCII, U+0020–U+007E. */
39
- ascii: {
40
- from: number;
41
- to: number;
42
- };
43
- /** An arbitrary inclusive code point range. */
16
+ scalars: ReadonlyArray<CodepointRange>;
17
+ codespace: CodepointRange;
18
+ bmp: CodepointRange;
19
+ ascii: CodepointRange;
44
20
  range: (from: number, to: number) => CodepointRange;
45
21
  };
46
22
  /**
@@ -1,7 +1,7 @@
1
1
  import type { Adaptations } from "../../Adapter/Types";
2
2
  import type { InputLength, Length } from "../../Bound";
3
3
  import type { Produce } from "../../Random/Types";
4
- import type { Adaptation, Kind, Meta, Produces } from "../../Types";
4
+ import type { Adaptation, Kind, Meta, Produced, Produces } from "../../Types";
5
5
  import type { classes } from "./Constants";
6
6
  /** An inclusive range of Unicode code points. */
7
7
  export type CodepointRange = {
@@ -68,6 +68,6 @@ export type Meta = {
68
68
  export type Core<$Meta extends Meta = Meta, $Adaptations extends Adaptations = {}> = {
69
69
  [Kind]: "string";
70
70
  [Meta]: $Meta;
71
- readonly [Produces]?: Fabricated;
71
+ readonly [Produces]?: Produced<Fabricated>;
72
72
  readonly [Adaptation]?: $Adaptations;
73
73
  };
@@ -1,6 +1,6 @@
1
1
  import type { Adaptations } from "../../Adapter/Types";
2
2
  import type { Produce } from "../../Random/Types";
3
- import type { Adaptation, Kind, Meta, Produces } from "../../Types";
3
+ import type { Adaptation, Kind, Meta, Produced, Produces } from "../../Types";
4
4
  export type Fabricated = symbol;
5
5
  /**
6
6
  * A symbol keyed via `keyed`, or unkeyed if `key` is absent, optionally
@@ -14,6 +14,6 @@ export type Meta = {
14
14
  export type Core<$Meta extends Meta = Meta, $Adaptations extends Adaptations = {}> = {
15
15
  [Kind]: "symbol";
16
16
  [Meta]: $Meta;
17
- readonly [Produces]?: Fabricated;
17
+ readonly [Produces]?: Produced<Fabricated>;
18
18
  readonly [Adaptation]?: $Adaptations;
19
19
  };
@@ -1,7 +1,7 @@
1
1
  import type { Adaptations } from "../../Adapter/Types";
2
2
  import type { Produce } from "../../Random/Types";
3
- import type { AnySchema, ValueOf } from "../../Schema/Types";
4
- import type { Adaptation, Kind, Meta, Produces } from "../../Types";
3
+ import type { AnySchema, Fabricated as FabricatedBy } from "../../Schema/Types";
4
+ import type { Adaptation, Kind, Meta, Produced, Produces } from "../../Types";
5
5
  /** The schema occupying a single tuple slot. */
6
6
  export type Item = AnySchema;
7
7
  /**
@@ -19,9 +19,9 @@ export type Items = ReadonlyArray<Item>;
19
19
  * `keyof` a still-abstract `ReadonlyArray<Item>` (this type's default, and what
20
20
  * a kind-local `Fabrication<$Fabricator>` resolves against for the _bare_,
21
21
  * unparameterized `Fabricator`) pulls in `"length"`/method keys that don't
22
- * resolve to a sensible `ValueOf`. A homomorphic version type-checks for any
23
- * concrete tuple but silently produces a malformed bare type, which then fails
24
- * `.schema.as`'s contravariant parameter check against any concrete
22
+ * resolve to a sensible `FabricatedBy`. A homomorphic version type-checks for
23
+ * any concrete tuple but silently produces a malformed bare type, which then
24
+ * fails `.schema.as`'s contravariant parameter check against any concrete
25
25
  * instantiation (`Fabrication.types.test.ts`). Matching a fixed-length tuple
26
26
  * pattern at every step avoids it, as `TupleItems` does for `ToTypeBox`. The
27
27
  * fallback (a genuinely widened, arity-less array) is a plain `Array<...>`,
@@ -30,7 +30,7 @@ export type Items = ReadonlyArray<Item>;
30
30
  export type Fabricated<$Items extends Items = Items, $Bindings extends unknown[] = []> = $Items extends readonly [] ? [] : $Items extends readonly [
31
31
  infer $Head extends Item,
32
32
  ...infer $Rest extends Items
33
- ] ? [ValueOf<$Head, $Bindings>, ...Fabricated<$Rest, $Bindings>] : Array<ValueOf<$Items[number], $Bindings>>;
33
+ ] ? [FabricatedBy<$Head, $Bindings>, ...Fabricated<$Rest, $Bindings>] : Array<FabricatedBy<$Items[number], $Bindings>>;
34
34
  /**
35
35
  * No `whereby`: arity is fixed at `T.tuple([...])` and there is nothing left to
36
36
  * configure. Unlike `array`'s two-variant union this needs no "config or
@@ -47,6 +47,6 @@ export interface Core<$Items extends Items = Items, $Adaptations extends Adaptat
47
47
  [Kind]: "tuple";
48
48
  [Meta]: Meta<$Items>;
49
49
  bindings?: unknown[];
50
- readonly [Produces]?: Fabricated<$Items, NonNullable<this["bindings"]>>;
50
+ readonly [Produces]?: Produced<Fabricated<$Items, NonNullable<this["bindings"]>>>;
51
51
  readonly [Adaptation]?: $Adaptations;
52
52
  }
@@ -1,10 +1,10 @@
1
1
  import type { Adaptations } from "../../Adapter/Types";
2
2
  import type { Produce } from "../../Random/Types";
3
- import type { AnySchema, ValueOf } from "../../Schema/Types";
4
- import type { Adaptation, Kind, Meta, Produces } from "../../Types";
3
+ import type { AnySchema, Fabricated as FabricatedBy } from "../../Schema/Types";
4
+ import type { Adaptation, Kind, Meta, Produced, Produces } from "../../Types";
5
5
  /** The wrapped schema — the value type produced when the roll isn't `undefined`. */
6
6
  export type Definition = AnySchema;
7
- export type Fabricated<$Definition extends Definition, $Bindings extends unknown[] = []> = ValueOf<$Definition, $Bindings> | undefined;
7
+ export type Fabricated<$Definition extends Definition, $Bindings extends unknown[] = []> = FabricatedBy<$Definition, $Bindings> | undefined;
8
8
  export type { Outcome } from "./Outcomes";
9
9
  /**
10
10
  * Relative weights for `.weighted(...)`, keyed by `Outcome`. Keys optional — an
@@ -43,6 +43,6 @@ export interface Core<$Definition extends Definition = Definition, $Adaptations
43
43
  [Kind]: "undefinable";
44
44
  [Meta]: Meta<$Definition>;
45
45
  bindings?: unknown[];
46
- readonly [Produces]?: Fabricated<$Definition, NonNullable<this["bindings"]>>;
46
+ readonly [Produces]?: Produced<Fabricated<$Definition, NonNullable<this["bindings"]>>>;
47
47
  readonly [Adaptation]?: $Adaptations;
48
48
  }
@@ -1,5 +1,5 @@
1
1
  import type { Adaptations } from "../../Adapter/Types";
2
- import type { Adaptation, Kind, Meta, Produces } from "../../Types";
2
+ import type { Adaptation, Kind, Meta, Produced, Produces } from "../../Types";
3
3
  export type Fabricated = undefined;
4
4
  /**
5
5
  * Nothing to configure: `undefined` has exactly one possible value, so there is
@@ -10,6 +10,6 @@ export type Meta = Record<string, never>;
10
10
  export type Core<$Meta extends Meta = Meta, $Adaptations extends Adaptations = {}> = {
11
11
  [Kind]: "undefined";
12
12
  [Meta]: $Meta;
13
- readonly [Produces]?: Fabricated;
13
+ readonly [Produces]?: Produced<Fabricated>;
14
14
  readonly [Adaptation]?: $Adaptations;
15
15
  };
@@ -1,6 +1,6 @@
1
1
  import type { Adaptations } from "../Adapter/Types";
2
2
  import type { Kind as SchemaKind } from "../Primitive";
3
- import { Adaptation, Kind, Meta, type Produces } from "../Types";
3
+ import { Adaptation, Kind, Meta, type Produced, type Produces } from "../Types";
4
4
  import { type PlainObject } from "../Utility/Types";
5
5
  /**
6
6
  * Normalize a Schema, a builder namespace, or an already-built Fabricator into
@@ -16,20 +16,24 @@ import { type PlainObject } from "../Utility/Types";
16
16
  * enclosing `object`/`array`, which is where every adapter actually reads it
17
17
  * from (see `Adapter/TypeBox`'s `build`, which walks `[Meta].definition`).
18
18
  *
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
19
+ * `$Produces` is threaded through in the type only (never read or written at
20
+ * runtime) so `Fabricated` stays precise across a `toSchema` call — dropping it
21
21
  * would make every normalized field (e.g. every `object`/`array` element) fall
22
- * back to `unknown`.
22
+ * back to `unknown`. It is inferred through the box (`Produced<$Produces>`,
23
+ * `Types.ts`), not as the brand's whole type: inferred against a bare
24
+ * `[Produces]?: $Produces`, a value type's own `undefined` is absorbed into the
25
+ * optional slot whenever the caller compiles without
26
+ * `exactOptionalPropertyTypes`.
23
27
  */
24
28
  export declare function toSchema<$Kind extends string, $Meta extends PlainObject, $Produces = unknown, $Adaptations extends Adaptations = Adaptations>(value: {
25
29
  [Kind]: $Kind;
26
30
  [Meta]: $Meta;
27
- [Produces]?: $Produces;
31
+ [Produces]?: Produced<$Produces>;
28
32
  [Adaptation]?: $Adaptations;
29
33
  }): {
30
34
  [Kind]: $Kind;
31
35
  [Meta]: $Meta;
32
- readonly [Produces]?: $Produces;
36
+ readonly [Produces]?: Produced<$Produces>;
33
37
  readonly [Adaptation]?: $Adaptations;
34
38
  };
35
39
  /**
@@ -1,6 +1,6 @@
1
1
  import type { NaiveFabricator } from "../Fabricator/Types";
2
- import type { Buildable, Produces } from "../Types";
3
- import type { ValueOf } from "./Types";
2
+ import type { Buildable, Produced, Produces } from "../Types";
3
+ import type { Fabricated } from "./Types";
4
4
  /**
5
5
  * The `this`-parameter constraint every kind's `.satisfies<$Target>()`
6
6
  * intersects onto the receiver, so a mismatch names both sides on the call that
@@ -8,13 +8,14 @@ import type { ValueOf } from "./Types";
8
8
  * where the error lands on `inner` rather than the outer object.
9
9
  *
10
10
  * `$Produced` is each kind's own `Fabricated<…>` (or `Resolved<…>` for `derive`
11
- * / `object.compute`, which have no `Fabricated` alias). A shared
12
- * `ValueOf<this>` form errors in the same place but reports `"schema produces":
13
- * any`, which is why each kind still names its own produced type. The check is
14
- * wrapped in a 1-tuple so it does not distribute over unions: a bare `$Produced
15
- * extends $Target ? unknown : Error` on `"x" | null` becomes `unknown | Error`,
16
- * which is `unknown`, and `T.nullable(…).satisfies<string>()` would pass. Other
17
- * signatures that were considered, and why they are not this:
11
+ * / `object.compute`, which have no `Fabricated` alias). A shared schema-level
12
+ * `Fabricated<this>` form errors in the same place but reports `"schema
13
+ * produces": any`, which is why each kind still names its own produced type.
14
+ * The check is wrapped in a 1-tuple so it does not distribute over unions: a
15
+ * bare `$Produced extends $Target ? unknown : Error` on `"x" | null` becomes
16
+ * `unknown | Error`, which is `unknown`, and
17
+ * `T.nullable(…).satisfies<string>()` would pass. Other signatures that were
18
+ * considered, and why they are not this:
18
19
  *
19
20
  * - A rest tuple `...check: D extends T ? [] : [error]` errors in the right place
20
21
  * but says "Expected 1 arguments, but got 0".
@@ -26,11 +27,12 @@ import type { ValueOf } from "./Types";
26
27
  * that changes a field's type is not re-checked. Put `.satisfies` last to check
27
28
  * the final shape. Carrying `$Target` on every `Schema` interface would add a
28
29
  * type parameter to all 25 kinds, and `.as`'s contravariant parameter check is
29
- * where a variance shift on those interfaces surfaces — `Types.ts`'s `ValueOf`
30
- * note records that same check breaking from a constraint on `$Schema`. The
31
- * return is `Schema`, not polymorphic `this`, because `T.date.past` /
32
- * `T.number.integer` / `T.symbol` are `Schema & { whereby, … }` and a `this`
33
- * return is not assignable into those extra members — same as `.as()`.
30
+ * where a variance shift on those interfaces surfaces — `Types.ts`'s
31
+ * `Fabricated` note records that same check breaking from a constraint on
32
+ * `$Schema`. The return is `Schema`, not polymorphic `this`, because
33
+ * `T.date.past` / `T.number.integer` / `T.symbol` are `Schema & { whereby, … }`
34
+ * and a `this` return is not assignable into those extra members — same as
35
+ * `.as()`.
34
36
  */
35
37
  export type SatisfiesThis<$Produced, $Target> = [$Produced] extends [$Target] ? unknown : {
36
38
  "schema produces": $Produced;
@@ -60,8 +62,8 @@ export declare function schemaSatisfies<$Receiver>(this: $Receiver): $Receiver;
60
62
  * `note?: string | undefined` (present, present-as-`undefined`, or omitted).
61
63
  * `T.omittable` produces `note?: string` and does.
62
64
  */
63
- export type SatisfiedBy<$Target, $Buildable> = ValueOf<$Buildable> extends $Target ? true : {
64
- produces: ValueOf<$Buildable>;
65
+ export type SatisfiedBy<$Target, $Buildable> = Fabricated<$Buildable> extends $Target ? true : {
66
+ produces: Fabricated<$Buildable>;
65
67
  required: $Target;
66
68
  };
67
69
  /**
@@ -71,14 +73,20 @@ export type SatisfiedBy<$Target, $Buildable> = ValueOf<$Buildable> extends $Targ
71
73
  *
72
74
  * `fabricate?: never` on the Schema arm is required. A built Fabricator has no
73
75
  * `[Produces]`, and a type that lacks an optional property still matches `{
74
- * readonly [Produces]?: $Target }` — the same trap `ValueOf` documents at
75
- * `Types.ts`. Without the exclusion, a non-conforming Fabricator would pass the
76
- * Schema arm unchecked. Ordered overloads do not replace this: overload
77
- * resolution falls through a failing overload onto the next one, so a
78
- * Fabricator rejected by `NaiveFabricator<$Target>` would still be accepted by
79
- * the Schema arm.
76
+ * readonly [Produces]?: Produced<$Target> }` — the same trap `Types.ts`'s
77
+ * `Fabricated` documents at `Types.ts`. Without the exclusion, a non-conforming
78
+ * Fabricator would pass the Schema arm unchecked. Ordered overloads do not
79
+ * replace this: overload resolution falls through a failing overload onto the
80
+ * next one, so a Fabricator rejected by `NaiveFabricator<$Target>` would still
81
+ * be accepted by the Schema arm.
82
+ *
83
+ * The Schema arm matches through the box (`Produced<$Target>`, `../Types.ts`),
84
+ * never `[Produces]?: $Target`: a caller compiling without
85
+ * `exactOptionalPropertyTypes` reads that optional slot as `$Target |
86
+ * undefined`, so a schema that may produce `undefined` would pass a target that
87
+ * excludes it.
80
88
  */
81
89
  export declare function satisfies<$Target>(buildable: NaiveFabricator<$Target> | (Buildable & {
82
90
  fabricate?: never;
83
- readonly [Produces]?: $Target;
91
+ readonly [Produces]?: Produced<$Target>;
84
92
  })): void;