@ghostry/fabricator 0.0.13 → 0.0.15

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 (234) hide show
  1. package/dist/esm/Bound.js +74 -1
  2. package/dist/esm/Distribution/index.js +103 -2
  3. package/dist/esm/Enumeration/Enumerate.js +10 -5
  4. package/dist/esm/Enumeration/Plan.js +2 -2
  5. package/dist/esm/Error/index.js +96 -27
  6. package/dist/esm/Fabricator/Constructor.js +7 -5
  7. package/dist/esm/Instance/Core.js +3 -0
  8. package/dist/esm/Primitive/array/Admits.js +18 -0
  9. package/dist/esm/Primitive/array/Fabricator.js +20 -2
  10. package/dist/esm/Primitive/array/Registry.js +32 -0
  11. package/dist/esm/Primitive/array/Schema.js +8 -0
  12. package/dist/esm/Primitive/bigint/Admits.js +11 -0
  13. package/dist/esm/Primitive/bigint/Fabricator.js +16 -23
  14. package/dist/esm/Primitive/bigint/Registry.js +17 -6
  15. package/dist/esm/Primitive/bigint/Schema.js +8 -0
  16. package/dist/esm/Primitive/date/Admits.js +22 -0
  17. package/dist/esm/Primitive/date/Defaults.js +27 -1
  18. package/dist/esm/Primitive/date/Fabricator.js +32 -34
  19. package/dist/esm/Primitive/date/Registry.js +80 -13
  20. package/dist/esm/Primitive/date/Schema.js +8 -0
  21. package/dist/esm/Primitive/enum/Fabricator.js +14 -2
  22. package/dist/esm/Primitive/enum/Registry.js +38 -25
  23. package/dist/esm/Primitive/index.js +1 -0
  24. package/dist/esm/Primitive/number/Admits.js +27 -0
  25. package/dist/esm/Primitive/number/Fabricator.js +18 -9
  26. package/dist/esm/Primitive/number/Registry.js +55 -4
  27. package/dist/esm/Primitive/number/Schema.js +10 -3
  28. package/dist/esm/Primitive/object/Fabricator.js +2 -0
  29. package/dist/esm/Primitive/record/Admits.js +42 -0
  30. package/dist/esm/Primitive/record/Fabricator.js +49 -19
  31. package/dist/esm/Primitive/record/Registry.js +29 -0
  32. package/dist/esm/Primitive/record/Schema.js +8 -0
  33. package/dist/esm/Primitive/recursive/Fabricator.js +3 -2
  34. package/dist/esm/Primitive/recursive/Terminate.js +16 -2
  35. package/dist/esm/Primitive/string/Admits.js +26 -0
  36. package/dist/esm/Primitive/string/Capacity.js +81 -0
  37. package/dist/esm/Primitive/string/Fabricator.js +23 -43
  38. package/dist/esm/Primitive/string/Registry.js +31 -9
  39. package/dist/esm/Primitive/string/Schema.js +10 -3
  40. package/dist/esm/Primitive/string/Sources.js +41 -0
  41. package/dist/esm/Primitive/unique/Registry.js +22 -0
  42. package/dist/esm/Primitive/unique/index.js +2 -0
  43. package/dist/esm/Types.js +2 -1
  44. package/dist/esm/Unique/Capacity.js +85 -0
  45. package/dist/esm/Unique/Distinct.js +187 -0
  46. package/dist/esm/Unique/Key.js +70 -0
  47. package/dist/esm/Unique/Override.js +23 -0
  48. package/dist/esm/Unique/Strategy.js +173 -0
  49. package/dist/esm/internal.js +1 -0
  50. package/dist/types/Adapter/Core.d.ts +2 -2
  51. package/dist/types/Adapter/Types.d.ts +1 -1
  52. package/dist/types/Bound.d.ts +67 -1
  53. package/dist/types/Distribution/index.d.ts +83 -1
  54. package/dist/types/Enumeration/Enumerate.d.ts +3 -3
  55. package/dist/types/Enumeration/Plan.d.ts +1 -1
  56. package/dist/types/Enumeration/Types.d.ts +14 -5
  57. package/dist/types/Error/index.d.ts +283 -0
  58. package/dist/types/Fabricator/Constructor.d.ts +9 -5
  59. package/dist/types/Fabricator/Fabricate.d.ts +5 -5
  60. package/dist/types/Fabricator/Types.d.ts +19 -6
  61. package/dist/types/Harnessing/Core.d.ts +3 -3
  62. package/dist/types/Harnessing/Salt.d.ts +1 -1
  63. package/dist/types/Harnessing/Types.d.ts +2 -2
  64. package/dist/types/Instance/Core.d.ts +4 -4
  65. package/dist/types/Instance/Stack/Async.d.ts +1 -1
  66. package/dist/types/Instance/Stack/Sync.d.ts +1 -1
  67. package/dist/types/Instance/Stack/Visible.d.ts +2 -2
  68. package/dist/types/Instance/Types.d.ts +19 -5
  69. package/dist/types/Primitive/always/Fabricator.d.ts +6 -6
  70. package/dist/types/Primitive/always/Registry.d.ts +2 -2
  71. package/dist/types/Primitive/always/Schema.d.ts +4 -4
  72. package/dist/types/Primitive/always/Types.d.ts +2 -2
  73. package/dist/types/Primitive/always/index.d.ts +5 -5
  74. package/dist/types/Primitive/array/Admits.d.ts +7 -0
  75. package/dist/types/Primitive/array/Fabricator.d.ts +7 -7
  76. package/dist/types/Primitive/array/Registry.d.ts +40 -3
  77. package/dist/types/Primitive/array/Schema.d.ts +10 -5
  78. package/dist/types/Primitive/array/Types.d.ts +37 -5
  79. package/dist/types/Primitive/array/index.d.ts +5 -5
  80. package/dist/types/Primitive/bigint/Admits.d.ts +7 -0
  81. package/dist/types/Primitive/bigint/Fabricator.d.ts +8 -6
  82. package/dist/types/Primitive/bigint/Registry.d.ts +24 -4
  83. package/dist/types/Primitive/bigint/Schema.d.ts +13 -5
  84. package/dist/types/Primitive/bigint/Types.d.ts +30 -6
  85. package/dist/types/Primitive/bigint/index.d.ts +5 -5
  86. package/dist/types/Primitive/boolean/Fabricator.d.ts +6 -6
  87. package/dist/types/Primitive/boolean/Registry.d.ts +2 -2
  88. package/dist/types/Primitive/boolean/Schema.d.ts +5 -5
  89. package/dist/types/Primitive/boolean/Types.d.ts +3 -3
  90. package/dist/types/Primitive/boolean/index.d.ts +6 -6
  91. package/dist/types/Primitive/choice/Fabricator.d.ts +6 -6
  92. package/dist/types/Primitive/choice/Registry.d.ts +2 -2
  93. package/dist/types/Primitive/choice/Schema.d.ts +5 -5
  94. package/dist/types/Primitive/choice/Types.d.ts +4 -4
  95. package/dist/types/Primitive/choice/index.d.ts +5 -5
  96. package/dist/types/Primitive/date/Admits.d.ts +7 -0
  97. package/dist/types/Primitive/date/Defaults.d.ts +22 -1
  98. package/dist/types/Primitive/date/Fabricator.d.ts +8 -6
  99. package/dist/types/Primitive/date/Registry.d.ts +49 -13
  100. package/dist/types/Primitive/date/Schema.d.ts +14 -5
  101. package/dist/types/Primitive/date/Types.d.ts +57 -8
  102. package/dist/types/Primitive/date/index.d.ts +5 -5
  103. package/dist/types/Primitive/derive/Fabricator.d.ts +7 -7
  104. package/dist/types/Primitive/derive/Registry.d.ts +2 -2
  105. package/dist/types/Primitive/derive/Schema.d.ts +6 -6
  106. package/dist/types/Primitive/derive/Types.d.ts +6 -6
  107. package/dist/types/Primitive/derive/index.d.ts +5 -5
  108. package/dist/types/Primitive/enum/Fabricator.d.ts +8 -6
  109. package/dist/types/Primitive/enum/Registry.d.ts +22 -2
  110. package/dist/types/Primitive/enum/Schema.d.ts +5 -5
  111. package/dist/types/Primitive/enum/Types.d.ts +8 -3
  112. package/dist/types/Primitive/enum/index.d.ts +5 -5
  113. package/dist/types/Primitive/index.d.ts +28 -27
  114. package/dist/types/Primitive/namespace.d.ts +21 -21
  115. package/dist/types/Primitive/null/Fabricator.d.ts +6 -6
  116. package/dist/types/Primitive/null/Registry.d.ts +1 -1
  117. package/dist/types/Primitive/null/Schema.d.ts +4 -4
  118. package/dist/types/Primitive/null/Types.d.ts +2 -2
  119. package/dist/types/Primitive/null/index.d.ts +5 -5
  120. package/dist/types/Primitive/nullable/Fabricator.d.ts +6 -6
  121. package/dist/types/Primitive/nullable/Registry.d.ts +2 -2
  122. package/dist/types/Primitive/nullable/Schema.d.ts +6 -6
  123. package/dist/types/Primitive/nullable/Types.d.ts +5 -5
  124. package/dist/types/Primitive/nullable/index.d.ts +6 -6
  125. package/dist/types/Primitive/nullish/Fabricator.d.ts +6 -6
  126. package/dist/types/Primitive/nullish/Registry.d.ts +2 -2
  127. package/dist/types/Primitive/nullish/Schema.d.ts +6 -6
  128. package/dist/types/Primitive/nullish/Types.d.ts +5 -5
  129. package/dist/types/Primitive/nullish/index.d.ts +6 -6
  130. package/dist/types/Primitive/number/Admits.d.ts +9 -0
  131. package/dist/types/Primitive/number/Defaults.d.ts +1 -1
  132. package/dist/types/Primitive/number/Fabricator.d.ts +8 -6
  133. package/dist/types/Primitive/number/Registry.d.ts +45 -4
  134. package/dist/types/Primitive/number/Schema.d.ts +14 -6
  135. package/dist/types/Primitive/number/Types.d.ts +36 -14
  136. package/dist/types/Primitive/number/index.d.ts +5 -5
  137. package/dist/types/Primitive/object/Fabricator.d.ts +6 -6
  138. package/dist/types/Primitive/object/Registry.d.ts +4 -4
  139. package/dist/types/Primitive/object/Schema.d.ts +8 -8
  140. package/dist/types/Primitive/object/Types.d.ts +6 -6
  141. package/dist/types/Primitive/object/compute/Fabricator.d.ts +7 -7
  142. package/dist/types/Primitive/object/compute/Registry.d.ts +2 -2
  143. package/dist/types/Primitive/object/compute/Schema.d.ts +7 -7
  144. package/dist/types/Primitive/object/compute/Types.d.ts +3 -3
  145. package/dist/types/Primitive/object/compute/index.d.ts +5 -5
  146. package/dist/types/Primitive/object/index.d.ts +8 -8
  147. package/dist/types/Primitive/object/omit/Registry.d.ts +2 -2
  148. package/dist/types/Primitive/object/omit/index.d.ts +2 -2
  149. package/dist/types/Primitive/object/omittable/Fabricator.d.ts +6 -6
  150. package/dist/types/Primitive/object/omittable/Registry.d.ts +2 -2
  151. package/dist/types/Primitive/object/omittable/Schema.d.ts +6 -6
  152. package/dist/types/Primitive/object/omittable/Types.d.ts +5 -5
  153. package/dist/types/Primitive/object/omittable/index.d.ts +6 -6
  154. package/dist/types/Primitive/object/optional/Fabricator.d.ts +6 -6
  155. package/dist/types/Primitive/object/optional/Registry.d.ts +2 -2
  156. package/dist/types/Primitive/object/optional/Schema.d.ts +6 -6
  157. package/dist/types/Primitive/object/optional/Types.d.ts +5 -5
  158. package/dist/types/Primitive/object/optional/index.d.ts +6 -6
  159. package/dist/types/Primitive/object/pick/Registry.d.ts +2 -2
  160. package/dist/types/Primitive/object/pick/index.d.ts +2 -2
  161. package/dist/types/Primitive/opaque/Fabricator.d.ts +6 -6
  162. package/dist/types/Primitive/opaque/Registry.d.ts +2 -2
  163. package/dist/types/Primitive/opaque/Schema.d.ts +4 -4
  164. package/dist/types/Primitive/opaque/Types.d.ts +3 -3
  165. package/dist/types/Primitive/opaque/index.d.ts +5 -5
  166. package/dist/types/Primitive/record/Admits.d.ts +18 -0
  167. package/dist/types/Primitive/record/Fabricator.d.ts +7 -7
  168. package/dist/types/Primitive/record/Registry.d.ts +20 -3
  169. package/dist/types/Primitive/record/Schema.d.ts +12 -5
  170. package/dist/types/Primitive/record/Types.d.ts +64 -10
  171. package/dist/types/Primitive/record/index.d.ts +5 -5
  172. package/dist/types/Primitive/recursive/Fabricator.d.ts +6 -6
  173. package/dist/types/Primitive/recursive/Registry.d.ts +4 -4
  174. package/dist/types/Primitive/recursive/Schema.d.ts +4 -4
  175. package/dist/types/Primitive/recursive/Terminate.d.ts +8 -1
  176. package/dist/types/Primitive/recursive/Types.d.ts +3 -3
  177. package/dist/types/Primitive/recursive/index.d.ts +6 -6
  178. package/dist/types/Primitive/recursive/self/Fabricator.d.ts +5 -5
  179. package/dist/types/Primitive/recursive/self/Registry.d.ts +1 -1
  180. package/dist/types/Primitive/recursive/self/Schema.d.ts +4 -4
  181. package/dist/types/Primitive/recursive/self/Types.d.ts +2 -2
  182. package/dist/types/Primitive/recursive/self/index.d.ts +5 -5
  183. package/dist/types/Primitive/string/Admits.d.ts +8 -0
  184. package/dist/types/Primitive/string/Capacity.d.ts +36 -0
  185. package/dist/types/Primitive/string/Constants.d.ts +1 -1
  186. package/dist/types/Primitive/string/Fabricator.d.ts +8 -6
  187. package/dist/types/Primitive/string/Registry.d.ts +29 -8
  188. package/dist/types/Primitive/string/Schema.d.ts +32 -6
  189. package/dist/types/Primitive/string/Sources.d.ts +16 -0
  190. package/dist/types/Primitive/string/Types.d.ts +39 -19
  191. package/dist/types/Primitive/string/index.d.ts +6 -6
  192. package/dist/types/Primitive/symbol/Fabricator.d.ts +6 -6
  193. package/dist/types/Primitive/symbol/Registry.d.ts +2 -2
  194. package/dist/types/Primitive/symbol/Schema.d.ts +5 -5
  195. package/dist/types/Primitive/symbol/Types.d.ts +3 -3
  196. package/dist/types/Primitive/symbol/index.d.ts +5 -5
  197. package/dist/types/Primitive/tuple/Fabricator.d.ts +6 -6
  198. package/dist/types/Primitive/tuple/Registry.d.ts +2 -2
  199. package/dist/types/Primitive/tuple/Schema.d.ts +5 -5
  200. package/dist/types/Primitive/tuple/Types.d.ts +4 -4
  201. package/dist/types/Primitive/tuple/index.d.ts +5 -5
  202. package/dist/types/Primitive/undefinable/Fabricator.d.ts +6 -6
  203. package/dist/types/Primitive/undefinable/Registry.d.ts +2 -2
  204. package/dist/types/Primitive/undefinable/Schema.d.ts +6 -6
  205. package/dist/types/Primitive/undefinable/Types.d.ts +5 -5
  206. package/dist/types/Primitive/undefinable/index.d.ts +6 -6
  207. package/dist/types/Primitive/undefined/Fabricator.d.ts +6 -6
  208. package/dist/types/Primitive/undefined/Registry.d.ts +1 -1
  209. package/dist/types/Primitive/undefined/Schema.d.ts +4 -4
  210. package/dist/types/Primitive/undefined/Types.d.ts +2 -2
  211. package/dist/types/Primitive/undefined/index.d.ts +5 -5
  212. package/dist/types/Primitive/unique/Registry.d.ts +39 -0
  213. package/dist/types/Primitive/unique/index.d.ts +2 -0
  214. package/dist/types/Random/Generator/sfc32.d.ts +1 -1
  215. package/dist/types/Random/Types.d.ts +1 -1
  216. package/dist/types/Random/index.d.ts +1 -1
  217. package/dist/types/Schema/Core.d.ts +5 -5
  218. package/dist/types/Schema/Registry.d.ts +3 -3
  219. package/dist/types/Schema/Satisfies.d.ts +3 -3
  220. package/dist/types/Schema/Types.d.ts +5 -5
  221. package/dist/types/Types.d.ts +11 -2
  222. package/dist/types/Unique/Capacity.d.ts +29 -0
  223. package/dist/types/Unique/Distinct.d.ts +95 -0
  224. package/dist/types/Unique/Key.d.ts +29 -0
  225. package/dist/types/Unique/Override.d.ts +16 -0
  226. package/dist/types/Unique/Strategy.d.ts +135 -0
  227. package/dist/types/Utility/Core.d.ts +2 -2
  228. package/dist/types/Utility/DeepMerge.d.ts +2 -2
  229. package/dist/types/Utility/ShallowMerge.d.ts +2 -2
  230. package/dist/types/adapting.d.ts +3 -3
  231. package/dist/types/harnessing.d.ts +2 -2
  232. package/dist/types/index.d.ts +40 -27
  233. package/dist/types/internal.d.ts +16 -15
  234. package/package.json +2 -2
