@fougere/core 0.5.0-alpha.1 → 0.7.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 (519) hide show
  1. package/README.md +1 -1
  2. package/dist/boot/Emissions.d.ts +14 -91
  3. package/dist/boot/Emissions.d.ts.map +1 -1
  4. package/dist/boot/Emissions.js +21 -118
  5. package/dist/boot/Emissions.js.map +1 -1
  6. package/dist/boot/ambient-port.d.ts +3 -24
  7. package/dist/boot/ambient-port.d.ts.map +1 -1
  8. package/dist/boot/ambient.als.d.ts.map +1 -1
  9. package/dist/boot/ambient.als.js +7 -12
  10. package/dist/boot/ambient.als.js.map +1 -1
  11. package/dist/boot/ambient.queue.d.ts +2 -5
  12. package/dist/boot/ambient.queue.d.ts.map +1 -1
  13. package/dist/boot/ambient.queue.js.map +1 -1
  14. package/dist/boot/apply.d.ts +1 -13
  15. package/dist/boot/apply.d.ts.map +1 -1
  16. package/dist/boot/apply.js +3 -15
  17. package/dist/boot/apply.js.map +1 -1
  18. package/dist/boot/auth.d.ts +6 -16
  19. package/dist/boot/auth.d.ts.map +1 -1
  20. package/dist/boot/boot.d.ts +5 -18
  21. package/dist/boot/boot.d.ts.map +1 -1
  22. package/dist/boot/boot.js +4 -11
  23. package/dist/boot/boot.js.map +1 -1
  24. package/dist/boot/bootstrap.d.ts.map +1 -1
  25. package/dist/boot/bootstrap.js +106 -163
  26. package/dist/boot/bootstrap.js.map +1 -1
  27. package/dist/boot/card.d.ts +5 -0
  28. package/dist/boot/card.d.ts.map +1 -0
  29. package/dist/boot/card.js +71 -0
  30. package/dist/boot/card.js.map +1 -0
  31. package/dist/boot/frame.d.ts +8 -32
  32. package/dist/boot/frame.d.ts.map +1 -1
  33. package/dist/boot/frame.js +23 -57
  34. package/dist/boot/frame.js.map +1 -1
  35. package/dist/boot/hosted.d.ts +3 -19
  36. package/dist/boot/hosted.d.ts.map +1 -1
  37. package/dist/boot/hosted.js +12 -17
  38. package/dist/boot/hosted.js.map +1 -1
  39. package/dist/boot/ownership.d.ts +5 -36
  40. package/dist/boot/ownership.d.ts.map +1 -1
  41. package/dist/boot/ownership.js +9 -49
  42. package/dist/boot/ownership.js.map +1 -1
  43. package/dist/boot/ports.d.ts +2 -15
  44. package/dist/boot/ports.d.ts.map +1 -1
  45. package/dist/boot/ports.js +1 -14
  46. package/dist/boot/ports.js.map +1 -1
  47. package/dist/boot/remote.d.ts +5 -38
  48. package/dist/boot/remote.d.ts.map +1 -1
  49. package/dist/boot/remote.js +8 -41
  50. package/dist/boot/remote.js.map +1 -1
  51. package/dist/boot/runner.d.ts +11 -0
  52. package/dist/boot/runner.d.ts.map +1 -0
  53. package/dist/boot/runner.js +13 -0
  54. package/dist/boot/runner.js.map +1 -0
  55. package/dist/boot/seed.d.ts +5 -32
  56. package/dist/boot/seed.d.ts.map +1 -1
  57. package/dist/boot/seed.js +10 -41
  58. package/dist/boot/seed.js.map +1 -1
  59. package/dist/boot/statement-drift.d.ts +4 -22
  60. package/dist/boot/statement-drift.d.ts.map +1 -1
  61. package/dist/boot/statement-drift.js +4 -9
  62. package/dist/boot/statement-drift.js.map +1 -1
  63. package/dist/boot/together.d.ts +8 -12
  64. package/dist/boot/together.d.ts.map +1 -1
  65. package/dist/boot/together.js +28 -65
  66. package/dist/boot/together.js.map +1 -1
  67. package/dist/boot/types.d.ts +36 -180
  68. package/dist/boot/types.d.ts.map +1 -1
  69. package/dist/builtin/config.d.ts +7 -0
  70. package/dist/builtin/config.d.ts.map +1 -0
  71. package/dist/builtin/config.js +15 -0
  72. package/dist/builtin/config.js.map +1 -0
  73. package/dist/{builtins → builtin}/logger.d.ts +4 -25
  74. package/dist/builtin/logger.d.ts.map +1 -0
  75. package/dist/{builtins → builtin}/logger.js +5 -32
  76. package/dist/builtin/logger.js.map +1 -0
  77. package/dist/config-loader.d.ts +9 -67
  78. package/dist/config-loader.d.ts.map +1 -1
  79. package/dist/config-loader.js +5 -18
  80. package/dist/config-loader.js.map +1 -1
  81. package/dist/contract.d.ts +13 -31
  82. package/dist/contract.d.ts.map +1 -1
  83. package/dist/contract.js +10 -26
  84. package/dist/contract.js.map +1 -1
  85. package/dist/crypto/encoding.d.ts +2 -15
  86. package/dist/crypto/encoding.d.ts.map +1 -1
  87. package/dist/crypto/encoding.js +2 -15
  88. package/dist/crypto/encoding.js.map +1 -1
  89. package/dist/crypto/node.d.ts.map +1 -1
  90. package/dist/crypto/node.js +1 -7
  91. package/dist/crypto/node.js.map +1 -1
  92. package/dist/crypto/port.d.ts +2 -18
  93. package/dist/crypto/port.d.ts.map +1 -1
  94. package/dist/crypto/port.js +1 -17
  95. package/dist/crypto/port.js.map +1 -1
  96. package/dist/crypto/webcrypto.d.ts.map +1 -1
  97. package/dist/crypto/webcrypto.js +1 -12
  98. package/dist/crypto/webcrypto.js.map +1 -1
  99. package/dist/declare.d.ts +41 -0
  100. package/dist/declare.d.ts.map +1 -0
  101. package/dist/{scan/declare.js → declare.js} +6 -31
  102. package/dist/declare.js.map +1 -0
  103. package/dist/define.d.ts +2 -3
  104. package/dist/define.d.ts.map +1 -1
  105. package/dist/define.js +2 -3
  106. package/dist/define.js.map +1 -1
  107. package/dist/descriptor/Fronds.d.ts +19 -0
  108. package/dist/descriptor/Fronds.d.ts.map +1 -0
  109. package/dist/descriptor/Fronds.js +40 -0
  110. package/dist/descriptor/Fronds.js.map +1 -0
  111. package/dist/descriptor/frond.d.ts +135 -0
  112. package/dist/descriptor/frond.d.ts.map +1 -0
  113. package/dist/{scan → descriptor}/frond.js.map +1 -1
  114. package/dist/dispatch/ArgumentResolver.d.ts +6 -3
  115. package/dist/dispatch/ArgumentResolver.d.ts.map +1 -1
  116. package/dist/dispatch/ArgumentResolver.js +48 -3
  117. package/dist/dispatch/ArgumentResolver.js.map +1 -1
  118. package/dist/dispatch/DispatchEvent.d.ts +2 -2
  119. package/dist/dispatch/DispatchEvent.d.ts.map +1 -1
  120. package/dist/dispatch/DispatchLifecycle.d.ts +1 -7
  121. package/dist/dispatch/DispatchLifecycle.d.ts.map +1 -1
  122. package/dist/dispatch/DispatchLifecycle.js +1 -7
  123. package/dist/dispatch/DispatchLifecycle.js.map +1 -1
  124. package/dist/dispatch/DispatchPort.d.ts +1 -1
  125. package/dist/dispatch/DispatchPort.d.ts.map +1 -1
  126. package/dist/dispatch/Dispatcher.d.ts +1 -1
  127. package/dist/dispatch/Dispatcher.d.ts.map +1 -1
  128. package/dist/dispatch/Dispatcher.js +2 -2
  129. package/dist/dispatch/Dispatcher.js.map +1 -1
  130. package/dist/{boot → dispatch}/HandlerFacade.d.ts +25 -38
  131. package/dist/dispatch/HandlerFacade.d.ts.map +1 -0
  132. package/dist/{boot → dispatch}/HandlerFacade.js +65 -74
  133. package/dist/dispatch/HandlerFacade.js.map +1 -0
  134. package/dist/dispatch/LocalRoutePolicy.d.ts +1 -1
  135. package/dist/dispatch/LocalRoutePolicy.d.ts.map +1 -1
  136. package/dist/dispatch/LocalRoutePolicy.js +4 -4
  137. package/dist/dispatch/LocalRoutePolicy.js.map +1 -1
  138. package/dist/dispatch/OperationRoute.d.ts +2 -2
  139. package/dist/dispatch/OperationRoute.d.ts.map +1 -1
  140. package/dist/dispatch/OutputView.d.ts +3 -2
  141. package/dist/dispatch/OutputView.d.ts.map +1 -1
  142. package/dist/dispatch/OutputView.js +19 -1
  143. package/dist/dispatch/OutputView.js.map +1 -1
  144. package/dist/dispatch/Route.d.ts +2 -3
  145. package/dist/dispatch/Route.d.ts.map +1 -1
  146. package/dist/dispatch/RoutePolicy.d.ts +1 -1
  147. package/dist/dispatch/RoutePolicy.d.ts.map +1 -1
  148. package/dist/dispatch/RouteRegistry.d.ts +1 -1
  149. package/dist/dispatch/RouteRegistry.d.ts.map +1 -1
  150. package/dist/dispatch/RouteRegistry.js +2 -2
  151. package/dist/dispatch/RouteRegistry.js.map +1 -1
  152. package/dist/dispatch/RouteResolver.d.ts +2 -4
  153. package/dist/dispatch/RouteResolver.d.ts.map +1 -1
  154. package/dist/dispatch/StorageGuard.d.ts +9 -8
  155. package/dist/dispatch/StorageGuard.d.ts.map +1 -1
  156. package/dist/dispatch/StorageGuard.js +66 -23
  157. package/dist/dispatch/StorageGuard.js.map +1 -1
  158. package/dist/dispatch/presenterArguments.d.ts +7 -0
  159. package/dist/dispatch/presenterArguments.d.ts.map +1 -0
  160. package/dist/dispatch/presenterArguments.js +12 -0
  161. package/dist/dispatch/presenterArguments.js.map +1 -0
  162. package/dist/dispatch/remoteRoutes.d.ts +7 -0
  163. package/dist/dispatch/remoteRoutes.d.ts.map +1 -0
  164. package/dist/dispatch/{RemoteRouteResolver.js → remoteRoutes.js} +6 -10
  165. package/dist/dispatch/remoteRoutes.js.map +1 -0
  166. package/dist/dispatch/routeNotFound.d.ts +9 -0
  167. package/dist/dispatch/routeNotFound.d.ts.map +1 -0
  168. package/dist/dispatch/routeNotFound.js +21 -0
  169. package/dist/dispatch/routeNotFound.js.map +1 -0
  170. package/dist/dispatch/validateInput.d.ts +5 -0
  171. package/dist/dispatch/validateInput.d.ts.map +1 -0
  172. package/dist/dispatch/validateInput.js +20 -0
  173. package/dist/dispatch/validateInput.js.map +1 -0
  174. package/dist/effective-operation.d.ts +6 -3
  175. package/dist/effective-operation.d.ts.map +1 -1
  176. package/dist/effective-operation.js +49 -27
  177. package/dist/effective-operation.js.map +1 -1
  178. package/dist/emit.d.ts +4 -42
  179. package/dist/emit.d.ts.map +1 -1
  180. package/dist/emit.js +3 -39
  181. package/dist/emit.js.map +1 -1
  182. package/dist/entry/facade.d.ts +8 -0
  183. package/dist/entry/facade.d.ts.map +1 -0
  184. package/dist/entry/facade.js +28 -0
  185. package/dist/entry/facade.js.map +1 -0
  186. package/dist/entry/transport.d.ts +5 -0
  187. package/dist/entry/transport.d.ts.map +1 -0
  188. package/dist/entry/transport.js +11 -0
  189. package/dist/entry/transport.js.map +1 -0
  190. package/dist/frond-config.d.ts +8 -71
  191. package/dist/frond-config.d.ts.map +1 -1
  192. package/dist/frond-config.js +1 -9
  193. package/dist/frond-config.js.map +1 -1
  194. package/dist/graph.d.ts +1 -1
  195. package/dist/graph.d.ts.map +1 -1
  196. package/dist/identity-keys.d.ts +2 -5
  197. package/dist/identity-keys.d.ts.map +1 -1
  198. package/dist/identity-keys.js +3 -16
  199. package/dist/identity-keys.js.map +1 -1
  200. package/dist/identity.d.ts +4 -30
  201. package/dist/identity.d.ts.map +1 -1
  202. package/dist/identity.js +11 -73
  203. package/dist/identity.js.map +1 -1
  204. package/dist/imports.d.ts +2 -8
  205. package/dist/imports.d.ts.map +1 -1
  206. package/dist/imports.js +1 -7
  207. package/dist/imports.js.map +1 -1
  208. package/dist/index.d.ts +28 -30
  209. package/dist/index.d.ts.map +1 -1
  210. package/dist/index.js +17 -22
  211. package/dist/index.js.map +1 -1
  212. package/dist/loader.d.ts +1 -8
  213. package/dist/loader.d.ts.map +1 -1
  214. package/dist/loader.js +1 -8
  215. package/dist/loader.js.map +1 -1
  216. package/dist/node.d.ts +2 -11
  217. package/dist/node.d.ts.map +1 -1
  218. package/dist/node.js +2 -11
  219. package/dist/node.js.map +1 -1
  220. package/dist/prefab/collector.d.ts +1 -22
  221. package/dist/prefab/collector.d.ts.map +1 -1
  222. package/dist/prefab/collector.js +1 -22
  223. package/dist/prefab/collector.js.map +1 -1
  224. package/dist/prefab/crud.d.ts +19 -35
  225. package/dist/prefab/crud.d.ts.map +1 -1
  226. package/dist/prefab/crud.js +39 -66
  227. package/dist/prefab/crud.js.map +1 -1
  228. package/dist/prefab/mirror.d.ts +5 -27
  229. package/dist/prefab/mirror.d.ts.map +1 -1
  230. package/dist/prefab/mirror.js +6 -24
  231. package/dist/prefab/mirror.js.map +1 -1
  232. package/dist/prefab/prefab.d.ts +1 -7
  233. package/dist/prefab/prefab.d.ts.map +1 -1
  234. package/dist/prefab/prefab.js +1 -7
  235. package/dist/prefab/prefab.js.map +1 -1
  236. package/dist/prefab/presenter.d.ts +2 -36
  237. package/dist/prefab/presenter.d.ts.map +1 -1
  238. package/dist/prefab/presenter.js +2 -36
  239. package/dist/prefab/presenter.js.map +1 -1
  240. package/dist/prefab/repository.d.ts +12 -80
  241. package/dist/prefab/repository.d.ts.map +1 -1
  242. package/dist/prefab/repository.js +22 -35
  243. package/dist/prefab/repository.js.map +1 -1
  244. package/dist/scan/adapters.d.ts +3 -0
  245. package/dist/scan/adapters.d.ts.map +1 -0
  246. package/dist/scan/adapters.js +25 -0
  247. package/dist/scan/adapters.js.map +1 -0
  248. package/dist/scan/bundling.d.ts +1 -12
  249. package/dist/scan/bundling.d.ts.map +1 -1
  250. package/dist/scan/bundling.js +1 -12
  251. package/dist/scan/bundling.js.map +1 -1
  252. package/dist/scan/conventions.d.ts +6 -40
  253. package/dist/scan/conventions.d.ts.map +1 -1
  254. package/dist/scan/conventions.js +5 -34
  255. package/dist/scan/conventions.js.map +1 -1
  256. package/dist/scan/emit.d.ts +2 -6
  257. package/dist/scan/emit.d.ts.map +1 -1
  258. package/dist/scan/emit.js +5 -39
  259. package/dist/scan/emit.js.map +1 -1
  260. package/dist/scan/handler-parser.d.ts +9 -76
  261. package/dist/scan/handler-parser.d.ts.map +1 -1
  262. package/dist/scan/handler-parser.js +28 -85
  263. package/dist/scan/handler-parser.js.map +1 -1
  264. package/dist/scan/result.d.ts +28 -0
  265. package/dist/scan/result.d.ts.map +1 -0
  266. package/dist/scan/result.js +2 -0
  267. package/dist/scan/result.js.map +1 -0
  268. package/dist/scan/scanner.d.ts +3 -28
  269. package/dist/scan/scanner.d.ts.map +1 -1
  270. package/dist/scan/scanner.js +36 -135
  271. package/dist/scan/scanner.js.map +1 -1
  272. package/dist/scan/statement.d.ts +1 -1
  273. package/dist/scan/statement.d.ts.map +1 -1
  274. package/dist/scan/statement.js +4 -30
  275. package/dist/scan/statement.js.map +1 -1
  276. package/dist/source.d.ts +41 -0
  277. package/dist/source.d.ts.map +1 -0
  278. package/dist/source.js +10 -0
  279. package/dist/source.js.map +1 -0
  280. package/dist/storage.d.ts +92 -0
  281. package/dist/storage.d.ts.map +1 -0
  282. package/dist/storage.js +50 -0
  283. package/dist/storage.js.map +1 -0
  284. package/dist/store.d.ts +18 -0
  285. package/dist/store.d.ts.map +1 -0
  286. package/dist/store.js +146 -0
  287. package/dist/store.js.map +1 -0
  288. package/dist/verify.d.ts +6 -39
  289. package/dist/verify.d.ts.map +1 -1
  290. package/dist/verify.js +19 -39
  291. package/dist/verify.js.map +1 -1
  292. package/dist/wire/CallLog.d.ts +32 -0
  293. package/dist/wire/CallLog.d.ts.map +1 -0
  294. package/dist/{contract → wire}/CallLog.js.map +1 -1
  295. package/dist/wire/Invocation.d.ts +32 -0
  296. package/dist/wire/Invocation.d.ts.map +1 -0
  297. package/dist/wire/Invocation.js +66 -0
  298. package/dist/wire/Invocation.js.map +1 -0
  299. package/dist/wire/RouteAddress.d.ts +24 -0
  300. package/dist/wire/RouteAddress.d.ts.map +1 -0
  301. package/dist/{contract → wire}/RouteAddress.js +7 -0
  302. package/dist/wire/RouteAddress.js.map +1 -0
  303. package/dist/wire/binding.d.ts +36 -0
  304. package/dist/wire/binding.d.ts.map +1 -0
  305. package/dist/{boot → wire}/binding.js +5 -62
  306. package/dist/wire/binding.js.map +1 -0
  307. package/dist/wire/call.d.ts +25 -172
  308. package/dist/wire/call.d.ts.map +1 -1
  309. package/dist/wire/call.js +15 -166
  310. package/dist/wire/call.js.map +1 -1
  311. package/dist/wire/drift.d.ts +3 -28
  312. package/dist/wire/drift.d.ts.map +1 -1
  313. package/dist/wire/drift.js +4 -23
  314. package/dist/wire/drift.js.map +1 -1
  315. package/dist/wire/errors.d.ts +4 -24
  316. package/dist/wire/errors.d.ts.map +1 -1
  317. package/dist/wire/errors.js +4 -24
  318. package/dist/wire/errors.js.map +1 -1
  319. package/dist/wire/http-error.d.ts +2 -13
  320. package/dist/wire/http-error.d.ts.map +1 -1
  321. package/dist/wire/http-error.js +5 -19
  322. package/dist/wire/http-error.js.map +1 -1
  323. package/dist/wire/loggerMiddleware.d.ts +2 -8
  324. package/dist/wire/loggerMiddleware.d.ts.map +1 -1
  325. package/dist/wire/loggerMiddleware.js +1 -7
  326. package/dist/wire/loggerMiddleware.js.map +1 -1
  327. package/dist/wire/middleware.d.ts +3 -7
  328. package/dist/wire/middleware.d.ts.map +1 -1
  329. package/dist/wire/middleware.js +1 -5
  330. package/dist/wire/middleware.js.map +1 -1
  331. package/dist/wire/operation.d.ts +12 -74
  332. package/dist/wire/operation.d.ts.map +1 -1
  333. package/dist/wire/operation.js +4 -66
  334. package/dist/wire/operation.js.map +1 -1
  335. package/dist/wire/signature.d.ts +37 -0
  336. package/dist/wire/signature.d.ts.map +1 -0
  337. package/dist/wire/signature.js +2 -0
  338. package/dist/wire/signature.js.map +1 -0
  339. package/package.json +3 -3
  340. package/src/boot/Emissions.ts +22 -119
  341. package/src/boot/ambient-port.ts +3 -24
  342. package/src/boot/ambient.als.ts +7 -12
  343. package/src/boot/ambient.queue.ts +2 -5
  344. package/src/boot/apply.ts +3 -15
  345. package/src/boot/auth.ts +6 -16
  346. package/src/boot/boot.ts +8 -23
  347. package/src/boot/bootstrap.ts +117 -173
  348. package/src/boot/card.ts +84 -0
  349. package/src/boot/frame.ts +31 -65
  350. package/src/boot/hosted.ts +15 -40
  351. package/src/boot/ownership.ts +14 -49
  352. package/src/boot/ports.ts +2 -15
  353. package/src/boot/remote.ts +11 -58
  354. package/src/boot/runner.ts +17 -0
  355. package/src/boot/seed.ts +11 -42
  356. package/src/boot/statement-drift.ts +10 -28
  357. package/src/boot/together.ts +38 -72
  358. package/src/boot/types.ts +36 -180
  359. package/src/{builtins → builtin}/config.ts +1 -7
  360. package/src/{builtins → builtin}/logger.ts +6 -39
  361. package/src/config-loader.ts +12 -71
  362. package/src/contract.ts +15 -39
  363. package/src/crypto/encoding.ts +2 -15
  364. package/src/crypto/node.ts +1 -7
  365. package/src/crypto/port.ts +2 -18
  366. package/src/crypto/webcrypto.ts +1 -12
  367. package/src/{scan/declare.ts → declare.ts} +11 -42
  368. package/src/define.ts +2 -3
  369. package/src/descriptor/Fronds.ts +47 -0
  370. package/src/descriptor/frond.ts +145 -0
  371. package/src/dispatch/ArgumentResolver.ts +54 -8
  372. package/src/dispatch/DispatchEvent.ts +2 -2
  373. package/src/dispatch/DispatchLifecycle.ts +1 -7
  374. package/src/dispatch/DispatchPort.ts +1 -1
  375. package/src/dispatch/Dispatcher.ts +3 -3
  376. package/src/dispatch/HandlerFacade.ts +231 -0
  377. package/src/dispatch/LocalRoutePolicy.ts +4 -4
  378. package/src/dispatch/OperationRoute.ts +2 -2
  379. package/src/dispatch/OutputView.ts +24 -2
  380. package/src/dispatch/Route.ts +2 -4
  381. package/src/dispatch/RoutePolicy.ts +1 -1
  382. package/src/dispatch/RouteRegistry.ts +2 -2
  383. package/src/dispatch/RouteResolver.ts +2 -4
  384. package/src/dispatch/StorageGuard.ts +75 -23
  385. package/src/dispatch/presenterArguments.ts +25 -0
  386. package/src/dispatch/{RemoteRouteResolver.ts → remoteRoutes.ts} +7 -9
  387. package/src/dispatch/routeNotFound.ts +33 -0
  388. package/src/dispatch/validateInput.ts +28 -0
  389. package/src/effective-operation.ts +60 -37
  390. package/src/emit.ts +5 -63
  391. package/src/entry/facade.ts +44 -0
  392. package/src/entry/transport.ts +16 -0
  393. package/src/frond-config.ts +8 -71
  394. package/src/graph.ts +1 -1
  395. package/src/identity-keys.ts +3 -16
  396. package/src/identity.ts +12 -80
  397. package/src/imports.ts +3 -32
  398. package/src/index.ts +28 -33
  399. package/src/loader.ts +2 -16
  400. package/src/node.ts +2 -11
  401. package/src/prefab/collector.ts +1 -22
  402. package/src/prefab/crud.ts +51 -90
  403. package/src/prefab/mirror.ts +9 -49
  404. package/src/prefab/prefab.ts +2 -21
  405. package/src/prefab/presenter.ts +2 -36
  406. package/src/prefab/repository.ts +32 -108
  407. package/src/scan/adapters.ts +32 -0
  408. package/src/scan/bundling.ts +1 -12
  409. package/src/scan/conventions.ts +6 -40
  410. package/src/scan/emit.ts +7 -43
  411. package/src/scan/handler-parser.ts +41 -163
  412. package/src/scan/result.ts +29 -0
  413. package/src/scan/scanner.ts +40 -138
  414. package/src/scan/statement.ts +6 -31
  415. package/src/source.ts +44 -0
  416. package/src/storage.ts +141 -0
  417. package/src/store.ts +152 -0
  418. package/src/verify.ts +19 -60
  419. package/src/wire/CallLog.ts +30 -0
  420. package/src/{contract → wire}/Invocation.ts +24 -17
  421. package/src/{contract → wire}/RouteAddress.ts +10 -0
  422. package/src/wire/binding.ts +102 -0
  423. package/src/wire/call.ts +30 -261
  424. package/src/wire/drift.ts +5 -30
  425. package/src/wire/errors.ts +4 -24
  426. package/src/wire/http-error.ts +5 -19
  427. package/src/wire/loggerMiddleware.ts +2 -8
  428. package/src/wire/middleware.ts +3 -7
  429. package/src/wire/operation.ts +13 -110
  430. package/src/wire/signature.ts +38 -0
  431. package/dist/boot/HandlerFacade.d.ts.map +0 -1
  432. package/dist/boot/HandlerFacade.js.map +0 -1
  433. package/dist/boot/binding.d.ts +0 -60
  434. package/dist/boot/binding.d.ts.map +0 -1
  435. package/dist/boot/binding.js.map +0 -1
  436. package/dist/builtins/config.d.ts +0 -13
  437. package/dist/builtins/config.d.ts.map +0 -1
  438. package/dist/builtins/config.js +0 -21
  439. package/dist/builtins/config.js.map +0 -1
  440. package/dist/builtins/logger.d.ts.map +0 -1
  441. package/dist/builtins/logger.js.map +0 -1
  442. package/dist/contract/Call.d.ts +0 -10
  443. package/dist/contract/Call.d.ts.map +0 -1
  444. package/dist/contract/Call.js +0 -15
  445. package/dist/contract/Call.js.map +0 -1
  446. package/dist/contract/CallLog.d.ts +0 -57
  447. package/dist/contract/CallLog.d.ts.map +0 -1
  448. package/dist/contract/Invocation.d.ts +0 -27
  449. package/dist/contract/Invocation.d.ts.map +0 -1
  450. package/dist/contract/Invocation.js +0 -59
  451. package/dist/contract/Invocation.js.map +0 -1
  452. package/dist/contract/RouteAddress.d.ts +0 -17
  453. package/dist/contract/RouteAddress.d.ts.map +0 -1
  454. package/dist/contract/RouteAddress.js.map +0 -1
  455. package/dist/dispatch/InputValidator.d.ts +0 -7
  456. package/dist/dispatch/InputValidator.d.ts.map +0 -1
  457. package/dist/dispatch/InputValidator.js +0 -22
  458. package/dist/dispatch/InputValidator.js.map +0 -1
  459. package/dist/dispatch/OperationExecutor.d.ts +0 -25
  460. package/dist/dispatch/OperationExecutor.d.ts.map +0 -1
  461. package/dist/dispatch/OperationExecutor.js +0 -32
  462. package/dist/dispatch/OperationExecutor.js.map +0 -1
  463. package/dist/dispatch/OutputProjector.d.ts +0 -12
  464. package/dist/dispatch/OutputProjector.d.ts.map +0 -1
  465. package/dist/dispatch/OutputProjector.js +0 -30
  466. package/dist/dispatch/OutputProjector.js.map +0 -1
  467. package/dist/dispatch/PresenterArgumentResolver.d.ts +0 -12
  468. package/dist/dispatch/PresenterArgumentResolver.d.ts.map +0 -1
  469. package/dist/dispatch/PresenterArgumentResolver.js +0 -20
  470. package/dist/dispatch/PresenterArgumentResolver.js.map +0 -1
  471. package/dist/dispatch/RemoteRouteResolver.d.ts +0 -13
  472. package/dist/dispatch/RemoteRouteResolver.d.ts.map +0 -1
  473. package/dist/dispatch/RemoteRouteResolver.js.map +0 -1
  474. package/dist/dispatch/RouteNotFoundError.d.ts +0 -10
  475. package/dist/dispatch/RouteNotFoundError.d.ts.map +0 -1
  476. package/dist/dispatch/RouteNotFoundError.js +0 -24
  477. package/dist/dispatch/RouteNotFoundError.js.map +0 -1
  478. package/dist/entry/DynamicFacade.d.ts +0 -10
  479. package/dist/entry/DynamicFacade.d.ts.map +0 -1
  480. package/dist/entry/DynamicFacade.js +0 -27
  481. package/dist/entry/DynamicFacade.js.map +0 -1
  482. package/dist/entry/FacadeEntry.d.ts +0 -11
  483. package/dist/entry/FacadeEntry.d.ts.map +0 -1
  484. package/dist/entry/FacadeEntry.js +0 -26
  485. package/dist/entry/FacadeEntry.js.map +0 -1
  486. package/dist/entry/TransportEntry.d.ts +0 -13
  487. package/dist/entry/TransportEntry.d.ts.map +0 -1
  488. package/dist/entry/TransportEntry.js +0 -24
  489. package/dist/entry/TransportEntry.js.map +0 -1
  490. package/dist/orm.d.ts +0 -207
  491. package/dist/orm.d.ts.map +0 -1
  492. package/dist/orm.js +0 -66
  493. package/dist/orm.js.map +0 -1
  494. package/dist/scan/Fronds.d.ts +0 -45
  495. package/dist/scan/Fronds.d.ts.map +0 -1
  496. package/dist/scan/Fronds.js +0 -66
  497. package/dist/scan/Fronds.js.map +0 -1
  498. package/dist/scan/declare.d.ts +0 -71
  499. package/dist/scan/declare.d.ts.map +0 -1
  500. package/dist/scan/declare.js.map +0 -1
  501. package/dist/scan/frond.d.ts +0 -224
  502. package/dist/scan/frond.d.ts.map +0 -1
  503. package/src/boot/HandlerFacade.ts +0 -242
  504. package/src/boot/binding.ts +0 -182
  505. package/src/contract/Call.ts +0 -18
  506. package/src/contract/CallLog.ts +0 -55
  507. package/src/dispatch/InputValidator.ts +0 -28
  508. package/src/dispatch/OperationExecutor.ts +0 -60
  509. package/src/dispatch/OutputProjector.ts +0 -32
  510. package/src/dispatch/PresenterArgumentResolver.ts +0 -25
  511. package/src/dispatch/RouteNotFoundError.ts +0 -29
  512. package/src/entry/DynamicFacade.ts +0 -28
  513. package/src/entry/FacadeEntry.ts +0 -32
  514. package/src/entry/TransportEntry.ts +0 -30
  515. package/src/orm.ts +0 -252
  516. package/src/scan/Fronds.ts +0 -73
  517. package/src/scan/frond.ts +0 -235
  518. /package/dist/{scan → descriptor}/frond.js +0 -0
  519. /package/dist/{contract → wire}/CallLog.js +0 -0
