@fougere/core 0.2.0-alpha.2 → 0.4.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 (500) hide show
  1. package/README.md +3 -2
  2. package/dist/boot/AppLifecycle.d.ts +18 -0
  3. package/dist/boot/AppLifecycle.d.ts.map +1 -0
  4. package/dist/boot/AppLifecycle.js +42 -0
  5. package/dist/boot/AppLifecycle.js.map +1 -0
  6. package/dist/boot/Emissions.d.ts +126 -0
  7. package/dist/boot/Emissions.d.ts.map +1 -0
  8. package/dist/boot/Emissions.js +233 -0
  9. package/dist/boot/Emissions.js.map +1 -0
  10. package/dist/boot/HandlerFacade.d.ts +72 -0
  11. package/dist/boot/HandlerFacade.d.ts.map +1 -0
  12. package/dist/boot/HandlerFacade.js +174 -0
  13. package/dist/boot/HandlerFacade.js.map +1 -0
  14. package/dist/boot/Lifecycle.d.ts +4 -0
  15. package/dist/boot/Lifecycle.d.ts.map +1 -0
  16. package/dist/boot/Lifecycle.js +3 -0
  17. package/dist/boot/Lifecycle.js.map +1 -0
  18. package/dist/boot/ambient-port.d.ts +38 -0
  19. package/dist/boot/ambient-port.d.ts.map +1 -0
  20. package/dist/boot/ambient-port.js +2 -0
  21. package/dist/boot/ambient-port.js.map +1 -0
  22. package/dist/boot/ambient.als.d.ts +3 -0
  23. package/dist/boot/ambient.als.d.ts.map +1 -0
  24. package/dist/boot/ambient.als.js +34 -0
  25. package/dist/boot/ambient.als.js.map +1 -0
  26. package/dist/boot/ambient.queue.d.ts +10 -0
  27. package/dist/boot/ambient.queue.d.ts.map +1 -0
  28. package/dist/boot/ambient.queue.js +60 -0
  29. package/dist/boot/ambient.queue.js.map +1 -0
  30. package/dist/boot/apply.d.ts +22 -0
  31. package/dist/boot/apply.d.ts.map +1 -0
  32. package/dist/boot/apply.js +38 -0
  33. package/dist/boot/apply.js.map +1 -0
  34. package/dist/boot/auth.d.ts +53 -0
  35. package/dist/boot/auth.d.ts.map +1 -0
  36. package/dist/boot/auth.js +2 -0
  37. package/dist/boot/auth.js.map +1 -0
  38. package/dist/{binding.d.ts → boot/binding.d.ts} +14 -17
  39. package/dist/boot/binding.d.ts.map +1 -0
  40. package/dist/{binding.js → boot/binding.js} +19 -10
  41. package/dist/boot/binding.js.map +1 -0
  42. package/dist/{boot.d.ts → boot/boot.d.ts} +25 -5
  43. package/dist/boot/boot.d.ts.map +1 -0
  44. package/dist/boot/boot.js +70 -0
  45. package/dist/boot/boot.js.map +1 -0
  46. package/dist/boot/bootstrap.d.ts.map +1 -0
  47. package/dist/boot/bootstrap.js +722 -0
  48. package/dist/boot/bootstrap.js.map +1 -0
  49. package/dist/boot/frame.d.ts +44 -0
  50. package/dist/boot/frame.d.ts.map +1 -0
  51. package/dist/boot/frame.js +172 -0
  52. package/dist/boot/frame.js.map +1 -0
  53. package/dist/boot/ownership.d.ts +42 -0
  54. package/dist/boot/ownership.d.ts.map +1 -0
  55. package/dist/boot/ownership.js +127 -0
  56. package/dist/boot/ownership.js.map +1 -0
  57. package/dist/boot/ports.d.ts +17 -0
  58. package/dist/boot/ports.d.ts.map +1 -0
  59. package/dist/boot/ports.js +57 -0
  60. package/dist/boot/ports.js.map +1 -0
  61. package/dist/{remote.d.ts → boot/remote.d.ts} +11 -3
  62. package/dist/boot/remote.d.ts.map +1 -0
  63. package/dist/{remote.js → boot/remote.js} +26 -28
  64. package/dist/boot/remote.js.map +1 -0
  65. package/dist/{seed.d.ts → boot/seed.d.ts} +13 -1
  66. package/dist/boot/seed.d.ts.map +1 -0
  67. package/dist/{seed.js → boot/seed.js} +24 -3
  68. package/dist/boot/seed.js.map +1 -0
  69. package/dist/boot/together.d.ts +26 -0
  70. package/dist/boot/together.d.ts.map +1 -0
  71. package/dist/boot/together.js +163 -0
  72. package/dist/boot/together.js.map +1 -0
  73. package/dist/boot/types.d.ts +260 -0
  74. package/dist/boot/types.d.ts.map +1 -0
  75. package/dist/boot/types.js.map +1 -0
  76. package/dist/builtins/config.d.ts +9 -0
  77. package/dist/builtins/config.d.ts.map +1 -1
  78. package/dist/builtins/config.js +16 -1
  79. package/dist/builtins/config.js.map +1 -1
  80. package/dist/builtins/logger.d.ts +37 -4
  81. package/dist/builtins/logger.d.ts.map +1 -1
  82. package/dist/builtins/logger.js +66 -7
  83. package/dist/builtins/logger.js.map +1 -1
  84. package/dist/config-loader.d.ts +39 -35
  85. package/dist/config-loader.d.ts.map +1 -1
  86. package/dist/config-loader.js +15 -54
  87. package/dist/config-loader.js.map +1 -1
  88. package/dist/contract/Call.d.ts +10 -0
  89. package/dist/contract/Call.d.ts.map +1 -0
  90. package/dist/contract/Call.js +15 -0
  91. package/dist/contract/Call.js.map +1 -0
  92. package/dist/contract/Invocation.d.ts +27 -0
  93. package/dist/contract/Invocation.d.ts.map +1 -0
  94. package/dist/contract/Invocation.js +59 -0
  95. package/dist/contract/Invocation.js.map +1 -0
  96. package/dist/contract/RouteAddress.d.ts +17 -0
  97. package/dist/contract/RouteAddress.d.ts.map +1 -0
  98. package/dist/contract/RouteAddress.js +38 -0
  99. package/dist/contract/RouteAddress.js.map +1 -0
  100. package/dist/contract.d.ts +25 -19
  101. package/dist/contract.d.ts.map +1 -1
  102. package/dist/contract.js +25 -10
  103. package/dist/contract.js.map +1 -1
  104. package/dist/crypto/encoding.d.ts +25 -0
  105. package/dist/crypto/encoding.d.ts.map +1 -0
  106. package/dist/crypto/encoding.js +58 -0
  107. package/dist/crypto/encoding.js.map +1 -0
  108. package/dist/crypto/node.d.ts +4 -0
  109. package/dist/crypto/node.d.ts.map +1 -0
  110. package/dist/crypto/node.js +25 -0
  111. package/dist/crypto/node.js.map +1 -0
  112. package/dist/crypto/port.d.ts +42 -0
  113. package/dist/crypto/port.d.ts.map +1 -0
  114. package/dist/crypto/port.js +19 -0
  115. package/dist/crypto/port.js.map +1 -0
  116. package/dist/crypto/webcrypto.d.ts +4 -0
  117. package/dist/crypto/webcrypto.d.ts.map +1 -0
  118. package/dist/crypto/webcrypto.js +34 -0
  119. package/dist/crypto/webcrypto.js.map +1 -0
  120. package/dist/dispatch/ArgumentResolver.d.ts +10 -0
  121. package/dist/dispatch/ArgumentResolver.d.ts.map +1 -0
  122. package/dist/dispatch/ArgumentResolver.js +12 -0
  123. package/dist/dispatch/ArgumentResolver.js.map +1 -0
  124. package/dist/dispatch/ArrayResult.d.ts +3 -0
  125. package/dist/dispatch/ArrayResult.d.ts.map +1 -0
  126. package/dist/dispatch/ArrayResult.js +11 -0
  127. package/dist/dispatch/ArrayResult.js.map +1 -0
  128. package/dist/dispatch/DispatchEvent.d.ts +18 -0
  129. package/dist/dispatch/DispatchEvent.d.ts.map +1 -0
  130. package/dist/dispatch/DispatchEvent.js +30 -0
  131. package/dist/dispatch/DispatchEvent.js.map +1 -0
  132. package/dist/dispatch/DispatchLifecycle.d.ts +9 -0
  133. package/dist/dispatch/DispatchLifecycle.d.ts.map +1 -0
  134. package/dist/dispatch/DispatchLifecycle.js +25 -0
  135. package/dist/dispatch/DispatchLifecycle.js.map +1 -0
  136. package/dist/dispatch/DispatchPort.d.ts +6 -0
  137. package/dist/dispatch/DispatchPort.d.ts.map +1 -0
  138. package/dist/dispatch/DispatchPort.js +2 -0
  139. package/dist/dispatch/DispatchPort.js.map +1 -0
  140. package/dist/dispatch/Dispatcher.d.ts +16 -0
  141. package/dist/dispatch/Dispatcher.d.ts.map +1 -0
  142. package/dist/dispatch/Dispatcher.js +44 -0
  143. package/dist/dispatch/Dispatcher.js.map +1 -0
  144. package/dist/dispatch/InFlight.d.ts +12 -0
  145. package/dist/dispatch/InFlight.d.ts.map +1 -0
  146. package/dist/dispatch/InFlight.js +46 -0
  147. package/dist/dispatch/InFlight.js.map +1 -0
  148. package/dist/dispatch/InputValidator.d.ts +7 -0
  149. package/dist/dispatch/InputValidator.d.ts.map +1 -0
  150. package/dist/dispatch/InputValidator.js +22 -0
  151. package/dist/dispatch/InputValidator.js.map +1 -0
  152. package/dist/dispatch/LocalRoutePolicy.d.ts +11 -0
  153. package/dist/dispatch/LocalRoutePolicy.d.ts.map +1 -0
  154. package/dist/dispatch/LocalRoutePolicy.js +32 -0
  155. package/dist/dispatch/LocalRoutePolicy.js.map +1 -0
  156. package/dist/dispatch/OperationExecutor.d.ts +25 -0
  157. package/dist/dispatch/OperationExecutor.d.ts.map +1 -0
  158. package/dist/dispatch/OperationExecutor.js +32 -0
  159. package/dist/dispatch/OperationExecutor.js.map +1 -0
  160. package/dist/dispatch/OperationRoute.d.ts +13 -0
  161. package/dist/dispatch/OperationRoute.d.ts.map +1 -0
  162. package/dist/dispatch/OperationRoute.js +15 -0
  163. package/dist/dispatch/OperationRoute.js.map +1 -0
  164. package/dist/dispatch/OutputProjector.d.ts +12 -0
  165. package/dist/dispatch/OutputProjector.d.ts.map +1 -0
  166. package/dist/dispatch/OutputProjector.js +30 -0
  167. package/dist/dispatch/OutputProjector.js.map +1 -0
  168. package/dist/dispatch/OutputView.d.ts +8 -0
  169. package/dist/dispatch/OutputView.d.ts.map +1 -0
  170. package/dist/dispatch/OutputView.js +10 -0
  171. package/dist/dispatch/OutputView.js.map +1 -0
  172. package/dist/dispatch/PresenterArgumentResolver.d.ts +12 -0
  173. package/dist/dispatch/PresenterArgumentResolver.d.ts.map +1 -0
  174. package/dist/dispatch/PresenterArgumentResolver.js +20 -0
  175. package/dist/dispatch/PresenterArgumentResolver.js.map +1 -0
  176. package/dist/dispatch/PresenterExecutor.d.ts +11 -0
  177. package/dist/dispatch/PresenterExecutor.d.ts.map +1 -0
  178. package/dist/dispatch/PresenterExecutor.js +56 -0
  179. package/dist/dispatch/PresenterExecutor.js.map +1 -0
  180. package/dist/dispatch/RemoteRouteResolver.d.ts +13 -0
  181. package/dist/dispatch/RemoteRouteResolver.d.ts.map +1 -0
  182. package/dist/dispatch/RemoteRouteResolver.js +18 -0
  183. package/dist/dispatch/RemoteRouteResolver.js.map +1 -0
  184. package/dist/dispatch/Route.d.ts +10 -0
  185. package/dist/dispatch/Route.d.ts.map +1 -0
  186. package/dist/dispatch/Route.js +2 -0
  187. package/dist/dispatch/Route.js.map +1 -0
  188. package/dist/dispatch/RouteNotFoundError.d.ts +10 -0
  189. package/dist/dispatch/RouteNotFoundError.d.ts.map +1 -0
  190. package/dist/dispatch/RouteNotFoundError.js +24 -0
  191. package/dist/dispatch/RouteNotFoundError.js.map +1 -0
  192. package/dist/dispatch/RoutePolicy.d.ts +8 -0
  193. package/dist/dispatch/RoutePolicy.d.ts.map +1 -0
  194. package/dist/dispatch/RoutePolicy.js +2 -0
  195. package/dist/dispatch/RoutePolicy.js.map +1 -0
  196. package/dist/dispatch/RouteRegistry.d.ts +18 -0
  197. package/dist/dispatch/RouteRegistry.d.ts.map +1 -0
  198. package/dist/dispatch/RouteRegistry.js +62 -0
  199. package/dist/dispatch/RouteRegistry.js.map +1 -0
  200. package/dist/dispatch/RouteResolver.d.ts +7 -0
  201. package/dist/dispatch/RouteResolver.d.ts.map +1 -0
  202. package/dist/dispatch/RouteResolver.js +2 -0
  203. package/dist/dispatch/RouteResolver.js.map +1 -0
  204. package/dist/dispatch/StorageGuard.d.ts +15 -0
  205. package/dist/dispatch/StorageGuard.d.ts.map +1 -0
  206. package/dist/dispatch/StorageGuard.js +63 -0
  207. package/dist/dispatch/StorageGuard.js.map +1 -0
  208. package/dist/effective-operation.d.ts +90 -0
  209. package/dist/effective-operation.d.ts.map +1 -0
  210. package/dist/effective-operation.js +449 -0
  211. package/dist/effective-operation.js.map +1 -0
  212. package/dist/emit.d.ts +2 -2
  213. package/dist/emit.d.ts.map +1 -1
  214. package/dist/emit.js +2 -2
  215. package/dist/emit.js.map +1 -1
  216. package/dist/entry/DynamicFacade.d.ts +10 -0
  217. package/dist/entry/DynamicFacade.d.ts.map +1 -0
  218. package/dist/entry/DynamicFacade.js +27 -0
  219. package/dist/entry/DynamicFacade.js.map +1 -0
  220. package/dist/entry/FacadeEntry.d.ts +11 -0
  221. package/dist/entry/FacadeEntry.d.ts.map +1 -0
  222. package/dist/entry/FacadeEntry.js +26 -0
  223. package/dist/entry/FacadeEntry.js.map +1 -0
  224. package/dist/entry/TransportEntry.d.ts +13 -0
  225. package/dist/entry/TransportEntry.d.ts.map +1 -0
  226. package/dist/entry/TransportEntry.js +24 -0
  227. package/dist/entry/TransportEntry.js.map +1 -0
  228. package/dist/frond-config.d.ts +24 -7
  229. package/dist/frond-config.d.ts.map +1 -1
  230. package/dist/frond-config.js.map +1 -1
  231. package/dist/graph.d.ts +1 -1
  232. package/dist/graph.d.ts.map +1 -1
  233. package/dist/graph.js +3 -2
  234. package/dist/graph.js.map +1 -1
  235. package/dist/identity-keys.d.ts +14 -0
  236. package/dist/identity-keys.d.ts.map +1 -0
  237. package/dist/identity-keys.js +37 -0
  238. package/dist/identity-keys.js.map +1 -0
  239. package/dist/identity.d.ts +58 -0
  240. package/dist/identity.d.ts.map +1 -0
  241. package/dist/identity.js +182 -0
  242. package/dist/identity.js.map +1 -0
  243. package/dist/imports.d.ts +2 -2
  244. package/dist/imports.d.ts.map +1 -1
  245. package/dist/imports.js +7 -3
  246. package/dist/imports.js.map +1 -1
  247. package/dist/index.d.ts +57 -38
  248. package/dist/index.d.ts.map +1 -1
  249. package/dist/index.js +38 -32
  250. package/dist/index.js.map +1 -1
  251. package/dist/loader.d.ts +16 -0
  252. package/dist/loader.d.ts.map +1 -0
  253. package/dist/loader.js +25 -0
  254. package/dist/loader.js.map +1 -0
  255. package/dist/node.d.ts +21 -0
  256. package/dist/node.d.ts.map +1 -0
  257. package/dist/node.js +24 -0
  258. package/dist/node.js.map +1 -0
  259. package/dist/orm.d.ts +69 -8
  260. package/dist/orm.d.ts.map +1 -1
  261. package/dist/orm.js +35 -2
  262. package/dist/orm.js.map +1 -1
  263. package/dist/prefab/collector.d.ts +29 -0
  264. package/dist/prefab/collector.d.ts.map +1 -0
  265. package/dist/prefab/collector.js +34 -0
  266. package/dist/prefab/collector.js.map +1 -0
  267. package/dist/{crud.d.ts → prefab/crud.d.ts} +7 -8
  268. package/dist/prefab/crud.d.ts.map +1 -0
  269. package/dist/{crud.js → prefab/crud.js} +39 -5
  270. package/dist/prefab/crud.js.map +1 -0
  271. package/dist/prefab/mirror.d.ts +52 -0
  272. package/dist/prefab/mirror.d.ts.map +1 -0
  273. package/dist/prefab/mirror.js +66 -0
  274. package/dist/prefab/mirror.js.map +1 -0
  275. package/dist/prefab/prefab.d.ts +15 -0
  276. package/dist/prefab/prefab.d.ts.map +1 -0
  277. package/dist/prefab/prefab.js +19 -0
  278. package/dist/prefab/prefab.js.map +1 -0
  279. package/dist/{presenter.d.ts → prefab/presenter.d.ts} +6 -17
  280. package/dist/prefab/presenter.d.ts.map +1 -0
  281. package/dist/{presenter.js → prefab/presenter.js} +5 -23
  282. package/dist/prefab/presenter.js.map +1 -0
  283. package/dist/prefab/repository.d.ts +104 -0
  284. package/dist/prefab/repository.d.ts.map +1 -0
  285. package/dist/prefab/repository.js +62 -0
  286. package/dist/prefab/repository.js.map +1 -0
  287. package/dist/scan/Fronds.d.ts +45 -0
  288. package/dist/scan/Fronds.d.ts.map +1 -0
  289. package/dist/scan/Fronds.js +66 -0
  290. package/dist/scan/Fronds.js.map +1 -0
  291. package/dist/scan/conventions.d.ts +74 -0
  292. package/dist/scan/conventions.d.ts.map +1 -0
  293. package/dist/scan/conventions.js +82 -0
  294. package/dist/scan/conventions.js.map +1 -0
  295. package/dist/scan/emit.d.ts +14 -0
  296. package/dist/scan/emit.d.ts.map +1 -0
  297. package/dist/scan/emit.js +212 -0
  298. package/dist/scan/emit.js.map +1 -0
  299. package/dist/scan/frond.d.ts +224 -0
  300. package/dist/scan/frond.d.ts.map +1 -0
  301. package/dist/scan/frond.js +2 -0
  302. package/dist/scan/frond.js.map +1 -0
  303. package/dist/{handler-parser.d.ts → scan/handler-parser.d.ts} +20 -9
  304. package/dist/scan/handler-parser.d.ts.map +1 -0
  305. package/dist/scan/handler-parser.js +665 -0
  306. package/dist/scan/handler-parser.js.map +1 -0
  307. package/dist/scan/scan-cache.d.ts +16 -0
  308. package/dist/scan/scan-cache.d.ts.map +1 -0
  309. package/dist/{scan-cache.js → scan/scan-cache.js} +27 -20
  310. package/dist/scan/scan-cache.js.map +1 -0
  311. package/dist/scan/scanner.d.ts +20 -0
  312. package/dist/scan/scanner.d.ts.map +1 -0
  313. package/dist/{scanner.js → scan/scanner.js} +212 -167
  314. package/dist/scan/scanner.js.map +1 -0
  315. package/dist/verify.d.ts +16 -3
  316. package/dist/verify.d.ts.map +1 -1
  317. package/dist/verify.js +21 -18
  318. package/dist/verify.js.map +1 -1
  319. package/dist/{call.d.ts → wire/call.d.ts} +76 -7
  320. package/dist/wire/call.d.ts.map +1 -0
  321. package/dist/{call.js → wire/call.js} +53 -80
  322. package/dist/wire/call.js.map +1 -0
  323. package/dist/{middleware.d.ts → wire/errors.d.ts} +18 -19
  324. package/dist/wire/errors.d.ts.map +1 -0
  325. package/dist/{middleware.js → wire/errors.js} +26 -14
  326. package/dist/wire/errors.js.map +1 -0
  327. package/dist/{errors.d.ts → wire/http-error.d.ts} +5 -6
  328. package/dist/wire/http-error.d.ts.map +1 -0
  329. package/dist/{errors.js → wire/http-error.js} +7 -6
  330. package/dist/wire/http-error.js.map +1 -0
  331. package/dist/wire/invocation.d.ts +4 -0
  332. package/dist/wire/invocation.d.ts.map +1 -0
  333. package/dist/wire/invocation.js +3 -0
  334. package/dist/wire/invocation.js.map +1 -0
  335. package/dist/{middleware/logger.d.ts → wire/loggerMiddleware.d.ts} +3 -3
  336. package/dist/wire/loggerMiddleware.d.ts.map +1 -0
  337. package/dist/{middleware/logger.js → wire/loggerMiddleware.js} +2 -2
  338. package/dist/wire/loggerMiddleware.js.map +1 -0
  339. package/dist/wire/middleware.d.ts +29 -0
  340. package/dist/wire/middleware.d.ts.map +1 -0
  341. package/dist/wire/middleware.js +20 -0
  342. package/dist/wire/middleware.js.map +1 -0
  343. package/dist/{operation.d.ts → wire/operation.d.ts} +39 -10
  344. package/dist/wire/operation.d.ts.map +1 -0
  345. package/dist/wire/operation.js +167 -0
  346. package/dist/wire/operation.js.map +1 -0
  347. package/package.json +27 -8
  348. package/src/boot/AppLifecycle.ts +50 -0
  349. package/src/boot/Emissions.ts +263 -0
  350. package/src/boot/HandlerFacade.ts +242 -0
  351. package/src/boot/Lifecycle.ts +3 -0
  352. package/src/boot/ambient-port.ts +41 -0
  353. package/src/boot/ambient.als.ts +43 -0
  354. package/src/boot/ambient.queue.ts +75 -0
  355. package/src/boot/apply.ts +47 -0
  356. package/src/boot/auth.ts +55 -0
  357. package/src/boot/binding.ts +182 -0
  358. package/src/boot/boot.ts +125 -0
  359. package/src/boot/bootstrap.ts +839 -0
  360. package/src/boot/frame.ts +210 -0
  361. package/src/boot/ownership.ts +140 -0
  362. package/src/boot/ports.ts +66 -0
  363. package/src/boot/remote.ts +179 -0
  364. package/src/boot/seed.ts +158 -0
  365. package/src/boot/together.ts +215 -0
  366. package/src/boot/types.ts +261 -0
  367. package/src/builtins/config.ts +19 -0
  368. package/src/builtins/logger.ts +175 -0
  369. package/src/config-loader.ts +146 -0
  370. package/src/contract/Call.ts +18 -0
  371. package/src/contract/Invocation.ts +72 -0
  372. package/src/contract/RouteAddress.ts +49 -0
  373. package/src/contract.ts +74 -0
  374. package/src/crypto/encoding.ts +59 -0
  375. package/src/crypto/node.ts +30 -0
  376. package/src/crypto/port.ts +45 -0
  377. package/src/crypto/webcrypto.ts +55 -0
  378. package/src/define.ts +10 -0
  379. package/src/dispatch/ArgumentResolver.ts +17 -0
  380. package/src/dispatch/ArrayResult.ts +10 -0
  381. package/src/dispatch/DispatchEvent.ts +38 -0
  382. package/src/dispatch/DispatchLifecycle.ts +23 -0
  383. package/src/dispatch/DispatchPort.ts +6 -0
  384. package/src/dispatch/Dispatcher.ts +48 -0
  385. package/src/dispatch/InFlight.ts +49 -0
  386. package/src/dispatch/InputValidator.ts +28 -0
  387. package/src/dispatch/LocalRoutePolicy.ts +34 -0
  388. package/src/dispatch/OperationExecutor.ts +60 -0
  389. package/src/dispatch/OperationRoute.ts +18 -0
  390. package/src/dispatch/OutputProjector.ts +32 -0
  391. package/src/dispatch/OutputView.ts +9 -0
  392. package/src/dispatch/PresenterArgumentResolver.ts +25 -0
  393. package/src/dispatch/PresenterExecutor.ts +55 -0
  394. package/src/dispatch/RemoteRouteResolver.ts +21 -0
  395. package/src/dispatch/Route.ts +11 -0
  396. package/src/dispatch/RouteNotFoundError.ts +29 -0
  397. package/src/dispatch/RoutePolicy.ts +8 -0
  398. package/src/dispatch/RouteRegistry.ts +73 -0
  399. package/src/dispatch/RouteResolver.ts +7 -0
  400. package/src/dispatch/StorageGuard.ts +71 -0
  401. package/src/effective-operation.ts +597 -0
  402. package/src/emit.ts +90 -0
  403. package/src/entry/DynamicFacade.ts +28 -0
  404. package/src/entry/FacadeEntry.ts +32 -0
  405. package/src/entry/TransportEntry.ts +30 -0
  406. package/src/frond-config.ts +138 -0
  407. package/src/graph.ts +180 -0
  408. package/src/identity-keys.ts +43 -0
  409. package/src/identity.ts +235 -0
  410. package/src/imports.ts +123 -0
  411. package/src/index.ts +106 -0
  412. package/src/loader.ts +41 -0
  413. package/src/node.ts +28 -0
  414. package/src/orm.ts +252 -0
  415. package/src/prefab/collector.ts +36 -0
  416. package/src/prefab/crud.ts +188 -0
  417. package/src/prefab/mirror.ts +122 -0
  418. package/src/prefab/prefab.ts +46 -0
  419. package/src/prefab/presenter.ts +63 -0
  420. package/src/prefab/repository.ts +170 -0
  421. package/src/scan/Fronds.ts +73 -0
  422. package/src/scan/conventions.ts +122 -0
  423. package/src/scan/emit.ts +231 -0
  424. package/src/scan/frond.ts +235 -0
  425. package/src/scan/handler-parser.ts +818 -0
  426. package/src/scan/scan-cache.ts +115 -0
  427. package/src/scan/scanner.ts +758 -0
  428. package/src/verify.ts +193 -0
  429. package/src/wire/call.ts +369 -0
  430. package/src/wire/errors.ts +124 -0
  431. package/src/wire/http-error.ts +77 -0
  432. package/src/wire/invocation.ts +10 -0
  433. package/src/wire/loggerMiddleware.ts +29 -0
  434. package/src/wire/middleware.ts +47 -0
  435. package/src/wire/operation.ts +258 -0
  436. package/dist/binding.d.ts.map +0 -1
  437. package/dist/binding.js.map +0 -1
  438. package/dist/boot.d.ts.map +0 -1
  439. package/dist/boot.js +0 -53
  440. package/dist/boot.js.map +0 -1
  441. package/dist/bootstrap.d.ts.map +0 -1
  442. package/dist/bootstrap.js +0 -879
  443. package/dist/bootstrap.js.map +0 -1
  444. package/dist/call.d.ts.map +0 -1
  445. package/dist/call.js.map +0 -1
  446. package/dist/collector.d.ts +0 -28
  447. package/dist/collector.d.ts.map +0 -1
  448. package/dist/collector.js +0 -32
  449. package/dist/collector.js.map +0 -1
  450. package/dist/crud.d.ts.map +0 -1
  451. package/dist/crud.js.map +0 -1
  452. package/dist/egress.d.ts +0 -52
  453. package/dist/egress.d.ts.map +0 -1
  454. package/dist/egress.js +0 -186
  455. package/dist/egress.js.map +0 -1
  456. package/dist/errors.d.ts.map +0 -1
  457. package/dist/errors.js.map +0 -1
  458. package/dist/handler-parser.d.ts.map +0 -1
  459. package/dist/handler-parser.js +0 -505
  460. package/dist/handler-parser.js.map +0 -1
  461. package/dist/invocation.d.ts +0 -20
  462. package/dist/invocation.d.ts.map +0 -1
  463. package/dist/invocation.js +0 -15
  464. package/dist/invocation.js.map +0 -1
  465. package/dist/middleware/error-handler.d.ts +0 -15
  466. package/dist/middleware/error-handler.d.ts.map +0 -1
  467. package/dist/middleware/error-handler.js +0 -29
  468. package/dist/middleware/error-handler.js.map +0 -1
  469. package/dist/middleware/logger.d.ts.map +0 -1
  470. package/dist/middleware/logger.js.map +0 -1
  471. package/dist/middleware.d.ts.map +0 -1
  472. package/dist/middleware.js.map +0 -1
  473. package/dist/mirror.d.ts +0 -93
  474. package/dist/mirror.d.ts.map +0 -1
  475. package/dist/mirror.js +0 -96
  476. package/dist/mirror.js.map +0 -1
  477. package/dist/operation.d.ts.map +0 -1
  478. package/dist/operation.js +0 -95
  479. package/dist/operation.js.map +0 -1
  480. package/dist/presenter.d.ts.map +0 -1
  481. package/dist/presenter.js.map +0 -1
  482. package/dist/remote.d.ts.map +0 -1
  483. package/dist/remote.js.map +0 -1
  484. package/dist/repository.d.ts +0 -55
  485. package/dist/repository.d.ts.map +0 -1
  486. package/dist/repository.js +0 -26
  487. package/dist/repository.js.map +0 -1
  488. package/dist/scan-cache.d.ts +0 -10
  489. package/dist/scan-cache.d.ts.map +0 -1
  490. package/dist/scan-cache.js.map +0 -1
  491. package/dist/scanner.d.ts +0 -34
  492. package/dist/scanner.d.ts.map +0 -1
  493. package/dist/scanner.js.map +0 -1
  494. package/dist/seed.d.ts.map +0 -1
  495. package/dist/seed.js.map +0 -1
  496. package/dist/types.d.ts +0 -421
  497. package/dist/types.d.ts.map +0 -1
  498. package/dist/types.js.map +0 -1
  499. /package/dist/{bootstrap.d.ts → boot/bootstrap.d.ts} +0 -0
  500. /package/dist/{types.js → boot/types.js} +0 -0
