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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (430) hide show
  1. package/README.md +313 -380
  2. package/bin/adjacent-tsconfig.mjs +46 -8
  3. package/bin/gkm.mjs +11 -3
  4. package/bin/owning-tsconfig-jsx-register.mjs +18 -0
  5. package/bin/owning-tsconfig-jsx.mjs +108 -0
  6. package/dist/EndpointGenerator-B99OGzbO.mjs +1035 -0
  7. package/dist/EndpointGenerator-B99OGzbO.mjs.map +1 -0
  8. package/dist/EndpointGenerator-De0lknKD.cjs +1094 -0
  9. package/dist/EndpointGenerator-De0lknKD.cjs.map +1 -0
  10. package/dist/GoDaddyProvider-D10Le3VX.mjs +388 -0
  11. package/dist/GoDaddyProvider-D10Le3VX.mjs.map +1 -0
  12. package/dist/GoDaddyProvider-DTfa47i3.cjs +388 -0
  13. package/dist/GoDaddyProvider-DTfa47i3.cjs.map +1 -0
  14. package/dist/{HostingerProvider-BY26bWwB.mjs → HostingerProvider-Cjh_2Ml6.mjs} +11 -6
  15. package/dist/HostingerProvider-Cjh_2Ml6.mjs.map +1 -0
  16. package/dist/{HostingerProvider-BZFGYYVA.cjs → HostingerProvider-OdQmKXE3.cjs} +11 -6
  17. package/dist/HostingerProvider-OdQmKXE3.cjs.map +1 -0
  18. package/dist/LegacyStateStore-C5c_zS4h.mjs +124 -0
  19. package/dist/LegacyStateStore-C5c_zS4h.mjs.map +1 -0
  20. package/dist/LegacyStateStore-CZSBR6ar.cjs +124 -0
  21. package/dist/LegacyStateStore-CZSBR6ar.cjs.map +1 -0
  22. package/dist/LocalStateStore-Ba0Y6q5C.mjs +167 -0
  23. package/dist/LocalStateStore-Ba0Y6q5C.mjs.map +1 -0
  24. package/dist/LocalStateStore-CgQtQix2.cjs +178 -0
  25. package/dist/LocalStateStore-CgQtQix2.cjs.map +1 -0
  26. package/dist/OpenApiTsGenerator-DMLzN-LU.cjs +541 -0
  27. package/dist/OpenApiTsGenerator-DMLzN-LU.cjs.map +1 -0
  28. package/dist/OpenApiTsGenerator-DNUCgkkx.mjs +536 -0
  29. package/dist/OpenApiTsGenerator-DNUCgkkx.mjs.map +1 -0
  30. package/dist/{Route53Provider-DVILBsvV.cjs → Route53Provider-Bllus2NR.cjs} +2 -2
  31. package/dist/Route53Provider-Bllus2NR.cjs.map +1 -0
  32. package/dist/{Route53Provider-Cvj40A8I.mjs → Route53Provider-QXxjkZO1.mjs} +2 -2
  33. package/dist/Route53Provider-QXxjkZO1.mjs.map +1 -0
  34. package/dist/S3StateStore-00mB2AG4.mjs +223 -0
  35. package/dist/S3StateStore-00mB2AG4.mjs.map +1 -0
  36. package/dist/S3StateStore-C6amZI39.cjs +222 -0
  37. package/dist/S3StateStore-C6amZI39.cjs.map +1 -0
  38. package/dist/SSMStateStore-CkYqOAzW.mjs +205 -0
  39. package/dist/SSMStateStore-CkYqOAzW.mjs.map +1 -0
  40. package/dist/SSMStateStore-Cnn5fHCg.cjs +204 -0
  41. package/dist/SSMStateStore-Cnn5fHCg.cjs.map +1 -0
  42. package/dist/SubscriberGenerator-0ruEmYXj.mjs +646 -0
  43. package/dist/SubscriberGenerator-0ruEmYXj.mjs.map +1 -0
  44. package/dist/SubscriberGenerator-CPjbWEOI.cjs +687 -0
  45. package/dist/SubscriberGenerator-CPjbWEOI.cjs.map +1 -0
  46. package/dist/add-CdMInvmN.cjs +719 -0
  47. package/dist/add-CdMInvmN.cjs.map +1 -0
  48. package/dist/add-DZSU5Tcc.mjs +717 -0
  49. package/dist/add-DZSU5Tcc.mjs.map +1 -0
  50. package/dist/appPorts-BoXMwolc.mjs +249 -0
  51. package/dist/appPorts-BoXMwolc.mjs.map +1 -0
  52. package/dist/appPorts-IW-OZmRi.cjs +296 -0
  53. package/dist/appPorts-IW-OZmRi.cjs.map +1 -0
  54. package/dist/aws-8QQ8n-t6.mjs +89 -0
  55. package/dist/aws-8QQ8n-t6.mjs.map +1 -0
  56. package/dist/aws-DY9NqQIT.cjs +100 -0
  57. package/dist/aws-DY9NqQIT.cjs.map +1 -0
  58. package/dist/awsStore-Bx5nCFnS.mjs +121 -0
  59. package/dist/awsStore-Bx5nCFnS.mjs.map +1 -0
  60. package/dist/awsStore-u3ehhMoY.cjs +138 -0
  61. package/dist/awsStore-u3ehhMoY.cjs.map +1 -0
  62. package/dist/{backup-provisioner-DIVCbfee.mjs → backup-provisioner-C8DnCmxK.mjs} +2 -2
  63. package/dist/backup-provisioner-C8DnCmxK.mjs.map +1 -0
  64. package/dist/{backup-provisioner-BmhIO_Yr.cjs → backup-provisioner-oDEsPj02.cjs} +2 -2
  65. package/dist/backup-provisioner-oDEsPj02.cjs.map +1 -0
  66. package/dist/backups/runner.cjs +519 -0
  67. package/dist/backups/runner.cjs.map +1 -0
  68. package/dist/backups/runner.d.cts +102 -0
  69. package/dist/backups/runner.d.cts.map +1 -0
  70. package/dist/backups/runner.d.mts +102 -0
  71. package/dist/backups/runner.d.mts.map +1 -0
  72. package/dist/backups/runner.mjs +506 -0
  73. package/dist/backups/runner.mjs.map +1 -0
  74. package/dist/{bundler-BodTL4kf.mjs → bundler-BzDMJbx8.mjs} +32 -11
  75. package/dist/bundler-BzDMJbx8.mjs.map +1 -0
  76. package/dist/{bundler-BeNDZdHQ.cjs → bundler-GKF4xpYI.cjs} +32 -11
  77. package/dist/bundler-GKF4xpYI.cjs.map +1 -0
  78. package/dist/cli-Ct6PQtc7.cjs +71 -0
  79. package/dist/cli-Ct6PQtc7.cjs.map +1 -0
  80. package/dist/cli-DXeLFtpA.mjs +71 -0
  81. package/dist/cli-DXeLFtpA.mjs.map +1 -0
  82. package/dist/compose-BfLDidYU.cjs +3977 -0
  83. package/dist/compose-BfLDidYU.cjs.map +1 -0
  84. package/dist/compose-CnanpQBB.mjs +3834 -0
  85. package/dist/compose-CnanpQBB.mjs.map +1 -0
  86. package/dist/config-DPsCfNpR.d.mts +268 -0
  87. package/dist/config-DPsCfNpR.d.mts.map +1 -0
  88. package/dist/config-azErNJSd.d.cts +268 -0
  89. package/dist/config-azErNJSd.d.cts.map +1 -0
  90. package/dist/config.cjs +420 -9
  91. package/dist/config.cjs.map +1 -0
  92. package/dist/config.d.cts +4 -117
  93. package/dist/config.d.mts +4 -117
  94. package/dist/config.mjs +406 -3
  95. package/dist/config.mjs.map +1 -0
  96. package/dist/credentialSchemas-CM0rxWmS.cjs +272 -0
  97. package/dist/credentialSchemas-CM0rxWmS.cjs.map +1 -0
  98. package/dist/credentialSchemas-DPOGqOrU.mjs +237 -0
  99. package/dist/credentialSchemas-DPOGqOrU.mjs.map +1 -0
  100. package/dist/credentials-D7XJypNd.cjs +520 -0
  101. package/dist/credentials-D7XJypNd.cjs.map +1 -0
  102. package/dist/credentials-DpfnUvIR.mjs +395 -0
  103. package/dist/credentials-DpfnUvIR.mjs.map +1 -0
  104. package/dist/databases-Db48ZIXL.mjs +588 -0
  105. package/dist/databases-Db48ZIXL.mjs.map +1 -0
  106. package/dist/databases-P824RTnx.cjs +703 -0
  107. package/dist/databases-P824RTnx.cjs.map +1 -0
  108. package/dist/define-6poNqm5O.mjs +106 -0
  109. package/dist/define-6poNqm5O.mjs.map +1 -0
  110. package/dist/define-crmMcXFS.cjs +153 -0
  111. package/dist/define-crmMcXFS.cjs.map +1 -0
  112. package/dist/deploy/public.cjs +211 -0
  113. package/dist/deploy/public.cjs.map +1 -0
  114. package/dist/deploy/public.d.cts +652 -0
  115. package/dist/deploy/public.d.cts.map +1 -0
  116. package/dist/deploy/public.d.mts +652 -0
  117. package/dist/deploy/public.d.mts.map +1 -0
  118. package/dist/deploy/public.mjs +144 -0
  119. package/dist/deploy/public.mjs.map +1 -0
  120. package/dist/deploy/sniffer-envparser-worker.cjs +54 -0
  121. package/dist/deploy/sniffer-envparser-worker.cjs.map +1 -0
  122. package/dist/deploy/sniffer-envparser-worker.d.cts +1 -0
  123. package/dist/deploy/sniffer-envparser-worker.d.mts +1 -0
  124. package/dist/deploy/sniffer-envparser-worker.mjs +55 -0
  125. package/dist/deploy/sniffer-envparser-worker.mjs.map +1 -0
  126. package/dist/deploy/sniffer-hooks.cjs +1 -1
  127. package/dist/deploy/sniffer-hooks.mjs +1 -1
  128. package/dist/deploy/sniffer-loader.cjs +2 -2
  129. package/dist/deploy/sniffer-loader.mjs +1 -1
  130. package/dist/deploy/sniffer-routes-worker.cjs +2 -2
  131. package/dist/deploy/sniffer-routes-worker.mjs +2 -2
  132. package/dist/deploy-B35L6CMr.mjs +3439 -0
  133. package/dist/deploy-B35L6CMr.mjs.map +1 -0
  134. package/dist/deploy-zFe_W4WS.cjs +3494 -0
  135. package/dist/deploy-zFe_W4WS.cjs.map +1 -0
  136. package/dist/derive-BtGidITm.cjs +161 -0
  137. package/dist/derive-BtGidITm.cjs.map +1 -0
  138. package/dist/derive-Dew0QoGe.mjs +150 -0
  139. package/dist/derive-Dew0QoGe.mjs.map +1 -0
  140. package/dist/discover-DEOspD9M.cjs +796 -0
  141. package/dist/discover-DEOspD9M.cjs.map +1 -0
  142. package/dist/discover-DOhYSKY_.mjs +693 -0
  143. package/dist/discover-DOhYSKY_.mjs.map +1 -0
  144. package/dist/dokploy-BGJxcEh0.cjs +38 -0
  145. package/dist/dokploy-BGJxcEh0.cjs.map +1 -0
  146. package/dist/dokploy-sDTohVj5.mjs +38 -0
  147. package/dist/dokploy-sDTohVj5.mjs.map +1 -0
  148. package/dist/drivers-C47nm-wB.cjs +311 -0
  149. package/dist/drivers-C47nm-wB.cjs.map +1 -0
  150. package/dist/drivers-CDjpjakg.mjs +252 -0
  151. package/dist/drivers-CDjpjakg.mjs.map +1 -0
  152. package/dist/eas-Bxb9pymo.mjs +334 -0
  153. package/dist/eas-Bxb9pymo.mjs.map +1 -0
  154. package/dist/eas-DogHTOxl.cjs +337 -0
  155. package/dist/eas-DogHTOxl.cjs.map +1 -0
  156. package/dist/{emit-BdoPFjZf.cjs → emit-CYloptRS.cjs} +44 -54
  157. package/dist/emit-CYloptRS.cjs.map +1 -0
  158. package/dist/{emit-Bzq7JsMP.mjs → emit-CiJGdy_f.mjs} +45 -43
  159. package/dist/emit-CiJGdy_f.mjs.map +1 -0
  160. package/dist/encryption-BZk_sxC-.mjs +89 -0
  161. package/dist/encryption-BZk_sxC-.mjs.map +1 -0
  162. package/dist/encryption-DRXgL9Lh.cjs +90 -0
  163. package/dist/encryption-DRXgL9Lh.cjs.map +1 -0
  164. package/dist/engine-BuPhWFVm.cjs +3328 -0
  165. package/dist/engine-BuPhWFVm.cjs.map +1 -0
  166. package/dist/engine-uQmNnvNQ.mjs +3215 -0
  167. package/dist/engine-uQmNnvNQ.mjs.map +1 -0
  168. package/dist/errors-D8Gwp5kU.mjs +23 -0
  169. package/dist/errors-D8Gwp5kU.mjs.map +1 -0
  170. package/dist/errors-DMC4Umsb.cjs +34 -0
  171. package/dist/errors-DMC4Umsb.cjs.map +1 -0
  172. package/dist/github-BCRbDSQa.cjs +901 -0
  173. package/dist/github-BCRbDSQa.cjs.map +1 -0
  174. package/dist/github-YknZQnYF.mjs +900 -0
  175. package/dist/github-YknZQnYF.mjs.map +1 -0
  176. package/dist/googlePlay-B_2dIDSO.mjs +931 -0
  177. package/dist/googlePlay-B_2dIDSO.mjs.map +1 -0
  178. package/dist/googlePlay-Cm2uipeZ.cjs +931 -0
  179. package/dist/googlePlay-Cm2uipeZ.cjs.map +1 -0
  180. package/dist/identity-CBXr4wNi.mjs +129 -0
  181. package/dist/identity-CBXr4wNi.mjs.map +1 -0
  182. package/dist/identity-CbLfgQNT.cjs +182 -0
  183. package/dist/identity-CbLfgQNT.cjs.map +1 -0
  184. package/dist/{index-D-iAVHx-.d.cts → index-D-gNc445.d.cts} +39 -15
  185. package/dist/index-D-gNc445.d.cts.map +1 -0
  186. package/dist/{index-Cd-qeOam.d.mts → index-Ur-ZIDYC.d.mts} +39 -15
  187. package/dist/index-Ur-ZIDYC.d.mts.map +1 -0
  188. package/dist/index.cjs +13461 -12270
  189. package/dist/index.cjs.map +1 -1
  190. package/dist/index.mjs +13486 -12293
  191. package/dist/index.mjs.map +1 -1
  192. package/dist/local-B7Zv1NoA.mjs +224 -0
  193. package/dist/local-B7Zv1NoA.mjs.map +1 -0
  194. package/dist/local-OPC9BCZt.cjs +241 -0
  195. package/dist/local-OPC9BCZt.cjs.map +1 -0
  196. package/dist/migrate-BIl4kLb1.cjs +181 -0
  197. package/dist/migrate-BIl4kLb1.cjs.map +1 -0
  198. package/dist/migrate-Co3UnkrE.cjs +273 -0
  199. package/dist/migrate-Co3UnkrE.cjs.map +1 -0
  200. package/dist/migrate-D71REG0N.mjs +268 -0
  201. package/dist/migrate-D71REG0N.mjs.map +1 -0
  202. package/dist/migrate-zqsyod5I.mjs +181 -0
  203. package/dist/migrate-zqsyod5I.mjs.map +1 -0
  204. package/dist/openapi.cjs +214 -7
  205. package/dist/openapi.cjs.map +1 -0
  206. package/dist/openapi.d.cts +32 -8
  207. package/dist/openapi.d.cts.map +1 -1
  208. package/dist/openapi.d.mts +32 -8
  209. package/dist/openapi.d.mts.map +1 -1
  210. package/dist/openapi.mjs +209 -2
  211. package/dist/openapi.mjs.map +1 -0
  212. package/dist/projectBucket-BBbQ1lHF.cjs +263 -0
  213. package/dist/projectBucket-BBbQ1lHF.cjs.map +1 -0
  214. package/dist/projectBucket-C_DN4WzF.mjs +222 -0
  215. package/dist/projectBucket-C_DN4WzF.mjs.map +1 -0
  216. package/dist/provider-BqpjG9QM.cjs +57 -0
  217. package/dist/provider-BqpjG9QM.cjs.map +1 -0
  218. package/dist/provider-CEOKk8NS.mjs +46 -0
  219. package/dist/provider-CEOKk8NS.mjs.map +1 -0
  220. package/dist/publish-BUnnuLl_.cjs +124 -0
  221. package/dist/publish-BUnnuLl_.cjs.map +1 -0
  222. package/dist/publish-BtmLOhV9.mjs +123 -0
  223. package/dist/publish-BtmLOhV9.mjs.map +1 -0
  224. package/dist/ready-BwtLriAF.mjs +375 -0
  225. package/dist/ready-BwtLriAF.mjs.map +1 -0
  226. package/dist/ready-Cj4pI0dw.cjs +404 -0
  227. package/dist/ready-Cj4pI0dw.cjs.map +1 -0
  228. package/dist/reconcile/public.cjs +2 -4
  229. package/dist/reconcile/public.d.cts +8 -67
  230. package/dist/reconcile/public.d.cts.map +1 -1
  231. package/dist/reconcile/public.d.mts +8 -67
  232. package/dist/reconcile/public.d.mts.map +1 -1
  233. package/dist/reconcile/public.mjs +3 -3
  234. package/dist/{reconcile-DhQ00DpU.mjs → reconcile--I7V4Klj.mjs} +2 -2
  235. package/dist/{reconcile-DhQ00DpU.mjs.map → reconcile--I7V4Klj.mjs.map} +1 -1
  236. package/dist/{reconcile-Dd2iyILf.cjs → reconcile-CuCQBa5-.cjs} +3 -3
  237. package/dist/{reconcile-Dd2iyILf.cjs.map → reconcile-CuCQBa5-.cjs.map} +1 -1
  238. package/dist/resolve-B1zK9f8_.mjs +263 -0
  239. package/dist/resolve-B1zK9f8_.mjs.map +1 -0
  240. package/dist/resolve-BVVSf27Y.cjs +316 -0
  241. package/dist/resolve-BVVSf27Y.cjs.map +1 -0
  242. package/dist/rollback-CAPWtOm3.mjs +136 -0
  243. package/dist/rollback-CAPWtOm3.mjs.map +1 -0
  244. package/dist/rollback-hV8Kbbg_.cjs +165 -0
  245. package/dist/rollback-hV8Kbbg_.cjs.map +1 -0
  246. package/dist/runtime-C0okGPpK.d.cts +82 -0
  247. package/dist/runtime-C0okGPpK.d.cts.map +1 -0
  248. package/dist/runtime-DfwIeO8f.d.mts +82 -0
  249. package/dist/runtime-DfwIeO8f.d.mts.map +1 -0
  250. package/dist/s3-CkERdmxm.mjs +215 -0
  251. package/dist/s3-CkERdmxm.mjs.map +1 -0
  252. package/dist/s3-xJtWm6WN.cjs +215 -0
  253. package/dist/s3-xJtWm6WN.cjs.map +1 -0
  254. package/dist/sandbox/config-worker.cjs +43 -0
  255. package/dist/sandbox/config-worker.cjs.map +1 -0
  256. package/dist/sandbox/config-worker.d.cts +1 -0
  257. package/dist/sandbox/config-worker.d.mts +1 -0
  258. package/dist/sandbox/config-worker.mjs +44 -0
  259. package/dist/sandbox/config-worker.mjs.map +1 -0
  260. package/dist/sandbox/credentials-worker.cjs +54 -0
  261. package/dist/sandbox/credentials-worker.cjs.map +1 -0
  262. package/dist/sandbox/credentials-worker.d.cts +1 -0
  263. package/dist/sandbox/credentials-worker.d.mts +1 -0
  264. package/dist/sandbox/credentials-worker.mjs +55 -0
  265. package/dist/sandbox/credentials-worker.mjs.map +1 -0
  266. package/dist/sandbox/discover-worker.cjs +50 -0
  267. package/dist/sandbox/discover-worker.cjs.map +1 -0
  268. package/dist/sandbox/discover-worker.d.cts +1 -0
  269. package/dist/sandbox/discover-worker.d.mts +1 -0
  270. package/dist/sandbox/discover-worker.mjs +51 -0
  271. package/dist/sandbox/discover-worker.mjs.map +1 -0
  272. package/dist/sandbox/migrate-worker.cjs +76 -0
  273. package/dist/sandbox/migrate-worker.cjs.map +1 -0
  274. package/dist/sandbox/migrate-worker.d.cts +1 -0
  275. package/dist/sandbox/migrate-worker.d.mts +1 -0
  276. package/dist/sandbox/migrate-worker.mjs +77 -0
  277. package/dist/sandbox/migrate-worker.mjs.map +1 -0
  278. package/dist/sandbox-CHv3OYXg.cjs +165 -0
  279. package/dist/sandbox-CHv3OYXg.cjs.map +1 -0
  280. package/dist/sandbox-CbVB7uOD.mjs +118 -0
  281. package/dist/sandbox-CbVB7uOD.mjs.map +1 -0
  282. package/dist/{workspace-mFpI_ky_.cjs → schemas-BCwKKA42.mjs} +399 -1162
  283. package/dist/schemas-BCwKKA42.mjs.map +1 -0
  284. package/dist/{workspace-CgwmXEtc.mjs → schemas-BQ_v0lEX.cjs} +487 -971
  285. package/dist/schemas-BQ_v0lEX.cjs.map +1 -0
  286. package/dist/secretsManager-CQORubp9.mjs +97 -0
  287. package/dist/secretsManager-CQORubp9.mjs.map +1 -0
  288. package/dist/secretsManager-RAGcEDX1.cjs +108 -0
  289. package/dist/secretsManager-RAGcEDX1.cjs.map +1 -0
  290. package/dist/seeds-CNPdk_2f.mjs +9198 -0
  291. package/dist/seeds-CNPdk_2f.mjs.map +1 -0
  292. package/dist/seeds-MR13eS-F.cjs +10303 -0
  293. package/dist/seeds-MR13eS-F.cjs.map +1 -0
  294. package/dist/serverSetup-9kFFmA86.cjs +651 -0
  295. package/dist/serverSetup-9kFFmA86.cjs.map +1 -0
  296. package/dist/serverSetup-DgAERQ5s.mjs +651 -0
  297. package/dist/serverSetup-DgAERQ5s.mjs.map +1 -0
  298. package/dist/sniffer-Biw5SE1V.cjs +1998 -0
  299. package/dist/sniffer-Biw5SE1V.cjs.map +1 -0
  300. package/dist/sniffer-KS_EcbAk.mjs +1825 -0
  301. package/dist/sniffer-KS_EcbAk.mjs.map +1 -0
  302. package/dist/snsSubscriptions-Bl3CChIH.mjs +1472 -0
  303. package/dist/snsSubscriptions-Bl3CChIH.mjs.map +1 -0
  304. package/dist/snsSubscriptions-CQFfrCJf.cjs +1695 -0
  305. package/dist/snsSubscriptions-CQFfrCJf.cjs.map +1 -0
  306. package/dist/sst-DmVJRu5l.cjs +463 -0
  307. package/dist/sst-DmVJRu5l.cjs.map +1 -0
  308. package/dist/sst-fop6uZ25.mjs +440 -0
  309. package/dist/sst-fop6uZ25.mjs.map +1 -0
  310. package/dist/stage-BIKAMxNc.cjs +313 -0
  311. package/dist/stage-BIKAMxNc.cjs.map +1 -0
  312. package/dist/stage-tIMFTQtj.mjs +302 -0
  313. package/dist/stage-tIMFTQtj.mjs.map +1 -0
  314. package/dist/stages-C9uSkohw.cjs +190 -0
  315. package/dist/stages-C9uSkohw.cjs.map +1 -0
  316. package/dist/stages-DhmbURs_.mjs +190 -0
  317. package/dist/stages-DhmbURs_.mjs.map +1 -0
  318. package/dist/target/public.cjs +15 -0
  319. package/dist/target/public.d.cts +28 -0
  320. package/dist/target/public.d.cts.map +1 -0
  321. package/dist/target/public.d.mts +28 -0
  322. package/dist/target/public.d.mts.map +1 -0
  323. package/dist/target/public.mjs +4 -0
  324. package/dist/terminal-CebFDhWQ.mjs +85 -0
  325. package/dist/terminal-CebFDhWQ.mjs.map +1 -0
  326. package/dist/terminal-DBwedwSS.cjs +85 -0
  327. package/dist/terminal-DBwedwSS.cjs.map +1 -0
  328. package/dist/{types-BGo5TaNE.d.mts → types-Cjnqw1ta.d.cts} +2199 -462
  329. package/dist/types-Cjnqw1ta.d.cts.map +1 -0
  330. package/dist/{types-C5ZNpUad.d.cts → types-xBx-07__.d.mts} +2197 -462
  331. package/dist/types-xBx-07__.d.mts.map +1 -0
  332. package/dist/utils-D2Nk1Nv2.cjs +205 -0
  333. package/dist/utils-D2Nk1Nv2.cjs.map +1 -0
  334. package/dist/utils-D_fxUqvU.mjs +156 -0
  335. package/dist/utils-D_fxUqvU.mjs.map +1 -0
  336. package/dist/vitest.cjs +65 -0
  337. package/dist/vitest.cjs.map +1 -0
  338. package/dist/vitest.d.cts +29 -0
  339. package/dist/vitest.d.cts.map +1 -0
  340. package/dist/vitest.d.mts +29 -0
  341. package/dist/vitest.d.mts.map +1 -0
  342. package/dist/vitest.mjs +65 -0
  343. package/dist/vitest.mjs.map +1 -0
  344. package/dist/workerRuntime-BXfhbe13.cjs +108 -0
  345. package/dist/workerRuntime-BXfhbe13.cjs.map +1 -0
  346. package/dist/workerRuntime-CsOyBRx2.mjs +79 -0
  347. package/dist/workerRuntime-CsOyBRx2.mjs.map +1 -0
  348. package/dist/workspace/index.cjs +6 -2
  349. package/dist/workspace/index.d.cts +3 -3
  350. package/dist/workspace/index.d.mts +3 -3
  351. package/dist/workspace/index.mjs +2 -2
  352. package/dist/workspace-CjSfjfMK.mjs +2396 -0
  353. package/dist/workspace-CjSfjfMK.mjs.map +1 -0
  354. package/dist/workspace-DImrdet4.cjs +2808 -0
  355. package/dist/workspace-DImrdet4.cjs.map +1 -0
  356. package/package.json +55 -20
  357. package/dist/HostingerProvider-BY26bWwB.mjs.map +0 -1
  358. package/dist/HostingerProvider-BZFGYYVA.cjs.map +0 -1
  359. package/dist/LocalStateProvider-7HR6SS2t.cjs +0 -48
  360. package/dist/LocalStateProvider-7HR6SS2t.cjs.map +0 -1
  361. package/dist/LocalStateProvider-D7QyJoLM.mjs +0 -48
  362. package/dist/LocalStateProvider-D7QyJoLM.mjs.map +0 -1
  363. package/dist/Route53Provider-Cvj40A8I.mjs.map +0 -1
  364. package/dist/Route53Provider-DVILBsvV.cjs.map +0 -1
  365. package/dist/SSMStateProvider-B0Hu1MKZ.mjs +0 -75
  366. package/dist/SSMStateProvider-B0Hu1MKZ.mjs.map +0 -1
  367. package/dist/SSMStateProvider-VrQ-yeqd.cjs +0 -74
  368. package/dist/SSMStateProvider-VrQ-yeqd.cjs.map +0 -1
  369. package/dist/backup-provisioner-BmhIO_Yr.cjs.map +0 -1
  370. package/dist/backup-provisioner-DIVCbfee.mjs.map +0 -1
  371. package/dist/bundler-BeNDZdHQ.cjs.map +0 -1
  372. package/dist/bundler-BodTL4kf.mjs.map +0 -1
  373. package/dist/config-Q1rvKHvw.cjs +0 -467
  374. package/dist/config-Q1rvKHvw.cjs.map +0 -1
  375. package/dist/config-pqGD3hF9.mjs +0 -414
  376. package/dist/config-pqGD3hF9.mjs.map +0 -1
  377. package/dist/config.d.cts.map +0 -1
  378. package/dist/config.d.mts.map +0 -1
  379. package/dist/credentials-BekkKtY_.mjs +0 -2780
  380. package/dist/credentials-BekkKtY_.mjs.map +0 -1
  381. package/dist/credentials-Q6F0uqJq.cjs +0 -2917
  382. package/dist/credentials-Q6F0uqJq.cjs.map +0 -1
  383. package/dist/discover-BERGFg8v.cjs +0 -288
  384. package/dist/discover-BERGFg8v.cjs.map +0 -1
  385. package/dist/discover-CK-n3w6b.mjs +0 -244
  386. package/dist/discover-CK-n3w6b.mjs.map +0 -1
  387. package/dist/emit-BdoPFjZf.cjs.map +0 -1
  388. package/dist/emit-Bzq7JsMP.mjs.map +0 -1
  389. package/dist/fullstack-secrets-BET8gqwK.mjs +0 -81
  390. package/dist/fullstack-secrets-BET8gqwK.mjs.map +0 -1
  391. package/dist/fullstack-secrets-DXsWO-5m.cjs +0 -92
  392. package/dist/fullstack-secrets-DXsWO-5m.cjs.map +0 -1
  393. package/dist/generator-LfZU7NlU.mjs +0 -247
  394. package/dist/generator-LfZU7NlU.mjs.map +0 -1
  395. package/dist/generator-Wdfp0jCS.cjs +0 -282
  396. package/dist/generator-Wdfp0jCS.cjs.map +0 -1
  397. package/dist/github-BfflNPVe.cjs +0 -203
  398. package/dist/github-BfflNPVe.cjs.map +0 -1
  399. package/dist/github-CRwnxKmD.mjs +0 -203
  400. package/dist/github-CRwnxKmD.mjs.map +0 -1
  401. package/dist/index-Cd-qeOam.d.mts.map +0 -1
  402. package/dist/index-D-iAVHx-.d.cts.map +0 -1
  403. package/dist/keystore-B4PRlbgE.mjs +0 -81
  404. package/dist/keystore-B4PRlbgE.mjs.map +0 -1
  405. package/dist/keystore-DgGRj2Yy.cjs +0 -98
  406. package/dist/keystore-DgGRj2Yy.cjs.map +0 -1
  407. package/dist/openapi-Dcbme-Us.cjs +0 -2038
  408. package/dist/openapi-Dcbme-Us.cjs.map +0 -1
  409. package/dist/openapi-react-query.cjs +0 -158
  410. package/dist/openapi-react-query.cjs.map +0 -1
  411. package/dist/openapi-react-query.d.cts +0 -9
  412. package/dist/openapi-react-query.d.cts.map +0 -1
  413. package/dist/openapi-react-query.d.mts +0 -9
  414. package/dist/openapi-react-query.d.mts.map +0 -1
  415. package/dist/openapi-react-query.mjs +0 -158
  416. package/dist/openapi-react-query.mjs.map +0 -1
  417. package/dist/openapi-vy4JzhUv.mjs +0 -1991
  418. package/dist/openapi-vy4JzhUv.mjs.map +0 -1
  419. package/dist/storage-C-30BD1e.cjs +0 -272
  420. package/dist/storage-C-30BD1e.cjs.map +0 -1
  421. package/dist/storage-P_b3w7uj.mjs +0 -231
  422. package/dist/storage-P_b3w7uj.mjs.map +0 -1
  423. package/dist/sync-B3xxXtJT.mjs +0 -88
  424. package/dist/sync-B3xxXtJT.mjs.map +0 -1
  425. package/dist/sync-D7uTIIEi.cjs +0 -111
  426. package/dist/sync-D7uTIIEi.cjs.map +0 -1
  427. package/dist/types-BGo5TaNE.d.mts.map +0 -1
  428. package/dist/types-C5ZNpUad.d.cts.map +0 -1
  429. package/dist/workspace-CgwmXEtc.mjs.map +0 -1
  430. package/dist/workspace-mFpI_ky_.cjs.map +0 -1
