@geekmidas/cli 10.0.0-alpha.67 → 10.0.0-alpha.69

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 (175) hide show
  1. package/dist/{LegacyStateStore-C39UKwmf.mjs → LegacyStateStore-BE1Et8RS.mjs} +2 -2
  2. package/dist/{LegacyStateStore-C39UKwmf.mjs.map → LegacyStateStore-BE1Et8RS.mjs.map} +1 -1
  3. package/dist/{LegacyStateStore-BZiO9-Lw.cjs → LegacyStateStore-LS_uTO8D.cjs} +2 -2
  4. package/dist/{LegacyStateStore-BZiO9-Lw.cjs.map → LegacyStateStore-LS_uTO8D.cjs.map} +1 -1
  5. package/dist/{LocalStateStore-DHVsZLyF.cjs → LocalStateStore-CV6phNMZ.cjs} +2 -2
  6. package/dist/{LocalStateStore-DHVsZLyF.cjs.map → LocalStateStore-CV6phNMZ.cjs.map} +1 -1
  7. package/dist/{LocalStateStore-Dk3Wbvzk.mjs → LocalStateStore-DAnFc708.mjs} +2 -2
  8. package/dist/{LocalStateStore-Dk3Wbvzk.mjs.map → LocalStateStore-DAnFc708.mjs.map} +1 -1
  9. package/dist/{OpenApiTsGenerator-BmUAcR7d.mjs → OpenApiTsGenerator-CSaXs-dB.mjs} +2 -2
  10. package/dist/{OpenApiTsGenerator-BmUAcR7d.mjs.map → OpenApiTsGenerator-CSaXs-dB.mjs.map} +1 -1
  11. package/dist/{OpenApiTsGenerator-B2zrdyP4.cjs → OpenApiTsGenerator-CxB8mqXz.cjs} +2 -2
  12. package/dist/{OpenApiTsGenerator-B2zrdyP4.cjs.map → OpenApiTsGenerator-CxB8mqXz.cjs.map} +1 -1
  13. package/dist/{S3StateStore-B_ZF9eHt.mjs → S3StateStore-8kJEGnTh.mjs} +2 -2
  14. package/dist/{S3StateStore-B_ZF9eHt.mjs.map → S3StateStore-8kJEGnTh.mjs.map} +1 -1
  15. package/dist/{S3StateStore--4tYVMAL.cjs → S3StateStore-dA34LAYm.cjs} +2 -2
  16. package/dist/{S3StateStore--4tYVMAL.cjs.map → S3StateStore-dA34LAYm.cjs.map} +1 -1
  17. package/dist/{SSMStateStore-ACZ8hRvZ.cjs → SSMStateStore-DBzlfc-S.cjs} +2 -2
  18. package/dist/{SSMStateStore-ACZ8hRvZ.cjs.map → SSMStateStore-DBzlfc-S.cjs.map} +1 -1
  19. package/dist/{SSMStateStore-DjPuKqrm.mjs → SSMStateStore-Dkdw-fPL.mjs} +2 -2
  20. package/dist/{SSMStateStore-DjPuKqrm.mjs.map → SSMStateStore-Dkdw-fPL.mjs.map} +1 -1
  21. package/dist/add-CoIr2wgv.cjs +568 -0
  22. package/dist/add-CoIr2wgv.cjs.map +1 -0
  23. package/dist/add-Dzk23476.mjs +566 -0
  24. package/dist/add-Dzk23476.mjs.map +1 -0
  25. package/dist/{bundler-pyLj-gS0.cjs → bundler-CSR2nM4m.cjs} +5 -5
  26. package/dist/{bundler-pyLj-gS0.cjs.map → bundler-CSR2nM4m.cjs.map} +1 -1
  27. package/dist/{bundler-Bq3HaLOZ.mjs → bundler-Cn0JF5G0.mjs} +5 -5
  28. package/dist/{bundler-Bq3HaLOZ.mjs.map → bundler-Cn0JF5G0.mjs.map} +1 -1
  29. package/dist/{cli-DR7B2_fX.cjs → cli-IoM2-x48.cjs} +13 -4
  30. package/dist/cli-IoM2-x48.cjs.map +1 -0
  31. package/dist/{cli-C2Tjbn27.mjs → cli-ij8Lwlww.mjs} +13 -4
  32. package/dist/cli-ij8Lwlww.mjs.map +1 -0
  33. package/dist/{compose-BjToENzG.mjs → compose-CZtinmtw.mjs} +173 -58
  34. package/dist/compose-CZtinmtw.mjs.map +1 -0
  35. package/dist/{compose-5oNHAKNT.cjs → compose-DfIioFX0.cjs} +173 -58
  36. package/dist/compose-DfIioFX0.cjs.map +1 -0
  37. package/dist/{config-4XFxX1al.d.cts → config-BnA0kPTY.d.cts} +3 -3
  38. package/dist/{config-4XFxX1al.d.cts.map → config-BnA0kPTY.d.cts.map} +1 -1
  39. package/dist/{config-UtKzhpFb.d.mts → config-CxEp_g7j.d.mts} +3 -3
  40. package/dist/{config-UtKzhpFb.d.mts.map → config-CxEp_g7j.d.mts.map} +1 -1
  41. package/dist/config.cjs +3 -3
  42. package/dist/config.d.cts +3 -3
  43. package/dist/config.d.mts +3 -3
  44. package/dist/config.mjs +3 -3
  45. package/dist/credentialSchemas-BcNL1N5R.cjs +271 -0
  46. package/dist/credentialSchemas-BcNL1N5R.cjs.map +1 -0
  47. package/dist/credentialSchemas-BmYxnEz_.mjs +236 -0
  48. package/dist/credentialSchemas-BmYxnEz_.mjs.map +1 -0
  49. package/dist/deploy/public.cjs +11 -7
  50. package/dist/deploy/public.d.cts +15 -4
  51. package/dist/deploy/public.d.cts.map +1 -1
  52. package/dist/deploy/public.d.mts +15 -4
  53. package/dist/deploy/public.d.mts.map +1 -1
  54. package/dist/deploy/public.mjs +8 -8
  55. package/dist/{deploy-DRAwTG72.mjs → deploy-BzqbkJ3o.mjs} +11 -7
  56. package/dist/deploy-BzqbkJ3o.mjs.map +1 -0
  57. package/dist/{deploy-BucRfbvX.cjs → deploy-Dpz9raPM.cjs} +11 -7
  58. package/dist/deploy-Dpz9raPM.cjs.map +1 -0
  59. package/dist/{discover-OEfZ9OkA.cjs → discover-B4VjaFJk.cjs} +2 -2
  60. package/dist/{discover-OEfZ9OkA.cjs.map → discover-B4VjaFJk.cjs.map} +1 -1
  61. package/dist/{discover-BFoJWKGD.mjs → discover-Buwf1z4P.mjs} +2 -2
  62. package/dist/{discover-BFoJWKGD.mjs.map → discover-Buwf1z4P.mjs.map} +1 -1
  63. package/dist/{dokploy-m345Zx02.cjs → dokploy-B6O-J1fb.cjs} +2 -2
  64. package/dist/{dokploy-m345Zx02.cjs.map → dokploy-B6O-J1fb.cjs.map} +1 -1
  65. package/dist/{dokploy-DIt1IZl1.mjs → dokploy-DkwcORbv.mjs} +2 -2
  66. package/dist/{dokploy-DIt1IZl1.mjs.map → dokploy-DkwcORbv.mjs.map} +1 -1
  67. package/dist/{encryption-Ccbahik7.mjs → encryption-7m1mKcRy.mjs} +3 -3
  68. package/dist/{encryption-Ccbahik7.mjs.map → encryption-7m1mKcRy.mjs.map} +1 -1
  69. package/dist/{encryption-rZ3BghXy.cjs → encryption-C8Ic5t0C.cjs} +3 -3
  70. package/dist/{encryption-rZ3BghXy.cjs.map → encryption-C8Ic5t0C.cjs.map} +1 -1
  71. package/dist/{engine-Gs0abjuj.mjs → engine-62Kl70Pj.mjs} +146 -28
  72. package/dist/engine-62Kl70Pj.mjs.map +1 -0
  73. package/dist/{engine-Cx_dvx9q.cjs → engine-BR9qlS7A.cjs} +146 -28
  74. package/dist/engine-BR9qlS7A.cjs.map +1 -0
  75. package/dist/{github-CrcGFkfD.cjs → github-CmGIZjhu.cjs} +3 -3
  76. package/dist/{github-CrcGFkfD.cjs.map → github-CmGIZjhu.cjs.map} +1 -1
  77. package/dist/{github-CJANTYqi.mjs → github-DtymyOcH.mjs} +3 -3
  78. package/dist/{github-CJANTYqi.mjs.map → github-DtymyOcH.mjs.map} +1 -1
  79. package/dist/{index-DD1FfUHh.d.mts → index-CkX89m6S.d.mts} +2 -2
  80. package/dist/{index-CyApaHVe.d.cts.map → index-CkX89m6S.d.mts.map} +1 -1
  81. package/dist/{index-CyApaHVe.d.cts → index-EvZBkycu.d.cts} +2 -2
  82. package/dist/{index-DD1FfUHh.d.mts.map → index-EvZBkycu.d.cts.map} +1 -1
  83. package/dist/index.cjs +94 -52
  84. package/dist/index.cjs.map +1 -1
  85. package/dist/index.mjs +94 -52
  86. package/dist/index.mjs.map +1 -1
  87. package/dist/{migrate-DCVo5gLS.mjs → migrate-CEzq6DjL.mjs} +4 -4
  88. package/dist/{migrate-DCVo5gLS.mjs.map → migrate-CEzq6DjL.mjs.map} +1 -1
  89. package/dist/{migrate-CQdSpttI.cjs → migrate-CYC-hBOU.cjs} +4 -4
  90. package/dist/{migrate-CQdSpttI.cjs.map → migrate-CYC-hBOU.cjs.map} +1 -1
  91. package/dist/openapi.cjs +1 -1
  92. package/dist/openapi.d.cts +1 -1
  93. package/dist/openapi.d.mts +1 -1
  94. package/dist/openapi.mjs +1 -1
  95. package/dist/{ready-2s3-CndS.mjs → ready-DeYaSoNN.mjs} +3 -3
  96. package/dist/{ready-2s3-CndS.mjs.map → ready-DeYaSoNN.mjs.map} +1 -1
  97. package/dist/{ready-B6uHr4sm.cjs → ready-QGgjmcuN.cjs} +3 -3
  98. package/dist/{ready-B6uHr4sm.cjs.map → ready-QGgjmcuN.cjs.map} +1 -1
  99. package/dist/reconcile/public.cjs +1 -1
  100. package/dist/reconcile/public.d.cts +1 -1
  101. package/dist/reconcile/public.d.mts +1 -1
  102. package/dist/reconcile/public.mjs +1 -1
  103. package/dist/{resolve-BexmDcsN.cjs → resolve-BDsMffvz.cjs} +3 -3
  104. package/dist/{resolve-BexmDcsN.cjs.map → resolve-BDsMffvz.cjs.map} +1 -1
  105. package/dist/{resolve-DhZgtvZe.mjs → resolve-Dn5wGf1r.mjs} +3 -3
  106. package/dist/{resolve-DhZgtvZe.mjs.map → resolve-Dn5wGf1r.mjs.map} +1 -1
  107. package/dist/{rollback-BnY7KuG_.cjs → rollback-5XHaBDxW.cjs} +5 -5
  108. package/dist/{rollback-BnY7KuG_.cjs.map → rollback-5XHaBDxW.cjs.map} +1 -1
  109. package/dist/{rollback-m4Yeym5x.mjs → rollback-DDfaqv7P.mjs} +5 -5
  110. package/dist/{rollback-m4Yeym5x.mjs.map → rollback-DDfaqv7P.mjs.map} +1 -1
  111. package/dist/{runtime-CEk5n4VH.d.mts → runtime-B3jNgeP-.d.mts} +2 -2
  112. package/dist/{runtime-BRqFOvPM.d.cts.map → runtime-B3jNgeP-.d.mts.map} +1 -1
  113. package/dist/{runtime-BRqFOvPM.d.cts → runtime-DWThEP-r.d.cts} +2 -2
  114. package/dist/{runtime-CEk5n4VH.d.mts.map → runtime-DWThEP-r.d.cts.map} +1 -1
  115. package/dist/sandbox/credentials-worker.cjs +54 -0
  116. package/dist/sandbox/credentials-worker.cjs.map +1 -0
  117. package/dist/sandbox/credentials-worker.d.cts +1 -0
  118. package/dist/sandbox/credentials-worker.d.mts +1 -0
  119. package/dist/sandbox/credentials-worker.mjs +55 -0
  120. package/dist/sandbox/credentials-worker.mjs.map +1 -0
  121. package/dist/sandbox/discover-worker.cjs +1 -1
  122. package/dist/sandbox/discover-worker.mjs +1 -1
  123. package/dist/sandbox/migrate-worker.cjs +1 -1
  124. package/dist/sandbox/migrate-worker.mjs +1 -1
  125. package/dist/{schemas-RUlKHu27.cjs → schemas-BObwxB_t.cjs} +164 -3
  126. package/dist/schemas-BObwxB_t.cjs.map +1 -0
  127. package/dist/{schemas-Cfhtpdo0.mjs → schemas-D-xeKJDD.mjs} +153 -4
  128. package/dist/schemas-D-xeKJDD.mjs.map +1 -0
  129. package/dist/{sniffer-D66HIvi9.cjs → sniffer-Bc0nNBDF.cjs} +7 -7
  130. package/dist/sniffer-Bc0nNBDF.cjs.map +1 -0
  131. package/dist/{sniffer-BdFeLSmA.mjs → sniffer-DMqi2b1q.mjs} +7 -7
  132. package/dist/sniffer-DMqi2b1q.mjs.map +1 -0
  133. package/dist/{state-DgmM4EKq.cjs → state-8RgXeX5Y.cjs} +398 -8
  134. package/dist/state-8RgXeX5Y.cjs.map +1 -0
  135. package/dist/{state-DkUStoqJ.mjs → state-DClnPZt5.mjs} +291 -9
  136. package/dist/state-DClnPZt5.mjs.map +1 -0
  137. package/dist/target/public.cjs +1 -1
  138. package/dist/target/public.d.cts +2 -2
  139. package/dist/target/public.d.mts +2 -2
  140. package/dist/target/public.mjs +1 -1
  141. package/dist/{terminal-C3cv-OQu.mjs → terminal-C6TBo_SA.mjs} +2 -2
  142. package/dist/{terminal-C3cv-OQu.mjs.map → terminal-C6TBo_SA.mjs.map} +1 -1
  143. package/dist/{terminal-DjzgLu6m.cjs → terminal-CFO3xWoF.cjs} +2 -2
  144. package/dist/{terminal-DjzgLu6m.cjs.map → terminal-CFO3xWoF.cjs.map} +1 -1
  145. package/dist/{types-CSw2w69a.d.mts → types-CZdCxUCK.d.cts} +64 -2
  146. package/dist/types-CZdCxUCK.d.cts.map +1 -0
  147. package/dist/{types-D5WIxRDP.d.cts → types-Da0E3Qv7.d.mts} +63 -3
  148. package/dist/types-Da0E3Qv7.d.mts.map +1 -0
  149. package/dist/vitest.cjs +1 -1
  150. package/dist/vitest.mjs +1 -1
  151. package/dist/workspace/index.cjs +1 -1
  152. package/dist/workspace/index.d.cts +2 -2
  153. package/dist/workspace/index.d.mts +2 -2
  154. package/dist/workspace/index.mjs +1 -1
  155. package/dist/{workspace-ON-bqiJz.cjs → workspace-8NuAjaXJ.cjs} +2 -2
  156. package/dist/{workspace-ON-bqiJz.cjs.map → workspace-8NuAjaXJ.cjs.map} +1 -1
  157. package/dist/{workspace-Be6uBhlF.mjs → workspace-B2UK_rVP.mjs} +2 -2
  158. package/dist/{workspace-Be6uBhlF.mjs.map → workspace-B2UK_rVP.mjs.map} +1 -1
  159. package/package.json +16 -13
  160. package/dist/cli-C2Tjbn27.mjs.map +0 -1
  161. package/dist/cli-DR7B2_fX.cjs.map +0 -1
  162. package/dist/compose-5oNHAKNT.cjs.map +0 -1
  163. package/dist/compose-BjToENzG.mjs.map +0 -1
  164. package/dist/deploy-BucRfbvX.cjs.map +0 -1
  165. package/dist/deploy-DRAwTG72.mjs.map +0 -1
  166. package/dist/engine-Cx_dvx9q.cjs.map +0 -1
  167. package/dist/engine-Gs0abjuj.mjs.map +0 -1
  168. package/dist/schemas-Cfhtpdo0.mjs.map +0 -1
  169. package/dist/schemas-RUlKHu27.cjs.map +0 -1
  170. package/dist/sniffer-BdFeLSmA.mjs.map +0 -1
  171. package/dist/sniffer-D66HIvi9.cjs.map +0 -1
  172. package/dist/state-DgmM4EKq.cjs.map +0 -1
  173. package/dist/state-DkUStoqJ.mjs.map +0 -1
  174. package/dist/types-CSw2w69a.d.mts.map +0 -1
  175. package/dist/types-D5WIxRDP.d.cts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"rollback-BnY7KuG_.cjs","names":["storedCredentials","LocalSandbox","findWorkspaceRoot","resolve","withSandbox","loadWorkspaceConfig","createStateStore","DeployJournal","createEmptyState","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 { createStateStore } from '../../deploy/StateStore';\nimport {\n\tcreateEmptyState,\n\ttype ReleasedImage,\n\trecordRollback,\n} from '../../deploy/state';\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 Error {\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 Error {\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 Error {\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\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});\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(store, input.stage, () =>\n\t\t\t\tcreateEmptyState(input.stage, '', ''),\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":"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"}
