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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (438) hide show
  1. package/README.md +313 -380
  2. package/bin/adjacent-tsconfig.mjs +46 -8
  3. package/bin/gkm.mjs +11 -3
  4. package/bin/owning-tsconfig-jsx-register.mjs +18 -0
  5. package/bin/owning-tsconfig-jsx.mjs +108 -0
  6. package/dist/EndpointGenerator-CusLH-9S.mjs +1037 -0
  7. package/dist/EndpointGenerator-CusLH-9S.mjs.map +1 -0
  8. package/dist/EndpointGenerator-DyLMYClE.cjs +1096 -0
  9. package/dist/EndpointGenerator-DyLMYClE.cjs.map +1 -0
  10. package/dist/GoDaddyProvider-BZYq0-nV.cjs +412 -0
  11. package/dist/GoDaddyProvider-BZYq0-nV.cjs.map +1 -0
  12. package/dist/GoDaddyProvider-D-8GW8cP.mjs +412 -0
  13. package/dist/GoDaddyProvider-D-8GW8cP.mjs.map +1 -0
  14. package/dist/{HostingerProvider-BZFGYYVA.cjs → HostingerProvider-BxRR2ibx.cjs} +23 -9
  15. package/dist/HostingerProvider-BxRR2ibx.cjs.map +1 -0
  16. package/dist/{HostingerProvider-BY26bWwB.mjs → HostingerProvider-C-C4aiKF.mjs} +23 -9
  17. package/dist/HostingerProvider-C-C4aiKF.mjs.map +1 -0
  18. package/dist/LegacyStateStore-BFkNiBxC.mjs +124 -0
  19. package/dist/LegacyStateStore-BFkNiBxC.mjs.map +1 -0
  20. package/dist/LegacyStateStore-DYaamZqR.cjs +124 -0
  21. package/dist/LegacyStateStore-DYaamZqR.cjs.map +1 -0
  22. package/dist/LocalStateStore-7pP4naiB.mjs +167 -0
  23. package/dist/LocalStateStore-7pP4naiB.mjs.map +1 -0
  24. package/dist/LocalStateStore-C0JSjyCg.cjs +178 -0
  25. package/dist/LocalStateStore-C0JSjyCg.cjs.map +1 -0
  26. package/dist/OpenApiTsGenerator-BTMuu1WS.mjs +534 -0
  27. package/dist/OpenApiTsGenerator-BTMuu1WS.mjs.map +1 -0
  28. package/dist/OpenApiTsGenerator-CI-tceXV.cjs +539 -0
  29. package/dist/OpenApiTsGenerator-CI-tceXV.cjs.map +1 -0
  30. package/dist/{Route53Provider-Cvj40A8I.mjs → Route53Provider-Di_SD9CF.mjs} +3 -3
  31. package/dist/Route53Provider-Di_SD9CF.mjs.map +1 -0
  32. package/dist/{Route53Provider-DVILBsvV.cjs → Route53Provider-emLuQHVw.cjs} +3 -3
  33. package/dist/Route53Provider-emLuQHVw.cjs.map +1 -0
  34. package/dist/S3StateStore-BnmbFco-.cjs +222 -0
  35. package/dist/S3StateStore-BnmbFco-.cjs.map +1 -0
  36. package/dist/S3StateStore-Dzyuiy3V.mjs +223 -0
  37. package/dist/S3StateStore-Dzyuiy3V.mjs.map +1 -0
  38. package/dist/SSMStateStore-BLbjoEFc.cjs +204 -0
  39. package/dist/SSMStateStore-BLbjoEFc.cjs.map +1 -0
  40. package/dist/SSMStateStore-BcNH7efc.mjs +205 -0
  41. package/dist/SSMStateStore-BcNH7efc.mjs.map +1 -0
  42. package/dist/SubscriberGenerator-BNJyPmXJ.cjs +848 -0
  43. package/dist/SubscriberGenerator-BNJyPmXJ.cjs.map +1 -0
  44. package/dist/SubscriberGenerator-CzPrixYu.mjs +783 -0
  45. package/dist/SubscriberGenerator-CzPrixYu.mjs.map +1 -0
  46. package/dist/add-SHsas9Yu.mjs +711 -0
  47. package/dist/add-SHsas9Yu.mjs.map +1 -0
  48. package/dist/add-moAE6nV4.cjs +713 -0
  49. package/dist/add-moAE6nV4.cjs.map +1 -0
  50. package/dist/appPorts-BoXMwolc.mjs +249 -0
  51. package/dist/appPorts-BoXMwolc.mjs.map +1 -0
  52. package/dist/appPorts-IW-OZmRi.cjs +296 -0
  53. package/dist/appPorts-IW-OZmRi.cjs.map +1 -0
  54. package/dist/apps-BOgA6AcI.mjs +5534 -0
  55. package/dist/apps-BOgA6AcI.mjs.map +1 -0
  56. package/dist/apps-DkxHjd59.cjs +6148 -0
  57. package/dist/apps-DkxHjd59.cjs.map +1 -0
  58. package/dist/aws-8QQ8n-t6.mjs +89 -0
  59. package/dist/aws-8QQ8n-t6.mjs.map +1 -0
  60. package/dist/aws-DY9NqQIT.cjs +100 -0
  61. package/dist/aws-DY9NqQIT.cjs.map +1 -0
  62. package/dist/awsStore-Bx5nCFnS.mjs +121 -0
  63. package/dist/awsStore-Bx5nCFnS.mjs.map +1 -0
  64. package/dist/awsStore-u3ehhMoY.cjs +138 -0
  65. package/dist/awsStore-u3ehhMoY.cjs.map +1 -0
  66. package/dist/{backup-provisioner-DIVCbfee.mjs → backup-provisioner-C8DnCmxK.mjs} +2 -2
  67. package/dist/backup-provisioner-C8DnCmxK.mjs.map +1 -0
  68. package/dist/{backup-provisioner-BmhIO_Yr.cjs → backup-provisioner-oDEsPj02.cjs} +2 -2
  69. package/dist/backup-provisioner-oDEsPj02.cjs.map +1 -0
  70. package/dist/backups/runner.cjs +519 -0
  71. package/dist/backups/runner.cjs.map +1 -0
  72. package/dist/backups/runner.d.cts +102 -0
  73. package/dist/backups/runner.d.cts.map +1 -0
  74. package/dist/backups/runner.d.mts +102 -0
  75. package/dist/backups/runner.d.mts.map +1 -0
  76. package/dist/backups/runner.mjs +506 -0
  77. package/dist/backups/runner.mjs.map +1 -0
  78. package/dist/{bundler-BeNDZdHQ.cjs → bundler-D0spRLb-.cjs} +59 -14
  79. package/dist/bundler-D0spRLb-.cjs.map +1 -0
  80. package/dist/{bundler-BodTL4kf.mjs → bundler-Dy-Dfchf.mjs} +59 -14
  81. package/dist/bundler-Dy-Dfchf.mjs.map +1 -0
  82. package/dist/cli-BmCyUTZf.cjs +71 -0
  83. package/dist/cli-BmCyUTZf.cjs.map +1 -0
  84. package/dist/cli-BpT_gg4n.mjs +71 -0
  85. package/dist/cli-BpT_gg4n.mjs.map +1 -0
  86. package/dist/compose-0HkjQywT.cjs +3046 -0
  87. package/dist/compose-0HkjQywT.cjs.map +1 -0
  88. package/dist/compose-B3OOowfE.mjs +1560 -0
  89. package/dist/compose-B3OOowfE.mjs.map +1 -0
  90. package/dist/compose-BIXEPrGA.mjs +2957 -0
  91. package/dist/compose-BIXEPrGA.mjs.map +1 -0
  92. package/dist/compose-BP8OeV7P.cjs +1919 -0
  93. package/dist/compose-BP8OeV7P.cjs.map +1 -0
  94. package/dist/config-BLrAd7Of.mjs +659 -0
  95. package/dist/config-BLrAd7Of.mjs.map +1 -0
  96. package/dist/config-CRk2vdSp.d.mts +268 -0
  97. package/dist/config-CRk2vdSp.d.mts.map +1 -0
  98. package/dist/config-juUyBlb1.cjs +772 -0
  99. package/dist/config-juUyBlb1.cjs.map +1 -0
  100. package/dist/config-oBgsbLip.d.cts +268 -0
  101. package/dist/config-oBgsbLip.d.cts.map +1 -0
  102. package/dist/config.cjs +11 -3
  103. package/dist/config.d.cts +4 -117
  104. package/dist/config.d.mts +4 -117
  105. package/dist/config.mjs +3 -3
  106. package/dist/credentialSchemas-BAklWDna.cjs +271 -0
  107. package/dist/credentialSchemas-BAklWDna.cjs.map +1 -0
  108. package/dist/credentialSchemas-mz9QZTYh.mjs +236 -0
  109. package/dist/credentialSchemas-mz9QZTYh.mjs.map +1 -0
  110. package/dist/credentials-B6ZwGsy-.cjs +2272 -0
  111. package/dist/credentials-B6ZwGsy-.cjs.map +1 -0
  112. package/dist/credentials-DRfP9aG7.mjs +1817 -0
  113. package/dist/credentials-DRfP9aG7.mjs.map +1 -0
  114. package/dist/databases-DawSdqBI.cjs +703 -0
  115. package/dist/databases-DawSdqBI.cjs.map +1 -0
  116. package/dist/databases-mzSUFBTw.mjs +588 -0
  117. package/dist/databases-mzSUFBTw.mjs.map +1 -0
  118. package/dist/define-6poNqm5O.mjs +106 -0
  119. package/dist/define-6poNqm5O.mjs.map +1 -0
  120. package/dist/define-crmMcXFS.cjs +153 -0
  121. package/dist/define-crmMcXFS.cjs.map +1 -0
  122. package/dist/deploy/public.cjs +211 -0
  123. package/dist/deploy/public.cjs.map +1 -0
  124. package/dist/deploy/public.d.cts +647 -0
  125. package/dist/deploy/public.d.cts.map +1 -0
  126. package/dist/deploy/public.d.mts +647 -0
  127. package/dist/deploy/public.d.mts.map +1 -0
  128. package/dist/deploy/public.mjs +144 -0
  129. package/dist/deploy/public.mjs.map +1 -0
  130. package/dist/deploy/sniffer-envparser-worker.cjs +54 -0
  131. package/dist/deploy/sniffer-envparser-worker.cjs.map +1 -0
  132. package/dist/deploy/sniffer-envparser-worker.d.cts +1 -0
  133. package/dist/deploy/sniffer-envparser-worker.d.mts +1 -0
  134. package/dist/deploy/sniffer-envparser-worker.mjs +55 -0
  135. package/dist/deploy/sniffer-envparser-worker.mjs.map +1 -0
  136. package/dist/deploy/sniffer-hooks.cjs +1 -1
  137. package/dist/deploy/sniffer-hooks.mjs +1 -1
  138. package/dist/deploy/sniffer-loader.cjs +2 -2
  139. package/dist/deploy/sniffer-loader.mjs +1 -1
  140. package/dist/deploy/sniffer-routes-worker.cjs +2 -2
  141. package/dist/deploy/sniffer-routes-worker.mjs +1 -1
  142. package/dist/deploy-BgOujGGL.mjs +3836 -0
  143. package/dist/deploy-BgOujGGL.mjs.map +1 -0
  144. package/dist/deploy-ciuNiVqo.cjs +3892 -0
  145. package/dist/deploy-ciuNiVqo.cjs.map +1 -0
  146. package/dist/discover-CRywE7yc.cjs +1085 -0
  147. package/dist/discover-CRywE7yc.cjs.map +1 -0
  148. package/dist/discover-DbDrCQ8h.mjs +940 -0
  149. package/dist/discover-DbDrCQ8h.mjs.map +1 -0
  150. package/dist/docker-74kvq2jQ.cjs +1514 -0
  151. package/dist/docker-74kvq2jQ.cjs.map +1 -0
  152. package/dist/docker-CXYz3W2U.mjs +1407 -0
  153. package/dist/docker-CXYz3W2U.mjs.map +1 -0
  154. package/dist/dokploy-CrxDMut1.cjs +38 -0
  155. package/dist/dokploy-CrxDMut1.cjs.map +1 -0
  156. package/dist/dokploy-tNy6ZU64.mjs +38 -0
  157. package/dist/dokploy-tNy6ZU64.mjs.map +1 -0
  158. package/dist/drivers-aM87NQJi.cjs +224 -0
  159. package/dist/drivers-aM87NQJi.cjs.map +1 -0
  160. package/dist/drivers-uxLBq3e3.mjs +195 -0
  161. package/dist/drivers-uxLBq3e3.mjs.map +1 -0
  162. package/dist/eas-B3yv_XVz.mjs +334 -0
  163. package/dist/eas-B3yv_XVz.mjs.map +1 -0
  164. package/dist/eas-CiORdzk0.cjs +337 -0
  165. package/dist/eas-CiORdzk0.cjs.map +1 -0
  166. package/dist/emit-Bj6XSivk.mjs +136 -0
  167. package/dist/emit-Bj6XSivk.mjs.map +1 -0
  168. package/dist/emit-CDC__ubE.cjs +147 -0
  169. package/dist/emit-CDC__ubE.cjs.map +1 -0
  170. package/dist/encryption-Birkm2_E.mjs +89 -0
  171. package/dist/encryption-Birkm2_E.mjs.map +1 -0
  172. package/dist/encryption-drgYmkGP.cjs +90 -0
  173. package/dist/encryption-drgYmkGP.cjs.map +1 -0
  174. package/dist/engine-CW78Wt8x.mjs +3217 -0
  175. package/dist/engine-CW78Wt8x.mjs.map +1 -0
  176. package/dist/engine-CfLaQ0bJ.cjs +3330 -0
  177. package/dist/engine-CfLaQ0bJ.cjs.map +1 -0
  178. package/dist/errors-D8Gwp5kU.mjs +23 -0
  179. package/dist/errors-D8Gwp5kU.mjs.map +1 -0
  180. package/dist/errors-DMC4Umsb.cjs +34 -0
  181. package/dist/errors-DMC4Umsb.cjs.map +1 -0
  182. package/dist/github-BfLlBWB5.cjs +901 -0
  183. package/dist/github-BfLlBWB5.cjs.map +1 -0
  184. package/dist/github-DphkHybE.mjs +900 -0
  185. package/dist/github-DphkHybE.mjs.map +1 -0
  186. package/dist/googlePlay-BWDhYvH_.cjs +931 -0
  187. package/dist/googlePlay-BWDhYvH_.cjs.map +1 -0
  188. package/dist/googlePlay-CjzqTF8t.mjs +931 -0
  189. package/dist/googlePlay-CjzqTF8t.mjs.map +1 -0
  190. package/dist/{index-D-iAVHx-.d.cts → index-B35vTdAW.d.cts} +39 -15
  191. package/dist/index-B35vTdAW.d.cts.map +1 -0
  192. package/dist/{index-Cd-qeOam.d.mts → index-Dv1Zj86i.d.mts} +39 -15
  193. package/dist/index-Dv1Zj86i.d.mts.map +1 -0
  194. package/dist/index.cjs +13594 -12347
  195. package/dist/index.cjs.map +1 -1
  196. package/dist/index.mjs +13541 -12292
  197. package/dist/index.mjs.map +1 -1
  198. package/dist/local-Bt9jPziD.cjs +241 -0
  199. package/dist/local-Bt9jPziD.cjs.map +1 -0
  200. package/dist/local-DBtepRK5.mjs +224 -0
  201. package/dist/local-DBtepRK5.mjs.map +1 -0
  202. package/dist/migrate-2YESt4v9.mjs +267 -0
  203. package/dist/migrate-2YESt4v9.mjs.map +1 -0
  204. package/dist/migrate-B-_cASJt.cjs +272 -0
  205. package/dist/migrate-B-_cASJt.cjs.map +1 -0
  206. package/dist/migrate-BUhe0BuA.cjs +181 -0
  207. package/dist/migrate-BUhe0BuA.cjs.map +1 -0
  208. package/dist/migrate-Dp_Y2XGi.mjs +181 -0
  209. package/dist/migrate-Dp_Y2XGi.mjs.map +1 -0
  210. package/dist/notes-DHN4qThL.mjs +399 -0
  211. package/dist/notes-DHN4qThL.mjs.map +1 -0
  212. package/dist/notes-DUq6Bx1I.cjs +500 -0
  213. package/dist/notes-DUq6Bx1I.cjs.map +1 -0
  214. package/dist/openapi.cjs +213 -7
  215. package/dist/openapi.cjs.map +1 -0
  216. package/dist/openapi.d.cts +32 -8
  217. package/dist/openapi.d.cts.map +1 -1
  218. package/dist/openapi.d.mts +32 -8
  219. package/dist/openapi.d.mts.map +1 -1
  220. package/dist/openapi.mjs +208 -2
  221. package/dist/openapi.mjs.map +1 -0
  222. package/dist/projectBucket-CxsutB3D.cjs +263 -0
  223. package/dist/projectBucket-CxsutB3D.cjs.map +1 -0
  224. package/dist/projectBucket-DzLZlleB.mjs +222 -0
  225. package/dist/projectBucket-DzLZlleB.mjs.map +1 -0
  226. package/dist/provider-BqpjG9QM.cjs +57 -0
  227. package/dist/provider-BqpjG9QM.cjs.map +1 -0
  228. package/dist/provider-CEOKk8NS.mjs +46 -0
  229. package/dist/provider-CEOKk8NS.mjs.map +1 -0
  230. package/dist/publish-BVal0GFd.mjs +123 -0
  231. package/dist/publish-BVal0GFd.mjs.map +1 -0
  232. package/dist/publish-DmTJhVe8.cjs +124 -0
  233. package/dist/publish-DmTJhVe8.cjs.map +1 -0
  234. package/dist/ready-BNh3zsSn.cjs +404 -0
  235. package/dist/ready-BNh3zsSn.cjs.map +1 -0
  236. package/dist/ready-g25dcGzK.mjs +375 -0
  237. package/dist/ready-g25dcGzK.mjs.map +1 -0
  238. package/dist/reconcile/public.cjs +3 -5
  239. package/dist/reconcile/public.d.cts +31 -89
  240. package/dist/reconcile/public.d.cts.map +1 -1
  241. package/dist/reconcile/public.d.mts +31 -89
  242. package/dist/reconcile/public.d.mts.map +1 -1
  243. package/dist/reconcile/public.mjs +3 -3
  244. package/dist/{reconcile-DhQ00DpU.mjs → reconcile--I7V4Klj.mjs} +2 -2
  245. package/dist/{reconcile-DhQ00DpU.mjs.map → reconcile--I7V4Klj.mjs.map} +1 -1
  246. package/dist/{reconcile-Dd2iyILf.cjs → reconcile-CuCQBa5-.cjs} +3 -3
  247. package/dist/{reconcile-Dd2iyILf.cjs.map → reconcile-CuCQBa5-.cjs.map} +1 -1
  248. package/dist/resolve-BwTJI8K7.cjs +316 -0
  249. package/dist/resolve-BwTJI8K7.cjs.map +1 -0
  250. package/dist/resolve-UBq26cZc.mjs +263 -0
  251. package/dist/resolve-UBq26cZc.mjs.map +1 -0
  252. package/dist/rollback-BFKex9TO.cjs +165 -0
  253. package/dist/rollback-BFKex9TO.cjs.map +1 -0
  254. package/dist/rollback-DiOcLTRc.mjs +136 -0
  255. package/dist/rollback-DiOcLTRc.mjs.map +1 -0
  256. package/dist/runtime-CFvcLEJW.d.cts +82 -0
  257. package/dist/runtime-CFvcLEJW.d.cts.map +1 -0
  258. package/dist/runtime-dwsH6ddo.d.mts +82 -0
  259. package/dist/runtime-dwsH6ddo.d.mts.map +1 -0
  260. package/dist/s3-BgG_xW-D.cjs +215 -0
  261. package/dist/s3-BgG_xW-D.cjs.map +1 -0
  262. package/dist/s3-CkrerKdA.mjs +215 -0
  263. package/dist/s3-CkrerKdA.mjs.map +1 -0
  264. package/dist/sandbox/config-worker.cjs +43 -0
  265. package/dist/sandbox/config-worker.cjs.map +1 -0
  266. package/dist/sandbox/config-worker.d.cts +1 -0
  267. package/dist/sandbox/config-worker.d.mts +1 -0
  268. package/dist/sandbox/config-worker.mjs +44 -0
  269. package/dist/sandbox/config-worker.mjs.map +1 -0
  270. package/dist/sandbox/credentials-worker.cjs +53 -0
  271. package/dist/sandbox/credentials-worker.cjs.map +1 -0
  272. package/dist/sandbox/credentials-worker.d.cts +1 -0
  273. package/dist/sandbox/credentials-worker.d.mts +1 -0
  274. package/dist/sandbox/credentials-worker.mjs +54 -0
  275. package/dist/sandbox/credentials-worker.mjs.map +1 -0
  276. package/dist/sandbox/discover-worker.cjs +47 -0
  277. package/dist/sandbox/discover-worker.cjs.map +1 -0
  278. package/dist/sandbox/discover-worker.d.cts +1 -0
  279. package/dist/sandbox/discover-worker.d.mts +1 -0
  280. package/dist/sandbox/discover-worker.mjs +48 -0
  281. package/dist/sandbox/discover-worker.mjs.map +1 -0
  282. package/dist/sandbox/migrate-worker.cjs +75 -0
  283. package/dist/sandbox/migrate-worker.cjs.map +1 -0
  284. package/dist/sandbox/migrate-worker.d.cts +1 -0
  285. package/dist/sandbox/migrate-worker.d.mts +1 -0
  286. package/dist/sandbox/migrate-worker.mjs +76 -0
  287. package/dist/sandbox/migrate-worker.mjs.map +1 -0
  288. package/dist/{workspace-mFpI_ky_.cjs → schemas-BCwKKA42.mjs} +399 -1162
  289. package/dist/schemas-BCwKKA42.mjs.map +1 -0
  290. package/dist/{workspace-CgwmXEtc.mjs → schemas-BQ_v0lEX.cjs} +487 -971
  291. package/dist/schemas-BQ_v0lEX.cjs.map +1 -0
  292. package/dist/secretsManager-CQORubp9.mjs +97 -0
  293. package/dist/secretsManager-CQORubp9.mjs.map +1 -0
  294. package/dist/secretsManager-RAGcEDX1.cjs +108 -0
  295. package/dist/secretsManager-RAGcEDX1.cjs.map +1 -0
  296. package/dist/seeds-B3xvUAQf.cjs +363 -0
  297. package/dist/seeds-B3xvUAQf.cjs.map +1 -0
  298. package/dist/seeds-BCC8vAXR.mjs +298 -0
  299. package/dist/seeds-BCC8vAXR.mjs.map +1 -0
  300. package/dist/serverSetup-CUBu8_Mk.cjs +652 -0
  301. package/dist/serverSetup-CUBu8_Mk.cjs.map +1 -0
  302. package/dist/serverSetup-eh9MUdSN.mjs +652 -0
  303. package/dist/serverSetup-eh9MUdSN.mjs.map +1 -0
  304. package/dist/sniffer-CNTnUmhc.mjs +1824 -0
  305. package/dist/sniffer-CNTnUmhc.mjs.map +1 -0
  306. package/dist/sniffer-CaoQH_kk.cjs +1997 -0
  307. package/dist/sniffer-CaoQH_kk.cjs.map +1 -0
  308. package/dist/snsSubscriptions-DiqwM9Ms.cjs +1173 -0
  309. package/dist/snsSubscriptions-DiqwM9Ms.cjs.map +1 -0
  310. package/dist/snsSubscriptions-zOIIswN0.mjs +1048 -0
  311. package/dist/snsSubscriptions-zOIIswN0.mjs.map +1 -0
  312. package/dist/sst-D6Dvhr6H.mjs +462 -0
  313. package/dist/sst-D6Dvhr6H.mjs.map +1 -0
  314. package/dist/sst-DECRMgjv.cjs +485 -0
  315. package/dist/sst-DECRMgjv.cjs.map +1 -0
  316. package/dist/stack-BZG5HoVN.mjs +2206 -0
  317. package/dist/stack-BZG5HoVN.mjs.map +1 -0
  318. package/dist/stack-CLk9WojF.cjs +2381 -0
  319. package/dist/stack-CLk9WojF.cjs.map +1 -0
  320. package/dist/stage-Cl0DPJ7w.cjs +313 -0
  321. package/dist/stage-Cl0DPJ7w.cjs.map +1 -0
  322. package/dist/stage-DiLPb89O.mjs +302 -0
  323. package/dist/stage-DiLPb89O.mjs.map +1 -0
  324. package/dist/stages-Bs1THSy7.cjs +190 -0
  325. package/dist/stages-Bs1THSy7.cjs.map +1 -0
  326. package/dist/stages-_xCG4Ymu.mjs +190 -0
  327. package/dist/stages-_xCG4Ymu.mjs.map +1 -0
  328. package/dist/target/public.cjs +15 -0
  329. package/dist/target/public.d.cts +28 -0
  330. package/dist/target/public.d.cts.map +1 -0
  331. package/dist/target/public.d.mts +28 -0
  332. package/dist/target/public.d.mts.map +1 -0
  333. package/dist/target/public.mjs +4 -0
  334. package/dist/terminal-XQE106CG.cjs +85 -0
  335. package/dist/terminal-XQE106CG.cjs.map +1 -0
  336. package/dist/terminal-jGj9TtMQ.mjs +85 -0
  337. package/dist/terminal-jGj9TtMQ.mjs.map +1 -0
  338. package/dist/types-Bl_CwZC9.cjs +90 -0
  339. package/dist/types-Bl_CwZC9.cjs.map +1 -0
  340. package/dist/{types-BGo5TaNE.d.mts → types-Dk--xVOT.d.cts} +2234 -439
  341. package/dist/types-Dk--xVOT.d.cts.map +1 -0
  342. package/dist/{types-C5ZNpUad.d.cts → types-DwQYpd_0.d.mts} +2232 -439
  343. package/dist/types-DwQYpd_0.d.mts.map +1 -0
  344. package/dist/types-Y1NfWlyG.mjs +61 -0
  345. package/dist/types-Y1NfWlyG.mjs.map +1 -0
  346. package/dist/utils-D2Nk1Nv2.cjs +205 -0
  347. package/dist/utils-D2Nk1Nv2.cjs.map +1 -0
  348. package/dist/utils-D_fxUqvU.mjs +156 -0
  349. package/dist/utils-D_fxUqvU.mjs.map +1 -0
  350. package/dist/vitest.cjs +65 -0
  351. package/dist/vitest.cjs.map +1 -0
  352. package/dist/vitest.d.cts +29 -0
  353. package/dist/vitest.d.cts.map +1 -0
  354. package/dist/vitest.d.mts +29 -0
  355. package/dist/vitest.d.mts.map +1 -0
  356. package/dist/vitest.mjs +65 -0
  357. package/dist/vitest.mjs.map +1 -0
  358. package/dist/workerRuntime-BXfhbe13.cjs +108 -0
  359. package/dist/workerRuntime-BXfhbe13.cjs.map +1 -0
  360. package/dist/workerRuntime-CsOyBRx2.mjs +79 -0
  361. package/dist/workerRuntime-CsOyBRx2.mjs.map +1 -0
  362. package/dist/workspace/index.cjs +6 -2
  363. package/dist/workspace/index.d.cts +3 -3
  364. package/dist/workspace/index.d.mts +3 -3
  365. package/dist/workspace/index.mjs +2 -2
  366. package/dist/workspace-1szcahj9.cjs +2916 -0
  367. package/dist/workspace-1szcahj9.cjs.map +1 -0
  368. package/dist/workspace-DFGsrjGD.mjs +2480 -0
  369. package/dist/workspace-DFGsrjGD.mjs.map +1 -0
  370. package/package.json +66 -14
  371. package/dist/HostingerProvider-BY26bWwB.mjs.map +0 -1
  372. package/dist/HostingerProvider-BZFGYYVA.cjs.map +0 -1
  373. package/dist/LocalStateProvider-7HR6SS2t.cjs +0 -48
  374. package/dist/LocalStateProvider-7HR6SS2t.cjs.map +0 -1
  375. package/dist/LocalStateProvider-D7QyJoLM.mjs +0 -48
  376. package/dist/LocalStateProvider-D7QyJoLM.mjs.map +0 -1
  377. package/dist/Route53Provider-Cvj40A8I.mjs.map +0 -1
  378. package/dist/Route53Provider-DVILBsvV.cjs.map +0 -1
  379. package/dist/SSMStateProvider-B0Hu1MKZ.mjs +0 -75
  380. package/dist/SSMStateProvider-B0Hu1MKZ.mjs.map +0 -1
  381. package/dist/SSMStateProvider-VrQ-yeqd.cjs +0 -74
  382. package/dist/SSMStateProvider-VrQ-yeqd.cjs.map +0 -1
  383. package/dist/backup-provisioner-BmhIO_Yr.cjs.map +0 -1
  384. package/dist/backup-provisioner-DIVCbfee.mjs.map +0 -1
  385. package/dist/bundler-BeNDZdHQ.cjs.map +0 -1
  386. package/dist/bundler-BodTL4kf.mjs.map +0 -1
  387. package/dist/config-Q1rvKHvw.cjs +0 -467
  388. package/dist/config-Q1rvKHvw.cjs.map +0 -1
  389. package/dist/config-pqGD3hF9.mjs +0 -414
  390. package/dist/config-pqGD3hF9.mjs.map +0 -1
  391. package/dist/config.d.cts.map +0 -1
  392. package/dist/config.d.mts.map +0 -1
  393. package/dist/credentials-BekkKtY_.mjs +0 -2780
  394. package/dist/credentials-BekkKtY_.mjs.map +0 -1
  395. package/dist/credentials-Q6F0uqJq.cjs +0 -2917
  396. package/dist/credentials-Q6F0uqJq.cjs.map +0 -1
  397. package/dist/discover-BERGFg8v.cjs +0 -288
  398. package/dist/discover-BERGFg8v.cjs.map +0 -1
  399. package/dist/discover-CK-n3w6b.mjs +0 -244
  400. package/dist/discover-CK-n3w6b.mjs.map +0 -1
  401. package/dist/emit-BdoPFjZf.cjs +0 -253
  402. package/dist/emit-BdoPFjZf.cjs.map +0 -1
  403. package/dist/emit-Bzq7JsMP.mjs +0 -224
  404. package/dist/emit-Bzq7JsMP.mjs.map +0 -1
  405. package/dist/fullstack-secrets-BET8gqwK.mjs +0 -81
  406. package/dist/fullstack-secrets-BET8gqwK.mjs.map +0 -1
  407. package/dist/fullstack-secrets-DXsWO-5m.cjs +0 -92
  408. package/dist/fullstack-secrets-DXsWO-5m.cjs.map +0 -1
  409. package/dist/generator-LfZU7NlU.mjs +0 -247
  410. package/dist/generator-LfZU7NlU.mjs.map +0 -1
  411. package/dist/generator-Wdfp0jCS.cjs +0 -282
  412. package/dist/generator-Wdfp0jCS.cjs.map +0 -1
  413. package/dist/github-BfflNPVe.cjs +0 -203
  414. package/dist/github-BfflNPVe.cjs.map +0 -1
  415. package/dist/github-CRwnxKmD.mjs +0 -203
  416. package/dist/github-CRwnxKmD.mjs.map +0 -1
  417. package/dist/index-Cd-qeOam.d.mts.map +0 -1
  418. package/dist/index-D-iAVHx-.d.cts.map +0 -1
  419. package/dist/keystore-B4PRlbgE.mjs +0 -81
  420. package/dist/keystore-B4PRlbgE.mjs.map +0 -1
  421. package/dist/keystore-DgGRj2Yy.cjs +0 -98
  422. package/dist/keystore-DgGRj2Yy.cjs.map +0 -1
  423. package/dist/openapi-Dcbme-Us.cjs +0 -2038
  424. package/dist/openapi-Dcbme-Us.cjs.map +0 -1
  425. package/dist/openapi-vy4JzhUv.mjs +0 -1991
  426. package/dist/openapi-vy4JzhUv.mjs.map +0 -1
  427. package/dist/storage-C-30BD1e.cjs +0 -272
  428. package/dist/storage-C-30BD1e.cjs.map +0 -1
  429. package/dist/storage-P_b3w7uj.mjs +0 -231
  430. package/dist/storage-P_b3w7uj.mjs.map +0 -1
  431. package/dist/sync-B3xxXtJT.mjs +0 -88
  432. package/dist/sync-B3xxXtJT.mjs.map +0 -1
  433. package/dist/sync-D7uTIIEi.cjs +0 -111
  434. package/dist/sync-D7uTIIEi.cjs.map +0 -1
  435. package/dist/types-BGo5TaNE.d.mts.map +0 -1
  436. package/dist/types-C5ZNpUad.d.cts.map +0 -1
  437. package/dist/workspace-CgwmXEtc.mjs.map +0 -1
  438. package/dist/workspace-mFpI_ky_.cjs.map +0 -1
