@fougere/core 0.6.0-alpha.0 → 0.8.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 (510) hide show
  1. package/README.md +1 -1
  2. package/dist/boot/AppLifecycle.d.ts +1 -1
  3. package/dist/boot/AppLifecycle.d.ts.map +1 -1
  4. package/dist/boot/AppLifecycle.js +13 -2
  5. package/dist/boot/AppLifecycle.js.map +1 -1
  6. package/dist/boot/Emissions.d.ts +13 -90
  7. package/dist/boot/Emissions.d.ts.map +1 -1
  8. package/dist/boot/Emissions.js +21 -118
  9. package/dist/boot/Emissions.js.map +1 -1
  10. package/dist/boot/ambient-port.d.ts +3 -24
  11. package/dist/boot/ambient-port.d.ts.map +1 -1
  12. package/dist/boot/ambient.als.d.ts.map +1 -1
  13. package/dist/boot/ambient.als.js +7 -12
  14. package/dist/boot/ambient.als.js.map +1 -1
  15. package/dist/boot/ambient.queue.d.ts +2 -5
  16. package/dist/boot/ambient.queue.d.ts.map +1 -1
  17. package/dist/boot/ambient.queue.js.map +1 -1
  18. package/dist/boot/apply.d.ts +1 -13
  19. package/dist/boot/apply.d.ts.map +1 -1
  20. package/dist/boot/apply.js +9 -16
  21. package/dist/boot/apply.js.map +1 -1
  22. package/dist/boot/auth.d.ts +2 -12
  23. package/dist/boot/auth.d.ts.map +1 -1
  24. package/dist/boot/boot.d.ts +3 -16
  25. package/dist/boot/boot.d.ts.map +1 -1
  26. package/dist/boot/boot.js +4 -11
  27. package/dist/boot/boot.js.map +1 -1
  28. package/dist/boot/bootstrap.d.ts.map +1 -1
  29. package/dist/boot/bootstrap.js +84 -130
  30. package/dist/boot/bootstrap.js.map +1 -1
  31. package/dist/boot/card.d.ts +1 -17
  32. package/dist/boot/card.d.ts.map +1 -1
  33. package/dist/boot/card.js +3 -32
  34. package/dist/boot/card.js.map +1 -1
  35. package/dist/boot/frame.d.ts +8 -32
  36. package/dist/boot/frame.d.ts.map +1 -1
  37. package/dist/boot/frame.js +17 -56
  38. package/dist/boot/frame.js.map +1 -1
  39. package/dist/boot/hosted.d.ts +2 -24
  40. package/dist/boot/hosted.d.ts.map +1 -1
  41. package/dist/boot/hosted.js +10 -15
  42. package/dist/boot/hosted.js.map +1 -1
  43. package/dist/boot/ownership.d.ts +3 -36
  44. package/dist/boot/ownership.d.ts.map +1 -1
  45. package/dist/boot/ownership.js +5 -40
  46. package/dist/boot/ownership.js.map +1 -1
  47. package/dist/boot/ports.d.ts +1 -14
  48. package/dist/boot/ports.d.ts.map +1 -1
  49. package/dist/boot/ports.js +1 -14
  50. package/dist/boot/ports.js.map +1 -1
  51. package/dist/boot/remote.d.ts +5 -38
  52. package/dist/boot/remote.d.ts.map +1 -1
  53. package/dist/boot/remote.js +8 -41
  54. package/dist/boot/remote.js.map +1 -1
  55. package/dist/boot/runner.d.ts +4 -21
  56. package/dist/boot/runner.d.ts.map +1 -1
  57. package/dist/boot/runner.js +4 -17
  58. package/dist/boot/runner.js.map +1 -1
  59. package/dist/boot/seed.d.ts +4 -31
  60. package/dist/boot/seed.d.ts.map +1 -1
  61. package/dist/boot/seed.js +6 -37
  62. package/dist/boot/seed.js.map +1 -1
  63. package/dist/boot/statement-drift.d.ts +2 -21
  64. package/dist/boot/statement-drift.d.ts.map +1 -1
  65. package/dist/boot/statement-drift.js +4 -9
  66. package/dist/boot/statement-drift.js.map +1 -1
  67. package/dist/boot/together.d.ts +4 -8
  68. package/dist/boot/together.d.ts.map +1 -1
  69. package/dist/boot/together.js +15 -50
  70. package/dist/boot/together.js.map +1 -1
  71. package/dist/boot/types.d.ts +31 -173
  72. package/dist/boot/types.d.ts.map +1 -1
  73. package/dist/builtin/config.d.ts +7 -0
  74. package/dist/builtin/config.d.ts.map +1 -0
  75. package/dist/builtin/config.js +15 -0
  76. package/dist/builtin/config.js.map +1 -0
  77. package/dist/{builtins → builtin}/logger.d.ts +4 -25
  78. package/dist/builtin/logger.d.ts.map +1 -0
  79. package/dist/{builtins → builtin}/logger.js +5 -32
  80. package/dist/builtin/logger.js.map +1 -0
  81. package/dist/config-loader.d.ts +9 -67
  82. package/dist/config-loader.d.ts.map +1 -1
  83. package/dist/config-loader.js +5 -18
  84. package/dist/config-loader.js.map +1 -1
  85. package/dist/contract.d.ts +15 -31
  86. package/dist/contract.d.ts.map +1 -1
  87. package/dist/contract.js +13 -26
  88. package/dist/contract.js.map +1 -1
  89. package/dist/criterion.d.ts +37 -0
  90. package/dist/criterion.d.ts.map +1 -0
  91. package/dist/criterion.js +28 -0
  92. package/dist/criterion.js.map +1 -0
  93. package/dist/crypto/encoding.d.ts +2 -15
  94. package/dist/crypto/encoding.d.ts.map +1 -1
  95. package/dist/crypto/encoding.js +2 -15
  96. package/dist/crypto/encoding.js.map +1 -1
  97. package/dist/crypto/node.d.ts.map +1 -1
  98. package/dist/crypto/node.js +1 -7
  99. package/dist/crypto/node.js.map +1 -1
  100. package/dist/crypto/port.d.ts +2 -18
  101. package/dist/crypto/port.d.ts.map +1 -1
  102. package/dist/crypto/port.js +1 -17
  103. package/dist/crypto/port.js.map +1 -1
  104. package/dist/crypto/webcrypto.d.ts.map +1 -1
  105. package/dist/crypto/webcrypto.js +1 -12
  106. package/dist/crypto/webcrypto.js.map +1 -1
  107. package/dist/declare.d.ts +19 -37
  108. package/dist/declare.d.ts.map +1 -1
  109. package/dist/declare.js +23 -30
  110. package/dist/declare.js.map +1 -1
  111. package/dist/define.d.ts +2 -3
  112. package/dist/define.d.ts.map +1 -1
  113. package/dist/define.js +2 -3
  114. package/dist/define.js.map +1 -1
  115. package/dist/descriptor/Fronds.d.ts +3 -28
  116. package/dist/descriptor/Fronds.d.ts.map +1 -1
  117. package/dist/descriptor/Fronds.js +6 -31
  118. package/dist/descriptor/Fronds.js.map +1 -1
  119. package/dist/descriptor/frond.d.ts +25 -60
  120. package/dist/descriptor/frond.d.ts.map +1 -1
  121. package/dist/descriptor/frond.js +5 -1
  122. package/dist/descriptor/frond.js.map +1 -1
  123. package/dist/dispatch/ArgumentResolver.d.ts +1 -1
  124. package/dist/dispatch/ArgumentResolver.d.ts.map +1 -1
  125. package/dist/dispatch/ArgumentResolver.js +5 -5
  126. package/dist/dispatch/ArgumentResolver.js.map +1 -1
  127. package/dist/dispatch/DispatchEvent.d.ts +2 -2
  128. package/dist/dispatch/DispatchEvent.d.ts.map +1 -1
  129. package/dist/dispatch/DispatchLifecycle.d.ts +1 -7
  130. package/dist/dispatch/DispatchLifecycle.d.ts.map +1 -1
  131. package/dist/dispatch/DispatchLifecycle.js +1 -7
  132. package/dist/dispatch/DispatchLifecycle.js.map +1 -1
  133. package/dist/dispatch/DispatchPort.d.ts +1 -1
  134. package/dist/dispatch/DispatchPort.d.ts.map +1 -1
  135. package/dist/dispatch/Dispatcher.d.ts +1 -1
  136. package/dist/dispatch/Dispatcher.d.ts.map +1 -1
  137. package/dist/dispatch/Dispatcher.js +2 -2
  138. package/dist/dispatch/Dispatcher.js.map +1 -1
  139. package/dist/{boot → dispatch}/HandlerFacade.d.ts +25 -38
  140. package/dist/dispatch/HandlerFacade.d.ts.map +1 -0
  141. package/dist/{boot → dispatch}/HandlerFacade.js +65 -74
  142. package/dist/dispatch/HandlerFacade.js.map +1 -0
  143. package/dist/dispatch/LocalRoutePolicy.d.ts +1 -1
  144. package/dist/dispatch/LocalRoutePolicy.d.ts.map +1 -1
  145. package/dist/dispatch/LocalRoutePolicy.js +4 -4
  146. package/dist/dispatch/LocalRoutePolicy.js.map +1 -1
  147. package/dist/dispatch/OperationRoute.d.ts +2 -2
  148. package/dist/dispatch/OperationRoute.d.ts.map +1 -1
  149. package/dist/dispatch/OutputView.d.ts +3 -2
  150. package/dist/dispatch/OutputView.d.ts.map +1 -1
  151. package/dist/dispatch/OutputView.js +19 -1
  152. package/dist/dispatch/OutputView.js.map +1 -1
  153. package/dist/dispatch/Route.d.ts +2 -2
  154. package/dist/dispatch/Route.d.ts.map +1 -1
  155. package/dist/dispatch/RoutePolicy.d.ts +1 -1
  156. package/dist/dispatch/RoutePolicy.d.ts.map +1 -1
  157. package/dist/dispatch/RouteRegistry.d.ts +1 -1
  158. package/dist/dispatch/RouteRegistry.d.ts.map +1 -1
  159. package/dist/dispatch/RouteRegistry.js +2 -2
  160. package/dist/dispatch/RouteRegistry.js.map +1 -1
  161. package/dist/dispatch/RouteResolver.d.ts +2 -4
  162. package/dist/dispatch/RouteResolver.d.ts.map +1 -1
  163. package/dist/dispatch/StorageGuard.d.ts +40 -8
  164. package/dist/dispatch/StorageGuard.d.ts.map +1 -1
  165. package/dist/dispatch/StorageGuard.js +151 -20
  166. package/dist/dispatch/StorageGuard.js.map +1 -1
  167. package/dist/dispatch/presenterArguments.d.ts +7 -0
  168. package/dist/dispatch/presenterArguments.d.ts.map +1 -0
  169. package/dist/dispatch/presenterArguments.js +12 -0
  170. package/dist/dispatch/presenterArguments.js.map +1 -0
  171. package/dist/dispatch/remoteRoutes.d.ts +7 -0
  172. package/dist/dispatch/remoteRoutes.d.ts.map +1 -0
  173. package/dist/dispatch/{RemoteRouteResolver.js → remoteRoutes.js} +6 -10
  174. package/dist/dispatch/remoteRoutes.js.map +1 -0
  175. package/dist/dispatch/routeNotFound.d.ts +9 -0
  176. package/dist/dispatch/routeNotFound.d.ts.map +1 -0
  177. package/dist/dispatch/routeNotFound.js +21 -0
  178. package/dist/dispatch/routeNotFound.js.map +1 -0
  179. package/dist/dispatch/validateInput.d.ts +5 -0
  180. package/dist/dispatch/validateInput.d.ts.map +1 -0
  181. package/dist/dispatch/validateInput.js +20 -0
  182. package/dist/dispatch/validateInput.js.map +1 -0
  183. package/dist/effective-operation.d.ts +1 -24
  184. package/dist/effective-operation.d.ts.map +1 -1
  185. package/dist/effective-operation.js +21 -50
  186. package/dist/effective-operation.js.map +1 -1
  187. package/dist/emit.d.ts +4 -42
  188. package/dist/emit.d.ts.map +1 -1
  189. package/dist/emit.js +3 -39
  190. package/dist/emit.js.map +1 -1
  191. package/dist/entry/facade.d.ts +8 -0
  192. package/dist/entry/facade.d.ts.map +1 -0
  193. package/dist/entry/facade.js +28 -0
  194. package/dist/entry/facade.js.map +1 -0
  195. package/dist/entry/transport.d.ts +5 -0
  196. package/dist/entry/transport.d.ts.map +1 -0
  197. package/dist/entry/transport.js +11 -0
  198. package/dist/entry/transport.js.map +1 -0
  199. package/dist/frond-config.d.ts +7 -70
  200. package/dist/frond-config.d.ts.map +1 -1
  201. package/dist/frond-config.js +1 -9
  202. package/dist/frond-config.js.map +1 -1
  203. package/dist/identity-keys.d.ts +2 -5
  204. package/dist/identity-keys.d.ts.map +1 -1
  205. package/dist/identity-keys.js +3 -16
  206. package/dist/identity-keys.js.map +1 -1
  207. package/dist/identity.d.ts +4 -30
  208. package/dist/identity.d.ts.map +1 -1
  209. package/dist/identity.js +11 -73
  210. package/dist/identity.js.map +1 -1
  211. package/dist/imports.d.ts +1 -7
  212. package/dist/imports.d.ts.map +1 -1
  213. package/dist/imports.js +1 -7
  214. package/dist/imports.js.map +1 -1
  215. package/dist/index.d.ts +17 -24
  216. package/dist/index.d.ts.map +1 -1
  217. package/dist/index.js +10 -18
  218. package/dist/index.js.map +1 -1
  219. package/dist/loader.d.ts +1 -8
  220. package/dist/loader.d.ts.map +1 -1
  221. package/dist/loader.js +1 -8
  222. package/dist/loader.js.map +1 -1
  223. package/dist/node.d.ts +2 -11
  224. package/dist/node.d.ts.map +1 -1
  225. package/dist/node.js +2 -11
  226. package/dist/node.js.map +1 -1
  227. package/dist/prefab/collector.d.ts +1 -22
  228. package/dist/prefab/collector.d.ts.map +1 -1
  229. package/dist/prefab/collector.js +1 -22
  230. package/dist/prefab/collector.js.map +1 -1
  231. package/dist/prefab/crud.d.ts +16 -32
  232. package/dist/prefab/crud.d.ts.map +1 -1
  233. package/dist/prefab/crud.js +31 -58
  234. package/dist/prefab/crud.js.map +1 -1
  235. package/dist/prefab/mirror.d.ts +2 -24
  236. package/dist/prefab/mirror.d.ts.map +1 -1
  237. package/dist/prefab/mirror.js +2 -20
  238. package/dist/prefab/mirror.js.map +1 -1
  239. package/dist/prefab/prefab.d.ts +1 -7
  240. package/dist/prefab/prefab.d.ts.map +1 -1
  241. package/dist/prefab/prefab.js +1 -7
  242. package/dist/prefab/prefab.js.map +1 -1
  243. package/dist/prefab/presenter.d.ts +2 -36
  244. package/dist/prefab/presenter.d.ts.map +1 -1
  245. package/dist/prefab/presenter.js +2 -36
  246. package/dist/prefab/presenter.js.map +1 -1
  247. package/dist/prefab/repository.d.ts +5 -73
  248. package/dist/prefab/repository.d.ts.map +1 -1
  249. package/dist/prefab/repository.js +3 -16
  250. package/dist/prefab/repository.js.map +1 -1
  251. package/dist/scan/adapters.d.ts +3 -0
  252. package/dist/scan/adapters.d.ts.map +1 -0
  253. package/dist/scan/adapters.js +25 -0
  254. package/dist/scan/adapters.js.map +1 -0
  255. package/dist/scan/bundling.d.ts +1 -12
  256. package/dist/scan/bundling.d.ts.map +1 -1
  257. package/dist/scan/bundling.js +1 -12
  258. package/dist/scan/bundling.js.map +1 -1
  259. package/dist/scan/contract.d.ts +27 -0
  260. package/dist/scan/contract.d.ts.map +1 -0
  261. package/dist/scan/contract.js +46 -0
  262. package/dist/scan/contract.js.map +1 -0
  263. package/dist/scan/conventions.d.ts +6 -40
  264. package/dist/scan/conventions.d.ts.map +1 -1
  265. package/dist/scan/conventions.js +5 -34
  266. package/dist/scan/conventions.js.map +1 -1
  267. package/dist/scan/emit.d.ts +1 -5
  268. package/dist/scan/emit.d.ts.map +1 -1
  269. package/dist/scan/emit.js +10 -78
  270. package/dist/scan/emit.js.map +1 -1
  271. package/dist/scan/handler-parser.d.ts +4 -26
  272. package/dist/scan/handler-parser.d.ts.map +1 -1
  273. package/dist/scan/handler-parser.js +26 -83
  274. package/dist/scan/handler-parser.js.map +1 -1
  275. package/dist/scan/result.d.ts +3 -16
  276. package/dist/scan/result.d.ts.map +1 -1
  277. package/dist/scan/scanner.d.ts +2 -27
  278. package/dist/scan/scanner.d.ts.map +1 -1
  279. package/dist/scan/scanner.js +45 -133
  280. package/dist/scan/scanner.js.map +1 -1
  281. package/dist/scan/statement.d.ts.map +1 -1
  282. package/dist/scan/statement.js +60 -37
  283. package/dist/scan/statement.js.map +1 -1
  284. package/dist/source.d.ts +53 -0
  285. package/dist/source.d.ts.map +1 -0
  286. package/dist/source.js +18 -0
  287. package/dist/source.js.map +1 -0
  288. package/dist/storage.d.ts +13 -210
  289. package/dist/storage.d.ts.map +1 -1
  290. package/dist/storage.js +4 -68
  291. package/dist/storage.js.map +1 -1
  292. package/dist/store.d.ts +18 -0
  293. package/dist/store.d.ts.map +1 -0
  294. package/dist/store.js +179 -0
  295. package/dist/store.js.map +1 -0
  296. package/dist/verify.d.ts +5 -38
  297. package/dist/verify.d.ts.map +1 -1
  298. package/dist/verify.js +17 -37
  299. package/dist/verify.js.map +1 -1
  300. package/dist/wire/CallLog.d.ts +32 -0
  301. package/dist/wire/CallLog.d.ts.map +1 -0
  302. package/dist/{contract → wire}/CallLog.js.map +1 -1
  303. package/dist/wire/Invocation.d.ts +32 -0
  304. package/dist/wire/Invocation.d.ts.map +1 -0
  305. package/dist/wire/Invocation.js +66 -0
  306. package/dist/wire/Invocation.js.map +1 -0
  307. package/dist/{contract → wire}/RouteAddress.d.ts +5 -0
  308. package/dist/wire/RouteAddress.d.ts.map +1 -0
  309. package/dist/{contract → wire}/RouteAddress.js +7 -0
  310. package/dist/wire/RouteAddress.js.map +1 -0
  311. package/dist/wire/binding.d.ts +5 -21
  312. package/dist/wire/binding.d.ts.map +1 -1
  313. package/dist/wire/binding.js +5 -10
  314. package/dist/wire/binding.js.map +1 -1
  315. package/dist/wire/call.d.ts +24 -133
  316. package/dist/wire/call.d.ts.map +1 -1
  317. package/dist/wire/call.js +15 -41
  318. package/dist/wire/call.js.map +1 -1
  319. package/dist/wire/drift.d.ts +3 -28
  320. package/dist/wire/drift.d.ts.map +1 -1
  321. package/dist/wire/drift.js +4 -23
  322. package/dist/wire/drift.js.map +1 -1
  323. package/dist/wire/errors.d.ts +4 -24
  324. package/dist/wire/errors.d.ts.map +1 -1
  325. package/dist/wire/errors.js +4 -24
  326. package/dist/wire/errors.js.map +1 -1
  327. package/dist/wire/http-error.d.ts +2 -13
  328. package/dist/wire/http-error.d.ts.map +1 -1
  329. package/dist/wire/http-error.js +5 -19
  330. package/dist/wire/http-error.js.map +1 -1
  331. package/dist/wire/loggerMiddleware.d.ts +2 -8
  332. package/dist/wire/loggerMiddleware.d.ts.map +1 -1
  333. package/dist/wire/loggerMiddleware.js +1 -7
  334. package/dist/wire/loggerMiddleware.js.map +1 -1
  335. package/dist/wire/middleware.d.ts +3 -7
  336. package/dist/wire/middleware.d.ts.map +1 -1
  337. package/dist/wire/middleware.js +1 -5
  338. package/dist/wire/middleware.js.map +1 -1
  339. package/dist/wire/operation.d.ts +7 -43
  340. package/dist/wire/operation.d.ts.map +1 -1
  341. package/dist/wire/operation.js +4 -15
  342. package/dist/wire/operation.js.map +1 -1
  343. package/dist/wire/signature.d.ts +4 -25
  344. package/dist/wire/signature.d.ts.map +1 -1
  345. package/package.json +3 -3
  346. package/src/boot/AppLifecycle.ts +15 -2
  347. package/src/boot/Emissions.ts +21 -118
  348. package/src/boot/ambient-port.ts +3 -24
  349. package/src/boot/ambient.als.ts +7 -12
  350. package/src/boot/ambient.queue.ts +2 -5
  351. package/src/boot/apply.ts +9 -16
  352. package/src/boot/auth.ts +2 -12
  353. package/src/boot/boot.ts +6 -21
  354. package/src/boot/bootstrap.ts +95 -140
  355. package/src/boot/card.ts +4 -33
  356. package/src/boot/frame.ts +24 -64
  357. package/src/boot/hosted.ts +12 -34
  358. package/src/boot/ownership.ts +5 -39
  359. package/src/boot/ports.ts +1 -14
  360. package/src/boot/remote.ts +11 -58
  361. package/src/boot/runner.ts +5 -22
  362. package/src/boot/seed.ts +6 -37
  363. package/src/boot/statement-drift.ts +5 -24
  364. package/src/boot/together.ts +18 -51
  365. package/src/boot/types.ts +31 -173
  366. package/src/{builtins → builtin}/config.ts +1 -7
  367. package/src/{builtins → builtin}/logger.ts +6 -39
  368. package/src/config-loader.ts +12 -71
  369. package/src/contract.ts +19 -39
  370. package/src/criterion.ts +54 -0
  371. package/src/crypto/encoding.ts +2 -15
  372. package/src/crypto/node.ts +1 -7
  373. package/src/crypto/port.ts +2 -18
  374. package/src/crypto/webcrypto.ts +1 -12
  375. package/src/declare.ts +42 -41
  376. package/src/define.ts +2 -3
  377. package/src/descriptor/Fronds.ts +6 -31
  378. package/src/descriptor/frond.ts +26 -60
  379. package/src/dispatch/ArgumentResolver.ts +6 -6
  380. package/src/dispatch/DispatchEvent.ts +2 -2
  381. package/src/dispatch/DispatchLifecycle.ts +1 -7
  382. package/src/dispatch/DispatchPort.ts +1 -1
  383. package/src/dispatch/Dispatcher.ts +3 -3
  384. package/src/dispatch/HandlerFacade.ts +231 -0
  385. package/src/dispatch/LocalRoutePolicy.ts +4 -4
  386. package/src/dispatch/OperationRoute.ts +2 -2
  387. package/src/dispatch/OutputView.ts +24 -2
  388. package/src/dispatch/Route.ts +2 -2
  389. package/src/dispatch/RoutePolicy.ts +1 -1
  390. package/src/dispatch/RouteRegistry.ts +2 -2
  391. package/src/dispatch/RouteResolver.ts +2 -4
  392. package/src/dispatch/StorageGuard.ts +175 -19
  393. package/src/dispatch/presenterArguments.ts +25 -0
  394. package/src/dispatch/{RemoteRouteResolver.ts → remoteRoutes.ts} +7 -9
  395. package/src/dispatch/routeNotFound.ts +33 -0
  396. package/src/dispatch/validateInput.ts +28 -0
  397. package/src/effective-operation.ts +21 -50
  398. package/src/emit.ts +5 -63
  399. package/src/entry/facade.ts +44 -0
  400. package/src/entry/transport.ts +16 -0
  401. package/src/frond-config.ts +7 -70
  402. package/src/identity-keys.ts +3 -16
  403. package/src/identity.ts +12 -80
  404. package/src/imports.ts +2 -31
  405. package/src/index.ts +17 -24
  406. package/src/loader.ts +2 -16
  407. package/src/node.ts +2 -11
  408. package/src/prefab/collector.ts +1 -22
  409. package/src/prefab/crud.ts +37 -76
  410. package/src/prefab/mirror.ts +4 -44
  411. package/src/prefab/prefab.ts +2 -21
  412. package/src/prefab/presenter.ts +2 -36
  413. package/src/prefab/repository.ts +7 -83
  414. package/src/scan/adapters.ts +32 -0
  415. package/src/scan/bundling.ts +1 -12
  416. package/src/scan/contract.ts +80 -0
  417. package/src/scan/conventions.ts +6 -40
  418. package/src/scan/emit.ts +11 -80
  419. package/src/scan/handler-parser.ts +27 -96
  420. package/src/scan/result.ts +3 -16
  421. package/src/scan/scanner.ts +46 -132
  422. package/src/scan/statement.ts +73 -41
  423. package/src/source.ts +63 -0
  424. package/src/storage.ts +14 -234
  425. package/src/store.ts +191 -0
  426. package/src/verify.ts +16 -57
  427. package/src/wire/CallLog.ts +30 -0
  428. package/src/{contract → wire}/Invocation.ts +24 -17
  429. package/src/{contract → wire}/RouteAddress.ts +7 -0
  430. package/src/wire/binding.ts +9 -25
  431. package/src/wire/call.ts +30 -133
  432. package/src/wire/drift.ts +5 -30
  433. package/src/wire/errors.ts +4 -24
  434. package/src/wire/http-error.ts +5 -19
  435. package/src/wire/loggerMiddleware.ts +2 -8
  436. package/src/wire/middleware.ts +3 -7
  437. package/src/wire/operation.ts +8 -48
  438. package/src/wire/signature.ts +4 -25
  439. package/dist/boot/HandlerFacade.d.ts.map +0 -1
  440. package/dist/boot/HandlerFacade.js.map +0 -1
  441. package/dist/builtins/config.d.ts +0 -13
  442. package/dist/builtins/config.d.ts.map +0 -1
  443. package/dist/builtins/config.js +0 -21
  444. package/dist/builtins/config.js.map +0 -1
  445. package/dist/builtins/logger.d.ts.map +0 -1
  446. package/dist/builtins/logger.js.map +0 -1
  447. package/dist/contract/Call.d.ts +0 -10
  448. package/dist/contract/Call.d.ts.map +0 -1
  449. package/dist/contract/Call.js +0 -15
  450. package/dist/contract/Call.js.map +0 -1
  451. package/dist/contract/CallLog.d.ts +0 -57
  452. package/dist/contract/CallLog.d.ts.map +0 -1
  453. package/dist/contract/Invocation.d.ts +0 -27
  454. package/dist/contract/Invocation.d.ts.map +0 -1
  455. package/dist/contract/Invocation.js +0 -59
  456. package/dist/contract/Invocation.js.map +0 -1
  457. package/dist/contract/RouteAddress.d.ts.map +0 -1
  458. package/dist/contract/RouteAddress.js.map +0 -1
  459. package/dist/dispatch/InputValidator.d.ts +0 -7
  460. package/dist/dispatch/InputValidator.d.ts.map +0 -1
  461. package/dist/dispatch/InputValidator.js +0 -22
  462. package/dist/dispatch/InputValidator.js.map +0 -1
  463. package/dist/dispatch/OperationExecutor.d.ts +0 -25
  464. package/dist/dispatch/OperationExecutor.d.ts.map +0 -1
  465. package/dist/dispatch/OperationExecutor.js +0 -32
  466. package/dist/dispatch/OperationExecutor.js.map +0 -1
  467. package/dist/dispatch/OutputProjector.d.ts +0 -12
  468. package/dist/dispatch/OutputProjector.d.ts.map +0 -1
  469. package/dist/dispatch/OutputProjector.js +0 -30
  470. package/dist/dispatch/OutputProjector.js.map +0 -1
  471. package/dist/dispatch/PresenterArgumentResolver.d.ts +0 -12
  472. package/dist/dispatch/PresenterArgumentResolver.d.ts.map +0 -1
  473. package/dist/dispatch/PresenterArgumentResolver.js +0 -20
  474. package/dist/dispatch/PresenterArgumentResolver.js.map +0 -1
  475. package/dist/dispatch/RemoteRouteResolver.d.ts +0 -13
  476. package/dist/dispatch/RemoteRouteResolver.d.ts.map +0 -1
  477. package/dist/dispatch/RemoteRouteResolver.js.map +0 -1
  478. package/dist/dispatch/RouteNotFoundError.d.ts +0 -10
  479. package/dist/dispatch/RouteNotFoundError.d.ts.map +0 -1
  480. package/dist/dispatch/RouteNotFoundError.js +0 -24
  481. package/dist/dispatch/RouteNotFoundError.js.map +0 -1
  482. package/dist/entry/DynamicFacade.d.ts +0 -10
  483. package/dist/entry/DynamicFacade.d.ts.map +0 -1
  484. package/dist/entry/DynamicFacade.js +0 -27
  485. package/dist/entry/DynamicFacade.js.map +0 -1
  486. package/dist/entry/FacadeEntry.d.ts +0 -11
  487. package/dist/entry/FacadeEntry.d.ts.map +0 -1
  488. package/dist/entry/FacadeEntry.js +0 -26
  489. package/dist/entry/FacadeEntry.js.map +0 -1
  490. package/dist/entry/TransportEntry.d.ts +0 -13
  491. package/dist/entry/TransportEntry.d.ts.map +0 -1
  492. package/dist/entry/TransportEntry.js +0 -24
  493. package/dist/entry/TransportEntry.js.map +0 -1
  494. package/dist/rows.d.ts +0 -40
  495. package/dist/rows.d.ts.map +0 -1
  496. package/dist/rows.js +0 -146
  497. package/dist/rows.js.map +0 -1
  498. package/src/boot/HandlerFacade.ts +0 -242
  499. package/src/contract/Call.ts +0 -18
  500. package/src/contract/CallLog.ts +0 -55
  501. package/src/dispatch/InputValidator.ts +0 -28
  502. package/src/dispatch/OperationExecutor.ts +0 -60
  503. package/src/dispatch/OutputProjector.ts +0 -32
  504. package/src/dispatch/PresenterArgumentResolver.ts +0 -25
  505. package/src/dispatch/RouteNotFoundError.ts +0 -29
  506. package/src/entry/DynamicFacade.ts +0 -28
  507. package/src/entry/FacadeEntry.ts +0 -32
  508. package/src/entry/TransportEntry.ts +0 -30
  509. package/src/rows.ts +0 -155
  510. /package/dist/{contract → wire}/CallLog.js +0 -0
