@geekmidas/cli 10.0.0-alpha.147 → 10.0.0-alpha.148

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 (165) hide show
  1. package/dist/{GoDaddyProvider-DXuPFufW.mjs → GoDaddyProvider-CGgS-I6m.mjs} +2 -2
  2. package/dist/{GoDaddyProvider-DXuPFufW.mjs.map → GoDaddyProvider-CGgS-I6m.mjs.map} +1 -1
  3. package/dist/{GoDaddyProvider-CpO8dFYC.cjs → GoDaddyProvider-D_dZQJIX.cjs} +2 -2
  4. package/dist/{GoDaddyProvider-CpO8dFYC.cjs.map → GoDaddyProvider-D_dZQJIX.cjs.map} +1 -1
  5. package/dist/{HostingerProvider-Dum492dc.mjs → HostingerProvider-CWRE6auw.mjs} +2 -2
  6. package/dist/{HostingerProvider-Dum492dc.mjs.map → HostingerProvider-CWRE6auw.mjs.map} +1 -1
  7. package/dist/{HostingerProvider-Beu0Ciky.cjs → HostingerProvider-eGuDBjfN.cjs} +2 -2
  8. package/dist/{HostingerProvider-Beu0Ciky.cjs.map → HostingerProvider-eGuDBjfN.cjs.map} +1 -1
  9. package/dist/{LegacyStateStore-DZjph7ES.mjs → LegacyStateStore-CLyFmPIj.mjs} +2 -2
  10. package/dist/{LegacyStateStore-DZjph7ES.mjs.map → LegacyStateStore-CLyFmPIj.mjs.map} +1 -1
  11. package/dist/{LegacyStateStore-V4R0llou.cjs → LegacyStateStore-DyX9-7R_.cjs} +2 -2
  12. package/dist/{LegacyStateStore-V4R0llou.cjs.map → LegacyStateStore-DyX9-7R_.cjs.map} +1 -1
  13. package/dist/{LocalStateStore-DuSotrd3.cjs → LocalStateStore-C-v8K8zO.cjs} +2 -2
  14. package/dist/{LocalStateStore-DuSotrd3.cjs.map → LocalStateStore-C-v8K8zO.cjs.map} +1 -1
  15. package/dist/{LocalStateStore-Bth8pBp-.mjs → LocalStateStore-DQVwsyTh.mjs} +2 -2
  16. package/dist/{LocalStateStore-Bth8pBp-.mjs.map → LocalStateStore-DQVwsyTh.mjs.map} +1 -1
  17. package/dist/{S3StateStore-DTPxQS3z.cjs → S3StateStore-GA-DOTmj.cjs} +4 -4
  18. package/dist/{S3StateStore-DTPxQS3z.cjs.map → S3StateStore-GA-DOTmj.cjs.map} +1 -1
  19. package/dist/{S3StateStore-DGlh3s2p.mjs → S3StateStore-gR_6fNF6.mjs} +4 -4
  20. package/dist/{S3StateStore-DGlh3s2p.mjs.map → S3StateStore-gR_6fNF6.mjs.map} +1 -1
  21. package/dist/{SSMStateStore-DCa85jhG.mjs → SSMStateStore-CT68N-Ti.mjs} +2 -2
  22. package/dist/{SSMStateStore-DCa85jhG.mjs.map → SSMStateStore-CT68N-Ti.mjs.map} +1 -1
  23. package/dist/{SSMStateStore-B9R317q0.cjs → SSMStateStore-kdb9rf7x.cjs} +2 -2
  24. package/dist/{SSMStateStore-B9R317q0.cjs.map → SSMStateStore-kdb9rf7x.cjs.map} +1 -1
  25. package/dist/{add-Cr-9Ku0W.cjs → add-C7_WJEv2.cjs} +5 -6
  26. package/dist/{add-Cr-9Ku0W.cjs.map → add-C7_WJEv2.cjs.map} +1 -1
  27. package/dist/{add-Bl33BvDW.mjs → add-CvmRPEfW.mjs} +4 -5
  28. package/dist/{add-Bl33BvDW.mjs.map → add-CvmRPEfW.mjs.map} +1 -1
  29. package/dist/{apps-BIsxWYUo.cjs → apps-ClZkLcMz.cjs} +670 -12
  30. package/dist/apps-ClZkLcMz.cjs.map +1 -0
  31. package/dist/{apps-DFzUuJ22.mjs → apps-CmKxFPTj.mjs} +529 -15
  32. package/dist/apps-CmKxFPTj.mjs.map +1 -0
  33. package/dist/{bundler-BagXzefF.mjs → bundler-D6IEJvq4.mjs} +6 -6
  34. package/dist/{bundler-BagXzefF.mjs.map → bundler-D6IEJvq4.mjs.map} +1 -1
  35. package/dist/{bundler-Cael9EDc.cjs → bundler-Ronn7-mL.cjs} +6 -6
  36. package/dist/{bundler-Cael9EDc.cjs.map → bundler-Ronn7-mL.cjs.map} +1 -1
  37. package/dist/{cli-BJRPsFq7.mjs → cli-AZVyGSRn.mjs} +4 -4
  38. package/dist/{cli-BJRPsFq7.mjs.map → cli-AZVyGSRn.mjs.map} +1 -1
  39. package/dist/{cli-B1A-cLy-.cjs → cli-B1g2OvS0.cjs} +4 -4
  40. package/dist/{cli-B1A-cLy-.cjs.map → cli-B1g2OvS0.cjs.map} +1 -1
  41. package/dist/{compose-CnNmDNph.cjs → compose-B5AsRVqr.cjs} +13 -13
  42. package/dist/{compose-CnNmDNph.cjs.map → compose-B5AsRVqr.cjs.map} +1 -1
  43. package/dist/{compose-CZU60dwb.mjs → compose-BRNMF29g.mjs} +7 -7
  44. package/dist/{compose-CZU60dwb.mjs.map → compose-BRNMF29g.mjs.map} +1 -1
  45. package/dist/{compose-C7izI7Eo.mjs → compose-DNuENvIt.mjs} +13 -7
  46. package/dist/{compose-C7izI7Eo.mjs.map → compose-DNuENvIt.mjs.map} +1 -1
  47. package/dist/{compose-Cius-YHS.cjs → compose-DVPWitEu.cjs} +30 -6
  48. package/dist/{compose-Cius-YHS.cjs.map → compose-DVPWitEu.cjs.map} +1 -1
  49. package/dist/{credentials-D11xozSF.cjs → credentials-CrQglKgo.cjs} +5 -69
  50. package/dist/credentials-CrQglKgo.cjs.map +1 -0
  51. package/dist/{credentials-CJ_z0Nni.mjs → credentials-FRF4PZYo.mjs} +7 -41
  52. package/dist/credentials-FRF4PZYo.mjs.map +1 -0
  53. package/dist/deploy/public.cjs +10 -10
  54. package/dist/deploy/public.mjs +10 -10
  55. package/dist/{deploy-Dfn21QYG.mjs → deploy-DI_tg5Mi.mjs} +11 -11
  56. package/dist/{deploy-Dfn21QYG.mjs.map → deploy-DI_tg5Mi.mjs.map} +1 -1
  57. package/dist/{deploy-Ch1wCsU1.cjs → deploy-DTBod420.cjs} +29 -29
  58. package/dist/{deploy-Ch1wCsU1.cjs.map → deploy-DTBod420.cjs.map} +1 -1
  59. package/dist/{docker-BT6G7aJE.cjs → docker-CnWX5QNR.cjs} +7 -7
  60. package/dist/{docker-BT6G7aJE.cjs.map → docker-CnWX5QNR.cjs.map} +1 -1
  61. package/dist/{docker-_W_CauBY.mjs → docker-DsJNWnaX.mjs} +4 -4
  62. package/dist/{docker-_W_CauBY.mjs.map → docker-DsJNWnaX.mjs.map} +1 -1
  63. package/dist/{dokploy-DaQbR_NH.cjs → dokploy-CxttPnYP.cjs} +2 -2
  64. package/dist/{dokploy-DaQbR_NH.cjs.map → dokploy-CxttPnYP.cjs.map} +1 -1
  65. package/dist/{dokploy-CBgGuei3.mjs → dokploy-Dd2mXHgX.mjs} +2 -2
  66. package/dist/{dokploy-CBgGuei3.mjs.map → dokploy-Dd2mXHgX.mjs.map} +1 -1
  67. package/dist/{eas-YxDTJ3ql.cjs → eas-B-JskJLP.cjs} +2 -2
  68. package/dist/{eas-YxDTJ3ql.cjs.map → eas-B-JskJLP.cjs.map} +1 -1
  69. package/dist/{eas-3L1_yKhk.mjs → eas-B_yjP_Sl.mjs} +2 -2
  70. package/dist/{eas-3L1_yKhk.mjs.map → eas-B_yjP_Sl.mjs.map} +1 -1
  71. package/dist/{encryption-CRyFk5nu.mjs → encryption-dUnvnbu8.mjs} +2 -2
  72. package/dist/{encryption-CRyFk5nu.mjs.map → encryption-dUnvnbu8.mjs.map} +1 -1
  73. package/dist/{encryption-CVIu104e.cjs → encryption-yW6cWTsN.cjs} +2 -2
  74. package/dist/{encryption-CVIu104e.cjs.map → encryption-yW6cWTsN.cjs.map} +1 -1
  75. package/dist/{engine-DZnZy1R5.mjs → engine-W1gbyy7T.mjs} +8 -8
  76. package/dist/{engine-DZnZy1R5.mjs.map → engine-W1gbyy7T.mjs.map} +1 -1
  77. package/dist/{engine-XecwdLdj.cjs → engine-oBwumCI2.cjs} +12 -12
  78. package/dist/{engine-XecwdLdj.cjs.map → engine-oBwumCI2.cjs.map} +1 -1
  79. package/dist/{github-CDJXpBCT.mjs → github-D2-FIlNY.mjs} +6 -7
  80. package/dist/{github-CDJXpBCT.mjs.map → github-D2-FIlNY.mjs.map} +1 -1
  81. package/dist/{github-dnxU_tMp.cjs → github-DLucfS9E.cjs} +7 -8
  82. package/dist/{github-dnxU_tMp.cjs.map → github-DLucfS9E.cjs.map} +1 -1
  83. package/dist/{googlePlay-CnIU3qIV.cjs → googlePlay-C91kIbBZ.cjs} +4 -4
  84. package/dist/{googlePlay-CnIU3qIV.cjs.map → googlePlay-C91kIbBZ.cjs.map} +1 -1
  85. package/dist/{googlePlay-BYeXKpNE.mjs → googlePlay-CapfGnZ8.mjs} +4 -4
  86. package/dist/{googlePlay-BYeXKpNE.mjs.map → googlePlay-CapfGnZ8.mjs.map} +1 -1
  87. package/dist/index.cjs +94 -77
  88. package/dist/index.cjs.map +1 -1
  89. package/dist/index.mjs +82 -65
  90. package/dist/index.mjs.map +1 -1
  91. package/dist/{local-BIOpCtLE.mjs → local-2SR2d_BC.mjs} +2 -2
  92. package/dist/{local-BIOpCtLE.mjs.map → local-2SR2d_BC.mjs.map} +1 -1
  93. package/dist/{local-qdNfjzxQ.cjs → local-l5_-A-zI.cjs} +2 -2
  94. package/dist/{local-qdNfjzxQ.cjs.map → local-l5_-A-zI.cjs.map} +1 -1
  95. package/dist/{migrate-CkHtNdre.cjs → migrate-B05YVukh.cjs} +2 -2
  96. package/dist/{migrate-CkHtNdre.cjs.map → migrate-B05YVukh.cjs.map} +1 -1
  97. package/dist/{migrate-svXhccrs.mjs → migrate-C0ecSkL2.mjs} +2 -2
  98. package/dist/{migrate-svXhccrs.mjs.map → migrate-C0ecSkL2.mjs.map} +1 -1
  99. package/dist/{migrate-CDEHWq-e.cjs → migrate-DNLNhKNT.cjs} +4 -4
  100. package/dist/{migrate-CDEHWq-e.cjs.map → migrate-DNLNhKNT.cjs.map} +1 -1
  101. package/dist/{migrate--VNdTWT7.mjs → migrate-KdqlzELQ.mjs} +4 -4
  102. package/dist/{migrate--VNdTWT7.mjs.map → migrate-KdqlzELQ.mjs.map} +1 -1
  103. package/dist/{notes-D9ofENLJ.mjs → notes-Cj8jL1kS.mjs} +2 -2
  104. package/dist/{notes-D9ofENLJ.mjs.map → notes-Cj8jL1kS.mjs.map} +1 -1
  105. package/dist/{notes-DBNPml4N.cjs → notes-DTTUGZyi.cjs} +2 -2
  106. package/dist/{notes-DBNPml4N.cjs.map → notes-DTTUGZyi.cjs.map} +1 -1
  107. package/dist/{projectBucket-De0MQeNj.mjs → projectBucket-6BKUPlDp.mjs} +2 -2
  108. package/dist/{projectBucket-De0MQeNj.mjs.map → projectBucket-6BKUPlDp.mjs.map} +1 -1
  109. package/dist/{projectBucket-BtiC0Cn8.cjs → projectBucket-CjJB-nom.cjs} +2 -2
  110. package/dist/{projectBucket-BtiC0Cn8.cjs.map → projectBucket-CjJB-nom.cjs.map} +1 -1
  111. package/dist/{publish-CohTrVKe.cjs → publish-Cj36G3de.cjs} +2 -2
  112. package/dist/{publish-CohTrVKe.cjs.map → publish-Cj36G3de.cjs.map} +1 -1
  113. package/dist/{publish-k38S418e.mjs → publish-DRsFN1td.mjs} +2 -2
  114. package/dist/{publish-k38S418e.mjs.map → publish-DRsFN1td.mjs.map} +1 -1
  115. package/dist/{resolve-Cr3Qj8ch.cjs → resolve-C1NkdIcy.cjs} +4 -4
  116. package/dist/{resolve-Cr3Qj8ch.cjs.map → resolve-C1NkdIcy.cjs.map} +1 -1
  117. package/dist/{resolve-YMxlYJtO.mjs → resolve-DjbMNLt-.mjs} +4 -4
  118. package/dist/{resolve-YMxlYJtO.mjs.map → resolve-DjbMNLt-.mjs.map} +1 -1
  119. package/dist/{rollback-eyqvtzW_.cjs → rollback-531Va3dw.cjs} +5 -5
  120. package/dist/{rollback-eyqvtzW_.cjs.map → rollback-531Va3dw.cjs.map} +1 -1
  121. package/dist/{rollback-DIoyVrQI.mjs → rollback-D0ZpwlFq.mjs} +5 -5
  122. package/dist/{rollback-DIoyVrQI.mjs.map → rollback-D0ZpwlFq.mjs.map} +1 -1
  123. package/dist/{s3-CegRM8Sa.cjs → s3-BSfFgbms.cjs} +2 -2
  124. package/dist/{s3-CegRM8Sa.cjs.map → s3-BSfFgbms.cjs.map} +1 -1
  125. package/dist/{s3-Cl3tRemt.mjs → s3-Ho00alt7.mjs} +2 -2
  126. package/dist/{s3-Cl3tRemt.mjs.map → s3-Ho00alt7.mjs.map} +1 -1
  127. package/dist/{serverSetup-fQwkJ_EI.mjs → serverSetup-BW1RgJXo.mjs} +5 -5
  128. package/dist/{serverSetup-fQwkJ_EI.mjs.map → serverSetup-BW1RgJXo.mjs.map} +1 -1
  129. package/dist/{serverSetup-BwfMgz3W.cjs → serverSetup-C59lCe80.cjs} +5 -5
  130. package/dist/{serverSetup-BwfMgz3W.cjs.map → serverSetup-C59lCe80.cjs.map} +1 -1
  131. package/dist/{sniffer-BgdVvvzU.cjs → sniffer-BL7X_kzC.cjs} +6 -6
  132. package/dist/{sniffer-BgdVvvzU.cjs.map → sniffer-BL7X_kzC.cjs.map} +1 -1
  133. package/dist/{sniffer-FF7mfuR8.mjs → sniffer-DrmSlwg9.mjs} +6 -6
  134. package/dist/{sniffer-FF7mfuR8.mjs.map → sniffer-DrmSlwg9.mjs.map} +1 -1
  135. package/dist/{snsSubscriptions-DUY-Tu6J.cjs → snsSubscriptions-B8nZBBEE.cjs} +2 -2
  136. package/dist/{snsSubscriptions-DUY-Tu6J.cjs.map → snsSubscriptions-B8nZBBEE.cjs.map} +1 -1
  137. package/dist/{snsSubscriptions-B_WH4o1S.mjs → snsSubscriptions-DF7YGauz.mjs} +2 -2
  138. package/dist/{snsSubscriptions-B_WH4o1S.mjs.map → snsSubscriptions-DF7YGauz.mjs.map} +1 -1
  139. package/dist/{sst-BkTtncop.mjs → sst-C-RSpWC2.mjs} +4 -4
  140. package/dist/{sst-BkTtncop.mjs.map → sst-C-RSpWC2.mjs.map} +1 -1
  141. package/dist/{sst-BEXeTgDQ.cjs → sst-Dvko43Y3.cjs} +4 -4
  142. package/dist/{sst-BEXeTgDQ.cjs.map → sst-Dvko43Y3.cjs.map} +1 -1
  143. package/dist/{stack-CqfBL5LA.mjs → stack-CVzOFHed.mjs} +49 -368
  144. package/dist/stack-CVzOFHed.mjs.map +1 -0
  145. package/dist/{stack-CcFgY4sJ.cjs → stack-l_eQ63Gl.cjs} +51 -442
  146. package/dist/stack-l_eQ63Gl.cjs.map +1 -0
  147. package/dist/{stage-4ZtteXz8.mjs → stage-JMlDwobz.mjs} +16 -13
  148. package/dist/stage-JMlDwobz.mjs.map +1 -0
  149. package/dist/{stage-C19XRx7W.cjs → stage-_vzQ82Gz.cjs} +17 -14
  150. package/dist/stage-_vzQ82Gz.cjs.map +1 -0
  151. package/dist/target/public.cjs +1 -1
  152. package/dist/target/public.mjs +1 -1
  153. package/dist/{terminal-KVX_MmCR.mjs → terminal-BnKPi06T.mjs} +2 -2
  154. package/dist/{terminal-KVX_MmCR.mjs.map → terminal-BnKPi06T.mjs.map} +1 -1
  155. package/dist/{terminal-BkyVVOb-.cjs → terminal-CdPFlCS_.cjs} +2 -2
  156. package/dist/{terminal-BkyVVOb-.cjs.map → terminal-CdPFlCS_.cjs.map} +1 -1
  157. package/package.json +15 -15
  158. package/dist/apps-BIsxWYUo.cjs.map +0 -1
  159. package/dist/apps-DFzUuJ22.mjs.map +0 -1
  160. package/dist/credentials-CJ_z0Nni.mjs.map +0 -1
  161. package/dist/credentials-D11xozSF.cjs.map +0 -1
  162. package/dist/stack-CcFgY4sJ.cjs.map +0 -1
  163. package/dist/stack-CqfBL5LA.mjs.map +0 -1
  164. package/dist/stage-4ZtteXz8.mjs.map +0 -1
  165. package/dist/stage-C19XRx7W.cjs.map +0 -1
