@ghostry/fabricator 0.0.1
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.
- package/LICENSE +21 -0
- package/README.md +47 -0
- package/dist/esm/Adapter/Core.js +47 -0
- package/dist/esm/Adapter/Types.js +1 -0
- package/dist/esm/Bound.js +81 -0
- package/dist/esm/Distribution/index.js +200 -0
- package/dist/esm/Enumeration/Enumerate.js +103 -0
- package/dist/esm/Enumeration/Plan.js +286 -0
- package/dist/esm/Enumeration/Types.js +1 -0
- package/dist/esm/Error/index.js +201 -0
- package/dist/esm/Fabricator/Constructor.js +328 -0
- package/dist/esm/Fabricator/Types.js +1 -0
- package/dist/esm/Instance/Core.js +119 -0
- package/dist/esm/Instance/Types.js +1 -0
- package/dist/esm/Primitive/always/Fabricator.js +13 -0
- package/dist/esm/Primitive/always/Registry.js +11 -0
- package/dist/esm/Primitive/always/Schema.js +10 -0
- package/dist/esm/Primitive/always/Types.js +1 -0
- package/dist/esm/Primitive/always/index.js +5 -0
- package/dist/esm/Primitive/array/Fabricator.js +45 -0
- package/dist/esm/Primitive/array/Registry.js +26 -0
- package/dist/esm/Primitive/array/Schema.js +17 -0
- package/dist/esm/Primitive/array/Types.js +1 -0
- package/dist/esm/Primitive/array/index.js +5 -0
- package/dist/esm/Primitive/bigint/Fabricator.js +54 -0
- package/dist/esm/Primitive/bigint/Registry.js +31 -0
- package/dist/esm/Primitive/bigint/Schema.js +17 -0
- package/dist/esm/Primitive/bigint/Types.js +1 -0
- package/dist/esm/Primitive/bigint/index.js +5 -0
- package/dist/esm/Primitive/boolean/Fabricator.js +44 -0
- package/dist/esm/Primitive/boolean/Outcomes.js +5 -0
- package/dist/esm/Primitive/boolean/Registry.js +11 -0
- package/dist/esm/Primitive/boolean/Schema.js +33 -0
- package/dist/esm/Primitive/boolean/Types.js +1 -0
- package/dist/esm/Primitive/boolean/index.js +6 -0
- package/dist/esm/Primitive/choice/Fabricator.js +37 -0
- package/dist/esm/Primitive/choice/Registry.js +38 -0
- package/dist/esm/Primitive/choice/Schema.js +17 -0
- package/dist/esm/Primitive/choice/Types.js +1 -0
- package/dist/esm/Primitive/choice/index.js +5 -0
- package/dist/esm/Primitive/date/Fabricator.js +86 -0
- package/dist/esm/Primitive/date/Registry.js +61 -0
- package/dist/esm/Primitive/date/Schema.js +17 -0
- package/dist/esm/Primitive/date/Types.js +1 -0
- package/dist/esm/Primitive/date/index.js +5 -0
- package/dist/esm/Primitive/enum/Fabricator.js +33 -0
- package/dist/esm/Primitive/enum/Registry.js +33 -0
- package/dist/esm/Primitive/enum/Schema.js +17 -0
- package/dist/esm/Primitive/enum/Types.js +1 -0
- package/dist/esm/Primitive/enum/index.js +5 -0
- package/dist/esm/Primitive/index.js +24 -0
- package/dist/esm/Primitive/namespace.js +21 -0
- package/dist/esm/Primitive/null/Fabricator.js +14 -0
- package/dist/esm/Primitive/null/Registry.js +8 -0
- package/dist/esm/Primitive/null/Schema.js +10 -0
- package/dist/esm/Primitive/null/Types.js +1 -0
- package/dist/esm/Primitive/null/index.js +5 -0
- package/dist/esm/Primitive/nullable/Fabricator.js +58 -0
- package/dist/esm/Primitive/nullable/Outcomes.js +5 -0
- package/dist/esm/Primitive/nullable/Registry.js +13 -0
- package/dist/esm/Primitive/nullable/Schema.js +36 -0
- package/dist/esm/Primitive/nullable/Types.js +1 -0
- package/dist/esm/Primitive/nullable/index.js +6 -0
- package/dist/esm/Primitive/nullish/Fabricator.js +64 -0
- package/dist/esm/Primitive/nullish/Outcomes.js +6 -0
- package/dist/esm/Primitive/nullish/Registry.js +13 -0
- package/dist/esm/Primitive/nullish/Schema.js +36 -0
- package/dist/esm/Primitive/nullish/Types.js +1 -0
- package/dist/esm/Primitive/nullish/index.js +6 -0
- package/dist/esm/Primitive/number/Fabricator.js +73 -0
- package/dist/esm/Primitive/number/Registry.js +59 -0
- package/dist/esm/Primitive/number/Schema.js +18 -0
- package/dist/esm/Primitive/number/Types.js +1 -0
- package/dist/esm/Primitive/number/defaults.js +21 -0
- package/dist/esm/Primitive/number/index.js +5 -0
- package/dist/esm/Primitive/object/Fabricator.js +77 -0
- package/dist/esm/Primitive/object/Registry.js +146 -0
- package/dist/esm/Primitive/object/Schema.js +18 -0
- package/dist/esm/Primitive/object/Types.js +1 -0
- package/dist/esm/Primitive/object/compute/Fabricator.js +24 -0
- package/dist/esm/Primitive/object/compute/Registry.js +15 -0
- package/dist/esm/Primitive/object/compute/Schema.js +13 -0
- package/dist/esm/Primitive/object/compute/Types.js +1 -0
- package/dist/esm/Primitive/object/compute/index.js +5 -0
- package/dist/esm/Primitive/object/index.js +9 -0
- package/dist/esm/Primitive/object/omittable/Fabricator.js +57 -0
- package/dist/esm/Primitive/object/omittable/Outcomes.js +5 -0
- package/dist/esm/Primitive/object/omittable/Registry.js +13 -0
- package/dist/esm/Primitive/object/omittable/Schema.js +36 -0
- package/dist/esm/Primitive/object/omittable/Types.js +1 -0
- package/dist/esm/Primitive/object/omittable/index.js +6 -0
- package/dist/esm/Primitive/object/optional/Fabricator.js +55 -0
- package/dist/esm/Primitive/object/optional/Outcomes.js +6 -0
- package/dist/esm/Primitive/object/optional/Registry.js +13 -0
- package/dist/esm/Primitive/object/optional/Schema.js +36 -0
- package/dist/esm/Primitive/object/optional/Types.js +1 -0
- package/dist/esm/Primitive/object/optional/index.js +6 -0
- package/dist/esm/Primitive/opaque/Fabricator.js +19 -0
- package/dist/esm/Primitive/opaque/Registry.js +11 -0
- package/dist/esm/Primitive/opaque/Schema.js +10 -0
- package/dist/esm/Primitive/opaque/Types.js +1 -0
- package/dist/esm/Primitive/opaque/index.js +5 -0
- package/dist/esm/Primitive/record/Fabricator.js +55 -0
- package/dist/esm/Primitive/record/Registry.js +26 -0
- package/dist/esm/Primitive/record/Schema.js +17 -0
- package/dist/esm/Primitive/record/Types.js +1 -0
- package/dist/esm/Primitive/record/index.js +5 -0
- package/dist/esm/Primitive/recursive/Fabricator.js +33 -0
- package/dist/esm/Primitive/recursive/Registry.js +20 -0
- package/dist/esm/Primitive/recursive/Schema.js +10 -0
- package/dist/esm/Primitive/recursive/Terminate.js +236 -0
- package/dist/esm/Primitive/recursive/Types.js +1 -0
- package/dist/esm/Primitive/recursive/index.js +7 -0
- package/dist/esm/Primitive/recursive/self/Fabricator.js +15 -0
- package/dist/esm/Primitive/recursive/self/Registry.js +9 -0
- package/dist/esm/Primitive/recursive/self/Schema.js +10 -0
- package/dist/esm/Primitive/recursive/self/Types.js +1 -0
- package/dist/esm/Primitive/recursive/self/index.js +5 -0
- package/dist/esm/Primitive/string/Constants.js +73 -0
- package/dist/esm/Primitive/string/Fabricator.js +109 -0
- package/dist/esm/Primitive/string/Registry.js +25 -0
- package/dist/esm/Primitive/string/Schema.js +18 -0
- package/dist/esm/Primitive/string/Types.js +1 -0
- package/dist/esm/Primitive/string/index.js +6 -0
- package/dist/esm/Primitive/symbol/Fabricator.js +33 -0
- package/dist/esm/Primitive/symbol/Registry.js +17 -0
- package/dist/esm/Primitive/symbol/Schema.js +17 -0
- package/dist/esm/Primitive/symbol/Types.js +1 -0
- package/dist/esm/Primitive/symbol/index.js +5 -0
- package/dist/esm/Primitive/tuple/Fabricator.js +33 -0
- package/dist/esm/Primitive/tuple/Registry.js +13 -0
- package/dist/esm/Primitive/tuple/Schema.js +17 -0
- package/dist/esm/Primitive/tuple/Types.js +1 -0
- package/dist/esm/Primitive/tuple/index.js +5 -0
- package/dist/esm/Primitive/undefinable/Fabricator.js +58 -0
- package/dist/esm/Primitive/undefinable/Outcomes.js +5 -0
- package/dist/esm/Primitive/undefinable/Registry.js +13 -0
- package/dist/esm/Primitive/undefinable/Schema.js +36 -0
- package/dist/esm/Primitive/undefinable/Types.js +1 -0
- package/dist/esm/Primitive/undefinable/index.js +6 -0
- package/dist/esm/Primitive/undefined/Fabricator.js +16 -0
- package/dist/esm/Primitive/undefined/Registry.js +8 -0
- package/dist/esm/Primitive/undefined/Schema.js +10 -0
- package/dist/esm/Primitive/undefined/Types.js +1 -0
- package/dist/esm/Primitive/undefined/index.js +5 -0
- package/dist/esm/Random/CallSite.js +56 -0
- package/dist/esm/Random/Generator/sfc32.js +16 -0
- package/dist/esm/Random/Types.js +1 -0
- package/dist/esm/Random/index.js +151 -0
- package/dist/esm/Schema/Core.js +68 -0
- package/dist/esm/Schema/Registry.js +17 -0
- package/dist/esm/Schema/Types.js +1 -0
- package/dist/esm/Types.js +11 -0
- package/dist/esm/Utility/Core.js +36 -0
- package/dist/esm/Utility/DeepMerge.js +18 -0
- package/dist/esm/Utility/Digest.js +28 -0
- package/dist/esm/Utility/ShallowMerge.js +13 -0
- package/dist/esm/Utility/Types.js +1 -0
- package/dist/esm/index.js +11 -0
- package/dist/esm/internal.js +5 -0
- package/dist/types/Adapter/Core.d.ts +64 -0
- package/dist/types/Adapter/Types.d.ts +145 -0
- package/dist/types/Bound.d.ts +68 -0
- package/dist/types/Distribution/index.d.ts +157 -0
- package/dist/types/Enumeration/Enumerate.d.ts +35 -0
- package/dist/types/Enumeration/Plan.d.ts +44 -0
- package/dist/types/Enumeration/Types.d.ts +86 -0
- package/dist/types/Error/index.d.ts +541 -0
- package/dist/types/Fabricator/Constructor.d.ts +43 -0
- package/dist/types/Fabricator/Types.d.ts +150 -0
- package/dist/types/Instance/Core.d.ts +98 -0
- package/dist/types/Instance/Types.d.ts +167 -0
- package/dist/types/Primitive/always/Fabricator.d.ts +19 -0
- package/dist/types/Primitive/always/Registry.d.ts +3 -0
- package/dist/types/Primitive/always/Schema.d.ts +19 -0
- package/dist/types/Primitive/always/Types.d.ts +23 -0
- package/dist/types/Primitive/always/index.d.ts +5 -0
- package/dist/types/Primitive/array/Fabricator.d.ts +22 -0
- package/dist/types/Primitive/array/Registry.d.ts +18 -0
- package/dist/types/Primitive/array/Schema.d.ts +23 -0
- package/dist/types/Primitive/array/Types.d.ts +44 -0
- package/dist/types/Primitive/array/index.d.ts +5 -0
- package/dist/types/Primitive/bigint/Fabricator.d.ts +19 -0
- package/dist/types/Primitive/bigint/Registry.d.ts +19 -0
- package/dist/types/Primitive/bigint/Schema.d.ts +27 -0
- package/dist/types/Primitive/bigint/Types.d.ts +33 -0
- package/dist/types/Primitive/bigint/index.d.ts +5 -0
- package/dist/types/Primitive/boolean/Fabricator.d.ts +19 -0
- package/dist/types/Primitive/boolean/Outcomes.d.ts +12 -0
- package/dist/types/Primitive/boolean/Registry.d.ts +14 -0
- package/dist/types/Primitive/boolean/Schema.d.ts +28 -0
- package/dist/types/Primitive/boolean/Types.d.ts +26 -0
- package/dist/types/Primitive/boolean/index.d.ts +6 -0
- package/dist/types/Primitive/choice/Fabricator.d.ts +32 -0
- package/dist/types/Primitive/choice/Registry.d.ts +38 -0
- package/dist/types/Primitive/choice/Schema.d.ts +24 -0
- package/dist/types/Primitive/choice/Types.d.ts +35 -0
- package/dist/types/Primitive/choice/index.d.ts +5 -0
- package/dist/types/Primitive/date/Fabricator.d.ts +19 -0
- package/dist/types/Primitive/date/Registry.d.ts +82 -0
- package/dist/types/Primitive/date/Schema.d.ts +28 -0
- package/dist/types/Primitive/date/Types.d.ts +34 -0
- package/dist/types/Primitive/date/index.d.ts +5 -0
- package/dist/types/Primitive/enum/Fabricator.d.ts +19 -0
- package/dist/types/Primitive/enum/Registry.d.ts +39 -0
- package/dist/types/Primitive/enum/Schema.d.ts +23 -0
- package/dist/types/Primitive/enum/Types.d.ts +44 -0
- package/dist/types/Primitive/enum/index.d.ts +5 -0
- package/dist/types/Primitive/index.d.ts +28 -0
- package/dist/types/Primitive/namespace.d.ts +38 -0
- package/dist/types/Primitive/null/Fabricator.d.ts +19 -0
- package/dist/types/Primitive/null/Registry.d.ts +3 -0
- package/dist/types/Primitive/null/Schema.d.ts +16 -0
- package/dist/types/Primitive/null/Types.d.ts +15 -0
- package/dist/types/Primitive/null/index.d.ts +5 -0
- package/dist/types/Primitive/nullable/Fabricator.d.ts +31 -0
- package/dist/types/Primitive/nullable/Outcomes.d.ts +9 -0
- package/dist/types/Primitive/nullable/Registry.d.ts +3 -0
- package/dist/types/Primitive/nullable/Schema.d.ts +36 -0
- package/dist/types/Primitive/nullable/Types.d.ts +48 -0
- package/dist/types/Primitive/nullable/index.d.ts +6 -0
- package/dist/types/Primitive/nullish/Fabricator.d.ts +36 -0
- package/dist/types/Primitive/nullish/Outcomes.d.ts +9 -0
- package/dist/types/Primitive/nullish/Registry.d.ts +3 -0
- package/dist/types/Primitive/nullish/Schema.d.ts +36 -0
- package/dist/types/Primitive/nullish/Types.d.ts +58 -0
- package/dist/types/Primitive/nullish/index.d.ts +6 -0
- package/dist/types/Primitive/number/Fabricator.d.ts +19 -0
- package/dist/types/Primitive/number/Registry.d.ts +52 -0
- package/dist/types/Primitive/number/Schema.d.ts +32 -0
- package/dist/types/Primitive/number/Types.d.ts +56 -0
- package/dist/types/Primitive/number/defaults.d.ts +18 -0
- package/dist/types/Primitive/number/index.d.ts +5 -0
- package/dist/types/Primitive/object/Fabricator.d.ts +56 -0
- package/dist/types/Primitive/object/Registry.d.ts +23 -0
- package/dist/types/Primitive/object/Schema.d.ts +41 -0
- package/dist/types/Primitive/object/Types.d.ts +85 -0
- package/dist/types/Primitive/object/compute/Fabricator.d.ts +31 -0
- package/dist/types/Primitive/object/compute/Registry.d.ts +4 -0
- package/dist/types/Primitive/object/compute/Schema.d.ts +21 -0
- package/dist/types/Primitive/object/compute/Types.d.ts +56 -0
- package/dist/types/Primitive/object/compute/index.d.ts +5 -0
- package/dist/types/Primitive/object/index.d.ts +8 -0
- package/dist/types/Primitive/object/omittable/Fabricator.d.ts +37 -0
- package/dist/types/Primitive/object/omittable/Outcomes.d.ts +9 -0
- package/dist/types/Primitive/object/omittable/Registry.d.ts +3 -0
- package/dist/types/Primitive/object/omittable/Schema.d.ts +32 -0
- package/dist/types/Primitive/object/omittable/Types.d.ts +57 -0
- package/dist/types/Primitive/object/omittable/index.d.ts +6 -0
- package/dist/types/Primitive/object/optional/Fabricator.d.ts +45 -0
- package/dist/types/Primitive/object/optional/Outcomes.d.ts +9 -0
- package/dist/types/Primitive/object/optional/Registry.d.ts +3 -0
- package/dist/types/Primitive/object/optional/Schema.d.ts +32 -0
- package/dist/types/Primitive/object/optional/Types.d.ts +72 -0
- package/dist/types/Primitive/object/optional/index.d.ts +6 -0
- package/dist/types/Primitive/opaque/Fabricator.d.ts +19 -0
- package/dist/types/Primitive/opaque/Registry.d.ts +12 -0
- package/dist/types/Primitive/opaque/Schema.d.ts +22 -0
- package/dist/types/Primitive/opaque/Types.d.ts +18 -0
- package/dist/types/Primitive/opaque/index.d.ts +5 -0
- package/dist/types/Primitive/record/Fabricator.d.ts +25 -0
- package/dist/types/Primitive/record/Registry.d.ts +17 -0
- package/dist/types/Primitive/record/Schema.d.ts +27 -0
- package/dist/types/Primitive/record/Types.d.ts +85 -0
- package/dist/types/Primitive/record/index.d.ts +5 -0
- package/dist/types/Primitive/recursive/Fabricator.d.ts +47 -0
- package/dist/types/Primitive/recursive/Registry.d.ts +22 -0
- package/dist/types/Primitive/recursive/Schema.d.ts +21 -0
- package/dist/types/Primitive/recursive/Terminate.d.ts +20 -0
- package/dist/types/Primitive/recursive/Types.d.ts +82 -0
- package/dist/types/Primitive/recursive/index.d.ts +6 -0
- package/dist/types/Primitive/recursive/self/Fabricator.d.ts +29 -0
- package/dist/types/Primitive/recursive/self/Registry.d.ts +7 -0
- package/dist/types/Primitive/recursive/self/Schema.d.ts +20 -0
- package/dist/types/Primitive/recursive/self/Types.d.ts +28 -0
- package/dist/types/Primitive/recursive/self/index.d.ts +5 -0
- package/dist/types/Primitive/string/Constants.d.ts +58 -0
- package/dist/types/Primitive/string/Fabricator.d.ts +24 -0
- package/dist/types/Primitive/string/Registry.d.ts +44 -0
- package/dist/types/Primitive/string/Schema.d.ts +65 -0
- package/dist/types/Primitive/string/Types.d.ts +77 -0
- package/dist/types/Primitive/string/index.d.ts +6 -0
- package/dist/types/Primitive/symbol/Fabricator.d.ts +24 -0
- package/dist/types/Primitive/symbol/Registry.d.ts +16 -0
- package/dist/types/Primitive/symbol/Schema.d.ts +24 -0
- package/dist/types/Primitive/symbol/Types.d.ts +19 -0
- package/dist/types/Primitive/symbol/index.d.ts +5 -0
- package/dist/types/Primitive/tuple/Fabricator.d.ts +37 -0
- package/dist/types/Primitive/tuple/Registry.d.ts +3 -0
- package/dist/types/Primitive/tuple/Schema.d.ts +24 -0
- package/dist/types/Primitive/tuple/Types.d.ts +53 -0
- package/dist/types/Primitive/tuple/index.d.ts +5 -0
- package/dist/types/Primitive/undefinable/Fabricator.d.ts +31 -0
- package/dist/types/Primitive/undefinable/Outcomes.d.ts +9 -0
- package/dist/types/Primitive/undefinable/Registry.d.ts +3 -0
- package/dist/types/Primitive/undefinable/Schema.d.ts +36 -0
- package/dist/types/Primitive/undefinable/Types.d.ts +48 -0
- package/dist/types/Primitive/undefinable/index.d.ts +6 -0
- package/dist/types/Primitive/undefined/Fabricator.d.ts +19 -0
- package/dist/types/Primitive/undefined/Registry.d.ts +3 -0
- package/dist/types/Primitive/undefined/Schema.d.ts +16 -0
- package/dist/types/Primitive/undefined/Types.d.ts +15 -0
- package/dist/types/Primitive/undefined/index.d.ts +5 -0
- package/dist/types/Random/CallSite.d.ts +59 -0
- package/dist/types/Random/Generator/sfc32.d.ts +10 -0
- package/dist/types/Random/Types.d.ts +384 -0
- package/dist/types/Random/index.d.ts +107 -0
- package/dist/types/Schema/Core.d.ts +44 -0
- package/dist/types/Schema/Registry.d.ts +20 -0
- package/dist/types/Schema/Types.d.ts +70 -0
- package/dist/types/Types.d.ts +78 -0
- package/dist/types/Utility/Core.d.ts +35 -0
- package/dist/types/Utility/DeepMerge.d.ts +14 -0
- package/dist/types/Utility/Digest.d.ts +9 -0
- package/dist/types/Utility/ShallowMerge.d.ts +6 -0
- package/dist/types/Utility/Types.d.ts +4 -0
- package/dist/types/index.d.ts +186 -0
- package/dist/types/internal.d.ts +64 -0
- package/package.json +53 -0
|
@@ -0,0 +1,541 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every error this library throws is a named subclass of
|
|
3
|
+
* {@link FabricatorError}, kept in one dependency-free module:
|
|
4
|
+
* `instanceof FabricatorError` catches everything the library raises, and no
|
|
5
|
+
* error definition can pull a primitive's module graph into an unrelated
|
|
6
|
+
* import.
|
|
7
|
+
*
|
|
8
|
+
* Kind tags are plain `string`, not the `Kind` union from
|
|
9
|
+
* `Primitive/index.ts` — that second reason, and because several of these
|
|
10
|
+
* errors exist precisely because the kind in hand was *not* a member of it.
|
|
11
|
+
*
|
|
12
|
+
* Context is `public readonly` constructor parameters, but the message still
|
|
13
|
+
* stands on its own: a consumer reading only `.message` should not need a
|
|
14
|
+
* field to understand the failure. Fields are for programmatic access, and
|
|
15
|
+
* for detail too bulky to inline.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Base error class from which more specific errors inherit.
|
|
19
|
+
*/
|
|
20
|
+
export declare abstract class FabricatorError extends Error {
|
|
21
|
+
constructor();
|
|
22
|
+
}
|
|
23
|
+
export declare namespace FabricatorError {
|
|
24
|
+
/**
|
|
25
|
+
* The phase a failure was raised from, for the errors reachable both while
|
|
26
|
+
* building a Fabricator (`Fabricator/Constructor.ts`'s `make`) and while
|
|
27
|
+
* converting to an external schema (an adapter's own `convert`).
|
|
28
|
+
*/
|
|
29
|
+
type Phase = "construction" | "adaptation";
|
|
30
|
+
/**
|
|
31
|
+
* `initialize({ limits: { combinatorial } })` when the configured limit
|
|
32
|
+
* could never be a meaningful instance count.
|
|
33
|
+
*/
|
|
34
|
+
class InvalidCombinatorialLimitError extends FabricatorError {
|
|
35
|
+
/**
|
|
36
|
+
* The rejected limit, as resolved — so an explicit `0`, a fractional
|
|
37
|
+
* number, and a value past `Number.MAX_SAFE_INTEGER` are all
|
|
38
|
+
* distinguishable after the fact.
|
|
39
|
+
*/
|
|
40
|
+
readonly limit: unknown;
|
|
41
|
+
constructor(
|
|
42
|
+
/**
|
|
43
|
+
* The rejected limit, as resolved — so an explicit `0`, a fractional
|
|
44
|
+
* number, and a value past `Number.MAX_SAFE_INTEGER` are all
|
|
45
|
+
* distinguishable after the fact.
|
|
46
|
+
*/
|
|
47
|
+
limit: unknown);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* `initialize({ attribution: { kind: "rooted", root } })` when `root` is
|
|
51
|
+
* not an absolute path or a `file://` URL. A relative root can never prefix
|
|
52
|
+
* a resolved caller file, so `relativize` would leave every file unchanged
|
|
53
|
+
* — the option would look configured while silently doing nothing. Thrown
|
|
54
|
+
* eagerly at `initialize()`, not deferred to wherever that would first
|
|
55
|
+
* become observable.
|
|
56
|
+
*/
|
|
57
|
+
class InvalidAttributionRootError extends FabricatorError {
|
|
58
|
+
/**
|
|
59
|
+
* The rejected root, as given.
|
|
60
|
+
*/
|
|
61
|
+
readonly root: string;
|
|
62
|
+
constructor(
|
|
63
|
+
/**
|
|
64
|
+
* The rejected root, as given.
|
|
65
|
+
*/
|
|
66
|
+
root: string);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* A `self` placeholder resolved with no `T.recursive` expanding around it
|
|
70
|
+
* — only reachable by holding a `self` reference outside the
|
|
71
|
+
* `T.recursive(...)` callback it was handed to.
|
|
72
|
+
*/
|
|
73
|
+
class DetachedSelfError extends FabricatorError {
|
|
74
|
+
/**
|
|
75
|
+
* Which walk hit the detached reference.
|
|
76
|
+
*/
|
|
77
|
+
readonly during: Phase;
|
|
78
|
+
constructor(
|
|
79
|
+
/**
|
|
80
|
+
* Which walk hit the detached reference.
|
|
81
|
+
*/
|
|
82
|
+
during: Phase);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* `T.recursive(body).whereby({ depth })` with no `terminal`, when `body`
|
|
86
|
+
* has a `self` that is not behind a kind that can stop recursing — a
|
|
87
|
+
* required object field, a tuple slot, the body itself, or a `choice`
|
|
88
|
+
* whose every option still contains `self`. Thrown at `.whereby()`, not
|
|
89
|
+
* at fabricate time. An explicit `terminal` is the way out.
|
|
90
|
+
*/
|
|
91
|
+
class UnterminableRecursiveError extends FabricatorError {
|
|
92
|
+
/**
|
|
93
|
+
* Structural path from the recursive body to the unterminable
|
|
94
|
+
* `self` (or to the `choice` that had no remaining non-`self`
|
|
95
|
+
* option), as field names / slot indices.
|
|
96
|
+
*/
|
|
97
|
+
readonly path: ReadonlyArray<string>;
|
|
98
|
+
constructor(
|
|
99
|
+
/**
|
|
100
|
+
* Structural path from the recursive body to the unterminable
|
|
101
|
+
* `self` (or to the `choice` that had no remaining non-`self`
|
|
102
|
+
* option), as field names / slot indices.
|
|
103
|
+
*/
|
|
104
|
+
path: ReadonlyArray<string>);
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* A walk reached a node whose `[Kind]` it has no case for — a Schema built
|
|
108
|
+
* by hand or cast past the type system, or a kind added to
|
|
109
|
+
* `Primitive/index.ts` without wiring it into every dispatch site.
|
|
110
|
+
*/
|
|
111
|
+
class UnknownKindError extends FabricatorError {
|
|
112
|
+
/**
|
|
113
|
+
* The unrecognized `[Kind]` tag, stringified — it may be any value at all,
|
|
114
|
+
* since reaching this error means the type system was already bypassed.
|
|
115
|
+
*/
|
|
116
|
+
readonly kind: string;
|
|
117
|
+
/**
|
|
118
|
+
* Which walk failed to dispatch it.
|
|
119
|
+
*/
|
|
120
|
+
readonly during: Phase;
|
|
121
|
+
constructor(
|
|
122
|
+
/**
|
|
123
|
+
* The unrecognized `[Kind]` tag, stringified — it may be any value at all,
|
|
124
|
+
* since reaching this error means the type system was already bypassed.
|
|
125
|
+
*/
|
|
126
|
+
kind: string,
|
|
127
|
+
/**
|
|
128
|
+
* Which walk failed to dispatch it.
|
|
129
|
+
*/
|
|
130
|
+
during: Phase);
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* `T.enum`/`T.choice` given no items. An empty draw table has nothing to
|
|
134
|
+
* select, which would otherwise surface as an opaque `TypeError` inside
|
|
135
|
+
* `weighted()` at fabricate time rather than here.
|
|
136
|
+
*/
|
|
137
|
+
class EmptyItemsError extends FabricatorError {
|
|
138
|
+
/**
|
|
139
|
+
* The registry entry that was called, e.g. `"T.enum.uniform"`.
|
|
140
|
+
*/
|
|
141
|
+
readonly label: string;
|
|
142
|
+
/**
|
|
143
|
+
* What the kind calls its items, e.g. `"member"`/`"option"`.
|
|
144
|
+
*/
|
|
145
|
+
readonly noun: string;
|
|
146
|
+
constructor(
|
|
147
|
+
/**
|
|
148
|
+
* The registry entry that was called, e.g. `"T.enum.uniform"`.
|
|
149
|
+
*/
|
|
150
|
+
label: string,
|
|
151
|
+
/**
|
|
152
|
+
* What the kind calls its items, e.g. `"member"`/`"option"`.
|
|
153
|
+
*/
|
|
154
|
+
noun: string);
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* An object's definition names a key that would reach `Object.prototype` —
|
|
158
|
+
* a developer-written key, where throwing is actionable (contrast
|
|
159
|
+
* `record`'s *drawn* keys, written with `Object.defineProperty` instead of
|
|
160
|
+
* rejected).
|
|
161
|
+
*/
|
|
162
|
+
class PrototypePollutionError extends FabricatorError {
|
|
163
|
+
/**
|
|
164
|
+
* The offending key.
|
|
165
|
+
*/
|
|
166
|
+
readonly key: string;
|
|
167
|
+
constructor(
|
|
168
|
+
/**
|
|
169
|
+
* The offending key.
|
|
170
|
+
*/
|
|
171
|
+
key: string);
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* A `.refine()`-computed field fabricated on its own. A computed field's
|
|
175
|
+
* value is derived from its sibling fields, so there is nothing to resolve
|
|
176
|
+
* against outside the object that owns it.
|
|
177
|
+
*/
|
|
178
|
+
class DetachedComputeError extends FabricatorError {
|
|
179
|
+
constructor();
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* A `.refine()`-computed field's resolver returned a value of the wrong
|
|
183
|
+
* shape for the source schema it was declared against.
|
|
184
|
+
*/
|
|
185
|
+
class ComputeResultMismatchError extends FabricatorError {
|
|
186
|
+
/**
|
|
187
|
+
* The `[Kind]` of the field's source schema.
|
|
188
|
+
*/
|
|
189
|
+
readonly kind: string;
|
|
190
|
+
/**
|
|
191
|
+
* What the resolver actually returned.
|
|
192
|
+
*/
|
|
193
|
+
readonly value: unknown;
|
|
194
|
+
constructor(
|
|
195
|
+
/**
|
|
196
|
+
* The `[Kind]` of the field's source schema.
|
|
197
|
+
*/
|
|
198
|
+
kind: string,
|
|
199
|
+
/**
|
|
200
|
+
* What the resolver actually returned.
|
|
201
|
+
*/
|
|
202
|
+
value: unknown);
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* An override names a field the object schema does not define — most
|
|
206
|
+
* often a typo, which is why the known fields are listed.
|
|
207
|
+
*/
|
|
208
|
+
class UnknownOverrideFieldError extends FabricatorError {
|
|
209
|
+
/**
|
|
210
|
+
* The name that was not found.
|
|
211
|
+
*/
|
|
212
|
+
readonly field: string;
|
|
213
|
+
/**
|
|
214
|
+
* Every field the schema does define, in definition order.
|
|
215
|
+
*/
|
|
216
|
+
readonly available: ReadonlyArray<string>;
|
|
217
|
+
constructor(
|
|
218
|
+
/**
|
|
219
|
+
* The name that was not found.
|
|
220
|
+
*/
|
|
221
|
+
field: string,
|
|
222
|
+
/**
|
|
223
|
+
* Every field the schema does define, in definition order.
|
|
224
|
+
*/
|
|
225
|
+
available: ReadonlyArray<string>);
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* An override value does not fit the field it is meant to replace. Raised
|
|
229
|
+
* for every field shape — a plain field, a nested object, and each presence
|
|
230
|
+
* wrapper unwrapped to its inner kind — the same failure in each case.
|
|
231
|
+
*/
|
|
232
|
+
class InvalidOverrideValueError extends FabricatorError {
|
|
233
|
+
/**
|
|
234
|
+
* The field being overridden.
|
|
235
|
+
*/
|
|
236
|
+
readonly field: string;
|
|
237
|
+
/**
|
|
238
|
+
* The `[Kind]` the value was checked against — for a wrapper field, the
|
|
239
|
+
* *inner* kind, since the wrapper's own absent/null outcomes are accepted
|
|
240
|
+
* separately.
|
|
241
|
+
*/
|
|
242
|
+
readonly kind: string;
|
|
243
|
+
/**
|
|
244
|
+
* The rejected value.
|
|
245
|
+
*/
|
|
246
|
+
readonly value: unknown;
|
|
247
|
+
constructor(
|
|
248
|
+
/**
|
|
249
|
+
* The field being overridden.
|
|
250
|
+
*/
|
|
251
|
+
field: string,
|
|
252
|
+
/**
|
|
253
|
+
* The `[Kind]` the value was checked against — for a wrapper field, the
|
|
254
|
+
* *inner* kind, since the wrapper's own absent/null outcomes are accepted
|
|
255
|
+
* separately.
|
|
256
|
+
*/
|
|
257
|
+
kind: string,
|
|
258
|
+
/**
|
|
259
|
+
* The rejected value.
|
|
260
|
+
*/
|
|
261
|
+
value: unknown);
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Thrown when `Omitted` is passed to override a field that has no
|
|
265
|
+
* absent outcome. Only `T.omittable`/`T.optional` fields can be forced
|
|
266
|
+
* off.
|
|
267
|
+
*/
|
|
268
|
+
class IllegalOmittedOverrideError extends FabricatorError {
|
|
269
|
+
/**
|
|
270
|
+
* The field being overridden.
|
|
271
|
+
*/
|
|
272
|
+
readonly field: string;
|
|
273
|
+
/**
|
|
274
|
+
* The field's `[Kind]`, which is neither `object.omittable` nor
|
|
275
|
+
* `object.optional`.
|
|
276
|
+
*/
|
|
277
|
+
readonly kind: string;
|
|
278
|
+
constructor(
|
|
279
|
+
/**
|
|
280
|
+
* The field being overridden.
|
|
281
|
+
*/
|
|
282
|
+
field: string,
|
|
283
|
+
/**
|
|
284
|
+
* The field's `[Kind]`, which is neither `object.omittable` nor
|
|
285
|
+
* `object.optional`.
|
|
286
|
+
*/
|
|
287
|
+
kind: string);
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* An enumeration axis asked for an index at or past its own width — an
|
|
291
|
+
* internal invariant of `Enumeration/Plan.ts`, not caller-reachable.
|
|
292
|
+
*/
|
|
293
|
+
class EnumerationIndexError extends FabricatorError {
|
|
294
|
+
/**
|
|
295
|
+
* The requested index.
|
|
296
|
+
*/
|
|
297
|
+
readonly index: bigint;
|
|
298
|
+
/**
|
|
299
|
+
* The axis's width, which the index must stay below.
|
|
300
|
+
*/
|
|
301
|
+
readonly width: bigint;
|
|
302
|
+
constructor(
|
|
303
|
+
/**
|
|
304
|
+
* The requested index.
|
|
305
|
+
*/
|
|
306
|
+
index: bigint,
|
|
307
|
+
/**
|
|
308
|
+
* The axis's width, which the index must stay below.
|
|
309
|
+
*/
|
|
310
|
+
width: bigint);
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* `resolve()` handed a pin for a kind `plan()` never produces one for —
|
|
314
|
+
* the two must stay in agreement; internal invariant, not caller-reachable.
|
|
315
|
+
*/
|
|
316
|
+
class UnpinnableKindError extends FabricatorError {
|
|
317
|
+
/**
|
|
318
|
+
* The kind that received a pin.
|
|
319
|
+
*/
|
|
320
|
+
readonly kind: string;
|
|
321
|
+
constructor(
|
|
322
|
+
/**
|
|
323
|
+
* The kind that received a pin.
|
|
324
|
+
*/
|
|
325
|
+
kind: string);
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* `combinatorial(...)` when the cartesian product of every enumerable axis
|
|
329
|
+
* exceeds the configured limit. Thrown eagerly, before any instance is
|
|
330
|
+
* produced.
|
|
331
|
+
*/
|
|
332
|
+
class CombinatorialLimitExceededError extends FabricatorError {
|
|
333
|
+
/**
|
|
334
|
+
* The exact instance count, counted in `bigint` so it stays precise past
|
|
335
|
+
* `Number.MAX_SAFE_INTEGER`.
|
|
336
|
+
*/
|
|
337
|
+
readonly width: bigint;
|
|
338
|
+
/**
|
|
339
|
+
* The configured limit it exceeded.
|
|
340
|
+
*/
|
|
341
|
+
readonly limit: number;
|
|
342
|
+
constructor(
|
|
343
|
+
/**
|
|
344
|
+
* The exact instance count, counted in `bigint` so it stays precise past
|
|
345
|
+
* `Number.MAX_SAFE_INTEGER`.
|
|
346
|
+
*/
|
|
347
|
+
width: bigint,
|
|
348
|
+
/**
|
|
349
|
+
* The configured limit it exceeded.
|
|
350
|
+
*/
|
|
351
|
+
limit: number);
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* A `record`'s key schema has no counterpart in the external schema library
|
|
355
|
+
* being adapted to — a symbol key, for TypeBox, whose `Type.Record`
|
|
356
|
+
* silently yields a schema nothing can satisfy rather than raising.
|
|
357
|
+
*/
|
|
358
|
+
class UnrepresentableRecordKeyError extends FabricatorError {
|
|
359
|
+
/**
|
|
360
|
+
* The `[Kind]` of the record's key schema.
|
|
361
|
+
*/
|
|
362
|
+
readonly kind: string;
|
|
363
|
+
constructor(
|
|
364
|
+
/**
|
|
365
|
+
* The `[Kind]` of the record's key schema.
|
|
366
|
+
*/
|
|
367
|
+
kind: string);
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
370
|
+
* A `{ min, max }` range contains no fabricable value — inverted bounds,
|
|
371
|
+
* a point range with an exclusive end, or a discrete exclusive pair whose
|
|
372
|
+
* effective integers are none. Thrown at `.whereby()` (or at construction
|
|
373
|
+
* for `T.date.past`/`future`, whose other end is the instance clock).
|
|
374
|
+
*/
|
|
375
|
+
class EmptyRangeError extends FabricatorError {
|
|
376
|
+
/**
|
|
377
|
+
* The registry entry that was called, e.g. `"T.number.whereby"`.
|
|
378
|
+
*/
|
|
379
|
+
readonly label: string;
|
|
380
|
+
/**
|
|
381
|
+
* Canonical lower bound as stored — `{ value, exclusive }`.
|
|
382
|
+
*/
|
|
383
|
+
readonly min: {
|
|
384
|
+
readonly value: unknown;
|
|
385
|
+
readonly exclusive: boolean;
|
|
386
|
+
};
|
|
387
|
+
/**
|
|
388
|
+
* Canonical upper bound as stored.
|
|
389
|
+
*/
|
|
390
|
+
readonly max: {
|
|
391
|
+
readonly value: unknown;
|
|
392
|
+
readonly exclusive: boolean;
|
|
393
|
+
};
|
|
394
|
+
constructor(
|
|
395
|
+
/**
|
|
396
|
+
* The registry entry that was called, e.g. `"T.number.whereby"`.
|
|
397
|
+
*/
|
|
398
|
+
label: string,
|
|
399
|
+
/**
|
|
400
|
+
* Canonical lower bound as stored — `{ value, exclusive }`.
|
|
401
|
+
*/
|
|
402
|
+
min: {
|
|
403
|
+
readonly value: unknown;
|
|
404
|
+
readonly exclusive: boolean;
|
|
405
|
+
},
|
|
406
|
+
/**
|
|
407
|
+
* Canonical upper bound as stored.
|
|
408
|
+
*/
|
|
409
|
+
max: {
|
|
410
|
+
readonly value: unknown;
|
|
411
|
+
readonly exclusive: boolean;
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
/**
|
|
415
|
+
* A distribution's bounds fall outside its own domain — a `logarithmic`
|
|
416
|
+
* distribution's density is proportional to `1/x`, so it is undefined at
|
|
417
|
+
* or below zero.
|
|
418
|
+
*/
|
|
419
|
+
class InvalidDistributionBoundError extends FabricatorError {
|
|
420
|
+
/**
|
|
421
|
+
* The distribution that rejected the bounds.
|
|
422
|
+
*/
|
|
423
|
+
readonly distribution: string;
|
|
424
|
+
/**
|
|
425
|
+
* The lower bound as given.
|
|
426
|
+
*/
|
|
427
|
+
readonly min: number;
|
|
428
|
+
/**
|
|
429
|
+
* The upper bound as given.
|
|
430
|
+
*/
|
|
431
|
+
readonly max: number;
|
|
432
|
+
constructor(
|
|
433
|
+
/**
|
|
434
|
+
* The distribution that rejected the bounds.
|
|
435
|
+
*/
|
|
436
|
+
distribution: string,
|
|
437
|
+
/**
|
|
438
|
+
* The lower bound as given.
|
|
439
|
+
*/
|
|
440
|
+
min: number,
|
|
441
|
+
/**
|
|
442
|
+
* The upper bound as given.
|
|
443
|
+
*/
|
|
444
|
+
max: number);
|
|
445
|
+
}
|
|
446
|
+
/**
|
|
447
|
+
* Which entry of a `.weighted(...)` call carried the bad weight: a position in
|
|
448
|
+
* a caller-supplied list, or one of a fixed, named outcome set.
|
|
449
|
+
*/
|
|
450
|
+
type WeightEntry = {
|
|
451
|
+
readonly kind: "index";
|
|
452
|
+
readonly index: number;
|
|
453
|
+
readonly noun: string;
|
|
454
|
+
} | {
|
|
455
|
+
readonly kind: "name";
|
|
456
|
+
readonly name: string;
|
|
457
|
+
};
|
|
458
|
+
/**
|
|
459
|
+
* A `.weighted(...)` call gives an outcome a weight that is not
|
|
460
|
+
* expressible: negative, `NaN`, or `Infinity`. Zero is valid — it
|
|
461
|
+
* disables the outcome — so this is not "anything `weighted()` would
|
|
462
|
+
* drop." An empty drawable set is {@link NoDrawableOutcomesError}.
|
|
463
|
+
*/
|
|
464
|
+
class InvalidWeightError extends FabricatorError {
|
|
465
|
+
/**
|
|
466
|
+
* The registry entry that was called, e.g. `"T.choice.weighted"`.
|
|
467
|
+
*/
|
|
468
|
+
readonly label: string;
|
|
469
|
+
/**
|
|
470
|
+
* The rejected weight.
|
|
471
|
+
*/
|
|
472
|
+
readonly weight: number;
|
|
473
|
+
/**
|
|
474
|
+
* Which entry it was attached to.
|
|
475
|
+
*/
|
|
476
|
+
readonly entry: WeightEntry;
|
|
477
|
+
constructor(
|
|
478
|
+
/**
|
|
479
|
+
* The registry entry that was called, e.g. `"T.choice.weighted"`.
|
|
480
|
+
*/
|
|
481
|
+
label: string,
|
|
482
|
+
/**
|
|
483
|
+
* The rejected weight.
|
|
484
|
+
*/
|
|
485
|
+
weight: number,
|
|
486
|
+
/**
|
|
487
|
+
* Which entry it was attached to.
|
|
488
|
+
*/
|
|
489
|
+
entry: WeightEntry);
|
|
490
|
+
}
|
|
491
|
+
/**
|
|
492
|
+
* A weighted draw table has nothing left to pick: every weight is
|
|
493
|
+
* zero (or the list was empty of drawable entries). Zeroing an
|
|
494
|
+
* outcome disables it, so at least one must keep a positive weight.
|
|
495
|
+
*/
|
|
496
|
+
class NoDrawableOutcomesError extends FabricatorError {
|
|
497
|
+
/**
|
|
498
|
+
* The registry entry or call site, e.g. `"T.enum.weighted"`.
|
|
499
|
+
*/
|
|
500
|
+
readonly label: string;
|
|
501
|
+
/**
|
|
502
|
+
* What the kind calls its entries, e.g. `"member"`/`"option"`/
|
|
503
|
+
* `"outcome"`/`"component"`/`"character class"`.
|
|
504
|
+
*/
|
|
505
|
+
readonly noun: string;
|
|
506
|
+
constructor(
|
|
507
|
+
/**
|
|
508
|
+
* The registry entry or call site, e.g. `"T.enum.weighted"`.
|
|
509
|
+
*/
|
|
510
|
+
label: string,
|
|
511
|
+
/**
|
|
512
|
+
* What the kind calls its entries, e.g. `"member"`/`"option"`/
|
|
513
|
+
* `"outcome"`/`"component"`/`"character class"`.
|
|
514
|
+
*/
|
|
515
|
+
noun: string);
|
|
516
|
+
}
|
|
517
|
+
/**
|
|
518
|
+
* `new Fabricator(schema, trace)` when `trace.kind` names a different
|
|
519
|
+
* kind than `schema`. A trace reproduces the node it was taken from,
|
|
520
|
+
* so its kind must match the schema it is replayed against.
|
|
521
|
+
*/
|
|
522
|
+
class TraceKindMismatchError extends FabricatorError {
|
|
523
|
+
/**
|
|
524
|
+
* The schema's own kind.
|
|
525
|
+
*/
|
|
526
|
+
readonly expected: string;
|
|
527
|
+
/**
|
|
528
|
+
* The kind recorded on the trace.
|
|
529
|
+
*/
|
|
530
|
+
readonly given: string;
|
|
531
|
+
constructor(
|
|
532
|
+
/**
|
|
533
|
+
* The schema's own kind.
|
|
534
|
+
*/
|
|
535
|
+
expected: string,
|
|
536
|
+
/**
|
|
537
|
+
* The kind recorded on the trace.
|
|
538
|
+
*/
|
|
539
|
+
given: string);
|
|
540
|
+
}
|
|
541
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { Stack } from "../Instance/Types";
|
|
2
|
+
import type { ConstructorOptions, RandomSource } from "../Random/Types";
|
|
3
|
+
import { type Buildable } from "../Types";
|
|
4
|
+
import { type AsFabricator } from "./Types";
|
|
5
|
+
/**
|
|
6
|
+
* The type of `construct()` itself, as handed back by `Constructor` —
|
|
7
|
+
* kept separate so `initialize`'s return type (`src/index.ts`) can name
|
|
8
|
+
* it without re-deriving it from `Constructor`'s implementation.
|
|
9
|
+
*
|
|
10
|
+
* Both a call signature and a construct signature: `construct` is a
|
|
11
|
+
* plain `function` that explicitly returns an object, so
|
|
12
|
+
* `new construct(schema)` behaves identically to `construct(schema)` —
|
|
13
|
+
* a `new` call's returned object always replaces the freshly-created
|
|
14
|
+
* `this`. The construct signature lets callers spell
|
|
15
|
+
* `new T.Fabricator(schema)` — or `new Fabricator(schema, { seed })` to
|
|
16
|
+
* pin this one build to an explicit seed, independent of the file it's
|
|
17
|
+
* constructed in (see `construct()` for what `options.seed` does).
|
|
18
|
+
*/
|
|
19
|
+
export type Constructor = {
|
|
20
|
+
new <const $Schema extends Buildable>(schema: $Schema, options?: ConstructorOptions): AsFabricator<$Schema>;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Build the untyped recursive core — mirrors `Adapter/TypeBox/index.ts`'s
|
|
24
|
+
* own internal `convert(schema: any)` — and the precisely-typed
|
|
25
|
+
* `construct()` boundary around it, both closed over a single instance's
|
|
26
|
+
* `source` so every fabricator this `construct()` produces draws from
|
|
27
|
+
* that instance's own seed/streams and never another instance's.
|
|
28
|
+
*
|
|
29
|
+
* `stack` is the instance's own lineage-wide ambient stack
|
|
30
|
+
* (`Instance/Core.ts`'s `toStack()`) — passed straight through to
|
|
31
|
+
* `resolveScope` on every `construct()` call, never read here directly,
|
|
32
|
+
* so a build reached inside an active `wrap` resolves against that
|
|
33
|
+
* frame automatically, with nothing threaded through by the caller.
|
|
34
|
+
*
|
|
35
|
+
* No separate `clock` parameter: `source` already carries its own
|
|
36
|
+
* resolved clock intrinsically (`Random/Types.ts`'s `Options.clock`,
|
|
37
|
+
* baked in when the source was built), and `resolveScope`'s chosen
|
|
38
|
+
* source — the active `wrap` frame's, or this one — is exactly the
|
|
39
|
+
* source whose clock a construction should resolve "now" against.
|
|
40
|
+
* `toConstructionContext` reads it straight off the resolved root
|
|
41
|
+
* rather than threading a second value alongside `source`.
|
|
42
|
+
*/
|
|
43
|
+
export declare function Constructor(source: RandomSource, stack: Stack): Constructor;
|