@geekmidas/cli 10.0.0-alpha.19 → 10.0.0-alpha.190

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 (436) hide show
  1. package/README.md +323 -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-CBKH87_b.mjs +1043 -0
  7. package/dist/EndpointGenerator-CBKH87_b.mjs.map +1 -0
  8. package/dist/EndpointGenerator-iyA3HkOH.cjs +1102 -0
  9. package/dist/EndpointGenerator-iyA3HkOH.cjs.map +1 -0
  10. package/dist/LegacyStateStore-CWiswz6T.mjs +124 -0
  11. package/dist/LegacyStateStore-CWiswz6T.mjs.map +1 -0
  12. package/dist/LegacyStateStore-CuSe37fl.cjs +124 -0
  13. package/dist/LegacyStateStore-CuSe37fl.cjs.map +1 -0
  14. package/dist/LocalStateStore-BciJ_DF0.cjs +178 -0
  15. package/dist/LocalStateStore-BciJ_DF0.cjs.map +1 -0
  16. package/dist/LocalStateStore-CLHasLJI.mjs +167 -0
  17. package/dist/LocalStateStore-CLHasLJI.mjs.map +1 -0
  18. package/dist/OpenApiTsGenerator-CoVA3Ykv.mjs +534 -0
  19. package/dist/OpenApiTsGenerator-CoVA3Ykv.mjs.map +1 -0
  20. package/dist/OpenApiTsGenerator-vy-fOJgs.cjs +539 -0
  21. package/dist/OpenApiTsGenerator-vy-fOJgs.cjs.map +1 -0
  22. package/dist/S3StateStore-BHLRjoj3.cjs +222 -0
  23. package/dist/S3StateStore-BHLRjoj3.cjs.map +1 -0
  24. package/dist/S3StateStore-CTiv2_ON.mjs +223 -0
  25. package/dist/S3StateStore-CTiv2_ON.mjs.map +1 -0
  26. package/dist/SSMStateStore-BqT3MXXb.cjs +204 -0
  27. package/dist/SSMStateStore-BqT3MXXb.cjs.map +1 -0
  28. package/dist/SSMStateStore-D6qqaem2.mjs +205 -0
  29. package/dist/SSMStateStore-D6qqaem2.mjs.map +1 -0
  30. package/dist/SubscriberGenerator-Cfoz8uTY.mjs +787 -0
  31. package/dist/SubscriberGenerator-Cfoz8uTY.mjs.map +1 -0
  32. package/dist/SubscriberGenerator-CxzECrfj.cjs +852 -0
  33. package/dist/SubscriberGenerator-CxzECrfj.cjs.map +1 -0
  34. package/dist/add-B2OmIQzs.cjs +712 -0
  35. package/dist/add-B2OmIQzs.cjs.map +1 -0
  36. package/dist/add-CXwL549o.mjs +710 -0
  37. package/dist/add-CXwL549o.mjs.map +1 -0
  38. package/dist/appPorts-BoXMwolc.mjs +249 -0
  39. package/dist/appPorts-BoXMwolc.mjs.map +1 -0
  40. package/dist/appPorts-IW-OZmRi.cjs +296 -0
  41. package/dist/appPorts-IW-OZmRi.cjs.map +1 -0
  42. package/dist/aws-BXfiWNbi.cjs +108 -0
  43. package/dist/aws-BXfiWNbi.cjs.map +1 -0
  44. package/dist/aws-BjvSTTcE.mjs +97 -0
  45. package/dist/aws-BjvSTTcE.mjs.map +1 -0
  46. package/dist/awsStore-BYYCmXiq.mjs +121 -0
  47. package/dist/awsStore-BYYCmXiq.mjs.map +1 -0
  48. package/dist/awsStore-DKQUElJL.cjs +138 -0
  49. package/dist/awsStore-DKQUElJL.cjs.map +1 -0
  50. package/dist/{backup-provisioner-DIVCbfee.mjs → backup-provisioner-C8DnCmxK.mjs} +2 -2
  51. package/dist/backup-provisioner-C8DnCmxK.mjs.map +1 -0
  52. package/dist/{backup-provisioner-BmhIO_Yr.cjs → backup-provisioner-oDEsPj02.cjs} +2 -2
  53. package/dist/backup-provisioner-oDEsPj02.cjs.map +1 -0
  54. package/dist/backups/runner.cjs +1007 -0
  55. package/dist/backups/runner.cjs.map +1 -0
  56. package/dist/backups/runner.d.cts +187 -0
  57. package/dist/backups/runner.d.cts.map +1 -0
  58. package/dist/backups/runner.d.mts +187 -0
  59. package/dist/backups/runner.d.mts.map +1 -0
  60. package/dist/backups/runner.mjs +984 -0
  61. package/dist/backups/runner.mjs.map +1 -0
  62. package/dist/{bundler-mwH7WOb1.mjs → bundler-CHXyJFsS.mjs} +68 -15
  63. package/dist/bundler-CHXyJFsS.mjs.map +1 -0
  64. package/dist/{bundler-mjqGAvu1.cjs → bundler-CLoVtcBi.cjs} +67 -14
  65. package/dist/bundler-CLoVtcBi.cjs.map +1 -0
  66. package/dist/cli-Bjua3PaZ.mjs +80 -0
  67. package/dist/cli-Bjua3PaZ.mjs.map +1 -0
  68. package/dist/cli-DiuUr1Am.cjs +80 -0
  69. package/dist/cli-DiuUr1Am.cjs.map +1 -0
  70. package/dist/clientTelemetry-DXuYNH-J.d.cts +10 -0
  71. package/dist/clientTelemetry-DXuYNH-J.d.cts.map +1 -0
  72. package/dist/clientTelemetry-eC8VQ6nB.d.mts +10 -0
  73. package/dist/clientTelemetry-eC8VQ6nB.d.mts.map +1 -0
  74. package/dist/compose-DUOETDhc.mjs +2855 -0
  75. package/dist/compose-DUOETDhc.mjs.map +1 -0
  76. package/dist/compose-gnNrY3NQ.cjs +2939 -0
  77. package/dist/compose-gnNrY3NQ.cjs.map +1 -0
  78. package/dist/config-1zirYXeO.d.mts +300 -0
  79. package/dist/config-1zirYXeO.d.mts.map +1 -0
  80. package/dist/config-rSlB-bXj.d.cts +300 -0
  81. package/dist/config-rSlB-bXj.d.cts.map +1 -0
  82. package/dist/config.cjs +462 -9
  83. package/dist/config.cjs.map +1 -0
  84. package/dist/config.d.cts +4 -117
  85. package/dist/config.d.mts +4 -117
  86. package/dist/config.mjs +446 -3
  87. package/dist/config.mjs.map +1 -0
  88. package/dist/credentialSchemas-D_85KW2k.mjs +236 -0
  89. package/dist/credentialSchemas-D_85KW2k.mjs.map +1 -0
  90. package/dist/credentialSchemas-DjK6xKMk.cjs +271 -0
  91. package/dist/credentialSchemas-DjK6xKMk.cjs.map +1 -0
  92. package/dist/credentials-BI52H1ad.cjs +2911 -0
  93. package/dist/credentials-BI52H1ad.cjs.map +1 -0
  94. package/dist/credentials-Cp09PIsc.cjs +1451 -0
  95. package/dist/credentials-Cp09PIsc.cjs.map +1 -0
  96. package/dist/credentials-DbjLhvix.mjs +1140 -0
  97. package/dist/credentials-DbjLhvix.mjs.map +1 -0
  98. package/dist/credentials-VLP_959f.mjs +2390 -0
  99. package/dist/credentials-VLP_959f.mjs.map +1 -0
  100. package/dist/databases-CV22HzrI.mjs +588 -0
  101. package/dist/databases-CV22HzrI.mjs.map +1 -0
  102. package/dist/databases-DwYYH2mX.cjs +703 -0
  103. package/dist/databases-DwYYH2mX.cjs.map +1 -0
  104. package/dist/dbTunnel-CLsqWr7o.mjs +153 -0
  105. package/dist/dbTunnel-CLsqWr7o.mjs.map +1 -0
  106. package/dist/dbTunnel-DQcdaaLi.cjs +153 -0
  107. package/dist/dbTunnel-DQcdaaLi.cjs.map +1 -0
  108. package/dist/define-BfrNaY82.mjs +106 -0
  109. package/dist/define-BfrNaY82.mjs.map +1 -0
  110. package/dist/define-zKgLY65H.cjs +153 -0
  111. package/dist/define-zKgLY65H.cjs.map +1 -0
  112. package/dist/deploy/public.cjs +210 -0
  113. package/dist/deploy/public.cjs.map +1 -0
  114. package/dist/deploy/public.d.cts +659 -0
  115. package/dist/deploy/public.d.cts.map +1 -0
  116. package/dist/deploy/public.d.mts +659 -0
  117. package/dist/deploy/public.d.mts.map +1 -0
  118. package/dist/deploy/public.mjs +143 -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 +1 -1
  132. package/dist/deploy-DhIy2Ftj.mjs +3854 -0
  133. package/dist/deploy-DhIy2Ftj.mjs.map +1 -0
  134. package/dist/deploy-DpQ_4Pu1.cjs +3910 -0
  135. package/dist/deploy-DpQ_4Pu1.cjs.map +1 -0
  136. package/dist/destroy-DmTDT6V7.cjs +791 -0
  137. package/dist/destroy-DmTDT6V7.cjs.map +1 -0
  138. package/dist/destroy-wV9yNLQV.mjs +790 -0
  139. package/dist/destroy-wV9yNLQV.mjs.map +1 -0
  140. package/dist/discover-Dfmn6HQ7.mjs +940 -0
  141. package/dist/discover-Dfmn6HQ7.mjs.map +1 -0
  142. package/dist/discover-OXczlq08.cjs +1085 -0
  143. package/dist/discover-OXczlq08.cjs.map +1 -0
  144. package/dist/dokploy-B61ww4Yb.cjs +38 -0
  145. package/dist/dokploy-B61ww4Yb.cjs.map +1 -0
  146. package/dist/dokploy-Jhl3sPd4.mjs +38 -0
  147. package/dist/dokploy-Jhl3sPd4.mjs.map +1 -0
  148. package/dist/drivers-BQRb3KsL.mjs +294 -0
  149. package/dist/drivers-BQRb3KsL.mjs.map +1 -0
  150. package/dist/drivers-DP7__dJX.cjs +377 -0
  151. package/dist/drivers-DP7__dJX.cjs.map +1 -0
  152. package/dist/eas-BmvO40xS.mjs +334 -0
  153. package/dist/eas-BmvO40xS.mjs.map +1 -0
  154. package/dist/eas-X09Gz8_E.cjs +337 -0
  155. package/dist/eas-X09Gz8_E.cjs.map +1 -0
  156. package/dist/emit-C4KSXOeS.mjs +153 -0
  157. package/dist/emit-C4KSXOeS.mjs.map +1 -0
  158. package/dist/emit-DiW0kbue.cjs +164 -0
  159. package/dist/emit-DiW0kbue.cjs.map +1 -0
  160. package/dist/encryption-BBIUewnL.cjs +90 -0
  161. package/dist/encryption-BBIUewnL.cjs.map +1 -0
  162. package/dist/encryption-BOmswIgE.mjs +89 -0
  163. package/dist/encryption-BOmswIgE.mjs.map +1 -0
  164. package/dist/engine-BhjhShKf.cjs +3333 -0
  165. package/dist/engine-BhjhShKf.cjs.map +1 -0
  166. package/dist/engine-DW2H3KNa.mjs +3220 -0
  167. package/dist/engine-DW2H3KNa.mjs.map +1 -0
  168. package/dist/errors-C9uIyIDt.mjs +27 -0
  169. package/dist/errors-C9uIyIDt.mjs.map +1 -0
  170. package/dist/errors-D1x8duqI.cjs +38 -0
  171. package/dist/errors-D1x8duqI.cjs.map +1 -0
  172. package/dist/github-Ptbigbrq.mjs +986 -0
  173. package/dist/github-Ptbigbrq.mjs.map +1 -0
  174. package/dist/github-xUtu4Ur7.cjs +987 -0
  175. package/dist/github-xUtu4Ur7.cjs.map +1 -0
  176. package/dist/googlePlay-B4xhz5xT.cjs +931 -0
  177. package/dist/googlePlay-B4xhz5xT.cjs.map +1 -0
  178. package/dist/googlePlay-C9rrwN5b.mjs +931 -0
  179. package/dist/googlePlay-C9rrwN5b.mjs.map +1 -0
  180. package/dist/iam-D7mXd6by.cjs +521 -0
  181. package/dist/iam-D7mXd6by.cjs.map +1 -0
  182. package/dist/iam-DNlbVN_l.mjs +442 -0
  183. package/dist/iam-DNlbVN_l.mjs.map +1 -0
  184. package/dist/{index-RCUizGxL.d.cts → index-B1gfXH5K.d.mts} +38 -14
  185. package/dist/index-B1gfXH5K.d.mts.map +1 -0
  186. package/dist/{index-B4H4XF7A.d.mts → index-CunkOPOu.d.cts} +38 -14
  187. package/dist/index-CunkOPOu.d.cts.map +1 -0
  188. package/dist/index.cjs +15566 -13457
  189. package/dist/index.cjs.map +1 -1
  190. package/dist/index.mjs +15249 -13138
  191. package/dist/index.mjs.map +1 -1
  192. package/dist/local-CvC-z86k.mjs +224 -0
  193. package/dist/local-CvC-z86k.mjs.map +1 -0
  194. package/dist/local-DAJrhvSC.cjs +241 -0
  195. package/dist/local-DAJrhvSC.cjs.map +1 -0
  196. package/dist/migrate-0-A4BOcd.cjs +272 -0
  197. package/dist/migrate-0-A4BOcd.cjs.map +1 -0
  198. package/dist/migrate-C_36JSwV.mjs +181 -0
  199. package/dist/migrate-C_36JSwV.mjs.map +1 -0
  200. package/dist/migrate-DHbXzZIJ.mjs +267 -0
  201. package/dist/migrate-DHbXzZIJ.mjs.map +1 -0
  202. package/dist/migrate-fGWfv2DV.cjs +181 -0
  203. package/dist/migrate-fGWfv2DV.cjs.map +1 -0
  204. package/dist/next.cjs +59 -0
  205. package/dist/next.cjs.map +1 -0
  206. package/dist/next.d.cts +44 -0
  207. package/dist/next.d.cts.map +1 -0
  208. package/dist/next.d.mts +44 -0
  209. package/dist/next.d.mts.map +1 -0
  210. package/dist/next.mjs +58 -0
  211. package/dist/next.mjs.map +1 -0
  212. package/dist/openapi.cjs +213 -7
  213. package/dist/openapi.cjs.map +1 -0
  214. package/dist/openapi.d.cts +27 -8
  215. package/dist/openapi.d.cts.map +1 -1
  216. package/dist/openapi.d.mts +27 -8
  217. package/dist/openapi.d.mts.map +1 -1
  218. package/dist/openapi.mjs +208 -2
  219. package/dist/openapi.mjs.map +1 -0
  220. package/dist/projectBucket-BAoFOQtA.cjs +263 -0
  221. package/dist/projectBucket-BAoFOQtA.cjs.map +1 -0
  222. package/dist/projectBucket-Dxub09V1.mjs +222 -0
  223. package/dist/projectBucket-Dxub09V1.mjs.map +1 -0
  224. package/dist/provider-BvjDbsTR.mjs +46 -0
  225. package/dist/provider-BvjDbsTR.mjs.map +1 -0
  226. package/dist/provider-DLhgo-mB.cjs +57 -0
  227. package/dist/provider-DLhgo-mB.cjs.map +1 -0
  228. package/dist/publish-BX8_zXaf.cjs +124 -0
  229. package/dist/publish-BX8_zXaf.cjs.map +1 -0
  230. package/dist/publish-DE_yBzlz.mjs +123 -0
  231. package/dist/publish-DE_yBzlz.mjs.map +1 -0
  232. package/dist/ready-DCvnFZnJ.cjs +404 -0
  233. package/dist/ready-DCvnFZnJ.cjs.map +1 -0
  234. package/dist/ready-sSPuiZ7N.mjs +375 -0
  235. package/dist/ready-sSPuiZ7N.mjs.map +1 -0
  236. package/dist/reconcile/public.cjs +3 -5
  237. package/dist/reconcile/public.d.cts +33 -89
  238. package/dist/reconcile/public.d.cts.map +1 -1
  239. package/dist/reconcile/public.d.mts +33 -89
  240. package/dist/reconcile/public.d.mts.map +1 -1
  241. package/dist/reconcile/public.mjs +3 -3
  242. package/dist/reconcile--I7V4Klj.mjs +34 -0
  243. package/dist/reconcile--I7V4Klj.mjs.map +1 -0
  244. package/dist/reconcile-CuCQBa5-.cjs +34 -0
  245. package/dist/reconcile-CuCQBa5-.cjs.map +1 -0
  246. package/dist/resolve-CPB2jkB4.cjs +316 -0
  247. package/dist/resolve-CPB2jkB4.cjs.map +1 -0
  248. package/dist/resolve-DCPtP7-X.mjs +263 -0
  249. package/dist/resolve-DCPtP7-X.mjs.map +1 -0
  250. package/dist/rollback-sefKrjlE.mjs +137 -0
  251. package/dist/rollback-sefKrjlE.mjs.map +1 -0
  252. package/dist/rollback-ygh2qRWo.cjs +166 -0
  253. package/dist/rollback-ygh2qRWo.cjs.map +1 -0
  254. package/dist/runtime-BwiWhqkI.d.cts +82 -0
  255. package/dist/runtime-BwiWhqkI.d.cts.map +1 -0
  256. package/dist/runtime-Dx5F8-IL.d.mts +82 -0
  257. package/dist/runtime-Dx5F8-IL.d.mts.map +1 -0
  258. package/dist/s3-Bcvbg8io.cjs +240 -0
  259. package/dist/s3-Bcvbg8io.cjs.map +1 -0
  260. package/dist/s3-DK1ofU4f.mjs +240 -0
  261. package/dist/s3-DK1ofU4f.mjs.map +1 -0
  262. package/dist/sandbox/config-worker.cjs +43 -0
  263. package/dist/sandbox/config-worker.cjs.map +1 -0
  264. package/dist/sandbox/config-worker.d.cts +1 -0
  265. package/dist/sandbox/config-worker.d.mts +1 -0
  266. package/dist/sandbox/config-worker.mjs +44 -0
  267. package/dist/sandbox/config-worker.mjs.map +1 -0
  268. package/dist/sandbox/credentials-worker.cjs +53 -0
  269. package/dist/sandbox/credentials-worker.cjs.map +1 -0
  270. package/dist/sandbox/credentials-worker.d.cts +1 -0
  271. package/dist/sandbox/credentials-worker.d.mts +1 -0
  272. package/dist/sandbox/credentials-worker.mjs +54 -0
  273. package/dist/sandbox/credentials-worker.mjs.map +1 -0
  274. package/dist/sandbox/discover-worker.cjs +47 -0
  275. package/dist/sandbox/discover-worker.cjs.map +1 -0
  276. package/dist/sandbox/discover-worker.d.cts +1 -0
  277. package/dist/sandbox/discover-worker.d.mts +1 -0
  278. package/dist/sandbox/discover-worker.mjs +48 -0
  279. package/dist/sandbox/discover-worker.mjs.map +1 -0
  280. package/dist/sandbox/migrate-worker.cjs +75 -0
  281. package/dist/sandbox/migrate-worker.cjs.map +1 -0
  282. package/dist/sandbox/migrate-worker.d.cts +1 -0
  283. package/dist/sandbox/migrate-worker.d.mts +1 -0
  284. package/dist/sandbox/migrate-worker.mjs +76 -0
  285. package/dist/sandbox/migrate-worker.mjs.map +1 -0
  286. package/dist/{workspace-CRD9YinV.cjs → schemas-BCwKKA42.mjs} +399 -1179
  287. package/dist/schemas-BCwKKA42.mjs.map +1 -0
  288. package/dist/{workspace-Bu3xNCej.mjs → schemas-BQ_v0lEX.cjs} +487 -982
  289. package/dist/schemas-BQ_v0lEX.cjs.map +1 -0
  290. package/dist/secretsManager-CjTo6CRq.mjs +113 -0
  291. package/dist/secretsManager-CjTo6CRq.mjs.map +1 -0
  292. package/dist/secretsManager-CvmBGjdM.cjs +124 -0
  293. package/dist/secretsManager-CvmBGjdM.cjs.map +1 -0
  294. package/dist/seeds-Bc3niNVb.cjs +382 -0
  295. package/dist/seeds-Bc3niNVb.cjs.map +1 -0
  296. package/dist/seeds-Ccn0Ru2T.mjs +299 -0
  297. package/dist/seeds-Ccn0Ru2T.mjs.map +1 -0
  298. package/dist/serverSetup-ClU2iSeU.cjs +686 -0
  299. package/dist/serverSetup-ClU2iSeU.cjs.map +1 -0
  300. package/dist/serverSetup-D68Otrp0.mjs +686 -0
  301. package/dist/serverSetup-D68Otrp0.mjs.map +1 -0
  302. package/dist/sniffer-CFOmQQit.cjs +1997 -0
  303. package/dist/sniffer-CFOmQQit.cjs.map +1 -0
  304. package/dist/sniffer-CRF3eD_B.mjs +1824 -0
  305. package/dist/sniffer-CRF3eD_B.mjs.map +1 -0
  306. package/dist/snsSubscriptions-CwA6Ceg2.mjs +1024 -0
  307. package/dist/snsSubscriptions-CwA6Ceg2.mjs.map +1 -0
  308. package/dist/snsSubscriptions-S_CMCXqI.cjs +1149 -0
  309. package/dist/snsSubscriptions-S_CMCXqI.cjs.map +1 -0
  310. package/dist/sst-BgG7dJJu.cjs +514 -0
  311. package/dist/sst-BgG7dJJu.cjs.map +1 -0
  312. package/dist/sst-CDnHFO3U.mjs +491 -0
  313. package/dist/sst-CDnHFO3U.mjs.map +1 -0
  314. package/dist/stack-BXmLQf3K.mjs +10920 -0
  315. package/dist/stack-BXmLQf3K.mjs.map +1 -0
  316. package/dist/stack-BtnflNSa.cjs +11901 -0
  317. package/dist/stack-BtnflNSa.cjs.map +1 -0
  318. package/dist/stage-BbQidxxa.mjs +302 -0
  319. package/dist/stage-BbQidxxa.mjs.map +1 -0
  320. package/dist/stage-ssuPXLhP.cjs +331 -0
  321. package/dist/stage-ssuPXLhP.cjs.map +1 -0
  322. package/dist/stages-CQwD2QxS.cjs +190 -0
  323. package/dist/stages-CQwD2QxS.cjs.map +1 -0
  324. package/dist/stages-MA2sXnX4.mjs +190 -0
  325. package/dist/stages-MA2sXnX4.mjs.map +1 -0
  326. package/dist/target/public.cjs +15 -0
  327. package/dist/target/public.d.cts +28 -0
  328. package/dist/target/public.d.cts.map +1 -0
  329. package/dist/target/public.d.mts +28 -0
  330. package/dist/target/public.d.mts.map +1 -0
  331. package/dist/target/public.mjs +4 -0
  332. package/dist/terminal-BEGE1AEV.mjs +85 -0
  333. package/dist/terminal-BEGE1AEV.mjs.map +1 -0
  334. package/dist/terminal-BecJpgA3.cjs +85 -0
  335. package/dist/terminal-BecJpgA3.cjs.map +1 -0
  336. package/dist/{types-7R81hu0i.d.mts → types-BvokH0ya.d.cts} +2235 -459
  337. package/dist/types-BvokH0ya.d.cts.map +1 -0
  338. package/dist/{types-N7c2O2m7.d.cts → types-DmLnGeii.d.mts} +2233 -459
  339. package/dist/types-DmLnGeii.d.mts.map +1 -0
  340. package/dist/utils-CdKxD8Lt.mjs +156 -0
  341. package/dist/utils-CdKxD8Lt.mjs.map +1 -0
  342. package/dist/utils-DBqXbB8P.cjs +205 -0
  343. package/dist/utils-DBqXbB8P.cjs.map +1 -0
  344. package/dist/vitest.cjs +65 -0
  345. package/dist/vitest.cjs.map +1 -0
  346. package/dist/vitest.d.cts +29 -0
  347. package/dist/vitest.d.cts.map +1 -0
  348. package/dist/vitest.d.mts +29 -0
  349. package/dist/vitest.d.mts.map +1 -0
  350. package/dist/vitest.mjs +65 -0
  351. package/dist/vitest.mjs.map +1 -0
  352. package/dist/workerRuntime-BXfhbe13.cjs +108 -0
  353. package/dist/workerRuntime-BXfhbe13.cjs.map +1 -0
  354. package/dist/workerRuntime-CsOyBRx2.mjs +79 -0
  355. package/dist/workerRuntime-CsOyBRx2.mjs.map +1 -0
  356. package/dist/workspace/index.cjs +6 -2
  357. package/dist/workspace/index.d.cts +3 -3
  358. package/dist/workspace/index.d.mts +3 -3
  359. package/dist/workspace/index.mjs +2 -2
  360. package/dist/workspace-DEmfa9RO.cjs +3689 -0
  361. package/dist/workspace-DEmfa9RO.cjs.map +1 -0
  362. package/dist/workspace-RgU7TBgg.mjs +3133 -0
  363. package/dist/workspace-RgU7TBgg.mjs.map +1 -0
  364. package/package.json +76 -13
  365. package/dist/HostingerProvider-BY26bWwB.mjs +0 -243
  366. package/dist/HostingerProvider-BY26bWwB.mjs.map +0 -1
  367. package/dist/HostingerProvider-BZFGYYVA.cjs +0 -243
  368. package/dist/HostingerProvider-BZFGYYVA.cjs.map +0 -1
  369. package/dist/LocalStateProvider-7HR6SS2t.cjs +0 -48
  370. package/dist/LocalStateProvider-7HR6SS2t.cjs.map +0 -1
  371. package/dist/LocalStateProvider-D7QyJoLM.mjs +0 -48
  372. package/dist/LocalStateProvider-D7QyJoLM.mjs.map +0 -1
  373. package/dist/Route53Provider-Cvj40A8I.mjs +0 -209
  374. package/dist/Route53Provider-Cvj40A8I.mjs.map +0 -1
  375. package/dist/Route53Provider-DVILBsvV.cjs +0 -209
  376. package/dist/Route53Provider-DVILBsvV.cjs.map +0 -1
  377. package/dist/SSMStateProvider-B0Hu1MKZ.mjs +0 -75
  378. package/dist/SSMStateProvider-B0Hu1MKZ.mjs.map +0 -1
  379. package/dist/SSMStateProvider-VrQ-yeqd.cjs +0 -74
  380. package/dist/SSMStateProvider-VrQ-yeqd.cjs.map +0 -1
  381. package/dist/backup-provisioner-BmhIO_Yr.cjs.map +0 -1
  382. package/dist/backup-provisioner-DIVCbfee.mjs.map +0 -1
  383. package/dist/bundler-mjqGAvu1.cjs.map +0 -1
  384. package/dist/bundler-mwH7WOb1.mjs.map +0 -1
  385. package/dist/config-DSXI480r.cjs +0 -467
  386. package/dist/config-DSXI480r.cjs.map +0 -1
  387. package/dist/config-DdKkoUE1.mjs +0 -414
  388. package/dist/config-DdKkoUE1.mjs.map +0 -1
  389. package/dist/config.d.cts.map +0 -1
  390. package/dist/config.d.mts.map +0 -1
  391. package/dist/credentials-C6Pfn6GY.cjs +0 -2939
  392. package/dist/credentials-C6Pfn6GY.cjs.map +0 -1
  393. package/dist/credentials-lbv-j0Be.mjs +0 -2802
  394. package/dist/credentials-lbv-j0Be.mjs.map +0 -1
  395. package/dist/discover-BERGFg8v.cjs +0 -288
  396. package/dist/discover-BERGFg8v.cjs.map +0 -1
  397. package/dist/discover-CK-n3w6b.mjs +0 -244
  398. package/dist/discover-CK-n3w6b.mjs.map +0 -1
  399. package/dist/emit-BdoPFjZf.cjs +0 -253
  400. package/dist/emit-BdoPFjZf.cjs.map +0 -1
  401. package/dist/emit-Bzq7JsMP.mjs +0 -224
  402. package/dist/emit-Bzq7JsMP.mjs.map +0 -1
  403. package/dist/generator-LfZU7NlU.mjs +0 -247
  404. package/dist/generator-LfZU7NlU.mjs.map +0 -1
  405. package/dist/generator-Wdfp0jCS.cjs +0 -282
  406. package/dist/generator-Wdfp0jCS.cjs.map +0 -1
  407. package/dist/github-BvfpvBcW.cjs +0 -216
  408. package/dist/github-BvfpvBcW.cjs.map +0 -1
  409. package/dist/github-DW3CP-4D.mjs +0 -216
  410. package/dist/github-DW3CP-4D.mjs.map +0 -1
  411. package/dist/index-B4H4XF7A.d.mts.map +0 -1
  412. package/dist/index-RCUizGxL.d.cts.map +0 -1
  413. package/dist/openapi-B8bu_OXN.cjs +0 -2038
  414. package/dist/openapi-B8bu_OXN.cjs.map +0 -1
  415. package/dist/openapi-DfjbhrsM.mjs +0 -1991
  416. package/dist/openapi-DfjbhrsM.mjs.map +0 -1
  417. package/dist/reconcile-gb1lz1Dk.mjs +0 -113
  418. package/dist/reconcile-gb1lz1Dk.mjs.map +0 -1
  419. package/dist/reconcile-hx_vBvux.cjs +0 -136
  420. package/dist/reconcile-hx_vBvux.cjs.map +0 -1
  421. package/dist/ssm-BKN1Cg4z.mjs +0 -60
  422. package/dist/ssm-BKN1Cg4z.mjs.map +0 -1
  423. package/dist/ssm-FxeSAt35.cjs +0 -60
  424. package/dist/ssm-FxeSAt35.cjs.map +0 -1
  425. package/dist/storage-DgypfSD6.cjs +0 -351
  426. package/dist/storage-DgypfSD6.cjs.map +0 -1
  427. package/dist/storage-TP0x118M.mjs +0 -304
  428. package/dist/storage-TP0x118M.mjs.map +0 -1
  429. package/dist/transfer-DjFZRgub.mjs +0 -122
  430. package/dist/transfer-DjFZRgub.mjs.map +0 -1
  431. package/dist/transfer-SeiSeKEF.cjs +0 -151
  432. package/dist/transfer-SeiSeKEF.cjs.map +0 -1
  433. package/dist/types-7R81hu0i.d.mts.map +0 -1
  434. package/dist/types-N7c2O2m7.d.cts.map +0 -1
  435. package/dist/workspace-Bu3xNCej.mjs.map +0 -1
  436. package/dist/workspace-CRD9YinV.cjs.map +0 -1