@@ -1,5 +1,5 @@
1
- import type { Produce } from "../../Random/Types";
2
- import { Schema } from "./Schema";
1
+ import type { Produce } from "../../Random/Types.ts";
2
+ import { Schema } from "./Schema.ts";
3
3
  /**
4
4
  * A value this library has no kind for — a `Map`, a `Set`, a `URL`, a class
5
5
  * instance — produced by `produce` and typed as whatever it returns, so
@@ -1,7 +1,7 @@
1
- import { type AdaptationEntry } from "../../Adapter/Core";
2
- import type { Adaptations, Adapter, Adapting, WithAdaptations } from "../../Adapter/Types";
3
- import { type SatisfiesThis } from "../../Schema/Satisfies";
4
- import type { Core, Fabricated } from "./Types";
1
+ import { type AdaptationEntry } from "../../Adapter/Core.ts";
2
+ import type { Adaptations, Adapter, Adapting, WithAdaptations } from "../../Adapter/Types.ts";
3
+ import { type SatisfiesThis } from "../../Schema/Satisfies.ts";
4
+ import type { Core, Fabricated } from "./Types.ts";
5
5
  /**
6
6
  * Escape hatch for values no kind models — a `Map`, a `Set`, a `URL`, a class
7
7
  * instance, a branded type. `produce` is supplied at construction and receives
@@ -1,6 +1,6 @@
1
- import type { Adaptations } from "../../Adapter/Types";
2
- import type { Produce } from "../../Random/Types";
3
- import { Produces, type Adaptation, type Kind, type Meta, type Produced } from "../../Types";
1
+ import type { Adaptations } from "../../Adapter/Types.ts";
2
+ import type { Produce } from "../../Random/Types.ts";
3
+ import { Produces, type Adaptation, type Kind, type Meta, type Produced } from "../../Types.ts";
4
4
  export type Fabricated<$T> = $T;
5
5
  /**
6
6
  * A single required member, unlike the two-arm unions kinds with a `whereby`
@@ -1,5 +1,5 @@
1
- export * from "./Types";
2
- export * from "./Schema";
3
- export * from "./Fabricator";
4
- export * from "./Registry";
5
- export { default } from "./Registry";
1
+ export * from "./Types.ts";
2
+ export * from "./Schema.ts";
3
+ export * from "./Fabricator.ts";
4
+ export * from "./Registry.ts";
5
+ export { default } from "./Registry.ts";
@@ -0,0 +1,18 @@
1
+ import { type AdmittedEnds } from "../../Bound.ts";
2
+ import type { Admits, InputAdmits, Meta } from "./Types.ts";
3
+ /**
4
+ * Resolve `.admits(...)` against what is admitted already: `meta.admits`, or by
5
+ * default the written size ({@link toStatedSize}) — what an adapter states
6
+ * without one. Admitting is checked against what the record can fabricate
7
+ * ({@link toFabricableSize}), which for a plain record differs from what it
8
+ * states. Under `.as(produce)` nothing is drawn, so nothing is checked.
9
+ */
10
+ export declare function toAdmits(meta: Meta, input: InputAdmits): Admits;
11
+ /**
12
+ * The count a record states without `.admits`: the bounds written in `whereby`,
13
+ * as written. A unique record's `size` is a range. A plain record's `minTried`
14
+ * counts attempts, not entries, so only `max` is stated. The TypeBox adapter's
15
+ * `toPropertyCount` states the same, and `recursive/Terminate.ts` reads it to
16
+ * see whether an emptied record would break a stated minimum.
17
+ */
18
+ export declare function toStatedSize(meta: Meta): AdmittedEnds<number>;
@@ -1,9 +1,9 @@
1
- import type { AdaptationsOf } from "../../Adapter/Types";
2
- import type { FabricatorContext, NaiveFabricator } from "../../Fabricator/Types";
3
- import type { Trace } from "../../Random/Types";
4
- import { Children, Kind, Meta, type Adaptation } from "../../Types";
5
- import { Schema } from "./Schema";
6
- import type { Fabricated, Key, Meta as ThisMeta, Value } from "./Types";
1
+ import type { AdaptationsOf } from "../../Adapter/Types.ts";
2
+ import type { Fabricator as BaseFabricator, FabricatorContext, NaiveFabricator } from "../../Fabricator/Types.ts";
3
+ import type { Trace } from "../../Random/Types.ts";
4
+ import { Children, Kind, Meta, type Adaptation } from "../../Types.ts";
5
+ import { Schema } from "./Schema.ts";
6
+ import type { Fabricated, Key, Meta as ThisMeta, Value } from "./Types.ts";
7
7
  export type Fabrication<$Fabricator extends Fabricator> = $Fabricator extends Fabricator<infer $Schema extends {
8
8
  [Meta]: ThisMeta;
9
9
  }> ? Fabricated<$Schema[typeof Meta]["key"], $Schema[typeof Meta]["value"]> : never;