@@ -1,8 +1,8 @@
1
1
  const require_rolldown_runtime = require("./rolldown-runtime-C0BPl7ul.cjs");
2
2
  const require_errors = require("./errors-DMC4Umsb.cjs");
3
- const require_credentials = require("./credentials-D11xozSF.cjs");
3
+ const require_credentials = require("./credentials-CrQglKgo.cjs");
4
4
  const require_workspace = require("./workspace-1szcahj9.cjs");
5
- const require_compose = require("./compose-Cius-YHS.cjs");
5
+ const require_compose = require("./compose-DVPWitEu.cjs");
6
6
  const require_SubscriberGenerator = require("./SubscriberGenerator-BNJyPmXJ.cjs");
7
7
  const require_config = require("./config-juUyBlb1.cjs");
8
8
  const require_types = require("./types-Bl_CwZC9.cjs");
@@ -16,6 +16,8 @@ let node_child_process = require("node:child_process");
16
16
  let node_net = require("node:net");
17
17
  let node_crypto = require("node:crypto");
18
18
  let _geekmidas_manifest = require("@geekmidas/manifest");
19
+ let node_module = require("node:module");
20
+ let node_url = require("node:url");
19
21
  let _geekmidas_constructs_encryption = require("@geekmidas/constructs/encryption");
