@ghostry/fabricator 0.0.11 → 0.0.13

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.
Files changed (67) hide show
  1. package/README.md +1 -1
  2. package/dist/esm/Enumeration/Enumerate.js +2 -4
  3. package/dist/esm/Error/index.js +34 -6
  4. package/dist/esm/Fabricator/Constructor.js +40 -33
  5. package/dist/esm/Fabricator/Fabricate.js +23 -0
  6. package/dist/esm/Instance/Core.js +14 -2
  7. package/dist/esm/Instance/Stack/Visible.js +6 -1
  8. package/dist/esm/Primitive/boolean/Registry.js +10 -8
  9. package/dist/esm/Primitive/date/Defaults.js +12 -0
  10. package/dist/esm/Primitive/date/Fabricator.js +5 -10
  11. package/dist/esm/Primitive/date/Registry.js +49 -39
  12. package/dist/esm/Primitive/index.js +2 -0
  13. package/dist/esm/Primitive/null/Registry.js +6 -4
  14. package/dist/esm/Primitive/number/Fabricator.js +1 -1
  15. package/dist/esm/Primitive/number/Registry.js +36 -30
  16. package/dist/esm/Primitive/object/Fabricator.js +33 -11
  17. package/dist/esm/Primitive/object/Registry.js +90 -10
  18. package/dist/esm/Primitive/object/compute/Fabricator.js +10 -3
  19. package/dist/esm/Primitive/object/compute/Registry.js +20 -3
  20. package/dist/esm/Primitive/object/omit/Registry.js +5 -0
  21. package/dist/esm/Primitive/object/omit/index.js +2 -0
  22. package/dist/esm/Primitive/object/pick/Registry.js +5 -0
  23. package/dist/esm/Primitive/object/pick/index.js +2 -0
  24. package/dist/esm/Primitive/recursive/Fabricator.js +1 -0
  25. package/dist/esm/Primitive/recursive/Terminate.js +21 -9
  26. package/dist/esm/Primitive/symbol/Registry.js +15 -13
  27. package/dist/esm/Primitive/undefined/Registry.js +6 -4
  28. package/dist/esm/Schema/Core.js +9 -1
  29. package/dist/esm/Schema/Registry.js +27 -7
  30. package/dist/esm/Utility/DeepMerge.js +47 -6
  31. package/dist/esm/internal.js +1 -0
  32. package/dist/types/Error/index.d.ts +71 -6
  33. package/dist/types/Fabricator/Fabricate.d.ts +63 -0
  34. package/dist/types/Fabricator/Types.d.ts +13 -3
  35. package/dist/types/Harnessing/Core.d.ts +7 -7
  36. package/dist/types/Instance/Core.d.ts +15 -8
  37. package/dist/types/Instance/Stack/Visible.d.ts +10 -0
  38. package/dist/types/Instance/Types.d.ts +30 -15
  39. package/dist/types/Primitive/boolean/Registry.d.ts +6 -1
  40. package/dist/types/Primitive/date/Defaults.d.ts +11 -0
  41. package/dist/types/Primitive/date/Registry.d.ts +13 -9
  42. package/dist/types/Primitive/date/Types.d.ts +10 -0
  43. package/dist/types/Primitive/index.d.ts +2 -0
  44. package/dist/types/Primitive/null/Registry.d.ts +6 -1
  45. package/dist/types/Primitive/number/Registry.d.ts +8 -1
  46. package/dist/types/Primitive/object/Fabricator.d.ts +13 -5
  47. package/dist/types/Primitive/object/Registry.d.ts +17 -1
  48. package/dist/types/Primitive/object/Types.d.ts +19 -0
  49. package/dist/types/Primitive/object/compute/Fabricator.d.ts +9 -8
  50. package/dist/types/Primitive/object/compute/Registry.d.ts +7 -1
  51. package/dist/types/Primitive/object/compute/Schema.d.ts +20 -0
  52. package/dist/types/Primitive/object/compute/Types.d.ts +10 -0
  53. package/dist/types/Primitive/object/omit/Registry.d.ts +7 -0
  54. package/dist/types/Primitive/object/omit/index.d.ts +2 -0
  55. package/dist/types/Primitive/object/pick/Registry.d.ts +8 -0
  56. package/dist/types/Primitive/object/pick/index.d.ts +2 -0
  57. package/dist/types/Primitive/recursive/Fabricator.d.ts +9 -7
  58. package/dist/types/Primitive/symbol/Registry.d.ts +6 -1
  59. package/dist/types/Primitive/undefined/Registry.d.ts +6 -1
  60. package/dist/types/Schema/Core.d.ts +16 -1
  61. package/dist/types/Schema/Registry.d.ts +7 -4
  62. package/dist/types/Utility/DeepMerge.d.ts +11 -0
  63. package/dist/types/index.d.ts +23 -10
  64. package/dist/types/internal.d.ts +8 -0
  65. package/package.json +4 -4
  66. /package/dist/esm/Primitive/number/{defaults.js → Defaults.js} +0 -0
  67. /package/dist/types/Primitive/number/{defaults.d.ts → Defaults.d.ts} +0 -0
