@databehave/schema 0.1.3 → 0.2.0
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/CHANGELOG.md +18 -0
- package/README.md +12 -1
- package/dist/dataset/dataset.d.ts +6 -0
- package/dist/dataset/dataset.d.ts.map +1 -0
- package/dist/dataset/dataset.js +6 -0
- package/dist/dataset/dataset.js.map +1 -0
- package/dist/dataset/generate.d.ts +49 -0
- package/dist/dataset/generate.d.ts.map +1 -0
- package/dist/dataset/generate.js +96 -0
- package/dist/dataset/generate.js.map +1 -0
- package/dist/dataset/relate.d.ts +32 -0
- package/dist/dataset/relate.d.ts.map +1 -0
- package/dist/dataset/relate.js +46 -0
- package/dist/dataset/relate.js.map +1 -0
- package/dist/foundation/axes.d.ts +96 -0
- package/dist/foundation/axes.d.ts.map +1 -0
- package/dist/foundation/axes.js +16 -0
- package/dist/foundation/axes.js.map +1 -0
- package/dist/foundation/errors.d.ts +101 -0
- package/dist/foundation/errors.d.ts.map +1 -0
- package/dist/foundation/errors.js +91 -0
- package/dist/foundation/errors.js.map +1 -0
- package/dist/foundation/hash.d.ts +12 -0
- package/dist/foundation/hash.d.ts.map +1 -0
- package/dist/foundation/hash.js +21 -0
- package/dist/foundation/hash.js.map +1 -0
- package/dist/foundation/ir.d.ts +99 -0
- package/dist/foundation/ir.d.ts.map +1 -0
- package/dist/foundation/ir.js +16 -0
- package/dist/foundation/ir.js.map +1 -0
- package/dist/foundation/prng.d.ts +27 -0
- package/dist/foundation/prng.d.ts.map +1 -0
- package/dist/foundation/prng.js +56 -0
- package/dist/foundation/prng.js.map +1 -0
- package/dist/foundation/types.d.ts +116 -0
- package/dist/foundation/types.d.ts.map +1 -0
- package/dist/foundation/types.js +155 -0
- package/dist/foundation/types.js.map +1 -0
- package/dist/foundation/walk.d.ts +8 -0
- package/dist/foundation/walk.d.ts.map +1 -0
- package/dist/foundation/walk.js +9 -0
- package/dist/foundation/walk.js.map +1 -0
- package/dist/generator/engine.d.ts +69 -0
- package/dist/generator/engine.d.ts.map +1 -0
- package/dist/generator/engine.js +4 -0
- package/dist/generator/engine.js.map +1 -0
- package/dist/generator/replay.d.ts +38 -0
- package/dist/generator/replay.d.ts.map +1 -0
- package/dist/generator/replay.js +44 -0
- package/dist/generator/replay.js.map +1 -0
- package/dist/generator/trace.d.ts +54 -0
- package/dist/generator/trace.d.ts.map +1 -0
- package/dist/generator/trace.js +38 -0
- package/dist/generator/trace.js.map +1 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +40 -0
- package/dist/index.js.map +1 -0
- package/dist/internal.d.ts +22 -0
- package/dist/internal.d.ts.map +1 -0
- package/dist/internal.js +25 -0
- package/dist/internal.js.map +1 -0
- package/dist/plugin.d.ts +7 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +14 -0
- package/dist/plugin.js.map +1 -0
- package/dist/runtime/contracts.d.ts +101 -0
- package/dist/runtime/contracts.d.ts.map +1 -0
- package/dist/runtime/contracts.js +67 -0
- package/dist/runtime/contracts.js.map +1 -0
- package/dist/runtime/runtime.d.ts +56 -0
- package/dist/runtime/runtime.d.ts.map +1 -0
- package/dist/runtime/runtime.js +392 -0
- package/dist/runtime/runtime.js.map +1 -0
- package/dist/runtime.d.ts +7 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +5 -0
- package/dist/runtime.js.map +1 -0
- package/dist/schema/composites.d.ts +104 -0
- package/dist/schema/composites.d.ts.map +1 -0
- package/dist/schema/composites.js +134 -0
- package/dist/schema/composites.js.map +1 -0
- package/dist/schema/conditional.d.ts +28 -0
- package/dist/schema/conditional.d.ts.map +1 -0
- package/dist/schema/conditional.js +52 -0
- package/dist/schema/conditional.js.map +1 -0
- package/dist/schema/decimal.d.ts +33 -0
- package/dist/schema/decimal.d.ts.map +1 -0
- package/dist/schema/decimal.js +39 -0
- package/dist/schema/decimal.js.map +1 -0
- package/dist/schema/primitives.d.ts +47 -0
- package/dist/schema/primitives.d.ts.map +1 -0
- package/dist/schema/primitives.js +78 -0
- package/dist/schema/primitives.js.map +1 -0
- package/dist/standard/behaviors.d.ts +6 -0
- package/dist/standard/behaviors.d.ts.map +1 -0
- package/dist/standard/behaviors.js +358 -0
- package/dist/standard/behaviors.js.map +1 -0
- package/dist/standard/generation.d.ts +53 -0
- package/dist/standard/generation.d.ts.map +1 -0
- package/dist/standard/generation.js +359 -0
- package/dist/standard/generation.js.map +1 -0
- package/dist/standard/kinds.d.ts +6 -0
- package/dist/standard/kinds.d.ts.map +1 -0
- package/dist/standard/kinds.js +178 -0
- package/dist/standard/kinds.js.map +1 -0
- package/dist/standard/runtime.d.ts +3 -0
- package/dist/standard/runtime.d.ts.map +1 -0
- package/dist/standard/runtime.js +9 -0
- package/dist/standard/runtime.js.map +1 -0
- package/dist/standard/validation.d.ts +44 -0
- package/dist/standard/validation.d.ts.map +1 -0
- package/dist/standard/validation.js +353 -0
- package/dist/standard/validation.js.map +1 -0
- package/dist/standard.d.ts +5 -0
- package/dist/standard.d.ts.map +1 -0
- package/dist/standard.js +5 -0
- package/dist/standard.js.map +1 -0
- package/dist/validator/parse.d.ts +13 -0
- package/dist/validator/parse.d.ts.map +1 -0
- package/dist/validator/parse.js +4 -0
- package/dist/validator/parse.js.map +1 -0
- package/package.json +26 -4
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Composite schema builders: obj, arr, tuple, union, literal, enum_.
|
|
3
|
+
*
|
|
4
|
+
* These produce TS types derived from their inputs via mapped / conditional
|
|
5
|
+
* types so that {@link Infer} yields the exact composite shape.
|
|
6
|
+
*/
|
|
7
|
+
import type { ArrayKind, EnumKind, LiteralKind, ObjectKind, TupleKind, UnionKind } from '../foundation/ir.js';
|
|
8
|
+
import { Discrete, Schema, type Infer } from '../foundation/types.js';
|
|
9
|
+
type Fields = Record<string, Schema>;
|
|
10
|
+
/** Keys whose schema carries `optional: true` become optional in the output. */
|
|
11
|
+
type OptionalKeys<F extends Fields> = {
|
|
12
|
+
[K in keyof F]: F[K]['_node']['mods'] extends {
|
|
13
|
+
optional: true;
|
|
14
|
+
} ? K : never;
|
|
15
|
+
}[keyof F];
|
|
16
|
+
type RequiredKeys<F extends Fields> = Exclude<keyof F, OptionalKeys<F>>;
|
|
17
|
+
export type InferObject<F extends Fields> = {
|
|
18
|
+
[K in RequiredKeys<F>]: Infer<F[K]>;
|
|
19
|
+
} & {
|
|
20
|
+
[K in OptionalKeys<F>]?: Infer<F[K]>;
|
|
21
|
+
};
|
|
22
|
+
export declare class ObjectSchema<F extends Fields = Fields> extends Schema<{
|
|
23
|
+
[K in keyof InferObject<F>]: InferObject<F>[K];
|
|
24
|
+
}> {
|
|
25
|
+
readonly _node: ObjectKind & {
|
|
26
|
+
mods?: import('../foundation/ir.js').Modifiers;
|
|
27
|
+
};
|
|
28
|
+
readonly _fields: F;
|
|
29
|
+
constructor(fields: F);
|
|
30
|
+
/**
|
|
31
|
+
* Multi-field invariant — a predicate over the whole assembled object.
|
|
32
|
+
*
|
|
33
|
+
* Equivalent to `.invariant(...)` but typed against the object's inferred
|
|
34
|
+
* shape, so cross-field rules (e.g. `start <= end`) get full type-checking.
|
|
35
|
+
* The engine rejection-samples the object up to MAX_ATTEMPTS until the
|
|
36
|
+
* predicate holds.
|
|
37
|
+
*/
|
|
38
|
+
correlate(fn: (row: InferObject<F>) => boolean): this;
|
|
39
|
+
}
|
|
40
|
+
export declare const obj: <F extends Fields>(fields: F) => ObjectSchema<F>;
|
|
41
|
+
export declare class ArraySchema<S extends Schema> extends Schema<Infer<S>[]> {
|
|
42
|
+
readonly _node: ArrayKind & {
|
|
43
|
+
mods?: import('../foundation/ir.js').Modifiers;
|
|
44
|
+
};
|
|
45
|
+
readonly _item: S;
|
|
46
|
+
constructor(item: S, opts?: {
|
|
47
|
+
length?: number;
|
|
48
|
+
minLength?: number;
|
|
49
|
+
maxLength?: number;
|
|
50
|
+
});
|
|
51
|
+
/**
|
|
52
|
+
* Rebuild a fresh `ArraySchema` while preserving every previously-set
|
|
53
|
+
* bound *and* every modifier (axes, occasionally, derivedFrom,
|
|
54
|
+
* describe, weighted, …). Without this, `.min(2).max(10)` would
|
|
55
|
+
* silently drop the `min` and `arr(int()).typically(1,5).min(2)`
|
|
56
|
+
* would lose the distribution axis because the constructor builds
|
|
57
|
+
* the IR node from scratch. Mods live in `_node.mods`, which is
|
|
58
|
+
* outside the bounds-only constructor surface, so they have to be
|
|
59
|
+
* grafted back on after construction via `withMods`.
|
|
60
|
+
*/
|
|
61
|
+
private rebuild;
|
|
62
|
+
length(n: number): ArraySchema<S>;
|
|
63
|
+
min(n: number): ArraySchema<S>;
|
|
64
|
+
max(n: number): ArraySchema<S>;
|
|
65
|
+
}
|
|
66
|
+
export declare const arr: <S extends Schema>(item: S) => ArraySchema<S>;
|
|
67
|
+
type InferTuple<T extends readonly Schema[]> = {
|
|
68
|
+
[K in keyof T]: T[K] extends Schema ? Infer<T[K]> : never;
|
|
69
|
+
};
|
|
70
|
+
export declare class TupleSchema<T extends readonly Schema[]> extends Schema<InferTuple<T>> {
|
|
71
|
+
readonly _node: TupleKind & {
|
|
72
|
+
mods?: import('../foundation/ir.js').Modifiers;
|
|
73
|
+
};
|
|
74
|
+
readonly _items: T;
|
|
75
|
+
constructor(items: T);
|
|
76
|
+
}
|
|
77
|
+
export declare const tuple: <T extends readonly Schema[]>(...items: T) => TupleSchema<T>;
|
|
78
|
+
type InferUnion<T extends readonly Schema[]> = T[number] extends Schema ? Infer<T[number]> : never;
|
|
79
|
+
export declare class UnionSchema<T extends readonly Schema[]> extends Schema<InferUnion<T>> {
|
|
80
|
+
readonly _node: UnionKind & {
|
|
81
|
+
mods?: import('../foundation/ir.js').Modifiers;
|
|
82
|
+
};
|
|
83
|
+
readonly _options: T;
|
|
84
|
+
constructor(options: T);
|
|
85
|
+
}
|
|
86
|
+
export declare const union: <T extends readonly Schema[]>(...options: T) => UnionSchema<T>;
|
|
87
|
+
export declare class LiteralSchema<V extends string | number | boolean | null> extends Schema<V> {
|
|
88
|
+
readonly _node: LiteralKind & {
|
|
89
|
+
mods?: import('../foundation/ir.js').Modifiers;
|
|
90
|
+
};
|
|
91
|
+
readonly [Discrete]: true;
|
|
92
|
+
}
|
|
93
|
+
export declare const literal: <V extends string | number | boolean | null>(value: V) => LiteralSchema<V>;
|
|
94
|
+
export declare class EnumSchema<V extends string | number> extends Schema<V> {
|
|
95
|
+
readonly _node: EnumKind & {
|
|
96
|
+
mods?: import('../foundation/ir.js').Modifiers;
|
|
97
|
+
};
|
|
98
|
+
readonly [Discrete]: true;
|
|
99
|
+
readonly _values: readonly V[];
|
|
100
|
+
constructor(values: readonly V[]);
|
|
101
|
+
}
|
|
102
|
+
export declare const enum_: <V extends string | number>(values: readonly V[]) => EnumSchema<V>;
|
|
103
|
+
export {};
|
|
104
|
+
//# sourceMappingURL=composites.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composites.d.ts","sourceRoot":"","sources":["../../src/schema/composites.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,SAAS,EACT,QAAQ,EACR,WAAW,EACX,UAAU,EAEV,SAAS,EACT,SAAS,EACV,MAAM,qBAAqB,CAAA;AAE5B,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,KAAK,EAAE,MAAM,wBAAwB,CAAA;AAMrE,KAAK,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;AAgBpC,gFAAgF;AAChF,KAAK,YAAY,CAAC,CAAC,SAAS,MAAM,IAAI;KACnC,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,SAAS;QAAE,QAAQ,EAAE,IAAI,CAAA;KAAE,GAAG,CAAC,GAAG,KAAK;CAC7E,CAAC,MAAM,CAAC,CAAC,CAAA;AAEV,KAAK,YAAY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O,MAAM,KAAK,GAAI,CAAC,SAAS,MAAM,GAAG,MAAM,EAAE,QAAQ,SAAS,CAAC,EAAE,KAAG,UAAU,CAAC,CAAC,CAC5D,CAAA"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Composite schema builders: obj, arr, tuple, union, literal, enum_.
|
|
3
|
+
*
|
|
4
|
+
* These produce TS types derived from their inputs via mapped / conditional
|
|
5
|
+
* types so that {@link Infer} yields the exact composite shape.
|
|
6
|
+
*/
|
|
7
|
+
import { withMods } from '../foundation/ir.js';
|
|
8
|
+
import { Discrete, Schema } from '../foundation/types.js';
|
|
9
|
+
/** Field names that would clobber Object.prototype or pollute the prototype chain. */
|
|
10
|
+
const FORBIDDEN_FIELD_NAMES = new Set(['__proto__', 'prototype', 'constructor']);
|
|
11
|
+
const assertSafeFieldNames = (fields) => {
|
|
12
|
+
for (const k of Object.keys(fields)) {
|
|
13
|
+
if (FORBIDDEN_FIELD_NAMES.has(k)) {
|
|
14
|
+
throw new RangeError(`obj(): field name ${JSON.stringify(k)} is forbidden ` +
|
|
15
|
+
`(would shadow Object.prototype; rename the field).`);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
export class ObjectSchema extends Schema {
|
|
20
|
+
_fields;
|
|
21
|
+
constructor(fields) {
|
|
22
|
+
assertSafeFieldNames(fields);
|
|
23
|
+
const irFields = {};
|
|
24
|
+
for (const k of Object.keys(fields)) {
|
|
25
|
+
irFields[k] = fields[k]._node;
|
|
26
|
+
}
|
|
27
|
+
super({ kind: 'object', fields: irFields });
|
|
28
|
+
this._fields = fields;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Multi-field invariant — a predicate over the whole assembled object.
|
|
32
|
+
*
|
|
33
|
+
* Equivalent to `.invariant(...)` but typed against the object's inferred
|
|
34
|
+
* shape, so cross-field rules (e.g. `start <= end`) get full type-checking.
|
|
35
|
+
* The engine rejection-samples the object up to MAX_ATTEMPTS until the
|
|
36
|
+
* predicate holds.
|
|
37
|
+
*/
|
|
38
|
+
correlate(fn) {
|
|
39
|
+
return this.invariant((v) => fn(v));
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
export const obj = (fields) => new ObjectSchema(fields);
|
|
43
|
+
// ──────────────────────────────────────────────────────────────────────────
|
|
44
|
+
// array
|
|
45
|
+
// ──────────────────────────────────────────────────────────────────────────
|
|
46
|
+
export class ArraySchema extends Schema {
|
|
47
|
+
_item;
|
|
48
|
+
constructor(item, opts = {}) {
|
|
49
|
+
const base = {
|
|
50
|
+
kind: 'array',
|
|
51
|
+
item: item._node,
|
|
52
|
+
...(opts.length !== undefined ? { length: opts.length } : {}),
|
|
53
|
+
...(opts.minLength !== undefined ? { minLength: opts.minLength } : {}),
|
|
54
|
+
...(opts.maxLength !== undefined ? { maxLength: opts.maxLength } : {}),
|
|
55
|
+
};
|
|
56
|
+
super(base);
|
|
57
|
+
this._item = item;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Rebuild a fresh `ArraySchema` while preserving every previously-set
|
|
61
|
+
* bound *and* every modifier (axes, occasionally, derivedFrom,
|
|
62
|
+
* describe, weighted, …). Without this, `.min(2).max(10)` would
|
|
63
|
+
* silently drop the `min` and `arr(int()).typically(1,5).min(2)`
|
|
64
|
+
* would lose the distribution axis because the constructor builds
|
|
65
|
+
* the IR node from scratch. Mods live in `_node.mods`, which is
|
|
66
|
+
* outside the bounds-only constructor surface, so they have to be
|
|
67
|
+
* grafted back on after construction via `withMods`.
|
|
68
|
+
*/
|
|
69
|
+
rebuild(patch) {
|
|
70
|
+
const node = this._node;
|
|
71
|
+
const next = new ArraySchema(this._item, {
|
|
72
|
+
...(node.length !== undefined ? { length: node.length } : {}),
|
|
73
|
+
...(node.minLength !== undefined ? { minLength: node.minLength } : {}),
|
|
74
|
+
...(node.maxLength !== undefined ? { maxLength: node.maxLength } : {}),
|
|
75
|
+
...patch,
|
|
76
|
+
});
|
|
77
|
+
if (node.mods) {
|
|
78
|
+
// `_node` is declared `readonly` for the public API but we own
|
|
79
|
+
// both ends of the assignment here — the just-built instance is
|
|
80
|
+
// not observable to anyone else yet, so re-seating its IR node
|
|
81
|
+
// is safe and avoids an extra clone.
|
|
82
|
+
;
|
|
83
|
+
next._node = withMods(next._node, node.mods);
|
|
84
|
+
}
|
|
85
|
+
return next;
|
|
86
|
+
}
|
|
87
|
+
length(n) {
|
|
88
|
+
return this.rebuild({ length: n });
|
|
89
|
+
}
|
|
90
|
+
min(n) {
|
|
91
|
+
return this.rebuild({ minLength: n });
|
|
92
|
+
}
|
|
93
|
+
max(n) {
|
|
94
|
+
return this.rebuild({ maxLength: n });
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
export const arr = (item) => new ArraySchema(item);
|
|
98
|
+
export class TupleSchema extends Schema {
|
|
99
|
+
_items;
|
|
100
|
+
constructor(items) {
|
|
101
|
+
super({ kind: 'tuple', items: items.map((s) => s._node) });
|
|
102
|
+
this._items = items;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
export const tuple = (...items) => new TupleSchema(items);
|
|
106
|
+
export class UnionSchema extends Schema {
|
|
107
|
+
_options;
|
|
108
|
+
constructor(options) {
|
|
109
|
+
if (options.length === 0) {
|
|
110
|
+
throw new RangeError('union: requires at least one option');
|
|
111
|
+
}
|
|
112
|
+
super({ kind: 'union', options: options.map((s) => s._node) });
|
|
113
|
+
this._options = options;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
export const union = (...options) => new UnionSchema(options);
|
|
117
|
+
// ──────────────────────────────────────────────────────────────────────────
|
|
118
|
+
// literal / enum
|
|
119
|
+
// ──────────────────────────────────────────────────────────────────────────
|
|
120
|
+
export class LiteralSchema extends Schema {
|
|
121
|
+
}
|
|
122
|
+
export const literal = (value) => new LiteralSchema({ kind: 'literal', value });
|
|
123
|
+
export class EnumSchema extends Schema {
|
|
124
|
+
_values;
|
|
125
|
+
constructor(values) {
|
|
126
|
+
if (values.length === 0) {
|
|
127
|
+
throw new RangeError('enum: requires at least one value');
|
|
128
|
+
}
|
|
129
|
+
super({ kind: 'enum', values });
|
|
130
|
+
this._values = values;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
export const enum_ = (values) => new EnumSchema(values);
|
|
134
|
+
//# sourceMappingURL=composites.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composites.js","sourceRoot":"","sources":["../../src/schema/composites.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAWH,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAc,MAAM,wBAAwB,CAAA;AAQrE,sFAAsF;AACtF,MAAM,qBAAqB,GAAG,IAAI,GAAG,CAAC,CAAC,WAAW,EAAE,WAAW,EAAE,aAAa,CAAC,CAAC,CAAA;AAEhF,MAAM,oBAAoB,GAAG,CAAC,MAAc,EAAQ,EAAE;IACpD,KAAK,MAAM,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QACpC,IAAI,qBAAqB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;YACjC,MAAM,IAAI,UAAU,CAClB,qBAAqB,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,gBAAgB;gBACpD,oDAAoD,CACvD,CAAA;QACH,CAAC;IACH,CAAC;AACH,CAAC,CAAA;AAeD,MAAM,OAAO,YAAwC,SAAQ,MAG5D;IAEU,OAAO,CAAG;IAEnB,YAAY,MAAS;QACnB,oBAAoB,CAAC,MAAM,CAAC,CAAA;QAC5B,MAAM,QAAQ,GAA6D,EAAE,CAAA;QAC7E,KAAK,MAAM,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;YACpC,QAAQ,CAAC,CAAC,CAAC,GAAI,MAAM,CAAC,CAAC,CAAY,CAAC,KAAK,CAAA;QAC3C,CA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,MAAoB;QAC9B,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACxB,MAAM,IAAI,UAAU,CAAC,mCAAmC,CAAC,CAAA;QAC3D,CAAC;QACD,KAAK,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;QAC/B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAA;IACvB,CAAC;CACF;AAED,MAAM,CAAC,MAAM,KAAK,GAAG,CAA4B,MAAoB,EAAiB,EAAE,CACtF,IAAI,UAAU,CAAC,MAAM,CAAC,CAAA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Discriminated union.
|
|
3
|
+
*
|
|
4
|
+
* `discriminated(key, map)` builds a schema whose branches are selected by
|
|
5
|
+
* the value of the named discriminator field, both during generation and
|
|
6
|
+
* during validation.
|
|
7
|
+
*
|
|
8
|
+
* Each entry in `map` must be an object-kind schema whose `key` field is a
|
|
9
|
+
* `literal(...)` matching the map key. This is enforced at build time so
|
|
10
|
+
* the discriminator is genuinely useful: generation picks one branch and
|
|
11
|
+
* sets the key; validation reads the key and dispatches to the matching
|
|
12
|
+
* branch (O(1), with errors keyed on the discriminator).
|
|
13
|
+
*
|
|
14
|
+
* ```ts
|
|
15
|
+
* const Variant = discriminated('kind', {
|
|
16
|
+
* alpha: obj({ kind: literal('alpha'), score: decimal(10, 4) }),
|
|
17
|
+
* beta: obj({ kind: literal('beta'), weight: decimal(10, 4) }),
|
|
18
|
+
* })
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
import { Schema, type Infer } from '../foundation/types.js';
|
|
22
|
+
/**
|
|
23
|
+
* Build a discriminated union keyed on `key`. Each value in `map` must be a
|
|
24
|
+
* schema (typically `obj({...})`) whose `key` field is a `literal(...)`
|
|
25
|
+
* matching the map key.
|
|
26
|
+
*/
|
|
27
|
+
export declare const discriminated: <K extends string, M extends Readonly<Record<string, Schema<unknown>>>>(key: K, map: M) => Schema<{ [P in keyof M]: Infer<M[P]>; }[keyof M]>;
|
|
28
|
+
//# sourceMappingURL=conditional.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conditional.d.ts","sourceRoot":"","sources":["../../src/schema/conditional.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,EAAE,MAAM,EAAE,KAAK,KAAK,EAAE,MAAM,wBAAwB,CAAA;AAK3D;;;;GAIG;AACH,eAAO,MAAM,aAAa,GACxB,CAAC,SAAS,MAAM,EAGhB,CAAC,SAAS,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAEnD,KAAK,CAAC,EACN,KAAK,CAAC,KACL,MAAM,CAAC,GAAG,CAAC,IAAI,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAE,CAAC,MAAM,CAAC,CAAC,CA+BjD,CAAA"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Discriminated union.
|
|
3
|
+
*
|
|
4
|
+
* `discriminated(key, map)` builds a schema whose branches are selected by
|
|
5
|
+
* the value of the named discriminator field, both during generation and
|
|
6
|
+
* during validation.
|
|
7
|
+
*
|
|
8
|
+
* Each entry in `map` must be an object-kind schema whose `key` field is a
|
|
9
|
+
* `literal(...)` matching the map key. This is enforced at build time so
|
|
10
|
+
* the discriminator is genuinely useful: generation picks one branch and
|
|
11
|
+
* sets the key; validation reads the key and dispatches to the matching
|
|
12
|
+
* branch (O(1), with errors keyed on the discriminator).
|
|
13
|
+
*
|
|
14
|
+
* ```ts
|
|
15
|
+
* const Variant = discriminated('kind', {
|
|
16
|
+
* alpha: obj({ kind: literal('alpha'), score: decimal(10, 4) }),
|
|
17
|
+
* beta: obj({ kind: literal('beta'), weight: decimal(10, 4) }),
|
|
18
|
+
* })
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
import { Schema } from '../foundation/types.js';
|
|
22
|
+
const isObjectNode = (n) => n.kind === 'object';
|
|
23
|
+
/**
|
|
24
|
+
* Build a discriminated union keyed on `key`. Each value in `map` must be a
|
|
25
|
+
* schema (typically `obj({...})`) whose `key` field is a `literal(...)`
|
|
26
|
+
* matching the map key.
|
|
27
|
+
*/
|
|
28
|
+
export const discriminated = (key, map) => {
|
|
29
|
+
const tags = Object.keys(map);
|
|
30
|
+
if (tags.length === 0) {
|
|
31
|
+
throw new RangeError(`discriminated("${key}"): map must contain at least one branch`);
|
|
32
|
+
}
|
|
33
|
+
const branches = {};
|
|
34
|
+
for (const tag of tags) {
|
|
35
|
+
const branch = map[tag]._node;
|
|
36
|
+
if (!isObjectNode(branch)) {
|
|
37
|
+
throw new RangeError(`discriminated("${key}"): branch ${JSON.stringify(tag)} must be an obj({...}) schema`);
|
|
38
|
+
}
|
|
39
|
+
const keyField = branch.fields[key];
|
|
40
|
+
if (keyField === undefined) {
|
|
41
|
+
throw new RangeError(`discriminated("${key}"): branch ${JSON.stringify(tag)} is missing the discriminator field "${key}"`);
|
|
42
|
+
}
|
|
43
|
+
if (keyField.kind !== 'literal' || keyField.value !== tag) {
|
|
44
|
+
throw new RangeError(`discriminated("${key}"): branch ${JSON.stringify(tag)} must declare ` +
|
|
45
|
+
`${key}: literal(${JSON.stringify(tag)})`);
|
|
46
|
+
}
|
|
47
|
+
branches[tag] = branch;
|
|
48
|
+
}
|
|
49
|
+
const node = { kind: 'discriminated', key, branches };
|
|
50
|
+
return new Schema(node);
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=conditional.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conditional.js","sourceRoot":"","sources":["../../src/schema/conditional.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,EAAE,MAAM,EAAc,MAAM,wBAAwB,CAAA;AAE3D,MAAM,YAAY,GAAG,CA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G,MAAM,CAAA;IACxB,CAAC;IAED,MAAM,IAAI,GAAsB,EAAE,IAAI,EAAE,eAAe,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAA;IACxE,OAAO,IAAI,MAAM,CAAC,IAAI,CAAgE,CAAA;AACxF,CAAC,CAAA"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decimal — fixed-point numeric represented as a string for precision safety.
|
|
3
|
+
*
|
|
4
|
+
* Targets Snowflake / Postgres NUMERIC(precision, scale). Generated values are
|
|
5
|
+
* always strings (e.g. `"123.4500000000000000000"` for scale=19) so callers
|
|
6
|
+
* never lose precision through JavaScript number coercion.
|
|
7
|
+
*
|
|
8
|
+
* The inferred type is `string` for ergonomic interop with the rest of the
|
|
9
|
+
* ecosystem. Callers needing a nominal brand can intersect via `Infer<typeof S>
|
|
10
|
+
* & Brand` themselves; databehave intentionally avoids forcing a brand to keep
|
|
11
|
+
* `decimal().default('0.0')` and JSON round-trips friction-free.
|
|
12
|
+
*/
|
|
13
|
+
import type { DecimalKind, Modifiers } from '../foundation/ir.js';
|
|
14
|
+
import { Continuous, Numeric, Schema } from '../foundation/types.js';
|
|
15
|
+
export declare class DecimalSchema extends Schema<string> {
|
|
16
|
+
readonly _node: DecimalKind & {
|
|
17
|
+
mods?: Modifiers;
|
|
18
|
+
};
|
|
19
|
+
readonly [Numeric]: true;
|
|
20
|
+
readonly [Continuous]: true;
|
|
21
|
+
/** Inclusive lower bound. Pass as a numeric string. */
|
|
22
|
+
min(value: string | number): DecimalSchema;
|
|
23
|
+
/** Inclusive upper bound. Pass as a numeric string. */
|
|
24
|
+
max(value: string | number): DecimalSchema;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Declare a fixed-point decimal column.
|
|
28
|
+
*
|
|
29
|
+
* @param precision - total significant digits (1..38 for Snowflake)
|
|
30
|
+
* @param scale - digits after the decimal point (0..precision)
|
|
31
|
+
*/
|
|
32
|
+
export declare const decimal: (precision: number, scale: number) => DecimalSchema;
|
|
33
|
+
//# sourceMappingURL=decimal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decimal.d.ts","sourceRoot":"","sources":["../../src/schema/decimal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AACjE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAEpE,qBAAa,aAAc,SAAQ,MAAM,CAAC,MAAM,CAAC;IAC/C,SAAiB,KAAK,EAAE,WAAW,GAAG;QAAE,IAAI,CAAC,EAAE,SAAS,CAAA;KAAE,CAAA;IAC1D,SAAiB,CAAC,OAAO,CAAC,EAAE,IAAI,CAAA;IAChC,SAAiB,CAAC,UAAU,CAAC,EAAE,IAAI,CAAA;IAEnC,uDAAuD;IACvD,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,aAAa;IAG1C,uDAAuD;IACvD,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,aAAa;CAG3C;AAED;;;;;GAKG;AACH,eAAO,MAAM,OAAO,GAAI,WAAW,MAAM,EAAE,OAAO,MAAM,KAAG,aAQ1D,CAAA"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decimal — fixed-point numeric represented as a string for precision safety.
|
|
3
|
+
*
|
|
4
|
+
* Targets Snowflake / Postgres NUMERIC(precision, scale). Generated values are
|
|
5
|
+
* always strings (e.g. `"123.4500000000000000000"` for scale=19) so callers
|
|
6
|
+
* never lose precision through JavaScript number coercion.
|
|
7
|
+
*
|
|
8
|
+
* The inferred type is `string` for ergonomic interop with the rest of the
|
|
9
|
+
* ecosystem. Callers needing a nominal brand can intersect via `Infer<typeof S>
|
|
10
|
+
* & Brand` themselves; databehave intentionally avoids forcing a brand to keep
|
|
11
|
+
* `decimal().default('0.0')` and JSON round-trips friction-free.
|
|
12
|
+
*/
|
|
13
|
+
import { Continuous, Numeric, Schema } from '../foundation/types.js';
|
|
14
|
+
export class DecimalSchema extends Schema {
|
|
15
|
+
/** Inclusive lower bound. Pass as a numeric string. */
|
|
16
|
+
min(value) {
|
|
17
|
+
return new DecimalSchema({ ...this._node, min: String(value) });
|
|
18
|
+
}
|
|
19
|
+
/** Inclusive upper bound. Pass as a numeric string. */
|
|
20
|
+
max(value) {
|
|
21
|
+
return new DecimalSchema({ ...this._node, max: String(value) });
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Declare a fixed-point decimal column.
|
|
26
|
+
*
|
|
27
|
+
* @param precision - total significant digits (1..38 for Snowflake)
|
|
28
|
+
* @param scale - digits after the decimal point (0..precision)
|
|
29
|
+
*/
|
|
30
|
+
export const decimal = (precision, scale) => {
|
|
31
|
+
if (!Number.isInteger(precision) || precision < 1 || precision > 38) {
|
|
32
|
+
throw new RangeError(`decimal: precision must be integer in [1, 38], got ${precision}`);
|
|
33
|
+
}
|
|
34
|
+
if (!Number.isInteger(scale) || scale < 0 || scale > precision) {
|
|
35
|
+
throw new RangeError(`decimal: scale must be integer in [0, precision], got ${scale}`);
|
|
36
|
+
}
|
|
37
|
+
return new DecimalSchema({ kind: 'decimal', precision, scale });
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=decimal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decimal.js","sourceRoot":"","sources":["../../src/schema/decimal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAEpE,MAAM,OAAO,aAAc,SAAQ,MAAc;IAK/C,uDAAuD;IACvD,GAAG,CAAC,KAAsB;QACxB,OAAO,IAAI,aAAa,CAAC,EAAE,GAAG,IAAI,CAAC,KAAK,EAAE,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;IACjE,CAAC;IACD,uDAAuD;IACvD,GAAG,CAAC,KAAsB;QACxB,OAAO,IAAI,aAAa,CAAC,EAAE,GAAG,IAAI,CAAC,KAAK,EAAE,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;IACjE,CAAC;CACF;AAED;;;;;GAKG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,SAAiB,EAAE,KAAa,EAAiB,EAAE;IACzE,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,SAAS,GAAG,CAAC,IAAI,SAAS,GAAG,EAAE,EAAE,CAAC;QACpE,MAAM,IAAI,UAAU,CAAC,sDAAsD,SAAS,EAAE,CAAC,CAAA;IACzF,CAAC;IACD,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,IAAI,KAAK,GAAG,SAAS,EAAE,CAAC;QAC/D,MAAM,IAAI,UAAU,CAAC,yDAAyD,KAAK,EAAE,CAAC,CAAA;IACxF,CAAC;IACD,OAAO,IAAI,aAAa,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CAAA;AACjE,CAAC,CAAA"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Primitive schema builders: str, num, int, bool, null_.
|
|
3
|
+
*
|
|
4
|
+
* Each returns a {@link Schema} instance whose phantom `_type` reflects the
|
|
5
|
+
* generated TypeScript type, and whose `_node` is the serializable IR.
|
|
6
|
+
*/
|
|
7
|
+
import type { Modifiers, NumberKind, StringKind } from '../foundation/ir.js';
|
|
8
|
+
import { Continuous, Discrete, Numeric, Schema } from '../foundation/types.js';
|
|
9
|
+
export declare class StringSchema extends Schema<string> {
|
|
10
|
+
readonly _node: StringKind & {
|
|
11
|
+
mods?: Modifiers;
|
|
12
|
+
};
|
|
13
|
+
readonly [Discrete]: true;
|
|
14
|
+
min(n: number): StringSchema;
|
|
15
|
+
max(n: number): StringSchema;
|
|
16
|
+
pattern(re: RegExp | string): StringSchema;
|
|
17
|
+
}
|
|
18
|
+
export declare const str: () => StringSchema;
|
|
19
|
+
export declare class NumberSchema extends Schema<number> {
|
|
20
|
+
readonly _node: NumberKind & {
|
|
21
|
+
mods?: Modifiers;
|
|
22
|
+
};
|
|
23
|
+
min(n: number): this;
|
|
24
|
+
max(n: number): this;
|
|
25
|
+
protected cloneWithNode(node: NumberKind & {
|
|
26
|
+
mods?: Modifiers;
|
|
27
|
+
}): this;
|
|
28
|
+
}
|
|
29
|
+
/** `int()`-flavoured number — discrete, no Gaussian. Extends `NumberSchema`. */
|
|
30
|
+
export declare class IntSchema extends NumberSchema {
|
|
31
|
+
readonly [Discrete]: true;
|
|
32
|
+
}
|
|
33
|
+
export declare const num: () => NumberSchema & {
|
|
34
|
+
readonly [Numeric]: true;
|
|
35
|
+
readonly [Continuous]: true;
|
|
36
|
+
};
|
|
37
|
+
export declare const int: () => IntSchema & {
|
|
38
|
+
readonly [Numeric]: true;
|
|
39
|
+
};
|
|
40
|
+
export declare class BooleanSchema extends Schema<boolean> {
|
|
41
|
+
readonly [Discrete]: true;
|
|
42
|
+
}
|
|
43
|
+
export declare class NullSchema extends Schema<null> {
|
|
44
|
+
}
|
|
45
|
+
export declare const bool: () => BooleanSchema;
|
|
46
|
+
export declare const null_: () => NullSchema;
|
|
47
|
+
//# sourceMappingURL=primitives.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"primitives.d.ts","sourceRoot":"","sources":["../../src/schema/primitives.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAC5E,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM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E,IAAI,CAAA;CAClC;AAED,qBAAa,UAAW,SAAQ,MAAM,CAAC,IAAI,CAAC;CAAG;AAE/C,eAAO,MAAM,IAAI,QAAO,aAAuD,CAAA;AAE/E,eAAO,MAAM,KAAK,QAAO,UAA8C,CAAA"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Primitive schema builders: str, num, int, bool, null_.
|
|
3
|
+
*
|
|
4
|
+
* Each returns a {@link Schema} instance whose phantom `_type` reflects the
|
|
5
|
+
* generated TypeScript type, and whose `_node` is the serializable IR.
|
|
6
|
+
*/
|
|
7
|
+
import { Continuous, Discrete, Numeric, Schema } from '../foundation/types.js';
|
|
8
|
+
// ──────────────────────────────────────────────────────────────────────────
|
|
9
|
+
// string
|
|
10
|
+
// ──────────────────────────────────────────────────────────────────────────
|
|
11
|
+
export class StringSchema extends Schema {
|
|
12
|
+
min(n) {
|
|
13
|
+
return new StringSchema({ ...this._node, min: n });
|
|
14
|
+
}
|
|
15
|
+
max(n) {
|
|
16
|
+
return new StringSchema({ ...this._node, max: n });
|
|
17
|
+
}
|
|
18
|
+
pattern(re) {
|
|
19
|
+
return new StringSchema({
|
|
20
|
+
...this._node,
|
|
21
|
+
pattern: typeof re === 'string' ? re : re.source,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export const str = () => new StringSchema({ kind: 'string', format: 'plain' });
|
|
26
|
+
// ──────────────────────────────────────────────────────────────────────────
|
|
27
|
+
// number / int
|
|
28
|
+
//
|
|
29
|
+
// `NumberSchema` is the base class for both float-shaped (`num()`) and
|
|
30
|
+
// integer-shaped (`int()`) numeric schemas — the IR-level distinction is
|
|
31
|
+
// `_node.int`, this hierarchy is just a type-system reflection of it.
|
|
32
|
+
//
|
|
33
|
+
// Capability markers are NOT declared on the `NumberSchema` class because
|
|
34
|
+
// they need to differ between the two factories without violating subclass
|
|
35
|
+
// override constraints:
|
|
36
|
+
// - `num()` returns `NumberSchema & { [Numeric]: true; [Continuous]: true }`
|
|
37
|
+
// — gets `.normal` / `.typically`, but NOT `.weighted` (continuous
|
|
38
|
+
// values can't be enumerated).
|
|
39
|
+
// - `int()` returns `IntSchema & { [Numeric]: true }` (with `[Discrete]`
|
|
40
|
+
// declared on the class) — gets `.weighted` and `.typically` (the
|
|
41
|
+
// latter clamps and rounds), but NOT `.normal` (Gaussian on integers
|
|
42
|
+
// would silently lose σ to rounding).
|
|
43
|
+
// - `decimal()` (in `./decimal.ts`) carries `[Numeric]` AND `[Continuous]`
|
|
44
|
+
// by class declaration, mirroring `num()`.
|
|
45
|
+
//
|
|
46
|
+
// `min` / `max` use `this`-typed returns (rather than the explicit class
|
|
47
|
+
// type) so the marker intersection is preserved through chains:
|
|
48
|
+
// `num().min(0).normal(0, 1)` ✓
|
|
49
|
+
// `int().min(1).max(5).weighted([...])` ✓
|
|
50
|
+
// ──────────────────────────────────────────────────────────────────────────
|
|
51
|
+
export class NumberSchema extends Schema {
|
|
52
|
+
min(n) {
|
|
53
|
+
return this.cloneWithNode({ ...this._node, min: n });
|
|
54
|
+
}
|
|
55
|
+
max(n) {
|
|
56
|
+
return this.cloneWithNode({ ...this._node, max: n });
|
|
57
|
+
}
|
|
58
|
+
cloneWithNode(node) {
|
|
59
|
+
const next = Object.create(Object.getPrototypeOf(this));
|
|
60
|
+
Object.assign(next, this, { _node: node });
|
|
61
|
+
return next;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/** `int()`-flavoured number — discrete, no Gaussian. Extends `NumberSchema`. */
|
|
65
|
+
export class IntSchema extends NumberSchema {
|
|
66
|
+
}
|
|
67
|
+
export const num = () => new NumberSchema({ kind: 'number', int: false });
|
|
68
|
+
export const int = () => new IntSchema({ kind: 'number', int: true });
|
|
69
|
+
// ──────────────────────────────────────────────────────────────────────────
|
|
70
|
+
// boolean / null
|
|
71
|
+
// ──────────────────────────────────────────────────────────────────────────
|
|
72
|
+
export class BooleanSchema extends Schema {
|
|
73
|
+
}
|
|
74
|
+
export class NullSchema extends Schema {
|
|
75
|
+
}
|
|
76
|
+
export const bool = () => new BooleanSchema({ kind: 'boolean' });
|
|
77
|
+
export const null_ = () => new NullSchema({ kind: 'null' });
|
|
78
|
+
//# sourceMappingURL=primitives.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"primitives.js","sourceRoot":"","sources":["../../src/schema/primitives.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAE9E,6EAA6E;AAC7E,SAAS;AACT,6EAA6E;AAE7E,MAAM,OAAO,YAAa,SAAQ,MAAc;IAI9C,GAAG,CAAC,CAAS;QACX,OAAO,IAAI,YAAY,CAAC,EAAE,GAAG,IAAI,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,CAAA;IACpD,CAAC;IACD,GAAG,CAAC,CAAS;QACX,OAAO,IAAI,YAAY,CAAC,EAAE,GAAG,IAAI,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,CAAA;IACpD,CAAC;IACD,OAAO,CAAC,EAAmB;QACzB,OAAO,IAAI,YAAY,CAAC;YACtB,GAAG,IAAI,CAAC,KAAK;YACb,OAAO,EAAE,OAAO,EAAE,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM;SACjD,CAAC,CAAA;IACJ,CAAC;CACF;AAED,MAAM,CAAC,MAAM,GAAG,GAAG,GAAiB,EAAE,CACpC,IAAI,YAAY,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,CAAA;AAEvD,6EAA6E;AAC7E,eAAe;AACf,EAAE;AACF,uEAAuE;AACvE,yEAAyE;AACzE,sEAAsE;AACtE,EAAE;AACF,0EAA0E;AAC1E,2EAA2E;AAC3E,wBAAwB;AACxB,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,MAAM,OAAO,UAAW,SAAQ,MAAY;CAAG;AAE/C,MAAM,CAAC,MAAM,IAAI,GAAG,GAAkB,EAAE,CAAC,IAAI,aAAa,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAA;AAE/E,MAAM,CAAC,MAAM,KAAK,GAAG,GAAe,EAAE,CAAC,IAAI,UAAU,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { BehaviorDescriptor } from '../runtime/contracts.js';
|
|
2
|
+
/** Preserve JSON data and reject every closure, cycle and lossy JSON value. */
|
|
3
|
+
export declare const jsonData: (value: unknown, path?: readonly (string | number)[], seen?: Set<object>) => unknown;
|
|
4
|
+
/** Standard behavior descriptors; order preserves eventually before occasionally. */
|
|
5
|
+
export declare const standardBehaviors: readonly BehaviorDescriptor[];
|
|
6
|
+
//# sourceMappingURL=behaviors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"behaviors.d.ts","sourceRoot":"","sources":["../../src/standard/behaviors.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EACV,kBAAkB,EAInB,MAAM,yBAAyB,CAAA;AA0BhC,+EAA+E;AAC/E,eAAO,MAAM,QAAQ,GACnB,OAAO,OAAO,EACd,OAAM,SAAS,CAAC,MAAM,GAAG,MAAM,CAAC,EAAO,EACvC,kBAAwB,KACvB,OAuBF,CAAA;AA0UD,qFAAqF;AACrF,eAAO,MAAM,iBAAiB,EAAE,SAAS,kBAAkB,EAQzD,CAAA"}
|