@geekmidas/cli 10.0.0-alpha.15 → 10.0.0-alpha.150

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 (438) hide show
  1. package/README.md +313 -380
  2. package/bin/adjacent-tsconfig.mjs +46 -8
  3. package/bin/gkm.mjs +11 -3
  4. package/bin/owning-tsconfig-jsx-register.mjs +18 -0
  5. package/bin/owning-tsconfig-jsx.mjs +108 -0
  6. package/dist/EndpointGenerator-CusLH-9S.mjs +1037 -0
  7. package/dist/EndpointGenerator-CusLH-9S.mjs.map +1 -0
  8. package/dist/EndpointGenerator-DyLMYClE.cjs +1096 -0
  9. package/dist/EndpointGenerator-DyLMYClE.cjs.map +1 -0
  10. package/dist/GoDaddyProvider-CytuBrRm.cjs +412 -0
  11. package/dist/GoDaddyProvider-CytuBrRm.cjs.map +1 -0
  12. package/dist/GoDaddyProvider-W0Dxd5v9.mjs +412 -0
  13. package/dist/GoDaddyProvider-W0Dxd5v9.mjs.map +1 -0
  14. package/dist/{HostingerProvider-BZFGYYVA.cjs → HostingerProvider-CCc9xoBN.cjs} +23 -9
  15. package/dist/HostingerProvider-CCc9xoBN.cjs.map +1 -0
  16. package/dist/{HostingerProvider-BY26bWwB.mjs → HostingerProvider-DaQr2ueR.mjs} +23 -9
  17. package/dist/HostingerProvider-DaQr2ueR.mjs.map +1 -0
  18. package/dist/LegacyStateStore-BDA0rx3b.cjs +124 -0
  19. package/dist/LegacyStateStore-BDA0rx3b.cjs.map +1 -0
  20. package/dist/LegacyStateStore-BTcTbCGk.mjs +124 -0
  21. package/dist/LegacyStateStore-BTcTbCGk.mjs.map +1 -0
  22. package/dist/LocalStateStore-BNuQoZYe.cjs +178 -0
  23. package/dist/LocalStateStore-BNuQoZYe.cjs.map +1 -0
  24. package/dist/LocalStateStore-CqpCKVvi.mjs +167 -0
  25. package/dist/LocalStateStore-CqpCKVvi.mjs.map +1 -0
  26. package/dist/OpenApiTsGenerator-BTMuu1WS.mjs +534 -0
  27. package/dist/OpenApiTsGenerator-BTMuu1WS.mjs.map +1 -0
  28. package/dist/OpenApiTsGenerator-CI-tceXV.cjs +539 -0
  29. package/dist/OpenApiTsGenerator-CI-tceXV.cjs.map +1 -0
  30. package/dist/{Route53Provider-Cvj40A8I.mjs → Route53Provider-Di_SD9CF.mjs} +3 -3
  31. package/dist/Route53Provider-Di_SD9CF.mjs.map +1 -0
  32. package/dist/{Route53Provider-DVILBsvV.cjs → Route53Provider-emLuQHVw.cjs} +3 -3
  33. package/dist/Route53Provider-emLuQHVw.cjs.map +1 -0
  34. package/dist/S3StateStore-BpsGWDMK.mjs +223 -0
  35. package/dist/S3StateStore-BpsGWDMK.mjs.map +1 -0
  36. package/dist/S3StateStore-nrmSClXN.cjs +222 -0
  37. package/dist/S3StateStore-nrmSClXN.cjs.map +1 -0
  38. package/dist/SSMStateStore-DrPCC_VN.mjs +205 -0
  39. package/dist/SSMStateStore-DrPCC_VN.mjs.map +1 -0
  40. package/dist/SSMStateStore-hexM8C7n.cjs +204 -0
  41. package/dist/SSMStateStore-hexM8C7n.cjs.map +1 -0
  42. package/dist/SubscriberGenerator-BNJyPmXJ.cjs +848 -0
  43. package/dist/SubscriberGenerator-BNJyPmXJ.cjs.map +1 -0
  44. package/dist/SubscriberGenerator-CzPrixYu.mjs +783 -0
  45. package/dist/SubscriberGenerator-CzPrixYu.mjs.map +1 -0
  46. package/dist/add-DXMYV5ak.mjs +711 -0
  47. package/dist/add-DXMYV5ak.mjs.map +1 -0
  48. package/dist/add-DgAeo6ht.cjs +713 -0
  49. package/dist/add-DgAeo6ht.cjs.map +1 -0
  50. package/dist/appPorts-BoXMwolc.mjs +249 -0
  51. package/dist/appPorts-BoXMwolc.mjs.map +1 -0
  52. package/dist/appPorts-IW-OZmRi.cjs +296 -0
  53. package/dist/appPorts-IW-OZmRi.cjs.map +1 -0
  54. package/dist/apps-Bb05wCBm.mjs +5534 -0
  55. package/dist/apps-Bb05wCBm.mjs.map +1 -0
  56. package/dist/apps-CMLyyVGQ.cjs +6148 -0
  57. package/dist/apps-CMLyyVGQ.cjs.map +1 -0
  58. package/dist/aws-8QQ8n-t6.mjs +89 -0
  59. package/dist/aws-8QQ8n-t6.mjs.map +1 -0
  60. package/dist/aws-DY9NqQIT.cjs +100 -0
  61. package/dist/aws-DY9NqQIT.cjs.map +1 -0
  62. package/dist/awsStore-Bx5nCFnS.mjs +121 -0
  63. package/dist/awsStore-Bx5nCFnS.mjs.map +1 -0
  64. package/dist/awsStore-u3ehhMoY.cjs +138 -0
  65. package/dist/awsStore-u3ehhMoY.cjs.map +1 -0
  66. package/dist/{backup-provisioner-DIVCbfee.mjs → backup-provisioner-C8DnCmxK.mjs} +2 -2
  67. package/dist/backup-provisioner-C8DnCmxK.mjs.map +1 -0
  68. package/dist/{backup-provisioner-BmhIO_Yr.cjs → backup-provisioner-oDEsPj02.cjs} +2 -2
  69. package/dist/backup-provisioner-oDEsPj02.cjs.map +1 -0
  70. package/dist/backups/runner.cjs +519 -0
  71. package/dist/backups/runner.cjs.map +1 -0
  72. package/dist/backups/runner.d.cts +102 -0
  73. package/dist/backups/runner.d.cts.map +1 -0
  74. package/dist/backups/runner.d.mts +102 -0
  75. package/dist/backups/runner.d.mts.map +1 -0
  76. package/dist/backups/runner.mjs +506 -0
  77. package/dist/backups/runner.mjs.map +1 -0
  78. package/dist/{bundler-BodTL4kf.mjs → bundler-C1kDZyQ-.mjs} +59 -14
  79. package/dist/bundler-C1kDZyQ-.mjs.map +1 -0
  80. package/dist/{bundler-BeNDZdHQ.cjs → bundler-CD9Ug2uu.cjs} +59 -14
  81. package/dist/bundler-CD9Ug2uu.cjs.map +1 -0
  82. package/dist/cli-35yoGg9o.cjs +71 -0
  83. package/dist/cli-35yoGg9o.cjs.map +1 -0
  84. package/dist/cli-BAcJaRG7.mjs +71 -0
  85. package/dist/cli-BAcJaRG7.mjs.map +1 -0
  86. package/dist/compose-BZTh5HR3.mjs +1560 -0
  87. package/dist/compose-BZTh5HR3.mjs.map +1 -0
  88. package/dist/compose-CAhGIfG8.mjs +2877 -0
  89. package/dist/compose-CAhGIfG8.mjs.map +1 -0
  90. package/dist/compose-DF08HNJE.cjs +2966 -0
  91. package/dist/compose-DF08HNJE.cjs.map +1 -0
  92. package/dist/compose-KV6q3cEz.cjs +1919 -0
  93. package/dist/compose-KV6q3cEz.cjs.map +1 -0
  94. package/dist/config-BLrAd7Of.mjs +659 -0
  95. package/dist/config-BLrAd7Of.mjs.map +1 -0
  96. package/dist/config-CRk2vdSp.d.mts +268 -0
  97. package/dist/config-CRk2vdSp.d.mts.map +1 -0
  98. package/dist/config-juUyBlb1.cjs +772 -0
  99. package/dist/config-juUyBlb1.cjs.map +1 -0
  100. package/dist/config-oBgsbLip.d.cts +268 -0
  101. package/dist/config-oBgsbLip.d.cts.map +1 -0
  102. package/dist/config.cjs +11 -3
  103. package/dist/config.d.cts +4 -117
  104. package/dist/config.d.mts +4 -117
  105. package/dist/config.mjs +3 -3
  106. package/dist/credentialSchemas-BAklWDna.cjs +271 -0
  107. package/dist/credentialSchemas-BAklWDna.cjs.map +1 -0
  108. package/dist/credentialSchemas-mz9QZTYh.mjs +236 -0
  109. package/dist/credentialSchemas-mz9QZTYh.mjs.map +1 -0
  110. package/dist/credentials-B72Jrk66.mjs +1817 -0
  111. package/dist/credentials-B72Jrk66.mjs.map +1 -0
  112. package/dist/credentials-Dmhuj3FX.cjs +2272 -0
  113. package/dist/credentials-Dmhuj3FX.cjs.map +1 -0
  114. package/dist/databases-DawSdqBI.cjs +703 -0
  115. package/dist/databases-DawSdqBI.cjs.map +1 -0
  116. package/dist/databases-mzSUFBTw.mjs +588 -0
  117. package/dist/databases-mzSUFBTw.mjs.map +1 -0
  118. package/dist/define-6poNqm5O.mjs +106 -0
  119. package/dist/define-6poNqm5O.mjs.map +1 -0
  120. package/dist/define-crmMcXFS.cjs +153 -0
  121. package/dist/define-crmMcXFS.cjs.map +1 -0
  122. package/dist/deploy/public.cjs +211 -0
  123. package/dist/deploy/public.cjs.map +1 -0
  124. package/dist/deploy/public.d.cts +647 -0
  125. package/dist/deploy/public.d.cts.map +1 -0
  126. package/dist/deploy/public.d.mts +647 -0
  127. package/dist/deploy/public.d.mts.map +1 -0
  128. package/dist/deploy/public.mjs +144 -0
  129. package/dist/deploy/public.mjs.map +1 -0
  130. package/dist/deploy/sniffer-envparser-worker.cjs +54 -0
  131. package/dist/deploy/sniffer-envparser-worker.cjs.map +1 -0
  132. package/dist/deploy/sniffer-envparser-worker.d.cts +1 -0
  133. package/dist/deploy/sniffer-envparser-worker.d.mts +1 -0
  134. package/dist/deploy/sniffer-envparser-worker.mjs +55 -0
  135. package/dist/deploy/sniffer-envparser-worker.mjs.map +1 -0
  136. package/dist/deploy/sniffer-hooks.cjs +1 -1
  137. package/dist/deploy/sniffer-hooks.mjs +1 -1
  138. package/dist/deploy/sniffer-loader.cjs +2 -2
  139. package/dist/deploy/sniffer-loader.mjs +1 -1
  140. package/dist/deploy/sniffer-routes-worker.cjs +2 -2
  141. package/dist/deploy/sniffer-routes-worker.mjs +1 -1
  142. package/dist/deploy-BV6Tw73K.cjs +3892 -0
  143. package/dist/deploy-BV6Tw73K.cjs.map +1 -0
  144. package/dist/deploy-C4XjPy-a.mjs +3836 -0
  145. package/dist/deploy-C4XjPy-a.mjs.map +1 -0
  146. package/dist/discover-CRywE7yc.cjs +1085 -0
  147. package/dist/discover-CRywE7yc.cjs.map +1 -0
  148. package/dist/discover-DbDrCQ8h.mjs +940 -0
  149. package/dist/discover-DbDrCQ8h.mjs.map +1 -0
  150. package/dist/docker-B0di7_Ub.cjs +1514 -0
  151. package/dist/docker-B0di7_Ub.cjs.map +1 -0
  152. package/dist/docker-D_NN2Z6W.mjs +1407 -0
  153. package/dist/docker-D_NN2Z6W.mjs.map +1 -0
  154. package/dist/dokploy-DDyZ0o4M.mjs +38 -0
  155. package/dist/dokploy-DDyZ0o4M.mjs.map +1 -0
  156. package/dist/dokploy-FFNHKz37.cjs +38 -0
  157. package/dist/dokploy-FFNHKz37.cjs.map +1 -0
  158. package/dist/drivers-aM87NQJi.cjs +224 -0
  159. package/dist/drivers-aM87NQJi.cjs.map +1 -0
  160. package/dist/drivers-uxLBq3e3.mjs +195 -0
  161. package/dist/drivers-uxLBq3e3.mjs.map +1 -0
  162. package/dist/eas-6_Z1ImVg.mjs +334 -0
  163. package/dist/eas-6_Z1ImVg.mjs.map +1 -0
  164. package/dist/eas-BetrZzjq.cjs +337 -0
  165. package/dist/eas-BetrZzjq.cjs.map +1 -0
  166. package/dist/emit-Bj6XSivk.mjs +136 -0
  167. package/dist/emit-Bj6XSivk.mjs.map +1 -0
  168. package/dist/emit-CDC__ubE.cjs +147 -0
  169. package/dist/emit-CDC__ubE.cjs.map +1 -0
  170. package/dist/encryption-BrRVjItb.cjs +90 -0
  171. package/dist/encryption-BrRVjItb.cjs.map +1 -0
  172. package/dist/encryption-DGnfdO68.mjs +89 -0
  173. package/dist/encryption-DGnfdO68.mjs.map +1 -0
  174. package/dist/engine-8TjM26dd.mjs +3217 -0
  175. package/dist/engine-8TjM26dd.mjs.map +1 -0
  176. package/dist/engine-C36N8por.cjs +3330 -0
  177. package/dist/engine-C36N8por.cjs.map +1 -0
  178. package/dist/errors-D8Gwp5kU.mjs +23 -0
  179. package/dist/errors-D8Gwp5kU.mjs.map +1 -0
  180. package/dist/errors-DMC4Umsb.cjs +34 -0
  181. package/dist/errors-DMC4Umsb.cjs.map +1 -0
  182. package/dist/github-BOu0bETi.cjs +901 -0
  183. package/dist/github-BOu0bETi.cjs.map +1 -0
  184. package/dist/github-Ct6XDkzE.mjs +900 -0
  185. package/dist/github-Ct6XDkzE.mjs.map +1 -0
  186. package/dist/googlePlay-BaRsxlJo.mjs +931 -0
  187. package/dist/googlePlay-BaRsxlJo.mjs.map +1 -0
  188. package/dist/googlePlay-JAxXMaGu.cjs +931 -0
  189. package/dist/googlePlay-JAxXMaGu.cjs.map +1 -0
  190. package/dist/{index-D-iAVHx-.d.cts → index-B35vTdAW.d.cts} +39 -15
  191. package/dist/index-B35vTdAW.d.cts.map +1 -0
  192. package/dist/{index-Cd-qeOam.d.mts → index-Dv1Zj86i.d.mts} +39 -15
  193. package/dist/index-Dv1Zj86i.d.mts.map +1 -0
  194. package/dist/index.cjs +13594 -12347
  195. package/dist/index.cjs.map +1 -1
  196. package/dist/index.mjs +13541 -12292
  197. package/dist/index.mjs.map +1 -1
  198. package/dist/local-D7WVQcJJ.mjs +224 -0
  199. package/dist/local-D7WVQcJJ.mjs.map +1 -0
  200. package/dist/local-DFPeCIJi.cjs +241 -0
  201. package/dist/local-DFPeCIJi.cjs.map +1 -0
  202. package/dist/migrate-BMIUYmpM.mjs +267 -0
  203. package/dist/migrate-BMIUYmpM.mjs.map +1 -0
  204. package/dist/migrate-CnE-X40v.mjs +181 -0
  205. package/dist/migrate-CnE-X40v.mjs.map +1 -0
  206. package/dist/migrate-CvuWFjos.cjs +181 -0
  207. package/dist/migrate-CvuWFjos.cjs.map +1 -0
  208. package/dist/migrate-DdE8kF0j.cjs +272 -0
  209. package/dist/migrate-DdE8kF0j.cjs.map +1 -0
  210. package/dist/notes-C_4SO0x4.mjs +399 -0
  211. package/dist/notes-C_4SO0x4.mjs.map +1 -0
  212. package/dist/notes-ORze6zXA.cjs +500 -0
  213. package/dist/notes-ORze6zXA.cjs.map +1 -0
  214. package/dist/openapi.cjs +213 -7
  215. package/dist/openapi.cjs.map +1 -0
  216. package/dist/openapi.d.cts +32 -8
  217. package/dist/openapi.d.cts.map +1 -1
  218. package/dist/openapi.d.mts +32 -8
  219. package/dist/openapi.d.mts.map +1 -1
  220. package/dist/openapi.mjs +208 -2
  221. package/dist/openapi.mjs.map +1 -0
  222. package/dist/projectBucket-C9x0gzEO.cjs +263 -0
  223. package/dist/projectBucket-C9x0gzEO.cjs.map +1 -0
  224. package/dist/projectBucket-CdRj4IyR.mjs +222 -0
  225. package/dist/projectBucket-CdRj4IyR.mjs.map +1 -0
  226. package/dist/provider-BqpjG9QM.cjs +57 -0
  227. package/dist/provider-BqpjG9QM.cjs.map +1 -0
  228. package/dist/provider-CEOKk8NS.mjs +46 -0
  229. package/dist/provider-CEOKk8NS.mjs.map +1 -0
  230. package/dist/publish-CL376jrq.cjs +124 -0
  231. package/dist/publish-CL376jrq.cjs.map +1 -0
  232. package/dist/publish-DkkWS3Pj.mjs +123 -0
  233. package/dist/publish-DkkWS3Pj.mjs.map +1 -0
  234. package/dist/ready-BNh3zsSn.cjs +404 -0
  235. package/dist/ready-BNh3zsSn.cjs.map +1 -0
  236. package/dist/ready-g25dcGzK.mjs +375 -0
  237. package/dist/ready-g25dcGzK.mjs.map +1 -0
  238. package/dist/reconcile/public.cjs +3 -5
  239. package/dist/reconcile/public.d.cts +31 -89
  240. package/dist/reconcile/public.d.cts.map +1 -1
  241. package/dist/reconcile/public.d.mts +31 -89
  242. package/dist/reconcile/public.d.mts.map +1 -1
  243. package/dist/reconcile/public.mjs +3 -3
  244. package/dist/{reconcile-DhQ00DpU.mjs → reconcile--I7V4Klj.mjs} +2 -2
  245. package/dist/{reconcile-DhQ00DpU.mjs.map → reconcile--I7V4Klj.mjs.map} +1 -1
  246. package/dist/{reconcile-Dd2iyILf.cjs → reconcile-CuCQBa5-.cjs} +3 -3
  247. package/dist/{reconcile-Dd2iyILf.cjs.map → reconcile-CuCQBa5-.cjs.map} +1 -1
  248. package/dist/resolve-BXzDwYUS.cjs +316 -0
  249. package/dist/resolve-BXzDwYUS.cjs.map +1 -0
  250. package/dist/resolve-CZ_Wel7j.mjs +263 -0
  251. package/dist/resolve-CZ_Wel7j.mjs.map +1 -0
  252. package/dist/rollback-D_FXI_K5.mjs +136 -0
  253. package/dist/rollback-D_FXI_K5.mjs.map +1 -0
  254. package/dist/rollback-p1y0KlED.cjs +165 -0
  255. package/dist/rollback-p1y0KlED.cjs.map +1 -0
  256. package/dist/runtime-CFvcLEJW.d.cts +82 -0
  257. package/dist/runtime-CFvcLEJW.d.cts.map +1 -0
  258. package/dist/runtime-dwsH6ddo.d.mts +82 -0
  259. package/dist/runtime-dwsH6ddo.d.mts.map +1 -0
  260. package/dist/s3-CV5baYeq.mjs +215 -0
  261. package/dist/s3-CV5baYeq.mjs.map +1 -0
  262. package/dist/s3-DTX4Kkmn.cjs +215 -0
  263. package/dist/s3-DTX4Kkmn.cjs.map +1 -0
  264. package/dist/sandbox/config-worker.cjs +43 -0
  265. package/dist/sandbox/config-worker.cjs.map +1 -0
  266. package/dist/sandbox/config-worker.d.cts +1 -0
  267. package/dist/sandbox/config-worker.d.mts +1 -0
  268. package/dist/sandbox/config-worker.mjs +44 -0
  269. package/dist/sandbox/config-worker.mjs.map +1 -0
  270. package/dist/sandbox/credentials-worker.cjs +53 -0
  271. package/dist/sandbox/credentials-worker.cjs.map +1 -0
  272. package/dist/sandbox/credentials-worker.d.cts +1 -0
  273. package/dist/sandbox/credentials-worker.d.mts +1 -0
  274. package/dist/sandbox/credentials-worker.mjs +54 -0
  275. package/dist/sandbox/credentials-worker.mjs.map +1 -0
  276. package/dist/sandbox/discover-worker.cjs +47 -0
  277. package/dist/sandbox/discover-worker.cjs.map +1 -0
  278. package/dist/sandbox/discover-worker.d.cts +1 -0
  279. package/dist/sandbox/discover-worker.d.mts +1 -0
  280. package/dist/sandbox/discover-worker.mjs +48 -0
  281. package/dist/sandbox/discover-worker.mjs.map +1 -0
  282. package/dist/sandbox/migrate-worker.cjs +75 -0
  283. package/dist/sandbox/migrate-worker.cjs.map +1 -0
  284. package/dist/sandbox/migrate-worker.d.cts +1 -0
  285. package/dist/sandbox/migrate-worker.d.mts +1 -0
  286. package/dist/sandbox/migrate-worker.mjs +76 -0
  287. package/dist/sandbox/migrate-worker.mjs.map +1 -0
  288. package/dist/{workspace-mFpI_ky_.cjs → schemas-BCwKKA42.mjs} +399 -1162
  289. package/dist/schemas-BCwKKA42.mjs.map +1 -0
  290. package/dist/{workspace-CgwmXEtc.mjs → schemas-BQ_v0lEX.cjs} +487 -971
  291. package/dist/schemas-BQ_v0lEX.cjs.map +1 -0
  292. package/dist/secretsManager-CQORubp9.mjs +97 -0
  293. package/dist/secretsManager-CQORubp9.mjs.map +1 -0
  294. package/dist/secretsManager-RAGcEDX1.cjs +108 -0
  295. package/dist/secretsManager-RAGcEDX1.cjs.map +1 -0
  296. package/dist/seeds-B3xvUAQf.cjs +363 -0
  297. package/dist/seeds-B3xvUAQf.cjs.map +1 -0
  298. package/dist/seeds-BCC8vAXR.mjs +298 -0
  299. package/dist/seeds-BCC8vAXR.mjs.map +1 -0
  300. package/dist/serverSetup-BykJrnYe.cjs +652 -0
  301. package/dist/serverSetup-BykJrnYe.cjs.map +1 -0
  302. package/dist/serverSetup-CkuvIoej.mjs +652 -0
  303. package/dist/serverSetup-CkuvIoej.mjs.map +1 -0
  304. package/dist/sniffer-BIpoMNGz.mjs +1824 -0
  305. package/dist/sniffer-BIpoMNGz.mjs.map +1 -0
  306. package/dist/sniffer-DiBMi93N.cjs +1997 -0
  307. package/dist/sniffer-DiBMi93N.cjs.map +1 -0
  308. package/dist/snsSubscriptions-CkO_zk0j.cjs +1173 -0
  309. package/dist/snsSubscriptions-CkO_zk0j.cjs.map +1 -0
  310. package/dist/snsSubscriptions-CrmfcJfv.mjs +1048 -0
  311. package/dist/snsSubscriptions-CrmfcJfv.mjs.map +1 -0
  312. package/dist/sst-BZ9sTG8H.mjs +462 -0
  313. package/dist/sst-BZ9sTG8H.mjs.map +1 -0
  314. package/dist/sst-D233GoQY.cjs +485 -0
  315. package/dist/sst-D233GoQY.cjs.map +1 -0
  316. package/dist/stack-1yXKqI83.cjs +2287 -0
  317. package/dist/stack-1yXKqI83.cjs.map +1 -0
  318. package/dist/stack-pUz70Rmw.mjs +2124 -0
  319. package/dist/stack-pUz70Rmw.mjs.map +1 -0
  320. package/dist/stage-D6E_TlvR.mjs +302 -0
  321. package/dist/stage-D6E_TlvR.mjs.map +1 -0
  322. package/dist/stage-DAhomyUk.cjs +313 -0
  323. package/dist/stage-DAhomyUk.cjs.map +1 -0
  324. package/dist/stages-Bs1THSy7.cjs +190 -0
  325. package/dist/stages-Bs1THSy7.cjs.map +1 -0
  326. package/dist/stages-_xCG4Ymu.mjs +190 -0
  327. package/dist/stages-_xCG4Ymu.mjs.map +1 -0
  328. package/dist/target/public.cjs +15 -0
  329. package/dist/target/public.d.cts +28 -0
  330. package/dist/target/public.d.cts.map +1 -0
  331. package/dist/target/public.d.mts +28 -0
  332. package/dist/target/public.d.mts.map +1 -0
  333. package/dist/target/public.mjs +4 -0
  334. package/dist/terminal-CKBLsg6b.cjs +85 -0
  335. package/dist/terminal-CKBLsg6b.cjs.map +1 -0
  336. package/dist/terminal-CRinpE1t.mjs +85 -0
  337. package/dist/terminal-CRinpE1t.mjs.map +1 -0
  338. package/dist/types-Bl_CwZC9.cjs +90 -0
  339. package/dist/types-Bl_CwZC9.cjs.map +1 -0
  340. package/dist/{types-BGo5TaNE.d.mts → types-Dk--xVOT.d.cts} +2234 -439
  341. package/dist/types-Dk--xVOT.d.cts.map +1 -0
  342. package/dist/{types-C5ZNpUad.d.cts → types-DwQYpd_0.d.mts} +2232 -439
  343. package/dist/types-DwQYpd_0.d.mts.map +1 -0
  344. package/dist/types-Y1NfWlyG.mjs +61 -0
  345. package/dist/types-Y1NfWlyG.mjs.map +1 -0
  346. package/dist/utils-D2Nk1Nv2.cjs +205 -0
  347. package/dist/utils-D2Nk1Nv2.cjs.map +1 -0
  348. package/dist/utils-D_fxUqvU.mjs +156 -0
  349. package/dist/utils-D_fxUqvU.mjs.map +1 -0
  350. package/dist/vitest.cjs +65 -0
  351. package/dist/vitest.cjs.map +1 -0
  352. package/dist/vitest.d.cts +29 -0
  353. package/dist/vitest.d.cts.map +1 -0
  354. package/dist/vitest.d.mts +29 -0
  355. package/dist/vitest.d.mts.map +1 -0
  356. package/dist/vitest.mjs +65 -0
  357. package/dist/vitest.mjs.map +1 -0
  358. package/dist/workerRuntime-BXfhbe13.cjs +108 -0
  359. package/dist/workerRuntime-BXfhbe13.cjs.map +1 -0
  360. package/dist/workerRuntime-CsOyBRx2.mjs +79 -0
  361. package/dist/workerRuntime-CsOyBRx2.mjs.map +1 -0
  362. package/dist/workspace/index.cjs +6 -2
  363. package/dist/workspace/index.d.cts +3 -3
  364. package/dist/workspace/index.d.mts +3 -3
  365. package/dist/workspace/index.mjs +2 -2
  366. package/dist/workspace-1szcahj9.cjs +2916 -0
  367. package/dist/workspace-1szcahj9.cjs.map +1 -0
  368. package/dist/workspace-DFGsrjGD.mjs +2480 -0
  369. package/dist/workspace-DFGsrjGD.mjs.map +1 -0
  370. package/package.json +66 -14
  371. package/dist/HostingerProvider-BY26bWwB.mjs.map +0 -1
  372. package/dist/HostingerProvider-BZFGYYVA.cjs.map +0 -1
  373. package/dist/LocalStateProvider-7HR6SS2t.cjs +0 -48
  374. package/dist/LocalStateProvider-7HR6SS2t.cjs.map +0 -1
  375. package/dist/LocalStateProvider-D7QyJoLM.mjs +0 -48
  376. package/dist/LocalStateProvider-D7QyJoLM.mjs.map +0 -1
  377. package/dist/Route53Provider-Cvj40A8I.mjs.map +0 -1
  378. package/dist/Route53Provider-DVILBsvV.cjs.map +0 -1
  379. package/dist/SSMStateProvider-B0Hu1MKZ.mjs +0 -75
  380. package/dist/SSMStateProvider-B0Hu1MKZ.mjs.map +0 -1
  381. package/dist/SSMStateProvider-VrQ-yeqd.cjs +0 -74
  382. package/dist/SSMStateProvider-VrQ-yeqd.cjs.map +0 -1
  383. package/dist/backup-provisioner-BmhIO_Yr.cjs.map +0 -1
  384. package/dist/backup-provisioner-DIVCbfee.mjs.map +0 -1
  385. package/dist/bundler-BeNDZdHQ.cjs.map +0 -1
  386. package/dist/bundler-BodTL4kf.mjs.map +0 -1
  387. package/dist/config-Q1rvKHvw.cjs +0 -467
  388. package/dist/config-Q1rvKHvw.cjs.map +0 -1
  389. package/dist/config-pqGD3hF9.mjs +0 -414
  390. package/dist/config-pqGD3hF9.mjs.map +0 -1
  391. package/dist/config.d.cts.map +0 -1
  392. package/dist/config.d.mts.map +0 -1
  393. package/dist/credentials-BekkKtY_.mjs +0 -2780
  394. package/dist/credentials-BekkKtY_.mjs.map +0 -1
  395. package/dist/credentials-Q6F0uqJq.cjs +0 -2917
  396. package/dist/credentials-Q6F0uqJq.cjs.map +0 -1
  397. package/dist/discover-BERGFg8v.cjs +0 -288
  398. package/dist/discover-BERGFg8v.cjs.map +0 -1
  399. package/dist/discover-CK-n3w6b.mjs +0 -244
  400. package/dist/discover-CK-n3w6b.mjs.map +0 -1
  401. package/dist/emit-BdoPFjZf.cjs +0 -253
  402. package/dist/emit-BdoPFjZf.cjs.map +0 -1
  403. package/dist/emit-Bzq7JsMP.mjs +0 -224
  404. package/dist/emit-Bzq7JsMP.mjs.map +0 -1
  405. package/dist/fullstack-secrets-BET8gqwK.mjs +0 -81
  406. package/dist/fullstack-secrets-BET8gqwK.mjs.map +0 -1
  407. package/dist/fullstack-secrets-DXsWO-5m.cjs +0 -92
  408. package/dist/fullstack-secrets-DXsWO-5m.cjs.map +0 -1
  409. package/dist/generator-LfZU7NlU.mjs +0 -247
  410. package/dist/generator-LfZU7NlU.mjs.map +0 -1
  411. package/dist/generator-Wdfp0jCS.cjs +0 -282
  412. package/dist/generator-Wdfp0jCS.cjs.map +0 -1
  413. package/dist/github-BfflNPVe.cjs +0 -203
  414. package/dist/github-BfflNPVe.cjs.map +0 -1
  415. package/dist/github-CRwnxKmD.mjs +0 -203
  416. package/dist/github-CRwnxKmD.mjs.map +0 -1
  417. package/dist/index-Cd-qeOam.d.mts.map +0 -1
  418. package/dist/index-D-iAVHx-.d.cts.map +0 -1
  419. package/dist/keystore-B4PRlbgE.mjs +0 -81
  420. package/dist/keystore-B4PRlbgE.mjs.map +0 -1
  421. package/dist/keystore-DgGRj2Yy.cjs +0 -98
  422. package/dist/keystore-DgGRj2Yy.cjs.map +0 -1
  423. package/dist/openapi-Dcbme-Us.cjs +0 -2038
  424. package/dist/openapi-Dcbme-Us.cjs.map +0 -1
  425. package/dist/openapi-vy4JzhUv.mjs +0 -1991
  426. package/dist/openapi-vy4JzhUv.mjs.map +0 -1
  427. package/dist/storage-C-30BD1e.cjs +0 -272
  428. package/dist/storage-C-30BD1e.cjs.map +0 -1
  429. package/dist/storage-P_b3w7uj.mjs +0 -231
  430. package/dist/storage-P_b3w7uj.mjs.map +0 -1
  431. package/dist/sync-B3xxXtJT.mjs +0 -88
  432. package/dist/sync-B3xxXtJT.mjs.map +0 -1
  433. package/dist/sync-D7uTIIEi.cjs +0 -111
  434. package/dist/sync-D7uTIIEi.cjs.map +0 -1
  435. package/dist/types-BGo5TaNE.d.mts.map +0 -1
  436. package/dist/types-C5ZNpUad.d.cts.map +0 -1
  437. package/dist/workspace-CgwmXEtc.mjs.map +0 -1
  438. package/dist/workspace-mFpI_ky_.cjs.map +0 -1