20
22
  let _geekmidas_db_pg_roles = require("@geekmidas/db/pg/roles");
21
23
  let _geekmidas_events_sns_url = require("@geekmidas/events/sns/url");
@@ -30,6 +32,115 @@ let _aws_sdk_client_s3 = require("@aws-sdk/client-s3");
30
32
  let _aws_sdk_client_sns = require("@aws-sdk/client-sns");
31
33
  let _aws_sdk_client_sqs = require("@aws-sdk/client-sqs");
32
34
  let pg = require("pg");
35
+ //#region src/providers/dns.ts
36
+ /** Whether the workspace deploys through the compose target. */
37
+ function deploysWithCompose(workspace) {
38
+ return workspace.deploy?.default === "compose" || Object.values(workspace.apps).some((app) => app.resolvedDeployTarget === "compose");
39
+ }
40
+ //#endregion
41
+ //#region src/backups/config.ts
42
+ /**
43
+ * Which stages take backups, and where they are kept.
44
+ *
45
+ * A deployed compose stage whose stack runs Postgres is backed up by
46
+ * default — every day at 02:00 UTC, kept 30 days — unless
47
+ * `deploy.backups.<stage>` says otherwise. The local stage never is.
48
+ *
49
+ * Every backup is kept in the project bucket (`providers/projectBucket.ts`),
50
+ * beside the stage's deploy state, one folder per run and one file per
51
+ * database:
52
+ *
53
+ * ```
54
+ * gkm/<project>/<stage>/backups/2026-10-10/02-00-00Z/database.sql.gz
55
+ * gkm/<project>/<stage>/backups/2026-10-10/02-00-00Z/auth-database.sql.gz
56
+ * ```
57
+ *
58
+ * The file is named after the database's construct, the way its migrations
59
+ * folder is: `AuthDatabase` is `db/auth-database`, and `auth-database.sql.gz`.
60
+ */
61
+ /** Whether the stack runs Postgres: some construct is a database. */
62
+ function runsPostgres(manifest) {
63
+ return Object.values(manifest).some((d) => d.kind === "database");
64
+ }
65
+ /**
66
+ * What `stage`'s backups are: on — by its entry or the default — off by
67
+ * `false`, or none, for the local stage, a stage compose does not deploy,
68
+ * and a stack with no database.
69
+ */
70
+ function stageBackups(workspace, manifest, stage) {
71
+ if (stage === workspace.stages?.local) return {
72
+ mode: "none",
73
+ reason: "local"
74
+ };
75
+ if (!deploysWithCompose(workspace)) return {
76
+ mode: "none",
77
+ reason: "not-compose"
78
+ };
79
+ if (!runsPostgres(manifest)) return {
80
+ mode: "none",
81
+ reason: "no-postgres"
82
+ };
83
+ const value = (workspace.deploy?.backups)?.[stage];
84
+ const checked = require_workspace.checkStageBackups(stage, value ?? {});
85
+ if (checked === false) return { mode: "disabled" };
86
+ return {
87
+ mode: "on",
88
+ backups: checked,
89
+ source: value === void 0 ? "default" : "config"
90
+ };
91
+ }
92
+ /**
93
+ * Where a stage's backups are, in the project bucket — under the same
94
+ * `<prefix>/<project>/<stage>` its deploy state is: `gkm/shop/production/backups`.
95
+ */
96
+ function backupsPrefix(workspace, stage) {
97
+ const state = workspace.state;
98
+ const prefix = state?.provider === "s3" && state.prefix !== void 0 ? state.prefix.replace(/\/+$/, "") : "gkm";
99
+ return `${prefix ? `${prefix}/` : ""}${workspace.name}/${stage}/backups`;
100
+ }
101
+ /** A run folder's time back, or `undefined` for a key that is not one. */
102
+ function runTime(folder) {
103
+ const match = /^(\d{4}-\d{2}-\d{2})\/(\d{2})-(\d{2})-(\d{2})Z$/.exec(folder);
104
+ if (!match) return void 0;
105
+ const at = /* @__PURE__ */ new Date(`${match[1]}T${match[2]}:${match[3]}:${match[4]}Z`);
106
+ return Number.isNaN(at.getTime()) ? void 0 : at;
107
+ }
108
+ /** A database's file in a run's folder: `auth-database.sql.gz`. */
109
+ function backupFile(database) {
110
+ return `${database.file}.sql.gz`;
111
+ }
112
+ /** Each database the stack runs, by its construct and its name in Postgres. */
113
+ function backupDatabases(resources) {
114
+ return resources.filter((r) => r.kind === "database").map((r) => ({
115
+ id: r.id,
116
+ file: (0, _geekmidas_manifest.kebabCase)(r.id),
117
+ name: r.name
118
+ })).sort((a, b) => a.file.localeCompare(b.file));
119
+ }
120
+ /**
121
+ * The expiry of every stage's backups, by each stage's own entry — what the
122
+ * project bucket's lifecycle carries beside its own rule.
123
+ *
124
+ * A put replaces a bucket's whole lifecycle, so this is built from every
125
+ * deployed stage each time, never from the stage being deployed alone: one
126
+ * stage's deploy keeps every other's rule. A stage set to `false` has none,
127
+ * and its backups are kept until someone deletes them.
128
+ */
129
+ function backupExpiries(workspace, manifest) {
130
+ const expiries = [];
131
+ for (const stage of [...workspace.stages?.deployed ?? []].sort()) {
132
+ const choice = stageBackups(workspace, manifest, stage);
133
+ if (choice.mode !== "on") continue;
134
+ expiries.push({
135
+ id: `gkm-backups-${stage}`,
136
+ prefix: `${backupsPrefix(workspace, stage)}/`,
137
+ days: choice.backups.keepDays,
138
+ abortIncompleteDays: 1
139
+ });
140
+ }
141
+ return expiries;
142
+ }
143
+ //#endregion
33
144
  //#region src/generators/processorRoute.ts
