@fougere/core 0.3.0-alpha.0 → 0.5.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (243) hide show
  1. package/README.md +1 -1
  2. package/dist/boot/Emissions.js +1 -1
  3. package/dist/boot/Emissions.js.map +1 -1
  4. package/dist/boot/HandlerFacade.js +2 -2
  5. package/dist/boot/HandlerFacade.js.map +1 -1
  6. package/dist/boot/apply.d.ts.map +1 -1
  7. package/dist/boot/apply.js +2 -12
  8. package/dist/boot/apply.js.map +1 -1
  9. package/dist/boot/binding.d.ts +1 -1
  10. package/dist/boot/binding.d.ts.map +1 -1
  11. package/dist/boot/binding.js +4 -4
  12. package/dist/boot/binding.js.map +1 -1
  13. package/dist/boot/boot.d.ts +1 -1
  14. package/dist/boot/boot.d.ts.map +1 -1
  15. package/dist/boot/bootstrap.d.ts.map +1 -1
  16. package/dist/boot/bootstrap.js +26 -17
  17. package/dist/boot/bootstrap.js.map +1 -1
  18. package/dist/boot/frame.d.ts +1 -1
  19. package/dist/boot/frame.d.ts.map +1 -1
  20. package/dist/boot/frame.js +5 -14
  21. package/dist/boot/frame.js.map +1 -1
  22. package/dist/boot/hosted.d.ts +29 -0
  23. package/dist/boot/hosted.d.ts.map +1 -0
  24. package/dist/boot/hosted.js +38 -0
  25. package/dist/boot/hosted.js.map +1 -0
  26. package/dist/boot/ownership.d.ts +0 -3
  27. package/dist/boot/ownership.d.ts.map +1 -1
  28. package/dist/boot/ownership.js +5 -5
  29. package/dist/boot/ownership.js.map +1 -1
  30. package/dist/boot/remote.d.ts +1 -1
  31. package/dist/boot/remote.d.ts.map +1 -1
  32. package/dist/boot/remote.js +3 -3
  33. package/dist/boot/remote.js.map +1 -1
  34. package/dist/boot/statement-drift.d.ts +24 -0
  35. package/dist/boot/statement-drift.d.ts.map +1 -0
  36. package/dist/boot/statement-drift.js +38 -0
  37. package/dist/boot/statement-drift.js.map +1 -0
  38. package/dist/boot/together.d.ts.map +1 -1
  39. package/dist/boot/together.js +6 -6
  40. package/dist/boot/together.js.map +1 -1
  41. package/dist/boot/types.d.ts +17 -4
  42. package/dist/boot/types.d.ts.map +1 -1
  43. package/dist/contract/CallLog.d.ts +57 -0
  44. package/dist/contract/CallLog.d.ts.map +1 -0
  45. package/dist/contract/CallLog.js +2 -0
  46. package/dist/contract/CallLog.js.map +1 -0
  47. package/dist/contract.d.ts +9 -4
  48. package/dist/contract.d.ts.map +1 -1
  49. package/dist/contract.js +12 -5
  50. package/dist/contract.js.map +1 -1
  51. package/dist/dispatch/DispatchLifecycle.d.ts +9 -1
  52. package/dist/dispatch/DispatchLifecycle.d.ts.map +1 -1
  53. package/dist/dispatch/DispatchLifecycle.js +17 -2
  54. package/dist/dispatch/DispatchLifecycle.js.map +1 -1
  55. package/dist/dispatch/InFlight.d.ts +0 -1
  56. package/dist/dispatch/InFlight.d.ts.map +1 -1
  57. package/dist/dispatch/InFlight.js +0 -3
  58. package/dist/dispatch/InFlight.js.map +1 -1
  59. package/dist/dispatch/InputValidator.d.ts.map +1 -1
  60. package/dist/dispatch/InputValidator.js +3 -2
  61. package/dist/dispatch/InputValidator.js.map +1 -1
  62. package/dist/dispatch/OutputProjector.js +2 -2
  63. package/dist/dispatch/OutputProjector.js.map +1 -1
  64. package/dist/dispatch/StorageGuard.d.ts.map +1 -1
  65. package/dist/dispatch/StorageGuard.js +2 -2
  66. package/dist/dispatch/StorageGuard.js.map +1 -1
  67. package/dist/effective-operation.d.ts.map +1 -1
  68. package/dist/effective-operation.js +8 -5
  69. package/dist/effective-operation.js.map +1 -1
  70. package/dist/emit.d.ts +2 -2
  71. package/dist/emit.d.ts.map +1 -1
  72. package/dist/emit.js +2 -2
  73. package/dist/emit.js.map +1 -1
  74. package/dist/identity.js +1 -1
  75. package/dist/identity.js.map +1 -1
  76. package/dist/imports.d.ts +1 -1
  77. package/dist/imports.d.ts.map +1 -1
  78. package/dist/imports.js.map +1 -1
  79. package/dist/index.d.ts +8 -2
  80. package/dist/index.d.ts.map +1 -1
  81. package/dist/index.js +12 -1
  82. package/dist/index.js.map +1 -1
  83. package/dist/node.d.ts +2 -0
  84. package/dist/node.d.ts.map +1 -1
  85. package/dist/node.js +2 -0
  86. package/dist/node.js.map +1 -1
  87. package/dist/orm.d.ts.map +1 -1
  88. package/dist/orm.js +4 -4
  89. package/dist/orm.js.map +1 -1
  90. package/dist/prefab/collector.js +2 -2
  91. package/dist/prefab/collector.js.map +1 -1
  92. package/dist/prefab/mirror.d.ts.map +1 -1
  93. package/dist/prefab/mirror.js +2 -2
  94. package/dist/prefab/mirror.js.map +1 -1
  95. package/dist/prefab/presenter.d.ts.map +1 -1
  96. package/dist/prefab/presenter.js +2 -2
  97. package/dist/prefab/presenter.js.map +1 -1
  98. package/dist/prefab/repository.d.ts.map +1 -1
  99. package/dist/prefab/repository.js +2 -2
  100. package/dist/prefab/repository.js.map +1 -1
  101. package/dist/scan/bundling.d.ts +14 -0
  102. package/dist/scan/bundling.d.ts.map +1 -0
  103. package/dist/scan/bundling.js +26 -0
  104. package/dist/scan/bundling.js.map +1 -0
  105. package/dist/scan/declare.d.ts +71 -0
  106. package/dist/scan/declare.d.ts.map +1 -0
  107. package/dist/scan/declare.js +125 -0
  108. package/dist/scan/declare.js.map +1 -0
  109. package/dist/scan/emit.d.ts.map +1 -1
  110. package/dist/scan/emit.js +3 -2
  111. package/dist/scan/emit.js.map +1 -1
  112. package/dist/scan/handler-parser.d.ts +2 -0
  113. package/dist/scan/handler-parser.d.ts.map +1 -1
  114. package/dist/scan/handler-parser.js +52 -13
  115. package/dist/scan/handler-parser.js.map +1 -1
  116. package/dist/scan/scanner.d.ts.map +1 -1
  117. package/dist/scan/scanner.js +37 -11
  118. package/dist/scan/scanner.js.map +1 -1
  119. package/dist/scan/statement.d.ts +4 -0
  120. package/dist/scan/statement.d.ts.map +1 -0
  121. package/dist/scan/statement.js +112 -0
  122. package/dist/scan/statement.js.map +1 -0
  123. package/dist/verify.js +2 -2
  124. package/dist/verify.js.map +1 -1
  125. package/dist/wire/call.d.ts +19 -8
  126. package/dist/wire/call.d.ts.map +1 -1
  127. package/dist/wire/call.js +17 -6
  128. package/dist/wire/call.js.map +1 -1
  129. package/dist/wire/drift.d.ts +55 -0
  130. package/dist/wire/drift.d.ts.map +1 -0
  131. package/dist/wire/drift.js +121 -0
  132. package/dist/wire/drift.js.map +1 -0
  133. package/dist/wire/middleware.d.ts +1 -1
  134. package/dist/wire/middleware.d.ts.map +1 -1
  135. package/package.json +6 -4
  136. package/src/boot/AppLifecycle.ts +50 -0
  137. package/src/boot/Emissions.ts +263 -0
  138. package/src/boot/HandlerFacade.ts +242 -0
  139. package/src/boot/ambient-port.ts +41 -0
  140. package/src/boot/ambient.als.ts +43 -0
  141. package/src/boot/ambient.queue.ts +75 -0
  142. package/src/boot/apply.ts +47 -0
  143. package/src/boot/auth.ts +55 -0
  144. package/src/boot/binding.ts +182 -0
  145. package/src/boot/boot.ts +125 -0
  146. package/src/boot/bootstrap.ts +847 -0
  147. package/src/boot/frame.ts +210 -0
  148. package/src/boot/hosted.ts +77 -0
  149. package/src/boot/ownership.ts +137 -0
  150. package/src/boot/ports.ts +66 -0
  151. package/src/boot/remote.ts +179 -0
  152. package/src/boot/seed.ts +158 -0
  153. package/src/boot/statement-drift.ts +60 -0
  154. package/src/boot/together.ts +215 -0
  155. package/src/boot/types.ts +274 -0
  156. package/src/builtins/config.ts +19 -0
  157. package/src/builtins/logger.ts +175 -0
  158. package/src/config-loader.ts +146 -0
  159. package/src/contract/Call.ts +18 -0
  160. package/src/contract/CallLog.ts +55 -0
  161. package/src/contract/Invocation.ts +72 -0
  162. package/src/contract/RouteAddress.ts +49 -0
  163. package/src/contract.ts +83 -0
  164. package/src/crypto/encoding.ts +59 -0
  165. package/src/crypto/node.ts +30 -0
  166. package/src/crypto/port.ts +45 -0
  167. package/src/crypto/webcrypto.ts +55 -0
  168. package/src/define.ts +10 -0
  169. package/src/dispatch/ArgumentResolver.ts +17 -0
  170. package/src/dispatch/ArrayResult.ts +10 -0
  171. package/src/dispatch/DispatchEvent.ts +38 -0
  172. package/src/dispatch/DispatchLifecycle.ts +43 -0
  173. package/src/dispatch/DispatchPort.ts +6 -0
  174. package/src/dispatch/Dispatcher.ts +48 -0
  175. package/src/dispatch/InFlight.ts +45 -0
  176. package/src/dispatch/InputValidator.ts +28 -0
  177. package/src/dispatch/LocalRoutePolicy.ts +34 -0
  178. package/src/dispatch/OperationExecutor.ts +60 -0
  179. package/src/dispatch/OperationRoute.ts +18 -0
  180. package/src/dispatch/OutputProjector.ts +32 -0
  181. package/src/dispatch/OutputView.ts +9 -0
  182. package/src/dispatch/PresenterArgumentResolver.ts +25 -0
  183. package/src/dispatch/PresenterExecutor.ts +55 -0
  184. package/src/dispatch/RemoteRouteResolver.ts +21 -0
  185. package/src/dispatch/Route.ts +11 -0
  186. package/src/dispatch/RouteNotFoundError.ts +29 -0
  187. package/src/dispatch/RoutePolicy.ts +8 -0
  188. package/src/dispatch/RouteRegistry.ts +73 -0
  189. package/src/dispatch/RouteResolver.ts +7 -0
  190. package/src/dispatch/StorageGuard.ts +71 -0
  191. package/src/effective-operation.ts +601 -0
  192. package/src/emit.ts +90 -0
  193. package/src/entry/DynamicFacade.ts +28 -0
  194. package/src/entry/FacadeEntry.ts +32 -0
  195. package/src/entry/TransportEntry.ts +30 -0
  196. package/src/frond-config.ts +138 -0
  197. package/src/graph.ts +180 -0
  198. package/src/identity-keys.ts +43 -0
  199. package/src/identity.ts +235 -0
  200. package/src/imports.ts +123 -0
  201. package/src/index.ts +120 -0
  202. package/src/loader.ts +41 -0
  203. package/src/node.ts +30 -0
  204. package/src/orm.ts +252 -0
  205. package/src/prefab/collector.ts +36 -0
  206. package/src/prefab/crud.ts +188 -0
  207. package/src/prefab/mirror.ts +122 -0
  208. package/src/prefab/prefab.ts +46 -0
  209. package/src/prefab/presenter.ts +63 -0
  210. package/src/prefab/repository.ts +170 -0
  211. package/src/scan/Fronds.ts +73 -0
  212. package/src/scan/bundling.ts +25 -0
  213. package/src/scan/conventions.ts +122 -0
  214. package/src/scan/declare.ts +188 -0
  215. package/src/scan/emit.ts +231 -0
  216. package/src/scan/frond.ts +235 -0
  217. package/src/scan/handler-parser.ts +817 -0
  218. package/src/scan/scanner.ts +757 -0
  219. package/src/scan/statement.ts +126 -0
  220. package/src/verify.ts +193 -0
  221. package/src/wire/call.ts +381 -0
  222. package/src/wire/drift.ts +131 -0
  223. package/src/wire/errors.ts +124 -0
  224. package/src/wire/http-error.ts +77 -0
  225. package/src/wire/loggerMiddleware.ts +29 -0
  226. package/src/wire/middleware.ts +47 -0
  227. package/src/wire/operation.ts +258 -0
  228. package/dist/boot/Lifecycle.d.ts +0 -4
  229. package/dist/boot/Lifecycle.d.ts.map +0 -1
  230. package/dist/boot/Lifecycle.js +0 -3
  231. package/dist/boot/Lifecycle.js.map +0 -1
  232. package/dist/boot/egress.d.ts +0 -8
  233. package/dist/boot/egress.d.ts.map +0 -1
  234. package/dist/boot/egress.js +0 -11
  235. package/dist/boot/egress.js.map +0 -1
  236. package/dist/scan/scan-cache.d.ts +0 -16
  237. package/dist/scan/scan-cache.d.ts.map +0 -1
  238. package/dist/scan/scan-cache.js +0 -99
  239. package/dist/scan/scan-cache.js.map +0 -1
  240. package/dist/wire/invocation.d.ts +0 -4
  241. package/dist/wire/invocation.d.ts.map +0 -1
  242. package/dist/wire/invocation.js +0 -3
  243. package/dist/wire/invocation.js.map +0 -1
