@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
|
@@ -1,54 +1,44 @@
|
|
|
1
|
-
import type { BoundaryRef, Lifecycle } from '../field/index.js';
|
|
1
|
+
import type { BoundaryRef, Lifecycle, Relation, Role, Shape } from '../field/index.js';
|
|
2
2
|
/**
|
|
3
|
-
* The portable schema descriptor —
|
|
3
|
+
* The portable schema descriptor — an entity's "carte d'identité".
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* (identity/relations), `lifecycle` (write rules), `boundary` (wire↔domain).
|
|
9
|
-
* The normal forms (named tokens, pure JSON) ARE the wire form — lifecycle and
|
|
10
|
-
* boundary travel verbatim, no descriptor twin to maintain.
|
|
5
|
+
* A JSON Schema document: the `shape` axis at the top level, the three axes JSON Schema
|
|
6
|
+
* cannot express under one `x-fougere` key per field. The normal forms ARE the wire form —
|
|
7
|
+
* lifecycle and boundary travel verbatim, no descriptor twin to maintain.
|
|
11
8
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* transparent, serialisable description that crosses the wire. `describe()` produces
|
|
15
|
-
* it; a single `reconstruct()` reads it back into a working schema (validate + from).
|
|
16
|
-
*
|
|
17
|
-
* Honest losses vs the live field map — a reference becomes a name, a live function
|
|
18
|
-
* does not travel:
|
|
19
|
-
* - `role.relation.to` (a `() => Entity` thunk) → {@link RelationDescriptor.to}, a name.
|
|
20
|
-
* - a custom generator or boundary decoder/encoder travels by NAME, re-resolved
|
|
21
|
-
* against the consumer's registry ("unknown generator/alias" is loud and local).
|
|
9
|
+
* What cannot travel becomes a NAME, re-resolved against the consumer's registry: a
|
|
10
|
+
* relation's thunk, a custom generator, a boundary codec.
|
|
22
11
|
*/
|
|
23
12
|
/** JSON Schema's `type` values, plus `null` for the nullable union form. */
|
|
24
13
|
export type JsonSchemaType = 'string' | 'number' | 'integer' | 'boolean' | 'object' | 'array' | 'null';
|
|
14
|
+
/**
|
|
15
|
+
* A shape's constraint keywords, all optional and flattened — the union's branches merged.
|
|
16
|
+
* `type` is NOT here: intersecting the branches would make the discriminant impossible,
|
|
17
|
+
* and the wire genuinely allows a form memory never produces (see below).
|
|
18
|
+
*/
|
|
19
|
+
type ShapeKeywords = UnionToIntersection<KeywordsOf<Shape>>;
|
|
20
|
+
type KeywordsOf<S> = S extends unknown ? Partial<Omit<S, 'type' | 'items' | 'properties'>> : never;
|
|
21
|
+
type UnionToIntersection<U> = (U extends unknown ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
|
25
22
|
/**
|
|
26
23
|
* One field as a JSON Schema property. The shape keywords sit at the top level
|
|
27
24
|
* (so an external JSON Schema tool reads them directly); the Fougère-only axes
|
|
28
25
|
* live under `x-fougere`. A nullable field folds into the union `type: ['T','null']`.
|
|
29
26
|
*/
|
|
30
|
-
export
|
|
27
|
+
export type FieldDescriptor = ShapeKeywords & {
|
|
28
|
+
/**
|
|
29
|
+
* WIDER than `Shape`, which only ever emits `T` or the canonical `[T,'null']` tuple.
|
|
30
|
+
* A card can come from another language, so the door judges the form; `reconstruct`
|
|
31
|
+
* refuses what it cannot represent rather than pretending it read it.
|
|
32
|
+
*/
|
|
31
33
|
type?: JsonSchemaType | JsonSchemaType[];
|
|
32
|
-
/** JSON Schema format predicate (`date-time` for a date value, email, uuid, uri…). */
|
|
33
|
-
format?: 'date-time' | 'date' | 'time' | 'email' | 'uuid' | 'uri';
|
|
34
|
-
enum?: readonly (string | null)[];
|
|
35
|
-
minLength?: number;
|
|
36
|
-
maxLength?: number;
|
|
37
|
-
pattern?: string;
|
|
38
|
-
minimum?: number;
|
|
39
|
-
maximum?: number;
|
|
40
34
|
/** A value list's element shape (`list(text())`). A bare `many` relation has none. */
|
|
41
35
|
items?: FieldDescriptor;
|
|
42
|
-
minItems?: number;
|
|
43
|
-
maxItems?: number;
|
|
44
36
|
/** An embedded value object (`json(Entity)`): the nested shape-only properties. */
|
|
45
37
|
properties?: Record<string, FieldDescriptor>;
|
|
46
|
-
/** The embedded object's required keys (JSON Schema nesting, travels verbatim). */
|
|
47
|
-
required?: readonly string[];
|
|
48
38
|
/** JSON Schema standard keyword — mirrors the field's `description`. */
|
|
49
39
|
description?: string;
|
|
50
40
|
'x-fougere'?: FieldExtension;
|
|
51
|
-
}
|
|
41
|
+
};
|
|
52
42
|
/** The three axes JSON Schema can't express, namespaced under a field's `x-fougere`. */
|
|
53
43
|
export interface FieldExtension {
|
|
54
44
|
role?: RoleDescriptor;
|
|
@@ -56,35 +46,28 @@ export interface FieldExtension {
|
|
|
56
46
|
lifecycle?: Lifecycle;
|
|
57
47
|
boundary?: BoundaryRef;
|
|
58
48
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
* because a field does not know its own key) — a card always names its members, so a
|
|
69
|
-
* reader never has to know which field a group hangs on.
|
|
70
|
-
*/
|
|
49
|
+
/**
|
|
50
|
+
* The role, with its one unportable member replaced: `unique` names its members on the
|
|
51
|
+
* wire, where in memory a lone `unique()` holds `[]` — a field does not know its own key,
|
|
52
|
+
* a reader of the card must not have to guess it.
|
|
53
|
+
*
|
|
54
|
+
* Names what it KEEPS, like `describeRole` and `reconstructRole` do. Two of the four
|
|
55
|
+
* members do not travel as they are, so portability is not the default a new one gets.
|
|
56
|
+
*/
|
|
57
|
+
export type RoleDescriptor = Pick<Role, 'primary' | 'index'> & {
|
|
71
58
|
unique?: string[][];
|
|
72
|
-
index?: boolean;
|
|
73
59
|
relation?: RelationDescriptor;
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
export
|
|
60
|
+
};
|
|
61
|
+
/** The relation, with its thunk replaced: the target is a NAME. */
|
|
62
|
+
export type RelationDescriptor = Pick<Relation, 'kind' | 'onDelete'> & {
|
|
77
63
|
to: string;
|
|
78
|
-
|
|
79
|
-
onDelete?: 'cascade' | 'restrict' | 'set null';
|
|
80
|
-
}
|
|
64
|
+
};
|
|
81
65
|
/**
|
|
82
66
|
* A whole entity as a JSON Schema object document. `version`/`vendor` mirror Standard
|
|
83
67
|
* Schema's own (versioned + vendored), under `x-` extension keywords so the document
|
|
84
68
|
* stays a valid JSON Schema for external tooling.
|
|
85
69
|
*/
|
|
86
70
|
export interface SchemaDescriptor {
|
|
87
|
-
/** The entity name. */
|
|
88
71
|
title?: string;
|
|
89
72
|
type: 'object';
|
|
90
73
|
properties: Record<string, FieldDescriptor>;
|
|
@@ -100,12 +83,9 @@ export interface SchemaDescriptor {
|
|
|
100
83
|
'x-fougere-vendor': 'fougere';
|
|
101
84
|
}
|
|
102
85
|
/**
|
|
103
|
-
* A self-contained set of entity cards
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
* an inlined sub-schema, so `Post → Author → Post` is two references, not infinite
|
|
107
|
-
* nesting. `reconstructSet` resolves those `$ref`s so a synced relation hands back the
|
|
108
|
-
* real reconstructed target (it feeds adapters), not just a name.
|
|
86
|
+
* A self-contained set of entity cards. Every entity lives under `$defs`, keyed by name,
|
|
87
|
+
* and a relation's `to` is that key — a pointer, never an inlined sub-schema, so
|
|
88
|
+
* `Post → Author → Post` is two references and not infinite nesting.
|
|
109
89
|
*/
|
|
110
90
|
export interface SchemaBundle {
|
|
111
91
|
$defs: Record<string, SchemaDescriptor>;
|
|
@@ -114,4 +94,5 @@ export interface SchemaBundle {
|
|
|
114
94
|
}
|
|
115
95
|
/** Drop keys whose value is `undefined`, so the descriptor stays clean JSON. */
|
|
116
96
|
export declare function clean<T extends Record<string, unknown>>(obj: T): T;
|
|
97
|
+
export {};
|
|
117
98
|
//# sourceMappingURL=card.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"card.d.ts","sourceRoot":"","sources":["../../src/projections/card.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"card.d.ts","sourceRoot":"","sources":["../../src/projections/card.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAEvF;;;;;;;;;GASG;AAEH,4EAA4E;AAC5E,MAAM,MAAM,cAAc,GACtB,QAAQ,GACR,QAAQ,GACR,SAAS,GACT,SAAS,GACT,QAAQ,GACR,OAAO,GACP,MAAM,CAAC;AAEX;;;;GAIG;AACH,KAAK,aAAa,GAAG,mBAAmB,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC;AAI5D,KAAK,UAAU,CAAC,CAAC,IAAI,CAAC,SAAS,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,YAAY,CAAC,CAAC,GAAG,KAAK,CAAC;AACnG,KAAK,mBAAmB,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,OAAO,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK,IAAI,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,EAAE,MAAM,CAAC,KAAK,IAAI,GAAG,CAAC,GAAG,KAAK,CAAC;AAEpH;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG,aAAa,GAAG;IAC5C;;;;OAIG;IACH,IAAI,CAAC,EAAE,cAAc,GAAG,cAAc,EAAE,CAAC;IACzC,sFAAsF;IACtF,KAAK,CAAC,EAAE,eAAe,CAAC;IACxB,mFAAmF;IACnF,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IAC7C,wEAAwE;IACxE,WAAW,CAAC,EAAE,M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card.js","sourceRoot":"","sources":["../../src/projections/card.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"card.js","sourceRoot":"","sources":["../../src/projections/card.ts"],"names":[],"mappings":"AAgHA,gFAAgF;AAChF,MAAM,UAAU,KAAK,CAAoC,GAAM;IAC7D,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;QAAE,IAAI,GAAG,CAAC,GAAG,CAAC,KAAK,SAAS;YAAE,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC;IAChF,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SchemaView } from '../schema/index.js';
|
|
2
2
|
import { type SchemaBundle, type SchemaDescriptor } from './card.js';
|
|
3
3
|
/**
|
|
4
4
|
* Produce the portable card for a schema — THE single canonical serialiser
|
|
5
5
|
* (the hand-rolled copies in adapters call this). `name` titles the entity; it
|
|
6
6
|
* falls back to the schema's source/class name when omitted.
|
|
7
7
|
*/
|
|
8
|
-
export declare function describe(schema:
|
|
8
|
+
export declare function describe(schema: SchemaView, name?: string): SchemaDescriptor;
|
|
9
9
|
/**
|
|
10
10
|
* The name of the schema a view came from — `Post` for `Post`, and `Post` for
|
|
11
11
|
* `Post.pick('title')` too, since a derivation carries its `source`.
|
|
@@ -14,12 +14,12 @@ export declare function describe(schema: SchemaLike, name?: string): SchemaDescr
|
|
|
14
14
|
* and GraphQL names a field's enum type with it — an enum named after the view would give
|
|
15
15
|
* `Post.status` and `CreatePostInput.status` two incompatible types for one set of values.
|
|
16
16
|
*/
|
|
17
|
-
export declare function sourceNameOf(schema:
|
|
17
|
+
export declare function sourceNameOf(schema: SchemaView): string | undefined;
|
|
18
18
|
/**
|
|
19
19
|
* Describe a whole set of entities as one self-contained bundle (the `$defs`
|
|
20
20
|
* document). Accepts a name→schema record or an array (names taken from the
|
|
21
21
|
* schemas). Keys carry the registration key, the same spelling `describe` gives a
|
|
22
22
|
* relation's `to`, so `$ref`-by-name resolves cleanly in {@link reconstructSet}.
|
|
23
23
|
*/
|
|
24
|
-
export declare function describeSet(schemas: Record<string,
|
|
24
|
+
export declare function describeSet(schemas: Record<string, SchemaView> | SchemaView[]): SchemaBundle;
|
|
25
25
|
//# sourceMappingURL=describe.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"describe.d.ts","sourceRoot":"","sources":["../../src/projections/describe.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"describe.d.ts","sourceRoot":"","sources":["../../src/projections/describe.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGrD,OAAO,EAML,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACtB,MAAM,WAAW,CAAC;AAmEnB;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,gBAAgB,CAiB5E;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,GAAG,SAAS,CAGnE;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,UAAU,EAAE,GAAG,YAAY,CAU5F"}
|
|
@@ -61,15 +61,10 @@ function describeField(field, key) {
|
|
|
61
61
|
// Shape is already JSON Schema's vocabulary — nullability included, as the
|
|
62
62
|
// `[T,'null']` type union — so its keywords copy verbatim (an embedded object's
|
|
63
63
|
// `properties`/`required` too, themselves shape-only).
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
out[key] = value;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
else if (field.role?.relation?.kind === 'many') {
|
|
72
|
-
out.type = 'array';
|
|
64
|
+
for (const [key, value] of Object.entries(field.shape)) {
|
|
65
|
+
if (value === undefined)
|
|
66
|
+
continue;
|
|
67
|
+
out[key] = value;
|
|
73
68
|
}
|
|
74
69
|
if (field.meta?.description)
|
|
75
70
|
out.description = field.meta.description;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"describe.js","sourceRoot":"","sources":["../../src/projections/describe.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"describe.js","sourceRoot":"","sources":["../../src/projections/describe.ts"],"names":[],"mappings":"AAEA,OAAO,EAAW,aAAa,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EACL,KAAK,GAON,MAAM,WAAW,CAAC;AAEnB,sEAAsE;AAEtE;;;;;GAKG;AACH,SAAS,UAAU,CAAC,KAAY;IAC9B,4EAA4E;IAC5E,6EAA6E;IAC7E,0EAA0E;IAC1E,wEAAwE;IACxE,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IACpD,IAAI,KAAK,CAAC,SAAS,EAAE,MAAM,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IACxD,IAAI,KAAK,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,KAAK,MAAM;QAAE,OAAO,KAAK,CAAC;IACxD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,YAAY,CAAC,IAAU,EAAE,GAAW;IAC3C,MAAM,GAAG,GAAmB,EAAE,CAAC;IAC/B,IAAI,IAAI,CAAC,OAAO;QAAE,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC;IACrC,mFAAmF;IACnF,sFAAsF;IACtF,oFAAoF;IACpF,IAAI,IAAI,CAAC,MAAM,EAAE,MAAM;QAAE,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,aAAa,CAAC,KAAK,EAAE,GAAG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C;IACpC,IAAI,QAAQ,CAAC,MAAM;QAAE,UAAU,CAAC,QAAQ,GAAG,QAAQ,CAAC;IACpD,OAAO,UAAU,CAAC;AACpB,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,YAAY,CAAC,MAAkB;IAC7C,MAAM,CAAC,GAAG,MAAuD,CAAC;IAClE,OAAO,CAAC,CAAC,MAAM,EAAE,IAAI,IAAI,CAAC,CAAC,IAAI,CAAC;AAClC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,OAAkD;IAC5E,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC;QACpC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAU,CAAC;QACzD,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAC5B,MAAM,KAAK,GAAqC,EAAE,CAAC;IACnD,KAAK,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,OAAO,EAAE,CAAC;QACrC,MAAM,GAAG,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAC;QACpC,KAAK,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACrC,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,mBAAmB,EAAE,CAAC,EAAE,kBAAkB,EAAE,SAAS,EAAE,CAAC;AAC1E,CAAC"}
|
package/dist/projections/io.d.ts
CHANGED
|
@@ -1,17 +1,11 @@
|
|
|
1
1
|
import type { Fields } from '../field/index.js';
|
|
2
2
|
/**
|
|
3
|
-
* The two dual projections of a field set onto a client surface — membership
|
|
4
|
-
*
|
|
3
|
+
* The two dual projections of a field set onto a client surface — membership only. The
|
|
4
|
+
* create/patch MODE changes omissibility, which the view carries, never membership.
|
|
5
5
|
*
|
|
6
|
-
* The
|
|
7
|
-
* the
|
|
8
|
-
*
|
|
9
|
-
* ⚠️ The audience lives in this comment, not in the data — no axis says "client", so
|
|
10
|
-
* these two functions are the only place the word exists. Surfaces are SUPPOSED to read
|
|
11
|
-
* them instead of restating the rules, and several don't: the GraphQL public
|
|
12
|
-
* `registerInput`, the runtime judge and the CLI each answer "what may a client supply"
|
|
13
|
-
* with a different set. The judge is the most permissive — a client-forged primary key
|
|
14
|
-
* reaches the ORM. Reconciling them needs the audience to become data.
|
|
6
|
+
* ⚠️ The audience lives here and not in the data: no axis says "client". Surfaces are
|
|
7
|
+
* supposed to read these two functions, and the GraphQL input, the judge and the CLI each
|
|
8
|
+
* restate the rules with a different set — the judge being the most permissive.
|
|
15
9
|
*/
|
|
16
10
|
/**
|
|
17
11
|
* Ingress: what a CLIENT may supply. Excluded —
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"io.d.ts","sourceRoot":"","sources":["../../src/projections/io.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAGhD
|
|
1
|
+
{"version":3,"file":"io.d.ts","sourceRoot":"","sources":["../../src/projections/io.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAGhD;;;;;;;GAOG;AAEH;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAUlD;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAOnD"}
|
package/dist/projections/io.js
CHANGED
|
@@ -1,17 +1,11 @@
|
|
|
1
1
|
import { boundaryOf } from '../field/index.js';
|
|
2
2
|
/**
|
|
3
|
-
* The two dual projections of a field set onto a client surface — membership
|
|
4
|
-
*
|
|
3
|
+
* The two dual projections of a field set onto a client surface — membership only. The
|
|
4
|
+
* create/patch MODE changes omissibility, which the view carries, never membership.
|
|
5
5
|
*
|
|
6
|
-
* The
|
|
7
|
-
* the
|
|
8
|
-
*
|
|
9
|
-
* ⚠️ The audience lives in this comment, not in the data — no axis says "client", so
|
|
10
|
-
* these two functions are the only place the word exists. Surfaces are SUPPOSED to read
|
|
11
|
-
* them instead of restating the rules, and several don't: the GraphQL public
|
|
12
|
-
* `registerInput`, the runtime judge and the CLI each answer "what may a client supply"
|
|
13
|
-
* with a different set. The judge is the most permissive — a client-forged primary key
|
|
14
|
-
* reaches the ORM. Reconciling them needs the audience to become data.
|
|
6
|
+
* ⚠️ The audience lives here and not in the data: no axis says "client". Surfaces are
|
|
7
|
+
* supposed to read these two functions, and the GraphQL input, the judge and the CLI each
|
|
8
|
+
* restate the rules with a different set — the judge being the most permissive.
|
|
15
9
|
*/
|
|
16
10
|
/**
|
|
17
11
|
* Ingress: what a CLIENT may supply. Excluded —
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"io.js","sourceRoot":"","sources":["../../src/projections/io.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C
|
|
1
|
+
{"version":3,"file":"io.js","sourceRoot":"","sources":["../../src/projections/io.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C;;;;;;;GAOG;AAEH;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CAAC,MAAc;IACxC,MAAM,MAAM,GAAW,EAAE,CAAC;IAC1B,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QACnD,IAAI,KAAK,CAAC,IAAI,EAAE,OAAO;YAAE,SAAS;QAClC,IAAI,KAAK,CAAC,SAAS,EAAE,MAAM,KAAK,KAAK;YAAE,SAAS;QAChD,IAAI,KAAK,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,KAAK,MAAM;YAAE,SAAS;QACpD,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,QAAQ;YAAE,SAAS;QAChD,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;IACvB,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,MAAc;IACzC,MAAM,MAAM,GAAW,EAAE,CAAC;IAC1B,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QACnD,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC,GAAG,KAAK,QAAQ;YAAE,SAAS;QACjD,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;IACvB,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -1,25 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The lifecycle axis, realized — once, for every storage.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* - `schema-sql` realized `{ generate }` and `'now'` in its ORM, and `{ value }` in its
|
|
11
|
-
* DDL — as a column `DEFAULT` the database fills. A mechanism only SQL has.
|
|
12
|
-
* - The Nuxt module's fallback ORM realized none of the three: its signature is
|
|
13
|
-
* `(_entity, _name)`, both ignored, so it forces the name `id` and a random uuid.
|
|
14
|
-
* - A third-party adapter (MongoDB, written outside the repo on 2026-08-08) found the
|
|
15
|
-
* gap the only way available: a test that expected `'draft'` and got `undefined`.
|
|
16
|
-
*
|
|
17
|
-
* Measured, one entity, `oneOf('draft','published',{ default:'draft' })`: SQLite answered
|
|
18
|
-
* `'draft'`, MongoDB answered `undefined`. Same declaration, same port, two answers.
|
|
19
|
-
*
|
|
20
|
-
* So the rule and its realization live together now, and a storage adapter calls this
|
|
21
|
-
* instead of re-deriving it. `update: 'forbidden'` is NOT here: refusing a value is a
|
|
22
|
-
* judgment, and the façade already does it (`validation.ts`, patch mode).
|
|
4
|
+
* The judge answers "is this value legal" and never fills a hole; filling it — stamp
|
|
5
|
+
* `'now'`, apply `{ value }`, call `{ generate }` — belongs to the storage at the point of
|
|
6
|
+
* persistence. Shipping the rule without its realization made each storage rewrite it, and
|
|
7
|
+
* they drifted: one entity with a `default` answered `'draft'` on SQL and `undefined` on
|
|
8
|
+
* Mongo. `update: 'forbidden'` is NOT here — refusing is a judgment.
|
|
23
9
|
*/
|
|
24
10
|
import { type Fields } from '../field/index.js';
|
|
25
11
|
type Row = Record<string, unknown>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lifecycle.d.ts","sourceRoot":"","sources":["../../src/projections/lifecycle.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"lifecycle.d.ts","sourceRoot":"","sources":["../../src/projections/lifecycle.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAsC,KAAK,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAGpF,KAAK,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAsBnC;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,GAAG,CAqB3D;AAgBD;;;GAGG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,GAAG,CAS3D"}
|
|
@@ -1,37 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The lifecycle axis, realized — once, for every storage.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* - `schema-sql` realized `{ generate }` and `'now'` in its ORM, and `{ value }` in its
|
|
11
|
-
* DDL — as a column `DEFAULT` the database fills. A mechanism only SQL has.
|
|
12
|
-
* - The Nuxt module's fallback ORM realized none of the three: its signature is
|
|
13
|
-
* `(_entity, _name)`, both ignored, so it forces the name `id` and a random uuid.
|
|
14
|
-
* - A third-party adapter (MongoDB, written outside the repo on 2026-08-08) found the
|
|
15
|
-
* gap the only way available: a test that expected `'draft'` and got `undefined`.
|
|
16
|
-
*
|
|
17
|
-
* Measured, one entity, `oneOf('draft','published',{ default:'draft' })`: SQLite answered
|
|
18
|
-
* `'draft'`, MongoDB answered `undefined`. Same declaration, same port, two answers.
|
|
19
|
-
*
|
|
20
|
-
* So the rule and its realization live together now, and a storage adapter calls this
|
|
21
|
-
* instead of re-deriving it. `update: 'forbidden'` is NOT here: refusing a value is a
|
|
22
|
-
* judgment, and the façade already does it (`validation.ts`, patch mode).
|
|
4
|
+
* The judge answers "is this value legal" and never fills a hole; filling it — stamp
|
|
5
|
+
* `'now'`, apply `{ value }`, call `{ generate }` — belongs to the storage at the point of
|
|
6
|
+
* persistence. Shipping the rule without its realization made each storage rewrite it, and
|
|
7
|
+
* they drifted: one entity with a `default` answered `'draft'` on SQL and `undefined` on
|
|
8
|
+
* Mongo. `update: 'forbidden'` is NOT here — refusing is a judgment.
|
|
23
9
|
*/
|
|
24
10
|
import { resolveCustomGenerator } from '../field/index.js';
|
|
25
11
|
import { createId } from '@paralleldrive/cuid2';
|
|
26
|
-
/**
|
|
27
|
-
* Resolve a generator TOKEN to a function: a custom name registered via
|
|
28
|
-
* `registerGenerator` wins, then the built-ins. An unknown name throws — loud and
|
|
29
|
-
* local, instead of a silent divergence between two storages.
|
|
30
|
-
*
|
|
31
|
-
* The built-ins used to live storage-side, which put the inversion in plain sight: a
|
|
32
|
-
* generator YOU invent travelled to every adapter, and the three the framework ships
|
|
33
|
-
* did not.
|
|
34
|
-
*/
|
|
12
|
+
/** Resolve a generator TOKEN to a function — a registered name wins over a built-in. */
|
|
35
13
|
function generatorFor(ref) {
|
|
36
14
|
const custom = resolveCustomGenerator(ref);
|
|
37
15
|
if (custom)
|
|
@@ -91,7 +69,7 @@ export function applyCreate(fields, input) {
|
|
|
91
69
|
*
|
|
92
70
|
* Every default the vocabulary can express is a primitive (`text`, `number`, `bool`,
|
|
93
71
|
* `oneOf`; `list` and `json` take none), so this only pays for itself under the escape
|
|
94
|
-
* hatch — `
|
|
72
|
+
* hatch — `new Field({ shape, lifecycle: { create: { value: {…} } } })`. Cheap insurance
|
|
95
73
|
* against the one failure mode nobody would ever debug from the symptom.
|
|
96
74
|
*/
|
|
97
75
|
function freshValue(value) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lifecycle.js","sourceRoot":"","sources":["../../src/projections/lifecycle.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"lifecycle.js","sourceRoot":"","sources":["../../src/projections/lifecycle.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,sBAAsB,EAA2B,MAAM,mBAAmB,CAAC;AACpF,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAIhD,wFAAwF;AACxF,SAAS,YAAY,CAAC,GAAW;IAC/B,MAAM,MAAM,GAAG,sBAAsB,CAAC,GAAG,CAAC,CAAC;IAC3C,IAAI,MAAM;QAAE,OAAO,MAAM,CAAC;IAC1B,QAAQ,GAAG,EAAE,CAAC;QACZ,KAAK,OAAO,EAAE,OAAO,QAAQ,CAAC;QAC9B,KAAK,MAAM,EAAE,OAAO,GAAG,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;QACzD,KAAK,QAAQ,EAAE,CAAC;YACd,OAAO,GAAG,EAAE;gBACV,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC;gBACjC,UAAU,CAAC,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;gBACzC,MAAM,QAAQ,GAAG,kEAAkE,CAAC;gBACpF,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,CAA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AAS,UAAU,CAAC,KAAc;IAChC,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC9D,OAAO,eAAe,CAAC,KAAK,CAAC,CAAC;AAChC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,MAAc,EAAE,KAAU;IACpD,MAAM,GAAG,GAAQ,EAAE,GAAG,KAAK,EAAE,CAAC;IAC9B,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAE3B,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAsB,EAAE,CAAC;QACxE,IAAI,KAAK,CAAC,SAAS,EAAE,MAAM,KAAK,KAAK,IAAI,CAAC,CAAC,IAAI,IAAI,GAAG,CAAC;YAAE,GAAG,CAAC,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,OAAO,CAAC,CAAC;IACzF,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { type SchemaConstructor, type
|
|
1
|
+
import { Field, type Fields } from '../field/index.js';
|
|
2
|
+
import { type SchemaConstructor, type SchemaView, type Row } from '../schema/index.js';
|
|
3
3
|
import { type SchemaBundle, type SchemaDescriptor } from './card.js';
|
|
4
4
|
/**
|
|
5
|
-
* The field map a stated row shape implies.
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* describes rows as they are READ, and "what a caller must supply at creation" is a
|
|
9
|
-
* different question — one `required` answers, and one a synced consumer never asks,
|
|
10
|
-
* since it calls the host rather than constructing.
|
|
5
|
+
* The field map a stated row shape implies. A card describes rows as they are READ, so
|
|
6
|
+
* `required` answers what a creation payload must carry — a question a synced consumer
|
|
7
|
+
* never asks, since it calls the host rather than constructing.
|
|
11
8
|
*/
|
|
12
9
|
type FieldsOf<T> = {
|
|
13
|
-
[K in keyof T]-?: Field<T[K]
|
|
10
|
+
[K in keyof T]-?: Field<T[K]>;
|
|
14
11
|
};
|
|
15
12
|
/**
|
|
16
13
|
* Read a lone card back into a working schema — THE single reconstructor. The result
|
|
@@ -18,19 +15,17 @@ type FieldsOf<T> = {
|
|
|
18
15
|
* the wire as data, the behaviour is reconstituted here. Relations stay name stand-ins
|
|
19
16
|
* (no set to resolve against — use {@link reconstructSet} for live targets).
|
|
20
17
|
*
|
|
21
|
-
* `T` states the
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* Without it the instance type is an index signature, so a synced entity validated
|
|
25
|
-
* perfectly and taught the compiler nothing — `post.titel` compiled.
|
|
18
|
+
* `T` states the row, which is what makes a rebuilt schema a CLASS and not a type beside a
|
|
19
|
+
* value: `class Post extends reconstruct<{…}>(card) {}`, one declaration carrying both.
|
|
20
|
+
* Without it the instance type is an index signature, so `post.titel` compiled.
|
|
26
21
|
*/
|
|
27
|
-
export declare function reconstruct<T =
|
|
22
|
+
export declare function reconstruct<T = Row<Fields>>(descriptor: SchemaDescriptor): SchemaConstructor<FieldsOf<T>>;
|
|
28
23
|
/**
|
|
29
24
|
* Read a whole bundle back into live schemas, keyed by name — THE set reconstructor.
|
|
30
25
|
* Every entity is rebuilt against a shared `$defs` resolver, so a relation's `to()`
|
|
31
26
|
* hands back the real reconstructed target (feeds adapters), not a name stand-in.
|
|
32
27
|
* Targets absent from the set (external/cross-frond `$ref`) keep the stand-in.
|
|
33
28
|
*/
|
|
34
|
-
export declare function reconstructSet(bundle: SchemaBundle): Record<string,
|
|
29
|
+
export declare function reconstructSet(bundle: SchemaBundle): Record<string, SchemaView>;
|
|
35
30
|
export {};
|
|
36
31
|
//# sourceMappingURL=reconstruct.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reconstruct.d.ts","sourceRoot":"","sources":["../../src/projections/reconstruct.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"reconstruct.d.ts","sourceRoot":"","sources":["../../src/projections/reconstruct.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EAEL,KAAK,MAAM,EAGZ,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAU,KAAK,iBAAiB,EAAE,KAAK,UAAU,EAAE,KAAK,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAC/F,OAAO,EAIL,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACtB,MAAM,WAAW,CAAC;AAyHnB;;;;GAIG;AACH,KAAK,QAAQ,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,CAAC;AAErD;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAAC,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,EACzC,UAAU,EAAE,gBAAgB,GAC3B,iBAAiB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAEhC;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAa/E"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Field, } from '../field/index.js';
|
|
2
|
+
import { Schema } from '../schema/index.js';
|
|
3
3
|
import { clean, } from './card.js';
|
|
4
4
|
// ─── reconstruct — card → schema (the single reconstructor) ────────
|
|
5
5
|
/**
|
|
@@ -13,12 +13,11 @@ function reconstructShape(prop) {
|
|
|
13
13
|
if (base === undefined)
|
|
14
14
|
return undefined;
|
|
15
15
|
const type = prop.type;
|
|
16
|
-
// `array`
|
|
17
|
-
//
|
|
16
|
+
// `array` with `items` is a value list, without it a `many` relation whose elements
|
|
17
|
+
// live on the other side. Both are array shapes; only the role tells them apart, and
|
|
18
|
+
// it travels in `x-fougere`. Nothing to branch on here — the keywords copy back.
|
|
18
19
|
if (base === 'array') {
|
|
19
|
-
|
|
20
|
-
return undefined;
|
|
21
|
-
const items = reconstructShape(prop.items);
|
|
20
|
+
const items = prop.items ? reconstructShape(prop.items) : undefined;
|
|
22
21
|
return clean({ type, items, minItems: prop.minItems, maxItems: prop.maxItems });
|
|
23
22
|
}
|
|
24
23
|
switch (base) {
|
|
@@ -58,10 +57,18 @@ function reconstructRole(role, resolve) {
|
|
|
58
57
|
}
|
|
59
58
|
return out;
|
|
60
59
|
}
|
|
61
|
-
function reconstructField(prop, resolve) {
|
|
60
|
+
function reconstructField(prop, key, resolve) {
|
|
62
61
|
const ext = prop['x-fougere'];
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
const shape = reconstructShape(prop);
|
|
63
|
+
// A card that names no type for a property cannot become a field: every field states a
|
|
64
|
+
// shape. Loud and local, at the property that is missing it — the alternative is a field
|
|
65
|
+
// that judges nothing, which is what this whole rule exists to stop.
|
|
66
|
+
if (!shape) {
|
|
67
|
+
throw new Error(`Field '${key}': the card carries no \`type\` for it, so there is no shape to rebuild. `
|
|
68
|
+
+ `A field always states one.`);
|
|
69
|
+
}
|
|
70
|
+
return new Field({
|
|
71
|
+
shape,
|
|
65
72
|
role: ext?.role ? reconstructRole(ext.role, resolve) : undefined,
|
|
66
73
|
// The normal forms are pure JSON — they travelled verbatim, they read back verbatim.
|
|
67
74
|
lifecycle: ext?.lifecycle,
|
|
@@ -81,9 +88,7 @@ function compositeFromFields(fields) {
|
|
|
81
88
|
for (const group of field.role?.unique ?? []) {
|
|
82
89
|
if (group.length < 2)
|
|
83
90
|
continue;
|
|
84
|
-
//
|
|
85
|
-
// separator byte: a NUL in the source made every `grep` read this whole file as
|
|
86
|
-
// binary and skip it silently, a poor price for a de-duplication key.
|
|
91
|
+
// `JSON.stringify` and not a separator byte: a NUL made `grep` read the file as binary.
|
|
87
92
|
seen.set(JSON.stringify(group), [...group]);
|
|
88
93
|
}
|
|
89
94
|
}
|
|
@@ -93,18 +98,13 @@ function compositeFromFields(fields) {
|
|
|
93
98
|
function buildSchema(descriptor, resolve) {
|
|
94
99
|
const fields = {};
|
|
95
100
|
for (const [key, prop] of Object.entries(descriptor.properties)) {
|
|
96
|
-
fields[key] = reconstructField(prop, resolve);
|
|
101
|
+
fields[key] = reconstructField(prop, key, resolve);
|
|
97
102
|
}
|
|
98
|
-
//
|
|
99
|
-
//
|
|
100
|
-
|
|
101
|
-
//
|
|
102
|
-
|
|
103
|
-
// The name is the identity everything downstream keys on — the registration key, the
|
|
104
|
-
// table, the GraphQL type, what a relation's `to` points at. `describe` writes it as
|
|
105
|
-
// `title`; dropping it here left a rebuilt schema called `Schema`, so a card could not
|
|
106
|
-
// round-trip and an adapter standing on one had no entity name to work from.
|
|
107
|
-
// `reconstructSet` still overrides with the bundle key, which is the more specific truth.
|
|
103
|
+
// The card holds the fact once per MEMBER, so a group of two arrives twice — de-duplicate
|
|
104
|
+
// it and `getUnique()` answers what the author wrote.
|
|
105
|
+
const schema = Schema.of(fields, undefined, undefined, {}, compositeFromFields(fields));
|
|
106
|
+
// The name is what everything downstream keys on — the table, the GraphQL type, a
|
|
107
|
+
// relation's `to`. `reconstructSet` overrides it with the bundle key, more specific.
|
|
108
108
|
if (descriptor.title) {
|
|
109
109
|
Object.defineProperty(schema, 'name', { value: descriptor.title, configurable: true });
|
|
110
110
|
}
|
|
@@ -116,11 +116,9 @@ function buildSchema(descriptor, resolve) {
|
|
|
116
116
|
* the wire as data, the behaviour is reconstituted here. Relations stay name stand-ins
|
|
117
117
|
* (no set to resolve against — use {@link reconstructSet} for live targets).
|
|
118
118
|
*
|
|
119
|
-
* `T` states the
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
* Without it the instance type is an index signature, so a synced entity validated
|
|
123
|
-
* perfectly and taught the compiler nothing — `post.titel` compiled.
|
|
119
|
+
* `T` states the row, which is what makes a rebuilt schema a CLASS and not a type beside a
|
|
120
|
+
* value: `class Post extends reconstruct<{…}>(card) {}`, one declaration carrying both.
|
|
121
|
+
* Without it the instance type is an index signature, so `post.titel` compiled.
|
|
124
122
|
*/
|
|
125
123
|
export function reconstruct(descriptor) {
|
|
126
124
|
return buildSchema(descriptor);
|
|
@@ -137,9 +135,8 @@ export function reconstructSet(bundle) {
|
|
|
137
135
|
const out = {};
|
|
138
136
|
for (const [name, descriptor] of Object.entries(bundle.$defs)) {
|
|
139
137
|
const schema = buildSchema(descriptor, resolve);
|
|
140
|
-
//
|
|
141
|
-
//
|
|
142
|
-
// before any `.to()` call — true once this loop ends.
|
|
138
|
+
// Named after its key so re-describing yields the same `to`. `to` is lazy, so the map
|
|
139
|
+
// need only be full before the first call — true once this loop ends.
|
|
143
140
|
Object.defineProperty(schema, 'name', { value: name, configurable: true });
|
|
144
141
|
map[name.toLowerCase()] = schema;
|
|
145
142
|
out[name] = schema;
|