34
145
  /**
35
146
  * Where `gkm dev` serves a file server's processors, on the dev server of the
@@ -284,9 +395,7 @@ function toCaddyfile(sites, options) {
284
395
  https://${host} {
285
396
  tls ${options.certificate} ${options.certificate}
286
397
 
287
- # gkm's own header, which only a service of this stack may send: the auth
288
- # server rate-limits by the client address it carries.
289
- request_header -${_geekmidas_manifest.CLIENT_IP_HEADER}
398
+ ${clientIpRule(options.edgeToken)}
290
399
  ${processors ? `
291
400
  # Its processors' patterns, to the dev server holding them — under the
292
401
  # route it mounts them on. Answered there, so the bucket below never is.
@@ -337,6 +446,29 @@ const GENERATED = `# Generated by gkm from the construct manifest — do not edi
337
446
  # its root, so nothing has to be installed to use these URLs from code; a
338
447
  # browser needs the root trusted once ("gkm trust").
339
448
  `;
449
+ /**
450
+ * The lines every site block of an edge opens with, for gkm's own
451
+ * `x-gkm-client-ip` — the client address the auth server rate-limits by.
452
+ *
453
+ * Only a service of this stack may send it. One that calls a sibling at its
454
+ * public address comes through this edge, and proves where it comes from with
455
+ * the stack's token (`x-gkm-edge-token`), derived from the stage's seed and
456
+ * handed to every process of the stack — never to a browser. A request
457
+ * without it has the header removed, so nobody outside can choose the address
458
+ * they are rate-limited by. Without a token, it is removed from every request.
459
+ */
460
+ function clientIpRule(edgeToken) {
461
+ if (!edgeToken) return `
462
+ # gkm's own header, which only a service of this stack may send: the auth
463
+ # server rate-limits by the client address it carries.
464
+ request_header -${_geekmidas_manifest.CLIENT_IP_HEADER}`;
465
+ return `
466
+ # gkm's own header, which only a service of this stack may send — proven by
467
+ # the stack's token: the auth server rate-limits by the client address it
468
+ # carries. Removed from every other request.
469
+ @gkm_outside not header ${_geekmidas_manifest.EDGE_TOKEN_HEADER} ${edgeToken}
470
+ request_header @gkm_outside -${_geekmidas_manifest.CLIENT_IP_HEADER}`;
471
+ }
340
472
  //#endregion
341
473
  //#region src/telemetry/edges.ts