@@ -7,7 +7,7 @@
7
7
  * they never reshape it.
8
8
  */
9
9
  import { type SchemaDescriptor } from '@fougere/schema';
10
- import type { InvocationContext } from './invocation.js';
10
+ import type { InvocationContext } from '../contract/Invocation.js';
11
11
  import type { App } from '../boot/types.js';
12
12
  /** Target of a call — which façade operation, wherever it lives. */
13
13
  export interface FrondCall {
@@ -21,6 +21,17 @@ export interface FrondCall {
21
21
  /** A transport executes a call somewhere else. Failures surface as thrown FougereError. */
22
22
  export type Transport = (call: FrondCall, invocation: InvocationContext) => Promise<unknown>;
23
23
  /** Reserved namespace — calls the runner answers itself, never a façade. */
24
+ /**
25
+ * What a receiver accepts before it stops reading a body.
26
+ *
27
+ * Stated once because it was stated FOUR times — `transport/http/policy.ts` said so in its
28
+ * own comment ("spelled in four packages") while three doors kept their own literal, so
29
+ * raising the cap here used to leave three of them refusing at the old one.
30
+ *
31
+ * `@fougere/http` keeps a fourth copy on purpose: it declares no Fougere dependency at all,
32
+ * and giving a leaf port a dependency on the kernel to share a number is the wrong trade.
33
+ */
34
+ export declare const MAX_BODY_BYTES: number;
24
35
  export declare const RPC_ENTITY = "rpc";
25
36
  /**
26
37
  * What an `rpc` op answers — the door for what the app says about ITSELF, never about a row.
@@ -80,9 +91,9 @@ export interface CardOp {
80
91
  * every entry and refused whole cards over a health check.
81
92
  */
82
93
  export interface IdentityCard {
83
- fronds: Array<{
94
+ fronds: {
84
95
  name: string;
85
- doors: Array<{
96
+ doors: {
86
97
  name: string;
87
98
  ops: CardOp[];
88
99
  /**
@@ -92,7 +103,7 @@ export interface IdentityCard {
92
103
  * several shapes. A reader that needs the shape must say what it does without one.
93
104
  */
94
105
  schema?: SchemaDescriptor;
95
- }>;
106
+ }[];
96
107
  /**
97
108
  * The facts this frond ANNOUNCES — one entry per `Emit<T>` its handlers inject.
98
109
  *
@@ -110,11 +121,11 @@ export interface IdentityCard {
110
121
  * requires a fact to be one) and worth saying rather than hiding: the name travels, the
111
122
  * shape does not, and a consumer can see exactly that.
112
123
  */
113
- facts: Array<{
124
+ facts: {
114
125
  name: string;
115
126
  schema?: SchemaDescriptor;
116
- }>;
117
- }>;
127
+ }[];
128
+ }[];
118
129
  }
119
130
  /** A frond this process knows about, and whether it runs here. */
120
131
  export interface FrondPlacement {
@@ -158,7 +169,7 @@ export interface TopologyReport {
158
169
  * card.fronds is not iterable` was what a malformed card produced at the boot,
159
170
  * naming neither the remote nor the address.
160
171
  *
161
- * The descriptor behind a door is NOT checked here — `reconstruct` refuses it, and
172
+ * The descriptor behind a door is NOT checked here — `Card.toSchema` refuses it, and
162
173
  * only where one is consumed.
163
174
  */
164
175
  export declare function assertIdentityCard(value: unknown, source: string): IdentityCard;
@@ -1 +1 @@
1
- {"version":3,"file":"call.d.ts","sourceRoot":"","sources":["../../src/wire/call.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAA8B,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEpF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEzD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAG5C,oEAAoE;AACpE,MAAM,WAAW,SAAS;IACxB,+DAA+D;IAC/D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gDAAgD;IAChD,MAAM,EAAE,MAAM,CAAC;IACf,yDAAyD;IACzD,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,2FAA2F;AAC3F,MAAM,MAAM,SAAS,GAAG,CAAC,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,iBAAiB,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;AAE7F,4EAA4E;AAC5E,eAAO,MAAM,UAAU,QAAQ,CAAC;AAEhC;;;;;GAKG;AACH,MAAM,MAAM,SAAS,GAAG,CAAC,UAAU,EAAE,iBAAiB,EAAE,OAAO,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC;AAErF;;;;;;;GAOG;AACH,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC;AAED;;;;GAIG;AACH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;;;;;;;;;;GAaG;AACH,MAAM,MAAM,MAAM,CAAC,CAAC,IAAI;KACrB,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,MAAM,CAAC,GACtD,CAAC,UAAU,CAAC,EAAE,iBAAiB,KAAK,CAAC,GACrC,KAAK;CACV,CAAC;AAEF;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAExE;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAE3E;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,YAAY,CA6CvE;AAqCD;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAEvE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAErE"}
package/dist/wire/call.js CHANGED
@@ -6,11 +6,22 @@
6
6
  * runner below is the reference realization. Transports move the value,
7
7
  * they never reshape it.
8
8
  */
9
- import { describe as describeSchema } from '@fougere/schema';
9
+ import { Card } from '@fougere/schema';
10
10
  import { factsAnnouncedBy } from '../emit.js';
11
11
  import { FougereError, ErrorCode } from './errors.js';
12
12
  import { createTransportEntry } from '../entry/TransportEntry.js';
13
13
  /** Reserved namespace — calls the runner answers itself, never a façade. */
14
+ /**
15
+ * What a receiver accepts before it stops reading a body.
16
+ *
17
+ * Stated once because it was stated FOUR times — `transport/http/policy.ts` said so in its
18
+ * own comment ("spelled in four packages") while three doors kept their own literal, so
19
+ * raising the cap here used to leave three of them refusing at the old one.
20
+ *
21
+ * `@fougere/http` keeps a fourth copy on purpose: it declares no Fougere dependency at all,
22
+ * and giving a leaf port a dependency on the kernel to share a number is the wrong trade.
23
+ */
24
+ export const MAX_BODY_BYTES = 1024 * 1024;
14
25
  export const RPC_ENTITY = 'rpc';
15
26
  /**
16
27
  * The shape a card must have to be walked — `fronds`, and each frond's `doors`.
@@ -21,7 +32,7 @@ export const RPC_ENTITY = 'rpc';
21
32
  * card.fronds is not iterable` was what a malformed card produced at the boot,
22
33
  * naming neither the remote nor the address.
23
34
  *
24
- * The descriptor behind a door is NOT checked here — `reconstruct` refuses it, and
35
+ * The descriptor behind a door is NOT checked here — `Card.toSchema` refuses it, and
25
36
  * only where one is consumed.
26
37
  */
27
38
  export function assertIdentityCard(value, source) {
@@ -112,7 +123,7 @@ export function identityCardOf(app, surface) {
112
123
  name: address,
113
124
  ops,
114
125
  // Absent when nothing of that name is stored. A door is still a door.
115
- ...(entity ? { schema: describeSchema(entity.entityClass, address) } : {}),
126
+ ...(entity ? { schema: Card.fromSchema(entity.entityClass, address).descriptor } : {}),
116
127
  }];
117
128
  }),
118
129
  /**
@@ -126,7 +137,7 @@ export function identityCardOf(app, surface) {
126
137
  */
127
138
  facts: factsAnnouncedBy(frond.handlers).map((name) => {
128
139
  const entityClass = declared.get(name);
129
- return { name, ...(entityClass ? { schema: describeSchema(entityClass, name) } : {}) };
140
+ return { name, ...(entityClass ? { schema: Card.fromSchema(entityClass, name).descriptor } : {}) };
130
141
  }),
131
142
  };
132
143
  }),