@@ -22,4 +22,4 @@ export type Fabricator<$Schema extends {
22
22
  readonly [Adaptation]?: AdaptationsOf<$Schema>;
23
23
  schema: Schema<$Schema[typeof Meta]["key"], $Schema[typeof Meta]["value"], AdaptationsOf<$Schema>>;
24
24
  };
25
- export declare function Fabricator<$Key extends Key, $Value extends Value>(context: FabricatorContext<Schema<$Key, $Value>>, key: NaiveFabricator<any>, value: NaiveFabricator<any>): Fabricator<Schema<$Key, $Value>>;
25
+ export declare function Fabricator<$Key extends Key, $Value extends Value>(context: FabricatorContext<Schema<$Key, $Value>>, key: BaseFabricator<any>, value: BaseFabricator<any>): Fabricator<Schema<$Key, $Value>>;
@@ -1,6 +1,6 @@
1
- import type { Produce } from "../../Random/Types";
2
- import { Schema } from "./Schema";
3
- import type { Fabricated, Key, Value, Whereby } from "./Types";
1
+ import type { Produce } from "../../Random/Types.ts";
2
+ import { Schema } from "./Schema.ts";
3
+ import type { Fabricated, InputUniqueWhereby, Key, Value, Whereby } from "./Types.ts";
4
4
  type ThisRegistry<$Key extends Key, $Value extends Value> = {
5
5
  /**
6
6
  * A record of `value` keyed by `key`, attempted `whereby.size` times —
@@ -16,4 +16,21 @@ type ThisRegistry<$Key extends Key, $Value extends Value> = {
16
16
  as: (produce: Produce<Fabricated<$Key, $Value>>) => Schema<$Key, $Value>;
17
17
  };
18
18
  export default function <const $Key extends Key, const $Value extends Value>(key: $Key, value: $Value): ThisRegistry<$Key, $Value>;
19
+ type UniqueRegistry<$Key extends Key, $Value extends Value> = {
20
+ /**
21
+ * A record of `value` keyed by `key`, with `size` drawn from a bare `N` or `{
22
+ * min?, max, distribution? }` and every key distinct, so the record holds
23
+ * exactly the size drawn. A key drawn from a finite set (`T.enum`,
24
+ * `T.always`, …) is drawn without replacement, and a `size` that could exceed
25
+ * that set is rejected here, at construction. Any other key is redrawn while
26
+ * it repeats one already in the record, up to `redraws` times in a row.
27
+ */
28
+ whereby: (whereby: InputUniqueWhereby) => Schema<$Key, $Value>;
29
+ };
30
+ /**
31
+ * `T.unique.record`, assembled into the namespace by `Primitive/unique`. No
32
+ * `as`: a producer replaces the draw, so it would discard the one thing this
33
+ * builder adds.
34
+ */
35
+ export declare function unique<const $Key extends Key, const $Value extends Value>(key: $Key, value: $Value): UniqueRegistry<$Key, $Value>;
19
36
  export {};