342
474
  /**
@@ -823,6 +955,15 @@ function stageEnv(stored, resolved) {
823
955
  };
824
956
  }
825
957
  /**
958
+ * The token a stack's own services prove themselves with at its edge
959
+ * (`EDGE_TOKEN_HEADER`): derived from the stage's seed, as a bucket's webhook
960
+ * token is, so every process, the edge and the auth server agree on it with
961
+ * nothing stored.
962
+ */
963
+ function edgeToken(project, seed) {
964
+ return (0, node_crypto.createHash)("sha256").update(`${seed ? `${seed}:` : ""}${project}:edge-token`).digest("base64url").slice(0, 43);
965
+ }
966
+ /**
826
967
  * Every env key a reconciled plan resolves, and its value.
827
968
  *
828
969
  * Keys come from the declaration rather than being re-derived, so what the build
@@ -900,6 +1041,7 @@ function envFor(plan, options) {
900
1041
  env[(0, _geekmidas_manifest.provideKey)(resource.id, "eventsToken")] = require_compose.objectsWebhookToken(options.project ?? "", resource.id, credential.seed);
901
1042
  }
902
1043
  if (plan.resources.some((r) => r.kind === "inbox" && env[r.envKey])) env[require_SubscriberGenerator.INBOX_RELAY_TOKEN_KEY] = require_SubscriberGenerator.inboxRelayToken(options.project ?? "", credential.seed);
1044
+ if (plan.resources.some((r) => (r.kind === "rest-api" || r.kind === "websocket-api") && env[r.envKey])) env[_geekmidas_manifest.EDGE_TOKEN_KEY] = edgeToken(options.project ?? "", credential.seed);
903
1045
  if (plan.resources.some((r) => r.kind === "objects" && env[r.envKey])) Object.assign(env, storageCredentials(options.credentials));
904
1046
  return env;
905
1047
  }
@@ -1817,6 +1959,207 @@ async function applyBuckets(client, buckets) {
1817
1959
  return applied;
1818
1960
  }
1819
1961
  //#endregion
1962
+ //#region src/backups/service.ts
1963
+ /**
1964
+ * The stack's `backups` service: what a deployed compose stage with Postgres
1965
+ * runs beside its apps, unless `deploy.backups.<stage>` is `false`.
1966
+ *
1967
+ * - **The image** is built from the stack's own Postgres image —
1968
+ * `postgres:<major>-alpine`, already on the server for the stack, and with
1969
+ * the `pg_dump` that matches the server — with Node added and gkm's runner
1970
+ * (`runner.ts`) copied in. Nothing is pulled that the stack does not have,
1971
+ * and nothing is mounted from the host: the build context is two files.
1972
+ * - **Its key** is `BACKUPS_URL`, from the stage's secrets, like any app's:
1973
+ * allowed to put objects under the stage's backups prefix and nothing else.
1974
+ * The server holds no AWS credentials of its own.
1975
+ * - **Its login** is a role of its own, `<project>_backups`, granted
1976
+ * `pg_read_all_data` — it can read every database and write none. Postgres
1977
+ * before 14 has no such role, and there it signs in as the stack's
1978
+ * superuser.
1979
+ * - **Its health** is the last good run: unhealthy once that is more than
1980
+ * twice the schedule's longest gap old, after a startup grace.
1981
+ */
1982
+ /** The service's name in the stack. */
1983
+ const BACKUPS_SERVICE = "backups";
1984
+ /** The secret its key is written to. */
1985
+ const BACKUPS_URL_KEY = "BACKUPS_URL";
1986
+ /** Where the runner is, in the image. */
1987
+ const RUNNER_PATH = "/gkm/backup.mjs";
1988
+ /** The first Postgres with `pg_read_all_data`. */
1989
+ const READ_ALL_DATA_SINCE = 14;
1990
+ /** A stage that backs up, and no key to back up with. */
1991
+ var BackupsUrlMissing = class extends require_errors.GkmError {
1992
+ stage;
1993
+ constructor(stage) {
1994
+ super(`'${stage}' runs Postgres, so its stack backs it up, and its secrets hold no ${BACKUPS_URL_KEY} to back up with. The deploy writes it — the IAM user and key it creates in the stage's AWS account — so run the deploy with the account's credentials. To take no backups on this stage, set deploy.backups.${stage}: false.`);
1995
+ this.stage = stage;
1996
+ this.name = "BackupsUrlMissing";
1997
+ }
1998
+ };
1999
+ /** The backups role: `<project>_backups`, as the superuser is `<project>_admin`. */
2000
+ function backupsRole(project) {
2001
+ return `${require_compose.postgresRoleSlug(project)}_backups`;
2002
+ }
2003
+ /**
2004
+ * The runner's source, as JavaScript: the built `backups/runner.mjs` beside
2005
+ * the CLI's bundle, or — run from source — `runner.ts`, with its types
2006
+ * stripped by esbuild.
2007
+ */
2008
+ function runnerSource() {
2009
+ const here = (0, node_path.dirname)((0, node_url.fileURLToPath)(require("url").pathToFileURL(__filename).href));
2010
+ for (const path of [
2011
+ (0, node_path.join)(here, "backups", "runner.mjs"),
2012
+ (0, node_path.join)(here, "runner.mjs"),
2013
+ (0, node_path.join)(here, "..", "backups", "runner.mjs")
2014
+ ]) if ((0, node_fs.existsSync)(path)) return (0, node_fs.readFileSync)(path, "utf-8");
2015
+ const { transformSync } = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href)("esbuild");
2016
+ return transformSync((0, node_fs.readFileSync)((0, node_path.join)(here, "runner.ts"), "utf-8"), {
2017
+ loader: "ts",
2018
+ format: "esm",
2019
+ target: "node22"
2020
+ }).code;
2021
+ }
2022
+ /** The image's Dockerfile: the stack's Postgres, Node, and the runner. */
2023
+ function backupsDockerfile(from) {
2024
+ return `# Generated by gkm — the stage's backups: pg_dump from ${from}, and gkm's uploader.
2025
+ FROM ${from}
2026
+ RUN apk add --no-cache nodejs
2027
+ COPY backup.mjs ${RUNNER_PATH}
2028
+ USER postgres
2029
+ ENTRYPOINT []
2030
+ CMD ["node", "${RUNNER_PATH}", "serve"]
2031
+ `;
2032
+ }
2033
+ /**
2034
+ * The stack's backups service, for a stage whose backups are on.
2035
+ *
2036
+ * @throws {BackupsUrlMissing} when the stage's secrets hold no key
2037
+ */
2038
+ function stackBackups(input) {
2039
+ const { plan, stage } = input;
2040
+ const version = plan.resources.find((r) => r.version)?.version ?? _geekmidas_manifest.DEFAULT_POSTGRES_VERSION;
2041
+ const from = require_compose.postgresImage(version);
2042
+ const script = runnerSource();
2043
+ const dockerfile = backupsDockerfile(from);
2044
+ const hash = (0, node_crypto.createHash)("sha256").update(dockerfile).update(script).digest("hex").slice(0, 12);
2045
+ const readOnly = version >= READ_ALL_DATA_SINCE;
2046
+ const role = backupsRole(input.workspace.name);
2047
+ const login = readOnly ? {
2048
+ user: role,
2049
+ password: localRolePassword(input.workspace.name, plan, role, input.seed)
2050
+ } : input.superuser;
2051
+ const databases = backupDatabases(plan.resources);
2052
+ const prefix = backupsPrefix(input.workspace, stage);
2053
+ const { kind, ...schedule } = input.backups.schedule;
2054
+ let env = {};
2055
+ if (!input.buildOnly) {
2056
+ const url = input.custom[BACKUPS_URL_KEY];
2057
+ if (!url) throw new BackupsUrlMissing(stage);
2058
+ env = {
2059
+ BACKUPS_URL: url,
2060
+ BACKUPS_PREFIX: prefix,
2061
+ BACKUPS_DATABASES: JSON.stringify(databases.map(({ file, name }) => ({
2062
+ file,
2063
+ name
2064
+ }))),
2065
+ BACKUPS_SCHEDULE: JSON.stringify(kind === "cron" ? {
2066
+ kind,
2067
+ minutes: input.backups.schedule.minutes,
2068
+ hours: input.backups.schedule.hours,
2069
+ days: input.backups.schedule.days,
2070
+ months: input.backups.schedule.months,
2071
+ weekdays: input.backups.schedule.weekdays
2072
+ } : {
2073
+ kind,
2074
+ ...schedule
2075
+ }),
2076
+ BACKUPS_MAX_GAP_SECONDS: String(input.backups.maxGapSeconds),
2077
+ PGHOST: "postgres",
2078
+ PGPORT: "5432",
2079
+ PGUSER: login.user,
2080
+ PGPASSWORD: login.password,
2081
+ ...input.telemetry?.OTEL_EXPORTER_OTLP_ENDPOINT ? {
2082
+ OTEL_EXPORTER_OTLP_ENDPOINT: input.telemetry.OTEL_EXPORTER_OTLP_ENDPOINT,
2083
+ ...input.telemetry.OTEL_EXPORTER_OTLP_HEADERS ? { OTEL_EXPORTER_OTLP_HEADERS: input.telemetry.OTEL_EXPORTER_OTLP_HEADERS } : {},
2084
+ OTEL_SERVICE_NAME: BACKUPS_SERVICE
2085
+ } : {}
2086
+ };
2087
+ }
2088
+ return {
2089
+ backups: input.backups,
2090
+ databases,
2091
+ prefix,
2092
+ from,
2093
+ image: `${input.project}-backups:pg${version}-${hash}`,
2094
+ files: {
2095
+ Dockerfile: dockerfile,
2096
+ "backup.mjs": script
2097
+ },
2098
+ login,
2099
+ readOnly,
2100
+ env
2101
+ };
2102
+ }
2103
+ /** The service in the stack's compose file. */
2104
+ function backupsService(backups, envFiles) {
2105
+ return {
2106
+ image: backups.image,
2107
+ build: {
2108
+ context: `./${BACKUPS_SERVICE}`,
2109
+ dockerfile: "Dockerfile"
2110
+ },
2111
+ pull_policy: "build",
2112
+ restart: "unless-stopped",
2113
+ ...envFiles ? { env_file: [{
2114
+ path: `./${BACKUPS_SERVICE}.env`,
2115
+ format: "raw"
2116
+ }] } : {},
2117
+ depends_on: { postgres: { condition: "service_healthy" } },
2118
+ healthcheck: {
2119
+ test: [
2120
+ "CMD",
2121
+ "node",
2122
+ RUNNER_PATH,
2123
+ "health"
2124
+ ],
2125
+ interval: "1m",
2126
+ timeout: "10s",
2127
+ retries: 3,
2128
+ start_period: "30s"
2129
+ }
2130
+ };
2131
+ }
2132
+ /**
2133
+ * The backups role, created and kept: able to sign in and read every
2134
+ * database, and nothing else. None when it signs in as the superuser.
2135
+ */
2136
+ function backupsRoleStatements(backups) {
2137
+ if (!backups.readOnly) return [];
2138
+ const role = quoteIdentifier(backups.login.user);
2139
+ const password = `'${backups.login.password.replace(/'/g, "''")}'`;
2140
+ return [
2141
+ {
2142
+ id: BACKUPS_SERVICE,
2143
+ describe: `role ${backups.login.user}`,
2144
+ exists: {
2145
+ sql: "SELECT 1 FROM pg_roles WHERE rolname = $1",
2146
+ values: [backups.login.user]
2147
+ },
2148
+ create: `CREATE ROLE ${role} LOGIN PASSWORD ${password}`
2149
+ },
2150
+ {
2151
+ id: BACKUPS_SERVICE,
2152
+ describe: `role ${backups.login.user}: its password`,
2153
+ create: `ALTER ROLE ${role} WITH LOGIN PASSWORD ${password}`
2154
+ },
2155
+ {
2156
+ id: BACKUPS_SERVICE,
2157
+ describe: `role ${backups.login.user}: read every database`,
2158
+ create: `GRANT pg_read_all_data TO ${role}`
2159
+ }
2160
+ ];
2161
+ }
2162
+ //#endregion
1820
2163
  //#region src/build/workers.ts