1
+ {"version":3,"file":"rollback-5XHaBDxW.cjs","names":["storedCredentials","LocalSandbox","findWorkspaceRoot","resolve","withSandbox","loadWorkspaceConfig","createStateStore","DeployJournal","createEmptyState","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 { createStateStore } from '../../deploy/StateStore';\nimport {\n\tcreateEmptyState,\n\ttype ReleasedImage,\n\trecordRollback,\n} from '../../deploy/state';\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 Error {\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 Error {\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 Error {\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\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});\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(store, input.stage, () =>\n\t\t\t\tcreateEmptyState(input.stage, '', ''),\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":"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"}
@@ -1,11 +1,11 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-BhDjJH2R.mjs";
2
2
  import { i as LocalSandbox, r as storedCredentials } from "./credentials-pAtB70k3.mjs";
3
3
  import { c as withSandbox } from "./sandbox-Dm247NGx.mjs";
4
- import { k as assertDeployedStage } from "./workspace-Be6uBhlF.mjs";
4
+ import { k as assertDeployedStage } from "./workspace-B2UK_rVP.mjs";
5
5
  import { findWorkspaceRoot, loadWorkspaceConfig } from "./config.mjs";
6
- import { o as recordRollback, p as DeployJournal, t as createEmptyState } from "./state-DkUStoqJ.mjs";
7
- import { g as createStateStore } from "./sniffer-BdFeLSmA.mjs";
8
- import { i as dokployApi, l as restoreImage, p as verifySettings } from "./engine-Gs0abjuj.mjs";
6
+ import { o as recordRollback, p as DeployJournal, t as createEmptyState } from "./state-DClnPZt5.mjs";
7
+ import { g as createStateStore } from "./sniffer-DMqi2b1q.mjs";
8
+ import { i as dokployApi, l as restoreImage, p as verifySettings } from "./engine-62Kl70Pj.mjs";
9
9
  import { resolve } from "node:path";
10
10
  //#region src/target/dokploy/rollback.ts
11
11
  /**
@@ -129,4 +129,4 @@ async function rollbackStage(input) {
129
129
  //#endregion
130
130
  export { rollback_exports as a, rollbackStage as i, RollbackNeedsApp as n, StageNeverDeployed as r, NothingToRollBack as t };
131
131
 
132
- //# sourceMappingURL=rollback-m4Yeym5x.mjs.map
132
+ //# sourceMappingURL=rollback-DDfaqv7P.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"rollback-m4Yeym5x.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 { createStateStore } from '../../deploy/StateStore';\nimport {\n\tcreateEmptyState,\n\ttype ReleasedImage,\n\trecordRollback,\n} from '../../deploy/state';\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 Error {\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 Error {\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 Error {\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\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});\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(store, input.stage, () =>\n\t\t\t\tcreateEmptyState(input.stage, '', ''),\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":"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"}
1
+ {"version":3,"file":"rollback-DDfaqv7P.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 { createStateStore } from '../../deploy/StateStore';\nimport {\n\tcreateEmptyState,\n\ttype ReleasedImage,\n\trecordRollback,\n} from '../../deploy/state';\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 Error {\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 Error {\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 Error {\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\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});\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(store, input.stage, () =>\n\t\t\t\tcreateEmptyState(input.stage, '', ''),\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":"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"}
@@ -1,4 +1,4 @@
1
- import { H as DeployRuntime, X as TargetOptionsIssue } from "./types-CSw2w69a.mjs";
1
+ import { H as DeployRuntime, X as TargetOptionsIssue } from "./types-Da0E3Qv7.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 Error {
@@ -87,4 +87,4 @@ declare class TargetRuntimeUndeclared extends Error {
87
87
  }
88
88
  //#endregion
89
89
  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 };
90
- //# sourceMappingURL=runtime-CEk5n4VH.d.mts.map
90
+ //# sourceMappingURL=runtime-B3jNgeP-.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"runtime-BRqFOvPM.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":";;;cA+Da,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-B3jNgeP-.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":";;;cA+Da,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 { H as DeployRuntime, X as TargetOptionsIssue } from "./types-D5WIxRDP.cjs";
1
+ import { H as DeployRuntime, X as TargetOptionsIssue } from "./types-CZdCxUCK.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 Error {
@@ -87,4 +87,4 @@ declare class TargetRuntimeUndeclared extends Error {
87
87
  }
88
88
  //#endregion
89
89
  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 };
90
- //# sourceMappingURL=runtime-BRqFOvPM.d.cts.map
90
+ //# sourceMappingURL=runtime-DWThEP-r.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"runtime-CEk5n4VH.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":";;;cA+Da,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-DWThEP-r.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":";;;cA+Da,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"}
@@ -0,0 +1,54 @@
1
+ const require_discover = require("../discover-B4VjaFJk.cjs");
2
+ const require_sandbox = require("../sandbox-CL--ZDui.cjs");
3
+ const require_workerRuntime = require("../workerRuntime-BXfhbe13.cjs");
4
+ const require_credentialSchemas = require("../credentialSchemas-BcNL1N5R.cjs");
5
+ let node_path = require("node:path");
6
+ let node_fs_promises = require("node:fs/promises");
7
+ //#region src/sandbox/credentials-worker.ts
8
+ /**
9
+ * Loads a project's constructs in a sandbox and answers with what their
10
+ * credentials schemas say, as data: each schema as JSON Schema, and whether
11
+ * each value it was handed passes.
12
+ *
13
+ * Usage (by `inspectCredentials` under a sandbox, never by hand):
14
+ * node --import=<tsx> credentials-worker.ts '{"patterns":[…],"cwd":"…"}'
15
+ *
16
+ * The schemas are the project's code, which is why they run here. Each value
17
+ * arrives as a file in `GKM_SECRETS_DIR` named by its key, is read into this
18
+ * process's memory only, and never comes back: an answer carries issue paths
19
+ * and messages, not values.
20
+ */
21
+ /** Every secret file the sandbox mounted, by name. */
22
+ async function mountedSecrets() {
23
+ const dir = process.env[require_sandbox.SECRETS_DIR_ENV];
24
+ if (!dir) return {};
25
+ const secrets = {};
26
+ for (const name of await (0, node_fs_promises.readdir)(dir)) secrets[name] = (await (0, node_fs_promises.readFile)((0, node_path.join)(dir, name), "utf8")).trim();
27
+ return secrets;
28
+ }
29
+ async function main() {
30
+ try {
31
+ const request = JSON.parse(process.argv[2] ?? "{}");
32
+ await require_workerRuntime.registerAdjacentTsconfig();
33
+ const sources = {};
34
+ const manifest = await require_discover.discover({
35
+ patterns: request.patterns,
36
+ cwd: request.cwd,
37
+ sources
38
+ });
39
+ const inspection = await require_credentialSchemas.inspectLive(require_credentialSchemas.liveCredentials(manifest, sources), await mountedSecrets());
40
+ require_workerRuntime.answer({
41
+ reason: "inspected",
42
+ ...inspection
43
+ });
44
+ } catch (error) {
45
+ require_workerRuntime.answer({
46
+ reason: "failed",
47
+ error: require_workerRuntime.errorData(error)
48
+ });
49
+ }
50
+ }
51
+ main();
52
+ //#endregion
53
+
54
+ //# sourceMappingURL=credentials-worker.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credentials-worker.cjs","names":["SECRETS_DIR_ENV","readdir","readFile","join","registerAdjacentTsconfig","discover","inspectLive","liveCredentials","errorData"],"sources":["../../src/sandbox/credentials-worker.ts"],"sourcesContent":["/**\n * Loads a project's constructs in a sandbox and answers with what their\n * credentials schemas say, as data: each schema as JSON Schema, and whether\n * each value it was handed passes.\n *\n * Usage (by `inspectCredentials` under a sandbox, never by hand):\n * node --import=<tsx> credentials-worker.ts '{\"patterns\":[…],\"cwd\":\"…\"}'\n *\n * The schemas are the project's code, which is why they run here. Each value\n * arrives as a file in `GKM_SECRETS_DIR` named by its key, is read into this\n * process's memory only, and never comes back: an answer carries issue paths\n * and messages, not values.\n */\n\nimport { readdir, readFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { type ConstructSource, discover } from '../reconcile/discover';\nimport { inspectLive, liveCredentials } from '../secrets/credentialSchemas';\nimport { SECRETS_DIR_ENV } from './sandbox';\nimport { answer, errorData, registerAdjacentTsconfig } from './workerRuntime';\n\n/** Every secret file the sandbox mounted, by name. */\nasync function mountedSecrets(): Promise<Record<string, string>> {\n\tconst dir = process.env[SECRETS_DIR_ENV];\n\tif (!dir) return {};\n\n\tconst secrets: Record<string, string> = {};\n\tfor (const name of await readdir(dir)) {\n\t\tsecrets[name] = (await readFile(join(dir, name), 'utf8')).trim();\n\t}\n\treturn secrets;\n}\n\nasync function main(): Promise<void> {\n\ttry {\n\t\tconst request = JSON.parse(process.argv[2] ?? '{}') as {\n\t\t\tpatterns: string[];\n\t\t\tcwd: string;\n\t\t};\n\t\tawait registerAdjacentTsconfig();\n\n\t\tconst sources: Record<string, ConstructSource> = {};\n\t\tconst manifest = await discover({\n\t\t\tpatterns: request.patterns,\n\t\t\tcwd: request.cwd,\n\t\t\tsources,\n\t\t});\n\n\t\tconst inspection = await inspectLive(\n\t\t\tliveCredentials(manifest, sources),\n\t\t\tawait mountedSecrets(),\n\t\t);\n\t\tanswer({ reason: 'inspected', ...inspection });\n\t} catch (error) {\n\t\tanswer({ reason: 'failed', error: errorData(error) });\n\t}\n}\n\nvoid main();\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAsBA,eAAe,iBAAkD;CAChE,MAAM,MAAM,QAAQ,IAAIA,gBAAAA;CACxB,IAAI,CAAC,KAAK,OAAO,CAAC;CAElB,MAAM,UAAkC,CAAC;CACzC,KAAK,MAAM,QAAQ,OAAA,GAAMC,iBAAAA,QAAAA,CAAQ,GAAG,GACnC,QAAQ,SAAS,OAAA,GAAMC,iBAAAA,SAAAA,EAAAA,GAASC,UAAAA,KAAAA,CAAK,KAAK,IAAI,GAAG,MAAM,EAAA,CAAG,KAAK;CAEhE,OAAO;AACR;AAEA,eAAe,OAAsB;CACpC,IAAI;EACH,MAAM,UAAU,KAAK,MAAM,QAAQ,KAAK,MAAM,IAAI;EAIlD,MAAMC,sBAAAA,yBAAyB;EAE/B,MAAM,UAA2C,CAAC;EAClD,MAAM,WAAW,MAAMC,iBAAAA,SAAS;GAC/B,UAAU,QAAQ;GAClB,KAAK,QAAQ;GACb;EACD,CAAC;EAED,MAAM,aAAa,MAAMC,0BAAAA,YACxBC,0BAAAA,gBAAgB,UAAU,OAAO,GACjC,MAAM,eAAe,CACtB;EACA,sBAAA,OAAO;GAAE,QAAQ;GAAa,GAAG;EAAW,CAAC;CAC9C,SAAS,OAAO;EACf,sBAAA,OAAO;GAAE,QAAQ;GAAU,OAAOC,sBAAAA,UAAU,KAAK;EAAE,CAAC;CACrD;AACD;AAEK,KAAK"}
@@ -0,0 +1 @@
1
+ export {}
@@ -0,0 +1 @@
1
+ export {}
@@ -0,0 +1,55 @@
1
+ import { r as discover } from "../discover-Buwf1z4P.mjs";
2
+ import { t as SECRETS_DIR_ENV } from "../sandbox-Dm247NGx.mjs";
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-BmYxnEz_.mjs";
5
+ import { join } from "node:path";
6
+ import { readFile, readdir } from "node:fs/promises";
7
+ //#region src/sandbox/credentials-worker.ts
8
+ /**
9
+ * Loads a project's constructs in a sandbox and answers with what their
10
+ * credentials schemas say, as data: each schema as JSON Schema, and whether
11
+ * each value it was handed passes.
12
+ *
13
+ * Usage (by `inspectCredentials` under a sandbox, never by hand):
14
+ * node --import=<tsx> credentials-worker.ts '{"patterns":[…],"cwd":"…"}'
15
+ *
16
+ * The schemas are the project's code, which is why they run here. Each value
17
+ * arrives as a file in `GKM_SECRETS_DIR` named by its key, is read into this
18
+ * process's memory only, and never comes back: an answer carries issue paths
19
+ * and messages, not values.
20
+ */
21
+ /** Every secret file the sandbox mounted, by name. */
22
+ async function mountedSecrets() {
23
+ const dir = process.env[SECRETS_DIR_ENV];
24
+ if (!dir) return {};
25
+ const secrets = {};
26
+ for (const name of await readdir(dir)) secrets[name] = (await readFile(join(dir, name), "utf8")).trim();
27
+ return secrets;
28
+ }
29
+ async function main() {
30
+ try {
31
+ const request = JSON.parse(process.argv[2] ?? "{}");
32
+ await registerAdjacentTsconfig();
33
+ const sources = {};
34
+ const manifest = await discover({
35
+ patterns: request.patterns,
36
+ cwd: request.cwd,
37
+ sources
38
+ });
39
+ const inspection = await inspectLive(liveCredentials(manifest, sources), await mountedSecrets());
40
+ answer({
41
+ reason: "inspected",
42
+ ...inspection
43
+ });
44
+ } catch (error) {
45
+ answer({
46
+ reason: "failed",
47
+ error: errorData(error)
48
+ });
49
+ }
50
+ }
51
+ main();
52
+ //#endregion
53
+ export {};
54
+
55
+ //# sourceMappingURL=credentials-worker.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credentials-worker.mjs","names":[],"sources":["../../src/sandbox/credentials-worker.ts"],"sourcesContent":["/**\n * Loads a project's constructs in a sandbox and answers with what their\n * credentials schemas say, as data: each schema as JSON Schema, and whether\n * each value it was handed passes.\n *\n * Usage (by `inspectCredentials` under a sandbox, never by hand):\n * node --import=<tsx> credentials-worker.ts '{\"patterns\":[…],\"cwd\":\"…\"}'\n *\n * The schemas are the project's code, which is why they run here. Each value\n * arrives as a file in `GKM_SECRETS_DIR` named by its key, is read into this\n * process's memory only, and never comes back: an answer carries issue paths\n * and messages, not values.\n */\n\nimport { readdir, readFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { type ConstructSource, discover } from '../reconcile/discover';\nimport { inspectLive, liveCredentials } from '../secrets/credentialSchemas';\nimport { SECRETS_DIR_ENV } from './sandbox';\nimport { answer, errorData, registerAdjacentTsconfig } from './workerRuntime';\n\n/** Every secret file the sandbox mounted, by name. */\nasync function mountedSecrets(): Promise<Record<string, string>> {\n\tconst dir = process.env[SECRETS_DIR_ENV];\n\tif (!dir) return {};\n\n\tconst secrets: Record<string, string> = {};\n\tfor (const name of await readdir(dir)) {\n\t\tsecrets[name] = (await readFile(join(dir, name), 'utf8')).trim();\n\t}\n\treturn secrets;\n}\n\nasync function main(): Promise<void> {\n\ttry {\n\t\tconst request = JSON.parse(process.argv[2] ?? '{}') as {\n\t\t\tpatterns: string[];\n\t\t\tcwd: string;\n\t\t};\n\t\tawait registerAdjacentTsconfig();\n\n\t\tconst sources: Record<string, ConstructSource> = {};\n\t\tconst manifest = await discover({\n\t\t\tpatterns: request.patterns,\n\t\t\tcwd: request.cwd,\n\t\t\tsources,\n\t\t});\n\n\t\tconst inspection = await inspectLive(\n\t\t\tliveCredentials(manifest, sources),\n\t\t\tawait mountedSecrets(),\n\t\t);\n\t\tanswer({ reason: 'inspected', ...inspection });\n\t} catch (error) {\n\t\tanswer({ reason: 'failed', error: errorData(error) });\n\t}\n}\n\nvoid main();\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAsBA,eAAe,iBAAkD;CAChE,MAAM,MAAM,QAAQ,IAAI;CACxB,IAAI,CAAC,KAAK,OAAO,CAAC;CAElB,MAAM,UAAkC,CAAC;CACzC,KAAK,MAAM,QAAQ,MAAM,QAAQ,GAAG,GACnC,QAAQ,SAAS,MAAM,SAAS,KAAK,KAAK,IAAI,GAAG,MAAM,EAAA,CAAG,KAAK;CAEhE,OAAO;AACR;AAEA,eAAe,OAAsB;CACpC,IAAI;EACH,MAAM,UAAU,KAAK,MAAM,QAAQ,KAAK,MAAM,IAAI;EAIlD,MAAM,yBAAyB;EAE/B,MAAM,UAA2C,CAAC;EAClD,MAAM,WAAW,MAAM,SAAS;GAC/B,UAAU,QAAQ;GAClB,KAAK,QAAQ;GACb;EACD,CAAC;EAED,MAAM,aAAa,MAAM,YACxB,gBAAgB,UAAU,OAAO,GACjC,MAAM,eAAe,CACtB;EACA,OAAO;GAAE,QAAQ;GAAa,GAAG;EAAW,CAAC;CAC9C,SAAS,OAAO;EACf,OAAO;GAAE,QAAQ;GAAU,OAAO,UAAU,KAAK;EAAE,CAAC;CACrD;AACD;AAEK,KAAK"}
@@ -1,4 +1,4 @@
1
- const require_discover = require("../discover-OEfZ9OkA.cjs");
1
+ const require_discover = require("../discover-B4VjaFJk.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 { r as discover } from "../discover-BFoJWKGD.mjs";
1
+ import { r as discover } from "../discover-Buwf1z4P.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-OEfZ9OkA.cjs");
1
+ const require_discover = require("../discover-B4VjaFJk.cjs");
2
2
  const require_sandbox = require("../sandbox-CL--ZDui.cjs");
3
3
  const require_workerRuntime = require("../workerRuntime-BXfhbe13.cjs");
4
4
  const require_databases = require("../databases-C2p5LGAp.cjs");
@@ -1,4 +1,4 @@
1
- import { r as discover } from "../discover-BFoJWKGD.mjs";
1
+ import { r as discover } from "../discover-Buwf1z4P.mjs";
2
2
  import { t as SECRETS_DIR_ENV } from "../sandbox-Dm247NGx.mjs";
3
3
  import { a as registerAdjacentTsconfig, n as answer, r as errorData } from "../workerRuntime-CsOyBRx2.mjs";
4
4
  import { u as migrateDatabases } from "../databases-hUHTuwhx.mjs";
@@ -973,7 +973,7 @@ const uuid = (version) => {
973
973
  return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${version}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);
974
974
  };