@@ -1,5 +1,5 @@
1
- import { n as getHostingerToken } from "./index.mjs";
2
- //#region src/deploy/dns/hostinger-api.ts
1
+ import { ft as getHostingerToken, t as MissingCredential } from "./credentials-DRfP9aG7.mjs";
2
+ //#region src/target/dokploy/dns/hostinger-api.ts
3
3
  /**
4
4
  * Hostinger DNS API client
5
5
  *
@@ -147,25 +147,39 @@ var HostingerApi = class {
147
147
  }
148
148
  };
149
149
  //#endregion
150
- //#region src/deploy/dns/HostingerProvider.ts
150
+ //#region src/target/dokploy/dns/HostingerProvider.ts
151
151
  /**
152
152
  * Hostinger DNS Provider
153
153
  *
154
- * Implements DnsProvider interface using the Hostinger DNS API.
154
+ * Implements DnsProvider interface using the Hostinger DNS API. A record's
155
+ * `content` is its zone-file value — an MX record's is `<priority> <host>`,
156
+ * Hostinger having no field of its own for the priority — so values pass
157
+ * through as they are. Each write replaces its one name and type
158
+ * (`overwrite: true`): without it Hostinger appends, and a record with
159
+ * another value would end up holding both.
155
160
  */
161
+ /** A value compared the way DNS does: case, a trailing dot and spacing aside. */
162
+ function normalize(value) {
163
+ return value.trim().replace(/\.$/, "").replace(/\s+/g, " ").toLowerCase();
164
+ }
156
165
  /**
157
166
  * Hostinger DNS provider implementation.
158
167
  */
