@geekmidas/cli 10.0.0-alpha.13 → 10.0.0-alpha.130

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 (430) 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-B99OGzbO.mjs +1035 -0
  7. package/dist/EndpointGenerator-B99OGzbO.mjs.map +1 -0
  8. package/dist/EndpointGenerator-De0lknKD.cjs +1094 -0
  9. package/dist/EndpointGenerator-De0lknKD.cjs.map +1 -0
  10. package/dist/GoDaddyProvider-D10Le3VX.mjs +388 -0
  11. package/dist/GoDaddyProvider-D10Le3VX.mjs.map +1 -0
  12. package/dist/GoDaddyProvider-DTfa47i3.cjs +388 -0
  13. package/dist/GoDaddyProvider-DTfa47i3.cjs.map +1 -0
  14. package/dist/{HostingerProvider-BY26bWwB.mjs → HostingerProvider-Cjh_2Ml6.mjs} +11 -6
  15. package/dist/HostingerProvider-Cjh_2Ml6.mjs.map +1 -0
  16. package/dist/{HostingerProvider-BZFGYYVA.cjs → HostingerProvider-OdQmKXE3.cjs} +11 -6
  17. package/dist/HostingerProvider-OdQmKXE3.cjs.map +1 -0
  18. package/dist/LegacyStateStore-C5c_zS4h.mjs +124 -0
  19. package/dist/LegacyStateStore-C5c_zS4h.mjs.map +1 -0
  20. package/dist/LegacyStateStore-CZSBR6ar.cjs +124 -0
  21. package/dist/LegacyStateStore-CZSBR6ar.cjs.map +1 -0
  22. package/dist/LocalStateStore-Ba0Y6q5C.mjs +167 -0
  23. package/dist/LocalStateStore-Ba0Y6q5C.mjs.map +1 -0
  24. package/dist/LocalStateStore-CgQtQix2.cjs +178 -0
  25. package/dist/LocalStateStore-CgQtQix2.cjs.map +1 -0
  26. package/dist/OpenApiTsGenerator-DMLzN-LU.cjs +541 -0
  27. package/dist/OpenApiTsGenerator-DMLzN-LU.cjs.map +1 -0
  28. package/dist/OpenApiTsGenerator-DNUCgkkx.mjs +536 -0
  29. package/dist/OpenApiTsGenerator-DNUCgkkx.mjs.map +1 -0
  30. package/dist/{Route53Provider-DVILBsvV.cjs → Route53Provider-Bllus2NR.cjs} +2 -2
  31. package/dist/Route53Provider-Bllus2NR.cjs.map +1 -0
  32. package/dist/{Route53Provider-Cvj40A8I.mjs → Route53Provider-QXxjkZO1.mjs} +2 -2
  33. package/dist/Route53Provider-QXxjkZO1.mjs.map +1 -0
  34. package/dist/S3StateStore-00mB2AG4.mjs +223 -0
  35. package/dist/S3StateStore-00mB2AG4.mjs.map +1 -0
  36. package/dist/S3StateStore-C6amZI39.cjs +222 -0
  37. package/dist/S3StateStore-C6amZI39.cjs.map +1 -0
  38. package/dist/SSMStateStore-CkYqOAzW.mjs +205 -0
  39. package/dist/SSMStateStore-CkYqOAzW.mjs.map +1 -0
  40. package/dist/SSMStateStore-Cnn5fHCg.cjs +204 -0
  41. package/dist/SSMStateStore-Cnn5fHCg.cjs.map +1 -0
  42. package/dist/SubscriberGenerator-0ruEmYXj.mjs +646 -0
  43. package/dist/SubscriberGenerator-0ruEmYXj.mjs.map +1 -0
  44. package/dist/SubscriberGenerator-CPjbWEOI.cjs +687 -0
  45. package/dist/SubscriberGenerator-CPjbWEOI.cjs.map +1 -0
  46. package/dist/add-CdMInvmN.cjs +719 -0
  47. package/dist/add-CdMInvmN.cjs.map +1 -0
  48. package/dist/add-DZSU5Tcc.mjs +717 -0
  49. package/dist/add-DZSU5Tcc.mjs.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/aws-8QQ8n-t6.mjs +89 -0
  55. package/dist/aws-8QQ8n-t6.mjs.map +1 -0
  56. package/dist/aws-DY9NqQIT.cjs +100 -0
  57. package/dist/aws-DY9NqQIT.cjs.map +1 -0
  58. package/dist/awsStore-Bx5nCFnS.mjs +121 -0
  59. package/dist/awsStore-Bx5nCFnS.mjs.map +1 -0
  60. package/dist/awsStore-u3ehhMoY.cjs +138 -0
  61. package/dist/awsStore-u3ehhMoY.cjs.map +1 -0
  62. package/dist/{backup-provisioner-DIVCbfee.mjs → backup-provisioner-C8DnCmxK.mjs} +2 -2
  63. package/dist/backup-provisioner-C8DnCmxK.mjs.map +1 -0
  64. package/dist/{backup-provisioner-BmhIO_Yr.cjs → backup-provisioner-oDEsPj02.cjs} +2 -2
  65. package/dist/backup-provisioner-oDEsPj02.cjs.map +1 -0
  66. package/dist/backups/runner.cjs +519 -0
  67. package/dist/backups/runner.cjs.map +1 -0
  68. package/dist/backups/runner.d.cts +102 -0
  69. package/dist/backups/runner.d.cts.map +1 -0
  70. package/dist/backups/runner.d.mts +102 -0
  71. package/dist/backups/runner.d.mts.map +1 -0
  72. package/dist/backups/runner.mjs +506 -0
  73. package/dist/backups/runner.mjs.map +1 -0
  74. package/dist/{bundler-BodTL4kf.mjs → bundler-BzDMJbx8.mjs} +32 -11
  75. package/dist/bundler-BzDMJbx8.mjs.map +1 -0
  76. package/dist/{bundler-BeNDZdHQ.cjs → bundler-GKF4xpYI.cjs} +32 -11
  77. package/dist/bundler-GKF4xpYI.cjs.map +1 -0
  78. package/dist/cli-Ct6PQtc7.cjs +71 -0
  79. package/dist/cli-Ct6PQtc7.cjs.map +1 -0
  80. package/dist/cli-DXeLFtpA.mjs +71 -0
  81. package/dist/cli-DXeLFtpA.mjs.map +1 -0
  82. package/dist/compose-BfLDidYU.cjs +3977 -0
  83. package/dist/compose-BfLDidYU.cjs.map +1 -0
  84. package/dist/compose-CnanpQBB.mjs +3834 -0
  85. package/dist/compose-CnanpQBB.mjs.map +1 -0
  86. package/dist/config-DPsCfNpR.d.mts +268 -0
  87. package/dist/config-DPsCfNpR.d.mts.map +1 -0
  88. package/dist/config-azErNJSd.d.cts +268 -0
  89. package/dist/config-azErNJSd.d.cts.map +1 -0
  90. package/dist/config.cjs +420 -9
  91. package/dist/config.cjs.map +1 -0
  92. package/dist/config.d.cts +4 -117
  93. package/dist/config.d.mts +4 -117
  94. package/dist/config.mjs +406 -3
  95. package/dist/config.mjs.map +1 -0
  96. package/dist/credentialSchemas-CM0rxWmS.cjs +272 -0
  97. package/dist/credentialSchemas-CM0rxWmS.cjs.map +1 -0
  98. package/dist/credentialSchemas-DPOGqOrU.mjs +237 -0
  99. package/dist/credentialSchemas-DPOGqOrU.mjs.map +1 -0
  100. package/dist/credentials-D7XJypNd.cjs +520 -0
  101. package/dist/credentials-D7XJypNd.cjs.map +1 -0
  102. package/dist/credentials-DpfnUvIR.mjs +395 -0
  103. package/dist/credentials-DpfnUvIR.mjs.map +1 -0
  104. package/dist/databases-Db48ZIXL.mjs +588 -0
  105. package/dist/databases-Db48ZIXL.mjs.map +1 -0
  106. package/dist/databases-P824RTnx.cjs +703 -0
  107. package/dist/databases-P824RTnx.cjs.map +1 -0
  108. package/dist/define-6poNqm5O.mjs +106 -0
  109. package/dist/define-6poNqm5O.mjs.map +1 -0
  110. package/dist/define-crmMcXFS.cjs +153 -0
  111. package/dist/define-crmMcXFS.cjs.map +1 -0
  112. package/dist/deploy/public.cjs +211 -0
  113. package/dist/deploy/public.cjs.map +1 -0
  114. package/dist/deploy/public.d.cts +652 -0
  115. package/dist/deploy/public.d.cts.map +1 -0
  116. package/dist/deploy/public.d.mts +652 -0
  117. package/dist/deploy/public.d.mts.map +1 -0
  118. package/dist/deploy/public.mjs +144 -0
  119. package/dist/deploy/public.mjs.map +1 -0
  120. package/dist/deploy/sniffer-envparser-worker.cjs +54 -0
  121. package/dist/deploy/sniffer-envparser-worker.cjs.map +1 -0
  122. package/dist/deploy/sniffer-envparser-worker.d.cts +1 -0
  123. package/dist/deploy/sniffer-envparser-worker.d.mts +1 -0
  124. package/dist/deploy/sniffer-envparser-worker.mjs +55 -0
  125. package/dist/deploy/sniffer-envparser-worker.mjs.map +1 -0
  126. package/dist/deploy/sniffer-hooks.cjs +1 -1
  127. package/dist/deploy/sniffer-hooks.mjs +1 -1
  128. package/dist/deploy/sniffer-loader.cjs +2 -2
  129. package/dist/deploy/sniffer-loader.mjs +1 -1
  130. package/dist/deploy/sniffer-routes-worker.cjs +2 -2
  131. package/dist/deploy/sniffer-routes-worker.mjs +2 -2
  132. package/dist/deploy-B35L6CMr.mjs +3439 -0
  133. package/dist/deploy-B35L6CMr.mjs.map +1 -0
  134. package/dist/deploy-zFe_W4WS.cjs +3494 -0
  135. package/dist/deploy-zFe_W4WS.cjs.map +1 -0
  136. package/dist/derive-BtGidITm.cjs +161 -0
  137. package/dist/derive-BtGidITm.cjs.map +1 -0
  138. package/dist/derive-Dew0QoGe.mjs +150 -0
  139. package/dist/derive-Dew0QoGe.mjs.map +1 -0
  140. package/dist/discover-DEOspD9M.cjs +796 -0
  141. package/dist/discover-DEOspD9M.cjs.map +1 -0
  142. package/dist/discover-DOhYSKY_.mjs +693 -0
  143. package/dist/discover-DOhYSKY_.mjs.map +1 -0
  144. package/dist/dokploy-BGJxcEh0.cjs +38 -0
  145. package/dist/dokploy-BGJxcEh0.cjs.map +1 -0
  146. package/dist/dokploy-sDTohVj5.mjs +38 -0
  147. package/dist/dokploy-sDTohVj5.mjs.map +1 -0
  148. package/dist/drivers-C47nm-wB.cjs +311 -0
  149. package/dist/drivers-C47nm-wB.cjs.map +1 -0
  150. package/dist/drivers-CDjpjakg.mjs +252 -0
  151. package/dist/drivers-CDjpjakg.mjs.map +1 -0
  152. package/dist/eas-Bxb9pymo.mjs +334 -0
  153. package/dist/eas-Bxb9pymo.mjs.map +1 -0
  154. package/dist/eas-DogHTOxl.cjs +337 -0
  155. package/dist/eas-DogHTOxl.cjs.map +1 -0
  156. package/dist/{emit-BdoPFjZf.cjs → emit-CYloptRS.cjs} +44 -54
  157. package/dist/emit-CYloptRS.cjs.map +1 -0
  158. package/dist/{emit-Bzq7JsMP.mjs → emit-CiJGdy_f.mjs} +45 -43
  159. package/dist/emit-CiJGdy_f.mjs.map +1 -0
  160. package/dist/encryption-BZk_sxC-.mjs +89 -0
  161. package/dist/encryption-BZk_sxC-.mjs.map +1 -0
  162. package/dist/encryption-DRXgL9Lh.cjs +90 -0
  163. package/dist/encryption-DRXgL9Lh.cjs.map +1 -0
  164. package/dist/engine-BuPhWFVm.cjs +3328 -0
  165. package/dist/engine-BuPhWFVm.cjs.map +1 -0
  166. package/dist/engine-uQmNnvNQ.mjs +3215 -0
  167. package/dist/engine-uQmNnvNQ.mjs.map +1 -0
  168. package/dist/errors-D8Gwp5kU.mjs +23 -0
  169. package/dist/errors-D8Gwp5kU.mjs.map +1 -0
  170. package/dist/errors-DMC4Umsb.cjs +34 -0
  171. package/dist/errors-DMC4Umsb.cjs.map +1 -0
  172. package/dist/github-BCRbDSQa.cjs +901 -0
  173. package/dist/github-BCRbDSQa.cjs.map +1 -0
  174. package/dist/github-YknZQnYF.mjs +900 -0
  175. package/dist/github-YknZQnYF.mjs.map +1 -0
  176. package/dist/googlePlay-B_2dIDSO.mjs +931 -0
  177. package/dist/googlePlay-B_2dIDSO.mjs.map +1 -0
  178. package/dist/googlePlay-Cm2uipeZ.cjs +931 -0
  179. package/dist/googlePlay-Cm2uipeZ.cjs.map +1 -0
  180. package/dist/identity-CBXr4wNi.mjs +129 -0
  181. package/dist/identity-CBXr4wNi.mjs.map +1 -0
  182. package/dist/identity-CbLfgQNT.cjs +182 -0
  183. package/dist/identity-CbLfgQNT.cjs.map +1 -0
  184. package/dist/{index-D-iAVHx-.d.cts → index-D-gNc445.d.cts} +39 -15
  185. package/dist/index-D-gNc445.d.cts.map +1 -0
  186. package/dist/{index-Cd-qeOam.d.mts → index-Ur-ZIDYC.d.mts} +39 -15
  187. package/dist/index-Ur-ZIDYC.d.mts.map +1 -0
  188. package/dist/index.cjs +13461 -12270
  189. package/dist/index.cjs.map +1 -1
  190. package/dist/index.mjs +13486 -12293
  191. package/dist/index.mjs.map +1 -1
  192. package/dist/local-B7Zv1NoA.mjs +224 -0
  193. package/dist/local-B7Zv1NoA.mjs.map +1 -0
  194. package/dist/local-OPC9BCZt.cjs +241 -0
  195. package/dist/local-OPC9BCZt.cjs.map +1 -0
  196. package/dist/migrate-BIl4kLb1.cjs +181 -0
  197. package/dist/migrate-BIl4kLb1.cjs.map +1 -0
  198. package/dist/migrate-Co3UnkrE.cjs +273 -0
  199. package/dist/migrate-Co3UnkrE.cjs.map +1 -0
  200. package/dist/migrate-D71REG0N.mjs +268 -0
  201. package/dist/migrate-D71REG0N.mjs.map +1 -0
  202. package/dist/migrate-zqsyod5I.mjs +181 -0
  203. package/dist/migrate-zqsyod5I.mjs.map +1 -0
  204. package/dist/openapi.cjs +214 -7
  205. package/dist/openapi.cjs.map +1 -0
  206. package/dist/openapi.d.cts +32 -8
  207. package/dist/openapi.d.cts.map +1 -1
  208. package/dist/openapi.d.mts +32 -8
  209. package/dist/openapi.d.mts.map +1 -1
  210. package/dist/openapi.mjs +209 -2
  211. package/dist/openapi.mjs.map +1 -0
  212. package/dist/projectBucket-BBbQ1lHF.cjs +263 -0
  213. package/dist/projectBucket-BBbQ1lHF.cjs.map +1 -0
  214. package/dist/projectBucket-C_DN4WzF.mjs +222 -0
  215. package/dist/projectBucket-C_DN4WzF.mjs.map +1 -0
  216. package/dist/provider-BqpjG9QM.cjs +57 -0
  217. package/dist/provider-BqpjG9QM.cjs.map +1 -0
  218. package/dist/provider-CEOKk8NS.mjs +46 -0
  219. package/dist/provider-CEOKk8NS.mjs.map +1 -0
  220. package/dist/publish-BUnnuLl_.cjs +124 -0
  221. package/dist/publish-BUnnuLl_.cjs.map +1 -0
  222. package/dist/publish-BtmLOhV9.mjs +123 -0
  223. package/dist/publish-BtmLOhV9.mjs.map +1 -0
  224. package/dist/ready-BwtLriAF.mjs +375 -0
  225. package/dist/ready-BwtLriAF.mjs.map +1 -0
  226. package/dist/ready-Cj4pI0dw.cjs +404 -0
  227. package/dist/ready-Cj4pI0dw.cjs.map +1 -0
  228. package/dist/reconcile/public.cjs +2 -4
  229. package/dist/reconcile/public.d.cts +8 -67
  230. package/dist/reconcile/public.d.cts.map +1 -1
  231. package/dist/reconcile/public.d.mts +8 -67
  232. package/dist/reconcile/public.d.mts.map +1 -1
  233. package/dist/reconcile/public.mjs +3 -3
  234. package/dist/{reconcile-DhQ00DpU.mjs → reconcile--I7V4Klj.mjs} +2 -2
  235. package/dist/{reconcile-DhQ00DpU.mjs.map → reconcile--I7V4Klj.mjs.map} +1 -1
  236. package/dist/{reconcile-Dd2iyILf.cjs → reconcile-CuCQBa5-.cjs} +3 -3
  237. package/dist/{reconcile-Dd2iyILf.cjs.map → reconcile-CuCQBa5-.cjs.map} +1 -1
  238. package/dist/resolve-B1zK9f8_.mjs +263 -0
  239. package/dist/resolve-B1zK9f8_.mjs.map +1 -0
  240. package/dist/resolve-BVVSf27Y.cjs +316 -0
  241. package/dist/resolve-BVVSf27Y.cjs.map +1 -0
  242. package/dist/rollback-CAPWtOm3.mjs +136 -0
  243. package/dist/rollback-CAPWtOm3.mjs.map +1 -0
  244. package/dist/rollback-hV8Kbbg_.cjs +165 -0
  245. package/dist/rollback-hV8Kbbg_.cjs.map +1 -0
  246. package/dist/runtime-C0okGPpK.d.cts +82 -0
  247. package/dist/runtime-C0okGPpK.d.cts.map +1 -0
  248. package/dist/runtime-DfwIeO8f.d.mts +82 -0
  249. package/dist/runtime-DfwIeO8f.d.mts.map +1 -0
  250. package/dist/s3-CkERdmxm.mjs +215 -0
  251. package/dist/s3-CkERdmxm.mjs.map +1 -0
  252. package/dist/s3-xJtWm6WN.cjs +215 -0
  253. package/dist/s3-xJtWm6WN.cjs.map +1 -0
  254. package/dist/sandbox/config-worker.cjs +43 -0
  255. package/dist/sandbox/config-worker.cjs.map +1 -0
  256. package/dist/sandbox/config-worker.d.cts +1 -0
  257. package/dist/sandbox/config-worker.d.mts +1 -0
  258. package/dist/sandbox/config-worker.mjs +44 -0
  259. package/dist/sandbox/config-worker.mjs.map +1 -0
  260. package/dist/sandbox/credentials-worker.cjs +54 -0
  261. package/dist/sandbox/credentials-worker.cjs.map +1 -0
  262. package/dist/sandbox/credentials-worker.d.cts +1 -0
  263. package/dist/sandbox/credentials-worker.d.mts +1 -0
  264. package/dist/sandbox/credentials-worker.mjs +55 -0
  265. package/dist/sandbox/credentials-worker.mjs.map +1 -0
  266. package/dist/sandbox/discover-worker.cjs +50 -0
  267. package/dist/sandbox/discover-worker.cjs.map +1 -0
  268. package/dist/sandbox/discover-worker.d.cts +1 -0
  269. package/dist/sandbox/discover-worker.d.mts +1 -0
  270. package/dist/sandbox/discover-worker.mjs +51 -0
  271. package/dist/sandbox/discover-worker.mjs.map +1 -0
  272. package/dist/sandbox/migrate-worker.cjs +76 -0
  273. package/dist/sandbox/migrate-worker.cjs.map +1 -0
  274. package/dist/sandbox/migrate-worker.d.cts +1 -0
  275. package/dist/sandbox/migrate-worker.d.mts +1 -0
  276. package/dist/sandbox/migrate-worker.mjs +77 -0
  277. package/dist/sandbox/migrate-worker.mjs.map +1 -0
  278. package/dist/sandbox-CHv3OYXg.cjs +165 -0
  279. package/dist/sandbox-CHv3OYXg.cjs.map +1 -0
  280. package/dist/sandbox-CbVB7uOD.mjs +118 -0
  281. package/dist/sandbox-CbVB7uOD.mjs.map +1 -0
  282. package/dist/{workspace-mFpI_ky_.cjs → schemas-BCwKKA42.mjs} +399 -1162
  283. package/dist/schemas-BCwKKA42.mjs.map +1 -0
  284. package/dist/{workspace-CgwmXEtc.mjs → schemas-BQ_v0lEX.cjs} +487 -971
  285. package/dist/schemas-BQ_v0lEX.cjs.map +1 -0
  286. package/dist/secretsManager-CQORubp9.mjs +97 -0
  287. package/dist/secretsManager-CQORubp9.mjs.map +1 -0
  288. package/dist/secretsManager-RAGcEDX1.cjs +108 -0
  289. package/dist/secretsManager-RAGcEDX1.cjs.map +1 -0
  290. package/dist/seeds-CNPdk_2f.mjs +9198 -0
  291. package/dist/seeds-CNPdk_2f.mjs.map +1 -0
  292. package/dist/seeds-MR13eS-F.cjs +10303 -0
  293. package/dist/seeds-MR13eS-F.cjs.map +1 -0
  294. package/dist/serverSetup-9kFFmA86.cjs +651 -0
  295. package/dist/serverSetup-9kFFmA86.cjs.map +1 -0
  296. package/dist/serverSetup-DgAERQ5s.mjs +651 -0
  297. package/dist/serverSetup-DgAERQ5s.mjs.map +1 -0
  298. package/dist/sniffer-Biw5SE1V.cjs +1998 -0
  299. package/dist/sniffer-Biw5SE1V.cjs.map +1 -0
  300. package/dist/sniffer-KS_EcbAk.mjs +1825 -0
  301. package/dist/sniffer-KS_EcbAk.mjs.map +1 -0
  302. package/dist/snsSubscriptions-Bl3CChIH.mjs +1472 -0
  303. package/dist/snsSubscriptions-Bl3CChIH.mjs.map +1 -0
  304. package/dist/snsSubscriptions-CQFfrCJf.cjs +1695 -0
  305. package/dist/snsSubscriptions-CQFfrCJf.cjs.map +1 -0
  306. package/dist/sst-DmVJRu5l.cjs +463 -0
  307. package/dist/sst-DmVJRu5l.cjs.map +1 -0
  308. package/dist/sst-fop6uZ25.mjs +440 -0
  309. package/dist/sst-fop6uZ25.mjs.map +1 -0
  310. package/dist/stage-BIKAMxNc.cjs +313 -0
  311. package/dist/stage-BIKAMxNc.cjs.map +1 -0
  312. package/dist/stage-tIMFTQtj.mjs +302 -0
  313. package/dist/stage-tIMFTQtj.mjs.map +1 -0
  314. package/dist/stages-C9uSkohw.cjs +190 -0
  315. package/dist/stages-C9uSkohw.cjs.map +1 -0
  316. package/dist/stages-DhmbURs_.mjs +190 -0
  317. package/dist/stages-DhmbURs_.mjs.map +1 -0
  318. package/dist/target/public.cjs +15 -0
  319. package/dist/target/public.d.cts +28 -0
  320. package/dist/target/public.d.cts.map +1 -0
  321. package/dist/target/public.d.mts +28 -0
  322. package/dist/target/public.d.mts.map +1 -0
  323. package/dist/target/public.mjs +4 -0
  324. package/dist/terminal-CebFDhWQ.mjs +85 -0
  325. package/dist/terminal-CebFDhWQ.mjs.map +1 -0
  326. package/dist/terminal-DBwedwSS.cjs +85 -0
  327. package/dist/terminal-DBwedwSS.cjs.map +1 -0
  328. package/dist/{types-BGo5TaNE.d.mts → types-Cjnqw1ta.d.cts} +2199 -462
  329. package/dist/types-Cjnqw1ta.d.cts.map +1 -0
  330. package/dist/{types-C5ZNpUad.d.cts → types-xBx-07__.d.mts} +2197 -462
  331. package/dist/types-xBx-07__.d.mts.map +1 -0
  332. package/dist/utils-D2Nk1Nv2.cjs +205 -0
  333. package/dist/utils-D2Nk1Nv2.cjs.map +1 -0
  334. package/dist/utils-D_fxUqvU.mjs +156 -0
  335. package/dist/utils-D_fxUqvU.mjs.map +1 -0
  336. package/dist/vitest.cjs +65 -0
  337. package/dist/vitest.cjs.map +1 -0
  338. package/dist/vitest.d.cts +29 -0
  339. package/dist/vitest.d.cts.map +1 -0
  340. package/dist/vitest.d.mts +29 -0
  341. package/dist/vitest.d.mts.map +1 -0
  342. package/dist/vitest.mjs +65 -0
  343. package/dist/vitest.mjs.map +1 -0
  344. package/dist/workerRuntime-BXfhbe13.cjs +108 -0
  345. package/dist/workerRuntime-BXfhbe13.cjs.map +1 -0
  346. package/dist/workerRuntime-CsOyBRx2.mjs +79 -0
  347. package/dist/workerRuntime-CsOyBRx2.mjs.map +1 -0
  348. package/dist/workspace/index.cjs +6 -2
  349. package/dist/workspace/index.d.cts +3 -3
  350. package/dist/workspace/index.d.mts +3 -3
  351. package/dist/workspace/index.mjs +2 -2
  352. package/dist/workspace-CjSfjfMK.mjs +2396 -0
  353. package/dist/workspace-CjSfjfMK.mjs.map +1 -0
  354. package/dist/workspace-DImrdet4.cjs +2808 -0
  355. package/dist/workspace-DImrdet4.cjs.map +1 -0
  356. package/package.json +55 -20
  357. package/dist/HostingerProvider-BY26bWwB.mjs.map +0 -1
  358. package/dist/HostingerProvider-BZFGYYVA.cjs.map +0 -1
  359. package/dist/LocalStateProvider-7HR6SS2t.cjs +0 -48
  360. package/dist/LocalStateProvider-7HR6SS2t.cjs.map +0 -1
  361. package/dist/LocalStateProvider-D7QyJoLM.mjs +0 -48
  362. package/dist/LocalStateProvider-D7QyJoLM.mjs.map +0 -1
  363. package/dist/Route53Provider-Cvj40A8I.mjs.map +0 -1
  364. package/dist/Route53Provider-DVILBsvV.cjs.map +0 -1
  365. package/dist/SSMStateProvider-B0Hu1MKZ.mjs +0 -75
  366. package/dist/SSMStateProvider-B0Hu1MKZ.mjs.map +0 -1
  367. package/dist/SSMStateProvider-VrQ-yeqd.cjs +0 -74
  368. package/dist/SSMStateProvider-VrQ-yeqd.cjs.map +0 -1
  369. package/dist/backup-provisioner-BmhIO_Yr.cjs.map +0 -1
  370. package/dist/backup-provisioner-DIVCbfee.mjs.map +0 -1
  371. package/dist/bundler-BeNDZdHQ.cjs.map +0 -1
  372. package/dist/bundler-BodTL4kf.mjs.map +0 -1
  373. package/dist/config-Q1rvKHvw.cjs +0 -467
  374. package/dist/config-Q1rvKHvw.cjs.map +0 -1
  375. package/dist/config-pqGD3hF9.mjs +0 -414
  376. package/dist/config-pqGD3hF9.mjs.map +0 -1
  377. package/dist/config.d.cts.map +0 -1
  378. package/dist/config.d.mts.map +0 -1
  379. package/dist/credentials-BekkKtY_.mjs +0 -2780
  380. package/dist/credentials-BekkKtY_.mjs.map +0 -1
  381. package/dist/credentials-Q6F0uqJq.cjs +0 -2917
  382. package/dist/credentials-Q6F0uqJq.cjs.map +0 -1
  383. package/dist/discover-BERGFg8v.cjs +0 -288
  384. package/dist/discover-BERGFg8v.cjs.map +0 -1
  385. package/dist/discover-CK-n3w6b.mjs +0 -244
  386. package/dist/discover-CK-n3w6b.mjs.map +0 -1
  387. package/dist/emit-BdoPFjZf.cjs.map +0 -1
  388. package/dist/emit-Bzq7JsMP.mjs.map +0 -1
  389. package/dist/fullstack-secrets-BET8gqwK.mjs +0 -81
  390. package/dist/fullstack-secrets-BET8gqwK.mjs.map +0 -1
  391. package/dist/fullstack-secrets-DXsWO-5m.cjs +0 -92
  392. package/dist/fullstack-secrets-DXsWO-5m.cjs.map +0 -1
  393. package/dist/generator-LfZU7NlU.mjs +0 -247
  394. package/dist/generator-LfZU7NlU.mjs.map +0 -1
  395. package/dist/generator-Wdfp0jCS.cjs +0 -282
  396. package/dist/generator-Wdfp0jCS.cjs.map +0 -1
  397. package/dist/github-BfflNPVe.cjs +0 -203
  398. package/dist/github-BfflNPVe.cjs.map +0 -1
  399. package/dist/github-CRwnxKmD.mjs +0 -203
  400. package/dist/github-CRwnxKmD.mjs.map +0 -1
  401. package/dist/index-Cd-qeOam.d.mts.map +0 -1
  402. package/dist/index-D-iAVHx-.d.cts.map +0 -1
  403. package/dist/keystore-B4PRlbgE.mjs +0 -81
  404. package/dist/keystore-B4PRlbgE.mjs.map +0 -1
  405. package/dist/keystore-DgGRj2Yy.cjs +0 -98
  406. package/dist/keystore-DgGRj2Yy.cjs.map +0 -1
  407. package/dist/openapi-Dcbme-Us.cjs +0 -2038
  408. package/dist/openapi-Dcbme-Us.cjs.map +0 -1
  409. package/dist/openapi-react-query.cjs +0 -158
  410. package/dist/openapi-react-query.cjs.map +0 -1
  411. package/dist/openapi-react-query.d.cts +0 -9
  412. package/dist/openapi-react-query.d.cts.map +0 -1
  413. package/dist/openapi-react-query.d.mts +0 -9
  414. package/dist/openapi-react-query.d.mts.map +0 -1
  415. package/dist/openapi-react-query.mjs +0 -158
  416. package/dist/openapi-react-query.mjs.map +0 -1
  417. package/dist/openapi-vy4JzhUv.mjs +0 -1991
  418. package/dist/openapi-vy4JzhUv.mjs.map +0 -1
  419. package/dist/storage-C-30BD1e.cjs +0 -272
  420. package/dist/storage-C-30BD1e.cjs.map +0 -1
  421. package/dist/storage-P_b3w7uj.mjs +0 -231
  422. package/dist/storage-P_b3w7uj.mjs.map +0 -1
  423. package/dist/sync-B3xxXtJT.mjs +0 -88
  424. package/dist/sync-B3xxXtJT.mjs.map +0 -1
  425. package/dist/sync-D7uTIIEi.cjs +0 -111
  426. package/dist/sync-D7uTIIEi.cjs.map +0 -1
  427. package/dist/types-BGo5TaNE.d.mts.map +0 -1
  428. package/dist/types-C5ZNpUad.d.cts.map +0 -1
  429. package/dist/workspace-CgwmXEtc.mjs.map +0 -1
  430. package/dist/workspace-mFpI_ky_.cjs.map +0 -1