@@ -0,0 +1,665 @@
1
+ import { readFileSync, existsSync, statSync } from 'node:fs';
2
+ import { join, dirname, resolve as resolvePath } from 'node:path';
3
+ /** Lazy-loaded TypeScript module — avoids bundling the 9MB compiler. */
4
+ let _ts;
5
+ async function loadTS() {
6
+ if (!_ts)
7
+ _ts = (await import('@typescript/typescript6')).default;
8
+ return _ts;
9
+ }
10
+ function getTS() {
11
+ if (!_ts)
12
+ throw new Error('TypeScript not loaded — call an async parse function first');
13
+ return _ts;
14
+ }
15
+ /**
16
+ * One checked program per project/configuration during a scan.
17
+ *
18
+ * A checker is a project reader, not a file parser: creating one per handler would reopen
19
+ * the standard library and every imported declaration for each method. `scanProject`
20
+ * resets this map at the start of a run, so an edited source can never meet a program from
21
+ * the previous run.
22
+ */
23
+ const typeProjects = new Map();
24
+ const compilerProjects = new Map();
25
+ /**
26
+ * What survives a run: the parsed declarations, and the program built over them.
27
+ *
28
+ * Rebuilding a program re-reads `lib.d.ts` and every imported `.d.ts`, and that is FIXED
29
+ * work — measured, a second scan in one process cost the same at 16 frond files as at 406.
30
+ * The mtime is the guard, so a run still cannot see a stale type: a file that moved is
31
+ * re-read and TypeScript invalidates it and everything depending on it, which is a
32
+ * narrower rule than discarding the program and not a weaker one.
33
+ */
34
+ const sourceFiles = new Map();
35
+ const retained = new Map();
36
+ export function resetTypePrograms() {
37
+ typeProjects.clear();
38
+ compilerProjects.clear();
39
+ }
40
+ /** Drop what runs share. For a test that must prove a cold read. */
41
+ export function forgetParsedSources() {
42
+ sourceFiles.clear();
43
+ retained.clear();
44
+ }
45
+ function keptHost(key, options) {
46
+ const held = retained.get(key);
47
+ if (held)
48
+ return held.host;
49
+ const typescript = getTS();
50
+ const base = typescript.createCompilerHost(options);
51
+ const host = {
52
+ ...base,
53
+ getSourceFile(fileName, languageVersion, onError, shouldCreate) {
54
+ const path = resolvePath(fileName);
55
+ const mtime = statSync(path, { throwIfNoEntry: false })?.mtimeMs ?? -1;
56
+ const cached = sourceFiles.get(path);
57
+ if (cached && cached.mtime === mtime)
58
+ return cached.file;
59
+ const file = base.getSourceFile(fileName, languageVersion, onError, shouldCreate);
60
+ if (file && mtime >= 0)
61
+ sourceFiles.set(path, { mtime, file });
62
+ return file;
63
+ },
64
+ };
65
+ retained.set(key, { host, program: undefined });
66
+ return host;
67
+ }
68
+ function builtProgram(key, roots, options) {
69
+ const typescript = getTS();
70
+ const host = keptHost(key, options);
71
+ const program = typescript.createProgram({
72
+ rootNames: [...roots], options, host, oldProgram: retained.get(key)?.program,
73
+ });
74
+ retained.set(key, { host, program });
75
+ return program;
76
+ }
77
+ function compilerProjectOf(filePath, projectRoot) {
78
+ const typescript = getTS();
79
+ const absolute = resolvePath(filePath);
80
+ const configPath = typescript.findConfigFile(dirname(absolute), typescript.sys.fileExists);
81
+ if (configPath) {
82
+ const key = `${configPath}:${projectRoot ?? ''}`;
83
+ const cached = compilerProjects.get(key);
84
+ if (cached)
85
+ return cached;
86
+ const read = typescript.readConfigFile(configPath, typescript.sys.readFile);
87
+ if (read.error)
88
+ throw new Error(typescript.flattenDiagnosticMessageText(read.error.messageText, '\n'));
89
+ const parsed = typescript.parseJsonConfigFileContent(read.config, typescript.sys, dirname(configPath));
90
+ const configured = {
91
+ key,
92
+ // Compiler options belong to the project; its entire include glob does not belong
93
+ // to this scan. Each declaration inspected below becomes a root and TypeScript
94
+ // follows its imports. Seeding the monorepo here made a one-file scan compile it all.
95
+ roots: [],
96
+ // Handlers may be authored or emitted as JavaScript. They still need to belong to
97
+ // the checked program so constructor parsing does not fail on the first cold scan.
98
+ options: { ...parsed.options, allowJs: true, noEmit: true },
99
+ };
100
+ compilerProjects.set(key, configured);
101
+ return configured;
102
+ }
103
+ const key = projectRoot ?? dirname(absolute);
104
+ const cached = compilerProjects.get(key);
105
+ if (cached)
106
+ return cached;
107
+ const configured = {
108
+ key,
109
+ roots: [],
110
+ options: {
111
+ target: typescript.ScriptTarget.ES2022,
112
+ module: typescript.ModuleKind.Node16,
113
+ moduleResolution: typescript.ModuleResolutionKind.Node16,
114
+ strict: true,
115
+ skipLibCheck: true,
116
+ allowJs: true,
117
+ noEmit: true,
118
+ },
119
+ };
120
+ compilerProjects.set(key, configured);
121
+ return configured;
122
+ }
123
+ /**
124
+ * Declare every file a run will read, so one program covers it.
125
+ *
126
+ * `checkedSourceOf` rebuilds whenever it meets a root it has not seen, and a frond lives
127
+ * outside its project's tsconfig `include`, so every declaration was a new root: 44 files
128
+ * cost 7.3 s that way against 0.34 s for one program.
129
+ */
130
+ export async function seedTypeProgram(filePaths, projectRoot) {
131
+ const typescript = await loadTS();
132
+ const grouped = new Map();
133
+ for (const filePath of filePaths) {
134
+ const absolute = resolvePath(filePath);
135
+ const configured = compilerProjectOf(absolute, projectRoot);
136
+ const held = grouped.get(configured.key) ?? { options: configured.options, paths: [] };
137
+ held.paths.push(absolute);
138
+ grouped.set(configured.key, held);
139
+ }
140
+ for (const [key, { options, paths }] of grouped) {
141
+ const roots = new Set(typeProjects.get(key)?.roots ?? []);
142
+ for (const path of paths)
143
+ roots.add(path);
144
+ typeProjects.set(key, { roots, options, program: builtProgram(key, [...roots], options) });
145
+ }
146
+ }
147
+ function checkedSourceOf(filePath, projectRoot) {
148
+ const typescript = getTS();
149
+ const absolute = resolvePath(filePath);
150
+ const configured = compilerProjectOf(absolute, projectRoot);
151
+ let held = typeProjects.get(configured.key);
152
+ if (!held) {
153
+ // `path.resolve` is variadic, so handing it directly to `map` also passed the
154
+ // index and the whole roots array as path segments. A fixture without a warm scan
155
+ // cache exposed that first-run-only failure.
156
+ const roots = new Set(configured.roots.map((root) => resolvePath(root)));
157
+ roots.add(absolute);
158
+ const program = builtProgram(configured.key, [...roots], configured.options);
159
+ held = { roots, options: configured.options, program };
160
+ typeProjects.set(configured.key, held);
161
+ }
162
+ else if (!held.roots.has(absolute)) {
163
+ held.roots.add(absolute);
164
+ held.program = builtProgram(configured.key, [...held.roots], held.options);
165
+ }
166
+ const source = held.program.getSourceFile(absolute);
167
+ if (!source)
168
+ throw new Error(`TypeScript did not include '${absolute}' in its program.`);
169
+ return { source, checker: held.program.getTypeChecker() };
170
+ }
171
+ /** A file, opened. Five places read and parsed one, each spelling the same two calls. */
172
+ function sourceOf(filePath) {
173
+ const ts = getTS();
174
+ return ts.createSourceFile(filePath, readFileSync(filePath, 'utf-8'), ts.ScriptTarget.Latest, true);
175
+ }
176
+ /** One declared parameter — a constructor's and a method's are read the same way. */
177
+ function parsedParam(param, source, checker) {
178
+ const ts = getTS();
179
+ const type = param.type ? parseTypeNode(param.type, source, checker) : { raw: 'unknown', name: 'unknown' };
180
+ return {
181
+ name: ts.isIdentifier(param.name) ? param.name.text : param.name.getText(source),
182
+ type,
183
+ // `user?: User` and `user: User | undefined` are the same declaration of
184
+ // absence. A type alias may carry the latter, so only the checker can see it.
185
+ optional: param.questionToken !== undefined || param.initializer !== undefined || type.undefined === true,
186
+ };
187
+ }
188
+ /** Parse a TypeScript type node into a ParsedType. */
189
+ function parseTypeNode(node, source, checker) {
190
+ const ts = getTS();
191
+ const raw = node.getText(source);
192
+ if (checker) {
193
+ // `Fact<T>` is deliberately transparent in TypeScript (`type Fact<T> = T`), because
194
+ // a subscriber receives the payload itself. The checker erases that marker, while
195
+ // the binding plan still needs it to distinguish a fact from an ordinary body.
196
+ if (ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.text === 'Fact') {
197
+ return {
198
+ raw,
199
+ name: 'Fact',
200
+ generics: node.typeArguments?.map((arg) => parseTypeNode(arg, source, checker)) ?? [],
201
+ };
202
+ }
203
+ return parseCheckedType(checker.getTypeFromTypeNode(node), raw, checker);
204
+ }
205
+ // Union types — extract nullable, strip Promise
206
+ if (ts.isUnionTypeNode(node)) {
207
+ const nonNull = node.types.filter((t) => !(ts.isLiteralTypeNode(t) && t.literal.kind === ts.SyntaxKind.NullKeyword)
208
+ && !(t.kind === ts.SyntaxKind.UndefinedKeyword)
209
+ && !(t.kind === ts.SyntaxKind.VoidKeyword)
210
+ && !(t.kind === ts.SyntaxKind.NullKeyword));
211
+ const nullable = node.types.some((t) => (ts.isLiteralTypeNode(t) && t.literal.kind === ts.SyntaxKind.NullKeyword)
212
+ || t.kind === ts.SyntaxKind.NullKeyword);
213
+ const undefinable = node.types.some((t) => t.kind === ts.SyntaxKind.UndefinedKeyword || t.kind === ts.SyntaxKind.VoidKeyword);
214
+ if (nonNull.length === 1) {
215
+ const inner = parseTypeNode(nonNull[0], source);
216
+ return { ...inner, nullable: nullable || inner.nullable, undefined: undefinable || inner.undefined, raw };
217
+ }
218
+ return { raw, name: raw, nullable, undefined: undefinable };
219
+ }
220
+ // Promise<T> — unwrap
221
+ if (ts.isTypeReferenceNode(node)) {
222
+ const typeName = node.typeName.getText(source);
223
+ if (typeName === 'Promise' && node.typeArguments?.length === 1) {
224
+ const inner = parseTypeNode(node.typeArguments[0], source);
225
+ return { ...inner, promise: true, raw };
226
+ }
227
+ // Array<T>
228
+ if (typeName === 'Array' && node.typeArguments?.length === 1) {
229
+ const inner = parseTypeNode(node.typeArguments[0], source);
230
+ return { ...inner, array: true, arrayDepth: (inner.arrayDepth ?? 0) + 1, raw };
231
+ }
232
+ // Generic type: Foo<Bar, Baz>
233
+ if (node.typeArguments && node.typeArguments.length > 0) {
234
+ const generics = node.typeArguments.map((arg) => parseTypeNode(arg, source));
235
+ return { raw, name: typeName, generics };
236
+ }
237
+ // Simple type reference: Post, string, etc.
238
+ return { raw, name: typeName };
239
+ }
240
+ // T[]
241
+ if (ts.isArrayTypeNode(node)) {
242
+ const inner = parseTypeNode(node.elementType, source);
243
+ return { ...inner, array: true, arrayDepth: (inner.arrayDepth ?? 0) + 1, raw };
244
+ }
245
+ // Keyword types: string, number, boolean, void
246
+ switch (node.kind) {
247
+ case ts.SyntaxKind.StringKeyword: return { raw, name: 'string' };
248
+ case ts.SyntaxKind.NumberKeyword: return { raw, name: 'number' };
249
+ case ts.SyntaxKind.BooleanKeyword: return { raw, name: 'boolean' };
250
+ case ts.SyntaxKind.VoidKeyword: return { raw, name: 'void', undefined: true };
251
+ case ts.SyntaxKind.UndefinedKeyword: return { raw, name: 'undefined', undefined: true };
252
+ case ts.SyntaxKind.NullKeyword: return { raw, name: 'null', nullable: true };
253
+ case ts.SyntaxKind.AnyKeyword: return { raw, name: 'any' };
254
+ case ts.SyntaxKind.UnknownKeyword: return { raw, name: 'unknown' };
255
+ }
256
+ // Object literal type: { title: string; limit: number }
257
+ if (ts.isTypeLiteralNode(node)) {
258
+ return { raw, name: raw };
259
+ }
260
+ // Fallback
261
+ return { raw, name: raw };
262
+ }
263
+ function meaningfulSymbolName(type, checker) {
264
+ const typescript = getTS();
265
+ const symbol = type.aliasSymbol ?? type.getSymbol();
266
+ if (symbol && symbol.name !== 'default' && !symbol.name.startsWith('__'))
267
+ return symbol.name;
268
+ for (const declaration of symbol?.declarations ?? []) {
269
+ if ((typescript.isClassDeclaration(declaration)
270
+ || typescript.isInterfaceDeclaration(declaration)
271
+ || typescript.isTypeAliasDeclaration(declaration))
272
+ && declaration.name)
273
+ return declaration.name.text;
274
+ }
275
+ return checker.typeToString(type, undefined, typescript.TypeFormatFlags.NoTruncation);
276
+ }
277
+ /** Turn a checked TypeScript type into the small, serializable vocabulary the runtime reads. */
278
+ function parseCheckedType(type, raw, checker, depth = 0) {
279
+ const typescript = getTS();
280
+ if (depth > 12)
281
+ return { raw, name: checker.typeToString(type) };
282
+ if (type.isUnion()) {
283
+ const nullable = type.types.some((member) => (member.flags & typescript.TypeFlags.Null) !== 0);
284
+ const undefinable = type.types.some((member) => (member.flags & (typescript.TypeFlags.Undefined | typescript.TypeFlags.Void)) !== 0);
285
+ const members = type.types.filter((member) => (member.flags & (typescript.TypeFlags.Null | typescript.TypeFlags.Undefined | typescript.TypeFlags.Void)) === 0);
286
+ // The checker represents the `boolean` keyword itself as `false | true`. Preserve
287
+ // the primitive vocabulary consumed by binding and presenter metadata.
288
+ if (members.length > 0
289
+ && members.every((member) => (member.flags & typescript.TypeFlags.BooleanLiteral) !== 0)) {
290
+ return { raw, name: 'boolean', nullable, undefined: undefinable };
291
+ }
292
+ if (members.length === 1) {
293
+ const inner = parseCheckedType(members[0], raw, checker, depth + 1);
294
+ return {
295
+ ...inner,
296
+ raw,
297
+ nullable: nullable || inner.nullable,
298
+ undefined: undefinable || inner.undefined,
299
+ };
300
+ }
301
+ return {
302
+ raw,
303
+ name: members.map((member) => meaningfulSymbolName(member, checker)).join(' | ') || raw,
304
+ nullable,
305
+ undefined: undefinable,
306
+ };
307
+ }
308
+ // Present at runtime in the supported compiler versions, but intentionally omitted
309
+ // from TypeScript's public TypeChecker declaration.
310
+ const promised = checker.getPromisedTypeOfPromise(type);
311
+ if (promised)
312
+ return { ...parseCheckedType(promised, raw, checker, depth + 1), raw, promise: true };
313
+ if (checker.isArrayType(type)) {
314
+ const [element] = checker.getTypeArguments(type);
315
+ const inner = element ? parseCheckedType(element, raw, checker, depth + 1) : { raw, name: 'unknown' };
316
+ return { ...inner, raw, array: true, arrayDepth: (inner.arrayDepth ?? 0) + 1 };
317
+ }
318
+ if ((type.flags & typescript.TypeFlags.StringLike) !== 0)
319
+ return { raw, name: 'string' };
320
+ if ((type.flags & typescript.TypeFlags.NumberLike) !== 0)
321
+ return { raw, name: 'number' };
322
+ if ((type.flags & typescript.TypeFlags.BooleanLike) !== 0)
323
+ return { raw, name: 'boolean' };
324
+ if ((type.flags & typescript.TypeFlags.Void) !== 0)
325
+ return { raw, name: 'void', undefined: true };
326
+ if ((type.flags & typescript.TypeFlags.Undefined) !== 0)
327
+ return { raw, name: 'undefined', undefined: true };
328
+ if ((type.flags & typescript.TypeFlags.Null) !== 0)
329
+ return { raw, name: 'null', nullable: true };
330
+ if ((type.flags & typescript.TypeFlags.Any) !== 0)
331
+ return { raw, name: 'any' };
332
+ if ((type.flags & typescript.TypeFlags.Unknown) !== 0)
333
+ return { raw, name: 'unknown' };
334
+ const reference = type;
335
+ // A declared alias such as `Emit<PostPublished>` may reduce to a function or object
336
+ // type, so it is no longer a TypeReference. The checker keeps its arguments beside
337
+ // `aliasSymbol`; losing them turns DI keys into bare `Emit`/`Facade`.
338
+ const args = type.aliasTypeArguments
339
+ ?? checker.getTypeArguments(reference);
340
+ return {
341
+ raw,
342
+ name: meaningfulSymbolName(type, checker),
343
+ ...(args.length && { generics: args.map((arg) => parseCheckedType(arg, checker.typeToString(arg), checker, depth + 1)) }),
344
+ };
345
+ }
346
+ // ── Module resolution ────────────────────────
347
+ const TS_KEYWORDS = new Set([
348
+ 'string', 'number', 'boolean', 'void', 'undefined', 'null', 'any', 'unknown',
349
+ 'never', 'object', 'symbol', 'bigint',
350
+ ]);
351
+ /** Resolve an import specifier to an absolute file path. */
352
+ function resolveSpecifier(specifier, fromFile, projectRoot) {
353
+ // Relative import
354
+ if (specifier.startsWith('.')) {
355
+ const dir = dirname(fromFile);
356
+ let resolved = resolvePath(dir, specifier);
357
+ // .js → .ts
358
+ if (resolved.endsWith('.js'))
359
+ resolved = resolved.slice(0, -3) + '.ts';
360
+ if (!resolved.endsWith('.ts'))
361
+ resolved += '.ts';
362
+ if (existsSync(resolved))
363
+ return resolved;
364
+ return undefined;
365
+ }
366
+ // Workspace package: @fougere/core → packages/core/src/index.ts
367
+ const match = specifier.match(/^@fougere\/([^/]+)$/);
368
+ if (match) {
369
+ const pkgDir = join(projectRoot, 'packages', match[1], 'src');
370
+ const indexPath = join(pkgDir, 'index.ts');
371
+ if (existsSync(indexPath))
372
+ return indexPath;
373
+ }
374
+ return undefined;
375
+ }
376
+ // ── Mixin / heritage parsing ─────────────────
377
+ /**
378
+ * The class a returned expression carries, however it is wrapped.
379
+ *
380
+ * A mixin does not always hand its class back bare. `Crud` returns
381
+ * `asCrudConstructor(class CrudHandler { … })` — one assertion helper standing between
382
+ * `return` and the class — and a parser accepting only a bare `return class` found
383
+ * nothing there, silently: the five inherited CRUD ops stopped being derived, and a warm
384
+ * scan cache kept answering the old parse for weeks (`scan-cache.ts` keys on source, not
385
+ * on parser version).
386
+ *
387
+ * So unwrap rather than match one shape: descend through call arguments, `as` and
388
+ * `satisfies` assertions, and parentheses. What is looked for is a class; where the
389
+ * author put it is their business.
390
+ */
391
+ function classInExpression(expr, depth = 0) {
392
+ const ts = getTS();
393
+ if (depth > 8)
394
+ return undefined;
395
+ if (ts.isClassExpression(expr))
396
+ return expr;
397
+ if (ts.isCallExpression(expr)) {
398
+ for (const arg of expr.arguments) {
399
+ const found = classInExpression(arg, depth + 1);
400
+ if (found)
401
+ return found;
402
+ }
403
+ return undefined;
404
+ }
405
+ if (ts.isAsExpression(expr) || ts.isSatisfiesExpression(expr) || ts.isParenthesizedExpression(expr)) {
406
+ return classInExpression(expr.expression, depth + 1);
407
+ }
408
+ return undefined;
409
+ }
410
+ /** Find a class declaration inside a function (mixin pattern). */
411
+ function findClassInFunction(source, functionName) {
412
+ const ts = getTS();
413
+ for (const stmt of source.statements) {
414
+ if (!ts.isFunctionDeclaration(stmt))
415
+ continue;
416
+ if (stmt.name?.text !== functionName)
417
+ continue;
418
+ if (!stmt.body)
419
+ continue;
420
+ // Walk statements inside the function
421
+ for (const inner of stmt.body.statements) {
422
+ // return class CrudHandler { … }, or the same class behind a wrapper
423
+ if (ts.isReturnStatement(inner) && inner.expression) {
424
+ const found = classInExpression(inner.expression);
425
+ if (found)
426
+ return found;
427
+ }
428
+ // class CrudHandler { ... } (followed by return)
429
+ if (ts.isClassDeclaration(inner))
430
+ return inner;
431
+ }
432
+ }
433
+ return undefined;
434
+ }
435
+ /**
436
+ * Extract methods from a class node (no file reading — works on already-parsed AST).
437
+ */
438
+ function extractClassMethods(cls, source, skip, checker) {
439
+ const ts = getTS();
440
+ const results = [];
441
+ for (const member of cls.members) {
442
+ if (!ts.isMethodDeclaration(member))
443
+ continue;
444
+ if (!member.name || !ts.isIdentifier(member.name))
445
+ continue;
446
+ // `private`/`protected` is a statement about the surface, and the AST carries it —
447
+ // it was read past. Every helper a handler names by intent (`mustOwn`, `readMany`,
448
+ // `refuse`) became a callable op: measured on the bench, `list.readMany` executed
449
+ // and `list.mayPublish` judged its argument. A door is what the author declares
450
+ // public, and TypeScript already has the word for it. `#name` is private too, but
451
+ // it is not an identifier, so it never reached here in the first place.
452
+ if (member.modifiers?.some((m) => m.kind === ts.SyntaxKind.PrivateKeyword || m.kind === ts.SyntaxKind.ProtectedKeyword))
453
+ continue;
454
+ const name = member.name.text;
455
+ if (skip.has(name))
456
+ continue;
457
+ const params = member.parameters.map((p) => parsedParam(p, source, checker));
458
+ const returnType = member.type ? parseTypeNode(member.type, source, checker) : undefined;
459
+ results.push({
460
+ name, params, returnType,
461
+ description: docSentenceOf(member, source),
462
+ });
463
+ }
464
+ return results;
465
+ }
466
+ /**
467
+ * The first sentence of a member's doc comment, or nothing.
468
+ *
469
+ * One sentence on purpose: what a caller needs to choose an operation is a claim,
470
+ * not an essay, and the rest of the comment addresses whoever edits the method.
471
+ * Reads the leading trivia rather than `ts.getJSDocTags` — the comment is what the
472
+ * author wrote, tags are a schema they never agreed to.
473
+ */
474
+ function docSentenceOf(member, source) {
475
+ const ts = getTS();
476
+ const ranges = ts.getLeadingCommentRanges(source.text, member.pos) ?? [];
477
+ const block = ranges.filter((r) => source.text.slice(r.pos, r.pos + 3) === '/**').pop();
478
+ if (!block)
479
+ return undefined;
480
+ const body = source.text
481
+ .slice(block.pos + 3, block.end - 2)
482
+ .split('\n')
483
+ .map((line) => line.replace(/^\s*\*/, '').trim())
484
+ .join(' ')
485
+ .trim();
486
+ const [sentence] = body.split(/(?<=\.)\s/);
487
+ return sentence?.trim() || undefined;
488
+ }
489
+ /**
490
+ * Parse inherited methods from a class's heritage clause.
491
+ * Handles both `extends Crud(Entity)` (mixin) and `extends BaseClass` patterns.
492
+ */
493
+ /**
494
+ * Where a name used here is declared. The checker follows the import, the re-export chain
495
+ * and an installed package's types — the three cases three hand-rolled functions treated
496
+ * separately.
497
+ */
498
+ function declarationFileOf(node, checker) {
499
+ const typescript = getTS();
500
+ let symbol = checker.getSymbolAtLocation(node);
501
+ if (!symbol)
502
+ return undefined;
503
+ if (symbol.flags & typescript.SymbolFlags.Alias)
504
+ symbol = checker.getAliasedSymbol(symbol);
505
+ return symbol.declarations?.[0]?.getSourceFile().fileName;
506
+ }
507
+ /**
508
+ * The methods a base class contributes, read from the INSTANTIATED type.
509
+ *
510
+ * `extends Crud(Post)` gives `create(input: Partial<Post>)` directly: the checker has
511
+ * already substituted the mixin's type parameter. The three functions this replaces
512
+ * detected the generic names and mapped them to the mixin's arguments by position.
513
+ */
514
+ function inheritedFromBase(base, checker, skip) {
515
+ const typescript = getTS();
516
+ const results = [];
517
+ for (const property of checker.getPropertiesOfType(checker.getTypeAtLocation(base))) {
518
+ if (skip.has(property.name))
519
+ continue;
520
+ // `private`/`protected` is a statement about the surface, and the declaration carries
521
+ // it. A door is what the author declares public.
522
+ const declaration = property.declarations?.[0];
523
+ if (declaration && typescript.canHaveModifiers(declaration)
524
+ && typescript.getModifiers(declaration)?.some((m) => m.kind === typescript.SyntaxKind.PrivateKeyword
525
+ || m.kind === typescript.SyntaxKind.ProtectedKeyword))
526
+ continue;
527
+ const signature = checker.getTypeOfSymbolAtLocation(property, base).getCallSignatures()[0];
528
+ if (!signature)
529
+ continue;
530
+ const returned = signature.getReturnType();
531
+ const sentence = typescript.displayPartsToString(property.getDocumentationComment(checker)).trim();
532
+ results.push({
533
+ name: property.name,
534
+ params: signature.getParameters().map((parameter) => {
535
+ const type = checker.getTypeOfSymbolAtLocation(parameter, base);
536
+ return {
537
+ name: parameter.name,
538
+ type: parseCheckedType(type, checker.typeToString(type), checker),
539
+ optional: (parameter.flags & typescript.SymbolFlags.Optional) !== 0,
540
+ };
541
+ }),
542
+ returnType: parseCheckedType(returned, checker.typeToString(returned), checker),
543
+ ...(sentence ? { description: sentence.split(/(?<=\.)\s/)[0] } : {}),
544
+ });
545
+ }
546
+ return results;
547
+ }
548
+ function parseInheritedMethods(cls, source, checker, skip,
549
+ /**
550
+ * Base classes this pass could not open — an INSTALLED one, typically, whose
551
+ * source is not in the workspace. Reported rather than treated as "no inherited
552
+ * method": the two used to be the same answer, so an op inherited from a
553
+ * published base class was absent from the façade without a word.
554
+ */
555
+ unresolved) {
556
+ const ts = getTS();
557
+ if (!cls.heritageClauses)
558
+ return [];
559
+ for (const clause of cls.heritageClauses) {
560
+ if (clause.token !== ts.SyntaxKind.ExtendsKeyword)
561
+ continue;
562
+ for (const base of clause.types) {
563
+ const fromType = inheritedFromBase(base, checker, skip);
564
+ if (fromType.length > 0)
565
+ return fromType;
566
+ // A factory that ERASES its own type — `assertShape<unknown>(class …)`, `as unknown`
567
+ // — leaves the checker with nothing to enumerate. The written class is still there,
568
+ // so read it. This is the one case where what the author wrote beats what it means.
569
+ const expression = base.expression;
570
+ const declared = ts.isCallExpression(expression) && ts.isIdentifier(expression.expression)
571
+ ? declarationFileOf(expression.expression, checker)
572
+ : ts.isIdentifier(expression) ? declarationFileOf(expression, checker) : undefined;
573
+ if (!declared) {
574
+ unresolved.push(expression.getText(source));
575
+ continue;
576
+ }
577
+ const declaredSource = sourceOf(declared);
578
+ const written = ts.isCallExpression(expression) && ts.isIdentifier(expression.expression)
579
+ ? findClassInFunction(declaredSource, expression.expression.text)
580
+ : findDefaultClass(declaredSource);
581
+ if (!written) {
582
+ unresolved.push(expression.getText(source));
583
+ continue;
584
+ }
585
+ return extractClassMethods(written, declaredSource, skip);
586
+ }
587
+ }
588
+ return [];
589
+ }
590
+ // ── Class finding ────────────────────────────
591
+ /** Find the default exported class in a source file. */
592
+ function findDefaultClass(source) {
593
+ const ts = getTS();
594
+ for (const stmt of source.statements) {
595
+ // export default class Foo { ... }
596
+ if (ts.isClassDeclaration(stmt) && stmt.modifiers?.some((m) => m.kind === ts.SyntaxKind.ExportKeyword) && stmt.modifiers?.some((m) => m.kind === ts.SyntaxKind.DefaultKeyword)) {
597
+ return stmt;
598
+ }
599
+ }
600
+ // export default Foo (separate statement) — find the class it points to
601
+ for (const stmt of source.statements) {
602
+ if (ts.isExportAssignment(stmt) && !stmt.isExportEquals && ts.isIdentifier(stmt.expression)) {
603
+ const name = stmt.expression.text;
604
+ for (const s of source.statements) {
605
+ if (ts.isClassDeclaration(s) && s.name?.text === name)
606
+ return s;
607
+ }
608
+ }
609
+ }
610
+ return undefined;
611
+ }
612
+ /**
613
+ * Every method a handler declares, its inherited ones included — the raw material of a
614
+ * binding plan. With a `projectRoot`, the heritage clause is followed too.
615
+ */
616
+ export async function parseAllHandlerMethods(filePath, projectRoot) {
617
+ await loadTS();
618
+ return parseClassMethods(filePath, CONSTRUCTOR_ONLY, projectRoot);
619
+ }
620
+ /**
621
+ * Parse a presenter source file and extract all method signatures.
622
+ *
623
+ * Returns all methods (no CRUD filtering) — each method is a computed field.
624
+ */
625
+ export async function parsePresenterMethods(filePath, projectRoot) {
626
+ await loadTS();
627
+ // No `projectRoot`, so no heritage pass and nothing to report: a presenter's
628
+ // computed fields are its own methods.
629
+ return parseClassMethods(filePath, CONSTRUCTOR_ONLY, undefined, projectRoot).methods;
630
+ }
631
+ /**
632
+ * Parse constructor parameter types from a source file's default class.
633
+ * Returns type names (e.g. ['PostOrm', 'Logger']) for DI resolution.
634
+ */
635
+ export async function parseConstructorParams(filePath, projectRoot) {
636
+ const ts = await loadTS();
637
+ const { source, checker } = checkedSourceOf(filePath, projectRoot);
638
+ const cls = findDefaultClass(source);
639
+ if (!cls)
640
+ return [];
641
+ const ctor = cls.members.find(ts.isConstructorDeclaration);
642
+ return ctor ? ctor.parameters.map((p) => parsedParam(p, source, checker)) : [];
643
+ }
644
+ const CONSTRUCTOR_ONLY = new Set(['constructor']);
645
+ function parseClassMethods(filePath, skip, heritageRoot, typeRoot = heritageRoot) {
646
+ const unresolved = [];
647
+ const { source, checker } = checkedSourceOf(filePath, typeRoot);
648
+ const cls = findDefaultClass(source);
649
+ if (!cls)
650
+ return { methods: [], unresolvedHeritage: unresolved };
651
+ // Parse child class methods
652
+ const childMethods = extractClassMethods(cls, source, skip, checker);
653
+ const childNames = new Set(childMethods.map((m) => m.name));
654
+ // Parse inherited methods (if projectRoot is provided for resolution)
655
+ if (heritageRoot) {
656
+ const inherited = parseInheritedMethods(cls, source, checker, skip, unresolved);
657
+ // Merge: child methods win over inherited
658
+ const parentOnly = inherited
659
+ .filter((m) => !childNames.has(m.name))
660
+ .map((m) => ({ ...m, inherited: true }));
661
+ return { methods: [...childMethods, ...parentOnly], unresolvedHeritage: unresolved };
662
+ }
663
+ return { methods: childMethods, unresolvedHeritage: unresolved };
664
+ }
665
+ //# sourceMappingURL=handler-parser.js.map