@@ -1,8 +1,8 @@
1
- import { type AdaptationEntry } from "../../Adapter/Core";
2
- import type { Adaptations, Adapter, Adapting, WithAdaptations } from "../../Adapter/Types";
3
- import type { Produce } from "../../Random/Types";
4
- import { type SatisfiesThis } from "../../Schema/Satisfies";
5
- import type { Core, Fabricated, Key, Value } from "./Types";
1
+ import { type AdaptationEntry } from "../../Adapter/Core.ts";
2
+ import type { Adaptations, Adapter, Adapting, WithAdaptations } from "../../Adapter/Types.ts";
3
+ import type { Produce } from "../../Random/Types.ts";
4
+ import { type SatisfiesThis } from "../../Schema/Satisfies.ts";
5
+ import type { Core, Fabricated, Key, Value, InputAdmits } from "./Types.ts";
6
6
  /**
7
7
  * The buildable recipe for a `record`: a key Schema and a value Schema, drawn
8
8
  * `whereby.size` times. `array`'s sibling — one repeated value shape and a
@@ -15,6 +15,13 @@ export interface Schema<$Key extends Key = Key, $Value extends Value = Value, $A
15
15
  * (or future validation of `produce`) still has them to check against.
16
16
  */
17
17
  as: (produce: Produce<Fabricated<$Key, $Value>>) => Schema<$Key, $Value, $Adaptations>;
