@fougere/schema 0.2.0-alpha.0 → 0.2.0-alpha.2
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/entity.d.ts +9 -106
- package/dist/entity.d.ts.map +1 -1
- package/dist/entity.js +16 -266
- package/dist/entity.js.map +1 -1
- package/dist/field/boundary.d.ts +26 -43
- package/dist/field/boundary.d.ts.map +1 -1
- package/dist/field/boundary.js +30 -42
- package/dist/field/boundary.js.map +1 -1
- package/dist/field/field.d.ts +13 -56
- package/dist/field/field.d.ts.map +1 -1
- package/dist/field/field.js +22 -26
- package/dist/field/field.js.map +1 -1
- package/dist/field/format.d.ts +29 -0
- package/dist/field/format.d.ts.map +1 -0
- package/dist/field/format.js +24 -0
- package/dist/field/format.js.map +1 -0
- package/dist/field/index.d.ts +7 -6
- package/dist/field/index.d.ts.map +1 -1
- package/dist/field/index.js +6 -5
- package/dist/field/index.js.map +1 -1
- package/dist/field/lifecycle.d.ts +15 -24
- package/dist/field/lifecycle.d.ts.map +1 -1
- package/dist/field/lifecycle.js +10 -17
- package/dist/field/lifecycle.js.map +1 -1
- package/dist/field/meta.d.ts +1 -5
- package/dist/field/meta.d.ts.map +1 -1
- package/dist/field/meta.js +2 -4
- package/dist/field/meta.js.map +1 -1
- package/dist/field/role.d.ts +15 -22
- package/dist/field/role.d.ts.map +1 -1
- package/dist/field/role.js +11 -31
- package/dist/field/role.js.map +1 -1
- package/dist/field/shape.d.ts +24 -12
- package/dist/field/shape.d.ts.map +1 -1
- package/dist/field/shape.js +45 -27
- package/dist/field/shape.js.map +1 -1
- package/dist/hints.d.ts +10 -15
- package/dist/hints.d.ts.map +1 -1
- package/dist/hints.js +22 -1
- package/dist/hints.js.map +1 -1
- package/dist/index.d.ts +37 -36
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +37 -36
- package/dist/index.js.map +1 -1
- package/dist/name.d.ts +4 -12
- package/dist/name.d.ts.map +1 -1
- package/dist/name.js +4 -12
- package/dist/name.js.map +1 -1
- package/dist/projections/card.d.ts +39 -58
- package/dist/projections/card.d.ts.map +1 -1
- package/dist/projections/card.js.map +1 -1
- package/dist/projections/describe.d.ts +4 -4
- package/dist/projections/describe.d.ts.map +1 -1
- package/dist/projections/describe.js +4 -9
- package/dist/projections/describe.js.map +1 -1
- package/dist/projections/io.d.ts +5 -11
- package/dist/projections/io.d.ts.map +1 -1
- package/dist/projections/io.js +5 -11
- package/dist/projections/io.js.map +1 -1
- package/dist/projections/lifecycle.d.ts +5 -19
- package/dist/projections/lifecycle.d.ts.map +1 -1
- package/dist/projections/lifecycle.js +7 -29
- package/dist/projections/lifecycle.js.map +1 -1
- package/dist/projections/reconstruct.d.ts +11 -16
- package/dist/projections/reconstruct.d.ts.map +1 -1
- package/dist/projections/reconstruct.js +29 -32
- package/dist/projections/reconstruct.js.map +1 -1
- package/dist/projections/source.d.ts +11 -34
- package/dist/projections/source.d.ts.map +1 -1
- package/dist/projections/source.js +4 -23
- package/dist/projections/source.js.map +1 -1
- package/dist/projections/typescript.d.ts +6 -22
- package/dist/projections/typescript.d.ts.map +1 -1
- package/dist/projections/typescript.js +16 -43
- package/dist/projections/typescript.js.map +1 -1
- package/dist/schema/index.d.ts +3 -0
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/schema/index.js +2 -0
- package/dist/schema/index.js.map +1 -0
- package/dist/schema/schema.d.ts +74 -0
- package/dist/schema/schema.d.ts.map +1 -0
- package/dist/schema/schema.js +162 -0
- package/dist/schema/schema.js.map +1 -0
- package/dist/schema/view.d.ts +26 -0
- package/dist/schema/view.d.ts.map +1 -0
- package/dist/schema/view.js +2 -0
- package/dist/schema/view.js.map +1 -0
- package/dist/unique.d.ts +12 -37
- package/dist/unique.d.ts.map +1 -1
- package/dist/unique.js +11 -34
- package/dist/unique.js.map +1 -1
- package/dist/validation/index.d.ts +4 -0
- package/dist/validation/index.d.ts.map +1 -0
- package/dist/validation/index.js +2 -0
- package/dist/validation/index.js.map +1 -0
- package/dist/validation/judge.d.ts +55 -0
- package/dist/validation/judge.d.ts.map +1 -0
- package/dist/validation/judge.js +351 -0
- package/dist/validation/judge.js.map +1 -0
- package/dist/validation/options.d.ts +6 -0
- package/dist/validation/options.d.ts.map +1 -0
- package/dist/validation/options.js +3 -0
- package/dist/validation/options.js.map +1 -0
- package/dist/validation/result.d.ts +20 -0
- package/dist/validation/result.d.ts.map +1 -0
- package/dist/validation/result.js +3 -0
- package/dist/validation/result.js.map +1 -0
- package/dist/vocabulary/bool.d.ts +1 -1
- package/dist/vocabulary/bool.d.ts.map +1 -1
- package/dist/vocabulary/bool.js +2 -2
- package/dist/vocabulary/bool.js.map +1 -1
- package/dist/vocabulary/created.d.ts +4 -10
- package/dist/vocabulary/created.d.ts.map +1 -1
- package/dist/vocabulary/created.js +5 -12
- package/dist/vocabulary/created.js.map +1 -1
- package/dist/vocabulary/date.d.ts +1 -1
- package/dist/vocabulary/date.d.ts.map +1 -1
- package/dist/vocabulary/date.js +2 -2
- package/dist/vocabulary/date.js.map +1 -1
- package/dist/vocabulary/immutable.d.ts +4 -6
- package/dist/vocabulary/immutable.d.ts.map +1 -1
- package/dist/vocabulary/immutable.js +3 -6
- package/dist/vocabulary/immutable.js.map +1 -1
- package/dist/vocabulary/indexed.d.ts +5 -16
- package/dist/vocabulary/indexed.d.ts.map +1 -1
- package/dist/vocabulary/indexed.js +4 -16
- package/dist/vocabulary/indexed.js.map +1 -1
- package/dist/vocabulary/json.d.ts +8 -13
- package/dist/vocabulary/json.d.ts.map +1 -1
- package/dist/vocabulary/json.js +3 -3
- package/dist/vocabulary/json.js.map +1 -1
- package/dist/vocabulary/list.d.ts +3 -6
- package/dist/vocabulary/list.d.ts.map +1 -1
- package/dist/vocabulary/list.js +6 -5
- package/dist/vocabulary/list.js.map +1 -1
- package/dist/vocabulary/many.d.ts +3 -4
- package/dist/vocabulary/many.d.ts.map +1 -1
- package/dist/vocabulary/many.js +5 -5
- package/dist/vocabulary/many.js.map +1 -1
- package/dist/vocabulary/nullable.d.ts +2 -4
- package/dist/vocabulary/nullable.d.ts.map +1 -1
- package/dist/vocabulary/nullable.js +4 -8
- package/dist/vocabulary/nullable.js.map +1 -1
- package/dist/vocabulary/number.d.ts +1 -1
- package/dist/vocabulary/number.d.ts.map +1 -1
- package/dist/vocabulary/number.js +2 -2
- package/dist/vocabulary/number.js.map +1 -1
- package/dist/vocabulary/oneOf.d.ts +1 -1
- package/dist/vocabulary/oneOf.d.ts.map +1 -1
- package/dist/vocabulary/oneOf.js +2 -2
- package/dist/vocabulary/oneOf.js.map +1 -1
- package/dist/vocabulary/optional.d.ts +1 -1
- package/dist/vocabulary/optional.d.ts.map +1 -1
- package/dist/vocabulary/optional.js +3 -3
- package/dist/vocabulary/optional.js.map +1 -1
- package/dist/vocabulary/primary.d.ts +5 -5
- package/dist/vocabulary/primary.d.ts.map +1 -1
- package/dist/vocabulary/primary.js +14 -11
- package/dist/vocabulary/primary.js.map +1 -1
- package/dist/vocabulary/readOnly.d.ts +4 -7
- package/dist/vocabulary/readOnly.d.ts.map +1 -1
- package/dist/vocabulary/readOnly.js +4 -7
- package/dist/vocabulary/readOnly.js.map +1 -1
- package/dist/vocabulary/ref.d.ts +1 -1
- package/dist/vocabulary/ref.d.ts.map +1 -1
- package/dist/vocabulary/ref.js +2 -2
- package/dist/vocabulary/ref.js.map +1 -1
- package/dist/vocabulary/text.d.ts +1 -1
- package/dist/vocabulary/text.d.ts.map +1 -1
- package/dist/vocabulary/text.js +2 -2
- package/dist/vocabulary/text.js.map +1 -1
- package/dist/vocabulary/unique.d.ts +8 -18
- package/dist/vocabulary/unique.d.ts.map +1 -1
- package/dist/vocabulary/unique.js +7 -18
- package/dist/vocabulary/unique.js.map +1 -1
- package/dist/vocabulary/updated.d.ts +2 -2
- package/dist/vocabulary/updated.d.ts.map +1 -1
- package/dist/vocabulary/updated.js +1 -2
- package/dist/vocabulary/updated.js.map +1 -1
- package/dist/vocabulary/writeOnly.d.ts +4 -6
- package/dist/vocabulary/writeOnly.d.ts.map +1 -1
- package/dist/vocabulary/writeOnly.js +4 -6
- package/dist/vocabulary/writeOnly.js.map +1 -1
- package/package.json +2 -2
- package/dist/projections/validation.d.ts +0 -57
- package/dist/projections/validation.d.ts.map +0 -1
- package/dist/projections/validation.js +0 -148
- package/dist/projections/validation.js.map +0 -1
package/dist/field/role.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"role.d.ts","sourceRoot":"","sources":["../../src/field/role.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"role.d.ts","sourceRoot":"","sources":["../../src/field/role.ts"],"names":[],"mappings":"AAQA,MAAM,MAAM,iBAAiB,GAAG,QAAQ,MAAM,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC;AAErE;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,iBAAiB,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,CAEzF;AAED,kFAAkF;AAClF,eAAO,MAAM,cAAc,YAAI,KAAK,EAAE,MAAM,CAAU,CAAC;AACvD,eAAO,MAAM,SAAS,YAAI,SAAS,EAAE,UAAU,EAAE,UAAU,CAAU,CAAC;AAEtE,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,iBAAiB,CAAC;IAC5B,IAAI,EAAE,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC;IACtC,QAAQ,CAAC,EAAE,CAAC,OAAO,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC;CACvC;AAED,MAAM,WAAW,IAAI;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;;;;;;;OAUG;IACH,MAAM,CAAC,EAAE,aAAa,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC;IAC9C,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,aAAa,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAEpF"}
|
package/dist/field/role.js
CHANGED
|
@@ -1,30 +1,10 @@
|
|
|
1
1
|
// ─── Axis 2 · role — place in the entity graph ────────────
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
// an absent collection defaults to `[]` and that a supplied one must be an array
|
|
5
|
-
// (`projections/validation.ts`). The earlier claim "never by validation" was false.
|
|
2
|
+
// Identity and relations. Read by the storage and transport adapters, and by the judge:
|
|
3
|
+
// `relation.kind === 'many'` makes an absent collection default to `[]`.
|
|
6
4
|
//
|
|
7
|
-
// `unique` and `index` are
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
// never saw. A collision therefore surfaces as the driver's error, never as a
|
|
11
|
-
// `validate()` failure: judging one value can never see the other rows.
|
|
12
|
-
//
|
|
13
|
-
// ⚠️ READING `unique` — the one member of this axis that is not self-contained. A member
|
|
14
|
-
// list may be EMPTY, denoting the field that carries it, so a reader that walks the array
|
|
15
|
-
// literally sees a group of no fields. Every reader goes through `uniqueMembers(group,
|
|
16
|
-
// key)`, which needs the field's key — the half a field does not have (`slug` is named by
|
|
17
|
-
// the object literal `entity({...})` receives, one call up).
|
|
18
|
-
//
|
|
19
|
-
// for (const [key, field] of Object.entries(schema.getFields()))
|
|
20
|
-
// for (const group of field.role?.unique ?? [])
|
|
21
|
-
// uniqueMembers(group, key) // ← always. `[]` at key `slug` means `['slug']`.
|
|
22
|
-
//
|
|
23
|
-
// The in-repo readers do this (`schema-sql/src/table.ts`, `projections/describe.ts`). A
|
|
24
|
-
// consumer reading a CARD never meets the empty form: `describe` resolves it on the way
|
|
25
|
-
// out, so the wire always names its members — which is the point of resolving it there
|
|
26
|
-
// and not in `entity()`. Keeping it unresolved in memory is what makes `rename()` free:
|
|
27
|
-
// a self-reference names no key, so there is nothing to remap when the key moves.
|
|
5
|
+
// `unique` and `index` are the only axis members realized OUTSIDE the framework — the DDL
|
|
6
|
+
// emits them and the database enforces them, so a collision surfaces as the driver's
|
|
7
|
+
// error, never as a `validate()` failure.
|
|
28
8
|
/**
|
|
29
9
|
* Normalize a relation target to a lazy thunk. A target may be given as the entity
|
|
30
10
|
* class directly (`ref(Author)`) or as a thunk (`ref(() => Author)`) — the thunk
|
|
@@ -35,19 +15,19 @@
|
|
|
35
15
|
export function toTargetThunk(target) {
|
|
36
16
|
return 'getFields' in target ? () => target : target;
|
|
37
17
|
}
|
|
18
|
+
/** A relation's closed vocabularies — the runtime lists the types derive from. */
|
|
19
|
+
export const RELATION_KINDS = ['one', 'many'];
|
|
20
|
+
export const ON_DELETE = ['cascade', 'restrict', 'set null'];
|
|
38
21
|
/**
|
|
39
22
|
* The constraint a member list denotes, resolved against the field carrying it — the
|
|
40
23
|
* accessor every reader of `role.unique` goes through.
|
|
41
24
|
*
|
|
42
25
|
* ```ts
|
|
43
|
-
* uniqueMembers([], 'slug')
|
|
44
|
-
* uniqueMembers(['listId', 'docId'], 'docId') // ['listId','docId']
|
|
26
|
+
* uniqueMembers([], 'slug') // ['slug'] — the self-reference
|
|
27
|
+
* uniqueMembers(['listId', 'docId'], 'docId') // ['listId','docId'] — already named
|
|
45
28
|
* ```
|
|
46
29
|
*
|
|
47
|
-
* `ownKey` is the half the field is missing
|
|
48
|
-
* `Object.entries(getFields())`, never the field alone. Two spellings for one constraint
|
|
49
|
-
* is the price of a self-reference that survives `rename()` untouched; this function is
|
|
50
|
-
* what makes them one, and it is why the two forms never need to be compared as data.
|
|
30
|
+
* `ownKey` is the half the field is missing: iterate `Object.entries(getFields())`.
|
|
51
31
|
*/
|
|
52
32
|
export function uniqueMembers(group, ownKey) {
|
|
53
33
|
return group.length === 0 ? [ownKey] : [...group];
|
package/dist/field/role.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"role.js","sourceRoot":"","sources":["../../src/field/role.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,
|
|
1
|
+
{"version":3,"file":"role.js","sourceRoot":"","sources":["../../src/field/role.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,wFAAwF;AACxF,yEAAyE;AACzE,EAAE;AACF,0FAA0F;AAC1F,qFAAqF;AACrF,0CAA0C;AAI1C;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAA8B,MAAqB;IAC9E,OAAO,WAAW,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,MAAW,CAAC,CAAC,CAAE,MAAkB,CAAC;AACzE,CAAC;AAED,kFAAkF;AAClF,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAAK,EAAE,MAAM,CAAU,CAAC;AACvD,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,SAAS,EAAE,UAAU,EAAE,UAAU,CAAU,CAAC;AA0BtE;;;;;;;;;;GAUG;AACH,MAAM,UAAU,aAAa,CAAC,KAA4B,EAAE,MAAc;IACxE,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC;AACpD,CAAC"}
|
package/dist/field/shape.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import type { StringFormat } from './format.js';
|
|
2
2
|
/** A base type name, alone or in the nullable union form. */
|
|
3
3
|
type Nullably<T extends string> = T | readonly [T, 'null'];
|
|
4
4
|
interface StringConstraints {
|
|
@@ -13,7 +13,7 @@ interface NumericConstraints {
|
|
|
13
13
|
maximum?: number;
|
|
14
14
|
}
|
|
15
15
|
interface ArrayConstraints {
|
|
16
|
-
items
|
|
16
|
+
items?: Shape;
|
|
17
17
|
minItems?: number;
|
|
18
18
|
maxItems?: number;
|
|
19
19
|
}
|
|
@@ -32,8 +32,17 @@ export type Shape = ({
|
|
|
32
32
|
} & ArrayConstraints) | ({
|
|
33
33
|
type: Nullably<'object'>;
|
|
34
34
|
} & ObjectConstraints);
|
|
35
|
-
/**
|
|
36
|
-
|
|
35
|
+
/**
|
|
36
|
+
* The BASE type names — what `Anatomy.of(shape).base?.type` narrows to for a dispatch.
|
|
37
|
+
*
|
|
38
|
+
* The runtime list is the source and the type derives from it, not the reverse: a type
|
|
39
|
+
* union cannot be enumerated at runtime, so writing both by hand means two lists that
|
|
40
|
+
* drift. {@link isShape} needs the values, so it is the values that are declared.
|
|
41
|
+
*/
|
|
42
|
+
export declare const SHAPE_TYPES: readonly ['string', 'number', 'integer', 'boolean', 'array', 'object'];
|
|
43
|
+
export type ShapeType = (typeof SHAPE_TYPES)[number];
|
|
44
|
+
/** Is this a shape? Asked of its `type`, against {@link SHAPE_TYPES}. */
|
|
45
|
+
export declare function isShape(value: unknown): value is Shape;
|
|
37
46
|
/**
|
|
38
47
|
* `Shape` with `type` guaranteed scalar — what `anatomy` returns as `base`, the
|
|
39
48
|
* ONLY form consumers dispatch on. A scalar literal is a real discriminant, so
|
|
@@ -64,14 +73,17 @@ export interface ShapeAnatomy {
|
|
|
64
73
|
nullable: boolean;
|
|
65
74
|
}
|
|
66
75
|
/**
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
* fails silently on it. Cached per shape reference (shapes are stable — the
|
|
71
|
-
* derivations copy field refs, they never rebuild shapes).
|
|
76
|
+
* The read side — the single customs post at the standard's border. Every consumer that
|
|
77
|
+
* dispatches on a shape's type comes through here: `shape.type` may be the union
|
|
78
|
+
* `[T,'null']`, and a direct comparison fails silently on it.
|
|
72
79
|
*/
|
|
73
|
-
export declare
|
|
74
|
-
/**
|
|
75
|
-
|
|
80
|
+
export declare class Anatomy {
|
|
81
|
+
/** Cached per shape reference — derivations copy field refs, they never rebuild shapes. */
|
|
82
|
+
private static readonly cache;
|
|
83
|
+
private static readonly none;
|
|
84
|
+
static of(shape?: Shape): ShapeAnatomy;
|
|
85
|
+
/** Sugar for the most common read: does this shape's grammar accept `null`? */
|
|
86
|
+
static isNullable(shape?: Shape): boolean;
|
|
87
|
+
}
|
|
76
88
|
export {};
|
|
77
89
|
//# sourceMappingURL=shape.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shape.d.ts","sourceRoot":"","sources":["../../src/field/shape.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"shape.d.ts","sourceRoot":"","sources":["../../src/field/shape.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAwBhD,6DAA6D;AAC7D,KAAK,QAAQ,CAAC,CAAC,SAAS,MAAM,IAAI,CAAC,GAAG,SAAS,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;AAI3D,UAAU,iBAAiB;IAAG,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,SAAS,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC;IAAC,MAAM,CAAC,EAAE,YAAY,CAAA;CAAE;AAClJ,UAAU,kBAAkB;IAAG,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE;AAOnE,UAAU,gBAAgB;IAAG,KAAK,CAAC,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE;AAIlF,UAAU,iBAAiB;IAAG,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAAC,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE;AAElG,MAAM,MAAM,KAAK,GACb,CAAC;IAAE,IAAI,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAA;CAAE,GAAG,iBAAiB,CAAC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AAO,CAAC;CACnB;AAED;;;;GAIG;AACH,qBAAa,OAAO;IAClB,2FAA2F;IAC3F,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAuC;IACpE,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAsD;IAElF,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,GAAG,YAAY,CAiBrC;IAED,+EAA+E;IAC/E,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,KAAK,GAAG,OAAO,CAExC;CACF"}
|
package/dist/field/shape.js
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The BASE type names — what `Anatomy.of(shape).base?.type` narrows to for a dispatch.
|
|
3
|
+
*
|
|
4
|
+
* The runtime list is the source and the type derives from it, not the reverse: a type
|
|
5
|
+
* union cannot be enumerated at runtime, so writing both by hand means two lists that
|
|
6
|
+
* drift. {@link isShape} needs the values, so it is the values that are declared.
|
|
7
|
+
*/
|
|
8
|
+
export const SHAPE_TYPES = ['string', 'number', 'integer', 'boolean', 'array', 'object'];
|
|
9
|
+
/** Is this a shape? Asked of its `type`, against {@link SHAPE_TYPES}. */
|
|
10
|
+
export function isShape(value) {
|
|
11
|
+
if (typeof value !== 'object' || value === null)
|
|
12
|
+
return false;
|
|
13
|
+
const declared = value.type;
|
|
14
|
+
const names = Array.isArray(declared) ? declared : [declared];
|
|
15
|
+
return (names.some((name) => SHAPE_TYPES.includes(name)) &&
|
|
16
|
+
names.every((name) => name === 'null' || SHAPE_TYPES.includes(name)));
|
|
17
|
+
}
|
|
1
18
|
// ─── nullableShape / anatomy — the two gates of the union ──────────
|
|
2
19
|
/**
|
|
3
20
|
* Write side: make a shape's grammar accept `null` — the type becomes the union
|
|
@@ -13,37 +30,38 @@ export function nullableShape(shape) {
|
|
|
13
30
|
}
|
|
14
31
|
return out;
|
|
15
32
|
}
|
|
16
|
-
const anatomies = new WeakMap();
|
|
17
|
-
const NO_SHAPE = { base: undefined, nullable: false };
|
|
18
33
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* fails silently on it. Cached per shape reference (shapes are stable — the
|
|
23
|
-
* derivations copy field refs, they never rebuild shapes).
|
|
34
|
+
* The read side — the single customs post at the standard's border. Every consumer that
|
|
35
|
+
* dispatches on a shape's type comes through here: `shape.type` may be the union
|
|
36
|
+
* `[T,'null']`, and a direct comparison fails silently on it.
|
|
24
37
|
*/
|
|
25
|
-
export
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
if (
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
38
|
+
export class Anatomy {
|
|
39
|
+
/** Cached per shape reference — derivations copy field refs, they never rebuild shapes. */
|
|
40
|
+
static cache = new WeakMap();
|
|
41
|
+
static none = { base: undefined, nullable: false };
|
|
42
|
+
static of(shape) {
|
|
43
|
+
if (!shape)
|
|
44
|
+
return this.none;
|
|
45
|
+
let a = this.cache.get(shape);
|
|
46
|
+
if (!a) {
|
|
47
|
+
if (Array.isArray(shape.type)) {
|
|
48
|
+
const baseType = shape.type.find((t) => t !== 'null');
|
|
49
|
+
const base = { ...shape, type: baseType };
|
|
50
|
+
if ('enum' in base && base.enum) {
|
|
51
|
+
base.enum = base.enum.filter((v) => v !== null);
|
|
52
|
+
}
|
|
53
|
+
a = { base, nullable: true };
|
|
35
54
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
55
|
+
else {
|
|
56
|
+
a = { base: shape, nullable: false };
|
|
57
|
+
}
|
|
58
|
+
this.cache.set(shape, a);
|
|
40
59
|
}
|
|
41
|
-
|
|
60
|
+
return a;
|
|
61
|
+
}
|
|
62
|
+
/** Sugar for the most common read: does this shape's grammar accept `null`? */
|
|
63
|
+
static isNullable(shape) {
|
|
64
|
+
return this.of(shape).nullable;
|
|
42
65
|
}
|
|
43
|
-
return a;
|
|
44
|
-
}
|
|
45
|
-
/** Sugar for the most common read: does this shape's grammar accept `null`? */
|
|
46
|
-
export function isNullable(shape) {
|
|
47
|
-
return anatomy(shape).nullable;
|
|
48
66
|
}
|
|
49
67
|
//# sourceMappingURL=shape.js.map
|
package/dist/field/shape.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shape.js","sourceRoot":"","sources":["../../src/field/shape.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"shape.js","sourceRoot":"","sources":["../../src/field/shape.ts"],"names":[],"mappings":"AAmDA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,CAAU,CAAC;AAGlG,yEAAyE;AACzE,MAAM,UAAU,OAAO,CAAC,KAAc;IACpC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IAC9D,MAAM,QAAQ,GAAI,KAAe,CAAC,IAAI,CAAC;IACvC,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;IAC9D,OAAO,CACL,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAE,WAAkC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACxE,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,MAAM,IAAK,WAAkC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAC7F,CAAC;AACJ,CAAC;AAeD,sEAAsE;AAEtE;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,KAAY;IACxC,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC;QAAE,OAAO,KA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AAE,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC;gBAC5F,CAAC;gBACD,CAAC,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;YAC/B,CAAC;iBAAM,CAAC;gBACN,CAAC,GAAG,EAAE,IAAI,EAAE,KAAkB,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;YACpD,CAAC;YACD,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QAC3B,CAAC;QACD,OAAO,CAAC,CAAC;IACX,CAAC;IAED,+EAA+E;IAC/E,MAAM,CAAC,UAAU,CAAC,KAAa;QAC7B,OAAO,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC;IACjC,CAAC;CACF"}
|
package/dist/hints.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import type { Fields } from "./field/index.js";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* with a GIN index", which validation and the API must ignore).
|
|
3
|
+
* Per-consumer hints — the escape hatch for what a neutral field cannot carry ("store
|
|
4
|
+
* `body` as a `tsvector`"), which validation and the API ignore.
|
|
6
5
|
*
|
|
7
|
-
* EMPTY here
|
|
8
|
-
*
|
|
6
|
+
* EMPTY here: this package names no adapter. Each augments it from its own package, and
|
|
7
|
+
* `K` — the entity's field-key union — constrains a hint's inner keys to real fields.
|
|
9
8
|
*
|
|
10
9
|
* ```ts
|
|
11
10
|
* declare module '@fougere/schema' {
|
|
@@ -14,20 +13,16 @@ import type { Fields } from "./field/index.js";
|
|
|
14
13
|
* }
|
|
15
14
|
* }
|
|
16
15
|
* ```
|
|
17
|
-
*
|
|
18
|
-
* `K` is the entity's field-key union, so a hint's inner keys are constrained to
|
|
19
|
-
* real fields. Until an adapter augments it the registry is `{}` — there is simply
|
|
20
|
-
* nothing to hint against, and the constraint materialises once an adapter is in
|
|
21
|
-
* the compilation. No dependency inversion: schema never names an adapter.
|
|
22
16
|
*/
|
|
23
17
|
export interface FougereHints<K extends string> {
|
|
24
18
|
}
|
|
25
|
-
/**
|
|
26
|
-
* Per-consumer hints for an entity, keyed by registered adapter. Only adapters
|
|
27
|
-
* present in {@link FougereHints} are accepted; unknown adapters, unknown fields
|
|
28
|
-
* and unknown options are all rejected at the call site.
|
|
29
|
-
*/
|
|
19
|
+
/** Keyed by registered adapter — an unknown adapter, field or option is refused at the call site. */
|
|
30
20
|
export type Hints<TFields extends Fields> = {
|
|
31
21
|
[A in keyof FougereHints<Extract<keyof TFields, string>>]?: FougereHints<Extract<keyof TFields, string>>[A];
|
|
32
22
|
};
|
|
23
|
+
/**
|
|
24
|
+
* Carry hints across a key transform — a derivation preserves what it does not change.
|
|
25
|
+
* `transform` maps an old key to its new name, or to `undefined` when the field is dropped.
|
|
26
|
+
*/
|
|
27
|
+
export declare function deriveHints(hints: Hints<Fields> | undefined, transform: (key: string) => string | undefined): Hints<Fields> | undefined;
|
|
33
28
|
//# sourceMappingURL=hints.d.ts.map
|
package/dist/hints.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hints.d.ts","sourceRoot":"","sources":["../src/hints.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE/C
|
|
1
|
+
{"version":3,"file":"hints.d.ts","sourceRoot":"","sources":["../src/hints.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE/C;;;;;;;;;;;;;;GAcG;AAEH,MAAM,WAAW,YAAY,CAAC,CAAC,SAAS,MAAM;CAAI;AAElD,qGAAqG;AACrG,MAAM,MAAM,KAAK,CAAC,OAAO,SAAS,MAAM,IAAI;KACzC,CAAC,IAAI,MAAM,YAAY,CAAC,OAAO,CAAC,MAAM,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,YAAY,CACtE,OAAO,CAAC,MAAM,OAAO,EAAE,MAAM,CAAC,CAC/B,CAAC,CAAC,CAAC;CACL,CAAC;AAEF;;;GAGG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,SAAS,EAChC,SAAS,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,GAC7C,KAAK,CAAC,MAAM,CAAC,GAAG,SAAS,CAa3B"}
|
package/dist/hints.js
CHANGED
|
@@ -1,2 +1,23 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Carry hints across a key transform — a derivation preserves what it does not change.
|
|
3
|
+
* `transform` maps an old key to its new name, or to `undefined` when the field is dropped.
|
|
4
|
+
*/
|
|
5
|
+
export function deriveHints(hints, transform) {
|
|
6
|
+
if (!hints)
|
|
7
|
+
return undefined;
|
|
8
|
+
const out = {};
|
|
9
|
+
for (const [adapter, perField] of Object.entries(hints)) {
|
|
10
|
+
if (!perField || typeof perField !== 'object')
|
|
11
|
+
continue;
|
|
12
|
+
const mapped = {};
|
|
13
|
+
for (const [key, hint] of Object.entries(perField)) {
|
|
14
|
+
const next = transform(key);
|
|
15
|
+
if (next !== undefined)
|
|
16
|
+
mapped[next] = hint;
|
|
17
|
+
}
|
|
18
|
+
if (Object.keys(mapped).length)
|
|
19
|
+
out[adapter] = mapped;
|
|
20
|
+
}
|
|
21
|
+
return Object.keys(out).length ? out : undefined;
|
|
22
|
+
}
|
|
2
23
|
//# sourceMappingURL=hints.js.map
|
package/dist/hints.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hints.js","sourceRoot":"","sources":["../src/hints.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"hints.js","sourceRoot":"","sources":["../src/hints.ts"],"names":[],"mappings":"AA2BA;;;GAGG;AACH,MAAM,UAAU,WAAW,CACzB,KAAgC,EAChC,SAA8C;IAE9C,IAAI,CAAC,KAAK;QAAE,OAAO,SAAS,CAAC;IAC7B,MAAM,GAAG,GAA4C,EAAE,CAAC;IACxD,KAAK,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAA4D,CAAC,EAAE,CAAC;QAC/G,IAAI,CAAC,QAAQ,IAAI,OAAO,QAAQ,KAAK,QAAQ;YAAE,SAAS;QACxD,MAAM,MAAM,GAA4B,EAAE,CAAC;QAC3C,KAAK,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;YACnD,MAAM,IAAI,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC;YAC5B,IAAI,IAAI,KAAK,SAAS;gBAAE,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;QAC9C,CAAC;QACD,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM;YAAE,GAAG,CAAC,OAAO,CAAC,GAAG,MAAM,CAAC;IACxD,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAE,GAAqB,CAAC,CAAC,CAAC,SAAS,CAAC;AACtE,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,37 +1,38 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export { type FougereHints, type Hints } from
|
|
4
|
-
export { type CompositeUnique, type EntityDeclarations } from
|
|
5
|
-
export { primary } from
|
|
6
|
-
export { text, type TextOptions } from
|
|
7
|
-
export { email } from
|
|
8
|
-
export { url } from
|
|
9
|
-
export { list, type ListOptions } from
|
|
10
|
-
export { number } from
|
|
11
|
-
export { bool } from
|
|
12
|
-
export { date } from
|
|
13
|
-
export { created } from
|
|
14
|
-
export { updated } from
|
|
15
|
-
export { oneOf } from
|
|
16
|
-
export { ref } from
|
|
17
|
-
export { many } from
|
|
18
|
-
export { optional } from
|
|
19
|
-
export { nullable } from
|
|
20
|
-
export { immutable } from
|
|
21
|
-
export { unique } from
|
|
22
|
-
export { indexed } from
|
|
23
|
-
export { readOnly } from
|
|
24
|
-
export { writeOnly } from
|
|
25
|
-
export { json } from
|
|
26
|
-
export { applyCreate, applyUpdate } from
|
|
27
|
-
export {
|
|
28
|
-
export {
|
|
29
|
-
export {
|
|
30
|
-
export {
|
|
31
|
-
export {
|
|
32
|
-
export {
|
|
33
|
-
export {
|
|
34
|
-
export { type
|
|
35
|
-
export
|
|
36
|
-
export
|
|
1
|
+
export { Field, type Fields, type Shape, type ShapeType, type StringFormat, type FormatPredicate, type Role, type Relation, type Lifecycle, type GeneratorRef, type Boundary, type BoundaryRef, type Decoder, type Encoder, type Meta, nullableShape, uniqueMembers, registerGenerator, resolveCustomGenerator, resolveBoundary, boundaryOf, Anatomy, Formats, Boundaries, type EntityConstructor, } from "./field/index.js";
|
|
2
|
+
export { compose, Schema, ANONYMOUS_SCHEMA_NAME, type SchemaConstructor, type SchemaView, type Row, type PartialRow, } from "./schema/index.js";
|
|
3
|
+
export { type FougereHints, type Hints } from "./hints.js";
|
|
4
|
+
export { type CompositeUnique, type EntityDeclarations } from "./unique.js";
|
|
5
|
+
export { primary } from "./vocabulary/primary.js";
|
|
6
|
+
export { text, type TextOptions } from "./vocabulary/text.js";
|
|
7
|
+
export { email } from "./vocabulary/email.js";
|
|
8
|
+
export { url } from "./vocabulary/url.js";
|
|
9
|
+
export { list, type ListOptions } from "./vocabulary/list.js";
|
|
10
|
+
export { number } from "./vocabulary/number.js";
|
|
11
|
+
export { bool } from "./vocabulary/bool.js";
|
|
12
|
+
export { date } from "./vocabulary/date.js";
|
|
13
|
+
export { created } from "./vocabulary/created.js";
|
|
14
|
+
export { updated } from "./vocabulary/updated.js";
|
|
15
|
+
export { oneOf } from "./vocabulary/oneOf.js";
|
|
16
|
+
export { ref } from "./vocabulary/ref.js";
|
|
17
|
+
export { many } from "./vocabulary/many.js";
|
|
18
|
+
export { optional } from "./vocabulary/optional.js";
|
|
19
|
+
export { nullable } from "./vocabulary/nullable.js";
|
|
20
|
+
export { immutable } from "./vocabulary/immutable.js";
|
|
21
|
+
export { unique } from "./vocabulary/unique.js";
|
|
22
|
+
export { indexed } from "./vocabulary/indexed.js";
|
|
23
|
+
export { readOnly } from "./vocabulary/readOnly.js";
|
|
24
|
+
export { writeOnly } from "./vocabulary/writeOnly.js";
|
|
25
|
+
export { json } from "./vocabulary/json.js";
|
|
26
|
+
export { applyCreate, applyUpdate } from "./projections/lifecycle.js";
|
|
27
|
+
export { encodeFields } from "./projections/encode.js";
|
|
28
|
+
export { inputFields, outputFields } from "./projections/io.js";
|
|
29
|
+
export { registrationKeyOf } from "./name.js";
|
|
30
|
+
export { describe, describeSet, sourceNameOf } from "./projections/describe.js";
|
|
31
|
+
export { reconstruct, reconstructSet } from "./projections/reconstruct.js";
|
|
32
|
+
export { entitySourceOf, facadeTypeSourceOf, type TypeSourceOptions, type OpDescriptor, } from "./projections/typescript.js";
|
|
33
|
+
export { type SchemaBundle, type SchemaDescriptor, type FieldDescriptor, type FieldExtension, type RoleDescriptor, type RelationDescriptor, } from "./projections/card.js";
|
|
34
|
+
export { type SchemaSource, schemaOf, fieldsOf, } from "./projections/source.js";
|
|
35
|
+
export type { StandardSchemaV1 } from "./projections/standard.js";
|
|
36
|
+
export { entity } from "./entity.js";
|
|
37
|
+
export { Judge, type ValidateOptions, type ValidationError, type ValidationResult, type Checked } from "./validation/index.js";
|
|
37
38
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,EACL,KAAK,MAAM,EACX,KAAK,KAAK,EACV,KAAK,SAAS,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,YAAY,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAElE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,KAAK,EAAE,KAAK,eAAe,EAAE,KAAK,eAAe,EAAE,KAAK,gBAAgB,EAAE,KAAK,OAAO,EAAE,MAAM,uBAAuB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,48 +1,49 @@
|
|
|
1
1
|
// ─── The primitive — a Field on four orthogonal axes + meta ──
|
|
2
|
-
export {
|
|
2
|
+
export { Field, nullableShape,
|
|
3
3
|
// The constraint a `role.unique` member list denotes — `[]` means the field carrying it.
|
|
4
|
-
uniqueMembers,
|
|
4
|
+
uniqueMembers,
|
|
5
|
+
// The shape axis's own open registry — a NAMED predicate where JSON Schema
|
|
6
|
+
// already declares its vocabulary open, so the rule travels as `format`.
|
|
7
|
+
registerGenerator, resolveCustomGenerator, resolveBoundary, boundaryOf, Anatomy, Formats, Boundaries, } from "./field/index.js";
|
|
5
8
|
// ─── The carrier and its derivation algebra ──────────────────
|
|
6
|
-
export {
|
|
9
|
+
export { compose, Schema, ANONYMOUS_SCHEMA_NAME, } from "./schema/index.js";
|
|
7
10
|
// ─── The vocabulary — field constructors and transforms ──────
|
|
8
|
-
export { primary } from
|
|
9
|
-
export { text } from
|
|
10
|
-
export { email } from
|
|
11
|
-
export { url } from
|
|
12
|
-
export { list } from
|
|
13
|
-
export { number } from
|
|
14
|
-
export { bool } from
|
|
15
|
-
export { date } from
|
|
16
|
-
export { created } from
|
|
17
|
-
export { updated } from
|
|
18
|
-
export { oneOf } from
|
|
19
|
-
export { ref } from
|
|
20
|
-
export { many } from
|
|
21
|
-
export { optional } from
|
|
22
|
-
export { nullable } from
|
|
23
|
-
export { immutable } from
|
|
24
|
-
export { unique } from
|
|
25
|
-
export { indexed } from
|
|
26
|
-
export { readOnly } from
|
|
27
|
-
export { writeOnly } from
|
|
28
|
-
export { json } from
|
|
11
|
+
export { primary } from "./vocabulary/primary.js";
|
|
12
|
+
export { text } from "./vocabulary/text.js";
|
|
13
|
+
export { email } from "./vocabulary/email.js";
|
|
14
|
+
export { url } from "./vocabulary/url.js";
|
|
15
|
+
export { list } from "./vocabulary/list.js";
|
|
16
|
+
export { number } from "./vocabulary/number.js";
|
|
17
|
+
export { bool } from "./vocabulary/bool.js";
|
|
18
|
+
export { date } from "./vocabulary/date.js";
|
|
19
|
+
export { created } from "./vocabulary/created.js";
|
|
20
|
+
export { updated } from "./vocabulary/updated.js";
|
|
21
|
+
export { oneOf } from "./vocabulary/oneOf.js";
|
|
22
|
+
export { ref } from "./vocabulary/ref.js";
|
|
23
|
+
export { many } from "./vocabulary/many.js";
|
|
24
|
+
export { optional } from "./vocabulary/optional.js";
|
|
25
|
+
export { nullable } from "./vocabulary/nullable.js";
|
|
26
|
+
export { immutable } from "./vocabulary/immutable.js";
|
|
27
|
+
export { unique } from "./vocabulary/unique.js";
|
|
28
|
+
export { indexed } from "./vocabulary/indexed.js";
|
|
29
|
+
export { readOnly } from "./vocabulary/readOnly.js";
|
|
30
|
+
export { writeOnly } from "./vocabulary/writeOnly.js";
|
|
31
|
+
export { json } from "./vocabulary/json.js";
|
|
29
32
|
// ─── Projections — consumers of the axes ─────────────────────
|
|
30
33
|
// lifecycle: the axis → the values the system writes. The dual of validation — the
|
|
31
34
|
// judge never fills a hole, this is what fills it, and a storage adapter calls it
|
|
32
35
|
// instead of re-deriving the rule.
|
|
33
|
-
export { applyCreate, applyUpdate } from
|
|
34
|
-
|
|
35
|
-
export { validateFields, checkValue } from './projections/validation.js';
|
|
36
|
-
// encode: boundary → egress wire form (the dual of validation)
|
|
37
|
-
export { encodeFields } from './projections/encode.js';
|
|
36
|
+
export { applyCreate, applyUpdate } from "./projections/lifecycle.js";
|
|
37
|
+
export { encodeFields } from "./projections/encode.js";
|
|
38
38
|
// io: the dual client-surface projections — ingress (may supply) / egress (may read)
|
|
39
|
-
export { inputFields, outputFields } from
|
|
40
|
-
|
|
41
|
-
export { registrationKeyOf } from './name.js';
|
|
39
|
+
export { inputFields, outputFields } from "./projections/io.js";
|
|
40
|
+
export { registrationKeyOf } from "./name.js";
|
|
42
41
|
// descriptor (the card): the portable, serialisable identity of a schema
|
|
43
|
-
export { describe, describeSet, sourceNameOf } from
|
|
44
|
-
export { reconstruct, reconstructSet } from
|
|
45
|
-
export {
|
|
42
|
+
export { describe, describeSet, sourceNameOf } from "./projections/describe.js";
|
|
43
|
+
export { reconstruct, reconstructSet } from "./projections/reconstruct.js";
|
|
44
|
+
export { entitySourceOf, facadeTypeSourceOf, } from "./projections/typescript.js";
|
|
46
45
|
// source: the one reader that takes a live class OR a card — what an adapter stands on
|
|
47
|
-
export { schemaOf, fieldsOf,
|
|
46
|
+
export { schemaOf, fieldsOf, } from "./projections/source.js";
|
|
47
|
+
export { entity } from "./entity.js";
|
|
48
|
+
export { Judge } from "./validation/index.js";
|
|
48
49
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,OAAO,EACL,KAAK,EAeL,aAAa;AACb,yFAAyF;AACzF,aAAa;AACb,2EAA2E;AAC3E,yEAAyE;AACzE,iBAAiB,EACjB,sBAAsB,EACtB,eAAe,EACf,UAAU,EACV,OAAO,EACP,OAAO,EACP,UAAU,GAMX,MAAM,kBAAkB,CAAC;AAE1B,gEAAgE;AAChE,OAAO,EACL,OAAO,EACP,MAAM,EACN,qBAAqB,GAKtB,MAAM,mBAAmB,CAAC;AAI3B,gEAAgE;AAChE,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,IAAI,EAAoB,MAAM,sBAAsB,CAAC;AAC9D,OAA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iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,yEAAyE;AACzE,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAChF,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC3E,OAAO,EACL,cAAc,EACd,kBAAkB,GAGnB,MAAM,6BAA6B,CAAC;AASrC,uFAAuF;AACvF,OAAO,EAEL,QAAQ,EACR,QAAQ,GACT,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,KAAK,EAAmF,MAAM,uBAAuB,CAAC"}
|
package/dist/name.d.ts
CHANGED
|
@@ -1,16 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The key a class name is filed under — `AuthorUser` → `authorUser`.
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* the name wholesale, and `schema-sql` fell back to a no-op on anything already lowered.
|
|
7
|
-
* On a one-word name all three agree, which is why nothing in this repo ever met the
|
|
8
|
-
* divergence. On `AuthorUser` the card wrote `authoruser`, and the FK derived from it
|
|
9
|
-
* pointed at `authorusers` while the table it should reference was `author_users` — a
|
|
10
|
-
* reference to a table no pass ever creates.
|
|
11
|
-
*
|
|
12
|
-
* Idempotent, so a name that already arrived in this form crosses unchanged and
|
|
13
|
-
* re-describing a reconstructed schema yields the same card.
|
|
2
|
+
* The key a class name is filed under — `AuthorUser` → `authorUser`. THE canonical
|
|
3
|
+
* spelling, stated once because three places disagreed and only ever met on one-word
|
|
4
|
+
* names: on `AuthorUser` the card wrote `authoruser` and the derived FK pointed at a
|
|
5
|
+
* table no pass creates. Idempotent, so a card re-describes identically.
|
|
14
6
|
*/
|
|
15
7
|
export declare function registrationKeyOf(className: string): string;
|
|
16
8
|
//# sourceMappingURL=name.d.ts.map
|
package/dist/name.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"name.d.ts","sourceRoot":"","sources":["../src/name.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"name.d.ts","sourceRoot":"","sources":["../src/name.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAE3D"}
|
package/dist/name.js
CHANGED
|
@@ -1,16 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The key a class name is filed under — `AuthorUser` → `authorUser`.
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* the name wholesale, and `schema-sql` fell back to a no-op on anything already lowered.
|
|
7
|
-
* On a one-word name all three agree, which is why nothing in this repo ever met the
|
|
8
|
-
* divergence. On `AuthorUser` the card wrote `authoruser`, and the FK derived from it
|
|
9
|
-
* pointed at `authorusers` while the table it should reference was `author_users` — a
|
|
10
|
-
* reference to a table no pass ever creates.
|
|
11
|
-
*
|
|
12
|
-
* Idempotent, so a name that already arrived in this form crosses unchanged and
|
|
13
|
-
* re-describing a reconstructed schema yields the same card.
|
|
2
|
+
* The key a class name is filed under — `AuthorUser` → `authorUser`. THE canonical
|
|
3
|
+
* spelling, stated once because three places disagreed and only ever met on one-word
|
|
4
|
+
* names: on `AuthorUser` the card wrote `authoruser` and the derived FK pointed at a
|
|
5
|
+
* table no pass creates. Idempotent, so a card re-describes identically.
|
|
14
6
|
*/
|
|
15
7
|
export function registrationKeyOf(className) {
|
|
16
8
|
return className ? className[0].toLowerCase() + className.slice(1) : className;
|
package/dist/name.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"name.js","sourceRoot":"","sources":["../src/name.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"name.js","sourceRoot":"","sources":["../src/name.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,SAAiB;IACjD,OAAO,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACjF,CAAC"}
|