package/dist/source.js ADDED
@@ -0,0 +1,18 @@
1
+ import { Registry, Role } from '@fougere/schema';
2
+ /** Whether an entity asks for one, anywhere but on its key. */
3
+ export function declares(schema, constraint) {
4
+ if (constraint !== 'unique')
5
+ return false;
6
+ if ((schema.getUnique() ?? []).length > 0)
7
+ return true;
8
+ return Object.values(schema.getFields()).some((field) => Role.of(field).isUnique);
9
+ }
10
+ /** Which adapter answers a source name — one per process, no subject to hold. */
11
+ class SourceRegistry extends Registry {
12
+ /** The source this name stands for, built from the config entry that named it. */
13
+ open(name, conf, path) {
14
+ return this.resolve(name, path)(conf);
15
+ }
16
+ }
17
+ export const Sources = new SourceRegistry('source', 'import the adapter that answers it, or call Sources.register(name, build)');
18
+ //# sourceMappingURL=source.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"source.js","sourceRoot":"","sources":["../src/source.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAmB,MAAM,iBAAiB,CAAC;AAMlE,+DAA+D;AAC/D,MAAM,UAAU,QAAQ,CAAC,MAAkB,EAAE,UAAsB;IACjE,IAAI,UAAU,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC1C,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IAEvD,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,CAAC;AACpF,CAAC;AAuCD,iFAAiF;AACjF,MAAM,cAAe,SAAQ,QAAwC;IACnE,kFAAkF;IAClF,IAAI,CAAC,IAAY,EAAE,IAAkB,EAAE,IAAa;QAClD,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;IACxC,CAAC;CACF;AAED,MAAM,CAAC,MAAM,OAAO,GAAG,IAAI,cAAc,CACvC,QAAQ,EACR,2EAA2E,CAC5E,CAAC"}
package/dist/storage.d.ts CHANGED
@@ -16,9 +16,8 @@ export interface ListOptions {
16
16
  /** If true, also returns total count (for pagination UIs). */
17
17
  count?: boolean;
18
18
  /**
19
- * Equality criteria, field by field — `{ orderId: '…' }`. Named rather than spread
20
- * across the options so an unknown key stays ignored instead of silently becoming a
21
- * filter. `listBy(criteria)` is the same thing said as an intention.
19
+ * Equality criteria, field by field — `{ orderId: '…' }`. Named rather than spread across the
20
+ * options so an unknown key stays ignored instead of silently becoming a filter.
22
21
  */
23
22
  where?: Record<string, unknown>;
24
23
  }
