@ghostry/fabricator 0.0.7 → 0.0.9
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 +6 -1
- package/dist/esm/Distribution/index.js +10 -1
- package/dist/esm/Enumeration/Plan.js +16 -0
- package/dist/esm/Error/index.js +8 -0
- package/dist/esm/Fabricator/Constructor.js +13 -0
- package/dist/esm/Instance/Core.js +8 -8
- package/dist/esm/Primitive/always/Schema.js +2 -0
- package/dist/esm/Primitive/array/Fabricator.js +4 -9
- package/dist/esm/Primitive/array/Schema.js +2 -0
- package/dist/esm/Primitive/bigint/Schema.js +2 -0
- package/dist/esm/Primitive/boolean/Schema.js +2 -0
- package/dist/esm/Primitive/choice/Schema.js +2 -0
- package/dist/esm/Primitive/date/Schema.js +2 -0
- package/dist/esm/Primitive/derive/Fabricator.js +31 -0
- package/dist/esm/Primitive/derive/Registry.js +17 -0
- package/dist/esm/Primitive/derive/Schema.js +12 -0
- package/dist/esm/Primitive/derive/Types.js +1 -0
- package/dist/esm/Primitive/derive/index.js +5 -0
- package/dist/esm/Primitive/enum/Schema.js +2 -0
- package/dist/esm/Primitive/index.js +1 -0
- package/dist/esm/Primitive/namespace.js +2 -1
- package/dist/esm/Primitive/null/Schema.js +2 -0
- package/dist/esm/Primitive/nullable/Schema.js +2 -0
- package/dist/esm/Primitive/nullish/Schema.js +2 -0
- package/dist/esm/Primitive/number/Fabricator.js +3 -7
- package/dist/esm/Primitive/number/Schema.js +2 -0
- package/dist/esm/Primitive/object/Registry.js +8 -8
- package/dist/esm/Primitive/object/Schema.js +3 -1
- package/dist/esm/Primitive/object/compute/Schema.js +2 -0
- package/dist/esm/Primitive/object/omittable/Schema.js +2 -0
- package/dist/esm/Primitive/object/optional/Schema.js +2 -0
- package/dist/esm/Primitive/opaque/Schema.js +2 -0
- package/dist/esm/Primitive/record/Fabricator.js +6 -1
- package/dist/esm/Primitive/record/Schema.js +2 -0
- package/dist/esm/Primitive/recursive/Schema.js +2 -0
- package/dist/esm/Primitive/recursive/Terminate.js +17 -0
- package/dist/esm/Primitive/recursive/self/Schema.js +2 -0
- package/dist/esm/Primitive/string/Fabricator.js +6 -2
- package/dist/esm/Primitive/string/Schema.js +2 -0
- package/dist/esm/Primitive/symbol/Schema.js +2 -0
- package/dist/esm/Primitive/tuple/Schema.js +2 -0
- package/dist/esm/Primitive/undefinable/Schema.js +2 -0
- package/dist/esm/Primitive/undefined/Schema.js +2 -0
- package/dist/esm/Schema/Core.js +13 -1
- package/dist/esm/Schema/Satisfies.js +5 -0
- package/dist/esm/index.js +2 -0
- package/dist/types/Bound.d.ts +20 -4
- package/dist/types/Distribution/index.d.ts +19 -0
- package/dist/types/Enumeration/Types.d.ts +4 -3
- package/dist/types/Error/index.d.ts +37 -7
- package/dist/types/Fabricator/Types.d.ts +1 -1
- package/dist/types/Harnessing/Core.d.ts +4 -4
- package/dist/types/Primitive/always/Schema.d.ts +8 -1
- package/dist/types/Primitive/array/Registry.d.ts +7 -5
- package/dist/types/Primitive/array/Schema.d.ts +7 -0
- package/dist/types/Primitive/array/Types.d.ts +3 -9
- package/dist/types/Primitive/bigint/Schema.d.ts +7 -0
- package/dist/types/Primitive/boolean/Schema.d.ts +7 -0
- package/dist/types/Primitive/choice/Registry.d.ts +16 -6
- package/dist/types/Primitive/choice/Schema.d.ts +7 -0
- package/dist/types/Primitive/date/Schema.d.ts +7 -0
- package/dist/types/Primitive/derive/Fabricator.d.ts +44 -0
- package/dist/types/Primitive/derive/Registry.d.ts +6 -0
- package/dist/types/Primitive/derive/Schema.d.ts +44 -0
- package/dist/types/Primitive/derive/Types.d.ts +38 -0
- package/dist/types/Primitive/derive/index.d.ts +5 -0
- package/dist/types/Primitive/enum/Registry.d.ts +19 -9
- package/dist/types/Primitive/enum/Schema.d.ts +7 -0
- package/dist/types/Primitive/index.d.ts +3 -2
- package/dist/types/Primitive/namespace.d.ts +1 -0
- package/dist/types/Primitive/null/Schema.d.ts +9 -2
- package/dist/types/Primitive/nullable/Schema.d.ts +7 -0
- package/dist/types/Primitive/nullish/Schema.d.ts +7 -0
- package/dist/types/Primitive/number/Schema.d.ts +7 -0
- package/dist/types/Primitive/object/Schema.d.ts +12 -2
- package/dist/types/Primitive/object/compute/Schema.d.ts +8 -0
- package/dist/types/Primitive/object/omittable/Schema.d.ts +10 -1
- package/dist/types/Primitive/object/optional/Schema.d.ts +9 -1
- package/dist/types/Primitive/opaque/Schema.d.ts +8 -1
- package/dist/types/Primitive/record/Schema.d.ts +7 -0
- package/dist/types/Primitive/record/Types.d.ts +2 -2
- package/dist/types/Primitive/recursive/Schema.d.ts +8 -1
- package/dist/types/Primitive/recursive/self/Schema.d.ts +11 -1
- package/dist/types/Primitive/string/Registry.d.ts +13 -9
- package/dist/types/Primitive/string/Schema.d.ts +7 -0
- package/dist/types/Primitive/string/Types.d.ts +7 -11
- package/dist/types/Primitive/symbol/Schema.d.ts +7 -0
- package/dist/types/Primitive/tuple/Schema.d.ts +7 -0
- package/dist/types/Primitive/undefinable/Schema.d.ts +7 -0
- package/dist/types/Primitive/undefined/Schema.d.ts +9 -2
- package/dist/types/Schema/Core.d.ts +13 -0
- package/dist/types/Schema/Satisfies.d.ts +84 -0
- package/dist/types/Schema/Types.d.ts +17 -1
- package/dist/types/Types.d.ts +4 -3
- package/dist/types/index.d.ts +18 -0
- package/package.json +1 -1
package/dist/esm/Bound.js
CHANGED
|
@@ -76,6 +76,11 @@ function toLengthRange(length, label) {
|
|
|
76
76
|
max: toBound(length.max)
|
|
77
77
|
};
|
|
78
78
|
assertNonemptyDiscrete(label, range.min, range.max);
|
|
79
|
-
return range;
|
|
79
|
+
if ("number" == typeof length || void 0 === length.distribution) return range;
|
|
80
|
+
return {
|
|
81
|
+
min: range.min,
|
|
82
|
+
max: range.max,
|
|
83
|
+
distribution: length.distribution
|
|
84
|
+
};
|
|
80
85
|
}
|
|
81
86
|
export { assertNonemptyContinuous, assertNonemptyDiscrete, assertNonemptyDiscreteBigint, constrainContinuous, effectiveDiscrete, effectiveDiscreteBigint, epochBound, toBound, toLengthRange, towardInterior };
|
|
@@ -42,6 +42,14 @@ function unitPosition(x, min, max) {
|
|
|
42
42
|
if (!Number.isFinite(ratio)) return 0;
|
|
43
43
|
return 1 / (1 + ratio);
|
|
44
44
|
}
|
|
45
|
+
function discreteSampler(distribution, range, stream) {
|
|
46
|
+
const { min, max } = range;
|
|
47
|
+
const draw = sampler(null != distribution ? distribution : Distribution_Distribution.uniform(), {
|
|
48
|
+
min,
|
|
49
|
+
max: max + 1
|
|
50
|
+
}, stream);
|
|
51
|
+
return ()=>Math.min(max, Math.floor(draw()));
|
|
52
|
+
}
|
|
45
53
|
function sampler(distribution, range, stream) {
|
|
46
54
|
const { min, max } = range;
|
|
47
55
|
const span = max - min;
|
|
@@ -135,6 +143,7 @@ function normalInv(p) {
|
|
|
135
143
|
return -(((((-0.007784894002430293 * q - 3.223964580411365e-1) * q - 2.400758277161838) * q - 2.549732539343734) * q + 4.374664141464968) * q + 2.938163982698783) / ((((7.784695709041462e-3 * q + 3.224671290700398e-1) * q + 2.445134137142996) * q + 3.754408661907416) * q + 1);
|
|
136
144
|
}
|
|
137
145
|
function sample(list, stream) {
|
|
146
|
+
if (0 === list.length) throw new FabricatorError.EmptyItemsError("sample", "item");
|
|
138
147
|
const index = Math.floor(stream.next() * list.length);
|
|
139
148
|
const item = list[index];
|
|
140
149
|
return item;
|
|
@@ -197,4 +206,4 @@ function weighted(weights, stream, label) {
|
|
|
197
206
|
};
|
|
198
207
|
}
|
|
199
208
|
var Distribution_Distribution;
|
|
200
|
-
export { Distribution_Distribution as Distribution, assertDrawableKeyedWeights, assertDrawableWeights, drawableOutcomes, isDrawable, isValidWeight, sample, sampler, shuffle, weighted };
|
|
209
|
+
export { Distribution_Distribution as Distribution, assertDrawableKeyedWeights, assertDrawableWeights, discreteSampler, drawableOutcomes, isDrawable, isValidWeight, sample, sampler, shuffle, weighted };
|
|
@@ -186,6 +186,14 @@ function axisFor(node, planning) {
|
|
|
186
186
|
slots
|
|
187
187
|
}));
|
|
188
188
|
}
|
|
189
|
+
case "derive":
|
|
190
|
+
{
|
|
191
|
+
const from = node[Children];
|
|
192
|
+
const axes = from.map((slot)=>plan(slot, planning));
|
|
193
|
+
return productAxis(planning.strategy, axes, (slots)=>({
|
|
194
|
+
slots
|
|
195
|
+
}));
|
|
196
|
+
}
|
|
189
197
|
case "object":
|
|
190
198
|
{
|
|
191
199
|
const definition = node[Meta].definition;
|
|
@@ -271,6 +279,14 @@ function resolve(node, pin) {
|
|
|
271
279
|
const elements = node[Children];
|
|
272
280
|
return elements.map((element, i)=>resolve(element, p.slots[i]));
|
|
273
281
|
}
|
|
282
|
+
case "derive":
|
|
283
|
+
{
|
|
284
|
+
const p = pin;
|
|
285
|
+
const from = node[Children];
|
|
286
|
+
return node.fabricate({
|
|
287
|
+
from: from.map((slot, i)=>resolve(slot, p.slots[i]))
|
|
288
|
+
});
|
|
289
|
+
}
|
|
274
290
|
case "object":
|
|
275
291
|
{
|
|
276
292
|
const p = pin;
|
package/dist/esm/Error/index.js
CHANGED
|
@@ -88,6 +88,14 @@ class Error_FabricatorError extends Error {
|
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
FabricatorError.ComputeResultMismatchError = ComputeResultMismatchError;
|
|
91
|
+
class DeriveResultMismatchError extends FabricatorError {
|
|
92
|
+
constructor(kind, value){
|
|
93
|
+
super(), _define_property(this, "kind", void 0), _define_property(this, "value", void 0), this.kind = kind, this.value = value;
|
|
94
|
+
this.name = "DeriveResultMismatchError";
|
|
95
|
+
this.message = `A T.derive resolver returned a value of type ${typeof value} that does not match its \`to\` schema ("${kind}").`;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
FabricatorError.DeriveResultMismatchError = DeriveResultMismatchError;
|
|
91
99
|
class UnknownOverrideFieldError extends FabricatorError {
|
|
92
100
|
constructor(field, available){
|
|
93
101
|
super(), _define_property(this, "field", void 0), _define_property(this, "available", void 0), this.field = field, this.available = available;
|
|
@@ -209,6 +209,19 @@ function Constructor(source, stack, ancestry) {
|
|
|
209
209
|
schema: s
|
|
210
210
|
}, elements);
|
|
211
211
|
}
|
|
212
|
+
case "derive":
|
|
213
|
+
{
|
|
214
|
+
const s = schema;
|
|
215
|
+
const from = s[Meta].from.map((item, i)=>make(item, [
|
|
216
|
+
...path,
|
|
217
|
+
"from",
|
|
218
|
+
i.toString(10)
|
|
219
|
+
], context));
|
|
220
|
+
return Primitive.derive.Fabricator({
|
|
221
|
+
...common,
|
|
222
|
+
schema: s
|
|
223
|
+
}, from);
|
|
224
|
+
}
|
|
212
225
|
case "object.compute":
|
|
213
226
|
{
|
|
214
227
|
const s = schema;
|
|
@@ -96,14 +96,14 @@ function instantiate(config, stack, parent) {
|
|
|
96
96
|
return normalizeSalt((null != (_ref = null == (_visibleFrame = visibleFrame()) ? void 0 : _visibleFrame.config) ? _ref : config).salt);
|
|
97
97
|
},
|
|
98
98
|
get algorithm () {
|
|
99
|
-
var
|
|
100
|
-
var
|
|
101
|
-
return (null != (
|
|
99
|
+
var _ref;
|
|
100
|
+
var _visibleFrame;
|
|
101
|
+
return (null != (_ref = null == (_visibleFrame = visibleFrame()) ? void 0 : _visibleFrame.config) ? _ref : config).algorithm;
|
|
102
102
|
},
|
|
103
103
|
get clock () {
|
|
104
|
-
var
|
|
105
|
-
var
|
|
106
|
-
return resolveClock(null != (
|
|
104
|
+
var _ref;
|
|
105
|
+
var _visibleFrame;
|
|
106
|
+
return resolveClock(null != (_ref = null == (_visibleFrame = visibleFrame()) ? void 0 : _visibleFrame.config) ? _ref : config);
|
|
107
107
|
},
|
|
108
108
|
scope: ()=>{
|
|
109
109
|
var _ref;
|
|
@@ -118,8 +118,8 @@ function instantiate(config, stack, parent) {
|
|
|
118
118
|
T: config.types,
|
|
119
119
|
ancestry,
|
|
120
120
|
get root () {
|
|
121
|
-
var
|
|
122
|
-
return null != (
|
|
121
|
+
var _ref;
|
|
122
|
+
return null != (_ref = null == parent ? void 0 : parent.root) ? _ref : instance;
|
|
123
123
|
},
|
|
124
124
|
Fabricator,
|
|
125
125
|
combinatorial,
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { withAdaptations } from "../../Adapter/Core.js";
|
|
2
|
+
import { schemaSatisfies } from "../../Schema/Satisfies.js";
|
|
2
3
|
import { Kind } from "../../Types.js";
|
|
3
4
|
function Schema(schema) {
|
|
4
5
|
return {
|
|
5
6
|
...schema,
|
|
6
7
|
[Kind]: "always",
|
|
8
|
+
satisfies: schemaSatisfies,
|
|
7
9
|
adapt: (adapter, produce)=>Schema(withAdaptations(schema, adapter, produce))
|
|
8
10
|
};
|
|
9
11
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { effectiveDiscrete } from "../../Bound.js";
|
|
2
|
+
import { discreteSampler } from "../../Distribution/index.js";
|
|
2
3
|
import { toStreamFromTrace } from "../../Random/index.js";
|
|
3
4
|
import { Children, Kind, Meta } from "../../Types.js";
|
|
4
|
-
import { inline } from "../../Utility/Core.js";
|
|
5
5
|
import { Schema } from "./Schema.js";
|
|
6
6
|
function Fabricator(context, element) {
|
|
7
7
|
const { schema, algorithm, trace } = context;
|
|
@@ -24,15 +24,10 @@ function Fabricator(context, element) {
|
|
|
24
24
|
}
|
|
25
25
|
const stream = toStreamFromTrace(algorithm, trace);
|
|
26
26
|
const whereby = meta.whereby;
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
return min + Math.floor(stream.next() * (max - min + 1));
|
|
31
|
-
});
|
|
32
|
-
return Array.from({
|
|
33
|
-
length
|
|
27
|
+
const drawLength = discreteSampler(whereby.length.distribution, effectiveDiscrete(whereby.length.min, whereby.length.max), stream);
|
|
28
|
+
const fabricate = ()=>Array.from({
|
|
29
|
+
length: drawLength()
|
|
34
30
|
}, ()=>element.fabricate());
|
|
35
|
-
};
|
|
36
31
|
return {
|
|
37
32
|
[Kind]: "array",
|
|
38
33
|
[Meta]: meta,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { withAdaptations } from "../../Adapter/Core.js";
|
|
2
|
+
import { schemaSatisfies } from "../../Schema/Satisfies.js";
|
|
2
3
|
import { Kind, Meta } from "../../Types.js";
|
|
3
4
|
function Schema(schema) {
|
|
4
5
|
return {
|
|
@@ -11,6 +12,7 @@ function Schema(schema) {
|
|
|
11
12
|
produce
|
|
12
13
|
}
|
|
13
14
|
}),
|
|
15
|
+
satisfies: schemaSatisfies,
|
|
14
16
|
adapt: (adapter, produce)=>Schema(withAdaptations(schema, adapter, produce))
|
|
15
17
|
};
|
|
16
18
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { withAdaptations } from "../../Adapter/Core.js";
|
|
2
|
+
import { schemaSatisfies } from "../../Schema/Satisfies.js";
|
|
2
3
|
import { Kind, Meta } from "../../Types.js";
|
|
3
4
|
function Schema(schema) {
|
|
4
5
|
return {
|
|
@@ -11,6 +12,7 @@ function Schema(schema) {
|
|
|
11
12
|
produce
|
|
12
13
|
}
|
|
13
14
|
}),
|
|
15
|
+
satisfies: schemaSatisfies,
|
|
14
16
|
adapt: (adapter, produce)=>Schema(withAdaptations(schema, adapter, produce))
|
|
15
17
|
};
|
|
16
18
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { withAdaptations } from "../../Adapter/Core.js";
|
|
2
2
|
import { assertDrawableKeyedWeights } from "../../Distribution/index.js";
|
|
3
|
+
import { schemaSatisfies } from "../../Schema/Satisfies.js";
|
|
3
4
|
import { Kind, Meta } from "../../Types.js";
|
|
4
5
|
import { outcomes } from "./Outcomes.js";
|
|
5
6
|
function Schema(schema) {
|
|
@@ -13,6 +14,7 @@ function Schema(schema) {
|
|
|
13
14
|
produce
|
|
14
15
|
}
|
|
15
16
|
}),
|
|
17
|
+
satisfies: schemaSatisfies,
|
|
16
18
|
weighted: (weights)=>{
|
|
17
19
|
const merged = {
|
|
18
20
|
...schema[Meta].weights,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { withAdaptations } from "../../Adapter/Core.js";
|
|
2
|
+
import { schemaSatisfies } from "../../Schema/Satisfies.js";
|
|
2
3
|
import { Kind, Meta } from "../../Types.js";
|
|
3
4
|
function Schema(schema) {
|
|
4
5
|
return {
|
|
@@ -11,6 +12,7 @@ function Schema(schema) {
|
|
|
11
12
|
produce
|
|
12
13
|
}
|
|
13
14
|
}),
|
|
15
|
+
satisfies: schemaSatisfies,
|
|
14
16
|
adapt: (adapter, produce)=>Schema(withAdaptations(schema, adapter, produce))
|
|
15
17
|
};
|
|
16
18
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { withAdaptations } from "../../Adapter/Core.js";
|
|
2
|
+
import { schemaSatisfies } from "../../Schema/Satisfies.js";
|
|
2
3
|
import { Kind, Meta } from "../../Types.js";
|
|
3
4
|
function Schema(schema) {
|
|
4
5
|
return {
|
|
@@ -11,6 +12,7 @@ function Schema(schema) {
|
|
|
11
12
|
produce
|
|
12
13
|
}
|
|
13
14
|
}),
|
|
15
|
+
satisfies: schemaSatisfies,
|
|
14
16
|
adapt: (adapter, produce)=>Schema(withAdaptations(schema, adapter, produce))
|
|
15
17
|
};
|
|
16
18
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { FabricatorError } from "../../Error/index.js";
|
|
2
|
+
import { toStreamFromTrace } from "../../Random/index.js";
|
|
3
|
+
import { toValueKind, violatesKind } from "../../Schema/Core.js";
|
|
4
|
+
import { Children, Kind, Meta } from "../../Types.js";
|
|
5
|
+
import { Schema } from "./Schema.js";
|
|
6
|
+
function Fabricator(context, from) {
|
|
7
|
+
const { schema, algorithm, trace } = context;
|
|
8
|
+
const meta = schema[Meta];
|
|
9
|
+
const rehydrated = Schema(schema);
|
|
10
|
+
const stream = toStreamFromTrace(algorithm, trace);
|
|
11
|
+
const resolve = meta.resolve;
|
|
12
|
+
const toKind = toValueKind(meta.to);
|
|
13
|
+
return {
|
|
14
|
+
[Kind]: "derive",
|
|
15
|
+
[Meta]: meta,
|
|
16
|
+
trace,
|
|
17
|
+
[Children]: from,
|
|
18
|
+
fabricate: (params)=>{
|
|
19
|
+
var _ref;
|
|
20
|
+
const values = null != (_ref = null == params ? void 0 : params.from) ? _ref : from.map((slot)=>slot.fabricate());
|
|
21
|
+
const result = resolve(values, {
|
|
22
|
+
random: stream,
|
|
23
|
+
clock: trace.clock
|
|
24
|
+
});
|
|
25
|
+
if (violatesKind(toKind, result)) throw new FabricatorError.DeriveResultMismatchError(toKind, result);
|
|
26
|
+
return result;
|
|
27
|
+
},
|
|
28
|
+
schema: rehydrated
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
export { Fabricator };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { toSchema } from "../../Schema/Core.js";
|
|
2
|
+
import { Kind, Meta } from "../../Types.js";
|
|
3
|
+
import { Schema } from "./Schema.js";
|
|
4
|
+
function Registry({ to, from }) {
|
|
5
|
+
const normalized = from.map((item)=>toSchema(item));
|
|
6
|
+
return {
|
|
7
|
+
as: (resolve)=>Schema({
|
|
8
|
+
[Kind]: "derive",
|
|
9
|
+
[Meta]: {
|
|
10
|
+
from: normalized,
|
|
11
|
+
to,
|
|
12
|
+
resolve
|
|
13
|
+
}
|
|
14
|
+
})
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export default Registry;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { withAdaptations } from "../../Adapter/Core.js";
|
|
2
|
+
import { schemaSatisfies } from "../../Schema/Satisfies.js";
|
|
3
|
+
import { Kind } from "../../Types.js";
|
|
4
|
+
function Schema(schema) {
|
|
5
|
+
return {
|
|
6
|
+
...schema,
|
|
7
|
+
[Kind]: "derive",
|
|
8
|
+
satisfies: schemaSatisfies,
|
|
9
|
+
adapt: (adapter, produce)=>Schema(withAdaptations(schema, adapter, produce))
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export { Schema };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { withAdaptations } from "../../Adapter/Core.js";
|
|
2
|
+
import { schemaSatisfies } from "../../Schema/Satisfies.js";
|
|
2
3
|
import { Kind, Meta } from "../../Types.js";
|
|
3
4
|
function Schema(schema) {
|
|
4
5
|
return {
|
|
@@ -11,6 +12,7 @@ function Schema(schema) {
|
|
|
11
12
|
produce
|
|
12
13
|
}
|
|
13
14
|
}),
|
|
15
|
+
satisfies: schemaSatisfies,
|
|
14
16
|
adapt: (adapter, produce)=>Schema(withAdaptations(schema, adapter, produce))
|
|
15
17
|
};
|
|
16
18
|
}
|
|
@@ -5,6 +5,7 @@ export { default as bigint } from "./bigint/index.js";
|
|
|
5
5
|
export { default as boolean } from "./boolean/index.js";
|
|
6
6
|
export { default as choice } from "./choice/index.js";
|
|
7
7
|
export { default as date } from "./date/index.js";
|
|
8
|
+
export { default as derive } from "./derive/index.js";
|
|
8
9
|
export { default as enum } from "./enum/index.js";
|
|
9
10
|
export { default as null } from "./null/index.js";
|
|
10
11
|
export { default as nullable } from "./nullable/index.js";
|
|
@@ -4,6 +4,7 @@ import * as __rspack_external__bigint_index_js_adedcded from "./bigint/index.js"
|
|
|
4
4
|
import * as __rspack_external__boolean_index_js_0a69a391 from "./boolean/index.js";
|
|
5
5
|
import * as __rspack_external__choice_index_js_ce126df9 from "./choice/index.js";
|
|
6
6
|
import * as __rspack_external__date_index_js_99c830c9 from "./date/index.js";
|
|
7
|
+
import * as __rspack_external__derive_index_js_be41c87a from "./derive/index.js";
|
|
7
8
|
import * as __rspack_external__enum_index_js_39677e4c from "./enum/index.js";
|
|
8
9
|
import * as __rspack_external__null_index_js_b154bd62 from "./null/index.js";
|
|
9
10
|
import * as __rspack_external__nullable_index_js_a31c5679 from "./nullable/index.js";
|
|
@@ -18,4 +19,4 @@ import * as __rspack_external__symbol_index_js_65f53bf7 from "./symbol/index.js"
|
|
|
18
19
|
import * as __rspack_external__tuple_index_js_fe5f0f11 from "./tuple/index.js";
|
|
19
20
|
import * as __rspack_external__undefinable_index_js_01dfdeb8 from "./undefinable/index.js";
|
|
20
21
|
import * as __rspack_external__undefined_index_js_b61f9fc3 from "./undefined/index.js";
|
|
21
|
-
export { __rspack_external__always_index_js_5b7da93f as always, __rspack_external__array_index_js_e390953b as array, __rspack_external__bigint_index_js_adedcded as bigint, __rspack_external__boolean_index_js_0a69a391 as boolean, __rspack_external__choice_index_js_ce126df9 as choice, __rspack_external__date_index_js_99c830c9 as date, __rspack_external__enum_index_js_39677e4c as enum, __rspack_external__null_index_js_b154bd62 as null, __rspack_external__nullable_index_js_a31c5679 as nullable, __rspack_external__nullish_index_js_03ff6564 as nullish, __rspack_external__number_index_js_b8c783ea as number, __rspack_external__object_index_js_53384658 as object, __rspack_external__opaque_index_js_0795d628 as opaque, __rspack_external__record_index_js_120e2811 as record, __rspack_external__recursive_index_js_3c8bba6b as recursive, __rspack_external__string_index_js_18f2393a as string, __rspack_external__symbol_index_js_65f53bf7 as symbol, __rspack_external__tuple_index_js_fe5f0f11 as tuple, __rspack_external__undefinable_index_js_01dfdeb8 as undefinable, __rspack_external__undefined_index_js_b61f9fc3 as undefined };
|
|
22
|
+
export { __rspack_external__always_index_js_5b7da93f as always, __rspack_external__array_index_js_e390953b as array, __rspack_external__bigint_index_js_adedcded as bigint, __rspack_external__boolean_index_js_0a69a391 as boolean, __rspack_external__choice_index_js_ce126df9 as choice, __rspack_external__date_index_js_99c830c9 as date, __rspack_external__derive_index_js_be41c87a as derive, __rspack_external__enum_index_js_39677e4c as enum, __rspack_external__null_index_js_b154bd62 as null, __rspack_external__nullable_index_js_a31c5679 as nullable, __rspack_external__nullish_index_js_03ff6564 as nullish, __rspack_external__number_index_js_b8c783ea as number, __rspack_external__object_index_js_53384658 as object, __rspack_external__opaque_index_js_0795d628 as opaque, __rspack_external__record_index_js_120e2811 as record, __rspack_external__recursive_index_js_3c8bba6b as recursive, __rspack_external__string_index_js_18f2393a as string, __rspack_external__symbol_index_js_65f53bf7 as symbol, __rspack_external__tuple_index_js_fe5f0f11 as tuple, __rspack_external__undefinable_index_js_01dfdeb8 as undefinable, __rspack_external__undefined_index_js_b61f9fc3 as undefined };
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { withAdaptations } from "../../Adapter/Core.js";
|
|
2
|
+
import { schemaSatisfies } from "../../Schema/Satisfies.js";
|
|
2
3
|
import { Kind } from "../../Types.js";
|
|
3
4
|
function Schema(schema) {
|
|
4
5
|
return {
|
|
5
6
|
...schema,
|
|
6
7
|
[Kind]: "null",
|
|
8
|
+
satisfies: schemaSatisfies,
|
|
7
9
|
adapt: (adapter, produce)=>Schema(withAdaptations(schema, adapter, produce))
|
|
8
10
|
};
|
|
9
11
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { withAdaptations } from "../../Adapter/Core.js";
|
|
2
2
|
import { assertDrawableKeyedWeights } from "../../Distribution/index.js";
|
|
3
|
+
import { schemaSatisfies } from "../../Schema/Satisfies.js";
|
|
3
4
|
import { Kind, Meta } from "../../Types.js";
|
|
4
5
|
import { outcomes } from "./Outcomes.js";
|
|
5
6
|
function Schema(schema) {
|
|
@@ -13,6 +14,7 @@ function Schema(schema) {
|
|
|
13
14
|
produce
|
|
14
15
|
}
|
|
15
16
|
}),
|
|
17
|
+
satisfies: schemaSatisfies,
|
|
16
18
|
weighted: (weights)=>{
|
|
17
19
|
const merged = {
|
|
18
20
|
...schema[Meta].weights,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { withAdaptations } from "../../Adapter/Core.js";
|
|
2
2
|
import { assertDrawableKeyedWeights } from "../../Distribution/index.js";
|
|
3
|
+
import { schemaSatisfies } from "../../Schema/Satisfies.js";
|
|
3
4
|
import { Kind, Meta } from "../../Types.js";
|
|
4
5
|
import { outcomes } from "./Outcomes.js";
|
|
5
6
|
function Schema(schema) {
|
|
@@ -13,6 +14,7 @@ function Schema(schema) {
|
|
|
13
14
|
produce
|
|
14
15
|
}
|
|
15
16
|
}),
|
|
17
|
+
satisfies: schemaSatisfies,
|
|
16
18
|
weighted: (weights)=>{
|
|
17
19
|
const merged = {
|
|
18
20
|
...schema[Meta].weights,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { constrainContinuous, effectiveDiscrete } from "../../Bound.js";
|
|
2
|
-
import { Distribution, sampler } from "../../Distribution/index.js";
|
|
2
|
+
import { Distribution, discreteSampler, sampler } from "../../Distribution/index.js";
|
|
3
3
|
import { toStreamFromTrace } from "../../Random/index.js";
|
|
4
4
|
import { Kind, Meta } from "../../Types.js";
|
|
5
5
|
import { unboundedContinuous, unboundedDiscrete } from "./defaults.js";
|
|
@@ -46,16 +46,12 @@ function Fabricator(context) {
|
|
|
46
46
|
};
|
|
47
47
|
const distribution = null != (_range_distribution = range.distribution) ? _range_distribution : Distribution.uniform();
|
|
48
48
|
if (meta.integer) {
|
|
49
|
-
const
|
|
50
|
-
const draw = sampler(distribution, {
|
|
51
|
-
min,
|
|
52
|
-
max: max + 1
|
|
53
|
-
}, stream);
|
|
49
|
+
const draw = discreteSampler(distribution, effectiveDiscrete(range.min, range.max), stream);
|
|
54
50
|
return {
|
|
55
51
|
[Kind]: "number",
|
|
56
52
|
[Meta]: meta,
|
|
57
53
|
trace,
|
|
58
|
-
fabricate: ()=>
|
|
54
|
+
fabricate: ()=>draw(),
|
|
59
55
|
schema: rehydrated
|
|
60
56
|
};
|
|
61
57
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { withAdaptations } from "../../Adapter/Core.js";
|
|
2
|
+
import { schemaSatisfies } from "../../Schema/Satisfies.js";
|
|
2
3
|
import { Kind, Meta } from "../../Types.js";
|
|
3
4
|
function Schema(schema) {
|
|
4
5
|
return {
|
|
@@ -12,6 +13,7 @@ function Schema(schema) {
|
|
|
12
13
|
hints
|
|
13
14
|
}
|
|
14
15
|
}),
|
|
16
|
+
satisfies: schemaSatisfies,
|
|
15
17
|
adapt: (adapter, produce)=>Schema(withAdaptations(schema, adapter, produce))
|
|
16
18
|
};
|
|
17
19
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { mergeAdaptations } from "../../Adapter/Core.js";
|
|
2
2
|
import { FabricatorError } from "../../Error/index.js";
|
|
3
|
-
import { toSchema, violatesKind } from "../../Schema/Core.js";
|
|
3
|
+
import { toSchema, toValueKind, violatesKind } from "../../Schema/Core.js";
|
|
4
4
|
import { Adaptation, Fixed, Kind, Meta, Omitted } from "../../Types.js";
|
|
5
5
|
import { isPlainObject } from "../../Utility/Core.js";
|
|
6
6
|
import { shallowMerge } from "../../Utility/ShallowMerge.js";
|
|
7
7
|
import { isNullableSchema } from "../nullable/Schema.js";
|
|
8
8
|
import { isNullishSchema } from "../nullish/Schema.js";
|
|
9
9
|
import { isUndefinableSchema } from "../undefinable/Schema.js";
|
|
10
|
-
import compute_0
|
|
10
|
+
import compute_0 from "./compute/index.js";
|
|
11
11
|
import { isObjectOmittableSchema } from "./omittable/Schema.js";
|
|
12
12
|
import { isObjectOptionalSchema } from "./optional/Schema.js";
|
|
13
13
|
import { Schema, isObjectSchema } from "./Schema.js";
|
|
@@ -67,7 +67,7 @@ function make(definition, refinements, adaptations) {
|
|
|
67
67
|
};
|
|
68
68
|
continue;
|
|
69
69
|
}
|
|
70
|
-
const innerKind = fieldSchema[Meta].definition
|
|
70
|
+
const innerKind = toValueKind(fieldSchema[Meta].definition);
|
|
71
71
|
if (violatesKind(innerKind, value)) throw new FabricatorError.InvalidOverrideValueError(key, innerKind, value);
|
|
72
72
|
overridden[key] = {
|
|
73
73
|
...toSchema(fieldSchema),
|
|
@@ -83,7 +83,7 @@ function make(definition, refinements, adaptations) {
|
|
|
83
83
|
};
|
|
84
84
|
continue;
|
|
85
85
|
}
|
|
86
|
-
const innerKind = fieldSchema[Meta].definition
|
|
86
|
+
const innerKind = toValueKind(fieldSchema[Meta].definition);
|
|
87
87
|
if (violatesKind(innerKind, value)) throw new FabricatorError.InvalidOverrideValueError(key, innerKind, value);
|
|
88
88
|
overridden[key] = {
|
|
89
89
|
...toSchema(fieldSchema),
|
|
@@ -93,7 +93,7 @@ function make(definition, refinements, adaptations) {
|
|
|
93
93
|
}
|
|
94
94
|
if (isUndefinableSchema(fieldSchema)) {
|
|
95
95
|
if (void 0 !== value) {
|
|
96
|
-
const innerKind = fieldSchema[Meta].definition
|
|
96
|
+
const innerKind = toValueKind(fieldSchema[Meta].definition);
|
|
97
97
|
if (violatesKind(innerKind, value)) throw new FabricatorError.InvalidOverrideValueError(key, innerKind, value);
|
|
98
98
|
}
|
|
99
99
|
overridden[key] = {
|
|
@@ -104,7 +104,7 @@ function make(definition, refinements, adaptations) {
|
|
|
104
104
|
}
|
|
105
105
|
if (isNullableSchema(fieldSchema)) {
|
|
106
106
|
if (null !== value) {
|
|
107
|
-
const innerKind = fieldSchema[Meta].definition
|
|
107
|
+
const innerKind = toValueKind(fieldSchema[Meta].definition);
|
|
108
108
|
if (violatesKind(innerKind, value)) throw new FabricatorError.InvalidOverrideValueError(key, innerKind, value);
|
|
109
109
|
}
|
|
110
110
|
overridden[key] = {
|
|
@@ -115,7 +115,7 @@ function make(definition, refinements, adaptations) {
|
|
|
115
115
|
}
|
|
116
116
|
if (isNullishSchema(fieldSchema)) {
|
|
117
117
|
if (null != value) {
|
|
118
|
-
const innerKind = fieldSchema[Meta].definition
|
|
118
|
+
const innerKind = toValueKind(fieldSchema[Meta].definition);
|
|
119
119
|
if (violatesKind(innerKind, value)) throw new FabricatorError.InvalidOverrideValueError(key, innerKind, value);
|
|
120
120
|
}
|
|
121
121
|
overridden[key] = {
|
|
@@ -125,7 +125,7 @@ function make(definition, refinements, adaptations) {
|
|
|
125
125
|
continue;
|
|
126
126
|
}
|
|
127
127
|
if (value === Omitted) throw new FabricatorError.IllegalOmittedOverrideError(key, fieldSchema[Kind]);
|
|
128
|
-
const kind =
|
|
128
|
+
const kind = toValueKind(fieldSchema);
|
|
129
129
|
if (violatesKind(kind, value)) throw new FabricatorError.InvalidOverrideValueError(key, kind, value);
|
|
130
130
|
overridden[key] = {
|
|
131
131
|
...toSchema(fieldSchema),
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { schemaSatisfies } from "../../Schema/Satisfies.js";
|
|
1
2
|
import { Kind, Meta } from "../../Types.js";
|
|
2
3
|
function Schema(schema) {
|
|
3
4
|
return {
|
|
@@ -9,7 +10,8 @@ function Schema(schema) {
|
|
|
9
10
|
...schema[Meta],
|
|
10
11
|
produce
|
|
11
12
|
}
|
|
12
|
-
})
|
|
13
|
+
}),
|
|
14
|
+
satisfies: schemaSatisfies
|
|
13
15
|
};
|
|
14
16
|
}
|
|
15
17
|
function isObjectSchema(candidate) {
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { withAdaptations } from "../../../Adapter/Core.js";
|
|
2
|
+
import { schemaSatisfies } from "../../../Schema/Satisfies.js";
|
|
2
3
|
import { Kind } from "../../../Types.js";
|
|
3
4
|
function Schema(schema) {
|
|
4
5
|
return {
|
|
5
6
|
...schema,
|
|
6
7
|
[Kind]: "object.compute",
|
|
8
|
+
satisfies: schemaSatisfies,
|
|
7
9
|
adapt: (adapter, produce)=>Schema(withAdaptations(schema, adapter, produce))
|
|
8
10
|
};
|
|
9
11
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { withAdaptations } from "../../../Adapter/Core.js";
|
|
2
2
|
import { assertDrawableKeyedWeights } from "../../../Distribution/index.js";
|
|
3
|
+
import { schemaSatisfies } from "../../../Schema/Satisfies.js";
|
|
3
4
|
import { Kind, Meta } from "../../../Types.js";
|
|
4
5
|
import { outcomes } from "./Outcomes.js";
|
|
5
6
|
function Schema(schema) {
|
|
@@ -13,6 +14,7 @@ function Schema(schema) {
|
|
|
13
14
|
produce
|
|
14
15
|
}
|
|
15
16
|
}),
|
|
17
|
+
satisfies: schemaSatisfies,
|
|
16
18
|
weighted: (weights)=>{
|
|
17
19
|
const merged = {
|
|
18
20
|
...schema[Meta].weights,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { withAdaptations } from "../../../Adapter/Core.js";
|
|
2
2
|
import { assertDrawableKeyedWeights } from "../../../Distribution/index.js";
|
|
3
|
+
import { schemaSatisfies } from "../../../Schema/Satisfies.js";
|
|
3
4
|
import { Kind, Meta } from "../../../Types.js";
|
|
4
5
|
import { outcomes } from "./Outcomes.js";
|
|
5
6
|
function Schema(schema) {
|
|
@@ -13,6 +14,7 @@ function Schema(schema) {
|
|
|
13
14
|
produce
|
|
14
15
|
}
|
|
15
16
|
}),
|
|
17
|
+
satisfies: schemaSatisfies,
|
|
16
18
|
weighted: (weights)=>{
|
|
17
19
|
const merged = {
|
|
18
20
|
...schema[Meta].weights,
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { withAdaptations } from "../../Adapter/Core.js";
|
|
2
|
+
import { schemaSatisfies } from "../../Schema/Satisfies.js";
|
|
2
3
|
import { Kind } from "../../Types.js";
|
|
3
4
|
function Schema(schema) {
|
|
4
5
|
return {
|
|
5
6
|
...schema,
|
|
6
7
|
[Kind]: "opaque",
|
|
8
|
+
satisfies: schemaSatisfies,
|
|
7
9
|
adapt: (adapter, produce)=>Schema(withAdaptations(schema, adapter, produce))
|
|
8
10
|
};
|
|
9
11
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { discreteSampler } from "../../Distribution/index.js";
|
|
1
2
|
import { toStreamFromTrace } from "../../Random/index.js";
|
|
2
3
|
import { Children, Kind, Meta } from "../../Types.js";
|
|
3
4
|
import { Schema } from "./Schema.js";
|
|
@@ -25,8 +26,12 @@ function Fabricator(context, key, value) {
|
|
|
25
26
|
}
|
|
26
27
|
const stream = toStreamFromTrace(algorithm, trace);
|
|
27
28
|
const { max, minTried = 0 } = meta.whereby.size;
|
|
29
|
+
const drawSize = discreteSampler(void 0, {
|
|
30
|
+
min: minTried,
|
|
31
|
+
max
|
|
32
|
+
}, stream);
|
|
28
33
|
const fabricate = ()=>{
|
|
29
|
-
const size =
|
|
34
|
+
const size = drawSize();
|
|
30
35
|
const fabricated = {};
|
|
31
36
|
for(let i = 0; i < size; i++){
|
|
32
37
|
const k = key.fabricate();
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { withAdaptations } from "../../Adapter/Core.js";
|
|
2
|
+
import { schemaSatisfies } from "../../Schema/Satisfies.js";
|
|
2
3
|
import { Kind, Meta } from "../../Types.js";
|
|
3
4
|
function Schema(schema) {
|
|
4
5
|
return {
|
|
@@ -11,6 +12,7 @@ function Schema(schema) {
|
|
|
11
12
|
produce
|
|
12
13
|
}
|
|
13
14
|
}),
|
|
15
|
+
satisfies: schemaSatisfies,
|
|
14
16
|
adapt: (adapter, produce)=>Schema(withAdaptations(schema, adapter, produce))
|
|
15
17
|
};
|
|
16
18
|
}
|