975
975
  /** Practical email validation */
976
- const email = /^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
976
+ const email$1 = /^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
977
977
  const _emoji$1 = `^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`;
978
978
  function emoji() {
979
979
  return new RegExp(_emoji$1, "u");
@@ -1512,7 +1512,7 @@ const $ZodUUID = /*@__PURE__*/ $constructor("$ZodUUID", (inst, def) => {
1512
1512
  $ZodStringFormat.init(inst, def);
1513
1513
  });
1514
1514
  const $ZodEmail = /*@__PURE__*/ $constructor("$ZodEmail", (inst, def) => {
1515
- def.pattern ?? (def.pattern = email);
1515
+ def.pattern ?? (def.pattern = email$1);
1516
1516
  $ZodStringFormat.init(inst, def);
1517
1517
  });
1518
1518
  function canParseURL(input) {
@@ -4403,9 +4403,33 @@ const numberProcessor = (schema, ctx, _json, params) => {
4403
4403
  const booleanProcessor = (_schema, _ctx, json, _params) => {
4404
4404
  json.type = "boolean";
4405
4405
  };
4406
+ const bigintProcessor = (schema, ctx, json, params) => {
4407
+ handleUnrepresentable(schema, ctx, json, params, "BigInt cannot be represented in JSON Schema");
4408
+ };
4409
+ const symbolProcessor = (schema, ctx, json, params) => {
4410
+ handleUnrepresentable(schema, ctx, json, params, "Symbols cannot be represented in JSON Schema");
4411
+ };
4412
+ const nullProcessor = (_schema, ctx, json, _params) => {
4413
+ if (ctx.target === "openapi-3.0") {
4414
+ json.type = "string";
4415
+ json.nullable = true;
4416
+ json.enum = [null];
4417
+ } else json.type = "null";
4418
+ };
4419
+ const undefinedProcessor = (schema, ctx, json, params) => {
4420
+ handleUnrepresentable(schema, ctx, json, params, "Undefined cannot be represented in JSON Schema");
4421
+ };
4422
+ const voidProcessor = (schema, ctx, json, params) => {
4423
+ handleUnrepresentable(schema, ctx, json, params, "Void cannot be represented in JSON Schema");
4424
+ };
4406
4425
  const neverProcessor = (_schema, _ctx, json, _params) => {
4407
4426
  json.not = {};
4408
4427
  };
4428
+ const anyProcessor = (_schema, _ctx, _json, _params) => {};
4429
+ const unknownProcessor = (_schema, _ctx, _json, _params) => {};
4430
+ const dateProcessor = (schema, ctx, json, params) => {
4431
+ handleUnrepresentable(schema, ctx, json, params, "Date cannot be represented in JSON Schema");
4432
+ };
4409
4433
  const enumProcessor = (schema, _ctx, json, _params) => {
4410
4434
  const def = schema._zod.def;
4411
4435
  const values = getEnumValues(def.entries);
@@ -4443,12 +4467,47 @@ const literalProcessor = (schema, ctx, json, params) => {
4443
4467
  json.enum = vals;
4444
4468
  }
4445
4469
  };
4470
+ const nanProcessor = (schema, ctx, json, params) => {
4471
+ handleUnrepresentable(schema, ctx, json, params, "NaN cannot be represented in JSON Schema");
4472
+ };
4473
+ const templateLiteralProcessor = (schema, _ctx, json, _params) => {
4474
+ const _json = json;
4475
+ const pattern = schema._zod.pattern;
4476
+ if (!pattern) throw new Error("Pattern not found in template literal");
4477
+ _json.type = "string";
4478
+ _json.pattern = pattern.source;
4479
+ };
4480
+ const fileProcessor = (schema, _ctx, json, _params) => {
4481
+ const _json = json;
4482
+ _json.type = "string";
4483
+ _json.format = "binary";
4484
+ _json.contentEncoding = "binary";
4485
+ const { minimum, maximum, mime } = aggregateChecks(schema);
4486
+ if (minimum !== void 0) _json.minLength = minimum;
4487
+ if (maximum !== void 0) _json.maxLength = maximum;
4488
+ if (!mime) return;
4489
+ if (mime.length === 0) _json.not = {};
4490
+ else if (mime.length === 1) _json.contentMediaType = mime[0];
4491
+ else _json.anyOf = mime.map((m) => ({ contentMediaType: m }));
4492
+ };
4493
+ const successProcessor = (_schema, _ctx, json, _params) => {
4494
+ json.type = "boolean";
4495
+ };
4446
4496
  const customProcessor = (schema, ctx, json, params) => {
4447
4497
  handleUnrepresentable(schema, ctx, json, params, "Custom types cannot be represented in JSON Schema");
4448
4498
  };
4499
+ const functionProcessor = (schema, ctx, json, params) => {
4500
+ handleUnrepresentable(schema, ctx, json, params, "Function types cannot be represented in JSON Schema");
4501
+ };
4449
4502
  const transformProcessor = (schema, ctx, json, params) => {
4450
4503
  handleUnrepresentable(schema, ctx, json, params, "Transforms cannot be represented in JSON Schema");
4451
4504
  };
4505
+ const mapProcessor = (schema, ctx, json, params) => {
4506
+ handleUnrepresentable(schema, ctx, json, params, "Map cannot be represented in JSON Schema");
4507
+ };
4508
+ const setProcessor = (schema, ctx, json, params) => {
4509
+ handleUnrepresentable(schema, ctx, json, params, "Set cannot be represented in JSON Schema");
4510
+ };
4452
4511
  const arrayProcessor = (schema, ctx, _json, params) => {
4453
4512
  const json = _json;
4454
4513
  const def = schema._zod.def;
@@ -4762,12 +4821,99 @@ const readonlyProcessor = (schema, ctx, json, params) => {
4762
4821
  seen.ref = def.innerType;
4763
4822
  json.readOnly = true;
4764
4823
  };
4824
+ const promiseProcessor = (schema, ctx, _json, params) => {
4825
+ const def = schema._zod.def;
4826
+ processSchema(def.innerType, ctx, params);
4827
+ const seen = ctx.seen.get(schema);
4828
+ seen.ref = def.innerType;
4829
+ };
4765
4830
  const optionalProcessor = (schema, ctx, _json, params) => {
4766
4831
  const def = schema._zod.def;
4767
4832
  processSchema(def.innerType, ctx, params);
4768
4833
  const seen = ctx.seen.get(schema);
4769
4834
  seen.ref = def.innerType;
4770
4835
  };
4836
+ const lazyProcessor = (schema, ctx, _json, params) => {
4837
+ const innerType = schema._zod.innerType;
4838
+ processSchema(innerType, ctx, params);
4839
+ const seen = ctx.seen.get(schema);
4840
+ seen.ref = innerType;
4841
+ };
4842
+ const allProcessors = {
4843
+ string: stringProcessor,
4844
+ number: numberProcessor,
4845
+ boolean: booleanProcessor,
4846
+ bigint: bigintProcessor,
4847
+ symbol: symbolProcessor,
4848
+ null: nullProcessor,
4849
+ undefined: undefinedProcessor,
4850
+ void: voidProcessor,
4851
+ never: neverProcessor,
4852
+ any: anyProcessor,
4853
+ unknown: unknownProcessor,
4854
+ date: dateProcessor,
4855
+ enum: enumProcessor,
4856
+ literal: literalProcessor,
4857
+ nan: nanProcessor,
4858
+ template_literal: templateLiteralProcessor,
4859
+ file: fileProcessor,
4860
+ success: successProcessor,
4861
+ custom: customProcessor,
4862
+ function: functionProcessor,
4863
+ transform: transformProcessor,
4864
+ map: mapProcessor,
4865
+ set: setProcessor,
4866
+ array: arrayProcessor,
4867
+ object: objectProcessor,
4868
+ union: unionProcessor,
4869
+ intersection: intersectionProcessor,
4870
+ tuple: tupleProcessor,
4871
+ record: recordProcessor,
4872
+ nullable: nullableProcessor,
4873
+ nonoptional: nonoptionalProcessor,
4874
+ default: defaultProcessor,
4875
+ prefault: prefaultProcessor,
4876
+ catch: catchProcessor,
4877
+ pipe: pipeProcessor,
4878
+ readonly: readonlyProcessor,
4879
+ promise: promiseProcessor,
4880
+ optional: optionalProcessor,
4881
+ lazy: lazyProcessor
4882
+ };
4883
+ function toJSONSchema(input, params) {
4884
+ if ("_idmap" in input) {
4885
+ const registry = input;
4886
+ const ctx = initializeContext({
4887
+ ...params,
4888
+ processors: allProcessors
4889
+ });
4890
+ const defs = {};
4891
+ for (const entry of registry._idmap.entries()) {
4892
+ const [_, schema] = entry;
4893
+ processSchema(schema, ctx);
4894
+ }
4895
+ const schemas = {};
4896
+ ctx.external = {
4897
+ registry,
4898
+ uri: params?.uri,
4899
+ defs
4900
+ };
4901
+ for (const entry of registry._idmap.entries()) {
4902
+ const [key, schema] = entry;
4903
+ extractDefs(ctx, schema);
4904
+ assignProp(schemas, key, finalize(ctx, schema));
4905
+ }
4906
+ if (Object.keys(defs).length > 0) schemas.__shared = { [ctx.target === "draft-2020-12" ? "$defs" : "definitions"]: defs };
4907
+ return { schemas };
4908
+ }
4909
+ const ctx = initializeContext({
4910
+ ...params,
4911
+ processors: allProcessors
4912
+ });
4913
+ processSchema(input, ctx);
4914
+ extractDefs(ctx, input);
4915
+ return finalize(ctx, input);
4916
+ }
4771
4917
  //#endregion
4772
4918
  //#region ../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/classic/errors.js
4773
4919
  const _installedErrorProtos = /* @__PURE__ */ new WeakSet([Object.prototype, Error.prototype]);
@@ -5175,6 +5321,9 @@ const ZodEmail = /*@__PURE__*/ $constructor("ZodEmail", (inst, def) => {
5175
5321
  $ZodEmail.init(inst, def);
5176
5322
  ZodStringFormat.init(inst, def);
5177
5323
  });
5324
+ function email(params) {
5325
+ return /* @__PURE__ */ _email(ZodEmail, params);
5326
+ }
5178
5327
  const ZodGUID = /*@__PURE__*/ $constructor("ZodGUID", (inst, def) => {
5179
5328
  $ZodGUID.init(inst, def);
5180
5329
  ZodStringFormat.init(inst, def);
@@ -5792,6 +5941,12 @@ Object.defineProperty(exports, "discriminatedUnion", {
5792
5941
  return discriminatedUnion;
5793
5942
  }
5794
5943
  });
5944
+ Object.defineProperty(exports, "email", {
5945
+ enumerable: true,
5946
+ get: function() {
5947
+ return email;
5948
+ }
5949
+ });
5795
5950
  Object.defineProperty(exports, "literal", {
5796
5951
  enumerable: true,
5797
5952
  get: function() {
@@ -5828,6 +5983,12 @@ Object.defineProperty(exports, "string", {
5828
5983
  return string;
5829
5984
  }
5830
5985
  });
5986
+ Object.defineProperty(exports, "toJSONSchema", {
5987
+ enumerable: true,
5988
+ get: function() {
5989
+ return toJSONSchema;
5990
+ }
5991
+ });
5831
5992
  Object.defineProperty(exports, "tuple", {
5832
5993
  enumerable: true,
5833
5994
  get: function() {
@@ -5853,4 +6014,4 @@ Object.defineProperty(exports, "url", {
5853
6014
  }
5854
6015
  });
5855
6016
 
5856
- //# sourceMappingURL=schemas-RUlKHu27.cjs.map
6017
+ //# sourceMappingURL=schemas-BObwxB_t.cjs.map