@@ -42,83 +41,27 @@ export interface Storage<T = Record<string, unknown>> {
42
41
  list(options?: ListOptions & SelectOption): Promise<ListResult<T>>;
43
42
  findById(id: string, options?: SelectOption): Promise<T | undefined>;
44
43
  /**
45
- * Read by criteria — `findBy({ email })` for the one, `findAllBy({ orderId })` for the
46
- * many, which is what a one-to-many relation *is*.
47
- *
48
- * Both existed on the SQL implementation from the start and neither was declared here.
49
- * A port that hides what it offers is a port nobody can use: `auth-better` cast its way
50
- * in (`storage as StorageWithFindBy`), a presenter that needed the lines of an order read the
51
- * whole table instead, and the GraphQL relation resolver passed criteria to `list()`
52
- * — which drops what it does not know.
44
+ * Read by criteria — `findBy({ email })` for the one, `findAllBy({ orderId })` for the many,
45
+ * which is what a one-to-many relation *is*.
53
46
  */
54
47
  findBy(criteria: Partial<T> | Record<string, unknown>, options?: SelectOption): Promise<T | undefined>;
55
48
  findAllBy(criteria: Partial<T> | Record<string, unknown>, options?: SelectOption): Promise<T[]>;
56
49
  /**
57
- * Read a SET of rows by their key, in one go — the gesture every other one was
58
- * being bent into.
59
- *
60
- * `findAllBy` compares with `=`, so a list of ids could not be passed to it; the
61
- * only way to read N rows was `list()` then filter in memory, which is what 14 of
62
- * 14 handlers of a real app measured on 2026-08-14 were doing. It is invisible on
63
- * SQLite and it is the whole table the day the rows are not local.
64
- *
65
- * It answers a MAP, because the caller holds keys and not positions: a page zips
66
- * against it by `get(row.authorId)`, a miss is the absence of a key, and a repeated
67
- * key is one entry. The list form this replaced promised that zip and could not
68
- * keep it — dropping a miss shifts every later position — so each caller rebuilt
69
- * the very index the implementation had just thrown away.
50
+ * Read a SET of rows by their key, in one go — the gesture every other one was being bent into.
70
51
  */
71
52
  findByKeys(ids: readonly string[], options?: SelectOption): Promise<Map<string, T>>;
72
- /**
73
- * Its dual: the rows that point AT each of these keys, grouped by the one they point at.
74
- *
75
- * `findByKeys` answers the side a row designates — one each, at most. This answers the
76
- * side that designates the row — several each, and a key with none is simply absent.
77
- * Together they are both directions of a relation, each in one query.
78
- *
79
- * Written because the page-shaped gesture only covered one of them: a presenter holding
80
- * its page and wanting "the items of these lists" had no vocabulary for it and read the
81
- * whole table instead, measured on a real app. `field` names the foreign key on THIS
82
- * entity, the one carrying the value.
83
- */
53
+ /** The dual of `findByKeys`: many rows per key, not one. */
84
54
  findAllByKeys(field: string, keys: readonly string[], options?: SelectOption): Promise<Map<string, T[]>>;
85
55
  create(input: Partial<T>, options?: SelectOption): Promise<T>;
86
- /**
87
- * Write the row, or make the existing one look like this — one statement.
88
- *
89
- * What an import needs and the port did not have: `create` throws on the second run,
90
- * so re-reading a source meant deleting first. Measured pulling an API twice.
91
- *
92
- * The key and the creation stamps survive an overwrite — a row keeps the moment it
93
- * appeared. An engine with no upsert clause refuses by name rather than emulating
94
- * one with a read in front, which would promise an atomicity it has not got.
95
- */
56
+ /** Write the row, or make the existing one look like this — one statement. */
96
57
  upsert(input: Partial<T>, options?: SelectOption): Promise<T>;
97
- /**
98
- * A whole page in one statement — what an import writes through.
99
- *
100
- * Row by row, 500 rows were 500 statements (measured); the shape of an import is a
101
- * page, so the write is one too. Answers how many rows were written rather than the
102
- * rows: `create` hands back the complete row because a caller acts on it, and an
103
- * import acts on none of them — re-reading a page for a symmetry nobody uses would
104
- * double the work.
105
- */
58
+ /** A whole page in one statement — what an import writes through. */
106
59
  upsertAll(inputs: readonly Partial<T>[], options?: SelectOption): Promise<number>;
107
60
  update(id: string, input: Partial<T>, options?: SelectOption): Promise<T>;
108
61
  delete(id: string): Promise<boolean>;
109
62
  /** Returns a scoped storage that restricts all read results to the fields of the given schema. */
110
63
  output(schema: SchemaView): Storage<T>;
111
- /**
112
- * What this storage wraps — the Kysely instance for the SQL one, something else elsewhere.
113
- *
114
- * Every judge sits on the storage's own methods, so a statement issued here meets none of
115
- * them: a value the entity refuses lands in the table without a word. It is the port's
116
- * own escape hatch rather than a handle on the side, so it keeps the scope the container
117
- * gave you — `productStorage.client` reaches the products, not the whole database.
118
- *
119
- * `unknown` on purpose: the client belongs to the implementation, and narrowing it is
120
- * the caller saying out loud which one they are standing on.
121
- */
64
+ /** What this storage wraps — the Kysely instance for the SQL one, something else elsewhere. */
122
65
  readonly client: unknown;
123
66
  }