@@ -0,0 +1,124 @@
1
+ import { c as currentActor } from "./seeds-CNPdk_2f.mjs";
2
+ import { T as upgradeV2State, _ as appendHistory, d as StageStateMissing, g as StateVersionConflict, h as StateStoreWithoutLocking, w as newLockHolder, x as contentVersion } from "./sniffer-KS_EcbAk.mjs";
3
+ //#region src/deploy/LegacyStateStore.ts
4
+ /**
5
+ * A custom `StateProvider` as a `StateStore`.
6
+ *
7
+ * A provider only reads and writes whole states, so this adapter can check a
8
+ * version before it writes but cannot make the check and the write one step,
9
+ * and cannot lock. It warns once (`StateStoreWithoutLocking`) the first time
10
+ * a caller relies on either, and otherwise behaves as a store. Resource
11
+ * records travel inside the state the provider stores, under `resources`.
12
+ */
13
+ var LegacyStateStore = class {
14
+ provider;
15
+ warned = false;
16
+ /** The operation of the lock each stage is held for. */
17
+ held = /* @__PURE__ */ new Map();
18
+ logged = /* @__PURE__ */ new Map();
19
+ warn;
20
+ constructor(provider, options = {}) {
21
+ this.provider = provider;
22
+ this.warn = options.warn ?? ((warning) => process.emitWarning(warning));
23
+ }
24
+ async lock(stage, options) {
25
+ this.warnOnce();
26
+ const holder = newLockHolder(options);
27
+ this.held.set(stage, holder);
28
+ return {
29
+ stage,
30
+ holder,
31
+ release: async () => {
32
+ if (this.held.get(stage)?.id === holder.id) this.held.delete(stage);
33
+ }
34
+ };
35
+ }
36
+ async forceUnlock(_stage) {
37
+ return null;
38
+ }
39
+ async read(stage) {
40
+ const stored = await this.provider.read(stage);
41
+ if (!stored) return null;
42
+ const { resources: storedResources = {}, history = [], ...storedState } = stored;
43
+ const { state, resources } = storedState.provider === "dokploy" ? upgradeV2State(storedState, storedResources) : {
44
+ state: storedState,
45
+ resources: storedResources
46
+ };
47
+ return {
48
+ state,
49
+ resources,
50
+ history,
51
+ version: versionOf(stored)
52
+ };
53
+ }
54
+ async write(stage, state, options) {
55
+ const current = await this.read(stage);
56
+ this.check(stage, options.expectedVersion, current);
57
+ return this.put(stage, current, {
58
+ ...state,
59
+ resources: current?.resources ?? {}
60
+ });
61
+ }
62
+ async putResource(stage, record, options) {
63
+ const current = await this.current(stage, options);
64
+ return this.put(stage, current, {
65
+ ...current.state,
66
+ resources: {
67
+ ...current.resources,
68
+ [record.key]: {
69
+ ...record,
70
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
71
+ updatedBy: currentActor()
72
+ }
73
+ }
74
+ });
75
+ }
76
+ async deleteResource(stage, key, options) {
77
+ const current = await this.current(stage, options);
78
+ const { [key]: _removed, ...resources } = current.resources;
79
+ return this.put(stage, current, {
80
+ ...current.state,
81
+ resources
82
+ });
83
+ }
84
+ async current(stage, options) {
85
+ const current = await this.read(stage);
86
+ if (options?.expectedVersion !== void 0) this.check(stage, options.expectedVersion, current);
87
+ if (!current) throw new StageStateMissing(stage);
88
+ return current;
89
+ }
90
+ check(stage, expected, current) {
91
+ const actual = current?.version ?? null;
92
+ if (actual !== expected) throw new StateVersionConflict(stage, expected, actual);
93
+ }
94
+ async put(stage, current, state) {
95
+ this.warnOnce();
96
+ const holder = this.held.get(stage);
97
+ const operation = holder?.operation ?? "write";
98
+ const history = current?.history ?? [];
99
+ const sameRun = holder !== void 0 && this.logged.get(stage) === holder.id && history[0]?.operation === operation;
100
+ if (holder) this.logged.set(stage, holder.id);
101
+ const serial = (history[0]?.serial ?? 0) + 1;
102
+ state.history = appendHistory(history, {
103
+ serial,
104
+ at: (/* @__PURE__ */ new Date()).toISOString(),
105
+ by: currentActor(),
106
+ operation
107
+ }, sameRun);
108
+ await this.provider.write(stage, state);
109
+ return versionOf(state);
110
+ }
111
+ warnOnce() {
112
+ if (this.warned) return;
113
+ this.warned = true;
114
+ this.warn(new StateStoreWithoutLocking(this.provider.constructor?.name || "anonymous"));
115
+ }
116
+ };
117
+ /** Key order is the provider's, so this is stable for a given stored state. */
118
+ function versionOf(state) {
119
+ return contentVersion(JSON.stringify(state));
120
+ }
121
+ //#endregion
122
+ export { LegacyStateStore };
123
+
124
+ //# sourceMappingURL=LegacyStateStore-C5c_zS4h.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LegacyStateStore-C5c_zS4h.mjs","names":[],"sources":["../src/deploy/LegacyStateStore.ts"],"sourcesContent":["/**\n * A custom `StateProvider` as a `StateStore`.\n *\n * A provider only reads and writes whole states, so this adapter can check a\n * version before it writes but cannot make the check and the write one step,\n * and cannot lock. It warns once (`StateStoreWithoutLocking`) the first time\n * a caller relies on either, and otherwise behaves as a store. Resource\n * records travel inside the state the provider stores, under `resources`.\n */\n\nimport { currentActor } from './actor';\nimport type { StateProvider } from './StateProvider';\nimport {\n\tappendHistory,\n\tcontentVersion,\n\ttype HistoryEntry,\n\ttype LockHolder,\n\ttype LockOptions,\n\tnewLockHolder,\n\ttype ResourceInput,\n\ttype ResourceRecord,\n\ttype ResourceWriteOptions,\n\tStageStateMissing,\n\ttype StateLock,\n\ttype StateStore,\n\tStateStoreWithoutLocking,\n\ttype StateVersion,\n\tStateVersionConflict,\n\ttype StoredStageState,\n\tupgradeV2State,\n\ttype WriteOptions,\n} from './StateStore';\nimport type { StageState } from './state';\n\ntype ProviderState = StageState & {\n\tresources?: Record<string, ResourceRecord>;\n\thistory?: HistoryEntry[];\n};\n\nexport interface LegacyStateStoreOptions {\n\t/** Where the warning goes; `process.emitWarning` by default. */\n\twarn?: (warning: StateStoreWithoutLocking) => void;\n}\n\nexport class LegacyStateStore implements StateStore {\n\tprivate warned = false;\n\t/** The operation of the lock each stage is held for. */\n\tprivate readonly held = new Map<string, LockHolder>();\n\tprivate readonly logged = new Map<string, string>();\n\tprivate readonly warn: (warning: StateStoreWithoutLocking) => void;\n\n\tconstructor(\n\t\treadonly provider: StateProvider,\n\t\toptions: LegacyStateStoreOptions = {},\n\t) {\n\t\tthis.warn = options.warn ?? ((warning) => process.emitWarning(warning));\n\t}\n\n\tasync lock(stage: string, options?: LockOptions): Promise<StateLock> {\n\t\tthis.warnOnce();\n\t\tconst holder = newLockHolder(options);\n\t\tthis.held.set(stage, holder);\n\t\treturn {\n\t\t\tstage,\n\t\t\tholder,\n\t\t\trelease: async () => {\n\t\t\t\tif (this.held.get(stage)?.id === holder.id) this.held.delete(stage);\n\t\t\t},\n\t\t};\n\t}\n\n\tasync forceUnlock(_stage: string): Promise<LockHolder | null> {\n\t\treturn null;\n\t}\n\n\tasync read(stage: string): Promise<StoredStageState | null> {\n\t\tconst stored = (await this.provider.read(stage)) as ProviderState | null;\n\t\tif (!stored) return null;\n\t\tconst {\n\t\t\tresources: storedResources = {},\n\t\t\thistory = [],\n\t\t\t...storedState\n\t\t} = stored;\n\t\tconst { state, resources } =\n\t\t\tstoredState.provider === 'dokploy'\n\t\t\t\t? upgradeV2State(storedState, storedResources)\n\t\t\t\t: { state: storedState as StageState, resources: storedResources };\n\t\treturn { state, resources, history, version: versionOf(stored) };\n\t}\n\n\tasync write(\n\t\tstage: string,\n\t\tstate: StageState,\n\t\toptions: WriteOptions,\n\t): Promise<StateVersion> {\n\t\tconst current = await this.read(stage);\n\t\tthis.check(stage, options.expectedVersion, current);\n\t\treturn this.put(stage, current, {\n\t\t\t...state,\n\t\t\tresources: current?.resources ?? {},\n\t\t});\n\t}\n\n\tasync putResource(\n\t\tstage: string,\n\t\trecord: ResourceInput,\n\t\toptions?: ResourceWriteOptions,\n\t): Promise<StateVersion> {\n\t\tconst current = await this.current(stage, options);\n\t\treturn this.put(stage, current, {\n\t\t\t...current.state,\n\t\t\tresources: {\n\t\t\t\t...current.resources,\n\t\t\t\t[record.key]: {\n\t\t\t\t\t...record,\n\t\t\t\t\tupdatedAt: new Date().toISOString(),\n\t\t\t\t\tupdatedBy: currentActor(),\n\t\t\t\t},\n\t\t\t},\n\t\t});\n\t}\n\n\tasync deleteResource(\n\t\tstage: string,\n\t\tkey: string,\n\t\toptions?: ResourceWriteOptions,\n\t): Promise<StateVersion> {\n\t\tconst current = await this.current(stage, options);\n\t\tconst { [key]: _removed, ...resources } = current.resources;\n\t\treturn this.put(stage, current, { ...current.state, resources });\n\t}\n\n\tprivate async current(\n\t\tstage: string,\n\t\toptions?: ResourceWriteOptions,\n\t): Promise<StoredStageState> {\n\t\tconst current = await this.read(stage);\n\t\tif (options?.expectedVersion !== undefined) {\n\t\t\tthis.check(stage, options.expectedVersion, current);\n\t\t}\n\t\tif (!current) throw new StageStateMissing(stage);\n\t\treturn current;\n\t}\n\n\tprivate check(\n\t\tstage: string,\n\t\texpected: StateVersion | null,\n\t\tcurrent: StoredStageState | null,\n\t): void {\n\t\tconst actual = current?.version ?? null;\n\t\tif (actual !== expected) {\n\t\t\tthrow new StateVersionConflict(stage, expected, actual);\n\t\t}\n\t}\n\n\tprivate async put(\n\t\tstage: string,\n\t\tcurrent: StoredStageState | null,\n\t\tstate: ProviderState,\n\t): Promise<StateVersion> {\n\t\tthis.warnOnce();\n\t\tconst holder = this.held.get(stage);\n\t\tconst operation = holder?.operation ?? 'write';\n\t\tconst history = current?.history ?? [];\n\t\tconst sameRun =\n\t\t\tholder !== undefined &&\n\t\t\tthis.logged.get(stage) === holder.id &&\n\t\t\thistory[0]?.operation === operation;\n\t\tif (holder) this.logged.set(stage, holder.id);\n\t\tconst serial = (history[0]?.serial ?? 0) + 1;\n\t\tstate.history = appendHistory(\n\t\t\thistory,\n\t\t\t{ serial, at: new Date().toISOString(), by: currentActor(), operation },\n\t\t\tsameRun,\n\t\t);\n\t\t// Providers stamp `lastDeployedAt` on the object they are given, so the\n\t\t// version is taken after the write, from what was actually stored.\n\t\tawait this.provider.write(stage, state);\n\t\treturn versionOf(state);\n\t}\n\n\tprivate warnOnce(): void {\n\t\tif (this.warned) return;\n\t\tthis.warned = true;\n\t\tthis.warn(\n\t\t\tnew StateStoreWithoutLocking(\n\t\t\t\tthis.provider.constructor?.name || 'anonymous',\n\t\t\t),\n\t\t);\n\t}\n}\n\n/** Key order is the provider's, so this is stable for a given stored state. */\nfunction versionOf(state: ProviderState): StateVersion {\n\treturn contentVersion(JSON.stringify(state));\n}\n"],"mappings":";;;;;;;;;;;;AA4CA,IAAa,mBAAb,MAAoD;CAQzC;CAPV,SAAiB;;CAEjB,uBAAwB,IAAI,IAAwB;CACpD,yBAA0B,IAAI,IAAoB;CAClD;CAEA,YACC,UACA,UAAmC,CAAC,GACnC;EAFQ,KAAA,WAAA;EAGT,KAAK,OAAO,QAAQ,UAAU,YAAY,QAAQ,YAAY,OAAO;CACtE;CAEA,MAAM,KAAK,OAAe,SAA2C;EACpE,KAAK,SAAS;EACd,MAAM,SAAS,cAAc,OAAO;EACpC,KAAK,KAAK,IAAI,OAAO,MAAM;EAC3B,OAAO;GACN;GACA;GACA,SAAS,YAAY;IACpB,IAAI,KAAK,KAAK,IAAI,KAAK,CAAC,EAAE,OAAO,OAAO,IAAI,KAAK,KAAK,OAAO,KAAK;GACnE;EACD;CACD;CAEA,MAAM,YAAY,QAA4C;EAC7D,OAAO;CACR;CAEA,MAAM,KAAK,OAAiD;EAC3D,MAAM,SAAU,MAAM,KAAK,SAAS,KAAK,KAAK;EAC9C,IAAI,CAAC,QAAQ,OAAO;EACpB,MAAM,EACL,WAAW,kBAAkB,CAAC,GAC9B,UAAU,CAAC,GACX,GAAG,gBACA;EACJ,MAAM,EAAE,OAAO,cACd,YAAY,aAAa,YACtB,eAAe,aAAa,eAAe,IAC3C;GAAE,OAAO;GAA2B,WAAW;EAAgB;EACnE,OAAO;GAAE;GAAO;GAAW;GAAS,SAAS,UAAU,MAAM;EAAE;CAChE;CAEA,MAAM,MACL,OACA,OACA,SACwB;EACxB,MAAM,UAAU,MAAM,KAAK,KAAK,KAAK;EACrC,KAAK,MAAM,OAAO,QAAQ,iBAAiB,OAAO;EAClD,OAAO,KAAK,IAAI,OAAO,SAAS;GAC/B,GAAG;GACH,WAA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KAAK;EAC3C,MAAM,UAAU,cACf,SACA;GAAE;GAAQ,qBAAI,IAAI,KAAK,EAAA,CAAE,YAAY;GAAG,IAAI,aAAa;GAAG;EAAU,GACtE,OACD;EAGA,MAAM,KAAK,SAAS,MAAM,OAAO,KAAK;EACtC,OAAO,UAAU,KAAK;CACvB;CAEA,WAAyB;EACxB,IAAI,KAAK,QAAQ;EACjB,KAAK,SAAS;EACd,KAAK,KACJ,IAAI,yBACH,KAAK,SAAS,aAAa,QAAQ,WACpC,CACD;CACD;AACD;;AAGA,SAAS,UAAU,OAAoC;CACtD,OAAO,eAAe,KAAK,UAAU,KAAK,CAAC;AAC5C"}
@@ -0,0 +1,124 @@
1
+ const require_seeds = require("./seeds-MR13eS-F.cjs");
2
+ const require_sniffer = require("./sniffer-Biw5SE1V.cjs");
3
+ //#region src/deploy/LegacyStateStore.ts
4
+ /**
5
+ * A custom `StateProvider` as a `StateStore`.
6
+ *
7
+ * A provider only reads and writes whole states, so this adapter can check a
8
+ * version before it writes but cannot make the check and the write one step,
9
+ * and cannot lock. It warns once (`StateStoreWithoutLocking`) the first time
10
+ * a caller relies on either, and otherwise behaves as a store. Resource
11
+ * records travel inside the state the provider stores, under `resources`.
12
+ */
13
+ var LegacyStateStore = class {
14
+ provider;
15
+ warned = false;
16
+ /** The operation of the lock each stage is held for. */
17
+ held = /* @__PURE__ */ new Map();
18
+ logged = /* @__PURE__ */ new Map();
19
+ warn;
20
+ constructor(provider, options = {}) {
21
+ this.provider = provider;
22
+ this.warn = options.warn ?? ((warning) => process.emitWarning(warning));
23
+ }
24
+ async lock(stage, options) {
25
+ this.warnOnce();
26
+ const holder = require_sniffer.newLockHolder(options);
27
+ this.held.set(stage, holder);
28
+ return {
29
+ stage,
30
+ holder,
31
+ release: async () => {
32
+ if (this.held.get(stage)?.id === holder.id) this.held.delete(stage);
33
+ }
34
+ };
35
+ }
36
+ async forceUnlock(_stage) {
37
+ return null;
38
+ }
39
+ async read(stage) {
40
+ const stored = await this.provider.read(stage);
41
+ if (!stored) return null;
42
+ const { resources: storedResources = {}, history = [], ...storedState } = stored;
43
+ const { state, resources } = storedState.provider === "dokploy" ? require_sniffer.upgradeV2State(storedState, storedResources) : {
44
+ state: storedState,
45
+ resources: storedResources
46
+ };
47
+ return {
48
+ state,
49
+ resources,
50
+ history,
51
+ version: versionOf(stored)
52
+ };
53
+ }
54
+ async write(stage, state, options) {
55
+ const current = await this.read(stage);
56
+ this.check(stage, options.expectedVersion, current);
57
+ return this.put(stage, current, {
58
+ ...state,
59
+ resources: current?.resources ?? {}
60
+ });
61
+ }
62
+ async putResource(stage, record, options) {
63
+ const current = await this.current(stage, options);
64
+ return this.put(stage, current, {
65
+ ...current.state,
66
+ resources: {
67
+ ...current.resources,
68
+ [record.key]: {
69
+ ...record,
70
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
71
+ updatedBy: require_seeds.currentActor()
72
+ }
73
+ }
74
+ });
75
+ }
76
+ async deleteResource(stage, key, options) {
77
+ const current = await this.current(stage, options);
78
+ const { [key]: _removed, ...resources } = current.resources;
79
+ return this.put(stage, current, {
80
+ ...current.state,
81
+ resources
82
+ });
83
+ }
84
+ async current(stage, options) {
85
+ const current = await this.read(stage);
86
+ if (options?.expectedVersion !== void 0) this.check(stage, options.expectedVersion, current);
87
+ if (!current) throw new require_sniffer.StageStateMissing(stage);
88
+ return current;
89
+ }
90
+ check(stage, expected, current) {
91
+ const actual = current?.version ?? null;
92
+ if (actual !== expected) throw new require_sniffer.StateVersionConflict(stage, expected, actual);
93
+ }
94
+ async put(stage, current, state) {
95
+ this.warnOnce();
96
+ const holder = this.held.get(stage);
97
+ const operation = holder?.operation ?? "write";
98
+ const history = current?.history ?? [];
99
+ const sameRun = holder !== void 0 && this.logged.get(stage) === holder.id && history[0]?.operation === operation;
100
+ if (holder) this.logged.set(stage, holder.id);
101
+ const serial = (history[0]?.serial ?? 0) + 1;
102
+ state.history = require_sniffer.appendHistory(history, {
103
+ serial,
104
+ at: (/* @__PURE__ */ new Date()).toISOString(),
105
+ by: require_seeds.currentActor(),
106
+ operation
107
+ }, sameRun);
108
+ await this.provider.write(stage, state);
109
+ return versionOf(state);
110
+ }
111
+ warnOnce() {
112
+ if (this.warned) return;
113
+ this.warned = true;
114
+ this.warn(new require_sniffer.StateStoreWithoutLocking(this.provider.constructor?.name || "anonymous"));
115
+ }
116
+ };
117
+ /** Key order is the provider's, so this is stable for a given stored state. */
118
+ function versionOf(state) {
119
+ return require_sniffer.contentVersion(JSON.stringify(state));
120
+ }
121
+ //#endregion
122
+ exports.LegacyStateStore = LegacyStateStore;
123
+
124
+ //# sourceMappingURL=LegacyStateStore-CZSBR6ar.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LegacyStateStore-CZSBR6ar.cjs","names":["newLockHolder","upgradeV2State","currentActor","StageStateMissing","StateVersionConflict","appendHistory","StateStoreWithoutLocking","contentVersion"],"sources":["../src/deploy/LegacyStateStore.ts"],"sourcesContent":["/**\n * A custom `StateProvider` as a `StateStore`.\n *\n * A provider only reads and writes whole states, so this adapter can check a\n * version before it writes but cannot make the check and the write one step,\n * and cannot lock. It warns once (`StateStoreWithoutLocking`) the first time\n * a caller relies on either, and otherwise behaves as a store. Resource\n * records travel inside the state the provider stores, under `resources`.\n */\n\nimport { currentActor } from './actor';\nimport type { StateProvider } from './StateProvider';\nimport {\n\tappendHistory,\n\tcontentVersion,\n\ttype HistoryEntry,\n\ttype LockHolder,\n\ttype LockOptions,\n\tnewLockHolder,\n\ttype ResourceInput,\n\ttype ResourceRecord,\n\ttype ResourceWriteOptions,\n\tStageStateMissing,\n\ttype StateLock,\n\ttype StateStore,\n\tStateStoreWithoutLocking,\n\ttype StateVersion,\n\tStateVersionConflict,\n\ttype StoredStageState,\n\tupgradeV2State,\n\ttype WriteOptions,\n} from './StateStore';\nimport type { StageState } from './state';\n\ntype ProviderState = StageState & {\n\tresources?: Record<string, ResourceRecord>;\n\thistory?: HistoryEntry[];\n};\n\nexport interface LegacyStateStoreOptions {\n\t/** Where the warning goes; `process.emitWarning` by default. */\n\twarn?: (warning: StateStoreWithoutLocking) => void;\n}\n\nexport class LegacyStateStore implements StateStore {\n\tprivate warned = false;\n\t/** The operation of the lock each stage is held for. */\n\tprivate readonly held = new Map<string, LockHolder>();\n\tprivate readonly logged = new Map<string, string>();\n\tprivate readonly warn: (warning: StateStoreWithoutLocking) => void;\n\n\tconstructor(\n\t\treadonly provider: StateProvider,\n\t\toptions: LegacyStateStoreOptions = {},\n\t) {\n\t\tthis.warn = options.warn ?? ((warning) => process.emitWarning(warning));\n\t}\n\n\tasync lock(stage: string, options?: LockOptions): Promise<StateLock> {\n\t\tthis.warnOnce();\n\t\tconst holder = newLockHolder(options);\n\t\tthis.held.set(stage, holder);\n\t\treturn {\n\t\t\tstage,\n\t\t\tholder,\n\t\t\trelease: async () => {\n\t\t\t\tif (this.held.get(stage)?.id === holder.id) this.held.delete(stage);\n\t\t\t},\n\t\t};\n\t}\n\n\tasync forceUnlock(_stage: string): Promise<LockHolder | null> {\n\t\treturn null;\n\t}\n\n\tasync read(stage: string): Promise<StoredStageState | null> {\n\t\tconst stored = (await this.provider.read(stage)) as ProviderState | null;\n\t\tif (!stored) return null;\n\t\tconst {\n\t\t\tresources: storedResources = {},\n\t\t\thistory = [],\n\t\t\t...storedState\n\t\t} = stored;\n\t\tconst { state, resources } =\n\t\t\tstoredState.provider === 'dokploy'\n\t\t\t\t? upgradeV2State(storedState, storedResources)\n\t\t\t\t: { state: storedState as StageState, resources: storedResources };\n\t\treturn { state, resources, history, version: versionOf(stored) };\n\t}\n\n\tasync write(\n\t\tstage: string,\n\t\tstate: StageState,\n\t\toptions: WriteOptions,\n\t): Promise<StateVersion> {\n\t\tconst current = await this.read(stage);\n\t\tthis.check(stage, options.expectedVersion, current);\n\t\treturn this.put(stage, current, {\n\t\t\t...state,\n\t\t\tresources: current?.resources ?? {},\n\t\t});\n\t}\n\n\tasync putResource(\n\t\tstage: string,\n\t\trecord: ResourceInput,\n\t\toptions?: ResourceWriteOptions,\n\t): Promise<StateVersion> {\n\t\tconst current = await this.current(stage, options);\n\t\treturn this.put(stage, current, {\n\t\t\t...current.state,\n\t\t\tresources: {\n\t\t\t\t...current.resources,\n\t\t\t\t[record.key]: {\n\t\t\t\t\t...record,\n\t\t\t\t\tupdatedAt: new Date().toISOString(),\n\t\t\t\t\tupdatedBy: currentActor(),\n\t\t\t\t},\n\t\t\t},\n\t\t});\n\t}\n\n\tasync deleteResource(\n\t\tstage: string,\n\t\tkey: string,\n\t\toptions?: ResourceWriteOptions,\n\t): Promise<StateVersion> {\n\t\tconst current = await this.current(stage, options);\n\t\tconst { [key]: _removed, ...resources } = current.resources;\n\t\treturn this.put(stage, current, { ...current.state, resources });\n\t}\n\n\tprivate async current(\n\t\tstage: string,\n\t\toptions?: ResourceWriteOptions,\n\t): Promise<StoredStageState> {\n\t\tconst current = await this.read(stage);\n\t\tif (options?.expectedVersion !== undefined) {\n\t\t\tthis.check(stage, options.expectedVersion, current);\n\t\t}\n\t\tif (!current) throw new StageStateMissing(stage);\n\t\treturn current;\n\t}\n\n\tprivate check(\n\t\tstage: string,\n\t\texpected: StateVersion | null,\n\t\tcurrent: StoredStageState | null,\n\t): void {\n\t\tconst actual = current?.version ?? null;\n\t\tif (actual !== expected) {\n\t\t\tthrow new StateVersionConflict(stage, expected, actual);\n\t\t}\n\t}\n\n\tprivate async put(\n\t\tstage: string,\n\t\tcurrent: StoredStageState | null,\n\t\tstate: ProviderState,\n\t): Promise<StateVersion> {\n\t\tthis.warnOnce();\n\t\tconst holder = this.held.get(stage);\n\t\tconst operation = holder?.operation ?? 'write';\n\t\tconst history = current?.history ?? [];\n\t\tconst sameRun =\n\t\t\tholder !== undefined &&\n\t\t\tthis.logged.get(stage) === holder.id &&\n\t\t\thistory[0]?.operation === operation;\n\t\tif (holder) this.logged.set(stage, holder.id);\n\t\tconst serial = (history[0]?.serial ?? 0) + 1;\n\t\tstate.history = appendHistory(\n\t\t\thistory,\n\t\t\t{ serial, at: new Date().toISOString(), by: currentActor(), operation },\n\t\t\tsameRun,\n\t\t);\n\t\t// Providers stamp `lastDeployedAt` on the object they are given, so the\n\t\t// version is taken after the write, from what was actually stored.\n\t\tawait this.provider.write(stage, state);\n\t\treturn versionOf(state);\n\t}\n\n\tprivate warnOnce(): void {\n\t\tif (this.warned) return;\n\t\tthis.warned = true;\n\t\tthis.warn(\n\t\t\tnew StateStoreWithoutLocking(\n\t\t\t\tthis.provider.constructor?.name || 'anonymous',\n\t\t\t),\n\t\t);\n\t}\n}\n\n/** Key order is the provider's, so this is stable for a given stored state. */\nfunction versionOf(state: ProviderState): StateVersion {\n\treturn contentVersion(JSON.stringify(state));\n}\n"],"mappings":";;;;;;;;;;;;AA4CA,IAAa,mBAAb,MAAoD;CAQzC;CAPV,SAAiB;;CAEjB,uBAAwB,IAAI,IAAwB;CACpD,yBAA0B,IAAI,IAAoB;CAClD;CAEA,YACC,UACA,UAAmC,CAAC,GACnC;EAFQ,KAAA,WAAA;EAGT,KAAK,OAAO,QAAQ,UAAU,YAAY,QAAQ,YAAY,OAAO;CACtE;CAEA,MAAM,KAAK,OAAe,SAA2C;EACpE,KAAK,SAAS;EACd,MAAM,SAASA,gBAAAA,cAAc,OAAO;EACpC,KAAK,KAAK,IAAI,OAAO,MAAM;EAC3B,OAAO;GACN;GACA;GACA,SAAS,YAAY;IACpB,IAAI,KAAK,KAAK,IAAI,KAAK,CAAC,EAAE,OAAO,OAAO,IAAI,KAAK,KAAK,OAAO,KAAK;GACnE;EACD;CACD;CAEA,MAAM,YAAY,QAA4C;EAC7D,OAAO;CACR;CAEA,MAAM,KAAK,OAAiD;EAC3D,MAAM,SAAU,MAAM,KAAK,SAAS,KAAK,KAAK;EAC9C,IAAI,CAAC,QAAQ,OAAO;EACpB,MAAM,EACL,WAAW,kBAAkB,CAAC,GAC9B,UAAU,CAAC,GACX,GAAG,gBACA;EACJ,MAAM,EAAE,OAAO,cACd,YAAY,aAAa,YACtBC,gB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,OACwB;EACxB,KAAK,SAAS;EACd,MAAM,SAAS,KAAK,KAAK,IAAI,KAAK;EAClC,MAAM,YAAY,QAAQ,aAAa;EACvC,MAAM,UAAU,SAAS,WAAW,CAAC;EACrC,MAAM,UACL,WAAW,KAAA,KACX,KAAK,OAAO,IAAI,KAAK,MAAM,OAAO,MAClC,QAAQ,EAAE,EAAE,cAAc;EAC3B,IAAI,QAAQ,KAAK,OAAO,IAAI,OAAO,OAAO,EAAE;EAC5C,MAAM,UAAU,QAAQ,EAAE,EAAE,UAAU,KAAK;EAC3C,MAAM,UAAUC,gBAAAA,cACf,SACA;GAAE;GAAQ,qBAAI,IAAI,KAAK,EAAA,CAAE,YAAY;GAAG,IAAIH,cAAAA,aAAa;GAAG;EAAU,GACtE,OACD;EAGA,MAAM,KAAK,SAAS,MAAM,OAAO,KAAK;EACtC,OAAO,UAAU,KAAK;CACvB;CAEA,WAAyB;EACxB,IAAI,KAAK,QAAQ;EACjB,KAAK,SAAS;EACd,KAAK,KACJ,IAAII,gBAAAA,yBACH,KAAK,SAAS,aAAa,QAAQ,WACpC,CACD;CACD;AACD;;AAGA,SAAS,UAAU,OAAoC;CACtD,OAAOC,gBAAAA,eAAe,KAAK,UAAU,KAAK,CAAC;AAC5C"}
@@ -0,0 +1,167 @@
1
+ import { t as __exportAll } from "./rolldown-runtime-BhDjJH2R.mjs";
2
+ import { f as StateLocked, g as StateVersionConflict, l as DocumentStateStore, m as StateStoreBusy, x as contentVersion } from "./sniffer-KS_EcbAk.mjs";
3
+ import { join } from "node:path";
4
+ import { link, mkdir, open, readFile, rename, rm, stat, unlink, writeFile } from "node:fs/promises";
5
+ import { randomUUID } from "node:crypto";
6
+ //#region src/deploy/LocalStateStore.ts
7
+ /**
8
+ * Local filesystem state store.
9
+ *
10
+ * `.gkm/deploy-<stage>.json` holds the state, `.gkm/deploy-<stage>.lock` the
11
+ * lock. Every file is mode 0600: state holds database passwords and IAM keys.
12
+ */
13
+ var LocalStateStore_exports = /* @__PURE__ */ __exportAll({ LocalStateStore: () => LocalStateStore });
14
+ const FILE_MODE = 384;
15
+ /** How long a write waits for another process's write to finish. */
16
+ const MUTEX_TIMEOUT_MS = 5e3;
17
+ /**
18
+ * A write holds the mutex for milliseconds, so one this old was left by a
19
+ * process that died mid-write and is safe to take over.
20
+ */
21
+ const MUTEX_STALE_MS = 3e4;
22
+ function isCode(error, code) {
23
+ return error?.code === code;
24
+ }
25
+ var LocalStateStore = class extends DocumentStateStore {
26
+ workspaceRoot;
27
+ constructor(workspaceRoot) {
28
+ super();
29
+ this.workspaceRoot = workspaceRoot;
30
+ }
31
+ get dir() {
32
+ return join(this.workspaceRoot, ".gkm");
33
+ }
34
+ statePath(stage) {
35
+ return join(this.dir, `deploy-${stage}.json`);
36
+ }
37
+ lockPath(stage) {
38
+ return join(this.dir, `deploy-${stage}.lock`);
39
+ }
40
+ backupPath(stage) {
41
+ return join(this.dir, `deploy-${stage}.v1.json`);
42
+ }
43
+ mutexPath(stage) {
44
+ return join(this.dir, `deploy-${stage}.json.mutex`);
45
+ }
46
+ location(stage) {
47
+ return this.statePath(stage);
48
+ }
49
+ async readRaw(stage) {
50
+ try {
51
+ const body = await readFile(this.statePath(stage), "utf-8");
52
+ return {
53
+ body,
54
+ version: contentVersion(body)
55
+ };
56
+ } catch (error) {
57
+ if (isCode(error, "ENOENT")) return null;
58
+ throw error;
59
+ }
60
+ }
61
+ async writeRaw(stage, body, expectedVersion) {
62
+ await this.ensureDir();
63
+ return this.withMutex(stage, async () => {
64
+ const actual = (await this.readRaw(stage))?.version ?? null;
65
+ if (actual !== expectedVersion) throw new StateVersionConflict(stage, expectedVersion, actual);
66
+ const target = this.statePath(stage);
67
+ const temp = `${target}.${randomUUID()}.tmp`;
68
+ try {
69
+ const handle = await open(temp, "wx", FILE_MODE);
70
+ try {
71
+ await handle.writeFile(body);
72
+ await handle.sync();
73
+ } finally {
74
+ await handle.close();
75
+ }
76
+ await rename(temp, target);
77
+ } catch (error) {
78
+ await rm(temp, { force: true });
79
+ throw error;
80
+ }
81
+ return contentVersion(body);
82
+ });
83
+ }
84
+ async writeV1Backup(stage, body) {
85
+ try {
86
+ await writeFile(this.backupPath(stage), body, {
87
+ flag: "wx",
88
+ mode: FILE_MODE
89
+ });
90
+ } catch (error) {
91
+ if (!isCode(error, "EEXIST")) throw error;
92
+ }
93
+ }
94
+ async createLock(stage, holder) {
95
+ await this.ensureDir();
96
+ const lock = this.lockPath(stage);
97
+ const temp = `${lock}.${randomUUID()}.tmp`;
98
+ await writeFile(temp, JSON.stringify(holder, null, 2), {
99
+ flag: "wx",
100
+ mode: FILE_MODE
101
+ });
102
+ try {
103
+ await link(temp, lock);
104
+ } catch (error) {
105
+ if (isCode(error, "EEXIST")) throw new StateLocked(stage, await this.readLock(stage), lock);
106
+ throw error;
107
+ } finally {
108
+ await unlink(temp).catch(() => {});
109
+ }
110
+ }
111
+ async readLock(stage) {
112
+ try {
113
+ return JSON.parse(await readFile(this.lockPath(stage), "utf-8"));
114
+ } catch {
115
+ return null;
116
+ }
117
+ }
118
+ async removeLock(stage, holder) {
119
+ if (holder) {
120
+ if ((await this.readLock(stage))?.id !== holder.id) return;
121
+ }
122
+ await rm(this.lockPath(stage), { force: true });
123
+ }
124
+ async ensureDir() {
125
+ await mkdir(this.dir, {
126
+ recursive: true,
127
+ mode: 448
128
+ });
129
+ }
130
+ /**
131
+ * Serialises the check-then-rename of a conditional write across
132
+ * processes. The stage lock is for whole runs; this is for the instant of
133
+ * a single write, so even writers that skip the lock never interleave.
134
+ */
135
+ async withMutex(stage, fn) {
136
+ const path = this.mutexPath(stage);
137
+ const deadline = Date.now() + MUTEX_TIMEOUT_MS;
138
+ for (;;) try {
139
+ await (await open(path, "wx", FILE_MODE)).close();
140
+ break;
141
+ } catch (error) {
142
+ if (!isCode(error, "EEXIST")) throw error;
143
+ if (await this.isStale(path)) {
144
+ await unlink(path).catch(() => {});
145
+ continue;
146
+ }
147
+ if (Date.now() > deadline) throw new StateStoreBusy(stage, path);
148
+ await new Promise((resolve) => setTimeout(resolve, 10));
149
+ }
150
+ try {
151
+ return await fn();
152
+ } finally {
153
+ await rm(path, { force: true });
154
+ }
155
+ }
156
+ async isStale(path) {
157
+ try {
158
+ return Date.now() - (await stat(path)).mtimeMs > MUTEX_STALE_MS;
159
+ } catch {
160
+ return false;
161
+ }
162
+ }
163
+ };
164
+ //#endregion
165
+ export { LocalStateStore_exports as n, LocalStateStore as t };
166
+
167
+ //# sourceMappingURL=LocalStateStore-Ba0Y6q5C.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LocalStateStore-Ba0Y6q5C.mjs","names":[],"sources":["../src/deploy/LocalStateStore.ts"],"sourcesContent":["/**\n * Local filesystem state store.\n *\n * `.gkm/deploy-<stage>.json` holds the state, `.gkm/deploy-<stage>.lock` the\n * lock. Every file is mode 0600: state holds database passwords and IAM keys.\n */\n\nimport { randomUUID } from 'node:crypto';\nimport {\n\tlink,\n\tmkdir,\n\topen,\n\treadFile,\n\trename,\n\trm,\n\tstat,\n\tunlink,\n\twriteFile,\n} from 'node:fs/promises';\nimport { join } from 'node:path';\nimport {\n\tcontentVersion,\n\tDocumentStateStore,\n\ttype LockHolder,\n\ttype RawState,\n\tStateLocked,\n\tStateStoreBusy,\n\ttype StateVersion,\n\tStateVersionConflict,\n} from './StateStore';\n\nconst FILE_MODE = 0o600;\n\n/** How long a write waits for another process's write to finish. */\nconst MUTEX_TIMEOUT_MS = 5_000;\n/**\n * A write holds the mutex for milliseconds, so one this old was left by a\n * process that died mid-write and is safe to take over.\n */\nconst MUTEX_STALE_MS = 30_000;\n\nfunction isCode(error: unknown, code: string): boolean {\n\treturn (error as NodeJS.ErrnoException)?.code === code;\n}\n\nexport class LocalStateStore extends DocumentStateStore {\n\tconstructor(readonly workspaceRoot: string) {\n\t\tsuper();\n\t}\n\n\tprivate get dir(): string {\n\t\treturn join(this.workspaceRoot, '.gkm');\n\t}\n\n\tstatePath(stage: string): string {\n\t\treturn join(this.dir, `deploy-${stage}.json`);\n\t}\n\n\tlockPath(stage: string): string {\n\t\treturn join(this.dir, `deploy-${stage}.lock`);\n\t}\n\n\tbackupPath(stage: string): string {\n\t\treturn join(this.dir, `deploy-${stage}.v1.json`);\n\t}\n\n\tprivate mutexPath(stage: string): string {\n\t\treturn join(this.dir, `deploy-${stage}.json.mutex`);\n\t}\n\n\tprotected location(stage: string): string {\n\t\treturn this.statePath(stage);\n\t}\n\n\tprotected async readRaw(stage: string): Promise<RawState | null> {\n\t\ttry {\n\t\t\tconst body = await readFile(this.statePath(stage), 'utf-8');\n\t\t\treturn { body, version: contentVersion(body) };\n\t\t} catch (error) {\n\t\t\tif (isCode(error, 'ENOENT')) return null;\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tprotected async writeRaw(\n\t\tstage: string,\n\t\tbody: string,\n\t\texpectedVersion: StateVersion | null,\n\t): Promise<StateVersion> {\n\t\tawait this.ensureDir();\n\t\treturn this.withMutex(stage, async () => {\n\t\t\tconst current = await this.readRaw(stage);\n\t\t\tconst actual = current?.version ?? null;\n\t\t\tif (actual !== expectedVersion) {\n\t\t\t\tthrow new StateVersionConflict(stage, expectedVersion, actual);\n\t\t\t}\n\n\t\t\t// Written beside the target and renamed over it: a reader sees the\n\t\t\t// old file or the new one, never half of either.\n\t\t\tconst target = this.statePath(stage);\n\t\t\tconst temp = `${target}.${randomUUID()}.tmp`;\n\t\t\ttry {\n\t\t\t\tconst handle = await open(temp, 'wx', FILE_MODE);\n\t\t\t\ttry {\n\t\t\t\t\tawait handle.writeFile(body);\n\t\t\t\t\tawait handle.sync();\n\t\t\t\t} finally {\n\t\t\t\t\tawait handle.close();\n\t\t\t\t}\n\t\t\t\tawait rename(temp, target);\n\t\t\t} catch (error) {\n\t\t\t\tawait rm(temp, { force: true });\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\treturn contentVersion(body);\n\t\t});\n\t}\n\n\tprotected async writeV1Backup(stage: string, body: string): Promise<void> {\n\t\ttry {\n\t\t\tawait writeFile(this.backupPath(stage), body, {\n\t\t\t\tflag: 'wx',\n\t\t\t\tmode: FILE_MODE,\n\t\t\t});\n\t\t} catch (error) {\n\t\t\t// The first migration's backup is the one worth keeping.\n\t\t\tif (!isCode(error, 'EEXIST')) throw error;\n\t\t}\n\t}\n\n\tprotected async createLock(stage: string, holder: LockHolder): Promise<void> {\n\t\tawait this.ensureDir();\n\t\t// Written whole, then linked into place: `link` fails if the lock\n\t\t// exists, so taking it is atomic — and a racing runner that loses never\n\t\t// reads a lock its winner has created but not yet written to.\n\t\tconst lock = this.lockPath(stage);\n\t\tconst temp = `${lock}.${randomUUID()}.tmp`;\n\t\tawait writeFile(temp, JSON.stringify(holder, null, 2), {\n\t\t\tflag: 'wx',\n\t\t\tmode: FILE_MODE,\n\t\t});\n\t\ttry {\n\t\t\tawait link(temp, lock);\n\t\t} catch (error) {\n\t\t\tif (isCode(error, 'EEXIST')) {\n\t\t\t\tthrow new StateLocked(stage, await this.readLock(stage), lock);\n\t\t\t}\n\t\t\tthrow error;\n\t\t} finally {\n\t\t\tawait unlink(temp).catch(() => {});\n\t\t}\n\t}\n\n\tprotected async readLock(stage: string): Promise<LockHolder | null> {\n\t\ttry {\n\t\t\treturn JSON.parse(\n\t\t\t\tawait readFile(this.lockPath(stage), 'utf-8'),\n\t\t\t) as LockHolder;\n\t\t} catch {\n\t\t\t// Missing, or created by a process that died before writing to it.\n\t\t\treturn null;\n\t\t}\n\t}\n\n\tprotected async removeLock(\n\t\tstage: string,\n\t\tholder: LockHolder | null,\n\t): Promise<void> {\n\t\tif (holder) {\n\t\t\tconst current = await this.readLock(stage);\n\t\t\tif (current?.id !== holder.id) return;\n\t\t}\n\t\tawait rm(this.lockPath(stage), { force: true });\n\t}\n\n\tprivate async ensureDir(): Promise<void> {\n\t\tawait mkdir(this.dir, { recursive: true, mode: 0o700 });\n\t}\n\n\t/**\n\t * Serialises the check-then-rename of a conditional write across\n\t * processes. The stage lock is for whole runs; this is for the instant of\n\t * a single write, so even writers that skip the lock never interleave.\n\t */\n\tprivate async withMutex<T>(stage: string, fn: () => Promise<T>): Promise<T> {\n\t\tconst path = this.mutexPath(stage);\n\t\tconst deadline = Date.now() + MUTEX_TIMEOUT_MS;\n\n\t\tfor (;;) {\n\t\t\ttry {\n\t\t\t\tconst handle = await open(path, 'wx', FILE_MODE);\n\t\t\t\tawait handle.close();\n\t\t\t\tbreak;\n\t\t\t} catch (error) {\n\t\t\t\tif (!isCode(error, 'EEXIST')) throw error;\n\t\t\t\tif (await this.isStale(path)) {\n\t\t\t\t\tawait unlink(path).catch(() => {});\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (Date.now() > deadline) throw new StateStoreBusy(stage, path);\n\t\t\t\tawait new Promise((resolve) => setTimeout(resolve, 10));\n\t\t\t}\n\t\t}\n\n\t\ttry {\n\t\t\treturn await fn();\n\t\t} finally {\n\t\t\tawait rm(path, { force: true });\n\t\t}\n\t}\n\n\tprivate async isStale(path: string): Promise<boolean> {\n\t\ttry {\n\t\t\treturn Date.now() - (await stat(path)).mtimeMs > MUTEX_STALE_MS;\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;AA+BA,MAAM,YAAY;;AAGlB,MAAM,mBAAmB;;;;;AAKzB,MAAM,iBAAiB;AAEvB,SAAS,OAAO,OAAgB,MAAuB;CACtD,OAAQ,OAAiC,SAAS;AACnD;AAEA,IAAa,kBAAb,cAAqC,mBAAmB;CAClC;CAArB,YAAY,eAAgC;EAC3C,MAAM;EADc,KAAA,gBAAA;CAErB;CAEA,IAAY,MAAc;EACzB,OAAO,KAAK,KAAK,eAAe,MAAM;CACvC;CAEA,UAAU,OAAuB;EAChC,OAAO,KAAK,KAAK,KAAK,UAAU,MAAM,MAAM;CAC7C;CAEA,SAAS,OAAuB;EAC/B,OAAO,KAAK,KAAK,KAAK,UAAU,MAAM,MAAM;CAC7C;CAEA,WAAW,OAAuB;EACjC,OAAO,KA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CAAC,CAAC,YAAY,CAAC,CAAC;IACjC;GACD;GACA,IAAI,KAAK,IAAI,IAAI,UAAU,MAAM,IAAI,eAAe,OAAO,IAAI;GAC/D,MAAM,IAAI,SAAS,YAAY,WAAW,SAAS,EAAE,CAAC;EACvD;EAGD,IAAI;GACH,OAAO,MAAM,GAAG;EACjB,UAAU;GACT,MAAM,GAAG,MAAM,EAAE,OAAO,KAAK,CAAC;EAC/B;CACD;CAEA,MAAc,QAAQ,MAAgC;EACrD,IAAI;GACH,OAAO,KAAK,IAAI,KAAK,MAAM,KAAK,IAAI,EAAA,CAAG,UAAU;EAClD,QAAQ;GACP,OAAO;EACR;CACD;AACD"}
@@ -0,0 +1,178 @@
1
+ const require_rolldown_runtime = require("./rolldown-runtime-C0BPl7ul.cjs");
2
+ const require_sniffer = require("./sniffer-Biw5SE1V.cjs");
3
+ let node_path = require("node:path");
4
+ let node_fs_promises = require("node:fs/promises");
5
+ let node_crypto = require("node:crypto");
6
+ //#region src/deploy/LocalStateStore.ts
7
+ /**
8
+ * Local filesystem state store.
9
+ *
10
+ * `.gkm/deploy-<stage>.json` holds the state, `.gkm/deploy-<stage>.lock` the
11
+ * lock. Every file is mode 0600: state holds database passwords and IAM keys.
12
+ */
13
+ var LocalStateStore_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({ LocalStateStore: () => LocalStateStore });
14
+ const FILE_MODE = 384;
15
+ /** How long a write waits for another process's write to finish. */
16
+ const MUTEX_TIMEOUT_MS = 5e3;
17
+ /**
18
+ * A write holds the mutex for milliseconds, so one this old was left by a
19
+ * process that died mid-write and is safe to take over.
20
+ */
21
+ const MUTEX_STALE_MS = 3e4;
22
+ function isCode(error, code) {
23
+ return error?.code === code;
24
+ }
25
+ var LocalStateStore = class extends require_sniffer.DocumentStateStore {
26
+ workspaceRoot;
27
+ constructor(workspaceRoot) {
28
+ super();
29
+ this.workspaceRoot = workspaceRoot;
30
+ }
31
+ get dir() {
32
+ return (0, node_path.join)(this.workspaceRoot, ".gkm");
33
+ }
34
+ statePath(stage) {
35
+ return (0, node_path.join)(this.dir, `deploy-${stage}.json`);
36
+ }
37
+ lockPath(stage) {
38
+ return (0, node_path.join)(this.dir, `deploy-${stage}.lock`);
39
+ }
40
+ backupPath(stage) {
41
+ return (0, node_path.join)(this.dir, `deploy-${stage}.v1.json`);
42
+ }
43
+ mutexPath(stage) {
44
+ return (0, node_path.join)(this.dir, `deploy-${stage}.json.mutex`);
45
+ }
46
+ location(stage) {
47
+ return this.statePath(stage);
48
+ }
49
+ async readRaw(stage) {
50
+ try {
51
+ const body = await (0, node_fs_promises.readFile)(this.statePath(stage), "utf-8");
52
+ return {
53
+ body,
54
+ version: require_sniffer.contentVersion(body)
55
+ };
56
+ } catch (error) {
57
+ if (isCode(error, "ENOENT")) return null;
58
+ throw error;
59
+ }
60
+ }
61
+ async writeRaw(stage, body, expectedVersion) {
62
+ await this.ensureDir();
63
+ return this.withMutex(stage, async () => {
64
+ const actual = (await this.readRaw(stage))?.version ?? null;
65
+ if (actual !== expectedVersion) throw new require_sniffer.StateVersionConflict(stage, expectedVersion, actual);
66
+ const target = this.statePath(stage);
67
+ const temp = `${target}.${(0, node_crypto.randomUUID)()}.tmp`;
68
+ try {
69
+ const handle = await (0, node_fs_promises.open)(temp, "wx", FILE_MODE);
70
+ try {
71
+ await handle.writeFile(body);
72
+ await handle.sync();
73
+ } finally {
74
+ await handle.close();
75
+ }
76
+ await (0, node_fs_promises.rename)(temp, target);
77
+ } catch (error) {
78
+ await (0, node_fs_promises.rm)(temp, { force: true });
79
+ throw error;
80
+ }
81
+ return require_sniffer.contentVersion(body);
82
+ });
83
+ }
84
+ async writeV1Backup(stage, body) {
85
+ try {
86
+ await (0, node_fs_promises.writeFile)(this.backupPath(stage), body, {
87
+ flag: "wx",
88
+ mode: FILE_MODE
89
+ });
90
+ } catch (error) {
91
+ if (!isCode(error, "EEXIST")) throw error;
92
+ }
93
+ }
94
+ async createLock(stage, holder) {
95
+ await this.ensureDir();
96
+ const lock = this.lockPath(stage);
97
+ const temp = `${lock}.${(0, node_crypto.randomUUID)()}.tmp`;
98
+ await (0, node_fs_promises.writeFile)(temp, JSON.stringify(holder, null, 2), {
99
+ flag: "wx",
100
+ mode: FILE_MODE
101
+ });
102
+ try {
103
+ await (0, node_fs_promises.link)(temp, lock);
104
+ } catch (error) {
105
+ if (isCode(error, "EEXIST")) throw new require_sniffer.StateLocked(stage, await this.readLock(stage), lock);
106
+ throw error;
107
+ } finally {
108
+ await (0, node_fs_promises.unlink)(temp).catch(() => {});
109
+ }
110
+ }
111
+ async readLock(stage) {
112
+ try {
113
+ return JSON.parse(await (0, node_fs_promises.readFile)(this.lockPath(stage), "utf-8"));
114
+ } catch {
115
+ return null;
116
+ }
117
+ }
118
+ async removeLock(stage, holder) {
119
+ if (holder) {
120
+ if ((await this.readLock(stage))?.id !== holder.id) return;
121
+ }
122
+ await (0, node_fs_promises.rm)(this.lockPath(stage), { force: true });
123
+ }
124
+ async ensureDir() {
125
+ await (0, node_fs_promises.mkdir)(this.dir, {
126
+ recursive: true,
127
+ mode: 448
128
+ });
129
+ }
130
+ /**
131
+ * Serialises the check-then-rename of a conditional write across
132
+ * processes. The stage lock is for whole runs; this is for the instant of
133
+ * a single write, so even writers that skip the lock never interleave.
134
+ */
135
+ async withMutex(stage, fn) {
136
+ const path = this.mutexPath(stage);
137
+ const deadline = Date.now() + MUTEX_TIMEOUT_MS;
138
+ for (;;) try {
139
+ await (await (0, node_fs_promises.open)(path, "wx", FILE_MODE)).close();
140
+ break;
141
+ } catch (error) {
142
+ if (!isCode(error, "EEXIST")) throw error;
143
+ if (await this.isStale(path)) {
144
+ await (0, node_fs_promises.unlink)(path).catch(() => {});
145
+ continue;
146
+ }
147
+ if (Date.now() > deadline) throw new require_sniffer.StateStoreBusy(stage, path);
148
+ await new Promise((resolve) => setTimeout(resolve, 10));
149
+ }
150
+ try {
151
+ return await fn();
152
+ } finally {
153
+ await (0, node_fs_promises.rm)(path, { force: true });
154
+ }
155
+ }
156
+ async isStale(path) {
157
+ try {
158
+ return Date.now() - (await (0, node_fs_promises.stat)(path)).mtimeMs > MUTEX_STALE_MS;
159
+ } catch {
160
+ return false;
161
+ }
162
+ }
163
+ };
164
+ //#endregion
165
+ Object.defineProperty(exports, "LocalStateStore", {
166
+ enumerable: true,
167
+ get: function() {
168
+ return LocalStateStore;
169
+ }
170
+ });
171
+ Object.defineProperty(exports, "LocalStateStore_exports", {
172
+ enumerable: true,
173
+ get: function() {
174
+ return LocalStateStore_exports;
175
+ }
176
+ });
177
+
178
+ //# sourceMappingURL=LocalStateStore-CgQtQix2.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LocalStateStore-CgQtQix2.cjs","names":["DocumentStateStore","join","readFile","contentVersion","StateVersionConflict","randomUUID","open","rename","rm","writeFile","link","StateLocked","unlink","mkdir","StateStoreBusy","stat"],"sources":["../src/deploy/LocalStateStore.ts"],"sourcesContent":["/**\n * Local filesystem state store.\n *\n * `.gkm/deploy-<stage>.json` holds the state, `.gkm/deploy-<stage>.lock` the\n * lock. Every file is mode 0600: state holds database passwords and IAM keys.\n */\n\nimport { randomUUID } from 'node:crypto';\nimport {\n\tlink,\n\tmkdir,\n\topen,\n\treadFile,\n\trename,\n\trm,\n\tstat,\n\tunlink,\n\twriteFile,\n} from 'node:fs/promises';\nimport { join } from 'node:path';\nimport {\n\tcontentVersion,\n\tDocumentStateStore,\n\ttype LockHolder,\n\ttype RawState,\n\tStateLocked,\n\tStateStoreBusy,\n\ttype StateVersion,\n\tStateVersionConflict,\n} from './StateStore';\n\nconst FILE_MODE = 0o600;\n\n/** How long a write waits for another process's write to finish. */\nconst MUTEX_TIMEOUT_MS = 5_000;\n/**\n * A write holds the mutex for milliseconds, so one this old was left by a\n * process that died mid-write and is safe to take over.\n */\nconst MUTEX_STALE_MS = 30_000;\n\nfunction isCode(error: unknown, code: string): boolean {\n\treturn (error as NodeJS.ErrnoException)?.code === code;\n}\n\nexport class LocalStateStore extends DocumentStateStore {\n\tconstructor(readonly workspaceRoot: string) {\n\t\tsuper();\n\t}\n\n\tprivate get dir(): string {\n\t\treturn join(this.workspaceRoot, '.gkm');\n\t}\n\n\tstatePath(stage: string): string {\n\t\treturn join(this.dir, `deploy-${stage}.json`);\n\t}\n\n\tlockPath(stage: string): string {\n\t\treturn join(this.dir, `deploy-${stage}.lock`);\n\t}\n\n\tbackupPath(stage: string): string {\n\t\treturn join(this.dir, `deploy-${stage}.v1.json`);\n\t}\n\n\tprivate mutexPath(stage: string): string {\n\t\treturn join(this.dir, `deploy-${stage}.json.mutex`);\n\t}\n\n\tprotected location(stage: string): string {\n\t\treturn this.statePath(stage);\n\t}\n\n\tprotected async readRaw(stage: string): Promise<RawState | null> {\n\t\ttry {\n\t\t\tconst body = await readFile(this.statePath(stage), 'utf-8');\n\t\t\treturn { body, version: contentVersion(body) };\n\t\t} catch (error) {\n\t\t\tif (isCode(error, 'ENOENT')) return null;\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tprotected async writeRaw(\n\t\tstage: string,\n\t\tbody: string,\n\t\texpectedVersion: StateVersion | null,\n\t): Promise<StateVersion> {\n\t\tawait this.ensureDir();\n\t\treturn this.withMutex(stage, async () => {\n\t\t\tconst current = await this.readRaw(stage);\n\t\t\tconst actual = current?.version ?? null;\n\t\t\tif (actual !== expectedVersion) {\n\t\t\t\tthrow new StateVersionConflict(stage, expectedVersion, actual);\n\t\t\t}\n\n\t\t\t// Written beside the target and renamed over it: a reader sees the\n\t\t\t// old file or the new one, never half of either.\n\t\t\tconst target = this.statePath(stage);\n\t\t\tconst temp = `${target}.${randomUUID()}.tmp`;\n\t\t\ttry {\n\t\t\t\tconst handle = await open(temp, 'wx', FILE_MODE);\n\t\t\t\ttry {\n\t\t\t\t\tawait handle.writeFile(body);\n\t\t\t\t\tawait handle.sync();\n\t\t\t\t} finally {\n\t\t\t\t\tawait handle.close();\n\t\t\t\t}\n\t\t\t\tawait rename(temp, target);\n\t\t\t} catch (error) {\n\t\t\t\tawait rm(temp, { force: true });\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\treturn contentVersion(body);\n\t\t});\n\t}\n\n\tprotected async writeV1Backup(stage: string, body: string): Promise<void> {\n\t\ttry {\n\t\t\tawait writeFile(this.backupPath(stage), body, {\n\t\t\t\tflag: 'wx',\n\t\t\t\tmode: FILE_MODE,\n\t\t\t});\n\t\t} catch (error) {\n\t\t\t// The first migration's backup is the one worth keeping.\n\t\t\tif (!isCode(error, 'EEXIST')) throw error;\n\t\t}\n\t}\n\n\tprotected async createLock(stage: string, holder: LockHolder): Promise<void> {\n\t\tawait this.ensureDir();\n\t\t// Written whole, then linked into place: `link` fails if the lock\n\t\t// exists, so taking it is atomic — and a racing runner that loses never\n\t\t// reads a lock its winner has created but not yet written to.\n\t\tconst lock = this.lockPath(stage);\n\t\tconst temp = `${lock}.${randomUUID()}.tmp`;\n\t\tawait writeFile(temp, JSON.stringify(holder, null, 2), {\n\t\t\tflag: 'wx',\n\t\t\tmode: FILE_MODE,\n\t\t});\n\t\ttry {\n\t\t\tawait link(temp, lock);\n\t\t} catch (error) {\n\t\t\tif (isCode(error, 'EEXIST')) {\n\t\t\t\tthrow new StateLocked(stage, await this.readLock(stage), lock);\n\t\t\t}\n\t\t\tthrow error;\n\t\t} finally {\n\t\t\tawait unlink(temp).catch(() => {});\n\t\t}\n\t}\n\n\tprotected async readLock(stage: string): Promise<LockHolder | null> {\n\t\ttry {\n\t\t\treturn JSON.parse(\n\t\t\t\tawait readFile(this.lockPath(stage), 'utf-8'),\n\t\t\t) as LockHolder;\n\t\t} catch {\n\t\t\t// Missing, or created by a process that died before writing to it.\n\t\t\treturn null;\n\t\t}\n\t}\n\n\tprotected async removeLock(\n\t\tstage: string,\n\t\tholder: LockHolder | null,\n\t): Promise<void> {\n\t\tif (holder) {\n\t\t\tconst current = await this.readLock(stage);\n\t\t\tif (current?.id !== holder.id) return;\n\t\t}\n\t\tawait rm(this.lockPath(stage), { force: true });\n\t}\n\n\tprivate async ensureDir(): Promise<void> {\n\t\tawait mkdir(this.dir, { recursive: true, mode: 0o700 });\n\t}\n\n\t/**\n\t * Serialises the check-then-rename of a conditional write across\n\t * processes. The stage lock is for whole runs; this is for the instant of\n\t * a single write, so even writers that skip the lock never interleave.\n\t */\n\tprivate async withMutex<T>(stage: string, fn: () => Promise<T>): Promise<T> {\n\t\tconst path = this.mutexPath(stage);\n\t\tconst deadline = Date.now() + MUTEX_TIMEOUT_MS;\n\n\t\tfor (;;) {\n\t\t\ttry {\n\t\t\t\tconst handle = await open(path, 'wx', FILE_MODE);\n\t\t\t\tawait handle.close();\n\t\t\t\tbreak;\n\t\t\t} catch (error) {\n\t\t\t\tif (!isCode(error, 'EEXIST')) throw error;\n\t\t\t\tif (await this.isStale(path)) {\n\t\t\t\t\tawait unlink(path).catch(() => {});\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (Date.now() > deadline) throw new StateStoreBusy(stage, path);\n\t\t\t\tawait new Promise((resolve) => setTimeout(resolve, 10));\n\t\t\t}\n\t\t}\n\n\t\ttry {\n\t\t\treturn await fn();\n\t\t} finally {\n\t\t\tawait rm(path, { force: true });\n\t\t}\n\t}\n\n\tprivate async isStale(path: string): Promise<boolean> {\n\t\ttry {\n\t\t\treturn Date.now() - (await stat(path)).mtimeMs > MUTEX_STALE_MS;\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;AA+BA,MAAM,YAAY;;AAGlB,MAAM,mBAAmB;;;;;AAKzB,MAAM,iBAAiB;AAEvB,SAAS,OAAO,OAAgB,MAAuB;CACtD,OAAQ,OAAiC,SAAS;AACnD;AAEA,IAAa,kBAAb,cAAqCA,gBAAAA,mBAAmB;CAClC;CAArB,YAAY,eAAgC;EAC3C,MAAM;EADc,KAAA,gBAAA;CAErB;CAEA,IAAY,MAAc;EACzB,QAAA,GAAOC,UAAAA,KAAAA,CAAK,KAAK,eAAe,MAAM;CACvC;CA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