18
+ /**
19
+ * State what adapters admit for this schema, widening what `whereby` draws —
20
+ * see `string/Schema.ts`'s `admits` for the full contract. A plain record
21
+ * fabricates `[minTried >= 1 ? 1 : 0, size.max]` entries, since colliding
22
+ * keys collapse; a unique record its drawn `size`.
23
+ */
24
+ admits: (admitted: InputAdmits) => Schema<$Key, $Value, $Adaptations>;
18
25
  /**
19
26
  * Check that this schema's fabricated value type is assignable to `$Target`.
20
27
  * Identity at runtime; the target is not carried into later chained calls —
@@ -1,7 +1,9 @@
1
- import type { Adaptations } from "../../Adapter/Types";
2
- import type { Produce } from "../../Random/Types";
3
- import type { AnySchema, Fabricated as FabricatedBy } from "../../Schema/Types";
4
- import { Produces, type Adaptation, type Kind, type Meta, type Produced } from "../../Types";
1
+ import type { Adaptations } from "../../Adapter/Types.ts";
2
+ import type { AdmittedEnds, InputAdmittedEnds, InputLength, Length } from "../../Bound.ts";
3
+ import type { Produce } from "../../Random/Types.ts";
4
+ import type { AnySchema, Fabricated as FabricatedBy } from "../../Schema/Types.ts";
5
+ import { Produces, type Adaptation, type Kind, type Meta, type Produced } from "../../Types.ts";
6
+ import type { Redraws } from "../../Unique/Strategy.ts";
5
7
  /**
6
8
  * A Schema usable as a record's keys: any Schema whose fabricated value is a
7
9
  * legal JS property key. Constrained through the phantom `[Produces]` marker
@@ -40,8 +42,12 @@ type IsKeyspaceOpen<$Key> = string extends $Key ? true : symbol extends $Key ? t
40
42
  *
41
43
  * A finite literal key set (`enum`/`always`/`choice`) is `Partial`: size is
42
44
  * drawn from `whereby.size`, and colliding keys collapse (`Fabricator.ts`), so
43
- * a two-member key schema may produce only one. Every key present wants
44
- * `T.object({ ... })` — what a record over a finite key set degenerates to.
45
+ * a two-member key schema may produce only one. `T.unique.record` has no
46
+ * collisions, but it still holds only as many keys as its drawn size: over
47
+ * `["a", "b", "c"]` with `size: { min: 1, max: 3 }`, a value may hold `a`
48
+ * alone. Only a size fixed at the key count guarantees every key, which the
49
+ * type does not track. Every key present wants `T.object({ ... })` — what a
50
+ * record over a finite key set degenerates to.
45
51
  */
46
52
  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>>>;
47
53
  /**
@@ -54,7 +60,8 @@ export type Fabricated<$Key extends Key = Key, $Value extends Value = Value, $Bi
54
60
  * `whereby.length.min`.
55
61
  *
56
62
  * No bare-number form (unlike `string`'s and `array`'s `length`): "exactly N"
57
- * is a promise a collapsing key set cannot keep.
63
+ * is a promise a collapsing key set cannot keep. `T.unique.record` draws its
64
+ * keys distinct instead, which is what lets its {@link UniqueWhereby} keep it.
58
65
  */