package/README.md CHANGED
@@ -50,4 +50,4 @@ const item = Product.fabricate();
50
50
  const widget = Product.fabricate({ name: "Widget", inStock: true });
51
51
  ```
52
52
 
53
- `initialize()` takes no required configuration. Its `clock` (by default, the wall-clock instant of the call) is the run's entropy, so every run differs, and passing that one number back as `clock` replays the run exactly. See the [docs site](https://docs.ghostry.dev/fabricator/) for the full guide: the mental model behind Schemas and Fabricators, composing and overriding schemas, custom types, distributions, and the [TypeBox adapter](https://www.npmjs.com/package/@ghostry/fabricator-adapter-typebox-v0).
53
+ `initialize()` takes no required configuration. Its `clock` (by default, the wall-clock instant of the call) is the run's entropy, so every run differs, and passing that one number back as `clock` replays the run exactly. See the [docs site](https://docs.ghostry.dev/fabricator) for the full guide: the mental model behind Schemas and Fabricators, composing and overriding schemas, custom types, distributions, and the [TypeBox adapter](https://www.npmjs.com/package/@ghostry/fabricator-adapter-typebox-v0).
@@ -1,15 +1,13 @@
1
1
  import { shuffle } from "../Distribution/index.js";
2
2
  import { FabricatorError } from "../Error/index.js";
3
3
  import { Constructor } from "../Fabricator/Constructor.js";
4
- import { toInnermostFrame } from "../Instance/Stack/Visible.js";
4
+ import { toEffectiveSource } from "../Instance/Stack/Visible.js";
5
5
  import { toStreamFromTrace } from "../Random/index.js";
6
6
  import { plan, resolve } from "./Plan.js";
7
7
  function enumerables(source, limits, stack, ancestry) {
8
8
  const Fabricator = Constructor(source, stack, ancestry);
9
9
  function effectiveSource() {
10
- var _ref;
11
- var _toInnermostFrame;
12
- return null != (_ref = null == (_toInnermostFrame = toInnermostFrame(stack, ancestry)) ? void 0 : _toInnermostFrame.source) ? _ref : source;
10
+ return toEffectiveSource(source, stack, ancestry);
13
11
  }
14
12
  function iterable(rebuild) {
15
13
  return {
@@ -31,6 +31,14 @@ class Error_FabricatorError extends Error {
31
31
  }
32
32
  }
33
33
  FabricatorError.InvalidCombinatorialLimitError = InvalidCombinatorialLimitError;
34
+ class InvalidClockError extends FabricatorError {
35
+ constructor(clock){
36
+ super(), _define_property(this, "clock", void 0), this.clock = clock;
37
+ this.name = "InvalidClockError";
38
+ this.message = `clock requires a valid Date or an integer number of epoch milliseconds within ±8.64e15; received ${String(clock)}.`;
39
+ }
40
+ }
41
+ FabricatorError.InvalidClockError = InvalidClockError;
34
42
  class DetachedSelfError extends FabricatorError {
35
43
  constructor(during){
36
44
  super(), _define_property(this, "during", void 0), this.during = during;
@@ -96,14 +104,22 @@ class Error_FabricatorError extends Error {
96
104
  }
97
105
  }
98
106
  FabricatorError.DeriveResultMismatchError = DeriveResultMismatchError;
99
- class UnknownOverrideFieldError extends FabricatorError {
100
- constructor(field, available){
101
- super(), _define_property(this, "field", void 0), _define_property(this, "available", void 0), this.field = field, this.available = available;
102
- this.name = "UnknownOverrideFieldError";
103
- this.message = `Cannot override unknown field: "${field}". This object schema defines ` + (0 === available.length ? "no fields." : `${available.map((k)=>`"${k}"`).join(", ")}.`);
107
+ class UnknownFieldError extends FabricatorError {
108
+ constructor(field, available, operation){
109
+ super(), _define_property(this, "field", void 0), _define_property(this, "available", void 0), _define_property(this, "operation", void 0), this.field = field, this.available = available, this.operation = operation;
110
+ this.name = "UnknownFieldError";
111
+ this.message = `Cannot ${operation} unknown field: "${field}". This object schema defines ` + (0 === available.length ? "no fields." : `${available.map((k)=>`"${k}"`).join(", ")}.`);
112
+ }
113
+ }
114
+ FabricatorError.UnknownFieldError = UnknownFieldError;
115
+ class ComputeDependencyCycleError extends FabricatorError {
116
+ constructor(fields){
117
+ super(), _define_property(this, "fields", void 0), this.fields = fields;
118
+ this.name = "ComputeDependencyCycleError";
119
+ this.message = `Computed fields depend on each other in a cycle: ${fields.map((k)=>`"${k}"`).join(" -> ")}.`;
104
120
  }
105
121
  }
106
- FabricatorError.UnknownOverrideFieldError = UnknownOverrideFieldError;
122
+ FabricatorError.ComputeDependencyCycleError = ComputeDependencyCycleError;
107
123
  class InvalidOverrideValueError extends FabricatorError {
108
124
  constructor(field, kind, value){
109
125
  super(), _define_property(this, "field", void 0), _define_property(this, "kind", void 0), _define_property(this, "value", void 0), this.field = field, this.kind = kind, this.value = value;
@@ -197,6 +213,18 @@ class Error_FabricatorError extends Error {
197
213
  }
198
214
  }
199
215
  FabricatorError.TraceKindMismatchError = TraceKindMismatchError;
216
+ class FabricateArgumentError extends FabricatorError {
217
+ constructor(argument){
218
+ super(), _define_property(this, "argument", void 0), this.argument = argument;
219
+ this.name = "FabricateArgumentError";
220
+ this.message = describe(argument);
221
+ function describe(given) {
222
+ if ("object" == typeof given && null !== given && "fabricate" in given) return "fabricate(...) takes a Schema, not a built Fabricator. Call `.fabricate()` on the Fabricator you have, or pass its `.schema` to fabricate(...).";
223
+ return `fabricate(...) takes a Schema, but was handed a ${typeof given}. A builder that still needs configuring, such as \`T.array(x)\`, becomes a Schema once you call \`.whereby(...)\` on it.`;
224
+ }
225
+ }
226
+ }
227
+ FabricatorError.FabricateArgumentError = FabricateArgumentError;
200
228
  class SynchronousStackError extends FabricatorError {
201
229
  constructor(){
202
230
  super();
@@ -1,7 +1,7 @@
1
1
  import { FabricatorError } from "../Error/index.js";
2
- import { toInnermostFrame } from "../Instance/Stack/Visible.js";
2
+ import { toEffectiveSource } from "../Instance/Stack/Visible.js";
3
3
  import { Primitive } from "../Primitive/index.js";
4
- import { isLayered, normalizeSalt } from "../Random/index.js";
4
+ import { isLayered, normalizeSalt, toRandomSource } from "../Random/index.js";
5
5
  import { toSchema } from "../Schema/Core.js";
6
6
  import { Adaptation, Fixed, Kind, Layer, Meta } from "../Types.js";
7
7
  import { inline } from "../Utility/Core.js";
@@ -187,7 +187,7 @@ function Constructor(source, stack, ancestry) {
187
187
  return Primitive.recursive.Fabricator({
188
188
  ...common,
189
189
  schema: s
190
- }, source.fork, make);
190
+ }, context.fork, make);
191
191
  }
