@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,85 +1,53 @@
1
- import { FabricatorError } from "../Error/index.js";
2
1
  import { Layer, MAX_TIME } from "../Types.js";
3
- import { inline } from "../Utility/Core.js";
4
2
  import { cyrb128 } from "../Utility/Digest.js";
5
- import { directoryOf, normalizeLocation, relativize, resolveCallerFile } from "./CallSite.js";
6
3
  import { sfc32 } from "./Generator/sfc32.js";
7
4
  function defaultAlgorithm(seed) {
8
5
  return sfc32(...cyrb128(seed));
9
6
  }
10
- function randomSeed() {
7
+ function randomSalt() {
11
8
  return (0x100000000 * Math.random() >>> 0).toString(10);
12
9
  }
13
- function deriveClock(algorithm, seed) {
10
+ function deriveClock(algorithm, salt) {
14
11
  const stream = toStream(algorithm, JSON.stringify([
15
- seed,
12
+ salt,
16
13
  "clock"
17
14
  ]));
18
15
  return Math.trunc((2 * stream.next() - 1) * MAX_TIME);
19
16
  }
20
- function envSeed() {
21
- var _ref, _ref1;
17
+ function envSalt() {
22
18
  const env = "object" == typeof process ? process.env : void 0;
23
- return null != (_ref = null != (_ref1 = null == env ? void 0 : env["FABRICATOR_SEED"]) ? _ref1 : null == env ? void 0 : env["SEED"]) ? _ref : null == env ? void 0 : env["RANDOM_SEED"];
19
+ return null == env ? void 0 : env["FABRICATOR_SALT"];
24
20
  }
25
21
  function encode(trace) {
26
22
  return JSON.stringify([
27
- trace.seed,
23
+ trace.salt,
28
24
  trace.clock,
29
- trace.root,
30
- trace.file,
31
25
  trace.path,
32
26
  trace.kind,
33
27
  trace.ordinal
34
28
  ]);
35
29
  }
36
- function normalizeSeed(seed) {
37
- if (void 0 === seed) {
38
- const fromEnv = envSeed();
30
+ function normalizeSalt(salt) {
31
+ if (void 0 === salt) {
32
+ const fromEnv = envSalt();
39
33
  return void 0 === fromEnv ? [] : [
40
34
  fromEnv
41
35
  ];
42
36
  }
43
- return "string" == typeof seed ? [
44
- seed
37
+ return "string" == typeof salt ? [
38
+ salt
45
39
  ] : [
46
- ...seed
40
+ ...salt
47
41
  ];
48
42
  }
49
- function Random_layer(seed) {
43
+ function Random_layer(salt) {
50
44
  return {
51
- [Layer]: seed
45
+ [Layer]: salt
52
46
  };
53
47
  }
54
48
  function isLayered(value) {
55
49
  return "object" == typeof value && null !== value && Layer in value;
56
50
  }
57
- function resolveAttribution(attribution) {
58
- const policy = null != attribution ? attribution : {
59
- kind: "call site"
60
- };
61
- switch(policy.kind){
62
- case "none":
63
- return policy;
64
- case "rooted":
65
- {
66
- const root = normalizeLocation(policy.root);
67
- if (!root.startsWith("/")) throw new FabricatorError.InvalidAttributionRootError(policy.root);
68
- return toRooted(root);
69
- }
70
- case "call site":
71
- {
72
- const root = directoryOf(resolveCallerFile());
73
- return toRooted(root);
74
- }
75
- }
76
- }
77
- function toRooted(root) {
78
- return {
79
- kind: "rooted",
80
- root: root.endsWith("/") ? root : `${root}/`
81
- };
82
- }
83
51
  function toStream(algorithm, seed) {
84
52
  const generator = algorithm(seed);
85
53
  let iterations = 0;
@@ -99,53 +67,30 @@ function toStreamFromTrace(algorithm, trace) {
99
67
  }
100
68
  function toRandomSource(options) {
101
69
  var _options_algorithm;
102
- let seed = normalizeSeed(options.seed);
70
+ let salt = normalizeSalt(options.salt);
103
71
  let algorithm = null != (_options_algorithm = options.algorithm) ? _options_algorithm : defaultAlgorithm;
104
- let attribution = resolveAttribution(options.attribution);
105
72
  const clock = options.clock;
106
- let constructionOrdinals = new Map();
107
- function nextConstructionOrdinal(file) {
108
- var _constructionOrdinals_get;
109
- const ordinal = null != (_constructionOrdinals_get = constructionOrdinals.get(file)) ? _constructionOrdinals_get : 0;
110
- constructionOrdinals.set(file, ordinal + 1);
111
- return ordinal;
112
- }
113
- function toRoot(kind, pins = {}) {
114
- var _pins_root, _pins_clock;
115
- const replaying = void 0 !== pins.root;
116
- const root = null != (_pins_root = pins.root) ? _pins_root : kind;
117
- const file = replaying || void 0 !== pins.file ? pins.file : resolveRootFile(kind);
118
- const ordinal = inline(()=>{
119
- if (replaying || void 0 !== pins.ordinal) return pins.ordinal;
120
- if ("unattributed" === root) return;
121
- return nextConstructionOrdinal(file);
122
- });
73
+ let constructionOrdinal = 0;
74
+ function toRoot(pins = {}) {
75
+ var _pins_salt, _pins_clock;
123
76
  return {
124
- seed,
77
+ salt: null != (_pins_salt = pins.salt) ? _pins_salt : salt,
125
78
  clock: null != (_pins_clock = pins.clock) ? _pins_clock : clock,
126
- root,
127
- file,
128
- ordinal
79
+ ordinal: void 0 !== pins.ordinal ? pins.ordinal : constructionOrdinal++
129
80
  };
130
81
  }
131
- function resolveRootFile(kind) {
132
- if ("attributed" !== kind) return;
133
- if ("none" === attribution.kind) return;
134
- return relativize(attribution.root, resolveCallerFile());
135
- }
136
- function fork(childSeed) {
82
+ function fork(childSalt) {
137
83
  return toRandomSource({
138
- seed: childSeed,
84
+ salt: childSalt,
139
85
  algorithm,
140
- attribution,
141
86
  clock
142
87
  });
143
88
  }
144
89
  return {
145
90
  toRoot,
146
91
  algorithm,
147
- seed,
92
+ salt,
148
93
  fork
149
94
  };
150
95
  }
151
- export { Random_layer as layer, defaultAlgorithm, deriveClock, encode, isLayered, normalizeSeed, randomSeed, resolveAttribution, toRandomSource, toStream, toStreamFromTrace };
96
+ export { Random_layer as layer, defaultAlgorithm, deriveClock, encode, isLayered, normalizeSalt, randomSalt, toRandomSource, toStream, toStreamFromTrace };
@@ -3,6 +3,11 @@ function inline(fn) {
3
3
  return fn();
4
4
  }
5
5
  function never(_) {}
6
+ function noop() {}
7
+ function isThenable(value) {
8
+ if ("object" != typeof value || null === value) return false;
9
+ return "function" == typeof value.then;
10
+ }
6
11
  function isArray(candidate) {
7
12
  return Array.isArray(candidate);
8
13
  }
@@ -33,4 +38,4 @@ function replace(value) {
33
38
  [Replace]: true
34
39
  };
35
40
  }
36
- export { inline, isArray, isPlainObject, isPollutionKey, mergeableKeys, never, replace };
41
+ export { inline, isArray, isPlainObject, isPollutionKey, isThenable, mergeableKeys, never, noop, replace };
@@ -0,0 +1,2 @@
1
+ export { walk } from "./Adapter/Core.js";
2
+ export { Adaptation } from "./Types.js";
@@ -0,0 +1 @@
1
+ export { integration } from "./Harnessing/Core.js";
package/dist/esm/index.js CHANGED
@@ -1,11 +1,12 @@
1
- import { instantiate, overlay, toStack } from "./Instance/Core.js";
1
+ import { toStack } from "#stack";
2
+ import { instantiate, overlay } from "./Instance/Core.js";
2
3
  function initialize(config) {
3
- return instantiate(overlay({}, null != config ? config : {}), toStack()).instance;
4
+ var _ref;
5
+ return instantiate(overlay({}, null != config ? config : {}), null != (_ref = null == config ? void 0 : config.stack) ? _ref : toStack()).instance;
4
6
  }
5
- export { Adaptation, Omitted } from "./Types.js";
7
+ export { Omitted } from "./Types.js";
6
8
  export { layer } from "./Random/index.js";
7
9
  export { FabricatorError } from "./Error/index.js";
8
- export { drive } from "./Adapter/Core.js";
9
10
  export { registry } from "./Schema/Registry.js";
10
11
  export { effectiveDiscrete, toBound } from "./Bound.js";
11
12
  export { initialize };
@@ -1,5 +1,5 @@
1
1
  export { Children, Kind, Meta, Produces } from "./Types.js";
2
2
  export { isPlainObject } from "./Utility/Core.js";
3
3
  export { plan, resolve } from "./Enumeration/Plan.js";
4
- export { defaultAlgorithm, encode, randomSeed, toRandomSource, toStream, toStreamFromTrace } from "./Random/index.js";
5
- export { directoryOf, normalizeLocation, relativize } from "./Random/CallSite.js";
4
+ export { defaultAlgorithm, encode, randomSalt, toRandomSource, toStream, toStreamFromTrace } from "./Random/index.js";
5
+ export { toStack as toSynchronousStack } from "./Instance/Stack/Sync.js";
@@ -4,61 +4,58 @@ type OverrideSchemaAdaptation<$Schema extends object, $Map extends Adaptations>
4
4
  readonly [Adaptation]?: WithAdaptations<AdaptationsOf<$Schema>, $Map>;
5
5
  };
6
6
  /**
7
- * One adapter's entry, keyed by `$Adapter["key"]`. Written as a mapped
8
- * type rather than built inline: a computed key in an object literal
9
- * (`{ [adapter.key]: produce }`) widens to a `string` index signature,
10
- * which no adapter's literal-keyed dispatch matches.
7
+ * One adapter's entry, keyed by `$Adapter["key"]`. Written as a mapped type
8
+ * rather than built inline: a computed key in an object literal (`{
9
+ * [adapter.key]: produce }`) widens to a `string` index signature, which no
10
+ * adapter's literal-keyed dispatch matches.
11
11
  */
12
12
  export type AdaptationEntry<$Adapter extends Adapter, $Returnable> = {
13
13
  readonly [$K in $Adapter["key"]]: (schema: any) => $Returnable;
14
14
  };
15
15
  /**
16
- * A copy of `schema` carrying `produce` as `adapter`'s adaptation:
17
- * that adapter's prior entry is replaced (via {@link layer}), every
18
- * other adapter's is carried forward. Every kind's `.adapt(...)` is a
19
- * call to this, re-typed to that kind's own
20
- * `Schema<..., WithAdaptations<...>>`.
16
+ * A copy of `schema` carrying `produce` as `adapter`'s adaptation: that
17
+ * adapter's prior entry is replaced (via {@link layer}), every other adapter's
18
+ * is carried forward. Every kind's `.adapt(...)` is a call to this, re-typed to
19
+ * that kind's own `Schema<..., WithAdaptations<...>>`.
21
20
  *
22
- * Takes the adapter and producer separately rather than a prebuilt map
23
- * so the key stays a literal, per {@link AdaptationEntry}. The return
24
- * type mirrors the merge (rather than handing back `$Schema`) so call
25
- * sites need no cast: `AdaptationsOf<$Schema>` recovers the prior map
26
- * from whichever kind's `Core` was passed in.
21
+ * Takes the adapter and producer separately rather than a prebuilt map so the
22
+ * key stays a literal, per {@link AdaptationEntry}. The return type mirrors the
23
+ * merge (rather than handing back `$Schema`) so call sites need no cast:
24
+ * `AdaptationsOf<$Schema>` recovers the prior map from whichever kind's `Core`
25
+ * was passed in.
27
26
  */
28
27
  export declare function withAdaptations<const $Schema extends object, const $Adapter extends Adapter, $Returnable>(schema: $Schema, adapter: $Adapter, produce: (adapting: Adapting<any>) => $Returnable): OverrideSchemaAdaptation<$Schema, AdaptationEntry<$Adapter, $Returnable>>;
29
28
  /**
30
29
  * {@link withAdaptations} at the map level, for a kind that keeps its
31
30
  * adaptations beside its schema rather than on it — `object`, whose
32
31
  * `extend`/`refine`/`override` each rebuild the schema from scratch, so
33
- * `Registry.ts`'s `make` has to thread the map through explicitly (see
34
- * its `adapt`).
32
+ * `Registry.ts`'s `make` has to thread the map through explicitly (see its
33
+ * `adapt`).
35
34
  *
36
- * `undefined` rather than an empty map when there is nothing to carry,
37
- * for the same reason `patched` drops the symbol: an absent map and an
38
- * empty one mean the same thing, and only one of them should exist at
39
- * runtime.
35
+ * `undefined` rather than an empty map when there is nothing to carry, for the
36
+ * same reason `patched` drops the symbol: an absent map and an empty one mean
37
+ * the same thing, and only one of them should exist at runtime.
40
38
  */
41
39
  export declare function mergeAdaptations<$Prior extends Adaptations, const $Adapter extends Adapter, $Returnable>(prior: $Prior | undefined, adapter: $Adapter, produce: (adapting: Adapting<any>) => $Returnable): WithAdaptations<$Prior, AdaptationEntry<$Adapter, $Returnable>> | undefined;
42
40
  /**
43
41
  * Walk `schema` with `adapter`, resolving each node to its external
44
42
  * counterpart. Every adapter's entry point is a call to this.
45
43
  *
46
- * The adaptation lookup lives here, ahead of the adapter's own
47
- * per-kind dispatch, so an explicit adaptation wins over the kind's
48
- * mapping — and here rather than in each adapter so it applies at
49
- * *every* node the walk reaches, not just the one it started from.
50
- * That is why an adapter recurses through the {@link Recurse} it is
51
- * handed rather than calling its own `convert` again: a nested
52
- * `object` field, `array` element, or `choice` option gets the same
44
+ * The adaptation lookup lives here, ahead of the adapter's own per-kind
45
+ * dispatch, so an explicit adaptation wins over the kind's mapping — and here
46
+ * rather than in each adapter so it applies at _every_ node the walk reaches,
47
+ * not just the one it started from. That is why an adapter recurses through the
48
+ * {@link Recurse} it is handed rather than calling its own `convert` again: a
49
+ * nested `object` field, `array` element, or `choice` option gets the same
53
50
  * treatment as the root.
54
51
  *
55
- * Paired with {@link layer}: together they make `toTypeBox(schema)`
56
- * *inside* an adaptation resolve to the layer that adaptation replaced
57
- * instead of re-entering itself. This reads the entry; `layer` already
58
- * substituted the previous one into the argument. Splitting the two
59
- * across packages is how they drift.
52
+ * Paired with {@link layer}: together they make `toTypeBox(schema)` _inside_ an
53
+ * adaptation resolve to the layer that adaptation replaced instead of
54
+ * re-entering itself. This reads the entry; `layer` already substituted the
55
+ * previous one into the argument. Splitting the two across packages is how they
56
+ * drift.
60
57
  */
61
- export declare function drive<$Context, $Returnable>(adapter: Adapter<string, $Context, $Returnable>, schema: {
58
+ export declare function walk<$Context, $Returnable>(adapter: Adapter<string, $Context, $Returnable>, schema: {
62
59
  [Adaptation]?: Adaptations;
63
60
  }, context: $Context): $Returnable;
64
61
  export {};
@@ -1,43 +1,41 @@
1
1
  import type { Adaptation, Meta } from "../Types";
2
2
  /**
3
- * One adapter's override for one schema, *as stored* in `[Adaptation]` —
4
- * the loosest signature the mechanism needs. An adapter states its real
5
- * return type on {@link Adapter.convert}, and `.adapt(...)` checks a
6
- * supplied adaptation against that; nothing here reads either end.
3
+ * One adapter's override for one schema, _as stored_ in `[Adaptation]` — the
4
+ * loosest signature the mechanism needs. An adapter states its real return type
5
+ * on {@link Adapter.convert}, and `.adapt(...)` checks a supplied adaptation
6
+ * against that; nothing here reads either end.
7
7
  *
8
- * Not the shape a caller writes: a kind's `.adapt(...)` takes a producer
9
- * of {@link Adapting}, which `Adapter/Core.ts`'s `withAdaptations`/
10
- * `mergeAdaptations` wrap into this one entry point-side. The stored
11
- * form stays schema-taking so `patched`/`layer` treat an incoming
12
- * producer and a prior layered entry as one type, and so
13
- * `AdaptationEntry`'s `(schema: any) => $Returnable` is an accurate
14
- * account of what a schema carries.
8
+ * Not the shape a caller writes: a kind's `.adapt(...)` takes a producer of
9
+ * {@link Adapting}, which `Adapter/Core.ts`'s `withAdaptations`/
10
+ * `mergeAdaptations` wrap into this one entry point-side. The stored form stays
11
+ * schema-taking so `patched`/`layer` treat an incoming producer and a prior
12
+ * layered entry as one type, and so `AdaptationEntry`'s `(schema: any) =>
13
+ * $Returnable` is an accurate account of what a schema carries.
15
14
  */
16
15
  export type SchemaAdaptation = (schema: any) => unknown;
17
16
  /**
18
- * What a kind's `.adapt(adapter, produce)` hands its producer: the schema
19
- * being adapted, and that schema's `[Meta]` — one object rather than two
20
- * parameters, so destructuring picks whichever half is needed and neither
21
- * is reachable only through a well-known symbol.
17
+ * What a kind's `.adapt(adapter, produce)` hands its producer: the schema being
18
+ * adapted, and that schema's `[Meta]` — one object rather than two parameters,
19
+ * so destructuring picks whichever half is needed and neither is reachable only
20
+ * through a well-known symbol.
22
21
  *
23
- * `schema` carries whichever adaptation for this same adapter it
24
- * replaced, absent at the bottom of the stack (see `Adapter/Core.ts`'s
25
- * `layer`) — so `toTypeBox(schema)` inside a producer resolves to the
26
- * previous layer, or to the kind's ordinary mapping when there is none.
27
- * `meta` is read off that same substituted schema, so the two keys
28
- * describe one object.
22
+ * `schema` carries whichever adaptation for this same adapter it replaced,
23
+ * absent at the bottom of the stack (see `Adapter/Core.ts`'s `layer`) — so
24
+ * `toTypeBox(schema)` inside a producer resolves to the previous layer, or to
25
+ * the kind's ordinary mapping when there is none. `meta` is read off that same
26
+ * substituted schema, so the two keys describe one object.
29
27
  *
30
- * `meta`'s shape is the kind's own config blob, derived by indexed
31
- * access rather than named separately so no kind states its own `Meta`
32
- * twice in an `adapt` signature. **Readable but not stabilized**: an
33
- * adaptation may read it; a kind stays free to restructure it — nothing
34
- * outside a kind's own files should *interpret* another kind's `[Meta]`.
28
+ * `meta`'s shape is the kind's own config blob, derived by indexed access
29
+ * rather than named separately so no kind states its own `Meta` twice in an
30
+ * `adapt` signature. **Readable but not stabilized**: an adaptation may read
31
+ * it; a kind stays free to restructure it — nothing outside a kind's own files
32
+ * should _interpret_ another kind's `[Meta]`.
35
33
  *
36
34
  * A kind with no bare-form default carries no `[Meta]` at runtime until
37
35
  * configured (`string`/`bigint`'s registry exports — see "Anatomy of a
38
- * primitive"), so `meta` can be `undefined` there despite this type.
39
- * Same imprecision `Schema<$Meta>` already states, and why the TypeBox
40
- * adapter reads `[Meta]` defensively for those kinds.
36
+ * primitive"), so `meta` can be `undefined` there despite this type. Same
37
+ * imprecision `Schema<$Meta>` already states, and why the TypeBox adapter reads
38
+ * `[Meta]` defensively for those kinds.
41
39
  */
42
40
  export type Adapting<$Schema extends {
43
41
  [Meta]: unknown;
@@ -46,70 +44,64 @@ export type Adapting<$Schema extends {
46
44
  readonly meta: $Schema[typeof Meta];
47
45
  };
48
46
  /**
49
- * What a Schema's `[Adaptation]` holds: each adapter's override, under
50
- * that adapter's own key.
47
+ * What a Schema's `[Adaptation]` holds: each adapter's override, under that
48
+ * adapter's own key.
51
49
  *
52
- * Open rather than a closed registry of known libraries: an adapter is
53
- * a value (see {@link Adapter}), not a name this package knows. Nothing
54
- * has to be declared for a third party's adapter to work, and two
55
- * adapters for different versions of the same library collide with
56
- * nothing.
50
+ * Open rather than a closed registry of known libraries: an adapter is a value
51
+ * (see {@link Adapter}), not a name this package knows. Nothing has to be
52
+ * declared for a third party's adapter to work, and two adapters for different
53
+ * versions of the same library collide with nothing.
57
54
  */
58
55
  export type Adaptations = {
59
56
  readonly [key: string]: SchemaAdaptation;
60
57
  };
61
58
  /**
62
59
  * An {@link Adaptations} update as `withAdaptations` accepts it. Identical
63
- * except that an explicitly-`undefined` entry *removes* that adapter's
64
- * override — how the layering hands an adaptation the schema it is
65
- * adapting with its own entry replaced by the previous one, or absent
66
- * at the bottom of the stack.
60
+ * except that an explicitly-`undefined` entry _removes_ that adapter's override
61
+ * — how the layering hands an adaptation the schema it is adapting with its own
62
+ * entry replaced by the previous one, or absent at the bottom of the stack.
67
63
  *
68
- * Not what a kind's `.adapt(...)` accepts: removal is an internal need
69
- * of the layering, and letting a caller express it would produce a
70
- * `[Adaptation]` type that `exactOptionalPropertyTypes` rejects against
71
- * {@link Adaptations}.
64
+ * Not what a kind's `.adapt(...)` accepts: removal is an internal need of the
65
+ * layering, and letting a caller express it would produce a `[Adaptation]` type
66
+ * that `exactOptionalPropertyTypes` rejects against {@link Adaptations}.
72
67
  */
73
68
  export type Patch = {
74
69
  readonly [key: string]: SchemaAdaptation | undefined;
75
70
  };
76
71
  /**
77
72
  * How an adapter recurses into a nested schema — handed to
78
- * {@link Adapter.convert} by `Adapter/Core.ts`'s `drive` rather than
79
- * being the adapter's own private recursion, so every nested node goes
80
- * back through the adaptation lookup, not only the outermost one.
73
+ * {@link Adapter.convert} by `Adapter/Core.ts`'s `walk` rather than being the
74
+ * adapter's own private recursion, so every nested node goes back through the
75
+ * adaptation lookup, not only the outermost one.
81
76
  *
82
- * `$Context` is the adapter's own, and opaque here: an adapter that
83
- * needs to carry something down its recursion (the enclosing
84
- * `T.recursive`'s placeholder, say) threads it through unchanged.
85
- * `$Returnable` is likewise the adapter's own — stated so a nested
86
- * node's result drops straight into a composite
87
- * (`Type.Array(recurse(element, context))`) with no cast at any call
77
+ * `$Context` is the adapter's own, and opaque here: an adapter that needs to
78
+ * carry something down its recursion (the enclosing `T.recursive`'s
79
+ * placeholder, say) threads it through unchanged. `$Returnable` is likewise the
80
+ * adapter's own — stated so a nested node's result drops straight into a
81
+ * composite (`Type.Array(recurse(element, context))`) with no cast at any call
88
82
  * site.
89
83
  */
90
84
  export type Recurse<$Context, $Returnable> = (schema: any, context: $Context) => $Returnable;
91
85
  /**
92
- * An adapter to one external schema library: a plain value, imported
93
- * directly by whoever adapts a schema (`schema.adapt(typebox, ...)`)
94
- * and by whoever converts one. Nothing to register — no global
95
- * interface to declaration-merge, and no name chosen anywhere but here.
86
+ * An adapter to one external schema library: a plain value, imported directly
87
+ * by whoever adapts a schema (`schema.adapt(typebox, ...)`) and by whoever
88
+ * converts one. Nothing to register — no global interface to declaration-merge,
89
+ * and no name chosen anywhere but here.
96
90
  *
97
- * `key` is the adapter's `[Adaptation]` namespace. Read off the value
98
- * as a literal type, so a wrong one is an import error rather than an
99
- * entry nothing looks up. Give it something collision-proof — a package
100
- * specifier, versioned when a library's major rewrite means two
101
- * adapters can coexist.
91
+ * `key` is the adapter's `[Adaptation]` namespace. Read off the value as a
92
+ * literal type, so a wrong one is an import error rather than an entry nothing
93
+ * looks up. Give it something collision-proof — a package specifier, versioned
94
+ * when a library's major rewrite means two adapters can coexist.
102
95
  *
103
- * `convert`'s declared return type is this adapter's external bound:
104
- * the type every `.adapt(...)` against it must produce, and why an
105
- * adaptation that returns the wrong thing fails at the call site.
96
+ * `convert`'s declared return type is this adapter's external bound: the type
97
+ * every `.adapt(...)` against it must produce, and why an adaptation that
98
+ * returns the wrong thing fails at the call site.
106
99
  *
107
- * Deliberately *not* carrying the adapter's type-level mapping. An
108
- * adapter package declares its own conversion entry point with its own
109
- * return type (`toTypeBox<$S>(schema: $S): ToTypeBox<$S>`), so nothing
110
- * has to compute a type-level mapping out of a stored value — which
111
- * would need the interface-member-lookup encoding `ValueOf`'s
112
- * `$Bindings` uses, for no gain.
100
+ * Deliberately _not_ carrying the adapter's type-level mapping. An adapter
101
+ * package declares its own conversion entry point with its own return type
102
+ * (`toTypeBox<$S>(schema: $S): ToTypeBox<$S>`), so nothing has to compute a
103
+ * type-level mapping out of a stored value — which would need the
104
+ * interface-member-lookup encoding `ValueOf`'s `$Bindings` uses, for no gain.
113
105
  */
114
106
  export interface Adapter<$Key extends string = string, $Context = unknown, $Returnable = unknown> {
115
107
  readonly key: $Key;
@@ -119,27 +111,25 @@ export interface Adapter<$Key extends string = string, $Context = unknown, $Retu
119
111
  * The adaptations a Schema (or a built Fabricator, which carries them
120
112
  * identically) declares, or `{}` for one that declares none.
121
113
  *
122
- * The two steps — extract the map, then match against it — are
123
- * load-bearing, and why no adapter matches
124
- * `{ [Adaptation]?: Record<Key, ...> }` directly. Every kind's `Core`
125
- * declares `[Adaptation]` as *optional*, and a conditional matching an
126
- * optional property against a schema that lacks it entirely still
127
- * *succeeds*, inferring `unknown` (the same behavior `ValueOf` relies
128
- * on for `[Produces]`) — so a direct match would resolve every
129
- * unadapted schema to whatever the adapter's adaptation branch
130
- * produces. Constraining the `infer` sends that case here, to `{}`,
131
- * which then fails each adapter's `Record<Key, ...>` check as it
132
- * should.
114
+ * The two steps — extract the map, then match against it — are load-bearing,
115
+ * and why no adapter matches `{ [Adaptation]?: Record<Key, ...> }` directly.
116
+ * Every kind's `Core` declares `[Adaptation]` as _optional_, and a conditional
117
+ * matching an optional property against a schema that lacks it entirely still
118
+ * _succeeds_, inferring `unknown` (the same behavior `ValueOf` relies on for
119
+ * `[Produces]`) — so a direct match would resolve every unadapted schema to
120
+ * whatever the adapter's adaptation branch produces. Constraining the `infer`
121
+ * sends that case here, to `{}`, which then fails each adapter's `Record<Key,
122
+ * ...>` check as it should.
133
123
  */
134
124
  export type AdaptationsOf<$Schema> = $Schema extends {
135
125
  [Adaptation]?: infer $Adaptations extends Adaptations;
136
126
  } ? $Adaptations : {};
137
127
  /**
138
- * `$Prior` with `$Map` applied: an adapter named in `$Map` takes its new
139
- * entry; one it doesn't name is carried forward. `Omit` first (rather
140
- * than a plain `$Prior & $Map`) so a replaced entry is genuinely
141
- * replaced — intersecting two call signatures for the same adapter
142
- * would produce an overload, from which an adapter's `infer` would
143
- * read whichever member TypeScript happens to resolve last.
128
+ * `$Prior` with `$Map` applied: an adapter named in `$Map` takes its new entry;
129
+ * one it doesn't name is carried forward. `Omit` first (rather than a plain
130
+ * `$Prior & $Map`) so a replaced entry is genuinely replaced — intersecting two
131
+ * call signatures for the same adapter would produce an overload, from which an
132
+ * adapter's `infer` would read whichever member TypeScript happens to resolve
133
+ * last.
144
134
  */
145
135
  export type WithAdaptations<$Prior extends Adaptations, $Map extends Adaptations> = Omit<$Prior, keyof $Map> & $Map;
@@ -1,16 +1,16 @@
1
1
  /**
2
2
  * Canonical endpoint stored on `[Meta].whereby`. Call sites still accept a
3
- * scalar (inclusive) via {@link InputBound}; `.whereby()` runs {@link toBound}
4
- * so adapters always see this shape — never a scalar/object union.
3
+ * scalar (inclusive) via {@link InputBound}; `.whereby()` runs {@link toBound} so
4
+ * adapters always see this shape — never a scalar/object union.
5
5
  */
6
6
  export type Bound<$T> = {
7
7
  value: $T;
8
8
  exclusive: boolean;
9
9
  };
10
10
  /**
11
- * What `.whereby({ min, max })` accepts: a scalar is inclusive, an object
12
- * names an endpoint policy. `exclusive` is required on the object form so
13
- * that form exists only to state one.
11
+ * What `.whereby({ min, max })` accepts: a scalar is inclusive, an object names
12
+ * an endpoint policy. `exclusive` is required on the object form so that form
13
+ * exists only to state one.
14
14
  */
15
15
  export type InputBound<$T> = $T | Bound<$T>;
16
16
  /**
@@ -20,8 +20,8 @@ export type InputBound<$T> = $T | Bound<$T>;
20
20
  */
21
21
  export declare function toBound<$T>(input: InputBound<$T>): Bound<$T>;
22
22
  /**
23
- * Inclusive integer interval implied by a discrete Bound pair. Exclusive min
24
- * is `value + 1`, exclusive max is `value - 1` — the same unit the length/
23
+ * Inclusive integer interval implied by a discrete Bound pair. Exclusive min is
24
+ * `value + 1`, exclusive max is `value - 1` — the same unit the length/
25
25
  * integer/bigint draws already use. Empty iff `min > max`.
26
26
  */
27
27
  export declare function effectiveDiscrete(min: Bound<number>, max: Bound<number>): {
@@ -37,15 +37,15 @@ export declare function assertNonemptyDiscreteBigint(label: string, min: Bound<b
37
37
  /**
38
38
  * Continuous emptiness: inverted bounds, a point range with either end
39
39
  * exclusive, or both ends exclusive with no float strictly between them.
40
- * Sampling still uses the closed interval and {@link constrainContinuous}
41
- * steps off an exclusive endpoint — this check is what makes that step
42
- * always have somewhere to land.
40
+ * Sampling still uses the closed interval and {@link constrainContinuous} steps
41
+ * off an exclusive endpoint — this check is what makes that step always have
42
+ * somewhere to land.
43
43
  */
44
44
  export declare function assertNonemptyContinuous(label: string, min: Bound<number>, max: Bound<number>): void;
45
45
  /**
46
- * One ulp toward `toward` from `value`. Approximate, and enough to leave
47
- * an exclusive endpoint without rejection-looping a truncated distribution
48
- * that clamped onto it.
46
+ * One ulp toward `toward` from `value`. Approximate, and enough to leave an
47
+ * exclusive endpoint without rejection-looping a truncated distribution that
48
+ * clamped onto it.
49
49
  */
50
50
  export declare function towardInterior(value: number, toward: number): number;
51
51
  /**
@@ -56,8 +56,8 @@ export declare function towardInterior(value: number, toward: number): number;
56
56
  export declare function constrainContinuous(next: () => number, min: Bound<number>, max: Bound<number>): () => number;
57
57
  export declare function epochBound(bound: Bound<Date>): Bound<number>;
58
58
  /**
59
- * Array/string `length`: a bare number is an exact count; an omitted `min`
60
- * is inclusive `0`. Always stored as a Bound pair so adapters have one path.
59
+ * Array/string `length`: a bare number is an exact count; an omitted `min` is
60
+ * inclusive `0`. Always stored as a Bound pair so adapters have one path.
61
61
  */
62
62
  export declare function toLengthRange(length: number | {
63
63
  max: InputBound<number>;