@geekmidas/cli 10.0.0-alpha.1 → 10.0.0-alpha.100

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