192
192
  case "recursive.self":
193
193
  {
@@ -257,35 +257,39 @@ function Constructor(source, stack, ancestry) {
257
257
  case "object":
258
258
  {
259
259
  const s = schema;
260
- const definition = s[Meta].definition;
261
- const fields = {};
262
- for(const key in definition){
263
- const fieldSchema = definition[key];
264
- const fieldPath = [
265
- ...path,
266
- key
267
- ];
268
- fields[key] = inline(()=>{
269
- if (Fixed in fieldSchema) {
270
- const built = make(fieldSchema, fieldPath, context);
271
- const value = fieldSchema[Fixed];
272
- if (Primitive.object.compute.isObjectComputeFabricator(built)) return {
273
- ...built,
274
- [Kind]: built[Meta].source[Kind],
275
- fabricate: ()=>value
276
- };
277
- return {
278
- ...built,
279
- fabricate: ()=>value
280
- };
281
- }
282
- return make(fieldSchema, fieldPath, context);
283
- });
284
- }
260
+ const build = (definition)=>{
261
+ const fields = {};
262
+ for(const key in definition){
263
+ const fieldSchema = definition[key];
264
+ const fieldPath = [
265
+ ...path,
266
+ key
267
+ ];
268
+ fields[key] = inline(()=>{
269
+ if (Fixed in fieldSchema) {
270
+ const built = make(fieldSchema, fieldPath, context);
271
+ const value = fieldSchema[Fixed];
272
+ if (Primitive.object.compute.isObjectComputeFabricator(built)) return {
273
+ ...built,
274
+ [Kind]: built[Meta].source[Kind],
275
+ fabricate: ()=>value
276
+ };
277
+ return {
278
+ ...built,
279
+ fabricate: ()=>value
280
+ };
281
+ }
282
+ return make(fieldSchema, fieldPath, context);
283
+ });
284
+ }
285
+ return fields;
286
+ };
287
+ const fields = build(s[Meta].definition);
288
+ const hidden = s[Meta].hidden ? build(s[Meta].hidden) : {};
285
289
  return Primitive.object.Fabricator({
286
290
  ...common,
287
291
  schema: Primitive.object.rehydrate(s)
288
- }, fields);
292
+ }, fields, hidden);
289
293
  }