@@ -0,0 +1,687 @@
1
+ const require_errors = require("./errors-DMC4Umsb.cjs");
2
+ const require_EndpointGenerator = require("./EndpointGenerator-De0lknKD.cjs");
3
+ const require_discover = require("./discover-DEOspD9M.cjs");
4
+ let node_path = require("node:path");
5
+ let node_fs_promises = require("node:fs/promises");
6
+ let _geekmidas_manifest = require("@geekmidas/manifest");
7
+ let node_url = require("node:url");
8
+ let _geekmidas_constructs_subscribers = require("@geekmidas/constructs/subscribers");
9
+ //#region src/generators/subscriberRoute.ts
10
+ /**
11
+ * Where SNS pushes a topic subscriber's messages, on the server that runs it:
12
+ * named after the subscriber's export.
13
+ *
14
+ * One definition for both sides — the generated server mounts the route, and
15
+ * the stack exposes exactly these paths on a worker's host — so the path the
16
+ * edge lets through and the path the worker answers cannot drift.
17
+ */
18
+ const SUBSCRIBER_ROUTE_PREFIX = "/__gkm/subscribers/";
19
+ /** The route a subscriber's pushes arrive on. */
20
+ function subscriberRoute(exportName) {
21
+ return `${SUBSCRIBER_ROUTE_PREFIX}${exportName}`;
22
+ }
23
+ /**
24
+ * Where the deploy hands a server the SNS subscriptions it made for its
25
+ * routes: a JSON object of subscriber export → subscription ARN. Against SNS
26
+ * itself a server mounts a route only for a subscription recorded here, and
27
+ * refuses a notification that names another.
28
+ */
29
+ const SNS_SUBSCRIPTIONS_KEY = "GKM_SNS_SUBSCRIPTIONS";
30
+ /**
31
+ * Where a local object store posts a bucket's events, on the process that runs
32
+ * the bucket's subscribers: named after the bucket. Never on a public host —
33
+ * MinIO reaches it over the stack's network, or the host's.
34
+ */
35
+ const OBJECTS_ROUTE_PREFIX = "/__gkm/objects/";
36
+ /** The route a bucket's events are posted to. */
37
+ function objectsRoute(bucketId) {
38
+ return `${OBJECTS_ROUTE_PREFIX}${bucketId}`;
39
+ }
40
+ //#endregion
41
+ //#region src/reconcile/fakes.ts
42
+ /**
43
+ * Fakes, read from where the convention puts them.
44
+ *
45
+ * `test/fakes/<id>.ts` default-exports `fake.app(…)` or `fake.image(…)` for an
46
+ * external API, and `fake.credential(…)` for a credential. The construct never
47
+ * names it — that is what keeps a fake out of a deployed bundle — so this is
48
+ * the one place it is found, by the same rule that finds a database's factory
49
+ * in `test/factories/<id>.ts`.
50
+ */
51
+ /** Where a project keeps its external APIs' fakes, relative to its root. */
52
+ const DEFAULT_FAKES_DIR = "test/fakes";
53
+ /** The marker `fake.app` and `fake.image` set — the same registered symbol. */
54
+ const FAKE = Symbol.for("@geekmidas/constructs/fake");
55
+ /**
56
+ * The fake for every external API the manifest declares, keyed by id.
57
+ *
58
+ * @throws {NoFake} when an external API has no file, since a local stage would
59
+ * otherwise have nothing to call.
60
+ * @throws {NotAFake} when the file's default export is not one.
61
+ */
62
+ async function readFakes(root, manifest) {
63
+ const fakes = {};
64
+ for (const [id, declaration] of Object.entries(manifest)) {
65
+ if (declaration?.kind !== "external-api") continue;
66
+ const file = await fakeFile((0, node_path.join)(root, DEFAULT_FAKES_DIR), id);
67
+ if (!file) throw new NoFake(id, `${fakeBase(root, id)}.ts`);
68
+ const value = await importFake(file);
69
+ if (value.kind === "credential") throw new NotAFake(file);
70
+ fakes[id] = {
71
+ file,
72
+ ...value.kind === "image" ? {
73
+ image: value.image,
74
+ port: value.port
75
+ } : {},
76
+ credentials: JSON.stringify(value.credentials)
77
+ };
78
+ }
79
+ return fakes;
80
+ }
81
+ /**
82
+ * Each credential's fake value, as the JSON `<ID>_CREDENTIALS` holds, keyed by
83
+ * id — for the credentials that have a fake. Unlike an external API's, a
84
+ * credential's fake is optional here: a stage that stores the real value
85
+ * needs none. The test stage's own check (`assertTestCredentials`) is what
86
+ * refuses one with neither.
87
+ *
88
+ * @throws {NotAFake} when the file's default export is not a credential's fake.
89
+ */
90
+ async function readCredentialFakes(root, manifest) {
91
+ const values = {};
92
+ for (const [id, declaration] of Object.entries(manifest)) {
93
+ if (declaration?.kind !== "credential") continue;
94
+ const file = await fakeFile((0, node_path.join)(root, DEFAULT_FAKES_DIR), id);
95
+ if (!file) continue;
96
+ const value = await importFake(file);
97
+ if (value.kind !== "credential") throw new NotAFake(file);
98
+ values[id] = JSON.stringify(value.credentials);
99
+ }
100
+ return values;
101
+ }
102
+ /**
103
+ * A credential the test stage has no value for: no fake, and nothing stored.
104
+ * Raised when the stage is set up, before a test reaches it — not as a schema
105
+ * error inside the handler that first asked.
106
+ */
107
+ var CredentialHasNoTestValue = class extends require_errors.GkmError {
108
+ id;
109
+ key;
110
+ file;
111
+ constructor(id, key, file) {
112
+ 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>).`);
113
+ this.id = id;
114
+ this.key = key;
115
+ this.file = file;
116
+ this.name = "CredentialHasNoTestValue";
117
+ }
118
+ };
119
+ /**
120
+ * Every credential the test stage must hand its suite, with the value it
121
+ * resolved — a fake's, or one the stage stores.
122
+ *
123
+ * @throws {CredentialHasNoTestValue} for the first one with neither.
124
+ */
125
+ function assertTestCredentials(root, plan, env) {
126
+ const values = {};
127
+ for (const { id, kind, envKey } of plan.resources) {
128
+ if (kind !== "credential") continue;
129
+ const value = env[envKey];
130
+ if (value === void 0) throw new CredentialHasNoTestValue(id, envKey, `${fakeBase(root, id)}.ts`);
131
+ values[envKey] = value;
132
+ }
133
+ return values;
134
+ }
135
+ /** `<root>/test/fakes/<id>`, without an extension. */
136
+ function fakeBase(root, id) {
137
+ return (0, node_path.join)(root, DEFAULT_FAKES_DIR, (0, _geekmidas_manifest.kebabCase)(id));
138
+ }
139
+ /** The first of `<id>.ts`, `.mts`, `.js`, `.mjs` that exists. */
140
+ async function fakeFile(folder, id) {
141
+ const base = (0, node_path.join)(folder, (0, _geekmidas_manifest.kebabCase)(id));
142
+ for (const extension of [
143
+ ".ts",
144
+ ".mts",
145
+ ".js",
146
+ ".mjs"
147
+ ]) {
148
+ const file = `${base}${extension}`;
149
+ if (await (0, node_fs_promises.access)(file).then(() => true, () => false)) return file;
150
+ }
151
+ }
152
+ /**
153
+ * A fake file's default export.
154
+ *
155
+ * @throws {NotAFake} when it is not a fake.
156
+ */
157
+ async function importFake(file) {
158
+ const value = (await import((0, node_url.pathToFileURL)(file).href)).default;
159
+ if (!isFakeExport(value)) throw new NotAFake(file);
160
+ return value;
161
+ }
162
+ function isFakeExport(value) {
163
+ return typeof value === "object" && value !== null && value[FAKE] === true;
164
+ }
165
+ /** An external API with no fake for a local stage to call. */
166
+ var NoFake = class extends require_errors.GkmError {
167
+ id;
168
+ file;
169
+ constructor(id, file) {
170
+ 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.`);
171
+ this.id = id;
172
+ this.file = file;
173
+ this.name = "NoFake";
174
+ }
175
+ };
176
+ /** A file in the fakes folder whose default export is not a fake. */
177
+ var NotAFake = class extends require_errors.GkmError {
178
+ file;
179
+ constructor(file) {
180
+ 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).`);
181
+ this.file = file;
182
+ this.name = "NotAFake";
183
+ }
184
+ };
185
+ //#endregion
186
+ //#region src/generators/SubscriberGenerator.ts
187
+ var SubscriberGenerator = class extends require_discover.ConstructGenerator {
188
+ isConstruct(value) {
189
+ return _geekmidas_constructs_subscribers.Subscriber.isSubscriber(value);
190
+ }
191
+ async build(context, constructs, outputDir, options) {
192
+ const target = options?.target ?? "aws";
193
+ const logger = console;
194
+ const subscriberInfos = [];
195
+ for (const { key, construct } of constructs) assertDoesNotFeedItself(key, construct);
196
+ if (target === "server") {
197
+ await this.generateServerSubscribersFile(outputDir, constructs, (context.eventsBackends?.includes("sns") ?? false) || constructs.some(({ construct }) => construct.bucketName));
198
+ logger.log(`Generated server subscribers file with ${constructs.length} subscribers (polling mode)`);
199
+ return subscriberInfos;
200
+ }
201
+ if (constructs.length === 0) return subscriberInfos;
202
+ const subscribersDir = (0, node_path.join)(outputDir, "subscribers");
203
+ await (0, node_fs_promises.mkdir)(subscribersDir, { recursive: true });
204
+ for (const { key, construct, path } of constructs) {
205
+ const handlerFile = await this.generateSubscriberHandler(subscribersDir, path.relative, key, construct, context, construct.owner);
206
+ subscriberInfos.push({
207
+ name: key,
208
+ handler: (0, node_path.relative)(options?.root ?? process.cwd(), handlerFile).replace(/\.ts$/, ".handler"),
209
+ subscribedEvents: construct.subscribedEvents || [],
210
+ ...construct.topicName ? {
211
+ transport: "topic",
212
+ topic: construct.topicName
213
+ } : {},
214
+ ...construct.bucketName ? {
215
+ transport: "topic",
216
+ bucket: construct.bucketName,
217
+ ...construct.objectFilter
218
+ } : {},
219
+ timeout: construct.timeout,
220
+ memorySize: construct.memorySize,
221
+ environment: await construct.getEnvironment({ markOptional: context.markOptional }),
222
+ dependencies: construct.constructs
223
+ });
224
+ logger.log(`Generated subscriber handler: ${key}`);
225
+ }
226
+ return subscriberInfos;
227
+ }
228
+ async generateSubscriberHandler(outputDir, sourceFile, exportName, _subscriber, context, owner) {
229
+ const handlerFileName = `${exportName}.ts`;
230
+ const handlerPath = (0, node_path.join)(outputDir, handlerFileName);
231
+ const importPath = (0, node_path.relative)((0, node_path.dirname)(handlerPath), sourceFile).replace(/\.ts$/, ".js");
232
+ const runtime = require_EndpointGenerator.runtimeFor(context, (0, node_path.dirname)(handlerPath), owner);
233
+ const content = `import { AWSLambdaSubscriber } from '@geekmidas/constructs/aws';
234
+ import { ${exportName} } from '${importPath}';
235
+ ${runtime.imports}
236
+ ${context.storageDrivers?.imports ?? ""}
237
+ ${runtime.bindings}
238
+ ${context.storageDrivers?.setup ? `\n// The handler registers the drivers its target needs.\n${context.storageDrivers.setup}\n` : ""}
239
+ const adapter = new AWSLambdaSubscriber(envParser, ${exportName});
240
+
241
+ export const handler = adapter.handler;
242
+ `;
243
+ await (0, node_fs_promises.writeFile)(handlerPath, content);
244
+ return handlerPath;
245
+ }
246
+ async generateServerSubscribersFile(outputDir, subscribers, push) {
247
+ await (0, node_fs_promises.mkdir)(outputDir, { recursive: true });
248
+ const subscribersPath = (0, node_path.join)(outputDir, "subscribers.ts");
249
+ if (subscribers.length === 0) {
250
+ await (0, node_fs_promises.writeFile)(subscribersPath, `/**
251
+ * Generated subscribers setup — this app declares none.
252
+ */
253
+ import type { EnvironmentParser } from '@geekmidas/envkit';
254
+ import type { Logger } from '@geekmidas/logger';
255
+
256
+ export async function setupSubscribers(
257
+ _app: unknown,
258
+ _envParser: EnvironmentParser<any>,
259
+ _logger: Logger,
260
+ ): Promise<(port: number) => Promise<void>> {
261
+ return async () => {};
262
+ }
263
+
264
+ export function subscribersStatus(): { failed: string[]; connections: unknown[] } {
265
+ return { failed: [], connections: [] };
266
+ }
267
+
268
+ export async function stopSubscribers(): Promise<void> {}
269
+ `);
270
+ return subscribersPath;
271
+ }
272
+ const importsByFile = /* @__PURE__ */ new Map();
273
+ for (const { path, key } of subscribers) {
274
+ const importPath = (0, node_path.relative)((0, node_path.dirname)(subscribersPath), path.relative).replace(/\.ts$/, ".js");
275
+ importsByFile.set(importPath, [...importsByFile.get(importPath) ?? [], key]);
276
+ }
277
+ const imports = Array.from(importsByFile.entries()).map(([importPath, exports]) => `import { ${exports.join(", ")} } from '${importPath}';`).join("\n");
278
+ const entries = subscribers.map(({ key, construct }) => {
279
+ const connectionKey = require_discover.subscriberConnectionKey(construct);
280
+ const tokenKey = require_discover.subscriberTokenKey(construct);
281
+ const topic = construct.topicName ?? construct.bucketName;
282
+ const bucket = construct.bucketName ? (0, _geekmidas_manifest.canonicalId)(construct.bucketName) : void 0;
283
+ return ` { id: '${key}', subscriber: ${key}, topic: ${topic ? `'${topic}'` : "undefined"}, connectionKey: ${connectionKey ? `'${connectionKey}'` : "undefined"}, filtered: ${construct.bucketName ? "false" : "true"}, bucket: ${bucket ? `'${bucket}'` : "undefined"}, tokenKey: ${tokenKey ? `'${tokenKey}'` : "undefined"} },`;
284
+ }).join("\n");
285
+ const content = `/**
286
+ * Generated subscribers setup.
287
+ *
288
+ * Each subscriber is run against the topic it is bound to, through that
289
+ * topic's own connection string:
290
+ *
291
+ * - **sns://** — pushed, not polled. The subscriber gets an HTTP route on this
292
+ * server, subscribed to the topic with a filter policy of the events it
293
+ * named, so SNS fans out to each subscriber. The route runs the subscriber
294
+ * through the same adaptor a Lambda subscription does. Against SNS itself
295
+ * the deploy made the subscription and recorded its ARN in
296
+ * ${SNS_SUBSCRIPTIONS_KEY}: a route is mounted only for a recorded one, its
297
+ * confirmation goes through the API, and nothing is subscribed from here.
298
+ * Against an emulator, where nothing deploys, the route subscribes itself.
299
+ * - **anything else** (pgboss://, rabbitmq://, sqs://) — polled. On pg-boss
300
+ * each subscriber drains a queue of its own, \`<topic>/<subscriber>\`, so
301
+ * every subscriber sees every event; replicas of one subscriber share it.
302
+ *
303
+ * A bucket's subscriber is polled the same way, under the bucket's name, when
304
+ * the bucket is in a local object store: the store posts each event to
305
+ * \`${OBJECTS_ROUTE_PREFIX}<Bucket>\` on this server, with the bucket's token, and
306
+ * the event is relayed onto the broker as \`object.created\` or
307
+ * \`object.deleted\` — so every subscriber of the bucket sees it.
308
+ *
309
+ * GKM_SUBSCRIBERS=off (\`gkm dev --no-subscribers\`) runs none of them.
310
+ * GKM_SUBSCRIBER_PUSH_URL is the address an emulator pushes to, defaulting to
311
+ * this server through host.docker.internal.
312
+ */
313
+ import { timingSafeEqual } from 'node:crypto';
314
+ import { connect } from 'node:net';
315
+ import type { EnvironmentParser } from '@geekmidas/envkit';
316
+ import type { Logger } from '@geekmidas/logger';
317
+ import { EventConnectionFactory, Publisher, Subscriber } from '@geekmidas/events';
318
+ import type { EventConnection } from '@geekmidas/events';
319
+ import { ServiceDiscovery } from '@geekmidas/services';
320
+ ${imports}
321
+
322
+ const subscribers = [
323
+ ${entries}
324
+ ];
325
+
326
+ // What was opened, and what could not be: a worker's health check reads both,
327
+ // and its shutdown closes what was opened.
328
+ const connections = new Map<string, EventConnection>();
329
+ const failed: string[] = [];
330
+
331
+ /**
332
+ * The subscriptions the deploy made against SNS itself, by subscriber: which
333
+ * routes to mount, and the ARN each one's notifications must name.
334
+ */
335
+ function recordedSubscriptions(logger: Logger): Record<string, string> {
336
+ const raw = process.env.${SNS_SUBSCRIPTIONS_KEY};
337
+ if (!raw) return {};
338
+ try {
339
+ const parsed = JSON.parse(raw);
340
+ if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) return parsed;
341
+ } catch {}
342
+ logger.error('${SNS_SUBSCRIPTIONS_KEY} is not a JSON object of subscriber → subscription ARN');
343
+ return {};
344
+ }
345
+
346
+ /** The route a subscriber's pushes arrive on. */
347
+ export const SUBSCRIBER_ROUTE = (id: string) => \`${SUBSCRIBER_ROUTE_PREFIX}\${id}\`;
348
+
349
+ /** The route a local object store posts a bucket's events to. */
350
+ export const OBJECTS_ROUTE = (bucket: string) => \`${OBJECTS_ROUTE_PREFIX}\${bucket}\`;
351
+
352
+ // The buckets whose events this server relays: one route each, however many
353
+ // subscribers watch the bucket.
354
+ const relays = new Set<string>();
355
+
356
+ /**
357
+ * Mount the route a local object store posts one bucket's events to, and
358
+ * relay each event onto the broker under the bucket's name.
359
+ *
360
+ * Answered 2xx only once every event is published: the store keeps what it
361
+ * was not told it delivered, and sends it again.
362
+ */
363
+ async function mountObjectRelay(
364
+ app: { post: (path: string, handler: (c: any) => unknown) => unknown },
365
+ relay: { bucket: string; topic: string; connection: EventConnection; tokenKey: string },
366
+ logger: Logger,
367
+ ): Promise<void> {
368
+ const token = process.env[relay.tokenKey];
369
+ if (!token) {
370
+ logger.error(
371
+ { bucket: relay.bucket, tokenKey: relay.tokenKey },
372
+ 'No token for this bucket: the events its object store posts cannot be received',
373
+ );
374
+ failed.push(\`\${relay.bucket}#events\`);
375
+ return;
376
+ }
377
+ const { toObjectEvents } = await import('@geekmidas/storage/events');
378
+ const publisher = await Publisher.fromConnection(relay.connection, { topic: relay.topic });
379
+ const expected = Buffer.from(\`Bearer \${token}\`);
380
+
381
+ app.post(OBJECTS_ROUTE(relay.bucket), async (c: any) => {
382
+ // Compared in constant time: the route is not public, but it is the one
383
+ // way to put an event in front of every subscriber of the bucket.
384
+ const given = Buffer.from(c.req.header('authorization') ?? '');
385
+ if (given.length !== expected.length || !timingSafeEqual(given, expected)) {
386
+ return c.json({ status: 'refused' }, 401);
387
+ }
388
+
389
+ let messages: Awaited<ReturnType<typeof toObjectEvents>>;
390
+ try {
391
+ messages = toObjectEvents(JSON.parse(await c.req.text()));
392
+ } catch (error) {
393
+ logger.warn({ err: error, bucket: relay.bucket }, 'Refused an object notification that did not parse');
394
+ return c.json({ status: 'malformed' }, 400);
395
+ }
396
+
397
+ try {
398
+ if (messages.length > 0) await publisher.publish(messages as any);
399
+ } catch (error) {
400
+ // The store sends it again.
401
+ logger.error({ err: error, bucket: relay.bucket }, 'Failed to relay object events');
402
+ return c.json({ status: 'failed' }, 500);
403
+ }
404
+ return c.json({ status: 'ok', relayed: messages.length }, 200);
405
+ });
406
+ logger.info({ bucket: relay.bucket }, 'Relaying object events');
407
+ }
408
+
409
+ /** Resolves once something is accepting connections on the port. */
410
+ async function listening(port: number): Promise<void> {
411
+ for (let attempt = 0; attempt < 100; attempt++) {
412
+ const open = await new Promise<boolean>((resolve) => {
413
+ const socket = connect(port, '127.0.0.1');
414
+ socket.once('connect', () => { socket.end(); resolve(true); });
415
+ socket.once('error', () => resolve(false));
416
+ });
417
+ if (open) return;
418
+ await new Promise((resolve) => setTimeout(resolve, 50));
419
+ }
420
+ }
421
+
422
+ /**
423
+ * Mount each pushed subscriber's route and start each polled one. Returns what
424
+ * to run once the server is listening: subscribing a route makes SNS send its
425
+ * confirmation at once, so the route has to be reachable first.
426
+ */
427
+ export async function setupSubscribers(
428
+ app: { post: (path: string, handler: (c: any) => unknown) => unknown },
429
+ envParser: EnvironmentParser<any>,
430
+ logger: Logger,
431
+ ): Promise<(port: number) => Promise<void>> {
432
+ if (process.env.GKM_SUBSCRIBERS === 'off') {
433
+ logger.info('Subscribers are off (--no-subscribers)');
434
+ return async () => {};
435
+ }
436
+
437
+ const serviceDiscovery = ServiceDiscovery.getInstance(envParser);
438
+ const recorded = recordedSubscriptions(logger);
439
+ const afterListening: ((port: number) => Promise<void>)[] = [];
440
+
441
+ for (const { id, subscriber, topic, connectionKey, filtered, bucket, tokenKey } of subscribers) {
442
+ const events = subscriber.subscribedEvents || [];
443
+ if (events.length === 0) {
444
+ logger.warn({ subscriber: id }, 'Subscriber has no subscribed events, skipping');
445
+ continue;
446
+ }
447
+ const connectionString = connectionKey ? process.env[connectionKey] : undefined;
448
+ if (!connectionString) {
449
+ logger.error(
450
+ { subscriber: id, connectionKey },
451
+ 'No connection string for the topic or bucket this subscriber is bound to',
452
+ );
453
+ failed.push(id);
454
+ continue;
455
+ }
456
+
457
+ try {
458
+ ${push ? ` if (connectionString.startsWith('sns:')) {
459
+ const { SNSConnection, snsUrl, subscribeHttpEndpoint, confirmSubscription } = await import('@geekmidas/events/sns');
460
+ const { SnsPushSubscriberAdaptor } = await import('@geekmidas/constructs/subscribers');
461
+ const address = snsUrl.parse(connectionString);
462
+ const route = SUBSCRIBER_ROUTE(id);
463
+ const mount = (adaptor: InstanceType<typeof SnsPushSubscriberAdaptor>) =>
464
+ app.post(route, async (c: any) => {
465
+ const body = JSON.parse(await c.req.text());
466
+ const response = await adaptor.handle(body, {
467
+ subscriptionArn: c.req.header('x-amz-sns-subscription-arn'),
468
+ });
469
+ return c.json(response.body, response.status);
470
+ });
471
+
472
+ if (!address.endpoint) {
473
+ // SNS itself: the deploy subscribed this route and recorded the ARN.
474
+ // Nothing is subscribed from here, so this server's credentials need
475
+ // only sns:ConfirmSubscription on the topic.
476
+ const subscriptionArn = recorded[id];
477
+ if (!subscriptionArn) {
478
+ logger.error(
479
+ { subscriber: id },
480
+ 'No subscription recorded for this subscriber in ${SNS_SUBSCRIPTIONS_KEY}: deploy it so SNS has a route to push to',
481
+ );
482
+ failed.push(id);
483
+ continue;
484
+ }
485
+ const connection = await SNSConnection.fromConnectionString(connectionString);
486
+ mount(
487
+ new SnsPushSubscriberAdaptor(envParser, subscriber, {
488
+ topicArn: address.topicArn,
489
+ verify: true,
490
+ subscriptionArn,
491
+ // As the topic's owner, so only the owner can unsubscribe the
492
+ // route — not whoever holds a notification's UnsubscribeURL.
493
+ confirm: (message) => confirmSubscription(connection, message),
494
+ }),
495
+ );
496
+ logger.info({ subscriber: id, events }, 'Subscriber mounted for push');
497
+ continue;
498
+ }
499
+
500
+ // An emulator signs nothing, and nothing deploys its subscriptions:
501
+ // decided by the address this server was configured with, never by
502
+ // anything a request says about itself.
503
+ mount(
504
+ new SnsPushSubscriberAdaptor(envParser, subscriber, {
505
+ topicArn: address.topicArn,
506
+ verify: false,
507
+ emulatorEndpoint: address.endpoint,
508
+ }),
509
+ );
510
+
511
+ afterListening.push(async (port) => {
512
+ const base =
513
+ process.env.GKM_SUBSCRIBER_PUSH_URL ?? \`http://host.docker.internal:\${port}\`;
514
+ const connection = await SNSConnection.fromConnectionString(connectionString);
515
+ await subscribeHttpEndpoint(connection, {
516
+ endpoint: new URL(route, base).toString(),
517
+ ...(filtered ? { events } : {}),
518
+ });
519
+ logger.info({ subscriber: id, events }, 'Subscriber subscribed for push');
520
+ });
521
+ continue;
522
+ }
523
+ ` : ` if (connectionString.startsWith('sns:')) {
524
+ // Built for a broker other than SNS, so this entry registered no SNS
525
+ // driver and has no push route to offer.
526
+ logger.error(
527
+ { subscriber: id, connectionKey },
528
+ 'This build has no SNS driver: it was built for a target whose broker is not SNS',
529
+ );
530
+ failed.push(id);
531
+ continue;
532
+ }
533
+ `}
534
+
535
+ let connection = connections.get(connectionString);
536
+ if (!connection) {
537
+ connection = await EventConnectionFactory.fromConnectionString(connectionString);
538
+ connections.set(connectionString, connection);
539
+ }
540
+ // Named, so a broker with one address for everything (pg-boss) gives
541
+ // this subscriber a queue of its own: fan-out, not competition.
542
+ const eventSubscriber = await Subscriber.fromConnection(connection, {
543
+ topic,
544
+ subscription: id,
545
+ });
546
+ const services = subscriber.services.length > 0
547
+ ? await serviceDiscovery.register(subscriber.services)
548
+ : {};
549
+ // The subscriber's database — the worker's, or its own — as \`db\`. A
550
+ // pushed subscriber gets it from the adaptor above instead.
551
+ const db = subscriber.databaseService
552
+ ? (await serviceDiscovery.register([subscriber.databaseService]))[
553
+ subscriber.databaseService.serviceName
554
+ ]
555
+ : undefined;
556
+
557
+ await eventSubscriber.subscribe(events, async (event) => {
558
+ try {
559
+ await subscriber.handler({
560
+ events: [event],
561
+ services: services as any,
562
+ logger: subscriber.logger,
563
+ db,
564
+ } as any);
565
+ } catch (error) {
566
+ logger.error({ err: error, event, subscriber: id }, 'Failed to process event');
567
+ // Rethrown so the transport keeps the event for a retry — as a queue
568
+ // consumer's failure does, and as a pushed subscriber's 500 does.
569
+ throw error;
570
+ }
571
+ });
572
+ logger.info({ subscriber: id, events }, 'Subscriber started polling');
573
+
574
+ // A bucket in a local object store publishes nothing for this to poll:
575
+ // the store posts its events here, and they are relayed onto the broker.
576
+ if (bucket && tokenKey && topic && !relays.has(bucket)) {
577
+ relays.add(bucket);
578
+ await mountObjectRelay(app, { bucket, topic, connection, tokenKey }, logger);
579
+ }
580
+ } catch (error) {
581
+ // The message too: a missing module's code alone does not say which.
582
+ logger.error(
583
+ { err: error, subscriber: id },
584
+ 'Failed to set up subscriber',
585
+ );
586
+ failed.push(id);
587
+ }
588
+ }
589
+
590
+ return async (port) => {
591
+ if (afterListening.length === 0) return;
592
+ await listening(port);
593
+ for (const subscribe of afterListening) {
594
+ await subscribe(port).catch((error) => {
595
+ logger.error({ err: error }, 'Failed to subscribe for push');
596
+ });
597
+ }
598
+ };
599
+ }
600
+
601
+ /** The subscribers that could not start, and the connections that did. */
602
+ export function subscribersStatus(): { failed: string[]; connections: EventConnection[] } {
603
+ return { failed: [...failed], connections: [...connections.values()] };
604
+ }
605
+
606
+ /**
607
+ * Stop polling, let the events in flight finish, and close each broker
608
+ * connection — pg-boss's graceful stop does all three. The caller bounds it.
609
+ */
610
+ export async function stopSubscribers(): Promise<void> {
611
+ const open = [...connections.values()];
612
+ connections.clear();
613
+ await Promise.all(open.map((connection) => connection.close()));
614
+ }
615
+ `;
616
+ await (0, node_fs_promises.writeFile)(subscribersPath, content);
617
+ return subscribersPath;
618
+ }
619
+ };
620
+ /**
621
+ * A bucket's subscriber that writes back into the keys it watches.
622
+ *
623
+ * Every write it makes is a new object event, which runs it again — forever,
624
+ * and billed per run. The rule is the one the build can check: a subscriber
625
+ * that depends on the bucket it watches must watch a prefix, so what it writes
626
+ * can go elsewhere. A thumbnailer watching `uploads/` writes `thumbnails/`.
627
+ */
628
+ var ObjectSubscriberFeedsItself = class extends Error {
629
+ subscriber;
630
+ bucket;
631
+ constructor(subscriber, bucket) {
632
+ 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.`);
633
+ this.subscriber = subscriber;
634
+ this.bucket = bucket;
635
+ this.name = "ObjectSubscriberFeedsItself";
636
+ }
637
+ };
638
+ function assertDoesNotFeedItself(key, construct) {
639
+ const bucket = construct.bucketName;
640
+ if (!bucket || construct.objectFilter?.prefix) return;
641
+ if ((construct.constructs ?? []).some((id) => (0, _geekmidas_manifest.canonicalId)(id) === (0, _geekmidas_manifest.canonicalId)(bucket))) throw new ObjectSubscriberFeedsItself(key, bucket);
642
+ }
643
+ //#endregion
644
+ Object.defineProperty(exports, "SNS_SUBSCRIPTIONS_KEY", {
645
+ enumerable: true,
646
+ get: function() {
647
+ return SNS_SUBSCRIPTIONS_KEY;
648
+ }
649
+ });
650
+ Object.defineProperty(exports, "SubscriberGenerator", {
651
+ enumerable: true,
652
+ get: function() {
653
+ return SubscriberGenerator;
654
+ }
655
+ });
656
+ Object.defineProperty(exports, "assertTestCredentials", {
657
+ enumerable: true,
658
+ get: function() {
659
+ return assertTestCredentials;
660
+ }
661
+ });
662
+ Object.defineProperty(exports, "objectsRoute", {
663
+ enumerable: true,
664
+ get: function() {
665
+ return objectsRoute;
666
+ }
667
+ });
668
+ Object.defineProperty(exports, "readCredentialFakes", {
669
+ enumerable: true,
670
+ get: function() {
671
+ return readCredentialFakes;
672
+ }
673
+ });
674
+ Object.defineProperty(exports, "readFakes", {
675
+ enumerable: true,
676
+ get: function() {
677
+ return readFakes;
678
+ }
679
+ });
680
+ Object.defineProperty(exports, "subscriberRoute", {
681
+ enumerable: true,
682
+ get: function() {
683
+ return subscriberRoute;
684
+ }
685
+ });
686
+
687
+ //# sourceMappingURL=SubscriberGenerator-CPjbWEOI.cjs.map