59
66
  export type Whereby = {
60
67
  size: {
@@ -62,24 +69,71 @@ export type Whereby = {
62
69
  minTried?: number | undefined;
63
70
  };
64
71
  };
72
+ /**
73
+ * `T.unique.record`'s `.whereby`: keys are drawn distinct, so `size` is a real
74
+ * `Length` — a bare `N` or `{ min?, max, distribution? }` whose `min` holds —
75
+ * plus {@link Redraws}.
76
+ */
77
+ export type InputUniqueWhereby = {
78
+ size: InputLength;
79
+ } & Redraws;
80
+ export type UniqueWhereby = {
81
+ size: Length;
82
+ redraws?: number | undefined;
83
+ };
84
+ /**
85
+ * `.admits(...)`'s input: the property count an adapter states, widening what
86
+ * the record fabricates. An end is replaced, `Infinity` states no limit, and an
87
+ * omitted end keeps what is admitted already. A plain record fabricates
88
+ * `[minTried >= 1 ? 1 : 0, size.max]` entries, since colliding keys collapse
89
+ * but the first attempt always lands; a unique record its drawn `size`.
90
+ */
91
+ export type InputAdmits = {
92
+ size?: InputAdmittedEnds<number> | undefined;
93
+ };
94
+ /**
95
+ * `[Meta].admits`, set only by `.admits(...)` and complete once set: an absent
96
+ * end states no limit (`Admits.ts`'s `toAdmits`).
97
+ */
98
+ export type Admits = {
99
+ size: AdmittedEnds<number>;
100
+ };
65
101
  /**
66
102
  * `key`/`value` stay required regardless of `produce` — both are known at
67
103
  * `T.record(...)` call time and describe the shape TypeBox derives either way.
68
104
  * `produce` is carried _alongside_ `whereby` rather than replacing it, so a
69
105
  * prior size spec survives `as` for future validation — same as `array`'s
70
106
  * `Meta`.
107
+ *
108
+ * Two discriminants, crossed. `unique` decides `whereby`'s shape, so testing it
109
+ * narrows `whereby` to {@link Whereby} or {@link UniqueWhereby} with no cast.
110
+ * `produce` decides whether anything is drawn, and is `never` on the drawn
111
+ * members so that a falsy `produce` narrows to them — an optional `Produce` on
112
+ * every member would not narrow. Only the plain builder's `.as(...)` produces
113
+ * with no `whereby`; `T.unique.record` has no such form, so a unique record
114
+ * always carries its size.
71
115
  */
72
116
  export type Meta<$Key extends Key = Key, $Value extends Value = Value> = {
73
117
  key: $Key;
74
118
  value: $Value;
119
+ admits?: Admits | undefined;
120
+ } & ({
121
+ unique?: never;
75
122
  whereby: Whereby;
76
123
  produce?: never;
77
124
  } | {
78
- key: $Key;
79
- value: $Value;
125
+ unique?: never;
80
126
  whereby?: Whereby;
81
127
  produce: Produce<Fabricated<$Key, $Value>>;
82
- };
128
+ } | {
129
+ unique: true;
130
+ whereby: UniqueWhereby;
131
+ produce?: never;
132
+ } | {
133
+ unique: true;
134
+ whereby: UniqueWhereby;
135
+ produce: Produce<Fabricated<$Key, $Value>>;
136
+ });
83
137
  export interface Core<$Key extends Key = Key, $Value extends Value = Value, $Adaptations extends Adaptations = {}> {
84
138
  [Kind]: "record";
85
139
  [Meta]: Meta<$Key, $Value>;
@@ -1,5 +1,5 @@
1
- export * from "./Types";
2
- export * from "./Schema";
3
- export * from "./Fabricator";
4
- export * from "./Registry";
5
- export { default } from "./Registry";
1
+ export * from "./Types.ts";
2
+ export * from "./Schema.ts";
3
+ export * from "./Fabricator.ts";
4
+ export * from "./Registry.ts";
5
+ export { default } from "./Registry.ts";
@@ -1,9 +1,9 @@
1
- import type { AdaptationsOf } from "../../Adapter/Types";
2
- import type { ConstructionContext, FabricatorContext, NaiveFabricator } from "../../Fabricator/Types";
3
- import type { RandomSource, Trace } from "../../Random/Types";
4
- import { Kind, Meta, type Adaptation } from "../../Types";
5
- import { Schema } from "./Schema";
6
- import type { Fabricated, Meta as ThisMeta } from "./Types";
1
+ import type { AdaptationsOf } from "../../Adapter/Types.ts";
2
+ import type { ConstructionContext, FabricatorContext, NaiveFabricator } from "../../Fabricator/Types.ts";
3
+ import type { RandomSource, Trace } from "../../Random/Types.ts";
4
+ import { Kind, Meta, type Adaptation } from "../../Types.ts";
5
+ import { Schema } from "./Schema.ts";
6
+ import type { Fabricated, Meta as ThisMeta } from "./Types.ts";
7
7
  export type Fabrication<$Fabricator extends Fabricator> = $Fabricator extends Fabricator<infer $Schema extends {
8
8
  [Meta]: ThisMeta;
9
9
  }> ? Fabricated<$Schema[typeof Meta]["body"]> : never;
@@ -1,7 +1,7 @@
1
- import type { AnySchema } from "../../Schema/Types";
2
- import { type Schema as SelfSchema } from "./self";
3
- import { Schema } from "./Schema";
4
- import type { Whereby } from "./Types";
1
+ import type { AnySchema } from "../../Schema/Types.ts";
2
+ import { type Schema as SelfSchema } from "./self/index.ts";
3
+ import { Schema } from "./Schema.ts";
4
+ import type { Whereby } from "./Types.ts";
5
5
  /**
6
6
  * `T.recursive(body)` — a builder, not a Schema, matching `array`/`record`:
7
7
  * `.whereby({ depth })` is what produces one; no bare form. `terminal` is
@@ -1,7 +1,7 @@
1
- import { type AdaptationEntry } from "../../Adapter/Core";
2
- import type { Adaptations, Adapter, Adapting, WithAdaptations } from "../../Adapter/Types";
3
- import { type SatisfiesThis } from "../../Schema/Satisfies";
4
- import type { Core, Fabricated } from "./Types";
1
+ import { type AdaptationEntry } from "../../Adapter/Core.ts";
2
+ import type { Adaptations, Adapter, Adapting, WithAdaptations } from "../../Adapter/Types.ts";
3
+ import { type SatisfiesThis } from "../../Schema/Satisfies.ts";
4
+ import type { Core, Fabricated } from "./Types.ts";
5
5
  /**
6
6
  * A recursive schema, produced by `.whereby({ depth })` — see `Registry.ts` for
7
7
  * the builder `T.recursive(body)` itself returns. `terminal` is optional there;
@@ -1,4 +1,4 @@
1
- import type { AnySchema } from "../../Schema/Types";
1
+ import type { AnySchema } from "../../Schema/Types.ts";
2
2
  /**
3
3
  * Derive the schema that `fabricateAt` swaps in at `depth.max` when the caller
4
4
  * omits `terminal`. Walks `body` and rewrites every `self` site into a
@@ -15,5 +15,12 @@ import type { AnySchema } from "../../Schema/Types";
15
15
  *
16
16
  * Nested `T.recursive` is its own fixed point and is treated as a leaf; its
17
17
  * inner `self` is not this walk's `self`.
18
+ *
19
+ * An emptied collection must not state a minimum above 0: an adapter states it
20
+ * as written, for every level of the tree, and every branch ends here empty, so
21
+ * no finite tree would validate. {@link assertEmptiable} throws
22
+ * `UnsatisfiableRecursiveBoundError` instead. A wrapper above the collection
23
+ * declines first (`T.optional(T.array(self))` becomes omitted), so only a
24
+ * collection this walk empties is checked.
18
25
  */
19
26
  export declare function terminate(body: AnySchema): AnySchema;
@@ -1,6 +1,6 @@
1
- import type { Adaptations } from "../../Adapter/Types";
2
- import type { AnySchema, Fabricated as FabricatedBy } from "../../Schema/Types";
3
- import { Produces, type Adaptation, type Kind, type Meta, type Produced } from "../../Types";
1
+ import type { Adaptations } from "../../Adapter/Types.ts";
2
+ import type { AnySchema, Fabricated as FabricatedBy } from "../../Schema/Types.ts";
3
+ import { Produces, type Adaptation, type Kind, type Meta, type Produced } from "../../Types.ts";
4
4
  /**
5
5
  * Fixed point of a recursive schema. A self-referential alias, normally
6
6
  * `TS2456` ("`RecursiveValue` circularly references itself") — legal _only_
@@ -1,6 +1,6 @@
1
- export * from "./Types";
2
- export * from "./Schema";
3
- export * from "./Fabricator";
4
- export * from "./Registry";
5
- export { default } from "./Registry";
6
- export * as self from "./self";
1
+ export * from "./Types.ts";
2
+ export * from "./Schema.ts";
3
+ export * from "./Fabricator.ts";
4
+ export * from "./Registry.ts";
5
+ export { default } from "./Registry.ts";
6
+ export * as self from "./self/index.ts";
@@ -1,8 +1,8 @@
1
- import type { FabricatorContext, NaiveFabricator } from "../../../Fabricator/Types";
2
- import type { Trace } from "../../../Random/Types";
3
- import { Kind, Meta } from "../../../Types";
4
- import type { Schema } from "./Schema";
5
- import type { Fabricated, Meta as ThisMeta } from "./Types";
1
+ import type { FabricatorContext, NaiveFabricator } from "../../../Fabricator/Types.ts";
2
+ import type { Trace } from "../../../Random/Types.ts";
3
+ import { Kind, Meta } from "../../../Types.ts";
4
+ import type { Schema } from "./Schema.ts";
5
+ import type { Fabricated, Meta as ThisMeta } from "./Types.ts";
6
6
  export type Fabrication<$Fabricator extends Fabricator> = $Fabricator extends Fabricator<infer $Bindings> ? $Bindings[0] : never;
7
7
  /**
8
8
  * Deliberately not parameterized by a Schema the way every other kind's
@@ -1,4 +1,4 @@
1
- import { Schema } from "./Schema";
1
+ import { Schema } from "./Schema.ts";
2
2
  /**
3
3
  * Mints a fresh `self` placeholder — called only from `recursive/Registry.ts`
4
4
  * to hand one to `T.recursive`'s own body callback. Not exposed as `T.self`,
@@ -1,7 +1,7 @@
1
- import { type AdaptationEntry } from "../../../Adapter/Core";
2
- import type { Adaptations, Adapter, Adapting, WithAdaptations } from "../../../Adapter/Types";
3
- import { type SatisfiesThis } from "../../../Schema/Satisfies";
4
- import type { Core, Fabricated } from "./Types";
1
+ import { type AdaptationEntry } from "../../../Adapter/Core.ts";
2
+ import type { Adaptations, Adapter, Adapting, WithAdaptations } from "../../../Adapter/Types.ts";
3
+ import { type SatisfiesThis } from "../../../Schema/Satisfies.ts";
4
+ import type { Core, Fabricated } from "./Types.ts";
5
5
  /**
6
6
  * The placeholder `T.recursive`'s body callback receives in place of the schema
7
7
  * being defined — everywhere `self` appears, it stands for "recurse one level
@@ -1,5 +1,5 @@
1
- import type { Adaptations } from "../../../Adapter/Types";
2
- import { Produces, type Adaptation, type Produced, type Kind, type Meta } from "../../../Types";
1
+ import type { Adaptations } from "../../../Adapter/Types.ts";
2
+ import { Produces, type Adaptation, type Produced, type Kind, type Meta } from "../../../Types.ts";
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]`,
@@ -1,5 +1,5 @@
1
- export * from "./Types";
2
- export * from "./Schema";
3
- export * from "./Fabricator";
4
- export * from "./Registry";
5
- export { default } from "./Registry";
1
+ export * from "./Types.ts";
2
+ export * from "./Schema.ts";
3
+ export * from "./Fabricator.ts";
4
+ export * from "./Registry.ts";
5
+ export { default } from "./Registry.ts";
@@ -0,0 +1,8 @@
1
+ import type { Admits, InputAdmits, Meta } from "./Types.ts";
2
+ /**
3
+ * Resolve `.admits(...)` against what is admitted already: `meta.admits`, or by
4
+ * default the drawn `length` — what an adapter states without one. Under
5
+ * `.as(produce)` nothing is drawn, so nothing is checked. `format` and
6
+ * `pattern` are never checked (`Types.ts`'s `Keywords`).
7
+ */
8
+ export declare function toAdmits(meta: Meta, input: InputAdmits): Admits;
@@ -0,0 +1,36 @@
1
+ import type { Whereby } from "./Types.ts";
2
+ /**
3
+ * The strings a `string` `whereby` can produce: how many, and a membership test
4
+ * for a value claimed rather than drawn (`Unique/Strategy.ts`'s `tracked`,
5
+ * whose `admits` keeps an out-of-domain override from using up capacity).
6
+ */
7
+ export type StringDomain = {
8
+ readonly capacity: bigint;
9
+ admits: (value: unknown) => boolean;
10
+ };
11
+ /**
12
+ * Count exactly what `Fabricator.ts` can produce, so a unique string exhausts
13
+ * by counting and a unique collection of strings is checked at construction.
14
+ *
15
+ * The characters are the union of every drawable source's code points — a
16
+ * character two sources share counts once. Length is in UTF-16 code units: a
17
+ * BMP character takes one, an astral character two. So with `a` one-unit and
18
+ * `b` two-unit characters, the strings of exactly `L` units number `f(L) =
19
+ * a·f(L − 1) + b·f(L − 2)`, `f(0) = 1`.
20
+ *
21
+ * The fabricator also has a filler: when one unit of budget is left and an
22
+ * astral character is drawn, it inserts one BMP scalar from outside the
23
+ * composition at any character boundary and stops. So when `b > 0`, a string of
24
+ * `L` units may also be any `L − 1`-unit string with one such character
25
+ * inserted. Its positions are the base string's character count plus one, so
26
+ * the count carries `c(L)`, the total characters across all `L`-unit strings:
27
+ * `c(L) = a·(c(L − 1) + f(L − 1)) + b·(c(L − 2) + f(L − 2))`. A filler from
28
+ * inside the composition produces a string already counted, so only the BMP
29
+ * scalars outside it add new ones.
30
+ *
31
+ * Every length in `[min, max]` is assumed reachable, which holds for every
32
+ * built-in `distribution`; a `custom` one that gives a length zero probability
33
+ * leaves the count too high, and the last strings surface as
34
+ * `UniqueRedrawsError` rather than `UniqueExhaustedError`.
35
+ */
36
+ export declare function toStringDomain(whereby: Whereby): StringDomain;
@@ -1,4 +1,4 @@
1
- import type { CodepointRange } from "./Types";
1
+ import type { CodepointRange } from "./Types.ts";
2
2
  /**
3
3
  * Unicode code point ranges for spanning the codespace — a fuzzing aid for
4
4
  * exercising input far outside ordinary text. Use a preset or build an
@@ -1,9 +1,9 @@
1
- import type { AdaptationsOf } from "../../Adapter/Types";
2
- import type { FabricatorContext, NaiveFabricator } from "../../Fabricator/Types";
3
- import type { Trace } from "../../Random/Types";
4
- import { Kind, Meta, type Adaptation } from "../../Types";
5
- import { Schema } from "./Schema";
6
- import type { Fabricated, Meta as ThisMeta } from "./Types";
1
+ import type { AdaptationsOf } from "../../Adapter/Types.ts";
2
+ import type { FabricatorContext, NaiveFabricator } from "../../Fabricator/Types.ts";
3
+ import type { Trace } from "../../Random/Types.ts";
4
+ import { Claim, Kind, Meta, type Adaptation } from "../../Types.ts";
5
+ import { Schema } from "./Schema.ts";
6
+ import type { Fabricated, Meta as ThisMeta } from "./Types.ts";
7
7
  export type Fabrication<_ extends Fabricator> = Fabricated;
8
8
  export type Fabricator<$Schema extends {
9
9
  [Meta]: ThisMeta;
@@ -14,6 +14,8 @@ export type Fabricator<$Schema extends {
14
14
  [Meta]: $Schema[typeof Meta];
15
15
  readonly trace: Trace;
16
16
  readonly [Adaptation]?: AdaptationsOf<$Schema>;
17
+ /** Present on a `T.unique.string` only — see `Types.ts`'s `Claim`. */
18
+ readonly [Claim]?: (value: unknown) => void;
17
19
  schema: Schema<$Schema[typeof Meta], AdaptationsOf<$Schema>>;
18
20
  };