159
168
  var HostingerProvider = class {
169
+ credential;
160
170
  name = "hostinger";
161
171
  api = null;
172
+ /** `credential`: the token, when the caller already has it. */
173
+ constructor(credential) {
174
+ this.credential = credential;
175
+ }
162
176
  /**
163
177
  * Get or create the Hostinger API client.
164
178
  */
165
179
  async getApi() {
166
180
  if (this.api) return this.api;
167
- const token = await getHostingerToken();
168
- if (!token) throw new Error("Hostinger API token not configured. Run `gkm login --service=hostinger` or get your token from https://hpanel.hostinger.com/profile/api");
181
+ const token = this.credential?.token ?? await getHostingerToken();
182
+ if (!token) throw new MissingCredential("hostinger", void 0);
169
183
  this.api = new HostingerApi(token);
170
184
  return this.api;
171
185
  }
@@ -184,7 +198,7 @@ var HostingerProvider = class {
184
198
  for (const record of records) {
185
199
  const existing = existingRecords.find((r) => r.name === record.name && r.type === record.type);
186
200
  const existingValue = existing?.records?.[0]?.content;
187
- if (existing && existingValue === record.value) {
201
+ if (existing && existingValue !== void 0 && normalize(existingValue) === normalize(record.value)) {
188
202
  results.push({
189
203
  record,
190
204
  created: false,
@@ -197,7 +211,7 @@ var HostingerProvider = class {
197
211
  type: record.type,
198
212
  ttl: record.ttl,
199
213
  records: [{ content: record.value }]
200
- }]);
214
+ }], true);
201
215
  results.push({
202
216
  record,
203
217
  created: !existing,
@@ -240,4 +254,4 @@ var HostingerProvider = class {
240
254
  //#endregion
241
255
  export { HostingerProvider };
242
256
 
243
- //# sourceMappingURL=HostingerProvider-BY26bWwB.mjs.map
257
+ //# sourceMappingURL=HostingerProvider-C-C4aiKF.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HostingerProvider-C-C4aiKF.mjs","names":[],"sources":["../src/target/dokploy/dns/hostinger-api.ts","../src/target/dokploy/dns/HostingerProvider.ts"],"sourcesContent":["/**\n * Hostinger DNS API client\n *\n * API Documentation: https://developers.hostinger.com/\n * Authentication: Bearer token from hpanel.hostinger.com/profile/api\n */\n\nconst HOSTINGER_API_BASE = 'https://developers.hostinger.com';\n\n/**\n * DNS record types supported by Hostinger\n */\nexport type DnsRecordType =\n\t| 'A'\n\t| 'AAAA'\n\t| 'CNAME'\n\t| 'MX'\n\t| 'TXT'\n\t| 'NS'\n\t| 'SRV'\n\t| 'CAA';\n\n/**\n * A single DNS record\n */\nexport interface DnsRecord {\n\t/** Subdomain name (e.g., 'api.joemoer' for api.joemoer.traflabs.io) */\n\tname: string;\n\t/** Record type */\n\ttype: DnsRecordType;\n\t/** TTL in seconds */\n\tttl: number;\n\t/** Record values */\n\trecords: Array<{ content: string }>;\n}\n\n/**\n * Filter for deleting specific records\n */\nexport interface DnsRecordFilter {\n\tname: string;\n\ttype: DnsRecordType;\n}\n\n/**\n * API error response\n */\nexport interface HostingerErrorResponse {\n\tmessage?: string;\n\terrors?: Record<string, string[]>;\n}\n\n/**\n * Hostinger API error\n */\nexport class HostingerApiError extends Error {\n\tconstructor(\n\t\tmessage: string,\n\t\tpublic status: number,\n\t\tpublic statusText: string,\n\t\tpublic errors?: Record<string, string[]>,\n\t) {\n\t\tsuper(message);\n\t\tthis.name = 'HostingerApiError';\n\t}\n}\n\n/**\n * Hostinger DNS API client\n *\n * @example\n * ```ts\n * const api = new HostingerApi(token);\n *\n * // Get all records for a domain\n * const records = await api.getRecords('traflabs.io');\n *\n * // Create/update records\n * await api.upsertRecords('traflabs.io', [\n * { name: 'api.joemoer', type: 'A', ttl: 300, records: ['1.2.3.4'] }\n * ]);\n * ```\n */\nexport class HostingerApi {\n\tprivate token: string;\n\n\tconstructor(token: string) {\n\t\tthis.token = token;\n\t}\n\n\t/**\n\t * Make a request to the Hostinger API\n\t */\n\tprivate async request<T>(\n\t\tmethod: 'GET' | 'POST' | 'PUT' | 'DELETE',\n\t\tendpoint: string,\n\t\tbody?: unknown,\n\t): Promise<T> {\n\t\tconst url = `${HOSTINGER_API_BASE}${endpoint}`;\n\n\t\tconst response = await fetch(url, {\n\t\t\tmethod,\n\t\t\theaders: {\n\t\t\t\t'Content-Type': 'application/json',\n\t\t\t\tAuthorization: `Bearer ${this.token}`,\n\t\t\t},\n\t\t\tbody: body ? JSON.stringify(body) : undefined,\n\t\t});\n\n\t\tif (!response.ok) {\n\t\t\tlet errorMessage = `Hostinger API error: ${response.status} ${response.statusText}`;\n\t\t\tlet errors: Record<string, string[]> | undefined;\n\n\t\t\ttry {\n\t\t\t\tconst errorBody = (await response.json()) as HostingerErrorResponse;\n\t\t\t\tif (errorBody.message) {\n\t\t\t\t\terrorMessage = `Hostinger API error: ${errorBody.message}`;\n\t\t\t\t}\n\t\t\t\terrors = errorBody.errors;\n\t\t\t} catch {\n\t\t\t\t// Ignore JSON parse errors\n\t\t\t}\n\n\t\t\tthrow new HostingerApiError(\n\t\t\t\terrorMessage,\n\t\t\t\tresponse.status,\n\t\t\t\tresponse.statusText,\n\t\t\t\terrors,\n\t\t\t);\n\t\t}\n\n\t\t// Handle empty responses\n\t\tconst text = await response.text();\n\t\tif (!text || text.trim() === '') {\n\t\t\treturn undefined as T;\n\t\t}\n\t\treturn JSON.parse(text) as T;\n\t}\n\n\t/**\n\t * Get all DNS records for a domain\n\t *\n\t * @param domain - Root domain (e.g., 'traflabs.io')\n\t */\n\tasync getRecords(domain: string): Promise<DnsRecord[]> {\n\t\t// The zone comes back as a **bare array**, not `{ data: [...] }`.\n\t\t//\n\t\t// This read `response.data || []`, so every call returned zero records\n\t\t// against the real API while every mocked test passed. Silently: no error,\n\t\t// no warning, just an empty zone. `upsertRecords` uses this to decide what\n\t\t// already exists, so everything looked new and every write was reported as\n\t\t// a creation — harmless only because the PUT merges rather than replaces.\n\t\t//\n\t\t// Both shapes are accepted because one of them is a guess: the wrapper was\n\t\t// written against documentation and the array is what the API actually\n\t\t// sends, so tolerating an envelope costs a line and survives it appearing.\n\t\tconst response = await this.request<DnsRecord[] | { data?: DnsRecord[] }>(\n\t\t\t'GET',\n\t\t\t`/api/dns/v1/zones/${domain}`,\n\t\t);\n\n\t\tif (Array.isArray(response)) return response;\n\n\t\treturn response?.data ?? [];\n\t}\n\n\t/**\n\t * Create or update DNS records\n\t *\n\t * @param domain - Root domain (e.g., 'traflabs.io')\n\t * @param records - Records to create/update\n\t * @param overwrite - If true, replaces all existing records. If false, merges with existing.\n\t */\n\tasync upsertRecords(\n\t\tdomain: string,\n\t\trecords: DnsRecord[],\n\t\toverwrite = false,\n\t): Promise<void> {\n\t\tawait this.request('PUT', `/api/dns/v1/zones/${domain}`, {\n\t\t\toverwrite,\n\t\t\tzone: records,\n\t\t});\n\t}\n\n\t/**\n\t * Validate DNS records before applying\n\t *\n\t * @param domain - Root domain (e.g., 'traflabs.io')\n\t * @param records - Records to validate\n\t * @returns true if valid, throws if invalid\n\t */\n\tasync validateRecords(\n\t\tdomain: string,\n\t\trecords: DnsRecord[],\n\t): Promise<boolean> {\n\t\tawait this.request('POST', `/api/dns/v1/zones/${domain}/validate`, {\n\t\t\toverwrite: false,\n\t\t\tzone: records,\n\t\t});\n\t\treturn true;\n\t}\n\n\t/**\n\t * Delete specific DNS records\n\t *\n\t * @param domain - Root domain (e.g., 'traflabs.io')\n\t * @param filters - Filters to match records for deletion\n\t */\n\tasync deleteRecords(\n\t\tdomain: string,\n\t\tfilters: DnsRecordFilter[],\n\t): Promise<void> {\n\t\tawait this.request('DELETE', `/api/dns/v1/zones/${domain}`, {\n\t\t\tfilters,\n\t\t});\n\t}\n\n\t/**\n\t * Check if a specific record exists\n\t *\n\t * @param domain - Root domain (e.g., 'traflabs.io')\n\t * @param name - Subdomain name (e.g., 'api.joemoer')\n\t * @param type - Record type (e.g., 'A')\n\t */\n\tasync recordExists(\n\t\tdomain: string,\n\t\tname: string,\n\t\ttype: DnsRecordType = 'A',\n\t): Promise<boolean> {\n\t\tconst records = await this.getRecords(domain);\n\t\treturn records.some((r) => r.name === name && r.type === type);\n\t}\n\n\t/**\n\t * Create a single A record if it doesn't exist\n\t *\n\t * @param domain - Root domain (e.g., 'traflabs.io')\n\t * @param subdomain - Subdomain name (e.g., 'api.joemoer')\n\t * @param ip - IP address to point to\n\t * @param ttl - TTL in seconds (default: 300)\n\t * @returns true if created, false if already exists\n\t */\n\tasync createARecordIfNotExists(\n\t\tdomain: string,\n\t\tsubdomain: string,\n\t\tip: string,\n\t\tttl = 300,\n\t): Promise<boolean> {\n\t\tconst exists = await this.recordExists(domain, subdomain, 'A');\n\t\tif (exists) {\n\t\t\treturn false;\n\t\t}\n\n\t\tawait this.upsertRecords(domain, [\n\t\t\t{\n\t\t\t\tname: subdomain,\n\t\t\t\ttype: 'A',\n\t\t\t\tttl,\n\t\t\t\trecords: [{ content: ip }],\n\t\t\t},\n\t\t]);\n\n\t\treturn true;\n\t}\n}\n","/**\n * Hostinger DNS Provider\n *\n * Implements DnsProvider interface using the Hostinger DNS API. A record's\n * `content` is its zone-file value — an MX record's is `<priority> <host>`,\n * Hostinger having no field of its own for the priority — so values pass\n * through as they are. Each write replaces its one name and type\n * (`overwrite: true`): without it Hostinger appends, and a record with\n * another value would end up holding both.\n */\n\nimport { getHostingerToken } from '../../../auth/credentials';\nimport {\n\ttype HostingerCredential,\n\tMissingCredential,\n} from '../../../deploy/credentials';\nimport type {\n\tDeleteDnsRecord,\n\tDeleteResult,\n\tDnsProvider,\n\tDnsRecord,\n\tUpsertDnsRecord,\n\tUpsertResult,\n} from './DnsProvider';\nimport { HostingerApi } from './hostinger-api';\n\n/** A value compared the way DNS does: case, a trailing dot and spacing aside. */\nfunction normalize(value: string): string {\n\treturn value.trim().replace(/\\.$/, '').replace(/\\s+/g, ' ').toLowerCase();\n}\n\n/**\n * Hostinger DNS provider implementation.\n */\nexport class HostingerProvider implements DnsProvider {\n\treadonly name = 'hostinger';\n\tprivate api: HostingerApi | null = null;\n\n\t/** `credential`: the token, when the caller already has it. */\n\tconstructor(private readonly credential?: HostingerCredential) {}\n\n\t/**\n\t * Get or create the Hostinger API client.\n\t */\n\tprivate async getApi(): Promise<HostingerApi> {\n\t\tif (this.api) {\n\t\t\treturn this.api;\n\t\t}\n\n\t\tconst token = this.credential?.token ?? (await getHostingerToken());\n\t\tif (!token) throw new MissingCredential('hostinger', undefined);\n\n\t\tthis.api = new HostingerApi(token);\n\t\treturn this.api;\n\t}\n\n\tasync getRecords(domain: string): Promise<DnsRecord[]> {\n\t\tconst api = await this.getApi();\n\t\tconst records = await api.getRecords(domain);\n\n\t\treturn records.map((r) => ({\n\t\t\tname: r.name,\n\t\t\ttype: r.type,\n\t\t\tttl: r.ttl,\n\t\t\tvalues: r.records.map((rec) => rec.content),\n\t\t}));\n\t}\n\n\tasync upsertRecords(\n\t\tdomain: string,\n\t\trecords: UpsertDnsRecord[],\n\t): Promise<UpsertResult[]> {\n\t\tconst api = await this.getApi();\n\t\tconst results: UpsertResult[] = [];\n\n\t\t// Get existing records to check what already exists\n\t\tconst existingRecords = await api.getRecords(domain);\n\n\t\tfor (const record of records) {\n\t\t\tconst existing = existingRecords.find(\n\t\t\t\t(r) => r.name === record.name && r.type === record.type,\n\t\t\t);\n\n\t\t\tconst existingValue = existing?.records?.[0]?.content;\n\n\t\t\tif (\n\t\t\t\texisting &&\n\t\t\t\texistingValue !== undefined &&\n\t\t\t\tnormalize(existingValue) === normalize(record.value)\n\t\t\t) {\n\t\t\t\t// Record exists with same value - unchanged\n\t\t\t\tresults.push({\n\t\t\t\t\trecord,\n\t\t\t\t\tcreated: false,\n\t\t\t\t\tunchanged: true,\n\t\t\t\t});\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// Create the record, or replace this name's records of this type.\n\t\t\tawait api.upsertRecords(\n\t\t\t\tdomain,\n\t\t\t\t[\n\t\t\t\t\t{\n\t\t\t\t\t\tname: record.name,\n\t\t\t\t\t\ttype: record.type,\n\t\t\t\t\t\tttl: record.ttl,\n\t\t\t\t\t\trecords: [{ content: record.value }],\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\ttrue,\n\t\t\t);\n\n\t\t\tresults.push({\n\t\t\t\trecord,\n\t\t\t\tcreated: !existing,\n\t\t\t\tunchanged: false,\n\t\t\t});\n\t\t}\n\n\t\treturn results;\n\t}\n\n\tasync deleteRecords(\n\t\tdomain: string,\n\t\trecords: DeleteDnsRecord[],\n\t): Promise<DeleteResult[]> {\n\t\tconst api = await this.getApi();\n\t\tconst results: DeleteResult[] = [];\n\n\t\t// Get existing records to check what exists\n\t\tconst existingRecords = await api.getRecords(domain);\n\n\t\t// Filter to only records that exist\n\t\tconst recordsToDelete = records.filter((record) =>\n\t\t\texistingRecords.some(\n\t\t\t\t(r) => r.name === record.name && r.type === record.type,\n\t\t\t),\n\t\t);\n\n\t\t// Delete existing records\n\t\tif (recordsToDelete.length > 0) {\n\t\t\ttry {\n\t\t\t\tawait api.deleteRecords(\n\t\t\t\t\tdomain,\n\t\t\t\t\trecordsToDelete.map((r) => ({\n\t\t\t\t\t\tname: r.name,\n\t\t\t\t\t\ttype: r.type as\n\t\t\t\t\t\t\t| 'A'\n\t\t\t\t\t\t\t| 'AAAA'\n\t\t\t\t\t\t\t| 'CNAME'\n\t\t\t\t\t\t\t| 'MX'\n\t\t\t\t\t\t\t| 'TXT'\n\t\t\t\t\t\t\t| 'SRV'\n\t\t\t\t\t\t\t| 'CAA',\n\t\t\t\t\t})),\n\t\t\t\t);\n\n\t\t\t\tfor (const record of recordsToDelete) {\n\t\t\t\t\tresults.push({\n\t\t\t\t\t\trecord,\n\t\t\t\t\t\tdeleted: true,\n\t\t\t\t\t\tnotFound: false,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\t// If batch delete fails, report error for all records\n\t\t\t\tfor (const record of recordsToDelete) {\n\t\t\t\t\tresults.push({\n\t\t\t\t\t\trecord,\n\t\t\t\t\t\tdeleted: false,\n\t\t\t\t\t\tnotFound: false,\n\t\t\t\t\t\terror: String(error),\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Mark non-existent records as not found\n\t\tfor (const record of records) {\n\t\t\tconst existing = existingRecords.find(\n\t\t\t\t(r) => r.name === record.name && r.type === record.type,\n\t\t\t);\n\t\t\tif (!existing) {\n\t\t\t\tresults.push({\n\t\t\t\t\trecord,\n\t\t\t\t\tdeleted: false,\n\t\t\t\t\tnotFound: true,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\treturn results;\n\t}\n}\n"],"mappings":";;;;;;;;AAOA,MAAM,qBAAqB;;;;AAgD3B,IAAa,oBAAb,cAAuC,MAAM;CAGpC;CACA;CACA;CAJR,YACC,SACA,QACA,YACA,QACC;EACD,MAAM,OAAO;EAJN,KAAA,SAAA;EACA,KAAA,aAAA;EACA,KAAA,SAAA;EAGP,KAAK,OAAO;CACb;AACD;;;;;;;;;;;;;;;;;AAkBA,IAAa,eAAb,MAA0B;CACzB;CAEA,YAAY,OAAe;EAC1B,KAAK,QAAQ;CACd;;;;CAKA,MAAc,QACb,QACA,UACA,MACa;EACb,MAAM,MAAM,GAAG,qBAAqB;EAEpC,MAAM,WAAW,MAAM,MAAM,KAAK;GACjC;GACA,SAAS;IACR,gBAAgB;IAChB,eAAe,UAAU,KAAK;GAC/B;GACA,MAAM,OAAO,KAAK,UAAU,IAAI,IAAI,KAAA;EACrC,CAAC;EAED,IAAI,CAAC,SAAS,IAAI;GACjB,IAAI,eAAe,wBAAwB,SAAS,OAAO,GAAG,SAAS;GACvE,IAAI;GAEJ,IAAI;IACH,MAAM,YAAa,MAAM,SAAS,KAAK;IACvC,IAAI,UAAU,SACb,eAAe,wBAAwB,UAAU;IAElD,SAAS,UAAU;GACpB,QAAQ,CAER;GAEA,MAAM,IAAI,kBACT,cACA,SAAS,QACT,SAAS,YACT,MACD;EACD;EAGA,MAAM,OAAO,MAAM,SAAS,KAAK;EACjC,IAAI,CAAC,QAAQ,KAAK,KAAK,MAAM,IAC5B;EAED,OAAO,KAAK,MAAM,IAAI;CACvB;;;;;;CAOA,MAAM,WAAW,QAAsC;EAYtD,MAAM,WAAW,MAAM,KAAK,QAC3B,OACA,qBAAqB,QACtB;EAEA,IAAI,MAAM,QAAQ,QAA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AAS,OAAO,QAAQ,EAAE,SAAS,OAAO,IACpD,CACD;EAGA,IAAI,gBAAgB,SAAS,GAC5B,IAAI;GACH,MAAM,IAAI,cACT,QACA,gBAAgB,KAAK,OAAO;IAC3B,MAAM,EAAE;IACR,MAAM,EAAE;GAQT,EAAE,CACH;GAEA,KAAK,MAAM,UAAU,iBACpB,QAAQ,KAAK;IACZ;IACA,SAAS;IACT,UAAU;GACX,CAAC;EAEH,SAAS,OAAO;GAEf,KAAK,MAAM,UAAU,iBACpB,QAAQ,KAAK;IACZ;IACA,SAAS;IACT,UAAU;IACV,OAAO,OAAO,KAAK;GACpB,CAAC;EAEH;EAID,KAAK,MAAM,UAAU,SAIpB,IAAI,CAHa,gBAAgB,MAC/B,MAAM,EAAE,SAAS,OAAO,QAAQ,EAAE,SAAS,OAAO,IAExC,GACX,QAAQ,KAAK;GACZ;GACA,SAAS;GACT,UAAU;EACX,CAAC;EAIH,OAAO;CACR;AACD"}
@@ -0,0 +1,124 @@
1
+ import { T as upgradeV2State, _ as appendHistory, d as StageStateMissing, g as StateVersionConflict, h as StateStoreWithoutLocking, w as newLockHolder, x as contentVersion } from "./sniffer-CNTnUmhc.mjs";
2
+ import { c as currentActor } from "./seeds-BCC8vAXR.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-BFkNiBxC.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LegacyStateStore-BFkNiBxC.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,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IAAI,qBAAqB,OAAO,UAAU,MAAM;CAExD;CAEA,MAAc,IACb,OACA,SACA,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,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_sniffer = require("./sniffer-CaoQH_kk.cjs");
2
+ const require_seeds = require("./seeds-B3xvUAQf.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-DYaamZqR.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LegacyStateStore-DYaamZqR.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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jJH2R.mjs";
2
+ import { f as StateLocked, g as StateVersionConflict, l as DocumentStateStore, m as StateStoreBusy, x as contentVersion } from "./sniffer-CNTnUmhc.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-7pP4naiB.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LocalStateStore-7pP4naiB.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,OAA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