290
294
  default:
291
295
  throw new FabricatorError.UnknownKindError(String(kind), "construction");
@@ -312,13 +316,16 @@ function toConstructionContext(source, options, stack, ancestry) {
312
316
  path,
313
317
  kind
314
318
  }),
315
- algorithm: resolved.algorithm
319
+ algorithm: resolved.algorithm,
320
+ fork: (salt)=>toRandomSource({
321
+ salt,
322
+ algorithm: resolved.algorithm,
323
+ clock: trace.clock
324
+ })
316
325
  };
317
326
  }
318
327
  function resolveScope(source, options, stack, ancestry) {
319
- var _ref;
320
- var _toInnermostFrame;
321
- const base = null != (_ref = null == (_toInnermostFrame = toInnermostFrame(stack, ancestry)) ? void 0 : _toInnermostFrame.source) ? _ref : source;
328
+ const base = toEffectiveSource(source, stack, ancestry);
322
329
  const salt = inline(()=>{
323
330
  if (!options.salt) return;
324
331
  if (isLayered(options.salt)) return [
@@ -0,0 +1,23 @@
1
+ import { toEffectiveSource } from "../Instance/Stack/Visible.js";
2
+ import { FabricatorError } from "../Error/index.js";
3
+ import { isSchema } from "../Schema/Core.js";
4
+ function Fabricate(construct, source, stack, ancestry, fabricatorCache) {
5
+ function cacheFor(base) {
6
+ const existing = fabricatorCache.get(base);
7
+ if (existing) return existing;
8
+ const created = new WeakMap();
9
+ fabricatorCache.set(base, created);
10
+ return created;
11
+ }
12
+ function fabricatorFor(schema) {
13
+ if (!isSchema(schema)) throw new FabricatorError.FabricateArgumentError(schema);
14
+ const cache = cacheFor(toEffectiveSource(source, stack, ancestry));
15
+ const existing = cache.get(schema);
16
+ if (existing) return existing;
17
+ const built = new construct(schema);
18
+ cache.set(schema, built);
19
+ return built;
20
+ }
21
+ return (schema)=>fabricatorFor(schema).fabricate();
22
+ }
23
+ export { Fabricate };
@@ -1,6 +1,7 @@
1
1
  import { enumerables } from "../Enumeration/Enumerate.js";
2
2
  import { FabricatorError } from "../Error/index.js";
3
3
  import { Constructor } from "../Fabricator/Constructor.js";
4
+ import { Fabricate } from "../Fabricator/Fabricate.js";
4
5
  import { defaultAlgorithm, deriveClock, isLayered, normalizeSalt, toRandomSource } from "../Random/index.js";
5
6
  import { registry } from "../Schema/Registry.js";
6
7
  import { Layer } from "../Types.js";
@@ -12,6 +13,12 @@ function resolveCombinatorialLimit(limit) {
12
13
  if (!Number.isSafeInteger(limit) || limit < 1) throw new FabricatorError.InvalidCombinatorialLimitError(limit);
13
14
  return limit;
14
15
  }
16
+ function resolveInstant(clock) {
17
+ const given = clock.valueOf();
18
+ const instant = new Date(given).valueOf();
19
+ if (instant !== given) throw new FabricatorError.InvalidClockError(clock);
20
+ return instant;
21
+ }
15
22
  function resolveClock(config) {
16
23
  return "number" == typeof config.clock ? config.clock : deriveClock(config.algorithm, normalizeSalt(config.salt));
17
24
  }
@@ -32,7 +39,7 @@ function overlay(base, over) {
32
39
  const clock = inline(()=>{
33
40
  var _base_clock;
34
41
  if ("derived" === over.clock) return "derived";
35
- if (void 0 !== over.clock) return over.clock.valueOf();
42
+ if (void 0 !== over.clock) return resolveInstant(over.clock);
36
43
  return null != (_base_clock = base.clock) ? _base_clock : Date.now();
37
44
  });
38
45
  return {
@@ -46,6 +53,7 @@ function overlay(base, over) {
46
53
  };
47
54
  }
48
55
  function instantiate(config, stack, parent) {
56
+ var _ref;
49
57
  const ancestry = void 0 === parent ? [
50
58
  mint()
51
59
  ] : [
@@ -59,12 +67,15 @@ function instantiate(config, stack, parent) {
59
67
  });
60
68
  const Fabricator = Constructor(source, stack, ancestry);
61
69
  const { combinatorial, coverage } = enumerables(source, config.limits, stack, ancestry);
70
+ const fabricatorCache = null != (_ref = null == parent ? void 0 : parent.fabricatorCache) ? _ref : new WeakMap();
71
+ const fabricate = Fabricate(Fabricator, source, stack, ancestry, fabricatorCache);
62
72
  function derive(over) {
63
73
  const derived = overlay(config, over);
64
74
  return {
65
75
  ...instantiate(derived, stack, {
66
76
  ancestry,
67
- root: instance.root
77
+ root: instance.root,
78
+ fabricatorCache
68
79
  }),
69
80
  config: derived
70
81
  };
@@ -122,6 +133,7 @@ function instantiate(config, stack, parent) {
122
133
  return null != (_ref = null == parent ? void 0 : parent.root) ? _ref : instance;
123
134
  },
124
135
  Fabricator,
136
+ fabricate,
125
137
  combinatorial,
126
138
  coverage,
127
139
  salt: source.salt,
@@ -10,4 +10,9 @@ function toInnermostFrame(stack, ancestry) {
10
10
  const frames = stack.visible(ancestry);
11
11
  return frames[frames.length - 1];
12
12
  }
13
- export { toInnermostFrame, toVisible };
13
+ function toEffectiveSource(source, stack, ancestry) {
14
+ var _ref;
15
+ var _toInnermostFrame;
16
+ return null != (_ref = null == (_toInnermostFrame = toInnermostFrame(stack, ancestry)) ? void 0 : _toInnermostFrame.source) ? _ref : source;
17
+ }
18
+ export { toEffectiveSource, toInnermostFrame, toVisible };
@@ -1,12 +1,14 @@
1
1
  import { Adaptation, Kind, Meta, Produces } from "../../Types.js";
2
2
  import { Schema } from "./Schema.js";
3
- const registry = {
4
- ...Schema({
5
- [Kind]: "boolean",
6
- [Meta]: {},
7
- [Produces]: void 0,
8
- [Adaptation]: void 0
9
- })
10
- };
3
+ function registry() {
4
+ return {
5
+ ...Schema({
6
+ [Kind]: "boolean",
7
+ [Meta]: {},
8
+ [Produces]: void 0,
9
+ [Adaptation]: void 0
10
+ })
11
+ };
12
+ }
11
13
  const Registry = registry;
12
14
  export default Registry;
@@ -0,0 +1,12 @@
1
+ import { MAX_TIME } from "../../Types.js";
2
+ const unboundedEpoch = {
3
+ min: {
4
+ value: -MAX_TIME,
5
+ exclusive: false
6
+ },
7
+ max: {
8
+ value: MAX_TIME,
9
+ exclusive: false
10
+ }
11
+ };
12
+ export { unboundedEpoch };
@@ -2,6 +2,7 @@ import { assertNonemptyDiscrete, effectiveDiscrete, epochBound } from "../../Bou
2
2
  import { Distribution, sampler } from "../../Distribution/index.js";
3
3
  import { toStreamFromTrace } from "../../Random/index.js";
4
4
  import { Kind, MAX_TIME, Meta } from "../../Types.js";
5
+ import { unboundedEpoch } from "./Defaults.js";
5
6
  import { Schema } from "./Schema.js";
6
7
  function Fabricator(context) {
7
8
  const { schema, algorithm, trace } = context;
@@ -26,10 +27,7 @@ function Fabricator(context) {
26
27
  const whereby = meta.whereby;
27
28
  if ("past" === meta.mode) {
28
29
  const fabricate = whereby ? drawPastOrFuture({
29
- min: whereby.min ? epochBound(whereby.min) : {
30
- value: -MAX_TIME,
31
- exclusive: false
32
- },
30
+ min: whereby.min ? epochBound(whereby.min) : unboundedEpoch.min,
33
31
  max: {
34
32
  value: clock,
35
33
  exclusive: false
@@ -49,10 +47,7 @@ function Fabricator(context) {
49
47
  value: clock,
50
48
  exclusive: false
51
49
  },
52
- max: whereby.max ? epochBound(whereby.max) : {
53
- value: MAX_TIME,
54
- exclusive: false
55
- }
50
+ max: whereby.max ? epochBound(whereby.max) : unboundedEpoch.max
56
51
  }, "T.date.future", whereby.distribution, stream) : ()=>new Date(clock + stream.next() * (MAX_TIME - clock));
57
52
  return {
58
53
  [Kind]: "date",
@@ -63,8 +58,8 @@ function Fabricator(context) {
63
58
  };
64
59
  }
65
60
  const fabricate = whereby ? draw({
66
- min: epochBound(whereby.min),
67
- max: epochBound(whereby.max)
61
+ min: whereby.min ? epochBound(whereby.min) : unboundedEpoch.min,
62
+ max: whereby.max ? epochBound(whereby.max) : unboundedEpoch.max
68
63
  }, whereby.distribution, stream) : ()=>new Date((2 * stream.next() - 1) * MAX_TIME);
69
64
  return {
70
65
  [Kind]: "date",
@@ -1,55 +1,65 @@
1
1
  import { assertNonemptyDiscrete, epochBound, toBound } from "../../Bound.js";
2
2
  import { Adaptation, Kind, Meta, Produces } from "../../Types.js";
3
+ import { unboundedEpoch } from "./Defaults.js";
3
4
  import { Schema } from "./Schema.js";
4
- const registry = {
5
- ...Schema({
6
- [Kind]: "date",
7
- [Meta]: {},
8
- [Produces]: void 0,
9
- [Adaptation]: void 0
10
- }),
11
- whereby: (whereby)=>Schema({
12
- [Kind]: "date",
13
- [Meta]: {
14
- whereby: toWhereby(whereby)
15
- }
16
- }),
17
- past: {
18
- ...Schema({
19
- [Kind]: "date",
20
- [Meta]: {
21
- mode: "past"
22
- }
23
- }),
24
- whereby: (whereby)=>Schema({
25
- [Kind]: "date",
26
- [Meta]: {
27
- mode: "past",
28
- whereby: toWhereby(whereby)
29
- }
30
- })
31
- },
32
- future: {
5
+ function registry() {
6
+ return {
33
7
  ...Schema({
34
8
  [Kind]: "date",
35
- [Meta]: {
36
- mode: "future"
37
- }
9
+ [Meta]: {},
10
+ [Produces]: void 0,
11
+ [Adaptation]: void 0
38
12
  }),
39
- whereby: (whereby)=>Schema({
13
+ whereby: (whereby)=>{
14
+ const converted = toWhereby(whereby);
15
+ assertNonemptyDiscrete("T.date.whereby", converted.min ? epochBound(converted.min) : unboundedEpoch.min, converted.max ? epochBound(converted.max) : unboundedEpoch.max);
16
+ return Schema({
40
17
  [Kind]: "date",
41
18
  [Meta]: {
42
- mode: "future",
43
- whereby: toWhereby(whereby)
19
+ whereby: converted
44
20
  }
45
- })
46
- }
47
- };
21
+ });
22
+ },
23
+ get past () {
24
+ return {
25
+ ...Schema({
26
+ [Kind]: "date",
27
+ [Meta]: {
28
+ mode: "past"
29
+ }
30
+ }),
31
+ whereby: (whereby)=>Schema({
32
+ [Kind]: "date",
33
+ [Meta]: {
34
+ mode: "past",
35
+ whereby: toWhereby(whereby)
36
+ }
37
+ })
38
+ };
39
+ },
40
+ get future () {
41
+ return {
42
+ ...Schema({
43
+ [Kind]: "date",
44
+ [Meta]: {
45
+ mode: "future"
46
+ }
47
+ }),
48
+ whereby: (whereby)=>Schema({
49
+ [Kind]: "date",
50
+ [Meta]: {
51
+ mode: "future",
52
+ whereby: toWhereby(whereby)
53
+ }
54
+ })
55
+ };
56
+ }
57
+ };
58
+ }
48
59
  const Registry = registry;
49
60
  function toWhereby(input) {
50
61
  const min = void 0 === input.min ? void 0 : toBound(input.min);
51
62
  const max = void 0 === input.max ? void 0 : toBound(input.max);
52
- if (void 0 !== min && void 0 !== max) assertNonemptyDiscrete("T.date.whereby", epochBound(min), epochBound(max));
53
63
  return void 0 === input.distribution ? {
54
64
  min,
55
65
  max
@@ -12,8 +12,10 @@ export { default as nullable } from "./nullable/index.js";
12
12
  export { default as nullish } from "./nullish/index.js";
13
13
  export { default as number } from "./number/index.js";
14
14
  export { default as object } from "./object/index.js";
15
+ export { default as omit } from "./object/omit/index.js";
15
16
  export { default as omittable } from "./object/omittable/index.js";
16
17
  export { default as optional } from "./object/optional/index.js";
18
+ export { default as pick } from "./object/pick/index.js";
17
19
  export { default as opaque } from "./opaque/index.js";
18
20
  export { default as record } from "./record/index.js";
19
21
  export { default as recursive } from "./recursive/index.js";
@@ -1,8 +1,10 @@
1
1
  import { Kind, Meta } from "../../Types.js";
2
2
  import { Schema } from "./Schema.js";
3
- const registry = Schema({
4
- [Kind]: "null",
5
- [Meta]: {}
6
- });
3
+ function registry() {
4
+ return Schema({
5
+ [Kind]: "null",
6
+ [Meta]: {}
7
+ });
8
+ }
7
9
  const Registry = registry;
8
10
  export default Registry;
@@ -2,7 +2,7 @@ import { constrainContinuous, effectiveDiscrete } from "../../Bound.js";
2
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
- import { unboundedContinuous, unboundedDiscrete } from "./defaults.js";
5
+ import { unboundedContinuous, unboundedDiscrete } from "./Defaults.js";
6
6
  import { Schema } from "./Schema.js";
7
7
  function Fabricator(context) {
8
8
  var _ref, _ref1, _range_distribution;
@@ -1,45 +1,51 @@
1
1
  import { assertNonemptyContinuous, assertNonemptyDiscrete, toBound } from "../../Bound.js";
2
2
  import { Adaptation, Kind, Meta, Produces } from "../../Types.js";
3
3
  import bigint from "../bigint/index.js";
4
- import { unboundedContinuous, unboundedDiscrete } from "./defaults.js";
4
+ import { unboundedContinuous, unboundedDiscrete } from "./Defaults.js";
5
5
  import { Schema } from "./Schema.js";
6
- const registry = {
7
- ...Schema({
8
- [Kind]: "number",
9
- [Meta]: {},
10
- [Produces]: void 0,
11
- [Adaptation]: void 0
12
- }),
13
- whereby: (whereby)=>Schema({
14
- [Kind]: "number",
15
- [Meta]: {
16
- whereby: toWhereby(whereby, false)
17
- }
18
- }),
19
- integer: {
6
+ function registry() {
7
+ return {
20
8
  ...Schema({
21
9
  [Kind]: "number",
22
- [Meta]: {
23
- integer: true
24
- }
10
+ [Meta]: {},
11
+ [Produces]: void 0,
12
+ [Adaptation]: void 0
25
13
  }),
26
14
  whereby: (whereby)=>Schema({
27
15
  [Kind]: "number",
28
16
  [Meta]: {
29
- integer: true,
30
- whereby: toWhereby(whereby, true)
17
+ whereby: toWhereby(whereby, false)
31
18
  }
32
19
  }),
33
- sequence: Schema({
34
- [Kind]: "number",
35
- [Meta]: {
36
- sequence: true,
37
- integer: true
38
- }
39
- }),
40
- big: bigint
41
- }
42
- };
20
+ get integer () {
21
+ return {
22
+ ...Schema({
23
+ [Kind]: "number",
24
+ [Meta]: {
25
+ integer: true
26
+ }
27
+ }),
28
+ whereby: (whereby)=>Schema({
29
+ [Kind]: "number",
30
+ [Meta]: {
31
+ integer: true,
32
+ whereby: toWhereby(whereby, true)
33
+ }
34
+ }),
35
+ get sequence () {
36
+ return Schema({
37
+ [Kind]: "number",
38
+ [Meta]: {
39
+ sequence: true,
40
+ integer: true
41
+ }
42
+ });
43
+ },
44
+ big: bigint
45
+ };
46
+ }
47
+ };
48
+ }
43
49
  const Registry = registry;
44
50
  function toWhereby(input, integer) {
45
51
  const min = void 0 === input.min ? void 0 : toBound(input.min);