1821
2164
  /** A worker with background work and no backend app to build it from. */
1822
2165
  var WorkerHasNoApp = class extends require_errors.GkmError {
@@ -2031,6 +2374,15 @@ function siteOfflineHosts(manifest, appName, ownUrl, urls) {
2031
2374
  }
2032
2375
  return offlineBuildHosts(site, manifest, (key) => byKey.get(key));
2033
2376
  }
2377
+ /**
2378
+ * Whether a site runs a server of its own — Next's, TanStack Start's — which
2379
+ * reads an environment at runtime as a backend does: its edges' public URLs
2380
+ * and the stage's secrets. A `static` site is a finished bundle, and reads
2381
+ * nothing once it is built.
2382
+ */
2383
+ function runsServer(site) {
2384
+ return site.variant !== "static";
2385
+ }
2034
2386
  //#endregion
2035
2387
  //#region src/exec/imageBuild.ts
2036
2388
  /**
@@ -3054,6 +3406,64 @@ function toPosix(path) {
3054
3406
  return path.split(node_path.sep).join("/");
3055
3407
  }
3056
3408
  //#endregion
3409
+ //#region src/providers/processorOrigin.ts
3410
+ /**
3411
+ * A file server's processors as a CDN origin: the names both sides agree on.
3412
+ *
3413
+ * On a compose stage whose bucket is on S3, the CDN serves the bucket and
3414
+ * sends each processor pattern to the stack's processor unit, at a host of
3415
+ * its own. That host is public — a CDN reaches its origin over the internet —
3416
+ * so the CDN adds a secret header and the edge refuses any request without
3417
+ * it. One definition, read by the CDN that sends the header and by the stack
3418
+ * whose edge checks it, so the two cannot drift.
3419
+ */
3420
+ /** The header the CDN adds to every request it sends a processor. */
3421
+ const ORIGIN_VERIFY_HEADER = "X-Gkm-Origin-Verify";
3422
+ /** Where a file server's processors answer the CDN: `<fileserver>-processors.<domain>`. */
3423
+ function processorOriginHost(serverId, domain) {
3424
+ return `${require_config.appKey(serverId)}-processors.${domain}`.toLowerCase();
3425
+ }
3426
+ /** The stage secret holding the header's value: `ASSETS_SERVER_ORIGIN_SECRET`. */
3427
+ function originSecretKey(serverId) {
3428
+ return (0, _geekmidas_manifest.provideKey)(serverId, "originSecret");
3429
+ }
3430
+ /**
3431
+ * What the processor unit reads that secret from. Set wherever the CDN fronts
3432
+ * it, so the unit refuses a request without the header itself — on Dokploy,
3433
+ * whose edge cannot match a header, the only check; behind the stack's own
3434
+ * edge, a second one.
3435
+ */
3436
+ const PROCESSOR_ORIGIN_SECRET_ENV = "GKM_PROCESSOR_ORIGIN_SECRET";
3437
+ /** A new value for that secret: random, generated once, kept in the stage. */
3438
+ function newOriginSecret() {
3439
+ return (0, node_crypto.randomBytes)(32).toString("base64url");
3440
+ }
3441
+ //#endregion
3442
+ //#region src/secrets/stackKeys.ts
3443
+ /**
3444
+ * The stage secrets gkm keeps for the stack itself rather than for the
3445
+ * application: the server's address, the logins of the containers it runs
3446
+ * (Redis, OpenObserve), the key backups write with, the secret a CDN sends a
3447
+ * file server's processors.
3448
+ *
3449
+ * Nothing in an app reads them, so no process is handed one as "the stage's
3450
+ * own" (`processEnvKeys`) — the containers that do read them are given them
3451
+ * by name.
3452
+ */
3453
+ const STACK_KEYS = /* @__PURE__ */ new Set([
3454
+ BACKUPS_URL_KEY,
3455
+ require_compose.LOGS_EMAIL_KEY,
3456
+ require_compose.LOGS_PASSWORD_KEY,
3457
+ require_compose.REDIS_PASSWORD_KEY,
3458
+ PROCESSOR_ORIGIN_SECRET_ENV
3459
+ ]);
3460
+ /** A file server's origin secret: `ASSETS_SERVER_ORIGIN_SECRET`. */
3461
+ const ORIGIN_SECRET = /_ORIGIN_SECRET$/;
3462
+ /** Whether a stage secret is the stack's own, which no app process reads. */
3463
+ function isStackKey(key) {
3464
+ return require_workspace.isReservedStageKey(key) || key.startsWith("GKM_") || STACK_KEYS.has(key) || ORIGIN_SECRET.test(key);
3465
+ }
3466
+ //#endregion
3057
3467
  //#region src/trust/authority.ts
3058
3468
  /**
3059
3469
  * gkm's local certificate authority: one per machine, and every local edge's
@@ -4328,7 +4738,10 @@ async function reconcile(options) {
4328
4738
  const sites = sitesFor(plan, project, options.addresses, options.processorAddresses);
4329
4739
  const edged = plan.containers.includes("caddy");
4330
4740
  const authorityPaths = options.authority ?? localAuthorityPaths();
4331
- const caddyfile = toCaddyfile(sites, { certificate: `${CADDY_SITES_IN_CONTAINER}/${stage}.pem` });
4741
+ const caddyfile = toCaddyfile(sites, {
4742
+ certificate: `${CADDY_SITES_IN_CONTAINER}/${stage}.pem`,
4743
+ edgeToken: edgeToken(project, seed)
4744
+ });
4332
4745
  const hash = planHash(plan, compose, {
4333
4746
  caddyfile,
4334
4747
  postgres: postgresStatements(plan, project, seed).map((statement) => statement.create).join(";\n")
@@ -4620,7 +5033,8 @@ async function reconcileWorkspace(workspace, options) {
4620
5033
  for (const outcome of result.logins) if (outcome.notice) console.log(outcome.notice);
4621
5034
  return {
4622
5035
  ...result,
4623
- manifest
5036
+ manifest,
5037
+ background
4624
5038
  };
4625
5039
  }
4626
5040
  /**
@@ -4756,6 +5170,21 @@ function localAddress(port) {
4756
5170
  * `gkm test` rewrites the same file, and running the tests must not quietly
4757
5171
  * point these apps at the test databases.
4758
5172
  */
5173
+ var apps_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({
5174
+ APPS_PROFILE: () => APPS_PROFILE,
5175
+ appEnvKeys: () => appEnvKeys,
5176
+ appProcess: () => appProcess,
5177
+ appServices: () => appServices,
5178
+ constructKeys: () => constructKeys,
5179
+ dockerfileOf: () => dockerfileOf,
5180
+ healthcheck: () => healthcheck,
5181
+ networkEnv: () => networkEnv,
5182
+ processEnv: () => processEnv,
5183
+ processEnvKeys: () => processEnvKeys,
5184
+ processorEnvKeys: () => processorEnvKeys,
5185
+ sitePublicArgs: () => sitePublicArgs,
5186
+ workerEnvKeys: () => workerEnvKeys
5187
+ });
4759
5188
  /** The profile app services carry, so `gkm dev` starts only the containers. */
4760
5189
  const APPS_PROFILE = "apps";
