@fougere/schema 0.2.0-alpha.1 → 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.
Files changed (188) hide show
  1. package/dist/entity.d.ts +9 -106
  2. package/dist/entity.d.ts.map +1 -1
  3. package/dist/entity.js +16 -266
  4. package/dist/entity.js.map +1 -1
  5. package/dist/field/boundary.d.ts +26 -43
  6. package/dist/field/boundary.d.ts.map +1 -1
  7. package/dist/field/boundary.js +30 -42
  8. package/dist/field/boundary.js.map +1 -1
  9. package/dist/field/field.d.ts +13 -56
  10. package/dist/field/field.d.ts.map +1 -1
  11. package/dist/field/field.js +22 -26
  12. package/dist/field/field.js.map +1 -1
  13. package/dist/field/format.d.ts +29 -0
  14. package/dist/field/format.d.ts.map +1 -0
  15. package/dist/field/format.js +24 -0
  16. package/dist/field/format.js.map +1 -0
  17. package/dist/field/index.d.ts +7 -6
  18. package/dist/field/index.d.ts.map +1 -1
  19. package/dist/field/index.js +6 -5
  20. package/dist/field/index.js.map +1 -1
  21. package/dist/field/lifecycle.d.ts +15 -24
  22. package/dist/field/lifecycle.d.ts.map +1 -1
  23. package/dist/field/lifecycle.js +10 -17
  24. package/dist/field/lifecycle.js.map +1 -1
  25. package/dist/field/meta.d.ts +1 -5
  26. package/dist/field/meta.d.ts.map +1 -1
  27. package/dist/field/meta.js +2 -4
  28. package/dist/field/meta.js.map +1 -1
  29. package/dist/field/role.d.ts +15 -22
  30. package/dist/field/role.d.ts.map +1 -1
  31. package/dist/field/role.js +11 -31
  32. package/dist/field/role.js.map +1 -1
  33. package/dist/field/shape.d.ts +24 -12
  34. package/dist/field/shape.d.ts.map +1 -1
  35. package/dist/field/shape.js +45 -27
  36. package/dist/field/shape.js.map +1 -1
  37. package/dist/hints.d.ts +10 -15
  38. package/dist/hints.d.ts.map +1 -1
  39. package/dist/hints.js +22 -1
  40. package/dist/hints.js.map +1 -1
  41. package/dist/index.d.ts +37 -36
  42. package/dist/index.d.ts.map +1 -1
  43. package/dist/index.js +37 -36
  44. package/dist/index.js.map +1 -1
  45. package/dist/name.d.ts +4 -12
  46. package/dist/name.d.ts.map +1 -1
  47. package/dist/name.js +4 -12
  48. package/dist/name.js.map +1 -1
  49. package/dist/projections/card.d.ts +39 -58
  50. package/dist/projections/card.d.ts.map +1 -1
  51. package/dist/projections/card.js.map +1 -1
  52. package/dist/projections/describe.d.ts +4 -4
  53. package/dist/projections/describe.d.ts.map +1 -1
  54. package/dist/projections/describe.js +4 -9
  55. package/dist/projections/describe.js.map +1 -1
  56. package/dist/projections/io.d.ts +5 -11
  57. package/dist/projections/io.d.ts.map +1 -1
  58. package/dist/projections/io.js +5 -11
  59. package/dist/projections/io.js.map +1 -1
  60. package/dist/projections/lifecycle.d.ts +5 -19
  61. package/dist/projections/lifecycle.d.ts.map +1 -1
  62. package/dist/projections/lifecycle.js +7 -29
  63. package/dist/projections/lifecycle.js.map +1 -1
  64. package/dist/projections/reconstruct.d.ts +11 -16
  65. package/dist/projections/reconstruct.d.ts.map +1 -1
  66. package/dist/projections/reconstruct.js +29 -32
  67. package/dist/projections/reconstruct.js.map +1 -1
  68. package/dist/projections/source.d.ts +11 -34
  69. package/dist/projections/source.d.ts.map +1 -1
  70. package/dist/projections/source.js +4 -23
  71. package/dist/projections/source.js.map +1 -1
  72. package/dist/projections/typescript.d.ts +6 -22
  73. package/dist/projections/typescript.d.ts.map +1 -1
  74. package/dist/projections/typescript.js +16 -43
  75. package/dist/projections/typescript.js.map +1 -1
  76. package/dist/schema/index.d.ts +3 -0
  77. package/dist/schema/index.d.ts.map +1 -0
  78. package/dist/schema/index.js +2 -0
  79. package/dist/schema/index.js.map +1 -0
  80. package/dist/schema/schema.d.ts +74 -0
  81. package/dist/schema/schema.d.ts.map +1 -0
  82. package/dist/schema/schema.js +162 -0
  83. package/dist/schema/schema.js.map +1 -0
  84. package/dist/schema/view.d.ts +26 -0
  85. package/dist/schema/view.d.ts.map +1 -0
  86. package/dist/schema/view.js +2 -0
  87. package/dist/schema/view.js.map +1 -0
  88. package/dist/unique.d.ts +12 -37
  89. package/dist/unique.d.ts.map +1 -1
  90. package/dist/unique.js +11 -34
  91. package/dist/unique.js.map +1 -1
  92. package/dist/validation/index.d.ts +4 -0
  93. package/dist/validation/index.d.ts.map +1 -0
  94. package/dist/validation/index.js +2 -0
  95. package/dist/validation/index.js.map +1 -0
  96. package/dist/validation/judge.d.ts +55 -0
  97. package/dist/validation/judge.d.ts.map +1 -0
  98. package/dist/validation/judge.js +351 -0
  99. package/dist/validation/judge.js.map +1 -0
  100. package/dist/validation/options.d.ts +6 -0
  101. package/dist/validation/options.d.ts.map +1 -0
  102. package/dist/validation/options.js +3 -0
  103. package/dist/validation/options.js.map +1 -0
  104. package/dist/validation/result.d.ts +20 -0
  105. package/dist/validation/result.d.ts.map +1 -0
  106. package/dist/validation/result.js +3 -0
  107. package/dist/validation/result.js.map +1 -0
  108. package/dist/vocabulary/bool.d.ts +1 -1
  109. package/dist/vocabulary/bool.d.ts.map +1 -1
  110. package/dist/vocabulary/bool.js +2 -2
  111. package/dist/vocabulary/bool.js.map +1 -1
  112. package/dist/vocabulary/created.d.ts +4 -10
  113. package/dist/vocabulary/created.d.ts.map +1 -1
  114. package/dist/vocabulary/created.js +5 -12
  115. package/dist/vocabulary/created.js.map +1 -1
  116. package/dist/vocabulary/date.d.ts +1 -1
  117. package/dist/vocabulary/date.d.ts.map +1 -1
  118. package/dist/vocabulary/date.js +2 -2
  119. package/dist/vocabulary/date.js.map +1 -1
  120. package/dist/vocabulary/immutable.d.ts +4 -6
  121. package/dist/vocabulary/immutable.d.ts.map +1 -1
  122. package/dist/vocabulary/immutable.js +3 -6
  123. package/dist/vocabulary/immutable.js.map +1 -1
  124. package/dist/vocabulary/indexed.d.ts +5 -16
  125. package/dist/vocabulary/indexed.d.ts.map +1 -1
  126. package/dist/vocabulary/indexed.js +4 -16
  127. package/dist/vocabulary/indexed.js.map +1 -1
  128. package/dist/vocabulary/json.d.ts +8 -13
  129. package/dist/vocabulary/json.d.ts.map +1 -1
  130. package/dist/vocabulary/json.js +3 -3
  131. package/dist/vocabulary/json.js.map +1 -1
  132. package/dist/vocabulary/list.d.ts +3 -6
  133. package/dist/vocabulary/list.d.ts.map +1 -1
  134. package/dist/vocabulary/list.js +6 -5
  135. package/dist/vocabulary/list.js.map +1 -1
  136. package/dist/vocabulary/many.d.ts +3 -4
  137. package/dist/vocabulary/many.d.ts.map +1 -1
  138. package/dist/vocabulary/many.js +5 -5
  139. package/dist/vocabulary/many.js.map +1 -1
  140. package/dist/vocabulary/nullable.d.ts +2 -4
  141. package/dist/vocabulary/nullable.d.ts.map +1 -1
  142. package/dist/vocabulary/nullable.js +4 -8
  143. package/dist/vocabulary/nullable.js.map +1 -1
  144. package/dist/vocabulary/number.d.ts +1 -1
  145. package/dist/vocabulary/number.d.ts.map +1 -1
  146. package/dist/vocabulary/number.js +2 -2
  147. package/dist/vocabulary/number.js.map +1 -1
  148. package/dist/vocabulary/oneOf.d.ts +1 -1
  149. package/dist/vocabulary/oneOf.d.ts.map +1 -1
  150. package/dist/vocabulary/oneOf.js +2 -2
  151. package/dist/vocabulary/oneOf.js.map +1 -1
  152. package/dist/vocabulary/optional.d.ts +1 -1
  153. package/dist/vocabulary/optional.d.ts.map +1 -1
  154. package/dist/vocabulary/optional.js +3 -3
  155. package/dist/vocabulary/optional.js.map +1 -1
  156. package/dist/vocabulary/primary.d.ts +5 -5
  157. package/dist/vocabulary/primary.d.ts.map +1 -1
  158. package/dist/vocabulary/primary.js +14 -11
  159. package/dist/vocabulary/primary.js.map +1 -1
  160. package/dist/vocabulary/readOnly.d.ts +4 -7
  161. package/dist/vocabulary/readOnly.d.ts.map +1 -1
  162. package/dist/vocabulary/readOnly.js +4 -7
  163. package/dist/vocabulary/readOnly.js.map +1 -1
  164. package/dist/vocabulary/ref.d.ts +1 -1
  165. package/dist/vocabulary/ref.d.ts.map +1 -1
  166. package/dist/vocabulary/ref.js +2 -2
  167. package/dist/vocabulary/ref.js.map +1 -1
  168. package/dist/vocabulary/text.d.ts +1 -1
  169. package/dist/vocabulary/text.d.ts.map +1 -1
  170. package/dist/vocabulary/text.js +2 -2
  171. package/dist/vocabulary/text.js.map +1 -1
  172. package/dist/vocabulary/unique.d.ts +8 -18
  173. package/dist/vocabulary/unique.d.ts.map +1 -1
  174. package/dist/vocabulary/unique.js +7 -18
  175. package/dist/vocabulary/unique.js.map +1 -1
  176. package/dist/vocabulary/updated.d.ts +2 -2
  177. package/dist/vocabulary/updated.d.ts.map +1 -1
  178. package/dist/vocabulary/updated.js +1 -2
  179. package/dist/vocabulary/updated.js.map +1 -1
  180. package/dist/vocabulary/writeOnly.d.ts +4 -6
  181. package/dist/vocabulary/writeOnly.d.ts.map +1 -1
  182. package/dist/vocabulary/writeOnly.js +4 -6
  183. package/dist/vocabulary/writeOnly.js.map +1 -1
  184. package/package.json +2 -2
  185. package/dist/projections/validation.d.ts +0 -57
  186. package/dist/projections/validation.d.ts.map +0 -1
  187. package/dist/projections/validation.js +0 -148
  188. package/dist/projections/validation.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"reconstruct.js","sourceRoot":"","sources":["../../src/projections/reconstruct.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,GAOZ,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,uBAAuB,EAAgD,MAAM,cAAc,CAAC;AACrG,OAAO,EACL,KAAK,GAKN,MAAM,WAAW,CAAC;AAEnB,sEAAsE;AAEtE;;;;GAIG;AACH,SAAS,gBAAgB,CAAC,IAAqB;IAC7C,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAClF,MAAM,IAAI,GAAG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AAO,MAAM,CAAC;AAChB,CAAC;AASD;;;;;;;;;GASG;AACH,MAAM,UAAU,WAAW,CACzB,UAA4B;IAE5B,OAAO,WAAW,CAAC,UAAU,CAA8C,CAAC;AAC9E,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,MAAoB;IACjD,MAAM,GAAG,GAAsC,EAAE,CAAC;IAClD,MAAM,OAAO,GAAa,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;IAC5D,MAAM,GAAG,GAA+B,EAAE,CAAC;IAC3C,KAAK,MAAM,CAAC,IAAI,EAAE,UAAU,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;QAC9D,MAAM,MAAM,GAAG,WAAW,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;QAChD,sFAAsF;QACtF,sEAAsE;QACtE,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC;QAC3E,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,GAAG,MAAsC,CAAC;QACjE,GAAG,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;IACrB,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -1,41 +1,18 @@
1
- import type { Fields, SchemaLike } from '../field/index.js';
1
+ import type { Fields } from '../field/index.js';
2
+ import type { SchemaView } from '../schema/index.js';
2
3
  import type { SchemaDescriptor } from './card.js';
3
4
  /**
4
- * The two forms a schema reaches an adapter in and the single reader that takes both.
5
- *
6
- * An adapter has never needed the class, only its fields. In-process it gets the class
7
- * because the class is there; from a remote or foreign frond it gets the card, because a
8
- * class does not cross a wire. Naming that union here is what lets one projection serve
9
- * both, instead of each adapter growing its own branch.
10
- *
11
- * The card was built for exactly this and had no in-repo reader: every adapter called
12
- * `getFields()` on the live class, so writing a Fougere adapter meant being inside the
13
- * repo, in TypeScript, with the class in hand.
5
+ * The two forms a schema reaches an adapter in. In-process it gets the class; from a
6
+ * remote or foreign frond it gets the card, because a class does not cross a wire. Naming
7
+ * the union is what lets one projection serve both.
14
8
  */
15
- export type SchemaSource = SchemaLike | SchemaDescriptor;
9
+ export type SchemaSource = SchemaView | SchemaDescriptor;
16
10
  /**
17
- * Normalize a source to a live schema reconstructing a card, passing a class through.
18
- *
19
- * This is what an adapter reaching for the schema MORE THAN ONCE should call, once, at its
20
- * boundary: `reconstruct` runs per call (6.5 µs for a 17-field entity), so a component that
21
- * reads fields in two places would otherwise rebuild the schema twice and hold two
22
- * unrelated field objects. Normalize at the edge, then nothing downstream knows the
23
- * difference — which is the point.
24
- */
25
- export declare function schemaOf(source: SchemaSource): SchemaLike;
26
- /**
27
- * The fields an adapter projects from, whichever form it was handed — {@link schemaOf}
28
- * for the single-read case.
29
- *
30
- * Cost: nothing for a class. For a card, one `reconstruct` — measured at 6.5 µs for a
31
- * 17-field entity, paid once per entity when the adapter builds, never per request. Read
32
- * twice and you pay twice: hold the result, or normalize with `schemaOf` instead.
11
+ * Normalize a source to a live schema. Call it ONCE, at the adapter's boundary:
12
+ * `reconstruct` runs per call (6.5 µs for 17 fields), so reading fields in two places
13
+ * would rebuild the schema twice and hold two unrelated field objects.
33
14
  */
15
+ export declare function schemaOf(source: SchemaSource): SchemaView;
16
+ /** The fields an adapter projects from, whichever form it was handed. */
34
17
  export declare function fieldsOf(source: SchemaSource): Fields;
35
- /**
36
- * The composite unique groups, whichever form. A bare wrapper (a view mid-derivation)
37
- * carries no `getUnique` and answers `undefined`; a card's groups are recovered from what
38
- * its members carry, so `reconstruct` has already restored them by the time this reads.
39
- */
40
- export declare function uniqueOf(source: SchemaSource): ReadonlyArray<ReadonlyArray<string>> | undefined;
41
18
  //# sourceMappingURL=source.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"source.d.ts","sourceRoot":"","sources":["../../src/projections/source.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAGlD;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,YAAY,GAAG,UAAU,GAAG,gBAAgB,CAAC;AAOzD;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,YAAY,GAAG,UAAU,CAEzD;AAED;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAErD;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,YAAY,GAAG,aAAa,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,GAAG,SAAS,CAE/F"}
1
+ {"version":3,"file":"source.d.ts","sourceRoot":"","sources":["../../src/projections/source.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAGlD;;;;GAIG;AACH,MAAM,MAAM,YAAY,GAAG,UAAU,GAAG,gBAAgB,CAAC;AAOzD;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,YAAY,GAAG,UAAU,CAEzD;AAED,yEAAyE;AACzE,wBAAgB,QAAQ,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAErD"}
@@ -4,34 +4,15 @@ function isDescriptor(source) {
4
4
  return typeof source.getFields !== 'function';
5
5
  }
6
6
  /**
7
- * Normalize a source to a live schema reconstructing a card, passing a class through.
8
- *
9
- * This is what an adapter reaching for the schema MORE THAN ONCE should call, once, at its
10
- * boundary: `reconstruct` runs per call (6.5 µs for a 17-field entity), so a component that
11
- * reads fields in two places would otherwise rebuild the schema twice and hold two
12
- * unrelated field objects. Normalize at the edge, then nothing downstream knows the
13
- * difference — which is the point.
7
+ * Normalize a source to a live schema. Call it ONCE, at the adapter's boundary:
8
+ * `reconstruct` runs per call (6.5 µs for 17 fields), so reading fields in two places
9
+ * would rebuild the schema twice and hold two unrelated field objects.
14
10
  */
15
11
  export function schemaOf(source) {
16
12
  return isDescriptor(source) ? reconstruct(source) : source;
17
13
  }
18
- /**
19
- * The fields an adapter projects from, whichever form it was handed — {@link schemaOf}
20
- * for the single-read case.
21
- *
22
- * Cost: nothing for a class. For a card, one `reconstruct` — measured at 6.5 µs for a
23
- * 17-field entity, paid once per entity when the adapter builds, never per request. Read
24
- * twice and you pay twice: hold the result, or normalize with `schemaOf` instead.
25
- */
14
+ /** The fields an adapter projects from, whichever form it was handed. */
26
15
  export function fieldsOf(source) {
27
16
  return schemaOf(source).getFields();
28
17
  }
29
- /**
30
- * The composite unique groups, whichever form. A bare wrapper (a view mid-derivation)
31
- * carries no `getUnique` and answers `undefined`; a card's groups are recovered from what
32
- * its members carry, so `reconstruct` has already restored them by the time this reads.
33
- */
34
- export function uniqueOf(source) {
35
- return schemaOf(source).getUnique?.();
36
- }
37
18
  //# sourceMappingURL=source.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"source.js","sourceRoot":"","sources":["../../src/projections/source.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAgB/C,sEAAsE;AACtE,SAAS,YAAY,CAAC,MAAoB;IACxC,OAAO,OAAQ,MAAqB,CAAC,SAAS,KAAK,UAAU,CAAC;AAChE,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,QAAQ,CAAC,MAAoB;IAC3C,OAAO,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;AAC7D,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,QAAQ,CAAC,MAAoB;IAC3C,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,CAAC;AACtC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,QAAQ,CAAC,MAAoB;IAC3C,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC;AACxC,CAAC"}
1
+ {"version":3,"file":"source.js","sourceRoot":"","sources":["../../src/projections/source.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAS/C,sEAAsE;AACtE,SAAS,YAAY,CAAC,MAAoB;IACxC,OAAO,OAAQ,MAAqB,CAAC,SAAS,KAAK,UAAU,CAAC;AAChE,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,QAAQ,CAAC,MAAoB;IAC3C,OAAO,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;AAC7D,CAAC;AAED,yEAAyE;AACzE,MAAM,UAAU,QAAQ,CAAC,MAAoB;IAC3C,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,CAAC;AACtC,CAAC"}
@@ -2,11 +2,11 @@ import type { SchemaDescriptor } from './card.js';
2
2
  export interface TypeSourceOptions {
3
3
  /** Name of the emitted interface. Defaults to the card's `title`, capitalized. */
4
4
  name?: string;
5
- /** Emit `export` before the declaration. Default: true. */
6
5
  exported?: boolean;
7
6
  }
8
7
  /**
9
8
  * The anonymous object type one card describes — the members, nothing around them.
9
+ * Internal: `entitySourceOf` is what a consumer calls, and it emits this above the judge.
10
10
  *
11
11
  * Every property is present: `required` on a Fougère card answers "what must a CALLER
12
12
  * supply at creation", not "what is always there when read" — an `id` the system
@@ -15,18 +15,11 @@ export interface TypeSourceOptions {
15
15
  */
16
16
  export declare function shapeTypeOf(descriptor: SchemaDescriptor, indent?: string): string;
17
17
  /**
18
- * Emit the entity a card describes — ONE class, judge and shape together.
18
+ * Emit the entity a card describes — ONE class, judge and shape together, because a class
19
+ * is the language's own answer to "a name that is both a value and a type".
19
20
  *
20
- * An entity is a class here (`class Post extends entity({…}) {}`), and a class is the
21
- * language's own answer to "a name that is both a value and a type". Emitting an
22
- * interface next to a const said the same thing twice and relied on declaration
23
- * merging to look like a class; this IS one.
24
- *
25
- * The card travels inline, so the rebuilt judge is exact — the shape written above it
26
- * is read off that same card, never a second source to keep in step.
27
- *
28
- * Requires `reconstruct` in scope: the caller writes the import, since only it knows
29
- * whether the consumer says `@fougere/schema` or a path.
21
+ * The card travels inline, so the rebuilt judge and the shape above it read off the same
22
+ * source. Requires `reconstruct` in scope: only the caller knows how the consumer imports.
30
23
  */
31
24
  export declare function entitySourceOf(descriptor: SchemaDescriptor, options?: TypeSourceOptions): string;
32
25
  /** One operation, as much of it as a card can say. */
@@ -37,16 +30,7 @@ export interface OpDescriptor {
37
30
  /** How much `output` describes. Absent means the card did not say. */
38
31
  cardinality?: 'one' | 'maybe' | 'many' | 'page' | 'none';
39
32
  }
40
- /**
41
- * Emit the type of a façade — every operation an entity serves, as a caller meets it.
42
- *
43
- * This is what `Facade<T>` needs and what no consumer in another repository could have:
44
- * writing `Facade<ArticleHandler>` used to require importing the handler's class, which
45
- * `sync` does not carry and should not. The card carries the operations; this reads them.
46
- *
47
- * Each op takes an optional invocation and returns a promise — the door's signature, not
48
- * the handler's. A handler's method takes positional arguments; its door takes the call.
49
- */
33
+ /** Emit the type of a façade — every operation an entity serves, as a callable surface. */
50
34
  export declare function facadeTypeSourceOf(ops: readonly OpDescriptor[], options?: TypeSourceOptions & {
51
35
  rowType?: string;
52
36
  }): string;
@@ -1 +1 @@
1
- {"version":3,"file":"typescript.d.ts","sourceRoot":"","sources":["../../src/projections/typescript.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAmB,gBAAgB,EAAE,MAAM,WAAW,CAAC;AA0FnE,MAAM,WAAW,iBAAiB;IAChC,kFAAkF;IACl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AAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAC1B,sEAAsE;IACtE,WAAW,CAAC,EAAE,KAAK,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;CAC1D;AAyBD,2FAA2F;AAC3F,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,SAAS,YAAY,EAAE,EAC5B,OAAO,GAAE,iBAAiB,GAAG;IAAE,OAAO,CAAC,EAAE,MAAM,CAAA;CAAO,GACrD,MAAM,CAYR"}
@@ -1,22 +1,11 @@
1
1
  /**
2
- * card → TypeScript source the projection that was missing.
2
+ * card → TypeScript source. `reconstruct` gives a consumer a living judge; this gives it
3
+ * the type, so `post.title` is `string` rather than `any` and `post.titel` fails.
3
4
  *
4
- * `describe` turns a schema into a card and `reconstruct` turns it back into a
5
- * living judge, so a consumer in another repository validates by the host's rules
6
- * without holding its code. What it did NOT get is a type: left to infer, a rebuilt
7
- * schema has an index signature for an instance type, so `post.title` was `any` and
8
- * `post.titel` compiled. The declaration travelled and the compiler learned nothing.
9
- *
10
- * So the card gets a third reader, and it writes the shape where `reconstruct` now
11
- * accepts it — as the type argument of the class's own base expression, one
12
- * declaration for the judge and the rows it judges. Same input as the other two
13
- * readers, same rule: the shape IS JSON Schema, and JSON Schema has a type form.
14
- *
15
- * Deliberately NOT a JSON Schema→TS library: the input is not arbitrary JSON Schema,
16
- * it is a Fougère card, whose vocabulary is closed (`describe` writes it). A general
17
- * library would carry `$ref`, `allOf`, tuple `items`, `additionalProperties` and the
18
- * rest of a spec we never emit, and would still need this file to know that
19
- * `format: date-time` means `Date` here — a fact about our boundary, not about JSON.
5
+ * Deliberately NOT a JSON Schema→TS library: the input is a Fougère card, whose vocabulary
6
+ * is closed. A general one would carry `$ref`, `allOf` and the rest we never emit, and
7
+ * would still need this file to know `format: date-time` means `Date` a fact about our
8
+ * boundary, not about JSON.
20
9
  */
21
10
  /** What a field's value looks like once `reconstruct` has decoded it. */
22
11
  function typeOf(field) {
@@ -33,8 +22,8 @@ function baseTypeOf(base, field) {
33
22
  }
34
23
  switch (base) {
35
24
  case 'string':
36
- // `date-time` is the wire form of a value the boundary decodes to a Date, and
37
- // the façade now hands the decoded value on. The type says what you receive.
25
+ // `date-time` is the wire form of a value the boundary decodes; the type says what
26
+ // you receive, not what travelled.
38
27
  return field.format === 'date-time' ? 'Date' : 'string';
39
28
  case 'number':
40
29
  case 'integer':
@@ -42,9 +31,8 @@ function baseTypeOf(base, field) {
42
31
  case 'boolean':
43
32
  return 'boolean';
44
33
  case 'array':
45
- // Two distinct things share `array`: a value list carries `items`, a bare `many`
46
- // relation carries none — the ids of the other side, which the card names as a
47
- // relation rather than a shape.
34
+ // `array` covers two things: a value list carries `items`, a `many` relation carries
35
+ // none — the ids of the other side.
48
36
  return field.items ? `${typeOf(field.items)}[]` : 'string[]';
49
37
  case 'object':
50
38
  return field.properties ? objectTypeOf(field.properties, field.required ?? []) : 'Record<string, unknown>';
@@ -83,6 +71,7 @@ function docCommentOf(text, indent) {
83
71
  }
84
72
  /**
85
73
  * The anonymous object type one card describes — the members, nothing around them.
74
+ * Internal: `entitySourceOf` is what a consumer calls, and it emits this above the judge.
86
75
  *
87
76
  * Every property is present: `required` on a Fougère card answers "what must a CALLER
88
77
  * supply at creation", not "what is always there when read" — an `id` the system
@@ -100,18 +89,11 @@ export function shapeTypeOf(descriptor, indent = '') {
100
89
  return `{\n${lines.join('\n')}\n${indent}}`;
101
90
  }
102
91
  /**
103
- * Emit the entity a card describes — ONE class, judge and shape together.
104
- *
105
- * An entity is a class here (`class Post extends entity({…}) {}`), and a class is the
106
- * language's own answer to "a name that is both a value and a type". Emitting an
107
- * interface next to a const said the same thing twice and relied on declaration
108
- * merging to look like a class; this IS one.
109
- *
110
- * The card travels inline, so the rebuilt judge is exact — the shape written above it
111
- * is read off that same card, never a second source to keep in step.
92
+ * Emit the entity a card describes — ONE class, judge and shape together, because a class
93
+ * is the language's own answer to "a name that is both a value and a type".
112
94
  *
113
- * Requires `reconstruct` in scope: the caller writes the import, since only it knows
114
- * whether the consumer says `@fougere/schema` or a path.
95
+ * The card travels inline, so the rebuilt judge and the shape above it read off the same
96
+ * source. Requires `reconstruct` in scope: only the caller knows how the consumer imports.
115
97
  */
116
98
  export function entitySourceOf(descriptor, options = {}) {
117
99
  const name = identifierOf(options.name ?? capitalize(descriptor.title ?? 'Schema'));
@@ -159,16 +141,7 @@ function returnTypeOf(op, rowType) {
159
141
  default: return 'unknown';
160
142
  }
161
143
  }
162
- /**
163
- * Emit the type of a façade — every operation an entity serves, as a caller meets it.
164
- *
165
- * This is what `Facade<T>` needs and what no consumer in another repository could have:
166
- * writing `Facade<ArticleHandler>` used to require importing the handler's class, which
167
- * `sync` does not carry and should not. The card carries the operations; this reads them.
168
- *
169
- * Each op takes an optional invocation and returns a promise — the door's signature, not
170
- * the handler's. A handler's method takes positional arguments; its door takes the call.
171
- */
144
+ /** Emit the type of a façade — every operation an entity serves, as a callable surface. */
172
145
  export function facadeTypeSourceOf(ops, options = {}) {
173
146
  const name = options.name ?? 'Facade';
174
147
  const exported = options.exported === false ? '' : 'export ';
@@ -1 +1 @@
1
- {"version":3,"file":"typescript.js","sourceRoot":"","sources":["../../src/projections/typescript.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,yEAAyE;AACzE,SAAS,MAAM,CAAC,KAAsB;IACpC,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACtF,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACxC,MAAM,IAA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sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/schema/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,GAAG,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,qBAAqB,EAAE,KAAK,iBAAiB,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { Schema, compose, ANONYMOUS_SCHEMA_NAME } from "./schema.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/schema/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,qBAAqB,EAA0B,MAAM,aAAa,CAAC"}
@@ -0,0 +1,74 @@
1
+ import { type Fields } from "../field/index.js";
2
+ import { type Hints } from "../hints.js";
3
+ import { type CompositeUnique } from "../unique.js";
4
+ import { type ValidateOptions } from '../validation/index.js';
5
+ import type { StandardSchemaV1 } from "../projections/standard.js";
6
+ import type { PartialRow, Row, SchemaView } from "./view.js";
7
+ /** The name a derivation carries when no class declaration named it. */
8
+ export declare const ANONYMOUS_SCHEMA_NAME = "Schema";
9
+ /** A schema view that also constructs and derives. */
10
+ export interface SchemaConstructor<TFields extends Fields> extends SchemaView<TFields> {
11
+ new (data: PartialRow<TFields>): Row<TFields>;
12
+ readonly "~standard": StandardSchemaV1.Props<Record<string, unknown>, Row<TFields>>;
13
+ /** The Entity class this derivation came from — absent on a `compose()` result. */
14
+ readonly source?: abstract new (...args: never[]) => unknown;
15
+ from(data: Record<string, unknown>): Row<TFields>;
16
+ pick<K extends string & keyof TFields>(...keys: K[]): SchemaConstructor<Pick<TFields, K>>;
17
+ omit<K extends string & keyof TFields>(...keys: K[]): SchemaConstructor<Omit<TFields, K>>;
18
+ partial(): SchemaConstructor<TFields>;
19
+ extend<E extends Fields>(extra: E): SchemaConstructor<TFields & E>;
20
+ /** Give an anonymous derivation an explicit runtime name. */
21
+ named(name: string): SchemaConstructor<TFields>;
22
+ rename(mapping: Partial<Record<string & keyof TFields, string>>): SchemaConstructor<Fields>;
23
+ }
24
+ /**
25
+ * The carrier. Its data lives on the class, so `this` resolves it and a derivation is a
26
+ * subclass with a different map — `Post.pick('id')` reads `Post.fields`, not a closure.
27
+ */
28
+ export declare class Schema {
29
+ static fields: Fields;
30
+ static hints: Hints<Fields> | undefined;
31
+ static unique: CompositeUnique<Fields> | undefined;
32
+ static opts: ValidateOptions;
33
+ static source: (abstract new (...args: never[]) => unknown) | undefined;
34
+ /** Trusted: takes already-shaped data. Untrusted input goes through `validate`/`from`. */
35
+ constructor(data?: Record<string, unknown>);
36
+ static getFields(): Fields;
37
+ static getHints(): Hints<Fields> | undefined;
38
+ static getUnique(): CompositeUnique<Fields> | undefined;
39
+ static getOpts(): ValidateOptions;
40
+ static validate(input: unknown): import("../validation/result.js").ValidationResult<Record<string, unknown>>;
41
+ /** Trusted: keeps known keys, decodes each through its boundary, leaves the rest. */
42
+ static from(data: Record<string, unknown>): Record<string, unknown>;
43
+ static get ["~standard"](): StandardSchemaV1.Props<Record<string, unknown>>;
44
+ static pick(...keys: string[]): SchemaConstructor<Fields>;
45
+ static omit(...keys: string[]): SchemaConstructor<Fields>;
46
+ static rename(mapping: Record<string, string>): SchemaConstructor<Fields>;
47
+ /** Patch mode: an unsent field is untouched. Moves the presence axis, never nullity. */
48
+ static partial(): SchemaConstructor<{
49
+ [x: string]: import("../field/field.js").Field<unknown>;
50
+ }>;
51
+ static extend(extra: Fields): SchemaConstructor<{
52
+ [x: string]: import("../field/field.js").Field<unknown>;
53
+ }>;
54
+ /**
55
+ * Renames in place, so it may only name what has no name — on a declared class it would
56
+ * silently retarget its table, its GraphQL type and its registration key.
57
+ */
58
+ static named(name: string): typeof Schema;
59
+ /** A subclass carrying its own map — the only way a schema is made. */
60
+ static of<TFields extends Fields>(fields: TFields, source?: abstract new (...args: never[]) => unknown, hints?: Hints<TFields>, opts?: ValidateOptions, unique?: CompositeUnique<Fields>): SchemaConstructor<TFields>;
61
+ /** A key transform applied to the fields, the hints and the unique groups at once. */
62
+ private static derive;
63
+ }
64
+ type UnionToIntersection<U> = (U extends unknown ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
65
+ type Merged<T extends SchemaView[]> = UnionToIntersection<T[number] extends {
66
+ getFields(): infer F;
67
+ } ? F : Fields> & Fields;
68
+ /**
69
+ * Merge schemas into one — `class User extends compose(UserBase, Timestamps) {}`.
70
+ * Left to right, later sources win on conflict. Use `.rename()` first to avoid one.
71
+ */
72
+ export declare function compose<T extends SchemaView[]>(...sources: T): SchemaConstructor<Merged<T>>;
73
+ export {};
74
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/schema/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,MAAM,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,EAAe,KAAK,KAAK,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAmC,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AACrF,OAAO,EAAS,KAAK,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACrE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,KAAK,EAAE,UAAU,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE7D,wEAAwE;AACxE,eAAO,MAAM,qBAAqB,WAAW,CAAC;AAE9C,sDAAsD;AACtD,MAAM,WAAW,iBAAiB,CAAC,OAAO,SAAS,MAAM,CAAE,SAAQ,UAAU,CAAC,OAAO,CAAC;IACpF,KAAK,IAAI,EAAE,UAAU,CAAC,OAAO,CAAC,GAAG,GAAG,CAAC,OAAO,CAAC,CAAC;IAC9C,QAAQ,CAAC,WAAW,EAAE,g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O,EACnD,KAAK,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC,EACtB,IAAI,GAAE,eAAoB,EAC1B,MAAM,CAAC,EAAE,eAAe,CAAC,MAAM,CAAC,GAC/B,iBAAiB,CAAC,OAAO,CAAC,CAM5B;IAED,sFAAsF;IACtF,OAAO,CAAC,MAAM,CAAC,MAAM;CAStB;AAYD,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;AACpH,KAAK,MAAM,CAAC,CAAC,SAAS,UAAU,EAAE,IAAI,mBAAmB,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS;IAAE,SAAS,IAAI,MAAM,CAAC,CAAA;CAAE,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,MAAM,CAAC;AAE5H;;;GAGG;AACH,wBAAgB,OAAO,CAAC,CAAC,SAAS,UAAU,EAAE,EAAE,GAAG,OAAO,EAAE,CAAC,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAiB3F"}
@@ -0,0 +1,162 @@
1
+ import { resolveBoundary } from "../field/index.js";
2
+ import { deriveHints } from "../hints.js";
3
+ import { deriveUnique, deriveUniqueRoles } from "../unique.js";
4
+ import { Judge } from '../validation/index.js';
5
+ /** The name a derivation carries when no class declaration named it. */
6
+ export const ANONYMOUS_SCHEMA_NAME = "Schema";
7
+ /**
8
+ * The carrier. Its data lives on the class, so `this` resolves it and a derivation is a
9
+ * subclass with a different map — `Post.pick('id')` reads `Post.fields`, not a closure.
10
+ */
11
+ export class Schema {
12
+ static fields = {};
13
+ static hints;
14
+ static unique;
15
+ static opts = {};
16
+ static source;
17
+ /** Trusted: takes already-shaped data. Untrusted input goes through `validate`/`from`. */
18
+ constructor(data) {
19
+ if (!data)
20
+ return;
21
+ // Define, never assign: `Object.assign` writes through [[Set]], so a `__proto__` key
22
+ // from a parsed JSON row fires the setter and replaces this instance's prototype.
23
+ for (const [key, value] of Object.entries(data)) {
24
+ Object.defineProperty(this, key, { value, writable: true, enumerable: true, configurable: true });
25
+ }
26
+ }
27
+ static getFields() { return this.fields; }
28
+ static getHints() { return this.hints; }
29
+ static getUnique() { return this.unique; }
30
+ static getOpts() { return this.opts; }
31
+ static validate(input) {
32
+ return Judge.row(this.fields, input, this.opts);
33
+ }
34
+ /** Trusted: keeps known keys, decodes each through its boundary, leaves the rest. */
35
+ static from(data) {
36
+ const out = {};
37
+ for (const [key, field] of Object.entries(this.fields)) {
38
+ if (!(key in data))
39
+ continue;
40
+ const value = data[key];
41
+ if (value === null || value === undefined) {
42
+ out[key] = value;
43
+ continue;
44
+ }
45
+ const decoded = resolveBoundary(field).decode(value);
46
+ out[key] = "error" in decoded ? value : decoded.value;
47
+ }
48
+ return out;
49
+ }
50
+ static get ["~standard"]() {
51
+ const { fields, opts } = this;
52
+ return {
53
+ version: 1,
54
+ vendor: "fougere",
55
+ validate(value) {
56
+ const result = Judge.row(fields, value, opts);
57
+ if (result.success)
58
+ return { value: result.data };
59
+ // ONE segment, not a split: a path is always a single field name until nested
60
+ // objects report their own, so splitting invented segments for a name like `a.b`.
61
+ return {
62
+ issues: result.errors.map((e) => ({
63
+ message: e.message,
64
+ path: e.path && e.path !== "." ? [{ key: e.path }] : undefined,
65
+ })),
66
+ };
67
+ },
68
+ };
69
+ }
70
+ // ─── The derivation algebra ───
71
+ // Each derivation states its difference and keeps the rest. `source ?? this` records
72
+ // the ORIGIN once: a view of a view keeps it rather than the intermediate.
73
+ static pick(...keys) {
74
+ assertKnownKeys("pick", keys, this.fields);
75
+ const picked = {};
76
+ for (const key of keys)
77
+ if (this.fields[key])
78
+ picked[key] = this.fields[key];
79
+ return this.derive(picked, (k) => (keys.includes(k) ? k : undefined));
80
+ }
81
+ static omit(...keys) {
82
+ assertKnownKeys("omit", keys, this.fields);
83
+ const kept = {};
84
+ for (const [key, field] of Object.entries(this.fields))
85
+ if (!keys.includes(key))
86
+ kept[key] = field;
87
+ return this.derive(kept, (k) => (keys.includes(k) ? undefined : k));
88
+ }
89
+ static rename(mapping) {
90
+ assertKnownKeys("rename", Object.keys(mapping), this.fields);
91
+ const renamed = {};
92
+ for (const [key, field] of Object.entries(this.fields))
93
+ renamed[mapping[key] ?? key] = field;
94
+ return this.derive(renamed, (k) => mapping[k] ?? k);
95
+ }
96
+ /** Patch mode: an unsent field is untouched. Moves the presence axis, never nullity. */
97
+ static partial() {
98
+ return Schema.of({ ...this.fields }, this.source ?? this, this.hints, { ...this.opts, patch: true }, this.unique);
99
+ }
100
+ static extend(extra) {
101
+ return Schema.of({ ...this.fields, ...extra }, this.source ?? this, this.hints, this.opts, this.unique);
102
+ }
103
+ /**
104
+ * Renames in place, so it may only name what has no name — on a declared class it would
105
+ * silently retarget its table, its GraphQL type and its registration key.
106
+ */
107
+ static named(name) {
108
+ if (!/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(name)) {
109
+ throw new Error(`named(): \`${name}\` is not a valid class name.`);
110
+ }
111
+ if (this.name !== ANONYMOUS_SCHEMA_NAME) {
112
+ throw new Error(`named(): \`${this.name}\` is already named by its class declaration.`);
113
+ }
114
+ Object.defineProperty(this, "name", { value: name, configurable: true });
115
+ return this;
116
+ }
117
+ /** A subclass carrying its own map — the only way a schema is made. */
118
+ static of(fields, source, hints, opts = {}, unique) {
119
+ class Derived extends Schema {
120
+ }
121
+ Object.assign(Derived, { fields, source, hints, opts, unique });
122
+ Object.defineProperty(Derived, "name", { value: ANONYMOUS_SCHEMA_NAME, configurable: true });
123
+ // TS sees an empty subclass and cannot prove it matches the precise map.
124
+ return Derived;
125
+ }
126
+ /** A key transform applied to the fields, the hints and the unique groups at once. */
127
+ static derive(fields, survives) {
128
+ return Schema.of(deriveUniqueRoles(fields, survives), this.source ?? this, deriveHints(this.hints, survives), this.opts, deriveUnique(this.unique, survives));
129
+ }
130
+ }
131
+ /** Refuse a key the schema does not carry — a typo in `pick`/`omit` used to be obeyed. */
132
+ function assertKnownKeys(operation, keys, fields) {
133
+ const strangers = keys.filter((key) => !(key in fields));
134
+ if (strangers.length === 0)
135
+ return;
136
+ throw new Error(`${operation}(): unknown field ${strangers.map((s) => `\`${s}\``).join(", ")}. ` +
137
+ `This schema carries ${Object.keys(fields).join(", ")}.`);
138
+ }
139
+ /**
140
+ * Merge schemas into one — `class User extends compose(UserBase, Timestamps) {}`.
141
+ * Left to right, later sources win on conflict. Use `.rename()` first to avoid one.
142
+ */
143
+ export function compose(...sources) {
144
+ const merged = {};
145
+ const mergedHints = {};
146
+ let mergedOpts = {};
147
+ for (const source of sources) {
148
+ Object.assign(merged, source.getFields());
149
+ const hints = source.getHints();
150
+ if (hints) {
151
+ for (const [adapter, perField] of Object.entries(hints)) {
152
+ if (!perField || typeof perField !== "object")
153
+ continue;
154
+ mergedHints[adapter] = { ...mergedHints[adapter], ...perField };
155
+ }
156
+ }
157
+ mergedOpts = { ...mergedOpts, ...source.getOpts() };
158
+ }
159
+ const hints = Object.keys(mergedHints).length ? mergedHints : undefined;
160
+ return Schema.of(merged, undefined, hints, mergedOpts);
161
+ }
162
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/schema/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAe,MAAM,mBAAmB,CAAC;AACjE,OAAO,EAAE,WAAW,EAAc,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAwB,MAAM,cAAc,CAAC;AACrF,OAAO,EAAE,KAAK,EAAwB,MAAM,wBAAwB,CAAC;AAIrE,wEAAwE;AACxE,MAAM,CAAC,MAAM,qBAAqB,GAAG,QAAQ,CAAC;AAkB9C;;;GAGG;AACH,MAAM,OAAO,MAAM;IACjB,MAAM,CAAC,MAAM,GAAW,EAA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