@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
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { type Distribution, type Range } from "../Distribution/index.ts";
|
|
2
|
+
import type { Fabricator } from "../Fabricator/Types.ts";
|
|
3
|
+
import type { Whereby as BigintWhereby } from "../Primitive/bigint/Types.ts";
|
|
4
|
+
import type { Meta as NumberMeta } from "../Primitive/number/Types.ts";
|
|
5
|
+
import type { Stream } from "../Random/Types.ts";
|
|
6
|
+
import { type Strategy } from "./Strategy.ts";
|
|
7
|
+
/**
|
|
8
|
+
* How many distinct values a unique `number` can produce: every integer of an
|
|
9
|
+
* integer range, skewed or not, and for a continuous range only the single
|
|
10
|
+
* value of one whose ends meet — any other continuous range is left uncounted.
|
|
11
|
+
* Shared by {@link toNumberStrategy} and `Unique/Capacity.ts`.
|
|
12
|
+
*/
|
|
13
|
+
export declare function toNumberCapacity(meta: NumberMeta): bigint | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* The size of an inclusive integer range, exact past `Number.MAX_SAFE_INTEGER`.
|
|
16
|
+
*/
|
|
17
|
+
export declare function toRangeCapacity(range: Range): bigint;
|
|
18
|
+
/**
|
|
19
|
+
* How a unique `number` draws. A uniform integer range small enough for exact
|
|
20
|
+
* positions is a sparse Fisher–Yates permutation on `stream`. Everything else —
|
|
21
|
+
* an unbounded integer, a skewed integer range, any continuous range — tracks
|
|
22
|
+
* the numbers it has produced, calling `draw` (the kind's ordinary sampler)
|
|
23
|
+
* until it lands on a new one. An integer range keeps its exact size as
|
|
24
|
+
* `capacity` even when tracked, so it exhausts by counting rather than by
|
|
25
|
+
* spinning; a continuous range has one only when its two ends meet.
|
|
26
|
+
*
|
|
27
|
+
* Shared by `number/Fabricator.ts` (a `T.unique.number` leaf, with its own
|
|
28
|
+
* stream and sampler) and {@link toDistinct} (a collection member, with the
|
|
29
|
+
* collection's stream and the member's `fabricate`). A leaf's cap is its own
|
|
30
|
+
* `whereby.redraws`; a member's is the collection's.
|
|
31
|
+
*/
|
|
32
|
+
export declare function toNumberStrategy(options: {
|
|
33
|
+
label: string;
|
|
34
|
+
meta: NumberMeta;
|
|
35
|
+
stream: Stream;
|
|
36
|
+
draw: () => number;
|
|
37
|
+
redraws?: number | undefined;
|
|
38
|
+
}): Strategy;
|
|
39
|
+
/**
|
|
40
|
+
* How a unique `date` draws, over `range` — every whole millisecond a draw can
|
|
41
|
+
* produce (`date/Defaults.ts`'s `toEpochRange`). A uniform range small enough
|
|
42
|
+
* for exact positions is a permutation of those milliseconds, like an integer
|
|
43
|
+
* range. Anything wider or skewed tracks the instants produced, by time value,
|
|
44
|
+
* and its exact size lets it exhaust by counting.
|
|
45
|
+
*
|
|
46
|
+
* Both draw whole milliseconds from `stream` — the tracked path through
|
|
47
|
+
* `discreteSampler`, the integer draw — never through the kind's ordinary
|
|
48
|
+
* continuous sampler. That sampler reaches the upper millisecond only when a
|
|
49
|
+
* draw lands exactly on it, so a count that includes it would leave the last
|
|
50
|
+
* instant all but unreachable and the final draw spinning to the cap.
|
|
51
|
+
*/
|
|
52
|
+
export declare function toDateStrategy(options: {
|
|
53
|
+
label: string;
|
|
54
|
+
range: Range;
|
|
55
|
+
distribution: Distribution | undefined;
|
|
56
|
+
stream: Stream;
|
|
57
|
+
redraws?: number | undefined;
|
|
58
|
+
}): Strategy;
|
|
59
|
+
/**
|
|
60
|
+
* How a unique `bigint` draws: a bigint sparse Fisher–Yates permutation of its
|
|
61
|
+
* range on `stream`, exact at any width.
|
|
62
|
+
*/
|
|
63
|
+
export declare function toBigintStrategy(whereby: BigintWhereby, stream: Stream): Strategy;
|
|
64
|
+
/**
|
|
65
|
+
* How a unique collection (`T.unique.array`'s elements, `T.unique.record`'s
|
|
66
|
+
* keys) draws distinct members from `member`, an already-built Fabricator.
|
|
67
|
+
* Chosen once, at construction, by reading `member`'s `[Kind]`/`[Meta]`; the
|
|
68
|
+
* collection then opens a fresh scope per `fabricate()` call.
|
|
69
|
+
*
|
|
70
|
+
* Exact strategies draw from `stream`, the collection's own, never from the
|
|
71
|
+
* member's — the member's own `fabricate` is simply not called. A `date` member
|
|
72
|
+
* reads its range against its own `trace.clock`. Everything else is tracked by
|
|
73
|
+
* canonical key over `member.fabricate`: any member under a `by` projection or
|
|
74
|
+
* an `.as(...)` producer, and also a member that does not repeat by itself (a
|
|
75
|
+
* `sequence`, a bare `symbol`, a `T.unique.*` leaf). Trusting the last group
|
|
76
|
+
* would save a hash per member, but a unique leaf does repeat once it cycles
|
|
77
|
+
* under `combinatorial`/`coverage` (`Fabricator/Types.ts`'s `Exhaustion`), and
|
|
78
|
+
* a repeat would land inside one value.
|
|
79
|
+
*
|
|
80
|
+
* Reads another kind's `[Meta]`, which AGENTS.md otherwise keeps kind-private —
|
|
81
|
+
* the same exception `Enumeration/Plan.ts` takes, for the same reason: the
|
|
82
|
+
* finite value set a kind draws from is exactly what is needed here.
|
|
83
|
+
*/
|
|
84
|
+
export declare function toDistinct(member: Fabricator<unknown>, stream: Stream, options: {
|
|
85
|
+
label: string;
|
|
86
|
+
by?: ((value: any) => unknown) | undefined;
|
|
87
|
+
redraws?: number | undefined;
|
|
88
|
+
}): Strategy;
|
|
89
|
+
/**
|
|
90
|
+
* Reject, at construction, a collection that may ask for more distinct members
|
|
91
|
+
* than its member schema has — so an exact member can never run out on a draw
|
|
92
|
+
* whose size depends on the salt. A member of unknown capacity passes; it is
|
|
93
|
+
* left to the tracked scope's cap.
|
|
94
|
+
*/
|
|
95
|
+
export declare function assertCapacity(label: string, strategy: Strategy, requested: number): void;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Maps a value to a number that equal values share — what a tracked unique
|
|
3
|
+
* scope (`Unique/Strategy.ts`) stores in place of the value itself, so memory
|
|
4
|
+
* per produced value stays one number however large the value is.
|
|
5
|
+
*/
|
|
6
|
+
export type Keyer = (value: unknown) => number;
|
|
7
|
+
/**
|
|
8
|
+
* A fresh {@link Keyer}, owning the identity tables its encoding needs. Two
|
|
9
|
+
* values share a key when they are the same plain data:
|
|
10
|
+
*
|
|
11
|
+
* - Primitives compare by SameValueZero, as a `Set` would: `-0` is `0`, `NaN` is
|
|
12
|
+
* `NaN`, and `"1"` is not `1`.
|
|
13
|
+
* - A `Date` compares by its time value.
|
|
14
|
+
* - Arrays compare element by element, a hole reading as `undefined`.
|
|
15
|
+
* - Plain objects compare by their own enumerable keys and values, in any key
|
|
16
|
+
* order. A key present as `undefined` differs from an absent one, the
|
|
17
|
+
* distinction `T.optional` draws.
|
|
18
|
+
*
|
|
19
|
+
* Everything else — symbols, functions, and objects that are not plain data
|
|
20
|
+
* (`Map`, `Set`, class instances) — compares by identity, through an id the
|
|
21
|
+
* tables hand out on first sight. Structural rules for those would be guesses;
|
|
22
|
+
* a `by` projection says what makes one unique.
|
|
23
|
+
*
|
|
24
|
+
* The encoding is hashed to 53 bits (`cyrb128`'s first two words), exact as a
|
|
25
|
+
* `number`. The error is one-sided: two different values sharing a hash makes a
|
|
26
|
+
* scope skip one of them, never produce a duplicate. Across a million values
|
|
27
|
+
* that happens with probability around 5e-5.
|
|
28
|
+
*/
|
|
29
|
+
export declare function toKeyer(): Keyer;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Record a per-call override on the `T.unique.*` leaf it stands in for, so no
|
|
3
|
+
* later draw repeats it. An override skips the field's draw
|
|
4
|
+
* (`object/Fabricator.ts`), so without this the leaf would never learn that the
|
|
5
|
+
* value was used.
|
|
6
|
+
*
|
|
7
|
+
* The field handed in is not always the leaf: `T.omittable(T.unique...)` is how
|
|
8
|
+
* an optional unique field is spelled. So this walks down through the
|
|
9
|
+
* single-child presence wrappers via `[Children]`, stopping where `value` is
|
|
10
|
+
* that wrapper's own outcome (`null`, `undefined`, `Omitted`) rather than its
|
|
11
|
+
* child's, and calls the leaf's `[Claim]`. Any other node ends the walk: a
|
|
12
|
+
* nested `object` records its own fields through its own
|
|
13
|
+
* `fabricate(overrides)`, and nothing else holds a unique leaf whose draw an
|
|
14
|
+
* override could stand in for.
|
|
15
|
+
*/
|
|
16
|
+
export declare function recordOverride(field: any, value: unknown): void;
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { type Range } from "../Distribution/index.ts";
|
|
2
|
+
import { FabricatorError } from "../Error/index.ts";
|
|
3
|
+
import type { Exhaustion } from "../Fabricator/Types.ts";
|
|
4
|
+
import type { Stream } from "../Random/Types.ts";
|
|
5
|
+
import { type Keyer } from "./Key.ts";
|
|
6
|
+
/**
|
|
7
|
+
* One run of distinct draws: nothing `draw` returns repeats anything it, or
|
|
8
|
+
* `claim`, saw before in the same scope. A `T.unique.*` leaf opens one scope
|
|
9
|
+
* for its built Fabricator's lifetime; a unique collection opens a fresh one
|
|
10
|
+
* per `fabricate()` call.
|
|
11
|
+
*/
|
|
12
|
+
export type Scope = {
|
|
13
|
+
draw: () => unknown;
|
|
14
|
+
/**
|
|
15
|
+
* Record `value` as produced without drawing it — an override value
|
|
16
|
+
* (`Unique/Override.ts`). Recording only: claiming a value already produced,
|
|
17
|
+
* or one outside the domain, changes nothing.
|
|
18
|
+
*/
|
|
19
|
+
claim: (value: unknown) => void;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* How a schema's distinct values are drawn. `capacity` is how many there are,
|
|
23
|
+
* when that is known, which is what lets a collection reject an impossible size
|
|
24
|
+
* at construction rather than on a salt-dependent draw.
|
|
25
|
+
*/
|
|
26
|
+
export type Strategy = {
|
|
27
|
+
readonly capacity: bigint | undefined;
|
|
28
|
+
open: () => Scope;
|
|
29
|
+
};
|
|
30
|
+
export declare function defaultRedraws(produced: number): number;
|
|
31
|
+
/**
|
|
32
|
+
* The `redraws` every `T.unique.*` builder's `.whereby` accepts: how many times
|
|
33
|
+
* in a row a tracked draw may repeat a value already produced while looking for
|
|
34
|
+
* a new one, before it forfeits — per value, not across the scope. `0` means
|
|
35
|
+
* one draw and no retries. Replaces the default formula
|
|
36
|
+
* ({@link defaultRedraws}); a skewed distribution is what needs it most, since
|
|
37
|
+
* its rarest values take many draws to find. Validated by {@link toRedraws},
|
|
38
|
+
* and stored on each kind's `Whereby` as a plain `redraws` field.
|
|
39
|
+
*/
|
|
40
|
+
export type Redraws = {
|
|
41
|
+
redraws?: number | undefined;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Validate a caller-supplied `redraws`. It counts retries, so any whole number
|
|
45
|
+
* from `0` up can be one.
|
|
46
|
+
*/
|
|
47
|
+
export declare function toRedraws(label: string, redraws: number | undefined): number | undefined;
|
|
48
|
+
/**
|
|
49
|
+
* Sampling without replacement from a weighted list of values — `enum`,
|
|
50
|
+
* `boolean`, and the single-value kinds. Equal values (by {@link toKeyer}) are
|
|
51
|
+
* merged first, their weights summed, so `capacity` counts distinct values and
|
|
52
|
+
* `T.enum.uniform(["a", "a", "b"])` still draws `"a"` two times in three. Draws
|
|
53
|
+
* come from `stream`, the owning node's own.
|
|
54
|
+
*/
|
|
55
|
+
export declare function exactValues(kind: string, entries: ReadonlyArray<readonly [number, unknown]>, stream: Stream): Strategy;
|
|
56
|
+
/**
|
|
57
|
+
* `entries`' drawable values with equal ones merged and their weights summed,
|
|
58
|
+
* each tagged with its canonical key — what {@link exactValues} draws from, and
|
|
59
|
+
* what `Unique/Capacity.ts` counts for a unique `enum`. Returns the
|
|
60
|
+
* {@link Keyer} too, since a claim must key a value the same way.
|
|
61
|
+
*/
|
|
62
|
+
export declare function toDistinctValues(entries: ReadonlyArray<readonly [number, unknown]>): {
|
|
63
|
+
keyer: Keyer;
|
|
64
|
+
values: Array<[number, {
|
|
65
|
+
key: number;
|
|
66
|
+
value: unknown;
|
|
67
|
+
}]>;
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* Sampling without replacement from a uniform integer range, by sparse
|
|
71
|
+
* Fisher–Yates (`Distribution/index.ts`'s `permutation`). A claimed value is
|
|
72
|
+
* held aside and skipped when the permutation reaches it — consumed, not
|
|
73
|
+
* redrawn into — which leaves every later draw uniform over what remains.
|
|
74
|
+
* Precondition: the range's size is at most `Number.MAX_SAFE_INTEGER`.
|
|
75
|
+
*/
|
|
76
|
+
export declare function exactRange(kind: string, range: Range, stream: Stream): Strategy;
|
|
77
|
+
/**
|
|
78
|
+
* {@link exactRange} over a bigint range — no size precondition.
|
|
79
|
+
*/
|
|
80
|
+
export declare function exactBigintRange(kind: string, range: {
|
|
81
|
+
min: bigint;
|
|
82
|
+
max: bigint;
|
|
83
|
+
}, stream: Stream): Strategy;
|
|
84
|
+
/**
|
|
85
|
+
* Rejection sampling: draw, and draw again while the key has been seen. For
|
|
86
|
+
* every domain no exact strategy covers — strings, dates, composites,
|
|
87
|
+
* `.as(...)`, a skewed or unbounded integer range, a `by` projection.
|
|
88
|
+
*
|
|
89
|
+
* `key` reduces a value to what is stored: a number for a numeric domain (`Set`
|
|
90
|
+
* compares those by SameValueZero already), a {@link Keyer} hash otherwise. When
|
|
91
|
+
* `capacity` is known the scope counts rather than searches — exhausted the
|
|
92
|
+
* moment it has seen that many, with no retries. `admits` keeps a claimed value
|
|
93
|
+
* from outside the domain out of that count: an override of `0` on a `[1, 10]`
|
|
94
|
+
* field must not use up one of its ten.
|
|
95
|
+
*/
|
|
96
|
+
export declare function tracked(options: {
|
|
97
|
+
label: string;
|
|
98
|
+
kind: string;
|
|
99
|
+
draw: () => unknown;
|
|
100
|
+
key: (value: unknown) => unknown;
|
|
101
|
+
capacity?: bigint | undefined;
|
|
102
|
+
admits?: ((value: unknown) => boolean) | undefined;
|
|
103
|
+
redraws?: number | undefined;
|
|
104
|
+
}): Strategy;
|
|
105
|
+
/**
|
|
106
|
+
* {@link tracked} keyed by a fresh {@link Keyer}, through `by` when given.
|
|
107
|
+
*/
|
|
108
|
+
export declare function trackedByKey(options: {
|
|
109
|
+
label: string;
|
|
110
|
+
kind: string;
|
|
111
|
+
draw: () => unknown;
|
|
112
|
+
by?: ((value: any) => unknown) | undefined;
|
|
113
|
+
capacity?: bigint | undefined;
|
|
114
|
+
admits?: ((value: unknown) => boolean) | undefined;
|
|
115
|
+
redraws?: number | undefined;
|
|
116
|
+
}): Strategy;
|
|
117
|
+
/**
|
|
118
|
+
* `member.fabricate`, for a plain `T.array`/`T.record` whose element or key is
|
|
119
|
+
* a `T.unique.*` leaf (one carrying `[Claim]`): an exhaustion it raises is
|
|
120
|
+
* re-raised naming the collection, whose message points at the per-value
|
|
121
|
+
* builder. Any other member is returned untouched, so the common path pays
|
|
122
|
+
* nothing.
|
|
123
|
+
*/
|
|
124
|
+
export declare function withinCollection<$T>(collection: FabricatorError.UniqueWithin, member: {
|
|
125
|
+
fabricate: () => $T;
|
|
126
|
+
}): () => $T;
|
|
127
|
+
/**
|
|
128
|
+
* The scope a `T.unique.*` leaf keeps for its built Fabricator's whole life,
|
|
129
|
+
* under the build's exhaustion policy. Under `"cycle"` (an enumeration build —
|
|
130
|
+
* `Fabricator/Types.ts`'s `Exhaustion`), running out opens a fresh scope and
|
|
131
|
+
* draws again, as if nothing had been produced; claims go to whichever scope is
|
|
132
|
+
* current. Both exhaustion errors reset: a tracked leaf of unknown size knows
|
|
133
|
+
* it ran out only by hitting its cap.
|
|
134
|
+
*/
|
|
135
|
+
export declare function toLifetimeScope(strategy: Strategy, exhaustion: Exhaustion): Scope;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Replace } from "../Types";
|
|
2
|
-
import type { PlainObject, Pretty } from "./Types";
|
|
1
|
+
import { Replace } from "../Types.ts";
|
|
2
|
+
import type { PlainObject, Pretty } from "./Types.ts";
|
|
3
3
|
export type DeepMerge<$A, $B> = $B extends {
|
|
4
4
|
[Replace]: true;
|
|
5
5
|
} ? Pretty<Omit<$B, typeof Replace>> : Pretty<{
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Replace } from "../Types";
|
|
2
|
-
import type { PlainObject, Pretty } from "./Types";
|
|
1
|
+
import { Replace } from "../Types.ts";
|
|
2
|
+
import type { PlainObject, Pretty } from "./Types.ts";
|
|
3
3
|
export type ShallowMerge<$A, $B> = $B extends {
|
|
4
4
|
[Replace]: true;
|
|
5
5
|
} ? Pretty<Omit<$B, typeof Replace>> : Pretty<Omit<$A, keyof $B> & Omit<$B, typeof Replace>>;
|
package/dist/types/adapting.d.ts
CHANGED
|
@@ -19,14 +19,14 @@
|
|
|
19
19
|
*
|
|
20
20
|
* @module
|
|
21
21
|
*/
|
|
22
|
-
export { walk } from "./Adapter/Core";
|
|
22
|
+
export { walk } from "./Adapter/Core.ts";
|
|
23
23
|
/**
|
|
24
24
|
* `Adapter`/`Recurse` are what an adapter declares; `AdaptationsOf` is how it
|
|
25
25
|
* reads what a Schema declared at the type level, keyed by its own `key`.
|
|
26
26
|
*/
|
|
27
|
-
export type { Adaptations, AdaptationsOf, Adapter, Recurse, } from "./Adapter/Types";
|
|
27
|
+
export type { Adaptations, AdaptationsOf, Adapter, Recurse, } from "./Adapter/Types.ts";
|
|
28
28
|
/**
|
|
29
29
|
* What `[Adaptation]` holds at runtime — a per-adapter map of overrides, read
|
|
30
30
|
* only by an adapter.
|
|
31
31
|
*/
|
|
32
|
-
export { Adaptation } from "./Types";
|
|
32
|
+
export { Adaptation } from "./Types.ts";
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
* caller owns `initialize(...)` (and in particular the suite-wide `clock`), and
|
|
29
29
|
* this only wraps each test body in that instance's per-identity `wrap`.
|
|
30
30
|
*/
|
|
31
|
-
export { integration } from "./Harnessing/Core";
|
|
31
|
+
export { integration } from "./Harnessing/Core.ts";
|
|
32
32
|
/**
|
|
33
33
|
* `Identity` is what identifies one registered test or suite; `Integration` is
|
|
34
34
|
* the `{ name, provides, frame }` shape `integration(instance)` returns —
|
|
@@ -39,4 +39,4 @@ export { integration } from "./Harnessing/Core";
|
|
|
39
39
|
* same thing plus `established`, for a provider; `FabricatorTestContext` is the
|
|
40
40
|
* `{ fabricator }` slice of the test context this integration contributes.
|
|
41
41
|
*/
|
|
42
|
-
export type { FabricatorTestContext, Frame, FrameArgs, Identity, Integration, Provider, ProviderArgs, Provides, Wrapper, } from "./Harnessing/Types";
|
|
42
|
+
export type { FabricatorTestContext, Frame, FrameArgs, Identity, Integration, Provider, ProviderArgs, Provides, Wrapper, } from "./Harnessing/Types.ts";
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { Limits } from "./Enumeration/Types";
|
|
2
|
-
import type { Instance, Stack } from "./Instance/Types";
|
|
3
|
-
import type { Algorithm, Salt } from "./Random/Types";
|
|
4
|
-
import { registry } from "./Schema/Registry";
|
|
5
|
-
import type { PlainObject } from "./Utility/Types";
|
|
1
|
+
import type { Limits } from "./Enumeration/Types.ts";
|
|
2
|
+
import type { Instance, Stack } from "./Instance/Types.ts";
|
|
3
|
+
import type { Algorithm, Salt } from "./Random/Types.ts";
|
|
4
|
+
import { registry } from "./Schema/Registry.ts";
|
|
5
|
+
import type { PlainObject } from "./Utility/Types.ts";
|
|
6
6
|
export declare function initialize<const $Registry extends PlainObject = typeof registry>(config?: Partial<{
|
|
7
7
|
/** The registry of type definers to use — `registry` itself. */
|
|
8
8
|
types: $Registry;
|
|
@@ -71,18 +71,18 @@ export declare function initialize<const $Registry extends PlainObject = typeof
|
|
|
71
71
|
*/
|
|
72
72
|
stack?: Stack;
|
|
73
73
|
}>): Instance<$Registry>;
|
|
74
|
-
export { Omitted } from "./Types";
|
|
74
|
+
export { Omitted } from "./Types.ts";
|
|
75
75
|
/**
|
|
76
76
|
* Tags a `Salt` — for `new Fabricator(schema, { salt })`, or `fork`'s own
|
|
77
77
|
* `Overlay.salt` — as composing onto whatever base is in effect, rather than
|
|
78
78
|
* replacing it outright.
|
|
79
79
|
*/
|
|
80
|
-
export { layer } from "./Random";
|
|
80
|
+
export { layer } from "./Random/index.ts";
|
|
81
81
|
/**
|
|
82
82
|
* `layer(...)`'s return type, so a caller building one programmatically can
|
|
83
83
|
* name it — the same rationale as the existing `Salt` export.
|
|
84
84
|
*/
|
|
85
|
-
export type { Layered } from "./Random/Types";
|
|
85
|
+
export type { Layered } from "./Random/Types.ts";
|
|
86
86
|
/**
|
|
87
87
|
* Every failure this library raises is an instance of this class — see
|
|
88
88
|
* `src/Error/index.ts` for the full hierarchy. Every subclass is a member of
|
|
@@ -90,21 +90,28 @@ export type { Layered } from "./Random/Types";
|
|
|
90
90
|
* them: `e instanceof FabricatorError.InvalidOverrideValueError` works, and
|
|
91
91
|
* `.name` names the same failure.
|
|
92
92
|
*/
|
|
93
|
-
export { FabricatorError } from "./Error";
|
|
93
|
+
export { FabricatorError } from "./Error/index.ts";
|
|
94
94
|
/**
|
|
95
95
|
* The default registry of type definers, exported so it can be extended via
|
|
96
96
|
* `registry.extend(({ T }) => ({ ... }))` before being passed to `initialize({
|
|
97
97
|
* types })`.
|
|
98
98
|
*/
|
|
99
|
-
export { registry } from "./Schema/Registry";
|
|
99
|
+
export { registry } from "./Schema/Registry.ts";
|
|
100
100
|
/**
|
|
101
101
|
* Canonical `{ value, exclusive }` endpoint stored on `whereby` min/max, plus
|
|
102
102
|
* the call-site union that still accepts a scalar (inclusive). Exported so a
|
|
103
103
|
* named `.whereby(...)` argument or an `.adapt` producer reading `meta` can
|
|
104
104
|
* type it — the same rationale as `Stream`.
|
|
105
105
|
*/
|
|
106
|
-
export { effectiveDiscrete, toBound } from "./Bound";
|
|
107
|
-
export type { Bound, InputBound } from "./Bound";
|
|
106
|
+
export { effectiveDiscrete, toBound } from "./Bound.ts";
|
|
107
|
+
export type { Bound, InputBound } from "./Bound.ts";
|
|
108
|
+
/**
|
|
109
|
+
* What `.admits(...)` accepts for a group of ends, and how `[Meta].admits`
|
|
110
|
+
* stores it (an absent end states no limit). Exported so an argument built
|
|
111
|
+
* programmatically, or an `.adapt` producer reading `meta.admits`, can be typed
|
|
112
|
+
* — the same rationale as `Bound`.
|
|
113
|
+
*/
|
|
114
|
+
export type { AdmittedEnds, InputAdmittedEnds } from "./Bound.ts";
|
|
108
115
|
/**
|
|
109
116
|
* The `length` shapes `T.string`/`T.array`'s `.whereby(...)` accept and store,
|
|
110
117
|
* and the `distribution` every range-bearing `whereby` takes. Exported so a
|
|
@@ -114,8 +121,8 @@ export type { Bound, InputBound } from "./Bound";
|
|
|
114
121
|
* object (`{ kind: "skew", exponent: 4 }`), and the type's namespace members
|
|
115
122
|
* (`Distribution.Normal`, …) name each variant.
|
|
116
123
|
*/
|
|
117
|
-
export type { Distribution, Range } from "./Distribution";
|
|
118
|
-
export type { InputLength, Length } from "./Bound";
|
|
124
|
+
export type { Distribution, Range } from "./Distribution/index.ts";
|
|
125
|
+
export type { InputLength, Length } from "./Bound.ts";
|
|
119
126
|
/**
|
|
120
127
|
* `T.string`'s `composition` vocabulary: the class-weighting and `[weight,
|
|
121
128
|
* source]` forms, and the sources the second form draws from. `classes` holds
|
|
@@ -123,14 +130,14 @@ export type { InputLength, Length } from "./Bound";
|
|
|
123
130
|
* class with an arbitrary range (`[[3, classes.lowercase], [1, unicode.bmp]]`);
|
|
124
131
|
* `unicode` holds codespace presets and `range(from, to)`.
|
|
125
132
|
*/
|
|
126
|
-
export type { CharacterClass, CharacterSource, CodepointRange, Composition, } from "./Primitive/string/Types";
|
|
127
|
-
export { classes, unicode } from "./Primitive/string/Constants";
|
|
133
|
+
export type { CharacterClass, CharacterSource, CodepointRange, Composition, } from "./Primitive/string/Types.ts";
|
|
134
|
+
export { classes, unicode } from "./Primitive/string/Constants.ts";
|
|
128
135
|
/**
|
|
129
136
|
* Public because it is the type of `ProduceContext`'s `random` member — the
|
|
130
137
|
* seeded stream every kind's `.as(produce)` and `T.opaque`'s producer are
|
|
131
138
|
* handed — so a caller writing either as a named function can name it.
|
|
132
139
|
*/
|
|
133
|
-
export type { Stream } from "./Random/Types";
|
|
140
|
+
export type { Stream } from "./Random/Types.ts";
|
|
134
141
|
/**
|
|
135
142
|
* Uniform pick and Fisher–Yates shuffle over a caller-held list, each taking
|
|
136
143
|
* the `Stream` a producer is already handed. Exported so a caller writing
|
|
@@ -139,14 +146,14 @@ export type { Stream } from "./Random/Types";
|
|
|
139
146
|
* `T.enum` when the pick can be a schema: it is enumerable and path-keyed;
|
|
140
147
|
* these helpers are for the cases that cannot.
|
|
141
148
|
*/
|
|
142
|
-
export { sample, shuffle } from "./Distribution";
|
|
149
|
+
export { sample, shuffle } from "./Distribution/index.ts";
|
|
143
150
|
/**
|
|
144
151
|
* What every kind's `.as(produce)` producer is called with — a single curated
|
|
145
152
|
* object rather than a positional argument list, so a caller writing the
|
|
146
153
|
* producer as a named function can name its parameter. `T.opaque`'s producer
|
|
147
154
|
* takes the same shape.
|
|
148
155
|
*/
|
|
149
|
-
export type { ProduceContext } from "./Random/Types";
|
|
156
|
+
export type { ProduceContext } from "./Random/Types.ts";
|
|
150
157
|
/**
|
|
151
158
|
* What every kind's `.adapt(adapter, produce)` producer is called with — `{
|
|
152
159
|
* schema, meta }` — the same rationale as `Stream`/`ProduceContext` above: a
|
|
@@ -158,24 +165,24 @@ export type { ProduceContext } from "./Random/Types";
|
|
|
158
165
|
* `AdaptationsOf`, `Recurse`) is exported from `@ghostry/fabricator/adapting`
|
|
159
166
|
* instead — surface for implementing an adapter, not for calling `.adapt()`.
|
|
160
167
|
*/
|
|
161
|
-
export type { Adapting } from "./Adapter/Types";
|
|
168
|
+
export type { Adapting } from "./Adapter/Types.ts";
|
|
162
169
|
/**
|
|
163
170
|
* The shape `initialize({ salt })` and `new Fabricator(schema, { salt })` both
|
|
164
171
|
* accept — a single string, or several — so a caller building one
|
|
165
172
|
* programmatically (rather than as an inline literal) can name the type.
|
|
166
173
|
*/
|
|
167
|
-
export type { Salt } from "./Random/Types";
|
|
174
|
+
export type { Salt } from "./Random/Types.ts";
|
|
168
175
|
/**
|
|
169
176
|
* The shape that `initialize({ algorithm })` accepts — a seed in, a `[0, 1)`
|
|
170
177
|
* generator out.
|
|
171
178
|
*/
|
|
172
|
-
export type { Algorithm } from "./Random/Types";
|
|
179
|
+
export type { Algorithm } from "./Random/Types.ts";
|
|
173
180
|
/**
|
|
174
181
|
* Reads the value type a Schema produces, via its phantom `[Produces]` marker —
|
|
175
182
|
* before it is built, which is what a helper accepting a Schema needs — or the
|
|
176
183
|
* value type a built Fabricator produces, off its `fabricate` signature.
|
|
177
184
|
*/
|
|
178
|
-
export type { Fabricated } from "./Schema/Types";
|
|
185
|
+
export type { Fabricated } from "./Schema/Types.ts";
|
|
179
186
|
/**
|
|
180
187
|
* Check that a Schema or built Fabricator produces a value assignable to a
|
|
181
188
|
* supplied type — `.satisfies<T>()` on every kind's Schema is the main form;
|
|
@@ -183,13 +190,13 @@ export type { Fabricated } from "./Schema/Types";
|
|
|
183
190
|
* caller does not want to edit. `SatisfiedBy` is the type-only equivalent. See
|
|
184
191
|
* `Schema/Satisfies.ts`.
|
|
185
192
|
*/
|
|
186
|
-
export { satisfies } from "./Schema/Satisfies";
|
|
187
|
-
export type { SatisfiedBy } from "./Schema/Satisfies";
|
|
193
|
+
export { satisfies } from "./Schema/Satisfies.ts";
|
|
194
|
+
export type { SatisfiedBy } from "./Schema/Satisfies.ts";
|
|
188
195
|
/**
|
|
189
196
|
* `fabricator.trace`'s type — otherwise unnameable by a caller wanting to hold
|
|
190
197
|
* onto one, the same reason `Stream` is exported above.
|
|
191
198
|
*/
|
|
192
|
-
export type { Trace } from "./Random/Types";
|
|
199
|
+
export type { Trace } from "./Random/Types.ts";
|
|
193
200
|
/**
|
|
194
201
|
* `fork`/`wrap`'s own config shapes, so a caller building an overlay
|
|
195
202
|
* programmatically (rather than as an inline literal) can name them — the same
|
|
@@ -204,4 +211,10 @@ export type { Trace } from "./Random/Types";
|
|
|
204
211
|
* and the ordinary "same lineage?" question is `a.root === b.root` rather than
|
|
205
212
|
* anything a caller needs to name.
|
|
206
213
|
*/
|
|
207
|
-
export type { Ancestry, Config, Context, Overlay, Stack, } from "./Instance/Types";
|
|
214
|
+
export type { Ancestry, Config, Context, Overlay, Stack, } from "./Instance/Types.ts";
|
|
215
|
+
/**
|
|
216
|
+
* `capacity`'s type, and what `combinatorial`/`coverage` return, so a caller
|
|
217
|
+
* holding either can name it.
|
|
218
|
+
*/
|
|
219
|
+
export type { Capacity } from "./Unique/Capacity.ts";
|
|
220
|
+
export type { Enumeration } from "./Enumeration/Types.ts";
|
package/dist/types/internal.d.ts
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
* (re-exported here as `Primitive`), or no adapter can reach that kind's `Core`
|
|
20
20
|
* type.
|
|
21
21
|
*/
|
|
22
|
-
export type { Fabrication, NaiveFabricator } from "./Fabricator/Types";
|
|
22
|
+
export type { Fabrication, NaiveFabricator } from "./Fabricator/Types.ts";
|
|
23
23
|
/**
|
|
24
24
|
* Schema -> the Fabricator type `construct()` produces for it, dispatching per
|
|
25
25
|
* kind. `Constructor` already names this as its own construct signature's
|
|
@@ -34,7 +34,7 @@ export type { Fabrication, NaiveFabricator } from "./Fabricator/Types";
|
|
|
34
34
|
* type is exactly this. Without it, an integration is pushed into hand-writing
|
|
35
35
|
* a per-kind stand-in — a second copy of this mapping, susceptible to drift.
|
|
36
36
|
*/
|
|
37
|
-
export type { AsFabricator } from "./Fabricator/Types";
|
|
37
|
+
export type { AsFabricator } from "./Fabricator/Types.ts";
|
|
38
38
|
/**
|
|
39
39
|
* `Produced` travels with `Produces`: `[Produces]` holds a Schema's value type
|
|
40
40
|
* boxed, so anything outside this package that matches or infers through the
|
|
@@ -42,8 +42,8 @@ export type { AsFabricator } from "./Fabricator/Types";
|
|
|
42
42
|
* `Types.ts` for why an unboxed `{ readonly [Produces]?: $T }` cannot be read
|
|
43
43
|
* exactly.
|
|
44
44
|
*/
|
|
45
|
-
export { Children, Kind, Meta, Produces, type Buildable, type Produced, } from "./Types";
|
|
46
|
-
export { isArray, isPlainObject } from "./Utility/Core";
|
|
45
|
+
export { Children, Kind, Meta, Produces, type Buildable, type Produced, } from "./Types.ts";
|
|
46
|
+
export { isArray, isPlainObject } from "./Utility/Core.ts";
|
|
47
47
|
/**
|
|
48
48
|
* The runtime counterparts of `Buildable` and `AnySchema`, for an integration
|
|
49
49
|
* that takes one from an untyped caller. `@ghostry/extern`'s fabricator
|
|
@@ -51,41 +51,42 @@ export { isArray, isPlainObject } from "./Utility/Core";
|
|
|
51
51
|
* an identity, since a block could either continue its streams or build afresh
|
|
52
52
|
* from its schema.
|
|
53
53
|
*/
|
|
54
|
-
export { isBuildable, isSchema } from "./Schema/Core";
|
|
55
|
-
export type
|
|
54
|
+
export { isBuildable, isSchema } from "./Schema/Core.ts";
|
|
55
|
+
export { toKeyer, type Keyer } from "./Unique/Key.ts";
|
|
56
|
+
export type * as Primitive from "./Primitive/namespace.ts";
|
|
56
57
|
/**
|
|
57
58
|
* `Schema/Types.ts`'s own value-type resolution, needed by tests asserting
|
|
58
59
|
* `Fabricated<...>` directly rather than through a built Fabricator's
|
|
59
60
|
* `Fabrication<...>`.
|
|
60
61
|
*/
|
|
61
|
-
export type { Fabricated } from "./Schema/Types";
|
|
62
|
+
export type { Fabricated } from "./Schema/Types.ts";
|
|
62
63
|
/**
|
|
63
64
|
* `Constructor` is `Instance.Fabricator`'s own type — public in effect (every
|
|
64
65
|
* `initialize()` caller receives one), just never named directly by the `.`
|
|
65
66
|
* export, which only ever describes it inline.
|
|
66
67
|
*/
|
|
67
|
-
export type { Constructor } from "./Fabricator/Constructor";
|
|
68
|
+
export type { Constructor } from "./Fabricator/Constructor.ts";
|
|
68
69
|
/**
|
|
69
70
|
* The enumeration planner's own shapes — `combinatorial`/`coverage` (the `.`
|
|
70
71
|
* export's public entry points) are built on `plan`/`resolve`, which a test
|
|
71
72
|
* asserting `axisFor`'s per-kind width/strategy decisions needs directly.
|
|
72
73
|
*/
|
|
73
|
-
export { plan, resolve } from "./Enumeration/Plan";
|
|
74
|
-
export type { Axis, Enumerable, Pin, Resolvable } from "./Enumeration/Types";
|
|
74
|
+
export { plan, resolve } from "./Enumeration/Plan.ts";
|
|
75
|
+
export type { Axis, Enumerable, Pin, Resolvable } from "./Enumeration/Types.ts";
|
|
75
76
|
/**
|
|
76
77
|
* The randomness layer underneath `initialize({ clock, salt, algorithm })` and
|
|
77
78
|
* a Fabricator's `.trace` — needed by tests exercising stream construction
|
|
78
79
|
* directly, beneath the level `initialize()` itself exposes.
|
|
79
80
|
*/
|
|
80
|
-
export { defaultAlgorithm, encode, randomSalt, toRandomSource, toStream, toStreamFromTrace, } from "./Random";
|
|
81
|
-
export type { Algorithm, ConstructionPins, ConstructionTrace, ConstructorOptions, Salt, Trace, } from "./Random/Types";
|
|
81
|
+
export { defaultAlgorithm, encode, randomSalt, toRandomSource, toStream, toStreamFromTrace, } from "./Random/index.ts";
|
|
82
|
+
export type { Algorithm, ConstructionPins, ConstructionTrace, ConstructorOptions, Salt, Trace, } from "./Random/Types.ts";
|
|
82
83
|
/**
|
|
83
84
|
* The shared index-selection draw every weighted kind (`enum`, `choice`,
|
|
84
85
|
* `boolean`, the presence wrappers) reaches through construction — exported so
|
|
85
86
|
* a test can measure its distribution against a raw stream, without a kind's
|
|
86
87
|
* registry guards or `.fabricate()` in between.
|
|
87
88
|
*/
|
|
88
|
-
export { weighted } from "./Distribution";
|
|
89
|
+
export { weighted } from "./Distribution/index.ts";
|
|
89
90
|
/**
|
|
90
91
|
* The normal CDF the `normal` distribution's truncation is computed with. The
|
|
91
92
|
* docs site's distribution explorer draws each variant's exact density, and a
|
|
@@ -98,7 +99,7 @@ export { weighted } from "./Distribution";
|
|
|
98
99
|
* against the exact curve fabrication will draw from, rather than against a
|
|
99
100
|
* second approximation that could disagree with it in the tails.
|
|
100
101
|
*/
|
|
101
|
-
export { normalCdf, normalInv } from "./Distribution";
|
|
102
|
+
export { normalCdf, normalInv } from "./Distribution/index.ts";
|
|
102
103
|
/**
|
|
103
104
|
* The synchronous ambient carrier. `#stack` (`package.json`) selects it only
|
|
104
105
|
* where there is no `node:async_hooks` — in practice a browser bundle — so on
|
|
@@ -109,4 +110,4 @@ export { normalCdf, normalInv } from "./Distribution";
|
|
|
109
110
|
* serviceable argument for `initialize({ stack })` for anyone who wants the old
|
|
110
111
|
* semantics back deliberately.
|
|
111
112
|
*/
|
|
112
|
-
export { toStack as toSynchronousStack } from "./Instance/Stack/Sync";
|
|
113
|
+
export { toStack as toSynchronousStack } from "./Instance/Stack/Sync.ts";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ghostry/fabricator",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.15",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Fabricate typed data from composable schemas.",
|
|
6
6
|
"keywords": [
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"provenance": true
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
|
-
"@ghostry/harness": "^0.0.
|
|
68
|
+
"@ghostry/harness": "^0.0.7"
|
|
69
69
|
},
|
|
70
70
|
"scripts": {
|
|
71
71
|
"build:reset": "rm -rf ./dist",
|