4761
5190
  /**
@@ -4804,9 +5233,10 @@ function sitePublicArgs(manifest, appName, env) {
4804
5233
  * name on the compose network — `postgres:5432` rather than the port
4805
5234
  * published for the host.
4806
5235
  *
4807
- * The addresses of surfaces and sites are the caller's: on the compose
4808
- * network for a service another service calls, public for what a browser is
4809
- * handed. `gkm compose` asks twice, once for each.
5236
+ * The addresses of surfaces and sites are the caller's: `gkm compose` hands
5237
+ * every process the public ones, which one app calls another on through the
5238
+ * edge; `gkm docker`'s apps profile, which runs no edge, the compose
5239
+ * network's.
4810
5240
  */
4811
5241
  function networkEnv(plan, options, hostOf = (container) => container) {
4812
5242
  const placeholders = {};
@@ -4884,7 +5314,6 @@ function workerEnvKeys(manifest, workerId) {
4884
5314
  addEdgeKeys(manifest, require_discover.workerEdges(manifest, workerId), keys);
4885
5315
  return keys;
4886
5316
  }
4887
- /** What each construct an edge reaches hands the process that reaches it. */
4888
5317
  /**
4889
5318
  * The keys a file server's processor unit reads: its bucket's, and what each
4890
5319
  * of its processors depends on. `undefined` for a file server with none.
@@ -4896,6 +5325,91 @@ function processorEnvKeys(manifest, fileServerId) {
4896
5325
  addEdgeKeys(manifest, [server.of, ...server.processors.flatMap((p) => p.dependencies.map((d) => d.target))], keys);
4897
5326
  return keys;
4898
5327
  }
5328
+ /**
5329
+ * The keys the declared constructs hand to some process — each scoped to the
5330
+ * processes with an edge to it. A stage key outside this set is the stage's
5331
+ * own: one set by hand, which nothing declares a reader of.
5332
+ */
5333
+ function constructKeys(manifest) {
5334
+ const keys = /* @__PURE__ */ new Set();
5335
+ const add = (more) => {
5336
+ for (const key of more ?? []) keys.add(key);
5337
+ };
5338
+ for (const [id, declaration] of Object.entries(manifest)) {
5339
+ add(declaration.provides);
5340
+ add(declaration.requires);
5341
+ if (declaration.kind === "worker") add(workerEnvKeys(manifest, id));
5342
+ if (declaration.kind === "file-server") add(processorEnvKeys(manifest, id));
5343
+ if (declaration.kind === "rest-api" || declaration.kind === "websocket-api" || declaration.kind === "site" || declaration.kind === "mobile-app") add(appEnvKeys(manifest, require_config.appKey(id)));
5344
+ }
5345
+ return keys;
5346
+ }
5347
+ /**
5348
+ * The keys one process is handed — the one rule `gkm dev`, `gkm exec` and
5349
+ * `gkm compose` all apply, so an app gets the same keys whichever runs it:
5350
+ *
5351
+ * - **What its constructs reach**, by their edges: `appEnvKeys` for its app,
5352
+ * `workerEnvKeys` for each worker it runs, `processorEnvKeys` for each
5353
+ * file server's processors. A key a construct provides reaches only a
5354
+ * process with an edge to it, a stored one included — an auth server's
5355
+ * signing secret stays with the auth server.
5356
+ * - **The stack's edge token** (`EDGE_TOKEN_KEY`), which a call to a
5357
+ * sibling through the edge carries beside the client's address.
5358
+ * - **Every one of the stage's own keys** (`stageKeys` no construct
5359
+ * provides): a value set with `gkm secrets:set` that the code reads with
5360
+ * `get('X')`. Nothing declares which process reads it, so every process is
5361
+ * handed it — but for what gkm keeps for the stack itself (`isStackKey`):
5362
+ * a container's login, the backups key, the server's address.
5363
+ *
5364
+ * `undefined` for an app no declaration describes, which nothing narrows.
5365
+ */
5366
+ function processEnvKeys(manifest, units, stageKeys) {
5367
+ const keys = /* @__PURE__ */ new Set();
5368
+ if (units.app !== void 0) {
5369
+ const own = appEnvKeys(manifest, units.app);
5370
+ if (!own && !units.workers?.length && !units.processors?.length) return;
5371
+ for (const key of own ?? []) keys.add(key);
5372
+ }
5373
+ for (const id of units.workers ?? []) for (const key of workerEnvKeys(manifest, id) ?? []) keys.add(key);
5374
+ for (const id of units.processors ?? []) for (const key of processorEnvKeys(manifest, id) ?? []) keys.add(key);
5375
+ keys.add(_geekmidas_manifest.EDGE_TOKEN_KEY);
5376
+ const owned = constructKeys(manifest);
5377
+ for (const key of stageKeys) if (!owned.has(key) && !isStackKey(key)) keys.add(key);
5378
+ return keys;
5379
+ }
5380
+ /**
5381
+ * One process's environment, from the stage's stored keys and every value
5382
+ * it resolved (`stageEnv`'s merge): exactly {@link processEnvKeys}.
5383
+ */
5384
+ function processEnv(manifest, units, stored, resolved) {
5385
+ const env = stageEnv(stored, resolved);
5386
+ const keys = processEnvKeys(manifest, units, Object.keys(stored));
5387
+ if (!keys) return env;
5388
+ return Object.fromEntries(Object.entries(env).filter(([key]) => keys.has(key)));
5389
+ }
5390
+ /**
5391
+ * What an app's own process runs locally: its surface or site, and the
5392
+ * workers and processors whose code it holds — the same choice `gkm build`
5393
+ * makes (`workerUnits`, `processorUnits`).
5394
+ *
5395
+ * A worker no app can build is left out here: `gkm build` says so, and a
5396
+ * dev loop has nothing to run it in.
5397
+ */
5398
+ function appProcess(workspace, manifest, background, appName) {
5399
+ const hosted = (units) => {
5400
+ try {
5401
+ return units().filter((unit) => unit.app === appName).map((unit) => unit.id);
5402
+ } catch (error) {
5403
+ if (error instanceof WorkerHasNoApp || error instanceof WorkerNameTaken || error instanceof ProcessorsHaveNoApp) return [];
5404
+ throw error;
5405
+ }
5406
+ };
5407
+ return {
5408
+ app: appName,
5409
+ workers: hosted(() => workerUnits(workspace, manifest, background)),
5410
+ processors: hosted(() => processorUnits(workspace, manifest))
5411
+ };
5412
+ }
4899
5413
  function addEdgeKeys(manifest, edges, keys, client = false) {
4900
5414
  for (const id of edges) {
4901
5415
  const bucket = require_discover.eventsEdgeBucket(id);
@@ -5009,6 +5523,18 @@ function healthcheck(port, path) {
5009
5523
  };
5010
5524
  }
5011
5525
  //#endregion
5526
+ Object.defineProperty(exports, "BACKUPS_SERVICE", {
5527
+ enumerable: true,
5528
+ get: function() {
5529
+ return BACKUPS_SERVICE;
5530
+ }
5531
+ });
5532
+ Object.defineProperty(exports, "BACKUPS_URL_KEY", {
5533
+ enumerable: true,
5534
+ get: function() {
5535
+ return BACKUPS_URL_KEY;
5536
+ }
5537
+ });
5012
5538
  Object.defineProperty(exports, "COMPOSE_PATH", {
5013
5539
  enumerable: true,
5014
5540
  get: function() {
@@ -5039,18 +5565,36 @@ Object.defineProperty(exports, "OFFLINE_BUILD_ADDRESS", {
5039
5565
  return OFFLINE_BUILD_ADDRESS;
5040
5566
  }
5041
5567
  });
5568
+ Object.defineProperty(exports, "ORIGIN_VERIFY_HEADER", {
5569
+ enumerable: true,
5570
+ get: function() {
5571
+ return ORIGIN_VERIFY_HEADER;
5572
+ }
5573
+ });
5042
5574
  Object.defineProperty(exports, "PROCESSORS_DEV_PREFIX", {
5043
5575
  enumerable: true,
5044
5576
  get: function() {
5045
5577
  return PROCESSORS_DEV_PREFIX;
5046
5578
  }
5047
5579
  });
5580
+ Object.defineProperty(exports, "PROCESSOR_ORIGIN_SECRET_ENV", {
5581
+ enumerable: true,
5582
+ get: function() {
5583
+ return PROCESSOR_ORIGIN_SECRET_ENV;
5584
+ }
5585
+ });
5048
5586
  Object.defineProperty(exports, "PROCESSOR_PORT", {
5049
5587
  enumerable: true,
5050
5588
  get: function() {
5051
5589
  return PROCESSOR_PORT;
5052
5590
  }
5053
5591
  });
5592
+ Object.defineProperty(exports, "RUNNER_PATH", {
5593
+ enumerable: true,
5594
+ get: function() {
5595
+ return RUNNER_PATH;
5596
+ }
5597
+ });
5054
5598
  Object.defineProperty(exports, "TELEMETRY_CONTAINER", {
5055
5599
  enumerable: true,
5056
5600
  get: function() {
@@ -5081,6 +5625,12 @@ Object.defineProperty(exports, "appImageOptions", {
5081
5625
  return appImageOptions;
5082
5626
  }
5083
5627
  });
5628
+ Object.defineProperty(exports, "appProcess", {
5629
+ enumerable: true,
5630
+ get: function() {
5631
+ return appProcess;
5632
+ }
5633
+ });
5084
5634
  Object.defineProperty(exports, "appTelemetry", {
5085
5635
  enumerable: true,
5086
5636
  get: function() {
@@ -5117,12 +5667,54 @@ Object.defineProperty(exports, "applyPostgres", {
5117
5667
  return applyPostgres;
5118
5668
  }
5119
5669
  });
5670
+ Object.defineProperty(exports, "apps_exports", {
5671
+ enumerable: true,
5672
+ get: function() {
5673
+ return apps_exports;
5674
+ }
5675
+ });
5120
5676
  Object.defineProperty(exports, "backendsOf", {
5121
5677
  enumerable: true,
5122
5678
  get: function() {
5123
5679
  return backendsOf;
5124
5680
  }
5125
5681
  });
5682
+ Object.defineProperty(exports, "backupDatabases", {
5683
+ enumerable: true,
5684
+ get: function() {
5685
+ return backupDatabases;
5686
+ }
5687
+ });
5688
+ Object.defineProperty(exports, "backupExpiries", {
5689
+ enumerable: true,
5690
+ get: function() {
5691
+ return backupExpiries;
5692
+ }
5693
+ });
5694
+ Object.defineProperty(exports, "backupFile", {
5695
+ enumerable: true,
5696
+ get: function() {
5697
+ return backupFile;
5698
+ }
5699
+ });
5700
+ Object.defineProperty(exports, "backupsPrefix", {
5701
+ enumerable: true,
5702
+ get: function() {
5703
+ return backupsPrefix;
5704
+ }
5705
+ });
5706
+ Object.defineProperty(exports, "backupsRoleStatements", {
5707
+ enumerable: true,
5708
+ get: function() {
5709
+ return backupsRoleStatements;
5710
+ }
5711
+ });
5712
+ Object.defineProperty(exports, "backupsService", {
5713
+ enumerable: true,
5714
+ get: function() {
5715
+ return backupsService;
5716
+ }
5717
+ });
5126
5718
  Object.defineProperty(exports, "bucketClient", {
5127
5719
  enumerable: true,
5128
5720
  get: function() {
@@ -5141,6 +5733,12 @@ Object.defineProperty(exports, "bucketPolicies", {
5141
5733
  return bucketPolicies;
5142
5734
  }
5143
5735
  });
5736
+ Object.defineProperty(exports, "clientIpRule", {
5737
+ enumerable: true,
5738
+ get: function() {
5739
+ return clientIpRule;
5740
+ }
5741
+ });
5144
5742
  Object.defineProperty(exports, "composeBuildPaths", {
5145
5743
  enumerable: true,
5146
5744
  get: function() {
@@ -5153,6 +5751,12 @@ Object.defineProperty(exports, "constructGlobs", {
5153
5751
  return constructGlobs;
5154
5752
  }
5155
5753
  });
5754
+ Object.defineProperty(exports, "deploysWithCompose", {
5755
+ enumerable: true,
5756
+ get: function() {
5757
+ return deploysWithCompose;
5758
+ }
5759
+ });
5156
5760
  Object.defineProperty(exports, "derivedContainers", {
5157
5761
  enumerable: true,
5158
5762
  get: function() {
@@ -5321,12 +5925,24 @@ Object.defineProperty(exports, "networkEnv", {
5321
5925
  return networkEnv;
5322
5926
  }
5323
5927
  });
5928
+ Object.defineProperty(exports, "newOriginSecret", {
5929
+ enumerable: true,
5930
+ get: function() {
5931
+ return newOriginSecret;
5932
+ }
5933
+ });
5324
5934
  Object.defineProperty(exports, "offlineBuildHosts", {
5325
5935
  enumerable: true,
5326
5936
  get: function() {
5327
5937
  return offlineBuildHosts;
5328
5938
  }
5329
5939
  });
5940
+ Object.defineProperty(exports, "originSecretKey", {
5941
+ enumerable: true,
5942
+ get: function() {
5943
+ return originSecretKey;
5944
+ }
5945
+ });
5330
5946
  Object.defineProperty(exports, "pgClient", {
5331
5947
  enumerable: true,
5332
5948
  get: function() {
@@ -5351,12 +5967,30 @@ Object.defineProperty(exports, "postgresStatements", {
5351
5967
  return postgresStatements;
5352
5968
  }
5353
5969
  });
5970
+ Object.defineProperty(exports, "processEnv", {
5971
+ enumerable: true,
5972
+ get: function() {
5973
+ return processEnv;
5974
+ }
5975
+ });
5976
+ Object.defineProperty(exports, "processEnvKeys", {
5977
+ enumerable: true,
5978
+ get: function() {
5979
+ return processEnvKeys;
5980
+ }
5981
+ });
5354
5982
  Object.defineProperty(exports, "processorEnvKeys", {
5355
5983
  enumerable: true,
5356
5984
  get: function() {
5357
5985
  return processorEnvKeys;
5358
5986
  }
5359
5987
  });
5988
+ Object.defineProperty(exports, "processorOriginHost", {
5989
+ enumerable: true,
5990
+ get: function() {
5991
+ return processorOriginHost;
5992
+ }
5993
+ });
5360
5994
  Object.defineProperty(exports, "processorUnitName", {
5361
5995
  enumerable: true,
5362
5996
  get: function() {
@@ -5405,6 +6039,18 @@ Object.defineProperty(exports, "resourceName", {
5405
6039
  return resourceName;
5406
6040
  }
5407
6041
  });
6042
+ Object.defineProperty(exports, "runTime", {
6043
+ enumerable: true,
6044
+ get: function() {
6045
+ return runTime;
6046
+ }
6047
+ });
6048
+ Object.defineProperty(exports, "runsServer", {
6049
+ enumerable: true,
6050
+ get: function() {
6051
+ return runsServer;
6052
+ }
6053
+ });
5408
6054
  Object.defineProperty(exports, "scopeTelemetryEnv", {
5409
6055
  enumerable: true,
5410
6056
  get: function() {
@@ -5423,6 +6069,18 @@ Object.defineProperty(exports, "siteOfflineHosts", {
5423
6069
  return siteOfflineHosts;
5424
6070
  }
5425
6071
  });
6072
+ Object.defineProperty(exports, "stackBackups", {
6073
+ enumerable: true,
6074
+ get: function() {
6075
+ return stackBackups;
6076
+ }
6077
+ });
6078
+ Object.defineProperty(exports, "stageBackups", {
6079
+ enumerable: true,
6080
+ get: function() {
6081
+ return stageBackups;
6082
+ }
6083
+ });
5426
6084
  Object.defineProperty(exports, "stageEnv", {
5427
6085
  enumerable: true,
5428
6086
  get: function() {
@@ -5466,4 +6124,4 @@ Object.defineProperty(exports, "workspace_exports", {
5466
6124
  }
5467
6125
  });
5468
6126
 
5469
- //# sourceMappingURL=apps-BIsxWYUo.cjs.map
6127
+ //# sourceMappingURL=apps-ClZkLcMz.cjs.map