@@ -153,8 +164,8 @@ function facadeOps(app, entityName, surface) {
153
164
  return {
154
165
  name,
155
166
  ...(contract?.description && { description: contract.description }),
156
- ...(contract?.input && { input: describeSchema(contract.input, name) }),
157
- ...(contract?.output && { output: describeSchema(contract.output, name) }),
167
+ ...(contract?.input && { input: Card.fromSchema(contract.input, name).descriptor }),
168
+ ...(contract?.output && { output: Card.fromSchema(contract.output, name).descriptor }),
158
169
  ...(contract?.cardinality && { cardinality: contract.cardinality }),
159
170
  kind: contract.kind,
160
171
  };
@@ -1 +1 @@
1
- {"version":3,"file":"call.js","sourceRoot":"","sources":["../../src/wire/call.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,QAAQ,IAAI,cAAc,EAAyB,MAAM,iBAAiB,CAAC;AACpF,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAE9C,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAEtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAelE,4EAA4E;AAC5E,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,CAAC;AAqIhC;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAc,EAAE,MAAc;IAC/D,MAAM,IAAI,GAAG,KAAiC,CAAC;IAC/C,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;IACrE,IAAI,CAAC,MAAM;QAAE,MAAM,WAAW,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;IAC1D,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ;YAAE,MAAM,WAAW,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAC;QAChG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC;YAAE,MAAM,WAAW,CAAC,MAAM,EAAE,UAAU,KAAK,CAAC,IAAI,4BAA4B,CAAC,CAAC;IAC/G,CAAC;IACD,OAAO,IAAoB,CAAC;AAC9B,CAAC;AAED,SAAS,WAAW,CAAC,MAAc,EAAE,IAAY;IAC/C,OAAO,IAA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,UAAU,CAAC,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,UAAU,EAAE,CAAC;YACtF,GAAG,CAAC,QAAQ,EAAE,WAAW,IAAI,EAAE,WAAW,EAAE,QAAQ,CAAC,WAAW,EAAE,CAAC;YACnE,IAAI,EAAE,QAAQ,CAAC,IAAI;SACpB,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,GAAQ,EAAE,OAAgB;IAC1D,OAAO,oBAAoB,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AAClD,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,eAAe,CAAC,GAAQ,EAAE,OAAgB;IACxD,OAAO,oBAAoB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;AAC5C,CAAC"}
@@ -0,0 +1,55 @@
1
+ import { type Change } from '@fougere/schema';
2
+ import type { IdentityCard } from './call.js';
3
+ /**
4
+ * What separates the copy a consumer holds from what the producer actually serves.
5
+ *
6
+ * It lives beside `IdentityCard` and not in `@fougere/testing` for the reason the card
7
+ * itself does: the subject is the card, and a second reader arrived — the dev panel, which
8
+ * must not drag a 426 KB faker in to compare two of them.
9
+ */
10
+ export interface CardDrift {
11
+ frond: string;
12
+ /** A door the consumer calls that the producer no longer serves. */
13
+ missingDoors: string[];
14
+ /** An operation the consumer calls that the door no longer has. */
15
+ missingOps: {
16
+ door: string;
17
+ ops: string[];
18
+ }[];
19
+ /** A shape that moved under a door the consumer still calls. */
20
+ shapes: {
21
+ door: string;
22
+ changes: Change[];
23
+ }[];
24
+ /** A fact the consumer subscribes to whose shape moved, or that is gone. */
25
+ facts: {
26
+ fact: string;
27
+ changes: Change[] | 'gone';
28
+ }[];
29
+ }
30
+ /**
31
+ * What a consumer's synced copy no longer matches in what the producer serves.
32
+ *
33
+ * The gap TypeScript cannot see, and the only place the gradient genuinely lies: the code
34
+ * is identical in-process and split, but one side may have aged. `fougere sync` wrote the
35
+ * consumer's copy three weeks ago, the producer moved on, and it still compiles —
36
+ * production is where that is found today. This is what Pact sells; the material was
37
+ * already here, in `rpc.discover` and in `Card.diff`.
38
+ *
39
+ * Read in ONE direction on purpose: what the consumer holds, checked against what is
40
+ * served. A producer serving MORE than the consumer knows is not drift — it is a producer
41
+ * that moved forward without breaking anyone, which is the whole point of the order the
42
+ * repo already states (re-sync the readers, then deploy the sender).
43
+ */
44
+ export declare function driftOf(mine: IdentityCard, theirs: IdentityCard, frond: string): CardDrift;
45
+ /** Whether anything at all separates the two cards. */
46
+ export declare function agrees(drift: CardDrift): boolean;
47
+ /**
48
+ * The drift, in the words a deploy needs.
49
+ *
50
+ * A fact says the order out loud, because the repo already states it as a rule and
51
+ * nothing enforced it: a fact is judged strictly, so a reader that has not been re-synced
52
+ * refuses what the sender now announces.
53
+ */
54
+ export declare function explain(drift: CardDrift): string[];
55
+ //# sourceMappingURL=drift.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"drift.d.ts","sourceRoot":"","sources":["../../src/wire/drift.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,MAAM,EAAyB,MAAM,iBAAiB,CAAC;AAC3E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAE9C;;;;;;GAMG;AACH,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,oEAAoE;IACpE,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,mEAAmE;IACnE,UAAU,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,EAAE,CAAA;KAAE,EAAE,CAAC;IAC9C,gEAAgE;IAChE,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,EAAE,CAAA;KAAE,EAAE,CAAC;IAC9C,4EAA4E;IAC5E,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,CAAA;KAAE,EAAE,CAAC;CACvD;AAuBD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,CAgC1F;AAED,uDAAuD;AACvD,wBAAgB,MAAM,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAKhD;AAED;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM,EAAE,CAYlD"}
@@ -0,0 +1,121 @@
1
+ import { Card } from '@fougere/schema';
2
+ /** Every door of a card, by name. */
3
+ function doorsOf(card, frond) {
4
+ const found = new Map();
5
+ for (const one of card.fronds) {
6
+ if (one.name !== frond)
7
+ continue;
8
+ for (const door of one.doors) {
9
+ found.set(door.name, { ops: new Set(door.ops.map((op) => op.name)), schema: door.schema });
10
+ }
11
+ }
12
+ return found;
13
+ }
14
+ function factsOf(card, frond) {
15
+ const found = new Map();
16
+ for (const one of card.fronds) {
17
+ if (one.name !== frond)
18
+ continue;
19
+ for (const fact of one.facts ?? [])
20
+ found.set(fact.name, fact.schema);
21
+ }
22
+ return found;
23
+ }
24
+ /**
25
+ * What a consumer's synced copy no longer matches in what the producer serves.
26
+ *
27
+ * The gap TypeScript cannot see, and the only place the gradient genuinely lies: the code
28
+ * is identical in-process and split, but one side may have aged. `fougere sync` wrote the
29
+ * consumer's copy three weeks ago, the producer moved on, and it still compiles —
30
+ * production is where that is found today. This is what Pact sells; the material was
31
+ * already here, in `rpc.discover` and in `Card.diff`.
32
+ *
33
+ * Read in ONE direction on purpose: what the consumer holds, checked against what is
34
+ * served. A producer serving MORE than the consumer knows is not drift — it is a producer
35
+ * that moved forward without breaking anyone, which is the whole point of the order the
36
+ * repo already states (re-sync the readers, then deploy the sender).
37
+ */
38
+ export function driftOf(mine, theirs, frond) {
39
+ const held = doorsOf(mine, frond);
40
+ const served = doorsOf(theirs, frond);
41
+ const drift = { frond, missingDoors: [], missingOps: [], shapes: [], facts: [] };
42
+ for (const [name, door] of held) {
43
+ const there = served.get(name);
44
+ if (!there) {
45
+ drift.missingDoors.push(name);
46
+ continue;
47
+ }
48
+ const missing = [...door.ops].filter((op) => !there.ops.has(op));
49
+ if (missing.length > 0)
50
+ drift.missingOps.push({ door: name, ops: missing.sort() });
51
+ if (door.schema && there.schema) {
52
+ // `Card.diff` never guesses a rename — a field gone plus a field appeared lands in
53
+ // `ambiguous`, and only a declaration settles it. Here nobody can declare one, so
54
+ // the pair is reported as it is and a human reads it.
55
+ const moved = Card.fromDescriptor(door.schema).diff(Card.fromDescriptor(there.schema));
56
+ if (moved.changes.length > 0)
57
+ drift.shapes.push({ door: name, changes: moved.changes });
58
+ }
59
+ }
60
+ const heldFacts = factsOf(mine, frond);
61
+ const servedFacts = factsOf(theirs, frond);
62
+ for (const [name, shape] of heldFacts) {
63
+ if (!servedFacts.has(name)) {
64
+ drift.facts.push({ fact: name, changes: 'gone' });
65
+ continue;
66
+ }
67
+ const there = servedFacts.get(name);
68
+ if (!shape || !there)
69
+ continue;
70
+ const moved = Card.fromDescriptor(shape).diff(Card.fromDescriptor(there));
71
+ if (moved.changes.length > 0)
72
+ drift.facts.push({ fact: name, changes: moved.changes });
73
+ }
74
+ return drift;
75
+ }
76
+ /** Whether anything at all separates the two cards. */
77
+ export function agrees(drift) {
78
+ return drift.missingDoors.length === 0
79
+ && drift.missingOps.length === 0
80
+ && drift.shapes.length === 0
81
+ && drift.facts.length === 0;
82
+ }
83
+ /**
84
+ * The drift, in the words a deploy needs.
85
+ *
86
+ * A fact says the order out loud, because the repo already states it as a rule and
87
+ * nothing enforced it: a fact is judged strictly, so a reader that has not been re-synced
88
+ * refuses what the sender now announces.
89
+ */
90
+ export function explain(drift) {
91
+ const lines = [];
92
+ for (const door of drift.missingDoors)
93
+ lines.push(`${drift.frond}.${door} — you call it, it is not served`);
94
+ for (const { door, ops } of drift.missingOps)
95
+ lines.push(`${drift.frond}.${door} — gone: ${ops.join(', ')}`);
96
+ for (const { door, changes } of drift.shapes) {
97
+ for (const change of changes)
98
+ lines.push(`${drift.frond}.${door} — ${describe(change)}`);
99
+ }
100
+ for (const { fact, changes } of drift.facts) {
101
+ if (changes === 'gone') {
102
+ lines.push(`${fact} — you subscribe to it, it is no longer announced`);
103
+ continue;
104
+ }
105
+ for (const change of changes)
106
+ lines.push(`${fact} — ${describe(change)} → re-sync and deploy the readers, THEN the sender`);
107
+ }
108
+ return lines;
109
+ }
110
+ function describe(change) {
111
+ switch (change.kind) {
112
+ case 'added': return `+ ${change.field}${change.required ? ' (required)' : ''}`;
113
+ case 'removed': return `- ${change.field}`;
114
+ case 'renamed': return `${change.from} → ${change.to}`;
115
+ case 'retyped': return `${change.field}: ${[...change.from].join('|')} → ${[...change.to].join('|')}`;
116
+ case 'reshaped': return `${change.field}: its bounds moved`;
117
+ case 'required': return `${change.field}: ${change.from ? 'no longer' : 'now'} required`;
118
+ case 'restated': return `${change.field}: its ${change.axis} moved`;
119
+ }
120
+ }
121
+ //# sourceMappingURL=drift.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"drift.js","sourceRoot":"","sources":["../../src/wire/drift.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAsC,MAAM,iBAAiB,CAAC;AAsB3E,qCAAqC;AACrC,SAAS,OAAO,CAAC,IAAkB,EAAE,KAAa;IAChD,MAAM,KAAK,GAAG,IAAI,GAAG,EAA2D,CAAC;IACjF,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;QAC9B,IAAI,GAAG,CAAC,IAAI,KAAK,KAAK;YAAE,SAAS;QACjC,KAAK,MAAM,IAAI,IAAI,GAAG,CAAC,KAAK,EAAE,CAAC;YAC7B,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,GAAG,EAAE,IAAI,GAAG,CAAC,IAAI,CAAC,G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AAU,CAAC,CAAC,OAAO,GAAG,MAAM,CAAC,KAAK,KAAK,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,WAAW,CAAC;QACzF,KAAK,UAAU,CAAC,CAAC,OAAO,GAAG,MAAM,CAAC,KAAK,SAAS,MAAM,CAAC,IAAI,QAAQ,CAAC;IACtE,CAAC;AACH,CAAC"}
@@ -18,7 +18,7 @@ export interface OperationContext {
18
18
  /** Extensible bag — middlewares deposit data here (user, permissions, etc.). */
19
19
  state: Record<string, unknown>;
20
20
  /** Transport-agnostic invocation context (params, query, body, state). */
21
- invocation?: import('./invocation.js').InvocationContext;
21
+ invocation?: import('../contract/Invocation.js').InvocationContext;
22
22
  }
23
23
  export type AppNext = () => Promise<unknown>;
24
24
  export type AppMiddleware = (ctx: OperationContext, next: AppNext) => Promise<unknown>;
@@ -1 +1 @@
1
- {"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../src/wire/middleware.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,MAAM,WAAW,gBAAgB;IAC/B,oCAAoC;IACpC,MAAM,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,mEAAmE;IACnE,SAAS,EAAE,MAAM,CAAC;IAClB,yCAAyC;IACzC,IAAI,EAAE,OAAO,EAAE,CAAC;IAChB,gFAAgF;IAChF,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,0EAA0E;IAC1E,UAAU,CAAC,EAAE,OAAO,iBAAiB,EAAE,iBAAiB,CAAC;CAC1D;AAED,MAAM,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;AAC7C,MAAM,MAAM,aAAa,GAAG,CAAC,GAAG,EAAE,gBAAgB,EAAE,IAAI,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;AAIvF;;GAEG;AACH,wBAAgB,cAAc,CAC5B,WAAW,EAAE,aAAa,EAAE,EAC5B,GAAG,EAAE,gBAAgB,EACrB,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,OAAO,CAAC,CASlB"}
1
+ {"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../src/wire/middleware.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,MAAM,WAAW,gBAAgB;IAC/B,oCAAoC;IACpC,MAAM,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,mEAAmE;IACnE,SAAS,EAAE,MAAM,CAAC;IAClB,yCAAyC;IACzC,IAAI,EAAE,OAAO,EAAE,CAAC;IAChB,gFAAgF;IAChF,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,0EAA0E;IAC1E,UAAU,CAAC,EAAE,OAAO,2BAA2B,EAAE,iBAAiB,CAAC;CACpE;AAED,MAAM,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;AAC7C,MAAM,MAAM,aAAa,GAAG,CAAC,GAAG,EAAE,gBAAgB,EAAE,IAAI,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;AAIvF;;GAEG;AACH,wBAAgB,cAAc,CAC5B,WAAW,EAAE,aAAa,EAAE,EAC5B,GAAG,EAAE,gBAAgB,EACrB,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,OAAO,CAAC,CASlB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fougere/core",
3
- "version": "0.3.0-alpha.0",
3
+ "version": "0.5.0-alpha.0",
4
4
  "description": "The core — scan, call contract, façades, remote stand-ins.",
5
5
  "keywords": [
6
6
  "fougere",
@@ -50,12 +50,14 @@
50
50
  }
51
51
  },
52
52
  "files": [
53
- "dist"
53
+ "dist",
54
+ "src"
54
55
  ],
55
56
  "dependencies": {
56
57
  "@typescript/typescript6": "^6.0.2",
57
- "@fougere/schema": "0.3.0-alpha.0",
58
- "@fougere/container": "0.3.0-alpha.0"
58
+ "dequal": "^2.0.3",
59
+ "@fougere/container": "0.5.0-alpha.0",
60
+ "@fougere/schema": "0.5.0-alpha.0"
59
61
  },
60
62
  "devDependencies": {
61
63
  "@types/node": "^22.0.0"
@@ -0,0 +1,50 @@
1
+ import type { App } from './types.js';
2
+
3
+ /** One process-level extension and its reversible lifecycle. */
4
+ export interface Extension {
5
+ name: string;
6
+ up?(app: App): void | Promise<void>;
7
+ down?(app: App): void | Promise<void>;
8
+ }
9
+
10
+ /** Runs application extensions up in order and down in reverse order. */
11
+ export class AppLifecycle {
12
+ private readonly members: Extension[] = [];
13
+
14
+ add(...extensions: readonly (Extension | undefined)[]): this {
15
+ for (const extension of extensions) {
16
+ if (!extension) continue;
17
+ const at = this.members.findIndex((held) => held.name === extension.name);
18
+ if (at === -1) this.members.push(extension);
19
+ else this.members[at] = extension;
20
+ }
21
+ return this;
22
+ }
23
+
24
+ names(): string[] {
25
+ return this.members.map((extension) => extension.name);
26
+ }
27
+
28
+ async up(app: App): Promise<void> {
29
+ for (const extension of this.members) await extension.up?.(app);
30
+ }
31
+
32
+ async down(app: App): Promise<void> {
33
+ const refused: unknown[] = [];
34
+ for (const extension of [...this.members].reverse()) {
35
+ try {
36
+ await extension.down?.(app);
37
+ } catch (error) {
38
+ refused.push(error);
39
+ }
40
+ }
41
+ if (refused.length > 0) {
42
+ throw new AggregateError(refused, `${refused.length} extension(s) refused to release`);
43
+ }
44
+ }
45
+ }
46
+
47
+ /** The replaceable migration slot of the application lifecycle. */
48
+ export function migrating(migrate?: Extension['up']): Extension {
49
+ return migrate ? { name: 'migrate', up: migrate } : { name: 'migrate' };
50
+ }