@ghostry/fabricator 0.0.12 → 0.0.14
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/README.md +1 -1
- 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/Fabricator/Fabricate.js +1 -6
- 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/boolean/Registry.js +10 -8
- 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 +111 -38
- 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/null/Registry.js +6 -4
- 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 +86 -29
- 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/symbol/Registry.js +15 -13
- package/dist/esm/Primitive/undefined/Registry.js +6 -4
- package/dist/esm/Primitive/unique/Registry.js +22 -0
- package/dist/esm/Primitive/unique/index.js +2 -0
- package/dist/esm/Schema/Core.js +9 -1
- package/dist/esm/Schema/Registry.js +27 -7
- 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/Utility/DeepMerge.js +47 -6
- package/dist/esm/internal.js +2 -0
- package/dist/types/Bound.d.ts +66 -0
- package/dist/types/Distribution/index.d.ts +82 -0
- package/dist/types/Enumeration/Types.d.ts +10 -1
- package/dist/types/Error/index.d.ts +283 -0
- package/dist/types/Fabricator/Constructor.d.ts +6 -2
- package/dist/types/Fabricator/Fabricate.d.ts +4 -2
- package/dist/types/Fabricator/Types.d.ts +13 -0
- package/dist/types/Instance/Types.d.ts +14 -0
- package/dist/types/Primitive/array/Admits.d.ts +7 -0
- package/dist/types/Primitive/array/Fabricator.d.ts +2 -2
- package/dist/types/Primitive/array/Registry.d.ts +38 -1
- package/dist/types/Primitive/array/Schema.d.ts +6 -1
- package/dist/types/Primitive/array/Types.d.ts +33 -1
- package/dist/types/Primitive/bigint/Admits.d.ts +7 -0
- package/dist/types/Primitive/bigint/Fabricator.d.ts +3 -1
- package/dist/types/Primitive/bigint/Registry.d.ts +20 -0
- package/dist/types/Primitive/bigint/Schema.d.ts +9 -1
- package/dist/types/Primitive/bigint/Types.d.ts +27 -3
- package/dist/types/Primitive/boolean/Registry.d.ts +6 -1
- 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 +3 -1
- package/dist/types/Primitive/date/Registry.d.ts +54 -12
- package/dist/types/Primitive/date/Schema.d.ts +10 -1
- package/dist/types/Primitive/date/Types.d.ts +53 -4
- package/dist/types/Primitive/enum/Fabricator.d.ts +3 -1
- package/dist/types/Primitive/enum/Registry.d.ts +20 -0
- package/dist/types/Primitive/enum/Types.d.ts +5 -0
- package/dist/types/Primitive/index.d.ts +1 -0
- package/dist/types/Primitive/null/Registry.d.ts +6 -1
- package/dist/types/Primitive/number/Admits.d.ts +9 -0
- package/dist/types/Primitive/number/Fabricator.d.ts +3 -1
- package/dist/types/Primitive/number/Registry.d.ts +50 -2
- package/dist/types/Primitive/number/Schema.d.ts +10 -2
- package/dist/types/Primitive/number/Types.d.ts +32 -10
- package/dist/types/Primitive/record/Admits.d.ts +18 -0
- package/dist/types/Primitive/record/Fabricator.d.ts +2 -2
- package/dist/types/Primitive/record/Registry.d.ts +18 -1
- package/dist/types/Primitive/record/Schema.d.ts +8 -1
- package/dist/types/Primitive/record/Types.d.ts +60 -6
- package/dist/types/Primitive/recursive/Terminate.d.ts +7 -0
- 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/Fabricator.d.ts +3 -1
- package/dist/types/Primitive/string/Registry.d.ts +26 -5
- package/dist/types/Primitive/string/Schema.d.ts +28 -2
- package/dist/types/Primitive/string/Sources.d.ts +16 -0
- package/dist/types/Primitive/string/Types.d.ts +35 -15
- package/dist/types/Primitive/symbol/Registry.d.ts +6 -1
- package/dist/types/Primitive/undefined/Registry.d.ts +6 -1
- package/dist/types/Primitive/unique/Registry.d.ts +39 -0
- package/dist/types/Primitive/unique/index.d.ts +2 -0
- package/dist/types/Schema/Core.d.ts +16 -1
- package/dist/types/Schema/Registry.d.ts +7 -4
- package/dist/types/Types.d.ts +9 -0
- 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/DeepMerge.d.ts +11 -0
- package/dist/types/index.d.ts +13 -0
- package/dist/types/internal.d.ts +9 -0
- package/package.json +3 -3
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { discreteWithin, toAdmittedEnds, toFiniteBound } from "../../Bound.js";
|
|
2
|
+
const label = ".admits on a string schema";
|
|
3
|
+
function toAdmits(meta, input) {
|
|
4
|
+
var _input_format, _input_pattern, _ref;
|
|
5
|
+
var _meta_whereby, _meta_admits, _meta_admits1, _meta_admits2;
|
|
6
|
+
const drawn = toEnds(null == (_meta_whereby = meta.whereby) ? void 0 : _meta_whereby.length);
|
|
7
|
+
const format = null != (_input_format = input.format) ? _input_format : null == (_meta_admits = meta.admits) ? void 0 : _meta_admits.format;
|
|
8
|
+
const pattern = null != (_input_pattern = input.pattern) ? _input_pattern : null == (_meta_admits1 = meta.admits) ? void 0 : _meta_admits1.pattern;
|
|
9
|
+
return {
|
|
10
|
+
...void 0 === format ? {} : {
|
|
11
|
+
format
|
|
12
|
+
},
|
|
13
|
+
...void 0 === pattern ? {} : {
|
|
14
|
+
pattern
|
|
15
|
+
},
|
|
16
|
+
length: toAdmittedEnds(label, "length", null != (_ref = null == (_meta_admits2 = meta.admits) ? void 0 : _meta_admits2.length) ? _ref : drawn, meta.produce ? void 0 : drawn, input.length, (end, given)=>toFiniteBound(label, end, given), discreteWithin)
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
function toEnds(length) {
|
|
20
|
+
if (!length) return {};
|
|
21
|
+
return {
|
|
22
|
+
min: length.min,
|
|
23
|
+
max: length.max
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export { toAdmits };
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { effectiveDiscrete } from "../../Bound.js";
|
|
2
|
+
import { isDrawable } from "../../Distribution/index.js";
|
|
3
|
+
import { bmpScalars, toRanges, toSources } from "./Sources.js";
|
|
4
|
+
function toStringDomain(whereby) {
|
|
5
|
+
const characters = merge(toSources(whereby.composition).filter(([weight])=>isDrawable(weight)).flatMap(([, source])=>toRanges(source)));
|
|
6
|
+
const { min, max } = effectiveDiscrete(whereby.length.min, whereby.length.max);
|
|
7
|
+
const one = BigInt(count(characters, 0, 0xffff));
|
|
8
|
+
const two = BigInt(count(characters, 0x10000, 1 / 0));
|
|
9
|
+
const fillers = BigInt(bmpScalars.reduce((total, range)=>total + (range.to - range.from + 1) - count(characters, range.from, range.to), 0));
|
|
10
|
+
let capacity = BigInt(0);
|
|
11
|
+
let [f2, c2] = [
|
|
12
|
+
BigInt(0),
|
|
13
|
+
BigInt(0)
|
|
14
|
+
];
|
|
15
|
+
let [f1, c1] = [
|
|
16
|
+
BigInt(1),
|
|
17
|
+
BigInt(0)
|
|
18
|
+
];
|
|
19
|
+
for(let length = 0; length <= max; length++)if (length > 0) {
|
|
20
|
+
const f = one * f1 + two * f2;
|
|
21
|
+
const c = one * (c1 + f1) + two * (c2 + f2);
|
|
22
|
+
const filled = two > BigInt(0) ? fillers * (c1 + f1) : BigInt(0);
|
|
23
|
+
if (length >= min) capacity += f + filled;
|
|
24
|
+
[f2, c2, f1, c1] = [
|
|
25
|
+
f1,
|
|
26
|
+
c1,
|
|
27
|
+
f,
|
|
28
|
+
c
|
|
29
|
+
];
|
|
30
|
+
} else if (0 === min) capacity += BigInt(1);
|
|
31
|
+
return {
|
|
32
|
+
capacity,
|
|
33
|
+
admits: (value)=>{
|
|
34
|
+
if ("string" != typeof value) return false;
|
|
35
|
+
if (value.length < min || value.length > max) return false;
|
|
36
|
+
let outside = 0;
|
|
37
|
+
for (const char of value)if (!contains(characters, char.codePointAt(0))) {
|
|
38
|
+
if (two === BigInt(0) || !contains(bmpScalars, char.codePointAt(0))) return false;
|
|
39
|
+
outside++;
|
|
40
|
+
}
|
|
41
|
+
return outside <= 1;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function merge(ranges) {
|
|
46
|
+
const sorted = [
|
|
47
|
+
...ranges
|
|
48
|
+
].sort((a, b)=>a.from - b.from);
|
|
49
|
+
const merged = [];
|
|
50
|
+
for (const range of sorted){
|
|
51
|
+
const last = merged[merged.length - 1];
|
|
52
|
+
if (last && range.from <= last.to + 1) merged[merged.length - 1] = {
|
|
53
|
+
from: last.from,
|
|
54
|
+
to: Math.max(last.to, range.to)
|
|
55
|
+
};
|
|
56
|
+
else merged.push(range);
|
|
57
|
+
}
|
|
58
|
+
return merged;
|
|
59
|
+
}
|
|
60
|
+
function count(ranges, from, to) {
|
|
61
|
+
return ranges.reduce((total, range)=>{
|
|
62
|
+
const low = Math.max(range.from, from);
|
|
63
|
+
const high = Math.min(range.to, to);
|
|
64
|
+
return high < low ? total : total + high - low + 1;
|
|
65
|
+
}, 0);
|
|
66
|
+
}
|
|
67
|
+
function contains(ranges, codepoint) {
|
|
68
|
+
let low = 0;
|
|
69
|
+
let high = ranges.length - 1;
|
|
70
|
+
while(low <= high){
|
|
71
|
+
const middle = low + high >> 1;
|
|
72
|
+
const range = ranges[middle];
|
|
73
|
+
if (codepoint < range.from) high = middle - 1;
|
|
74
|
+
else {
|
|
75
|
+
if (!(codepoint > range.to)) return true;
|
|
76
|
+
low = middle + 1;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
export { toStringDomain };
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { effectiveDiscrete } from "../../Bound.js";
|
|
2
2
|
import { discreteSampler, weighted } from "../../Distribution/index.js";
|
|
3
3
|
import { toStreamFromTrace } from "../../Random/index.js";
|
|
4
|
-
import { Kind, Meta } from "../../Types.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
4
|
+
import { Claim, Kind, Meta } from "../../Types.js";
|
|
5
|
+
import { toLifetimeScope, trackedByKey } from "../../Unique/Strategy.js";
|
|
6
|
+
import { toStringDomain } from "./Capacity.js";
|
|
7
|
+
import { bmpScalars, toRanges, toSources } from "./Sources.js";
|
|
7
8
|
import { Schema } from "./Schema.js";
|
|
8
9
|
function Fabricator(context) {
|
|
9
|
-
const { schema, algorithm, trace } = context;
|
|
10
|
+
const { schema, algorithm, trace, exhaustion } = context;
|
|
10
11
|
const meta = schema[Meta];
|
|
11
12
|
const rehydrated = Schema(schema);
|
|
12
13
|
if (meta.produce) {
|
|
@@ -30,20 +31,7 @@ function Fabricator(context) {
|
|
|
30
31
|
min,
|
|
31
32
|
max
|
|
32
33
|
}, stream);
|
|
33
|
-
const sources =
|
|
34
|
-
const composition = whereby.composition;
|
|
35
|
-
if (void 0 === composition) return [
|
|
36
|
-
[
|
|
37
|
-
1,
|
|
38
|
-
unicode.scalars
|
|
39
|
-
]
|
|
40
|
-
];
|
|
41
|
-
if (Array.isArray(composition)) return composition;
|
|
42
|
-
return Object.entries(composition).map(([name, weight])=>[
|
|
43
|
-
weight,
|
|
44
|
-
classes[name]
|
|
45
|
-
]);
|
|
46
|
-
});
|
|
34
|
+
const sources = toSources(whereby.composition);
|
|
47
35
|
const pick = weighted(sources.map(([weight, source])=>[
|
|
48
36
|
weight,
|
|
49
37
|
compiler(source, stream)
|
|
@@ -66,6 +54,23 @@ function Fabricator(context) {
|
|
|
66
54
|
}
|
|
67
55
|
return pieces.join("");
|
|
68
56
|
};
|
|
57
|
+
if (meta.unique) {
|
|
58
|
+
const scope = toLifetimeScope(trackedByKey({
|
|
59
|
+
label: "T.unique.string",
|
|
60
|
+
kind: "string",
|
|
61
|
+
draw: fabricate,
|
|
62
|
+
redraws: whereby.redraws,
|
|
63
|
+
...toStringDomain(whereby)
|
|
64
|
+
}), exhaustion);
|
|
65
|
+
return {
|
|
66
|
+
[Kind]: "string",
|
|
67
|
+
[Meta]: meta,
|
|
68
|
+
trace,
|
|
69
|
+
fabricate: ()=>scope.draw(),
|
|
70
|
+
[Claim]: scope.claim,
|
|
71
|
+
schema: rehydrated
|
|
72
|
+
};
|
|
73
|
+
}
|
|
69
74
|
return {
|
|
70
75
|
[Kind]: "string",
|
|
71
76
|
[Meta]: meta,
|
|
@@ -74,31 +79,6 @@ function Fabricator(context) {
|
|
|
74
79
|
schema: rehydrated
|
|
75
80
|
};
|
|
76
81
|
}
|
|
77
|
-
const toRanges = (source)=>{
|
|
78
|
-
if ("string" == typeof source) return [
|
|
79
|
-
...source
|
|
80
|
-
].map((char)=>{
|
|
81
|
-
const codepoint = char.codePointAt(0);
|
|
82
|
-
return {
|
|
83
|
-
from: codepoint,
|
|
84
|
-
to: codepoint
|
|
85
|
-
};
|
|
86
|
-
});
|
|
87
|
-
if (Array.isArray(source)) return source;
|
|
88
|
-
return [
|
|
89
|
-
source
|
|
90
|
-
];
|
|
91
|
-
};
|
|
92
|
-
const bmpScalars = [
|
|
93
|
-
{
|
|
94
|
-
from: 0x0,
|
|
95
|
-
to: 0xd7ff
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
from: 0xe000,
|
|
99
|
-
to: 0xffff
|
|
100
|
-
}
|
|
101
|
-
];
|
|
102
82
|
const compiler = (source, stream)=>{
|
|
103
83
|
const pick = weighted(toRanges(source).map((range)=>[
|
|
104
84
|
range.to - range.from + 1,
|
|
@@ -1,25 +1,47 @@
|
|
|
1
1
|
import { toLengthRange } from "../../Bound.js";
|
|
2
2
|
import { Kind, Meta } from "../../Types.js";
|
|
3
|
+
import { toRedraws } from "../../Unique/Strategy.js";
|
|
3
4
|
import { Schema } from "./Schema.js";
|
|
4
5
|
const Registry = {
|
|
5
6
|
[Kind]: "string",
|
|
6
|
-
as: (produce
|
|
7
|
+
as: (produce)=>Schema({
|
|
7
8
|
[Kind]: "string",
|
|
8
9
|
[Meta]: {
|
|
9
|
-
produce
|
|
10
|
-
hints
|
|
10
|
+
produce
|
|
11
11
|
}
|
|
12
12
|
}),
|
|
13
13
|
whereby: (whereby)=>Schema({
|
|
14
14
|
[Kind]: "string",
|
|
15
15
|
[Meta]: {
|
|
16
|
-
whereby:
|
|
17
|
-
length: toLengthRange(whereby.length, "T.string.whereby"),
|
|
18
|
-
...void 0 === whereby.composition ? {} : {
|
|
19
|
-
composition: whereby.composition
|
|
20
|
-
}
|
|
21
|
-
}
|
|
16
|
+
whereby: toWhereby("T.string.whereby", whereby)
|
|
22
17
|
}
|
|
23
18
|
})
|
|
24
19
|
};
|
|
20
|
+
const unique = {
|
|
21
|
+
[Kind]: "string",
|
|
22
|
+
whereby: (whereby)=>{
|
|
23
|
+
const label = "T.unique.string.whereby";
|
|
24
|
+
const converted = toWhereby(label, whereby);
|
|
25
|
+
const redraws = toRedraws(label, whereby.redraws);
|
|
26
|
+
return Schema({
|
|
27
|
+
[Kind]: "string",
|
|
28
|
+
[Meta]: {
|
|
29
|
+
whereby: void 0 === redraws ? converted : {
|
|
30
|
+
...converted,
|
|
31
|
+
redraws
|
|
32
|
+
},
|
|
33
|
+
unique: true
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
function toWhereby(label, input) {
|
|
39
|
+
return {
|
|
40
|
+
length: toLengthRange(input.length, label),
|
|
41
|
+
...void 0 === input.composition ? {} : {
|
|
42
|
+
composition: input.composition
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
}
|
|
25
46
|
export default Registry;
|
|
47
|
+
export { unique };
|
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
import { withAdaptations } from "../../Adapter/Core.js";
|
|
2
2
|
import { schemaSatisfies } from "../../Schema/Satisfies.js";
|
|
3
3
|
import { Kind, Meta } from "../../Types.js";
|
|
4
|
+
import { toAdmits } from "./Admits.js";
|
|
4
5
|
function Schema(schema) {
|
|
5
6
|
return {
|
|
6
7
|
...schema,
|
|
7
8
|
[Kind]: "string",
|
|
8
|
-
as: (produce
|
|
9
|
+
as: (produce)=>Schema({
|
|
9
10
|
...schema,
|
|
10
11
|
[Meta]: {
|
|
11
12
|
...schema[Meta],
|
|
12
|
-
produce
|
|
13
|
-
|
|
13
|
+
produce
|
|
14
|
+
}
|
|
15
|
+
}),
|
|
16
|
+
admits: (admitted)=>Schema({
|
|
17
|
+
...schema,
|
|
18
|
+
[Meta]: {
|
|
19
|
+
...schema[Meta],
|
|
20
|
+
admits: toAdmits(schema[Meta], admitted)
|
|
14
21
|
}
|
|
15
22
|
}),
|
|
16
23
|
satisfies: schemaSatisfies,
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { isArray } from "../../Utility/Core.js";
|
|
2
|
+
import { classes, unicode } from "./Constants.js";
|
|
3
|
+
function toSources(composition) {
|
|
4
|
+
if (void 0 === composition) return [
|
|
5
|
+
[
|
|
6
|
+
1,
|
|
7
|
+
unicode.scalars
|
|
8
|
+
]
|
|
9
|
+
];
|
|
10
|
+
if (Array.isArray(composition)) return composition;
|
|
11
|
+
return Object.entries(composition).map(([name, weight])=>[
|
|
12
|
+
weight,
|
|
13
|
+
classes[name]
|
|
14
|
+
]);
|
|
15
|
+
}
|
|
16
|
+
function toRanges(source) {
|
|
17
|
+
if ("string" == typeof source) return [
|
|
18
|
+
...source
|
|
19
|
+
].map((char)=>{
|
|
20
|
+
const codepoint = char.codePointAt(0);
|
|
21
|
+
return {
|
|
22
|
+
from: codepoint,
|
|
23
|
+
to: codepoint
|
|
24
|
+
};
|
|
25
|
+
});
|
|
26
|
+
if (isArray(source)) return source;
|
|
27
|
+
return [
|
|
28
|
+
source
|
|
29
|
+
];
|
|
30
|
+
}
|
|
31
|
+
const bmpScalars = [
|
|
32
|
+
{
|
|
33
|
+
from: 0x0,
|
|
34
|
+
to: 0xd7ff
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
from: 0xe000,
|
|
38
|
+
to: 0xffff
|
|
39
|
+
}
|
|
40
|
+
];
|
|
41
|
+
export { bmpScalars, toRanges, toSources };
|
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
import { Adaptation, Kind, Meta, Produces } from "../../Types.js";
|
|
2
2
|
import { Schema } from "./Schema.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
[Meta]: {},
|
|
7
|
-
[Produces]: void 0,
|
|
8
|
-
[Adaptation]: void 0
|
|
9
|
-
}),
|
|
10
|
-
keyed: (key)=>Schema({
|
|
3
|
+
function registry() {
|
|
4
|
+
return {
|
|
5
|
+
...Schema({
|
|
11
6
|
[Kind]: "symbol",
|
|
12
|
-
[Meta]: {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
})
|
|
16
|
-
|
|
7
|
+
[Meta]: {},
|
|
8
|
+
[Produces]: void 0,
|
|
9
|
+
[Adaptation]: void 0
|
|
10
|
+
}),
|
|
11
|
+
keyed: (key)=>Schema({
|
|
12
|
+
[Kind]: "symbol",
|
|
13
|
+
[Meta]: {
|
|
14
|
+
key
|
|
15
|
+
}
|
|
16
|
+
})
|
|
17
|
+
};
|
|
18
|
+
}
|
|
17
19
|
const Registry = registry;
|
|
18
20
|
export default Registry;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { Kind, Meta } from "../../Types.js";
|
|
2
2
|
import { Schema } from "./Schema.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
3
|
+
function registry() {
|
|
4
|
+
return Schema({
|
|
5
|
+
[Kind]: "undefined",
|
|
6
|
+
[Meta]: {}
|
|
7
|
+
});
|
|
8
|
+
}
|
|
7
9
|
const Registry = registry;
|
|
8
10
|
export default Registry;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { unique } from "../array/Registry.js";
|
|
2
|
+
import { unique as Registry_js_unique } from "../bigint/Registry.js";
|
|
3
|
+
import { unique as external_date_Registry_js_unique } from "../date/Registry.js";
|
|
4
|
+
import { unique as external_enum_Registry_js_unique } from "../enum/Registry.js";
|
|
5
|
+
import { unique as external_number_Registry_js_unique } from "../number/Registry.js";
|
|
6
|
+
import { unique as external_record_Registry_js_unique } from "../record/Registry.js";
|
|
7
|
+
import { unique as external_string_Registry_js_unique } from "../string/Registry.js";
|
|
8
|
+
const registry = {
|
|
9
|
+
enum: external_enum_Registry_js_unique,
|
|
10
|
+
get number () {
|
|
11
|
+
return external_number_Registry_js_unique();
|
|
12
|
+
},
|
|
13
|
+
bigint: Registry_js_unique,
|
|
14
|
+
string: external_string_Registry_js_unique,
|
|
15
|
+
get date () {
|
|
16
|
+
return external_date_Registry_js_unique();
|
|
17
|
+
},
|
|
18
|
+
array: unique,
|
|
19
|
+
record: external_record_Registry_js_unique
|
|
20
|
+
};
|
|
21
|
+
const Registry = registry;
|
|
22
|
+
export default Registry;
|
package/dist/esm/Schema/Core.js
CHANGED
|
@@ -11,6 +11,14 @@ function toSchema(value) {
|
|
|
11
11
|
[Meta]: value[Meta]
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
|
+
function isBuildable(candidate) {
|
|
15
|
+
if ("object" != typeof candidate || null === candidate) return false;
|
|
16
|
+
if ("string" != typeof candidate[Kind]) return false;
|
|
17
|
+
return Meta in candidate;
|
|
18
|
+
}
|
|
19
|
+
function isSchema(candidate) {
|
|
20
|
+
return isBuildable(candidate) && !("fabricate" in candidate);
|
|
21
|
+
}
|
|
14
22
|
function toValueKind(schema) {
|
|
15
23
|
switch(schema[Kind]){
|
|
16
24
|
case "object.compute":
|
|
@@ -77,4 +85,4 @@ function violatesKind(kind, value) {
|
|
|
77
85
|
return never(kind);
|
|
78
86
|
}
|
|
79
87
|
}
|
|
80
|
-
export { toSchema, toValueKind, violatesKind };
|
|
88
|
+
export { isBuildable, isSchema, toSchema, toValueKind, violatesKind };
|
|
@@ -5,13 +5,33 @@ const Registry = (registrations)=>{
|
|
|
5
5
|
T: registrations,
|
|
6
6
|
augment: deepMerge
|
|
7
7
|
})));
|
|
8
|
-
return {
|
|
9
|
-
...registrations,
|
|
8
|
+
return deepMerge(registrations, {
|
|
10
9
|
extend
|
|
11
|
-
};
|
|
10
|
+
});
|
|
12
11
|
};
|
|
13
|
-
|
|
14
|
-
const { Primitive: _, ...
|
|
15
|
-
return
|
|
16
|
-
|
|
12
|
+
function builders() {
|
|
13
|
+
const { Primitive: _, ...rest } = __rspack_external__Primitive_index_js_8ad84a20;
|
|
14
|
+
return {
|
|
15
|
+
...rest,
|
|
16
|
+
get boolean () {
|
|
17
|
+
return __rspack_external__Primitive_index_js_8ad84a20.boolean();
|
|
18
|
+
},
|
|
19
|
+
get date () {
|
|
20
|
+
return __rspack_external__Primitive_index_js_8ad84a20.date();
|
|
21
|
+
},
|
|
22
|
+
get null () {
|
|
23
|
+
return __rspack_external__Primitive_index_js_8ad84a20["null"]();
|
|
24
|
+
},
|
|
25
|
+
get number () {
|
|
26
|
+
return __rspack_external__Primitive_index_js_8ad84a20.number();
|
|
27
|
+
},
|
|
28
|
+
get symbol () {
|
|
29
|
+
return __rspack_external__Primitive_index_js_8ad84a20.symbol();
|
|
30
|
+
},
|
|
31
|
+
get undefined () {
|
|
32
|
+
return __rspack_external__Primitive_index_js_8ad84a20.undefined();
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
const registry = Registry({}).extend(builders);
|
|
17
37
|
export { registry };
|
package/dist/esm/Types.js
CHANGED
|
@@ -7,5 +7,6 @@ const Layer = Symbol.for("fabricator:layer");
|
|
|
7
7
|
const Children = Symbol.for("fabricator:children");
|
|
8
8
|
const Adaptation = Symbol.for("fabricator:adaptation");
|
|
9
9
|
const Omitted = Symbol.for("fabricator:omitted");
|
|
10
|
+
const Claim = Symbol.for("fabricator:claim");
|
|
10
11
|
const MAX_TIME = 8640000000000000;
|
|
11
|
-
export { Adaptation, Children, Fixed, Kind, Layer, MAX_TIME, Meta, Omitted, Produces, Replace };
|
|
12
|
+
export { Adaptation, Children, Claim, Fixed, Kind, Layer, MAX_TIME, Meta, Omitted, Produces, Replace };
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { effectiveDiscrete, effectiveDiscreteBigint } from "../Bound.js";
|
|
2
|
+
import { isDrawable } from "../Distribution/index.js";
|
|
3
|
+
import { toEpochRange } from "../Primitive/date/Defaults.js";
|
|
4
|
+
import { toStringDomain } from "../Primitive/string/Capacity.js";
|
|
5
|
+
import { toSchema } from "../Schema/Core.js";
|
|
6
|
+
import { Fixed, Kind, Meta } from "../Types.js";
|
|
7
|
+
import { toNumberCapacity, toRangeCapacity } from "./Distinct.js";
|
|
8
|
+
import { toDistinctValues } from "./Strategy.js";
|
|
9
|
+
function toCapacity(schema, clock) {
|
|
10
|
+
const limits = [];
|
|
11
|
+
walk(toSchema(schema), BigInt(1), clock, limits);
|
|
12
|
+
return limits.reduce((tightest, limit)=>void 0 === tightest || limit < tightest ? limit : tightest, void 0);
|
|
13
|
+
}
|
|
14
|
+
function walk(node, draws, clock, limits) {
|
|
15
|
+
const meta = null == node ? void 0 : node[Meta];
|
|
16
|
+
if (!meta || meta.produce || draws === BigInt(0)) return;
|
|
17
|
+
if (true === meta.unique && "record" !== node[Kind]) {
|
|
18
|
+
const capacity = toLeafCapacity(node[Kind], meta, clock);
|
|
19
|
+
if (void 0 !== capacity) limits.push(capacity / draws);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const visit = (child, times = draws)=>walk(child, times, clock, limits);
|
|
23
|
+
switch(node[Kind]){
|
|
24
|
+
case "object":
|
|
25
|
+
{
|
|
26
|
+
const fields = {
|
|
27
|
+
...meta.definition,
|
|
28
|
+
...meta.hidden
|
|
29
|
+
};
|
|
30
|
+
for (const field of Object.values(fields))if (!(Fixed in field)) visit(field);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
case "tuple":
|
|
34
|
+
meta.items.forEach((item)=>visit(item));
|
|
35
|
+
return;
|
|
36
|
+
case "derive":
|
|
37
|
+
meta.from.forEach((item)=>visit(item));
|
|
38
|
+
return;
|
|
39
|
+
case "choice":
|
|
40
|
+
for (const [weight, option] of meta.items)if (isDrawable(weight)) visit(option);
|
|
41
|
+
return;
|
|
42
|
+
case "nullable":
|
|
43
|
+
case "nullish":
|
|
44
|
+
case "undefinable":
|
|
45
|
+
case "object.omittable":
|
|
46
|
+
case "object.optional":
|
|
47
|
+
visit(meta.definition);
|
|
48
|
+
return;
|
|
49
|
+
case "array":
|
|
50
|
+
{
|
|
51
|
+
const { max } = effectiveDiscrete(meta.whereby.length.min, meta.whereby.length.max);
|
|
52
|
+
visit(meta.definition, draws * BigInt(max));
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
case "record":
|
|
56
|
+
{
|
|
57
|
+
const max = meta.unique ? effectiveDiscrete(meta.whereby.size.min, meta.whereby.size.max).max : meta.whereby.size.max;
|
|
58
|
+
visit(meta.key, draws * BigInt(max));
|
|
59
|
+
visit(meta.value, draws * BigInt(max));
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
default:
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
function toLeafCapacity(kind, meta, clock) {
|
|
67
|
+
switch(kind){
|
|
68
|
+
case "enum":
|
|
69
|
+
return BigInt(toDistinctValues(meta.items).values.length);
|
|
70
|
+
case "number":
|
|
71
|
+
return toNumberCapacity(meta);
|
|
72
|
+
case "bigint":
|
|
73
|
+
{
|
|
74
|
+
const range = effectiveDiscreteBigint(meta.whereby.min, meta.whereby.max);
|
|
75
|
+
return range.max - range.min + BigInt(1);
|
|
76
|
+
}
|
|
77
|
+
case "date":
|
|
78
|
+
return toRangeCapacity(toEpochRange(meta, clock));
|
|
79
|
+
case "string":
|
|
80
|
+
return toStringDomain(meta.whereby).capacity;
|
|
81
|
+
default:
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
export { toCapacity };
|