@@ -1,32 +1,10 @@
1
- import { FieldSet, Lifecycle, type EntityConstructor, type Fields, type ValidationResult } from '@fougere/schema';
2
- import type { EntityOrm } from '../orm.js';
1
+ import { Lifecycle, type EntityConstructor, type Fields } from '@fougere/schema';
2
+ import type { Storage } from '../storage.js';
3
3
 
4
- /**
5
- * A paginated local copy of a source that cannot be queried directly.
6
- *
7
- * The shape must contain an `updated()` field used as a high-water mark. Subclasses
8
- * implement `pull`; `refresh` validates and upserts each returned page.
9
- *
10
- * ```ts
11
- * export default class PartnerCatalog extends Mirror(BookCard) {
12
- * constructor(orm: EntityOrm<BookCard>, private catalog: Facade<CatalogHandler>) {
13
- * super(orm);
14
- * }
15
- *
16
- * async *pull(since?: Date) {
17
- * for (let page = 0; page !== null;) {
18
- * const body = await fetch(`${api}?page=${page}&since=${since?.toISOString() ?? ''}`);
19
- * const { items, next } = await body.json();
20
- * yield items.map(toCard);
21
- * page = next;
22
- * }
23
- * }
24
- * }
25
- * ```
26
- */
4
+ /** A paginated local copy of a source that cannot be queried directly. */
27
5
  /** What one refresh did — enough to log it, and to decide whether to run again. */
