@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,28 @@
|
|
|
1
|
+
import { Kind } from "../Types";
|
|
2
|
+
import * as Primitive from "./namespace";
|
|
3
|
+
export { default as always } from "./always";
|
|
4
|
+
export { default as array } from "./array";
|
|
5
|
+
export { default as bigint } from "./bigint";
|
|
6
|
+
export { default as boolean } from "./boolean";
|
|
7
|
+
export { default as choice } from "./choice";
|
|
8
|
+
export { default as date } from "./date";
|
|
9
|
+
export { default as enum } from "./enum";
|
|
10
|
+
export { default as null } from "./null";
|
|
11
|
+
export { default as nullable } from "./nullable";
|
|
12
|
+
export { default as nullish } from "./nullish";
|
|
13
|
+
export { default as number } from "./number";
|
|
14
|
+
export { default as object } from "./object";
|
|
15
|
+
export { default as omittable } from "./object/omittable";
|
|
16
|
+
export { default as optional } from "./object/optional";
|
|
17
|
+
export { default as opaque } from "./opaque";
|
|
18
|
+
export { default as record } from "./record";
|
|
19
|
+
export { default as recursive } from "./recursive";
|
|
20
|
+
export { default as string } from "./string";
|
|
21
|
+
export { default as symbol } from "./symbol";
|
|
22
|
+
export { default as tuple } from "./tuple";
|
|
23
|
+
export { default as undefinable } from "./undefinable";
|
|
24
|
+
export { default as undefined } from "./undefined";
|
|
25
|
+
export { Primitive };
|
|
26
|
+
export type Fabricator = Primitive.always.Fabricator<any> | Primitive.array.Fabricator<any> | Primitive.bigint.Fabricator | Primitive.boolean.Fabricator | Primitive.choice.Fabricator<any> | Primitive.date.Fabricator | Primitive.enum.Fabricator<any> | Primitive.null.Fabricator | Primitive.nullable.Fabricator<any> | Primitive.nullish.Fabricator<any> | Primitive.number.Fabricator | Primitive.object.Fabricator<any> | Primitive.object.compute.Fabricator<any, any> | Primitive.object.omittable.Fabricator<any> | Primitive.object.optional.Fabricator<any> | Primitive.opaque.Fabricator<any> | Primitive.record.Fabricator<any> | Primitive.recursive.Fabricator<any> | Primitive.recursive.self.Fabricator<any> | Primitive.string.Fabricator | Primitive.symbol.Fabricator | Primitive.tuple.Fabricator<any> | Primitive.undefined.Fabricator | Primitive.undefinable.Fabricator<any>;
|
|
27
|
+
export type Schema = Primitive.always.Schema<any> | Primitive.array.Schema<any> | Primitive.bigint.Schema | Primitive.boolean.Schema | Primitive.choice.Schema<any> | Primitive.date.Schema | Primitive.enum.Schema<any> | Primitive.null.Schema | Primitive.nullable.Schema<any> | Primitive.nullish.Schema<any> | Primitive.number.Schema | Primitive.object.Schema<any> | Primitive.object.compute.Schema<any, any> | Primitive.object.omittable.Schema<any> | Primitive.object.optional.Schema<any> | Primitive.opaque.Schema<any> | Primitive.record.Schema<any, any> | Primitive.recursive.Schema<any> | Primitive.recursive.self.Schema<any> | Primitive.string.Schema | Primitive.symbol.Schema | Primitive.tuple.Schema<any> | Primitive.undefined.Schema | Primitive.undefinable.Schema<any>;
|
|
28
|
+
export type Kind = Schema[typeof Kind];
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The kind modules as a single namespace object — `Primitive.boolean`,
|
|
3
|
+
* `Primitive.object.compute`, and so on.
|
|
4
|
+
*
|
|
5
|
+
* Each kind's `Types.ts` must stay type-only. A value export in the same
|
|
6
|
+
* file as `export type Fabricated = boolean` (or `string`) makes that
|
|
7
|
+
* module a value module; `export * as boolean` here then resolves
|
|
8
|
+
* `boolean` to this namespace rather than the TypeScript primitive, which
|
|
9
|
+
* drops `[Kind]`/`[Meta]` off `Core`. Named outcome lists and string's
|
|
10
|
+
* character tables live in `Outcomes.ts`.
|
|
11
|
+
*
|
|
12
|
+
* A top-level `import * as boolean` is the same trap without needing a
|
|
13
|
+
* cycle through this file. Prefer `import { Primitive }`.
|
|
14
|
+
*
|
|
15
|
+
* Consumed as `import { Primitive }` from `./index` (or from
|
|
16
|
+
* `@ghostry/fabricator/internal`). Do not add this object to the
|
|
17
|
+
* registry: `T.Primitive` is not a builder.
|
|
18
|
+
*/
|
|
19
|
+
export * as always from "./always";
|
|
20
|
+
export * as array from "./array";
|
|
21
|
+
export * as bigint from "./bigint";
|
|
22
|
+
export * as boolean from "./boolean";
|
|
23
|
+
export * as choice from "./choice";
|
|
24
|
+
export * as date from "./date";
|
|
25
|
+
export * as enum from "./enum";
|
|
26
|
+
export * as null from "./null";
|
|
27
|
+
export * as nullable from "./nullable";
|
|
28
|
+
export * as nullish from "./nullish";
|
|
29
|
+
export * as number from "./number";
|
|
30
|
+
export * as object from "./object";
|
|
31
|
+
export * as opaque from "./opaque";
|
|
32
|
+
export * as record from "./record";
|
|
33
|
+
export * as recursive from "./recursive";
|
|
34
|
+
export * as string from "./string";
|
|
35
|
+
export * as symbol from "./symbol";
|
|
36
|
+
export * as tuple from "./tuple";
|
|
37
|
+
export * as undefinable from "./undefinable";
|
|
38
|
+
export * as undefined from "./undefined";
|
|
@@ -0,0 +1,19 @@
|
|
|
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";
|
|
7
|
+
export type Fabrication<_ extends Fabricator> = Fabricated;
|
|
8
|
+
export type Fabricator<$Schema extends {
|
|
9
|
+
[Meta]: ThisMeta;
|
|
10
|
+
} = {
|
|
11
|
+
[Meta]: ThisMeta;
|
|
12
|
+
}> = NaiveFabricator<Fabricated> & {
|
|
13
|
+
[Kind]: "null";
|
|
14
|
+
[Meta]: $Schema[typeof Meta];
|
|
15
|
+
readonly trace: Trace;
|
|
16
|
+
readonly [Adaptation]?: AdaptationsOf<$Schema>;
|
|
17
|
+
schema: Schema<AdaptationsOf<$Schema>>;
|
|
18
|
+
};
|
|
19
|
+
export declare function Fabricator(context: FabricatorContext<Schema>): Fabricator;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type AdaptationEntry } from "../../Adapter/Core";
|
|
2
|
+
import type { Adaptations, Adapter, Adapting, WithAdaptations } from "../../Adapter/Types";
|
|
3
|
+
import type { Core, Meta as ThisMeta } from "./Types";
|
|
4
|
+
/**
|
|
5
|
+
* Nothing to configure (see `Types.ts`'s `Meta`), so `adapt` is this kind's
|
|
6
|
+
* only builder method — an external library that spells "null" differently
|
|
7
|
+
* still needs a way to say so.
|
|
8
|
+
*/
|
|
9
|
+
export interface Schema<$Adaptations extends Adaptations = {}> extends Core<ThisMeta, $Adaptations> {
|
|
10
|
+
/**
|
|
11
|
+
* Override what this schema maps to in one or more external schema
|
|
12
|
+
* libraries — see `string/Schema.ts`'s `adapt` for the full contract.
|
|
13
|
+
*/
|
|
14
|
+
adapt: <const $Adapter extends Adapter, $Returnable extends ReturnType<$Adapter["convert"]>>(adapter: $Adapter, produce: (adapting: Adapting<Schema<$Adaptations>>) => $Returnable) => Schema<WithAdaptations<$Adaptations, AdaptationEntry<$Adapter, $Returnable>>>;
|
|
15
|
+
}
|
|
16
|
+
export declare function Schema<$Adaptations extends Adaptations = {}>(schema: Core<ThisMeta, $Adaptations>): Schema<$Adaptations>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Adaptations } from "../../Adapter/Types";
|
|
2
|
+
import type { Adaptation, Kind, Meta, Produces } from "../../Types";
|
|
3
|
+
export type Fabricated = null;
|
|
4
|
+
/**
|
|
5
|
+
* Nothing to configure: `null` has exactly one possible value, so there is
|
|
6
|
+
* no `.as()` (see `always/Types.ts` for the same reasoning) and no other
|
|
7
|
+
* knob to carry.
|
|
8
|
+
*/
|
|
9
|
+
export type Meta = Record<string, never>;
|
|
10
|
+
export type Core<$Meta extends Meta = Meta, $Adaptations extends Adaptations = {}> = {
|
|
11
|
+
[Kind]: "null";
|
|
12
|
+
[Meta]: $Meta;
|
|
13
|
+
readonly [Produces]?: Fabricated;
|
|
14
|
+
readonly [Adaptation]?: $Adaptations;
|
|
15
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { AdaptationsOf } from "../../Adapter/Types";
|
|
2
|
+
import type { Fabricator as BaseFabricator, FabricatorContext } 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 { Definition, Fabricated, Meta as ThisMeta } from "./Types";
|
|
7
|
+
export type Fabrication<$Fabricator extends Fabricator> = $Fabricator extends Fabricator<infer $Schema> ? Fabricated<$Schema[typeof Meta]["definition"]> : never;
|
|
8
|
+
export type Fabricator<$Schema extends {
|
|
9
|
+
[Meta]: ThisMeta;
|
|
10
|
+
} = {
|
|
11
|
+
[Meta]: ThisMeta;
|
|
12
|
+
}> = {
|
|
13
|
+
[Kind]: "nullable";
|
|
14
|
+
[Meta]: $Schema[typeof Meta];
|
|
15
|
+
readonly trace: Trace;
|
|
16
|
+
[Children]: BaseFabricator<any>;
|
|
17
|
+
readonly [Adaptation]?: AdaptationsOf<$Schema>;
|
|
18
|
+
schema: Schema<$Schema[typeof Meta]["definition"], AdaptationsOf<$Schema>>;
|
|
19
|
+
fabricate: () => Fabricated<$Schema[typeof Meta]["definition"]>;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* A presence roll on this field's private stream, drawn only when the
|
|
23
|
+
* wrapped value is needed — a `null` roll never advances `source`'s stream,
|
|
24
|
+
* and since `source` is already dispatched into its own independent stream
|
|
25
|
+
* by `Constructor.ts` regardless of this roll, skipping its draw here can
|
|
26
|
+
* never perturb any other field's reproducibility (see
|
|
27
|
+
* `object/omittable/Fabricator.ts`, and CLAUDE.md's "Randomness"). 50/50 by
|
|
28
|
+
* default; `.weighted(...)` (`Schema.ts`) reweights either outcome relative
|
|
29
|
+
* to that same default of `1`.
|
|
30
|
+
*/
|
|
31
|
+
export declare function Fabricator<$Definition extends Definition>(context: FabricatorContext<Schema<$Definition>>, source: BaseFabricator<any>): Fabricator<Schema<$Definition>>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The two outcomes a nullable field's roll can land on. Also the key space
|
|
3
|
+
* `.weighted(...)` weighs — see `Types.ts`'s `Weights`.
|
|
4
|
+
*
|
|
5
|
+
* Lives here rather than `Types.ts` so that file stays type-only (see
|
|
6
|
+
* `boolean/Outcomes.ts`).
|
|
7
|
+
*/
|
|
8
|
+
export declare const outcomes: readonly ["null", "value"];
|
|
9
|
+
export type Outcome = (typeof outcomes)[number];
|
|
@@ -0,0 +1,36 @@
|
|
|
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 { AnySchema } from "../../Schema/Types";
|
|
5
|
+
import type { Core, Definition, Fabricated, Weights } from "./Types";
|
|
6
|
+
/**
|
|
7
|
+
* The buildable recipe for a `nullable`: a single wrapped Schema, drawn (or
|
|
8
|
+
* not) each fabrication.
|
|
9
|
+
*/
|
|
10
|
+
export interface Schema<$Definition extends Definition = Definition, $Adaptations extends Adaptations = {}> extends Core<$Definition, $Adaptations> {
|
|
11
|
+
/**
|
|
12
|
+
* Layer an opaque production on this schema's existing `[Meta]` — carrying
|
|
13
|
+
* `definition` forward, not discarding it, so a later `.as(...)` (or
|
|
14
|
+
* future validation of `produce`) still has it to check against.
|
|
15
|
+
* `produce` may return `null`, so custom logic composes the same way the
|
|
16
|
+
* built-in roll does.
|
|
17
|
+
*/
|
|
18
|
+
as: (produce: Produce<Fabricated<$Definition>>) => Schema<$Definition, $Adaptations>;
|
|
19
|
+
/**
|
|
20
|
+
* Reweight the built-in 50/50 roll. Keys are optional — an omitted key
|
|
21
|
+
* keeps baseline weight `1`, the same weight the 50/50 split already uses
|
|
22
|
+
* — but that baseline is still relative to whatever else is specified, so
|
|
23
|
+
* `.weighted({ null: 0.1 })` shifts both outcomes' shares, not just
|
|
24
|
+
* `null`'s (see `Types.ts`'s `Weights`). Chaining `.weighted(...)` merges
|
|
25
|
+
* into previous weights rather than replacing them, the same layering
|
|
26
|
+
* `.as(...)` uses for `produce`.
|
|
27
|
+
*/
|
|
28
|
+
weighted: (weights: Weights) => Schema<$Definition, $Adaptations>;
|
|
29
|
+
/**
|
|
30
|
+
* Override what this schema maps to in one or more external schema
|
|
31
|
+
* libraries — see `string/Schema.ts`'s `adapt` for the full contract.
|
|
32
|
+
*/
|
|
33
|
+
adapt: <const $Adapter extends Adapter, $Returnable extends ReturnType<$Adapter["convert"]>>(adapter: $Adapter, produce: (adapting: Adapting<Schema<$Definition, $Adaptations>>) => $Returnable) => Schema<$Definition, WithAdaptations<$Adaptations, AdaptationEntry<$Adapter, $Returnable>>>;
|
|
34
|
+
}
|
|
35
|
+
export declare function Schema<$Definition extends Definition, $Adaptations extends Adaptations = {}>(schema: Core<$Definition, $Adaptations>): Schema<$Definition, $Adaptations>;
|
|
36
|
+
export declare function isNullableSchema(candidate: AnySchema): candidate is Schema;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { Adaptations } from "../../Adapter/Types";
|
|
2
|
+
import type { Produce } from "../../Random/Types";
|
|
3
|
+
import type { AnySchema, ValueOf } from "../../Schema/Types";
|
|
4
|
+
import type { Adaptation, Kind, Meta, Produces } from "../../Types";
|
|
5
|
+
/** The wrapped schema — the value type produced when the roll isn't `null`. */
|
|
6
|
+
export type Definition = AnySchema;
|
|
7
|
+
export type Fabricated<$Definition extends Definition, $Bindings extends unknown[] = []> = ValueOf<$Definition, $Bindings> | null;
|
|
8
|
+
export type { Outcome } from "./Outcomes";
|
|
9
|
+
/**
|
|
10
|
+
* Relative weights for `.weighted(...)`, keyed by `Outcome`. Keys optional —
|
|
11
|
+
* an omitted key falls back to baseline `1`, the same weight the 50/50
|
|
12
|
+
* split already uses. Values are relative, exactly like `weighted()`
|
|
13
|
+
* (`Distribution/index.ts`) — they need not sum to one, and are fed to
|
|
14
|
+
* `weighted()` unchanged alongside each unspecified key's baseline `1`.
|
|
15
|
+
*
|
|
16
|
+
* Specifying one outcome's weight shifts the *other* outcome's resulting
|
|
17
|
+
* probability too, even though its weight stays at `1` — its share of the
|
|
18
|
+
* total still moves, since the total changed. `.weighted({ null: 0.1 })` is
|
|
19
|
+
* not "10% null, 90% present" — with `value` at default `1`, the split is
|
|
20
|
+
* `0.1 / 1.1 ≈ 9.1%` null, `≈90.9%` value. No independent "absolute
|
|
21
|
+
* probability" mode; weights are only meaningful relative to the full set
|
|
22
|
+
* in play.
|
|
23
|
+
*/
|
|
24
|
+
export type Weights = {
|
|
25
|
+
null: number;
|
|
26
|
+
value?: number | undefined;
|
|
27
|
+
} | {
|
|
28
|
+
null?: number | undefined;
|
|
29
|
+
value: number;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* `definition` stays required regardless of `produce` — an opaque `as`
|
|
33
|
+
* production layers on top rather than replacing it, so a prior definition
|
|
34
|
+
* survives `as` for future validation of `produce` (and so `ToTypeBox`'s
|
|
35
|
+
* structural derivation of the wrapped shape keeps working either way).
|
|
36
|
+
*/
|
|
37
|
+
export type Meta<$Definition extends Definition = Definition> = {
|
|
38
|
+
definition: $Definition;
|
|
39
|
+
produce?: Produce<Fabricated<$Definition>>;
|
|
40
|
+
weights?: Weights;
|
|
41
|
+
};
|
|
42
|
+
export interface Core<$Definition extends Definition = Definition, $Adaptations extends Adaptations = {}> {
|
|
43
|
+
[Kind]: "nullable";
|
|
44
|
+
[Meta]: Meta<$Definition>;
|
|
45
|
+
bindings?: unknown[];
|
|
46
|
+
readonly [Produces]?: Fabricated<$Definition, NonNullable<this["bindings"]>>;
|
|
47
|
+
readonly [Adaptation]?: $Adaptations;
|
|
48
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { AdaptationsOf } from "../../Adapter/Types";
|
|
2
|
+
import type { Fabricator as BaseFabricator, FabricatorContext } 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 { Definition, Fabricated, Meta as ThisMeta } from "./Types";
|
|
7
|
+
export type Fabrication<$Fabricator extends Fabricator> = $Fabricator extends Fabricator<infer $Schema> ? Fabricated<$Schema[typeof Meta]["definition"]> : never;
|
|
8
|
+
export type Fabricator<$Schema extends {
|
|
9
|
+
[Meta]: ThisMeta;
|
|
10
|
+
} = {
|
|
11
|
+
[Meta]: ThisMeta;
|
|
12
|
+
}> = {
|
|
13
|
+
[Kind]: "nullish";
|
|
14
|
+
[Meta]: $Schema[typeof Meta];
|
|
15
|
+
readonly trace: Trace;
|
|
16
|
+
[Children]: BaseFabricator<any>;
|
|
17
|
+
readonly [Adaptation]?: AdaptationsOf<$Schema>;
|
|
18
|
+
schema: Schema<$Schema[typeof Meta]["definition"], AdaptationsOf<$Schema>>;
|
|
19
|
+
fabricate: () => Fabricated<$Schema[typeof Meta]["definition"]>;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Three-way roll: `null`, `undefined`, or the wrapped value — on this
|
|
23
|
+
* field's private stream; `source` is drawn only when "value" wins. Uniform
|
|
24
|
+
* (1/3 each) by default; not achievable by composing
|
|
25
|
+
* `nullable(T.undefinable(inner))`'s two independent 50/50 rolls (that is
|
|
26
|
+
* 50/25/25, not 33/33/33), hence the dedicated three-way `weighted()` here
|
|
27
|
+
* — see `object/optional/Fabricator.ts` and CLAUDE.md's "Why `T.optional`
|
|
28
|
+
* isn't `omittable(undefinable(inner))`". `.weighted(...)` (`Schema.ts`)
|
|
29
|
+
* reweights individual outcomes relative to that same default of `1`; an
|
|
30
|
+
* unspecified outcome keeps it. Skipping `source`'s draw on the two
|
|
31
|
+
* non-"value" outcomes is safe for the same reason as
|
|
32
|
+
* `object/omittable/Fabricator.ts`: `source` already has its own
|
|
33
|
+
* independent stream, minted at build time regardless of this roll (see
|
|
34
|
+
* CLAUDE.md's "Randomness").
|
|
35
|
+
*/
|
|
36
|
+
export declare function Fabricator<$Definition extends Definition>(context: FabricatorContext<Schema<$Definition>>, source: BaseFabricator<any>): Fabricator<Schema<$Definition>>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The three outcomes a nullish roll can land on. Also the key space
|
|
3
|
+
* `.weighted(...)` weighs — see `Types.ts`'s `Weights`.
|
|
4
|
+
*
|
|
5
|
+
* Lives here rather than `Types.ts` so that file stays type-only (see
|
|
6
|
+
* `boolean/Outcomes.ts`).
|
|
7
|
+
*/
|
|
8
|
+
export declare const outcomes: readonly ["null", "undefined", "value"];
|
|
9
|
+
export type Outcome = (typeof outcomes)[number];
|
|
@@ -0,0 +1,36 @@
|
|
|
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 { AnySchema } from "../../Schema/Types";
|
|
5
|
+
import type { Core, Definition, Fabricated, Weights } from "./Types";
|
|
6
|
+
/**
|
|
7
|
+
* The buildable recipe for a `nullish`: a single wrapped Schema, drawn (or
|
|
8
|
+
* not) each fabrication.
|
|
9
|
+
*/
|
|
10
|
+
export interface Schema<$Definition extends Definition = Definition, $Adaptations extends Adaptations = {}> extends Core<$Definition, $Adaptations> {
|
|
11
|
+
/**
|
|
12
|
+
* Layer an opaque production on this schema's existing `[Meta]` — carrying
|
|
13
|
+
* `definition` forward, not discarding it, so a later `.as(...)` (or
|
|
14
|
+
* future validation of `produce`) still has it to check against.
|
|
15
|
+
* `produce` may return `null` or `undefined`, so custom logic composes
|
|
16
|
+
* the same way the built-in three-way roll does.
|
|
17
|
+
*/
|
|
18
|
+
as: (produce: Produce<Fabricated<$Definition>>) => Schema<$Definition, $Adaptations>;
|
|
19
|
+
/**
|
|
20
|
+
* Reweight the built-in three-way roll. Keys are optional — an omitted key
|
|
21
|
+
* keeps baseline weight `1`, the same weight the uniform 1/3 split already
|
|
22
|
+
* uses — but that baseline is still relative to whatever else is specified,
|
|
23
|
+
* so `.weighted({ null: 0.1 })` shifts every outcome's share, not just
|
|
24
|
+
* `null`'s (see `Types.ts`'s `Weights`). Chaining `.weighted(...)` merges
|
|
25
|
+
* into previous weights rather than replacing them, the same layering
|
|
26
|
+
* `.as(...)` uses for `produce`.
|
|
27
|
+
*/
|
|
28
|
+
weighted: (weights: Weights) => Schema<$Definition, $Adaptations>;
|
|
29
|
+
/**
|
|
30
|
+
* Override what this schema maps to in one or more external schema
|
|
31
|
+
* libraries — see `string/Schema.ts`'s `adapt` for the full contract.
|
|
32
|
+
*/
|
|
33
|
+
adapt: <const $Adapter extends Adapter, $Returnable extends ReturnType<$Adapter["convert"]>>(adapter: $Adapter, produce: (adapting: Adapting<Schema<$Definition, $Adaptations>>) => $Returnable) => Schema<$Definition, WithAdaptations<$Adaptations, AdaptationEntry<$Adapter, $Returnable>>>;
|
|
34
|
+
}
|
|
35
|
+
export declare function Schema<$Definition extends Definition, $Adaptations extends Adaptations = {}>(schema: Core<$Definition, $Adaptations>): Schema<$Definition, $Adaptations>;
|
|
36
|
+
export declare function isNullishSchema(candidate: AnySchema): candidate is Schema;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { Adaptations } from "../../Adapter/Types";
|
|
2
|
+
import type { Produce } from "../../Random/Types";
|
|
3
|
+
import type { AnySchema, ValueOf } from "../../Schema/Types";
|
|
4
|
+
import type { Adaptation, Kind, Meta, Produces } from "../../Types";
|
|
5
|
+
/**
|
|
6
|
+
* The wrapped schema — the value type produced when the roll lands on
|
|
7
|
+
* neither `null` nor `undefined`.
|
|
8
|
+
*/
|
|
9
|
+
export type Definition = AnySchema;
|
|
10
|
+
export type Fabricated<$Definition extends Definition, $Bindings extends unknown[] = []> = ValueOf<$Definition, $Bindings> | null | undefined;
|
|
11
|
+
export type { Outcome } from "./Outcomes";
|
|
12
|
+
/**
|
|
13
|
+
* Relative weights for `.weighted(...)`, keyed by `Outcome`. Keys optional —
|
|
14
|
+
* an omitted key falls back to baseline `1`, the same weight the uniform
|
|
15
|
+
* 1/3 split already uses. Values are relative, exactly like `weighted()`
|
|
16
|
+
* (`Distribution/index.ts`) — they need not sum to one, and are fed to
|
|
17
|
+
* `weighted()` unchanged alongside each unspecified key's baseline `1`.
|
|
18
|
+
*
|
|
19
|
+
* Specifying one outcome's weight shifts *every* outcome's resulting
|
|
20
|
+
* probability, not just the named one — unspecified ones stay at weight `1`
|
|
21
|
+
* but their share of the total still moves, since the total changed.
|
|
22
|
+
* `.weighted({ null: 0.1 })` on `T.nullish` is not "10% null, other two
|
|
23
|
+
* still 33%" — with `undefined`/`value` at default `1`, the split is
|
|
24
|
+
* `0.1 / 2.1 ≈ 4.8%` null and `≈47.6%` each for the other two. No
|
|
25
|
+
* independent "absolute probability" mode; weights are only meaningful
|
|
26
|
+
* relative to the full set in play.
|
|
27
|
+
*/
|
|
28
|
+
export type Weights = {
|
|
29
|
+
null: number;
|
|
30
|
+
undefined?: number | undefined;
|
|
31
|
+
value?: number | undefined;
|
|
32
|
+
} | {
|
|
33
|
+
null?: number | undefined;
|
|
34
|
+
undefined: number;
|
|
35
|
+
value?: number | undefined;
|
|
36
|
+
} | {
|
|
37
|
+
null?: number | undefined;
|
|
38
|
+
undefined?: number | undefined;
|
|
39
|
+
value: number;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* `definition` stays required regardless of `produce` — an opaque `as`
|
|
43
|
+
* production layers on top rather than replacing it, so a prior definition
|
|
44
|
+
* survives `as` for future validation of `produce` (and so `ToTypeBox`'s
|
|
45
|
+
* structural derivation of the wrapped shape keeps working either way).
|
|
46
|
+
*/
|
|
47
|
+
export type Meta<$Definition extends Definition = Definition> = {
|
|
48
|
+
definition: $Definition;
|
|
49
|
+
produce?: Produce<Fabricated<$Definition>>;
|
|
50
|
+
weights?: Weights;
|
|
51
|
+
};
|
|
52
|
+
export interface Core<$Definition extends Definition = Definition, $Adaptations extends Adaptations = {}> {
|
|
53
|
+
[Kind]: "nullish";
|
|
54
|
+
[Meta]: Meta<$Definition>;
|
|
55
|
+
bindings?: unknown[];
|
|
56
|
+
readonly [Produces]?: Fabricated<$Definition, NonNullable<this["bindings"]>>;
|
|
57
|
+
readonly [Adaptation]?: $Adaptations;
|
|
58
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
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";
|
|
7
|
+
export type Fabrication<_ extends Fabricator> = Fabricated;
|
|
8
|
+
export type Fabricator<$Schema extends {
|
|
9
|
+
[Meta]: ThisMeta;
|
|
10
|
+
} = {
|
|
11
|
+
[Meta]: ThisMeta;
|
|
12
|
+
}> = NaiveFabricator<Fabricated> & {
|
|
13
|
+
[Kind]: "number";
|
|
14
|
+
[Meta]: $Schema[typeof Meta];
|
|
15
|
+
readonly trace: Trace;
|
|
16
|
+
readonly [Adaptation]?: AdaptationsOf<$Schema>;
|
|
17
|
+
schema: Schema<$Schema[typeof Meta], AdaptationsOf<$Schema>>;
|
|
18
|
+
};
|
|
19
|
+
export declare function Fabricator(context: FabricatorContext<Schema>): Fabricator;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { Adaptations } from "../../Adapter/Types";
|
|
2
|
+
import { Adaptation, Kind, Meta, Produces } from "../../Types";
|
|
3
|
+
import { Schema } from "./Schema";
|
|
4
|
+
import type { Fabricated, InputWhereby, Whereby } from "./Types";
|
|
5
|
+
declare const _default: {
|
|
6
|
+
[Kind]: "number";
|
|
7
|
+
[Meta]: {};
|
|
8
|
+
[Produces]?: Fabricated;
|
|
9
|
+
[Adaptation]?: Adaptations;
|
|
10
|
+
as: (produce: import("../../Random/Types").Produce<Fabricated>, hints?: import("./Types").JsonSchema) => Schema<{}, Adaptations>;
|
|
11
|
+
adapt: <const $Adapter extends import("../..").Adapter, $Returnable extends ReturnType<$Adapter["convert"]>>(adapter: $Adapter, produce: (adapting: import("../..").Adapting<Schema<{}, Adaptations>>) => $Returnable) => Schema<{}, import("../../Adapter/Types").WithAdaptations<Adaptations, import("../../Adapter/Core").AdaptationEntry<$Adapter, $Returnable>>>;
|
|
12
|
+
whereby: (whereby: InputWhereby) => Schema<{
|
|
13
|
+
whereby: Whereby;
|
|
14
|
+
}, {}>;
|
|
15
|
+
integer: {
|
|
16
|
+
[Kind]: "number";
|
|
17
|
+
[Meta]: {
|
|
18
|
+
integer: true;
|
|
19
|
+
};
|
|
20
|
+
[Produces]?: Fabricated;
|
|
21
|
+
[Adaptation]?: {};
|
|
22
|
+
as: (produce: import("../../Random/Types").Produce<Fabricated>, hints?: import("./Types").JsonSchema) => Schema<{
|
|
23
|
+
integer: true;
|
|
24
|
+
}, {}>;
|
|
25
|
+
adapt: <const $Adapter extends import("../..").Adapter, $Returnable extends ReturnType<$Adapter["convert"]>>(adapter: $Adapter, produce: (adapting: import("../..").Adapting<Schema<{
|
|
26
|
+
integer: true;
|
|
27
|
+
}, {}>>) => $Returnable) => Schema<{
|
|
28
|
+
integer: true;
|
|
29
|
+
}, import("../../Adapter/Types").WithAdaptations<{}, import("../../Adapter/Core").AdaptationEntry<$Adapter, $Returnable>>>;
|
|
30
|
+
whereby: (whereby: InputWhereby) => Schema<{
|
|
31
|
+
integer: true;
|
|
32
|
+
whereby: Whereby;
|
|
33
|
+
}, {}>;
|
|
34
|
+
/**
|
|
35
|
+
* A monotonically increasing counter starting at 1, fresh per `construct()`.
|
|
36
|
+
*/
|
|
37
|
+
sequence: Schema<{
|
|
38
|
+
sequence: true;
|
|
39
|
+
integer: true;
|
|
40
|
+
}, {}>;
|
|
41
|
+
big: {
|
|
42
|
+
[Kind]: "bigint";
|
|
43
|
+
whereby: (whereby: import("../bigint").InputWhereby) => import("../bigint").Schema<{
|
|
44
|
+
whereby: import("../bigint").Whereby;
|
|
45
|
+
}, {}>;
|
|
46
|
+
as: (produce: import("../../Random/Types").Produce<import("../bigint").Fabricated>) => import("../bigint").Schema<{
|
|
47
|
+
produce: import("../../Random/Types").Produce<bigint>;
|
|
48
|
+
}, {}>;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
export default _default;
|
|
@@ -0,0 +1,32 @@
|
|
|
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 { Core, Fabricated, JsonSchema, Meta as ThisMeta } from "./Types";
|
|
5
|
+
/**
|
|
6
|
+
* Buildable `number` recipe: a range/distribution (`whereby`, absent for
|
|
7
|
+
* the full-range bare form), `integer` for whole-number semantics, a
|
|
8
|
+
* `sequence` counter, or opaque production via `as`. `construct()` derives
|
|
9
|
+
* `fabricate` from this data — no variant carries its own closure until
|
|
10
|
+
* it's built.
|
|
11
|
+
*
|
|
12
|
+
* `$Meta` is generic (defaulting to the full `Meta` union) so builder
|
|
13
|
+
* return types stay narrow — e.g. `T.number.integer.sequence` types as
|
|
14
|
+
* `Schema<{ sequence: true; integer: true }>`, not the widened `Schema`, so
|
|
15
|
+
* a downstream conditional (`ToTypeBox`) can still tell an integer schema
|
|
16
|
+
* apart from a bare one.
|
|
17
|
+
*/
|
|
18
|
+
export interface Schema<$Meta extends ThisMeta = ThisMeta, $Adaptations extends Adaptations = {}> extends Core<$Meta, $Adaptations> {
|
|
19
|
+
/**
|
|
20
|
+
* Layer an opaque production on this schema's existing `[Meta]` — carrying
|
|
21
|
+
* `whereby`/`integer`/`sequence` forward, not discarding them, so a later
|
|
22
|
+
* `.as(...)` (or future validation of `produce`) still has them to check
|
|
23
|
+
* against.
|
|
24
|
+
*/
|
|
25
|
+
as: (produce: Produce<Fabricated>, hints?: JsonSchema) => Schema<$Meta, $Adaptations>;
|
|
26
|
+
/**
|
|
27
|
+
* Override what this schema maps to in one or more external schema
|
|
28
|
+
* libraries — see `string/Schema.ts`'s `adapt` for the full contract.
|
|
29
|
+
*/
|
|
30
|
+
adapt: <const $Adapter extends Adapter, $Returnable extends ReturnType<$Adapter["convert"]>>(adapter: $Adapter, produce: (adapting: Adapting<Schema<$Meta, $Adaptations>>) => $Returnable) => Schema<$Meta, WithAdaptations<$Adaptations, AdaptationEntry<$Adapter, $Returnable>>>;
|
|
31
|
+
}
|
|
32
|
+
export declare function Schema<$Meta extends ThisMeta, $Adaptations extends Adaptations = {}>(schema: Core<$Meta, $Adaptations>): Schema<$Meta, $Adaptations>;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { Adaptations } from "../../Adapter/Types";
|
|
2
|
+
import type { Bound, InputBound } from "../../Bound";
|
|
3
|
+
import type { Distribution } from "../../Distribution";
|
|
4
|
+
import type { Produce } from "../../Random/Types";
|
|
5
|
+
import type { Adaptation, Kind, Meta, Produces } from "../../Types";
|
|
6
|
+
/**
|
|
7
|
+
* Call-site `{ min, max }` — scalars are inclusive. Either end may be
|
|
8
|
+
* omitted; a missing end is unbounded (the same policy as a bare
|
|
9
|
+
* `T.number`), not a default of `0`.
|
|
10
|
+
*/
|
|
11
|
+
export type InputWhereby = {
|
|
12
|
+
min?: InputBound<number> | undefined;
|
|
13
|
+
max?: InputBound<number> | undefined;
|
|
14
|
+
distribution?: Distribution | undefined;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Stored `{ min, max }` — each present end is a canonical {@link Bound}.
|
|
18
|
+
* An omitted end stays omitted (fabricate fills the unbounded cap; adapters
|
|
19
|
+
* forward only the ends that were named).
|
|
20
|
+
*/
|
|
21
|
+
export type Whereby = {
|
|
22
|
+
min?: Bound<number> | undefined;
|
|
23
|
+
max?: Bound<number> | undefined;
|
|
24
|
+
distribution?: Distribution | undefined;
|
|
25
|
+
};
|
|
26
|
+
export type Fabricated = number;
|
|
27
|
+
/**
|
|
28
|
+
* JSON-Schema keywords that constrain a number value — carried as neutral,
|
|
29
|
+
* schema-library-agnostic hints (see the builder's `as`). The numeric range
|
|
30
|
+
* lives on `whereby` as {@link Bound}s, which adapters forward; `hints`
|
|
31
|
+
* holds only the orthogonal constraints not expressible there.
|
|
32
|
+
*/
|
|
33
|
+
export type JsonSchema = {
|
|
34
|
+
multipleOf?: number;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* A ranged number — `whereby` is absent on the full-range form, `integer`
|
|
38
|
+
* (a literal, not widened to `boolean`) selects whole-number semantics, or
|
|
39
|
+
* a sequence counter (`sequence`, always paired with `integer: true`, since
|
|
40
|
+
* a counter only ever yields whole numbers), optionally overridden by an
|
|
41
|
+
* opaque `as` production — carried alongside the rest rather than replacing
|
|
42
|
+
* it, so a prior scoping survives `as` for future validation.
|
|
43
|
+
*/
|
|
44
|
+
export type Meta = {
|
|
45
|
+
whereby?: Whereby;
|
|
46
|
+
integer?: boolean;
|
|
47
|
+
sequence?: boolean;
|
|
48
|
+
hints?: JsonSchema | undefined;
|
|
49
|
+
produce?: Produce<Fabricated>;
|
|
50
|
+
};
|
|
51
|
+
export type Core<$Meta extends Meta = Meta, $Adaptations extends Adaptations = {}> = {
|
|
52
|
+
[Kind]: "number";
|
|
53
|
+
[Meta]: $Meta;
|
|
54
|
+
readonly [Produces]?: Fabricated;
|
|
55
|
+
readonly [Adaptation]?: $Adaptations;
|
|
56
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Bound } from "../../Bound";
|
|
2
|
+
/**
|
|
3
|
+
* Inclusive caps a missing `whereby` end draws against. Not stored on the
|
|
4
|
+
* bare schema — `T.number` / `T.number.integer` carry no `whereby` until
|
|
5
|
+
* one is named, and an omitted end stays omitted on `[Meta]`.
|
|
6
|
+
*/
|
|
7
|
+
export declare const unboundedContinuous: {
|
|
8
|
+
min: Bound<number>;
|
|
9
|
+
max: Bound<number>;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Inclusive caps a missing integer `whereby` end draws against. Same
|
|
13
|
+
* fabricate-time fill as {@link unboundedContinuous}.
|
|
14
|
+
*/
|
|
15
|
+
export declare const unboundedDiscrete: {
|
|
16
|
+
min: Bound<number>;
|
|
17
|
+
max: Bound<number>;
|
|
18
|
+
};
|