124
67
  /**
@@ -126,139 +69,11 @@ export interface Storage<T = Record<string, unknown>> {
126
69
  * Called by bootstrap for every scanned entity.
127
70
  */
128
71
  export type StorageFactory = (entity: SchemaView, name: string) => Storage;
129
- /**
130
- * A place rows live, whatever realizes it.
131
- *
132
- * `StorageFactory` plus its lifecycle, which is why it lives beside it. Three of the four
133
- * gestures are optional and ABSENCE IS THE ANSWER: no `transacted` and a frame compensates
134
- * instead of transacting (`boot/together.ts`), no `migrate` and there is no shape to bring
135
- * up to date. What a source is MADE OF is not here — `adapter/sql` states `dialect`, `db`
136
- * and `sink` on its own `SqlSource`, reached by narrowing, the rule {@link Storage.client}
137
- * already obeys one level down.
138
- */
139
- export interface Source {
140
- storageFactory: StorageFactory;
141
- /** Bring the shape of what lives here up to date. */
142
- migrate?(view: SourceView): Promise<void>;
143
- /** Run `fn` as ONE unit of work, with a factory bound to it. */
144
- transacted?<R>(fn: (factory: StorageFactory) => Promise<R>): Promise<R>;
145
- close?(): Promise<void>;
146
- /** What distinguishes it when a query is reported. */
147
- name?: string;
148
- }
149
- /**
150
- * The app as ONE source sees it: what lives there, and the NAMES of what does not.
151
- *
152
- * The second half is what lets a DDL stop lying. A batch holding every entity cannot tell
153
- * a cross-source target from a typo, so a `ref()` falls back to a derived table name and
154
- * the constraint is emitted against a table that may not exist. `elsewhere` says which
155
- * misses are legitimate — and a target in neither list is a mistake, out loud.
156
- */
157
- export interface SourceView {
158
- fronds: readonly {
159
- readonly name: string;
160
- readonly entities: readonly {
161
- readonly name: string;
162
- }[];
163
- }[];
164
- /** The auth provider's own entities, when they ride with this source. */
165
- auth?: unknown;
166
- elsewhere: readonly string[];
167
- }
168
- /**
169
- * What a config file can carry about a source — values, never a live driver.
170
- *
171
- * `source` names the ADAPTER, and everything else belongs to the adapter it named:
172
- * `adapter/sql` reads `dialect`, a file one reads `path`. That is the shape
173
- * `EntityAdapters` already has — addressed by adapter, and what sits below is the
174
- * adapter's own. Which is why the level `schema` owns is not repeated here.
175
- */
176
- export interface SourceConfig {
177
- /** The adapter that realizes it. Absent means the conventional one. */
178
- source?: string;
179
- /** The entities whose rows live here. Absent on the default source: it holds the rest. */
180
- entities?: string[];
181
- [key: string]: unknown;
182
- }
183
- /**
184
- * Which adapter answers a source name — one per process, no subject to hold.
185
- *
186
- * The shape `Generators` already has, and the refusal `resolveStorage` already made: only
187
- * `sqlite` could be resolved from its name, because it was the one driver `defaults`
188
- * depended on. That refusal had no owner — it lived in the package that happened to import
189
- * the driver — so a second adapter had nowhere to say it exists. Here it does, and an
190
- * unknown name is refused naming what this process answers.
191
- *
192
- * Registered at IMPORT by each adapter, so nothing central lists them.
193
- */
194
- export declare class Sources {
195
- private static readonly registry;
196
- static register(name: string, build: (conf: SourceConfig) => Source): void;
197
- /** The source this name stands for, refused by name when nothing does. */
198
- static resolve(name: string, conf: SourceConfig): Source;
199
- /** Whether a name is answered, for a caller that must not throw to find out. */
200
- static answers(name: string): boolean;
201
- /** What this process answers — what a refusal elsewhere prints. */
202
- static answered(): string[];
203
- }
204
- /**
205
- * Container key of an entity's storage — 'reading' → 'ReadingStorage'.
206
- *
207
- * The twin of {@link repositoryKeyOf} and of `facadeKeyOf`: the key of a thing
208
- * lives with the thing. This one was spelled by hand in four places in
209
- * `bootstrap.ts` and a fifth in `scanner.ts` — where the SCAN derives what a
210
- * constructor asks for. Two readers of one convention, neither of them naming it,
211
- * so a rename would have moved one and left the other resolving to nothing.
212
- */
72
+ /** Container key of an entity's storage — 'reading' → 'ReadingStorage'. */
213
73
  export declare function storageKeyOf(entity: string): string;