28
6
  export interface Refreshed {
29
- /** Rows written, counting a replaced row once. */
7
+ /** Instances written, counting a replaced one once. */
30
8
  written: number;
31
9
  /** The age the pull was asked to start from — absent on the first ever run. */
32
10
  since?: Date;
@@ -36,7 +14,7 @@ export interface Refreshed {
36
14
 
37
15
  export interface MirrorOf<T> {
38
16
  /** The copy's own storage — where a page lands, and where its age is read. */
39
- orm: EntityOrm<T>;
17
+ storage: Storage<T>;
40
18
  /** Pages of rows to write. The one thing a mirror's author supplies. */
41
19
  pull(since?: Date): AsyncIterable<Partial<T>[]>;
42
20
  /** Run one pass: read the high-water mark, pull from there, write each page. */
@@ -46,7 +24,7 @@ export interface MirrorOf<T> {
46
24
  }
47
25
 
48
26
  export interface MirrorConstructor<T> {
49
- new (orm: EntityOrm<T>): MirrorOf<T>;
27
+ new (storage: Storage<T>): MirrorOf<T>;
50
28
  readonly __entity: unknown;
51
29
  }
52
30
 
@@ -66,13 +44,13 @@ export function Mirror<E extends EntityConstructor>(shape: E): MirrorConstructor
66
44
  abstract class MirrorBase implements MirrorOf<T> {
67
45
  static readonly __entity = shape;
68
46
 
69
- constructor(public orm: EntityOrm<T>) {}
47
+ constructor(public storage: Storage<T>) {}
70
48
 
71
49
  abstract pull(since?: Date): AsyncIterable<Partial<T>[]>;
72
50
 
73
51
  /** The freshest persisted stamp; no process-local freshness state is kept. */
74
52
  async freshness(): Promise<Date | undefined> {
75
- const [newest] = await this.orm.list({ orderBy: age, order: 'desc', limit: 1 });
53
+ const [newest] = await this.storage.list({ orderBy: age, order: 'desc', limit: 1 });
76
54
  const value = (newest as Record<string, unknown> | undefined)?.[age];
77
55
  return value instanceof Date ? value : undefined;
78
56
  }
@@ -84,7 +62,7 @@ export function Mirror<E extends EntityConstructor>(shape: E): MirrorConstructor
84
62
  // Preserve the source's page boundaries: one page becomes one upsert.
85
63
  for await (const page of this.pull(since)) {
86
64
  if (page.length === 0) continue;
87
- written += await this.orm.upsertAll(judgePage(shape, page) as Partial<T>[]);
65
+ written += await this.storage.upsertAll(page);
88
66
  }
89
67
  return { written, since, ms: Date.now() - started };
90
68
  }
@@ -102,21 +80,3 @@ export function ageFieldOf(shape: unknown): string | undefined {
102
80
  }
103
81
  return undefined;
104
82
  }
105
-
106
- /** Validate and decode a page, naming a refused row by its declared primary field. */
107
- function judgePage<T>(shape: unknown, page: Partial<T>[]): Record<string, unknown>[] {
108
- const judge = (shape as { validate?: (input: unknown) => ValidationResult<unknown> }).validate;
109
- if (typeof judge !== 'function') return page as Record<string, unknown>[];
110
-
111
- const name = (shape as { name?: string }).name ?? 'mirror';
112
- const fields = (shape as { getFields?: () => Fields }).getFields?.();
113
- const primary = fields ? FieldSet.of(fields).primary : undefined;
114
- return page.map((row, index) => {
115
- const verdict = judge.call(shape, row);
116
- if (verdict.success) return verdict.data as Record<string, unknown>;
117
- const key = primary === undefined ? undefined : (row as Record<string, unknown>)[primary];
118
- const where = key !== undefined ? `row ${primary} ${JSON.stringify(key)}` : `row ${index} of this page`;
119
- const why = verdict.errors.map((e) => `${e.path}: ${e.message}`).join(', ');
120
- throw new Error(`${name} mirror refused ${where} — ${why}`);
121
- });
122
- }
@@ -1,20 +1,7 @@
1
1
  import type { EntityConstructor } from '@fougere/schema';
2
2
  import type { PresenterViews } from './presenter.js';
3
3
 
4
- /**
5
- * What a prefab class declares about ITSELF, at runtime.
6
- *
7
- * `Crud(Post)`, `Presenter(Post)`, `Repository(Post)`, `Collector(User)` and
8
- * `Mirror(BookCard)` all fabricate a class, and only the fabricator knows what it was
9
- * built on: the AST scan is workspace-only, so an INSTALLED prefab resolves to nothing
10
- * and a statement written in source would be lost. Hence a runtime marker — the same
11
- * reason `__ops` exists.
12
- *
13
- * It was three spellings for one statement: `static __entity` on three of the five, a
14
- * private `Symbol.for('fougere:x_target')` on the other two, and BOTH on `Repository`
15
- * and `Mirror` — the same class recording its subject twice, under two names, with two
16
- * readers that could disagree. A mark that answers one question answers it once.
17
- */
4
+ /** What a prefab class declares about ITSELF, at runtime. */
18
5
  interface Prefab {
19
6
  /** The shape this class was built on. `Mirror` calls it a shape; it is the same slot. */
20
7
  readonly __entity?: EntityConstructor;
@@ -24,13 +11,7 @@ interface Prefab {
24
11
  readonly __output?: EntityConstructor;
25
12
  }
26
13
 
27
- /**
28
- * The shape a prefab was built on, or `undefined` when the class is not one.
29
- *
30
- * A plain property read: JavaScript walks a constructor's own prototype chain, so a
31
- * subclass of a prefab answers what its base recorded. Three of the five accessors this
32
- * replaces walked that chain by hand, and two did not — one question, two mechanisms.
33
- */
14
+ /** The shape a prefab was built on, or `undefined` when the class is not one. */
34
15
  export function targetOf(ctor: unknown): EntityConstructor | undefined {
35
16
  return (ctor as Prefab | undefined)?.__entity;
36
17
  }
@@ -1,26 +1,4 @@
1
- /**
2
- * Presenter(Entity) — enriches an entity's output with computed fields.
3
- *
4
- * Each method on the presenter is a computed field resolver:
5
- * - Receives the entity record as first argument
6
- * - Can be sync or async
7
- * - Injected via DI (constructor params resolved by the container)
8
- *
9
- * Usage:
10
- * ```ts
11
- * export default class PostPresenter extends Presenter(Post) {
12
- * constructor(private commentOrm: CommentOrm) { super(); }
13
- *
14
- * excerpt(post: Post) {
15
- * return post.body.slice(0, 200);
16
- * }
17
- *
18
- * async commentCount(post: Post) {
19
- * return this.commentOrm.countFor(post.id);
20
- * }
21
- * }
22
- * ```
23
- */
1
+ /** Presenter(Entity) — enriches an entity's output with computed fields. */
24
2
 
25
3
  import { upperFirst, type EntityConstructor } from '@fougere/schema';
26
4
 
@@ -30,19 +8,7 @@ import { upperFirst, type EntityConstructor } from '@fougere/schema';
30
8
  */
31
9
  export type PresenterViews = Record<string, EntityConstructor | [EntityConstructor]>;
32
10
 
33
- /**
34
- * `Presenter(Order, { items: [OrderItemView], user: UserCard })` — the second argument names
35
- * the view each computed field emits, exactly as `Crud(Post, { list: PostCard })` names an
36
- * op's. What fabricates a field declares its contract, and it declares it **once**: the
37
- * façade applies the presenter (see `PresenterExecutor`), and every surface reads the same statement
38
- * instead of guessing.
39
- *
40
- * Guessing was the cost of not stating it. The scan can read a scalar off a return type and
41
- * nothing more, so a field returning an object had no derivable shape: the GraphQL projection
42
- * fell back to a serialized `String`, and a client asking `items { quantity }` got a schema
43
- * error on a field REST served whole. Declaring is optional — a scalar field needs nothing,
44
- * and an undeclared object keeps the old behaviour.
45
- */
11
+ /** `Presenter(Order, { items. */
46
12
  export function Presenter<E extends EntityConstructor>(entity: E, views?: PresenterViews) {
47
13
  class PresenterBase {
48
14
  static readonly __entity = entity;
@@ -1,95 +1,32 @@
1
1
  import { upperFirst, type EntityConstructor } from '@fougere/schema';
2
- import type { EntityOrm, ListOptions, ListResult, SelectOption } from '../orm.js';
2
+ import type { Storage, ListOptions, ListResult, SelectOption } from '../storage.js';
3
3
  import type { SchemaView } from '@fougere/schema';
4
4
 
5
- /**
6
- * Repository(…entities) — who owns an entity's storage, and where its questions are named.
7
- *
8
- * **The arity decides**, which is the second reading of what `orm.ts` already states for
9
- * `EntityOrm` against `Together`: the arity of the unit is the whole distinction.
10
- *
11
- * ONE entity — the repository IS that entity's storage, with your methods added. The port's
12
- * thirteen gestures are forwarded, so a handler reads `this.posts.list()` whether or not
13
- * anyone wrote the file, and a named question sits beside them:
14
- *
15
- * ```ts
16
- * // repositories/PostRepository.ts
17
- * export default class PostRepository extends Repository(Post) {
18
- * published() {
19
- * return this.list({ where: { status: 'published' }, orderBy: 'publishedAt', order: 'desc' });
20
- * }
21
- * }
22
- * ```
23
- *
24
- * TWO OR MORE — an aggregate. It owns them: nothing else in the app is handed their
25
- * storage, and no gesture is forwarded (which entity would `create` write to?), so the only
26
- * way in is a method this class names. That is what lets a rule spanning two tables exist:
27
- * it is ordinary TypeScript inside the method that does the writing.
28
- *
29
- * ```ts
30
- * // repositories/CommandeRepository.ts
31
- * export default class CommandeRepository extends Repository(Commande, Stock) {
32
- * avecLignes(id: string) {
33
- * const [commandes, stock] = this.orms;
34
- * …
35
- * }
36
- * }
37
- * ```
38
- *
39
- * `this.orms` is protected, because the whole point is that the storage stops at this file.
40
- * `protected` is erased at runtime, like `abstract` on a port: a compile-time guarantee, not
41
- * a barrier. The same bargain, already accepted.
42
- *
43
- * **The boundary is not the unit of work.** An aggregate says the rules of these entities
44
- * hold together; a frame says these writes land together, and the two lists coincide only
45
- * often. Deriving the frame from the membership would make a read-only aggregate carry one
46
- * — refusals included, and `registerFrames` refuses without storage or over `remotes:` —
47
- * and would put `Together<[Commande, Stock], [StockMirror]>` out of reach forever. So a
48
- * frame is ASKED FOR here as anywhere else, which is what makes it declared:
49
- *
50
- * ```ts
51
- * constructor(commandes: CommandeOrm, stock: StockOrm, private frame: Together<[Commande, Stock]>) {
52
- * super(commandes, stock);
53
- * }
54
- * ```
55
- *
56
- * The ORM words come back in that line, and only there: this class IS the holder, which is
57
- * the one case `boot/ownership.ts` lets name the storage it was built on.
58
- *
59
- * A repository is NOT a door: it has no façade, so nothing here is reachable from the wire.
60
- */
5
+ /** Repository(…entities) — who owns an entity's storage, and where its questions are named. */
61
6
 
62
7
  /**
63
- * The shape a repository of ONE entity has — the port itself, plus whatever the subclass
64
- * names on top. Written by an author who has not written the file: `RepositoryOf<Post>` is
65
- * to `PostRepository` what `EntityOrm<Post>` is to `PostOrm`, one spelling of one key, and
66
- * `depKeyOf` reads both.
8
+ * The shape a repository of ONE entity has — the port itself, plus whatever the subclass names on
9
+ * top.
67
10
  */
68
- export type RepositoryOf<T> = EntityOrm<T>;
11
+ export type RepositoryOf<T> = Storage<T>;
69
12
 
70
13
  /** The single-entity form: the port, plus whatever the subclass names. */
71
14
  export interface RepositoryConstructor<T> {
72
- new (orm: EntityOrm<T>): EntityOrm<T>;
15
+ new (storage: Storage<T>): Storage<T>;
73
16
  readonly __entity: unknown;
74
17
  }
75
18
 
76
- /**
77
- * What an aggregate's subclass sees: the storage of the members it owns, in declared order,
78
- * and `protected` — the storage stops at that file, which is the whole mechanism.
79
- *
80
- * A class and not an interface, because `protected` cannot be spelled in one. Ambient: the
81
- * value it describes is fabricated by `many()` for an arity only known at the call.
82
- */
19
+ /** What an aggregate's subclass sees. */
83
20
  declare abstract class AggregateShape<E extends readonly EntityConstructor[]> {
84
- protected orms: { [K in keyof E]: EntityOrm<InstanceType<E[K]>> };
21
+ protected storages: { [K in keyof E]: Storage<InstanceType<E[K]>> };
85
22
  }
86
23
 
87
24
  /** The tuple an aggregate holds — the readable form of {@link AggregateShape}'s member. */
88
25
  export type AggregateOf<E extends readonly EntityConstructor[]> =
89
- { [K in keyof E]: EntityOrm<InstanceType<E[K]>> };
26
+ { [K in keyof E]: Storage<InstanceType<E[K]>> };
90
27
 
91
28
  export type AggregateConstructor<E extends readonly EntityConstructor[]> =
92
- (new (...orms: unknown[]) => AggregateShape<E>) & {
29
+ (new (...storages: unknown[]) => AggregateShape<E>) & {
93
30
  readonly __entity: unknown;
94
31
  /** The entities this class owns. Present from two on — an owner of one owns nothing. */
95
32
  readonly __owns: E;
@@ -103,51 +40,43 @@ export function Repository(...entities: EntityConstructor[]): unknown {
103
40
  return entities.length === 1 ? one(entities[0]) : many(entities);
104
41
  }
105
42
 
106
- /**
107
- * The port forwarded, member by member. Written out rather than proxied: a Proxy would
108
- * answer every name including the ones the port does not have, and this file would then
109
- * state the surface nowhere. Thirteen lines against one declaration that can be read.
110
- */
43
+ /** The port forwarded, member by member. */
111
44
  function one<E extends EntityConstructor>(entity: E): RepositoryConstructor<InstanceType<E>> {
112
45
  type T = InstanceType<E>;
113
46
 
114
- class RepositoryBase implements EntityOrm<T> {
47
+ class RepositoryBase implements Storage<T> {
115
48
  static readonly __entity = entity;
116
49
 
117
- constructor(protected orm: EntityOrm<T>) {}
118
-
119
- list(options?: ListOptions & SelectOption): Promise<ListResult<T>> { return this.orm.list(options); }
120
- findById(id: string, options?: SelectOption) { return this.orm.findById(id, options); }
121
- findBy(criteria: Partial<T> | Record<string, unknown>, options?: SelectOption) { return this.orm.findBy(criteria, options); }
122
- findAllBy(criteria: Partial<T> | Record<string, unknown>, options?: SelectOption) { return this.orm.findAllBy(criteria, options); }
123
- findByKeys(ids: readonly string[], options?: SelectOption) { return this.orm.findByKeys(ids, options); }
124
- findAllByKeys(field: string, keys: readonly string[], options?: SelectOption) { return this.orm.findAllByKeys(field, keys, options); }
125
- create(input: Partial<T>, options?: SelectOption) { return this.orm.create(input, options); }
126
- upsert(input: Partial<T>, options?: SelectOption) { return this.orm.upsert(input, options); }
127
- upsertAll(inputs: readonly Partial<T>[], options?: SelectOption) { return this.orm.upsertAll(inputs, options); }
128
- update(id: string, input: Partial<T>, options?: SelectOption) { return this.orm.update(id, input, options); }
129
- delete(id: string) { return this.orm.delete(id); }
130
- output(schema: SchemaView) { return this.orm.output(schema); }
131
- get client(): unknown { return this.orm.client; }
50
+ constructor(protected storage: Storage<T>) {}
51
+
52
+ list(options?: ListOptions & SelectOption): Promise<ListResult<T>> { return this.storage.list(options); }
53
+ findById(id: string, options?: SelectOption) { return this.storage.findById(id, options); }
54
+ findBy(criteria: Partial<T> | Record<string, unknown>, options?: SelectOption) { return this.storage.findBy(criteria, options); }
55
+ findAllBy(criteria: Partial<T> | Record<string, unknown>, options?: SelectOption) { return this.storage.findAllBy(criteria, options); }
56
+ findByKeys(ids: readonly string[], options?: SelectOption) { return this.storage.findByKeys(ids, options); }
57
+ findAllByKeys(field: string, keys: readonly string[], options?: SelectOption) { return this.storage.findAllByKeys(field, keys, options); }
58
+ create(input: Partial<T>, options?: SelectOption) { return this.storage.create(input, options); }
59
+ upsert(input: Partial<T>, options?: SelectOption) { return this.storage.upsert(input, options); }
60
+ upsertAll(inputs: readonly Partial<T>[], options?: SelectOption) { return this.storage.upsertAll(inputs, options); }
61
+ update(id: string, input: Partial<T>, options?: SelectOption) { return this.storage.update(id, input, options); }
62
+ delete(id: string) { return this.storage.delete(id); }
63
+ output(schema: SchemaView) { return this.storage.output(schema); }
64
+ get client(): unknown { return this.storage.client; }
132
65
  }
133
66
 
134
67
  return RepositoryBase as unknown as RepositoryConstructor<T>;
135
68
  }
136
69
 
137
- /**
138
- * The aggregate. Its constructor takes the members' storage in the DECLARED order — the
139
- * order `toProvider` fills its `deps` with, and the order a subclass hands back to `super()`
140
- * when it declares a constructor of its own.
141
- */
70
+ /** The aggregate. */
142
71
  function many<E extends readonly EntityConstructor[]>(entities: E): AggregateConstructor<E> {
143
72
  class AggregateBase {
144
73
  static readonly __entity = entities[0];
145
74
  static readonly __owns = entities;
146
75
 
147
- protected orms: AggregateOf<E>;
76
+ protected storages: AggregateOf<E>;
148
77
 
149
- constructor(...orms: unknown[]) {
150
- this.orms = orms.slice(0, entities.length) as AggregateOf<E>;
78
+ constructor(...storages: unknown[]) {
79
+ this.storages = storages.slice(0, entities.length) as AggregateOf<E>;
151
80
  }
152
81
  }
153
82
 
@@ -159,12 +88,7 @@ export function repositoryKeyOf(entity: string): string {
159
88
  return `${upperFirst(entity)}Repository`;
160
89
  }
161
90
 
162
- /**
163
- * The entities a class owns — empty for anything that is not an aggregate.
164
- *
165
- * Read from the mark rather than from the constructor, for the reason `Crud.__ops` exists:
166
- * the AST scan is workspace-only, so an installed prefab resolves to nothing.
167
- */
91
+ /** The entities a class owns — empty for anything that is not an aggregate. */
168
92
  export function ownedBy(ctor: unknown): readonly EntityConstructor[] {
169
93
  return (ctor as { __owns?: readonly EntityConstructor[] } | undefined)?.__owns ?? [];
170
94
  }
@@ -0,0 +1,32 @@
1
+ import { readFile } from 'node:fs/promises';
2
+ import { join } from 'node:path';
3
+
4
+ /** Which adapters a PROJECT could load, read off its dependencies. */
5
+ const ADAPTER_PACKAGE = /^@fougere\/adapter-(.+)$/;
6
+
7
+ /** The adapter names this project depends on — empty when it has no package.json to read. */
8
+ export async function adaptersOf(root: string): Promise<string[]> {
9
+ const manifest = await read(join(root, 'package.json'));
10
+ if (!manifest) return [];
11
+
12
+ const declared = { ...manifest.dependencies, ...manifest.devDependencies };
13
+
14
+ return Object.keys(declared)
15
+ .map((name) => ADAPTER_PACKAGE.exec(name)?.[1])
16
+ .filter((name): name is string => name !== undefined);
17
+ }
18
+
19
+ async function read(path: string): Promise<Manifest | undefined> {
20
+ try {
21
+ return JSON.parse(await readFile(path, 'utf8')) as Manifest;
22
+ } catch {
23
+ // No manifest, or one that is not JSON. Either way this cannot validate a name, and
24
+ // reporting every `adapters:` key as unknown would be worse than saying nothing.
25
+ return undefined;
26
+ }
27
+ }
28
+
29
+ interface Manifest {
30
+ dependencies?: Record<string, string>;
31
+ devDependencies?: Record<string, string>;
32
+ }
@@ -1,15 +1,4 @@
1
- /**
2
- * What a Fougere boot loads at RUNTIME, so a bundler must leave it alone.
3
- *
4
- * Stated once because it was stated twice and the two had already drifted: the Vite plugin
5
- * listed `@fougere/schema`, `@fougere/adapter-graphql` and `@fougere/auth-better`, the Next
6
- * one did not, and BOTH omitted the two packages `@fougere/app`'s boot actually imports
7
- * dynamically — `@fougere/defaults` and `@fougere/transport-http`. A list a bundler reads
8
- * has no way to notice it is wrong: nothing fails at build time, the app fails at boot.
9
- *
10
- * It sits here rather than beside the dynamic imports because both readers are BUILD-TIME
11
- * plugins that already depend on core, and neither may pull the boot into a bundler config.
12
- */
1
+ /** What a Fougere boot loads at RUNTIME, so a bundler must leave it alone. */
13
2
  export const RUNTIME_PACKAGES: readonly string[] = [
14
3
  '@fougere/app',
15
4
  '@fougere/core',
@@ -1,19 +1,7 @@
1
- /**
2
- * The names the scan READS instead of deriving them.
3
- *
4
- * Everything else a frond states, it states by its shape; these seven directories and the
5
- * import prefix are the one place where a name is the declaration. They were spelled as
6
- * literals in five packages, so a project could not move any of them and `frondsDir` was
7
- * a declared key with no reader.
8
- */
1
+ /** The names the scan READS instead of deriving them. */
9
2
 
10
3
  export interface Conventions {
11
- /**
12
- * The scope a frond's package name carries — `@fronds/blog`.
13
- *
14
- * A real package name, not only an alias: the CLI writes it as `name` in a scaffolded
15
- * frond and as a `workspace:*` dependency in the app that consumes it.
16
- */
4
+ /** The scope a frond's package name carries — `@fronds/blog`. */
17
5
  scope: string;
18
6
  /** The directory holding fronds, below the project root. */
19
7
  fronds: string;
@@ -31,12 +19,7 @@ export interface Conventions {
31
19
  };
32
20
  }
33
21
 
34
- /**
35
- * What a project means when it declares nothing — the convention itself.
36
- *
37
- * `@fronds` and not `@frond`: the npm org for the singular belongs to someone else, and a
38
- * scope is a name that must be ownable.
39
- */
22
+ /** What a project means when it declares nothing — the convention itself. */
40
23
  export const DEFAULT_CONVENTIONS: Conventions = {
41
24
  scope: '@fronds',
42
25
  fronds: 'fronds',
@@ -59,13 +42,7 @@ export type ConventionsInput = {
59
42
  dirs?: Partial<Conventions['dirs']>;
60
43
  };
61
44
 
62
- /**
63
- * The convention, with a project's exceptions folded in.
64
- *
65
- * Merged one level into `dirs` so renaming one directory does not require restating the
66
- * other six — the same reading `sources:` and `ports:` get, where only the exception is
67
- * declared.
68
- */
45
+ /** The convention, with a project's exceptions folded in. */
69
46
  export function resolveConventions(input?: ConventionsInput): Conventions {
70
47
  return {
71
48
  scope: input?.scope ?? DEFAULT_CONVENTIONS.scope,
@@ -79,23 +56,12 @@ export function frondPackage(name: string, conventions: Conventions): string {
79
56
  return `${conventions.scope}/${name}`;
80
57
  }
81
58
 
82
- /**
83
- * Directories whose classes register as providers — two spellings, one behaviour.
84
- *
85
- * A project may point both roles at one directory; the scan must then read it once, or
86
- * every provider would be registered twice.
87
- */
59
+ /** Directories whose classes register as providers — two spellings, one behaviour. */
88
60
  export function providerDirsOf(conventions: Conventions): string[] {
89
61
  return [...new Set([conventions.dirs.services, conventions.dirs.repositories])];
90
62
  }
91
63
 
92
- /**
93
- * The frond vocabulary — every directory the scan reads.
94
- *
95
- * What a reader needs to bound a frond: the Nuxt module watches these for the root frond
96
- * (watching the root itself would match every write), and a flat app's tsconfig lists
97
- * them instead of `["."]`, which would swallow `app/` and `nuxt.config.ts`.
98
- */
64
+ /** The frond vocabulary — every directory the scan reads. */
99
65
  export function frondDirsOf(conventions: Conventions): string[] {
100
66
  const { entities, handlers, presenters, collectors, seeds, versions } = conventions.dirs;
101
67
  return [...new Set([
package/src/scan/emit.ts CHANGED
@@ -1,25 +1,8 @@
1
- /**
2
- * The scan, written down as a module — what `createApp` is handed where there is no disk.
3
- *
4
- * It RE-RESOLVES NOTHING. By the time this runs the scan has already decided what every
5
- * slot holds, and `resolveSchema` put the entity's own class in `contract.output` — the
6
- * very object `EntityEntry.entityClass` holds. So the emitter keeps a table from object
7
- * to import alias and writes the alias. Identity is preserved because it is the same
8
- * object that becomes the same import, which is what three call sites depend on
9
- * (`adapter/graphql`'s `view === entity.entityClass` and its WeakMap, and `bootstrap`'s
10
- * `outputSchema !== entity.entityClass`). An emitter that re-resolved instead would build
11
- * a second class for `Post` and those three would silently take the other branch.
12
- *
13
- * Measured on three real projects: every live reference is either a class the descriptor
14
- * already names by `filePath`, a named export of the file that declared the signature, or
15
- * `Partial<X>` — the one derivation `resolveSchema` fabricates.
16
- */
1
+ /** The scan, written down as a module — what `createApp` is handed where there is no disk. */
17
2
  import { dirname, relative } from 'node:path';
18
3
  import { ANONYMOUS_SCHEMA_NAME, Card, type SchemaView } from '@fougere/schema';
19
- import type {
20
- ScanResult, FrondDescriptor, EntityEntry, HandlerEntry,
21
- PresenterEntry, CollectorEntry, ProviderEntry, SeedEntry,
22
- } from './frond.js';
4
+ import type { FrondDescriptor, EntityEntry, HandlerEntry, PresenterEntry, CollectorEntry, ProviderEntry, SeedEntry } from '../descriptor/frond.js';
5
+ import type { ScanResult } from './result.js';
23
6
  import type { OperationContract } from '../wire/operation.js';
24
7
 
25
8
  export interface EmitOptions {
@@ -34,14 +17,7 @@ type Live = object;
34
17
  /** Is a TypeScript compiler going to read this module? Its name is the only thing that says. */
35
18
  const isTypeScript = (outFile: string): boolean => /\.tsx?$/.test(outFile);
36
19
 
37
- /**
38
- * A source file becomes a specifier its reader can follow — and the two readers differ.
39
- *
40
- * A `.ts` destination is compiled by tsc under Node16 resolution, which spells a
41
- * TypeScript source with `.js`. A `.mjs` destination is read by a bundler, which resolves
42
- * the path AS IT IS ON DISK — measured, Nitro's rollup refused `Post.seed.js` because no
43
- * such file exists. One rule, read off the destination, exactly like the type annotation.
44
- */
20
+ /** A source file becomes a specifier its reader can follow — and the two readers differ. */
45
21
  function specifierOf(filePath: string, outFile: string): string {
46
22
  const path = relative(dirname(outFile), filePath);
47
23
  const rel = isTypeScript(outFile) ? path.replace(/\.tsx?$/, '.js') : path;
@@ -83,15 +59,7 @@ class Imports {
83
59
  render(): string { return this.lines.join('\n'); }
84
60
  }
85
61
 
86
- /**
87
- * What a schema slot becomes in the generated module.
88
- *
89
- * Three answers, and the third is the only rule: a class already imported is its alias; a
90
- * named export of the file that declared the signature is imported by its own name — it
91
- * IS exported there, because that is where `resolveSchema` found it; and an anonymous
92
- * schema is `Partial<X>`, the one derivation `resolveSchema` builds, so it is written as
93
- * the derivation rather than as a value.
94
- */
62
+ /** What a schema slot becomes in the generated module. */
95
63
  function schemaRef(schema: SchemaView | undefined, declaredIn: string, imports: Imports): string | undefined {
96
64
  if (!schema) return undefined;
97
65
  const known = imports.aliasOf(schema as Live);
@@ -180,11 +148,7 @@ function frondOf(f: FrondDescriptor, imports: Imports): string {
180
148
  ].filter(Boolean).join('\n');
181
149
  }
182
150
 
183
- /**
184
- * Write a scan down. The result is a TypeScript module whose only imports are the classes
185
- * the scan found — static, so a bundler traces them — and whose only value is the
186
- * descriptor `createApp` asks for.
187
- */
151
+ /** Write a scan down. */
188
152
  export function emitScan(result: ScanResult, options: EmitOptions): string {
189
153
  const imports = new Imports(options.outFile);
190
154
  const core = options.core ?? '@fougere/core';
@@ -222,7 +186,7 @@ import { Fronds } from '${core}';
222
186
  ${typed ? `import type { ScanResult } from '${core}';\n` : ''}${imports.render()}
223
187
 
224
188
  export const scan${typed ? ': ScanResult' : ''} = {
225
- fronds: Fronds.scanned([
189
+ fronds: Fronds.hosting([
226
190
  ${fronds}
227
191
  ]),
228
192
  diagnostics: [${diagnostics.join(', ')}],