@geekmidas/cli 10.0.0-alpha.126 → 10.0.0-alpha.127

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 (207) hide show
  1. package/dist/{EndpointGenerator-errMeldx.mjs → EndpointGenerator-B99OGzbO.mjs} +2 -2
  2. package/dist/{EndpointGenerator-errMeldx.mjs.map → EndpointGenerator-B99OGzbO.mjs.map} +1 -1
  3. package/dist/{EndpointGenerator-BGxf9jWE.cjs → EndpointGenerator-De0lknKD.cjs} +2 -2
  4. package/dist/{EndpointGenerator-BGxf9jWE.cjs.map → EndpointGenerator-De0lknKD.cjs.map} +1 -1
  5. package/dist/{GoDaddyProvider-CvRVmN4W.mjs → GoDaddyProvider-BG-UdElN.mjs} +2 -2
  6. package/dist/{GoDaddyProvider-CvRVmN4W.mjs.map → GoDaddyProvider-BG-UdElN.mjs.map} +1 -1
  7. package/dist/{GoDaddyProvider-DFfpzCOP.cjs → GoDaddyProvider-DnmLq7eo.cjs} +2 -2
  8. package/dist/{GoDaddyProvider-DFfpzCOP.cjs.map → GoDaddyProvider-DnmLq7eo.cjs.map} +1 -1
  9. package/dist/{LegacyStateStore-BFrCHrFQ.cjs → LegacyStateStore-CeBkK9K2.cjs} +3 -3
  10. package/dist/{LegacyStateStore-BFrCHrFQ.cjs.map → LegacyStateStore-CeBkK9K2.cjs.map} +1 -1
  11. package/dist/{LegacyStateStore-CgfENrXF.mjs → LegacyStateStore-DHG_4jcn.mjs} +3 -3
  12. package/dist/{LegacyStateStore-CgfENrXF.mjs.map → LegacyStateStore-DHG_4jcn.mjs.map} +1 -1
  13. package/dist/{LocalStateStore-DxoNpiBg.mjs → LocalStateStore-EenTHwr4.mjs} +2 -2
  14. package/dist/{LocalStateStore-DxoNpiBg.mjs.map → LocalStateStore-EenTHwr4.mjs.map} +1 -1
  15. package/dist/{LocalStateStore-BU5z_IOE.cjs → LocalStateStore-HRnBQFe3.cjs} +2 -2
  16. package/dist/{LocalStateStore-BU5z_IOE.cjs.map → LocalStateStore-HRnBQFe3.cjs.map} +1 -1
  17. package/dist/{OpenApiTsGenerator-cQgtxWQo.cjs → OpenApiTsGenerator-DMLzN-LU.cjs} +2 -2
  18. package/dist/{OpenApiTsGenerator-cQgtxWQo.cjs.map → OpenApiTsGenerator-DMLzN-LU.cjs.map} +1 -1
  19. package/dist/{OpenApiTsGenerator-W_HRXH1X.mjs → OpenApiTsGenerator-DNUCgkkx.mjs} +2 -2
  20. package/dist/{OpenApiTsGenerator-W_HRXH1X.mjs.map → OpenApiTsGenerator-DNUCgkkx.mjs.map} +1 -1
  21. package/dist/{S3StateStore-DiekMLpn.cjs → S3StateStore-DyLljVN1.cjs} +2 -2
  22. package/dist/{S3StateStore-DiekMLpn.cjs.map → S3StateStore-DyLljVN1.cjs.map} +1 -1
  23. package/dist/{S3StateStore-CGMSDilh.mjs → S3StateStore-vbkyBnRB.mjs} +2 -2
  24. package/dist/{S3StateStore-CGMSDilh.mjs.map → S3StateStore-vbkyBnRB.mjs.map} +1 -1
  25. package/dist/{SSMStateStore-BDCOFdKq.cjs → SSMStateStore-BBKlmfaU.cjs} +2 -2
  26. package/dist/{SSMStateStore-BDCOFdKq.cjs.map → SSMStateStore-BBKlmfaU.cjs.map} +1 -1
  27. package/dist/{SSMStateStore-Cq2H9MlF.mjs → SSMStateStore-uk2QLUgz.mjs} +2 -2
  28. package/dist/{SSMStateStore-Cq2H9MlF.mjs.map → SSMStateStore-uk2QLUgz.mjs.map} +1 -1
  29. package/dist/{SubscriberGenerator-BALddfuW.mjs → SubscriberGenerator-0ruEmYXj.mjs} +3 -3
  30. package/dist/{SubscriberGenerator-BALddfuW.mjs.map → SubscriberGenerator-0ruEmYXj.mjs.map} +1 -1
  31. package/dist/{SubscriberGenerator-LgyTxZ8r.cjs → SubscriberGenerator-CPjbWEOI.cjs} +3 -3
  32. package/dist/{SubscriberGenerator-LgyTxZ8r.cjs.map → SubscriberGenerator-CPjbWEOI.cjs.map} +1 -1
  33. package/dist/{add-BsiBYkAW.cjs → add-CH7-9AHI.cjs} +7 -7
  34. package/dist/add-CH7-9AHI.cjs.map +1 -0
  35. package/dist/{add-CamA9Uqv.mjs → add-CgyyN6aF.mjs} +7 -7
  36. package/dist/add-CgyyN6aF.mjs.map +1 -0
  37. package/dist/{bundler-CijtdIZ2.cjs → bundler-BtAkF9wb.cjs} +5 -5
  38. package/dist/{bundler-CijtdIZ2.cjs.map → bundler-BtAkF9wb.cjs.map} +1 -1
  39. package/dist/{bundler-2V2PR_E-.mjs → bundler-DqHozK8W.mjs} +5 -5
  40. package/dist/{bundler-2V2PR_E-.mjs.map → bundler-DqHozK8W.mjs.map} +1 -1
  41. package/dist/{cli-7gc1QG8X.cjs → cli-D08bMg7m.cjs} +3 -3
  42. package/dist/{cli-7gc1QG8X.cjs.map → cli-D08bMg7m.cjs.map} +1 -1
  43. package/dist/{cli-PiyYqHGx.mjs → cli-D_BQkb4B.mjs} +3 -3
  44. package/dist/{cli-PiyYqHGx.mjs.map → cli-D_BQkb4B.mjs.map} +1 -1
  45. package/dist/{compose-8e2xJ61E.cjs → compose-BK9s_2Qe.cjs} +68 -40
  46. package/dist/compose-BK9s_2Qe.cjs.map +1 -0
  47. package/dist/{compose-CvHIjMDd.mjs → compose-CIzCcsoz.mjs} +68 -40
  48. package/dist/compose-CIzCcsoz.mjs.map +1 -0
  49. package/dist/{config-_y1FGBWR.d.mts → config-B8fXmuK0.d.cts} +3 -3
  50. package/dist/{config-CdytFgSR.d.cts.map → config-B8fXmuK0.d.cts.map} +1 -1
  51. package/dist/{config-CdytFgSR.d.cts → config-CRRxZMk7.d.mts} +3 -3
  52. package/dist/{config-_y1FGBWR.d.mts.map → config-CRRxZMk7.d.mts.map} +1 -1
  53. package/dist/config.cjs +2 -2
  54. package/dist/config.d.cts +3 -3
  55. package/dist/config.d.mts +3 -3
  56. package/dist/config.mjs +2 -2
  57. package/dist/{credentialSchemas-DFxvGEwa.cjs → credentialSchemas-CM0rxWmS.cjs} +2 -2
  58. package/dist/{credentialSchemas-DFxvGEwa.cjs.map → credentialSchemas-CM0rxWmS.cjs.map} +1 -1
  59. package/dist/{credentialSchemas-DaMpt-Dx.mjs → credentialSchemas-DPOGqOrU.mjs} +2 -2
  60. package/dist/{credentialSchemas-DaMpt-Dx.mjs.map → credentialSchemas-DPOGqOrU.mjs.map} +1 -1
  61. package/dist/deploy/public.cjs +8 -8
  62. package/dist/deploy/public.d.cts +3 -3
  63. package/dist/deploy/public.d.mts +3 -3
  64. package/dist/deploy/public.mjs +8 -8
  65. package/dist/{deploy-wSlIRPn5.cjs → deploy-A_fzSa59.cjs} +10 -10
  66. package/dist/deploy-A_fzSa59.cjs.map +1 -0
  67. package/dist/{deploy-CIPwTJ47.mjs → deploy-BVf6c_h8.mjs} +10 -10
  68. package/dist/deploy-BVf6c_h8.mjs.map +1 -0
  69. package/dist/{derive-DAbo49sm.cjs → derive-BtGidITm.cjs} +7 -7
  70. package/dist/derive-BtGidITm.cjs.map +1 -0
  71. package/dist/{derive-B4vDpzgP.mjs → derive-Dew0QoGe.mjs} +7 -7
  72. package/dist/derive-Dew0QoGe.mjs.map +1 -0
  73. package/dist/{discover-DL6h-J97.cjs → discover-DEOspD9M.cjs} +12 -1
  74. package/dist/discover-DEOspD9M.cjs.map +1 -0
  75. package/dist/{discover-CzGM5P3p.mjs → discover-DOhYSKY_.mjs} +12 -1
  76. package/dist/discover-DOhYSKY_.mjs.map +1 -0
  77. package/dist/{dokploy-BKbUrz05.cjs → dokploy-CshlFRwr.cjs} +2 -2
  78. package/dist/{dokploy-BKbUrz05.cjs.map → dokploy-CshlFRwr.cjs.map} +1 -1
  79. package/dist/{dokploy-BZf1AHd0.mjs → dokploy-DOndleTd.mjs} +2 -2
  80. package/dist/{dokploy-BZf1AHd0.mjs.map → dokploy-DOndleTd.mjs.map} +1 -1
  81. package/dist/{eas-DzDMGzfc.cjs → eas-ApfPYR4-.cjs} +3 -3
  82. package/dist/{eas-DzDMGzfc.cjs.map → eas-ApfPYR4-.cjs.map} +1 -1
  83. package/dist/{eas-CxX2RCE_.mjs → eas-Dlr1Lw56.mjs} +3 -3
  84. package/dist/{eas-CxX2RCE_.mjs.map → eas-Dlr1Lw56.mjs.map} +1 -1
  85. package/dist/{encryption-BFSrt89F.mjs → encryption-D0tWRvy_.mjs} +2 -2
  86. package/dist/{encryption-BFSrt89F.mjs.map → encryption-D0tWRvy_.mjs.map} +1 -1
  87. package/dist/{encryption-RNcBnG4Z.cjs → encryption-SGWvnBxV.cjs} +2 -2
  88. package/dist/{encryption-RNcBnG4Z.cjs.map → encryption-SGWvnBxV.cjs.map} +1 -1
  89. package/dist/{engine-Dqe9KQCm.cjs → engine-CYu4wavP.cjs} +5 -5
  90. package/dist/{engine-Dqe9KQCm.cjs.map → engine-CYu4wavP.cjs.map} +1 -1
  91. package/dist/{engine-_0pjyCd_.mjs → engine-DKz1NYDX.mjs} +5 -5
  92. package/dist/{engine-_0pjyCd_.mjs.map → engine-DKz1NYDX.mjs.map} +1 -1
  93. package/dist/{github-Csev5EFf.cjs → github-CxWaWQtW.cjs} +5 -5
  94. package/dist/{github-Csev5EFf.cjs.map → github-CxWaWQtW.cjs.map} +1 -1
  95. package/dist/{github-Dck0nLW9.mjs → github-VQaj8gLE.mjs} +5 -5
  96. package/dist/{github-Dck0nLW9.mjs.map → github-VQaj8gLE.mjs.map} +1 -1
  97. package/dist/{googlePlay-DBtDAGBk.cjs → googlePlay-4KVtZ89D.cjs} +3 -3
  98. package/dist/{googlePlay-DBtDAGBk.cjs.map → googlePlay-4KVtZ89D.cjs.map} +1 -1
  99. package/dist/{googlePlay-DTuvDHi5.mjs → googlePlay-Nqc4EAiC.mjs} +3 -3
  100. package/dist/{googlePlay-DTuvDHi5.mjs.map → googlePlay-Nqc4EAiC.mjs.map} +1 -1
  101. package/dist/{index-DrkV7N5w.d.mts → index-Cu8eIwUW.d.mts} +2 -2
  102. package/dist/{index-DrkV7N5w.d.mts.map → index-Cu8eIwUW.d.mts.map} +1 -1
  103. package/dist/{index-yaXZ9m-J.d.cts → index-Dx93n3Ur.d.cts} +2 -2
  104. package/dist/{index-yaXZ9m-J.d.cts.map → index-Dx93n3Ur.d.cts.map} +1 -1
  105. package/dist/index.cjs +101 -73
  106. package/dist/index.cjs.map +1 -1
  107. package/dist/index.mjs +101 -73
  108. package/dist/index.mjs.map +1 -1
  109. package/dist/{migrate-3ZEoqx5q.cjs → migrate-BQPRclv2.cjs} +2 -2
  110. package/dist/{migrate-3ZEoqx5q.cjs.map → migrate-BQPRclv2.cjs.map} +1 -1
  111. package/dist/{migrate-BABIuzQj.mjs → migrate-C7exqXTD.mjs} +2 -2
  112. package/dist/{migrate-BABIuzQj.mjs.map → migrate-C7exqXTD.mjs.map} +1 -1
  113. package/dist/{migrate-DZeNpuX2.mjs → migrate-DQPEUiFC.mjs} +3 -3
  114. package/dist/{migrate-DZeNpuX2.mjs.map → migrate-DQPEUiFC.mjs.map} +1 -1
  115. package/dist/{migrate-pGiUqvBi.cjs → migrate-DTv6LHux.cjs} +3 -3
  116. package/dist/{migrate-pGiUqvBi.cjs.map → migrate-DTv6LHux.cjs.map} +1 -1
  117. package/dist/openapi.cjs +3 -3
  118. package/dist/openapi.d.cts +1 -1
  119. package/dist/openapi.d.mts +1 -1
  120. package/dist/openapi.mjs +3 -3
  121. package/dist/{publish-CS6xDvGT.cjs → publish-CgwqwKDs.cjs} +2 -2
  122. package/dist/{publish-CS6xDvGT.cjs.map → publish-CgwqwKDs.cjs.map} +1 -1
  123. package/dist/{publish-BsnDeOVL.mjs → publish-VYt4xOOc.mjs} +2 -2
  124. package/dist/{publish-BsnDeOVL.mjs.map → publish-VYt4xOOc.mjs.map} +1 -1
  125. package/dist/{ready-DrvaAwKv.mjs → ready-BwtLriAF.mjs} +5 -5
  126. package/dist/{ready-DrvaAwKv.mjs.map → ready-BwtLriAF.mjs.map} +1 -1
  127. package/dist/{ready-CxPJm0Hc.cjs → ready-Cj4pI0dw.cjs} +5 -5
  128. package/dist/{ready-CxPJm0Hc.cjs.map → ready-Cj4pI0dw.cjs.map} +1 -1
  129. package/dist/reconcile/public.cjs +1 -1
  130. package/dist/reconcile/public.d.cts +1 -1
  131. package/dist/reconcile/public.d.mts +1 -1
  132. package/dist/reconcile/public.mjs +1 -1
  133. package/dist/{resolve-zqCMFio0.cjs → resolve-C-W3kZM7.cjs} +4 -4
  134. package/dist/{resolve-zqCMFio0.cjs.map → resolve-C-W3kZM7.cjs.map} +1 -1
  135. package/dist/{resolve-fCGJmM-R.mjs → resolve-CCVCc43b.mjs} +4 -4
  136. package/dist/{resolve-fCGJmM-R.mjs.map → resolve-CCVCc43b.mjs.map} +1 -1
  137. package/dist/{rollback-qc79mj6L.cjs → rollback-CdBj1Boy.cjs} +4 -4
  138. package/dist/{rollback-qc79mj6L.cjs.map → rollback-CdBj1Boy.cjs.map} +1 -1
  139. package/dist/{rollback-BkhVrtAf.mjs → rollback-dUShCpZu.mjs} +4 -4
  140. package/dist/{rollback-BkhVrtAf.mjs.map → rollback-dUShCpZu.mjs.map} +1 -1
  141. package/dist/{runtime-DCkfI2E7.d.mts → runtime-C_1PteGG.d.cts} +2 -2
  142. package/dist/{runtime-DCkfI2E7.d.mts.map → runtime-C_1PteGG.d.cts.map} +1 -1
  143. package/dist/{runtime-Ie4znWIB.d.cts → runtime-jjB2e3-M.d.mts} +2 -2
  144. package/dist/{runtime-Ie4znWIB.d.cts.map → runtime-jjB2e3-M.d.mts.map} +1 -1
  145. package/dist/sandbox/credentials-worker.cjs +2 -2
  146. package/dist/sandbox/credentials-worker.mjs +2 -2
  147. package/dist/sandbox/discover-worker.cjs +1 -1
  148. package/dist/sandbox/discover-worker.mjs +1 -1
  149. package/dist/sandbox/migrate-worker.cjs +1 -1
  150. package/dist/sandbox/migrate-worker.mjs +1 -1
  151. package/dist/{seeds-Cfejy8wj.mjs → seeds-BX9pskrU.mjs} +66 -27
  152. package/dist/seeds-BX9pskrU.mjs.map +1 -0
  153. package/dist/{seeds-3awh33Wz.cjs → seeds-sMVADbkg.cjs} +66 -27
  154. package/dist/seeds-sMVADbkg.cjs.map +1 -0
  155. package/dist/{serverSetup-BFQuwUeL.cjs → serverSetup-4avavig6.cjs} +25 -5
  156. package/dist/serverSetup-4avavig6.cjs.map +1 -0
  157. package/dist/{serverSetup-C8ZbHTm_.mjs → serverSetup-BvHpm7QD.mjs} +25 -5
  158. package/dist/serverSetup-BvHpm7QD.mjs.map +1 -0
  159. package/dist/{sniffer-Cq1nhxIB.cjs → sniffer-DWLala8l.cjs} +7 -7
  160. package/dist/{sniffer-Cq1nhxIB.cjs.map → sniffer-DWLala8l.cjs.map} +1 -1
  161. package/dist/{sniffer-CCkdzjiU.mjs → sniffer-XnAnEbuI.mjs} +7 -7
  162. package/dist/{sniffer-CCkdzjiU.mjs.map → sniffer-XnAnEbuI.mjs.map} +1 -1
  163. package/dist/{snsSubscriptions-R_AKBZYK.mjs → snsSubscriptions-BxLJQH4u.mjs} +3 -3
  164. package/dist/{snsSubscriptions-R_AKBZYK.mjs.map → snsSubscriptions-BxLJQH4u.mjs.map} +1 -1
  165. package/dist/{snsSubscriptions-DYyYP0Xf.cjs → snsSubscriptions-f_z4PSFb.cjs} +3 -3
  166. package/dist/{snsSubscriptions-DYyYP0Xf.cjs.map → snsSubscriptions-f_z4PSFb.cjs.map} +1 -1
  167. package/dist/{sst-lEkBwzGc.cjs → sst-DmVJRu5l.cjs} +2 -2
  168. package/dist/{sst-lEkBwzGc.cjs.map → sst-DmVJRu5l.cjs.map} +1 -1
  169. package/dist/{sst-CTqZZl1_.mjs → sst-fop6uZ25.mjs} +2 -2
  170. package/dist/{sst-CTqZZl1_.mjs.map → sst-fop6uZ25.mjs.map} +1 -1
  171. package/dist/{stage-BkgbVJ9Z.cjs → stage-ZWOE0oLB.cjs} +5 -5
  172. package/dist/{stage-BkgbVJ9Z.cjs.map → stage-ZWOE0oLB.cjs.map} +1 -1
  173. package/dist/{stage-DCaxqm-G.mjs → stage-mta618Oy.mjs} +5 -5
  174. package/dist/{stage-DCaxqm-G.mjs.map → stage-mta618Oy.mjs.map} +1 -1
  175. package/dist/target/public.cjs +1 -1
  176. package/dist/target/public.d.cts +2 -2
  177. package/dist/target/public.d.mts +2 -2
  178. package/dist/target/public.mjs +1 -1
  179. package/dist/{terminal-bqY33lpN.mjs → terminal-CebFDhWQ.mjs} +2 -2
  180. package/dist/{terminal-bqY33lpN.mjs.map → terminal-CebFDhWQ.mjs.map} +1 -1
  181. package/dist/{terminal-PKhPAajN.cjs → terminal-DBwedwSS.cjs} +2 -2
  182. package/dist/{terminal-PKhPAajN.cjs.map → terminal-DBwedwSS.cjs.map} +1 -1
  183. package/dist/{types-D0IsQxES.d.cts → types-DLANxOpy.d.mts} +7 -2
  184. package/dist/types-DLANxOpy.d.mts.map +1 -0
  185. package/dist/{types-Bmjs4jZV.d.mts → types-SEHMr6Aw.d.cts} +8 -1
  186. package/dist/types-SEHMr6Aw.d.cts.map +1 -0
  187. package/dist/vitest.cjs +1 -1
  188. package/dist/vitest.mjs +1 -1
  189. package/dist/workspace/index.d.cts +2 -2
  190. package/dist/workspace/index.d.mts +2 -2
  191. package/package.json +15 -15
  192. package/dist/add-BsiBYkAW.cjs.map +0 -1
  193. package/dist/add-CamA9Uqv.mjs.map +0 -1
  194. package/dist/compose-8e2xJ61E.cjs.map +0 -1
  195. package/dist/compose-CvHIjMDd.mjs.map +0 -1
  196. package/dist/deploy-CIPwTJ47.mjs.map +0 -1
  197. package/dist/deploy-wSlIRPn5.cjs.map +0 -1
  198. package/dist/derive-B4vDpzgP.mjs.map +0 -1
  199. package/dist/derive-DAbo49sm.cjs.map +0 -1
  200. package/dist/discover-CzGM5P3p.mjs.map +0 -1
  201. package/dist/discover-DL6h-J97.cjs.map +0 -1
  202. package/dist/seeds-3awh33Wz.cjs.map +0 -1
  203. package/dist/seeds-Cfejy8wj.mjs.map +0 -1
  204. package/dist/serverSetup-BFQuwUeL.cjs.map +0 -1
  205. package/dist/serverSetup-C8ZbHTm_.mjs.map +0 -1
  206. package/dist/types-Bmjs4jZV.d.mts.map +0 -1
  207. package/dist/types-D0IsQxES.d.cts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"resolve-fCGJmM-R.mjs","names":[],"sources":["../src/target/package.ts","../src/target/runtime.ts","../src/target/resolve.ts"],"sourcesContent":["/**\n * A target package, found the way the project would find it.\n *\n * From the workspace root, never from the CLI's own location or the process's\n * working directory: the package is the project's dependency, and a CLI run\n * through `pnpm dlx` — or a host deploying a checkout elsewhere — has neither\n * in common with the project.\n */\n\nimport { existsSync, readFileSync, realpathSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport { GkmError } from '../errors';\n\nexport interface TargetPackageManifest {\n\tname?: string;\n\tmain?: string;\n\tmodule?: string;\n\texports?: unknown;\n\tgkm?: { runtime?: unknown };\n}\n\nexport interface LocatedPackage {\n\t/** The package's directory, symlinks resolved. */\n\tdir: string;\n\tmanifest: TargetPackageManifest;\n}\n\n/** A target package the project does not have installed. */\nexport class TargetPackageNotFound extends GkmError {\n\tconstructor(\n\t\treadonly target: string,\n\t\treadonly packageName: string,\n\t\treadonly from: string,\n\t) {\n\t\tsuper(\n\t\t\t`deploy.targets.${target} names the package \"${packageName}\", which is not installed in ${from}. Add it to the workspace root: pnpm add -D ${packageName}`,\n\t\t);\n\t\tthis.name = 'TargetPackageNotFound';\n\t}\n}\n\n/**\n * `name`'s directory and `package.json`, from the nearest `node_modules` at\n * or above `from` — Node's own lookup, without the exports map getting in\n * the way of reading `package.json`.\n */\nexport function locatePackage(\n\tname: string,\n\tfrom: string,\n): LocatedPackage | undefined {\n\tlet dir = from;\n\twhile (true) {\n\t\tconst manifestPath = join(dir, 'node_modules', name, 'package.json');\n\t\tif (existsSync(manifestPath)) {\n\t\t\treturn {\n\t\t\t\tdir: realpathSync(dirname(manifestPath)),\n\t\t\t\tmanifest: JSON.parse(\n\t\t\t\t\treadFileSync(manifestPath, 'utf-8'),\n\t\t\t\t) as TargetPackageManifest,\n\t\t\t};\n\t\t}\n\t\tconst parent = dirname(dir);\n\t\tif (parent === dir) return undefined;\n\t\tdir = parent;\n\t}\n}\n\n/** The first file a conditions object leads to, as an `import` would. */\nfunction pick(node: unknown): string | undefined {\n\tif (typeof node === 'string') return node;\n\tif (Array.isArray(node)) {\n\t\tfor (const option of node) {\n\t\t\tconst found = pick(option);\n\t\t\tif (found) return found;\n\t\t}\n\t\treturn undefined;\n\t}\n\tif (node && typeof node === 'object') {\n\t\tconst conditions = node as Record<string, unknown>;\n\t\tfor (const condition of ['import', 'node', 'default', 'require']) {\n\t\t\tif (condition in conditions) {\n\t\t\t\tconst found = pick(conditions[condition]);\n\t\t\t\tif (found) return found;\n\t\t\t}\n\t\t}\n\t}\n\treturn undefined;\n}\n\n/** The file `import(name)` loads, relative to the package directory. */\nexport function packageEntry(manifest: TargetPackageManifest): string {\n\tconst { exports } = manifest;\n\tlet root: unknown = exports;\n\tif (exports && typeof exports === 'object' && !Array.isArray(exports)) {\n\t\tconst keys = Object.keys(exports);\n\t\t// A subpath map — `{ \".\": …, \"./x\": … }` — rather than one conditions\n\t\t// object for the root.\n\t\tif (keys.some((key) => key.startsWith('.'))) {\n\t\t\troot = (exports as Record<string, unknown>)['.'];\n\t\t}\n\t}\n\treturn pick(root) ?? manifest.module ?? manifest.main ?? 'index.js';\n}\n\n/** The module `name` is, imported from where the project would import it. */\nexport async function importPackage(\n\ttarget: string,\n\tname: string,\n\tfrom: string,\n): Promise<Record<string, unknown>> {\n\tconst located = locatePackage(name, from);\n\tif (!located) throw new TargetPackageNotFound(target, name, from);\n\n\tconst entry = join(located.dir, packageEntry(located.manifest));\n\treturn (await import(pathToFileURL(entry).href)) as Record<string, unknown>;\n}\n","/**\n * A target's runtime, without loading the target.\n *\n * `gkm dev` and `gkm build` choose a project's backends by it on every start,\n * synchronously, and must not import a deploy plugin to do so — a plugin may\n * pull in a cloud SDK, and a broken one would stop `gkm dev` for a project\n * that is only being developed. So a built-in's runtime is in the table, an\n * inline target carries its own, and a package declares it in its\n * `package.json`:\n *\n * ```json\n * { \"name\": \"@acme/gkm-target\", \"gkm\": { \"runtime\": \"server\" } }\n * ```\n */\n\nimport { GkmError } from '../errors';\nimport {\n\tbuiltinTarget,\n\tconfigurableBuiltins,\n\tconfiguredTarget,\n\tUnknownDeployTarget,\n} from './builtins';\nimport { locatePackage, TargetPackageNotFound } from './package';\nimport type { DeployRuntime, DeployTargetEntry } from './types';\n\nconst RUNTIMES: readonly DeployRuntime[] = ['server', 'aws'];\n\n/** A target package whose `package.json` does not say where it runs. */\nexport class TargetRuntimeUndeclared extends GkmError {\n\tconstructor(\n\t\treadonly target: string,\n\t\treadonly packageName: string,\n\t\t/** What `gkm.runtime` held instead, when it held anything. */\n\t\treadonly found?: unknown,\n\t) {\n\t\tsuper(\n\t\t\t`The deploy target \"${target}\" (${packageName}) does not declare its runtime${found === undefined ? '' : ` (gkm.runtime is ${JSON.stringify(found)})`}. Its package.json needs \"gkm\": { \"runtime\": \"server\" } or \"aws\", so gkm dev and gkm build can choose backends without loading it.`,\n\t\t);\n\t\tthis.name = 'TargetRuntimeUndeclared';\n\t}\n}\n\n/** What a workspace's deploy config is read for here. */\nexport interface TargetSource {\n\t/** Where the target packages are installed from. */\n\troot?: string;\n\tdeploy?:\n\t\t| { default?: string; targets?: Record<string, DeployTargetEntry> }\n\t\t| undefined;\n}\n\n/** The runtime a target package declares in `package.json#gkm.runtime`. */\nexport function declaredRuntime(\n\ttarget: string,\n\tpackageName: string,\n\troot: string | undefined,\n): DeployRuntime {\n\tconst located = root ? locatePackage(packageName, root) : undefined;\n\tif (!located) {\n\t\tthrow new TargetPackageNotFound(\n\t\t\ttarget,\n\t\t\tpackageName,\n\t\t\troot ?? 'the workspace',\n\t\t);\n\t}\n\tconst runtime = located.manifest.gkm?.runtime;\n\tif (!RUNTIMES.includes(runtime as DeployRuntime)) {\n\t\tthrow new TargetRuntimeUndeclared(target, packageName, runtime);\n\t}\n\treturn runtime as DeployRuntime;\n}\n\n/** The runtime of the target `name`, as the workspace resolves it. */\nexport function runtimeOf(\n\tname: string,\n\tworkspace: TargetSource,\n): DeployRuntime {\n\tconst builtin = builtinTarget(name);\n\tif (builtin) return builtin.runtime;\n\n\tconst entry = configuredTarget(workspace.deploy, name);\n\tif (entry === undefined) {\n\t\tthrow new UnknownDeployTarget(name, [\n\t\t\t...configurableBuiltins(),\n\t\t\t...Object.keys(workspace.deploy?.targets ?? {}),\n\t\t]);\n\t}\n\n\tconst implementation = Array.isArray(entry) ? entry[0] : entry;\n\treturn typeof implementation === 'string'\n\t\t? declaredRuntime(name, implementation, workspace.root)\n\t\t: (implementation as { runtime: DeployRuntime }).runtime;\n}\n","/**\n * From a target's name to the target.\n *\n * In this order, the first that has the name wins:\n *\n * 1. the host's own targets — what a program calling `deploy()` passes\n * 2. the built-ins — `dokploy`, `compose`, `sst`\n * 3. `deploy.targets` in gkm.config.ts — a package, an object, or either\n * with options\n *\n * Built-ins come before the config so that a dependency cannot take over\n * `dokploy` by being listed under its name. A name nothing has is\n * `UnknownDeployTarget`. There is deliberately no fourth step that guesses a\n * package from the name (`acme` → `@acme/gkm-target`): an npm scope nobody\n * has claimed can be claimed by anyone, and a deploy would then run their\n * code with the stage's credentials. A target is installed and named.\n */\n\nimport { GkmError } from '../errors';\nimport {\n\tbuiltinTarget,\n\tconfigurableBuiltins,\n\tconfiguredTarget,\n\tDeployTargetNotYetSupported,\n\tUnknownDeployTarget,\n} from './builtins';\nimport { isDeployTarget } from './define';\nimport { importPackage } from './package';\nimport { declaredRuntime } from './runtime';\nimport type {\n\tAnyDeployTarget,\n\tDeployRuntime,\n\tDeployTargetEntry,\n\tTargetOptionsIssue,\n} from './types';\n\n/** Where a target came from. */\nexport type TargetSourceKind = 'host' | 'builtin' | 'config';\n\nexport interface ResolvedTarget {\n\t/** The name it was asked for by. */\n\tname: string;\n\ttarget: AnyDeployTarget;\n\tsource: TargetSourceKind;\n\t/** Its options as written in the config, before its schema parsed them. */\n\toptions: unknown;\n}\n\nexport interface ResolveTargetOptions {\n\t/** The workspace whose `deploy.targets` is consulted. */\n\tworkspace: {\n\t\troot: string;\n\t\tdeploy?: { targets?: Record<string, DeployTargetEntry> } | undefined;\n\t};\n\t/** The host's targets, consulted first. */\n\thost?: Record<string, AnyDeployTarget>;\n\t/** The stage being deployed, for what to do instead of a refused target. */\n\tstage: string;\n}\n\n/** A target package whose default export is not a target. */\nexport class TargetPackageInvalid extends GkmError {\n\tconstructor(\n\t\treadonly target: string,\n\t\treadonly packageName: string,\n\t) {\n\t\tsuper(\n\t\t\t`deploy.targets.${target} names \"${packageName}\", whose default export is not a deploy target. A target package exports one as default: export default defineTarget({ … }) from '@geekmidas/cli/target'.`,\n\t\t);\n\t\tthis.name = 'TargetPackageInvalid';\n\t}\n}\n\n/** A `deploy.targets` entry that is not a target, a package name or a pair. */\nexport class TargetEntryInvalid extends GkmError {\n\tconstructor(readonly target: string) {\n\t\tsuper(\n\t\t\t`deploy.targets.${target} must be a package name, a target object (defineTarget), or [package or target, options].`,\n\t\t);\n\t\tthis.name = 'TargetEntryInvalid';\n\t}\n}\n\n/** A target whose `runtime` is not the one its package declares. */\nexport class TargetRuntimeMismatch extends GkmError {\n\tconstructor(\n\t\treadonly target: string,\n\t\treadonly packageName: string,\n\t\treadonly declared: DeployRuntime,\n\t\treadonly actual: DeployRuntime,\n\t) {\n\t\tsuper(\n\t\t\t`The deploy target \"${target}\" runs on \"${actual}\", but ${packageName}'s package.json declares gkm.runtime \"${declared}\". gkm dev and gkm build chose backends for \"${declared}\", so the two must agree — fix the package.`,\n\t\t);\n\t\tthis.name = 'TargetRuntimeMismatch';\n\t}\n}\n\n/** Options a target's schema rejected. */\nexport class InvalidTargetOptions extends GkmError {\n\tconstructor(\n\t\treadonly target: string,\n\t\treadonly issues: readonly TargetOptionsIssue[],\n\t) {\n\t\tconst lines = issues.map((issue) => {\n\t\t\tconst path = (issue.path ?? [])\n\t\t\t\t.map((segment) =>\n\t\t\t\t\ttypeof segment === 'object' ? String(segment.key) : String(segment),\n\t\t\t\t)\n\t\t\t\t.join('.');\n\t\t\treturn ` - ${path ? `${path}: ` : ''}${issue.message}`;\n\t\t});\n\t\tsuper(\n\t\t\t`The options for deploy target \"${target}\" are invalid — fix them in deploy.targets.${target} in gkm.config.ts:\\n${lines.join('\\n')}`,\n\t\t);\n\t\tthis.name = 'InvalidTargetOptions';\n\t}\n}\n\n/** The built-ins `gkm deploy` deploys through, loaded only when used. */\nconst BUILTIN_LOADERS: Record<string, () => Promise<AnyDeployTarget>> = {\n\tdokploy: async () => (await import('./dokploy')).dokployTarget,\n\tcompose: async () => (await import('./compose/index')).composeTarget(),\n\tsst: async () => (await import('./sst/index')).sstTarget,\n};\n\n/** The target `name` means, in this workspace, for this host. */\nexport async function resolveTarget(\n\tname: string,\n\t{ workspace, host, stage }: ResolveTargetOptions,\n): Promise<ResolvedTarget> {\n\tif (host && Object.hasOwn(host, name)) {\n\t\treturn { name, target: host[name]!, source: 'host', options: undefined };\n\t}\n\n\tconst builtin = builtinTarget(name);\n\tif (builtin) {\n\t\tconst load = BUILTIN_LOADERS[name];\n\t\tif (builtin.status !== 'available' || !load) {\n\t\t\tthrow new DeployTargetNotYetSupported(name, builtin.instead?.(stage));\n\t\t}\n\t\treturn {\n\t\t\tname,\n\t\t\ttarget: await load(),\n\t\t\tsource: 'builtin',\n\t\t\toptions: undefined,\n\t\t};\n\t}\n\n\tconst entry = configuredTarget(workspace.deploy, name);\n\tif (entry === undefined) {\n\t\tthrow new UnknownDeployTarget(name, [\n\t\t\t...configurableBuiltins(),\n\t\t\t...Object.keys(workspace.deploy?.targets ?? {}),\n\t\t]);\n\t}\n\n\tconst [implementation, options] = Array.isArray(entry)\n\t\t? (entry as readonly [unknown, unknown])\n\t\t: [entry, undefined];\n\n\tif (typeof implementation === 'string') {\n\t\t// Before the import: a package that does not say where it runs is\n\t\t// refused without running any of its code.\n\t\tconst declared = declaredRuntime(name, implementation, workspace.root);\n\t\tconst loaded = await importPackage(name, implementation, workspace.root);\n\t\tconst target = loaded.default;\n\t\tif (!isDeployTarget(target)) {\n\t\t\tthrow new TargetPackageInvalid(name, implementation);\n\t\t}\n\t\tif (target.runtime !== declared) {\n\t\t\tthrow new TargetRuntimeMismatch(\n\t\t\t\tname,\n\t\t\t\timplementation,\n\t\t\t\tdeclared,\n\t\t\t\ttarget.runtime,\n\t\t\t);\n\t\t}\n\t\treturn { name, target, source: 'config', options };\n\t}\n\n\tif (!isDeployTarget(implementation)) throw new TargetEntryInvalid(name);\n\treturn { name, target: implementation, source: 'config', options };\n}\n\n/** The target's options, parsed by its schema. */\nexport async function parseTargetOptions(\n\tresolved: ResolvedTarget,\n): Promise<unknown> {\n\tconst { name, target, options } = resolved;\n\tif (!target.options) {\n\t\tif (options !== undefined) {\n\t\t\tthrow new InvalidTargetOptions(name, [\n\t\t\t\t{ message: 'this target takes no options' },\n\t\t\t]);\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tconst result = await target.options['~standard'].validate(options);\n\tif (result.issues) throw new InvalidTargetOptions(name, result.issues);\n\treturn result.value;\n}\n"],"mappings":";;;;;;;;;;;;;;;AA6BA,IAAa,wBAAb,cAA2C,SAAS;CAEzC;CACA;CACA;CAHV,YACC,QACA,aACA,MACC;EACD,MACC,kBAAkB,OAAO,sBAAsB,YAAY,+BAA+B,KAAK,8CAA8C,aAC9I;EANS,KAAA,SAAA;EACA,KAAA,cAAA;EACA,KAAA,OAAA;EAKT,KAAK,OAAO;CACb;AACD;;;;;;AAOA,SAAgB,cACf,MACA,MAC6B;CAC7B,IAAI,MAAM;CACV,OAAO,MAAM;EACZ,MAAM,eAAe,KAAK,KAAK,gBAAgB,MAAM,cAAc;EACnE,IAAI,WAAW,YAAY,GAC1B,OAAO;GACN,KAAK,aAAa,QAAQ,YAAY,CAAC;GACvC,UAAU,KAAK,MACd,aAAa,cAAc,OAAO,CACnC;EACD;EAED,MAAM,SAAS,QAAQ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 {"version":3,"file":"resolve-CCVCc43b.mjs","names":[],"sources":["../src/target/package.ts","../src/target/runtime.ts","../src/target/resolve.ts"],"sourcesContent":["/**\n * A target package, found the way the project would find it.\n *\n * From the workspace root, never from the CLI's own location or the process's\n * working directory: the package is the project's dependency, and a CLI run\n * through `pnpm dlx` — or a host deploying a checkout elsewhere — has neither\n * in common with the project.\n */\n\nimport { existsSync, readFileSync, realpathSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport { GkmError } from '../errors';\n\nexport interface TargetPackageManifest {\n\tname?: string;\n\tmain?: string;\n\tmodule?: string;\n\texports?: unknown;\n\tgkm?: { runtime?: unknown };\n}\n\nexport interface LocatedPackage {\n\t/** The package's directory, symlinks resolved. */\n\tdir: string;\n\tmanifest: TargetPackageManifest;\n}\n\n/** A target package the project does not have installed. */\nexport class TargetPackageNotFound extends GkmError {\n\tconstructor(\n\t\treadonly target: string,\n\t\treadonly packageName: string,\n\t\treadonly from: string,\n\t) {\n\t\tsuper(\n\t\t\t`deploy.targets.${target} names the package \"${packageName}\", which is not installed in ${from}. Add it to the workspace root: pnpm add -D ${packageName}`,\n\t\t);\n\t\tthis.name = 'TargetPackageNotFound';\n\t}\n}\n\n/**\n * `name`'s directory and `package.json`, from the nearest `node_modules` at\n * or above `from` — Node's own lookup, without the exports map getting in\n * the way of reading `package.json`.\n */\nexport function locatePackage(\n\tname: string,\n\tfrom: string,\n): LocatedPackage | undefined {\n\tlet dir = from;\n\twhile (true) {\n\t\tconst manifestPath = join(dir, 'node_modules', name, 'package.json');\n\t\tif (existsSync(manifestPath)) {\n\t\t\treturn {\n\t\t\t\tdir: realpathSync(dirname(manifestPath)),\n\t\t\t\tmanifest: JSON.parse(\n\t\t\t\t\treadFileSync(manifestPath, 'utf-8'),\n\t\t\t\t) as TargetPackageManifest,\n\t\t\t};\n\t\t}\n\t\tconst parent = dirname(dir);\n\t\tif (parent === dir) return undefined;\n\t\tdir = parent;\n\t}\n}\n\n/** The first file a conditions object leads to, as an `import` would. */\nfunction pick(node: unknown): string | undefined {\n\tif (typeof node === 'string') return node;\n\tif (Array.isArray(node)) {\n\t\tfor (const option of node) {\n\t\t\tconst found = pick(option);\n\t\t\tif (found) return found;\n\t\t}\n\t\treturn undefined;\n\t}\n\tif (node && typeof node === 'object') {\n\t\tconst conditions = node as Record<string, unknown>;\n\t\tfor (const condition of ['import', 'node', 'default', 'require']) {\n\t\t\tif (condition in conditions) {\n\t\t\t\tconst found = pick(conditions[condition]);\n\t\t\t\tif (found) return found;\n\t\t\t}\n\t\t}\n\t}\n\treturn undefined;\n}\n\n/** The file `import(name)` loads, relative to the package directory. */\nexport function packageEntry(manifest: TargetPackageManifest): string {\n\tconst { exports } = manifest;\n\tlet root: unknown = exports;\n\tif (exports && typeof exports === 'object' && !Array.isArray(exports)) {\n\t\tconst keys = Object.keys(exports);\n\t\t// A subpath map — `{ \".\": …, \"./x\": … }` — rather than one conditions\n\t\t// object for the root.\n\t\tif (keys.some((key) => key.startsWith('.'))) {\n\t\t\troot = (exports as Record<string, unknown>)['.'];\n\t\t}\n\t}\n\treturn pick(root) ?? manifest.module ?? manifest.main ?? 'index.js';\n}\n\n/** The module `name` is, imported from where the project would import it. */\nexport async function importPackage(\n\ttarget: string,\n\tname: string,\n\tfrom: string,\n): Promise<Record<string, unknown>> {\n\tconst located = locatePackage(name, from);\n\tif (!located) throw new TargetPackageNotFound(target, name, from);\n\n\tconst entry = join(located.dir, packageEntry(located.manifest));\n\treturn (await import(pathToFileURL(entry).href)) as Record<string, unknown>;\n}\n","/**\n * A target's runtime, without loading the target.\n *\n * `gkm dev` and `gkm build` choose a project's backends by it on every start,\n * synchronously, and must not import a deploy plugin to do so — a plugin may\n * pull in a cloud SDK, and a broken one would stop `gkm dev` for a project\n * that is only being developed. So a built-in's runtime is in the table, an\n * inline target carries its own, and a package declares it in its\n * `package.json`:\n *\n * ```json\n * { \"name\": \"@acme/gkm-target\", \"gkm\": { \"runtime\": \"server\" } }\n * ```\n */\n\nimport { GkmError } from '../errors';\nimport {\n\tbuiltinTarget,\n\tconfigurableBuiltins,\n\tconfiguredTarget,\n\tUnknownDeployTarget,\n} from './builtins';\nimport { locatePackage, TargetPackageNotFound } from './package';\nimport type { DeployRuntime, DeployTargetEntry } from './types';\n\nconst RUNTIMES: readonly DeployRuntime[] = ['server', 'aws'];\n\n/** A target package whose `package.json` does not say where it runs. */\nexport class TargetRuntimeUndeclared extends GkmError {\n\tconstructor(\n\t\treadonly target: string,\n\t\treadonly packageName: string,\n\t\t/** What `gkm.runtime` held instead, when it held anything. */\n\t\treadonly found?: unknown,\n\t) {\n\t\tsuper(\n\t\t\t`The deploy target \"${target}\" (${packageName}) does not declare its runtime${found === undefined ? '' : ` (gkm.runtime is ${JSON.stringify(found)})`}. Its package.json needs \"gkm\": { \"runtime\": \"server\" } or \"aws\", so gkm dev and gkm build can choose backends without loading it.`,\n\t\t);\n\t\tthis.name = 'TargetRuntimeUndeclared';\n\t}\n}\n\n/** What a workspace's deploy config is read for here. */\nexport interface TargetSource {\n\t/** Where the target packages are installed from. */\n\troot?: string;\n\tdeploy?:\n\t\t| { default?: string; targets?: Record<string, DeployTargetEntry> }\n\t\t| undefined;\n}\n\n/** The runtime a target package declares in `package.json#gkm.runtime`. */\nexport function declaredRuntime(\n\ttarget: string,\n\tpackageName: string,\n\troot: string | undefined,\n): DeployRuntime {\n\tconst located = root ? locatePackage(packageName, root) : undefined;\n\tif (!located) {\n\t\tthrow new TargetPackageNotFound(\n\t\t\ttarget,\n\t\t\tpackageName,\n\t\t\troot ?? 'the workspace',\n\t\t);\n\t}\n\tconst runtime = located.manifest.gkm?.runtime;\n\tif (!RUNTIMES.includes(runtime as DeployRuntime)) {\n\t\tthrow new TargetRuntimeUndeclared(target, packageName, runtime);\n\t}\n\treturn runtime as DeployRuntime;\n}\n\n/** The runtime of the target `name`, as the workspace resolves it. */\nexport function runtimeOf(\n\tname: string,\n\tworkspace: TargetSource,\n): DeployRuntime {\n\tconst builtin = builtinTarget(name);\n\tif (builtin) return builtin.runtime;\n\n\tconst entry = configuredTarget(workspace.deploy, name);\n\tif (entry === undefined) {\n\t\tthrow new UnknownDeployTarget(name, [\n\t\t\t...configurableBuiltins(),\n\t\t\t...Object.keys(workspace.deploy?.targets ?? {}),\n\t\t]);\n\t}\n\n\tconst implementation = Array.isArray(entry) ? entry[0] : entry;\n\treturn typeof implementation === 'string'\n\t\t? declaredRuntime(name, implementation, workspace.root)\n\t\t: (implementation as { runtime: DeployRuntime }).runtime;\n}\n","/**\n * From a target's name to the target.\n *\n * In this order, the first that has the name wins:\n *\n * 1. the host's own targets — what a program calling `deploy()` passes\n * 2. the built-ins — `dokploy`, `compose`, `sst`\n * 3. `deploy.targets` in gkm.config.ts — a package, an object, or either\n * with options\n *\n * Built-ins come before the config so that a dependency cannot take over\n * `dokploy` by being listed under its name. A name nothing has is\n * `UnknownDeployTarget`. There is deliberately no fourth step that guesses a\n * package from the name (`acme` → `@acme/gkm-target`): an npm scope nobody\n * has claimed can be claimed by anyone, and a deploy would then run their\n * code with the stage's credentials. A target is installed and named.\n */\n\nimport { GkmError } from '../errors';\nimport {\n\tbuiltinTarget,\n\tconfigurableBuiltins,\n\tconfiguredTarget,\n\tDeployTargetNotYetSupported,\n\tUnknownDeployTarget,\n} from './builtins';\nimport { isDeployTarget } from './define';\nimport { importPackage } from './package';\nimport { declaredRuntime } from './runtime';\nimport type {\n\tAnyDeployTarget,\n\tDeployRuntime,\n\tDeployTargetEntry,\n\tTargetOptionsIssue,\n} from './types';\n\n/** Where a target came from. */\nexport type TargetSourceKind = 'host' | 'builtin' | 'config';\n\nexport interface ResolvedTarget {\n\t/** The name it was asked for by. */\n\tname: string;\n\ttarget: AnyDeployTarget;\n\tsource: TargetSourceKind;\n\t/** Its options as written in the config, before its schema parsed them. */\n\toptions: unknown;\n}\n\nexport interface ResolveTargetOptions {\n\t/** The workspace whose `deploy.targets` is consulted. */\n\tworkspace: {\n\t\troot: string;\n\t\tdeploy?: { targets?: Record<string, DeployTargetEntry> } | undefined;\n\t};\n\t/** The host's targets, consulted first. */\n\thost?: Record<string, AnyDeployTarget>;\n\t/** The stage being deployed, for what to do instead of a refused target. */\n\tstage: string;\n}\n\n/** A target package whose default export is not a target. */\nexport class TargetPackageInvalid extends GkmError {\n\tconstructor(\n\t\treadonly target: string,\n\t\treadonly packageName: string,\n\t) {\n\t\tsuper(\n\t\t\t`deploy.targets.${target} names \"${packageName}\", whose default export is not a deploy target. A target package exports one as default: export default defineTarget({ … }) from '@geekmidas/cli/target'.`,\n\t\t);\n\t\tthis.name = 'TargetPackageInvalid';\n\t}\n}\n\n/** A `deploy.targets` entry that is not a target, a package name or a pair. */\nexport class TargetEntryInvalid extends GkmError {\n\tconstructor(readonly target: string) {\n\t\tsuper(\n\t\t\t`deploy.targets.${target} must be a package name, a target object (defineTarget), or [package or target, options].`,\n\t\t);\n\t\tthis.name = 'TargetEntryInvalid';\n\t}\n}\n\n/** A target whose `runtime` is not the one its package declares. */\nexport class TargetRuntimeMismatch extends GkmError {\n\tconstructor(\n\t\treadonly target: string,\n\t\treadonly packageName: string,\n\t\treadonly declared: DeployRuntime,\n\t\treadonly actual: DeployRuntime,\n\t) {\n\t\tsuper(\n\t\t\t`The deploy target \"${target}\" runs on \"${actual}\", but ${packageName}'s package.json declares gkm.runtime \"${declared}\". gkm dev and gkm build chose backends for \"${declared}\", so the two must agree — fix the package.`,\n\t\t);\n\t\tthis.name = 'TargetRuntimeMismatch';\n\t}\n}\n\n/** Options a target's schema rejected. */\nexport class InvalidTargetOptions extends GkmError {\n\tconstructor(\n\t\treadonly target: string,\n\t\treadonly issues: readonly TargetOptionsIssue[],\n\t) {\n\t\tconst lines = issues.map((issue) => {\n\t\t\tconst path = (issue.path ?? [])\n\t\t\t\t.map((segment) =>\n\t\t\t\t\ttypeof segment === 'object' ? String(segment.key) : String(segment),\n\t\t\t\t)\n\t\t\t\t.join('.');\n\t\t\treturn ` - ${path ? `${path}: ` : ''}${issue.message}`;\n\t\t});\n\t\tsuper(\n\t\t\t`The options for deploy target \"${target}\" are invalid — fix them in deploy.targets.${target} in gkm.config.ts:\\n${lines.join('\\n')}`,\n\t\t);\n\t\tthis.name = 'InvalidTargetOptions';\n\t}\n}\n\n/** The built-ins `gkm deploy` deploys through, loaded only when used. */\nconst BUILTIN_LOADERS: Record<string, () => Promise<AnyDeployTarget>> = {\n\tdokploy: async () => (await import('./dokploy')).dokployTarget,\n\tcompose: async () => (await import('./compose/index')).composeTarget(),\n\tsst: async () => (await import('./sst/index')).sstTarget,\n};\n\n/** The target `name` means, in this workspace, for this host. */\nexport async function resolveTarget(\n\tname: string,\n\t{ workspace, host, stage }: ResolveTargetOptions,\n): Promise<ResolvedTarget> {\n\tif (host && Object.hasOwn(host, name)) {\n\t\treturn { name, target: host[name]!, source: 'host', options: undefined };\n\t}\n\n\tconst builtin = builtinTarget(name);\n\tif (builtin) {\n\t\tconst load = BUILTIN_LOADERS[name];\n\t\tif (builtin.status !== 'available' || !load) {\n\t\t\tthrow new DeployTargetNotYetSupported(name, builtin.instead?.(stage));\n\t\t}\n\t\treturn {\n\t\t\tname,\n\t\t\ttarget: await load(),\n\t\t\tsource: 'builtin',\n\t\t\toptions: undefined,\n\t\t};\n\t}\n\n\tconst entry = configuredTarget(workspace.deploy, name);\n\tif (entry === undefined) {\n\t\tthrow new UnknownDeployTarget(name, [\n\t\t\t...configurableBuiltins(),\n\t\t\t...Object.keys(workspace.deploy?.targets ?? {}),\n\t\t]);\n\t}\n\n\tconst [implementation, options] = Array.isArray(entry)\n\t\t? (entry as readonly [unknown, unknown])\n\t\t: [entry, undefined];\n\n\tif (typeof implementation === 'string') {\n\t\t// Before the import: a package that does not say where it runs is\n\t\t// refused without running any of its code.\n\t\tconst declared = declaredRuntime(name, implementation, workspace.root);\n\t\tconst loaded = await importPackage(name, implementation, workspace.root);\n\t\tconst target = loaded.default;\n\t\tif (!isDeployTarget(target)) {\n\t\t\tthrow new TargetPackageInvalid(name, implementation);\n\t\t}\n\t\tif (target.runtime !== declared) {\n\t\t\tthrow new TargetRuntimeMismatch(\n\t\t\t\tname,\n\t\t\t\timplementation,\n\t\t\t\tdeclared,\n\t\t\t\ttarget.runtime,\n\t\t\t);\n\t\t}\n\t\treturn { name, target, source: 'config', options };\n\t}\n\n\tif (!isDeployTarget(implementation)) throw new TargetEntryInvalid(name);\n\treturn { name, target: implementation, source: 'config', options };\n}\n\n/** The target's options, parsed by its schema. */\nexport async function parseTargetOptions(\n\tresolved: ResolvedTarget,\n): Promise<unknown> {\n\tconst { name, target, options } = resolved;\n\tif (!target.options) {\n\t\tif (options !== undefined) {\n\t\t\tthrow new InvalidTargetOptions(name, [\n\t\t\t\t{ message: 'this target takes no options' },\n\t\t\t]);\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tconst result = await target.options['~standard'].validate(options);\n\tif (result.issues) throw new InvalidTargetOptions(name, result.issues);\n\treturn result.value;\n}\n"],"mappings":";;;;;;;;;;;;;;;AA6BA,IAAa,wBAAb,cAA2C,SAAS;CAEzC;CACA;CACA;CAHV,YACC,QACA,aACA,MACC;EACD,MACC,kBAAkB,OAAO,sBAAsB,YAAY,+BAA+B,KAAK,8CAA8C,aAC9I;EANS,KAAA,SAAA;EACA,KAAA,cAAA;EACA,KAAA,OAAA;EAKT,KAAK,OAAO;CACb;AACD;;;;;;AAOA,SAAgB,cACf,MACA,MAC6B;CAC7B,IAAI,MAAM;CACV,OAAO,MAAM;EACZ,MAAM,eAAe,KAAK,KAAK,gBAAgB,MAAM,cAAc;EACnE,IAAI,WAAW,YAAY,GAC1B,OAAO;GACN,KAAK,aAAa,QAAQ,YAAY,CAAC;GACvC,UAAU,KAAK,MACd,aAAa,cAAc,OAAO,CACnC;EACD;EAED,MAAM,SAAS,QAAQ,GAAG;EAC1B,IAAI,WAAW,KAAK,OAAO,KAAA;EAC3B,MAAM;CACP;AACD;;AAGA,SAAS,KAAK,MAAmC;CAChD,IAAI,OAAO,SAAS,U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A,MAAM,QAAQ,iBAAiB,UAAU,QAAQ,IAAI;CACrD,IAAI,UAAU,KAAA,GACb,MAAM,IAAI,oBAAoB,MAAM,CACnC,GAAG,qBAAqB,GACxB,GAAG,OAAO,KAAK,UAAU,QAAQ,WAAW,CAAC,CAAC,CAC/C,CAAC;CAGF,MAAM,CAAC,gBAAgB,WAAW,MAAM,QAAQ,KAAK,IACjD,QACD,CAAC,OAAO,KAAA,CAAS;CAEpB,IAAI,OAAO,mBAAmB,UAAU;EAGvC,MAAM,WAAW,gBAAgB,MAAM,gBAAgB,UAAU,IAAI;EAErE,MAAM,UAAS,MADM,cAAc,MAAM,gBAAgB,UAAU,IAAI,EAAA,CACjD;EACtB,IAAI,CAAC,eAAe,MAAM,GACzB,MAAM,IAAI,qBAAqB,MAAM,cAAc;EAEpD,IAAI,OAAO,YAAY,UACtB,MAAM,IAAI,sBACT,MACA,gBACA,UACA,OAAO,OACR;EAED,OAAO;GAAE;GAAM;GAAQ,QAAQ;GAAU;EAAQ;CAClD;CAEA,IAAI,CAAC,eAAe,cAAc,GAAG,MAAM,IAAI,mBAAmB,IAAI;CACtE,OAAO;EAAE;EAAM,QAAQ;EAAgB,QAAQ;EAAU;CAAQ;AAClE;;AAGA,eAAsB,mBACrB,UACmB;CACnB,MAAM,EAAE,MAAM,QAAQ,YAAY;CAClC,IAAI,CAAC,OAAO,SAAS;EACpB,IAAI,YAAY,KAAA,GACf,MAAM,IAAI,qBAAqB,MAAM,CACpC,EAAE,SAAS,+BAA+B,CAC3C,CAAC;EAEF;CACD;CAEA,MAAM,SAAS,MAAM,OAAO,QAAQ,YAAY,CAAC,SAAS,OAAO;CACjE,IAAI,OAAO,QAAQ,MAAM,IAAI,qBAAqB,MAAM,OAAO,MAAM;CACrE,OAAO,OAAO;AACf"}
@@ -2,12 +2,12 @@ const require_rolldown_runtime = require("./rolldown-runtime-C0BPl7ul.cjs");
2
2
  const require_errors = require("./errors-DMC4Umsb.cjs");
3
3
  const require_credentials = require("./credentials-D7XJypNd.cjs");
4
4
  const require_workspace = require("./workspace-Du4Afb03.cjs");
5
- const require_seeds = require("./seeds-3awh33Wz.cjs");
5
+ const require_seeds = require("./seeds-sMVADbkg.cjs");
6
6
  const require_sandbox = require("./sandbox-CHv3OYXg.cjs");
7
7
  const require_config = require("./config.cjs");
8
8
  const require_local = require("./local-OPC9BCZt.cjs");
9
- const require_sniffer = require("./sniffer-Cq1nhxIB.cjs");
10
- const require_engine = require("./engine-Dqe9KQCm.cjs");
9
+ const require_sniffer = require("./sniffer-DWLala8l.cjs");
10
+ const require_engine = require("./engine-CYu4wavP.cjs");
11
11
  let node_path = require("node:path");
12
12
  //#region src/target/dokploy/rollback.ts
13
13
  /**
@@ -162,4 +162,4 @@ Object.defineProperty(exports, "rollback_exports", {
162
162
  }
163
163
  });
164
164
 
165
- //# sourceMappingURL=rollback-qc79mj6L.cjs.map
165
+ //# sourceMappingURL=rollback-CdBj1Boy.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"rollback-qc79mj6L.cjs","names":["GkmError","storedCredentials","LocalSandbox","findWorkspaceRoot","resolve","withSandbox","loadWorkspaceConfig","createStateStore","DeployJournal","createEmptyState","asDokployState","dokployApi","verifySettings","restoreImage"],"sources":["../src/target/dokploy/rollback.ts"],"sourcesContent":["/**\n * `gkm deploy:rollback`: a stage's apps put back on the release before the\n * one they run, by hand — for a release that passed its checks and turned out\n * wrong anyway.\n *\n * One app by default, because an app is what usually broke: rolling the API\n * back over a site fix that shipped beside it undoes the fix too. `atomic`\n * rolls back every app that has a release to go back to, for apps that only\n * work together — an API and the site built against its newer contract.\n *\n * It restores images and nothing else. The environment an app runs with is\n * the stage's, resolved on every deploy, and migrations are forward-only: a\n * migration that the older code cannot run against is undone by a new\n * migration, never by a rollback.\n */\n\nimport { resolve } from 'node:path';\nimport { findWorkspaceRoot, loadWorkspaceConfig } from '../../config';\nimport {\n\ttype CredentialProvider,\n\tstoredCredentials,\n} from '../../deploy/credentials';\nimport { DeployJournal } from '../../deploy/journal';\nimport {\n\tassertStateOutlivesRun,\n\tcreateStateStore,\n} from '../../deploy/StateStore';\nimport {\n\tasDokployState,\n\tcreateEmptyState,\n\ttype ReleasedImage,\n\trecordRollback,\n} from '../../deploy/state';\nimport { GkmError } from '../../errors';\nimport { LocalSandbox } from '../../sandbox/local';\nimport { type Sandbox, withSandbox } from '../../sandbox/sandbox';\nimport { assertDeployedStage } from '../../workspace/stages';\nimport { dokployApi, restoreImage, verifySettings } from './engine';\n\nexport interface RollbackInput {\n\t/** The project: the directory holding `gkm.config.ts`, or one inside it. */\n\tcwd: string;\n\tstage: string;\n\t/** The app to roll back. */\n\tapp?: string;\n\t/** Every app with an earlier release, instead of one. */\n\tatomic?: boolean;\n\t/** Defaults to the environment, then the logins `gkm login` stored. */\n\tcredentials?: CredentialProvider;\n\tsignal?: AbortSignal;\n\t/** Each progress line. Defaults to none. */\n\tlog?: (line: string) => void;\n\t/** Where the config is loaded. Defaults to a `LocalSandbox` on the project. */\n\tsandbox?: Sandbox;\n}\n\n/** One app rolled back. */\nexport interface RolledBack {\n\tapp: string;\n\tfrom: ReleasedImage;\n\tto: ReleasedImage;\n}\n\n/** Neither an app nor every app was asked for. */\nexport class RollbackNeedsApp extends GkmError {\n\tconstructor(\n\t\treadonly stage: string,\n\t\t/** The apps that have a release to go back to. */\n\t\treadonly apps: readonly string[],\n\t) {\n\t\tsuper(\n\t\t\t`Say what to roll back: --app <name> for one app (${apps.join(', ') || 'none has an earlier release'}), ` +\n\t\t\t\t`or --atomic for every app of \"${stage}\" together.`,\n\t\t);\n\t\tthis.name = 'RollbackNeedsApp';\n\t}\n}\n\n/** An app has no release before the one it runs. */\nexport class NothingToRollBack extends GkmError {\n\tconstructor(\n\t\treadonly stage: string,\n\t\treadonly app: string,\n\t) {\n\t\tsuper(\n\t\t\t`\"${app}\" has no earlier release on \"${stage}\" to roll back to: it has been released once, ` +\n\t\t\t\t'or every earlier release was itself rolled back. Deploy the version you want instead.',\n\t\t);\n\t\tthis.name = 'NothingToRollBack';\n\t}\n}\n\n/** The stage was never deployed through Dokploy from this state. */\nexport class StageNeverDeployed extends GkmError {\n\tconstructor(readonly stage: string) {\n\t\tsuper(\n\t\t\t`\"${stage}\" has no deploy state, so there is nothing to roll back. ` +\n\t\t\t\t'Check the stage name, and that `state` in gkm.config.ts points at the store the deploys write to.',\n\t\t);\n\t\tthis.name = 'StageNeverDeployed';\n\t}\n}\n\n/**\n * Roll a stage's app — or, `atomic`, all of them — back to its previous\n * release, holding the stage's lock as a deploy does.\n */\nexport async function rollbackStage(\n\tinput: RollbackInput,\n): Promise<RolledBack[]> {\n\tconst signal = input.signal ?? new AbortController().signal;\n\tconst log = input.log ?? (() => {});\n\tconst credentials = input.credentials ?? storedCredentials();\n\tconst sandbox =\n\t\tinput.sandbox ??\n\t\tnew LocalSandbox({ root: findWorkspaceRoot(resolve(input.cwd)) });\n\n\treturn withSandbox(sandbox, async () => {\n\t\tconst { workspace } = await loadWorkspaceConfig(resolve(input.cwd), {\n\t\t\tsandbox,\n\t\t});\n\t\tassertDeployedStage(workspace.stages, input.stage);\n\t\tassertStateOutlivesRun(workspace, input.stage, 'deploy:rollback');\n\n\t\tconst store = await createStateStore({\n\t\t\tconfig: workspace.state,\n\t\t\tworkspaceRoot: workspace.root,\n\t\t\tworkspaceName: workspace.name,\n\t\t\tnamespace: workspace.deploy?.namespace,\n\t\t});\n\t\tif (!(await store.read(input.stage))) {\n\t\t\tthrow new StageNeverDeployed(input.stage);\n\t\t}\n\n\t\tconst lock = await store.lock(input.stage, { operation: 'rollback' });\n\t\ttry {\n\t\t\tconst journal = await DeployJournal.open(\n\t\t\t\tstore,\n\t\t\t\tinput.stage,\n\t\t\t\t() => createEmptyState(input.stage, '', ''),\n\t\t\t\tasDokployState,\n\t\t\t);\n\t\t\tconst { state } = journal;\n\t\t\tconst releases = state.releases ?? {};\n\t\t\tconst restorable = Object.keys(releases).filter(\n\t\t\t\t(app) => releases[app]!.previous,\n\t\t\t);\n\n\t\t\tlet apps: string[];\n\t\t\tif (input.atomic) {\n\t\t\t\tapps = restorable;\n\t\t\t\tif (apps.length === 0) {\n\t\t\t\t\tthrow new RollbackNeedsApp(input.stage, restorable);\n\t\t\t\t}\n\t\t\t} else if (input.app) {\n\t\t\t\tif (!releases[input.app]?.previous) {\n\t\t\t\t\tthrow new NothingToRollBack(input.stage, input.app);\n\t\t\t\t}\n\t\t\t\tapps = [input.app];\n\t\t\t} else {\n\t\t\t\tthrow new RollbackNeedsApp(input.stage, restorable);\n\t\t\t}\n\n\t\t\tconst { api } = await dokployApi(workspace, { credentials, signal });\n\t\t\tconst verify = verifySettings(workspace.deploy.dokploy?.verify);\n\t\t\tconst rolled: RolledBack[] = [];\n\n\t\t\tfor (const app of apps) {\n\t\t\t\tsignal.throwIfAborted();\n\t\t\t\tconst { current, previous } = releases[app]!;\n\t\t\t\tconst applicationId = state.applications[app];\n\t\t\t\tif (!previous || !applicationId) {\n\t\t\t\t\tthrow new NothingToRollBack(input.stage, app);\n\t\t\t\t}\n\n\t\t\t\tlog(`⏪ ${app}: ${current.ref} → ${previous.ref}`);\n\t\t\t\tawait restoreImage(api, {\n\t\t\t\t\tapplicationId,\n\t\t\t\t\timage: previous,\n\t\t\t\t\tregistryId: state.registryId,\n\t\t\t\t\tverify,\n\t\t\t\t\tsignal,\n\t\t\t\t});\n\t\t\t\trecordRollback(state, app, previous);\n\t\t\t\tawait journal.save();\n\t\t\t\tlog(` ✓ ${app} is running ${previous.ref}`);\n\t\t\t\trolled.push({ app, from: current, to: previous });\n\t\t\t}\n\n\t\t\treturn rolled;\n\t\t} finally {\n\t\t\tawait lock.release();\n\t\t}\n\t});\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgEA,IAAa,mBAAb,cAAsCA,eAAAA,SAAS;CAEpC;CAEA;CAHV,YACC,OAEA,MACC;EACD,MACC,oDAAoD,KAAK,KAAK,IAAI,KAAK,8BAA8B,mCACnE,MAAM,YAC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,KAAK;KAAE;KAAK,MAAM;KAAS,IAAI;IAAS,CAAC;GACjD;GAEA,OAAO;EACR,UAAU;GACT,MAAM,KAAK,QAAQ;EACpB;CACD,CAAC;AACF"}
1
+ {"version":3,"file":"rollback-CdBj1Boy.cjs","names":["GkmError","storedCredentials","LocalSandbox","findWorkspaceRoot","resolve","withSandbox","loadWorkspaceConfig","createStateStore","DeployJournal","createEmptyState","asDokployState","dokployApi","verifySettings","restoreImage"],"sources":["../src/target/dokploy/rollback.ts"],"sourcesContent":["/**\n * `gkm deploy:rollback`: a stage's apps put back on the release before the\n * one they run, by hand — for a release that passed its checks and turned out\n * wrong anyway.\n *\n * One app by default, because an app is what usually broke: rolling the API\n * back over a site fix that shipped beside it undoes the fix too. `atomic`\n * rolls back every app that has a release to go back to, for apps that only\n * work together — an API and the site built against its newer contract.\n *\n * It restores images and nothing else. The environment an app runs with is\n * the stage's, resolved on every deploy, and migrations are forward-only: a\n * migration that the older code cannot run against is undone by a new\n * migration, never by a rollback.\n */\n\nimport { resolve } from 'node:path';\nimport { findWorkspaceRoot, loadWorkspaceConfig } from '../../config';\nimport {\n\ttype CredentialProvider,\n\tstoredCredentials,\n} from '../../deploy/credentials';\nimport { DeployJournal } from '../../deploy/journal';\nimport {\n\tassertStateOutlivesRun,\n\tcreateStateStore,\n} from '../../deploy/StateStore';\nimport {\n\tasDokployState,\n\tcreateEmptyState,\n\ttype ReleasedImage,\n\trecordRollback,\n} from '../../deploy/state';\nimport { GkmError } from '../../errors';\nimport { LocalSandbox } from '../../sandbox/local';\nimport { type Sandbox, withSandbox } from '../../sandbox/sandbox';\nimport { assertDeployedStage } from '../../workspace/stages';\nimport { dokployApi, restoreImage, verifySettings } from './engine';\n\nexport interface RollbackInput {\n\t/** The project: the directory holding `gkm.config.ts`, or one inside it. */\n\tcwd: string;\n\tstage: string;\n\t/** The app to roll back. */\n\tapp?: string;\n\t/** Every app with an earlier release, instead of one. */\n\tatomic?: boolean;\n\t/** Defaults to the environment, then the logins `gkm login` stored. */\n\tcredentials?: CredentialProvider;\n\tsignal?: AbortSignal;\n\t/** Each progress line. Defaults to none. */\n\tlog?: (line: string) => void;\n\t/** Where the config is loaded. Defaults to a `LocalSandbox` on the project. */\n\tsandbox?: Sandbox;\n}\n\n/** One app rolled back. */\nexport interface RolledBack {\n\tapp: string;\n\tfrom: ReleasedImage;\n\tto: ReleasedImage;\n}\n\n/** Neither an app nor every app was asked for. */\nexport class RollbackNeedsApp extends GkmError {\n\tconstructor(\n\t\treadonly stage: string,\n\t\t/** The apps that have a release to go back to. */\n\t\treadonly apps: readonly string[],\n\t) {\n\t\tsuper(\n\t\t\t`Say what to roll back: --app <name> for one app (${apps.join(', ') || 'none has an earlier release'}), ` +\n\t\t\t\t`or --atomic for every app of \"${stage}\" together.`,\n\t\t);\n\t\tthis.name = 'RollbackNeedsApp';\n\t}\n}\n\n/** An app has no release before the one it runs. */\nexport class NothingToRollBack extends GkmError {\n\tconstructor(\n\t\treadonly stage: string,\n\t\treadonly app: string,\n\t) {\n\t\tsuper(\n\t\t\t`\"${app}\" has no earlier release on \"${stage}\" to roll back to: it has been released once, ` +\n\t\t\t\t'or every earlier release was itself rolled back. Deploy the version you want instead.',\n\t\t);\n\t\tthis.name = 'NothingToRollBack';\n\t}\n}\n\n/** The stage was never deployed through Dokploy from this state. */\nexport class StageNeverDeployed extends GkmError {\n\tconstructor(readonly stage: string) {\n\t\tsuper(\n\t\t\t`\"${stage}\" has no deploy state, so there is nothing to roll back. ` +\n\t\t\t\t'Check the stage name, and that `state` in gkm.config.ts points at the store the deploys write to.',\n\t\t);\n\t\tthis.name = 'StageNeverDeployed';\n\t}\n}\n\n/**\n * Roll a stage's app — or, `atomic`, all of them — back to its previous\n * release, holding the stage's lock as a deploy does.\n */\nexport async function rollbackStage(\n\tinput: RollbackInput,\n): Promise<RolledBack[]> {\n\tconst signal = input.signal ?? new AbortController().signal;\n\tconst log = input.log ?? (() => {});\n\tconst credentials = input.credentials ?? storedCredentials();\n\tconst sandbox =\n\t\tinput.sandbox ??\n\t\tnew LocalSandbox({ root: findWorkspaceRoot(resolve(input.cwd)) });\n\n\treturn withSandbox(sandbox, async () => {\n\t\tconst { workspace } = await loadWorkspaceConfig(resolve(input.cwd), {\n\t\t\tsandbox,\n\t\t});\n\t\tassertDeployedStage(workspace.stages, input.stage);\n\t\tassertStateOutlivesRun(workspace, input.stage, 'deploy:rollback');\n\n\t\tconst store = await createStateStore({\n\t\t\tconfig: workspace.state,\n\t\t\tworkspaceRoot: workspace.root,\n\t\t\tworkspaceName: workspace.name,\n\t\t\tnamespace: workspace.deploy?.namespace,\n\t\t});\n\t\tif (!(await store.read(input.stage))) {\n\t\t\tthrow new StageNeverDeployed(input.stage);\n\t\t}\n\n\t\tconst lock = await store.lock(input.stage, { operation: 'rollback' });\n\t\ttry {\n\t\t\tconst journal = await DeployJournal.open(\n\t\t\t\tstore,\n\t\t\t\tinput.stage,\n\t\t\t\t() => createEmptyState(input.stage, '', ''),\n\t\t\t\tasDokployState,\n\t\t\t);\n\t\t\tconst { state } = journal;\n\t\t\tconst releases = state.releases ?? {};\n\t\t\tconst restorable = Object.keys(releases).filter(\n\t\t\t\t(app) => releases[app]!.previous,\n\t\t\t);\n\n\t\t\tlet apps: string[];\n\t\t\tif (input.atomic) {\n\t\t\t\tapps = restorable;\n\t\t\t\tif (apps.length === 0) {\n\t\t\t\t\tthrow new RollbackNeedsApp(input.stage, restorable);\n\t\t\t\t}\n\t\t\t} else if (input.app) {\n\t\t\t\tif (!releases[input.app]?.previous) {\n\t\t\t\t\tthrow new NothingToRollBack(input.stage, input.app);\n\t\t\t\t}\n\t\t\t\tapps = [input.app];\n\t\t\t} else {\n\t\t\t\tthrow new RollbackNeedsApp(input.stage, restorable);\n\t\t\t}\n\n\t\t\tconst { api } = await dokployApi(workspace, { credentials, signal });\n\t\t\tconst verify = verifySettings(workspace.deploy.dokploy?.verify);\n\t\t\tconst rolled: RolledBack[] = [];\n\n\t\t\tfor (const app of apps) {\n\t\t\t\tsignal.throwIfAborted();\n\t\t\t\tconst { current, previous } = releases[app]!;\n\t\t\t\tconst applicationId = state.applications[app];\n\t\t\t\tif (!previous || !applicationId) {\n\t\t\t\t\tthrow new NothingToRollBack(input.stage, app);\n\t\t\t\t}\n\n\t\t\t\tlog(`⏪ ${app}: ${current.ref} → ${previous.ref}`);\n\t\t\t\tawait restoreImage(api, {\n\t\t\t\t\tapplicationId,\n\t\t\t\t\timage: previous,\n\t\t\t\t\tregistryId: state.registryId,\n\t\t\t\t\tverify,\n\t\t\t\t\tsignal,\n\t\t\t\t});\n\t\t\t\trecordRollback(state, app, previous);\n\t\t\t\tawait journal.save();\n\t\t\t\tlog(` ✓ ${app} is running ${previous.ref}`);\n\t\t\t\trolled.push({ app, from: current, to: previous });\n\t\t\t}\n\n\t\t\treturn rolled;\n\t\t} finally {\n\t\t\tawait lock.release();\n\t\t}\n\t});\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgEA,IAAa,mBAAb,cAAsCA,eAAAA,SAAS;CAEpC;CAEA;CAHV,YACC,OAEA,MACC;EACD,MACC,oDAAoD,KAAK,KAAK,IAAI,KAAK,8BAA8B,mCACnE,MAAM,YACzC;EAPS,KAAA,QAAA;EAEA,KAAA,OAAA;EAMT,KAAK,OAAO;CACb;AACD;;AAGA,IAAa,oBAAb,cAAuCA,eAAAA,SAAS;CAErC;CACA;CAFV,YACC,OACA,KACC;EACD,MACC,IAAI,IAAI,+BAA+B,MAAM,oIAE9C;EANS,KAAA,QAAA;EACA,KAAA,MAAA;EAMT,KAAK,OAAO;CACb;AACD;;AAGA,IAAa,qBAAb,cAAwCA,eAAAA,SAAS;CAC3B;CAArB,YAAY,OAAwB;EACnC,MACC,IAAI,MAAM,6JAEX;EAJoB,KAAA,QAAA;EAKpB,KAAK,OAAO;CACb;AACD;;;;;AAMA,eAAsB,cACrB,OACwB;CACxB,MAAM,SAAS,MAAM,UAAU,IAAI,gBAAgB,CAAC,C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,EAAE,UACzB,MAAM,IAAI,kBAAkB,MAAM,OAAO,MAAM,GAAG;IAEnD,OAAO,CAAC,MAAM,GAAG;GAClB,OACC,MAAM,IAAI,iBAAiB,MAAM,OAAO,UAAU;GAGnD,MAAM,EAAE,QAAQ,MAAMC,eAAAA,WAAW,WAAW;IAAE;IAAa;GAAO,CAAC;GACnE,MAAM,SAASC,eAAAA,eAAe,UAAU,OAAO,SAAS,MAAM;GAC9D,MAAM,SAAuB,CAAC;GAE9B,KAAK,MAAM,OAAO,MAAM;IACvB,OAAO,eAAe;IACtB,MAAM,EAAE,SAAS,aAAa,SAAS;IACvC,MAAM,gBAAgB,MAAM,aAAa;IACzC,IAAI,CAAC,YAAY,CAAC,eACjB,MAAM,IAAI,kBAAkB,MAAM,OAAO,GAAG;IAG7C,IAAI,KAAK,IAAI,IAAI,QAAQ,IAAI,KAAK,SAAS,KAAK;IAChD,MAAMC,eAAAA,aAAa,KAAK;KACvB;KACA,OAAO;KACP,YAAY,MAAM;KAClB;KACA;IACD,CAAC;IACD,cAAA,eAAe,OAAO,KAAK,QAAQ;IACnC,MAAM,QAAQ,KAAK;IACnB,IAAI,QAAQ,IAAI,cAAc,SAAS,KAAK;IAC5C,OAAO,KAAK;KAAE;KAAK,MAAM;KAAS,IAAI;IAAS,CAAC;GACjD;GAEA,OAAO;EACR,UAAU;GACT,MAAM,KAAK,QAAQ;EACpB;CACD,CAAC;AACF"}
@@ -2,12 +2,12 @@ import { t as __exportAll } from "./rolldown-runtime-BhDjJH2R.mjs";
2
2
  import { t as GkmError } from "./errors-D8Gwp5kU.mjs";
3
3
  import { r as storedCredentials } from "./credentials-DpfnUvIR.mjs";
4
4
  import { N as assertDeployedStage } from "./workspace-DBHF9Gba.mjs";
5
- import { C as recordRollback, _ as asDokployState, d as DeployJournal, y as createEmptyState } from "./seeds-Cfejy8wj.mjs";
5
+ import { C as recordRollback, _ as asDokployState, d as DeployJournal, y as createEmptyState } from "./seeds-BX9pskrU.mjs";
6
6
  import { c as withSandbox } from "./sandbox-CbVB7uOD.mjs";
7
7
  import { findWorkspaceRoot, loadWorkspaceConfig } from "./config.mjs";
8
8
  import { t as LocalSandbox } from "./local-B7Zv1NoA.mjs";
9
- import { S as createStateStore, v as assertStateOutlivesRun } from "./sniffer-CCkdzjiU.mjs";
10
- import { i as dokployApi, l as restoreImage, p as verifySettings } from "./engine-_0pjyCd_.mjs";
9
+ import { S as createStateStore, v as assertStateOutlivesRun } from "./sniffer-XnAnEbuI.mjs";
10
+ import { i as dokployApi, l as restoreImage, p as verifySettings } from "./engine-DKz1NYDX.mjs";
11
11
  import { resolve } from "node:path";
12
12
  //#region src/target/dokploy/rollback.ts
13
13
  /**
@@ -133,4 +133,4 @@ async function rollbackStage(input) {
133
133
  //#endregion
134
134
  export { rollback_exports as a, rollbackStage as i, RollbackNeedsApp as n, StageNeverDeployed as r, NothingToRollBack as t };
135
135
 
136
- //# sourceMappingURL=rollback-BkhVrtAf.mjs.map
136
+ //# sourceMappingURL=rollback-dUShCpZu.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"rollback-BkhVrtAf.mjs","names":[],"sources":["../src/target/dokploy/rollback.ts"],"sourcesContent":["/**\n * `gkm deploy:rollback`: a stage's apps put back on the release before the\n * one they run, by hand — for a release that passed its checks and turned out\n * wrong anyway.\n *\n * One app by default, because an app is what usually broke: rolling the API\n * back over a site fix that shipped beside it undoes the fix too. `atomic`\n * rolls back every app that has a release to go back to, for apps that only\n * work together — an API and the site built against its newer contract.\n *\n * It restores images and nothing else. The environment an app runs with is\n * the stage's, resolved on every deploy, and migrations are forward-only: a\n * migration that the older code cannot run against is undone by a new\n * migration, never by a rollback.\n */\n\nimport { resolve } from 'node:path';\nimport { findWorkspaceRoot, loadWorkspaceConfig } from '../../config';\nimport {\n\ttype CredentialProvider,\n\tstoredCredentials,\n} from '../../deploy/credentials';\nimport { DeployJournal } from '../../deploy/journal';\nimport {\n\tassertStateOutlivesRun,\n\tcreateStateStore,\n} from '../../deploy/StateStore';\nimport {\n\tasDokployState,\n\tcreateEmptyState,\n\ttype ReleasedImage,\n\trecordRollback,\n} from '../../deploy/state';\nimport { GkmError } from '../../errors';\nimport { LocalSandbox } from '../../sandbox/local';\nimport { type Sandbox, withSandbox } from '../../sandbox/sandbox';\nimport { assertDeployedStage } from '../../workspace/stages';\nimport { dokployApi, restoreImage, verifySettings } from './engine';\n\nexport interface RollbackInput {\n\t/** The project: the directory holding `gkm.config.ts`, or one inside it. */\n\tcwd: string;\n\tstage: string;\n\t/** The app to roll back. */\n\tapp?: string;\n\t/** Every app with an earlier release, instead of one. */\n\tatomic?: boolean;\n\t/** Defaults to the environment, then the logins `gkm login` stored. */\n\tcredentials?: CredentialProvider;\n\tsignal?: AbortSignal;\n\t/** Each progress line. Defaults to none. */\n\tlog?: (line: string) => void;\n\t/** Where the config is loaded. Defaults to a `LocalSandbox` on the project. */\n\tsandbox?: Sandbox;\n}\n\n/** One app rolled back. */\nexport interface RolledBack {\n\tapp: string;\n\tfrom: ReleasedImage;\n\tto: ReleasedImage;\n}\n\n/** Neither an app nor every app was asked for. */\nexport class RollbackNeedsApp extends GkmError {\n\tconstructor(\n\t\treadonly stage: string,\n\t\t/** The apps that have a release to go back to. */\n\t\treadonly apps: readonly string[],\n\t) {\n\t\tsuper(\n\t\t\t`Say what to roll back: --app <name> for one app (${apps.join(', ') || 'none has an earlier release'}), ` +\n\t\t\t\t`or --atomic for every app of \"${stage}\" together.`,\n\t\t);\n\t\tthis.name = 'RollbackNeedsApp';\n\t}\n}\n\n/** An app has no release before the one it runs. */\nexport class NothingToRollBack extends GkmError {\n\tconstructor(\n\t\treadonly stage: string,\n\t\treadonly app: string,\n\t) {\n\t\tsuper(\n\t\t\t`\"${app}\" has no earlier release on \"${stage}\" to roll back to: it has been released once, ` +\n\t\t\t\t'or every earlier release was itself rolled back. Deploy the version you want instead.',\n\t\t);\n\t\tthis.name = 'NothingToRollBack';\n\t}\n}\n\n/** The stage was never deployed through Dokploy from this state. */\nexport class StageNeverDeployed extends GkmError {\n\tconstructor(readonly stage: string) {\n\t\tsuper(\n\t\t\t`\"${stage}\" has no deploy state, so there is nothing to roll back. ` +\n\t\t\t\t'Check the stage name, and that `state` in gkm.config.ts points at the store the deploys write to.',\n\t\t);\n\t\tthis.name = 'StageNeverDeployed';\n\t}\n}\n\n/**\n * Roll a stage's app — or, `atomic`, all of them — back to its previous\n * release, holding the stage's lock as a deploy does.\n */\nexport async function rollbackStage(\n\tinput: RollbackInput,\n): Promise<RolledBack[]> {\n\tconst signal = input.signal ?? new AbortController().signal;\n\tconst log = input.log ?? (() => {});\n\tconst credentials = input.credentials ?? storedCredentials();\n\tconst sandbox =\n\t\tinput.sandbox ??\n\t\tnew LocalSandbox({ root: findWorkspaceRoot(resolve(input.cwd)) });\n\n\treturn withSandbox(sandbox, async () => {\n\t\tconst { workspace } = await loadWorkspaceConfig(resolve(input.cwd), {\n\t\t\tsandbox,\n\t\t});\n\t\tassertDeployedStage(workspace.stages, input.stage);\n\t\tassertStateOutlivesRun(workspace, input.stage, 'deploy:rollback');\n\n\t\tconst store = await createStateStore({\n\t\t\tconfig: workspace.state,\n\t\t\tworkspaceRoot: workspace.root,\n\t\t\tworkspaceName: workspace.name,\n\t\t\tnamespace: workspace.deploy?.namespace,\n\t\t});\n\t\tif (!(await store.read(input.stage))) {\n\t\t\tthrow new StageNeverDeployed(input.stage);\n\t\t}\n\n\t\tconst lock = await store.lock(input.stage, { operation: 'rollback' });\n\t\ttry {\n\t\t\tconst journal = await DeployJournal.open(\n\t\t\t\tstore,\n\t\t\t\tinput.stage,\n\t\t\t\t() => createEmptyState(input.stage, '', ''),\n\t\t\t\tasDokployState,\n\t\t\t);\n\t\t\tconst { state } = journal;\n\t\t\tconst releases = state.releases ?? {};\n\t\t\tconst restorable = Object.keys(releases).filter(\n\t\t\t\t(app) => releases[app]!.previous,\n\t\t\t);\n\n\t\t\tlet apps: string[];\n\t\t\tif (input.atomic) {\n\t\t\t\tapps = restorable;\n\t\t\t\tif (apps.length === 0) {\n\t\t\t\t\tthrow new RollbackNeedsApp(input.stage, restorable);\n\t\t\t\t}\n\t\t\t} else if (input.app) {\n\t\t\t\tif (!releases[input.app]?.previous) {\n\t\t\t\t\tthrow new NothingToRollBack(input.stage, input.app);\n\t\t\t\t}\n\t\t\t\tapps = [input.app];\n\t\t\t} else {\n\t\t\t\tthrow new RollbackNeedsApp(input.stage, restorable);\n\t\t\t}\n\n\t\t\tconst { api } = await dokployApi(workspace, { credentials, signal });\n\t\t\tconst verify = verifySettings(workspace.deploy.dokploy?.verify);\n\t\t\tconst rolled: RolledBack[] = [];\n\n\t\t\tfor (const app of apps) {\n\t\t\t\tsignal.throwIfAborted();\n\t\t\t\tconst { current, previous } = releases[app]!;\n\t\t\t\tconst applicationId = state.applications[app];\n\t\t\t\tif (!previous || !applicationId) {\n\t\t\t\t\tthrow new NothingToRollBack(input.stage, app);\n\t\t\t\t}\n\n\t\t\t\tlog(`⏪ ${app}: ${current.ref} → ${previous.ref}`);\n\t\t\t\tawait restoreImage(api, {\n\t\t\t\t\tapplicationId,\n\t\t\t\t\timage: previous,\n\t\t\t\t\tregistryId: state.registryId,\n\t\t\t\t\tverify,\n\t\t\t\t\tsignal,\n\t\t\t\t});\n\t\t\t\trecordRollback(state, app, previous);\n\t\t\t\tawait journal.save();\n\t\t\t\tlog(` ✓ ${app} is running ${previous.ref}`);\n\t\t\t\trolled.push({ app, from: current, to: previous });\n\t\t\t}\n\n\t\t\treturn rolled;\n\t\t} finally {\n\t\t\tawait lock.release();\n\t\t}\n\t});\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgEA,IAAa,mBAAb,cAAsC,SAAS;CAEpC;CAEA;CAHV,YACC,OAEA,MACC;EACD,MACC,oDAAoD,KAAK,KAAK,IAAI,KAAK,8BAA8B,mCACnE,MAAM,YACzC;EAPS,KAAA,QAAA;EAEA,KAAA,OAAA;EAMT,KAAK,OAAO;CACb;AACD;;AAGA,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AAK,QAAQ,CAAC,CAAC,QACvC,QAAQ,SAAS,IAAI,CAAE,QACzB;GAEA,IAAI;GACJ,IAAI,MAAM,QAAQ;IACjB,OAAO;IACP,IAAI,KAAK,WAAW,GACnB,MAAM,IAAI,iBAAiB,MAAM,OAAO,UAAU;GAEpD,OAAO,IAAI,MAAM,KAAK;IACrB,IAAI,CAAC,SAAS,MAAM,IAAI,EAAE,UACzB,MAAM,IAAI,kBAAkB,MAAM,OAAO,MAAM,GAAG;IAEnD,OAAO,CAAC,MAAM,GAAG;GAClB,OACC,MAAM,IAAI,iBAAiB,MAAM,OAAO,UAAU;GAGnD,MAAM,EAAE,QAAQ,MAAM,WAAW,WAAW;IAAE;IAAa;GAAO,CAAC;GACnE,MAAM,SAAS,eAAe,UAAU,OAAO,SAAS,MAAM;GAC9D,MAAM,SAAuB,CAAC;GAE9B,KAAK,MAAM,OAAO,MAAM;IACvB,OAAO,eAAe;IACtB,MAAM,EAAE,SAAS,aAAa,SAAS;IACvC,MAAM,gBAAgB,MAAM,aAAa;IACzC,IAAI,CAAC,YAAY,CAAC,eACjB,MAAM,IAAI,kBAAkB,MAAM,OAAO,GAAG;IAG7C,IAAI,KAAK,IAAI,IAAI,QAAQ,IAAI,KAAK,SAAS,KAAK;IAChD,MAAM,aAAa,KAAK;KACvB;KACA,OAAO;KACP,YAAY,MAAM;KAClB;KACA;IACD,CAAC;IACD,eAAe,OAAO,KAAK,QAAQ;IACnC,MAAM,QAAQ,KAAK;IACnB,IAAI,QAAQ,IAAI,cAAc,SAAS,KAAK;IAC5C,OAAO,KAAK;KAAE;KAAK,MAAM;KAAS,IAAI;IAAS,CAAC;GACjD;GAEA,OAAO;EACR,UAAU;GACT,MAAM,KAAK,QAAQ;EACpB;CACD,CAAC;AACF"}
1
+ {"version":3,"file":"rollback-dUShCpZu.mjs","names":[],"sources":["../src/target/dokploy/rollback.ts"],"sourcesContent":["/**\n * `gkm deploy:rollback`: a stage's apps put back on the release before the\n * one they run, by hand — for a release that passed its checks and turned out\n * wrong anyway.\n *\n * One app by default, because an app is what usually broke: rolling the API\n * back over a site fix that shipped beside it undoes the fix too. `atomic`\n * rolls back every app that has a release to go back to, for apps that only\n * work together — an API and the site built against its newer contract.\n *\n * It restores images and nothing else. The environment an app runs with is\n * the stage's, resolved on every deploy, and migrations are forward-only: a\n * migration that the older code cannot run against is undone by a new\n * migration, never by a rollback.\n */\n\nimport { resolve } from 'node:path';\nimport { findWorkspaceRoot, loadWorkspaceConfig } from '../../config';\nimport {\n\ttype CredentialProvider,\n\tstoredCredentials,\n} from '../../deploy/credentials';\nimport { DeployJournal } from '../../deploy/journal';\nimport {\n\tassertStateOutlivesRun,\n\tcreateStateStore,\n} from '../../deploy/StateStore';\nimport {\n\tasDokployState,\n\tcreateEmptyState,\n\ttype ReleasedImage,\n\trecordRollback,\n} from '../../deploy/state';\nimport { GkmError } from '../../errors';\nimport { LocalSandbox } from '../../sandbox/local';\nimport { type Sandbox, withSandbox } from '../../sandbox/sandbox';\nimport { assertDeployedStage } from '../../workspace/stages';\nimport { dokployApi, restoreImage, verifySettings } from './engine';\n\nexport interface RollbackInput {\n\t/** The project: the directory holding `gkm.config.ts`, or one inside it. */\n\tcwd: string;\n\tstage: string;\n\t/** The app to roll back. */\n\tapp?: string;\n\t/** Every app with an earlier release, instead of one. */\n\tatomic?: boolean;\n\t/** Defaults to the environment, then the logins `gkm login` stored. */\n\tcredentials?: CredentialProvider;\n\tsignal?: AbortSignal;\n\t/** Each progress line. Defaults to none. */\n\tlog?: (line: string) => void;\n\t/** Where the config is loaded. Defaults to a `LocalSandbox` on the project. */\n\tsandbox?: Sandbox;\n}\n\n/** One app rolled back. */\nexport interface RolledBack {\n\tapp: string;\n\tfrom: ReleasedImage;\n\tto: ReleasedImage;\n}\n\n/** Neither an app nor every app was asked for. */\nexport class RollbackNeedsApp extends GkmError {\n\tconstructor(\n\t\treadonly stage: string,\n\t\t/** The apps that have a release to go back to. */\n\t\treadonly apps: readonly string[],\n\t) {\n\t\tsuper(\n\t\t\t`Say what to roll back: --app <name> for one app (${apps.join(', ') || 'none has an earlier release'}), ` +\n\t\t\t\t`or --atomic for every app of \"${stage}\" together.`,\n\t\t);\n\t\tthis.name = 'RollbackNeedsApp';\n\t}\n}\n\n/** An app has no release before the one it runs. */\nexport class NothingToRollBack extends GkmError {\n\tconstructor(\n\t\treadonly stage: string,\n\t\treadonly app: string,\n\t) {\n\t\tsuper(\n\t\t\t`\"${app}\" has no earlier release on \"${stage}\" to roll back to: it has been released once, ` +\n\t\t\t\t'or every earlier release was itself rolled back. Deploy the version you want instead.',\n\t\t);\n\t\tthis.name = 'NothingToRollBack';\n\t}\n}\n\n/** The stage was never deployed through Dokploy from this state. */\nexport class StageNeverDeployed extends GkmError {\n\tconstructor(readonly stage: string) {\n\t\tsuper(\n\t\t\t`\"${stage}\" has no deploy state, so there is nothing to roll back. ` +\n\t\t\t\t'Check the stage name, and that `state` in gkm.config.ts points at the store the deploys write to.',\n\t\t);\n\t\tthis.name = 'StageNeverDeployed';\n\t}\n}\n\n/**\n * Roll a stage's app — or, `atomic`, all of them — back to its previous\n * release, holding the stage's lock as a deploy does.\n */\nexport async function rollbackStage(\n\tinput: RollbackInput,\n): Promise<RolledBack[]> {\n\tconst signal = input.signal ?? new AbortController().signal;\n\tconst log = input.log ?? (() => {});\n\tconst credentials = input.credentials ?? storedCredentials();\n\tconst sandbox =\n\t\tinput.sandbox ??\n\t\tnew LocalSandbox({ root: findWorkspaceRoot(resolve(input.cwd)) });\n\n\treturn withSandbox(sandbox, async () => {\n\t\tconst { workspace } = await loadWorkspaceConfig(resolve(input.cwd), {\n\t\t\tsandbox,\n\t\t});\n\t\tassertDeployedStage(workspace.stages, input.stage);\n\t\tassertStateOutlivesRun(workspace, input.stage, 'deploy:rollback');\n\n\t\tconst store = await createStateStore({\n\t\t\tconfig: workspace.state,\n\t\t\tworkspaceRoot: workspace.root,\n\t\t\tworkspaceName: workspace.name,\n\t\t\tnamespace: workspace.deploy?.namespace,\n\t\t});\n\t\tif (!(await store.read(input.stage))) {\n\t\t\tthrow new StageNeverDeployed(input.stage);\n\t\t}\n\n\t\tconst lock = await store.lock(input.stage, { operation: 'rollback' });\n\t\ttry {\n\t\t\tconst journal = await DeployJournal.open(\n\t\t\t\tstore,\n\t\t\t\tinput.stage,\n\t\t\t\t() => createEmptyState(input.stage, '', ''),\n\t\t\t\tasDokployState,\n\t\t\t);\n\t\t\tconst { state } = journal;\n\t\t\tconst releases = state.releases ?? {};\n\t\t\tconst restorable = Object.keys(releases).filter(\n\t\t\t\t(app) => releases[app]!.previous,\n\t\t\t);\n\n\t\t\tlet apps: string[];\n\t\t\tif (input.atomic) {\n\t\t\t\tapps = restorable;\n\t\t\t\tif (apps.length === 0) {\n\t\t\t\t\tthrow new RollbackNeedsApp(input.stage, restorable);\n\t\t\t\t}\n\t\t\t} else if (input.app) {\n\t\t\t\tif (!releases[input.app]?.previous) {\n\t\t\t\t\tthrow new NothingToRollBack(input.stage, input.app);\n\t\t\t\t}\n\t\t\t\tapps = [input.app];\n\t\t\t} else {\n\t\t\t\tthrow new RollbackNeedsApp(input.stage, restorable);\n\t\t\t}\n\n\t\t\tconst { api } = await dokployApi(workspace, { credentials, signal });\n\t\t\tconst verify = verifySettings(workspace.deploy.dokploy?.verify);\n\t\t\tconst rolled: RolledBack[] = [];\n\n\t\t\tfor (const app of apps) {\n\t\t\t\tsignal.throwIfAborted();\n\t\t\t\tconst { current, previous } = releases[app]!;\n\t\t\t\tconst applicationId = state.applications[app];\n\t\t\t\tif (!previous || !applicationId) {\n\t\t\t\t\tthrow new NothingToRollBack(input.stage, app);\n\t\t\t\t}\n\n\t\t\t\tlog(`⏪ ${app}: ${current.ref} → ${previous.ref}`);\n\t\t\t\tawait restoreImage(api, {\n\t\t\t\t\tapplicationId,\n\t\t\t\t\timage: previous,\n\t\t\t\t\tregistryId: state.registryId,\n\t\t\t\t\tverify,\n\t\t\t\t\tsignal,\n\t\t\t\t});\n\t\t\t\trecordRollback(state, app, previous);\n\t\t\t\tawait journal.save();\n\t\t\t\tlog(` ✓ ${app} is running ${previous.ref}`);\n\t\t\t\trolled.push({ app, from: current, to: previous });\n\t\t\t}\n\n\t\t\treturn rolled;\n\t\t} finally {\n\t\t\tawait lock.release();\n\t\t}\n\t});\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgEA,IAAa,mBAAb,cAAsC,SAAS;CAEpC;CAEA;CAHV,YACC,OAEA,MACC;EACD,MACC,oDAAoD,KAAK,KAAK,IAAI,KAAK,8BAA8B,mCACnE,MAAM,YACzC;EAPS,KAAA,QAAA;EAEA,KAAA,OAAA;EAMT,KAAK,OAAO;CACb;AACD;;AAGA,IAAa,oBAAb,cAAuC,SAAS;CAErC;CACA;CAFV,YACC,OACA,KACC;EACD,MACC,IAAI,IAAI,+BAA+B,MAAM,oIAE9C;EANS,KAAA,QAAA;EACA,KAAA,MAAA;EAMT,KAAK,OAAO;CACb;AACD;;AAGA,IAAa,qBAAb,cAAwC,SAAS;CAC3B;CAArB,YAAY,OAAwB;EACnC,MACC,IAAI,MAAM,6JAEX;EAJoB,KAAA,QAAA;EAKpB,KAAK,OAAO;CACb;AACD;;;;;AAMA,eAAsB,cACrB,OACwB;CACxB,MAAM,SAAS,MAAM,UAAU,IAAI,gBAAgB,CAAC,CAAC;CACrD,MAAM,MAAM,MAAM,cAAc,CAAC;CACjC,MAAM,cAAc,MAAM,eAAe,kBAAkB;CAC3D,MAAM,UACL,MAAM,WACN,IAAI,aAAa,EAAE,MAAM,kBAAkB,QAAQ,MAAM,GAAG,CAAC,EAAE,CAAC;CAEjE,OAAO,YAAY,SAAS,YAAY;EACvC,MAAM,EAAE,cAAc,MAAM,oBAAoB,QAAQ,MAAM,GAAG,GAAG,EACnE,QACD,CAAC;EACD,oBAAoB,UAAU,QAAQ,MAAM,KAAK;EACjD,uBAAuB,WAAW,MAAM,OAAO,iBAAiB;EAEhE,MAAM,QAAQ,MAAM,iBAAiB;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AAM,aAAa,KAAK;KACvB;KACA,OAAO;KACP,YAAY,MAAM;KAClB;KACA;IACD,CAAC;IACD,eAAe,OAAO,KAAK,QAAQ;IACnC,MAAM,QAAQ,KAAK;IACnB,IAAI,QAAQ,IAAI,cAAc,SAAS,KAAK;IAC5C,OAAO,KAAK;KAAE;KAAK,MAAM;KAAS,IAAI;IAAS,CAAC;GACjD;GAEA,OAAO;EACR,UAAU;GACT,MAAM,KAAK,QAAQ;EACpB;CACD,CAAC;AACF"}
@@ -1,4 +1,4 @@
1
- import { K as DeployRuntime, Wt as GkmError, et as TargetOptionsIssue } from "./types-Bmjs4jZV.mjs";
1
+ import { K as DeployRuntime, Wt as GkmError, et as TargetOptionsIssue } from "./types-SEHMr6Aw.cjs";
2
2
  //#region src/target/builtins.d.ts
3
3
  /** A target name that is neither built in nor in `deploy.targets`. */
4
4
  declare class UnknownDeployTarget extends GkmError {
@@ -79,4 +79,4 @@ declare class TargetRuntimeUndeclared extends GkmError {
79
79
  }
80
80
  //#endregion
81
81
  export { TargetRuntimeMismatch as a, DeployTargetNotYetSupported as c, TargetPackageInvalid as i, UnknownDeployTarget as l, InvalidTargetOptions as n, ProviderRemoved as o, TargetEntryInvalid as r, TargetPackageNotFound as s, TargetRuntimeUndeclared as t };
82
- //# sourceMappingURL=runtime-DCkfI2E7.d.mts.map
82
+ //# sourceMappingURL=runtime-C_1PteGG.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"runtime-DCkfI2E7.d.mts","names":[],"sources":["../src/target/builtins.ts","../src/target/package.ts","../src/target/provider.ts","../src/target/resolve.ts","../src/target/runtime.ts"],"mappings":";;;cAgEa,4BAA4B;WAE9B;;WAEA;EAHV,YACU,gBAEA;;EAAA;;;cAUE,oCAAoC;WAEtC;;WAEA;EAHV,YACU,gBAEA;;EAAA;;;;;cCrDE,8BAA8B;WAEhC;WACA;WACA;EAHV,YACU,gBACA,qBACA;;;;;cCZE,wBAAwB;WAE1B;;WAEA;EAHV,YACU,kBAEA;;EAAA;;;;;cCoCE,6BAA6B;WAE/B;WACA;EAFV,YACU,gBACA;;;cAUE,2BAA2B;WAClB;EAArB,YAAqB;;;cAST,8BAA8B;WAEhC;WACA;WACA,UAAU;WACV,QAAQ;EAJlB,YACU,gBACA,qBACA,UAAU,eACV,QAAQ;;;cAUN,6BAA6B;WAE/B;WACA,iBAAiB;EAF3B,YACU,gBACA,iBAAiB;;;;;cC1Ef,gCAAgC;WAElC;WACA;;WAEA;EAJV,YACU,gBACA,qBAEA;;EAAA"}
1
+ {"version":3,"file":"runtime-C_1PteGG.d.cts","names":[],"sources":["../src/target/builtins.ts","../src/target/package.ts","../src/target/provider.ts","../src/target/resolve.ts","../src/target/runtime.ts"],"mappings":";;;cAgEa,4BAA4B;WAE9B;;WAEA;EAHV,YACU,gBAEA;;EAAA;;;cAUE,oCAAoC;WAEtC;;WAEA;EAHV,YACU,gBAEA;;EAAA;;;;;cCrDE,8BAA8B;WAEhC;WACA;WACA;EAHV,YACU,gBACA,qBACA;;;;;cCZE,wBAAwB;WAE1B;;WAEA;EAHV,YACU,kBAEA;;EAAA;;;;;cCoCE,6BAA6B;WAE/B;WACA;EAFV,YACU,gBACA;;;cAUE,2BAA2B;WAClB;EAArB,YAAqB;;;cAST,8BAA8B;WAEhC;WACA;WACA,UAAU;WACV,QAAQ;EAJlB,YACU,gBACA,qBACA,UAAU,eACV,QAAQ;;;cAUN,6BAA6B;WAE/B;WACA,iBAAiB;EAF3B,YACU,gBACA,iBAAiB;;;;;cC1Ef,gCAAgC;WAElC;WACA;;WAEA;EAJV,YACU,gBACA,qBAEA;;EAAA"}
@@ -1,4 +1,4 @@
1
- import { K as DeployRuntime, Wt as GkmError, et as TargetOptionsIssue } from "./types-D0IsQxES.cjs";
1
+ import { K as DeployRuntime, Wt as GkmError, et as TargetOptionsIssue } from "./types-DLANxOpy.mjs";
2
2
  //#region src/target/builtins.d.ts
3
3
  /** A target name that is neither built in nor in `deploy.targets`. */
4
4
  declare class UnknownDeployTarget extends GkmError {
@@ -79,4 +79,4 @@ declare class TargetRuntimeUndeclared extends GkmError {
79
79
  }
80
80
  //#endregion
81
81
  export { TargetRuntimeMismatch as a, DeployTargetNotYetSupported as c, TargetPackageInvalid as i, UnknownDeployTarget as l, InvalidTargetOptions as n, ProviderRemoved as o, TargetEntryInvalid as r, TargetPackageNotFound as s, TargetRuntimeUndeclared as t };
82
- //# sourceMappingURL=runtime-Ie4znWIB.d.cts.map
82
+ //# sourceMappingURL=runtime-jjB2e3-M.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"runtime-Ie4znWIB.d.cts","names":[],"sources":["../src/target/builtins.ts","../src/target/package.ts","../src/target/provider.ts","../src/target/resolve.ts","../src/target/runtime.ts"],"mappings":";;;cAgEa,4BAA4B;WAE9B;;WAEA;EAHV,YACU,gBAEA;;EAAA;;;cAUE,oCAAoC;WAEtC;;WAEA;EAHV,YACU,gBAEA;;EAAA;;;;;cCrDE,8BAA8B;WAEhC;WACA;WACA;EAHV,YACU,gBACA,qBACA;;;;;cCZE,wBAAwB;WAE1B;;WAEA;EAHV,YACU,kBAEA;;EAAA;;;;;cCoCE,6BAA6B;WAE/B;WACA;EAFV,YACU,gBACA;;;cAUE,2BAA2B;WAClB;EAArB,YAAqB;;;cAST,8BAA8B;WAEhC;WACA;WACA,UAAU;WACV,QAAQ;EAJlB,YACU,gBACA,qBACA,UAAU,eACV,QAAQ;;;cAUN,6BAA6B;WAE/B;WACA,iBAAiB;EAF3B,YACU,gBACA,iBAAiB;;;;;cC1Ef,gCAAgC;WAElC;WACA;;WAEA;EAJV,YACU,gBACA,qBAEA;;EAAA"}
1
+ {"version":3,"file":"runtime-jjB2e3-M.d.mts","names":[],"sources":["../src/target/builtins.ts","../src/target/package.ts","../src/target/provider.ts","../src/target/resolve.ts","../src/target/runtime.ts"],"mappings":";;;cAgEa,4BAA4B;WAE9B;;WAEA;EAHV,YACU,gBAEA;;EAAA;;;cAUE,oCAAoC;WAEtC;;WAEA;EAHV,YACU,gBAEA;;EAAA;;;;;cCrDE,8BAA8B;WAEhC;WACA;WACA;EAHV,YACU,gBACA,qBACA;;;;;cCZE,wBAAwB;WAE1B;;WAEA;EAHV,YACU,kBAEA;;EAAA;;;;;cCoCE,6BAA6B;WAE/B;WACA;EAFV,YACU,gBACA;;;cAUE,2BAA2B;WAClB;EAArB,YAAqB;;;cAST,8BAA8B;WAEhC;WACA;WACA,UAAU;WACV,QAAQ;EAJlB,YACU,gBACA,qBACA,UAAU,eACV,QAAQ;;;cAUN,6BAA6B;WAE/B;WACA,iBAAiB;EAF3B,YACU,gBACA,iBAAiB;;;;;cC1Ef,gCAAgC;WAElC;WACA;;WAEA;EAJV,YACU,gBACA,qBAEA;;EAAA"}
@@ -1,7 +1,7 @@
1
- const require_discover = require("../discover-DL6h-J97.cjs");
1
+ const require_discover = require("../discover-DEOspD9M.cjs");
2
2
  const require_sandbox = require("../sandbox-CHv3OYXg.cjs");
3
3
  const require_workerRuntime = require("../workerRuntime-BXfhbe13.cjs");
4
- const require_credentialSchemas = require("../credentialSchemas-DFxvGEwa.cjs");
4
+ const require_credentialSchemas = require("../credentialSchemas-CM0rxWmS.cjs");
5
5
  let node_path = require("node:path");
6
6
  let node_fs_promises = require("node:fs/promises");
7
7
  //#region src/sandbox/credentials-worker.ts
@@ -1,7 +1,7 @@
1
- import { i as discover } from "../discover-CzGM5P3p.mjs";
1
+ import { i as discover } from "../discover-DOhYSKY_.mjs";
2
2
  import { t as SECRETS_DIR_ENV } from "../sandbox-CbVB7uOD.mjs";
3
3
  import { a as registerAdjacentTsconfig, n as answer, r as errorData } from "../workerRuntime-CsOyBRx2.mjs";
4
- import { a as liveCredentials, r as inspectLive } from "../credentialSchemas-DaMpt-Dx.mjs";
4
+ import { a as liveCredentials, r as inspectLive } from "../credentialSchemas-DPOGqOrU.mjs";
5
5
  import { join } from "node:path";
6
6
  import { readFile, readdir } from "node:fs/promises";
7
7
  //#region src/sandbox/credentials-worker.ts
@@ -1,4 +1,4 @@
1
- const require_discover = require("../discover-DL6h-J97.cjs");
1
+ const require_discover = require("../discover-DEOspD9M.cjs");
2
2
  const require_workerRuntime = require("../workerRuntime-BXfhbe13.cjs");
3
3
  //#region src/sandbox/discover-worker.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { i as discover } from "../discover-CzGM5P3p.mjs";
1
+ import { i as discover } from "../discover-DOhYSKY_.mjs";
2
2
  import { a as registerAdjacentTsconfig, i as liveValuePaths, n as answer, r as errorData } from "../workerRuntime-CsOyBRx2.mjs";
3
3
  //#region src/sandbox/discover-worker.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
- const require_discover = require("../discover-DL6h-J97.cjs");
1
+ const require_discover = require("../discover-DEOspD9M.cjs");
2
2
  const require_sandbox = require("../sandbox-CHv3OYXg.cjs");
3
3
  const require_workerRuntime = require("../workerRuntime-BXfhbe13.cjs");
4
4
  const require_databases = require("../databases-CuVGf7-M.cjs");
@@ -1,4 +1,4 @@
1
- import { i as discover } from "../discover-CzGM5P3p.mjs";
1
+ import { i as discover } from "../discover-DOhYSKY_.mjs";
2
2
  import { t as SECRETS_DIR_ENV } from "../sandbox-CbVB7uOD.mjs";
3
3
  import { a as registerAdjacentTsconfig, n as answer, r as errorData } from "../workerRuntime-CsOyBRx2.mjs";
4
4
  import { o as SeedFailed, p as seedDatabases, u as migrateDatabases } from "../databases-6GD0tI2F.mjs";
@@ -2,14 +2,14 @@ import { t as __exportAll } from "./rolldown-runtime-BhDjJH2R.mjs";
2
2
  import { t as GkmError } from "./errors-D8Gwp5kU.mjs";
3
3
  import { s as run$1, x as gkmHome } from "./credentials-DpfnUvIR.mjs";
4
4
  import { B as LOGS_PORT, H as provisioningOf, R as stageSampleRate, U as stageProvider, _ as PUBLIC_ENV_PREFIXES, a as allConstructGlobs, ct as UnknownSecretsStoreProvider, ft as SERVER_IPV4_KEY, ht as isReservedStageKey, j as TEST_STAGE, pt as SERVER_IPV6_KEY, ut as s3SecretsLocation, v as getPublicEnvPrefix, z as telemetryEnv } from "./workspace-DBHF9Gba.mjs";
5
- import { t as appKey } from "./derive-B4vDpzgP.mjs";
5
+ import { t as appKey } from "./derive-Dew0QoGe.mjs";
6
6
  import { c as DEFAULT_STORAGE, l as holdsEveryCache, o as DEFAULT_CACHE, s as DEFAULT_EVENTS$1 } from "./drivers-CDjpjakg.mjs";
7
7
  import { n as deployIdentity } from "./identity-CBXr4wNi.mjs";
8
- import { a as startTelemetryCode, n as runtimeFor, s as writeTelemetryModule, u as telemetryArgs } from "./EndpointGenerator-errMeldx.mjs";
9
- import { d as ConstructGenerator, f as output, h as eventsEdgeBucket, i as discover } from "./discover-CzGM5P3p.mjs";
8
+ import { a as startTelemetryCode, n as runtimeFor, s as writeTelemetryModule, u as telemetryArgs } from "./EndpointGenerator-B99OGzbO.mjs";
9
+ import { d as ConstructGenerator, f as output, h as eventsEdgeBucket, i as discover } from "./discover-DOhYSKY_.mjs";
10
10
  import { ConfigNotFound, NotInAnApp, loadWorkspaceAppInfo, loadWorkspaceConfig } from "./config.mjs";
11
- import { i as readFakes, o as objectsRoute, r as readCredentialFakes, t as SubscriberGenerator } from "./SubscriberGenerator-BALddfuW.mjs";
12
- import { c as runtimeOf } from "./resolve-fCGJmM-R.mjs";
11
+ import { i as readFakes, o as objectsRoute, r as readCredentialFakes, t as SubscriberGenerator } from "./SubscriberGenerator-0ruEmYXj.mjs";
12
+ import { c as runtimeOf } from "./resolve-CCVCc43b.mjs";
13
13
  import { basename, dirname, isAbsolute, join, parse, relative, resolve, sep } from "node:path";
14
14
  import { constants, existsSync, readFileSync } from "node:fs";
15
15
  import { appendFile, chmod, copyFile, mkdir, readFile, readdir, rm, stat, writeFile } from "node:fs/promises";
@@ -542,6 +542,7 @@ function processorsDevRoute(fileServerId) {
542
542
  const EDGE_KINDS = {
543
543
  "file-server": true,
544
544
  "rest-api": true,
545
+ "websocket-api": true,
545
546
  site: true
546
547
  };
547
548
  /**
@@ -888,7 +889,7 @@ function telemetryOf(manifest, id) {
888
889
  const declaration = manifest[id];
889
890
  if (!declaration) return void 0;
890
891
  if (declaration.kind === "worker" || declaration.kind === "file-server") return nodeOf(manifest, declaration.telemetry);
891
- if (declaration.kind !== "rest-api") return void 0;
892
+ if (declaration.kind !== "rest-api" && declaration.kind !== "websocket-api") return void 0;
892
893
  return nodeOf(manifest, declaration.telemetry);
893
894
  }
894
895
  /**
@@ -896,12 +897,12 @@ function telemetryOf(manifest, id) {
896
897
  * undefined for a site, an app without one, or one with no edge.
897
898
  */
898
899
  function appTelemetry(manifest, appName) {
899
- const id = Object.entries(manifest).find(([id, d]) => d.kind === "rest-api" && appKey(id) === appName)?.[0];
900
+ const id = Object.entries(manifest).find(([id, d]) => (d.kind === "rest-api" || d.kind === "websocket-api") && appKey(id) === appName)?.[0];
900
901
  return id ? telemetryOf(manifest, id) : void 0;
901
902
  }
902
903
  /** Whether any process in the manifest emits through a `Telemetry` node. */
903
904
  function usesTelemetry(manifest) {
904
- return Object.entries(manifest).some(([id, d]) => (d.kind === "rest-api" || d.kind === "worker" || d.kind === "file-server") && telemetryOf(manifest, id) !== void 0);
905
+ return Object.entries(manifest).some(([id, d]) => (d.kind === "rest-api" || d.kind === "websocket-api" || d.kind === "worker" || d.kind === "file-server") && telemetryOf(manifest, id) !== void 0);
905
906
  }
906
907
  /**
907
908
  * One process's share of the telemetry keys a stage resolved: all of them,
@@ -975,7 +976,8 @@ const CONTAINERS = {
975
976
  "database-schema": "postgres",
976
977
  objects: "minio",
977
978
  "file-server": "caddy",
978
- email: "mailpit"
979
+ email: "mailpit",
980
+ "websocket-api": "redis"
979
981
  };
980
982
  /**
981
983
  * The container a cache backend needs locally.
@@ -1155,7 +1157,7 @@ function planFor(manifest, stage, order, options = {}) {
1155
1157
  name: resourceName(id, declaration.kind, stage, options.localStage),
1156
1158
  envKey: providedKeyFor(id, declaration.kind, ROLES[declaration.kind] ?? "url"),
1157
1159
  provisions: PROVISIONS[declaration.kind] === true,
1158
- ...declaration.kind === "rest-api" ? { callers: dependentsOf(manifest, id) } : {},
1160
+ ...declaration.kind === "rest-api" || declaration.kind === "websocket-api" ? { callers: dependentsOf(manifest, id) } : {},
1159
1161
  ...declaration.kind === "site" ? { publicEnv: publicEnvFor(declaration, manifest) } : {},
1160
1162
  ...declaration.kind === "mobile-app" ? {
1161
1163
  publicEnv: publicEnvFor(declaration, manifest),
@@ -1164,7 +1166,7 @@ function planFor(manifest, stage, order, options = {}) {
1164
1166
  ...declaration.kind === "file-server" && declaration.open?.length ? { open: declaration.open } : {},
1165
1167
  ...declaration.kind === "file-server" && declaration.processors?.length ? { processors: [...new Set(declaration.processors.map((p) => p.prefix))].sort() } : {},
1166
1168
  ...declaration.kind === "objects" && bucketExpiry(manifest, id) ? { expire: bucketExpiry(manifest, id) } : {},
1167
- ...(declaration.kind === "rest-api" || declaration.kind === "site") && declaration.subdomain ? { subdomain: declaration.subdomain } : {},
1169
+ ...(declaration.kind === "rest-api" || declaration.kind === "websocket-api" || declaration.kind === "site") && declaration.subdomain ? { subdomain: declaration.subdomain } : {},
1168
1170
  ...fake ? { fake: {
1169
1171
  key: fake.key,
1170
1172
  credentials: fake.credentials
@@ -1331,6 +1333,12 @@ function envFor(plan, options) {
1331
1333
  ...options.lanAddress ? { lanAddress: options.lanAddress } : {},
1332
1334
  ...options.metroPorts ? { metroPorts: options.metroPorts } : {}
1333
1335
  }));
1336
+ if (resource.kind === "websocket-api") {
1337
+ const origins = surfaceEnv(resource, url, resolved)[provideKey(resource.id, "trustedOrigins")];
1338
+ if (origins !== void 0) env[provideKey(resource.id, "trustedOrigins")] = origins;
1339
+ const publisher = webSocketPublisher(resource, options.ports, options.project ?? "", credential);
1340
+ if (publisher) env[provideKey(resource.id, "publisherConnectionString")] = publisher;
1341
+ }
1334
1342
  if (url) env[resource.envKey] = url;
1335
1343
  if (isDatabase(resource.kind) && resource.roles !== false) {
1336
1344
  const owner = ownerUrl(resource, plan, options.ports, options.project ?? "", credential);
@@ -1423,10 +1431,27 @@ function surfaceEnv(resource, url, resolved = {}, local = {}) {
1423
1431
  ...device ? { [provideKey(resource.id, "deviceUrl")]: device } : {}
1424
1432
  };
1425
1433
  }
1426
- /** An address reduced to the origin a browser compares against. */
1434
+ /**
1435
+ * Where a WebSocket surface's publisher meets its sockets: the local Redis,
1436
+ * on channels named for the project and the surface, so two projects sharing
1437
+ * one Redis never see each other's frames.
1438
+ */
1439
+ function webSocketPublisher(resource, ports, project, credential) {
1440
+ const port = ports[primaryPortKey("redis")];
1441
+ if (port === void 0) return void 0;
1442
+ const channel = encodeURIComponent(`gkm:ws:${project ? `${project}:` : ""}${resource.id}`);
1443
+ return `redis://:${encodeURIComponent(credential.containers.redis.password)}@${LOCAL_HOST}:${port}?channel=${channel}`;
1444
+ }
1445
+ /**
1446
+ * An address reduced to the origin a browser compares against.
1447
+ *
1448
+ * A WebSocket surface's address is `wss://`, but its host is served over
1449
+ * HTTPS like any other: its origin is that one, and a non-web scheme among the
1450
+ * origins means a mobile app to whoever reads the list.
1451
+ */
1427
1452
  function originOf(address) {
1428
1453
  try {
1429
- return new URL(address).origin;
1454
+ return new URL(address.replace(/^ws(s?):/, "http$1:")).origin;
1430
1455
  } catch {
1431
1456
  return;
1432
1457
  }
@@ -1514,6 +1539,11 @@ function urlFor(resource, plan, ports, project, addresses, credential) {
1514
1539
  const edge = plan.containers.includes("caddy") ? ports[primaryPortKey("caddy")] : void 0;
1515
1540
  return address && edge !== void 0 ? `https://${hostFor$1(resource, project)}:${edge}` : address;
1516
1541
  }
1542
+ if (resource.kind === "websocket-api") {
1543
+ const address = addresses?.[resource.id];
1544
+ const edge = plan.containers.includes("caddy") ? ports[primaryPortKey("caddy")] : void 0;
1545
+ return address && edge !== void 0 ? `wss://${hostFor$1(resource, project)}:${edge}` : address?.replace(/^http/, "ws");
1546
+ }
1517
1547
  if (!resource.container) return void 0;
1518
1548
  const port = ports[primaryPortKey(resource.container)];
1519
1549
  if (port === void 0) return void 0;
@@ -1786,11 +1816,14 @@ var RedisPasswordMissing = class extends GkmError {
1786
1816
  }
1787
1817
  };
1788
1818
  /**
1789
- * Whether a stage's stack runs Redis: a cache is declared and the stage's
1790
- * secrets do not set the URL of every one.
1819
+ * Whether a stage's stack runs Redis: a cache or a WebSocket surface is
1820
+ * declared and the stage's secrets do not set the URL of every one.
1791
1821
  */
1792
1822
  function runsRedis(manifest, custom) {
1793
- return Object.values(manifest).some((declaration) => declaration?.kind === "cache" && (declaration.provides ?? []).some((key) => custom[key] === void 0));
1823
+ return Object.values(manifest).some((declaration) => {
1824
+ if (declaration?.kind === "cache") return (declaration.provides ?? []).some((key) => custom[key] === void 0);
1825
+ return declaration?.kind === "websocket-api" && custom[provideKey(declaration.id, "publisherConnectionString")] === void 0;
1826
+ });
1794
1827
  }
1795
1828
  /** A password: 256 random bits, URL-safe, so it sits in a URL unescaped. */
1796
1829
  function generateRedisPassword() {
@@ -1827,7 +1860,8 @@ function withRedisPassword(secrets) {
1827
1860
  function stackRedis(options) {
1828
1861
  const { plan, stage, local, custom } = options;
1829
1862
  const caches = plan.resources.filter((r) => r.kind === "cache" && custom[r.envKey] === void 0).sort((a, b) => a.id.localeCompare(b.id));
1830
- if (caches.length === 0) return void 0;
1863
+ const publishers = plan.resources.filter((r) => r.kind === "websocket-api").map((r) => provideKey(r.id, "publisherConnectionString")).filter((key) => custom[key] === void 0);
1864
+ if (caches.length === 0 && publishers.length === 0) return void 0;
1831
1865
  const set = custom[REDIS_PASSWORD_KEY];
1832
1866
  const password = set ?? (local ? options.localPassword : void 0);
1833
1867
  if (!password) throw new RedisPasswordMissing(stage);
@@ -1835,7 +1869,7 @@ function stackRedis(options) {
1835
1869
  return {
1836
1870
  password,
1837
1871
  passwordFromSecrets: Boolean(set),
1838
- urls: Object.fromEntries(caches.map((cache, index) => [cache.envKey, `redis://:${auth}@${REDIS_SERVICE}:${REDIS_PORT}/${index}`])),
1872
+ urls: Object.fromEntries([...caches.map((cache, index) => [cache.envKey, `redis://:${auth}@${REDIS_SERVICE}:${REDIS_PORT}/${index}`]), ...publishers.map((key) => [key, `redis://:${auth}@${REDIS_SERVICE}:${REDIS_PORT}`])]),
1839
1873
  env: {
1840
1874
  [REDIS_PASSWORD_KEY]: password,
1841
1875
  REDISCLI_AUTH: password
@@ -2960,11 +2994,11 @@ function processorUnits(workspace, manifest) {
2960
2994
  /** The backend apps whose builds generate a server, each where it lives. */
2961
2995
  function hostApps(workspace, manifest) {
2962
2996
  return Object.entries(workspace.apps).filter(([, app]) => app.type === "backend" && !app.entry).map(([name, app]) => {
2963
- const surface = Object.entries(manifest).find(([id, d]) => d.kind === "rest-api" && appKey(id) === name)?.[1];
2997
+ const surface = Object.entries(manifest).find(([id, d]) => (d.kind === "rest-api" || d.kind === "websocket-api") && appKey(id) === name)?.[1];
2964
2998
  return {
2965
2999
  name,
2966
3000
  root: isAbsolute(app.path) ? app.path : join(workspace.root, app.path),
2967
- generated: !(surface?.kind === "rest-api" && surface.endpoints.length > 0)
3001
+ generated: !(surface?.kind === "websocket-api" || surface?.kind === "rest-api" && surface.endpoints.length > 0)
2968
3002
  };
2969
3003
  }).sort((a, b) => a.name.localeCompare(b.name));
2970
3004
  }
@@ -6152,7 +6186,7 @@ function processorAddresses(workspace, manifest) {
6152
6186
  function surfaceAddresses(workspace, manifest, at = (_app, port) => localAddress(port)) {
6153
6187
  const addresses = {};
6154
6188
  for (const [id, declaration] of Object.entries(manifest)) {
6155
- if (declaration.kind !== "rest-api" && declaration.kind !== "site") continue;
6189
+ if (declaration.kind !== "rest-api" && declaration.kind !== "websocket-api" && declaration.kind !== "site") continue;
6156
6190
  const host = appKey(id);
6157
6191
  const port = workspace.apps[host]?.port;
6158
6192
  if (port) addresses[id] = at(host, port);
@@ -6277,7 +6311,7 @@ function networkEnv(plan, options, hostOf = (container) => container) {
6277
6311
  * port.
6278
6312
  */
6279
6313
  function appEnvKeys(manifest, appName, runnables = {}) {
6280
- const entry = Object.entries(manifest).find(([id, d]) => (d.kind === "rest-api" || d.kind === "site" || d.kind === "mobile-app") && appKey(id) === appName);
6314
+ const entry = Object.entries(manifest).find(([id, d]) => (d.kind === "rest-api" || d.kind === "websocket-api" || d.kind === "site" || d.kind === "mobile-app") && appKey(id) === appName);
6281
6315
  if (!entry) return void 0;
6282
6316
  const [id, declaration] = entry;
6283
6317
  const keys = /* @__PURE__ */ new Set([
@@ -6285,7 +6319,7 @@ function appEnvKeys(manifest, appName, runnables = {}) {
6285
6319
  ...declaration.requires ?? [],
6286
6320
  ...declaration.kind === "rest-api" ? declaration.endpoints.flatMap((endpoint) => endpoint.requires ?? []) : []
6287
6321
  ]);
6288
- addEdgeKeys(manifest, [...dependenciesOf(declaration).map((edge) => edge.target), ...runnables[id] ?? []], keys);
6322
+ addEdgeKeys(manifest, [...dependenciesOf(declaration).map((edge) => edge.target), ...runnables[id] ?? []], keys, declaration.kind === "site" || declaration.kind === "mobile-app");
6289
6323
  if (declaration.kind === "site" || declaration.kind === "mobile-app") {
6290
6324
  for (const key of TELEMETRY_KEYS) keys.delete(key);
6291
6325
  for (const key of Object.keys(publicEnvFor(declaration, manifest))) keys.add(key);
@@ -6327,7 +6361,7 @@ function processorEnvKeys(manifest, fileServerId, runnables = {}) {
6327
6361
  ], keys);
6328
6362
  return keys;
6329
6363
  }
6330
- function addEdgeKeys(manifest, edges, keys) {
6364
+ function addEdgeKeys(manifest, edges, keys, client = false) {
6331
6365
  for (const id of edges) {
6332
6366
  const bucket = eventsEdgeBucket(id);
6333
6367
  if (bucket) {
@@ -6343,6 +6377,11 @@ function addEdgeKeys(manifest, edges, keys) {
6343
6377
  keys.add(provideKey(id, "url"));
6344
6378
  continue;
6345
6379
  }
6380
+ if (target.kind === "websocket-api") {
6381
+ keys.add(provideKey(id, "url"));
6382
+ if (!client) keys.add(provideKey(id, "publisherConnectionString"));
6383
+ continue;
6384
+ }
6346
6385
  for (const key of target.provides ?? []) keys.add(key);
6347
6386
  if (target.kind === "queue" || target.kind === "topic") keys.add("EVENT_PUBLISHER_CONNECTION_STRING");
6348
6387
  if (target.kind === "objects") {
@@ -6573,7 +6612,7 @@ function stageServiceDeclarations(input) {
6573
6612
  };
6574
6613
  for (const [id, declaration] of Object.entries(manifest)) {
6575
6614
  const name = appKey(id);
6576
- if (declaration.kind === "rest-api" || declaration.kind === "site" || declaration.kind === "mobile-app") read(name, appEnvKeys(manifest, name, runnables) ?? []);
6615
+ if (declaration.kind === "rest-api" || declaration.kind === "websocket-api" || declaration.kind === "site" || declaration.kind === "mobile-app") read(name, appEnvKeys(manifest, name, runnables) ?? []);
6577
6616
  if (declaration.kind === "site") read(name, Object.values(publicEnvFor(declaration, manifest)));
6578
6617
  if (declaration.kind === "worker") read(name, workerEnvKeys(manifest, id, runnables) ?? []);
6579
6618
  }
@@ -8284,7 +8323,7 @@ async function createDnsProvider(options) {
8284
8323
  });
8285
8324
  }
8286
8325
  if (provider === "godaddy") {
8287
- const { GoDaddyProvider } = await import("./GoDaddyProvider-CvRVmN4W.mjs");
8326
+ const { GoDaddyProvider } = await import("./GoDaddyProvider-BG-UdElN.mjs");
8288
8327
  return new GoDaddyProvider(options.godaddy ?? {});
8289
8328
  }
8290
8329
  if (provider === "cloudflare") throw new DnsProviderNotImplemented("cloudflare");
@@ -9135,4 +9174,4 @@ function reportPlannedSeeds(planned, log) {
9135
9174
  //#endregion
9136
9175
  export { ORIGIN_VERIFY_HEADER as $, telemetryOf as $n, maskPassword as $t, StageProviderDisabled as A, postgresSuperuser as An, LEGACY_LOCAL_LOGIN as At, processorDockerfile as B, redisService as Bn, createCredentialsPreload as Bt, recordRollback as C, postgresDatabaseNames as Cn, backendsOf as Ct, setPostgresBackupId as D, LOCAL_RABBITMQ_USER as Dn, workspace_exports as Dt, setGeneratedSecret as E, mergeLifecycle as En, reconcileWorkspace as Et, DockerBuildFailed as F, projectKey as Fn, composeFor as Ft, workerBundleName as G, localRolePassword as Gn, loadPortState as Gt, workerDockerfile as H, stackRedis as Hn, findAvailablePort as Ht, DockerPushFailed as I, readKey as In, cacheBackendFor as It, CronGenerator as J, resourceName as Jn, isRemoteStore as Jt, workerEntryDir as K, TELEMETRY_CONTAINER as Kn, loadSecretsForApp as Kt, appDockerfile as L, withGeneratedSecrets as Ln, eventsBackendFor as Lt, provisionCommand as M, FileSecretsStore as Mn, bucketClient as Mt, stageProviderNotes as N, getKeyPath as Nn, pgClient as Nt, DnsRecordsUnreadable as O, loadLocalCredentials as On, LOCAL_CA_PATH as Ot, PROVIDER_KINDS as P, keystoreProject as Pn, CLUSTER_DATABASE as Pt, processorInfo as Q, surfaceClientTraced as Qn, initStageSecrets as Qt, dockerCommand as R, REDIS_SERVICE as Rn, providerOf as Rt, recordRelease as S, bucketPolicies as Sn, FAKE_ENV as St, setBackupState as T, quoteIdentifier as Tn, derivedContainers as Tt, workerDockerfileOf as U, withRedisPassword as Un, isPortAvailable as Ut, processorNative as V, runsRedis as Vn, createEntryWrapper as Vt, WorkerGenerator as W, envFor as Wn, loadEnvFiles as Wt, processorBundleName as X, isTelemetryKey as Xn, storeFromConfig as Xt, ProcessorGenerator as Y, appTelemetry as Yn, secretsStoreFor as Yt, processorEntryDir as Z, scopeTelemetryEnv as Zn, store_exports as Zt, asDokployState as _, applyLifecycles as _n, withLogsPassword as _r, appEnvKeys as _t, dnsResources as a, PROCESSOR_PORT as an, DEFAULT_IMAGES as ar, AllowDevServicesTakesNoValue as at, getBackupState as b, applyPostgres as bn, resolveHost as br, processorEnvKeys as bt, currentActor as c, detectPackageManager as cn, portKeys as cr, ExternalServicesNotConfigured as ct, DeployJournal as d, isImageBuild as dn, primaryPortKey as dr, devServicesUsed as dt, storage_exports as en, usesTelemetry as er, PROCESSOR_ORIGIN_SECRET_ENV as et, extractSubdomain as f, publicBuildValues as fn, LOCAL_LOGS_EMAIL as fr, externalServices as ft, verifyDnsRecords as g, applyBuckets as gn, stackLogs as gr, suppliedOnly as gt, orchestrateDns as h, workerUnits as hn, logsService as hr, stageServiceDeclarations as ht, dnsRecordResource as i, imageLayout as in, hostFor$1 as ir, validateImageRef as it, assertStageProvidersEnabled as j, readLocalCredentials as jn, ensurePostgresLogin as jt, createDnsProvider as k, postgresRoleSlug as kn, forgetState as kt, describeActor as l, findBuildRoot as ln, portsOf as lr, STORAGE_KEY_PAIR as lt, normalizeDnsConfig as m, processorUnits as mn, logsAccess as mr, requiredStageKeys as mt, reportDatabaseRuns as n, withCustomSecret as nn, watchedBuckets as nr, originSecretKey as nt, forgetDnsResource as o, TURBO_VERSION as on, describeServices as or, DEV_SERVICES as ot, findRootDomain as p, isUnder as pn, LOGS_SERVICE as pr, reportDevServices as pt, QueueGenerator as q, planFor as qn, prepareEntryCredentials as qt, reportPlannedSeeds as r, composeBuildPaths as rn, EMULATOR_ACCESS_KEY_ID as rr, processorOriginHost as rt, recordDnsChanges as s, WORKER_PORT as sn, fakeKey as sr, DevServicesNeedServerTarget as st, DeploySeedsFailed as t, toEmbeddableSecrets as tn, minioWebhookEnv as tr, newOriginSecret as tt, isCi as u, imageBuildCredentials as un, postgresImage as ur, assertDevServicesFlag as ut, createComposeState as v, applyNotifications as vn, NoDomainForStage as vr, dockerfileOf as vt, setApplicationId as w, postgresStatements as wn, constructGlobs as wt, getGeneratedSecret as x, bucketLifecycles as xn, workerEnvKeys as xt, createEmptyState as y, applyPolicies as yn, isMainFrontendApp as yr, networkEnv as yt, ensureDockerignore as z, STACK_CACHE as zn, storageBackendFor as zt };
9137
9176
 
9138
- //# sourceMappingURL=seeds-Cfejy8wj.mjs.map
9177
+ //# sourceMappingURL=seeds-BX9pskrU.mjs.map