@@ -0,0 +1,1997 @@
1
+ const require_rolldown_runtime = require("./rolldown-runtime-C0BPl7ul.cjs");
2
+ const require_errors = require("./errors-D1x8duqI.cjs");
3
+ const require_workspace = require("./workspace-DEmfa9RO.cjs");
4
+ const require_discover = require("./discover-OXczlq08.cjs");
5
+ const require_local = require("./local-DAJrhvSC.cjs");
6
+ const require_seeds = require("./seeds-Bc3niNVb.cjs");
7
+ let node_path = require("node:path");
8
+ let node_fs = require("node:fs");
9
+ let node_os = require("node:os");
10
+ let node_crypto = require("node:crypto");
11
+ let node_url = require("node:url");
12
+ let node_zlib = require("node:zlib");
13
+ //#region src/secrets/encryption.ts
14
+ var encryption_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({
15
+ encryptSecrets: () => encryptSecrets,
16
+ generateDefineOptions: () => generateDefineOptions,
17
+ keyFingerprint: () => keyFingerprint
18
+ });
19
+ /** AES-256-GCM configuration */
20
+ const ALGORITHM = "aes-256-gcm";
21
+ const KEY_LENGTH = 32;
22
+ const IV_LENGTH = 12;
23
+ /**
24
+ * Encrypt secrets for embedding in a bundle.
25
+ * Uses AES-256-GCM with a randomly generated ephemeral key.
26
+ *
27
+ * @param secrets - Key-value pairs to encrypt
28
+ * @returns Encrypted payload with ephemeral master key
29
+ */
30
+ function encryptSecrets(secrets) {
31
+ const masterKey = (0, node_crypto.randomBytes)(KEY_LENGTH);
32
+ const iv = (0, node_crypto.randomBytes)(IV_LENGTH);
33
+ const plaintext = JSON.stringify(secrets);
34
+ const cipher = (0, node_crypto.createCipheriv)(ALGORITHM, masterKey, iv);
35
+ const ciphertext = Buffer.concat([cipher.update(plaintext, "utf-8"), cipher.final()]);
36
+ const authTag = cipher.getAuthTag();
37
+ return {
38
+ encrypted: Buffer.concat([ciphertext, authTag]).toString("base64"),
39
+ iv: iv.toString("hex"),
40
+ masterKey: masterKey.toString("hex")
41
+ };
42
+ }
43
+ /**
44
+ * Generate the define options for tsdown/esbuild.
45
+ * These will be injected at build time.
46
+ */
47
+ function generateDefineOptions(payload) {
48
+ return {
49
+ __GKM_ENCRYPTED_CREDENTIALS__: JSON.stringify(payload.encrypted),
50
+ __GKM_CREDENTIALS_IV__: JSON.stringify(payload.iv)
51
+ };
52
+ }
53
+ /**
54
+ * A short, one-way name for a master key: the first 8 hex characters of its
55
+ * SHA-256.
56
+ *
57
+ * Printed where the key itself used to be, so a person can tell which key a
58
+ * build used — and match it against the one they hold — without the output
59
+ * carrying a value that decrypts every secret of the stage.
60
+ */
61
+ function keyFingerprint(masterKey) {
62
+ return (0, node_crypto.createHash)("sha256").update(masterKey).digest("hex").slice(0, 8);
63
+ }
64
+ //#endregion
65
+ //#region src/deploy/events.ts
66
+ /** An error as an event carries it: its name and message, nothing else. */
67
+ function eventError(error) {
68
+ if (error instanceof Error) return {
69
+ name: error.name,
70
+ message: error.message
71
+ };
72
+ return {
73
+ name: "Error",
74
+ message: String(error)
75
+ };
76
+ }
77
+ //#endregion
78
+ //#region src/deploy/StateProvider.ts
79
+ /**
80
+ * Check if value is a StateProvider implementation.
81
+ */
82
+ function isStateProvider(value) {
83
+ return typeof value === "object" && value !== null && typeof value.read === "function" && typeof value.write === "function";
84
+ }
85
+ var StateLocked = class extends require_errors.GkmError {
86
+ stage;
87
+ holder;
88
+ location;
89
+ constructor(stage, holder, location) {
90
+ const by = holder ? `${holder.owner}@${holder.host} (pid ${holder.pid}) since ${holder.acquiredAt}${holder.operation ? ` for '${holder.operation}'` : ""}` : "a run that did not record who it was";
91
+ super(`Deploy state for stage '${stage}' is locked by ${by} (${location}). Wait for that run to finish; if it crashed, release the lock with \`gkm state:unlock --stage ${stage}\`.`);
92
+ this.stage = stage;
93
+ this.holder = holder;
94
+ this.location = location;
95
+ this.name = "StateLocked";
96
+ }
97
+ };
98
+ var StateVersionConflict = class extends require_errors.GkmError {
99
+ stage;
100
+ expectedVersion;
101
+ actualVersion;
102
+ constructor(stage, expectedVersion, actualVersion) {
103
+ super(`Deploy state for stage '${stage}' changed since it was read (expected ${expectedVersion ? `version ${expectedVersion}` : "no state"}, found ${actualVersion ? `version ${actualVersion}` : "no state"}). Another run wrote it: read the state again and re-apply the change, and hold the stage's lock so runs take turns.`);
104
+ this.stage = stage;
105
+ this.expectedVersion = expectedVersion;
106
+ this.actualVersion = actualVersion;
107
+ this.name = "StateVersionConflict";
108
+ }
109
+ };
110
+ var StageStateMissing = class extends require_errors.GkmError {
111
+ stage;
112
+ constructor(stage) {
113
+ super(`There is no deploy state for stage '${stage}' to record a resource in. Write the stage's state first (write with expectedVersion: null).`);
114
+ this.stage = stage;
115
+ this.name = "StageStateMissing";
116
+ }
117
+ };
118
+ var StateUnreadable = class extends require_errors.GkmError {
119
+ stage;
120
+ location;
121
+ constructor(stage, location, cause) {
122
+ super(`Deploy state for stage '${stage}' at ${location} is not valid JSON. Restore it from a backup (or the provider's history) rather than deploying without it — a deploy without state recreates every resource.`, { cause });
123
+ this.stage = stage;
124
+ this.location = location;
125
+ this.name = "StateUnreadable";
126
+ }
127
+ };
128
+ var StateSchemaTooNew = class extends require_errors.GkmError {
129
+ stage;
130
+ schemaVersion;
131
+ constructor(stage, schemaVersion) {
132
+ super(`Deploy state for stage '${stage}' has schema version ${String(schemaVersion)}, newer than this @geekmidas/cli understands (3). Upgrade @geekmidas/cli to the version that wrote it.`);
133
+ this.stage = stage;
134
+ this.schemaVersion = schemaVersion;
135
+ this.name = "StateSchemaTooNew";
136
+ }
137
+ };
138
+ /**
139
+ * Not thrown: emitted (once per store) when a custom `StateProvider` stands
140
+ * in for a store, so a deploy that cannot be protected from a concurrent one
141
+ * says so.
142
+ */
143
+ var StateStoreWithoutLocking = class extends require_errors.GkmError {
144
+ provider;
145
+ constructor(provider) {
146
+ super(`The custom state provider '${provider}' has no lock and no versions, so two deploys of the same stage can still overwrite each other. Implement StateStore (lock, versioned read, conditional write) or use the 'local', 'ssm' or 's3' state provider.`);
147
+ this.provider = provider;
148
+ this.name = "StateStoreWithoutLocking";
149
+ }
150
+ };
151
+ var StateStoreNeedsWorkspaceName = class extends require_errors.GkmError {
152
+ provider;
153
+ constructor(provider) {
154
+ super(`The '${provider}' state provider keys state by workspace name. Set "name" in gkm.config.ts.`);
155
+ this.provider = provider;
156
+ this.name = "StateStoreNeedsWorkspaceName";
157
+ }
158
+ };
159
+ var UnknownStateProvider = class extends require_errors.GkmError {
160
+ config;
161
+ constructor(config) {
162
+ super(`Unknown state provider ${JSON.stringify(config)}. Use 'local', 'ssm', 's3', or an object implementing StateStore or StateProvider.`);
163
+ this.config = config;
164
+ this.name = "UnknownStateProvider";
165
+ }
166
+ };
167
+ /**
168
+ * A deploy, setup or rollback of a stage in CI, with the stage's state kept on
169
+ * the runner — which is discarded when the job ends.
170
+ */
171
+ var LocalStateInCi = class extends require_errors.GkmError {
172
+ stage;
173
+ operation;
174
+ region;
175
+ constructor(stage, operation, region) {
176
+ super(`\`gkm ${operation}\` would keep stage '${stage}'s deploy state in .gkm/ on this CI runner, and the runner is discarded when the job ends: the next run would start without it — no releases to roll back to, no record of what was created. Keep the state in S3, in a bucket gkm creates for the project — in gkm.config.ts:\n\n state: { provider: 's3', region: '${region}' },\n\nthen move the state you already have, from the machine that holds it:\n\n gkm state:push --stage ${stage}\n`);
177
+ this.stage = stage;
178
+ this.operation = operation;
179
+ this.region = region;
180
+ this.name = "LocalStateInCi";
181
+ }
182
+ };
183
+ /**
184
+ * What a run adds to a document, at most, as the store writes it: a release
185
+ * per app and a history entry — the release and run history are capped, so
186
+ * a stage's document stops growing once they are full.
187
+ */
188
+ const STATE_HEADROOM_BYTES = 1024;
189
+ /** The switch to S3, as the messages below spell it out. */
190
+ function moveToS3(stage, region) {
191
+ return `Keep the state in S3 instead — in gkm.config.ts:\n\n state: { provider: 's3', region: '${region}' },\n\nwhich keeps it in a bucket gkm creates for the project. Move the state there: \`gkm state:pull --stage ${stage}\` with the ssm config, then switch the config and \`gkm state:push --stage ${stage}\`.`;
192
+ }
193
+ /**
194
+ * Before a deploy changes anything: the stage's state, with room for what
195
+ * this run adds, would not fit in its SSM parameter.
196
+ */
197
+ var StateTooLargeForSsm = class extends require_errors.GkmError {
198
+ stage;
199
+ bytes;
200
+ limit;
201
+ location;
202
+ region;
203
+ constructor(stage, bytes, limit, location, region) {
204
+ super(`Deploy state for stage '${stage}' is ${bytes} bytes compressed (${location}), and with room for this deploy (${STATE_HEADROOM_BYTES} bytes) it would pass SSM's limit of ${limit}. Nothing was deployed. ` + moveToS3(stage, region));
205
+ this.stage = stage;
206
+ this.bytes = bytes;
207
+ this.limit = limit;
208
+ this.location = location;
209
+ this.region = region;
210
+ this.name = "StateTooLargeForSsm";
211
+ }
212
+ };
213
+ /** SSM refused a write of the stage's state — past its size limit, usually. */
214
+ var StateRejectedBySsm = class extends require_errors.GkmError {
215
+ stage;
216
+ bytes;
217
+ location;
218
+ region;
219
+ constructor(stage, bytes, location, region, cause) {
220
+ super(`SSM refused to save the deploy state for stage '${stage}' (${bytes} bytes, ${location}): ${cause instanceof Error ? cause.message : String(cause)} If a deploy was running, what it released is running now — only the record of it is missing, and the state holds what the last saved write left. ${moveToS3(stage, region)} Then deploy again to record the release, or push a good copy with \`gkm state:push\`.`, { cause });
221
+ this.stage = stage;
222
+ this.bytes = bytes;
223
+ this.location = location;
224
+ this.region = region;
225
+ this.name = "StateRejectedBySsm";
226
+ }
227
+ };
228
+ /** A lock or write that could not get at the state backend in time. */
229
+ var StateStoreBusy = class extends require_errors.GkmError {
230
+ stage;
231
+ location;
232
+ constructor(stage, location) {
233
+ super(`Timed out waiting to write deploy state for stage '${stage}' (${location}). If no other gkm process is running, remove ${location}.`);
234
+ this.stage = stage;
235
+ this.location = location;
236
+ this.name = "StateStoreBusy";
237
+ }
238
+ };
239
+ /** `body` as `gz:` and its gzip in base64. */
240
+ function compressBody(body) {
241
+ return "gz:" + (0, node_zlib.gzipSync)(body).toString("base64");
242
+ }
243
+ /** A stored body as the JSON it holds: compressed or not. */
244
+ function decompressBody(body) {
245
+ if (!body.startsWith("gz:")) return body;
246
+ return (0, node_zlib.gunzipSync)(Buffer.from(body.slice(3), "base64")).toString("utf-8");
247
+ }
248
+ function decodeDocument(stage, body, location) {
249
+ let parsed;
250
+ try {
251
+ parsed = JSON.parse(decompressBody(body));
252
+ } catch (error) {
253
+ throw new StateUnreadable(stage, location, error);
254
+ }
255
+ if (typeof parsed !== "object" || parsed === null) throw new StateUnreadable(stage, location, parsed);
256
+ const schemaVersion = parsed.schemaVersion;
257
+ if (schemaVersion === void 0) return {
258
+ schemaVersion: 1,
259
+ state: parsed
260
+ };
261
+ if (schemaVersion === 2) return {
262
+ schemaVersion: 2,
263
+ document: parsed
264
+ };
265
+ if (schemaVersion === 3) return {
266
+ schemaVersion: 3,
267
+ document: parsed
268
+ };
269
+ throw new StateSchemaTooNew(stage, schemaVersion);
270
+ }
271
+ function encodeDocument(document) {
272
+ return JSON.stringify(document, null, 2);
273
+ }
274
+ /**
275
+ * v1 state as a v2 document. The ids v1 kept are seeded as `ready` records,
276
+ * so the first journaled deploy after an upgrade adopts them rather than
277
+ * treating them as unknown.
278
+ */
279
+ function migrateV1(stage, state) {
280
+ const now = (/* @__PURE__ */ new Date()).toISOString();
281
+ const resources = {};
282
+ const seed = (type, name, id) => {
283
+ if (!id) return;
284
+ const key = name ? `${type}:${name}` : type;
285
+ resources[key] = {
286
+ key,
287
+ type,
288
+ id,
289
+ status: "ready",
290
+ updatedAt: now
291
+ };
292
+ };
293
+ seed("project", null, state.projectId);
294
+ seed("environment", null, state.environmentId);
295
+ for (const [app, id] of Object.entries(state.applications ?? {})) seed("application", app, id);
296
+ seed("postgres", null, state.services?.postgresId);
297
+ seed("redis", null, state.services?.redisId);
298
+ seed("backup-destination", null, state.backups?.destinationId);
299
+ return {
300
+ schemaVersion: 2,
301
+ stage,
302
+ serial: 1,
303
+ state,
304
+ resources,
305
+ updatedAt: now
306
+ };
307
+ }
308
+ const isEmpty = (value) => !value || Object.keys(value).length === 0;
309
+ /**
310
+ * Whether a v2 state in the Dokploy shape was written by the compose target.
311
+ *
312
+ * Before v3 every target wrote the Dokploy shape, and compose filled none of
313
+ * its Dokploy fields. So the rule is the shape's content, not the target the
314
+ * workspace names now: a state whose every Dokploy-only field is empty — no
315
+ * project or environment id, no application or service ids, no credentials,
316
+ * generated secrets, backups or registry — holds nothing only Dokploy could
317
+ * use, and reading it as compose loses nothing. One with any of them was
318
+ * written by Dokploy and is kept exactly as it is.
319
+ *
320
+ * The configured target is not used: a document decodes the same wherever it
321
+ * is read (`state:show`, `state:push`) without a workspace, a stage can be
322
+ * moved between targets, and `--target` can override a run.
323
+ */
324
+ function writtenByCompose(state) {
325
+ return !state.projectId && !state.environmentId && isEmpty(state.applications) && !state.services?.postgresId && !state.services?.redisId && isEmpty(state.appCredentials) && isEmpty(state.generatedSecrets) && !state.backups && !state.registryId;
326
+ }
327
+ /**
328
+ * A v2 state and its records as v3 keeps them. A compose-written state
329
+ * becomes the compose shape: its `dnsRecords` become `dns-record` resources,
330
+ * and `dnsVerified` and the empty Dokploy fields go — the DNS check is made
331
+ * on every deploy. A Dokploy state is returned as it is.
332
+ */
333
+ function upgradeV2State(state, resources) {
334
+ if (!writtenByCompose(state)) return {
335
+ state,
336
+ resources
337
+ };
338
+ const compose = {
339
+ provider: "compose",
340
+ stage: state.stage,
341
+ lastDeployedAt: state.lastDeployedAt,
342
+ ...state.identity ? { identity: state.identity } : {},
343
+ ...state.releases ? { releases: state.releases } : {}
344
+ };
345
+ const upgraded = { ...resources };
346
+ for (const record of Object.values(state.dnsRecords ?? {})) {
347
+ const resource = migratedDnsResource(record);
348
+ upgraded[resource.key] = resource;
349
+ }
350
+ return {
351
+ state: compose,
352
+ resources: upgraded
353
+ };
354
+ }
355
+ /** A v2 `dnsRecords` entry as the `dns-record` resource v3 keeps. */
356
+ function migratedDnsResource(record) {
357
+ return {
358
+ ...require_seeds.dnsRecordResource({
359
+ domain: record.domain,
360
+ name: record.name,
361
+ type: record.type,
362
+ value: record.value,
363
+ ttl: record.ttl
364
+ }),
365
+ updatedAt: record.createdAt
366
+ };
367
+ }
368
+ /** A v2 document as v3 — not written until the next write. */
369
+ function migrateV2(document) {
370
+ const { state, resources } = upgradeV2State(document.state, document.resources);
371
+ return {
372
+ schemaVersion: 3,
373
+ stage: document.stage,
374
+ serial: document.serial,
375
+ state,
376
+ resources,
377
+ updatedAt: document.updatedAt,
378
+ history: []
379
+ };
380
+ }
381
+ function newLockHolder(options) {
382
+ let owner = "unknown";
383
+ try {
384
+ owner = (0, node_os.userInfo)().username;
385
+ } catch {}
386
+ return {
387
+ id: (0, node_crypto.randomUUID)(),
388
+ owner,
389
+ host: (0, node_os.hostname)(),
390
+ pid: process.pid,
391
+ acquiredAt: (/* @__PURE__ */ new Date()).toISOString(),
392
+ operation: options?.operation
393
+ };
394
+ }
395
+ function contentVersion(body) {
396
+ return (0, node_crypto.createHash)("sha256").update(body).digest("hex").slice(0, 16);
397
+ }
398
+ /**
399
+ * `history` with this write at its head. A run makes many writes — one per
400
+ * resource it journals — so a run is one entry: a write by the run that
401
+ * wrote the newest entry (the same lock) replaces it, and any other is
402
+ * added. Without a lock, each write is its own entry.
403
+ */
404
+ function appendHistory(history, entry, sameRun) {
405
+ return [entry, ...sameRun ? history.slice(1) : history].slice(0, 20);
406
+ }
407
+ /**
408
+ * A store over a backend that can read and conditionally write one blob per
409
+ * stage, and create a lock object only if it does not exist. Migration,
410
+ * resource records and history are the same for every such backend, so they
411
+ * live here.
412
+ */
413
+ var DocumentStateStore = class {
414
+ /** The lock this store holds for each stage — what its writes are for. */
415
+ held = /* @__PURE__ */ new Map();
416
+ /** Per stage, the lock whose run wrote the newest history entry. */
417
+ logged = /* @__PURE__ */ new Map();
418
+ /** Who this store writes as. */
419
+ actor() {
420
+ return require_seeds.currentActor();
421
+ }
422
+ async lock(stage, options) {
423
+ const holder = newLockHolder(options);
424
+ await this.createLock(stage, holder);
425
+ this.held.set(stage, holder);
426
+ let released = false;
427
+ return {
428
+ stage,
429
+ holder,
430
+ release: async () => {
431
+ if (released) return;
432
+ released = true;
433
+ if (this.held.get(stage)?.id === holder.id) this.held.delete(stage);
434
+ await this.removeLock(stage, holder);
435
+ }
436
+ };
437
+ }
438
+ async forceUnlock(stage) {
439
+ const holder = await this.readLock(stage);
440
+ await this.removeLock(stage, null);
441
+ return holder;
442
+ }
443
+ async read(stage) {
444
+ const current = await this.readDocument(stage);
445
+ if (!current) return null;
446
+ return {
447
+ state: current.document.state,
448
+ resources: current.document.resources,
449
+ history: current.document.history,
450
+ version: current.version
451
+ };
452
+ }
453
+ async write(stage, state, options) {
454
+ if (options.expectedVersion === null) {
455
+ const document = this.stamp(stage, {
456
+ schemaVersion: 3,
457
+ stage,
458
+ serial: 1,
459
+ state,
460
+ resources: {},
461
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
462
+ history: []
463
+ });
464
+ return this.writeRaw(stage, encodeDocument(document), null);
465
+ }
466
+ return this.mutate(stage, options.expectedVersion, (document) => ({
467
+ ...document,
468
+ state
469
+ }));
470
+ }
471
+ async putResource(stage, record, options) {
472
+ return this.mutate(stage, options?.expectedVersion, (document) => ({
473
+ ...document,
474
+ resources: {
475
+ ...document.resources,
476
+ [record.key]: {
477
+ ...record,
478
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
479
+ updatedBy: this.actor()
480
+ }
481
+ }
482
+ }));
483
+ }
484
+ async deleteResource(stage, key, options) {
485
+ return this.mutate(stage, options?.expectedVersion, (document) => {
486
+ const { [key]: _removed, ...resources } = document.resources;
487
+ return {
488
+ ...document,
489
+ resources
490
+ };
491
+ });
492
+ }
493
+ /** `document` as this write leaves it: who wrote it, in its history. */
494
+ stamp(stage, document) {
495
+ const by = this.actor();
496
+ const holder = this.held.get(stage);
497
+ const operation = holder?.operation ?? "write";
498
+ const history = document.history ?? [];
499
+ const sameRun = holder !== void 0 && this.logged.get(stage) === holder.id && history[0]?.operation === operation;
500
+ if (holder) this.logged.set(stage, holder.id);
501
+ return {
502
+ ...document,
503
+ updatedBy: by,
504
+ history: appendHistory(history, {
505
+ serial: document.serial,
506
+ at: document.updatedAt,
507
+ by,
508
+ operation
509
+ }, sameRun)
510
+ };
511
+ }
512
+ async mutate(stage, expectedVersion, change) {
513
+ const current = await this.readDocument(stage);
514
+ if (!current) {
515
+ if (expectedVersion !== void 0) throw new StateVersionConflict(stage, expectedVersion, null);
516
+ throw new StageStateMissing(stage);
517
+ }
518
+ if (expectedVersion !== void 0 && current.version !== expectedVersion) throw new StateVersionConflict(stage, expectedVersion, current.version);
519
+ const next = change(current.document);
520
+ next.schemaVersion = 3;
521
+ next.serial = current.document.serial + 1;
522
+ next.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
523
+ return this.writeRaw(stage, encodeDocument(this.stamp(stage, next)), current.version);
524
+ }
525
+ /**
526
+ * Reads the stage's document as v3. A v1 document is migrated in place on
527
+ * the way — itself a conditional write: if another run migrated (or wrote)
528
+ * first, its result is read instead. A v2 document is upgraded in memory
529
+ * and written as v3 by the next write.
530
+ */
531
+ async readDocument(stage, attempt = 0) {
532
+ const raw = await this.readRaw(stage);
533
+ if (!raw) return null;
534
+ const decoded = decodeDocument(stage, raw.body, this.location(stage));
535
+ if (decoded.schemaVersion === 3) return {
536
+ document: decoded.document,
537
+ version: raw.version
538
+ };
539
+ if (decoded.schemaVersion === 2) return {
540
+ document: migrateV2(decoded.document),
541
+ version: raw.version
542
+ };
543
+ await this.writeV1Backup(stage, raw.body);
544
+ const document = this.stamp(stage, migrateV2(migrateV1(stage, decoded.state)));
545
+ try {
546
+ return {
547
+ document,
548
+ version: await this.writeRaw(stage, encodeDocument(document), raw.version)
549
+ };
550
+ } catch (error) {
551
+ if (error instanceof StateVersionConflict && attempt < 2) return this.readDocument(stage, attempt + 1);
552
+ throw error;
553
+ }
554
+ }
555
+ };
556
+ /**
557
+ * Refuses, with `StateTooLargeForSsm`, a run whose state would not fit its
558
+ * store once this run has added to it — before the run changes anything, not
559
+ * at the last write, after the stack has started.
560
+ */
561
+ async function assertStateRoom(store, stage) {
562
+ const capacity = await store.capacity?.(stage);
563
+ if (!capacity) return;
564
+ if (capacity.bytes + 1024 > capacity.limit) throw new StateTooLargeForSsm(stage, capacity.bytes, capacity.limit, capacity.location, capacity.region ?? "<region>");
565
+ }
566
+ /** Whether `config` keeps state on this machine — `local`, or none given. */
567
+ function isLocalState(config) {
568
+ return !config || config.provider === "local";
569
+ }
570
+ /**
571
+ * Refuses, with `LocalStateInCi`, a run that would write a deployed stage's
572
+ * state to a CI runner's disk — the local stage, which runs on the runner
573
+ * itself, is exempt. Local use is untouched. The region the message
574
+ * suggests is the secrets store's, when the workspace keeps them in AWS.
575
+ */
576
+ function assertStateOutlivesRun(workspace, stage, operation, env = process.env) {
577
+ if (stage === workspace.stages?.local) return;
578
+ if (!require_seeds.isCi(env) || !isLocalState(workspace.state)) return;
579
+ const store = workspace.secrets?.store;
580
+ throw new LocalStateInCi(stage, operation, typeof store === "object" && store && typeof store.region === "string" ? store.region : "<region>");
581
+ }
582
+ function isStateStore(value) {
583
+ return typeof value === "object" && value !== null && typeof value.lock === "function" && typeof value.read === "function" && typeof value.write === "function" && typeof value.putResource === "function";
584
+ }
585
+ /**
586
+ * The store for a workspace's `state` config:
587
+ *
588
+ * - none / `'local'`: `LocalStateStore` under `.gkm/`
589
+ * - `'ssm'`: `SSMStateStore`, with no local cache — SSM is read directly, so
590
+ * a stale local copy can never win over it
591
+ * - `'s3'`: `S3StateStore`
592
+ * - a `StateStore` object: used as is
593
+ * - a `StateProvider` object: wrapped by `LegacyStateStore`
594
+ */
595
+ async function createStateStore(options) {
596
+ const { config, workspaceRoot, workspaceName } = options;
597
+ if (!config || config.provider === "local") {
598
+ const { LocalStateStore } = await Promise.resolve().then(() => require("./LocalStateStore-BciJ_DF0.cjs")).then((n) => n.LocalStateStore_exports);
599
+ return new LocalStateStore(workspaceRoot);
600
+ }
601
+ if (isStateStore(config.provider)) return config.provider;
602
+ if (isStateProvider(config.provider)) {
603
+ const { LegacyStateStore } = await Promise.resolve().then(() => require("./LegacyStateStore-CuSe37fl.cjs"));
604
+ return new LegacyStateStore(config.provider, { warn: options.warn });
605
+ }
606
+ if (config.provider === "ssm") {
607
+ if (!workspaceName) throw new StateStoreNeedsWorkspaceName("ssm");
608
+ const { SSMStateStore } = await Promise.resolve().then(() => require("./SSMStateStore-BqT3MXXb.cjs"));
609
+ const ssm = config;
610
+ return SSMStateStore.create({
611
+ workspaceName,
612
+ region: ssm.region,
613
+ profile: ssm.profile
614
+ });
615
+ }
616
+ if (config.provider === "s3") {
617
+ if (!workspaceName) throw new StateStoreNeedsWorkspaceName("s3");
618
+ const { S3StateStore } = await Promise.resolve().then(() => require("./S3StateStore-BHLRjoj3.cjs"));
619
+ const s3 = config;
620
+ return S3StateStore.create({
621
+ workspaceName,
622
+ ...s3.bucket ? { bucket: s3.bucket } : {},
623
+ ...options.namespace ? { namespace: options.namespace } : {},
624
+ prefix: s3.prefix,
625
+ region: s3.region,
626
+ profile: s3.profile
627
+ });
628
+ }
629
+ throw new UnknownStateProvider(config);
630
+ }
631
+ //#endregion
632
+ //#region src/target/dokploy/dokploy-api.ts
633
+ /**
634
+ * Centralized Dokploy API client
635
+ *
636
+ * Handles authentication, error handling, and provides typed methods for all Dokploy API endpoints.
637
+ */
638
+ var dokploy_api_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({
639
+ DEFAULT_DEPLOYMENT_TIMEOUT_MS: () => DEFAULT_DEPLOYMENT_TIMEOUT_MS,
640
+ DEFAULT_DOKPLOY_TIMEOUT_MS: () => DEFAULT_DOKPLOY_TIMEOUT_MS,
641
+ DeploymentFailed: () => DeploymentFailed,
642
+ DeploymentTimedOut: () => DeploymentTimedOut,
643
+ DokployApi: () => DokployApi,
644
+ DokployApiError: () => DokployApiError,
645
+ DokployRequestTimedOut: () => DokployRequestTimedOut
646
+ });
647
+ /** Per request, so a stalled server fails the deploy, not the CI job. */
648
+ const DEFAULT_DOKPLOY_TIMEOUT_MS = 3e4;
649
+ /**
650
+ * Dokploy accepted the connection but did not answer in time.
651
+ *
652
+ * Not retried: a request that arrived and stalled may still be acted on, and
653
+ * sending it again could repeat a deploy or a create the server is already
654
+ * doing.
655
+ */
656
+ var DokployRequestTimedOut = class extends require_errors.GkmError {
657
+ baseUrl;
658
+ endpoint;
659
+ timeoutMs;
660
+ constructor(baseUrl, endpoint, timeoutMs) {
661
+ super(`Dokploy at ${baseUrl} did not answer ${endpoint} within ${timeoutMs}ms. Check that the Dokploy server is healthy, or raise \`timeoutMs\` if this call is known to be slow.`);
662
+ this.baseUrl = baseUrl;
663
+ this.endpoint = endpoint;
664
+ this.timeoutMs = timeoutMs;
665
+ this.name = "DokployRequestTimedOut";
666
+ }
667
+ };
668
+ /**
669
+ * Waits `ms` between retries, or rejects with the signal's reason the moment
670
+ * it aborts — a caller who gave up should not sit through the backoff.
671
+ */
672
+ function pause(ms, signal) {
673
+ return new Promise((resolve, reject) => {
674
+ if (signal?.aborted) {
675
+ reject(signal.reason);
676
+ return;
677
+ }
678
+ const onAbort = () => {
679
+ clearTimeout(timer);
680
+ reject(signal?.reason);
681
+ };
682
+ const timer = setTimeout(() => {
683
+ signal?.removeEventListener("abort", onAbort);
684
+ resolve();
685
+ }, ms);
686
+ signal?.addEventListener("abort", onAbort, { once: true });
687
+ });
688
+ }
689
+ /** How long a deployment may take to finish before a deploy gives up on it. */
690
+ const DEFAULT_DEPLOYMENT_TIMEOUT_MS = 6e5;
691
+ /** A deployment Dokploy ran and reported as failed. */
692
+ var DeploymentFailed = class extends require_errors.GkmError {
693
+ applicationId;
694
+ deployment;
695
+ constructor(applicationId, deployment) {
696
+ super(`Dokploy's deployment ${deployment.deploymentId} of application ${applicationId} ended in "${deployment.status}"${deployment.errorMessage ? `: ${deployment.errorMessage}` : ""}. Its log in Dokploy says why — usually an image the server could not pull, or a container that exited on start.`);
697
+ this.applicationId = applicationId;
698
+ this.deployment = deployment;
699
+ this.name = "DeploymentFailed";
700
+ }
701
+ };
702
+ /** A deployment that had not finished when the deploy stopped waiting. */
703
+ var DeploymentTimedOut = class extends require_errors.GkmError {
704
+ applicationId;
705
+ timeoutMs;
706
+ lastStatus;
707
+ constructor(applicationId, timeoutMs, lastStatus) {
708
+ super(`Application ${applicationId} did not finish deploying within ${Math.round(timeoutMs / 1e3)}s (${lastStatus ? `last status "${lastStatus}"` : "no deployment started"}). Check its deployment log in Dokploy, or raise deploy.dokploy.verify.deploymentTimeoutMs for an image that is slow to pull.`);
709
+ this.applicationId = applicationId;
710
+ this.timeoutMs = timeoutMs;
711
+ this.lastStatus = lastStatus;
712
+ this.name = "DeploymentTimedOut";
713
+ }
714
+ };
715
+ var DokployApiError = class extends Error {
716
+ status;
717
+ statusText;
718
+ issues;
719
+ constructor(message, status, statusText, issues) {
720
+ super(message);
721
+ this.status = status;
722
+ this.statusText = statusText;
723
+ this.issues = issues;
724
+ this.name = "DokployApiError";
725
+ }
726
+ };
727
+ /**
728
+ * Dokploy API client
729
+ */
730
+ var DokployApi = class {
731
+ baseUrl;
732
+ token;
733
+ timeoutMs;
734
+ signal;
735
+ constructor(options) {
736
+ this.baseUrl = options.baseUrl.replace(/\/$/, "");
737
+ this.token = options.token;
738
+ this.timeoutMs = options.timeoutMs ?? 3e4;
739
+ this.signal = options.signal;
740
+ }
741
+ /**
742
+ * Make a GET request to the Dokploy API
743
+ */
744
+ async get(endpoint) {
745
+ return this.request("GET", endpoint);
746
+ }
747
+ /**
748
+ * Make a POST request to the Dokploy API
749
+ */
750
+ async post(endpoint, body) {
751
+ return this.request("POST", endpoint, body);
752
+ }
753
+ /**
754
+ * Make a request to the Dokploy API
755
+ */
756
+ async request(method, endpoint, body) {
757
+ const url = `${this.baseUrl}/api/${endpoint}`;
758
+ let response;
759
+ let timeout;
760
+ let lastError;
761
+ for (let attempt = 1; attempt <= 3; attempt++) {
762
+ this.signal?.throwIfAborted();
763
+ timeout = AbortSignal.timeout(this.timeoutMs);
764
+ try {
765
+ response = await fetch(url, {
766
+ method,
767
+ headers: {
768
+ "Content-Type": "application/json",
769
+ "x-api-key": this.token
770
+ },
771
+ body: body ? JSON.stringify(body) : void 0,
772
+ signal: this.signal ? AbortSignal.any([this.signal, timeout]) : timeout
773
+ });
774
+ break;
775
+ } catch (error) {
776
+ const stopped = this.stopped(timeout, endpoint);
777
+ if (stopped) throw stopped;
778
+ lastError = error;
779
+ if (attempt === 3) break;
780
+ await pause(attempt * 750, this.signal);
781
+ }
782
+ }
783
+ if (!response || !timeout) {
784
+ const detail = lastError instanceof Error ? lastError.message : String(lastError);
785
+ throw new DokployApiError(`Could not reach Dokploy at ${this.baseUrl} (${endpoint}): ${detail}`, 0, "Network error");
786
+ }
787
+ try {
788
+ return await this.read(response);
789
+ } catch (error) {
790
+ throw this.stopped(timeout, endpoint) ?? error;
791
+ }
792
+ }
793
+ /**
794
+ * What a request cut short should reject with: the caller's own reason
795
+ * when they aborted, `DokployRequestTimedOut` when the deadline passed,
796
+ * nothing when it was neither.
797
+ */
798
+ stopped(timeout, endpoint) {
799
+ if (this.signal?.aborted) return this.signal.reason;
800
+ if (timeout.aborted) return new DokployRequestTimedOut(this.baseUrl, endpoint, this.timeoutMs);
801
+ }
802
+ /** Turns a response into its JSON body, or a `DokployApiError`. */
803
+ async read(response) {
804
+ if (!response.ok) {
805
+ let errorMessage = `Dokploy API error: ${response.status} ${response.statusText}`;
806
+ let issues;
807
+ try {
808
+ const errorBody = await response.json();
809
+ if (errorBody.message) errorMessage = `Dokploy API error: ${errorBody.message}`;
810
+ if (errorBody.issues?.length) {
811
+ issues = errorBody.issues;
812
+ errorMessage += `\n Issues: ${errorBody.issues.map((i) => i.message).join(", ")}`;
813
+ }
814
+ } catch {}
815
+ throw new DokployApiError(errorMessage, response.status, response.statusText, issues);
816
+ }
817
+ const text = await response.text();
818
+ if (!text || text.trim() === "") return;
819
+ return JSON.parse(text);
820
+ }
821
+ /**
822
+ * Every external port published on this server, across every project.
823
+ *
824
+ * Dokploy knows what it has bound; guessing does not. A port that looks free
825
+ * from here can be held by a service in a project this deploy has never
826
+ * heard of — which surfaces as `Port 5432 is already in use by container
827
+ * "…"`, naming something the caller cannot see.
828
+ *
829
+ * `project.all` is a summary, so each project is fetched: the per-service
830
+ * `externalPort` only appears on `project.one`.
831
+ */
832
+ async publishedPorts() {
833
+ const ports = /* @__PURE__ */ new Set();
834
+ const projects = await this.listProjects();
835
+ for (const project of projects) {
836
+ const details = await this.getProject(project.projectId);
837
+ for (const environment of details.environments ?? []) {
838
+ const resources = [
839
+ ...environment.postgres ?? [],
840
+ ...environment.redis ?? [],
841
+ ...environment.applications ?? []
842
+ ];
843
+ for (const resource of resources) if (typeof resource.externalPort === "number") ports.add(resource.externalPort);
844
+ }
845
+ }
846
+ return ports;
847
+ }
848
+ /**
849
+ * Validate the API token by making a test request
850
+ */
851
+ async validateToken() {
852
+ try {
853
+ await this.get("project.all");
854
+ return true;
855
+ } catch {
856
+ return false;
857
+ }
858
+ }
859
+ /**
860
+ * List all projects
861
+ */
862
+ async listProjects() {
863
+ return this.get("project.all");
864
+ }
865
+ /**
866
+ * Get a single project by ID
867
+ */
868
+ async getProject(projectId) {
869
+ return this.get(`project.one?projectId=${projectId}`);
870
+ }
871
+ /**
872
+ * Create a new project
873
+ */
874
+ async createProject(name, description) {
875
+ return this.post("project.create", {
876
+ name,
877
+ description: description ?? `Created by gkm CLI`
878
+ });
879
+ }
880
+ /**
881
+ * Change a project's name or description.
882
+ *
883
+ * The name is sent with the description because `project.update` validates
884
+ * the whole project on some Dokploy versions, and a missing name fails it.
885
+ */
886
+ async updateProject(projectId, updates) {
887
+ await this.post("project.update", {
888
+ projectId,
889
+ ...updates
890
+ });
891
+ }
892
+ /**
893
+ * Delete a project and all its resources
894
+ */
895
+ async deleteProject(projectId) {
896
+ await this.post("project.remove", { projectId });
897
+ }
898
+ /**
899
+ * Create an environment in a project
900
+ */
901
+ async createEnvironment(projectId, name, description) {
902
+ return this.post("environment.create", {
903
+ projectId,
904
+ name,
905
+ description: description ?? `${name} environment`
906
+ });
907
+ }
908
+ /**
909
+ * List all applications in a project
910
+ */
911
+ async listApplications(projectId) {
912
+ return this.listInProject(projectId, (env) => env.applications);
913
+ }
914
+ /**
915
+ * Everything of one kind in a project, across its environments.
916
+ *
917
+ * From `project.one`, because the per-kind `*.all?projectId=` endpoints
918
+ * return **404** on current Dokploy: resources live under environments now.
919
+ * Those calls used to be wrapped in `catch { return [] }`, which turned "I
920
+ * could not ask" into "there are none" — and for a find-or-create that is
921
+ * the worst available answer. Every deploy created a second application, a
922
+ * second Postgres and a second Redis, silently, for as long as the project
923
+ * existed.
924
+ *
925
+ * A failure here is not swallowed: creating a duplicate is worse than
926
+ * stopping.
927
+ */
928
+ async listInProject(projectId, pick) {
929
+ return ((await this.getProject(projectId)).environments ?? []).flatMap((environment) => (pick(environment) ?? []).map((resource) => ({
930
+ ...resource,
931
+ environmentId: environment.environmentId
932
+ })));
933
+ }
934
+ /**
935
+ * Find an application by name in a project
936
+ */
937
+ async findApplicationByName(projectId, name, environmentId) {
938
+ const applications = await this.listApplications(projectId);
939
+ const normalizedName = name.toLowerCase().replace(/[^a-z0-9-]/g, "-");
940
+ return applications.find((app) => (!environmentId || app.environmentId === environmentId) && (app.name === name || app.appName === normalizedName));
941
+ }
942
+ /**
943
+ * Create a new application
944
+ */
945
+ async createApplication(name, projectId, environmentId) {
946
+ return this.post("application.create", {
947
+ name,
948
+ projectId,
949
+ environmentId,
950
+ appName: name.toLowerCase().replace(/[^a-z0-9-]/g, "-")
951
+ });
952
+ }
953
+ /**
954
+ * Find or create an application by name
955
+ */
956
+ async findOrCreateApplication(name, projectId, environmentId) {
957
+ const existing = await this.findApplicationByName(projectId, name, environmentId);
958
+ if (existing) return {
959
+ application: existing,
960
+ created: false
961
+ };
962
+ return {
963
+ application: await this.createApplication(name, projectId, environmentId),
964
+ created: true
965
+ };
966
+ }
967
+ /**
968
+ * Get an application by ID
969
+ */
970
+ async getApplication(applicationId) {
971
+ try {
972
+ return await this.get(`application.one?applicationId=${applicationId}`);
973
+ } catch {
974
+ return null;
975
+ }
976
+ }
977
+ /**
978
+ * Update an application
979
+ */
980
+ async updateApplication(applicationId, updates) {
981
+ await this.post("application.update", {
982
+ applicationId,
983
+ ...updates
984
+ });
985
+ }
986
+ /**
987
+ * Save environment variables for an application
988
+ */
989
+ async saveApplicationEnv(applicationId, env, options) {
990
+ await this.post("application.saveEnvironment", {
991
+ applicationId,
992
+ env,
993
+ buildArgs: options?.buildArgs ?? null,
994
+ buildSecrets: options?.buildSecrets ?? null,
995
+ createEnvFile: false
996
+ });
997
+ }
998
+ /**
999
+ * Configure application to use Docker provider (pull from registry)
1000
+ *
1001
+ * For private registries, either:
1002
+ * - Use `registryId` if the registry is configured in Dokploy
1003
+ * - Or provide `username`, `password`, and `registryUrl` directly
1004
+ */
1005
+ async saveDockerProvider(applicationId, dockerImage, options) {
1006
+ await this.post("application.saveDockerProvider", {
1007
+ applicationId,
1008
+ dockerImage,
1009
+ ...options,
1010
+ username: options?.username ?? null,
1011
+ password: options?.password ?? null,
1012
+ registryUrl: options?.registryUrl ?? null
1013
+ });
1014
+ }
1015
+ /**
1016
+ * Deploy an application
1017
+ */
1018
+ async deployApplication(applicationId) {
1019
+ await this.post("application.deploy", { applicationId });
1020
+ }
1021
+ /**
1022
+ * An application's deployments, newest first.
1023
+ *
1024
+ * Sorted here rather than trusted to arrive sorted: which deployment is
1025
+ * the latest is the whole question `waitForDeployment` asks.
1026
+ */
1027
+ async listDeployments(applicationId) {
1028
+ return [...await this.get(`deployment.all?applicationId=${encodeURIComponent(applicationId)}`)].sort((a, b) => Date.parse(b.createdAt) - Date.parse(a.createdAt));
1029
+ }
1030
+ /**
1031
+ * When the application's latest deployment was created, by Dokploy's own
1032
+ * clock — what `waitForDeployment`'s `since` is measured against. Epoch
1033
+ * when it has none.
1034
+ */
1035
+ async latestDeploymentAt(applicationId) {
1036
+ const [latest] = await this.listDeployments(applicationId);
1037
+ return new Date(latest ? Date.parse(latest.createdAt) : 0);
1038
+ }
1039
+ /**
1040
+ * Wait for the deployment `application.deploy` queued to finish.
1041
+ *
1042
+ * `application.deploy` only queues one: it answers before the image is
1043
+ * pulled, let alone running, so a deploy that stopped there reported
1044
+ * success for containers that had not started. This polls the latest
1045
+ * deployment created after `since` — Dokploy's clock, from
1046
+ * `latestDeploymentAt` before deploying, so a laptop's skew cannot pick an
1047
+ * older one — and the application's own status, backing off from
1048
+ * `intervalMs` to `maxIntervalMs`.
1049
+ *
1050
+ * @throws {DeploymentFailed} when the deployment ends in `error` or is
1051
+ * cancelled, or the application reports `error` once it has finished.
1052
+ * @throws {DeploymentTimedOut} when it has not finished within `timeoutMs`.
1053
+ */
1054
+ async waitForDeployment(applicationId, options) {
1055
+ const { since, timeoutMs = DEFAULT_DEPLOYMENT_TIMEOUT_MS, signal, intervalMs = 2e3, maxIntervalMs = 15e3 } = options;
1056
+ const after = since.getTime();
1057
+ const deadline = Date.now() + timeoutMs;
1058
+ let interval = intervalMs;
1059
+ let last;
1060
+ while (true) {
1061
+ signal?.throwIfAborted();
1062
+ const deployment = (await this.listDeployments(applicationId)).find((d) => Date.parse(d.createdAt) > after);
1063
+ last = deployment ?? last;
1064
+ if (deployment) {
1065
+ if (deployment.status === "error" || deployment.status === "cancelled") throw new DeploymentFailed(applicationId, deployment);
1066
+ if (deployment.status === "done") {
1067
+ const { applicationStatus } = await this.get(`application.one?applicationId=${encodeURIComponent(applicationId)}`);
1068
+ if (applicationStatus === "error") throw new DeploymentFailed(applicationId, deployment);
1069
+ if (applicationStatus !== "running") return deployment;
1070
+ }
1071
+ }
1072
+ const left = deadline - Date.now();
1073
+ if (left <= 0) throw new DeploymentTimedOut(applicationId, timeoutMs, last?.status);
1074
+ await pause(Math.min(interval, left), signal);
1075
+ interval = Math.min(interval * 2, maxIntervalMs);
1076
+ }
1077
+ }
1078
+ /**
1079
+ * Delete an application
1080
+ */
1081
+ async deleteApplication(applicationId) {
1082
+ await this.post("application.remove", { applicationId });
1083
+ }
1084
+ /**
1085
+ * List all registries
1086
+ */
1087
+ async listRegistries() {
1088
+ return this.get("registry.all");
1089
+ }
1090
+ /**
1091
+ * Create a new registry
1092
+ */
1093
+ async createRegistry(registryName, registryUrl, username, password, options) {
1094
+ return this.post("registry.create", {
1095
+ registryName,
1096
+ registryUrl,
1097
+ username,
1098
+ password,
1099
+ imagePrefix: options?.imagePrefix
1100
+ });
1101
+ }
1102
+ /**
1103
+ * Get a registry by ID
1104
+ */
1105
+ async getRegistry(registryId) {
1106
+ return this.get(`registry.one?registryId=${registryId}`);
1107
+ }
1108
+ /**
1109
+ * Update a registry
1110
+ */
1111
+ async updateRegistry(registryId, updates) {
1112
+ await this.post("registry.update", {
1113
+ registryId,
1114
+ ...updates
1115
+ });
1116
+ }
1117
+ /**
1118
+ * Delete a registry
1119
+ */
1120
+ async deleteRegistry(registryId) {
1121
+ await this.post("registry.remove", { registryId });
1122
+ }
1123
+ /**
1124
+ * List all Postgres databases in a project
1125
+ */
1126
+ async listPostgres(projectId) {
1127
+ return this.listInProject(projectId, (env) => env.postgres);
1128
+ }
1129
+ /**
1130
+ * Find a Postgres database by name in a project
1131
+ */
1132
+ async findPostgresByName(projectId, name) {
1133
+ const databases = await this.listPostgres(projectId);
1134
+ const normalizedName = name.toLowerCase().replace(/[^a-z0-9-]/g, "-");
1135
+ const match = databases.find((db) => db.name === name || db.appName === normalizedName);
1136
+ if (!match) return void 0;
1137
+ return this.getPostgres(match.postgresId);
1138
+ }
1139
+ /**
1140
+ * Create a new Postgres database
1141
+ */
1142
+ async createPostgres(name, projectId, environmentId, options) {
1143
+ return this.post("postgres.create", {
1144
+ name,
1145
+ projectId,
1146
+ environmentId,
1147
+ appName: options?.appName ?? name.toLowerCase().replace(/[^a-z0-9-]/g, "-"),
1148
+ databaseName: options?.databaseName,
1149
+ databaseUser: options?.databaseUser ?? "postgres",
1150
+ databasePassword: options?.databasePassword,
1151
+ dockerImage: options?.dockerImage ?? "postgres:18",
1152
+ description: options?.description ?? `Postgres database for ${name}`
1153
+ });
1154
+ }
1155
+ /**
1156
+ * Find or create a Postgres database by name
1157
+ */
1158
+ async findOrCreatePostgres(name, projectId, environmentId, options) {
1159
+ const existing = await this.findPostgresByName(projectId, name);
1160
+ if (existing) return {
1161
+ postgres: existing,
1162
+ created: false
1163
+ };
1164
+ return {
1165
+ postgres: await this.createPostgres(name, projectId, environmentId, options),
1166
+ created: true
1167
+ };
1168
+ }
1169
+ /**
1170
+ * Get a Postgres database by ID
1171
+ */
1172
+ async getPostgres(postgresId) {
1173
+ return this.get(`postgres.one?postgresId=${postgresId}`);
1174
+ }
1175
+ /**
1176
+ * Deploy a Postgres database
1177
+ */
1178
+ async deployPostgres(postgresId) {
1179
+ await this.post("postgres.deploy", { postgresId });
1180
+ }
1181
+ /**
1182
+ * Save environment variables for Postgres
1183
+ */
1184
+ async savePostgresEnv(postgresId, env) {
1185
+ await this.post("postgres.saveEnvironment", {
1186
+ postgresId,
1187
+ env
1188
+ });
1189
+ }
1190
+ /**
1191
+ * Set external port for Postgres (for external access)
1192
+ */
1193
+ async savePostgresExternalPort(postgresId, externalPort) {
1194
+ await this.post("postgres.saveExternalPort", {
1195
+ postgresId,
1196
+ externalPort
1197
+ });
1198
+ }
1199
+ /**
1200
+ * Update Postgres configuration
1201
+ */
1202
+ async updatePostgres(postgresId, updates) {
1203
+ await this.post("postgres.update", {
1204
+ postgresId,
1205
+ ...updates
1206
+ });
1207
+ }
1208
+ /**
1209
+ * Delete a Postgres database
1210
+ */
1211
+ async deletePostgres(postgresId) {
1212
+ await this.post("postgres.remove", { postgresId });
1213
+ }
1214
+ /**
1215
+ * The compose stacks in a project.
1216
+ *
1217
+ * Dokploy has first-class primitives for Postgres and Redis and none for
1218
+ * MinIO, so an object store is a compose stack — the one kind whose contents
1219
+ * this target writes rather than configures.
1220
+ */
1221
+ async listCompose(projectId) {
1222
+ return this.listInProject(projectId, (env) => env.compose);
1223
+ }
1224
+ /** A compose stack by name, hydrated — `project.one` returns summaries. */
1225
+ async findComposeByName(projectId, name) {
1226
+ const summary = (await this.listCompose(projectId)).find((compose) => compose.name === name);
1227
+ return summary ? this.getCompose(summary.composeId) : void 0;
1228
+ }
1229
+ async getCompose(composeId) {
1230
+ return this.get(`compose.one?composeId=${composeId}`);
1231
+ }
1232
+ /**
1233
+ * A compose stack carrying the file this target wrote.
1234
+ *
1235
+ * Created empty and then updated, because `compose.create` takes no file:
1236
+ * it defaults to `sourceType: 'github'` and expects a repository. `raw` is
1237
+ * what makes the file ours.
1238
+ */
1239
+ async findOrCreateCompose(name, projectId, environmentId, composeFile) {
1240
+ const existing = await this.findComposeByName(projectId, name);
1241
+ const compose = existing ?? await this.post("compose.create", {
1242
+ name,
1243
+ environmentId,
1244
+ composeType: "docker-compose"
1245
+ });
1246
+ await this.post("compose.update", {
1247
+ composeId: compose.composeId,
1248
+ sourceType: "raw",
1249
+ composeFile
1250
+ });
1251
+ return {
1252
+ compose,
1253
+ created: !existing
1254
+ };
1255
+ }
1256
+ async deployCompose(composeId) {
1257
+ await this.post("compose.deploy", { composeId });
1258
+ }
1259
+ async deleteCompose(composeId) {
1260
+ await this.post("compose.delete", {
1261
+ composeId,
1262
+ deleteVolumes: false
1263
+ });
1264
+ }
1265
+ /**
1266
+ * List all Redis instances in a project
1267
+ */
1268
+ async listRedis(projectId) {
1269
+ return this.listInProject(projectId, (env) => env.redis);
1270
+ }
1271
+ /**
1272
+ * Find a Redis instance by name in a project
1273
+ */
1274
+ async findRedisByName(projectId, name) {
1275
+ const instances = await this.listRedis(projectId);
1276
+ const normalizedName = name.toLowerCase().replace(/[^a-z0-9-]/g, "-");
1277
+ const match = instances.find((redis) => redis.name === name || redis.appName === normalizedName);
1278
+ return match ? this.getRedis(match.redisId) : void 0;
1279
+ }
1280
+ /**
1281
+ * Create a new Redis instance
1282
+ */
1283
+ async createRedis(name, projectId, environmentId, options) {
1284
+ return this.post("redis.create", {
1285
+ name,
1286
+ projectId,
1287
+ environmentId,
1288
+ appName: options?.appName ?? name.toLowerCase().replace(/[^a-z0-9-]/g, "-"),
1289
+ databasePassword: options?.databasePassword,
1290
+ dockerImage: options?.dockerImage ?? "redis:8",
1291
+ description: options?.description ?? `Redis instance for ${name}`
1292
+ });
1293
+ }
1294
+ /**
1295
+ * Find or create a Redis instance by name
1296
+ */
1297
+ async findOrCreateRedis(name, projectId, environmentId, options) {
1298
+ const existing = await this.findRedisByName(projectId, name);
1299
+ if (existing) return {
1300
+ redis: existing,
1301
+ created: false
1302
+ };
1303
+ return {
1304
+ redis: await this.createRedis(name, projectId, environmentId, options),
1305
+ created: true
1306
+ };
1307
+ }
1308
+ /**
1309
+ * Get a Redis instance by ID
1310
+ */
1311
+ async getRedis(redisId) {
1312
+ return this.get(`redis.one?redisId=${redisId}`);
1313
+ }
1314
+ /**
1315
+ * Deploy a Redis instance
1316
+ */
1317
+ async deployRedis(redisId) {
1318
+ await this.post("redis.deploy", { redisId });
1319
+ }
1320
+ /**
1321
+ * Save environment variables for Redis
1322
+ */
1323
+ async saveRedisEnv(redisId, env) {
1324
+ await this.post("redis.saveEnvironment", {
1325
+ redisId,
1326
+ env
1327
+ });
1328
+ }
1329
+ /**
1330
+ * Set external port for Redis (for external access)
1331
+ */
1332
+ async saveRedisExternalPort(redisId, externalPort) {
1333
+ await this.post("redis.saveExternalPort", {
1334
+ redisId,
1335
+ externalPort
1336
+ });
1337
+ }
1338
+ /**
1339
+ * Update Redis configuration
1340
+ */
1341
+ async updateRedis(redisId, updates) {
1342
+ await this.post("redis.update", {
1343
+ redisId,
1344
+ ...updates
1345
+ });
1346
+ }
1347
+ /**
1348
+ * Delete a Redis instance
1349
+ */
1350
+ async deleteRedis(redisId) {
1351
+ await this.post("redis.remove", { redisId });
1352
+ }
1353
+ /**
1354
+ * Create a new domain for an application
1355
+ */
1356
+ async createDomain(options) {
1357
+ return this.post("domain.create", options);
1358
+ }
1359
+ /**
1360
+ * Update an existing domain
1361
+ */
1362
+ async updateDomain(domainId, updates) {
1363
+ await this.post("domain.update", {
1364
+ domainId,
1365
+ ...updates
1366
+ });
1367
+ }
1368
+ /**
1369
+ * Delete a domain
1370
+ */
1371
+ async deleteDomain(domainId) {
1372
+ await this.post("domain.delete", { domainId });
1373
+ }
1374
+ /**
1375
+ * Get a domain by ID
1376
+ */
1377
+ async getDomain(domainId) {
1378
+ return this.get(`domain.one?domainId=${domainId}`);
1379
+ }
1380
+ /**
1381
+ * Get all domains for an application
1382
+ */
1383
+ async getDomainsByApplicationId(applicationId) {
1384
+ return this.get(`domain.byApplicationId?applicationId=${applicationId}`);
1385
+ }
1386
+ /**
1387
+ * Validate a domain and trigger SSL certificate generation
1388
+ *
1389
+ * This should be called after DNS records are created and propagated.
1390
+ * It triggers Let's Encrypt certificate generation for HTTPS domains.
1391
+ *
1392
+ * @param domain - The domain hostname to validate (e.g., 'api.example.com')
1393
+ */
1394
+ async validateDomain(domain) {
1395
+ return this.post("domain.validateDomain", { domain });
1396
+ }
1397
+ /**
1398
+ * Auto-generate a domain name for an application
1399
+ */
1400
+ async generateDomain(appName, serverId) {
1401
+ return this.post("domain.generateDomain", {
1402
+ appName,
1403
+ serverId
1404
+ });
1405
+ }
1406
+ /**
1407
+ * List all backup destinations
1408
+ */
1409
+ async listDestinations() {
1410
+ return this.get("destination.all");
1411
+ }
1412
+ /**
1413
+ * Get a destination by ID
1414
+ */
1415
+ async getDestination(destinationId) {
1416
+ return this.get(`destination.one?destinationId=${destinationId}`);
1417
+ }
1418
+ /**
1419
+ * Create a new S3 backup destination
1420
+ */
1421
+ async createDestination(options) {
1422
+ return this.post("destination.create", { ...options });
1423
+ }
1424
+ /**
1425
+ * Find a destination by name
1426
+ */
1427
+ async findDestinationByName(name) {
1428
+ return (await this.listDestinations()).find((d) => d.name === name);
1429
+ }
1430
+ /**
1431
+ * Find or create a destination by name
1432
+ */
1433
+ async findOrCreateDestination(name, options) {
1434
+ const existing = await this.findDestinationByName(name);
1435
+ if (existing) return {
1436
+ destination: existing,
1437
+ created: false
1438
+ };
1439
+ return {
1440
+ destination: await this.createDestination({
1441
+ name,
1442
+ ...options
1443
+ }),
1444
+ created: true
1445
+ };
1446
+ }
1447
+ /**
1448
+ * Update a destination
1449
+ */
1450
+ async updateDestination(destinationId, updates) {
1451
+ await this.post("destination.update", {
1452
+ destinationId,
1453
+ ...updates
1454
+ });
1455
+ }
1456
+ /**
1457
+ * Delete a destination
1458
+ */
1459
+ async deleteDestination(destinationId) {
1460
+ await this.post("destination.remove", { destinationId });
1461
+ }
1462
+ /**
1463
+ * Test connection to a destination
1464
+ */
1465
+ async testDestinationConnection(destinationId) {
1466
+ return this.post("destination.testConnection", { destinationId });
1467
+ }
1468
+ /**
1469
+ * Create a backup schedule for postgres
1470
+ */
1471
+ async createPostgresBackup(options) {
1472
+ return this.post("backup.create", {
1473
+ ...options,
1474
+ databaseType: "postgres"
1475
+ });
1476
+ }
1477
+ /**
1478
+ * List backups for a postgres database
1479
+ */
1480
+ async listPostgresBackups(postgresId) {
1481
+ return this.get(`backup.all?postgresId=${postgresId}&databaseType=postgres`);
1482
+ }
1483
+ /**
1484
+ * Get a backup by ID
1485
+ */
1486
+ async getBackup(backupId) {
1487
+ return this.get(`backup.one?backupId=${backupId}`);
1488
+ }
1489
+ /**
1490
+ * Update a backup schedule
1491
+ */
1492
+ async updateBackup(backupId, updates) {
1493
+ await this.post("backup.update", {
1494
+ backupId,
1495
+ ...updates
1496
+ });
1497
+ }
1498
+ /**
1499
+ * Delete a backup schedule
1500
+ */
1501
+ async deleteBackup(backupId) {
1502
+ await this.post("backup.remove", { backupId });
1503
+ }
1504
+ /**
1505
+ * Trigger a manual backup run
1506
+ */
1507
+ async runBackupManually(backupId) {
1508
+ await this.post("backup.manualBackup", { backupId });
1509
+ }
1510
+ };
1511
+ //#endregion
1512
+ //#region src/workspace/client-generator.ts
1513
+ /**
1514
+ * Normalize routes to an array of patterns.
1515
+ * Handles a glob or a list of them.
1516
+ * @internal Exported for use in dev command
1517
+ */
1518
+ function normalizeRoutes(routes) {
1519
+ if (!routes) return [];
1520
+ return Array.isArray(routes) ? routes : [routes];
1521
+ }
1522
+ //#endregion
1523
+ //#region src/deploy/sniffer.ts
1524
+ const __filename$1 = (0, node_url.fileURLToPath)(require("url").pathToFileURL(__filename).href);
1525
+ const __dirname$1 = (0, node_path.dirname)(__filename$1);
1526
+ /**
1527
+ * Resolve the path to a sniffer helper file.
1528
+ * Handles both dev (.ts with tsx) and production (.mjs from dist).
1529
+ *
1530
+ * In production: sniffer.ts is bundled into dist/index.mjs, but sniffer helper
1531
+ * files are output to dist/deploy/ as standalone modules for subprocess loading.
1532
+ *
1533
+ * In development: All files are in src/deploy/ and loaded via tsx.
1534
+ */
1535
+ function resolveSnifferFile(baseName) {
1536
+ const deployMjsPath = (0, node_path.resolve)(__dirname$1, "deploy", `${baseName}.mjs`);
1537
+ if ((0, node_fs.existsSync)(deployMjsPath)) return deployMjsPath;
1538
+ const mjsPath = (0, node_path.resolve)(__dirname$1, `${baseName}.mjs`);
1539
+ if ((0, node_fs.existsSync)(mjsPath)) return mjsPath;
1540
+ const tsPath = (0, node_path.resolve)(__dirname$1, `${baseName}.ts`);
1541
+ if ((0, node_fs.existsSync)(tsPath)) return tsPath;
1542
+ return tsPath;
1543
+ }
1544
+ /**
1545
+ * Run a sniffer worker in the sandbox, with the sandbox's environment and
1546
+ * nothing of the deploy's: the deploy's Dokploy token, registry login and AWS
1547
+ * keys stay where they are. A worker that outlives the timeout is killed, and
1548
+ * comes back as the error the caller reports.
1549
+ */
1550
+ async function runSniffer(run, workspacePath, cwd, nodeArgs) {
1551
+ const sandbox = run.sandbox ?? require_discover.activeSandbox() ?? new require_local.LocalSandbox({ root: (0, node_path.resolve)(workspacePath) });
1552
+ try {
1553
+ const result = await sandbox.exec("node", nodeArgs, {
1554
+ cwd,
1555
+ env: { ...sandbox.env },
1556
+ timeoutMs: run.timeoutMs ?? 3e4,
1557
+ output: "capture"
1558
+ });
1559
+ return {
1560
+ stdout: result.stdout,
1561
+ stderr: result.stderr,
1562
+ code: result.exitCode
1563
+ };
1564
+ } catch (error) {
1565
+ return { error: error instanceof Error ? error : new Error(String(error)) };
1566
+ }
1567
+ }
1568
+ /** The worker's JSON answer: the last object on stdout naming `envVars`. */
1569
+ function snifferAnswer(stdout) {
1570
+ try {
1571
+ const jsonMatch = stdout.match(/\{[^{}]*"envVars"[^{}]*\}[^{]*$/);
1572
+ return jsonMatch ? JSON.parse(jsonMatch[0]) : void 0;
1573
+ } catch {
1574
+ return;
1575
+ }
1576
+ }
1577
+ /**
1578
+ * Get required environment variables for an app.
1579
+ *
1580
+ * Detection strategy (in order):
1581
+ * 1. Frontend apps: Returns empty (no server secrets)
1582
+ * 2. Apps with `requiredEnv`: Uses explicit list from config
1583
+ * 3. Entry apps: Imports entry file in subprocess to capture config.parse() calls
1584
+ * 4. Route-based apps: Loads route files and calls getEnvironment() on each construct
1585
+ * 5. Apps with `envParser` (no routes): Runs SnifferEnvironmentParser to detect usage
1586
+ * 6. Apps with neither: Returns empty
1587
+ *
1588
+ * This function handles "fire and forget" async operations gracefully,
1589
+ * capturing errors and unhandled rejections without failing the build.
1590
+ *
1591
+ * @param app - The normalized app configuration
1592
+ * @param appName - The name of the app
1593
+ * @param workspacePath - Absolute path to the workspace root
1594
+ * @param options - Optional configuration for sniffing behavior
1595
+ * @returns The sniffed environment with required variables
1596
+ */
1597
+ async function sniffAppEnvironment(app, appName, workspacePath, options = {}) {
1598
+ const { logWarnings = true, markOptional = false } = options;
1599
+ const run = {
1600
+ ...options.sandbox ? { sandbox: options.sandbox } : {},
1601
+ ...options.timeoutMs ? { timeoutMs: options.timeoutMs } : {}
1602
+ };
1603
+ if (app.type === "web" || app.type === "mobile") {
1604
+ const publicPrefix = require_workspace.getPublicEnvPrefix(app.framework);
1605
+ const depVars = publicPrefix ? (app.dependencies ?? []).map((dep) => `${publicPrefix}${dep.toUpperCase()}_URL`) : [];
1606
+ if (app.config) {
1607
+ const sniffedVars = [];
1608
+ const sniffedOptional = [];
1609
+ const configPaths = [];
1610
+ if (app.config.client) configPaths.push(app.config.client);
1611
+ if (app.config.server) configPaths.push(app.config.server);
1612
+ for (const configPath of configPaths) {
1613
+ const result = await sniffEntryFile(configPath, app.path, workspacePath, run);
1614
+ if (logWarnings && result.error) require_discover.output.warn(`[sniffer] ${appName}: Config file "${configPath}" threw error during sniffing (env vars still captured): ${result.error.message}`);
1615
+ sniffedVars.push(...result.envVars);
1616
+ sniffedOptional.push(...result.optionalEnvVars);
1617
+ }
1618
+ const optionalEnvVars = [...new Set(sniffedOptional)];
1619
+ return {
1620
+ appName,
1621
+ requiredEnvVars: applyMarkOptional([.../* @__PURE__ */ new Set([...depVars, ...sniffedVars])], optionalEnvVars, markOptional),
1622
+ optionalEnvVars
1623
+ };
1624
+ }
1625
+ return {
1626
+ appName,
1627
+ requiredEnvVars: depVars,
1628
+ optionalEnvVars: []
1629
+ };
1630
+ }
1631
+ if (app.entry) {
1632
+ const result = await sniffEntryFile(app.entry, app.path, workspacePath, run);
1633
+ if (logWarnings && result.error) require_discover.output.warn(`[sniffer] ${appName}: Entry file threw error during sniffing (env vars still captured): ${result.error.message}`);
1634
+ return {
1635
+ appName,
1636
+ requiredEnvVars: applyMarkOptional(result.envVars, result.optionalEnvVars, markOptional),
1637
+ optionalEnvVars: result.optionalEnvVars
1638
+ };
1639
+ }
1640
+ if (app.routes) {
1641
+ const result = await sniffRouteFiles(normalizeRoutes(app.routes), app.path, workspacePath, run);
1642
+ if (logWarnings && result.error) require_discover.output.warn(`[sniffer] ${appName}: Route sniffing threw error (env vars still captured): ${result.error.message}`);
1643
+ return {
1644
+ appName,
1645
+ requiredEnvVars: applyMarkOptional(result.envVars, result.optionalEnvVars, markOptional),
1646
+ optionalEnvVars: result.optionalEnvVars
1647
+ };
1648
+ }
1649
+ if (app.envParser) {
1650
+ const result = await sniffEnvParser(app.envParser, app.path, workspacePath, run);
1651
+ if (logWarnings) {
1652
+ if (result.error) require_discover.output.warn(`[sniffer] ${appName}: envParser threw error during sniffing (env vars still captured): ${result.error.message}`);
1653
+ if (result.unhandledRejections.length > 0) require_discover.output.warn(`[sniffer] ${appName}: Fire-and-forget rejections during sniffing (suppressed): ${result.unhandledRejections.map((e) => e.message).join(", ")}`);
1654
+ }
1655
+ return {
1656
+ appName,
1657
+ requiredEnvVars: applyMarkOptional(result.envVars, result.optionalEnvVars, markOptional),
1658
+ optionalEnvVars: result.optionalEnvVars
1659
+ };
1660
+ }
1661
+ return {
1662
+ appName,
1663
+ requiredEnvVars: [],
1664
+ optionalEnvVars: []
1665
+ };
1666
+ }
1667
+ /**
1668
+ * Apply the `?` suffix to optional variables in an env var list.
1669
+ * Only modifies the list when `markOptional` is true and there are optional vars.
1670
+ */
1671
+ function applyMarkOptional(envVars, optionalEnvVars, markOptional) {
1672
+ if (!markOptional || optionalEnvVars.length === 0) return envVars;
1673
+ const optionalSet = new Set(optionalEnvVars);
1674
+ return envVars.map((v) => optionalSet.has(v) ? `${v}?` : v);
1675
+ }
1676
+ /**
1677
+ * Sniff an entry file by importing it in a subprocess.
1678
+ *
1679
+ * Entry apps call `config.parse()` at module load time. To capture which
1680
+ * env vars are accessed, we:
1681
+ * 1. Spawn a subprocess with a module loader hook
1682
+ * 2. The loader intercepts `@geekmidas/envkit` and replaces EnvironmentParser
1683
+ * with SnifferEnvironmentParser
1684
+ * 3. Import the entry file (triggers config.parse())
1685
+ * 4. Capture and return the accessed env var names
1686
+ *
1687
+ * This approach provides process isolation - each app is sniffed in its own
1688
+ * subprocess, preventing module cache pollution.
1689
+ *
1690
+ * @param entryPath - Relative path to the entry file (e.g., './src/index.ts')
1691
+ * @param appPath - The app's path relative to workspace (e.g., 'apps/auth')
1692
+ * @param workspacePath - Absolute path to workspace root
1693
+ * @returns EntrySniffResult with env vars and optional error
1694
+ */
1695
+ async function sniffEntryFile(entryPath, appPath, workspacePath, run = {}) {
1696
+ const fullEntryPath = (0, node_path.resolve)(workspacePath, appPath, entryPath);
1697
+ const loaderPath = resolveSnifferFile("sniffer-loader");
1698
+ const workerPath = resolveSnifferFile("sniffer-worker");
1699
+ const ran = await runSniffer(run, workspacePath, (0, node_path.resolve)(workspacePath, appPath), require_discover.nodeWithTsx(workerPath, [fullEntryPath], [loaderPath]));
1700
+ if ("error" in ran) return {
1701
+ envVars: [],
1702
+ optionalEnvVars: [],
1703
+ error: ran.error
1704
+ };
1705
+ const answer = snifferAnswer(ran.stdout);
1706
+ if (answer) return {
1707
+ envVars: answer.envVars || [],
1708
+ optionalEnvVars: answer.optionalEnvVars || [],
1709
+ error: answer.error ? new Error(answer.error) : void 0
1710
+ };
1711
+ return {
1712
+ envVars: [],
1713
+ optionalEnvVars: [],
1714
+ error: /* @__PURE__ */ new Error(`Failed to sniff entry file (exit code ${ran.code}): ${ran.stderr || ran.stdout || "No output"}`)
1715
+ };
1716
+ }
1717
+ /**
1718
+ * Sniff route files by loading constructs and calling getEnvironment().
1719
+ *
1720
+ * Route-based apps have endpoints, functions, crons, and subscribers that
1721
+ * use services. Each service's register() method accesses environment variables.
1722
+ *
1723
+ * This runs in a subprocess with tsx loader to properly handle TypeScript
1724
+ * compilation and path alias resolution (e.g., `src/...` imports).
1725
+ *
1726
+ * @param routes - Glob pattern(s) for route files
1727
+ * @param appPath - The app's path relative to workspace (e.g., 'apps/api')
1728
+ * @param workspacePath - Absolute path to workspace root
1729
+ * @returns EntrySniffResult with env vars and optional error
1730
+ */
1731
+ async function sniffRouteFiles(routes, appPath, workspacePath, run = {}) {
1732
+ const fullAppPath = (0, node_path.resolve)(workspacePath, appPath);
1733
+ const workerPath = resolveSnifferFile("sniffer-routes-worker");
1734
+ const pattern = (Array.isArray(routes) ? routes : [routes])[0];
1735
+ if (!pattern) return {
1736
+ envVars: [],
1737
+ optionalEnvVars: [],
1738
+ error: /* @__PURE__ */ new Error("No route patterns provided")
1739
+ };
1740
+ const ran = await runSniffer(run, workspacePath, fullAppPath, require_discover.nodeWithTsx(workerPath, [fullAppPath, pattern]));
1741
+ if ("error" in ran) return {
1742
+ envVars: [],
1743
+ optionalEnvVars: [],
1744
+ error: ran.error
1745
+ };
1746
+ if (ran.stderr) ran.stderr.split("\n").filter((line) => line.trim()).forEach((line) => require_discover.output.warn(line));
1747
+ const answer = snifferAnswer(ran.stdout);
1748
+ if (answer) return {
1749
+ envVars: answer.envVars || [],
1750
+ optionalEnvVars: answer.optionalEnvVars || [],
1751
+ error: answer.error ? new Error(answer.error) : void 0
1752
+ };
1753
+ return {
1754
+ envVars: [],
1755
+ optionalEnvVars: [],
1756
+ error: /* @__PURE__ */ new Error(`Failed to sniff route files (exit code ${ran.code}): ${ran.stderr || ran.stdout || "No output"}`)
1757
+ };
1758
+ }
1759
+ /**
1760
+ * Run the SnifferEnvironmentParser on an envParser module to detect
1761
+ * which environment variables it accesses.
1762
+ *
1763
+ * In a subprocess, like the entry and route sniffers: the module is the
1764
+ * project's code, and it was imported into the deploy itself before — with
1765
+ * every credential the deploy held in reach. Fire-and-forget rejections are
1766
+ * collected there with the shared `sniffWithFireAndForget`.
1767
+ *
1768
+ * @param envParserPath - The envParser config (e.g., './src/config/env#envParser')
1769
+ * @param appPath - The app's path relative to workspace
1770
+ * @param workspacePath - Absolute path to workspace root
1771
+ * @returns SniffResult with env vars and any errors encountered
1772
+ */
1773
+ async function sniffEnvParser(envParserPath, appPath, workspacePath, run = {}) {
1774
+ const [modulePath, exportName = "default"] = envParserPath.split("#");
1775
+ if (!modulePath) return {
1776
+ envVars: [],
1777
+ optionalEnvVars: [],
1778
+ unhandledRejections: []
1779
+ };
1780
+ const appRoot = (0, node_path.resolve)(workspacePath, appPath);
1781
+ const fullPath = (0, node_path.resolve)(appRoot, modulePath);
1782
+ const workerPath = resolveSnifferFile("sniffer-envparser-worker");
1783
+ const ran = await runSniffer(run, workspacePath, appRoot, require_discover.nodeWithTsx(workerPath, [fullPath, exportName]));
1784
+ if ("error" in ran) return {
1785
+ envVars: [],
1786
+ optionalEnvVars: [],
1787
+ unhandledRejections: [],
1788
+ error: ran.error
1789
+ };
1790
+ const answer = snifferAnswer(ran.stdout);
1791
+ if (!answer) return {
1792
+ envVars: [],
1793
+ optionalEnvVars: [],
1794
+ unhandledRejections: [],
1795
+ error: /* @__PURE__ */ new Error(`Failed to sniff envParser (exit code ${ran.code}): ${ran.stderr || ran.stdout || "No output"}`)
1796
+ };
1797
+ for (const warning of answer.warnings ?? []) require_discover.output.warn(warning);
1798
+ return {
1799
+ envVars: answer.envVars ?? [],
1800
+ optionalEnvVars: answer.optionalEnvVars ?? [],
1801
+ unhandledRejections: (answer.unhandledRejections ?? []).map((message) => new Error(message)),
1802
+ ...answer.error ? { error: new Error(answer.error) } : {}
1803
+ };
1804
+ }
1805
+ /**
1806
+ * Sniff environment requirements for multiple apps.
1807
+ *
1808
+ * @param apps - Map of app name to app config
1809
+ * @param workspacePath - Absolute path to workspace root
1810
+ * @param options - Optional configuration for sniffing behavior
1811
+ * @returns Map of app name to sniffed environment
1812
+ */
1813
+ async function sniffAllApps(apps, workspacePath, options = {}) {
1814
+ const results = /* @__PURE__ */ new Map();
1815
+ for (const [appName, app] of Object.entries(apps)) {
1816
+ const sniffed = await sniffAppEnvironment(app, appName, workspacePath, options);
1817
+ results.set(appName, sniffed);
1818
+ }
1819
+ return results;
1820
+ }
1821
+ //#endregion
1822
+ Object.defineProperty(exports, "DEFAULT_DEPLOYMENT_TIMEOUT_MS", {
1823
+ enumerable: true,
1824
+ get: function() {
1825
+ return DEFAULT_DEPLOYMENT_TIMEOUT_MS;
1826
+ }
1827
+ });
1828
+ Object.defineProperty(exports, "DeploymentFailed", {
1829
+ enumerable: true,
1830
+ get: function() {
1831
+ return DeploymentFailed;
1832
+ }
1833
+ });
1834
+ Object.defineProperty(exports, "DeploymentTimedOut", {
1835
+ enumerable: true,
1836
+ get: function() {
1837
+ return DeploymentTimedOut;
1838
+ }
1839
+ });
1840
+ Object.defineProperty(exports, "DocumentStateStore", {
1841
+ enumerable: true,
1842
+ get: function() {
1843
+ return DocumentStateStore;
1844
+ }
1845
+ });
1846
+ Object.defineProperty(exports, "DokployApi", {
1847
+ enumerable: true,
1848
+ get: function() {
1849
+ return DokployApi;
1850
+ }
1851
+ });
1852
+ Object.defineProperty(exports, "DokployApiError", {
1853
+ enumerable: true,
1854
+ get: function() {
1855
+ return DokployApiError;
1856
+ }
1857
+ });
1858
+ Object.defineProperty(exports, "LocalStateInCi", {
1859
+ enumerable: true,
1860
+ get: function() {
1861
+ return LocalStateInCi;
1862
+ }
1863
+ });
1864
+ Object.defineProperty(exports, "StageStateMissing", {
1865
+ enumerable: true,
1866
+ get: function() {
1867
+ return StageStateMissing;
1868
+ }
1869
+ });
1870
+ Object.defineProperty(exports, "StateLocked", {
1871
+ enumerable: true,
1872
+ get: function() {
1873
+ return StateLocked;
1874
+ }
1875
+ });
1876
+ Object.defineProperty(exports, "StateRejectedBySsm", {
1877
+ enumerable: true,
1878
+ get: function() {
1879
+ return StateRejectedBySsm;
1880
+ }
1881
+ });
1882
+ Object.defineProperty(exports, "StateStoreBusy", {
1883
+ enumerable: true,
1884
+ get: function() {
1885
+ return StateStoreBusy;
1886
+ }
1887
+ });
1888
+ Object.defineProperty(exports, "StateStoreWithoutLocking", {
1889
+ enumerable: true,
1890
+ get: function() {
1891
+ return StateStoreWithoutLocking;
1892
+ }
1893
+ });
1894
+ Object.defineProperty(exports, "StateVersionConflict", {
1895
+ enumerable: true,
1896
+ get: function() {
1897
+ return StateVersionConflict;
1898
+ }
1899
+ });
1900
+ Object.defineProperty(exports, "appendHistory", {
1901
+ enumerable: true,
1902
+ get: function() {
1903
+ return appendHistory;
1904
+ }
1905
+ });
1906
+ Object.defineProperty(exports, "assertStateOutlivesRun", {
1907
+ enumerable: true,
1908
+ get: function() {
1909
+ return assertStateOutlivesRun;
1910
+ }
1911
+ });
1912
+ Object.defineProperty(exports, "assertStateRoom", {
1913
+ enumerable: true,
1914
+ get: function() {
1915
+ return assertStateRoom;
1916
+ }
1917
+ });
1918
+ Object.defineProperty(exports, "compressBody", {
1919
+ enumerable: true,
1920
+ get: function() {
1921
+ return compressBody;
1922
+ }
1923
+ });
1924
+ Object.defineProperty(exports, "contentVersion", {
1925
+ enumerable: true,
1926
+ get: function() {
1927
+ return contentVersion;
1928
+ }
1929
+ });
1930
+ Object.defineProperty(exports, "createStateStore", {
1931
+ enumerable: true,
1932
+ get: function() {
1933
+ return createStateStore;
1934
+ }
1935
+ });
1936
+ Object.defineProperty(exports, "decompressBody", {
1937
+ enumerable: true,
1938
+ get: function() {
1939
+ return decompressBody;
1940
+ }
1941
+ });
1942
+ Object.defineProperty(exports, "dokploy_api_exports", {
1943
+ enumerable: true,
1944
+ get: function() {
1945
+ return dokploy_api_exports;
1946
+ }
1947
+ });
1948
+ Object.defineProperty(exports, "encryptSecrets", {
1949
+ enumerable: true,
1950
+ get: function() {
1951
+ return encryptSecrets;
1952
+ }
1953
+ });
1954
+ Object.defineProperty(exports, "encryption_exports", {
1955
+ enumerable: true,
1956
+ get: function() {
1957
+ return encryption_exports;
1958
+ }
1959
+ });
1960
+ Object.defineProperty(exports, "eventError", {
1961
+ enumerable: true,
1962
+ get: function() {
1963
+ return eventError;
1964
+ }
1965
+ });
1966
+ Object.defineProperty(exports, "keyFingerprint", {
1967
+ enumerable: true,
1968
+ get: function() {
1969
+ return keyFingerprint;
1970
+ }
1971
+ });
1972
+ Object.defineProperty(exports, "newLockHolder", {
1973
+ enumerable: true,
1974
+ get: function() {
1975
+ return newLockHolder;
1976
+ }
1977
+ });
1978
+ Object.defineProperty(exports, "sniffAllApps", {
1979
+ enumerable: true,
1980
+ get: function() {
1981
+ return sniffAllApps;
1982
+ }
1983
+ });
1984
+ Object.defineProperty(exports, "sniffAppEnvironment", {
1985
+ enumerable: true,
1986
+ get: function() {
1987
+ return sniffAppEnvironment;
1988
+ }
1989
+ });
1990
+ Object.defineProperty(exports, "upgradeV2State", {
1991
+ enumerable: true,
1992
+ get: function() {
1993
+ return upgradeV2State;
1994
+ }
1995
+ });
1996
+
1997
+ //# sourceMappingURL=sniffer-CFOmQQit.cjs.map