@ghostry/fabricator 0.0.13 → 0.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/Bound.js +74 -1
- package/dist/esm/Distribution/index.js +103 -2
- package/dist/esm/Enumeration/Enumerate.js +10 -5
- package/dist/esm/Enumeration/Plan.js +2 -2
- package/dist/esm/Error/index.js +96 -27
- package/dist/esm/Fabricator/Constructor.js +7 -5
- package/dist/esm/Instance/Core.js +3 -0
- package/dist/esm/Primitive/array/Admits.js +18 -0
- package/dist/esm/Primitive/array/Fabricator.js +20 -2
- package/dist/esm/Primitive/array/Registry.js +32 -0
- package/dist/esm/Primitive/array/Schema.js +8 -0
- package/dist/esm/Primitive/bigint/Admits.js +11 -0
- package/dist/esm/Primitive/bigint/Fabricator.js +16 -23
- package/dist/esm/Primitive/bigint/Registry.js +17 -6
- package/dist/esm/Primitive/bigint/Schema.js +8 -0
- package/dist/esm/Primitive/date/Admits.js +22 -0
- package/dist/esm/Primitive/date/Defaults.js +27 -1
- package/dist/esm/Primitive/date/Fabricator.js +32 -34
- package/dist/esm/Primitive/date/Registry.js +80 -13
- package/dist/esm/Primitive/date/Schema.js +8 -0
- package/dist/esm/Primitive/enum/Fabricator.js +14 -2
- package/dist/esm/Primitive/enum/Registry.js +38 -25
- package/dist/esm/Primitive/index.js +1 -0
- package/dist/esm/Primitive/number/Admits.js +27 -0
- package/dist/esm/Primitive/number/Fabricator.js +18 -9
- package/dist/esm/Primitive/number/Registry.js +55 -4
- package/dist/esm/Primitive/number/Schema.js +10 -3
- package/dist/esm/Primitive/object/Fabricator.js +2 -0
- package/dist/esm/Primitive/record/Admits.js +42 -0
- package/dist/esm/Primitive/record/Fabricator.js +49 -19
- package/dist/esm/Primitive/record/Registry.js +29 -0
- package/dist/esm/Primitive/record/Schema.js +8 -0
- package/dist/esm/Primitive/recursive/Fabricator.js +3 -2
- package/dist/esm/Primitive/recursive/Terminate.js +16 -2
- package/dist/esm/Primitive/string/Admits.js +26 -0
- package/dist/esm/Primitive/string/Capacity.js +81 -0
- package/dist/esm/Primitive/string/Fabricator.js +23 -43
- package/dist/esm/Primitive/string/Registry.js +31 -9
- package/dist/esm/Primitive/string/Schema.js +10 -3
- package/dist/esm/Primitive/string/Sources.js +41 -0
- package/dist/esm/Primitive/unique/Registry.js +22 -0
- package/dist/esm/Primitive/unique/index.js +2 -0
- package/dist/esm/Types.js +2 -1
- package/dist/esm/Unique/Capacity.js +85 -0
- package/dist/esm/Unique/Distinct.js +187 -0
- package/dist/esm/Unique/Key.js +70 -0
- package/dist/esm/Unique/Override.js +23 -0
- package/dist/esm/Unique/Strategy.js +173 -0
- package/dist/esm/internal.js +1 -0
- package/dist/types/Adapter/Core.d.ts +2 -2
- package/dist/types/Adapter/Types.d.ts +1 -1
- package/dist/types/Bound.d.ts +67 -1
- package/dist/types/Distribution/index.d.ts +83 -1
- package/dist/types/Enumeration/Enumerate.d.ts +3 -3
- package/dist/types/Enumeration/Plan.d.ts +1 -1
- package/dist/types/Enumeration/Types.d.ts +14 -5
- package/dist/types/Error/index.d.ts +283 -0
- package/dist/types/Fabricator/Constructor.d.ts +9 -5
- package/dist/types/Fabricator/Fabricate.d.ts +5 -5
- package/dist/types/Fabricator/Types.d.ts +19 -6
- package/dist/types/Harnessing/Core.d.ts +3 -3
- package/dist/types/Harnessing/Salt.d.ts +1 -1
- package/dist/types/Harnessing/Types.d.ts +2 -2
- package/dist/types/Instance/Core.d.ts +4 -4
- package/dist/types/Instance/Stack/Async.d.ts +1 -1
- package/dist/types/Instance/Stack/Sync.d.ts +1 -1
- package/dist/types/Instance/Stack/Visible.d.ts +2 -2
- package/dist/types/Instance/Types.d.ts +19 -5
- package/dist/types/Primitive/always/Fabricator.d.ts +6 -6
- package/dist/types/Primitive/always/Registry.d.ts +2 -2
- package/dist/types/Primitive/always/Schema.d.ts +4 -4
- package/dist/types/Primitive/always/Types.d.ts +2 -2
- package/dist/types/Primitive/always/index.d.ts +5 -5
- package/dist/types/Primitive/array/Admits.d.ts +7 -0
- package/dist/types/Primitive/array/Fabricator.d.ts +7 -7
- package/dist/types/Primitive/array/Registry.d.ts +40 -3
- package/dist/types/Primitive/array/Schema.d.ts +10 -5
- package/dist/types/Primitive/array/Types.d.ts +37 -5
- package/dist/types/Primitive/array/index.d.ts +5 -5
- package/dist/types/Primitive/bigint/Admits.d.ts +7 -0
- package/dist/types/Primitive/bigint/Fabricator.d.ts +8 -6
- package/dist/types/Primitive/bigint/Registry.d.ts +24 -4
- package/dist/types/Primitive/bigint/Schema.d.ts +13 -5
- package/dist/types/Primitive/bigint/Types.d.ts +30 -6
- package/dist/types/Primitive/bigint/index.d.ts +5 -5
- package/dist/types/Primitive/boolean/Fabricator.d.ts +6 -6
- package/dist/types/Primitive/boolean/Registry.d.ts +2 -2
- package/dist/types/Primitive/boolean/Schema.d.ts +5 -5
- package/dist/types/Primitive/boolean/Types.d.ts +3 -3
- package/dist/types/Primitive/boolean/index.d.ts +6 -6
- package/dist/types/Primitive/choice/Fabricator.d.ts +6 -6
- package/dist/types/Primitive/choice/Registry.d.ts +2 -2
- package/dist/types/Primitive/choice/Schema.d.ts +5 -5
- package/dist/types/Primitive/choice/Types.d.ts +4 -4
- package/dist/types/Primitive/choice/index.d.ts +5 -5
- package/dist/types/Primitive/date/Admits.d.ts +7 -0
- package/dist/types/Primitive/date/Defaults.d.ts +22 -1
- package/dist/types/Primitive/date/Fabricator.d.ts +8 -6
- package/dist/types/Primitive/date/Registry.d.ts +49 -13
- package/dist/types/Primitive/date/Schema.d.ts +14 -5
- package/dist/types/Primitive/date/Types.d.ts +57 -8
- package/dist/types/Primitive/date/index.d.ts +5 -5
- package/dist/types/Primitive/derive/Fabricator.d.ts +7 -7
- package/dist/types/Primitive/derive/Registry.d.ts +2 -2
- package/dist/types/Primitive/derive/Schema.d.ts +6 -6
- package/dist/types/Primitive/derive/Types.d.ts +6 -6
- package/dist/types/Primitive/derive/index.d.ts +5 -5
- package/dist/types/Primitive/enum/Fabricator.d.ts +8 -6
- package/dist/types/Primitive/enum/Registry.d.ts +22 -2
- package/dist/types/Primitive/enum/Schema.d.ts +5 -5
- package/dist/types/Primitive/enum/Types.d.ts +8 -3
- package/dist/types/Primitive/enum/index.d.ts +5 -5
- package/dist/types/Primitive/index.d.ts +28 -27
- package/dist/types/Primitive/namespace.d.ts +21 -21
- package/dist/types/Primitive/null/Fabricator.d.ts +6 -6
- package/dist/types/Primitive/null/Registry.d.ts +1 -1
- package/dist/types/Primitive/null/Schema.d.ts +4 -4
- package/dist/types/Primitive/null/Types.d.ts +2 -2
- package/dist/types/Primitive/null/index.d.ts +5 -5
- package/dist/types/Primitive/nullable/Fabricator.d.ts +6 -6
- package/dist/types/Primitive/nullable/Registry.d.ts +2 -2
- package/dist/types/Primitive/nullable/Schema.d.ts +6 -6
- package/dist/types/Primitive/nullable/Types.d.ts +5 -5
- package/dist/types/Primitive/nullable/index.d.ts +6 -6
- package/dist/types/Primitive/nullish/Fabricator.d.ts +6 -6
- package/dist/types/Primitive/nullish/Registry.d.ts +2 -2
- package/dist/types/Primitive/nullish/Schema.d.ts +6 -6
- package/dist/types/Primitive/nullish/Types.d.ts +5 -5
- package/dist/types/Primitive/nullish/index.d.ts +6 -6
- package/dist/types/Primitive/number/Admits.d.ts +9 -0
- package/dist/types/Primitive/number/Defaults.d.ts +1 -1
- package/dist/types/Primitive/number/Fabricator.d.ts +8 -6
- package/dist/types/Primitive/number/Registry.d.ts +45 -4
- package/dist/types/Primitive/number/Schema.d.ts +14 -6
- package/dist/types/Primitive/number/Types.d.ts +36 -14
- package/dist/types/Primitive/number/index.d.ts +5 -5
- package/dist/types/Primitive/object/Fabricator.d.ts +6 -6
- package/dist/types/Primitive/object/Registry.d.ts +4 -4
- package/dist/types/Primitive/object/Schema.d.ts +8 -8
- package/dist/types/Primitive/object/Types.d.ts +6 -6
- package/dist/types/Primitive/object/compute/Fabricator.d.ts +7 -7
- package/dist/types/Primitive/object/compute/Registry.d.ts +2 -2
- package/dist/types/Primitive/object/compute/Schema.d.ts +7 -7
- package/dist/types/Primitive/object/compute/Types.d.ts +3 -3
- package/dist/types/Primitive/object/compute/index.d.ts +5 -5
- package/dist/types/Primitive/object/index.d.ts +8 -8
- package/dist/types/Primitive/object/omit/Registry.d.ts +2 -2
- package/dist/types/Primitive/object/omit/index.d.ts +2 -2
- package/dist/types/Primitive/object/omittable/Fabricator.d.ts +6 -6
- package/dist/types/Primitive/object/omittable/Registry.d.ts +2 -2
- package/dist/types/Primitive/object/omittable/Schema.d.ts +6 -6
- package/dist/types/Primitive/object/omittable/Types.d.ts +5 -5
- package/dist/types/Primitive/object/omittable/index.d.ts +6 -6
- package/dist/types/Primitive/object/optional/Fabricator.d.ts +6 -6
- package/dist/types/Primitive/object/optional/Registry.d.ts +2 -2
- package/dist/types/Primitive/object/optional/Schema.d.ts +6 -6
- package/dist/types/Primitive/object/optional/Types.d.ts +5 -5
- package/dist/types/Primitive/object/optional/index.d.ts +6 -6
- package/dist/types/Primitive/object/pick/Registry.d.ts +2 -2
- package/dist/types/Primitive/object/pick/index.d.ts +2 -2
- package/dist/types/Primitive/opaque/Fabricator.d.ts +6 -6
- package/dist/types/Primitive/opaque/Registry.d.ts +2 -2
- package/dist/types/Primitive/opaque/Schema.d.ts +4 -4
- package/dist/types/Primitive/opaque/Types.d.ts +3 -3
- package/dist/types/Primitive/opaque/index.d.ts +5 -5
- package/dist/types/Primitive/record/Admits.d.ts +18 -0
- package/dist/types/Primitive/record/Fabricator.d.ts +7 -7
- package/dist/types/Primitive/record/Registry.d.ts +20 -3
- package/dist/types/Primitive/record/Schema.d.ts +12 -5
- package/dist/types/Primitive/record/Types.d.ts +64 -10
- package/dist/types/Primitive/record/index.d.ts +5 -5
- package/dist/types/Primitive/recursive/Fabricator.d.ts +6 -6
- package/dist/types/Primitive/recursive/Registry.d.ts +4 -4
- package/dist/types/Primitive/recursive/Schema.d.ts +4 -4
- package/dist/types/Primitive/recursive/Terminate.d.ts +8 -1
- package/dist/types/Primitive/recursive/Types.d.ts +3 -3
- package/dist/types/Primitive/recursive/index.d.ts +6 -6
- package/dist/types/Primitive/recursive/self/Fabricator.d.ts +5 -5
- package/dist/types/Primitive/recursive/self/Registry.d.ts +1 -1
- package/dist/types/Primitive/recursive/self/Schema.d.ts +4 -4
- package/dist/types/Primitive/recursive/self/Types.d.ts +2 -2
- package/dist/types/Primitive/recursive/self/index.d.ts +5 -5
- package/dist/types/Primitive/string/Admits.d.ts +8 -0
- package/dist/types/Primitive/string/Capacity.d.ts +36 -0
- package/dist/types/Primitive/string/Constants.d.ts +1 -1
- package/dist/types/Primitive/string/Fabricator.d.ts +8 -6
- package/dist/types/Primitive/string/Registry.d.ts +29 -8
- package/dist/types/Primitive/string/Schema.d.ts +32 -6
- package/dist/types/Primitive/string/Sources.d.ts +16 -0
- package/dist/types/Primitive/string/Types.d.ts +39 -19
- package/dist/types/Primitive/string/index.d.ts +6 -6
- package/dist/types/Primitive/symbol/Fabricator.d.ts +6 -6
- package/dist/types/Primitive/symbol/Registry.d.ts +2 -2
- package/dist/types/Primitive/symbol/Schema.d.ts +5 -5
- package/dist/types/Primitive/symbol/Types.d.ts +3 -3
- package/dist/types/Primitive/symbol/index.d.ts +5 -5
- package/dist/types/Primitive/tuple/Fabricator.d.ts +6 -6
- package/dist/types/Primitive/tuple/Registry.d.ts +2 -2
- package/dist/types/Primitive/tuple/Schema.d.ts +5 -5
- package/dist/types/Primitive/tuple/Types.d.ts +4 -4
- package/dist/types/Primitive/tuple/index.d.ts +5 -5
- package/dist/types/Primitive/undefinable/Fabricator.d.ts +6 -6
- package/dist/types/Primitive/undefinable/Registry.d.ts +2 -2
- package/dist/types/Primitive/undefinable/Schema.d.ts +6 -6
- package/dist/types/Primitive/undefinable/Types.d.ts +5 -5
- package/dist/types/Primitive/undefinable/index.d.ts +6 -6
- package/dist/types/Primitive/undefined/Fabricator.d.ts +6 -6
- package/dist/types/Primitive/undefined/Registry.d.ts +1 -1
- package/dist/types/Primitive/undefined/Schema.d.ts +4 -4
- package/dist/types/Primitive/undefined/Types.d.ts +2 -2
- package/dist/types/Primitive/undefined/index.d.ts +5 -5
- package/dist/types/Primitive/unique/Registry.d.ts +39 -0
- package/dist/types/Primitive/unique/index.d.ts +2 -0
- package/dist/types/Random/Generator/sfc32.d.ts +1 -1
- package/dist/types/Random/Types.d.ts +1 -1
- package/dist/types/Random/index.d.ts +1 -1
- package/dist/types/Schema/Core.d.ts +5 -5
- package/dist/types/Schema/Registry.d.ts +3 -3
- package/dist/types/Schema/Satisfies.d.ts +3 -3
- package/dist/types/Schema/Types.d.ts +5 -5
- package/dist/types/Types.d.ts +11 -2
- package/dist/types/Unique/Capacity.d.ts +29 -0
- package/dist/types/Unique/Distinct.d.ts +95 -0
- package/dist/types/Unique/Key.d.ts +29 -0
- package/dist/types/Unique/Override.d.ts +16 -0
- package/dist/types/Unique/Strategy.d.ts +135 -0
- package/dist/types/Utility/Core.d.ts +2 -2
- package/dist/types/Utility/DeepMerge.d.ts +2 -2
- package/dist/types/Utility/ShallowMerge.d.ts +2 -2
- package/dist/types/adapting.d.ts +3 -3
- package/dist/types/harnessing.d.ts +2 -2
- package/dist/types/index.d.ts +40 -27
- package/dist/types/internal.d.ts +16 -15
- package/package.json +2 -2
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { type AdaptationEntry } from "../../Adapter/Core";
|
|
2
|
-
import type { Adaptations, Adapter, Adapting, WithAdaptations } from "../../Adapter/Types";
|
|
3
|
-
import type { Produce } from "../../Random/Types";
|
|
4
|
-
import { type SatisfiesThis } from "../../Schema/Satisfies";
|
|
5
|
-
import type { Core, Definition, Fabricated } from "./Types";
|
|
1
|
+
import { type AdaptationEntry } from "../../Adapter/Core.ts";
|
|
2
|
+
import type { Adaptations, Adapter, Adapting, WithAdaptations } from "../../Adapter/Types.ts";
|
|
3
|
+
import type { Produce } from "../../Random/Types.ts";
|
|
4
|
+
import { type SatisfiesThis } from "../../Schema/Satisfies.ts";
|
|
5
|
+
import type { Core, Definition, Fabricated, InputAdmits } from "./Types.ts";
|
|
6
6
|
/**
|
|
7
7
|
* The buildable recipe for an `array`: a single element Schema, repeated
|
|
8
8
|
* `whereby.length` times.
|
|
@@ -14,6 +14,11 @@ export interface Schema<$Definition extends Definition = Definition, $Adaptation
|
|
|
14
14
|
* (or future validation of `produce`) still has them to check against.
|
|
15
15
|
*/
|
|
16
16
|
as: (produce: Produce<Fabricated<$Definition>>) => Schema<$Definition, $Adaptations>;
|
|
17
|
+
/**
|
|
18
|
+
* State what adapters admit for this schema, widening what `whereby` draws —
|
|
19
|
+
* see `string/Schema.ts`'s `admits` for the full contract.
|
|
20
|
+
*/
|
|
21
|
+
admits: (admitted: InputAdmits) => Schema<$Definition, $Adaptations>;
|
|
17
22
|
/**
|
|
18
23
|
* Check that this schema's fabricated value type is assignable to `$Target`.
|
|
19
24
|
* Identity at runtime; the target is not carried into later chained calls —
|
|
@@ -1,15 +1,43 @@
|
|
|
1
|
-
import type { Adaptations } from "../../Adapter/Types";
|
|
2
|
-
import type { InputLength, Length } from "../../Bound";
|
|
3
|
-
import type { Produce } from "../../Random/Types";
|
|
4
|
-
import type { AnySchema, Fabricated as FabricatedBy } from "../../Schema/Types";
|
|
5
|
-
import type { Adaptation, Kind, Meta, Produced, Produces } from "../../Types";
|
|
1
|
+
import type { Adaptations } from "../../Adapter/Types.ts";
|
|
2
|
+
import type { AdmittedEnds, InputAdmittedEnds, InputLength, Length } from "../../Bound.ts";
|
|
3
|
+
import type { Produce } from "../../Random/Types.ts";
|
|
4
|
+
import type { AnySchema, Fabricated as FabricatedBy } from "../../Schema/Types.ts";
|
|
5
|
+
import type { Adaptation, Kind, Meta, Produced, Produces } from "../../Types.ts";
|
|
6
|
+
import type { Redraws } from "../../Unique/Strategy.ts";
|
|
6
7
|
export type Definition = AnySchema;
|
|
7
8
|
export type Fabricated<$Definition extends Definition, $Bindings extends unknown[] = []> = Array<FabricatedBy<$Definition, $Bindings>>;
|
|
8
9
|
export type InputWhereby = {
|
|
9
10
|
length: InputLength;
|
|
10
11
|
};
|
|
12
|
+
/** `T.unique.array`'s `.whereby`: the same `length`, plus {@link Redraws}. */
|
|
13
|
+
export type InputUniqueWhereby = InputWhereby & Redraws;
|
|
11
14
|
export type Whereby = {
|
|
12
15
|
length: Length;
|
|
16
|
+
redraws?: number | undefined;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* `.admits(...)`'s input: the length an adapter states, widening what `whereby`
|
|
20
|
+
* draws. An end is replaced, `Infinity` (or `-Infinity` for `min`) states no
|
|
21
|
+
* limit, and an omitted end keeps what is admitted already.
|
|
22
|
+
*/
|
|
23
|
+
export type InputAdmits = {
|
|
24
|
+
length?: InputAdmittedEnds<number> | undefined;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* `[Meta].admits`, set only by `.admits(...)` and complete once set: an absent
|
|
28
|
+
* end states no limit (`Admits.ts`'s `toAdmits`).
|
|
29
|
+
*/
|
|
30
|
+
export type Admits = {
|
|
31
|
+
length: AdmittedEnds<number>;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* `T.unique.array`'s marker on `[Meta]`: members are distinct within each
|
|
35
|
+
* fabricated array. `by` projects a member to what must be distinct, and is
|
|
36
|
+
* typed to the element at the builder (`Registry.ts`'s `unique`); stored here
|
|
37
|
+
* as `any` so `Meta` stays covariant in `$Definition`.
|
|
38
|
+
*/
|
|
39
|
+
export type Unique = {
|
|
40
|
+
by?: ((element: any) => unknown) | undefined;
|
|
13
41
|
};
|
|
14
42
|
/**
|
|
15
43
|
* `whereby` (a length spec — no natural bound to fuzz to, so unlike
|
|
@@ -23,10 +51,14 @@ export type Whereby = {
|
|
|
23
51
|
export type Meta<$Definition extends Definition = Definition> = {
|
|
24
52
|
definition: $Definition;
|
|
25
53
|
whereby: Whereby;
|
|
54
|
+
unique?: Unique;
|
|
55
|
+
admits?: Admits | undefined;
|
|
26
56
|
produce?: never;
|
|
27
57
|
} | {
|
|
28
58
|
definition: $Definition;
|
|
29
59
|
whereby?: Whereby;
|
|
60
|
+
unique?: Unique;
|
|
61
|
+
admits?: Admits | undefined;
|
|
30
62
|
produce: Produce<Fabricated<$Definition>>;
|
|
31
63
|
};
|
|
32
64
|
export interface Core<$Definition extends Definition = Definition, $Adaptations extends Adaptations = {}> {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from "./Types";
|
|
2
|
-
export * from "./Schema";
|
|
3
|
-
export * from "./Fabricator";
|
|
4
|
-
export * from "./Registry";
|
|
5
|
-
export { default } from "./Registry";
|
|
1
|
+
export * from "./Types.ts";
|
|
2
|
+
export * from "./Schema.ts";
|
|
3
|
+
export * from "./Fabricator.ts";
|
|
4
|
+
export * from "./Registry.ts";
|
|
5
|
+
export { default } from "./Registry.ts";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Admits, InputAdmits, Meta } from "./Types.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Resolve `.admits(...)` against what is admitted already: `meta.admits`, or by
|
|
4
|
+
* default the drawn range — what an adapter states without one. Under
|
|
5
|
+
* `.as(produce)` nothing is drawn, so nothing is checked.
|
|
6
|
+
*/
|
|
7
|
+
export declare function toAdmits(meta: Meta, input: InputAdmits): Admits;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { AdaptationsOf } from "../../Adapter/Types";
|
|
2
|
-
import type { FabricatorContext, NaiveFabricator } from "../../Fabricator/Types";
|
|
3
|
-
import type { Trace } from "../../Random/Types";
|
|
4
|
-
import { Kind, Meta, type Adaptation } from "../../Types";
|
|
5
|
-
import { Schema } from "./Schema";
|
|
6
|
-
import type { Fabricated, Meta as ThisMeta } from "./Types";
|
|
1
|
+
import type { AdaptationsOf } from "../../Adapter/Types.ts";
|
|
2
|
+
import type { FabricatorContext, NaiveFabricator } from "../../Fabricator/Types.ts";
|
|
3
|
+
import type { Trace } from "../../Random/Types.ts";
|
|
4
|
+
import { Claim, Kind, Meta, type Adaptation } from "../../Types.ts";
|
|
5
|
+
import { Schema } from "./Schema.ts";
|
|
6
|
+
import type { Fabricated, Meta as ThisMeta } from "./Types.ts";
|
|
7
7
|
export type Fabrication<_ extends Fabricator> = Fabricated;
|
|
8
8
|
export type Fabricator<$Schema extends {
|
|
9
9
|
[Meta]: ThisMeta;
|
|
@@ -14,6 +14,8 @@ export type Fabricator<$Schema extends {
|
|
|
14
14
|
[Meta]: $Schema[typeof Meta];
|
|
15
15
|
readonly trace: Trace;
|
|
16
16
|
readonly [Adaptation]?: AdaptationsOf<$Schema>;
|
|
17
|
+
/** Present on a `T.unique.bigint` only — see `Types.ts`'s `Claim`. */
|
|
18
|
+
readonly [Claim]?: (value: unknown) => void;
|
|
17
19
|
schema: Schema<$Schema[typeof Meta], AdaptationsOf<$Schema>>;
|
|
18
20
|
};
|
|
19
21
|
export declare function Fabricator(context: FabricatorContext<Schema>): Fabricator;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { Produce } from "../../Random/Types";
|
|
2
|
-
import { Kind } from "../../Types";
|
|
3
|
-
import { Schema } from "./Schema";
|
|
4
|
-
import type { Fabricated, InputWhereby, Whereby } from "./Types";
|
|
1
|
+
import type { Produce } from "../../Random/Types.ts";
|
|
2
|
+
import { Kind } from "../../Types.ts";
|
|
3
|
+
import { Schema } from "./Schema.ts";
|
|
4
|
+
import type { Fabricated, InputWhereby, Whereby } from "./Types.ts";
|
|
5
5
|
declare const _default: {
|
|
6
6
|
/**
|
|
7
7
|
* The builder carries the primitive's `[Kind]` so it can be named directly as
|
|
@@ -17,3 +17,23 @@ declare const _default: {
|
|
|
17
17
|
}>;
|
|
18
18
|
};
|
|
19
19
|
export default _default;
|
|
20
|
+
type UniqueRegistry = {
|
|
21
|
+
/** See the default export's `[Kind]`. */
|
|
22
|
+
[Kind]: "bigint";
|
|
23
|
+
/**
|
|
24
|
+
* A bigint the built Fabricator never repeats, drawn from `[min, max]` like
|
|
25
|
+
* `T.bigint.whereby`. The range is yielded as a random permutation at any
|
|
26
|
+
* width, so it produces every value exactly once and the draw after the last
|
|
27
|
+
* throws `UniqueExhaustedError`.
|
|
28
|
+
*/
|
|
29
|
+
whereby: (whereby: InputWhereby) => Schema<{
|
|
30
|
+
whereby: Whereby;
|
|
31
|
+
unique: true;
|
|
32
|
+
}>;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* `T.unique.bigint` (and `T.unique.number.integer.big`), assembled into the
|
|
36
|
+
* namespace by `Primitive/unique`. No `as`: a producer replaces the draw, so it
|
|
37
|
+
* would discard the one thing this builder adds.
|
|
38
|
+
*/
|
|
39
|
+
export declare const unique: UniqueRegistry;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { type AdaptationEntry } from "../../Adapter/Core";
|
|
2
|
-
import type { Adaptations, Adapter, Adapting, WithAdaptations } from "../../Adapter/Types";
|
|
3
|
-
import type { Produce } from "../../Random/Types";
|
|
4
|
-
import { type SatisfiesThis } from "../../Schema/Satisfies";
|
|
5
|
-
import type { Core, Fabricated, Meta as ThisMeta } from "./Types";
|
|
1
|
+
import { type AdaptationEntry } from "../../Adapter/Core.ts";
|
|
2
|
+
import type { Adaptations, Adapter, Adapting, WithAdaptations } from "../../Adapter/Types.ts";
|
|
3
|
+
import type { Produce } from "../../Random/Types.ts";
|
|
4
|
+
import { type SatisfiesThis } from "../../Schema/Satisfies.ts";
|
|
5
|
+
import type { Admits, Core, Fabricated, InputAdmits, Meta as ThisMeta } from "./Types.ts";
|
|
6
6
|
/**
|
|
7
7
|
* Buildable `bigint` recipe: a range (`whereby` — required, like `string`; no
|
|
8
8
|
* natural bound to fuzz to), or opaque production via `as`.
|
|
@@ -19,6 +19,14 @@ export interface Schema<$Meta extends ThisMeta = ThisMeta, $Adaptations extends
|
|
|
19
19
|
* validation of `produce`) still has it to check against.
|
|
20
20
|
*/
|
|
21
21
|
as: (produce: Produce<Fabricated>) => Schema<$Meta, $Adaptations>;
|
|
22
|
+
/**
|
|
23
|
+
* State what adapters admit for this schema, widening what `whereby` draws —
|
|
24
|
+
* see `string/Schema.ts`'s `admits` for the full contract. A safe-integer
|
|
25
|
+
* `number` converts as in `whereby`.
|
|
26
|
+
*/
|
|
27
|
+
admits: (admitted: InputAdmits) => Schema<$Meta & {
|
|
28
|
+
admits: Admits;
|
|
29
|
+
}, $Adaptations>;
|
|
22
30
|
/**
|
|
23
31
|
* Check that this schema's fabricated value type is assignable to `$Target`.
|
|
24
32
|
* Identity at runtime; the target is not carried into later chained calls —
|
|
@@ -1,15 +1,31 @@
|
|
|
1
|
-
import type { Adaptations } from "../../Adapter/Types";
|
|
2
|
-
import type { Bound, InputBound } from "../../Bound";
|
|
3
|
-
import type { Produce } from "../../Random/Types";
|
|
4
|
-
import type { Adaptation, Kind, Meta, Produced, Produces } from "../../Types";
|
|
1
|
+
import type { Adaptations } from "../../Adapter/Types.ts";
|
|
2
|
+
import type { AdmittedEnds, Bound, InputAdmittedEnds, InputBound } from "../../Bound.ts";
|
|
3
|
+
import type { Produce } from "../../Random/Types.ts";
|
|
4
|
+
import type { Adaptation, Kind, Meta, Produced, Produces } from "../../Types.ts";
|
|
5
|
+
/**
|
|
6
|
+
* Call-site `{ min?, max }`. Either end may be a `number` that is a safe
|
|
7
|
+
* integer (`Bound.ts`'s `toBigintBound`), stored as a `bigint`.
|
|
8
|
+
*/
|
|
5
9
|
export type InputWhereby = {
|
|
6
|
-
min?: InputBound<bigint> | undefined;
|
|
7
|
-
max: InputBound<bigint>;
|
|
10
|
+
min?: InputBound<bigint | number> | undefined;
|
|
11
|
+
max: InputBound<bigint | number>;
|
|
8
12
|
};
|
|
9
13
|
export type Whereby = {
|
|
10
14
|
min: Bound<bigint>;
|
|
11
15
|
max: Bound<bigint>;
|
|
12
16
|
};
|
|
17
|
+
/**
|
|
18
|
+
* `.admits(...)`'s input: the ends an adapter states, widening what `whereby`
|
|
19
|
+
* draws. An end is replaced (a safe-integer `number` converts as in `whereby`),
|
|
20
|
+
* `Infinity` (or `-Infinity` for `min`) states no limit, and an omitted end
|
|
21
|
+
* keeps what is admitted already.
|
|
22
|
+
*/
|
|
23
|
+
export type InputAdmits = InputAdmittedEnds<bigint | number>;
|
|
24
|
+
/**
|
|
25
|
+
* `[Meta].admits`, set only by `.admits(...)` and complete once set: an absent
|
|
26
|
+
* end states no limit (`Admits.ts`'s `toAdmits`).
|
|
27
|
+
*/
|
|
28
|
+
export type Admits = AdmittedEnds<bigint>;
|
|
13
29
|
export type Fabricated = bigint;
|
|
14
30
|
/**
|
|
15
31
|
* A ranged bigint, drawn via `whereby` — no natural bound to fuzz to, so unlike
|
|
@@ -17,12 +33,20 @@ export type Fabricated = bigint;
|
|
|
17
33
|
* `as` production, carried alongside `whereby` rather than replacing it (when
|
|
18
34
|
* `whereby` was already set) so a prior range survives `as` for future
|
|
19
35
|
* validation.
|
|
36
|
+
*
|
|
37
|
+
* `unique` is set by `T.unique.bigint`: the built Fabricator yields its range
|
|
38
|
+
* as a random permutation, never repeating for its whole lifetime
|
|
39
|
+
* (`Unique/Distinct.ts`'s `toBigintStrategy`).
|
|
20
40
|
*/
|
|
21
41
|
export type Meta = {
|
|
22
42
|
whereby: Whereby;
|
|
43
|
+
unique?: true;
|
|
44
|
+
admits?: Admits | undefined;
|
|
23
45
|
produce?: never;
|
|
24
46
|
} | {
|
|
25
47
|
whereby?: Whereby;
|
|
48
|
+
unique?: true;
|
|
49
|
+
admits?: Admits | undefined;
|
|
26
50
|
produce: Produce<Fabricated>;
|
|
27
51
|
};
|
|
28
52
|
export type Core<$Meta extends Meta = Meta, $Adaptations extends Adaptations = {}> = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from "./Types";
|
|
2
|
-
export * from "./Schema";
|
|
3
|
-
export * from "./Fabricator";
|
|
4
|
-
export * from "./Registry";
|
|
5
|
-
export { default } from "./Registry";
|
|
1
|
+
export * from "./Types.ts";
|
|
2
|
+
export * from "./Schema.ts";
|
|
3
|
+
export * from "./Fabricator.ts";
|
|
4
|
+
export * from "./Registry.ts";
|
|
5
|
+
export { default } from "./Registry.ts";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { AdaptationsOf } from "../../Adapter/Types";
|
|
2
|
-
import type { FabricatorContext, NaiveFabricator } from "../../Fabricator/Types";
|
|
3
|
-
import type { Trace } from "../../Random/Types";
|
|
4
|
-
import { Kind, Meta, type Adaptation } from "../../Types";
|
|
5
|
-
import { Schema } from "./Schema";
|
|
6
|
-
import type { Fabricated, Meta as ThisMeta } from "./Types";
|
|
1
|
+
import type { AdaptationsOf } from "../../Adapter/Types.ts";
|
|
2
|
+
import type { FabricatorContext, NaiveFabricator } from "../../Fabricator/Types.ts";
|
|
3
|
+
import type { Trace } from "../../Random/Types.ts";
|
|
4
|
+
import { Kind, Meta, type Adaptation } from "../../Types.ts";
|
|
5
|
+
import { Schema } from "./Schema.ts";
|
|
6
|
+
import type { Fabricated, Meta as ThisMeta } from "./Types.ts";
|
|
7
7
|
export type Fabrication<_ extends Fabricator> = Fabricated;
|
|
8
8
|
export type Fabricator<$Schema extends {
|
|
9
9
|
[Meta]: ThisMeta;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Adaptations } from "../../Adapter/Types";
|
|
2
|
-
import { Schema } from "./Schema";
|
|
1
|
+
import type { Adaptations } from "../../Adapter/Types.ts";
|
|
2
|
+
import { Schema } from "./Schema.ts";
|
|
3
3
|
/**
|
|
4
4
|
* A function, not the Schema itself: `Schema/Registry.ts` installs it as the
|
|
5
5
|
* `T.boolean` getter, so every read is a distinct Schema — see AGENTS.md's
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { type AdaptationEntry } from "../../Adapter/Core";
|
|
2
|
-
import type { Adaptations, Adapter, Adapting, WithAdaptations } from "../../Adapter/Types";
|
|
3
|
-
import type { Produce } from "../../Random/Types";
|
|
4
|
-
import { type SatisfiesThis } from "../../Schema/Satisfies";
|
|
5
|
-
import type { Core, Fabricated, Meta as ThisMeta, Weights } from "./Types";
|
|
1
|
+
import { type AdaptationEntry } from "../../Adapter/Core.ts";
|
|
2
|
+
import type { Adaptations, Adapter, Adapting, WithAdaptations } from "../../Adapter/Types.ts";
|
|
3
|
+
import type { Produce } from "../../Random/Types.ts";
|
|
4
|
+
import { type SatisfiesThis } from "../../Schema/Satisfies.ts";
|
|
5
|
+
import type { Core, Fabricated, Meta as ThisMeta, Weights } from "./Types.ts";
|
|
6
6
|
/**
|
|
7
7
|
* Buildable `boolean` recipe: an even coin flip, a weighted one (`weights`), or
|
|
8
8
|
* opaque production via `as`.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Adaptations } from "../../Adapter/Types";
|
|
2
|
-
import type { Produce } from "../../Random/Types";
|
|
3
|
-
import type { Adaptation, Kind, Meta, Produced, Produces } from "../../Types";
|
|
1
|
+
import type { Adaptations } from "../../Adapter/Types.ts";
|
|
2
|
+
import type { Produce } from "../../Random/Types.ts";
|
|
3
|
+
import type { Adaptation, Kind, Meta, Produced, Produces } from "../../Types.ts";
|
|
4
4
|
export type Fabricated = boolean;
|
|
5
5
|
export type Weights = {
|
|
6
6
|
true: number;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export * from "./Fabricator";
|
|
2
|
-
export * from "./Outcomes";
|
|
3
|
-
export * from "./Registry";
|
|
4
|
-
export { default } from "./Registry";
|
|
5
|
-
export * from "./Schema";
|
|
6
|
-
export * from "./Types";
|
|
1
|
+
export * from "./Fabricator.ts";
|
|
2
|
+
export * from "./Outcomes.ts";
|
|
3
|
+
export * from "./Registry.ts";
|
|
4
|
+
export { default } from "./Registry.ts";
|
|
5
|
+
export * from "./Schema.ts";
|
|
6
|
+
export * from "./Types.ts";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { AdaptationsOf } from "../../Adapter/Types";
|
|
2
|
-
import type { FabricatorContext, NaiveFabricator } from "../../Fabricator/Types";
|
|
3
|
-
import type { Trace } from "../../Random/Types";
|
|
4
|
-
import { Children, Kind, Meta, type Adaptation } from "../../Types";
|
|
5
|
-
import { Schema } from "./Schema";
|
|
6
|
-
import type { Fabricated, Items, Meta as ThisMeta } from "./Types";
|
|
1
|
+
import type { AdaptationsOf } from "../../Adapter/Types.ts";
|
|
2
|
+
import type { FabricatorContext, NaiveFabricator } from "../../Fabricator/Types.ts";
|
|
3
|
+
import type { Trace } from "../../Random/Types.ts";
|
|
4
|
+
import { Children, Kind, Meta, type Adaptation } from "../../Types.ts";
|
|
5
|
+
import { Schema } from "./Schema.ts";
|
|
6
|
+
import type { Fabricated, Items, Meta as ThisMeta } from "./Types.ts";
|
|
7
7
|
export type Fabrication<$Fabricator extends Fabricator> = $Fabricator extends Fabricator<infer $Schema extends {
|
|
8
8
|
[Meta]: ThisMeta;
|
|
9
9
|
}> ? Fabricated<$Schema[typeof Meta]["items"]> : never;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Schema } from "./Schema";
|
|
2
|
-
import type { Item, Items } from "./Types";
|
|
1
|
+
import { Schema } from "./Schema.ts";
|
|
2
|
+
import type { Item, Items } from "./Types.ts";
|
|
3
3
|
/**
|
|
4
4
|
* Tuple-preserving: a mapped type over `$Items` keeps its exact length and
|
|
5
5
|
* per-position option types (`{ [K in keyof $Items]: ... }` walks a tuple
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { type AdaptationEntry } from "../../Adapter/Core";
|
|
2
|
-
import type { Adaptations, Adapter, Adapting, WithAdaptations } from "../../Adapter/Types";
|
|
3
|
-
import type { Produce } from "../../Random/Types";
|
|
4
|
-
import { type SatisfiesThis } from "../../Schema/Satisfies";
|
|
5
|
-
import type { Core, Fabricated, Items } from "./Types";
|
|
1
|
+
import { type AdaptationEntry } from "../../Adapter/Core.ts";
|
|
2
|
+
import type { Adaptations, Adapter, Adapting, WithAdaptations } from "../../Adapter/Types.ts";
|
|
3
|
+
import type { Produce } from "../../Random/Types.ts";
|
|
4
|
+
import { type SatisfiesThis } from "../../Schema/Satisfies.ts";
|
|
5
|
+
import type { Core, Fabricated, Items } from "./Types.ts";
|
|
6
6
|
/**
|
|
7
7
|
* Buildable `choice` recipe: a weighted set of option Schemas, one of which is
|
|
8
8
|
* drawn (and only then dispatched into a value) each fabrication. No bare form
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { Adaptations } from "../../Adapter/Types";
|
|
2
|
-
import type { Produce } from "../../Random/Types";
|
|
3
|
-
import type { AnySchema, Fabricated as FabricatedBy } from "../../Schema/Types";
|
|
4
|
-
import type { Adaptation, Kind, Meta, Produced, Produces } from "../../Types";
|
|
1
|
+
import type { Adaptations } from "../../Adapter/Types.ts";
|
|
2
|
+
import type { Produce } from "../../Random/Types.ts";
|
|
3
|
+
import type { AnySchema, Fabricated as FabricatedBy } from "../../Schema/Types.ts";
|
|
4
|
+
import type { Adaptation, Kind, Meta, Produced, Produces } from "../../Types.ts";
|
|
5
5
|
/** The schemas a `choice` can draw from. */
|
|
6
6
|
export type Item = AnySchema;
|
|
7
7
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from "./Fabricator";
|
|
2
|
-
export * from "./Registry";
|
|
3
|
-
export { default } from "./Registry";
|
|
4
|
-
export * from "./Schema";
|
|
5
|
-
export * from "./Types";
|
|
1
|
+
export * from "./Fabricator.ts";
|
|
2
|
+
export * from "./Registry.ts";
|
|
3
|
+
export { default } from "./Registry.ts";
|
|
4
|
+
export * from "./Schema.ts";
|
|
5
|
+
export * from "./Types.ts";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Admits, InputAdmits, Meta } from "./Types.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Resolve `.admits(...)` against what is admitted already: `meta.admits`, or by
|
|
4
|
+
* default the `whereby` ends — what an adapter states without one. An omitted
|
|
5
|
+
* `whereby` end draws against `±MAX_TIME`, so only no limit admits it.
|
|
6
|
+
*/
|
|
7
|
+
export declare function toAdmits(meta: Meta, input: InputAdmits): Admits;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Bound } from "../../Bound.ts";
|
|
2
|
+
import type { Meta } from "./Types.ts";
|
|
2
3
|
/**
|
|
3
4
|
* Inclusive epoch-millisecond caps that a missing `whereby` end draws against —
|
|
4
5
|
* the whole representable `Date` range. Not stored on `[Meta]`: an omitted end
|
|
@@ -9,3 +10,23 @@ export declare const unboundedEpoch: {
|
|
|
9
10
|
min: Bound<number>;
|
|
10
11
|
max: Bound<number>;
|
|
11
12
|
};
|
|
13
|
+
/**
|
|
14
|
+
* The epoch-millisecond ends a `date` draws between, given the construction's
|
|
15
|
+
* `clock`: `whereby`'s named ends, the unbounded caps for the rest, and `clock`
|
|
16
|
+
* itself (inclusive) as `past`'s upper or `future`'s lower end. Here rather
|
|
17
|
+
* than in `Fabricator.ts` so `Unique/Distinct.ts` can read a collection
|
|
18
|
+
* member's range without importing a Fabricator.
|
|
19
|
+
*/
|
|
20
|
+
export declare function toEpochBounds(meta: Meta, clock: number): {
|
|
21
|
+
min: Bound<number>;
|
|
22
|
+
max: Bound<number>;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* {@link toEpochBounds} as the inclusive whole-millisecond interval a `Date` can
|
|
26
|
+
* actually take — `Date` is `TimeClip`ped to whole milliseconds, so this is
|
|
27
|
+
* every value a draw can produce.
|
|
28
|
+
*/
|
|
29
|
+
export declare function toEpochRange(meta: Meta, clock: number): {
|
|
30
|
+
min: number;
|
|
31
|
+
max: number;
|
|
32
|
+
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { AdaptationsOf } from "../../Adapter/Types";
|
|
2
|
-
import type { FabricatorContext, NaiveFabricator } from "../../Fabricator/Types";
|
|
3
|
-
import type { Trace } from "../../Random/Types";
|
|
4
|
-
import { Kind, Meta, type Adaptation } from "../../Types";
|
|
5
|
-
import { Schema } from "./Schema";
|
|
6
|
-
import type { Fabricated, Meta as ThisMeta } from "./Types";
|
|
1
|
+
import type { AdaptationsOf } from "../../Adapter/Types.ts";
|
|
2
|
+
import type { FabricatorContext, NaiveFabricator } from "../../Fabricator/Types.ts";
|
|
3
|
+
import type { Trace } from "../../Random/Types.ts";
|
|
4
|
+
import { Claim, Kind, Meta, type Adaptation } from "../../Types.ts";
|
|
5
|
+
import { Schema } from "./Schema.ts";
|
|
6
|
+
import type { Fabricated, Meta as ThisMeta } from "./Types.ts";
|
|
7
7
|
export type Fabrication<_ extends Fabricator> = Fabricated;
|
|
8
8
|
export type Fabricator<$Schema extends {
|
|
9
9
|
[Meta]: ThisMeta;
|
|
@@ -14,6 +14,8 @@ export type Fabricator<$Schema extends {
|
|
|
14
14
|
[Meta]: $Schema[typeof Meta];
|
|
15
15
|
readonly trace: Trace;
|
|
16
16
|
readonly [Adaptation]?: AdaptationsOf<$Schema>;
|
|
17
|
+
/** Present on a `T.unique.date` only — see `Types.ts`'s `Claim`. */
|
|
18
|
+
readonly [Claim]?: (value: unknown) => void;
|
|
17
19
|
schema: Schema<$Schema[typeof Meta], AdaptationsOf<$Schema>>;
|
|
18
20
|
};
|
|
19
21
|
export declare function Fabricator(context: FabricatorContext<Schema>): Fabricator;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import type { Adaptations } from "../../Adapter/Types";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { Schema } from "./Schema";
|
|
5
|
-
import type { InputWhereby, Whereby } from "./Types";
|
|
1
|
+
import type { Adaptations } from "../../Adapter/Types.ts";
|
|
2
|
+
import { Schema } from "./Schema.ts";
|
|
3
|
+
import type { InputFutureWhereby, InputPastWhereby, InputUniqueFutureWhereby, InputUniquePastWhereby, InputUniqueWhereby, InputWhereby, Whereby } from "./Types.ts";
|
|
6
4
|
type ThisRegistry = Schema<{}, Adaptations> & {
|
|
7
5
|
/**
|
|
8
6
|
* A `Date` drawn from `[min, max]`. Either end may be omitted: `min` defaults
|
|
@@ -26,10 +24,7 @@ type ThisRegistry = Schema<{}, Adaptations> & {
|
|
|
26
24
|
* `distribution` to shape how values cluster within the range; without one,
|
|
27
25
|
* every instant is equally likely.
|
|
28
26
|
*/
|
|
29
|
-
whereby: (whereby: {
|
|
30
|
-
min?: InputBound<Date> | undefined;
|
|
31
|
-
distribution?: Distribution | undefined;
|
|
32
|
-
}) => Schema<{
|
|
27
|
+
whereby: (whereby: InputPastWhereby) => Schema<{
|
|
33
28
|
mode: "past";
|
|
34
29
|
whereby: Whereby;
|
|
35
30
|
}>;
|
|
@@ -44,10 +39,7 @@ type ThisRegistry = Schema<{}, Adaptations> & {
|
|
|
44
39
|
* `distribution` to shape how values cluster within the range; without one,
|
|
45
40
|
* every instant is equally likely.
|
|
46
41
|
*/
|
|
47
|
-
whereby: (whereby: {
|
|
48
|
-
max?: InputBound<Date> | undefined;
|
|
49
|
-
distribution?: Distribution | undefined;
|
|
50
|
-
}) => Schema<{
|
|
42
|
+
whereby: (whereby: InputFutureWhereby) => Schema<{
|
|
51
43
|
mode: "future";
|
|
52
44
|
whereby: Whereby;
|
|
53
45
|
}>;
|
|
@@ -61,3 +53,47 @@ type ThisRegistry = Schema<{}, Adaptations> & {
|
|
|
61
53
|
*/
|
|
62
54
|
declare function registry(): ThisRegistry;
|
|
63
55
|
export default registry;
|
|
56
|
+
type UniqueRegistry = Schema<{
|
|
57
|
+
unique: true;
|
|
58
|
+
}, Adaptations> & {
|
|
59
|
+
/**
|
|
60
|
+
* A `Date` the built Fabricator never repeats, drawn from `[min, max]` like
|
|
61
|
+
* `T.date.whereby`. Instants are whole milliseconds, so a uniform range is
|
|
62
|
+
* drawn as a random permutation of them: every instant exactly once, then
|
|
63
|
+
* `UniqueExhaustedError`. A skewed range is tracked instead, still exhausting
|
|
64
|
+
* exactly; `redraws` raises the cap on consecutive repeats its rarest
|
|
65
|
+
* instants can need.
|
|
66
|
+
*/
|
|
67
|
+
whereby: (whereby: InputUniqueWhereby) => Schema<{
|
|
68
|
+
unique: true;
|
|
69
|
+
whereby: Whereby;
|
|
70
|
+
}>;
|
|
71
|
+
/** A past `Date` the built Fabricator never repeats. */
|
|
72
|
+
past: Schema<{
|
|
73
|
+
mode: "past";
|
|
74
|
+
unique: true;
|
|
75
|
+
}> & {
|
|
76
|
+
whereby: (whereby: InputUniquePastWhereby) => Schema<{
|
|
77
|
+
mode: "past";
|
|
78
|
+
unique: true;
|
|
79
|
+
whereby: Whereby;
|
|
80
|
+
}>;
|
|
81
|
+
};
|
|
82
|
+
/** A future `Date` the built Fabricator never repeats. */
|
|
83
|
+
future: Schema<{
|
|
84
|
+
mode: "future";
|
|
85
|
+
unique: true;
|
|
86
|
+
}> & {
|
|
87
|
+
whereby: (whereby: InputUniqueFutureWhereby) => Schema<{
|
|
88
|
+
mode: "future";
|
|
89
|
+
unique: true;
|
|
90
|
+
whereby: Whereby;
|
|
91
|
+
}>;
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* `T.unique.date`, assembled into the namespace by `Primitive/unique`, which
|
|
96
|
+
* installs it as a getter for the same reason `T.date` is one. `past` and
|
|
97
|
+
* `future` are getters here too.
|
|
98
|
+
*/
|
|
99
|
+
export declare function unique(): UniqueRegistry;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { type AdaptationEntry } from "../../Adapter/Core";
|
|
2
|
-
import type { Adaptations, Adapter, Adapting, WithAdaptations } from "../../Adapter/Types";
|
|
3
|
-
import type { Produce } from "../../Random/Types";
|
|
4
|
-
import { type SatisfiesThis } from "../../Schema/Satisfies";
|
|
5
|
-
import type { Core, Fabricated, Meta as ThisMeta } from "./Types";
|
|
1
|
+
import { type AdaptationEntry } from "../../Adapter/Core.ts";
|
|
2
|
+
import type { Adaptations, Adapter, Adapting, WithAdaptations } from "../../Adapter/Types.ts";
|
|
3
|
+
import type { Produce } from "../../Random/Types.ts";
|
|
4
|
+
import { type SatisfiesThis } from "../../Schema/Satisfies.ts";
|
|
5
|
+
import type { Core, Fabricated, Meta as ThisMeta, Admits, InputAdmitsOf } from "./Types.ts";
|
|
6
6
|
/**
|
|
7
7
|
* Buildable `Date` recipe: a range/distribution (`whereby`, absent for the
|
|
8
8
|
* full-range bare form), optionally scoped by `mode` to `"past"` (up to now) or
|
|
@@ -19,6 +19,15 @@ export interface Schema<$Meta extends ThisMeta = ThisMeta, $Adaptations extends
|
|
|
19
19
|
* future validation of `produce`) still has them to check against.
|
|
20
20
|
*/
|
|
21
21
|
as: (produce: Produce<Fabricated>) => Schema<$Meta, $Adaptations>;
|
|
22
|
+
/**
|
|
23
|
+
* State what adapters admit for this schema, widening what `whereby` draws —
|
|
24
|
+
* see `string/Schema.ts`'s `admits` for the full contract. Epoch milliseconds
|
|
25
|
+
* convert as in `whereby`. `past` admits only a `min` and `future` only a
|
|
26
|
+
* `max`: their other end is the clock.
|
|
27
|
+
*/
|
|
28
|
+
admits: (admitted: InputAdmitsOf<$Meta>) => Schema<$Meta & {
|
|
29
|
+
admits: Admits;
|
|
30
|
+
}, $Adaptations>;
|
|
22
31
|
/**
|
|
23
32
|
* Check that this schema's fabricated value type is assignable to `$Target`.
|
|
24
33
|
* Identity at runtime; the target is not carried into later chained calls —
|