@@ -0,0 +1,783 @@
1
+ import { t as GkmError } from "./errors-D8Gwp5kU.mjs";
2
+ import { n as runtimeFor } from "./EndpointGenerator-CusLH-9S.mjs";
3
+ import { C as subscriberTokenKey, S as subscriberConnectionKey, v as ConstructGenerator } from "./discover-DbDrCQ8h.mjs";
4
+ import { dirname, join, relative } from "node:path";
5
+ import { access, mkdir, writeFile } from "node:fs/promises";
6
+ import { createHash } from "node:crypto";
7
+ import { INBOX_EVENT, canonicalId, kebabCase, provideKey } from "@geekmidas/manifest";
8
+ import { pathToFileURL } from "node:url";
9
+ import { Subscriber } from "@geekmidas/constructs/subscribers";
10
+ //#region src/reconcile/inboxRelay.ts
11
+ /**
12
+ * Receiving mail locally: Mailpit's webhook, and the worker it posts to.
13
+ *
14
+ * Deployed, SES stores each message and publishes its receipt notification on
15
+ * the inbox's topic. Locally Mailpit receives it, and its webhook posts each
16
+ * message to one route — `POST /__gkm/inbox` on the worker that runs the
17
+ * inbox subscribers — which hands it to the same receiver `mailbox.receive`
18
+ * calls in a feature test (`receiveMail` in `@geekmidas/constructs/inbox`).
19
+ *
20
+ * Shared by every local stage and the local compose stack: each asks this
21
+ * module which worker relays and with what token, and supplies only how that
22
+ * worker is reached from its Mailpit — the host's gateway, or the stack's
23
+ * network.
24
+ */
25
+ /** The route Mailpit posts each message it receives to. */
26
+ const INBOX_ROUTE = "/__gkm/inbox";
27
+ /** The env key the relaying worker reads its token from. */
28
+ const INBOX_RELAY_TOKEN_KEY = "GKM_INBOX_RELAY_TOKEN";
29
+ /**
30
+ * Inbox subscribers in more than one worker. Mailpit posts to one webhook, so
31
+ * locally one worker receives for every inbox — #343 lifts this.
32
+ */
33
+ var InboxSubscribersSpanWorkers = class extends GkmError {
34
+ workers;
35
+ constructor(workers) {
36
+ super(`Inbox subscribers run in ${workers.map((w) => `'${w}'`).join(" and ")}, and locally mail is received by one worker: Mailpit posts each message to a single webhook. Bind every worker.inbox(…) to one worker for now (#343).`);
37
+ this.workers = workers;
38
+ this.name = "InboxSubscribersSpanWorkers";
39
+ }
40
+ };
41
+ /**
42
+ * The worker whose route Mailpit posts to: the one that runs every inbox
43
+ * subscriber. `undefined` when no inbox has a subscriber.
44
+ */
45
+ function inboxRelayWorker(manifest, subscribers) {
46
+ const topicKeys = /* @__PURE__ */ new Set();
47
+ for (const declaration of Object.values(manifest)) {
48
+ if (declaration.kind !== "inbox") continue;
49
+ topicKeys.add(provideKey(declaration.topic, "publisherConnectionString"));
50
+ }
51
+ if (topicKeys.size === 0) return void 0;
52
+ const workers = Object.keys(subscribers).sort().filter((worker) => (subscribers[worker] ?? []).some(({ connectionKey }) => topicKeys.has(connectionKey)));
53
+ if (workers.length > 1) throw new InboxSubscribersSpanWorkers(workers);
54
+ return workers[0];
55
+ }
56
+ /**
57
+ * The token Mailpit presents in the webhook's query — it cannot send a
58
+ * header. Derived as a bucket's webhook token is: from the stage's seed where
59
+ * one is given, and the project; not salted by the stage, since `gkm dev` and
60
+ * `gkm test` share one Mailpit.
61
+ */
62
+ function inboxRelayToken(project, seed) {
63
+ return createHash("sha256").update(`${seed ? `${seed}:` : ""}${project}:inbox-webhook`).digest("base64url").slice(0, 32);
64
+ }
65
+ /** Mailpit's `MP_WEBHOOK_URL`: the relay route at `base`, with the token. */
66
+ function inboxWebhookUrl(base, token) {
67
+ return `${base.replace(/\/+$/, "")}${INBOX_ROUTE}?token=${encodeURIComponent(token)}`;
68
+ }
69
+ //#endregion
70
+ //#region src/generators/subscriberRoute.ts
71
+ /**
72
+ * Where SNS pushes a topic subscriber's messages, on the server that runs it:
73
+ * named after the subscriber's export.
74
+ *
75
+ * One definition for both sides — the generated server mounts the route, and
76
+ * the stack exposes exactly these paths on a worker's host — so the path the
77
+ * edge lets through and the path the worker answers cannot drift.
78
+ */
79
+ const SUBSCRIBER_ROUTE_PREFIX = "/__gkm/subscribers/";
80
+ /** The route a subscriber's pushes arrive on. */
81
+ function subscriberRoute(exportName) {
82
+ return `${SUBSCRIBER_ROUTE_PREFIX}${exportName}`;
83
+ }
84
+ /**
85
+ * Where the deploy hands a server the SNS subscriptions it made for its
86
+ * routes: a JSON object of subscriber export → subscription ARN. Against SNS
87
+ * itself a server mounts a route only for a subscription recorded here, and
88
+ * refuses a notification that names another.
89
+ */
90
+ const SNS_SUBSCRIPTIONS_KEY = "GKM_SNS_SUBSCRIPTIONS";
91
+ /**
92
+ * Where a local object store posts a bucket's events, on the process that runs
93
+ * the bucket's subscribers: named after the bucket. Never on a public host —
94
+ * MinIO reaches it over the stack's network, or the host's.
95
+ */
96
+ const OBJECTS_ROUTE_PREFIX = "/__gkm/objects/";
97
+ /** The route a bucket's events are posted to. */
98
+ function objectsRoute(bucketId) {
99
+ return `${OBJECTS_ROUTE_PREFIX}${bucketId}`;
100
+ }
101
+ //#endregion
102
+ //#region src/reconcile/fakes.ts
103
+ /**
104
+ * Fakes, read from where the convention puts them.
105
+ *
106
+ * `test/fakes/<id>.ts` default-exports `fake.app(…)` or `fake.image(…)` for an
107
+ * external API, and `fake.credential(…)` for a credential. The construct never
108
+ * names it — that is what keeps a fake out of a deployed bundle — so this is
109
+ * the one place it is found, by the same rule that finds a database's factory
110
+ * in `test/factories/<id>.ts`.
111
+ */
112
+ /** Where a project keeps its external APIs' fakes, relative to its root. */
113
+ const DEFAULT_FAKES_DIR = "test/fakes";
114
+ /** The marker `fake.app` and `fake.image` set — the same registered symbol. */
115
+ const FAKE = Symbol.for("@geekmidas/constructs/fake");
116
+ /**
117
+ * The fake for every external API the manifest declares, keyed by id.
118
+ *
119
+ * @throws {NoFake} when an external API has no file, since a local stage would
120
+ * otherwise have nothing to call.
121
+ * @throws {NotAFake} when the file's default export is not one.
122
+ */
123
+ async function readFakes(root, manifest) {
124
+ const fakes = {};
125
+ for (const [id, declaration] of Object.entries(manifest)) {
126
+ if (declaration?.kind !== "external-api") continue;
127
+ const file = await fakeFile(join(root, DEFAULT_FAKES_DIR), id);
128
+ if (!file) throw new NoFake(id, `${fakeBase(root, id)}.ts`);
129
+ const value = await importFake(file);
130
+ if (value.kind === "credential") throw new NotAFake(file);
131
+ fakes[id] = {
132
+ file,
133
+ ...value.kind === "image" ? {
134
+ image: value.image,
135
+ port: value.port
136
+ } : {},
137
+ credentials: JSON.stringify(value.credentials)
138
+ };
139
+ }
140
+ return fakes;
141
+ }
142
+ /**
143
+ * Each credential's fake value, as the JSON `<ID>_CREDENTIALS` holds, keyed by
144
+ * id — for the credentials that have a fake. Unlike an external API's, a
145
+ * credential's fake is optional here: a stage that stores the real value
146
+ * needs none. The test stage's own check (`assertTestCredentials`) is what
147
+ * refuses one with neither.
148
+ *
149
+ * @throws {NotAFake} when the file's default export is not a credential's fake.
150
+ */
151
+ async function readCredentialFakes(root, manifest) {
152
+ const values = {};
153
+ for (const [id, declaration] of Object.entries(manifest)) {
154
+ if (declaration?.kind !== "credential") continue;
155
+ const file = await fakeFile(join(root, DEFAULT_FAKES_DIR), id);
156
+ if (!file) continue;
157
+ const value = await importFake(file);
158
+ if (value.kind !== "credential") throw new NotAFake(file);
159
+ values[id] = JSON.stringify(value.credentials);
160
+ }
161
+ return values;
162
+ }
163
+ /**
164
+ * A credential the test stage has no value for: no fake, and nothing stored.
165
+ * Raised when the stage is set up, before a test reaches it — not as a schema
166
+ * error inside the handler that first asked.
167
+ */
168
+ var CredentialHasNoTestValue = class extends GkmError {
169
+ id;
170
+ key;
171
+ file;
172
+ constructor(id, key, file) {
173
+ super(`'${id}' is a credential, and the test stage has no value for ${key}: no fake, and none stored — a stage set up fresh, as CI's auto-setup does, holds no third party's credentials. Give it a fake: create ${file}, default-exporting fake.credential(…) from @geekmidas/constructs/credential. It is read only by gkm test and gkm dev --fake; a deployed stage still needs the real value (gkm secrets:add --stage <stage>).`);
174
+ this.id = id;
175
+ this.key = key;
176
+ this.file = file;
177
+ this.name = "CredentialHasNoTestValue";
178
+ }
179
+ };
180
+ /**
181
+ * Every credential the test stage must hand its suite, with the value it
182
+ * resolved — a fake's, or one the stage stores.
183
+ *
184
+ * @throws {CredentialHasNoTestValue} for the first one with neither.
185
+ */
186
+ function assertTestCredentials(root, plan, env) {
187
+ const values = {};
188
+ for (const { id, kind, envKey } of plan.resources) {
189
+ if (kind !== "credential") continue;
190
+ const value = env[envKey];
191
+ if (value === void 0) throw new CredentialHasNoTestValue(id, envKey, `${fakeBase(root, id)}.ts`);
192
+ values[envKey] = value;
193
+ }
194
+ return values;
195
+ }
196
+ /** `<root>/test/fakes/<id>`, without an extension. */
197
+ function fakeBase(root, id) {
198
+ return join(root, DEFAULT_FAKES_DIR, kebabCase(id));
199
+ }
200
+ /** The first of `<id>.ts`, `.mts`, `.js`, `.mjs` that exists. */
201
+ async function fakeFile(folder, id) {
202
+ const base = join(folder, kebabCase(id));
203
+ for (const extension of [
204
+ ".ts",
205
+ ".mts",
206
+ ".js",
207
+ ".mjs"
208
+ ]) {
209
+ const file = `${base}${extension}`;
210
+ if (await access(file).then(() => true, () => false)) return file;
211
+ }
212
+ }
213
+ /**
214
+ * A fake file's default export.
215
+ *
216
+ * @throws {NotAFake} when it is not a fake.
217
+ */
218
+ async function importFake(file) {
219
+ const value = (await import(pathToFileURL(file).href)).default;
220
+ if (!isFakeExport(value)) throw new NotAFake(file);
221
+ return value;
222
+ }
223
+ function isFakeExport(value) {
224
+ return typeof value === "object" && value !== null && value[FAKE] === true;
225
+ }
226
+ /** An external API with no fake for a local stage to call. */
227
+ var NoFake = class extends GkmError {
228
+ id;
229
+ file;
230
+ constructor(id, file) {
231
+ super(`'${id}' is an external API, and a local stage calls its fake rather than the provider — but there is none. Create ${file}, default-exporting fake.app(…) or fake.image(…) from @geekmidas/constructs/external-api.`);
232
+ this.id = id;
233
+ this.file = file;
234
+ this.name = "NoFake";
235
+ }
236
+ };
237
+ /** A file in the fakes folder whose default export is not a fake. */
238
+ var NotAFake = class extends GkmError {
239
+ file;
240
+ constructor(file) {
241
+ super(`${file} is where a fake lives, and its default export is not one for its construct. For an external API, export default fake.app(handler, { credentials }) or fake.image(image, { port, credentials }); for a credential, fake.credential(value).`);
242
+ this.file = file;
243
+ this.name = "NotAFake";
244
+ }
245
+ };
246
+ //#endregion
247
+ //#region src/generators/SubscriberGenerator.ts
248
+ var SubscriberGenerator = class extends ConstructGenerator {
249
+ isConstruct(value) {
250
+ return Subscriber.isSubscriber(value);
251
+ }
252
+ async build(context, constructs, outputDir, options) {
253
+ const target = options?.target ?? "aws";
254
+ const logger = console;
255
+ const subscriberInfos = [];
256
+ for (const { key, construct } of constructs) assertDoesNotFeedItself(key, construct);
257
+ if (target === "server") {
258
+ await this.generateServerSubscribersFile(outputDir, constructs, (context.eventsBackends?.includes("sns") ?? false) || constructs.some(({ construct }) => construct.bucketName));
259
+ logger.log(`Generated server subscribers file with ${constructs.length} subscribers (polling mode)`);
260
+ return subscriberInfos;
261
+ }
262
+ if (constructs.length === 0) return subscriberInfos;
263
+ const subscribersDir = join(outputDir, "subscribers");
264
+ await mkdir(subscribersDir, { recursive: true });
265
+ for (const { key, construct, path } of constructs) {
266
+ const handlerFile = await this.generateSubscriberHandler(subscribersDir, path.relative, key, construct, context, construct.owner);
267
+ subscriberInfos.push({
268
+ name: key,
269
+ handler: relative(options?.root ?? process.cwd(), handlerFile).replace(/\.ts$/, ".handler"),
270
+ subscribedEvents: construct.subscribedEvents || [],
271
+ ...construct.topicName ? {
272
+ transport: "topic",
273
+ topic: construct.topicName
274
+ } : {},
275
+ ...construct.bucketName ? {
276
+ transport: "topic",
277
+ bucket: construct.bucketName,
278
+ ...construct.objectFilter
279
+ } : {},
280
+ ...construct.inboxName ? { inbox: construct.inboxName } : {},
281
+ timeout: construct.timeout,
282
+ memorySize: construct.memorySize,
283
+ environment: await construct.getEnvironment({ markOptional: context.markOptional }),
284
+ dependencies: construct.constructs
285
+ });
286
+ logger.log(`Generated subscriber handler: ${key}`);
287
+ }
288
+ return subscriberInfos;
289
+ }
290
+ async generateSubscriberHandler(outputDir, sourceFile, exportName, _subscriber, context, owner) {
291
+ const handlerFileName = `${exportName}.ts`;
292
+ const handlerPath = join(outputDir, handlerFileName);
293
+ const importPath = relative(dirname(handlerPath), sourceFile).replace(/\.ts$/, ".js");
294
+ const runtime = runtimeFor(context, dirname(handlerPath), owner);
295
+ const content = `import { AWSLambdaSubscriber } from '@geekmidas/constructs/aws';
296
+ import { ${exportName} } from '${importPath}';
297
+ ${runtime.imports}
298
+ ${context.storageDrivers?.imports ?? ""}
299
+ ${runtime.bindings}
300
+ ${context.storageDrivers?.setup ? `\n// The handler registers the drivers its target needs.\n${context.storageDrivers.setup}\n` : ""}
301
+ const adapter = new AWSLambdaSubscriber(envParser, ${exportName});
302
+
303
+ export const handler = adapter.handler;
304
+ `;
305
+ await writeFile(handlerPath, content);
306
+ return handlerPath;
307
+ }
308
+ async generateServerSubscribersFile(outputDir, subscribers, push) {
309
+ await mkdir(outputDir, { recursive: true });
310
+ const subscribersPath = join(outputDir, "subscribers.ts");
311
+ if (subscribers.length === 0) {
312
+ await writeFile(subscribersPath, `/**
313
+ * Generated subscribers setup — this app declares none.
314
+ */
315
+ import type { EnvironmentParser } from '@geekmidas/envkit';
316
+ import type { Logger } from '@geekmidas/logger';
317
+
318
+ export async function setupSubscribers(
319
+ _app: unknown,
320
+ _envParser: EnvironmentParser<any>,
321
+ _logger: Logger,
322
+ ): Promise<(port: number) => Promise<void>> {
323
+ return async () => {};
324
+ }
325
+
326
+ export function subscribersStatus(): { failed: string[]; connections: unknown[] } {
327
+ return { failed: [], connections: [] };
328
+ }
329
+
330
+ export async function stopSubscribers(): Promise<void> {}
331
+ `);
332
+ return subscribersPath;
333
+ }
334
+ const importsByFile = /* @__PURE__ */ new Map();
335
+ for (const { path, key } of subscribers) {
336
+ const importPath = relative(dirname(subscribersPath), path.relative).replace(/\.ts$/, ".js");
337
+ importsByFile.set(importPath, [...importsByFile.get(importPath) ?? [], key]);
338
+ }
339
+ const imports = Array.from(importsByFile.entries()).map(([importPath, exports]) => `import { ${exports.join(", ")} } from '${importPath}';`).join("\n");
340
+ const entries = subscribers.map(({ key, construct }) => {
341
+ const connectionKey = subscriberConnectionKey(construct);
342
+ const tokenKey = subscriberTokenKey(construct);
343
+ const topic = construct.topicName ?? construct.bucketName;
344
+ const bucket = construct.bucketName ? canonicalId(construct.bucketName) : void 0;
345
+ return ` { id: '${key}', subscriber: ${key}, topic: ${topic ? `'${topic}'` : "undefined"}, connectionKey: ${connectionKey ? `'${connectionKey}'` : "undefined"}, filtered: ${construct.bucketName || construct.inboxName ? "false" : "true"}, bucket: ${bucket ? `'${bucket}'` : "undefined"}, tokenKey: ${tokenKey ? `'${tokenKey}'` : "undefined"}, inbox: ${construct.inboxName ? JSON.stringify({
346
+ id: construct.inboxName,
347
+ domainKey: provideKey(construct.inboxName, "domain"),
348
+ addressing: construct.inboxAddressing ?? { addresses: [] }
349
+ }) : "undefined"} },`;
350
+ }).join("\n");
351
+ const receives = subscribers.some(({ construct }) => construct.inboxName);
352
+ const content = `/**
353
+ * Generated subscribers setup.
354
+ *
355
+ * Each subscriber is run against the topic it is bound to, through that
356
+ * topic's own connection string:
357
+ *
358
+ * - **sns://** — pushed, not polled. The subscriber gets an HTTP route on this
359
+ * server, subscribed to the topic with a filter policy of the events it
360
+ * named, so SNS fans out to each subscriber. The route runs the subscriber
361
+ * through the same adaptor a Lambda subscription does. Against SNS itself
362
+ * the deploy made the subscription and recorded its ARN in
363
+ * ${SNS_SUBSCRIPTIONS_KEY}: a route is mounted only for a recorded one, its
364
+ * confirmation goes through the API, and nothing is subscribed from here.
365
+ * Against an emulator, where nothing deploys, the route subscribes itself.
366
+ * - **anything else** (pgboss://, rabbitmq://, sqs://) — polled. On pg-boss
367
+ * each subscriber drains a queue of its own, \`<topic>/<subscriber>\`, so
368
+ * every subscriber sees every event; replicas of one subscriber share it.
369
+ *
370
+ * A bucket's subscriber is polled the same way, under the bucket's name, when
371
+ * the bucket is in a local object store: the store posts each event to
372
+ * \`${OBJECTS_ROUTE_PREFIX}<Bucket>\` on this server, with the bucket's token, and
373
+ * the event is relayed onto the broker as \`object.created\` or
374
+ * \`object.deleted\` — so every subscriber of the bucket sees it.
375
+ *
376
+ * GKM_SUBSCRIBERS=off (\`gkm dev --no-subscribers\`) runs none of them.
377
+ * GKM_SUBSCRIBER_PUSH_URL is the address an emulator pushes to, defaulting to
378
+ * this server through host.docker.internal.
379
+ */
380
+ import { timingSafeEqual } from 'node:crypto';
381
+ import { connect } from 'node:net';
382
+ import type { EnvironmentParser } from '@geekmidas/envkit';
383
+ import type { Logger } from '@geekmidas/logger';
384
+ import { EventConnectionFactory, Publisher, Subscriber } from '@geekmidas/events';
385
+ import type { EventConnection } from '@geekmidas/events';
386
+ import { ServiceDiscovery } from '@geekmidas/services';
387
+ ${receives ? "import { type ReceivingInbox, receiveMail } from '@geekmidas/constructs/inbox';\n" : ""}${imports}
388
+
389
+ const subscribers = [
390
+ ${entries}
391
+ ];
392
+
393
+ // What was opened, and what could not be: a worker's health check reads both,
394
+ // and its shutdown closes what was opened.
395
+ const connections = new Map<string, EventConnection>();
396
+ const failed: string[] = [];
397
+
398
+ /**
399
+ * The subscriptions the deploy made against SNS itself, by subscriber: which
400
+ * routes to mount, and the ARN each one's notifications must name.
401
+ */
402
+ function recordedSubscriptions(logger: Logger): Record<string, string> {
403
+ const raw = process.env.${SNS_SUBSCRIPTIONS_KEY};
404
+ if (!raw) return {};
405
+ try {
406
+ const parsed = JSON.parse(raw);
407
+ if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) return parsed;
408
+ } catch {}
409
+ logger.error('${SNS_SUBSCRIPTIONS_KEY} is not a JSON object of subscriber → subscription ARN');
410
+ return {};
411
+ }
412
+
413
+ /** The route a subscriber's pushes arrive on. */
414
+ export const SUBSCRIBER_ROUTE = (id: string) => \`${SUBSCRIBER_ROUTE_PREFIX}\${id}\`;
415
+
416
+ /** The route a local object store posts a bucket's events to. */
417
+ export const OBJECTS_ROUTE = (bucket: string) => \`${OBJECTS_ROUTE_PREFIX}\${bucket}\`;
418
+
419
+ // The buckets whose events this server relays: one route each, however many
420
+ // subscribers watch the bucket.
421
+ const relays = new Set<string>();
422
+
423
+ /**
424
+ * Mount the route a local object store posts one bucket's events to, and
425
+ * relay each event onto the broker under the bucket's name.
426
+ *
427
+ * Answered 2xx only once every event is published: the store keeps what it
428
+ * was not told it delivered, and sends it again.
429
+ */
430
+ async function mountObjectRelay(
431
+ app: { post: (path: string, handler: (c: any) => unknown) => unknown },
432
+ relay: { bucket: string; topic: string; connection: EventConnection; tokenKey: string },
433
+ logger: Logger,
434
+ ): Promise<void> {
435
+ const token = process.env[relay.tokenKey];
436
+ if (!token) {
437
+ logger.error(
438
+ { bucket: relay.bucket, tokenKey: relay.tokenKey },
439
+ 'No token for this bucket: the events its object store posts cannot be received',
440
+ );
441
+ failed.push(\`\${relay.bucket}#events\`);
442
+ return;
443
+ }
444
+ const { toObjectEvents } = await import('@geekmidas/storage/events');
445
+ const publisher = await Publisher.fromConnection(relay.connection, { topic: relay.topic });
446
+ const expected = Buffer.from(\`Bearer \${token}\`);
447
+
448
+ app.post(OBJECTS_ROUTE(relay.bucket), async (c: any) => {
449
+ // Compared in constant time: the route is not public, but it is the one
450
+ // way to put an event in front of every subscriber of the bucket.
451
+ const given = Buffer.from(c.req.header('authorization') ?? '');
452
+ if (given.length !== expected.length || !timingSafeEqual(given, expected)) {
453
+ return c.json({ status: 'refused' }, 401);
454
+ }
455
+
456
+ let messages: Awaited<ReturnType<typeof toObjectEvents>>;
457
+ try {
458
+ messages = toObjectEvents(JSON.parse(await c.req.text()));
459
+ } catch (error) {
460
+ logger.warn({ err: error, bucket: relay.bucket }, 'Refused an object notification that did not parse');
461
+ return c.json({ status: 'malformed' }, 400);
462
+ }
463
+
464
+ try {
465
+ if (messages.length > 0) await publisher.publish(messages as any);
466
+ } catch (error) {
467
+ // The store sends it again.
468
+ logger.error({ err: error, bucket: relay.bucket }, 'Failed to relay object events');
469
+ return c.json({ status: 'failed' }, 500);
470
+ }
471
+ return c.json({ status: 'ok', relayed: messages.length }, 200);
472
+ });
473
+ logger.info({ bucket: relay.bucket }, 'Relaying object events');
474
+ }
475
+
476
+ ${receives ? `// The inboxes this server receives for locally, by id.
477
+ const inboxRelays = new Map<string, ReceivingInbox>();
478
+
479
+ /**
480
+ * Mount the route Mailpit posts each message it receives to, and hand the
481
+ * message to the receiver a receipt rule stands for: each inbox one of its
482
+ * envelope recipients is addressed to gets the receipt notification on its
483
+ * topic. Mailpit names envelope recipients missing from the headers as Bcc.
484
+ */
485
+ function mountInboxRelay(
486
+ app: { post: (path: string, handler: (c: any) => unknown) => unknown },
487
+ logger: Logger,
488
+ ): void {
489
+ const token = process.env.${INBOX_RELAY_TOKEN_KEY};
490
+ if (!token) {
491
+ logger.error('No ${INBOX_RELAY_TOKEN_KEY}: the mail Mailpit posts cannot be received');
492
+ failed.push('inbox');
493
+ return;
494
+ }
495
+ const expected = Buffer.from(token);
496
+
497
+ app.post('${INBOX_ROUTE}', async (c: any) => {
498
+ const given = Buffer.from(c.req.query('token') ?? '');
499
+ if (given.length !== expected.length || !timingSafeEqual(given, expected)) {
500
+ return c.json({ status: 'refused' }, 401);
501
+ }
502
+
503
+ let message: { key: string; from: string; recipients: string[] };
504
+ try {
505
+ const summary = JSON.parse(await c.req.text());
506
+ const addresses = (list: unknown) =>
507
+ Array.isArray(list) ? list.map((a: any) => a?.Address).filter(Boolean) : [];
508
+ message = {
509
+ key: String(summary.ID),
510
+ from: summary.From?.Address ?? '',
511
+ recipients: [...addresses(summary.To), ...addresses(summary.Cc), ...addresses(summary.Bcc)],
512
+ };
513
+ } catch (error) {
514
+ logger.warn({ err: error }, 'Refused a Mailpit webhook that did not parse');
515
+ return c.json({ status: 'malformed' }, 400);
516
+ }
517
+
518
+ try {
519
+ const received = await receiveMail(
520
+ { ...message, store: 'mailpit' },
521
+ [...inboxRelays.values()],
522
+ );
523
+ return c.json({ status: 'ok', received }, 200);
524
+ } catch (error) {
525
+ logger.error({ err: error, message: message.key }, 'Failed to receive mail');
526
+ return c.json({ status: 'failed' }, 500);
527
+ }
528
+ });
529
+ logger.info({ inboxes: [...inboxRelays.keys()] }, 'Receiving mail from Mailpit');
530
+ }
531
+
532
+ ` : ""}/** Resolves once something is accepting connections on the port. */
533
+ async function listening(port: number): Promise<void> {
534
+ for (let attempt = 0; attempt < 100; attempt++) {
535
+ const open = await new Promise<boolean>((resolve) => {
536
+ const socket = connect(port, '127.0.0.1');
537
+ socket.once('connect', () => { socket.end(); resolve(true); });
538
+ socket.once('error', () => resolve(false));
539
+ });
540
+ if (open) return;
541
+ await new Promise((resolve) => setTimeout(resolve, 50));
542
+ }
543
+ }
544
+
545
+ /**
546
+ * Mount each pushed subscriber's route and start each polled one. Returns what
547
+ * to run once the server is listening: subscribing a route makes SNS send its
548
+ * confirmation at once, so the route has to be reachable first.
549
+ */
550
+ export async function setupSubscribers(
551
+ app: { post: (path: string, handler: (c: any) => unknown) => unknown },
552
+ envParser: EnvironmentParser<any>,
553
+ logger: Logger,
554
+ ): Promise<(port: number) => Promise<void>> {
555
+ if (process.env.GKM_SUBSCRIBERS === 'off') {
556
+ logger.info('Subscribers are off (--no-subscribers)');
557
+ return async () => {};
558
+ }
559
+
560
+ const serviceDiscovery = ServiceDiscovery.getInstance(envParser);
561
+ const recorded = recordedSubscriptions(logger);
562
+ const afterListening: ((port: number) => Promise<void>)[] = [];
563
+
564
+ for (const { id, subscriber, topic, connectionKey, filtered, bucket, tokenKey, inbox } of subscribers) {
565
+ const events = subscriber.subscribedEvents || [];
566
+ if (events.length === 0) {
567
+ logger.warn({ subscriber: id }, 'Subscriber has no subscribed events, skipping');
568
+ continue;
569
+ }
570
+ const connectionString = connectionKey ? process.env[connectionKey] : undefined;
571
+ if (!connectionString) {
572
+ logger.error(
573
+ { subscriber: id, connectionKey },
574
+ 'No connection string for the topic or bucket this subscriber is bound to',
575
+ );
576
+ failed.push(id);
577
+ continue;
578
+ }
579
+
580
+ try {
581
+ ${push ? ` if (connectionString.startsWith('sns:')) {
582
+ const { SNSConnection, snsUrl, subscribeHttpEndpoint, confirmSubscription } = await import('@geekmidas/events/sns');
583
+ const { SnsPushSubscriberAdaptor } = await import('@geekmidas/constructs/subscribers');
584
+ const address = snsUrl.parse(connectionString);
585
+ const route = SUBSCRIBER_ROUTE(id);
586
+ const mount = (adaptor: InstanceType<typeof SnsPushSubscriberAdaptor>) =>
587
+ app.post(route, async (c: any) => {
588
+ const body = JSON.parse(await c.req.text());
589
+ const response = await adaptor.handle(body, {
590
+ subscriptionArn: c.req.header('x-amz-sns-subscription-arn'),
591
+ });
592
+ return c.json(response.body, response.status);
593
+ });
594
+
595
+ if (!address.endpoint) {
596
+ // SNS itself: the deploy subscribed this route and recorded the ARN.
597
+ // Nothing is subscribed from here, so this server's credentials need
598
+ // only sns:ConfirmSubscription on the topic.
599
+ const subscriptionArn = recorded[id];
600
+ if (!subscriptionArn) {
601
+ logger.error(
602
+ { subscriber: id },
603
+ 'No subscription recorded for this subscriber in ${SNS_SUBSCRIPTIONS_KEY}: deploy it so SNS has a route to push to',
604
+ );
605
+ failed.push(id);
606
+ continue;
607
+ }
608
+ const connection = await SNSConnection.fromConnectionString(connectionString);
609
+ mount(
610
+ new SnsPushSubscriberAdaptor(envParser, subscriber, {
611
+ topicArn: address.topicArn,
612
+ verify: true,
613
+ subscriptionArn,
614
+ // As the topic's owner, so only the owner can unsubscribe the
615
+ // route — not whoever holds a notification's UnsubscribeURL.
616
+ confirm: (message) => confirmSubscription(connection, message),
617
+ }),
618
+ );
619
+ logger.info({ subscriber: id, events }, 'Subscriber mounted for push');
620
+ continue;
621
+ }
622
+
623
+ // An emulator signs nothing, and nothing deploys its subscriptions:
624
+ // decided by the address this server was configured with, never by
625
+ // anything a request says about itself.
626
+ mount(
627
+ new SnsPushSubscriberAdaptor(envParser, subscriber, {
628
+ topicArn: address.topicArn,
629
+ verify: false,
630
+ emulatorEndpoint: address.endpoint,
631
+ }),
632
+ );
633
+
634
+ afterListening.push(async (port) => {
635
+ const base =
636
+ process.env.GKM_SUBSCRIBER_PUSH_URL ?? \`http://host.docker.internal:\${port}\`;
637
+ const connection = await SNSConnection.fromConnectionString(connectionString);
638
+ await subscribeHttpEndpoint(connection, {
639
+ endpoint: new URL(route, base).toString(),
640
+ ...(filtered ? { events } : {}),
641
+ });
642
+ logger.info({ subscriber: id, events }, 'Subscriber subscribed for push');
643
+ });
644
+ continue;
645
+ }
646
+ ` : ` if (connectionString.startsWith('sns:')) {
647
+ // Built for a broker other than SNS, so this entry registered no SNS
648
+ // driver and has no push route to offer.
649
+ logger.error(
650
+ { subscriber: id, connectionKey },
651
+ 'This build has no SNS driver: it was built for a target whose broker is not SNS',
652
+ );
653
+ failed.push(id);
654
+ continue;
655
+ }
656
+ `}
657
+
658
+ let connection = connections.get(connectionString);
659
+ if (!connection) {
660
+ connection = await EventConnectionFactory.fromConnectionString(connectionString);
661
+ connections.set(connectionString, connection);
662
+ }
663
+ // Named, so a broker with one address for everything (pg-boss) gives
664
+ // this subscriber a queue of its own: fan-out, not competition.
665
+ const eventSubscriber = await Subscriber.fromConnection(connection, {
666
+ topic,
667
+ subscription: id,
668
+ });
669
+ const services = subscriber.services.length > 0
670
+ ? await serviceDiscovery.register(subscriber.services)
671
+ : {};
672
+ // The subscriber's database — the worker's, or its own — as \`db\`. A
673
+ // pushed subscriber gets it from the adaptor above instead.
674
+ const db = subscriber.databaseService
675
+ ? (await serviceDiscovery.register([subscriber.databaseService]))[
676
+ subscriber.databaseService.serviceName
677
+ ]
678
+ : undefined;
679
+
680
+ await eventSubscriber.subscribe(events, async (event) => {
681
+ try {
682
+ await subscriber.handler({
683
+ events: [event],
684
+ services: services as any,
685
+ logger: subscriber.logger,
686
+ db,
687
+ } as any);
688
+ } catch (error) {
689
+ logger.error({ err: error, event, subscriber: id }, 'Failed to process event');
690
+ // Rethrown so the transport keeps the event for a retry — as a queue
691
+ // consumer's failure does, and as a pushed subscriber's 500 does.
692
+ throw error;
693
+ }
694
+ });
695
+ logger.info({ subscriber: id, events }, 'Subscriber started polling');
696
+
697
+ // A bucket in a local object store publishes nothing for this to poll:
698
+ // the store posts its events here, and they are relayed onto the broker.
699
+ if (bucket && tokenKey && topic && !relays.has(bucket)) {
700
+ relays.add(bucket);
701
+ await mountObjectRelay(app, { bucket, topic, connection, tokenKey }, logger);
702
+ }${receives ? `
703
+ // An inbox polled here is a local one: Mailpit posts what it receives
704
+ // to this server, which announces it on the inbox's topic.
705
+ const domain = inbox ? process.env[inbox.domainKey] : undefined;
706
+ if (inbox && topic && domain && !inboxRelays.has(inbox.id)) {
707
+ const publisher = await Publisher.fromConnection(connection, { topic });
708
+ inboxRelays.set(inbox.id, {
709
+ id: inbox.id,
710
+ addressing: inbox.addressing,
711
+ domain,
712
+ publish: async (payload) => {
713
+ await publisher.publish([{ type: '${INBOX_EVENT}', payload }] as any);
714
+ },
715
+ });
716
+ }` : ""}
717
+ } catch (error) {
718
+ // The message too: a missing module's code alone does not say which.
719
+ logger.error(
720
+ { err: error, subscriber: id },
721
+ 'Failed to set up subscriber',
722
+ );
723
+ failed.push(id);
724
+ }
725
+ }
726
+
727
+ ${receives ? " if (inboxRelays.size > 0) mountInboxRelay(app, logger);\n\n" : ""} return async (port) => {
728
+ if (afterListening.length === 0) return;
729
+ await listening(port);
730
+ for (const subscribe of afterListening) {
731
+ await subscribe(port).catch((error) => {
732
+ logger.error({ err: error }, 'Failed to subscribe for push');
733
+ });
734
+ }
735
+ };
736
+ }
737
+
738
+ /** The subscribers that could not start, and the connections that did. */
739
+ export function subscribersStatus(): { failed: string[]; connections: EventConnection[] } {
740
+ return { failed: [...failed], connections: [...connections.values()] };
741
+ }
742
+
743
+ /**
744
+ * Stop polling, let the events in flight finish, and close each broker
745
+ * connection — pg-boss's graceful stop does all three. The caller bounds it.
746
+ */
747
+ export async function stopSubscribers(): Promise<void> {
748
+ const open = [...connections.values()];
749
+ connections.clear();
750
+ await Promise.all(open.map((connection) => connection.close()));
751
+ }
752
+ `;
753
+ await writeFile(subscribersPath, content);
754
+ return subscribersPath;
755
+ }
756
+ };
757
+ /**
758
+ * A bucket's subscriber that writes back into the keys it watches.
759
+ *
760
+ * Every write it makes is a new object event, which runs it again — forever,
761
+ * and billed per run. The rule is the one the build can check: a subscriber
762
+ * that depends on the bucket it watches must watch a prefix, so what it writes
763
+ * can go elsewhere. A thumbnailer watching `uploads/` writes `thumbnails/`.
764
+ */
765
+ var ObjectSubscriberFeedsItself = class extends Error {
766
+ subscriber;
767
+ bucket;
768
+ constructor(subscriber, bucket) {
769
+ super(`'${subscriber}' watches every key in '${bucket}' and depends on it, so each object it writes runs it again. Watch a prefix — .on([...], { prefix: 'uploads/' }) — and write outside it.`);
770
+ this.subscriber = subscriber;
771
+ this.bucket = bucket;
772
+ this.name = "ObjectSubscriberFeedsItself";
773
+ }
774
+ };
775
+ function assertDoesNotFeedItself(key, construct) {
776
+ const bucket = construct.bucketName;
777
+ if (!bucket || construct.objectFilter?.prefix) return;
778
+ if ((construct.constructs ?? []).some((id) => canonicalId(id) === canonicalId(bucket))) throw new ObjectSubscriberFeedsItself(key, bucket);
779
+ }
780
+ //#endregion
781
+ export { SNS_SUBSCRIPTIONS_KEY as a, INBOX_RELAY_TOKEN_KEY as c, inboxWebhookUrl as d, readFakes as i, inboxRelayToken as l, assertTestCredentials as n, objectsRoute as o, readCredentialFakes as r, subscriberRoute as s, SubscriberGenerator as t, inboxRelayWorker as u };
782
+
783
+ //# sourceMappingURL=SubscriberGenerator-CzPrixYu.mjs.map