19
21
  /**
@@ -1,7 +1,7 @@
1
- import type { Produce } from "../../Random/Types";
2
- import { Kind } from "../../Types";
3
- import { Schema } from "./Schema";
4
- import type { Fabricated, InputWhereby, JsonSchema, Whereby } from "./Types";
1
+ import type { Produce } from "../../Random/Types.ts";
2
+ import { Kind } from "../../Types.ts";
3
+ import { Schema } from "./Schema.ts";
4
+ import type { Fabricated, InputUniqueWhereby, InputWhereby, Whereby } from "./Types.ts";
5
5
  declare const _default: {
6
6
  /**
7
7
  * The builder carries the primitive's `[Kind]` so it can be named directly as
@@ -11,12 +11,11 @@ declare const _default: {
11
11
  [Kind]: "string";
12
12
  /**
13
13
  * Derive a custom string type: a `string` Schema whose production is
14
- * `produce`, optionally tagged with a `format` hint that schema exporters
15
- * (e.g. `toTypeBox`) read.
14
+ * `produce`. Chain `.admits({ format })` (or `pattern`) to tell adapters what
15
+ * the strings are.
16
16
  */
17
- as: (produce: Produce<Fabricated>, hints?: JsonSchema) => Schema<{
17
+ as: (produce: Produce<Fabricated>) => Schema<{
18
18
  produce: Produce<Fabricated>;
19
- hints: JsonSchema | undefined;
20
19
  }>;
21
20
  /**
22
21
  * A string of `length` UTF-16 code units. `length` is a bare `N` (exactly N)
@@ -40,3 +39,25 @@ declare const _default: {
40
39
  }>;
41
40
  };
42
41
  export default _default;
42
+ /**
43
+ * `T.unique.string`, assembled into the namespace by `Primitive/unique`. No
44
+ * `as`: a producer replaces the draw, so it would discard the one thing this
45
+ * builder adds.
46
+ */
47
+ export declare const unique: {
48
+ /** See the default export's `[Kind]`. */
49
+ [Kind]: "string";
50
+ /**
51
+ * A string the built Fabricator never repeats, drawn like `T.string.whereby`.
52
+ * Each draw is redrawn while it matches one already produced, up to `redraws`
53
+ * times in a row. The strings a length and composition can spell are counted
54
+ * exactly (`Capacity.ts`'s `toStringDomain`), so the draw after the last one
55
+ * throws `UniqueExhaustedError` rather than spending the cap. A `custom`
56
+ * length distribution can leave lengths unreachable that the count assumes
57
+ * reachable; those last strings surface as `UniqueRedrawsError`.
58
+ */
59
+ whereby: (whereby: InputUniqueWhereby) => Schema<{
60
+ whereby: Whereby;
61
+ unique: true;
62
+ }>;
63
+ };
@@ -1,8 +1,8 @@
1
- import { type AdaptationEntry } from "../../Adapter/Core";
2
- import type { Adaptations, Adapter, Adapting, WithAdaptations } from "../../Adapter/Types";
3
- import type { Produce } from "../../Random/Types";
4
- import { type SatisfiesThis } from "../../Schema/Satisfies";
5
- import type { Core, Fabricated, JsonSchema, Meta as ThisMeta } from "./Types";
1
+ import { type AdaptationEntry } from "../../Adapter/Core.ts";
2
+ import type { Adaptations, Adapter, Adapting, WithAdaptations } from "../../Adapter/Types.ts";
3
+ import type { Produce } from "../../Random/Types.ts";
4
+ import { type SatisfiesThis } from "../../Schema/Satisfies.ts";
5
+ import type { Core, Fabricated, Meta as ThisMeta, Admits, InputAdmits } from "./Types.ts";
6
6
  /**
7
7
  * Buildable `string` recipe: length/composition (`whereby` — required, unlike
8
8
  * `number`/`date`; no natural bound to fuzz a length to), or opaque production
@@ -19,7 +19,33 @@ export interface Schema<$Meta extends ThisMeta = ThisMeta, $Adaptations extends
19
19
  * `whereby` forward, not discarding it, so a later `.as(...)` (or future
20
20
  * validation of `produce`) still has it to check against.
21
21
  */
22
- as: (produce: Produce<Fabricated>, hints?: JsonSchema) => Schema<$Meta, $Adaptations>;
22
+ as: (produce: Produce<Fabricated>) => Schema<$Meta, $Adaptations>;
23
+ /**
24
+ * State what adapters admit for this schema, widening the bounds `whereby`
25
+ * draws — a `length.max` set small for test data need not cap what is
26
+ * accepted at runtime. Canonical `admits`; every other kind's method is the
27
+ * same and points here.
28
+ *
29
+ * Each end named replaces the current one, `Infinity` (`-Infinity` for a
30
+ * `min`) states no limit, and each end left out keeps what is admitted
31
+ * already — by default the drawn bounds, which is what an adapter states
32
+ * without this — so successive calls merge. Admitting may only widen: an end
33
+ * that excludes a value this schema can fabricate throws
34
+ * `AdmitsExcludesDrawError`, since that value would fail its own validation.
35
+ * Under `.as(produce)` nothing is drawn and nothing is checked.
36
+ *
37
+ * `format` and `pattern` ride along: JSON-Schema keywords for what the
38
+ * strings are, merged the same way and never checked against what is drawn.
39
+ * Like `.adapt`, the caller vouches that fabricated values match them —
40
+ * usually by fabricating through `.as(produce)`. `number` takes `multipleOf`
41
+ * the same way.
42
+ *
43
+ * This library validates nothing itself; `admits` only describes the set an
44
+ * adapter translates. `.as(...)` and `.adapt(...)` carry it forward.
45
+ */
46
+ admits: (admitted: InputAdmits) => Schema<$Meta & {
47
+ admits: Admits;
48
+ }, $Adaptations>;
23
49
  /**
24
50
  * Check that this schema's fabricated value type is assignable to `$Target`.
25
51
  * Identity at runtime; the target is not carried into later chained calls —
@@ -0,0 +1,16 @@
1
+ import type { CharacterSource, CodepointRange, Composition } from "./Types.ts";
2
+ /**
3
+ * A composition as weighted character sources — the shape `Fabricator.ts` draws
4
+ * from and `Capacity.ts` counts. No composition is every Unicode scalar value;
5
+ * a class-name record maps each name to its preset ranges.
6
+ */
7
+ export declare function toSources(composition: Composition | undefined): ReadonlyArray<readonly [number, CharacterSource]>;
8
+ /** Normalize any character source to its underlying code point ranges. */
9
+ export declare function toRanges(source: CharacterSource): ReadonlyArray<CodepointRange>;
10
+ /**
11
+ * Single-UTF-16-unit, well-formed code points (the BMP minus surrogates). Used
12
+ * to top up a length budget when a drawn unit is too wide to fit the remaining
13
+ * space (`Fabricator.ts`'s `fabricate`), which also puts them in the set of
14
+ * strings `Capacity.ts` counts.
15
+ */
16
+ export declare const bmpScalars: ReadonlyArray<CodepointRange>;