@geekmidas/cli 10.0.0-alpha.170 → 10.0.0-alpha.171
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.
- package/dist/{GoDaddyProvider-DK9_Jw9d.cjs → GoDaddyProvider-Cs32wo6I.cjs} +2 -2
- package/dist/{GoDaddyProvider-DK9_Jw9d.cjs.map → GoDaddyProvider-Cs32wo6I.cjs.map} +1 -1
- package/dist/{GoDaddyProvider-Cf4MIuaD.mjs → GoDaddyProvider-D7CTqN0f.mjs} +2 -2
- package/dist/{GoDaddyProvider-Cf4MIuaD.mjs.map → GoDaddyProvider-D7CTqN0f.mjs.map} +1 -1
- package/dist/{HostingerProvider-CQebZrz3.mjs → HostingerProvider-B_3Qs9mT.mjs} +2 -2
- package/dist/{HostingerProvider-CQebZrz3.mjs.map → HostingerProvider-B_3Qs9mT.mjs.map} +1 -1
- package/dist/{HostingerProvider-qQzo4MYp.cjs → HostingerProvider-D0515Stf.cjs} +2 -2
- package/dist/{HostingerProvider-qQzo4MYp.cjs.map → HostingerProvider-D0515Stf.cjs.map} +1 -1
- package/dist/{LegacyStateStore-BeMRGXRi.cjs → LegacyStateStore-Bv_2L86H.cjs} +2 -2
- package/dist/{LegacyStateStore-BeMRGXRi.cjs.map → LegacyStateStore-Bv_2L86H.cjs.map} +1 -1
- package/dist/{LegacyStateStore-DXPHKdMk.mjs → LegacyStateStore-CUjKKENQ.mjs} +2 -2
- package/dist/{LegacyStateStore-DXPHKdMk.mjs.map → LegacyStateStore-CUjKKENQ.mjs.map} +1 -1
- package/dist/{LocalStateStore-BYQ9lPje.mjs → LocalStateStore-DXuj1BDq.mjs} +2 -2
- package/dist/{LocalStateStore-BYQ9lPje.mjs.map → LocalStateStore-DXuj1BDq.mjs.map} +1 -1
- package/dist/{LocalStateStore-E_sa5GR2.cjs → LocalStateStore-PQ2qJ5VF.cjs} +2 -2
- package/dist/{LocalStateStore-E_sa5GR2.cjs.map → LocalStateStore-PQ2qJ5VF.cjs.map} +1 -1
- package/dist/{S3StateStore-BQaGVNRf.mjs → S3StateStore-BGnOwqUp.mjs} +4 -4
- package/dist/{S3StateStore-BQaGVNRf.mjs.map → S3StateStore-BGnOwqUp.mjs.map} +1 -1
- package/dist/{S3StateStore-Cjr4Rtsf.cjs → S3StateStore-cmS6iUZn.cjs} +4 -4
- package/dist/{S3StateStore-Cjr4Rtsf.cjs.map → S3StateStore-cmS6iUZn.cjs.map} +1 -1
- package/dist/{SSMStateStore-Bq_S7x5_.mjs → SSMStateStore-BqXzPBbu.mjs} +2 -2
- package/dist/{SSMStateStore-Bq_S7x5_.mjs.map → SSMStateStore-BqXzPBbu.mjs.map} +1 -1
- package/dist/{SSMStateStore-Cnfwdlme.cjs → SSMStateStore-BtNGbg8Z.cjs} +2 -2
- package/dist/{SSMStateStore-Cnfwdlme.cjs.map → SSMStateStore-BtNGbg8Z.cjs.map} +1 -1
- package/dist/{add-CNQFnG0C.mjs → add-DW2KLCY0.mjs} +5 -5
- package/dist/{add-CNQFnG0C.mjs.map → add-DW2KLCY0.mjs.map} +1 -1
- package/dist/{add-3_IHpF5F.cjs → add-Dp5xRn-u.cjs} +5 -5
- package/dist/{add-3_IHpF5F.cjs.map → add-Dp5xRn-u.cjs.map} +1 -1
- package/dist/{apps-BGu47YRF.cjs → apps-DYGKg5SP.cjs} +28 -897
- package/dist/apps-DYGKg5SP.cjs.map +1 -0
- package/dist/{apps-DGod3aS9.mjs → apps-DrXwv-0A.mjs} +16 -795
- package/dist/apps-DrXwv-0A.mjs.map +1 -0
- package/dist/{bundler-DWGxNGSB.cjs → bundler-BIfEe05e.cjs} +6 -6
- package/dist/{bundler-DWGxNGSB.cjs.map → bundler-BIfEe05e.cjs.map} +1 -1
- package/dist/{bundler-Dm0mB7EK.mjs → bundler-Swt8wHG9.mjs} +6 -6
- package/dist/{bundler-Dm0mB7EK.mjs.map → bundler-Swt8wHG9.mjs.map} +1 -1
- package/dist/{cli-Qm-8tG46.mjs → cli-C9wdKQy_.mjs} +4 -4
- package/dist/{cli-Qm-8tG46.mjs.map → cli-C9wdKQy_.mjs.map} +1 -1
- package/dist/{cli-CYeZF85I.cjs → cli-ohJToj0E.cjs} +4 -4
- package/dist/{cli-CYeZF85I.cjs.map → cli-ohJToj0E.cjs.map} +1 -1
- package/dist/{compose-CXgwCuqv.mjs → compose-BLOnkeaJ.mjs} +887 -15
- package/dist/compose-BLOnkeaJ.mjs.map +1 -0
- package/dist/{compose-IsvqY6iX.cjs → compose-Br3SQ2bW.cjs} +62 -9
- package/dist/compose-Br3SQ2bW.cjs.map +1 -0
- package/dist/{compose-CshnO-Th.cjs → compose-SNYBstbO.cjs} +1025 -15
- package/dist/compose-SNYBstbO.cjs.map +1 -0
- package/dist/{compose-BVeevJO_.mjs → compose-iUOeazjW.mjs} +61 -8
- package/dist/compose-iUOeazjW.mjs.map +1 -0
- package/dist/{config-u5XdE1Cq.d.cts → config-CsCYzlVO.d.mts} +3 -3
- package/dist/{config-B8gSu59v.d.mts.map → config-CsCYzlVO.d.mts.map} +1 -1
- package/dist/{config-B8gSu59v.d.mts → config-D-gHQXhi.d.cts} +3 -3
- package/dist/{config-u5XdE1Cq.d.cts.map → config-D-gHQXhi.d.cts.map} +1 -1
- package/dist/config.cjs +1 -1
- package/dist/config.d.cts +3 -3
- package/dist/config.d.mts +3 -3
- package/dist/config.mjs +1 -1
- package/dist/{credentials-DzR2j8h1.cjs → credentials-BdZhygvW.cjs} +6 -6
- package/dist/{credentials-DzR2j8h1.cjs.map → credentials-BdZhygvW.cjs.map} +1 -1
- package/dist/{credentials-CKIeLL7T.mjs → credentials-C2VfI-uf.mjs} +6 -6
- package/dist/{credentials-CKIeLL7T.mjs.map → credentials-C2VfI-uf.mjs.map} +1 -1
- package/dist/deploy/public.cjs +11 -11
- package/dist/deploy/public.d.cts +4 -4
- package/dist/deploy/public.d.mts +4 -4
- package/dist/deploy/public.mjs +11 -11
- package/dist/{deploy-DQjEjUfB.cjs → deploy-CYyf-Q8N.cjs} +24 -26
- package/dist/deploy-CYyf-Q8N.cjs.map +1 -0
- package/dist/{deploy-CjubyZlP.mjs → deploy-DqH8QReb.mjs} +23 -25
- package/dist/deploy-DqH8QReb.mjs.map +1 -0
- package/dist/{destroy-D4m5aO9k.mjs → destroy-B9myEYFT.mjs} +9 -9
- package/dist/{destroy-D4m5aO9k.mjs.map → destroy-B9myEYFT.mjs.map} +1 -1
- package/dist/{destroy-D1375m8C.cjs → destroy-Bp5iHtLf.cjs} +9 -9
- package/dist/{destroy-D1375m8C.cjs.map → destroy-Bp5iHtLf.cjs.map} +1 -1
- package/dist/{docker-CSEAKwFr.cjs → docker-BezTRGxN.cjs} +9 -9
- package/dist/{docker-CSEAKwFr.cjs.map → docker-BezTRGxN.cjs.map} +1 -1
- package/dist/{docker-C27YUUMQ.mjs → docker-De_-Ll-A.mjs} +5 -5
- package/dist/{docker-C27YUUMQ.mjs.map → docker-De_-Ll-A.mjs.map} +1 -1
- package/dist/{dokploy-DJDdiFz6.cjs → dokploy-CWCIqro_.cjs} +2 -2
- package/dist/{dokploy-DJDdiFz6.cjs.map → dokploy-CWCIqro_.cjs.map} +1 -1
- package/dist/{dokploy-CSqDsvY-.mjs → dokploy-EsBgWO8W.mjs} +2 -2
- package/dist/{dokploy-CSqDsvY-.mjs.map → dokploy-EsBgWO8W.mjs.map} +1 -1
- package/dist/{eas-DryGYjFk.cjs → eas-8t6PJRni.cjs} +3 -3
- package/dist/{eas-DryGYjFk.cjs.map → eas-8t6PJRni.cjs.map} +1 -1
- package/dist/{eas-DC3F8cy0.mjs → eas-BalvsiH5.mjs} +3 -3
- package/dist/{eas-DC3F8cy0.mjs.map → eas-BalvsiH5.mjs.map} +1 -1
- package/dist/{encryption-C8Y8Ly6n.mjs → encryption-B4mWxt4G.mjs} +3 -3
- package/dist/{encryption-C8Y8Ly6n.mjs.map → encryption-B4mWxt4G.mjs.map} +1 -1
- package/dist/{encryption-8qZGm15p.cjs → encryption-CKBmU66R.cjs} +3 -3
- package/dist/{encryption-8qZGm15p.cjs.map → encryption-CKBmU66R.cjs.map} +1 -1
- package/dist/{engine-DI7JAyiD.cjs → engine-BTG46RG-.cjs} +19 -19
- package/dist/{engine-DI7JAyiD.cjs.map → engine-BTG46RG-.cjs.map} +1 -1
- package/dist/{engine-C9E0MeLm.mjs → engine-y8iWIXuv.mjs} +9 -9
- package/dist/{engine-C9E0MeLm.mjs.map → engine-y8iWIXuv.mjs.map} +1 -1
- package/dist/{github-g3nRZlli.cjs → github-CeXlzWWA.cjs} +7 -7
- package/dist/{github-g3nRZlli.cjs.map → github-CeXlzWWA.cjs.map} +1 -1
- package/dist/{github-DdaV-Gll.mjs → github-DvGoKoQO.mjs} +7 -7
- package/dist/{github-DdaV-Gll.mjs.map → github-DvGoKoQO.mjs.map} +1 -1
- package/dist/{googlePlay-BHJ_iThq.cjs → googlePlay-CfzG7jOJ.cjs} +4 -4
- package/dist/{googlePlay-BHJ_iThq.cjs.map → googlePlay-CfzG7jOJ.cjs.map} +1 -1
- package/dist/{googlePlay-BmeR1kY4.mjs → googlePlay-DWv6CUgM.mjs} +4 -4
- package/dist/{googlePlay-BmeR1kY4.mjs.map → googlePlay-DWv6CUgM.mjs.map} +1 -1
- package/dist/{iam-ra1_Y405.mjs → iam-BE0qX5Lb.mjs} +2 -2
- package/dist/{iam-ra1_Y405.mjs.map → iam-BE0qX5Lb.mjs.map} +1 -1
- package/dist/{iam-BoYPPNdM.cjs → iam-FA95ku7l.cjs} +2 -2
- package/dist/{iam-BoYPPNdM.cjs.map → iam-FA95ku7l.cjs.map} +1 -1
- package/dist/{index-DFZ0SMwN.d.mts → index-QxGYzGEN.d.mts} +2 -2
- package/dist/{index-1H93w_H6.d.cts.map → index-QxGYzGEN.d.mts.map} +1 -1
- package/dist/{index-1H93w_H6.d.cts → index-tFzoro1V.d.cts} +2 -2
- package/dist/{index-DFZ0SMwN.d.mts.map → index-tFzoro1V.d.cts.map} +1 -1
- package/dist/index.cjs +72 -72
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +63 -63
- package/dist/index.mjs.map +1 -1
- package/dist/{local-Bkv-e8uM.mjs → local-CvRvfktv.mjs} +2 -2
- package/dist/{local-Bkv-e8uM.mjs.map → local-CvRvfktv.mjs.map} +1 -1
- package/dist/{local-DTidpa-a.cjs → local-DH9at_0c.cjs} +2 -2
- package/dist/{local-DTidpa-a.cjs.map → local-DH9at_0c.cjs.map} +1 -1
- package/dist/{migrate-CXLhrHwu.cjs → migrate-B1lHo2K2.cjs} +5 -5
- package/dist/{migrate-CXLhrHwu.cjs.map → migrate-B1lHo2K2.cjs.map} +1 -1
- package/dist/{migrate-DNOI23QA.mjs → migrate-D1iCmQgc.mjs} +5 -5
- package/dist/{migrate-DNOI23QA.mjs.map → migrate-D1iCmQgc.mjs.map} +1 -1
- package/dist/{migrate-DU4MtKxz.cjs → migrate-DzOWCnRR.cjs} +3 -3
- package/dist/{migrate-DU4MtKxz.cjs.map → migrate-DzOWCnRR.cjs.map} +1 -1
- package/dist/{migrate-BZRsJwni.mjs → migrate-NmW2Su8s.mjs} +3 -3
- package/dist/{migrate-BZRsJwni.mjs.map → migrate-NmW2Su8s.mjs.map} +1 -1
- package/dist/{notes-1TM_Vzi7.mjs → notes-BdIY7IoB.mjs} +4 -3
- package/dist/notes-BdIY7IoB.mjs.map +1 -0
- package/dist/{notes-BpaXOAkA.cjs → notes-ikElBCC8.cjs} +4 -3
- package/dist/{notes-1TM_Vzi7.mjs.map → notes-ikElBCC8.cjs.map} +1 -1
- package/dist/openapi.cjs +1 -1
- package/dist/openapi.d.cts +1 -1
- package/dist/openapi.d.mts +1 -1
- package/dist/openapi.mjs +1 -1
- package/dist/{projectBucket-BRgsSv2P.mjs → projectBucket-C-FOIic4.mjs} +2 -2
- package/dist/{projectBucket-BRgsSv2P.mjs.map → projectBucket-C-FOIic4.mjs.map} +1 -1
- package/dist/{projectBucket-DbEWuLGX.cjs → projectBucket-uidxz03Q.cjs} +2 -2
- package/dist/{projectBucket-DbEWuLGX.cjs.map → projectBucket-uidxz03Q.cjs.map} +1 -1
- package/dist/{publish-DjFgxu2v.mjs → publish-Ujng6o63.mjs} +2 -2
- package/dist/{publish-DjFgxu2v.mjs.map → publish-Ujng6o63.mjs.map} +1 -1
- package/dist/{publish-BN1l3tPF.cjs → publish-oO_8elIf.cjs} +2 -2
- package/dist/{publish-BN1l3tPF.cjs.map → publish-oO_8elIf.cjs.map} +1 -1
- package/dist/reconcile/public.d.cts +1 -1
- package/dist/reconcile/public.d.mts +1 -1
- package/dist/{resolve-BHVyg4Hg.cjs → resolve-CTb1gsTO.cjs} +4 -4
- package/dist/{resolve-BHVyg4Hg.cjs.map → resolve-CTb1gsTO.cjs.map} +1 -1
- package/dist/{resolve-NEKsqNAw.mjs → resolve-Lk7fd8Kb.mjs} +4 -4
- package/dist/{resolve-NEKsqNAw.mjs.map → resolve-Lk7fd8Kb.mjs.map} +1 -1
- package/dist/{rollback-BVgyLE7B.mjs → rollback-B2DhSX-I.mjs} +6 -6
- package/dist/{rollback-BVgyLE7B.mjs.map → rollback-B2DhSX-I.mjs.map} +1 -1
- package/dist/{rollback-CUjvOIDE.cjs → rollback-PK4pSOLd.cjs} +6 -6
- package/dist/{rollback-CUjvOIDE.cjs.map → rollback-PK4pSOLd.cjs.map} +1 -1
- package/dist/{runtime-CKOkIrw0.d.cts → runtime-BpGIXfYr.d.mts} +2 -2
- package/dist/{runtime-CKOkIrw0.d.cts.map → runtime-BpGIXfYr.d.mts.map} +1 -1
- package/dist/{runtime-Cdvv8SfU.d.mts → runtime-DLV0CNZ4.d.cts} +2 -2
- package/dist/{runtime-Cdvv8SfU.d.mts.map → runtime-DLV0CNZ4.d.cts.map} +1 -1
- package/dist/{s3-BO4yr61G.mjs → s3-BY5ry__M.mjs} +3 -3
- package/dist/{s3-BO4yr61G.mjs.map → s3-BY5ry__M.mjs.map} +1 -1
- package/dist/{s3-DnPbDfQN.cjs → s3-FG9qIgEB.cjs} +3 -3
- package/dist/{s3-DnPbDfQN.cjs.map → s3-FG9qIgEB.cjs.map} +1 -1
- package/dist/{serverSetup-BxnCM11A.mjs → serverSetup-BL1sHzRr.mjs} +6 -6
- package/dist/{serverSetup-BxnCM11A.mjs.map → serverSetup-BL1sHzRr.mjs.map} +1 -1
- package/dist/{serverSetup-DScJ7tQs.cjs → serverSetup-C7fDKGiN.cjs} +6 -6
- package/dist/{serverSetup-DScJ7tQs.cjs.map → serverSetup-C7fDKGiN.cjs.map} +1 -1
- package/dist/{sniffer-9smKtb86.mjs → sniffer-BvhDRsgI.mjs} +7 -7
- package/dist/{sniffer-9smKtb86.mjs.map → sniffer-BvhDRsgI.mjs.map} +1 -1
- package/dist/{sniffer-DHcxlSJF.cjs → sniffer-DJp9a2Pg.cjs} +7 -7
- package/dist/{sniffer-DHcxlSJF.cjs.map → sniffer-DJp9a2Pg.cjs.map} +1 -1
- package/dist/{snsSubscriptions-CygsiXhb.mjs → snsSubscriptions-7y2XBXde.mjs} +4 -4
- package/dist/{snsSubscriptions-CygsiXhb.mjs.map → snsSubscriptions-7y2XBXde.mjs.map} +1 -1
- package/dist/{snsSubscriptions-B8TYeAM-.cjs → snsSubscriptions-8t1XFvoc.cjs} +4 -4
- package/dist/{snsSubscriptions-B8TYeAM-.cjs.map → snsSubscriptions-8t1XFvoc.cjs.map} +1 -1
- package/dist/{sst-DiHVSku5.cjs → sst-8HZe83-M.cjs} +5 -5
- package/dist/{sst-DiHVSku5.cjs.map → sst-8HZe83-M.cjs.map} +1 -1
- package/dist/{sst-Bgb3WWEl.mjs → sst-CzFd-1om.mjs} +5 -5
- package/dist/{sst-Bgb3WWEl.mjs.map → sst-CzFd-1om.mjs.map} +1 -1
- package/dist/{stack-A3evQgbk.cjs → stack-3tvhk7SU.cjs} +80 -24
- package/dist/stack-3tvhk7SU.cjs.map +1 -0
- package/dist/{stack-Cy2FwO3Z.mjs → stack-j2e8ddGl.mjs} +62 -12
- package/dist/stack-j2e8ddGl.mjs.map +1 -0
- package/dist/{stage-Bm1x9Anp.cjs → stage-DCSJii_y.cjs} +6 -6
- package/dist/{stage-Bm1x9Anp.cjs.map → stage-DCSJii_y.cjs.map} +1 -1
- package/dist/{stage-Dgy08WVL.mjs → stage-DMv-IfSD.mjs} +6 -6
- package/dist/{stage-Dgy08WVL.mjs.map → stage-DMv-IfSD.mjs.map} +1 -1
- package/dist/{stages-COiipV8N.mjs → stages-CCAAe1tP.mjs} +2 -2
- package/dist/{stages-COiipV8N.mjs.map → stages-CCAAe1tP.mjs.map} +1 -1
- package/dist/{stages-BWg3NU3J.cjs → stages-D49CUpBY.cjs} +2 -2
- package/dist/{stages-BWg3NU3J.cjs.map → stages-D49CUpBY.cjs.map} +1 -1
- package/dist/target/public.cjs +1 -1
- package/dist/target/public.d.cts +2 -2
- package/dist/target/public.d.mts +2 -2
- package/dist/target/public.mjs +1 -1
- package/dist/{terminal-BDRxzEZD.cjs → terminal-DIEj2Nap.cjs} +2 -2
- package/dist/{terminal-BDRxzEZD.cjs.map → terminal-DIEj2Nap.cjs.map} +1 -1
- package/dist/{terminal-BRAIvH83.mjs → terminal-VLmWgL_N.mjs} +2 -2
- package/dist/{terminal-BRAIvH83.mjs.map → terminal-VLmWgL_N.mjs.map} +1 -1
- package/dist/{types-DEmuMHsS.d.cts → types-Bj1A1wkS.d.mts} +3 -3
- package/dist/{types-g_S0_RAi.d.mts.map → types-Bj1A1wkS.d.mts.map} +1 -1
- package/dist/{types-g_S0_RAi.d.mts → types-CV4AzwC_.d.cts} +4 -2
- package/dist/{types-DEmuMHsS.d.cts.map → types-CV4AzwC_.d.cts.map} +1 -1
- package/dist/workspace/index.cjs +1 -1
- package/dist/workspace/index.d.cts +2 -2
- package/dist/workspace/index.d.mts +2 -2
- package/dist/workspace/index.mjs +1 -1
- package/dist/{workspace-_aoe8v6u.mjs → workspace-B0PI9k9p.mjs} +28 -5
- package/dist/workspace-B0PI9k9p.mjs.map +1 -0
- package/dist/{workspace-CEpojAus.cjs → workspace-LR9DFjU8.cjs} +39 -4
- package/dist/workspace-LR9DFjU8.cjs.map +1 -0
- package/package.json +15 -15
- package/dist/apps-BGu47YRF.cjs.map +0 -1
- package/dist/apps-DGod3aS9.mjs.map +0 -1
- package/dist/compose-BVeevJO_.mjs.map +0 -1
- package/dist/compose-CXgwCuqv.mjs.map +0 -1
- package/dist/compose-CshnO-Th.cjs.map +0 -1
- package/dist/compose-IsvqY6iX.cjs.map +0 -1
- package/dist/deploy-CjubyZlP.mjs.map +0 -1
- package/dist/deploy-DQjEjUfB.cjs.map +0 -1
- package/dist/notes-BpaXOAkA.cjs.map +0 -1
- package/dist/stack-A3evQgbk.cjs.map +0 -1
- package/dist/stack-Cy2FwO3Z.mjs.map +0 -1
- package/dist/workspace-CEpojAus.cjs.map +0 -1
- package/dist/workspace-_aoe8v6u.mjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compose-SNYBstbO.cjs","names":["GkmError","GkmError","WILDCARD_SUBDOMAIN","getPublicEnvPrefix","GkmError","randomBytes","LOGS_PORT","DEFAULT_POSTGRES_VERSION","LOGS_PORT","kebabCase","HOST_GATEWAY","WILDCARD_SUBDOMAIN","fileServerLabel","CLIENT_IP_HEADER","EDGE_TOKEN_HEADER","createHash","providedKeyFor","TELEMETRY_KEYS","appKey","stageSampleRate","GkmError","hostLabels","DEFAULT_CACHE","holdsEveryCache","providedKeyFor","dependentsOf","publicEnvFor","isPublicDeclaration","imageOriginSources","PUBLIC_PREFIX","IMAGE_ORIGINS_KEY","bucketExpiry","isHostedDeclaration","hostLabels","isWildcardSite","protectedSubdomains","WILDCARD_SUBDOMAIN","appKey","GkmError","GkmError","providedKeyFor","randomBytes","generateKeyring","drawSecret","randomInt","randomBytes","randomBytes","randomInt","getKeystoreDir","join","gkmHome","GkmError","keystoreProject","existsSync","readKey","readFile","decrypt","getOrCreateKey","mkdir","dirname","writeFile","encrypt","stat","rm","resolve","existsSync","createServer","readFile","join","mkdir","writeFile","toEmbeddableSecrets","dirname","loadWorkspaceAppInfo","NotInAnApp","ConfigNotFound","loadWorkspaceConfig","secretsStoreFor","FileSecretsStore","stringify"],"sources":["../src/workspace/rootSite.ts","../src/target/dokploy/domain.ts","../src/compose/logs.ts","../src/reconcile/containers.ts","../src/generators/processorRoute.ts","../src/reconcile/caddyfile.ts","../src/reconcile/emulator.ts","../src/reconcile/objectEvents.ts","../src/telemetry/edges.ts","../src/reconcile/plan.ts","../src/compose/redis.ts","../src/deploy/generated.ts","../src/reconcile/localCredentials.ts","../src/credentials/index.ts","../src/reconcile/compose.ts"],"sourcesContent":["/**\n * Which site the base domain points at — deployed and locally alike.\n *\n * Three rules, in order, and the last one is the point:\n *\n * 1. **One site** — it is the root. Unambiguous, so nothing has to be said.\n * 2. **Named `web`** — the convention wins, because people already rely on it.\n * 3. **Declared `root: true`** — the site says so itself.\n *\n * Anything else throws. It used to take the *first* site it iterated, and that\n * order came from the manifest, which is built in glob traversal order — so two\n * sites with neither named `web` meant renaming a file could move the root\n * domain, silently.\n *\n * One rule for both targets: deployed the root site gets the base domain, and\n * locally it gets the project's bare host behind the edge. Before this was\n * shared, the local edge put every site on a subdomain, so what a developer\n * browsed was not the shape production served.\n *\n * @returns the root site's name, or `undefined` when there are no sites\n * @throws {AmbiguousRootSite} when several sites could be the root and none says it is\n */\n\nimport { GkmError } from '../errors';\nexport function rootSite(\n\tsites: readonly { name: string; root?: boolean }[],\n): string | undefined {\n\tif (sites.length === 0) return undefined;\n\n\t// 1. The only site there is.\n\tif (sites.length === 1) return sites[0]!.name;\n\n\t// 2. The convention.\n\tif (sites.some(({ name }) => name === 'web')) return 'web';\n\n\t// 3. What a site declared about itself.\n\tconst declared = sites.filter(({ root }) => root === true);\n\tif (declared.length === 1) return declared[0]!.name;\n\n\tthrow new AmbiguousRootSite(\n\t\tsites.map(({ name }) => name),\n\t\tdeclared.length > 1,\n\t);\n}\n\n/** Several sites could hold the base domain, and none of them says it does. */\nexport class AmbiguousRootSite extends GkmError {\n\tconstructor(\n\t\treadonly sites: readonly string[],\n\t\treadonly tooMany = false,\n\t) {\n\t\tsuper(\n\t\t\ttooMany\n\t\t\t\t? `More than one site declares \\`root: true\\` — ${sites.join(', ')}. ` +\n\t\t\t\t\t\t`The base domain points at one of them.`\n\t\t\t\t: `${sites.length} sites and nothing says which holds the base ` +\n\t\t\t\t\t\t`domain: ${sites.join(', ')}. Name one of them \\`web\\`, or ` +\n\t\t\t\t\t\t`declare \\`root: true\\` on the one the base domain points at. ` +\n\t\t\t\t\t\t`It used to be whichever the glob reached first, which is not a ` +\n\t\t\t\t\t\t`thing to decide a hostname.`,\n\t\t);\n\t\tthis.name = 'AmbiguousRootSite';\n\t}\n}\n","import { WILDCARD_SUBDOMAIN } from '@geekmidas/manifest';\nimport { GkmError } from '../../errors';\nimport { getPublicEnvPrefix } from '../../workspace/index.js';\nimport { rootSite } from '../../workspace/rootSite.js';\nimport type {\n\tDomainsConfig,\n\tNormalizedAppConfig,\n} from '../../workspace/types.js';\n\n/** A stage was deployed that `domains` gives no domain. */\nexport class NoDomainForStage extends GkmError {\n\tconstructor(readonly stage: string) {\n\t\tsuper(\n\t\t\t`No domain for stage \"${stage}\". Add it to gkm.config.ts: domains: { ${stage}: 'example.com' }.`,\n\t\t);\n\t\tthis.name = 'NoDomainForStage';\n\t}\n}\n\n/**\n * The hostname an app answers on for a stage.\n *\n * 1. An explicit `app.domain` — a string, or one per stage — wins.\n * 2. Otherwise from the stage's base domain in `domains`: the root site\n * answers on the domain itself, and every other app on\n * `{subdomain}.{domain}` — its declaration's `subdomain`, or its own name.\n *\n * @throws {NoDomainForStage} when `domains` names no domain for it\n */\nexport function resolveHost(\n\tappName: string,\n\tapp: NormalizedAppConfig,\n\tstage: string,\n\tdomains: DomainsConfig | undefined,\n\tisMainFrontend: boolean,\n): string {\n\tif (app.domain) {\n\t\tif (typeof app.domain === 'string') {\n\t\t\treturn app.domain;\n\t\t}\n\t\tif (app.domain[stage]) {\n\t\t\treturn app.domain[stage]!;\n\t\t}\n\t}\n\n\tconst baseDomain = domains?.[stage];\n\tif (!baseDomain) throw new NoDomainForStage(stage);\n\n\tif (isMainFrontend) return baseDomain;\n\n\treturn `${app.subdomain ?? appName}.${baseDomain}`;\n}\n\n/**\n * Whether this app is the site the base domain points at — see `rootSite`,\n * which the local edge asks too.\n *\n * @throws {AmbiguousRootSite} when several sites could be the root and none says it is\n */\nexport function isMainFrontendApp(\n\tappName: string,\n\tapp: NormalizedAppConfig,\n\tallApps: Record<string, NormalizedAppConfig>,\n): boolean {\n\t// A wildcard site answers on every subdomain, never on the domain itself.\n\tconst holds = (a: NormalizedAppConfig) =>\n\t\ta.type === 'web' && a.subdomain !== WILDCARD_SUBDOMAIN;\n\tif (!holds(app)) return false;\n\n\tconst sites = Object.entries(allApps)\n\t\t.filter(([, a]) => holds(a))\n\t\t.map(([name, a]) => ({ name, root: a.root }));\n\n\treturn rootSite(sites) === appName;\n}\n\nexport { AmbiguousRootSite } from '../../workspace/rootSite.js';\n\n/**\n * Generate public URL build args for a web/mobile app based on its dependencies.\n *\n * The prefix is chosen by the app's framework (NEXT_PUBLIC_, VITE_,\n * EXPO_PUBLIC_, or none for Remix). Apps without a public prefix get no\n * build args — they should fetch URLs at runtime instead.\n *\n * @param app - The web/mobile app configuration\n * @param deployedUrls - Map of app name to deployed public URL\n * @returns Array of build args like 'NEXT_PUBLIC_API_URL=https://api.example.com'\n */\nexport function generatePublicUrlBuildArgs(\n\tapp: NormalizedAppConfig,\n\tdeployedUrls: Record<string, string>,\n): string[] {\n\tconst prefix = getPublicEnvPrefix(app.framework);\n\tif (!prefix) return [];\n\n\tconst buildArgs: string[] = [];\n\tfor (const dep of app.dependencies) {\n\t\tconst publicUrl = deployedUrls[dep];\n\t\tif (publicUrl) {\n\t\t\tbuildArgs.push(`${prefix}${dep.toUpperCase()}_URL=${publicUrl}`);\n\t\t}\n\t}\n\n\treturn buildArgs;\n}\n\n/**\n * Get public URL arg names from app dependencies.\n *\n * @param app - The web/mobile app configuration\n * @returns Array of arg names like 'NEXT_PUBLIC_API_URL', or [] for frameworks\n * without a public prefix (e.g. Remix).\n */\nexport function getPublicUrlArgNames(app: NormalizedAppConfig): string[] {\n\tconst prefix = getPublicEnvPrefix(app.framework);\n\tif (!prefix) return [];\n\treturn app.dependencies.map((dep) => `${prefix}${dep.toUpperCase()}_URL`);\n}\n","/**\n * The stack's log UI: OpenObserve, run beside the apps as telemetry's\n * self-hosted provider, and every process with a `Telemetry` edge pointed at\n * it.\n *\n * The production server already exports its traces and pino logs over\n * OTLP/HTTP when `OTEL_EXPORTER_OTLP_ENDPOINT` is set. OpenObserve takes OTLP\n * at `/api/<org>/v1/{logs,traces}` with HTTP basic auth, so wiring an app is\n * two variables: the endpoint, `http://openobserve:5080/api/default`, and\n * the header that signs in as the root user.\n *\n * It is reached, by default, through an SSH tunnel: published on 127.0.0.1\n * only, because a port Docker publishes on every interface is opened in the\n * firewall by Docker itself, past ufw's rules. Served publicly, it is a host\n * on the stack's edge — the `Telemetry` construct's label under the stage's\n * domain — that refuses every address not allowed.\n *\n * Pure: the stack decides it, and the phases print and check it.\n */\n\nimport { randomBytes } from 'node:crypto';\nimport { GkmError } from '../errors';\nimport type { StageSecrets } from '../secrets/types.js';\nimport { NoDomainForStage } from '../target/dokploy/domain.js';\nimport { LOGS_PORT, type ResolvedLogs } from './logsConfig.js';\nimport type { StackService } from './stack.js';\n\n/**\n * The image, pinned — unless the `Telemetry` construct names its own. A log\n * store's on-disk format is the thing that must not move under a running\n * stack, so a new version is a change to this line, or to the construct's.\n */\nexport const OPENOBSERVE_IMAGE = 'public.ecr.aws/zinclabs/openobserve:v1.0.4';\n\n/** Its compose service name — the host the apps send to. */\nexport const LOGS_SERVICE = 'openobserve';\n\n/** The organisation every app's telemetry lands in. */\nexport const LOGS_ORG = 'default';\n\n/** The stage secrets that sign in as OpenObserve's root user. */\nexport const LOGS_EMAIL_KEY = 'ZO_ROOT_USER_EMAIL';\nexport const LOGS_PASSWORD_KEY = 'ZO_ROOT_USER_PASSWORD';\n\n/**\n * The local stage's root user. Its password is generated per machine with\n * the other local logins — see `reconcile/localCredentials.ts`.\n */\nexport const LOCAL_LOGS_EMAIL = 'admin@gkm.localhost';\n\n/** The stack's OpenObserve, as the stack runs it. */\nexport interface StackLogs extends ResolvedLogs {\n\t/** The root user's email and password. */\n\temail: string;\n\tpassword: string;\n\t/** Whether the stage's secrets set the password, rather than the local login. */\n\tpasswordFromSecrets: boolean;\n\t/** Where a browser opens it: the tunnel's end, or its public host. */\n\turl: string;\n\t/** Its public host, when it is served through the edge. */\n\thost?: string;\n\t/** The image it runs: the construct's, else {@link OPENOBSERVE_IMAGE}. */\n\timage: string;\n\t/** Its own environment, written to `openobserve.env` (0600). */\n\tenv: Record<string, string>;\n\t/** Where every process with a `Telemetry` edge sends, and how it signs. */\n\tappEnv: {\n\t\tOTEL_EXPORTER_OTLP_ENDPOINT: string;\n\t\tOTEL_EXPORTER_OTLP_HEADERS: string;\n\t};\n}\n\n/** A root password OpenObserve would refuse to start with. */\nexport class LogsPasswordWeak extends GkmError {\n\tconstructor(readonly stage: string) {\n\t\tsuper(\n\t\t\t`The stage '${stage}' sets ${LOGS_PASSWORD_KEY}, and OpenObserve refuses ` +\n\t\t\t\t'it: a root password must be 8 to 128 characters with a lowercase ' +\n\t\t\t\t'letter, an uppercase letter, a digit and a symbol. Set another with ' +\n\t\t\t\t`gkm secrets:set ${LOGS_PASSWORD_KEY} '…' --stage ${stage}, or unset ` +\n\t\t\t\t'it to have one generated.',\n\t\t);\n\t\tthis.name = 'LogsPasswordWeak';\n\t}\n}\n\n/**\n * The loopback port a stage's OpenObserve is published on is held by another\n * stack on its server — two stages on one machine, both on `5080`.\n */\nexport class LogsPortTaken extends GkmError {\n\tconstructor(\n\t\treadonly stage: string,\n\t\treadonly port: number,\n\t\t/** Who holds it: a compose project, else the container's name. */\n\t\treadonly holder: string,\n\t\t/** Whether the stage named the port, or no free one was found. */\n\t\treadonly named: boolean,\n\t) {\n\t\tsuper(\n\t\t\tnamed\n\t\t\t\t? `deploy.telemetry.${stage}.port is ${port}, and '${holder}' already ` +\n\t\t\t\t\t\t`publishes ${port} on this server. Give the stage another: ` +\n\t\t\t\t\t\t`deploy.telemetry.${stage}.port = ${port + 1}, or remove port to ` +\n\t\t\t\t\t\t'have a free one picked.'\n\t\t\t\t: `No loopback port from ${port} up is free for the stage '${stage}'s ` +\n\t\t\t\t\t\t`OpenObserve on this server ('${holder}' holds the last one tried). ` +\n\t\t\t\t\t\t`Set one: deploy.telemetry.${stage}.port = <free port>.`,\n\t\t);\n\t\tthis.name = 'LogsPortTaken';\n\t}\n}\n\n/** A deployed stage with logs on and no root password generated yet. */\nexport class LogsPasswordMissing extends GkmError {\n\tconstructor(readonly stage: string) {\n\t\tsuper(\n\t\t\t`The stage '${stage}' runs OpenObserve and has no ${LOGS_PASSWORD_KEY} ` +\n\t\t\t\t`in its secrets. Run gkm compose --stage ${stage} without --dry-run ` +\n\t\t\t\t'once to generate it, or set one: ' +\n\t\t\t\t`gkm secrets:set ${LOGS_PASSWORD_KEY} '…' --stage ${stage}`,\n\t\t);\n\t\tthis.name = 'LogsPasswordMissing';\n\t}\n}\n\n/** Whether OpenObserve accepts `password` for its root user. */\nexport function isStrongLogsPassword(password: string): boolean {\n\treturn (\n\t\tpassword.length >= 8 &&\n\t\tpassword.length <= 128 &&\n\t\t/[a-z]/.test(password) &&\n\t\t/[A-Z]/.test(password) &&\n\t\t/\\d/.test(password) &&\n\t\t/[^A-Za-z0-9]/.test(password)\n\t);\n}\n\n/**\n * A root password: 192 random bits, with a fixed tail so every class\n * OpenObserve requires is present whatever the random part drew.\n */\nexport function generateLogsPassword(): string {\n\treturn `${randomBytes(24).toString('base64url')}-Zo1`;\n}\n\n/**\n * The stage's secrets with a generated root password, where it has none.\n * Pure, like `withGeneratedSecrets`: the caller keeps the result once the\n * run goes ahead.\n */\nexport function withLogsPassword(secrets: StageSecrets): {\n\tsecrets: StageSecrets;\n\tgenerated: string[];\n} {\n\tif (secrets.custom?.[LOGS_PASSWORD_KEY]) return { secrets, generated: [] };\n\treturn {\n\t\tsecrets: {\n\t\t\t...secrets,\n\t\t\tcustom: {\n\t\t\t\t...secrets.custom,\n\t\t\t\t[LOGS_PASSWORD_KEY]: generateLogsPassword(),\n\t\t\t},\n\t\t\tupdatedAt: new Date().toISOString(),\n\t\t},\n\t\tgenerated: [LOGS_PASSWORD_KEY],\n\t};\n}\n\n/**\n * `OTEL_EXPORTER_OTLP_HEADERS` signing in as `email`.\n *\n * The variable's values are percent-decoded by the SDK (they follow the W3C\n * baggage format), so the space after `Basic` is written `%20`. Base64's own\n * `+`, `/` and `=` pass through decoding unchanged.\n */\nexport function otlpHeaders(email: string, password: string): string {\n\tconst token = Buffer.from(`${email}:${password}`).toString('base64');\n\treturn `Authorization=Basic%20${token}`;\n}\n\n/** The stack's OpenObserve for one stage. */\nexport function stackLogs(options: {\n\tconfig: ResolvedLogs;\n\tstage: string;\n\tlocal: boolean;\n\t/** The workspace's name: the local stage's public host is under it. */\n\tproject: string;\n\tdomain?: string;\n\t/** The `Telemetry` construct's label and image — see `stackTelemetry`. */\n\ttelemetry: { label: string; image?: string };\n\tcustom: Readonly<Record<string, string>>;\n\t/** The edge's HTTPS port, which a local public URL carries. */\n\thttps: number;\n\t/** The local stage's generated root login — required for it. */\n\tlocalLogin?: { email: string; password: string };\n}): StackLogs {\n\tconst { config, stage, local, custom } = options;\n\n\tif (!local && !options.domain) throw new NoDomainForStage(stage);\n\n\tconst email =\n\t\tcustom[LOGS_EMAIL_KEY] ??\n\t\t(local\n\t\t\t? (options.localLogin?.email ?? LOCAL_LOGS_EMAIL)\n\t\t\t: `admin@${options.domain}`);\n\tconst set = custom[LOGS_PASSWORD_KEY];\n\tconst password = set ?? (local ? options.localLogin?.password : undefined);\n\tif (!password) throw new LogsPasswordMissing(stage);\n\tif (!isStrongLogsPassword(password)) throw new LogsPasswordWeak(stage);\n\n\tconst { label } = options.telemetry;\n\tconst host = config.public\n\t\t? local\n\t\t\t? `${label}.${options.project}.localhost`\n\t\t\t: `${label}.${options.domain}`\n\t\t: undefined;\n\tconst url = host\n\t\t? `https://${host}${local && options.https !== 443 ? `:${options.https}` : ''}`\n\t\t: loopbackUrl(config.port);\n\n\treturn {\n\t\t...config,\n\t\temail,\n\t\tpassword,\n\t\tpasswordFromSecrets: Boolean(set),\n\t\turl,\n\t\t...(host ? { host } : {}),\n\t\timage: options.telemetry.image ?? OPENOBSERVE_IMAGE,\n\t\tenv: {\n\t\t\t[LOGS_EMAIL_KEY]: email,\n\t\t\t[LOGS_PASSWORD_KEY]: password,\n\t\t\tZO_DATA_DIR: '/data',\n\t\t\t// Verified against the image: days, and it refuses fewer than 3.\n\t\t\tZO_COMPACT_DATA_RETENTION_DAYS: String(config.retentionDays),\n\t\t\t// A self-hosted log store on a stage's box does not report home.\n\t\t\tZO_TELEMETRY: 'false',\n\t\t},\n\t\tappEnv: {\n\t\t\tOTEL_EXPORTER_OTLP_ENDPOINT: `http://${LOGS_SERVICE}:${LOGS_PORT}/api/${LOGS_ORG}`,\n\t\t\tOTEL_EXPORTER_OTLP_HEADERS: otlpHeaders(email, password),\n\t\t},\n\t};\n}\n\n/** Where a browser opens a loopback-published OpenObserve: the tunnel's end. */\nfunction loopbackUrl(port: number): string {\n\treturn `http://localhost:${port}`;\n}\n\n/**\n * The stack's OpenObserve published on another loopback port — the one the\n * server has free for it (`logsPortOnServer`). Served publicly, it publishes\n * none, and is returned as it is.\n */\nexport function logsOnPort(logs: StackLogs, port: number): StackLogs {\n\tif (logs.public || logs.port === port) return logs;\n\treturn { ...logs, port, url: loopbackUrl(port) };\n}\n\n/**\n * What OpenObserve's service publishes: its port on the server's loopback\n * only — Docker opens a port it publishes on every interface in the firewall\n * itself, past ufw — and nothing when it is served through the edge.\n */\nexport function logsPorts(logs: StackLogs): { ports?: string[] } {\n\treturn logs.public ? {} : { ports: [`127.0.0.1:${logs.port}:${LOGS_PORT}`] };\n}\n\n/**\n * OpenObserve's service. The image has no shell, `wget` or `curl`, so its\n * health check is its own binary asking the running server for its status —\n * which exits non-zero when nothing answers on its port.\n */\nexport function logsService(logs: StackLogs): StackService {\n\treturn {\n\t\timage: logs.image,\n\t\trestart: 'unless-stopped',\n\t\tenv_file: [{ path: `./${LOGS_SERVICE}.env`, format: 'raw' }],\n\t\tvolumes: ['openobserve-data:/data'],\n\t\t...logsPorts(logs),\n\t\thealthcheck: {\n\t\t\ttest: ['CMD', '/openobserve', 'node', 'status'],\n\t\t\tinterval: '10s',\n\t\t\ttimeout: '5s',\n\t\t\tretries: 12,\n\t\t\tstart_period: '20s',\n\t\t},\n\t};\n}\n\n/** Where to guess the stack is reached from, for the printed tunnel. */\nexport interface LogsAccessContext {\n\tstage: string;\n\tlocal: boolean;\n\t/**\n\t * The SSH target: the stage's server login, or — for the local stage —\n\t * this machine's user and name, the best guess at it.\n\t */\n\tuser: string;\n\thostname: string;\n\t/** Whether `user` and `hostname` are the stage's server, not a guess. */\n\tknown?: boolean;\n}\n\n/** What `gkm compose` prints once the stack is up: how to open the logs. */\nexport function logsAccess(logs: StackLogs, ctx: LogsAccessContext): string[] {\n\tconst login = `login: ${logs.email}, password: ${\n\t\tctx.local && !logs.passwordFromSecrets\n\t\t\t? logs.password\n\t\t\t: `gkm secrets:show --stage ${ctx.stage} --reveal → ${LOGS_PASSWORD_KEY}`\n\t}`;\n\n\tif (logs.public) {\n\t\treturn [\n\t\t\t`📜 Logs (OpenObserve): ${logs.url} (${login})`,\n\t\t\t` answered only for ${logs.public.allow.join(', ')}; every other address gets 403`,\n\t\t];\n\t}\n\n\treturn [\n\t\t`📜 Logs (OpenObserve) on 127.0.0.1:${logs.port} — from your computer:`,\n\t\t// The local stage usually runs where you are; it can run on a box too.\n\t\t...(ctx.local\n\t\t\t? [\n\t\t\t\t\t` on this machine, open http://localhost:${logs.port} directly; from another:`,\n\t\t\t\t]\n\t\t\t: []),\n\t\t` ssh -N -L ${logs.port}:localhost:${logs.port} ${ctx.user}@${ctx.hostname}${ctx.known ? '' : \" (user and host are guesses: this machine's)\"}`,\n\t\t` then open http://localhost:${logs.port} (${login})`,\n\t\t`⚠️ Docker-published ports bypass ufw, so OpenObserve is bound to 127.0.0.1 only — reach it through the tunnel, not by opening the port.`,\n\t];\n}\n","import {\n\tDEFAULT_POSTGRES_VERSION,\n\tkebabCase,\n\ttype PostgresVersion,\n} from '@geekmidas/manifest';\nimport { OPENOBSERVE_IMAGE } from '../compose/logs.js';\nimport { LOGS_PORT } from '../compose/logsConfig.js';\n/**\n * What gkm knows about each container it can derive.\n *\n * Everything provider-specific about the local target lives here: the image, the\n * ports the image listens on, and whether its data is worth keeping. The plan\n * says *which* containers exist and never says any of this, which is the split\n * the design asks for — neutral facts from the declaration, provider detail\n * from here and from config.\n *\n * Shared by allocation and by the compose writer so the two cannot disagree\n * about how many ports a container needs.\n */\n\n/**\n * The Postgres image for a major version.\n *\n * One place that knows the tag shape, so a declared version reaches the\n * container without anyone restating `-alpine` beside it.\n */\nexport function postgresImage(version: PostgresVersion): string {\n\treturn `postgres:${version}-alpine`;\n}\n\n/**\n * The default image for each container.\n *\n * Pinned to a major rather than `latest` where the image publishes one, so a\n * rebuild does not silently move a developer's Postgres a version. A database\n * can name its own (`image: 'postgis/postgis:…'`); any other pin is the\n * project's own `docker-compose.yml`.\n */\nexport const DEFAULT_IMAGES: Readonly<Record<string, string>> = {\n\tpostgres: postgresImage(DEFAULT_POSTGRES_VERSION),\n\tminio: 'pgsty/minio:RELEASE.2026-08-04T00-00-00Z',\n\tmailpit: 'axllent/mailpit:latest',\n\tredis: 'redis:8-alpine',\n\t'redis-http': 'hiett/serverless-redis-http:latest',\n\trabbitmq: 'rabbitmq:4-management-alpine',\n\t// Pinned: 2.2.0 answers a KMS decrypt under the wrong encryption context\n\t// with UnknownError instead of InvalidCiphertextException.\n\tlocalstack: 'floci/floci:2.1.0',\n\t// The local edge: TLS with gkm's local CA, and host-based routing onto the\n\t// bucket behind it. Not a CDN — what is missing locally is the *mapping*\n\t// and the certificate, not caching, and a caching proxy would add an\n\t// invalidation story no local stack needs.\n\tcaddy: 'caddy:2-alpine',\n\t// Telemetry's collector and its UI — the image the compose stack runs.\n\topenobserve: OPENOBSERVE_IMAGE,\n};\n\n/** One port an image listens on. */\nexport interface ContainerPort {\n\t/**\n\t * The name this port is allocated and persisted under.\n\t *\n\t * Per port rather than per container so that adding a console port later\n\t * assigns a new one instead of shifting the port the app already connects to.\n\t */\n\tkey: string;\n\t/** The port inside the container, fixed by the image. */\n\tinside: number;\n\t/** What it is for, in the one line `gkm dev` and `gkm setup` print. */\n\tlabel: string;\n\t/** A page a person opens, so it prints as a link rather than an address. */\n\tweb?: true;\n}\n\n/**\n * The ports each container listens on.\n *\n * The first is always the one an app connects to; the rest are consoles and\n * management UIs, published because a bucket or an inbox you can look at is most\n * of why these are real containers rather than stubs.\n */\nconst PORTS: Readonly<Record<string, readonly ContainerPort[]>> = {\n\tpostgres: [{ key: 'postgres', inside: 5432, label: 'postgres' }],\n\tminio: [\n\t\t{ key: 'minio', inside: 9000, label: 'minio api' },\n\t\t{ key: 'minio-console', inside: 9001, label: 'minio console', web: true },\n\t],\n\tmailpit: [\n\t\t{ key: 'mailpit', inside: 1025, label: 'smtp' },\n\t\t{ key: 'mailpit-web', inside: 8025, label: 'mailpit inbox', web: true },\n\t],\n\tredis: [{ key: 'redis', inside: 6379, label: 'redis' }],\n\t'redis-http': [{ key: 'redis-http', inside: 80, label: 'cache' }],\n\trabbitmq: [\n\t\t{ key: 'rabbitmq', inside: 5672, label: 'amqp' },\n\t\t{\n\t\t\tkey: 'rabbitmq-management',\n\t\t\tinside: 15672,\n\t\t\tlabel: 'rabbitmq console',\n\t\t\tweb: true,\n\t\t},\n\t],\n\tlocalstack: [{ key: 'localstack', inside: 4566, label: 'localstack' }],\n\t// One port, and an assigned one rather than 443. The whole point of\n\t// allocation is that two projects run at once, and an edge that insists on\n\t// the privileged port puts that back — at the cost of a port in the URL,\n\t// which no cookie or CORS rule looks at.\n\tcaddy: [{ key: 'caddy', inside: 443, label: 'https edge' }],\n\t// OTLP ingest and the UI on one port.\n\topenobserve: [\n\t\t{ key: 'openobserve', inside: LOGS_PORT, label: 'openobserve', web: true },\n\t],\n};\n\n/**\n * An external API's fake, as the local target runs it.\n *\n * Keyed by its port key, `<id>-fake`, which is also its container's name when\n * it has one — so `primaryPortKey` finds its port with no table to consult.\n * A module fake has no image: gkm serves it, on the port this key is assigned.\n */\nexport interface PlannedFake {\n\t/** The external API it stands in for. */\n\tid: string;\n\t/** The image to run, for a fake the provider publishes. */\n\timage?: string;\n\t/** The port that image listens on inside the container. */\n\tport?: number;\n}\n\n/** The port key — and container name, for an image — of an API's fake. */\nexport function fakeKey(id: string): string {\n\treturn `${kebabCase(id)}-fake`;\n}\n\n/**\n * The ports a container needs published. Empty for one gkm does not know.\n *\n * `fakes` answers for the containers no table can: an external API's fake\n * listens wherever its declaration says.\n */\nexport function portsOf(\n\tcontainer: string,\n\tfakes: Readonly<Record<string, PlannedFake>> = {},\n): readonly ContainerPort[] {\n\tconst fake = fakes[container];\n\tif (fake?.port !== undefined) {\n\t\treturn [{ key: container, inside: fake.port, label: `${fake.id} fake` }];\n\t}\n\n\treturn PORTS[container] ?? [];\n}\n\n/** One published port, as a person reads it. */\nexport interface ServiceAddress {\n\tcontainer: string;\n\tlabel: string;\n\t/** `http://localhost:<port>` for a page, `localhost:<port>` otherwise. */\n\taddress: string;\n}\n\n/**\n * Every port the containers publish — not only the one an app connects to.\n *\n * The consoles and the inbox are most of why these are real containers, and an\n * inbox nobody can find is an inbox nobody opens: a sign-in link gets fished\n * out of `docker ps` instead.\n */\nexport function serviceAddresses(\n\tcontainers: readonly string[],\n\tports: Readonly<Record<string, number>>,\n\tfakes: Readonly<Record<string, PlannedFake>> = {},\n): ServiceAddress[] {\n\treturn containers.flatMap((container) =>\n\t\tportsOf(container, fakes).flatMap((port) => {\n\t\t\tconst assigned = ports[port.key];\n\t\t\tif (assigned === undefined) return [];\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tcontainer,\n\t\t\t\t\tlabel: port.label,\n\t\t\t\t\taddress: port.web\n\t\t\t\t\t\t? `http://localhost:${assigned}`\n\t\t\t\t\t\t: `localhost:${assigned}`,\n\t\t\t\t},\n\t\t\t];\n\t\t}),\n\t);\n}\n\n/** The lines `gkm dev` and `gkm setup` print under the services heading. */\nexport function describeServices(\n\tservices: readonly ServiceAddress[],\n): string[] {\n\tconst width = Math.max(0, ...services.map(({ label }) => label.length));\n\treturn services.map(\n\t\t({ label, address }) => ` ${label.padEnd(width)} ${address}`,\n\t);\n}\n\n/** The key a container's primary port is allocated under. */\nexport function primaryPortKey(container: string): string {\n\treturn portsOf(container)[0]?.key ?? container;\n}\n\n/**\n * Every port key a set of containers needs, in a stable order.\n *\n * What allocation is handed: it assigns ports to names and knows nothing about\n * what listens on them.\n */\nexport function portKeys(\n\tcontainers: readonly string[],\n\tfakes: Readonly<Record<string, PlannedFake>> = {},\n): string[] {\n\tconst keys = [...containers]\n\t\t.sort()\n\t\t.flatMap((container) => portsOf(container, fakes).map((port) => port.key));\n\n\t// A module fake runs in no container, and still needs a port to answer on.\n\treturn [...new Set([...keys, ...Object.keys(fakes).sort()])];\n}\n\n/**\n * The named volume a container's data lives in.\n *\n * Mailpit deliberately has none: local mail is disposable, and an inbox that\n * survives days of dev is noise rather than state.\n */\nexport function volumeOf(container: string): string | undefined {\n\tconst volumes: Readonly<Record<string, string>> = {\n\t\tpostgres: 'postgres-data',\n\t\tminio: 'minio-data',\n\t\tredis: 'redis-data',\n\t\trabbitmq: 'rabbitmq-data',\n\t\tlocalstack: 'localstack-data',\n\t\t// Holds the CA it generated. Losing it means a new root on every start,\n\t\t// and a trust store full of dead authorities.\n\t\tcaddy: 'caddy-data',\n\t\topenobserve: 'openobserve-data',\n\t};\n\n\treturn volumes[container];\n}\n","/**\n * Where `gkm dev` serves a file server's processors, on the dev server of the\n * app holding them: named after the file server.\n *\n * One definition for both sides — the dev server mounts it, and the local\n * edge rewrites each processor pattern on the file server's host onto it — so\n * the path the edge sends and the path the server answers cannot drift.\n */\nexport const PROCESSORS_DEV_PREFIX = '/__gkm/processors/';\n\n/** The base a file server's processors answer under, in `gkm dev`. */\nexport function processorsDevRoute(fileServerId: string): string {\n\treturn `${PROCESSORS_DEV_PREFIX}${fileServerId}`;\n}\n","/**\n * The Caddy configuration a plan implies.\n *\n * A file server is a *domain that serves a bucket*, and locally it had neither:\n * `UPLOADS_URL` resolved to MinIO's path-style address, which works and\n * is not the deployed shape. MinIO's own virtual-host mode cannot fix that —\n * it reads the leading label *as the bucket name*, so it produces the right\n * shape only when the server's id and the bucket's happen to agree, and never\n * for a server fronting two buckets.\n *\n * So the mapping lives in front of MinIO instead: one host per file server,\n * rewriting the bucket in as a path prefix. That is the whole of it — no\n * caching, because caching is not what is missing locally, and a caching proxy\n * would add an invalidation story a local stack has no use for.\n *\n * What it buys beyond the shape is a certificate: gkm's local authority\n * (`trust/authority.ts`) issues one for the stage's hosts, which the edge\n * serves the way a deployed edge serves the stage's own, so a local address is\n * `https://` like the deployed one, and\n * everything downstream of that — `Secure` cookies, `SameSite`, a cookie domain\n * with more than one host under it — starts behaving the way it will in\n * production rather than the way `http://localhost` allows.\n *\n * Pure, like `composeFor`: what should exist is data, and rendering it is one\n * line at the edge.\n */\n\nimport {\n\tCLIENT_IP_HEADER,\n\tEDGE_TOKEN_HEADER,\n\tWILDCARD_SUBDOMAIN,\n} from '@geekmidas/manifest';\nimport { processorsDevRoute } from '../generators/processorRoute.js';\nimport { fileServerLabel } from '../workspace/fileServerLabel.js';\nimport type { Plan, PlannedResource } from './plan';\n\n/** One host on the edge, and what answers behind it. */\nexport interface CaddySite {\n\t/** e.g. `api.kitchen-sink.localhost` */\n\thost: string;\n\t/** Where the request is sent, e.g. `http://minio:9000`. */\n\tupstream: string;\n\t/**\n\t * More hosts answered exactly as `host` is — a construct's `aliases`,\n\t * under the project: `rest.kitchen-sink.localhost`.\n\t */\n\taliases?: readonly string[];\n\t/**\n\t * Hosts that answer with a permanent redirect to `host`, path and query\n\t * kept — a site's `redirects`: `www.kitchen-sink.localhost`.\n\t */\n\tredirects?: readonly string[];\n\t/**\n\t * A path to rewrite to, where the upstream expects a different one.\n\t *\n\t * The bucket prefix on an object store is the case. A surface and a site\n\t * want none: they are already serving the paths the client asked for.\n\t */\n\trewrite?: string;\n\t/**\n\t * Path prefixes sent somewhere else on the same host: a file server's\n\t * processor patterns, to the dev server holding them, under the route it\n\t * mounts them on.\n\t */\n\tprocessors?: {\n\t\tprefixes: readonly string[];\n\t\tupstream: string;\n\t\t/** Prepended to the path: `/__gkm/processors/AssetsServer`. */\n\t\tunder: string;\n\t};\n\t/**\n\t * For a wildcard site: what keeps a host that is not a tenant from\n\t * reaching it — the hosts nothing but an app may answer on, refused\n\t * outright, and the route asked about every other host before it is\n\t * served.\n\t */\n\ttenants?: {\n\t\t/** Full hosts — `api.shop.localhost`, `www.shop.localhost`. */\n\t\tprotected: readonly string[];\n\t\t/** Its `hosts` route: `200` serves the host, anything else is returned. */\n\t\thosts?: { upstream: string; uri: string };\n\t};\n}\n\n/**\n * The kinds the edge serves.\n *\n * Everything that owns a *public address*. Deployed, each of these has a real\n * hostname and a certificate, so this is what makes the local shape the same\n * one rather than a near-enough one — and the application is indifferent\n * either way, because it reads whichever address was injected and never\n * composes one.\n *\n * Adding a kind here is the whole of adding it to the edge.\n */\nexport const EDGE_KINDS: Readonly<Record<string, true>> = {\n\t'file-server': true,\n\t'rest-api': true,\n\t// Caddy proxies the upgrade as it is; nothing about the route differs.\n\t'websocket-api': true,\n\tsite: true,\n};\n\n/**\n * How the edge reaches the host, from inside its container.\n *\n * A surface and a site are served by processes `gkm dev` starts on the host,\n * not by containers — so the edge has to leave Docker's network to reach them.\n * Docker Desktop resolves this name already; on Linux the compose definition\n * maps it to the host gateway.\n */\nconst HOST_GATEWAY = 'host.docker.internal';\n\n/** Where the edge's container reads `.gkm/caddy-sites/` — routes and certificates. */\nexport const CADDY_SITES_IN_CONTAINER = '/etc/caddy/sites';\n\n/**\n * The suffix every local host shares.\n *\n * `.localhost` rather than a made-up TLD because it resolves to loopback\n * without touching `/etc/hosts` — macOS and systemd-resolved both answer for\n * subdomains of it.\n */\nexport const LOCAL_TLD = 'localhost';\n\n/**\n * The sites a plan implies, one per file server.\n *\n * The leading label is the *server's* stage-scoped name rather than the\n * bucket's, which is the difference that matters: two servers over one bucket\n * are a legitimate arrangement — two cache behaviours, one origin — and naming\n * the host after the bucket would make them collide.\n */\nexport function sitesFor(\n\tplan: Plan,\n\tproject: string,\n\t/**\n\t * Where surfaces and sites answer on the host, keyed by construct id.\n\t *\n\t * Assigned by whatever starts them rather than published by a container,\n\t * which is why they arrive here instead of being read off a port.\n\t */\n\taddresses: Readonly<Record<string, string>> = {},\n\t/**\n\t * Where each file server's processors answer, keyed by the file server's\n\t * id: the dev server of the app holding them.\n\t */\n\tprocessorAddresses: Readonly<Record<string, string>> = {},\n): CaddySite[] {\n\tconst byId = new Map(plan.resources.map((r) => [r.id, r]));\n\tconst sites: CaddySite[] = [];\n\n\tfor (const resource of plan.resources) {\n\t\tif (!EDGE_KINDS[resource.kind]) continue;\n\n\t\tconst host = hostFor(resource, project);\n\n\t\tif (resource.kind === 'file-server') {\n\t\t\t// The bucket is a prefix on the origin, never part of the address: the\n\t\t\t// client asks for the key it stored.\n\t\t\tconst origin = resource.of ? byId.get(resource.of) : undefined;\n\t\t\tif (!origin) continue;\n\n\t\t\t// Its processors' patterns go to the dev server holding them, once\n\t\t\t// it has an address; everything else is still the bucket.\n\t\t\tconst address = processorAddresses[resource.id];\n\t\t\tconst port = address ? portOf(address) : undefined;\n\t\t\tsites.push({\n\t\t\t\thost,\n\t\t\t\tupstream: 'http://minio:9000',\n\t\t\t\trewrite: `/${origin.name}{uri}`,\n\t\t\t\t...(resource.processors?.length && port\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tprocessors: {\n\t\t\t\t\t\t\t\tprefixes: resource.processors,\n\t\t\t\t\t\t\t\tupstream: `http://${HOST_GATEWAY}:${port}`,\n\t\t\t\t\t\t\t\tunder: processorsDevRoute(resource.id),\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t}\n\t\t\t\t\t: {}),\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\n\t\t// A surface or a site: a process on the host, at an address something\n\t\t// else assigned. Without one there is nothing to route to — which is the\n\t\t// ordinary state before `gkm dev` has decided where things listen.\n\t\tconst address = addresses[resource.id];\n\t\tif (!address) continue;\n\n\t\tconst port = portOf(address);\n\t\tif (!port) continue;\n\n\t\tconst upstream = `http://${HOST_GATEWAY}:${port}`;\n\t\tif (resource.subdomain === WILDCARD_SUBDOMAIN) {\n\t\t\tsites.push({\n\t\t\t\thost,\n\t\t\t\tupstream,\n\t\t\t\ttenants: tenantsOf(resource, host, addresses),\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst { aliases, redirects } = hostsFor(resource, project);\n\t\tsites.push({\n\t\t\thost,\n\t\t\tupstream,\n\t\t\t...(aliases.length ? { aliases } : {}),\n\t\t\t...(redirects.length ? { redirects } : {}),\n\t\t});\n\t}\n\n\treturn sites;\n}\n\n/**\n * What stands between a wildcard site and a host that is not a tenant.\n *\n * Caddy already prefers a named host to the `*`, so `api.shop.localhost`\n * reaches the API whatever the wildcard says. What it cannot know is the\n * labels nothing is running on: `www`, or an app this stage has not started.\n * Those are refused here, so no slug that a deploy would protect is ever\n * served locally either.\n *\n * The `hosts` route is asked through `forward_auth`, which is a deployed\n * edge's check in miniature: a `2xx` lets the request through, and any other\n * answer — the app's own `404` — is what the browser gets, so a mistyped\n * slug fails here and not first in production. Without an address for the\n * surface serving it there is nothing to ask, and every host is served.\n */\nfunction tenantsOf(\n\tresource: PlannedResource,\n\thost: string,\n\taddresses: Readonly<Record<string, string>>,\n): CaddySite['tenants'] {\n\tconst domain = host.slice(`${WILDCARD_SUBDOMAIN}.`.length);\n\tconst surface = resource.hosts\n\t\t? addresses[resource.hosts.surface]\n\t\t: undefined;\n\tconst port = surface ? portOf(surface) : undefined;\n\n\treturn {\n\t\tprotected: (resource.protectedSubdomains ?? []).map(\n\t\t\t(label) => `${label}.${domain}`,\n\t\t),\n\t\t...(resource.hosts && port\n\t\t\t? {\n\t\t\t\t\thosts: {\n\t\t\t\t\t\tupstream: `http://${HOST_GATEWAY}:${port}`,\n\t\t\t\t\t\turi: `${resource.hosts.path}?domain={host}`,\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t: {}),\n\t};\n}\n\n/** The port a local address answers on, defaulting by scheme. */\nfunction portOf(address: string): string | undefined {\n\ttry {\n\t\tconst { port, protocol } = new URL(address);\n\n\t\treturn port || (protocol === 'https:' ? '443' : '80');\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\n/**\n * Where one file server answers, including the stage its name carries.\n *\n * The project is a label rather than a decoration: it is what keeps two\n * checkouts from answering on one address. Omitted when there is no project to\n * name, because an empty label makes `uploads..localhost` — a host nothing\n * resolves and no certificate can be issued for.\n */\nexport function hostFor(resource: PlannedResource, project: string): string {\n\t// The root site answers on the project's bare host, as it does on the base\n\t// domain deployed; everything else on a subdomain of it. A stage other than\n\t// the local one keeps a label — the stage — because one edge serves every\n\t// stage, and `gkm test` claiming the bare host would take it from `gkm dev`.\n\t// Only under a project: without one, the \"bare host\" is `localhost` itself,\n\t// which is nobody's domain to take.\n\tconst label =\n\t\tresource.root && project ? stageOf(resource) : labelOf(resource);\n\n\t// A wildcard site answers on every label under the stage's own domain —\n\t// `*.shop.localhost`, `*.test.shop.localhost` — so a stage is a label of\n\t// that domain rather than a suffix on the `*`.\n\tif (resource.subdomain === WILDCARD_SUBDOMAIN) {\n\t\treturn [WILDCARD_SUBDOMAIN, stageOf(resource), project, LOCAL_TLD]\n\t\t\t.filter(Boolean)\n\t\t\t.join('.');\n\t}\n\n\treturn [label, project, LOCAL_TLD].filter(Boolean).join('.');\n}\n\n/** Every host a resource answers on: its own, its aliases, its redirects. */\nexport interface ResourceHosts {\n\t/** The canonical one — what its `<ID>_URL` is built on. */\n\thost: string;\n\t/** Answered exactly as `host` is. */\n\taliases: string[];\n\t/** Answered with a permanent redirect to `host`. */\n\tredirects: string[];\n}\n\n/**\n * Where a resource answers, every host of it: {@link hostFor}'s, and each\n * alias and redirect label under the project, carrying the stage as its own\n * label does — `www-test.shop.localhost` for `gkm test`.\n */\nexport function hostsFor(\n\tresource: PlannedResource,\n\tproject: string,\n): ResourceHosts {\n\tconst stage = stageOf(resource);\n\tconst under = (label: string) =>\n\t\t[stage ? `${label}-${stage}` : label, project, LOCAL_TLD]\n\t\t\t.filter(Boolean)\n\t\t\t.join('.');\n\treturn {\n\t\thost: hostFor(resource, project),\n\t\taliases: (resource.aliases ?? []).map(under),\n\t\tredirects: (resource.redirects ?? []).map(under),\n\t};\n}\n\n/**\n * A resource's own label: its `subdomain` where it declared one, and a file\n * server's own name — the label a deploy uses too — with the stage it carries\n * kept, so `gkm test` and `gkm dev` still answer on different hosts.\n */\nfunction labelOf(resource: PlannedResource): string {\n\tconst own =\n\t\tresource.kind === 'file-server'\n\t\t\t? fileServerLabel(resource.id)\n\t\t\t: resource.subdomain;\n\tif (!own) return resource.name;\n\tconst stage = stageOf(resource);\n\treturn stage ? `${own}-${stage}` : own;\n}\n\n/** The stage a resource's name carries, or nothing for the local stage's. */\nfunction stageOf(resource: PlannedResource): string | undefined {\n\tconst base = resource.id.toLowerCase();\n\treturn resource.name === base\n\t\t? undefined\n\t\t: resource.name.slice(base.length + 1);\n}\n\n/**\n * The static root config, which only ever imports.\n *\n * Written once and identical for every stage, because the *sites* are what\n * differ and they live in their own files. That split is not tidiness: one\n * container serves every stage — the same way one Postgres holds `orders` and\n * `orders_test` — so a single Caddyfile would mean `gkm test` deleting the\n * routes `gkm dev` is serving, and each command silently breaking the other.\n */\nexport function caddyfileRoot(): string {\n\treturn `${GENERATED}\n{\n\t# No ACME, no public DNS: each stage's certificate is gkm's, beside its\n\t# routes, and the names are local.\n\tauto_https disable_redirects\n}\n\n# One file per stage, so two stages share this edge the way they already share\n# one Postgres and one MinIO.\nimport ${CADDY_SITES_IN_CONTAINER}/*.caddy\n`;\n}\n\n/**\n * One stage's sites, as the file imported above.\n *\n * `rewrite` rather than a path prefix on the address: the bucket is the\n * origin's business, and the client asks for the key it stored.\n *\n * `header_up Host {upstream_hostport}` matters more than it looks. MinIO routes\n * and signs on the Host header, so forwarding the requested hostname would make\n * it look for a bucket named after the domain.\n */\nexport function toCaddyfile(\n\tsites: readonly CaddySite[],\n\toptions: {\n\t\t/**\n\t\t * The stage's certificate and key, one PEM file, as the edge's\n\t\t * container reads it.\n\t\t */\n\t\tcertificate: string;\n\t\t/** The stack's token: see {@link clientIpRule}. */\n\t\tedgeToken?: string;\n\t\t/**\n\t\t * The port the edge is published on, where it is not 443: what a\n\t\t * redirect to a canonical host keeps.\n\t\t */\n\t\tport?: number;\n\t},\n): string {\n\tif (sites.length === 0) {\n\t\treturn `${GENERATED}\n# No file server is declared in this stage, so it routes nothing.\n`;\n\t}\n\n\tconst port = options.port && options.port !== 443 ? `:${options.port}` : '';\n\tconst blocks = sites.map(\n\t\t({ host, upstream, rewrite, processors, tenants, aliases, redirects }) => {\n\t\t\tconst proxy = `reverse_proxy ${upstream} {${\n\t\t\t\trewrite\n\t\t\t\t\t? `\n\t\trewrite ${rewrite}\n\t\t# MinIO routes and signs on the Host header, so forwarding the requested\n\t\t# hostname would make it look for a bucket named after the domain.\n\t\theader_up Host {upstream_hostport}`\n\t\t\t\t\t: `\n\t\t# The application reads whatever address was injected, so it has to see\n\t\t# the one a caller used — that is what makes a redirect, a cookie domain\n\t\t# and a generated link point back here rather than at the upstream.\n\t\theader_up Host {host}\n\t\theader_up X-Forwarded-Proto {scheme}`\n\t\t\t}\n\t}`;\n\n\t\t\t// Each redirect host, one block: the browser is sent to the\n\t\t\t// canonical host with its path and query, and nothing is proxied.\n\t\t\tconst redirectBlocks = (redirects ?? [])\n\t\t\t\t.map(\n\t\t\t\t\t(from) => `\nhttps://${from} {\n\ttls ${options.certificate} ${options.certificate}\n\n\tredir https://${host}${port}{uri} permanent\n}`,\n\t\t\t\t)\n\t\t\t\t.join('');\n\t\t\tconst names = [host, ...(aliases ?? [])]\n\t\t\t\t.map((name) => `https://${name}`)\n\t\t\t\t.join(', ');\n\n\t\t\treturn `\n${names} {\n\ttls ${options.certificate} ${options.certificate}\n\n${clientIpRule(options.edgeToken)}\n${\n\tprocessors\n\t\t? `\n\t# Its processors' patterns, to the dev server holding them — under the\n\t# route it mounts them on. Answered there, so the bucket below never is.\n\t@processors path ${processors.prefixes.map((prefix) => `${prefix}*`).join(' ')}\n\thandle @processors {\n\t\treverse_proxy ${processors.upstream} {\n\t\t\trewrite ${processors.under}{uri}\n\t\t\theader_up Host {host}\n\t\t}\n\t}\n`\n\t\t: ''\n}${tenants ? tenantBlock(tenants, proxy) : `\t${proxy}`}\n}${redirectBlocks}`;\n\t\t},\n\t);\n\n\treturn `${GENERATED}${blocks.join('\\n')}\\n`;\n}\n\n/**\n * A wildcard site's routes: a protected host refused, every other host asked\n * about before it is proxied. `handle` blocks rather than bare directives,\n * because Caddy orders directives itself and would proxy before it refused.\n */\nfunction tenantBlock(\n\ttenants: NonNullable<CaddySite['tenants']>,\n\tproxy: string,\n): string {\n\tconst refused = tenants.protected.length\n\t\t? `\n\t# Labels an app answers on, or that the workspace protects: never a\n\t# tenant's, whether or not anything is running on them.\n\t@protected host ${tenants.protected.join(' ')}\n\thandle @protected {\n\t\trespond 404\n\t}\n`\n\t\t: '';\n\tconst check = tenants.hosts\n\t\t? `\n\t\t# Which hosts are tenants is the app's to say: its \\`hosts\\` route\n\t\t# answers 200 to serve this one, and anything else goes back as is.\n\t\tforward_auth ${tenants.hosts.upstream} {\n\t\t\turi ${tenants.hosts.uri}\n\t\t}\n`\n\t\t: '';\n\n\treturn `${refused}\n\thandle {${check}\n\t\t${proxy.replaceAll('\\n', '\\n\\t')}\n\t}`;\n}\n\nconst GENERATED = `# Generated by gkm from the construct manifest — do not edit.\n#\n# One host per declared file server, in front of the object store that holds its\n# objects. This is the shape a file server has deployed — a domain serving a\n# bucket — which MinIO alone cannot produce: its virtual-host mode reads the\n# leading label as the bucket name.\n#\n# Certificates come from gkm's local CA. \"gkm dev\" and \"gkm test\" point Node at\n# its root, so nothing has to be installed to use these URLs from code; a\n# browser needs the root trusted once (\"gkm trust\").\n`;\n\n/**\n * The lines every site block of an edge opens with, for gkm's own\n * `x-gkm-client-ip` — the client address the auth server rate-limits by.\n *\n * Only a service of this stack may send it. One that calls a sibling at its\n * public address comes through this edge, and proves where it comes from with\n * the stack's token (`x-gkm-edge-token`), derived from the stage's seed and\n * handed to every process of the stack — never to a browser. A request\n * without it has the header removed, so nobody outside can choose the address\n * they are rate-limited by. Without a token, it is removed from every request.\n */\nexport function clientIpRule(edgeToken: string | undefined): string {\n\tif (!edgeToken) {\n\t\treturn `\n\t# gkm's own header, which only a service of this stack may send: the auth\n\t# server rate-limits by the client address it carries.\n\trequest_header -${CLIENT_IP_HEADER}`;\n\t}\n\treturn `\n\t# gkm's own header, which only a service of this stack may send — proven by\n\t# the stack's token: the auth server rate-limits by the client address it\n\t# carries. Removed from every other request.\n\t@gkm_outside not header ${EDGE_TOKEN_HEADER} ${edgeToken}\n\trequest_header @gkm_outside -${CLIENT_IP_HEADER}`;\n}\n","/**\n * The AWS emulator (floci, LocalStack-compatible) the `sns` backend runs on\n * locally — the facts the compose file, the env writer and the applier must\n * agree on.\n *\n * The emulator has one account and answers with deterministic ARNs and queue\n * URLs, which is what lets a connection string be composed before the topic\n * or queue it names has been created.\n */\n\n/** The emulator's single account. */\nexport const EMULATOR_ACCOUNT = '000000000000';\n\nexport const EMULATOR_REGION = 'us-east-1';\n\n/**\n * The emulator's access key id. The `LSIA` prefix is what LocalStack required\n * on issued keys, and LocalStack reads the account from the id — so it is\n * fixed, where the secret key beside it is generated per machine (see\n * `localCredentials.ts`). Floci does not care; keeping it means a project\n * that pins the old image still works.\n */\nexport const EMULATOR_ACCESS_KEY_ID = 'LSIAQAAAAAAVNCBMPNSG';\n\n/** The emulator's address from the host, on the port it was published on. */\nexport function emulatorEndpoint(port: number): string {\n\treturn `http://localhost:${port}`;\n}\n\nexport function emulatorTopicArn(name: string): string {\n\treturn `arn:aws:sns:${EMULATOR_REGION}:${EMULATOR_ACCOUNT}:${name}`;\n}\n\nexport function emulatorQueueUrl(name: string, port: number): string {\n\treturn `${emulatorEndpoint(port)}/${EMULATOR_ACCOUNT}/${name}`;\n}\n","/**\n * A bucket's object events, where the bucket is a local MinIO.\n *\n * S3 publishes a bucket's events to a topic the deploy creates; MinIO has no\n * topic to publish to, but it can post each event to a webhook. So where MinIO\n * holds a watched bucket, it posts the bucket's events to the process that\n * runs the bucket's subscribers, on a route only it can use, and that process\n * relays each one onto the events broker — under the bucket's name, as\n * `object.created` or `object.deleted` — where every subscriber drains a queue\n * of its own, as a topic's subscribers do.\n *\n * Declared to MinIO in two halves, both derived here so they cannot drift:\n *\n * - **a webhook target per bucket**, as container environment: where to post,\n * the token to present, and a queue on disk, because MinIO starts before the\n * process it posts to and must keep what it could not deliver;\n * - **the bucket's notification**, written through the S3 API once the bucket\n * exists: every created and removed object, to that target. Unfiltered —\n * two subscribers watching overlapping prefixes are two rules S3 refuses on\n * one bucket, and each subscriber filters what it is handed anyway.\n */\n\nimport { createHash } from 'node:crypto';\nimport { type ConstructManifest, providedKeyFor } from '@geekmidas/manifest';\nimport type { BoundSubscriber } from './discover.js';\nimport type { BucketNotification } from './provision.js';\n\n/** Where MinIO posts one bucket's events. */\nexport interface ObjectWebhook {\n\t/** The bucket construct, `Uploads`. */\n\tbucket: string;\n\t/** The route on the process that runs the bucket's subscribers. */\n\tendpoint: string;\n\t/** What MinIO presents, and that process checks. */\n\ttoken: string;\n}\n\n/**\n * The token MinIO presents when it posts a bucket's events.\n *\n * Derived, never stored: the container and the process it posts to are handed\n * the same value by the same derivation — with the stage's random seed where a\n * deployed stage's stack has one, so the token is a secret there, and from the\n * project alone locally, where everything it would protect is on loopback.\n * Not salted by the stage: one MinIO serves `gkm dev` and `gkm test`, and a\n * target is declared once per container.\n */\nexport function objectsWebhookToken(\n\tproject: string,\n\tbucket: string,\n\tseed?: string,\n): string {\n\treturn createHash('sha256')\n\t\t.update(`${seed ? `${seed}:` : ''}${project}:objects-webhook:${bucket}`)\n\t\t.digest('base64url')\n\t\t.slice(0, 32);\n}\n\n/**\n * The target's id in MinIO's environment — `MINIO_NOTIFY_WEBHOOK_*_<ID>`.\n *\n * Upper-cased with nothing between words: a canonical id is letters and\n * digits, and an underscore inside the id would read as part of the setting's\n * name.\n */\nexport function minioTargetId(bucket: string): string {\n\treturn bucket.toUpperCase();\n}\n\n/** The target as a notification names it. */\nexport function minioTargetArn(bucket: string): string {\n\treturn `arn:minio:sqs::${minioTargetId(bucket)}:webhook`;\n}\n\n/** How a container reaches a process on the host. */\nexport const HOST_GATEWAY = 'host.docker.internal';\n\n/** Where MinIO keeps what it could not deliver yet, inside its container. */\nconst QUEUE_ROOT = '/gkm-object-events';\n\n/** The id of the notification rule gkm owns on a bucket. */\nexport const NOTIFICATION_RULE_PREFIX = 'gkm-';\n\n/**\n * MinIO's environment for each watched bucket's webhook target.\n *\n * Sorted, so the same buckets always render the same environment and a\n * reconcile that changed nothing does not recreate the container.\n */\nexport function minioWebhookEnv(\n\thooks: readonly ObjectWebhook[],\n): Record<string, string> {\n\tconst env: Record<string, string> = {};\n\tfor (const hook of [...hooks].sort((a, b) =>\n\t\ta.bucket.localeCompare(b.bucket),\n\t)) {\n\t\tconst id = minioTargetId(hook.bucket);\n\t\tenv[`MINIO_NOTIFY_WEBHOOK_ENABLE_${id}`] = 'on';\n\t\tenv[`MINIO_NOTIFY_WEBHOOK_ENDPOINT_${id}`] = hook.endpoint;\n\t\t// Sent as `Authorization: Bearer <token>`.\n\t\tenv[`MINIO_NOTIFY_WEBHOOK_AUTH_TOKEN_${id}`] = hook.token;\n\t\t// MinIO is up before whatever it posts to: what it cannot deliver is\n\t\t// kept here and sent once the route answers.\n\t\tenv[`MINIO_NOTIFY_WEBHOOK_QUEUE_DIR_${id}`] =\n\t\t\t`${QUEUE_ROOT}/${id.toLowerCase()}`;\n\t}\n\treturn env;\n}\n\n/** The rule that sends every created and removed object to the bucket's target. */\nexport function minioNotificationRule(\n\tbucket: string,\n): NonNullable<BucketNotification['QueueConfigurations']>[number] {\n\treturn {\n\t\tId: `${NOTIFICATION_RULE_PREFIX}${bucket}`,\n\t\tQueueArn: minioTargetArn(bucket),\n\t\tEvents: ['s3:ObjectCreated:*', 's3:ObjectRemoved:*'],\n\t};\n}\n\n/**\n * Each watched bucket, and the workers that run one of its subscribers.\n *\n * A bucket is watched when a subscriber reads its events key. MinIO posts a\n * bucket's events to one place, and the relay fans them out to every\n * subscriber whichever worker received them — so one worker per bucket is\n * enough, and the first, by id, is the one chosen, so the choice is stable.\n */\nexport function watchedBuckets(\n\tmanifest: ConstructManifest,\n\tsubscribers: Readonly<Record<string, readonly BoundSubscriber[]>>,\n): Map<string, string> {\n\tconst byKey = new Map<string, string>();\n\tfor (const declaration of Object.values(manifest)) {\n\t\tif (declaration.kind !== 'objects') continue;\n\t\tbyKey.set(\n\t\t\tprovidedKeyFor(\n\t\t\t\tdeclaration.id,\n\t\t\t\tdeclaration.kind,\n\t\t\t\t'eventsConnectionString',\n\t\t\t),\n\t\t\tdeclaration.id,\n\t\t);\n\t}\n\n\tconst watched = new Map<string, string>();\n\tfor (const worker of Object.keys(subscribers).sort()) {\n\t\tfor (const { connectionKey } of subscribers[worker] ?? []) {\n\t\t\tconst bucket = byKey.get(connectionKey);\n\t\t\tif (bucket && !watched.has(bucket)) watched.set(bucket, worker);\n\t\t}\n\t}\n\treturn watched;\n}\n","/**\n * Which processes use a `Telemetry` node — read off the manifest's edges.\n *\n * A process uses telemetry when its own declaration names the node: a\n * surface's `telemetry`, a worker's. A surface's process runs its own\n * endpoints, so a worker's edge never counts for it.\n *\n * A site's edge is recorded and never followed here: a site is handed none of\n * the node's keys (see `PUBLIC.telemetry`).\n */\n\nimport {\n\ttype ConstructManifest,\n\thostLabels,\n\tTELEMETRY_KEYS,\n\ttype TelemetryDeclaration,\n} from '@geekmidas/manifest';\nimport { GkmError } from '../errors.js';\nimport { appKey } from '../workspace/derive.js';\nimport type { StageTelemetryConfig } from '../workspace/types.js';\nimport { stageSampleRate } from './config.js';\n\n/** The `OTEL_*` keys a `Telemetry` node provides. */\nexport const TELEMETRY_ENV_KEYS: readonly string[] = TELEMETRY_KEYS;\n\n/** Whether `key` is one of the keys a `Telemetry` node provides. */\nexport function isTelemetryKey(key: string): boolean {\n\treturn TELEMETRY_ENV_KEYS.includes(key);\n}\n\n/** The node a declaration's `telemetry` edge names, when it names one. */\nfunction nodeOf(\n\tmanifest: ConstructManifest,\n\tid: string | undefined,\n): TelemetryDeclaration | undefined {\n\tif (!id) return undefined;\n\tconst node = manifest[id];\n\treturn node?.kind === 'telemetry' ? node : undefined;\n}\n\n/**\n * The `Telemetry` node the process for `id` — a surface, a worker, or a file\n * server's processor unit, by construct id — emits through, or undefined\n * when it has no edge to one.\n */\nexport function telemetryOf(\n\tmanifest: ConstructManifest,\n\tid: string,\n): TelemetryDeclaration | undefined {\n\tconst declaration = manifest[id];\n\tif (!declaration) return undefined;\n\n\tif (declaration.kind === 'worker' || declaration.kind === 'file-server') {\n\t\treturn nodeOf(manifest, declaration.telemetry);\n\t}\n\tif (declaration.kind !== 'rest-api' && declaration.kind !== 'websocket-api')\n\t\treturn undefined;\n\n\treturn nodeOf(manifest, declaration.telemetry);\n}\n\n/**\n * The `Telemetry` node the app `appName` emits through — its surface's, or\n * undefined for a site, an app without one, or one with no edge.\n */\nexport function appTelemetry(\n\tmanifest: ConstructManifest,\n\tappName: string,\n): TelemetryDeclaration | undefined {\n\tconst id = Object.entries(manifest).find(\n\t\t([id, d]) =>\n\t\t\t(d.kind === 'rest-api' || d.kind === 'websocket-api') &&\n\t\t\tappKey(id) === appName,\n\t)?.[0];\n\treturn id ? telemetryOf(manifest, id) : undefined;\n}\n\n/** Whether any process in the manifest emits through a `Telemetry` node. */\nexport function usesTelemetry(manifest: ConstructManifest): boolean {\n\treturn Object.entries(manifest).some(\n\t\t([id, d]) =>\n\t\t\t(d.kind === 'rest-api' ||\n\t\t\t\td.kind === 'websocket-api' ||\n\t\t\t\td.kind === 'worker' ||\n\t\t\t\td.kind === 'file-server') &&\n\t\t\ttelemetryOf(manifest, id) !== undefined,\n\t);\n}\n\n/**\n * One process's share of the telemetry keys a stage resolved: all of them,\n * named for the process, when it has an edge to the node — and none\n * otherwise.\n *\n * `env` is everything else the process is handed; its `OTEL_*` keys are\n * replaced, never merged, so a process without the edge cannot inherit them.\n */\nexport function scopeTelemetryEnv(\n\tenv: Readonly<Record<string, string>>,\n\toptions: {\n\t\t/** Whether the process has an edge to the node. */\n\t\tuses: boolean;\n\t\t/** The process's name — `OTEL_SERVICE_NAME`. */\n\t\tserviceName: string;\n\t\t/** What the stage resolved for the node, or nothing when it is off. */\n\t\ttelemetry?: Readonly<Record<string, string>>;\n\t},\n): Record<string, string> {\n\tconst scoped = Object.fromEntries(\n\t\tObject.entries(env).filter(([key]) => !isTelemetryKey(key)),\n\t);\n\tif (!options.uses || !options.telemetry) return scoped;\n\n\tconst values = Object.fromEntries(\n\t\tObject.entries(options.telemetry).filter(([key]) => isTelemetryKey(key)),\n\t);\n\tif (!values.OTEL_EXPORTER_OTLP_ENDPOINT) return scoped;\n\treturn {\n\t\t...scoped,\n\t\t...values,\n\t\tOTEL_SERVICE_NAME: options.serviceName,\n\t};\n}\n\n/** Whether the site `siteId` has an edge to a `Telemetry` node. */\nexport function siteUsesTelemetry(\n\tmanifest: ConstructManifest,\n\tsiteId: string,\n): boolean {\n\tconst site = manifest[siteId];\n\treturn (\n\t\tsite?.kind === 'site' && nodeOf(manifest, site.telemetry) !== undefined\n\t);\n}\n\n/**\n * Whether the client of the surface `surfaceId` propagates trace context:\n * when a site that calls it has an edge to a `Telemetry` node. One client\n * serves every site that calls the surface on the host, so one with the\n * edge turns it on; a site's image generates its own, from its own edge.\n */\nexport function surfaceClientTraced(\n\tmanifest: ConstructManifest,\n\tsurfaceId: string,\n): boolean {\n\treturn Object.entries(manifest).some(\n\t\t([id, d]) =>\n\t\t\td.kind === 'site' &&\n\t\t\tsiteUsesTelemetry(manifest, id) &&\n\t\t\td.dependencies.some((edge) => edge.target === surfaceId),\n\t);\n}\n\n/**\n * Whether the site app `appName`'s clients propagate trace context, and at\n * what rate: when the site has an edge to a `Telemetry` construct, at the\n * stage's sample rate — a public value, every trace locally — and not at all\n * for a stage that sends no telemetry.\n */\nexport function siteClientTelemetry(\n\tmanifest: ConstructManifest,\n\tappName: string,\n\tworkspace: {\n\t\tstages: { local: string };\n\t\tdeploy?: { telemetry?: Readonly<Record<string, StageTelemetryConfig>> };\n\t},\n\t/** The stage being built for — the local stage when absent. */\n\tstage?: string,\n): { sampleRate: number } | undefined {\n\tconst id = Object.entries(manifest).find(\n\t\t([id, d]) => d.kind === 'site' && appKey(id) === appName,\n\t)?.[0];\n\tif (!id || !siteUsesTelemetry(manifest, id)) return undefined;\n\tconst sampleRate = stageSampleRate(\n\t\tworkspace.deploy?.telemetry,\n\t\tstage ?? workspace.stages.local,\n\t\t!stage || stage === workspace.stages.local,\n\t);\n\treturn sampleRate === undefined ? undefined : { sampleRate };\n}\n\n/** The label a log UI answers on when the workspace declares no `Telemetry`. */\nconst DEFAULT_TELEMETRY_ID = 'Telemetry';\n\n/**\n * Two `Telemetry` nodes declare different labels or images for the one\n * OpenObserve a stack runs.\n */\nexport class TelemetryNodesDisagree extends GkmError {\n\tconstructor(\n\t\treadonly field: 'subdomain' | 'image',\n\t\treadonly ids: readonly string[],\n\t) {\n\t\tsuper(\n\t\t\t`A stack runs one OpenObserve for every Telemetry node, and ` +\n\t\t\t\t`${ids.join(', ')} give it different ${field === 'subdomain' ? 'labels' : 'images'}. ` +\n\t\t\t\t`Give each the same ${field}${field === 'subdomain' ? ' (each defaults to its id kebab-cased)' : ''}.`,\n\t\t);\n\t\tthis.name = 'TelemetryNodesDisagree';\n\t}\n}\n\n/**\n * The stack's one OpenObserve, as the workspace's `Telemetry` nodes declare\n * it: the label its UI answers on (`hostLabels`: `subdomain`, else the id\n * kebab-cased) and the image it runs, where a node names one.\n *\n * @throws {TelemetryNodesDisagree} when two nodes declare different ones\n */\nexport function stackTelemetry(manifest: ConstructManifest): {\n\tlabel: string;\n\timage?: string;\n} {\n\tconst nodes = Object.values(manifest)\n\t\t.filter((d): d is TelemetryDeclaration => d.kind === 'telemetry')\n\t\t.sort((a, b) => a.id.localeCompare(b.id));\n\tconst labels = [\n\t\t...new Set(\n\t\t\t(nodes.length ? nodes : [{ id: DEFAULT_TELEMETRY_ID }]).map(\n\t\t\t\t(node) => hostLabels(node).primary,\n\t\t\t),\n\t\t),\n\t];\n\tif (labels.length > 1) {\n\t\tthrow new TelemetryNodesDisagree(\n\t\t\t'subdomain',\n\t\t\tnodes.map((node) => node.id),\n\t\t);\n\t}\n\tconst images = [...new Set(nodes.flatMap((node) => node.image ?? []))];\n\tif (images.length > 1) {\n\t\tthrow new TelemetryNodesDisagree(\n\t\t\t'image',\n\t\t\tnodes.filter((node) => node.image).map((node) => node.id),\n\t\t);\n\t}\n\treturn { label: labels[0]!, ...(images[0] ? { image: images[0] } : {}) };\n}\n","/**\n * The reconcile plan — what a manifest wants to exist, for one stage.\n *\n * Pure. Turning the plan into running containers and provisioned resources is\n * the applier's job; deciding *what* should exist is this, so the decisions can\n * be asserted as data rather than by starting Docker.\n *\n * One plan serves every stage. `gkm dev` reconciles `development` and `gkm test`\n * reconciles `test`; they differ only in what the resources are called, never in\n * what infrastructure exists. Roles are cluster-scoped in Postgres while grants\n * are per-object, so one container and one role pair serve both.\n */\n\nimport {\n\tbucketExpiry,\n\ttype ConstructManifest,\n\ttype Declaration,\n\ttype DeclarationKind,\n\tdependentsOf,\n\thostLabels,\n\tIMAGE_ORIGINS_KEY,\n\timageOriginSources,\n\tisHostedDeclaration,\n\tisPublicDeclaration,\n\tisWildcardSite,\n\ttype PostgresVersion,\n\tPUBLIC_PREFIX,\n\tprovidedKeyFor,\n\tpublicEnvFor,\n\ttype SecretFormat,\n\ttype SiteHosts,\n\tWILDCARD_SUBDOMAIN,\n} from '@geekmidas/manifest';\nimport { GkmError } from '../errors';\nimport { usesTelemetry } from '../telemetry/edges.js';\nimport {\n\ttype CacheBackend,\n\tDEFAULT_CACHE,\n\ttype EventsBackend,\n\tholdsEveryCache,\n} from '../types';\nimport { appKey } from '../workspace/derive.js';\nimport { rootSite } from '../workspace/rootSite.js';\nimport { protectedSubdomains } from '../workspace/subdomains.js';\nimport { EDGE_KINDS } from './caddyfile';\nimport { fakeKey, type PlannedFake } from './containers';\nimport type { LocalFake } from './fakes';\n\n/**\n * Which container serves a kind.\n *\n * Derived kinds map to the same container as their parent — a schema tenant\n * lives in its parent's Postgres — so the set is deduplicated rather than\n * counted.\n */\nconst CONTAINERS: Partial<Record<DeclarationKind, string>> = {\n\tdatabase: 'postgres',\n\t'database-reader': 'postgres',\n\t'database-schema': 'postgres',\n\tobjects: 'minio',\n\t// The server is not the bucket. Its own container is the local edge, which\n\t// is what lets it answer on a *host* rather than on a path under MinIO —\n\t// the shape it has deployed, and the one MinIO's virtual-host mode cannot\n\t// produce because that mode reads the leading label as the bucket name.\n\t//\n\t// MinIO still runs: it is implied by the bucket this server is declared\n\t// over, which is a parent it always has.\n\t'file-server': 'caddy',\n\t// Every mail backend speaks SMTP, so locally there is one answer whichever\n\t// one is selected — which is the same reason the declaration has no\n\t// `provider` field.\n\temail: 'mailpit',\n\t// Locally mail is received the way it is sent: into Mailpit, whose\n\t// webhook hands `gkm dev` each message an inbox receives at.\n\tinbox: 'mailpit',\n\t// A WebSocket surface answers on its app's port like a REST one, but its\n\t// publisher is Redis pub/sub: an endpoint in another process reaches a\n\t// socket through it, so it runs wherever the surface is declared.\n\t'websocket-api': 'redis',\n};\n\n/**\n * The container a cache backend needs locally.\n *\n * Each one matches the protocol its deployed form speaks, which is the property\n * worth having: a cache that behaves differently in the two places is worse than\n * a slower one.\n *\n * `db` is deliberately absent, the same way `pgboss` is absent from\n * `EVENT_CONTAINERS`: the cache is a table in a database the manifest already\n * declares, so mapping it here would start a container for a project that needs\n * none.\n */\nconst CACHE_CONTAINERS: Partial<Record<CacheBackend, string>> = {\n\t// The proxy, not the Redis behind it: the client speaks HTTP with a token\n\t// wherever it runs, which is what makes dev and prod the same client.\n\tupstash: 'redis-http',\n\t// The wire protocol, which is what ElastiCache offers — so dev speaks it too.\n\telasticache: 'redis',\n\t// The stack's own Redis: the same container, on the stack's network.\n\tredis: 'redis',\n};\n\n/**\n * Kinds that resolve a value without anything running.\n *\n * A secret is the case: it has no address, so there is nothing to start and\n * nothing to connect to — but it still appears in the plan, because the target\n * still has to resolve it.\n */\nconst CONTAINERLESS: Partial<Record<DeclarationKind, true>> = {\n\tsecret: true,\n\t// A credential has no address either — and unlike a secret it has no value\n\t// this target can derive, because it was issued by somebody else.\n\tcredential: true,\n\t// An encryption key is a value too: a keyring the target derives, the way\n\t// it derives a secret.\n\tencryption: true,\n\t// A surface answers on the app's own port. It is the first kind whose\n\t// address belongs to something gkm starts rather than something Docker does.\n\t'rest-api': true,\n\t// A site is the second: it is served by its own framework's dev server, and\n\t// what the target resolves for it is only where that server answers.\n\tsite: true,\n\t// A mobile app resolves its scheme, which nothing has to be running for.\n\t'mobile-app': true,\n\t// An external API is answered by its fake. A module fake runs in no\n\t// container — gkm serves it — and an image's container is added per API,\n\t// since no kind-wide table can name it.\n\t'external-api': true,\n\t// Telemetry is collected by OpenObserve, which runs only where a process\n\t// uses the node — see `planFor`.\n\ttelemetry: true,\n};\n\n/** The container that collects telemetry locally, and serves its UI. */\nexport const TELEMETRY_CONTAINER = 'openobserve';\n\n/**\n * Containers that cannot run alone.\n *\n * The one case is the cache: `serverless-redis-http` is a proxy and needs the\n * Redis it proxies. Kept here rather than in the compose definition so the plan\n * -- which is what decides what must be running -- still names everything.\n */\nconst REQUIRES: Readonly<Record<string, readonly string[]>> = {\n\t'redis-http': ['redis'],\n};\n\n/**\n * The role each kind's one key plays, where it is not a URL.\n *\n * The twin of `ProvidesByKind` in `@geekmidas/manifest`: that is what a\n * construct declares, this is what the local target resolves, and both derive\n * the key from the same `providedKeyFor` so they cannot disagree.\n */\nconst ROLES: Partial<Record<DeclarationKind, string>> = {\n\tqueue: 'publisherConnectionString',\n\ttopic: 'publisherConnectionString',\n\tcredential: 'credentials',\n\t'mobile-app': 'scheme',\n\tobjects: 'connectionString',\n};\n\n/** The kinds whose container is the events backend's rather than their own. */\nconst EVENT_KINDS: Partial<Record<DeclarationKind, true>> = {\n\tqueue: true,\n\ttopic: true,\n};\n\n/**\n * Which kinds provision something *inside* their container.\n *\n * A database creates a database, a bucket creates a bucket; mail creates\n * nothing — Mailpit accepts whatever is sent to it and has no per-stage object\n * to name. Both still appear in the plan, because both still resolve a URL; the\n * flag is the difference between \"must be running\" and \"must be created\".\n */\nconst PROVISIONS: Partial<Record<DeclarationKind, true>> = {\n\tdatabase: true,\n\t'database-reader': true,\n\t'database-schema': true,\n\tobjects: true,\n\t// Only a cache that lives in a database creates anything — its table. The\n\t// other backends have nothing to create inside the container they use.\n\tcache: true,\n\t// The open patterns become a bucket policy on the origin — real\n\t// enforcement locally, from the same declaration the CDN behaviour comes\n\t// from deployed.\n\t'file-server': true,\n};\n// Queues and topics are absent deliberately: pg-boss creates its own schema and\n// tables on first connect, and a RabbitMQ exchange is declared by the client\n// that binds to it. Both still appear in the plan, because both still resolve a\n// connection string.\n\n/**\n * The container each events backend needs, where it needs one of its own.\n *\n * `pgboss` is deliberately absent rather than mapped to `postgres`: it is a\n * schema tenant in a database the manifest already declares, so mapping it here\n * would start a Postgres for a project that declared no database at all.\n *\n * This one comes from config rather than from a declaration because there are\n * no `topic` or `queue` kinds yet. When they land the mapping moves to\n * {@link CONTAINERS} keyed by kind, and this constant goes with them.\n */\nconst EVENT_CONTAINERS: Partial<Record<EventsBackend, string>> = {\n\tsns: 'localstack',\n\trabbitmq: 'rabbitmq',\n};\n\n/** The backend a project gets when it declares queues or topics and says nothing. */\nexport const DEFAULT_EVENTS: EventsBackend = 'pgboss';\n\n/**\n * How a resource of each kind separates its stage suffix.\n *\n * Postgres identifiers are snake_case and a hyphen would need quoting\n * everywhere; buckets and queues are kebab and disallow underscores in some\n * providers. The suffix is the same word either way.\n */\nconst SEPARATORS: Partial<Record<DeclarationKind, string>> = {\n\tdatabase: '_',\n\t'database-reader': '_',\n\t'database-schema': '_',\n\tobjects: '-',\n};\n\n/** One thing that must exist, and what it is called in this stage. */\nexport interface PlannedResource {\n\t/** The construct's canonical id, e.g. `Orders`. */\n\tid: string;\n\tkind: DeclarationKind;\n\t/** The container that serves it, e.g. `postgres`. Absent for a secret. */\n\tcontainer?: string;\n\t/** The stage-scoped name, e.g. `orders_test`. */\n\tname: string;\n\t/**\n\t * An inbox's addressing and the topic it declared — what the receiver\n\t * routes a message by, and where it announces it.\n\t */\n\tinbox?: {\n\t\taddresses: readonly string[];\n\t\tsubdomains: boolean;\n\t\ttopic: string;\n\t};\n\t/** Mail's local part — its declaration's `from` — joined to the stage's domain. */\n\tfrom?: string;\n\t/** The env key it resolves onto anything depending on it. */\n\tenvKey: string;\n\t/** The parent it derives from, for kinds that provision nothing themselves. */\n\tof?: string;\n\t/**\n\t * Whether anything has to be created inside the container for this.\n\t *\n\t * False for mail: Mailpit takes whatever is sent to it. The applier skips\n\t * these; the env writer still resolves their URL.\n\t */\n\tprovisions: boolean;\n\t/**\n\t * The site the base domain points at, by the rule a deploy uses\n\t * (`rootSite`) — so locally it answers on the project's bare host, the\n\t * shape production serves, rather than a subdomain of it.\n\t */\n\troot?: true;\n\t/**\n\t * The label a surface or site answers on, its declaration's `subdomain` —\n\t * the same one a deploy puts under the stage's domain.\n\t */\n\tsubdomain?: string;\n\t/** More labels it answers on, from `hostLabels` — the same a deploy adds. */\n\taliases?: string[];\n\t/** Labels that redirect to its host, from `hostLabels`. A site's only. */\n\tredirects?: string[];\n\t/** The schema a tenant pins on its roles' `search_path`. */\n\tschema?: string;\n\t/** For a secret: the format it is derived in, as a deploy generates it. */\n\tformat?: SecretFormat;\n\t/** For a cache in a database: the table entries are kept in. */\n\ttable?: string;\n\t/**\n\t * Whether to provision the owner/runtime role split.\n\t *\n\t * `false` is the documented downgrade — both URLs fall back to the cluster's\n\t * master credential — and it is a choice someone made rather than a default\n\t * they got, which is why it is carried through rather than inferred.\n\t */\n\troles?: boolean;\n\t/**\n\t * For a database: the engine major version to run.\n\t *\n\t * Carried like `schema` and `roles` — read off the declaration so the\n\t * container tag and the deployed engine come from one statement. They used\n\t * to come from two, and had drifted a major apart with nothing recording it.\n\t */\n\tversion?: PostgresVersion;\n\t/** For a database: the image it named in place of `postgres:<version>`. */\n\timage?: string;\n\t/**\n\t * For a database: the extensions to create in it, as the master, before\n\t * any migration. In this database alone.\n\t */\n\textensions?: readonly string[];\n\t/**\n\t * For a file server: the paths it serves without a signature.\n\t *\n\t * Carried into the plan because the local target enforces them for real — a\n\t * bucket policy with prefix resources, from the same declaration the CDN\n\t * behaviour comes from deployed. An open path that is open locally and shut\n\t * in production is the bug this avoids.\n\t */\n\topen?: readonly string[];\n\t/**\n\t * For a file server: the literal prefixes its processors answer — `/i/` —\n\t * which the local edge sends to the dev server holding them.\n\t */\n\tprocessors?: readonly string[];\n\t/**\n\t * For a bucket: days kept under each prefix before it deletes them.\n\t *\n\t * Carried for the same reason as `open`: the local MinIO expires them too,\n\t * so a prefix that empties itself in production empties itself here.\n\t */\n\texpire?: Readonly<Record<string, number>>;\n\t/**\n\t * For an external API: the port key its fake answers on, and the\n\t * credentials it accepts — what a local stage is handed in place of the\n\t * provider and the stage's own.\n\t */\n\tfake?: { key: string; credentials: string };\n\t/**\n\t * For a credential: its fake's value, as `<ID>_CREDENTIALS` holds it — what\n\t * a plan made with fakes hands the stage in place of its own.\n\t */\n\tfakeCredentials?: string;\n\t/**\n\t * For an external API with no fake in this plan: the URL it is called at,\n\t * as declared — one string, or one per stage name.\n\t */\n\turl?: string | Readonly<Record<string, string>>;\n\t/**\n\t * For a site: the keys its bundle needs, mapped to the key each value comes\n\t * from — `{ VITE_API_URL: 'API_URL' }`.\n\t *\n\t * One neutral name from the construct and one serialisation per framework.\n\t * The prefix is the whole of what varies, which is why the mapping is a\n\t * rename rather than a second derivation: `API_URL` is resolved once, by the\n\t * same code that resolves it for the server, and a site simply reads it\n\t * under the name its bundler will inline.\n\t */\n\tpublicEnv?: Record<string, string>;\n\t/**\n\t * A site's or app's list of the origins its pages load files from: the\n\t * key it is inlined under, and the keys whose values make it up\n\t * (`imageOriginSources`).\n\t */\n\timageOrigins?: { key: string; sources: string[] };\n\t/** For a mobile app: the scheme it gave, when not the project's name. */\n\tscheme?: string;\n\t/**\n\t * The ids that depend on this one — the graph read backwards.\n\t *\n\t * Carried on surfaces, where it is the whole answer to \"who may call this\":\n\t * CORS origins, trusted origins, and the cookie domain are three readings of\n\t * this one list. And on buckets, where it says whether a surface a mobile\n\t * app calls hands out their links. Resolved to addresses by the target, because the manifest\n\t * knows which constructs call which and only the target knows where any of\n\t * them answer.\n\t */\n\tcallers?: string[];\n\t/**\n\t * For a wildcard site: the labels no tenant may take — every app's own\n\t * and the workspace's `protectedSubdomains` — which it resolves as\n\t * `<ID>_PROTECTED_SUBDOMAINS`, and which an edge never sends to it.\n\t */\n\tprotectedSubdomains?: string[];\n\t/**\n\t * For a wildcard site: the route its edge asks before serving a host,\n\t * `GET <path>?domain=<host>` on `surface` — the declaration's `hosts`.\n\t */\n\thosts?: SiteHosts;\n}\n\nexport interface Plan {\n\tstage: string;\n\t/**\n\t * The events backend this plan was built for.\n\t *\n\t * Carried on the plan rather than passed alongside it, because everything\n\t * downstream that composes a connection string needs it and reading it off\n\t * the plan is what keeps the two from disagreeing.\n\t */\n\tevents: EventsBackend;\n\t/** Where the cache lives, for everything downstream that composes its URL. */\n\tcache: CacheBackend;\n\t/**\n\t * A worker is declared and the broker is pg-boss, so the broker is needed\n\t * whether or not a queue or topic is.\n\t *\n\t * On a server a worker's crons are scheduled through the events broker —\n\t * the app's one pg-boss. Crons are not in the manifest (a worker does not\n\t * list them), so the worker is the signal. pg-boss is a schema in the\n\t * declared database, so this starts nothing and provisions nothing; it only\n\t * means the broker's connection strings are resolved.\n\t */\n\tworkerBroker?: true;\n\t/** Containers to start, deduplicated. */\n\tcontainers: string[];\n\t/**\n\t * Each external API's fake, by its port key — `<id>-fake`. An image fake's\n\t * key is also in `containers`; a module fake's is a port gkm serves on.\n\t */\n\tfakes?: Record<string, PlannedFake>;\n\t/**\n\t * Everything the stage resolves a URL for, parents before children.\n\t *\n\t * Not all of it is provisioned — see `PlannedResource.provisions`.\n\t */\n\tresources: PlannedResource[];\n}\n\n/** What the plan needs that the manifest cannot tell it. */\nexport interface PlanOptions {\n\t/**\n\t * The project's local stage (`stages.local`), whose resources carry no\n\t * suffix. Absent, every stage is suffixed — which is right for a deploy,\n\t * since a deployed stage is never the local one.\n\t */\n\tlocalStage?: string;\n\t/**\n\t * Whether the local edge fronts the addresses this plan resolves.\n\t *\n\t * On by default, because deployed every surface, site and file server has a\n\t * real hostname and a certificate, and the point of the local target is to\n\t * be the same shape rather than a near-enough one. Off falls back to\n\t * `http://localhost:<port>`.\n\t *\n\t * Config rather than declaration for the same reason `cache` is: the\n\t * application reads whichever address was injected and composes none, so it\n\t * cannot tell the difference.\n\t */\n\tedge?: boolean;\n\t/**\n\t * Where a declared cache lives, which decides both the container it needs\n\t * locally and the protocol its URL speaks.\n\t *\n\t * Config rather than declaration, because the same application code caches\n\t * into any of them — the same reason `events` is config.\n\t */\n\tcache?: CacheBackend;\n\t/**\n\t * The events backend, which selects a container of its own for everything\n\t * except pg-boss.\n\t *\n\t * Config rather than declaration only until `topic` and `queue` are kinds —\n\t * see {@link EVENT_CONTAINERS}.\n\t */\n\tevents?: EventsBackend;\n\t/**\n\t * Containers no construct implies — the escape hatch, and the whole of what\n\t * the workspace `services:` block becomes.\n\t *\n\t * A list of exceptions rather than a list you maintain: everything a\n\t * construct implies is already in the plan before this is read.\n\t */\n\textraContainers?: readonly string[];\n\t/**\n\t * Each external API's fake, by id — read from `test/fakes` by `readFakes`,\n\t * since the declaration never names one. An external API without one\n\t * resolves no URL.\n\t */\n\tfakes?: Readonly<Record<string, LocalFake>>;\n\t/**\n\t * Each credential's fake value, by id — read from `test/fakes` by\n\t * `readCredentialFakes`, for a plan made with fakes (`gkm test`,\n\t * `gkm dev --fake`). A credential without one is the stage's own.\n\t */\n\tcredentialFakes?: Readonly<Record<string, string>>;\n\t/**\n\t * The workspace's `protectedSubdomains`: the names, beyond every app's\n\t * own, that a wildcard site's tenants may never take.\n\t */\n\tprotectedSubdomains?: readonly string[];\n}\n\n/**\n * The stage-scoped name for a resource.\n *\n * The local stage carries no suffix, so `gkm dev` keeps using `orders` and a\n * developer's psql history, saved connections, and muscle memory survive a\n * change of stage name. Every other stage is suffixed.\n */\nexport function resourceName(\n\tid: string,\n\tkind: DeclarationKind,\n\tstage: string,\n\t/** The project's local stage, whose names are unsuffixed. */\n\tlocalStage?: string,\n): string {\n\tconst base = id.toLowerCase();\n\tif (stage === localStage) return base;\n\n\treturn `${base}${SEPARATORS[kind] ?? '-'}${stage}`;\n}\n\n/**\n * The container a kind needs, or `undefined` if it needs none.\n *\n * Queues and topics have no container of their own — they live in whichever\n * broker the project selected, which is why the backend is an argument here\n * rather than a second pass that adds containers after the fact.\n */\nexport function containerFor(\n\tkind: DeclarationKind,\n\tevents: EventsBackend = DEFAULT_EVENTS,\n\t// The target-aware choice is made upstream, in `reconcile/workspace.ts`,\n\t// where the workspace knows where it deploys. This fires only for a caller\n\t// that passed nothing at all.\n\tcache: CacheBackend = DEFAULT_CACHE.aws,\n\t/** Whether the declaration named a parent — see the `cache` branch. */\n\tderived = false,\n\t/** Whether the local edge exists — see the `file-server` branch. */\n\tedge = true,\n): string | undefined {\n\tif (EVENT_KINDS[kind]) {\n\t\t// pg-boss is deliberately absent from EVENT_CONTAINERS: it is a schema\n\t\t// tenant in a database the manifest already declares, so its container is\n\t\t// that database's.\n\t\treturn EVENT_CONTAINERS[events] ?? CONTAINERS.database;\n\t}\n\n\t// A file server answers on the edge, which is what gives it a host of its\n\t// own. With the edge off it falls back to the object store that holds its\n\t// objects — a path under MinIO, which works and is not the deployed shape.\n\tif (kind === 'file-server') return edge ? 'caddy' : CONTAINERS.objects;\n\n\t// The same shape: a cache in the database lives in the database's container.\n\tif (kind === 'cache') {\n\t\t// A cache that *named* a database is in it whatever the backend config\n\t\t// says — the declaration is the stronger statement, and config choosing\n\t\t// otherwise would move a cache the app said lives here — except where\n\t\t// the backend holds every cache (the stack's own Redis).\n\t\tif (derived && !holdsEveryCache(cache)) return CONTAINERS.database;\n\n\t\treturn CACHE_CONTAINERS[cache] ?? CONTAINERS.database;\n\t}\n\n\treturn CONTAINERS[kind];\n}\n\n/**\n * Build the plan for a manifest and stage.\n *\n * `order` is the caller's provisioning order — parents before children — which\n * `provisionOrder` produces from the manifest. Passing it in keeps this\n * function free of the traversal and makes the ordering assertable on its own.\n */\nexport function planFor(\n\tmanifest: ConstructManifest,\n\tstage: string,\n\torder: readonly string[],\n\toptions: PlanOptions = {},\n): Plan {\n\tconst containers = new Set<string>();\n\tconst resources: PlannedResource[] = [];\n\tconst fakes: Record<string, PlannedFake> = {};\n\n\tconst events = options.events ?? DEFAULT_EVENTS;\n\tconst cache = options.cache ?? DEFAULT_CACHE.aws;\n\n\tfor (const id of order) {\n\t\tconst declaration: Declaration | undefined = manifest[id];\n\t\tif (!declaration) continue;\n\n\t\tconst local =\n\t\t\tdeclaration.kind === 'external-api' ? options.fakes?.[id] : undefined;\n\t\tconst fake = local && { key: fakeKey(id), ...local };\n\t\tif (fake) {\n\t\t\tfakes[fake.key] = {\n\t\t\t\tid,\n\t\t\t\t...(fake.image ? { image: fake.image, port: fake.port } : {}),\n\t\t\t};\n\t\t}\n\n\t\t// A cache whose backend holds every cache is detached from the database\n\t\t// it was declared from: it has no `of` and no table, so nothing\n\t\t// downstream composes a database URL for it or creates its table.\n\t\tconst detached = declaration.kind === 'cache' && holdsEveryCache(cache);\n\n\t\tconst container = fake?.image\n\t\t\t? fake.key\n\t\t\t: declaration.kind === 'telemetry'\n\t\t\t\t? usesTelemetry(manifest)\n\t\t\t\t\t? TELEMETRY_CONTAINER\n\t\t\t\t\t: undefined\n\t\t\t\t: containerFor(\n\t\t\t\t\t\tdeclaration.kind,\n\t\t\t\t\t\tevents,\n\t\t\t\t\t\tcache,\n\t\t\t\t\t\t'of' in declaration && typeof declaration.of === 'string',\n\t\t\t\t\t\toptions.edge !== false,\n\t\t\t\t\t);\n\t\tif (!container && !CONTAINERLESS[declaration.kind]) continue;\n\n\t\tif (container) {\n\t\t\tcontainers.add(container);\n\t\t\tfor (const required of REQUIRES[container] ?? [])\n\t\t\t\tcontainers.add(required);\n\t\t}\n\n\t\tresources.push({\n\t\t\tid,\n\t\t\tkind: declaration.kind,\n\t\t\t...(container ? { container } : {}),\n\t\t\tname: resourceName(id, declaration.kind, stage, options.localStage),\n\t\t\t// Through the shared derivation: a secret's name *is* its key, and\n\t\t\t// this target and the deploy target must not answer that separately.\n\t\t\tenvKey: providedKeyFor(\n\t\t\t\tid,\n\t\t\t\tdeclaration.kind,\n\t\t\t\tROLES[declaration.kind] ?? 'url',\n\t\t\t),\n\t\t\tprovisions: PROVISIONS[declaration.kind] === true,\n\t\t\t// For surfaces and buckets. A surface's callers are who may call it;\n\t\t\t// a bucket's say whether its links can end up on a phone (`envFor`).\n\t\t\t// Every other kind is reached by a URL that says nothing about who\n\t\t\t// holds it, so a caller list would be a fact with no reader.\n\t\t\t...(declaration.kind === 'rest-api' ||\n\t\t\tdeclaration.kind === 'websocket-api' ||\n\t\t\tdeclaration.kind === 'objects' ||\n\t\t\tdeclaration.kind === 'file-server'\n\t\t\t\t? { callers: dependentsOf(manifest, id) }\n\t\t\t\t: {}),\n\t\t\t...(declaration.kind === 'site'\n\t\t\t\t? { publicEnv: publicEnvFor(declaration, manifest) }\n\t\t\t\t: {}),\n\t\t\t...(isPublicDeclaration(declaration) &&\n\t\t\timageOriginSources(declaration, manifest).length > 0\n\t\t\t\t? {\n\t\t\t\t\t\timageOrigins: {\n\t\t\t\t\t\t\tkey: `${PUBLIC_PREFIX[declaration.variant]}${IMAGE_ORIGINS_KEY}`,\n\t\t\t\t\t\t\tsources: imageOriginSources(declaration, manifest),\n\t\t\t\t\t\t},\n\t\t\t\t\t}\n\t\t\t\t: {}),\n\t\t\t...(declaration.kind === 'mobile-app'\n\t\t\t\t? {\n\t\t\t\t\t\tpublicEnv: publicEnvFor(declaration, manifest),\n\t\t\t\t\t\t...(declaration.scheme ? { scheme: declaration.scheme } : {}),\n\t\t\t\t\t}\n\t\t\t\t: {}),\n\t\t\t...(declaration.kind === 'file-server' && declaration.open?.length\n\t\t\t\t? { open: declaration.open }\n\t\t\t\t: {}),\n\t\t\t...(declaration.kind === 'file-server' && declaration.processors?.length\n\t\t\t\t? {\n\t\t\t\t\t\tprocessors: [\n\t\t\t\t\t\t\t...new Set(declaration.processors.map((p) => p.prefix)),\n\t\t\t\t\t\t].sort(),\n\t\t\t\t\t}\n\t\t\t\t: {}),\n\t\t\t...(declaration.kind === 'email' && declaration.from\n\t\t\t\t? { from: declaration.from }\n\t\t\t\t: {}),\n\t\t\t...(declaration.kind === 'inbox'\n\t\t\t\t? {\n\t\t\t\t\t\tinbox: {\n\t\t\t\t\t\t\taddresses: declaration.addresses,\n\t\t\t\t\t\t\tsubdomains: declaration.subdomains === true,\n\t\t\t\t\t\t\ttopic: declaration.topic,\n\t\t\t\t\t\t},\n\t\t\t\t\t}\n\t\t\t\t: {}),\n\t\t\t...(declaration.kind === 'objects' && bucketExpiry(manifest, id)\n\t\t\t\t? { expire: bucketExpiry(manifest, id) }\n\t\t\t\t: {}),\n\t\t\t...((declaration.kind === 'rest-api' ||\n\t\t\t\tdeclaration.kind === 'websocket-api' ||\n\t\t\t\tdeclaration.kind === 'site') &&\n\t\t\tdeclaration.subdomain\n\t\t\t\t? { subdomain: declaration.subdomain }\n\t\t\t\t: {}),\n\t\t\t...(isHostedDeclaration(declaration) &&\n\t\t\thostLabels(declaration).aliases.length\n\t\t\t\t? { aliases: [...hostLabels(declaration).aliases] }\n\t\t\t\t: {}),\n\t\t\t...(isHostedDeclaration(declaration) &&\n\t\t\thostLabels(declaration).redirects.length\n\t\t\t\t? { redirects: [...hostLabels(declaration).redirects] }\n\t\t\t\t: {}),\n\t\t\t...(isWildcardSite(declaration)\n\t\t\t\t? {\n\t\t\t\t\t\tprotectedSubdomains: protectedSubdomains(\n\t\t\t\t\t\t\tmanifest,\n\t\t\t\t\t\t\toptions.protectedSubdomains,\n\t\t\t\t\t\t),\n\t\t\t\t\t\t...(declaration.hosts ? { hosts: declaration.hosts } : {}),\n\t\t\t\t\t}\n\t\t\t\t: {}),\n\t\t\t...(fake\n\t\t\t\t? { fake: { key: fake.key, credentials: fake.credentials } }\n\t\t\t\t: {}),\n\t\t\t...(declaration.kind === 'external-api' && !fake\n\t\t\t\t? { url: declaration.url }\n\t\t\t\t: {}),\n\t\t\t...(declaration.kind === 'credential' &&\n\t\t\toptions.credentialFakes?.[id] !== undefined\n\t\t\t\t? { fakeCredentials: options.credentialFakes[id] }\n\t\t\t\t: {}),\n\t\t\t...(declaration.kind === 'secret' &&\n\t\t\t(declaration.length !== undefined || declaration.symbols !== undefined)\n\t\t\t\t? {\n\t\t\t\t\t\tformat: {\n\t\t\t\t\t\t\t...(declaration.length !== undefined\n\t\t\t\t\t\t\t\t? { length: declaration.length }\n\t\t\t\t\t\t\t\t: {}),\n\t\t\t\t\t\t\t...(declaration.symbols !== undefined\n\t\t\t\t\t\t\t\t? { symbols: declaration.symbols }\n\t\t\t\t\t\t\t\t: {}),\n\t\t\t\t\t\t},\n\t\t\t\t\t}\n\t\t\t\t: {}),\n\t\t\t...('of' in declaration && !detached ? { of: declaration.of } : {}),\n\t\t\t...('schema' in declaration && declaration.schema\n\t\t\t\t? { schema: declaration.schema }\n\t\t\t\t: {}),\n\t\t\t...('version' in declaration && declaration.version\n\t\t\t\t? { version: declaration.version }\n\t\t\t\t: {}),\n\t\t\t...('image' in declaration && declaration.image\n\t\t\t\t? { image: declaration.image }\n\t\t\t\t: {}),\n\t\t\t...('extensions' in declaration && declaration.extensions?.length\n\t\t\t\t? { extensions: declaration.extensions }\n\t\t\t\t: {}),\n\t\t\t...('roles' in declaration && declaration.roles === false\n\t\t\t\t? { roles: false }\n\t\t\t\t: {}),\n\t\t\t...('table' in declaration && declaration.table && !detached\n\t\t\t\t? { table: declaration.table }\n\t\t\t\t: {}),\n\t\t});\n\t}\n\n\t// The edge serves anything that owns a public address — a surface and a site\n\t// as much as a file server. Added here rather than in `containerFor` because\n\t// those two are containerless in every other sense: nothing runs them in\n\t// Docker, and what the edge does is put a hostname and a certificate in\n\t// front of a process on the host.\n\t//\n\t// `edge: false` opts out, and then every local address is\n\t// `http://localhost:<port>` as before. The application cannot tell: it reads\n\t// whichever address was injected and composes none.\n\tif (\n\t\toptions.edge !== false &&\n\t\tresources.some((r) => EDGE_KINDS[r.kind] === true)\n\t) {\n\t\tcontainers.add('caddy');\n\t}\n\n\tfor (const extra of options.extraContainers ?? []) containers.add(extra);\n\n\t// pg-boss lives in a declared database. Without one there is nothing for it\n\t// to live in, and starting a Postgres to hold only a queue would be the\n\t// container this design refuses to invent.\n\tif (\n\t\tevents === 'pgboss' &&\n\t\tresources.some((r) => EVENT_KINDS[r.kind]) &&\n\t\t!resources.some((r) => r.kind === 'database')\n\t) {\n\t\tthrow new PgBossNeedsDatabase(\n\t\t\tresources.filter((r) => EVENT_KINDS[r.kind]).map((r) => r.id),\n\t\t);\n\t}\n\n\t// A cache the deploy target placed in a database becomes an *edge*, here,\n\t// once.\n\t//\n\t// A server target's `'db'` cache names something that exists in this graph, which\n\t// makes it different in kind from `upstash` or `elasticache`: those name a\n\t// backend nothing declares, while this one names a database sitting right\n\t// there. So it is resolved to `of` — the same field `database.cache()` sets\n\t// — and every reader downstream follows an edge instead of re-deriving the\n\t// answer from a string.\n\t//\n\t// It also turns a silent guess into an error. \"The declared database\" is\n\t// unambiguous with one and arbitrary with two, and picking whichever came\n\t// first would put the cache in a database nobody chose.\n\t//\n\t// A cache that named its parent is untouched: the declaration is the\n\t// stronger statement, and its parent is checked by `assertDerivations`,\n\t// which names the database that is missing rather than reporting that some\n\t// database is.\n\tif (cache === 'db') {\n\t\tconst placeless = resources.filter((r) => r.kind === 'cache' && !r.of);\n\n\t\tif (placeless.length > 0) {\n\t\t\tconst databases = resources.filter((r) => r.kind === 'database');\n\t\t\tconst [only] = databases;\n\n\t\t\t// Starting a Postgres to hold only a cache would be the container this\n\t\t\t// design refuses to invent.\n\t\t\tif (!only) {\n\t\t\t\tthrow new CacheNeedsDatabase(\n\t\t\t\t\tresources.filter((r) => r.kind === 'cache').map((r) => r.id),\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (databases.length > 1) {\n\t\t\t\tthrow new CacheIsAmbiguous(\n\t\t\t\t\tplaceless.map((r) => r.id),\n\t\t\t\t\tdatabases.map((r) => r.id),\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tfor (const resource of placeless) resource.of = only.id;\n\t\t}\n\t}\n\n\t// The site the base domain points at: the same answer a deploy gives, so the\n\t// local edge serves it on the bare host.\n\t// Never a wildcard site, which answers on every subdomain instead.\n\tconst sites = resources.filter(\n\t\t(r) => r.kind === 'site' && r.subdomain !== WILDCARD_SUBDOMAIN,\n\t);\n\tconst root = rootSite(\n\t\tsites.map((r) => {\n\t\t\tconst declared = manifest[r.id];\n\t\t\treturn {\n\t\t\t\tname: appKey(r.id),\n\t\t\t\t...(declared?.kind === 'site' && declared.root ? { root: true } : {}),\n\t\t\t};\n\t\t}),\n\t);\n\tfor (const site of sites) {\n\t\tif (appKey(site.id) === root) site.root = true;\n\t}\n\n\tconst workerBroker =\n\t\tevents === 'pgboss' &&\n\t\tObject.values(manifest).some((d) => d?.kind === 'worker') &&\n\t\tresources.some((r) => r.kind === 'database');\n\n\treturn {\n\t\tstage,\n\t\tevents,\n\t\tcache,\n\t\tcontainers: [...containers],\n\t\tresources,\n\t\t...(Object.keys(fakes).length ? { fakes } : {}),\n\t\t...(workerBroker ? { workerBroker: true as const } : {}),\n\t};\n}\n\n/**\n * Queues or topics were declared with pg-boss and no database to hold them.\n *\n * Not a reconcile failure but a manifest one: the fix is a line of application\n * code either way — declare a database, or select a backend that brings its own\n * broker.\n */\nexport class CacheNeedsDatabase extends GkmError {\n\tconstructor(readonly ids: readonly string[]) {\n\t\tsuper(\n\t\t\t`A cache backed by the database needs a declared database, and none ` +\n\t\t\t\t`was declared, and on this deploy target that is where a cache lives. ` +\n\t\t\t\t`Declare one. Caches affected: ${ids.join(', ')}.`,\n\t\t);\n\t\tthis.name = 'CacheNeedsDatabase';\n\t}\n}\n\n/**\n * A `'db'` cache — a server target's default — in an app that declares more\n * than one database.\n *\n * The target says *a* database and the graph offers several, so there is no\n * answer to give — and the wrong kind of failure would be to pick one, since a\n * cache silently landing in the wrong database is a bug that surfaces as\n * missing rows much later. The fix is a stronger statement in application code:\n * `orders.cache('Sessions')` names the database, which is a fact about the\n * application rather than a deployment choice.\n */\nexport class CacheIsAmbiguous extends GkmError {\n\tconstructor(\n\t\treadonly ids: readonly string[],\n\t\treadonly databases: readonly string[],\n\t) {\n\t\tsuper(\n\t\t\t`A cache backed by the database needs to know which one, and this app ` +\n\t\t\t\t`declares ${databases.length}: ${databases.join(', ')}. Declare the ` +\n\t\t\t\t`cache from its database — e.g. ${databases[0]}.cache('Sessions') — ` +\n\t\t\t\t`rather than as a bare new Cache(). Caches affected: ${ids.join(', ')}.`,\n\t\t);\n\t\tthis.name = 'CacheIsAmbiguous';\n\t}\n}\n\nexport class PgBossNeedsDatabase extends GkmError {\n\tconstructor(readonly ids: readonly string[]) {\n\t\tsuper(\n\t\t\t`pg-boss keeps its queues in a declared database, and none was declared. ` +\n\t\t\t\t`Declare one: on this deploy target, events are carried by pg-boss. ` +\n\t\t\t\t`Queues and topics affected: ${ids.join(', ')}.`,\n\t\t);\n\t\tthis.name = 'PgBossNeedsDatabase';\n\t}\n}\n","/**\n * The stack's Redis: what every declared cache lives in when a workspace runs\n * as a `gkm compose` stack, on the local stage and on a deployed one alike.\n *\n * A cache is the one store whose contents can always be rebuilt, so unlike\n * Mailpit and MinIO it is a production service, not a dev stand-in: it runs\n * for every stage, on the compose network only, with nothing published. It\n * is bounded (`maxmemory`, evicting the least recently used key), persisted\n * (an append-only file on a named volume, kept by `--down`) and password\n * protected — the stage's own password, generated once like its seed.\n *\n * A stage that sets a cache's URL in its secrets — a managed Redis — keeps\n * it, and a stack whose every cache is set that way runs no Redis at all.\n *\n * Pure: the stack decides it, and the phases keep the password.\n */\n\nimport { randomBytes } from 'node:crypto';\nimport { type ConstructManifest, providedKeyFor } from '@geekmidas/manifest';\nimport { GkmError } from '../errors';\nimport { DEFAULT_IMAGES } from '../reconcile/containers.js';\nimport type { Plan } from '../reconcile/plan.js';\nimport type { StageSecrets } from '../secrets/types.js';\nimport type { CacheBackend } from '../types.js';\nimport type { StackService } from './stack.js';\n\n/**\n * Where a stack's caches live: its own Redis, whatever the deploy target's\n * default is. A stack is one machine running containers, and a Redis beside\n * the apps is cheaper for a cache than a table in the database they share.\n */\nexport const STACK_CACHE: CacheBackend = 'redis';\n\n/** Its compose service name — the host every cache URL points at. */\nexport const REDIS_SERVICE = 'redis';\n\n/** The port it answers on, inside the network. */\nexport const REDIS_PORT = 6379;\n\n/** Reconcile's pin, so `gkm dev` and the stack run one Redis. */\nexport const REDIS_IMAGE = DEFAULT_IMAGES.redis!;\n\n/**\n * How much it may hold before it evicts. A cache that grows until the box\n * runs out of memory takes the apps with it; 256 MB is a lot of sessions and\n * little of a small server. A project's `docker-compose.<stage>.yml` can\n * replace the command to change it.\n */\nexport const REDIS_MAXMEMORY = '256mb';\n\n/** The stage secret holding its password. */\nexport const REDIS_PASSWORD_KEY = 'REDIS_PASSWORD';\n\n/** Redis's own count of logical databases, before `--databases` raises it. */\nconst REDIS_DATABASES = 16;\n\n/** A deployed stage that runs the stack's Redis and has no password yet. */\nexport class RedisPasswordMissing extends GkmError {\n\tconstructor(readonly stage: string) {\n\t\tsuper(\n\t\t\t`The stage '${stage}' runs the stack's Redis and has no ` +\n\t\t\t\t`${REDIS_PASSWORD_KEY} in its secrets. Run gkm compose --stage ` +\n\t\t\t\t`${stage} without --dry-run once to generate it, or set one: ` +\n\t\t\t\t`gkm secrets:set ${REDIS_PASSWORD_KEY} '…' --stage ${stage}`,\n\t\t);\n\t\tthis.name = 'RedisPasswordMissing';\n\t}\n}\n\n/** The stack's Redis, as the stack runs it. */\nexport interface StackRedis {\n\tpassword: string;\n\t/** Whether the stage's secrets set the password, rather than the local one. */\n\tpasswordFromSecrets: boolean;\n\t/**\n\t * Each cache it holds — its URL key, and the URL — and each WebSocket\n\t * surface's publisher, whose sockets meet their senders on its pub/sub.\n\t */\n\turls: Record<string, string>;\n\t/** Its own environment, written to `redis.env` (0600). */\n\tenv: Record<string, string>;\n\t/** How many logical databases it keeps — one per cache, at least 16. */\n\tdatabases: number;\n}\n\n/**\n * Whether a stage's stack runs Redis: a cache or a WebSocket surface is\n * declared and the stage's secrets do not set the URL of every one.\n */\nexport function runsRedis(\n\tmanifest: ConstructManifest,\n\tcustom: Readonly<Record<string, string>>,\n): boolean {\n\treturn Object.values(manifest).some((declaration) => {\n\t\tif (declaration?.kind === 'cache') {\n\t\t\treturn (declaration.provides ?? []).some(\n\t\t\t\t(key) => custom[key] === undefined,\n\t\t\t);\n\t\t}\n\t\treturn (\n\t\t\tdeclaration?.kind === 'websocket-api' &&\n\t\t\tcustom[\n\t\t\t\tprovidedKeyFor(\n\t\t\t\t\tdeclaration.id,\n\t\t\t\t\tdeclaration.kind,\n\t\t\t\t\t'publisherConnectionString',\n\t\t\t\t)\n\t\t\t] === undefined\n\t\t);\n\t});\n}\n\n/** A password: 256 random bits, URL-safe, so it sits in a URL unescaped. */\nexport function generateRedisPassword(): string {\n\treturn randomBytes(32).toString('base64url');\n}\n\n/**\n * The stage's secrets with a generated Redis password, where it has none.\n * Pure, like `withGeneratedSecrets`: the caller keeps the result once the run\n * goes ahead.\n */\nexport function withRedisPassword(secrets: StageSecrets): {\n\tsecrets: StageSecrets;\n\tgenerated: string[];\n} {\n\tif (secrets.custom?.[REDIS_PASSWORD_KEY]) return { secrets, generated: [] };\n\treturn {\n\t\tsecrets: {\n\t\t\t...secrets,\n\t\t\tcustom: {\n\t\t\t\t...secrets.custom,\n\t\t\t\t[REDIS_PASSWORD_KEY]: generateRedisPassword(),\n\t\t\t},\n\t\t\tupdatedAt: new Date().toISOString(),\n\t\t},\n\t\tgenerated: [REDIS_PASSWORD_KEY],\n\t};\n}\n\n/**\n * The stack's Redis for one stage, or nothing where no cache needs it.\n *\n * Each cache it holds gets a logical database of its own, by the order of\n * their ids, so two caches never read each other's keys.\n */\nexport function stackRedis(options: {\n\tplan: Plan;\n\tstage: string;\n\tlocal: boolean;\n\tcustom: Readonly<Record<string, string>>;\n\t/** The local stage's generated password — `gkm dev`'s Redis's too. */\n\tlocalPassword?: string;\n}): StackRedis | undefined {\n\tconst { plan, stage, local, custom } = options;\n\n\tconst caches = plan.resources\n\t\t.filter((r) => r.kind === 'cache' && custom[r.envKey] === undefined)\n\t\t.sort((a, b) => a.id.localeCompare(b.id));\n\tconst publishers = plan.resources\n\t\t.filter((r) => r.kind === 'websocket-api')\n\t\t.map((r) => providedKeyFor(r.id, r.kind, 'publisherConnectionString'))\n\t\t.filter((key) => custom[key] === undefined);\n\tif (caches.length === 0 && publishers.length === 0) return undefined;\n\n\tconst set = custom[REDIS_PASSWORD_KEY];\n\tconst password = set ?? (local ? options.localPassword : undefined);\n\tif (!password) throw new RedisPasswordMissing(stage);\n\tconst auth = encodeURIComponent(password);\n\n\treturn {\n\t\tpassword,\n\t\tpasswordFromSecrets: Boolean(set),\n\t\turls: Object.fromEntries([\n\t\t\t...caches.map((cache, index) => [\n\t\t\t\tcache.envKey,\n\t\t\t\t`redis://:${auth}@${REDIS_SERVICE}:${REDIS_PORT}/${index}`,\n\t\t\t]),\n\t\t\t// Pub/sub is not scoped by database, so no index: a surface's\n\t\t\t// channels are named for it.\n\t\t\t...publishers.map((key) => [\n\t\t\t\tkey,\n\t\t\t\t`redis://:${auth}@${REDIS_SERVICE}:${REDIS_PORT}`,\n\t\t\t]),\n\t\t]),\n\t\tenv: {\n\t\t\t// What the server is started with, by name: the command reads it\n\t\t\t// from the environment, so the value is never in its arguments.\n\t\t\t[REDIS_PASSWORD_KEY]: password,\n\t\t\t// What `redis-cli` signs in with — the health check's, and anyone's\n\t\t\t// who execs into the container — without `-a` on a command line.\n\t\t\tREDISCLI_AUTH: password,\n\t\t},\n\t\tdatabases: Math.max(REDIS_DATABASES, caches.length),\n\t};\n}\n\n/**\n * Redis's service: bounded, persisted and password protected, on the\n * network alone.\n *\n * The command runs the image's own entrypoint with `redis-server` first, so\n * it still drops to the `redis` user and owns `/data`; the password is read\n * from the env file by the shell (`$$` is compose's escape for `$`), so\n * neither the compose file nor the container's command holds it.\n */\nexport function redisService(redis: StackRedis): StackService {\n\tconst flags = [\n\t\t`--requirepass \"$$${REDIS_PASSWORD_KEY}\"`,\n\t\t`--maxmemory ${REDIS_MAXMEMORY}`,\n\t\t'--maxmemory-policy allkeys-lru',\n\t\t'--appendonly yes',\n\t\t...(redis.databases > REDIS_DATABASES\n\t\t\t? [`--databases ${redis.databases}`]\n\t\t\t: []),\n\t];\n\treturn {\n\t\timage: REDIS_IMAGE,\n\t\trestart: 'unless-stopped',\n\t\tcommand: [\n\t\t\t'sh',\n\t\t\t'-c',\n\t\t\t`exec docker-entrypoint.sh redis-server ${flags.join(' ')}`,\n\t\t],\n\t\tenv_file: [{ path: `./${REDIS_SERVICE}.env`, format: 'raw' }],\n\t\tvolumes: ['redis-data:/data'],\n\t\thealthcheck: {\n\t\t\t// `redis-cli` signs in with REDISCLI_AUTH; an unauthenticated ping\n\t\t\t// answers NOAUTH, which is not PONG.\n\t\t\ttest: ['CMD-SHELL', 'redis-cli ping | grep -q PONG'],\n\t\t\tinterval: '5s',\n\t\t\ttimeout: '3s',\n\t\t\tretries: 10,\n\t\t},\n\t};\n}\n","/**\n * The values a deployed stage generates once and keeps: what nothing can\n * provision and nobody else issues.\n *\n * - **A seed**, which salts every password a deploy derives — a database's\n * master and roles, a bucket's root user. Derived from repo facts alone\n * (project, stage, construct id), those passwords were computable by anyone\n * who could read the repo.\n * - **Each `secret` construct's value** — an auth server's signing secret, a\n * `RandomPassword` — random, rather than derived, in its declared format.\n * - **Each `encryption` construct's keyring** — one random key and an index\n * key. Later keys are added by `gkm encryption:rotate`, never by a deploy.\n *\n * Both are generated on the first deploy that needs them and written to the\n * stage's store, so every later deploy reads the same values: sessions survive\n * a redeploy, and a role's password does not move. A value set by hand with\n * `gkm secrets:set` is kept, never replaced.\n */\n\nimport { randomBytes, randomInt } from 'node:crypto';\nimport { generateKeyring } from '@geekmidas/constructs/encryption';\nimport { type ConstructManifest, drawSecret } from '@geekmidas/manifest';\nimport type { StageSecrets } from '../secrets/types.js';\n\nexport interface GeneratedSecrets {\n\t/** The stage's secrets with everything it generates present. */\n\tsecrets: StageSecrets;\n\t/** What was generated this time, by key — empty when nothing was missing. */\n\tgenerated: string[];\n}\n\n/**\n * The stage's secrets with its seed and every declared `secret`'s value\n * present, generating what is missing. Pure: the caller writes the result\n * back to the stage's store when `generated` is not empty.\n */\nexport function withGeneratedSecrets(\n\tsecrets: StageSecrets,\n\tmanifest: ConstructManifest,\n): GeneratedSecrets {\n\tconst generated: string[] = [];\n\tconst custom = { ...secrets.custom };\n\n\tfor (const declaration of Object.values(manifest)) {\n\t\tif (declaration?.kind !== 'secret' && declaration?.kind !== 'encryption') {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst key = declaration.provides?.[0];\n\t\tif (!key || custom[key]) continue;\n\n\t\tcustom[key] =\n\t\t\tdeclaration.kind === 'encryption'\n\t\t\t\t? generateKeyring()\n\t\t\t\t: drawSecret(randomInt, declaration);\n\t\tgenerated.push(key);\n\t}\n\n\tconst seed = secrets.seed ?? generateSeed();\n\tif (!secrets.seed) generated.push('seed');\n\n\treturn {\n\t\tsecrets: generated.length\n\t\t\t? { ...secrets, seed, custom, updatedAt: new Date().toISOString() }\n\t\t\t: secrets,\n\t\tgenerated,\n\t};\n}\n\n/** A stage's seed: 256 random bits, URL-safe. */\nexport function generateSeed(): string {\n\treturn random();\n}\n\n/** 256 bits, URL-safe. */\nfunction random(): string {\n\treturn randomBytes(32).toString('base64url');\n}\n","/**\n * The logins of the containers `gkm dev`, `gkm test` and the compose local\n * stage run — generated once per machine and workspace, and read back on\n * every later run.\n *\n * They used to be one fixed word, the same on every laptop, so anyone who\n * could reach a developer's Postgres could sign in to it. Now each password,\n * token and secret key is random, in the shape its service accepts, and the\n * user names are neutral ones derived from the workspace.\n *\n * **Where they are kept.** Encrypted with the local stage's key, in the CLI's\n * home beside the keys (`<home>/local/<namespace>/<project>.json`), rather\n * than in a checkout's `.gkm/`. The containers are per machine and project —\n * every checkout of a repo attaches to the same Postgres — so their logins\n * have to be too: two worktrees each generating their own would take turns\n * locking each other out of one database.\n *\n * **Why stored, not derived from a seed.** One cluster serves the local stage\n * and `test`, while a derivation is per stage; each service has its own rules\n * a hash does not meet by default; and a volume that cannot be rotated keeps\n * the login it has, which a derivation cannot express. The seed is generated\n * beside them all the same, and salts the per-role passwords the way a\n * deployed stage's does.\n */\n\nimport { randomBytes, randomInt } from 'node:crypto';\nimport { existsSync } from 'node:fs';\nimport { mkdir, readFile, rm, stat, writeFile } from 'node:fs/promises';\nimport { dirname, join } from 'node:path';\nimport { generateLogsPassword, LOCAL_LOGS_EMAIL } from '../compose/logs.js';\nimport { generateRedisPassword } from '../compose/redis.js';\nimport { generateSeed } from '../deploy/generated.js';\nimport { GkmError } from '../errors';\nimport { gkmHome } from '../home.js';\nimport {\n\tdecrypt,\n\ttype EncryptedSecretsFile,\n\tencrypt,\n} from '../secrets/file.js';\nimport {\n\tgetKeystoreDir,\n\tgetOrCreateKey,\n\ttype KeystoreProject,\n\tkeystoreProject,\n\treadKey,\n} from '../secrets/keystore.js';\nimport type { NormalizedWorkspace } from '../workspace/types.js';\nimport { EMULATOR_ACCESS_KEY_ID } from './emulator.js';\n\n/** A user name and its password. */\nexport interface Login {\n\tuser: string;\n\tpassword: string;\n}\n\n/**\n * What every container a plan implies is brought up with, and every URL\n * that reaches one carries.\n */\nexport interface ContainerCredentials {\n\t/** The cluster's superuser — what creates databases and roles. */\n\tpostgres: Login;\n\t/** MinIO's root user, which the S3 client signs with. */\n\tminio: Login;\n\t/** RabbitMQ's administrator. */\n\trabbitmq: Login;\n\t/** Redis's `requirepass`. */\n\tredis: { password: string };\n\t/** The token the cache's HTTP proxy accepts. */\n\tcacheToken: string;\n\t/** The AWS emulator's key pair. */\n\temulator: { accessKeyId: string; secretAccessKey: string };\n\t/**\n\t * OpenObserve's root user — `gkm dev`'s, where a process uses a\n\t * `Telemetry` construct, and `gkm compose`'s on the local stage.\n\t */\n\tlogs: { email: string; password: string };\n}\n\n/** The local stage's logins: the containers', and what else it generates. */\nexport interface LocalCredentials extends ContainerCredentials {\n\t/** Salts every per-role password, as a deployed stage's seed does. */\n\tseed: string;\n}\n\n/** MinIO refuses a root password shorter than 8 or longer than 40. */\nexport const MINIO_PASSWORD_LENGTH = 32;\n\n/** An AWS secret key is 40 characters. */\nexport const EMULATOR_SECRET_KEY_LENGTH = 40;\n\n/** MinIO's root user, the same for every workspace: it is not a secret. */\nexport const LOCAL_MINIO_USER = 'minio';\n\n/** RabbitMQ's administrator, the same way. */\nexport const LOCAL_RABBITMQ_USER = 'rabbitmq';\n\n/**\n * The Postgres superuser for a workspace: its name as an identifier, with\n * `_admin` — never the bare name, which a database construct of the same\n * name would claim as its runtime role.\n */\nexport function postgresSuperuser(project: string): string {\n\treturn `${postgresRoleSlug(project)}_admin`;\n}\n\n/**\n * The project as the start of a role's name: lowercase, `_` for anything\n * else, never starting with a digit — `gkm` when nothing is left.\n */\nexport function postgresRoleSlug(project: string): string {\n\tconst slug = project\n\t\t.toLowerCase()\n\t\t.replace(/^@[^/]+\\//, '')\n\t\t.replace(/[^a-z0-9]+/g, '_')\n\t\t.replace(/^_+|_+$/g, '')\n\t\t.replace(/^(\\d)/, '_$1');\n\treturn slug || 'gkm';\n}\n\n/** 256 random bits, URL-safe. */\nfunction token(): string {\n\treturn randomBytes(32).toString('base64url');\n}\n\n/** `length` characters of letters and digits, which every client takes as is. */\nfunction alphanumeric(length: number): string {\n\tconst alphabet =\n\t\t'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';\n\tlet out = '';\n\tfor (let i = 0; i < length; i++) out += alphabet[randomInt(alphabet.length)];\n\treturn out;\n}\n\n/** A fresh set of local logins for a workspace. */\nexport function generateLocalCredentials(project: string): LocalCredentials {\n\treturn {\n\t\tseed: generateSeed(),\n\t\tpostgres: { user: postgresSuperuser(project), password: token() },\n\t\tminio: {\n\t\t\tuser: LOCAL_MINIO_USER,\n\t\t\tpassword: alphanumeric(MINIO_PASSWORD_LENGTH),\n\t\t},\n\t\trabbitmq: { user: LOCAL_RABBITMQ_USER, password: token() },\n\t\tredis: { password: generateRedisPassword() },\n\t\tcacheToken: token(),\n\t\temulator: {\n\t\t\t// Fixed: the emulator reads its account from the key id, and every\n\t\t\t// ARN reconcile composes names that account. Only the secret is one.\n\t\t\taccessKeyId: EMULATOR_ACCESS_KEY_ID,\n\t\t\tsecretAccessKey: alphanumeric(EMULATOR_SECRET_KEY_LENGTH),\n\t\t},\n\t\tlogs: { email: LOCAL_LOGS_EMAIL, password: generateLogsPassword() },\n\t};\n}\n\n/**\n * The stored logins with anything missing generated — a file an older gkm\n * wrote before a service existed. Pure: the caller writes the result back\n * when `generated` is not empty.\n */\nexport function withLocalCredentials(\n\tstored: Partial<LocalCredentials> | null | undefined,\n\tproject: string,\n): { credentials: LocalCredentials; generated: string[] } {\n\tconst fresh = generateLocalCredentials(project);\n\tconst generated = (Object.keys(fresh) as (keyof LocalCredentials)[]).filter(\n\t\t(key) => stored?.[key] === undefined,\n\t);\n\treturn {\n\t\tcredentials: { ...fresh, ...stored } as LocalCredentials,\n\t\tgenerated,\n\t};\n}\n\n/** Where a workspace's local logins are kept on this machine. */\nexport function localCredentialsPath(project: KeystoreProject): string {\n\t// Validates the key and splits it the way the keystore does.\n\tconst keys = getKeystoreDir(project);\n\tconst name = keys.split(/[\\\\/]/).at(-1)!;\n\tconst namespace = keys.split(/[\\\\/]/).at(-2)!;\n\treturn join(project.home ?? gkmHome(), 'local', namespace, `${name}.json`);\n}\n\n/** The local stage's logins file is there, and its key is not. */\nexport class LocalCredentialsKeyMissing extends GkmError {\n\tconstructor(\n\t\treadonly path: string,\n\t\treadonly stage: string,\n\t) {\n\t\tsuper(\n\t\t\t`The local logins at ${path} are encrypted with the '${stage}' stage's ` +\n\t\t\t\t\"key, and this machine has none. Remove the file to generate new ones — the containers' volumes are rotated to them on the next gkm dev.\",\n\t\t);\n\t\tthis.name = 'LocalCredentialsKeyMissing';\n\t}\n}\n\n/** Another gkm held the logins file's lock for longer than any write takes. */\nexport class LocalCredentialsLocked extends GkmError {\n\tconstructor(readonly lock: string) {\n\t\tsuper(\n\t\t\t`Another gkm has been writing the local logins for over ${LOCK_TIMEOUT_MS / 1000}s. If none is running, remove ${lock} and run the command again.`,\n\t\t);\n\t\tthis.name = 'LocalCredentialsLocked';\n\t}\n}\n\n/** Read the stored logins, or `null` where none were generated yet. */\nexport async function readLocalCredentials(\n\tworkspace: Pick<NormalizedWorkspace, 'name' | 'root' | 'stages'> &\n\t\tParameters<typeof keystoreProject>[0],\n\thome?: string,\n): Promise<LocalCredentials | null> {\n\tconst project = keystoreProject(workspace, home);\n\tconst path = localCredentialsPath(project);\n\tif (!existsSync(path)) return null;\n\n\tconst stage = workspace.stages.local;\n\tconst key = await readKey(stage, project);\n\tif (!key) throw new LocalCredentialsKeyMissing(path, stage);\n\tconst file = JSON.parse(\n\t\tawait readFile(path, 'utf-8'),\n\t) as EncryptedSecretsFile;\n\treturn decrypt<LocalCredentials>(file, key);\n}\n\n/** Write the logins, encrypted with the local stage's key, owner-only. */\nexport async function saveLocalCredentials(\n\tworkspace: Parameters<typeof readLocalCredentials>[0],\n\tcredentials: LocalCredentials,\n\thome?: string,\n): Promise<void> {\n\tconst project = keystoreProject(workspace, home);\n\tconst path = localCredentialsPath(project);\n\tconst key = await getOrCreateKey(workspace.stages.local, project);\n\tawait mkdir(dirname(path), { recursive: true, mode: 0o700 });\n\tawait writeFile(path, JSON.stringify(encrypt(credentials, key), null, 2), {\n\t\tmode: 0o600,\n\t});\n}\n\n/**\n * The workspace's local logins: read back, or generated and kept the first\n * time anything needs them.\n *\n * Under a lock, because a workspace's `gkm dev` starts one per app and the\n * first run of each would otherwise generate — and keep — its own.\n */\nexport async function loadLocalCredentials(\n\tworkspace: Parameters<typeof readLocalCredentials>[0],\n\thome?: string,\n): Promise<{ credentials: LocalCredentials; generated: string[] }> {\n\tconst path = localCredentialsPath(keystoreProject(workspace, home));\n\treturn withLock(`${path}.lock`, async () => {\n\t\tconst stored = await readLocalCredentials(workspace, home);\n\t\tconst result = withLocalCredentials(stored, workspace.name);\n\t\tif (result.generated.length > 0) {\n\t\t\tawait saveLocalCredentials(workspace, result.credentials, home);\n\t\t}\n\t\treturn result;\n\t});\n}\n\n/** How long a lock may be held before it is someone else's problem. */\nconst LOCK_TIMEOUT_MS = 15_000;\n\nasync function withLock<T>(lock: string, body: () => Promise<T>): Promise<T> {\n\tawait mkdir(dirname(lock), { recursive: true, mode: 0o700 });\n\tconst started = Date.now();\n\tfor (;;) {\n\t\ttry {\n\t\t\tawait mkdir(lock);\n\t\t\tbreak;\n\t\t} catch (error) {\n\t\t\tif ((error as NodeJS.ErrnoException).code !== 'EEXIST') throw error;\n\t\t\t// A lock older than any write is left over from a process that died\n\t\t\t// holding it.\n\t\t\tconst age = await stat(lock)\n\t\t\t\t.then((s) => Date.now() - s.mtimeMs)\n\t\t\t\t.catch(() => 0);\n\t\t\tif (age > LOCK_TIMEOUT_MS) {\n\t\t\t\tawait rm(lock, { recursive: true, force: true });\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (Date.now() - started > LOCK_TIMEOUT_MS) {\n\t\t\t\tthrow new LocalCredentialsLocked(lock);\n\t\t\t}\n\t\t\tawait new Promise((resolve) => setTimeout(resolve, 50));\n\t\t}\n\t}\n\ttry {\n\t\treturn await body();\n\t} finally {\n\t\tawait rm(lock, { recursive: true, force: true });\n\t}\n}\n","import { existsSync } from 'node:fs';\nimport { mkdir, readFile, writeFile } from 'node:fs/promises';\nimport { createServer } from 'node:net';\nimport { dirname, join, resolve } from 'node:path';\nimport { config as dotenvConfig } from 'dotenv';\nimport {\n\tConfigNotFound,\n\tloadWorkspaceAppInfo,\n\tloadWorkspaceConfig,\n\tNotInAnApp,\n\ttype WorkspaceAppInfo,\n} from '../config';\nimport type { ReconcileResult } from '../reconcile/index.js';\nimport { toEmbeddableSecrets } from '../secrets/storage.js';\nimport {\n\tFileSecretsStore,\n\ttype SecretsStore,\n\tsecretsStoreFor,\n} from '../secrets/store.js';\nimport type { NormalizedWorkspace } from '../workspace/index.js';\n\nconst logger = console;\n\n// ---------------------------------------------------------------------------\n// Environment files\n// ---------------------------------------------------------------------------\n\n/**\n * Load environment files\n * @internal Exported for testing\n */\nexport function loadEnvFiles(\n\tenvConfig: string | string[] | undefined,\n\tcwd: string = process.cwd(),\n): { loaded: string[]; missing: string[] } {\n\tconst loaded: string[] = [];\n\tconst missing: string[] = [];\n\n\t// Normalize to array\n\tconst envFiles = envConfig\n\t\t? Array.isArray(envConfig)\n\t\t\t? envConfig\n\t\t\t: [envConfig]\n\t\t: ['.env'];\n\n\t// Load each env file in order (later files override earlier)\n\tfor (const envFile of envFiles) {\n\t\tconst envPath = resolve(cwd, envFile);\n\t\tif (existsSync(envPath)) {\n\t\t\tdotenvConfig({ path: envPath, override: true, quiet: true });\n\t\t\tloaded.push(envFile);\n\t\t} else if (envConfig) {\n\t\t\t// Only report as missing if explicitly configured\n\t\t\tmissing.push(envFile);\n\t\t}\n\t}\n\n\treturn { loaded, missing };\n}\n\n// ---------------------------------------------------------------------------\n// Port utilities\n// ---------------------------------------------------------------------------\n\n/**\n * Check if a port is available\n * @internal Exported for testing\n */\nexport async function isPortAvailable(port: number): Promise<boolean> {\n\treturn new Promise((resolve) => {\n\t\tconst server = createServer();\n\n\t\tserver.once('error', (err: NodeJS.ErrnoException) => {\n\t\t\tif (err.code === 'EADDRINUSE') {\n\t\t\t\tresolve(false);\n\t\t\t} else {\n\t\t\t\tresolve(false);\n\t\t\t}\n\t\t});\n\n\t\tserver.once('listening', () => {\n\t\t\tserver.close();\n\t\t\tresolve(true);\n\t\t});\n\n\t\tserver.listen(port);\n\t});\n}\n\n/**\n * Find an available port starting from the preferred port\n * @internal Exported for testing\n */\nexport async function findAvailablePort(\n\tpreferredPort: number,\n\tmaxAttempts = 10,\n): Promise<number> {\n\tfor (let i = 0; i < maxAttempts; i++) {\n\t\tconst port = preferredPort + i;\n\t\tif (await isPortAvailable(port)) {\n\t\t\treturn port;\n\t\t}\n\t\tlogger.log(`⚠️ Port ${port} is in use, trying ${port + 1}...`);\n\t}\n\n\tthrow new Error(\n\t\t`Could not find an available port after trying ${maxAttempts} ports starting from ${preferredPort}`,\n\t);\n}\n\n// ---------------------------------------------------------------------------\n// Docker Compose port mapping\n// ---------------------------------------------------------------------------\n\n/** Port state persisted to .gkm/ports.json, keyed by env var name. */\nexport type PortState = Record<string, number>;\n\nconst PORT_STATE_PATH = '.gkm/ports.json';\n\n/**\n * Load saved port state from .gkm/ports.json.\n * @internal Exported for testing\n */\nexport async function loadPortState(workspaceRoot: string): Promise<PortState> {\n\ttry {\n\t\tconst raw = await readFile(join(workspaceRoot, PORT_STATE_PATH), 'utf-8');\n\t\treturn JSON.parse(raw) as PortState;\n\t} catch {\n\t\treturn {};\n\t}\n}\n\n/**\n * Save port state to .gkm/ports.json.\n * @internal Exported for testing\n */\nexport async function savePortState(\n\tworkspaceRoot: string,\n\tports: PortState,\n): Promise<void> {\n\tconst dir = join(workspaceRoot, '.gkm');\n\tawait mkdir(dir, { recursive: true });\n\tawait writeFile(\n\t\tjoin(workspaceRoot, PORT_STATE_PATH),\n\t\t`${JSON.stringify(ports, null, 2)}\\n`,\n\t);\n}\n\n// ---------------------------------------------------------------------------\n// URL rewriting\n// ---------------------------------------------------------------------------\n\n// ---------------------------------------------------------------------------\n// Docker Compose services\n// ---------------------------------------------------------------------------\n\n// ---------------------------------------------------------------------------\n// Secrets loading\n// ---------------------------------------------------------------------------\n\n/**\n * Load and flatten a stage's secrets from its store.\n *\n * Every key as stored — nothing renamed. An app's database URL is its\n * construct's key, derived by reconcile, and never a stored per-app value\n * mapped onto `DATABASE_URL`.\n * @internal Exported for testing\n */\nexport async function loadSecretsForApp(\n\tstore: SecretsStore,\n\tstage: string,\n): Promise<Record<string, string>> {\n\tconst stageSecrets = await store.read(stage);\n\tif (!stageSecrets) return {};\n\n\tlogger.log(`🔐 Loading secrets from stage: ${stage}`);\n\treturn toEmbeddableSecrets(stageSecrets);\n}\n\n/**\n * Walk up the directory tree to find the root containing .gkm/secrets/.\n * @internal Exported for testing\n */\nexport function findSecretsRoot(startDir: string): string {\n\tlet dir = startDir;\n\twhile (dir !== '/') {\n\t\tif (existsSync(join(dir, '.gkm', 'secrets'))) {\n\t\t\treturn dir;\n\t\t}\n\t\tconst parent = dirname(dir);\n\t\tif (parent === dir) break;\n\t\tdir = parent;\n\t}\n\treturn startDir;\n}\n\n// ---------------------------------------------------------------------------\n// Credentials preload / injection\n// ---------------------------------------------------------------------------\n\n/**\n * Generate the credentials injection code snippet.\n * This is the common logic used by both entry wrapper and exec preload.\n * @internal\n */\nfunction generateCredentialsInjection(secretsJsonPath: string): string {\n\treturn `import { existsSync, readFileSync } from 'node:fs';\n\n// Inject dev secrets via globalThis and process.env\n// Using globalThis.__gkm_credentials__ avoids CJS/ESM interop issues where\n// Object.assign on the Credentials export only mutates one module copy.\nconst secretsPath = '${secretsJsonPath}';\nif (existsSync(secretsPath)) {\n const secrets = JSON.parse(readFileSync(secretsPath, 'utf-8'));\n globalThis.__gkm_credentials__ = secrets;\n Object.assign(process.env, secrets);\n}\n`;\n}\n\n/**\n * Create a preload script that injects secrets into Credentials.\n * Used by `gkm exec` to inject secrets before running any command.\n * @internal Exported for testing\n */\nexport async function createCredentialsPreload(\n\tpreloadPath: string,\n\tsecretsJsonPath: string,\n): Promise<void> {\n\tconst content = `/**\n * Credentials preload generated by 'gkm exec'\n * This file is loaded via NODE_OPTIONS=\"--import <path>\"\n */\n${generateCredentialsInjection(secretsJsonPath)}`;\n\n\tawait writeFile(preloadPath, content);\n}\n\n/**\n * Create a wrapper script that injects secrets before importing the entry file.\n * @internal Exported for testing\n */\nexport async function createEntryWrapper(\n\twrapperPath: string,\n\tentryPath: string,\n\tsecretsJsonPath?: string,\n): Promise<void> {\n\tconst credentialsInjection = secretsJsonPath\n\t\t? `${generateCredentialsInjection(secretsJsonPath)}\n`\n\t\t: '';\n\n\t// Use dynamic import() to ensure secrets are assigned before the entry file loads\n\t// Static imports are hoisted, so Object.assign would run after the entry file is loaded\n\tconst content = `#!/usr/bin/env node\n/**\n * Entry wrapper generated by 'gkm dev --entry'\n */\n${credentialsInjection}// Import and run the user's entry file (dynamic import ensures secrets load first)\nawait import('${entryPath}');\n`;\n\n\tawait writeFile(wrapperPath, content);\n}\n\n// ---------------------------------------------------------------------------\n// Prepare credentials (shared by dev, exec, test)\n// ---------------------------------------------------------------------------\n\n/**\n * Result of preparing credentials.\n */\nexport interface EntryCredentialsResult {\n\t/** Credentials to inject (secrets + PORT) */\n\tcredentials: Record<string, string>;\n\t/** Resolved port (from --port, workspace config, or default 3000) */\n\tresolvedPort: number;\n\t/** Path where credentials JSON was written */\n\tsecretsJsonPath: string;\n\t/** Resolved app name (if in workspace) */\n\tappName: string | undefined;\n\t/** Secrets root directory */\n\tsecretsRoot: string;\n\t/** Workspace app info (if in a workspace) */\n\tappInfo?: WorkspaceAppInfo;\n\t/**\n\t * The keys the manifest declared, as opposed to those a secret store held.\n\t *\n\t * Kept apart because they cannot be *sniffed*. A construct reads its own key\n\t * inside `@geekmidas/constructs`, not in application code, so a walk of the\n\t * app finds no `get('MAIL_URL')` to find — and a caller that filters the\n\t * environment down to what it sniffed would drop every URL the target just\n\t * resolved. `gkm test` did exactly that.\n\t */\n\tdeclaredKeys: string[];\n\t/** The reconcile just run, in a workspace: its plan and its ports. */\n\treconciled?: ReconcileResult;\n}\n\n/**\n * Prepare credentials for dev/exec/test modes.\n * Loads workspace config, secrets, resolves Docker ports, rewrites URLs,\n * injects PORT, dependency URLs, and writes credentials JSON.\n *\n * @param options.stage - The stage whose secrets to load. Default: the project's `stages.local`.\n * @param options.startDocker - Start Docker Compose services after port resolution. Default: false.\n * @param options.secretsFileName - Custom secrets JSON filename. Default: 'dev-secrets-{appName}.json' or 'dev-secrets.json'.\n * @internal Exported for testing\n */\nexport async function prepareEntryCredentials(options: {\n\texplicitPort?: number;\n\tcwd?: string;\n\t/** The stage whose secrets to load. Default: the project's `stages.local` */\n\tstage?: string;\n\t/** Start Docker Compose services after port resolution. Default: false */\n\tstartDocker?: boolean;\n\t/** Custom secrets JSON filename. Default: 'dev-secrets-{appName}.json' or 'dev-secrets.json' */\n\tsecretsFileName?: string;\n\t/**\n\t * The stage to reconcile the local target for.\n\t *\n\t * `gkm test` passes `test` and gets the same containers with suffixed\n\t * resources; left out, it is the project's local stage and they are\n\t * unsuffixed. Only read by workspaces that have adopted the constructs glob.\n\t */\n\treconcileStage?: string;\n\t/**\n\t * Hand an app only what its own process reads (`processEnv`) — its\n\t * edges' keys and the stage's own — as `gkm dev` and `gkm compose` do.\n\t * `gkm exec` asks; `gkm test` does not, since a feature test runs every\n\t * process's code in one.\n\t */\n\tscoped?: boolean;\n}): Promise<EntryCredentialsResult> {\n\tconst cwd = options.cwd ?? process.cwd();\n\n\t// Try to get workspace app config for port and secrets\n\tlet workspaceAppPort: number | undefined;\n\tlet secretsRoot: string = cwd;\n\tlet appName: string | undefined;\n\tlet appInfo: WorkspaceAppInfo | undefined;\n\n\tlet workspace: NormalizedWorkspace | undefined;\n\n\ttry {\n\t\tappInfo = await loadWorkspaceAppInfo(cwd);\n\t\tworkspace = appInfo.workspace;\n\t\tworkspaceAppPort = appInfo.app.port;\n\t\tsecretsRoot = appInfo.workspaceRoot;\n\t\tappName = appInfo.appName;\n\t} catch (error) {\n\t\t// Anything but \"not in an app\" or \"not in a workspace\" is a real fault —\n\t\t// a config that does not load — and must not be mistaken for either.\n\t\tif (!(error instanceof NotInAnApp || error instanceof ConfigNotFound)) {\n\t\t\tthrow error;\n\t\t}\n\t\t// Not an app — but possibly the workspace root, which is where the\n\t\t// scaffold's own `pnpm test` runs `gkm test` from. Without the workspace\n\t\t// here that run skipped the reconcile below: no container started, and the\n\t\t// URLs were whatever the stored secrets said, on ports nothing listened on.\n\t\tworkspace = await loadWorkspaceConfig(cwd)\n\t\t\t.then((loaded) => loaded.workspace)\n\t\t\t.catch(() => undefined);\n\t\t// Otherwise not in a workspace at all (expected for non-gkm apps using\n\t\t// gkm exec) — use defaults.\n\t\t// No app here, so no per-app keys to map.\n\t\tsecretsRoot = workspace?.root ?? findSecretsRoot(cwd);\n\t}\n\n\t// The app's local port, by the rule `gkm dev` applies: moved off a port\n\t// another project holds, and kept. Never refused here — the command may be\n\t// a build or a script that binds nothing, so this app's own dev server\n\t// holding the port is no reason to stop it.\n\tif (appName && workspace && options.explicitPort === undefined) {\n\t\tconst { assignAppPorts, describeMove, holderOf, withAppPorts } =\n\t\t\tawait import('../dev/appPorts.js');\n\t\tconst assigned = await assignAppPorts(workspace, [appName], {\n\t\t\tfree: isPortAvailable,\n\t\t\tholder: holderOf,\n\t\t});\n\t\tfor (const move of assigned.moved) logger.log(describeMove(move));\n\t\tworkspace = withAppPorts(workspace, assigned.ports);\n\t\tworkspaceAppPort = assigned.ports[appName] ?? workspaceAppPort;\n\t}\n\n\t// Tagged, so a later `gkm dev` can tell what this starts from another\n\t// project's process on the same port; the command inherits it.\n\tif (appName) {\n\t\tconst { APP_TAG_ENV, appTag } = await import('../dev/appPorts.js');\n\t\tprocess.env[APP_TAG_ENV] = appTag(secretsRoot, appName);\n\t}\n\n\t// Determine port: explicit --port > the app's local port > default 3000\n\tconst resolvedPort = options.explicitPort ?? workspaceAppPort ?? 3000;\n\n\t// Load secrets and inject PORT. Outside a workspace there are no declared\n\t// stages to read, so only a stage asked for by name is loaded.\n\tconst stage = options.stage ?? workspace?.stages.local;\n\t// The stage's own store; outside a workspace nothing names one but the file.\n\tconst store = stage\n\t\t? workspace\n\t\t\t? await secretsStoreFor(workspace, stage)\n\t\t\t: new FileSecretsStore(secretsRoot)\n\t\t: undefined;\n\tconst credentials =\n\t\tstore && stage ? await loadSecretsForApp(store, stage) : {};\n\n\t// Always inject PORT into credentials so apps can read it\n\tcredentials.PORT = String(resolvedPort);\n\t// Expo reads its Metro port from here when `expo start` is given none, so\n\t// a mobile app runs where the workspace placed it — and where the `exp://`\n\t// origins its auth server trusts say it is.\n\tif (appInfo?.app.type === 'mobile') {\n\t\tcredentials.RCT_METRO_PORT = String(resolvedPort);\n\t}\n\n\tconst declaredKeys: string[] = [];\n\tlet reconciled: ReconcileResult | undefined;\n\n\t// Every address — containers, the edge, each app — comes from what the\n\t// workspace declares. Outside a workspace (a non-gkm app using `gkm exec`)\n\t// there is nothing to resolve, only the secrets above.\n\tif (workspace) {\n\t\tconst { reconcileWorkspace } = await import('../reconcile/workspace.js');\n\t\tconst result = await reconcileWorkspace(workspace, {\n\t\t\tstage: options.reconcileStage ?? workspace.stages.local,\n\t\t\tstart: options.startDocker ?? false,\n\t\t});\n\t\treconciled = result;\n\n\t\t// Declared URLs win over anything stored: the manifest is the statement\n\t\t// of what exists, and a stale secret naming an old port is exactly the\n\t\t// drift this replaces.\n\t\tif (options.scoped && appName) {\n\t\t\tconst { appProcess, processEnv } = await import('../reconcile/apps.js');\n\t\t\tconst own = processEnv(\n\t\t\t\tresult.manifest,\n\t\t\t\tappProcess(workspace, result.manifest, result.background, appName),\n\t\t\t\t{ ...credentials },\n\t\t\t\tresult.env,\n\t\t\t);\n\t\t\tfor (const key of Object.keys(credentials)) delete credentials[key];\n\t\t\tObject.assign(credentials, own);\n\t\t} else {\n\t\t\tObject.assign(credentials, reconciled.env);\n\t\t}\n\t\tdeclaredKeys.push(\n\t\t\t...Object.keys(reconciled.env).filter((key) => key in credentials),\n\t\t);\n\n\t\tif (Object.keys(reconciled.env).length > 0) {\n\t\t\tlogger.log(\n\t\t\t\t`🔌 Resolved ${Object.keys(reconciled.env).length} declared URL(s)`,\n\t\t\t);\n\t\t}\n\t}\n\n\t// Write secrets to temp JSON file (always write since we have PORT)\n\t// Use app-specific filename to avoid race conditions when running multiple apps via turbo\n\tconst secretsDir = join(secretsRoot, '.gkm');\n\tawait mkdir(secretsDir, { recursive: true });\n\tconst secretsFileName =\n\t\toptions.secretsFileName ??\n\t\t(appName ? `dev-secrets-${appName}.json` : 'dev-secrets.json');\n\tconst secretsJsonPath = join(secretsDir, secretsFileName);\n\tawait writeFile(secretsJsonPath, JSON.stringify(credentials, null, 2));\n\n\treturn {\n\t\tcredentials,\n\t\tresolvedPort,\n\t\tsecretsJsonPath,\n\t\tappName,\n\t\tsecretsRoot,\n\t\tappInfo,\n\t\tdeclaredKeys,\n\t\t...(reconciled ? { reconciled } : {}),\n\t};\n}\n","/**\n * The compose document a plan implies.\n *\n * The third declaration of the same containers disappears here: today a\n * `services: ['postgres','minio']` block is kept in step with the code by hand,\n * which is the triplication this design exists to remove, in the one place you\n * touch every day. A `database` implies Postgres; the list is derived.\n *\n * Returns an object rather than a string for the same reason `plan` is pure —\n * what should exist is asserted as data, and turning it into YAML is one line at\n * the edge.\n *\n * What stays config is unchanged: images and versions are pinned explicitly, and\n * a container no construct implies is still declared by hand. Neutral facts come\n * from the declaration, provider detail from config.\n */\n\nimport { stringify } from 'yaml';\nimport { LOGS_EMAIL_KEY, LOGS_PASSWORD_KEY } from '../compose/logs.js';\nimport { LOGS_RETENTION_DAYS } from '../compose/logsConfig.js';\nimport { DEFAULT_IMAGES, portsOf, postgresImage, volumeOf } from './containers';\nimport { EMULATOR_REGION } from './emulator';\nimport type { ContainerCredentials } from './localCredentials';\nimport {\n\tHOST_GATEWAY,\n\tminioWebhookEnv,\n\ttype ObjectWebhook,\n} from './objectEvents';\nimport { type Plan, TELEMETRY_CONTAINER } from './plan';\nimport type { PortAssignments } from './ports';\n\n/** A compose service definition — as much of the schema as is emitted here. */\nexport interface ComposeService {\n\timage: string;\n\t/** An app is built from its generated Dockerfile; a container is pulled. */\n\tbuild?: {\n\t\tcontext: string;\n\t\tdockerfile: string;\n\t\t/** A site's public URLs, which its bundler inlines at build time. */\n\t\targs?: Record<string, string>;\n\t};\n\t/** Behind a profile, so starting the containers does not start the apps. */\n\tprofiles?: string[];\n\trestart?: string;\n\tentrypoint?: string;\n\tcommand?: string;\n\tports?: string[];\n\tenvironment?: Record<string, string>;\n\tvolumes?: string[];\n\tdepends_on?: string[];\n\thealthcheck?: {\n\t\ttest: string[];\n\t\tinterval: string;\n\t\ttimeout: string;\n\t\tretries: number;\n\t\tstart_period?: string;\n\t};\n\textra_hosts?: string[];\n}\n\nexport interface ComposeFile {\n\tname: string;\n\tservices: Record<string, ComposeService>;\n\tvolumes?: Record<string, Record<string, never>>;\n}\n\n/** The database every connection opens first: every cluster has it. */\nexport const CLUSTER_DATABASE = 'postgres';\n\nexport interface ComposeOptions {\n\t/** Names the compose project, which is what isolates it from other stacks. */\n\tproject: string;\n\t/** Ports assigned by `allocate`, keyed by port key — see `portKeys`. */\n\tports: PortAssignments;\n\t/** App services to write beside the containers — see `reconcile/apps.ts`. */\n\tapps?: Readonly<Record<string, ComposeService>>;\n\t/**\n\t * What each container is brought up with: the workspace's generated local\n\t * logins — see `localCredentials.ts` — or a stack's derived ones.\n\t */\n\tcredentials: ContainerCredentials;\n\t/**\n\t * Where MinIO posts each watched bucket's events — see `objectEvents.ts`.\n\t * Declared as MinIO's environment, so a change recreates the container.\n\t */\n\tobjectWebhooks?: readonly ObjectWebhook[];\n\t/**\n\t * Where Mailpit posts each message it receives, when an inbox is declared:\n\t * `gkm dev`'s relay, on the host. Mailpit's environment, so a change\n\t * recreates the container.\n\t */\n\tinboxRelay?: string;\n}\n\n/**\n * Build the compose document for a plan.\n *\n * Every container is published on its assigned port, never on the image's\n * default: the point of allocation is that two projects can run at once, and\n * one container publishing 5432 puts that back.\n */\nexport function composeFor(plan: Plan, options: ComposeOptions): ComposeFile {\n\tconst services: Record<string, ComposeService> = {};\n\tconst volumes: Record<string, Record<string, never>> = {};\n\n\tfor (const container of [...plan.containers].sort()) {\n\t\t// A declared version beats the default image, so the container a\n\t\t// developer runs is the major the declaration names — and the same one a\n\t\t// deploy provisions. An image pin is the project's own\n\t\t// `docker-compose.yml`, merged over this file, and wins over both.\n\t\t//\n\t\t// A database can name its own image (PostGIS, pgvector). The local\n\t\t// cluster is shared, so that image runs every database in it — and two\n\t\t// databases naming different ones cannot both have theirs.\n\t\tconst declared =\n\t\t\tcontainer === 'postgres'\n\t\t\t\t? plan.resources.find((r) => r.version)?.version\n\t\t\t\t: undefined;\n\t\tconst named =\n\t\t\tcontainer === 'postgres'\n\t\t\t\t? declaredPostgresImage(plan)\n\t\t\t\t: container === TELEMETRY_CONTAINER\n\t\t\t\t\t? declaredTelemetryImage(plan)\n\t\t\t\t\t: undefined;\n\n\t\tconst fake = plan.fakes?.[container];\n\t\tconst image =\n\t\t\tnamed ??\n\t\t\t(declared\n\t\t\t\t? postgresImage(declared)\n\t\t\t\t: (fake?.image ?? DEFAULT_IMAGES[container]));\n\t\tif (!image) throw new UnknownContainer(container);\n\n\t\tconst published = publish(container, options.ports, plan.fakes);\n\t\tservices[container] = fake\n\t\t\t? // An external API's fake: the provider's image, as it ships. It has\n\t\t\t\t// no volume — a fake keeps nothing worth keeping — and no\n\t\t\t\t// healthcheck, so running is what ready means.\n\t\t\t\t{ image, restart: 'unless-stopped', ports: published }\n\t\t\t: define(container, image, published, options.credentials);\n\n\t\tconst volume = volumeOf(container);\n\t\tif (volume) volumes[volume] = {};\n\t}\n\n\tconst minio = services.minio;\n\tif (minio && options.objectWebhooks?.length) {\n\t\tminio.environment = {\n\t\t\t...minio.environment,\n\t\t\t...minioWebhookEnv(options.objectWebhooks),\n\t\t};\n\t\t// Locally it posts to a process on the host, which Docker Desktop\n\t\t// resolves on its own and Linux needs mapped.\n\t\tif (\n\t\t\toptions.objectWebhooks.some((hook) =>\n\t\t\t\thook.endpoint.includes(`//${HOST_GATEWAY}:`),\n\t\t\t)\n\t\t) {\n\t\t\tminio.extra_hosts = [`${HOST_GATEWAY}:host-gateway`];\n\t\t}\n\t}\n\n\tconst mailpit = services.mailpit;\n\tif (mailpit && options.inboxRelay) {\n\t\tmailpit.environment = {\n\t\t\t...mailpit.environment,\n\t\t\tMP_WEBHOOK_URL: options.inboxRelay,\n\t\t};\n\t\tif (options.inboxRelay.includes(`//${HOST_GATEWAY}:`)) {\n\t\t\tmailpit.extra_hosts = [`${HOST_GATEWAY}:host-gateway`];\n\t\t}\n\t}\n\n\treturn {\n\t\t// Compose derives a project name from the directory otherwise, so two\n\t\t// checkouts of the same repo would fight over one set of containers.\n\t\tname: options.project,\n\t\tservices: { ...services, ...options.apps },\n\t\t...(Object.keys(volumes).length ? { volumes } : {}),\n\t};\n}\n\n/** Render a compose document as the file it becomes. */\nexport function toYaml(file: ComposeFile): string {\n\treturn `# Generated by gkm from the construct manifest — do not edit.\n# Containers are derived from what the app declares. Image pins and anything\n# no construct implies go in your own docker-compose.yml, which is merged over\n# this file and wins:\n#\n# docker compose -f docker-compose.constructs.yml -f docker-compose.yml …\n#\n# \"gkm dev\" and \"gkm test\" start the containers. The apps sit behind the\n# \"apps\" profile: run \"gkm setup\", then\n# docker compose -f docker-compose.constructs.yml --profile apps up --build\n${stringify(file, { lineWidth: 0 })}`;\n}\n\n/** A container with no image, from config or from the defaults. */\n/**\n * The image the databases in the plan named for the shared local cluster, if\n * any did.\n */\nfunction declaredPostgresImage(plan: Plan): string | undefined {\n\tconst named = plan.resources.filter(\n\t\t(r): r is typeof r & { image: string } =>\n\t\t\tr.kind === 'database' && Boolean(r.image),\n\t);\n\tconst images = [...new Set(named.map((r) => r.image))];\n\n\tif (images.length > 1) {\n\t\tthrow new ConflictingPostgresImages(\n\t\t\tnamed.map((r) => ({ id: r.id, image: r.image })),\n\t\t);\n\t}\n\n\treturn images[0];\n}\n\n/**\n * The image a `Telemetry` node named for OpenObserve, if one did — the same\n * one the stack runs (`stackTelemetry` refuses two that disagree).\n */\nfunction declaredTelemetryImage(plan: Plan): string | undefined {\n\treturn plan.resources\n\t\t.filter((r) => r.kind === 'telemetry' && r.image)\n\t\t.sort((a, b) => a.id.localeCompare(b.id))[0]?.image;\n}\n\n/** Two databases on the one local cluster named different images for it. */\nexport class ConflictingPostgresImages extends Error {\n\tconstructor(readonly databases: readonly { id: string; image: string }[]) {\n\t\tsuper(\n\t\t\t`Locally every database runs in one Postgres container, and these ` +\n\t\t\t\t`name different images for it: ` +\n\t\t\t\t`${databases.map((d) => `${d.id} (${d.image})`).join(', ')}. ` +\n\t\t\t\t`Give them the same image — one that ships every extension they ` +\n\t\t\t\t`declare.`,\n\t\t);\n\t\tthis.name = 'ConflictingPostgresImages';\n\t}\n}\n\nexport class UnknownContainer extends Error {\n\t/** The container that could not be resolved. */\n\treadonly container: string;\n\t/** The containers that have a default, so the caller can see the set. */\n\treadonly known: readonly string[] = Object.keys(DEFAULT_IMAGES).sort();\n\n\tconstructor(container: string) {\n\t\tsuper('No image is known for this container; pin one in config');\n\t\tthis.name = 'UnknownContainer';\n\t\tthis.container = container;\n\t}\n}\n\n/** One container's definition, published on the port it was assigned. */\nfunction define(\n\tcontainer: string,\n\timage: string,\n\tpublished: string[],\n\tcredentials: ContainerCredentials,\n): ComposeService {\n\tswitch (container) {\n\t\tcase 'postgres':\n\t\t\treturn {\n\t\t\t\timage,\n\t\t\t\trestart: 'unless-stopped',\n\t\t\t\tports: published,\n\t\t\t\tenvironment: {\n\t\t\t\t\t// Read only when the volume is first initialised. A volume made\n\t\t\t\t\t// with another login is rotated to this one by reconcile — see\n\t\t\t\t\t// `logins.ts` — rather than being trusted to follow.\n\t\t\t\t\tPOSTGRES_USER: credentials.postgres.user,\n\t\t\t\t\tPOSTGRES_PASSWORD: credentials.postgres.password,\n\t\t\t\t\t// Every declared database is created inside this cluster by the\n\t\t\t\t\t// applier, not by the image; connections open `postgres` first.\n\t\t\t\t\tPOSTGRES_DB: CLUSTER_DATABASE,\n\t\t\t\t},\n\t\t\t\t// One mount at the parent, not at `data`: the 18 image keeps its\n\t\t\t\t// cluster in a version-named subdirectory and refuses to start when\n\t\t\t\t// something is mounted over the legacy path. Mounting the parent is\n\t\t\t\t// also what makes the next major bump a `pg_upgrade --link` rather\n\t\t\t\t// than a new volume.\n\t\t\t\tvolumes: ['postgres-data:/var/lib/postgresql'],\n\t\t\t\thealthcheck: {\n\t\t\t\t\ttest: [\n\t\t\t\t\t\t'CMD-SHELL',\n\t\t\t\t\t\t`pg_isready -U ${credentials.postgres.user} -d ${CLUSTER_DATABASE}`,\n\t\t\t\t\t],\n\t\t\t\t\tinterval: '5s',\n\t\t\t\t\ttimeout: '3s',\n\t\t\t\t\tretries: 10,\n\t\t\t\t\tstart_period: '10s',\n\t\t\t\t},\n\t\t\t};\n\n\t\tcase 'minio':\n\t\t\treturn {\n\t\t\t\timage,\n\t\t\t\trestart: 'unless-stopped',\n\t\t\t\tports: published,\n\t\t\t\tenvironment: {\n\t\t\t\t\t// Read on every start, so a changed login takes effect when the\n\t\t\t\t\t// container is recreated with it; the buckets stay.\n\t\t\t\t\tMINIO_ROOT_USER: credentials.minio.user,\n\t\t\t\t\tMINIO_ROOT_PASSWORD: credentials.minio.password,\n\t\t\t\t},\n\t\t\t\t// No bucket is created here: buckets are planned resources, and\n\t\t\t\t// creating them in the entrypoint would put their names back in the\n\t\t\t\t// compose file — the declaration this change removes.\n\t\t\t\tcommand: 'server --console-address \":9001\" /data',\n\t\t\t\tvolumes: ['minio-data:/data'],\n\t\t\t\thealthcheck: {\n\t\t\t\t\ttest: ['CMD', 'mc', 'ready', 'local'],\n\t\t\t\t\tinterval: '10s',\n\t\t\t\t\ttimeout: '5s',\n\t\t\t\t\tretries: 5,\n\t\t\t\t\tstart_period: '10s',\n\t\t\t\t},\n\t\t\t};\n\n\t\tcase 'caddy':\n\t\t\treturn {\n\t\t\t\timage,\n\t\t\t\trestart: 'unless-stopped',\n\t\t\t\tports: published,\n\t\t\t\t// Relative to this file, which is at the project root, so the\n\t\t\t\t// mount resolves into `.gkm/` wherever the project lives.\n\t\t\t\tvolumes: [\n\t\t\t\t\t'./.gkm/Caddyfile:/etc/caddy/Caddyfile:ro',\n\t\t\t\t\t// A directory, not a file: every stage writes its own routes into\n\t\t\t\t\t// it, so `gkm test` cannot delete what `gkm dev` is serving.\n\t\t\t\t\t'./.gkm/caddy-sites:/etc/caddy/sites:ro',\n\t\t\t\t\t'caddy-data:/data',\n\t\t\t\t],\n\t\t\t\t// A surface and a site are processes on the *host*, not containers,\n\t\t\t\t// so the edge has to leave Docker's network to reach them. Docker\n\t\t\t\t// Desktop resolves this name already; on Linux it needs saying.\n\t\t\t\textra_hosts: ['host.docker.internal:host-gateway'],\n\t\t\t\thealthcheck: {\n\t\t\t\t\ttest: ['CMD', 'caddy', 'version'],\n\t\t\t\t\tinterval: '10s',\n\t\t\t\t\ttimeout: '5s',\n\t\t\t\t\tretries: 5,\n\t\t\t\t},\n\t\t\t};\n\n\t\tcase 'mailpit':\n\t\t\treturn {\n\t\t\t\timage,\n\t\t\t\trestart: 'unless-stopped',\n\t\t\t\tports: published,\n\t\t\t\tenvironment: {\n\t\t\t\t\t// Accept mail from anything on this network. The URL carries no\n\t\t\t\t\t// credentials locally, which is what the parser's optional `auth`\n\t\t\t\t\t// exists for.\n\t\t\t\t\tMP_SMTP_AUTH_ACCEPT_ANY: '1',\n\t\t\t\t\tMP_SMTP_AUTH_ALLOW_INSECURE: '1',\n\t\t\t\t},\n\t\t\t\thealthcheck: {\n\t\t\t\t\ttest: ['CMD', 'wget', '-q', '--spider', 'http://localhost:8025'],\n\t\t\t\t\tinterval: '10s',\n\t\t\t\t\ttimeout: '5s',\n\t\t\t\t\tretries: 5,\n\t\t\t\t},\n\t\t\t};\n\n\t\tcase 'redis':\n\t\t\treturn {\n\t\t\t\timage,\n\t\t\t\trestart: 'unless-stopped',\n\t\t\t\tports: published,\n\t\t\t\t// The password from the environment, by name, so it is not in the\n\t\t\t\t// container's arguments; `$$` is compose's escape for `$`.\n\t\t\t\t// Through the image's own entrypoint, so it still drops to `redis`.\n\t\t\t\tcommand:\n\t\t\t\t\t'sh -c \\'exec docker-entrypoint.sh redis-server --requirepass \"$$REDIS_PASSWORD\"\\'',\n\t\t\t\tenvironment: {\n\t\t\t\t\tREDIS_PASSWORD: credentials.redis.password,\n\t\t\t\t\t// What `redis-cli` signs in with — the health check's.\n\t\t\t\t\tREDISCLI_AUTH: credentials.redis.password,\n\t\t\t\t},\n\t\t\t\tvolumes: ['redis-data:/data'],\n\t\t\t\thealthcheck: {\n\t\t\t\t\t// Unauthenticated, a ping answers NOAUTH, which is not PONG.\n\t\t\t\t\ttest: ['CMD-SHELL', 'redis-cli ping | grep -q PONG'],\n\t\t\t\t\tinterval: '5s',\n\t\t\t\t\ttimeout: '3s',\n\t\t\t\t\tretries: 5,\n\t\t\t\t},\n\t\t\t};\n\n\t\tcase 'redis-http':\n\t\t\treturn {\n\t\t\t\timage,\n\t\t\t\trestart: 'unless-stopped',\n\t\t\t\tports: published,\n\t\t\t\tenvironment: {\n\t\t\t\t\tSRH_MODE: 'env',\n\t\t\t\t\tSRH_TOKEN: credentials.cacheToken,\n\t\t\t\t\t// The Redis beside it, by compose service name — the one address\n\t\t\t\t\t// in this file that is not published, because nothing outside the\n\t\t\t\t\t// network speaks to it.\n\t\t\t\t\tSRH_CONNECTION_STRING: `redis://:${encodeURIComponent(credentials.redis.password)}@redis:6379`,\n\t\t\t\t},\n\t\t\t\tdepends_on: ['redis'],\n\t\t\t\thealthcheck: {\n\t\t\t\t\t// 127.0.0.1, not localhost: the proxy binds IPv4 only, and\n\t\t\t\t\t// `localhost` resolves to ::1 first inside the container — which\n\t\t\t\t\t// is a health check that never passes and a container that never\n\t\t\t\t\t// comes up.\n\t\t\t\t\ttest: [\n\t\t\t\t\t\t'CMD',\n\t\t\t\t\t\t'wget',\n\t\t\t\t\t\t'-q',\n\t\t\t\t\t\t'-O',\n\t\t\t\t\t\t'/dev/null',\n\t\t\t\t\t\t'http://127.0.0.1:80/',\n\t\t\t\t\t],\n\t\t\t\t\tinterval: '5s',\n\t\t\t\t\ttimeout: '3s',\n\t\t\t\t\tretries: 10,\n\t\t\t\t},\n\t\t\t};\n\n\t\tcase 'rabbitmq':\n\t\t\treturn {\n\t\t\t\timage,\n\t\t\t\trestart: 'unless-stopped',\n\t\t\t\tports: published,\n\t\t\t\tenvironment: {\n\t\t\t\t\t// Read only when the volume is first initialised; reconcile\n\t\t\t\t\t// brings an older volume's users in line — see `logins.ts`.\n\t\t\t\t\tRABBITMQ_DEFAULT_USER: credentials.rabbitmq.user,\n\t\t\t\t\tRABBITMQ_DEFAULT_PASS: credentials.rabbitmq.password,\n\t\t\t\t},\n\t\t\t\tvolumes: ['rabbitmq-data:/var/lib/rabbitmq'],\n\t\t\t\thealthcheck: {\n\t\t\t\t\ttest: ['CMD', 'rabbitmq-diagnostics', '-q', 'ping'],\n\t\t\t\t\tinterval: '10s',\n\t\t\t\t\ttimeout: '5s',\n\t\t\t\t\tretries: 5,\n\t\t\t\t},\n\t\t\t};\n\n\t\tcase 'localstack':\n\t\t\treturn {\n\t\t\t\timage,\n\t\t\t\trestart: 'unless-stopped',\n\t\t\t\tports: published,\n\t\t\t\t// SNS pushes to subscribers on the host — the dev server — and only\n\t\t\t\t// Docker Desktop resolves host.docker.internal on its own. On Linux\n\t\t\t\t// the name has to be mapped, or every push is refused.\n\t\t\t\textra_hosts: ['host.docker.internal:host-gateway'],\n\t\t\t\tenvironment: {\n\t\t\t\t\tAWS_DEFAULT_REGION: EMULATOR_REGION,\n\t\t\t\t\tAWS_ACCESS_KEY_ID: credentials.emulator.accessKeyId,\n\t\t\t\t\tAWS_SECRET_ACCESS_KEY: credentials.emulator.secretAccessKey,\n\t\t\t\t},\n\t\t\t\tvolumes: ['localstack-data:/var/lib/localstack'],\n\t\t\t\thealthcheck: {\n\t\t\t\t\t// Bash, not curl: the floci image ships no curl, so a curl check\n\t\t\t\t\t// never passes and `--wait` fails every start. A TCP connect is\n\t\t\t\t\t// the fact a waiter needs — the gateway binds the port once its\n\t\t\t\t\t// HTTP server is up — and the repo's own compose file does the\n\t\t\t\t\t// same.\n\t\t\t\t\ttest: ['CMD', 'bash', '-c', 'exec 3<>/dev/tcp/localhost/4566'],\n\t\t\t\t\tinterval: '10s',\n\t\t\t\t\ttimeout: '5s',\n\t\t\t\t\tretries: 5,\n\t\t\t\t\tstart_period: '10s',\n\t\t\t\t},\n\t\t\t};\n\n\t\tcase 'openobserve': {\n\t\t\t// The compose stack's own service, with the local stage's login and\n\t\t\t// the default retention — what `gkm compose` on the local stage runs.\n\t\t\tconst login = credentials.logs;\n\t\t\treturn {\n\t\t\t\timage,\n\t\t\t\trestart: 'unless-stopped',\n\t\t\t\tports: published,\n\t\t\t\tenvironment: {\n\t\t\t\t\t[LOGS_EMAIL_KEY]: login.email,\n\t\t\t\t\t[LOGS_PASSWORD_KEY]: login.password,\n\t\t\t\t\tZO_DATA_DIR: '/data',\n\t\t\t\t\tZO_COMPACT_DATA_RETENTION_DAYS: String(LOGS_RETENTION_DAYS),\n\t\t\t\t\t// A local log store does not report home.\n\t\t\t\t\tZO_TELEMETRY: 'false',\n\t\t\t\t},\n\t\t\t\tvolumes: ['openobserve-data:/data'],\n\t\t\t\t// The image has no shell, `wget` or `curl`: its own binary asks the\n\t\t\t\t// running server for its status.\n\t\t\t\thealthcheck: {\n\t\t\t\t\ttest: ['CMD', '/openobserve', 'node', 'status'],\n\t\t\t\t\tinterval: '10s',\n\t\t\t\t\ttimeout: '5s',\n\t\t\t\t\tretries: 12,\n\t\t\t\t\tstart_period: '20s',\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\n\t\tdefault:\n\t\t\tthrow new UnknownContainer(container);\n\t}\n}\n\n/**\n * The published port mappings for a container.\n *\n * Every port is looked up by its own key rather than being derived as an offset\n * from the container's first, so MinIO's console cannot land on whatever was\n * allocated to the next container.\n */\nfunction publish(\n\tcontainer: string,\n\tports: PortAssignments,\n\tfakes?: Plan['fakes'],\n): string[] {\n\treturn portsOf(container, fakes).map((port) => {\n\t\tconst assigned = ports[port.key];\n\t\tif (assigned === undefined) throw new UnassignedPort(port.key);\n\n\t\treturn `${assigned}:${port.inside}`;\n\t});\n}\n\n/** A planned port that allocation never assigned. */\nexport class UnassignedPort extends Error {\n\t/** The port key that went unassigned, e.g. `minio-console`. */\n\treadonly key: string;\n\n\tconstructor(key: string) {\n\t\tsuper('No port was assigned for this container port');\n\t\tthis.name = 'UnassignedPort';\n\t\tthis.key = key;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwBA,SAAgB,SACf,OACqB;CACrB,IAAI,MAAM,WAAW,GAAG,OAAO,KAAA;CAG/B,IAAI,MAAM,WAAW,GAAG,OAAO,MAAM,EAAE,CAAE;CAGzC,IAAI,MAAM,MAAM,EAAE,WAAW,SAAS,KAAK,GAAG,OAAO;CAGrD,MAAM,WAAW,MAAM,QAAQ,EAAE,WAAW,SAAS,IAAI;CACzD,IAAI,SAAS,WAAW,GAAG,OAAO,SAAS,EAAE,CAAE;CAE/C,MAAM,IAAI,kBACT,MAAM,KAAK,EAAE,WAAW,IAAI,GAC5B,SAAS,SAAS,CACnB;AACD;;AAGA,IAAa,oBAAb,cAAuCA,eAA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AAM,KAAK;EAC5B,IAAI,aAAa,KAAA,GAAW,MAAM,IAAI,eAAe,KAAK,GAAG;EAE7D,OAAO,GAAG,SAAS,GAAG,KAAK;CAC5B,CAAC;AACF;;AAGA,IAAa,iBAAb,cAAoC,MAAM;;CAEzC;CAEA,YAAY,KAAa;EACxB,MAAM,8CAA8C;EACpD,KAAK,OAAO;EACZ,KAAK,MAAM;CACZ;AACD"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-BhDjJH2R.mjs";
|
|
2
2
|
import { t as GkmError } from "./errors-D8Gwp5kU.mjs";
|
|
3
|
-
import { F as toEmbeddableSecrets, M as initStageSecrets, Q as imageRef, a as findRootDomain, m as createComposeState, o as normalizeDnsConfig, ot as run, st as runOutput, v as recordRelease } from "./credentials-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
3
|
+
import { F as toEmbeddableSecrets, M as initStageSecrets, Q as imageRef, a as findRootDomain, m as createComposeState, o as normalizeDnsConfig, ot as run, st as runOutput, v as recordRelease } from "./credentials-C2VfI-uf.mjs";
|
|
4
|
+
import { B as LOGS_PORT, Dt as ComposeTlsFileMissing, Ft as SERVER_IPV4_KEY, L as resolveStageTelemetry, Rt as isReservedStageKey } from "./workspace-B0PI9k9p.mjs";
|
|
5
|
+
import { C as ensureLocalCertificate, Dt as envFor, E as readLocalAuthority, F as imageLayout, H as findBuildRoot, P as fromBuildRoot, S as ensureLocalAuthority, T as localCertificateNames, Z as nextPrerenderManifest, _t as applyLifecycles, b as bucketClient, bt as applyPostgres, d as backendsOf, f as constructGlobs, gt as applyBuckets, kt as stageEnv, l as workerEnvKeys, pt as backupsRoleStatements, t as appEnvKeys, ut as BACKUPS_SERVICE, v as LEGACY_LOCAL_LOGIN, vt as applyNotifications, wt as postgresStatements, x as pgClient, y as ensurePostgresLogin, yt as applyPolicies } from "./apps-DrXwv-0A.mjs";
|
|
6
6
|
import { t as defineTarget } from "./define-6poNqm5O.mjs";
|
|
7
|
-
import { E as withRedisPassword,
|
|
7
|
+
import { E as withRedisPassword, R as usesTelemetry, Tt as withLogsPassword, _t as LOGS_SERVICE, dt as primaryPortKey, m as loadLocalCredentials, vt as LogsPortTaken, w as runsRedis, x as REDIS_SERVICE, y as withGeneratedSecrets, yt as logsAccess } from "./compose-BLOnkeaJ.mjs";
|
|
8
8
|
import { i as discover } from "./discover-B_PDDaVj.mjs";
|
|
9
|
-
import { C as
|
|
10
|
-
import { a as ensureDockerignore } from "./docker-
|
|
11
|
-
import { _ as stageDns, a as subscriptionKey, c as HostNotPointingAtServer, g as stackHosts, i as recordedPushSubscriptions, m as serverAddressHint, n as SUBSCRIPTION_TYPE, o as subscriptionResource, p as requiredServerAddress, r as confirmPendingSubscriptions, s as topicConnection, t as PushSubscriptionsUnconfirmed, u as isLocalHost, y as systemLookup } from "./snsSubscriptions-
|
|
9
|
+
import { C as readEdgeClaims, D as assertImagesExist, E as RegistryRequired, S as edgeComposeFile, _ as EDGE_DYNAMIC_DIR, a as composeProject, b as EDGE_SERVICE, d as stackDir, g as EDGE_CERTS_DIR, h as EDGE_AWS_CREDENTIALS, i as LOOPBACK_SERVICES, k as pinImages, l as envFile, m as withLogsPort, n as LOGS_PORT_ENV, o as composeStack, p as withCaddyConfigs, r as LOG_ROTATION, t as EDGE_PORT_ENV, u as replicaNames, v as EDGE_NETWORK, w as traefikStaticFile, x as claimsOverlap, y as EDGE_PROJECT } from "./stack-j2e8ddGl.mjs";
|
|
10
|
+
import { a as ensureDockerignore } from "./docker-De_-Ll-A.mjs";
|
|
11
|
+
import { _ as stageDns, a as subscriptionKey, c as HostNotPointingAtServer, g as stackHosts, i as recordedPushSubscriptions, m as serverAddressHint, n as SUBSCRIPTION_TYPE, o as subscriptionResource, p as requiredServerAddress, r as confirmPendingSubscriptions, s as topicConnection, t as PushSubscriptionsUnconfirmed, u as isLocalHost, y as systemLookup } from "./snsSubscriptions-7y2XBXde.mjs";
|
|
12
12
|
import { i as installedFrom } from "./drivers-wcDnzf7l.mjs";
|
|
13
13
|
import { d as dnsResources, f as forgetDnsResource, i as currentActor, n as reportDatabaseRuns, p as recordDnsChanges, r as reportPlannedSeeds, s as DeployJournal, t as DeploySeedsFailed, u as dnsResourceKey } from "./seeds-Ccn0Ru2T.mjs";
|
|
14
14
|
import { f as plannedSeeds, o as SeedFailed, p as seedDatabases, u as migrateDatabases } from "./databases-zN-gEox0.mjs";
|
|
@@ -1774,6 +1774,7 @@ async function validateCompose(ctx, deps, options = {}) {
|
|
|
1774
1774
|
if (mode === "build") assertRedisClient(workspace, composed, manifest);
|
|
1775
1775
|
const pinned = (unpinned) => options.pin ? withPinnedImages(unpinned, options.pin.file, options.pin.digests) : unpinned;
|
|
1776
1776
|
const stack = pinned(composed);
|
|
1777
|
+
for (const warning of stack.warnings) ctx.logger.warn(`⚠ ${warning}`);
|
|
1777
1778
|
if (mode === "pull" && !ctx.dryRun) await assertImagesExist(deps.docker, tag, [
|
|
1778
1779
|
...stack.apps,
|
|
1779
1780
|
...stack.workers,
|
|
@@ -1863,6 +1864,7 @@ async function readyCompose(ctx, run, deps) {
|
|
|
1863
1864
|
}
|
|
1864
1865
|
if (run.server && !ctx.dryRun && !run.push) await deps.server.check(run.server);
|
|
1865
1866
|
await edgeHostsFree(ctx, run, deps);
|
|
1867
|
+
await logsPortOnServer(ctx, run, deps);
|
|
1866
1868
|
const prune = await stageHostsDns(ctx, deps, stackHosts(stack).filter((host) => !isLocalHost(host)), run.secrets?.custom, stack.wildcard?.host);
|
|
1867
1869
|
if (prune) run.pruneDns = prune;
|
|
1868
1870
|
}
|
|
@@ -1882,6 +1884,57 @@ async function edgeHostsFree(ctx, run, deps) {
|
|
|
1882
1884
|
...ref.output ? { output: ref.output } : {}
|
|
1883
1885
|
}), stack.project, stack.traefik);
|
|
1884
1886
|
}
|
|
1887
|
+
/** How many ports past the first a stage's OpenObserve is tried on. */
|
|
1888
|
+
const LOGS_PORT_TRIES = 100;
|
|
1889
|
+
/**
|
|
1890
|
+
* The loopback port the stack's OpenObserve is published on, settled against
|
|
1891
|
+
* what every other stack on the server publishes — before anything is
|
|
1892
|
+
* written, so two stages on one machine cannot both take `5080` and fail at
|
|
1893
|
+
* `up`.
|
|
1894
|
+
*
|
|
1895
|
+
* - A port the stage named is refused when another project holds it.
|
|
1896
|
+
* - Otherwise the stack keeps the port it already publishes, or takes the
|
|
1897
|
+
* first from the default up that no other project holds — and the stack,
|
|
1898
|
+
* its tunnel line included, is moved onto it.
|
|
1899
|
+
*
|
|
1900
|
+
* Asked of the server's engine, so not on a dry run, a push, or the local
|
|
1901
|
+
* stage; nor for a log UI served through the edge, which publishes nothing.
|
|
1902
|
+
*
|
|
1903
|
+
* @throws {LogsPortTaken}
|
|
1904
|
+
*/
|
|
1905
|
+
async function logsPortOnServer(ctx, run, deps) {
|
|
1906
|
+
const logs = run.stack.logs;
|
|
1907
|
+
if (!logs || logs.public || run.stack.local) return;
|
|
1908
|
+
if (ctx.dryRun || run.push || !run.server) return;
|
|
1909
|
+
const engine = run.ref.host ? { host: run.ref.host } : {};
|
|
1910
|
+
const project = run.ref.project;
|
|
1911
|
+
const holder = async (port) => {
|
|
1912
|
+
const others = (await deps.docker.publishers(engine, port)).filter((held) => held.project !== project);
|
|
1913
|
+
return others[0] && (others[0].project ?? others[0].container);
|
|
1914
|
+
};
|
|
1915
|
+
if (logs.portSet) {
|
|
1916
|
+
const taken = await holder(logs.port);
|
|
1917
|
+
if (taken) throw new LogsPortTaken(ctx.stage, logs.port, taken, true);
|
|
1918
|
+
return;
|
|
1919
|
+
}
|
|
1920
|
+
const kept = await deps.docker.published(engine, project, LOGS_SERVICE, LOGS_PORT);
|
|
1921
|
+
let port = kept;
|
|
1922
|
+
if (port === void 0) {
|
|
1923
|
+
let taken;
|
|
1924
|
+
for (let next = logs.port; next < logs.port + LOGS_PORT_TRIES; next++) {
|
|
1925
|
+
taken = await holder(next);
|
|
1926
|
+
if (!taken) {
|
|
1927
|
+
port = next;
|
|
1928
|
+
break;
|
|
1929
|
+
}
|
|
1930
|
+
}
|
|
1931
|
+
if (port === void 0) throw new LogsPortTaken(ctx.stage, logs.port, taken ?? "", false);
|
|
1932
|
+
}
|
|
1933
|
+
if (port !== logs.port) {
|
|
1934
|
+
ctx.logger.info(kept === void 0 ? `📜 OpenObserve: ${logs.port} is another stack's on this server, so "${ctx.stage}" publishes ${port}` : `📜 OpenObserve: "${ctx.stage}" keeps ${port}, the port it already publishes`);
|
|
1935
|
+
run.stack = withLogsPort(run.stack, port);
|
|
1936
|
+
}
|
|
1937
|
+
}
|
|
1885
1938
|
/** A stack whose caches are in Redis, built for an app that has no client. */
|
|
1886
1939
|
var RedisClientMissing = class extends GkmError {
|
|
1887
1940
|
apps;
|
|
@@ -3136,4 +3189,4 @@ function composeTarget(options = {}) {
|
|
|
3136
3189
|
//#endregion
|
|
3137
3190
|
export { projectNetwork as _, edgePorts as a, edgeRef as c, dockerHost as d, sshAccess as f, dockerCompose as g, ContainersNotStopped as h, ComposePushNeedsBuild as i, removeEdgeRoutes as l, ContainersNotStarted as m, compose_exports as n, stackOverrideFile as o, sshTarget as p, ComposePinNeedsPull as r, deployedStackSecrets as s, composeTarget as t, composeServer as u };
|
|
3138
3191
|
|
|
3139
|
-
//# sourceMappingURL=compose-
|
|
3192
|
+
//# sourceMappingURL=compose-iUOeazjW.mjs.map
|