214
- /**
215
- * The entity behind a storage key, or `undefined` when the key is not one.
216
- *
217
- * The dual of the line above, for the reason `membersOfTogetherKey` is. `known` is what the
218
- * suffix alone cannot answer: `FileStorage` is an ordinary class name.
219
- */
74
+ /** The entity behind a storage key, or `undefined` when the key is not one. */
220
75
  export declare function entityOfStorageKey(key: string, known: (entity: string) => boolean): string | undefined;
221
- /**
222
- * `Together<[Account, Ledger]>` — writes that stand or fall as one.
223
- *
224
- * `Storage` is the port whose every gesture is ONE statement, and one statement is
225
- * atomic in every engine. This is the port whose unit is a BLOCK: what the callback did
226
- * happens entirely, or not at all. Nothing else separates them — the arity of the unit
227
- * of work is the whole distinction, which is why this lives here and not in a file of
228
- * its own.
229
- *
230
- * ```ts
231
- * constructor(private together: Together<[Account, Ledger]>) {}
232
- *
233
- * await this.together.run(async ([accounts, ledger]) => {
234
- * await accounts.update(from, { balance: b - amount });
235
- * await ledger.create({ from, to, amount });
236
- * });
237
- * ```
238
- *
239
- * **The second list is providers**, rebuilt inside the frame so that what THEY write is
240
- * covered too — a `Mirror` writes its pages through `Storage<T>`, so naming it puts
241
- * them under the same unwind, with no locator and no second injection path:
242
- *
243
- * ```ts
244
- * constructor(private together: Together<[RateCard, Ledger], [RateMirror]>) {}
245
- *
246
- * await this.together.run(async ([rates, ledger], [mirror]) => { await mirror.refresh(); });
247
- * ```
248
- *
249
- * Two lists rather than one, because in a signature an entity and a provider are both
250
- * written as a class name and their instance types do not separate them — the type would
251
- * have to guess, by looking for methods or for a brand, and both answers are worse than
252
- * saying it. They are two different facts anyway: what the unwind covers, and what is
253
- * rebuilt to make that true.
254
- *
255
- * **All or nothing is the promise; isolation is not.** On one engine the members are
256
- * rebuilt over a transaction and the engine gives both. Across engines a transaction
257
- * cannot exist, so the frame keeps the before-image of each write and replays the
258
- * inverse in reverse order — the unwind holds, the isolation does not, and a reader
259
- * between two writes sees the half. The boot says which of the two it built rather
260
- * than letting the author assume the stronger one.
261
- */
76
+ /** `Together<[Account, Ledger]>` — writes that stand or fall as one. */
262
77
  export interface Together<E extends readonly unknown[], P extends readonly unknown[] = []> {
263
78
  run<R>(fn: (entities: {
264
79
  [K in keyof E]: Storage<E[K]>;
@@ -267,21 +82,9 @@ export interface Together<E extends readonly unknown[], P extends readonly unkno
267
82
  /**
268
83
  * The container key of a frame — `[['Account', 'Ledger'], ['RateMirror']]` →
269
84
  * 'Account+Ledger|RateMirrorTogether'.
270
- *
271
- * The DECLARED order, not a sorted one. The tuples are what the callback destructures, so
272
- * reordering here would hand `[ledger, accounts]` to a signature that says the opposite —
273
- * the type and the runtime disagreeing about the same line. Two orders of one frame are
274
- * therefore two keys and two registrations; they cost nothing, a frame holding no state
275
- * between runs.
276
85
  */
277
86
  export declare function togetherKeyOf(entities: readonly string[], providers?: readonly string[]): string;
278
- /**
279
- * The members behind a frame key, or `undefined` when the key is not one.
280
- *
281
- * The dual of the line above, and here for the reason `factOfEmitKey` is: the boot reads
282
- * the key back out of a handler's `deps` to know which frames to build. A key and the way
283
- * to undo it belong together — the pair that is split is the pair that drifts.
284
- */
87
+ /** The members behind a frame key, or `undefined` when the key is not one. */
285
88
  export declare function membersOfTogetherKey(key: string): {
286
89
  entities: string[];
287
90
  providers: string[];
@@ -1 +1 @@
1
- {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0B,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE1E,gEAAgE;AAChE,MAAM,WAAW,WAAW;IAC1B,mCAAmC;IACnC,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,oCAAoC;IACpC,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,0DAA0D;IAC1D,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,iDAAiD;IACjD,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,8BAA8B;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,uCAAuC;IACvC,KAAK,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;IAEvB,8DAA8D;IAC9D,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC;AAED,oEAAoE;AACpE,MAAM,WAAW,UAAU,CAAC,CAAC,CAAE,SAAQ,KAAK,CAAC,CAAC,CAAC;IAC7C,oEAA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saying so is the point:
4
- * the façade refuses an unknown key in a CLIENT's input (`Unknown field`) — this applies the
5
- * same rule to the framework's own arguments. `list({ orderId })` used to be accepted and
6
- * the filter dropped, so a one-to-many relation quietly returned the whole table.
7
- */
2
+ /** The keys `list()` answers to. */
8
3
  const LIST_OPTION_KEYS = [
9
4
  'limit', 'offset', 'page', 'after', 'orderBy', 'order', 'count', 'where', 'select',
10
5
  ];
@@ -19,58 +14,11 @@ export function assertListOptions(options, entity) {
19
14
  throw new Error(`${entity}.list(): unknown option ${strangers.map((s) => `\`${s}\``).join(', ')}. ` +
20
15
  `Known options are ${LIST_OPTION_KEYS.join(', ')} — to filter, pass \`where: { ${strangers[0]}: … }\`.`);
21
16
  }
22
- /**
23
- * Which adapter answers a source name — one per process, no subject to hold.
24
- *
25
- * The shape `Generators` already has, and the refusal `resolveStorage` already made: only
26
- * `sqlite` could be resolved from its name, because it was the one driver `defaults`
27
- * depended on. That refusal had no owner — it lived in the package that happened to import
28
- * the driver — so a second adapter had nowhere to say it exists. Here it does, and an
29
- * unknown name is refused naming what this process answers.
30
- *
31
- * Registered at IMPORT by each adapter, so nothing central lists them.
32
- */
33
- export class Sources {
34
- static registry = new Map();
35
- static register(name, build) {
36
- this.registry.set(name, build);
37
- }
38
- /** The source this name stands for, refused by name when nothing does. */
39
- static resolve(name, conf) {
40
- const build = this.registry.get(name);
41
- if (build)
42
- return build(conf);
43
- throw new Error(`Unknown source '${name}' — import the adapter that answers it, or register one with `
44
- + `Sources.register('${name}', build). This process answers `
45
- + `${[...this.registry.keys()].join(', ') || 'nothing yet'}.`);
46
- }
47
- /** Whether a name is answered, for a caller that must not throw to find out. */
48
- static answers(name) {
49
- return this.registry.has(name);
50
- }
51
- /** What this process answers — what a refusal elsewhere prints. */
52
- static answered() {
53
- return [...this.registry.keys()];
54
- }
55
- }
56
- /**
57
- * Container key of an entity's storage — 'reading' → 'ReadingStorage'.
58
- *
59
- * The twin of {@link repositoryKeyOf} and of `facadeKeyOf`: the key of a thing
60
- * lives with the thing. This one was spelled by hand in four places in
61
- * `bootstrap.ts` and a fifth in `scanner.ts` — where the SCAN derives what a
62
- * constructor asks for. Two readers of one convention, neither of them naming it,
63
- * so a rename would have moved one and left the other resolving to nothing.
64
- */
17
+ /** Container key of an entity's storage — 'reading' → 'ReadingStorage'. */
65
18
  export function storageKeyOf(entity) {
66
19
  return `${upperFirst(entity)}${HELD}`;
67
20
  }
68
- /**
69
- * The entity behind a storage key, or `undefined` when the key is not one.
70
- *
71
- * The dual of the line above, for the reason `membersOfTogetherKey` is. `known` is what the
72
- * suffix alone cannot answer: `FileStorage` is an ordinary class name.
73
- */
21
+ /** The entity behind a storage key, or `undefined` when the key is not one. */
74
22
  export function entityOfStorageKey(key, known) {
75
23
  if (key.length <= HELD.length || !key.endsWith(HELD))
76
24
  return undefined;
@@ -82,12 +30,6 @@ const HELD = 'Storage';
82
30
  /**
83
31
  * The container key of a frame — `[['Account', 'Ledger'], ['RateMirror']]` →
84
32
  * 'Account+Ledger|RateMirrorTogether'.
85
- *
86
- * The DECLARED order, not a sorted one. The tuples are what the callback destructures, so
87
- * reordering here would hand `[ledger, accounts]` to a signature that says the opposite —
88
- * the type and the runtime disagreeing about the same line. Two orders of one frame are
89
- * therefore two keys and two registrations; they cost nothing, a frame holding no state
90
- * between runs.
91
33
  */
92
34
  export function togetherKeyOf(entities, providers = []) {
93
35
  const named = entities.map(upperFirst).join(SEPARATOR);
@@ -97,13 +39,7 @@ const FRAME = 'Together';
97
39
  const SEPARATOR = '+';
98
40
  /** Separates the two lists — what the unwind covers, and what is rebuilt to make it true. */
99
41
  const KINDS = '|';
100
- /**
101
- * The members behind a frame key, or `undefined` when the key is not one.
102
- *
103
- * The dual of the line above, and here for the reason `factOfEmitKey` is: the boot reads
104
- * the key back out of a handler's `deps` to know which frames to build. A key and the way
105
- * to undo it belong together — the pair that is split is the pair that drifts.
106
- */
42
+ /** The members behind a frame key, or `undefined` when the key is not one. */
107
43
  export function membersOfTogetherKey(key) {
108
44
  if (key.length <= FRAME.length || !key.endsWith(FRAME))
109
45
  return undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"storage.js","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAmB,MAAM,iBAAiB,CAAC;AA2C1E;;;;;GAKG;AACH,MAAM,gBAAgB,GAAG;IACvB,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ;CAC1E,CAAC;AAEX,qFAAqF;AACrF,MAAM,UAAU,iBAAiB,CAAC,OAA2B,EAAE,MAAc;IAC3E,IAAI,CAAC,OAAO;QAAE,OAAO;IACrB,MAAM,KAAK,GAAG,IAAI,GAAG,CAAS,gBAAgB,CAAC,CAAC;IAChD,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;IACxE,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO;IACnC,MAAM,IAAI,KAAK,CACb,GAAG,MAAM,2BAA2B,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI;QACnF,qBAAqB,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,iCAAiC,SAAS,CAAC,CAAC,CAAC,UAAU,CACxG,CAAC;AACJ,CAAC;AAsJD;;;;;;;;;;GAUG;AACH,MAAM,OAAO,OAAO;IACV,MAAM,CAAU,QAAQ,GAAG,IAAI,GAAG,EAA0C,CAAC;IAErF,MAAM,CAAC,QAAQ,CAAC,IAAY,EAAE,KAAqC;QACjE,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,EAAE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AE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACtE,OAAO,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAS,CAAC,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,EAAE,CAAC;AACrE,CAAC"}
@@ -0,0 +1,18 @@
1
+ /** The thirteen gestures of {@link Storage}, derived from four. */
2
+ import { type SchemaView } from '@fougere/schema';
3
+ import type { StorageFactory } from './storage.js';
4
+ /** One instance, as every realization hands it over. */
5
+ export type Values = Record<string, unknown>;
6
+ /** Instances addressed by key — what an adapter supplies, and all of it. */
7
+ export interface Store {
8
+ get(key: string): Promise<Values | undefined>;
9
+ has(key: string): Promise<boolean>;
10
+ set(key: string, values: Values): Promise<void>;
11
+ delete(key: string): Promise<boolean>;
12
+ /** Everything it holds. A realization that cannot answer this cheaply says so in its doc. */
13
+ all(): Promise<Values[]>;
14
+ /** Handed on as `Storage.client` — the Map, the directory, whatever it is. */
15
+ readonly client: unknown;
16
+ }
17
+ export declare function storageOver(open: (entity: SchemaView, name: string) => Store): StorageFactory;
18
+ //# sourceMappingURL=store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../src/store.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,OAAO,EAA6C,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7F,OAAO,KAAK,EAAW,cAAc,EAAE,MAAM,cAAc,CAAC;AAE5D,wDAAwD;AACxD,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE7C,4EAA4E;AAC5E,MAAM,WAAW,KAAK;IACpB,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IAC9C,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACnC,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAChD,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACtC,6FAA6F;IAC7F,GAAG,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IACzB,8EAA8E;IAC9E,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;CAC1B;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,KAAK,KAAK,GAAG,cAAc,CA0I7F"}
package/dist/store.js ADDED
@@ -0,0 +1,179 @@
1
+ /** The thirteen gestures of {@link Storage}, derived from four. */
2
+ import { applyCreate, applyUpdate, Lifecycle, Role } from '@fougere/schema';
3
+ import { comparisonOf, comparisonsIn } from './criterion.js';
4
+ export function storageOver(open) {
5
+ return (entity, name) => {
6
+ const fields = entity.getFields();
7
+ const store = open(entity, name);
8
+ const pk = Object.entries(fields).find(([, field]) => Role.of(field).isPrimary)?.[0] ?? 'id';
9
+ // `Storage.findById(id: string)` — but a key can hold a number, and a Map keyed on
10
+ // `1` does not answer `'1'`. SQL never had the question; here the divergence was
11
+ // silent and only on this storage.
12
+ const keyOf = (value) => String(value);
13
+ // Same contract as SQL: a criterion may name a SET, and an empty set matches nothing.
14
+ // A comparison is told from a value by the FIELD, never by the criterion's own shape.
15
+ const matches = (values, criteria) => Object.entries(criteria).every(([key, value]) => {
16
+ const comparison = comparisonOf(fields[key], value);
17
+ if (comparison)
18
+ return compares(values[key], comparison);
19
+ return Array.isArray(value)
20
+ ? value.some((v) => Object.is(values[key], v))
21
+ : Object.is(values[key], value);
22
+ });
23
+ // A store holds whole instances and reads them whole, so the scope SQL puts in its
24
+ // SELECT is applied here on the way out. Same set of gestures either way: everything
25
+ // that hands back an instance, which leaves `delete` and `upsertAll` alone.
26
+ const scoped = (selected) => {
27
+ const pick = (values) => (selected
28
+ ? Object.fromEntries(Object.entries(values).filter(([key]) => selected.has(key)))
29
+ : values);
30
+ return {
31
+ client: store.client,
32
+ async list(options) {
33
+ let items = await store.all();
34
+ if (options?.where)
35
+ items = items.filter((values) => matches(values, options.where));
36
+ // Held before the page is cut, and after the filter: `total` answers "how many
37
+ // match", which is what a paginator divides. Reading `store.size` at the end
38
+ // answered a different question — everything the store holds, including the ones
39
+ // the filter exists to keep out of this caller's sight.
40
+ const matching = items.length;
41
+ const limit = options?.limit;
42
+ const offset = options?.page && limit ? (options.page - 1) * limit : options?.offset ?? 0;
43
+ if (offset > 0)
44
+ items = items.slice(offset);
45
+ const hasMore = limit ? items.length > limit : false;
46
+ if (limit)
47
+ items = items.slice(0, limit);
48
+ // The cursor is read before the scope cuts: a view that drops the key still
49
+ // pages, the way it does over SQL.
50
+ const endCursor = items.length > 0 ? String(items[items.length - 1][pk] ?? '') : undefined;
51
+ const result = items.map(pick);
52
+ result.hasMore = hasMore;
53
+ result.endCursor = endCursor;
54
+ if (options?.count)
55
+ result.total = matching;
56
+ return result;
57
+ },
58
+ async findById(id) {
59
+ const values = await store.get(keyOf(id));
60
+ return values && pick(values);
61
+ },
62
+ async findBy(criteria) {
63
+ const values = (await store.all()).find((held) => matches(held, criteria));
64
+ return values && pick(values);
65
+ },
66
+ async findAllBy(criteria) {
67
+ return (await store.all()).filter((values) => matches(values, criteria)).map(pick);
68
+ },
69
+ // Same contract as SQL: a map keyed by the primary key, a miss being an absent key.
70
+ async findByKeys(ids) {
71
+ const found = new Map();
72
+ for (const id of ids) {
73
+ const values = await store.get(keyOf(id));
74
+ if (values)
75
+ found.set(String(id), pick(values));
76
+ }
77
+ return found;
78
+ },
79
+ // The dual, same contract as SQL: grouped by the value read off the instance.
80
+ async findAllByKeys(field, keys) {
81
+ const grouped = new Map();
82
+ if (keys.length === 0)
83
+ return grouped;
84
+ const wanted = new Set(keys.map(String));
85
+ for (const values of await store.all()) {
86
+ const key = String(values[field]);
87
+ if (!wanted.has(key))
88
+ continue;
89
+ const bucket = grouped.get(key);
90
+ if (bucket)
91
+ bucket.push(pick(values));
92
+ else
93
+ grouped.set(key, [pick(values)]);
94
+ }
95
+ return grouped;
96
+ },
97
+ // Same contract as SQL: the key and the creation stamps survive an overwrite.
98
+ async upsert(input) {
99
+ const values = applyCreate(fields, applyUpdate(fields, input));
100
+ const id = values[pk];
101
+ if (id === undefined)
102
+ throw new Error(`${name}.upsert(): no \`${pk}\` — an upsert needs the key it writes at.`);
103
+ const previous = await store.get(keyOf(id));
104
+ if (previous) {
105
+ for (const [key, field] of Object.entries(fields)) {
106
+ if (key === pk || Lifecycle.of(field).stampedOnce)
107
+ values[key] = previous[key];
108
+ }
109
+ }
110
+ await store.set(keyOf(id), values);
111
+ return pick(values);
112
+ },
113
+ async upsertAll(inputs) {
114
+ for (const input of inputs)
115
+ await this.upsert(input);
116
+ return inputs.length;
117
+ },
118
+ async create(input) {
119
+ const values = applyCreate(fields, input);
120
+ const id = values[pk];
121
+ // `primary(text())` declares no generator, so nothing fills the hole and the
122
+ // caller has to. Keying on `undefined` would let the second create overwrite the
123
+ // first, in silence — the old version hid this by inventing an `id` field the
124
+ // entity never declared.
125
+ if (id === undefined) {
126
+ throw new Error(`${name}.create: '${pk}' is the primary key and nothing supplied it — this entity declares no generator for it.`);
127
+ }
128
+ // A create is not an upsert. `Map.set` overwrites, so a second create under the
129
+ // same key answered "created" while destroying the previous instance — SQL answers a
130
+ // constraint violation, and a store that loses data silently is worse than one
131
+ // that fails.
132
+ if (await store.has(keyOf(id))) {
133
+ throw new Error(`${name}.create: '${pk}' ${JSON.stringify(id)} already exists.`);
134
+ }
135
+ await store.set(keyOf(id), values);
136
+ return pick(values);
137
+ },
138
+ async update(id, input) {
139
+ const existing = await store.get(keyOf(id));
140
+ if (!existing)
141
+ throw new Error(`Not found: ${id}`);
142
+ const updated = { ...existing, ...applyUpdate(fields, input), [pk]: existing[pk] };
143
+ await store.set(keyOf(id), updated);
144
+ return pick(updated);
145
+ },
146
+ async delete(id) { return await store.delete(keyOf(id)); },
147
+ output(schema) { return scoped(new Set(Object.keys(schema.getFields()))); },
148
+ };
149
+ };
150
+ return scoped();
151
+ };
152
+ }
153
+ /**
154
+ * The same comparisons SQL compiles, answered in memory. Every one a criterion names has
155
+ * to hold — the rule two criteria already follow.
156
+ */
157
+ function compares(held, comparison) {
158
+ return comparisonsIn(comparison).every(([name, asked]) => {
159
+ switch (name) {
160
+ case 'gte': return ordered(held, asked, (a, b) => a >= b);
161
+ case 'lte': return ordered(held, asked, (a, b) => a <= b);
162
+ case 'gt': return ordered(held, asked, (a, b) => a > b);
163
+ case 'lt': return ordered(held, asked, (a, b) => a < b);
164
+ case 'ne': return !Object.is(held, asked);
165
+ case 'contains': return String(held ?? '').includes(String(asked));
166
+ case 'notIn': return !asked.some((one) => Object.is(held, one));
167
+ case 'isNull': return (held === null || held === undefined) === Boolean(asked);
168
+ case 'between': {
169
+ const [low, high] = asked;
170
+ return ordered(held, low, (a, b) => a >= b) && ordered(held, high, (a, b) => a <= b);
171
+ }
172
+ }
173
+ });
174
+ }
175
+ /** A row that holds nothing compares to nothing — the answer SQL gives for NULL. */
176
+ const ordered = (held, asked, holds) => held === null || held === undefined ? false : holds(order(held), order(asked));
177
+ /** What a Date and a number have in common, and a string keeps for itself. */
178
+ const order = (value) => value instanceof Date ? value.getTime() : value;
179
+ //# sourceMappingURL=store.js.map