@geekmidas/cli 10.0.0-alpha.167 → 10.0.0-alpha.169
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/{EndpointGenerator-DxrRqfJ3.cjs → EndpointGenerator-C1h_wExz.cjs} +2 -2
- package/dist/{EndpointGenerator-DxrRqfJ3.cjs.map → EndpointGenerator-C1h_wExz.cjs.map} +1 -1
- package/dist/{EndpointGenerator-B5BKAoLz.mjs → EndpointGenerator-CSKhAD6W.mjs} +2 -2
- package/dist/{EndpointGenerator-B5BKAoLz.mjs.map → EndpointGenerator-CSKhAD6W.mjs.map} +1 -1
- package/dist/{GoDaddyProvider-Dci0SlN5.mjs → GoDaddyProvider-Cvmy2SPq.mjs} +2 -2
- package/dist/{GoDaddyProvider-Dci0SlN5.mjs.map → GoDaddyProvider-Cvmy2SPq.mjs.map} +1 -1
- package/dist/{GoDaddyProvider-o6DJAsBZ.cjs → GoDaddyProvider-KmdZlFSL.cjs} +2 -2
- package/dist/{GoDaddyProvider-o6DJAsBZ.cjs.map → GoDaddyProvider-KmdZlFSL.cjs.map} +1 -1
- package/dist/{HostingerProvider-BzHPhONW.cjs → HostingerProvider--IyQKlIC.cjs} +2 -2
- package/dist/{HostingerProvider-BzHPhONW.cjs.map → HostingerProvider--IyQKlIC.cjs.map} +1 -1
- package/dist/{HostingerProvider-Dd5x1zvF.mjs → HostingerProvider-DYf1XT_W.mjs} +2 -2
- package/dist/{HostingerProvider-Dd5x1zvF.mjs.map → HostingerProvider-DYf1XT_W.mjs.map} +1 -1
- package/dist/{LegacyStateStore-tqY0hM8z.cjs → LegacyStateStore-8GVMHI12.cjs} +2 -2
- package/dist/{LegacyStateStore-tqY0hM8z.cjs.map → LegacyStateStore-8GVMHI12.cjs.map} +1 -1
- package/dist/{LegacyStateStore-CpF6rmZc.mjs → LegacyStateStore-BOZj8nj1.mjs} +2 -2
- package/dist/{LegacyStateStore-CpF6rmZc.mjs.map → LegacyStateStore-BOZj8nj1.mjs.map} +1 -1
- package/dist/{LocalStateStore-BYMUEGZN.cjs → LocalStateStore-CfBABk6G.cjs} +2 -2
- package/dist/{LocalStateStore-BYMUEGZN.cjs.map → LocalStateStore-CfBABk6G.cjs.map} +1 -1
- package/dist/{LocalStateStore-Adp96xPy.mjs → LocalStateStore-D3wY7Qkb.mjs} +2 -2
- package/dist/{LocalStateStore-Adp96xPy.mjs.map → LocalStateStore-D3wY7Qkb.mjs.map} +1 -1
- package/dist/{OpenApiTsGenerator-Vaf0pI8u.mjs → OpenApiTsGenerator-5xPn-p65.mjs} +2 -2
- package/dist/{OpenApiTsGenerator-Vaf0pI8u.mjs.map → OpenApiTsGenerator-5xPn-p65.mjs.map} +1 -1
- package/dist/{OpenApiTsGenerator-DOTLKBFf.cjs → OpenApiTsGenerator-CzrLGzC0.cjs} +2 -2
- package/dist/{OpenApiTsGenerator-DOTLKBFf.cjs.map → OpenApiTsGenerator-CzrLGzC0.cjs.map} +1 -1
- package/dist/{S3StateStore-DjXyhGIP.cjs → S3StateStore-C-Fs7CWD.cjs} +4 -4
- package/dist/{S3StateStore-DjXyhGIP.cjs.map → S3StateStore-C-Fs7CWD.cjs.map} +1 -1
- package/dist/{S3StateStore-13Go3hfM.mjs → S3StateStore-CO92LBQI.mjs} +4 -4
- package/dist/{S3StateStore-13Go3hfM.mjs.map → S3StateStore-CO92LBQI.mjs.map} +1 -1
- package/dist/{SSMStateStore-CQHUyH-c.mjs → SSMStateStore-Ns7FpnmB.mjs} +2 -2
- package/dist/{SSMStateStore-CQHUyH-c.mjs.map → SSMStateStore-Ns7FpnmB.mjs.map} +1 -1
- package/dist/{SSMStateStore-DspMPho-.cjs → SSMStateStore-t6mkXQew.cjs} +2 -2
- package/dist/{SSMStateStore-DspMPho-.cjs.map → SSMStateStore-t6mkXQew.cjs.map} +1 -1
- package/dist/{SubscriberGenerator-BybB6uez.mjs → SubscriberGenerator-CfZWX0lT.mjs} +6 -6
- package/dist/SubscriberGenerator-CfZWX0lT.mjs.map +1 -0
- package/dist/{SubscriberGenerator-mZpSuSU7.cjs → SubscriberGenerator-DMi4siph.cjs} +5 -5
- package/dist/SubscriberGenerator-DMi4siph.cjs.map +1 -0
- package/dist/{add-Dt8QKSOw.mjs → add-Byp8-rRf.mjs} +11 -11
- package/dist/add-Byp8-rRf.mjs.map +1 -0
- package/dist/{add-DsxJ0Knr.cjs → add-C3oUiBAc.cjs} +10 -10
- package/dist/add-C3oUiBAc.cjs.map +1 -0
- package/dist/{apps-w2sRQKCr.mjs → apps-C21-TXqR.mjs} +106 -50
- package/dist/apps-C21-TXqR.mjs.map +1 -0
- package/dist/{apps-C6s-trVp.cjs → apps-D_-DXV0H.cjs} +110 -48
- package/dist/apps-D_-DXV0H.cjs.map +1 -0
- package/dist/{bundler-AzkSRAuu.cjs → bundler-D43S2YTJ.cjs} +6 -6
- package/dist/{bundler-AzkSRAuu.cjs.map → bundler-D43S2YTJ.cjs.map} +1 -1
- package/dist/{bundler-BCWWne6N.mjs → bundler-DjfpJ0mX.mjs} +6 -6
- package/dist/{bundler-BCWWne6N.mjs.map → bundler-DjfpJ0mX.mjs.map} +1 -1
- package/dist/{cli-DSGw0Mw-.mjs → cli-00fMnBFk.mjs} +4 -4
- package/dist/{cli-DSGw0Mw-.mjs.map → cli-00fMnBFk.mjs.map} +1 -1
- package/dist/{cli-OGss08bZ.cjs → cli-CYBb8rgx.cjs} +4 -4
- package/dist/{cli-OGss08bZ.cjs.map → cli-CYBb8rgx.cjs.map} +1 -1
- package/dist/{compose-QSBmhr4V.cjs → compose-D9ksPt5H.cjs} +11 -11
- package/dist/compose-D9ksPt5H.cjs.map +1 -0
- package/dist/{compose-BqTuzitb.cjs → compose-Dgd-yfJT.cjs} +8 -8
- package/dist/compose-Dgd-yfJT.cjs.map +1 -0
- package/dist/{compose-Csegtvq_.mjs → compose-MwgjPj_A.mjs} +12 -12
- package/dist/compose-MwgjPj_A.mjs.map +1 -0
- package/dist/{compose-RhuFQmZS.mjs → compose-rn_DWcup.mjs} +9 -9
- package/dist/compose-rn_DWcup.mjs.map +1 -0
- package/dist/config.cjs +2 -2
- package/dist/config.mjs +2 -2
- package/dist/{credentialSchemas-mz9QZTYh.mjs → credentialSchemas-BzJiK1nQ.mjs} +4 -4
- package/dist/credentialSchemas-BzJiK1nQ.mjs.map +1 -0
- package/dist/{credentialSchemas-BAklWDna.cjs → credentialSchemas-OVXofU-r.cjs} +3 -3
- package/dist/credentialSchemas-OVXofU-r.cjs.map +1 -0
- package/dist/{credentials-CORvhcrO.cjs → credentials-C6n_kdu4.cjs} +7 -7
- package/dist/{credentials-CORvhcrO.cjs.map → credentials-C6n_kdu4.cjs.map} +1 -1
- package/dist/{credentials-D4DUPPPP.mjs → credentials-kK0X754I.mjs} +7 -7
- package/dist/{credentials-D4DUPPPP.mjs.map → credentials-kK0X754I.mjs.map} +1 -1
- package/dist/{databases-CrKh5jw6.cjs → databases-CuTL1e7s.cjs} +3 -3
- package/dist/databases-CuTL1e7s.cjs.map +1 -0
- package/dist/{databases-C1qqNxTu.mjs → databases-zN-gEox0.mjs} +4 -4
- package/dist/databases-zN-gEox0.mjs.map +1 -0
- package/dist/deploy/public.cjs +12 -12
- package/dist/deploy/public.mjs +12 -12
- package/dist/{deploy-BwJ7uWXd.cjs → deploy-C1gf4bT-.cjs} +47 -45
- package/dist/deploy-C1gf4bT-.cjs.map +1 -0
- package/dist/{deploy-DDfnQm8l.mjs → deploy-CFuDCbTq.mjs} +48 -46
- package/dist/deploy-CFuDCbTq.mjs.map +1 -0
- package/dist/{destroy-nTNRfdy6.cjs → destroy-CMz0BPEe.cjs} +9 -9
- package/dist/{destroy-nTNRfdy6.cjs.map → destroy-CMz0BPEe.cjs.map} +1 -1
- package/dist/{destroy-DKt8S051.mjs → destroy-UTWZmaGn.mjs} +9 -9
- package/dist/{destroy-DKt8S051.mjs.map → destroy-UTWZmaGn.mjs.map} +1 -1
- package/dist/{discover-CRywE7yc.cjs → discover-39VKSE2i.cjs} +5 -5
- package/dist/discover-39VKSE2i.cjs.map +1 -0
- package/dist/{discover-DbDrCQ8h.mjs → discover-B_PDDaVj.mjs} +6 -6
- package/dist/discover-B_PDDaVj.mjs.map +1 -0
- package/dist/{docker-Ele34O8z.mjs → docker-BIuidyEB.mjs} +11 -11
- package/dist/docker-BIuidyEB.mjs.map +1 -0
- package/dist/{docker-Dy1ZJUzV.cjs → docker-BrdCdNwm.cjs} +10 -10
- package/dist/docker-BrdCdNwm.cjs.map +1 -0
- package/dist/{dokploy-BrfA2m5K.mjs → dokploy--ndQ72iu.mjs} +2 -2
- package/dist/{dokploy-BrfA2m5K.mjs.map → dokploy--ndQ72iu.mjs.map} +1 -1
- package/dist/{dokploy-DN2W1YIH.cjs → dokploy-D7ZChrtZ.cjs} +2 -2
- package/dist/{dokploy-DN2W1YIH.cjs.map → dokploy-D7ZChrtZ.cjs.map} +1 -1
- package/dist/{eas-CO3ogve5.mjs → eas-BCcpBC4k.mjs} +3 -3
- package/dist/{eas-CO3ogve5.mjs.map → eas-BCcpBC4k.mjs.map} +1 -1
- package/dist/{eas-BRBdxmwe.cjs → eas-DCvA907G.cjs} +3 -3
- package/dist/{eas-BRBdxmwe.cjs.map → eas-DCvA907G.cjs.map} +1 -1
- package/dist/{encryption-BZ1zgtF5.cjs → encryption-8TklMCh2.cjs} +4 -4
- package/dist/encryption-8TklMCh2.cjs.map +1 -0
- package/dist/{encryption-CHmfNBAy.mjs → encryption-C2LzfQp8.mjs} +5 -5
- package/dist/encryption-C2LzfQp8.mjs.map +1 -0
- package/dist/{engine-DewbDHOq.cjs → engine-BMoNLayn.cjs} +37 -37
- package/dist/engine-BMoNLayn.cjs.map +1 -0
- package/dist/{engine-B3Gmu8-O.mjs → engine-D-_nkxQL.mjs} +38 -38
- package/dist/engine-D-_nkxQL.mjs.map +1 -0
- package/dist/{github-DU3iEmJN.mjs → github-B_zfStMR.mjs} +8 -8
- package/dist/{github-DU3iEmJN.mjs.map → github-B_zfStMR.mjs.map} +1 -1
- package/dist/{github-DPNgIxdc.cjs → github-CZjNDPAp.cjs} +8 -8
- package/dist/{github-DPNgIxdc.cjs.map → github-CZjNDPAp.cjs.map} +1 -1
- package/dist/{googlePlay-KPHn9H2f.mjs → googlePlay-BcVRYMh4.mjs} +4 -4
- package/dist/{googlePlay-KPHn9H2f.mjs.map → googlePlay-BcVRYMh4.mjs.map} +1 -1
- package/dist/{googlePlay-C2jnPqYn.cjs → googlePlay-Btn0lut5.cjs} +4 -4
- package/dist/{googlePlay-C2jnPqYn.cjs.map → googlePlay-Btn0lut5.cjs.map} +1 -1
- package/dist/{iam-C2sf6AUi.cjs → iam-BoYPPNdM.cjs} +2 -2
- package/dist/{iam-C2sf6AUi.cjs.map → iam-BoYPPNdM.cjs.map} +1 -1
- package/dist/{iam-CW61VcT3.mjs → iam-ra1_Y405.mjs} +2 -2
- package/dist/{iam-CW61VcT3.mjs.map → iam-ra1_Y405.mjs.map} +1 -1
- package/dist/index.cjs +79 -79
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +80 -80
- package/dist/index.mjs.map +1 -1
- package/dist/{local-CwR2DW6i.mjs → local-B9Vniy-F.mjs} +3 -3
- package/dist/{local-CwR2DW6i.mjs.map → local-B9Vniy-F.mjs.map} +1 -1
- package/dist/{local-BxjA0EXj.cjs → local-DxfqOu7A.cjs} +3 -3
- package/dist/{local-BxjA0EXj.cjs.map → local-DxfqOu7A.cjs.map} +1 -1
- package/dist/{migrate-B0a3WY4X.cjs → migrate-C1u7Tl7D.cjs} +7 -7
- package/dist/{migrate-B0a3WY4X.cjs.map → migrate-C1u7Tl7D.cjs.map} +1 -1
- package/dist/{migrate-CYtM1UBH.cjs → migrate-CcYfCpMe.cjs} +3 -3
- package/dist/{migrate-CYtM1UBH.cjs.map → migrate-CcYfCpMe.cjs.map} +1 -1
- package/dist/{migrate-vWy2CUoi.mjs → migrate-b5rcr4sw.mjs} +7 -7
- package/dist/{migrate-vWy2CUoi.mjs.map → migrate-b5rcr4sw.mjs.map} +1 -1
- package/dist/{migrate-DHWy64pc.mjs → migrate-blnmh2Tm.mjs} +3 -3
- package/dist/{migrate-DHWy64pc.mjs.map → migrate-blnmh2Tm.mjs.map} +1 -1
- package/dist/{notes-9bOfe08J.mjs → notes-CT1jNLDC.mjs} +13 -12
- package/dist/notes-CT1jNLDC.mjs.map +1 -0
- package/dist/{notes-DRdlsCYV.cjs → notes-Cw3JQ0Y_.cjs} +12 -11
- package/dist/notes-Cw3JQ0Y_.cjs.map +1 -0
- package/dist/openapi.cjs +3 -3
- package/dist/openapi.mjs +3 -3
- package/dist/{projectBucket-gIQUuhGm.cjs → projectBucket-8hJmCusk.cjs} +2 -2
- package/dist/{projectBucket-gIQUuhGm.cjs.map → projectBucket-8hJmCusk.cjs.map} +1 -1
- package/dist/{projectBucket-Cd7sEDhG.mjs → projectBucket-DJNi2yJL.mjs} +2 -2
- package/dist/{projectBucket-Cd7sEDhG.mjs.map → projectBucket-DJNi2yJL.mjs.map} +1 -1
- package/dist/{publish-DOxz4mxf.mjs → publish-CMaPsMsT.mjs} +2 -2
- package/dist/{publish-DOxz4mxf.mjs.map → publish-CMaPsMsT.mjs.map} +1 -1
- package/dist/{publish-BgDFx08y.cjs → publish-Dlb-rrc5.cjs} +2 -2
- package/dist/{publish-BgDFx08y.cjs.map → publish-Dlb-rrc5.cjs.map} +1 -1
- package/dist/{ready-BjFMu_1J.mjs → ready-COJHr1Yi.mjs} +9 -9
- package/dist/ready-COJHr1Yi.mjs.map +1 -0
- package/dist/{ready-eVMJIcWn.cjs → ready-DcD0SCnV.cjs} +8 -8
- package/dist/ready-DcD0SCnV.cjs.map +1 -0
- package/dist/reconcile/public.cjs +1 -1
- package/dist/reconcile/public.mjs +1 -1
- package/dist/{resolve-BhQd4IkT.cjs → resolve-BKn4TTn3.cjs} +4 -4
- package/dist/{resolve-BhQd4IkT.cjs.map → resolve-BKn4TTn3.cjs.map} +1 -1
- package/dist/{resolve-CdDyPOE8.mjs → resolve-DrFS2Ivb.mjs} +4 -4
- package/dist/{resolve-CdDyPOE8.mjs.map → resolve-DrFS2Ivb.mjs.map} +1 -1
- package/dist/{rollback-Brc-_HBJ.cjs → rollback-6ZeoByXd.cjs} +7 -7
- package/dist/{rollback-Brc-_HBJ.cjs.map → rollback-6ZeoByXd.cjs.map} +1 -1
- package/dist/{rollback-CLBKeSMl.mjs → rollback-B3lHgwkj.mjs} +7 -7
- package/dist/{rollback-CLBKeSMl.mjs.map → rollback-B3lHgwkj.mjs.map} +1 -1
- package/dist/{s3-CuLmr6Q9.cjs → s3-Cq1_F2J8.cjs} +3 -3
- package/dist/{s3-CuLmr6Q9.cjs.map → s3-Cq1_F2J8.cjs.map} +1 -1
- package/dist/{s3-D0BIG_ml.mjs → s3-DfAM0soB.mjs} +3 -3
- package/dist/{s3-D0BIG_ml.mjs.map → s3-DfAM0soB.mjs.map} +1 -1
- package/dist/sandbox/credentials-worker.cjs +2 -2
- package/dist/sandbox/credentials-worker.mjs +2 -2
- package/dist/sandbox/discover-worker.cjs +1 -1
- package/dist/sandbox/discover-worker.mjs +1 -1
- package/dist/sandbox/migrate-worker.cjs +2 -2
- package/dist/sandbox/migrate-worker.mjs +2 -2
- package/dist/{serverSetup-BMpzrB1y.cjs → serverSetup-DMNKsLKq.cjs} +6 -6
- package/dist/{serverSetup-BMpzrB1y.cjs.map → serverSetup-DMNKsLKq.cjs.map} +1 -1
- package/dist/{serverSetup-An1fE9nd.mjs → serverSetup-lZ7tYUZJ.mjs} +6 -6
- package/dist/{serverSetup-An1fE9nd.mjs.map → serverSetup-lZ7tYUZJ.mjs.map} +1 -1
- package/dist/{sniffer-9a8wQeeD.cjs → sniffer-CUImZsQL.cjs} +8 -8
- package/dist/{sniffer-9a8wQeeD.cjs.map → sniffer-CUImZsQL.cjs.map} +1 -1
- package/dist/{sniffer-BObBXR5q.mjs → sniffer-DcT9RrAj.mjs} +8 -8
- package/dist/{sniffer-BObBXR5q.mjs.map → sniffer-DcT9RrAj.mjs.map} +1 -1
- package/dist/{snsSubscriptions-BRmEdsks.cjs → snsSubscriptions-1lX1ze3u.cjs} +10 -5
- package/dist/snsSubscriptions-1lX1ze3u.cjs.map +1 -0
- package/dist/{snsSubscriptions-oUTOkG-s.mjs → snsSubscriptions-DFWhEgiA.mjs} +10 -5
- package/dist/snsSubscriptions-DFWhEgiA.mjs.map +1 -0
- package/dist/{sst-DVIeKWCH.mjs → sst-CB6rX5Zs.mjs} +6 -6
- package/dist/{sst-DVIeKWCH.mjs.map → sst-CB6rX5Zs.mjs.map} +1 -1
- package/dist/{sst-CJQI9GYW.cjs → sst-ct0Vhta9.cjs} +6 -6
- package/dist/{sst-CJQI9GYW.cjs.map → sst-ct0Vhta9.cjs.map} +1 -1
- package/dist/{stack-2jMvQfLo.cjs → stack-CkdkfmpN.cjs} +124 -47
- package/dist/stack-CkdkfmpN.cjs.map +1 -0
- package/dist/{stack-kcxH-2tZ.mjs → stack-Dsl0l3fi.mjs} +120 -49
- package/dist/stack-Dsl0l3fi.mjs.map +1 -0
- package/dist/{stage-AHgVG7H8.cjs → stage-Cmn0dCV2.cjs} +7 -7
- package/dist/{stage-AHgVG7H8.cjs.map → stage-Cmn0dCV2.cjs.map} +1 -1
- package/dist/{stage-BQSSMJL4.mjs → stage-DfdUf2sj.mjs} +7 -7
- package/dist/{stage-BQSSMJL4.mjs.map → stage-DfdUf2sj.mjs.map} +1 -1
- package/dist/{stages-DpF2K3PZ.cjs → stages-BWg3NU3J.cjs} +2 -2
- package/dist/{stages-DpF2K3PZ.cjs.map → stages-BWg3NU3J.cjs.map} +1 -1
- package/dist/{stages-BsK1Ro4s.mjs → stages-COiipV8N.mjs} +2 -2
- package/dist/{stages-BsK1Ro4s.mjs.map → stages-COiipV8N.mjs.map} +1 -1
- package/dist/target/public.cjs +1 -1
- package/dist/target/public.mjs +1 -1
- package/dist/{terminal-DWROY7JE.mjs → terminal-BDKhPIBA.mjs} +3 -3
- package/dist/{terminal-DWROY7JE.mjs.map → terminal-BDKhPIBA.mjs.map} +1 -1
- package/dist/{terminal-BNjNr7BN.cjs → terminal-CFeiyJxJ.cjs} +3 -3
- package/dist/{terminal-BNjNr7BN.cjs.map → terminal-CFeiyJxJ.cjs.map} +1 -1
- package/dist/vitest.cjs +1 -1
- package/dist/vitest.mjs +1 -1
- package/dist/workspace/index.cjs +1 -1
- package/dist/workspace/index.mjs +1 -1
- package/dist/{workspace-Ciw3SnME.cjs → workspace-CEpojAus.cjs} +42 -15
- package/dist/workspace-CEpojAus.cjs.map +1 -0
- package/dist/{workspace-9q4TSHlM.mjs → workspace-_aoe8v6u.mjs} +43 -16
- package/dist/workspace-_aoe8v6u.mjs.map +1 -0
- package/package.json +15 -15
- package/dist/SubscriberGenerator-BybB6uez.mjs.map +0 -1
- package/dist/SubscriberGenerator-mZpSuSU7.cjs.map +0 -1
- package/dist/add-DsxJ0Knr.cjs.map +0 -1
- package/dist/add-Dt8QKSOw.mjs.map +0 -1
- package/dist/apps-C6s-trVp.cjs.map +0 -1
- package/dist/apps-w2sRQKCr.mjs.map +0 -1
- package/dist/compose-BqTuzitb.cjs.map +0 -1
- package/dist/compose-Csegtvq_.mjs.map +0 -1
- package/dist/compose-QSBmhr4V.cjs.map +0 -1
- package/dist/compose-RhuFQmZS.mjs.map +0 -1
- package/dist/credentialSchemas-BAklWDna.cjs.map +0 -1
- package/dist/credentialSchemas-mz9QZTYh.mjs.map +0 -1
- package/dist/databases-C1qqNxTu.mjs.map +0 -1
- package/dist/databases-CrKh5jw6.cjs.map +0 -1
- package/dist/deploy-BwJ7uWXd.cjs.map +0 -1
- package/dist/deploy-DDfnQm8l.mjs.map +0 -1
- package/dist/discover-CRywE7yc.cjs.map +0 -1
- package/dist/discover-DbDrCQ8h.mjs.map +0 -1
- package/dist/docker-Dy1ZJUzV.cjs.map +0 -1
- package/dist/docker-Ele34O8z.mjs.map +0 -1
- package/dist/encryption-BZ1zgtF5.cjs.map +0 -1
- package/dist/encryption-CHmfNBAy.mjs.map +0 -1
- package/dist/engine-B3Gmu8-O.mjs.map +0 -1
- package/dist/engine-DewbDHOq.cjs.map +0 -1
- package/dist/notes-9bOfe08J.mjs.map +0 -1
- package/dist/notes-DRdlsCYV.cjs.map +0 -1
- package/dist/ready-BjFMu_1J.mjs.map +0 -1
- package/dist/ready-eVMJIcWn.cjs.map +0 -1
- package/dist/snsSubscriptions-BRmEdsks.cjs.map +0 -1
- package/dist/snsSubscriptions-oUTOkG-s.mjs.map +0 -1
- package/dist/stack-2jMvQfLo.cjs.map +0 -1
- package/dist/stack-kcxH-2tZ.mjs.map +0 -1
- package/dist/workspace-9q4TSHlM.mjs.map +0 -1
- package/dist/workspace-Ciw3SnME.cjs.map +0 -1
|
@@ -545,12 +545,12 @@ function clientConfigOf(options, target) {
|
|
|
545
545
|
* no owner — both URLs are the master credential by design.
|
|
546
546
|
*/
|
|
547
547
|
function ownerUrl(options, target) {
|
|
548
|
-
const key = (0, _geekmidas_manifest.
|
|
548
|
+
const key = (0, _geekmidas_manifest.providedKeyFor)(target.id, "database", "ownerUrl");
|
|
549
549
|
const owner = options.env[key];
|
|
550
550
|
if (owner) return owner;
|
|
551
551
|
const database = options.manifest[target.of ?? target.id];
|
|
552
552
|
if (database?.kind === "database" && database.roles === false) {
|
|
553
|
-
const url = options.env[(0, _geekmidas_manifest.
|
|
553
|
+
const url = options.env[(0, _geekmidas_manifest.providedKeyFor)(target.id, "database", "url")];
|
|
554
554
|
if (url) return url;
|
|
555
555
|
}
|
|
556
556
|
throw new NoOwnerCredential(target.id, key);
|
|
@@ -700,4 +700,4 @@ Object.defineProperty(exports, "seedDatabases", {
|
|
|
700
700
|
}
|
|
701
701
|
});
|
|
702
702
|
|
|
703
|
-
//# sourceMappingURL=databases-
|
|
703
|
+
//# sourceMappingURL=databases-CuTL1e7s.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"databases-CuTL1e7s.cjs","names":["GkmError","readdir","extname","join","pathToFileURL","stat","readFile","GkmError","driversFor","cacheBackendsIn","eventsBackendsIn","join","mkdir","writeFile","pathToFileURL","createHash","GkmError","join","migrationTargets","MIGRATIONS_ROOT","canonicalId","readdir","DATABASE_FOLDERS","providedKeyFor","require","createRequire","pathToFileURL"],"sources":["../src/migrate/provider.ts","../src/migrate/seedDrivers.ts","../src/migrate/databases.ts"],"sourcesContent":["/**\n * One construct's migrations and seeds, read from its folders.\n *\n * Two kinds of file, told apart by extension rather than by configuration: a\n * script exports `up` (and may export `down`) — or `seed(db, { stage })`, in\n * `seeds/` — and a\n * `.sql` file is run whole. The second is what makes a folder independent of\n * the client the app uses — Better Auth's schema is SQL whatever the\n * application queries with.\n */\n\nimport { readdir, readFile, stat } from 'node:fs/promises';\nimport { extname, join } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport type { SeedContext } from '@geekmidas/constructs';\nimport type { Kysely, sql } from 'kysely';\nimport type { Migration, MigrationProvider } from 'kysely/migration';\nimport { GkmError } from '../errors';\n\nconst SCRIPTS = new Set(['.ts', '.mts', '.js', '.mjs']);\n\n/** Two files in one folder that would be one migration. */\nexport class DuplicateMigration extends GkmError {\n\tconstructor(\n\t\treadonly folder: string,\n\t\treadonly migration: string,\n\t) {\n\t\tsuper(\n\t\t\t`${folder} has two migrations named '${migration}' — a script and a .sql file ` +\n\t\t\t\t`with the same name. A migration is recorded by name, so only one of ` +\n\t\t\t\t`them could ever run; rename or remove the other.`,\n\t\t);\n\t\tthis.name = 'DuplicateMigration';\n\t}\n}\n\n/** A script in a migrations folder that exports no `up`. */\nexport class MigrationHasNoUp extends GkmError {\n\tconstructor(readonly file: string) {\n\t\tsuper(\n\t\t\t`${file} is in a migrations folder but exports no \\`up\\` function. ` +\n\t\t\t\t`Export \\`async function up(db: Kysely<unknown>)\\`, or move the file ` +\n\t\t\t\t`out of the folder if it is not a migration.`,\n\t\t);\n\t\tthis.name = 'MigrationHasNoUp';\n\t}\n}\n\n/** A script in a seeds folder that exports no `seed`. */\nexport class SeedHasNoSeed extends GkmError {\n\tconstructor(readonly file: string) {\n\t\tsuper(\n\t\t\t`${file} is in a seeds folder but exports no \\`seed\\` function. ` +\n\t\t\t\t`Export \\`async function seed(db, { stage })\\`, or move the ` +\n\t\t\t\t`file out of the folder if it is not a seed.`,\n\t\t);\n\t\tthis.name = 'SeedHasNoSeed';\n\t}\n}\n\n/**\n * What a seed is handed beside its database — `@geekmidas/constructs`'\n * `SeedContext`, whose `stage` is the union of the declared stages once\n * `.gkm/stages.d.ts` is generated.\n */\nexport type { SeedContext };\n\n/** One seed: what it is called, and what it does. */\nexport interface Seed {\n\tname: string;\n\trun: (db: Kysely<unknown>, context: SeedContext) => Promise<void>;\n}\n\n/**\n * The migration files in a folder, by name, without reading them.\n *\n * Also what `gkm dev` compares against a construct's history to report what\n * is pending, which is why it is separate from loading them.\n */\nexport async function migrationFiles(\n\tfolder: string,\n): Promise<Map<string, string>> {\n\tconst entries = await readdir(folder, { withFileTypes: true }).catch(\n\t\t(error: NodeJS.ErrnoException) => {\n\t\t\tif (error.code === 'ENOENT') return [];\n\t\t\tthrow error;\n\t\t},\n\t);\n\n\tconst files = new Map<string, string>();\n\tfor (const entry of entries) {\n\t\tif (!entry.isFile() || !isMigration(entry.name)) continue;\n\n\t\tconst name = entry.name.slice(0, -extname(entry.name).length);\n\t\tif (files.has(name)) throw new DuplicateMigration(folder, name);\n\n\t\tfiles.set(name, join(folder, entry.name));\n\t}\n\n\treturn files;\n}\n\n/** A Kysely provider over one construct's folder. */\nexport function folderProvider(\n\tfolder: string,\n\traw: typeof sql,\n): MigrationProvider {\n\treturn {\n\t\tasync getMigrations() {\n\t\t\tconst migrations: Record<string, Migration> = {};\n\n\t\t\tfor (const [name, file] of await migrationFiles(folder)) {\n\t\t\t\tmigrations[name] =\n\t\t\t\t\textname(file) === '.sql'\n\t\t\t\t\t\t? await sqlMigration(file, raw)\n\t\t\t\t\t\t: await scriptMigration(file);\n\t\t\t}\n\n\t\t\treturn migrations;\n\t\t},\n\t};\n}\n\n/**\n * The seeds in a folder, loaded, in name order.\n *\n * Every one runs on every pass — there is no history to consult — so the order\n * is the only thing between two seeds where one reads what another writes.\n * Name them to sort that way.\n */\nexport async function loadSeeds(\n\tfolder: string,\n\traw: typeof sql,\n): Promise<Seed[]> {\n\tconst files = [...(await migrationFiles(folder))].sort(([a], [b]) =>\n\t\ta < b ? -1 : a > b ? 1 : 0,\n\t);\n\n\tconst seeds: Seed[] = [];\n\tfor (const [name, file] of files) {\n\t\tseeds.push({\n\t\t\tname,\n\t\t\trun:\n\t\t\t\textname(file) === '.sql'\n\t\t\t\t\t? (await sqlMigration(file, raw)).up\n\t\t\t\t\t: await scriptSeed(file),\n\t\t});\n\t}\n\n\treturn seeds;\n}\n\n/**\n * A seed script, imported as it is on disk now.\n *\n * Keyed by its modification time: a seed is run again after it is edited, and\n * a process that has imported it once would otherwise run the old one.\n */\nasync function scriptSeed(file: string): Promise<Seed['run']> {\n\tconst url = pathToFileURL(file);\n\turl.searchParams.set('mtime', String((await stat(file)).mtimeMs));\n\tconst module = (await import(url.href)) as { seed?: unknown };\n\tif (typeof module.seed !== 'function') throw new SeedHasNoSeed(file);\n\n\treturn module.seed as Seed['run'];\n}\n\nfunction isMigration(file: string): boolean {\n\tif (file.endsWith('.d.ts')) return false;\n\tif (/\\.(spec|test)\\.[cm]?[jt]s$/.test(file)) return false;\n\n\tconst extension = extname(file);\n\treturn extension === '.sql' || SCRIPTS.has(extension);\n}\n\nasync function scriptMigration(file: string): Promise<Migration> {\n\tconst module = (await import(pathToFileURL(file).href)) as Partial<Migration>;\n\tif (typeof module.up !== 'function') throw new MigrationHasNoUp(file);\n\n\treturn {\n\t\tup: module.up,\n\t\t...(typeof module.down === 'function' ? { down: module.down } : {}),\n\t};\n}\n\n/**\n * A `.sql` file, run whole.\n *\n * One query rather than split on `;`: with no parameters, Postgres takes\n * several statements in one message, and splitting by hand breaks on the first\n * `;` inside a string or a function body. There is no `down` — a generated\n * schema is rolled back by a migration that says how, not by guessing.\n */\nasync function sqlMigration(file: string, raw: typeof sql): Promise<Migration> {\n\tconst statements = await readFile(file, 'utf-8');\n\n\treturn {\n\t\tup: async (db: Kysely<unknown>) => {\n\t\t\tawait raw.raw(statements).execute(db);\n\t\t},\n\t};\n}\n","/**\n * The drivers a seed run registers before any seed runs.\n *\n * The seed runner is an entry point gkm owns, like the generated server and\n * the test harness, so it registers what they register — from the same\n * {@link driversFor}, so the two cannot drift. A seed then reaches a bucket or\n * a cache through the construct's service, exactly as a handler does, and no\n * application code names a provider.\n *\n * The registrations are written to a module under `.gkm/` and imported from\n * there, rather than imported by gkm itself: a registry is a module-level map,\n * so it has to be the copy the app's constructs resolve — which is the one a\n * bare specifier finds from the project root, not the one beside gkm.\n */\n\nimport { createHash } from 'node:crypto';\nimport { mkdir, writeFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport type { ConstructManifest } from '@geekmidas/manifest';\nimport { GkmError } from '../errors';\nimport {\n\tcacheBackendsIn,\n\tdriversFor,\n\teventsBackendsIn,\n} from '../generators/drivers';\nimport type { CacheBackend, EventsBackend } from '../types';\n\n/** Which backends the stage being seeded resolves its declarations to. */\nexport interface SeedBackends {\n\tcache: CacheBackend;\n\tevents: EventsBackend;\n}\n\n/** The drivers a seed run needs could not be loaded from the project. */\nexport class SeedDriversUnresolved extends GkmError {\n\tconstructor(\n\t\treadonly root: string,\n\t\toverride readonly cause: unknown,\n\t) {\n\t\tsuper(\n\t\t\t`Could not load the drivers seeds run with from ${root} — ` +\n\t\t\t\t`${cause instanceof Error ? cause.message : String(cause)}. ` +\n\t\t\t\t`They are the ones the app's own entry registers; install the ` +\n\t\t\t\t`package it names where the project's constructs are declared.`,\n\t\t);\n\t\tthis.name = 'SeedDriversUnresolved';\n\t}\n}\n\n/**\n * Register the drivers a generated entry for this project would: storage when\n * it installs `@geekmidas/storage`, the cache backend its caches resolve to,\n * and the broker its topics and queues do. Nothing when it declares none.\n */\nexport async function registerSeedDrivers(options: {\n\troot: string;\n\tmanifest: ConstructManifest;\n\tbackends: SeedBackends;\n}): Promise<void> {\n\tconst drivers = driversFor({\n\t\tappRoot: options.root,\n\t\tcache: cacheBackendsIn(options.manifest, options.backends.cache),\n\t\tevents: eventsBackendsIn(options.manifest, options.backends.events),\n\t});\n\tif (!drivers.setup) return;\n\n\tconst content = `${drivers.imports}\\n\\n${drivers.setup}\\n`;\n\tconst dir = join(options.root, '.gkm');\n\tconst file = join(dir, 'seed-drivers.mjs');\n\tawait mkdir(dir, { recursive: true });\n\tawait writeFile(file, content);\n\n\t// Keyed by content: registration is idempotent, but a process seeding\n\t// twice after the declarations changed must load the new set.\n\tconst url = pathToFileURL(file);\n\turl.searchParams.set(\n\t\t'v',\n\t\tcreateHash('sha256').update(content).digest('hex').slice(0, 12),\n\t);\n\n\ttry {\n\t\tawait import(url.href);\n\t} catch (error) {\n\t\tthrow new SeedDriversUnresolved(options.root, error);\n\t}\n}\n","/**\n * Bring each construct's schema up to its migrations folder.\n *\n * Which constructs, in what order, from which folder, is `migrationTargets`'\n * answer and nobody else's. What is decided here is only how one target is\n * run: as its owner, in its own schema, with a history of its own.\n */\n\nimport { readdir } from 'node:fs/promises';\nimport { createRequire } from 'node:module';\nimport { join } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport {\n\ttype ConstructManifest,\n\tcanonicalId,\n\tDATABASE_FOLDERS,\n\tMIGRATIONS_ROOT,\n\ttype MigrationTarget,\n\tmigrationTargets,\n\tprovidedKeyFor,\n} from '@geekmidas/manifest';\nimport type { Kysely, KyselyConfig } from 'kysely';\nimport type { Migrator } from 'kysely/migration';\nimport pg from 'pg';\nimport { GkmError } from '../errors';\nimport type { ConstructSource } from '../reconcile/discover';\nimport { folderProvider, loadSeeds, migrationFiles } from './provider';\nimport { registerSeedDrivers, type SeedBackends } from './seedDrivers';\n\nexport interface DatabasesOptions {\n\t/** The project root — where `db/` lives. */\n\troot: string;\n\tmanifest: ConstructManifest;\n\t/**\n\t * Where each construct was declared. A construct's migrations run with the\n\t * Kysely its own file resolves, which is the one its migrations import.\n\t */\n\tsources?: Readonly<Record<string, ConstructSource>>;\n\t/** The resolved environment: each construct's owner URL is read from it. */\n\tenv: Readonly<Record<string, string | undefined>>;\n\t/** One construct, by name. All of them when absent. */\n\tonly?: string;\n}\n\nexport interface MigrationRun {\n\ttarget: MigrationTarget;\n\t/** The migrations this run applied, in order. */\n\tapplied: string[];\n}\n\nexport interface SeedOptions extends DatabasesOptions {\n\t/** The stage being seeded, handed to every seed. */\n\tstage: string;\n\t/**\n\t * What the stage's caches and topics resolve to — which drivers a seed is\n\t * run with, as the stage's own entry would register them.\n\t */\n\tbackends: SeedBackends;\n}\n\nexport interface SeedRun {\n\ttarget: MigrationTarget;\n\t/** The seeds this run ran, in order — every one, every time. */\n\tseeded: string[];\n}\n\n/** The seeds a run would run for one construct, read without connecting. */\nexport interface PlannedSeeds {\n\ttarget: MigrationTarget;\n\t/** In the order they would run. */\n\tseeds: string[];\n}\n\nexport interface PendingMigrations {\n\ttarget: MigrationTarget;\n\tpending: string[];\n}\n\n/** A folder under `db/` that names no construct. */\nexport class UnknownMigrationFolder extends GkmError {\n\tconstructor(\n\t\treadonly folder: string,\n\t\treadonly known: readonly string[],\n\t) {\n\t\tsuper(\n\t\t\t`${folder} names no database construct, so its migrations would never ` +\n\t\t\t\t`run. ${known.length > 0 ? `The folders that do: ${known.join(', ')}.` : 'This project declares no database.'} ` +\n\t\t\t\t`Rename the folder after the construct it belongs to.`,\n\t\t);\n\t\tthis.name = 'UnknownMigrationFolder';\n\t}\n}\n\n/** A construct was asked for by a name that takes no migrations. */\nexport class NoSuchMigrationTarget extends GkmError {\n\tconstructor(\n\t\treadonly construct: string,\n\t\treadonly known: readonly string[],\n\t) {\n\t\tsuper(\n\t\t\t`'${construct}' is not a database construct. ` +\n\t\t\t\t(known.length > 0\n\t\t\t\t\t? `The ones with migrations: ${known.join(', ')}.`\n\t\t\t\t\t: 'This project declares no database.'),\n\t\t);\n\t\tthis.name = 'NoSuchMigrationTarget';\n\t}\n}\n\n/**\n * A migration left directly in a construct's folder, where nothing reads it.\n *\n * Migrations moved into `migrations/` so seeds could sit beside them. A file\n * still at the old level would otherwise never run, and nothing would say so.\n */\nexport class MigrationsOutsideFolder extends GkmError {\n\tconstructor(\n\t\treadonly folder: string,\n\t\treadonly files: readonly string[],\n\t) {\n\t\tsuper(\n\t\t\t`${folder} has ${files.join(', ')} directly inside it, where nothing ` +\n\t\t\t\t`runs them. Migrations live in ${folder}/migrations/ and seeds in ` +\n\t\t\t\t`${folder}/seeds/ — move ${files.length === 1 ? 'it' : 'them'} there.`,\n\t\t);\n\t\tthis.name = 'MigrationsOutsideFolder';\n\t}\n}\n\n/** A folder inside a construct's folder that is neither `migrations` nor `seeds`. */\nexport class UnknownDatabaseFolder extends GkmError {\n\tconstructor(readonly folder: string) {\n\t\tsuper(\n\t\t\t`${folder} is neither migrations/ nor seeds/, so nothing in it would ` +\n\t\t\t\t`ever run. A construct's folder holds those two; rename or remove it.`,\n\t\t);\n\t\tthis.name = 'UnknownDatabaseFolder';\n\t}\n}\n\n/** A seed failed; its own writes are rolled back, the ones before it stay. */\nexport class SeedFailed extends Error {\n\tconstructor(\n\t\treadonly construct: string,\n\t\treadonly seed: string,\n\t\toverride readonly cause: unknown,\n\t) {\n\t\tsuper(\n\t\t\t`${construct}: seed '${seed}' failed — ` +\n\t\t\t\t`${cause instanceof Error ? cause.message : String(cause)}. ` +\n\t\t\t\t`Its writes were rolled back; fix it and run it again.`,\n\t\t);\n\t\tthis.name = 'SeedFailed';\n\t}\n}\n\n/** A construct with roles has no owner URL to migrate with. */\nexport class NoOwnerCredential extends GkmError {\n\tconstructor(\n\t\treadonly construct: string,\n\t\treadonly key: string,\n\t) {\n\t\tsuper(\n\t\t\t`${construct} has no ${key} to migrate with. Migrations run as the owner ` +\n\t\t\t\t`role — the runtime one cannot create a table — and nothing ` +\n\t\t\t\t`resolved its URL. Is the stage reconciled?`,\n\t\t);\n\t\tthis.name = 'NoOwnerCredential';\n\t}\n}\n\n/** A migration failed; the ones before it in the run stay applied. */\nexport class MigrationFailed extends Error {\n\tconstructor(\n\t\treadonly construct: string,\n\t\treadonly migration: string | undefined,\n\t\toverride readonly cause: unknown,\n\t) {\n\t\tsuper(\n\t\t\t`${construct}: migration ${migration ? `'${migration}' ` : ''}failed — ` +\n\t\t\t\t`${cause instanceof Error ? cause.message : String(cause)}`,\n\t\t);\n\t\tthis.name = 'MigrationFailed';\n\t}\n}\n\n/** The project's Kysely could not be found from where a database is declared. */\nexport class KyselyNotFound extends GkmError {\n\tconstructor(readonly from: string) {\n\t\tsuper(\n\t\t\t`Could not resolve 'kysely' from ${from}. Migrations run with the ` +\n\t\t\t\t`project's own Kysely — install it where the database is declared.`,\n\t\t);\n\t\tthis.name = 'KyselyNotFound';\n\t}\n}\n\n/** Apply every pending migration, construct by construct, parents first. */\nexport async function migrateDatabases(\n\toptions: DatabasesOptions,\n): Promise<MigrationRun[]> {\n\tconst runs: MigrationRun[] = [];\n\n\tfor (const target of await targetsFor(options)) {\n\t\t// No folder, or an empty one, is nothing to do — and no reason to\n\t\t// connect, which a construct nobody has written a migration for yet\n\t\t// should not need.\n\t\tconst files = await migrationFiles(join(options.root, target.migrations));\n\t\tif (files.size === 0) {\n\t\t\truns.push({ target, applied: [] });\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst applied = await withMigrator(options, target, async (migrator) => {\n\t\t\tconst { error, results = [] } = await migrator.migrateToLatest();\n\t\t\tif (error) {\n\t\t\t\tconst failed = results.find((result) => result.status === 'Error');\n\t\t\t\tthrow new MigrationFailed(target.id, failed?.migrationName, error);\n\t\t\t}\n\n\t\t\treturn results\n\t\t\t\t.filter((result) => result.status === 'Success')\n\t\t\t\t.map((result) => result.migrationName);\n\t\t});\n\n\t\truns.push({ target, applied });\n\t}\n\n\treturn runs;\n}\n\n/**\n * Run every construct's seeds, parents first — each one, every time, on every\n * stage, production included. Each is handed the stage, so a seed decides\n * what belongs where.\n *\n * Seeds are reference data kept up to date by being run again, so there is no\n * history: a seed is an upsert, and a changed one is applied by the next run.\n * Each runs in its own transaction, as the construct's owner, so a failure\n * leaves nothing half-written. Assumes the schema is migrated —\n * {@link migrateAndSeed} is what makes that true.\n *\n * A seed is handed the client the app gets — the construct's `clientConfig`,\n * plugins included — on the owner's connection. One written against\n * `Kysely<DB>` with a `CamelCasePlugin` writes `isEditable` here as it does in\n * a handler or a test.\n *\n * And with the drivers the stage's entry registers, and the stage's `env`, so\n * a seed reaching a bucket or a cache through its construct gets the client a\n * handler would.\n */\nexport async function seedDatabases(options: SeedOptions): Promise<SeedRun[]> {\n\tconst runs: SeedRun[] = [];\n\tlet registered = false;\n\n\tfor (const target of await targetsFor(options)) {\n\t\tconst folder = join(options.root, target.seeds);\n\t\tif ((await migrationFiles(folder)).size === 0) {\n\t\t\truns.push({ target, seeded: [] });\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (!registered) {\n\t\t\tawait registerSeedDrivers(options);\n\t\t\tregistered = true;\n\t\t}\n\n\t\tconst config = clientConfigOf(options, target);\n\t\tconst seeded = await withOwner(\n\t\t\toptions,\n\t\t\ttarget,\n\t\t\tconfig,\n\t\t\tasync (db, kysely) => {\n\t\t\t\tconst names: string[] = [];\n\t\t\t\tfor (const seed of await loadSeeds(folder, kysely.sql)) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait db\n\t\t\t\t\t\t\t.transaction()\n\t\t\t\t\t\t\t.execute((trx) =>\n\t\t\t\t\t\t\t\tseed.run(trx, { stage: options.stage, env: options.env }),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tthrow new SeedFailed(target.id, seed.name, error);\n\t\t\t\t\t}\n\t\t\t\t\tnames.push(seed.name);\n\t\t\t\t}\n\t\t\t\treturn names;\n\t\t\t},\n\t\t);\n\n\t\truns.push({ target, seeded });\n\t}\n\n\treturn runs;\n}\n\n/**\n * The seeds {@link seedDatabases} would run, construct by construct, parents\n * first, in the order it would run them — read from the folders alone, with\n * no connection. What a dry run lists. Constructs with none are left out.\n */\nexport async function plannedSeeds(\n\toptions: Pick<DatabasesOptions, 'root' | 'manifest' | 'only'>,\n): Promise<PlannedSeeds[]> {\n\tconst planned: PlannedSeeds[] = [];\n\tfor (const target of await targetsFor(options)) {\n\t\tconst files = await migrationFiles(join(options.root, target.seeds));\n\t\tif (files.size === 0) continue;\n\t\tplanned.push({ target, seeds: [...files.keys()].sort() });\n\t}\n\treturn planned;\n}\n\n/**\n * Migrate, then seed: a seed only ever runs against the schema it was written\n * for.\n *\n * With `only`, the constructs it lives in are migrated too — a tenant's seed\n * cannot run before the database that owns its schema exists — and only it is\n * seeded.\n */\nexport async function migrateAndSeed(options: SeedOptions): Promise<{\n\tmigrations: MigrationRun[];\n\tseeds: SeedRun[];\n}> {\n\tconst migrations: MigrationRun[] = [];\n\tfor (const target of await withParents(options)) {\n\t\tmigrations.push(\n\t\t\t...(await migrateDatabases({ ...options, only: target.id })),\n\t\t);\n\t}\n\n\treturn { migrations, seeds: await seedDatabases(options) };\n}\n\n/** The targets `only` names, after the ones it lives in; all without it. */\nasync function withParents(\n\toptions: DatabasesOptions,\n): Promise<MigrationTarget[]> {\n\tconst chosen = await targetsFor(options);\n\tif (!options.only) return chosen;\n\n\tconst all = migrationTargets(options.manifest);\n\tconst ids = new Set<string>();\n\tfor (const target of chosen) {\n\t\tlet current: MigrationTarget | undefined = target;\n\t\twhile (current) {\n\t\t\tids.add(current.id);\n\t\t\tconst parent: string | undefined = current.of;\n\t\t\tcurrent = parent ? all.find((t) => t.id === parent) : undefined;\n\t\t}\n\t}\n\n\treturn all.filter((target) => ids.has(target.id));\n}\n\n/**\n * What each construct's folder has that its history does not — without\n * applying any of it. What `gkm dev` reports.\n */\nexport async function pendingMigrations(\n\toptions: DatabasesOptions,\n): Promise<PendingMigrations[]> {\n\tconst found: PendingMigrations[] = [];\n\n\tfor (const target of await targetsFor(options)) {\n\t\tconst files = await migrationFiles(join(options.root, target.migrations));\n\t\tif (files.size === 0) continue;\n\n\t\tconst pending = await withMigrator(options, target, async (migrator) =>\n\t\t\t(await migrator.getMigrations())\n\t\t\t\t.filter((migration) => migration.executedAt === undefined)\n\t\t\t\t.map((migration) => migration.name),\n\t\t);\n\n\t\tif (pending.length > 0) found.push({ target, pending });\n\t}\n\n\treturn found;\n}\n\n/**\n * The targets this run covers, with every folder under `db/` accounted for.\n *\n * A folder that names no construct is an error rather than something to skip:\n * a typo in its name is otherwise a migration that silently never runs.\n */\nasync function targetsFor(\n\toptions: Pick<DatabasesOptions, 'root' | 'manifest' | 'only'>,\n): Promise<MigrationTarget[]> {\n\tconst targets = migrationTargets(options.manifest);\n\tconst folders = targets.map((target) => target.folder);\n\n\tfor (const folder of await foldersIn(join(options.root, MIGRATIONS_ROOT))) {\n\t\tconst relative = `${MIGRATIONS_ROOT}/${folder}`;\n\t\tif (!folders.includes(relative)) {\n\t\t\tthrow new UnknownMigrationFolder(relative, folders);\n\t\t}\n\t\tawait checkLayout(options.root, relative);\n\t}\n\n\tif (!options.only) return targets;\n\n\tconst id = canonicalId(options.only);\n\tconst chosen = targets.filter((target) => target.id === id);\n\tif (chosen.length === 0) {\n\t\tthrow new NoSuchMigrationTarget(\n\t\t\toptions.only,\n\t\t\ttargets.map((target) => target.id),\n\t\t);\n\t}\n\n\treturn chosen;\n}\n\n/**\n * A construct's folder holds `migrations/` and `seeds/`, and nothing else —\n * anything beside them is a file or folder nothing would ever run.\n */\nasync function checkLayout(root: string, folder: string): Promise<void> {\n\tconst entries = await readdir(join(root, folder), { withFileTypes: true });\n\n\tconst loose = entries\n\t\t.filter((entry) => entry.isFile() && !entry.name.startsWith('.'))\n\t\t.map((entry) => entry.name);\n\tif (loose.length > 0) throw new MigrationsOutsideFolder(folder, loose);\n\n\tfor (const entry of entries) {\n\t\tif (\n\t\t\tentry.isDirectory() &&\n\t\t\t!(DATABASE_FOLDERS as readonly string[]).includes(entry.name)\n\t\t) {\n\t\t\tthrow new UnknownDatabaseFolder(`${folder}/${entry.name}`);\n\t\t}\n\t}\n}\n\nasync function foldersIn(dir: string): Promise<string[]> {\n\tconst entries = await readdir(dir, { withFileTypes: true }).catch(\n\t\t(error: NodeJS.ErrnoException) => {\n\t\t\tif (error.code === 'ENOENT') return [];\n\t\t\tthrow error;\n\t\t},\n\t);\n\n\treturn entries\n\t\t.filter((entry) => entry.isDirectory())\n\t\t.map((entry) => entry.name);\n}\n\n/**\n * A migrator for one target, connected as its owner.\n *\n * No `migrationTableSchema`: the owner role's `search_path` is pinned to the\n * construct's schema, so the history lands there — `app.kysely_migration` for\n * the database, `auth_database.kysely_migration` for its tenant — and two\n * constructs in one Postgres never share one.\n *\n * Unordered migrations are allowed. Files are timestamped, so a branch merged\n * after another's migration ran carries an older one; refusing it would make\n * every such merge a manual repair.\n *\n * The client is bare — none of the construct's plugins. A casing plugin\n * rewrites identifiers in schema-builder DDL too, and a migration must do the\n * same thing forever after it has run, so it cannot depend on configuration\n * that may change.\n */\nasync function withMigrator<T>(\n\toptions: DatabasesOptions,\n\ttarget: MigrationTarget,\n\trun: (migrator: Migrator) => Promise<T>,\n): Promise<T> {\n\treturn withOwner(options, target, {}, (db, { Migrator, sql }) =>\n\t\trun(\n\t\t\tnew Migrator({\n\t\t\t\tdb,\n\t\t\t\tprovider: folderProvider(join(options.root, target.migrations), sql),\n\t\t\t\tallowUnorderedMigrations: true,\n\t\t\t}),\n\t\t),\n\t);\n}\n\n/**\n * One target's database, connected as its owner and closed afterwards — what\n * migrations and seeds both run as, each with the client config it needs.\n */\nasync function withOwner<T>(\n\toptions: DatabasesOptions,\n\ttarget: MigrationTarget,\n\tconfig: Omit<KyselyConfig, 'dialect'>,\n\trun: (\n\t\tdb: Kysely<unknown>,\n\t\tkysely: Awaited<ReturnType<typeof kyselyFrom>>,\n\t) => Promise<T>,\n): Promise<T> {\n\tconst from =\n\t\toptions.sources?.[target.id]?.file ??\n\t\t(target.of ? options.sources?.[target.of]?.file : undefined) ??\n\t\tjoin(options.root, 'package.json');\n\tconst kysely = await kyselyFrom(from);\n\n\tconst db: Kysely<unknown> = new kysely.Kysely<unknown>({\n\t\t...config,\n\t\tdialect: new kysely.PostgresDialect({\n\t\t\tpool: new pg.Pool(poolConfig(ownerUrl(options, target))),\n\t\t}),\n\t});\n\n\ttry {\n\t\treturn await run(db, kysely);\n\t} finally {\n\t\tawait db.destroy();\n\t}\n}\n\n/**\n * What the construct builds its clients with besides a dialect — its plugins\n * and logging — read from the construct discovery already imported.\n *\n * A tenant's is its own: `database.schema('Auth', { plugins })` declares the\n * client for its tables, not the parent's. With no construct to ask (a\n * manifest without sources), the client is bare.\n */\nfunction clientConfigOf(\n\toptions: DatabasesOptions,\n\ttarget: MigrationTarget,\n): Omit<KyselyConfig, 'dialect'> {\n\tconst construct = options.sources?.[target.id]?.construct;\n\tif (typeof construct !== 'object' || construct === null) return {};\n\tif (!('clientConfig' in construct)) return {};\n\treturn (construct.clientConfig as Omit<KyselyConfig, 'dialect'>) ?? {};\n}\n\n/**\n * The owner's URL, with no fallback to the runtime one.\n *\n * The runtime role can create nothing, so falling back would only move the\n * failure to the first `CREATE TABLE` and make it read like a permissions\n * bug. The one exception is a database declared `roles: false`, where there is\n * no owner — both URLs are the master credential by design.\n */\nfunction ownerUrl(options: DatabasesOptions, target: MigrationTarget): string {\n\tconst key = providedKeyFor(target.id, 'database', 'ownerUrl');\n\tconst owner = options.env[key];\n\tif (owner) return owner;\n\n\tconst database = options.manifest[target.of ?? target.id];\n\tif (database?.kind === 'database' && database.roles === false) {\n\t\tconst url = options.env[providedKeyFor(target.id, 'database', 'url')];\n\t\tif (url) return url;\n\t}\n\n\tthrow new NoOwnerCredential(target.id, key);\n}\n\n/**\n * Pool settings for a URL, with `?search_path=` as the startup option Postgres\n * reads. Only a `roles: false` URL carries it — a role pins its own.\n */\nfunction poolConfig(url: string): pg.PoolConfig {\n\tconst parsed = new URL(url);\n\tconst searchPath = parsed.searchParams.get('search_path');\n\tif (!searchPath) return { connectionString: url };\n\n\tparsed.searchParams.delete('search_path');\n\treturn {\n\t\tconnectionString: parsed.toString(),\n\t\toptions: `-c search_path=${searchPath}`,\n\t};\n}\n\n/** Kysely as the project resolves it from `from`. */\nasync function kyselyFrom(from: string) {\n\tconst require = createRequire(from);\n\n\ttry {\n\t\tconst [main, migration] = await Promise.all([\n\t\t\timport(pathToFileURL(require.resolve('kysely')).href),\n\t\t\timport(pathToFileURL(require.resolve('kysely/migration')).href),\n\t\t]);\n\n\t\treturn {\n\t\t\tKysely: main.Kysely as typeof import('kysely').Kysely,\n\t\t\tPostgresDialect:\n\t\t\t\tmain.PostgresDialect as typeof import('kysely').PostgresDialect,\n\t\t\tsql: main.sql as typeof import('kysely').sql,\n\t\t\tMigrator:\n\t\t\t\tmigration.Migrator as typeof import('kysely/migration').Migrator,\n\t\t};\n\t} catch {\n\t\tthrow new KyselyNotFound(from);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAmBA,MAAM,0BAAU,IAAI,IAAI;CAAC;CAAO;CAAQ;CAAO;AAAM,CAAC;;AAGtD,IAAa,qBAAb,cAAwCA,eAAAA,SAAS;CAEtC;CACA;CAFV,YACC,QACA,WACC;EACD,MACC,GAAG,OAAO,6BAA6B,UAAU,kJAGlD;EAPS,KAAA,SAAA;EACA,KAAA,YAAA;EAOT,KAAK,OAAO;CACb;AACD;;AAGA,IAAa,mBAAb,cAAsCA,eAAAA,SAAS;CACzB;CAArB,YAAY,MAAuB;EAClC,MACC,GAAG,KAAK,2KAGT;EALoB,KAAA,OAAA;EAMpB,KAAK,OAAO;CACb;AACD;;AAGA,IAAa,gBAAb,cAAmCA,eAAAA,SAAS;CACtB;CAArB,YAAY,MAAuB;EAClC,MACC,GAAG,KAAK,+JAGT;EALoB,KAAA,OAAA;EAMpB,KAAK,OAAO;CACb;AACD;;;;;;;AAqBA,eAAsB,eACrB,QAC+B;CAC/B,MAAM,UAAU,OAAA,GAAMC,iBAAAA,QAAAA,CA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I,YAAY,KAAK;EACnE,IAAI,KAAK,OAAO;CACjB;CAEA,MAAM,IAAI,kBAAkB,OAAO,IAAI,GAAG;AAC3C;;;;;AAMA,SAAS,WAAW,KAA4B;CAC/C,MAAM,SAAS,IAAI,IAAI,GAAG;CAC1B,MAAM,aAAa,OAAO,aAAa,IAAI,aAAa;CACxD,IAAI,CAAC,YAAY,OAAO,EAAE,kBAAkB,IAAI;CAEhD,OAAO,aAAa,OAAO,aAAa;CACxC,OAAO;EACN,kBAAkB,OAAO,SAAS;EAClC,SAAS,kBAAkB;CAC5B;AACD;;AAGA,eAAe,WAAW,MAAc;CACvC,MAAMC,aAAAA,GAAUC,YAAAA,cAAAA,CAAc,IAAI;CAElC,IAAI;EACH,MAAM,CAAC,MAAM,aAAa,MAAM,QAAQ,IAAI,CAC3C,QAAA,GAAOC,SAAAA,cAAAA,CAAcF,UAAQ,QAAQ,QAAQ,CAAC,CAAC,CAAC,OAChD,QAAA,GAAOE,SAAAA,cAAAA,CAAcF,UAAQ,QAAQ,kBAAkB,CAAC,CAAC,CAAC,KAC3D,CAAC;EAED,OAAO;GACN,QAAQ,KAAK;GACb,iBACC,KAAK;GACN,KAAK,KAAK;GACV,UACC,UAAU;EACZ;CACD,QAAQ;EACP,MAAM,IAAI,eAAe,IAAI;CAC9B;AACD"}
|
|
@@ -4,7 +4,7 @@ import { createRequire } from "node:module";
|
|
|
4
4
|
import { extname, join } from "node:path";
|
|
5
5
|
import { mkdir, readFile, readdir, stat, writeFile } from "node:fs/promises";
|
|
6
6
|
import { createHash } from "node:crypto";
|
|
7
|
-
import { DATABASE_FOLDERS, MIGRATIONS_ROOT, canonicalId, migrationTargets,
|
|
7
|
+
import { DATABASE_FOLDERS, MIGRATIONS_ROOT, canonicalId, migrationTargets, providedKeyFor } from "@geekmidas/manifest";
|
|
8
8
|
import { pathToFileURL } from "node:url";
|
|
9
9
|
import pg from "pg";
|
|
10
10
|
//#region src/migrate/provider.ts
|
|
@@ -543,12 +543,12 @@ function clientConfigOf(options, target) {
|
|
|
543
543
|
* no owner — both URLs are the master credential by design.
|
|
544
544
|
*/
|
|
545
545
|
function ownerUrl(options, target) {
|
|
546
|
-
const key =
|
|
546
|
+
const key = providedKeyFor(target.id, "database", "ownerUrl");
|
|
547
547
|
const owner = options.env[key];
|
|
548
548
|
if (owner) return owner;
|
|
549
549
|
const database = options.manifest[target.of ?? target.id];
|
|
550
550
|
if (database?.kind === "database" && database.roles === false) {
|
|
551
|
-
const url = options.env[
|
|
551
|
+
const url = options.env[providedKeyFor(target.id, "database", "url")];
|
|
552
552
|
if (url) return url;
|
|
553
553
|
}
|
|
554
554
|
throw new NoOwnerCredential(target.id, key);
|
|
@@ -585,4 +585,4 @@ async function kyselyFrom(from) {
|
|
|
585
585
|
//#endregion
|
|
586
586
|
export { MigrationHasNoUp as _, NoSuchMigrationTarget as a, UnknownMigrationFolder as c, pendingMigrations as d, plannedSeeds as f, DuplicateMigration as g, registerSeedDrivers as h, NoOwnerCredential as i, migrateAndSeed as l, SeedDriversUnresolved as m, MigrationFailed as n, SeedFailed as o, seedDatabases as p, MigrationsOutsideFolder as r, UnknownDatabaseFolder as s, KyselyNotFound as t, migrateDatabases as u, SeedHasNoSeed as v, migrationFiles as y };
|
|
587
587
|
|
|
588
|
-
//# sourceMappingURL=databases-
|
|
588
|
+
//# sourceMappingURL=databases-zN-gEox0.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"databases-zN-gEox0.mjs","names":[],"sources":["../src/migrate/provider.ts","../src/migrate/seedDrivers.ts","../src/migrate/databases.ts"],"sourcesContent":["/**\n * One construct's migrations and seeds, read from its folders.\n *\n * Two kinds of file, told apart by extension rather than by configuration: a\n * script exports `up` (and may export `down`) — or `seed(db, { stage })`, in\n * `seeds/` — and a\n * `.sql` file is run whole. The second is what makes a folder independent of\n * the client the app uses — Better Auth's schema is SQL whatever the\n * application queries with.\n */\n\nimport { readdir, readFile, stat } from 'node:fs/promises';\nimport { extname, join } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport type { SeedContext } from '@geekmidas/constructs';\nimport type { Kysely, sql } from 'kysely';\nimport type { Migration, MigrationProvider } from 'kysely/migration';\nimport { GkmError } from '../errors';\n\nconst SCRIPTS = new Set(['.ts', '.mts', '.js', '.mjs']);\n\n/** Two files in one folder that would be one migration. */\nexport class DuplicateMigration extends GkmError {\n\tconstructor(\n\t\treadonly folder: string,\n\t\treadonly migration: string,\n\t) {\n\t\tsuper(\n\t\t\t`${folder} has two migrations named '${migration}' — a script and a .sql file ` +\n\t\t\t\t`with the same name. A migration is recorded by name, so only one of ` +\n\t\t\t\t`them could ever run; rename or remove the other.`,\n\t\t);\n\t\tthis.name = 'DuplicateMigration';\n\t}\n}\n\n/** A script in a migrations folder that exports no `up`. */\nexport class MigrationHasNoUp extends GkmError {\n\tconstructor(readonly file: string) {\n\t\tsuper(\n\t\t\t`${file} is in a migrations folder but exports no \\`up\\` function. ` +\n\t\t\t\t`Export \\`async function up(db: Kysely<unknown>)\\`, or move the file ` +\n\t\t\t\t`out of the folder if it is not a migration.`,\n\t\t);\n\t\tthis.name = 'MigrationHasNoUp';\n\t}\n}\n\n/** A script in a seeds folder that exports no `seed`. */\nexport class SeedHasNoSeed extends GkmError {\n\tconstructor(readonly file: string) {\n\t\tsuper(\n\t\t\t`${file} is in a seeds folder but exports no \\`seed\\` function. ` +\n\t\t\t\t`Export \\`async function seed(db, { stage })\\`, or move the ` +\n\t\t\t\t`file out of the folder if it is not a seed.`,\n\t\t);\n\t\tthis.name = 'SeedHasNoSeed';\n\t}\n}\n\n/**\n * What a seed is handed beside its database — `@geekmidas/constructs`'\n * `SeedContext`, whose `stage` is the union of the declared stages once\n * `.gkm/stages.d.ts` is generated.\n */\nexport type { SeedContext };\n\n/** One seed: what it is called, and what it does. */\nexport interface Seed {\n\tname: string;\n\trun: (db: Kysely<unknown>, context: SeedContext) => Promise<void>;\n}\n\n/**\n * The migration files in a folder, by name, without reading them.\n *\n * Also what `gkm dev` compares against a construct's history to report what\n * is pending, which is why it is separate from loading them.\n */\nexport async function migrationFiles(\n\tfolder: string,\n): Promise<Map<string, string>> {\n\tconst entries = await readdir(folder, { withFileTypes: true }).catch(\n\t\t(error: NodeJS.ErrnoException) => {\n\t\t\tif (error.code === 'ENOENT') return [];\n\t\t\tthrow error;\n\t\t},\n\t);\n\n\tconst files = new Map<string, string>();\n\tfor (const entry of entries) {\n\t\tif (!entry.isFile() || !isMigration(entry.name)) continue;\n\n\t\tconst name = entry.name.slice(0, -extname(entry.name).length);\n\t\tif (files.has(name)) throw new DuplicateMigration(folder, name);\n\n\t\tfiles.set(name, join(folder, entry.name));\n\t}\n\n\treturn files;\n}\n\n/** A Kysely provider over one construct's folder. */\nexport function folderProvider(\n\tfolder: string,\n\traw: typeof sql,\n): MigrationProvider {\n\treturn {\n\t\tasync getMigrations() {\n\t\t\tconst migrations: Record<string, Migration> = {};\n\n\t\t\tfor (const [name, file] of await migrationFiles(folder)) {\n\t\t\t\tmigrations[name] =\n\t\t\t\t\textname(file) === '.sql'\n\t\t\t\t\t\t? await sqlMigration(file, raw)\n\t\t\t\t\t\t: await scriptMigration(file);\n\t\t\t}\n\n\t\t\treturn migrations;\n\t\t},\n\t};\n}\n\n/**\n * The seeds in a folder, loaded, in name order.\n *\n * Every one runs on every pass — there is no history to consult — so the order\n * is the only thing between two seeds where one reads what another writes.\n * Name them to sort that way.\n */\nexport async function loadSeeds(\n\tfolder: string,\n\traw: typeof sql,\n): Promise<Seed[]> {\n\tconst files = [...(await migrationFiles(folder))].sort(([a], [b]) =>\n\t\ta < b ? -1 : a > b ? 1 : 0,\n\t);\n\n\tconst seeds: Seed[] = [];\n\tfor (const [name, file] of files) {\n\t\tseeds.push({\n\t\t\tname,\n\t\t\trun:\n\t\t\t\textname(file) === '.sql'\n\t\t\t\t\t? (await sqlMigration(file, raw)).up\n\t\t\t\t\t: await scriptSeed(file),\n\t\t});\n\t}\n\n\treturn seeds;\n}\n\n/**\n * A seed script, imported as it is on disk now.\n *\n * Keyed by its modification time: a seed is run again after it is edited, and\n * a process that has imported it once would otherwise run the old one.\n */\nasync function scriptSeed(file: string): Promise<Seed['run']> {\n\tconst url = pathToFileURL(file);\n\turl.searchParams.set('mtime', String((await stat(file)).mtimeMs));\n\tconst module = (await import(url.href)) as { seed?: unknown };\n\tif (typeof module.seed !== 'function') throw new SeedHasNoSeed(file);\n\n\treturn module.seed as Seed['run'];\n}\n\nfunction isMigration(file: string): boolean {\n\tif (file.endsWith('.d.ts')) return false;\n\tif (/\\.(spec|test)\\.[cm]?[jt]s$/.test(file)) return false;\n\n\tconst extension = extname(file);\n\treturn extension === '.sql' || SCRIPTS.has(extension);\n}\n\nasync function scriptMigration(file: string): Promise<Migration> {\n\tconst module = (await import(pathToFileURL(file).href)) as Partial<Migration>;\n\tif (typeof module.up !== 'function') throw new MigrationHasNoUp(file);\n\n\treturn {\n\t\tup: module.up,\n\t\t...(typeof module.down === 'function' ? { down: module.down } : {}),\n\t};\n}\n\n/**\n * A `.sql` file, run whole.\n *\n * One query rather than split on `;`: with no parameters, Postgres takes\n * several statements in one message, and splitting by hand breaks on the first\n * `;` inside a string or a function body. There is no `down` — a generated\n * schema is rolled back by a migration that says how, not by guessing.\n */\nasync function sqlMigration(file: string, raw: typeof sql): Promise<Migration> {\n\tconst statements = await readFile(file, 'utf-8');\n\n\treturn {\n\t\tup: async (db: Kysely<unknown>) => {\n\t\t\tawait raw.raw(statements).execute(db);\n\t\t},\n\t};\n}\n","/**\n * The drivers a seed run registers before any seed runs.\n *\n * The seed runner is an entry point gkm owns, like the generated server and\n * the test harness, so it registers what they register — from the same\n * {@link driversFor}, so the two cannot drift. A seed then reaches a bucket or\n * a cache through the construct's service, exactly as a handler does, and no\n * application code names a provider.\n *\n * The registrations are written to a module under `.gkm/` and imported from\n * there, rather than imported by gkm itself: a registry is a module-level map,\n * so it has to be the copy the app's constructs resolve — which is the one a\n * bare specifier finds from the project root, not the one beside gkm.\n */\n\nimport { createHash } from 'node:crypto';\nimport { mkdir, writeFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport type { ConstructManifest } from '@geekmidas/manifest';\nimport { GkmError } from '../errors';\nimport {\n\tcacheBackendsIn,\n\tdriversFor,\n\teventsBackendsIn,\n} from '../generators/drivers';\nimport type { CacheBackend, EventsBackend } from '../types';\n\n/** Which backends the stage being seeded resolves its declarations to. */\nexport interface SeedBackends {\n\tcache: CacheBackend;\n\tevents: EventsBackend;\n}\n\n/** The drivers a seed run needs could not be loaded from the project. */\nexport class SeedDriversUnresolved extends GkmError {\n\tconstructor(\n\t\treadonly root: string,\n\t\toverride readonly cause: unknown,\n\t) {\n\t\tsuper(\n\t\t\t`Could not load the drivers seeds run with from ${root} — ` +\n\t\t\t\t`${cause instanceof Error ? cause.message : String(cause)}. ` +\n\t\t\t\t`They are the ones the app's own entry registers; install the ` +\n\t\t\t\t`package it names where the project's constructs are declared.`,\n\t\t);\n\t\tthis.name = 'SeedDriversUnresolved';\n\t}\n}\n\n/**\n * Register the drivers a generated entry for this project would: storage when\n * it installs `@geekmidas/storage`, the cache backend its caches resolve to,\n * and the broker its topics and queues do. Nothing when it declares none.\n */\nexport async function registerSeedDrivers(options: {\n\troot: string;\n\tmanifest: ConstructManifest;\n\tbackends: SeedBackends;\n}): Promise<void> {\n\tconst drivers = driversFor({\n\t\tappRoot: options.root,\n\t\tcache: cacheBackendsIn(options.manifest, options.backends.cache),\n\t\tevents: eventsBackendsIn(options.manifest, options.backends.events),\n\t});\n\tif (!drivers.setup) return;\n\n\tconst content = `${drivers.imports}\\n\\n${drivers.setup}\\n`;\n\tconst dir = join(options.root, '.gkm');\n\tconst file = join(dir, 'seed-drivers.mjs');\n\tawait mkdir(dir, { recursive: true });\n\tawait writeFile(file, content);\n\n\t// Keyed by content: registration is idempotent, but a process seeding\n\t// twice after the declarations changed must load the new set.\n\tconst url = pathToFileURL(file);\n\turl.searchParams.set(\n\t\t'v',\n\t\tcreateHash('sha256').update(content).digest('hex').slice(0, 12),\n\t);\n\n\ttry {\n\t\tawait import(url.href);\n\t} catch (error) {\n\t\tthrow new SeedDriversUnresolved(options.root, error);\n\t}\n}\n","/**\n * Bring each construct's schema up to its migrations folder.\n *\n * Which constructs, in what order, from which folder, is `migrationTargets`'\n * answer and nobody else's. What is decided here is only how one target is\n * run: as its owner, in its own schema, with a history of its own.\n */\n\nimport { readdir } from 'node:fs/promises';\nimport { createRequire } from 'node:module';\nimport { join } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport {\n\ttype ConstructManifest,\n\tcanonicalId,\n\tDATABASE_FOLDERS,\n\tMIGRATIONS_ROOT,\n\ttype MigrationTarget,\n\tmigrationTargets,\n\tprovidedKeyFor,\n} from '@geekmidas/manifest';\nimport type { Kysely, KyselyConfig } from 'kysely';\nimport type { Migrator } from 'kysely/migration';\nimport pg from 'pg';\nimport { GkmError } from '../errors';\nimport type { ConstructSource } from '../reconcile/discover';\nimport { folderProvider, loadSeeds, migrationFiles } from './provider';\nimport { registerSeedDrivers, type SeedBackends } from './seedDrivers';\n\nexport interface DatabasesOptions {\n\t/** The project root — where `db/` lives. */\n\troot: string;\n\tmanifest: ConstructManifest;\n\t/**\n\t * Where each construct was declared. A construct's migrations run with the\n\t * Kysely its own file resolves, which is the one its migrations import.\n\t */\n\tsources?: Readonly<Record<string, ConstructSource>>;\n\t/** The resolved environment: each construct's owner URL is read from it. */\n\tenv: Readonly<Record<string, string | undefined>>;\n\t/** One construct, by name. All of them when absent. */\n\tonly?: string;\n}\n\nexport interface MigrationRun {\n\ttarget: MigrationTarget;\n\t/** The migrations this run applied, in order. */\n\tapplied: string[];\n}\n\nexport interface SeedOptions extends DatabasesOptions {\n\t/** The stage being seeded, handed to every seed. */\n\tstage: string;\n\t/**\n\t * What the stage's caches and topics resolve to — which drivers a seed is\n\t * run with, as the stage's own entry would register them.\n\t */\n\tbackends: SeedBackends;\n}\n\nexport interface SeedRun {\n\ttarget: MigrationTarget;\n\t/** The seeds this run ran, in order — every one, every time. */\n\tseeded: string[];\n}\n\n/** The seeds a run would run for one construct, read without connecting. */\nexport interface PlannedSeeds {\n\ttarget: MigrationTarget;\n\t/** In the order they would run. */\n\tseeds: string[];\n}\n\nexport interface PendingMigrations {\n\ttarget: MigrationTarget;\n\tpending: string[];\n}\n\n/** A folder under `db/` that names no construct. */\nexport class UnknownMigrationFolder extends GkmError {\n\tconstructor(\n\t\treadonly folder: string,\n\t\treadonly known: readonly string[],\n\t) {\n\t\tsuper(\n\t\t\t`${folder} names no database construct, so its migrations would never ` +\n\t\t\t\t`run. ${known.length > 0 ? `The folders that do: ${known.join(', ')}.` : 'This project declares no database.'} ` +\n\t\t\t\t`Rename the folder after the construct it belongs to.`,\n\t\t);\n\t\tthis.name = 'UnknownMigrationFolder';\n\t}\n}\n\n/** A construct was asked for by a name that takes no migrations. */\nexport class NoSuchMigrationTarget extends GkmError {\n\tconstructor(\n\t\treadonly construct: string,\n\t\treadonly known: readonly string[],\n\t) {\n\t\tsuper(\n\t\t\t`'${construct}' is not a database construct. ` +\n\t\t\t\t(known.length > 0\n\t\t\t\t\t? `The ones with migrations: ${known.join(', ')}.`\n\t\t\t\t\t: 'This project declares no database.'),\n\t\t);\n\t\tthis.name = 'NoSuchMigrationTarget';\n\t}\n}\n\n/**\n * A migration left directly in a construct's folder, where nothing reads it.\n *\n * Migrations moved into `migrations/` so seeds could sit beside them. A file\n * still at the old level would otherwise never run, and nothing would say so.\n */\nexport class MigrationsOutsideFolder extends GkmError {\n\tconstructor(\n\t\treadonly folder: string,\n\t\treadonly files: readonly string[],\n\t) {\n\t\tsuper(\n\t\t\t`${folder} has ${files.join(', ')} directly inside it, where nothing ` +\n\t\t\t\t`runs them. Migrations live in ${folder}/migrations/ and seeds in ` +\n\t\t\t\t`${folder}/seeds/ — move ${files.length === 1 ? 'it' : 'them'} there.`,\n\t\t);\n\t\tthis.name = 'MigrationsOutsideFolder';\n\t}\n}\n\n/** A folder inside a construct's folder that is neither `migrations` nor `seeds`. */\nexport class UnknownDatabaseFolder extends GkmError {\n\tconstructor(readonly folder: string) {\n\t\tsuper(\n\t\t\t`${folder} is neither migrations/ nor seeds/, so nothing in it would ` +\n\t\t\t\t`ever run. A construct's folder holds those two; rename or remove it.`,\n\t\t);\n\t\tthis.name = 'UnknownDatabaseFolder';\n\t}\n}\n\n/** A seed failed; its own writes are rolled back, the ones before it stay. */\nexport class SeedFailed extends Error {\n\tconstructor(\n\t\treadonly construct: string,\n\t\treadonly seed: string,\n\t\toverride readonly cause: unknown,\n\t) {\n\t\tsuper(\n\t\t\t`${construct}: seed '${seed}' failed — ` +\n\t\t\t\t`${cause instanceof Error ? cause.message : String(cause)}. ` +\n\t\t\t\t`Its writes were rolled back; fix it and run it again.`,\n\t\t);\n\t\tthis.name = 'SeedFailed';\n\t}\n}\n\n/** A construct with roles has no owner URL to migrate with. */\nexport class NoOwnerCredential extends GkmError {\n\tconstructor(\n\t\treadonly construct: string,\n\t\treadonly key: string,\n\t) {\n\t\tsuper(\n\t\t\t`${construct} has no ${key} to migrate with. Migrations run as the owner ` +\n\t\t\t\t`role — the runtime one cannot create a table — and nothing ` +\n\t\t\t\t`resolved its URL. Is the stage reconciled?`,\n\t\t);\n\t\tthis.name = 'NoOwnerCredential';\n\t}\n}\n\n/** A migration failed; the ones before it in the run stay applied. */\nexport class MigrationFailed extends Error {\n\tconstructor(\n\t\treadonly construct: string,\n\t\treadonly migration: string | undefined,\n\t\toverride readonly cause: unknown,\n\t) {\n\t\tsuper(\n\t\t\t`${construct}: migration ${migration ? `'${migration}' ` : ''}failed — ` +\n\t\t\t\t`${cause instanceof Error ? cause.message : String(cause)}`,\n\t\t);\n\t\tthis.name = 'MigrationFailed';\n\t}\n}\n\n/** The project's Kysely could not be found from where a database is declared. */\nexport class KyselyNotFound extends GkmError {\n\tconstructor(readonly from: string) {\n\t\tsuper(\n\t\t\t`Could not resolve 'kysely' from ${from}. Migrations run with the ` +\n\t\t\t\t`project's own Kysely — install it where the database is declared.`,\n\t\t);\n\t\tthis.name = 'KyselyNotFound';\n\t}\n}\n\n/** Apply every pending migration, construct by construct, parents first. */\nexport async function migrateDatabases(\n\toptions: DatabasesOptions,\n): Promise<MigrationRun[]> {\n\tconst runs: MigrationRun[] = [];\n\n\tfor (const target of await targetsFor(options)) {\n\t\t// No folder, or an empty one, is nothing to do — and no reason to\n\t\t// connect, which a construct nobody has written a migration for yet\n\t\t// should not need.\n\t\tconst files = await migrationFiles(join(options.root, target.migrations));\n\t\tif (files.size === 0) {\n\t\t\truns.push({ target, applied: [] });\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst applied = await withMigrator(options, target, async (migrator) => {\n\t\t\tconst { error, results = [] } = await migrator.migrateToLatest();\n\t\t\tif (error) {\n\t\t\t\tconst failed = results.find((result) => result.status === 'Error');\n\t\t\t\tthrow new MigrationFailed(target.id, failed?.migrationName, error);\n\t\t\t}\n\n\t\t\treturn results\n\t\t\t\t.filter((result) => result.status === 'Success')\n\t\t\t\t.map((result) => result.migrationName);\n\t\t});\n\n\t\truns.push({ target, applied });\n\t}\n\n\treturn runs;\n}\n\n/**\n * Run every construct's seeds, parents first — each one, every time, on every\n * stage, production included. Each is handed the stage, so a seed decides\n * what belongs where.\n *\n * Seeds are reference data kept up to date by being run again, so there is no\n * history: a seed is an upsert, and a changed one is applied by the next run.\n * Each runs in its own transaction, as the construct's owner, so a failure\n * leaves nothing half-written. Assumes the schema is migrated —\n * {@link migrateAndSeed} is what makes that true.\n *\n * A seed is handed the client the app gets — the construct's `clientConfig`,\n * plugins included — on the owner's connection. One written against\n * `Kysely<DB>` with a `CamelCasePlugin` writes `isEditable` here as it does in\n * a handler or a test.\n *\n * And with the drivers the stage's entry registers, and the stage's `env`, so\n * a seed reaching a bucket or a cache through its construct gets the client a\n * handler would.\n */\nexport async function seedDatabases(options: SeedOptions): Promise<SeedRun[]> {\n\tconst runs: SeedRun[] = [];\n\tlet registered = false;\n\n\tfor (const target of await targetsFor(options)) {\n\t\tconst folder = join(options.root, target.seeds);\n\t\tif ((await migrationFiles(folder)).size === 0) {\n\t\t\truns.push({ target, seeded: [] });\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (!registered) {\n\t\t\tawait registerSeedDrivers(options);\n\t\t\tregistered = true;\n\t\t}\n\n\t\tconst config = clientConfigOf(options, target);\n\t\tconst seeded = await withOwner(\n\t\t\toptions,\n\t\t\ttarget,\n\t\t\tconfig,\n\t\t\tasync (db, kysely) => {\n\t\t\t\tconst names: string[] = [];\n\t\t\t\tfor (const seed of await loadSeeds(folder, kysely.sql)) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait db\n\t\t\t\t\t\t\t.transaction()\n\t\t\t\t\t\t\t.execute((trx) =>\n\t\t\t\t\t\t\t\tseed.run(trx, { stage: options.stage, env: options.env }),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tthrow new SeedFailed(target.id, seed.name, error);\n\t\t\t\t\t}\n\t\t\t\t\tnames.push(seed.name);\n\t\t\t\t}\n\t\t\t\treturn names;\n\t\t\t},\n\t\t);\n\n\t\truns.push({ target, seeded });\n\t}\n\n\treturn runs;\n}\n\n/**\n * The seeds {@link seedDatabases} would run, construct by construct, parents\n * first, in the order it would run them — read from the folders alone, with\n * no connection. What a dry run lists. Constructs with none are left out.\n */\nexport async function plannedSeeds(\n\toptions: Pick<DatabasesOptions, 'root' | 'manifest' | 'only'>,\n): Promise<PlannedSeeds[]> {\n\tconst planned: PlannedSeeds[] = [];\n\tfor (const target of await targetsFor(options)) {\n\t\tconst files = await migrationFiles(join(options.root, target.seeds));\n\t\tif (files.size === 0) continue;\n\t\tplanned.push({ target, seeds: [...files.keys()].sort() });\n\t}\n\treturn planned;\n}\n\n/**\n * Migrate, then seed: a seed only ever runs against the schema it was written\n * for.\n *\n * With `only`, the constructs it lives in are migrated too — a tenant's seed\n * cannot run before the database that owns its schema exists — and only it is\n * seeded.\n */\nexport async function migrateAndSeed(options: SeedOptions): Promise<{\n\tmigrations: MigrationRun[];\n\tseeds: SeedRun[];\n}> {\n\tconst migrations: MigrationRun[] = [];\n\tfor (const target of await withParents(options)) {\n\t\tmigrations.push(\n\t\t\t...(await migrateDatabases({ ...options, only: target.id })),\n\t\t);\n\t}\n\n\treturn { migrations, seeds: await seedDatabases(options) };\n}\n\n/** The targets `only` names, after the ones it lives in; all without it. */\nasync function withParents(\n\toptions: DatabasesOptions,\n): Promise<MigrationTarget[]> {\n\tconst chosen = await targetsFor(options);\n\tif (!options.only) return chosen;\n\n\tconst all = migrationTargets(options.manifest);\n\tconst ids = new Set<string>();\n\tfor (const target of chosen) {\n\t\tlet current: MigrationTarget | undefined = target;\n\t\twhile (current) {\n\t\t\tids.add(current.id);\n\t\t\tconst parent: string | undefined = current.of;\n\t\t\tcurrent = parent ? all.find((t) => t.id === parent) : undefined;\n\t\t}\n\t}\n\n\treturn all.filter((target) => ids.has(target.id));\n}\n\n/**\n * What each construct's folder has that its history does not — without\n * applying any of it. What `gkm dev` reports.\n */\nexport async function pendingMigrations(\n\toptions: DatabasesOptions,\n): Promise<PendingMigrations[]> {\n\tconst found: PendingMigrations[] = [];\n\n\tfor (const target of await targetsFor(options)) {\n\t\tconst files = await migrationFiles(join(options.root, target.migrations));\n\t\tif (files.size === 0) continue;\n\n\t\tconst pending = await withMigrator(options, target, async (migrator) =>\n\t\t\t(await migrator.getMigrations())\n\t\t\t\t.filter((migration) => migration.executedAt === undefined)\n\t\t\t\t.map((migration) => migration.name),\n\t\t);\n\n\t\tif (pending.length > 0) found.push({ target, pending });\n\t}\n\n\treturn found;\n}\n\n/**\n * The targets this run covers, with every folder under `db/` accounted for.\n *\n * A folder that names no construct is an error rather than something to skip:\n * a typo in its name is otherwise a migration that silently never runs.\n */\nasync function targetsFor(\n\toptions: Pick<DatabasesOptions, 'root' | 'manifest' | 'only'>,\n): Promise<MigrationTarget[]> {\n\tconst targets = migrationTargets(options.manifest);\n\tconst folders = targets.map((target) => target.folder);\n\n\tfor (const folder of await foldersIn(join(options.root, MIGRATIONS_ROOT))) {\n\t\tconst relative = `${MIGRATIONS_ROOT}/${folder}`;\n\t\tif (!folders.includes(relative)) {\n\t\t\tthrow new UnknownMigrationFolder(relative, folders);\n\t\t}\n\t\tawait checkLayout(options.root, relative);\n\t}\n\n\tif (!options.only) return targets;\n\n\tconst id = canonicalId(options.only);\n\tconst chosen = targets.filter((target) => target.id === id);\n\tif (chosen.length === 0) {\n\t\tthrow new NoSuchMigrationTarget(\n\t\t\toptions.only,\n\t\t\ttargets.map((target) => target.id),\n\t\t);\n\t}\n\n\treturn chosen;\n}\n\n/**\n * A construct's folder holds `migrations/` and `seeds/`, and nothing else —\n * anything beside them is a file or folder nothing would ever run.\n */\nasync function checkLayout(root: string, folder: string): Promise<void> {\n\tconst entries = await readdir(join(root, folder), { withFileTypes: true });\n\n\tconst loose = entries\n\t\t.filter((entry) => entry.isFile() && !entry.name.startsWith('.'))\n\t\t.map((entry) => entry.name);\n\tif (loose.length > 0) throw new MigrationsOutsideFolder(folder, loose);\n\n\tfor (const entry of entries) {\n\t\tif (\n\t\t\tentry.isDirectory() &&\n\t\t\t!(DATABASE_FOLDERS as readonly string[]).includes(entry.name)\n\t\t) {\n\t\t\tthrow new UnknownDatabaseFolder(`${folder}/${entry.name}`);\n\t\t}\n\t}\n}\n\nasync function foldersIn(dir: string): Promise<string[]> {\n\tconst entries = await readdir(dir, { withFileTypes: true }).catch(\n\t\t(error: NodeJS.ErrnoException) => {\n\t\t\tif (error.code === 'ENOENT') return [];\n\t\t\tthrow error;\n\t\t},\n\t);\n\n\treturn entries\n\t\t.filter((entry) => entry.isDirectory())\n\t\t.map((entry) => entry.name);\n}\n\n/**\n * A migrator for one target, connected as its owner.\n *\n * No `migrationTableSchema`: the owner role's `search_path` is pinned to the\n * construct's schema, so the history lands there — `app.kysely_migration` for\n * the database, `auth_database.kysely_migration` for its tenant — and two\n * constructs in one Postgres never share one.\n *\n * Unordered migrations are allowed. Files are timestamped, so a branch merged\n * after another's migration ran carries an older one; refusing it would make\n * every such merge a manual repair.\n *\n * The client is bare — none of the construct's plugins. A casing plugin\n * rewrites identifiers in schema-builder DDL too, and a migration must do the\n * same thing forever after it has run, so it cannot depend on configuration\n * that may change.\n */\nasync function withMigrator<T>(\n\toptions: DatabasesOptions,\n\ttarget: MigrationTarget,\n\trun: (migrator: Migrator) => Promise<T>,\n): Promise<T> {\n\treturn withOwner(options, target, {}, (db, { Migrator, sql }) =>\n\t\trun(\n\t\t\tnew Migrator({\n\t\t\t\tdb,\n\t\t\t\tprovider: folderProvider(join(options.root, target.migrations), sql),\n\t\t\t\tallowUnorderedMigrations: true,\n\t\t\t}),\n\t\t),\n\t);\n}\n\n/**\n * One target's database, connected as its owner and closed afterwards — what\n * migrations and seeds both run as, each with the client config it needs.\n */\nasync function withOwner<T>(\n\toptions: DatabasesOptions,\n\ttarget: MigrationTarget,\n\tconfig: Omit<KyselyConfig, 'dialect'>,\n\trun: (\n\t\tdb: Kysely<unknown>,\n\t\tkysely: Awaited<ReturnType<typeof kyselyFrom>>,\n\t) => Promise<T>,\n): Promise<T> {\n\tconst from =\n\t\toptions.sources?.[target.id]?.file ??\n\t\t(target.of ? options.sources?.[target.of]?.file : undefined) ??\n\t\tjoin(options.root, 'package.json');\n\tconst kysely = await kyselyFrom(from);\n\n\tconst db: Kysely<unknown> = new kysely.Kysely<unknown>({\n\t\t...config,\n\t\tdialect: new kysely.PostgresDialect({\n\t\t\tpool: new pg.Pool(poolConfig(ownerUrl(options, target))),\n\t\t}),\n\t});\n\n\ttry {\n\t\treturn await run(db, kysely);\n\t} finally {\n\t\tawait db.destroy();\n\t}\n}\n\n/**\n * What the construct builds its clients with besides a dialect — its plugins\n * and logging — read from the construct discovery already imported.\n *\n * A tenant's is its own: `database.schema('Auth', { plugins })` declares the\n * client for its tables, not the parent's. With no construct to ask (a\n * manifest without sources), the client is bare.\n */\nfunction clientConfigOf(\n\toptions: DatabasesOptions,\n\ttarget: MigrationTarget,\n): Omit<KyselyConfig, 'dialect'> {\n\tconst construct = options.sources?.[target.id]?.construct;\n\tif (typeof construct !== 'object' || construct === null) return {};\n\tif (!('clientConfig' in construct)) return {};\n\treturn (construct.clientConfig as Omit<KyselyConfig, 'dialect'>) ?? {};\n}\n\n/**\n * The owner's URL, with no fallback to the runtime one.\n *\n * The runtime role can create nothing, so falling back would only move the\n * failure to the first `CREATE TABLE` and make it read like a permissions\n * bug. The one exception is a database declared `roles: false`, where there is\n * no owner — both URLs are the master credential by design.\n */\nfunction ownerUrl(options: DatabasesOptions, target: MigrationTarget): string {\n\tconst key = providedKeyFor(target.id, 'database', 'ownerUrl');\n\tconst owner = options.env[key];\n\tif (owner) return owner;\n\n\tconst database = options.manifest[target.of ?? target.id];\n\tif (database?.kind === 'database' && database.roles === false) {\n\t\tconst url = options.env[providedKeyFor(target.id, 'database', 'url')];\n\t\tif (url) return url;\n\t}\n\n\tthrow new NoOwnerCredential(target.id, key);\n}\n\n/**\n * Pool settings for a URL, with `?search_path=` as the startup option Postgres\n * reads. Only a `roles: false` URL carries it — a role pins its own.\n */\nfunction poolConfig(url: string): pg.PoolConfig {\n\tconst parsed = new URL(url);\n\tconst searchPath = parsed.searchParams.get('search_path');\n\tif (!searchPath) return { connectionString: url };\n\n\tparsed.searchParams.delete('search_path');\n\treturn {\n\t\tconnectionString: parsed.toString(),\n\t\toptions: `-c search_path=${searchPath}`,\n\t};\n}\n\n/** Kysely as the project resolves it from `from`. */\nasync function kyselyFrom(from: string) {\n\tconst require = createRequire(from);\n\n\ttry {\n\t\tconst [main, migration] = await Promise.all([\n\t\t\timport(pathToFileURL(require.resolve('kysely')).href),\n\t\t\timport(pathToFileURL(require.resolve('kysely/migration')).href),\n\t\t]);\n\n\t\treturn {\n\t\t\tKysely: main.Kysely as typeof import('kysely').Kysely,\n\t\t\tPostgresDialect:\n\t\t\t\tmain.PostgresDialect as typeof import('kysely').PostgresDialect,\n\t\t\tsql: main.sql as typeof import('kys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M,IAAI,kBAAkB,OAAO,IAAI,GAAG;AAC3C;;;;;AAMA,SAAS,WAAW,KAA4B;CAC/C,MAAM,SAAS,IAAI,IAAI,GAAG;CAC1B,MAAM,aAAa,OAAO,aAAa,IAAI,aAAa;CACxD,IAAI,CAAC,YAAY,OAAO,EAAE,kBAAkB,IAAI;CAEhD,OAAO,aAAa,OAAO,aAAa;CACxC,OAAO;EACN,kBAAkB,OAAO,SAAS;EAClC,SAAS,kBAAkB;CAC5B;AACD;;AAGA,eAAe,WAAW,MAAc;CACvC,MAAM,UAAU,cAAc,IAAI;CAElC,IAAI;EACH,MAAM,CAAC,MAAM,aAAa,MAAM,QAAQ,IAAI,CAC3C,OAAO,cAAc,QAAQ,QAAQ,QAAQ,CAAC,CAAC,CAAC,OAChD,OAAO,cAAc,QAAQ,QAAQ,kBAAkB,CAAC,CAAC,CAAC,KAC3D,CAAC;EAED,OAAO;GACN,QAAQ,KAAK;GACb,iBACC,KAAK;GACN,KAAK,KAAK;GACV,UACC,UAAU;EACZ;CACD,QAAQ;EACP,MAAM,IAAI,eAAe,IAAI;CAC9B;AACD"}
|
package/dist/deploy/public.cjs
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_errors = require("../errors-DMC4Umsb.cjs");
|
|
3
|
-
const require_credentials = require("../credentials-
|
|
4
|
-
const require_workspace = require("../workspace-
|
|
5
|
-
const require_apps = require("../apps-
|
|
3
|
+
const require_credentials = require("../credentials-C6n_kdu4.cjs");
|
|
4
|
+
const require_workspace = require("../workspace-CEpojAus.cjs");
|
|
5
|
+
const require_apps = require("../apps-D_-DXV0H.cjs");
|
|
6
6
|
const require_define = require("../define-crmMcXFS.cjs");
|
|
7
|
-
const require_discover = require("../discover-
|
|
7
|
+
const require_discover = require("../discover-39VKSE2i.cjs");
|
|
8
8
|
const require_config = require("../config.cjs");
|
|
9
|
-
const require_resolve = require("../resolve-
|
|
10
|
-
const require_notes = require("../notes-
|
|
11
|
-
const require_local = require("../local-
|
|
12
|
-
const require_sniffer = require("../sniffer-
|
|
13
|
-
const require_deploy = require("../deploy-
|
|
9
|
+
const require_resolve = require("../resolve-BKn4TTn3.cjs");
|
|
10
|
+
const require_notes = require("../notes-Cw3JQ0Y_.cjs");
|
|
11
|
+
const require_local = require("../local-DxfqOu7A.cjs");
|
|
12
|
+
const require_sniffer = require("../sniffer-CUImZsQL.cjs");
|
|
13
|
+
const require_deploy = require("../deploy-C1gf4bT-.cjs");
|
|
14
14
|
const require_seeds = require("../seeds-Bc3niNVb.cjs");
|
|
15
|
-
const require_engine = require("../engine-
|
|
16
|
-
const require_rollback = require("../rollback-
|
|
15
|
+
const require_engine = require("../engine-BMoNLayn.cjs");
|
|
16
|
+
const require_rollback = require("../rollback-6ZeoByXd.cjs");
|
|
17
17
|
const require_provider = require("../provider-BqpjG9QM.cjs");
|
|
18
|
-
const require_sst = require("../sst-
|
|
18
|
+
const require_sst = require("../sst-ct0Vhta9.cjs");
|
|
19
19
|
let node_path = require("node:path");
|
|
20
20
|
let node_fs = require("node:fs");
|
|
21
21
|
//#region src/sandbox/install.ts
|
package/dist/deploy/public.mjs
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { t as GkmError } from "../errors-D8Gwp5kU.mjs";
|
|
2
|
-
import { X as deployIdentity, bt as gkmHome, it as CommandTimedOut, n as chainCredentials, r as storedCredentials, rt as CommandFailed, t as MissingCredential, yt as GKM_HOME_ENV } from "../credentials-
|
|
3
|
-
import { V as UnknownStageProvider, xt as ProvisionedBucketUnreachable } from "../workspace-
|
|
4
|
-
import { V as detectPackageManager } from "../apps-
|
|
2
|
+
import { X as deployIdentity, bt as gkmHome, it as CommandTimedOut, n as chainCredentials, r as storedCredentials, rt as CommandFailed, t as MissingCredential, yt as GKM_HOME_ENV } from "../credentials-kK0X754I.mjs";
|
|
3
|
+
import { V as UnknownStageProvider, xt as ProvisionedBucketUnreachable } from "../workspace-_aoe8v6u.mjs";
|
|
4
|
+
import { V as detectPackageManager } from "../apps-C21-TXqR.mjs";
|
|
5
5
|
import { a as UnknownDeployTarget, i as DeployTargetNotYetSupported } from "../define-6poNqm5O.mjs";
|
|
6
|
-
import { d as SECRETS_DIR_ENV, f as SandboxCwdEscape, g as confineCwd, n as ConstructsNotSerializable, p as SecretNameInvalid, s as SandboxWorkerFailed, t as ConstructDiscoveryFailed } from "../discover-
|
|
6
|
+
import { d as SECRETS_DIR_ENV, f as SandboxCwdEscape, g as confineCwd, n as ConstructsNotSerializable, p as SecretNameInvalid, s as SandboxWorkerFailed, t as ConstructDiscoveryFailed } from "../discover-B_PDDaVj.mjs";
|
|
7
7
|
import { ConfigLoadFailed, ConfigObjectNotSerializable } from "../config.mjs";
|
|
8
|
-
import { i as TargetRuntimeMismatch, l as TargetPackageNotFound, n as TargetEntryInvalid, r as TargetPackageInvalid, s as TargetRuntimeUndeclared, t as InvalidTargetOptions } from "../resolve-
|
|
9
|
-
import { c as DevServicesNeedServerTarget, l as ExternalServicesNotConfigured, o as AllowDevServicesTakesNoValue, s as DEV_SERVICES, t as StageProviderDisabled } from "../notes-
|
|
10
|
-
import { n as SANDBOX_ENV_ALLOWLIST, r as allowlistedEnv, t as LocalSandbox } from "../local-
|
|
11
|
-
import { a as DeploymentTimedOut, f as StateLocked, g as StateVersionConflict, i as DeploymentFailed, u as LocalStateInCi } from "../sniffer-
|
|
12
|
-
import { a as UnknownDeployApps, i as TargetBuildsNothing, n as NoDeployableApps, r as RollbackFailed, t as deploy } from "../deploy-
|
|
8
|
+
import { i as TargetRuntimeMismatch, l as TargetPackageNotFound, n as TargetEntryInvalid, r as TargetPackageInvalid, s as TargetRuntimeUndeclared, t as InvalidTargetOptions } from "../resolve-DrFS2Ivb.mjs";
|
|
9
|
+
import { c as DevServicesNeedServerTarget, l as ExternalServicesNotConfigured, o as AllowDevServicesTakesNoValue, s as DEV_SERVICES, t as StageProviderDisabled } from "../notes-CT1jNLDC.mjs";
|
|
10
|
+
import { n as SANDBOX_ENV_ALLOWLIST, r as allowlistedEnv, t as LocalSandbox } from "../local-B9Vniy-F.mjs";
|
|
11
|
+
import { a as DeploymentTimedOut, f as StateLocked, g as StateVersionConflict, i as DeploymentFailed, u as LocalStateInCi } from "../sniffer-DcT9RrAj.mjs";
|
|
12
|
+
import { a as UnknownDeployApps, i as TargetBuildsNothing, n as NoDeployableApps, r as RollbackFailed, t as deploy } from "../deploy-CFuDCbTq.mjs";
|
|
13
13
|
import { t as DeploySeedsFailed } from "../seeds-Ccn0Ru2T.mjs";
|
|
14
|
-
import { _ as RegistryNotConfigured, g as RegistryAmbiguous, h as HealthCheckTimedOut, m as DeployMigrationsFailed, n as FrontendDeployFailed, r as MissingEnvVars, t as BackendDeployFailed, v as RegistryNotFound, y as ProjectNotOwned } from "../engine-
|
|
15
|
-
import { i as rollbackStage, n as RollbackNeedsApp, r as StageNeverDeployed, t as NothingToRollBack } from "../rollback-
|
|
14
|
+
import { _ as RegistryNotConfigured, g as RegistryAmbiguous, h as HealthCheckTimedOut, m as DeployMigrationsFailed, n as FrontendDeployFailed, r as MissingEnvVars, t as BackendDeployFailed, v as RegistryNotFound, y as ProjectNotOwned } from "../engine-D-_nkxQL.mjs";
|
|
15
|
+
import { i as rollbackStage, n as RollbackNeedsApp, r as StageNeverDeployed, t as NothingToRollBack } from "../rollback-B3lHgwkj.mjs";
|
|
16
16
|
import { t as ProviderRemoved } from "../provider-CEOKk8NS.mjs";
|
|
17
|
-
import { i as SurfacesUnhealthy, r as SstOutputsUnreadable, t as SstConfigNotFound } from "../sst-
|
|
17
|
+
import { i as SurfacesUnhealthy, r as SstOutputsUnreadable, t as SstConfigNotFound } from "../sst-CB6rX5Zs.mjs";
|
|
18
18
|
import { join, resolve } from "node:path";
|
|
19
19
|
import { existsSync } from "node:fs";
|
|
20
20
|
//#region src/sandbox/install.ts
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
const require_rolldown_runtime = require("./rolldown-runtime-C0BPl7ul.cjs");
|
|
2
2
|
const require_errors = require("./errors-DMC4Umsb.cjs");
|
|
3
|
-
const require_credentials = require("./credentials-
|
|
4
|
-
const require_workspace = require("./workspace-
|
|
5
|
-
const require_apps = require("./apps-
|
|
3
|
+
const require_credentials = require("./credentials-C6n_kdu4.cjs");
|
|
4
|
+
const require_workspace = require("./workspace-CEpojAus.cjs");
|
|
5
|
+
const require_apps = require("./apps-D_-DXV0H.cjs");
|
|
6
6
|
const require_define = require("./define-crmMcXFS.cjs");
|
|
7
|
-
const require_compose = require("./compose-
|
|
8
|
-
const require_SubscriberGenerator = require("./SubscriberGenerator-
|
|
9
|
-
const require_discover = require("./discover-
|
|
7
|
+
const require_compose = require("./compose-Dgd-yfJT.cjs");
|
|
8
|
+
const require_SubscriberGenerator = require("./SubscriberGenerator-DMi4siph.cjs");
|
|
9
|
+
const require_discover = require("./discover-39VKSE2i.cjs");
|
|
10
10
|
const require_config = require("./config.cjs");
|
|
11
|
-
const require_resolve = require("./resolve-
|
|
12
|
-
const require_notes = require("./notes-
|
|
13
|
-
const require_stack = require("./stack-
|
|
14
|
-
const require_snsSubscriptions = require("./snsSubscriptions-
|
|
15
|
-
const require_local = require("./local-
|
|
16
|
-
const require_sniffer = require("./sniffer-
|
|
17
|
-
const require_iam = require("./iam-
|
|
18
|
-
const require_projectBucket = require("./projectBucket-
|
|
11
|
+
const require_resolve = require("./resolve-BKn4TTn3.cjs");
|
|
12
|
+
const require_notes = require("./notes-Cw3JQ0Y_.cjs");
|
|
13
|
+
const require_stack = require("./stack-CkdkfmpN.cjs");
|
|
14
|
+
const require_snsSubscriptions = require("./snsSubscriptions-1lX1ze3u.cjs");
|
|
15
|
+
const require_local = require("./local-DxfqOu7A.cjs");
|
|
16
|
+
const require_sniffer = require("./sniffer-CUImZsQL.cjs");
|
|
17
|
+
const require_iam = require("./iam-BoYPPNdM.cjs");
|
|
18
|
+
const require_projectBucket = require("./projectBucket-8hJmCusk.cjs");
|
|
19
19
|
const require_seeds = require("./seeds-Bc3niNVb.cjs");
|
|
20
|
-
const require_credentialSchemas = require("./credentialSchemas-
|
|
20
|
+
const require_credentialSchemas = require("./credentialSchemas-OVXofU-r.cjs");
|
|
21
21
|
let node_path = require("node:path");
|
|
22
22
|
let node_crypto = require("node:crypto");
|
|
23
23
|
let _geekmidas_manifest = require("@geekmidas/manifest");
|
|
@@ -1410,8 +1410,8 @@ async function ensureBucketEvents(ctx, s3, input) {
|
|
|
1410
1410
|
*/
|
|
1411
1411
|
async function ensureEventsKey(ctx, input) {
|
|
1412
1412
|
const { id, topicArn, region } = input;
|
|
1413
|
-
const key = input.key ?? (0, _geekmidas_manifest.
|
|
1414
|
-
const url = ctx.secrets[input.urlKey ?? (0, _geekmidas_manifest.
|
|
1413
|
+
const key = input.key ?? (0, _geekmidas_manifest.providedKeyFor)(id, "objects", "eventsConnectionString");
|
|
1414
|
+
const url = ctx.secrets[input.urlKey ?? (0, _geekmidas_manifest.providedKeyFor)(id, "objects", "connectionString")];
|
|
1415
1415
|
let parsed;
|
|
1416
1416
|
try {
|
|
1417
1417
|
parsed = url ? _geekmidas_storage_s3_url.parse(url) : void 0;
|
|
@@ -1545,7 +1545,7 @@ async function ensurePushSubscriptions(ctx, input) {
|
|
|
1545
1545
|
* address over it.
|
|
1546
1546
|
*/
|
|
1547
1547
|
function bucketKeys(manifest, bucket) {
|
|
1548
|
-
return [(0, _geekmidas_manifest.
|
|
1548
|
+
return [(0, _geekmidas_manifest.providedKeyFor)(bucket, "objects", "connectionString"), ...Object.entries(manifest).filter(([, d]) => d.kind === "file-server" && d.of === bucket).map(([id]) => (0, _geekmidas_manifest.providedKeyFor)(id, "file-server", "url"))];
|
|
1549
1549
|
}
|
|
1550
1550
|
function bucketOrigins(input) {
|
|
1551
1551
|
const { manifest, workspace, stage } = input;
|
|
@@ -1785,7 +1785,7 @@ async function ensureBucket(ctx, stageClients, construct, watchers) {
|
|
|
1785
1785
|
id,
|
|
1786
1786
|
secret: require_iam.s3KeySecret(ctx, clients, {
|
|
1787
1787
|
bucket,
|
|
1788
|
-
urlKey: (0, _geekmidas_manifest.
|
|
1788
|
+
urlKey: (0, _geekmidas_manifest.providedKeyFor)(id, "objects", "connectionString")
|
|
1789
1789
|
}),
|
|
1790
1790
|
...user
|
|
1791
1791
|
});
|
|
@@ -2094,7 +2094,7 @@ function canonicalCors(rule) {
|
|
|
2094
2094
|
async function verifyS3(ctx) {
|
|
2095
2095
|
const S3 = await import("@aws-sdk/client-s3");
|
|
2096
2096
|
for (const { id } of bucketConstructs(ctx.manifest)) {
|
|
2097
|
-
const urlKey = (0, _geekmidas_manifest.
|
|
2097
|
+
const urlKey = (0, _geekmidas_manifest.providedKeyFor)(id, "objects", "connectionString");
|
|
2098
2098
|
const url = ctx.secrets[urlKey];
|
|
2099
2099
|
if (url === void 0) continue;
|
|
2100
2100
|
const address = _geekmidas_storage_s3_url.parse(url);
|
|
@@ -2148,8 +2148,8 @@ const s3Provider = {
|
|
|
2148
2148
|
runtimeKeys(manifest) {
|
|
2149
2149
|
const watched = bucketWatchers(manifest);
|
|
2150
2150
|
return bucketConstructs(manifest).flatMap((b) => [
|
|
2151
|
-
(0, _geekmidas_manifest.
|
|
2152
|
-
...watched.has(b.id) ? [(0, _geekmidas_manifest.
|
|
2151
|
+
(0, _geekmidas_manifest.providedKeyFor)(b.id, "objects", "connectionString"),
|
|
2152
|
+
...watched.has(b.id) ? [(0, _geekmidas_manifest.providedKeyFor)(b.id, "objects", "eventsConnectionString")] : [],
|
|
2153
2153
|
...b.servers.map((s) => (0, _geekmidas_manifest.providedKeyFor)(s.id, "file-server", "url"))
|
|
2154
2154
|
]);
|
|
2155
2155
|
},
|
|
@@ -2356,7 +2356,7 @@ async function ensureIdentity$1(ctx, { SES, ses }, domain) {
|
|
|
2356
2356
|
async function ensureInbox(ctx, { SES, ses }, events, input) {
|
|
2357
2357
|
const { inbox, domain, region, ruleSet } = input;
|
|
2358
2358
|
const name = require_workspace.inboxBucketId(inbox.id);
|
|
2359
|
-
const urlKey = (0, _geekmidas_manifest.
|
|
2359
|
+
const urlKey = (0, _geekmidas_manifest.providedKeyFor)(inbox.id, inbox.kind, "url");
|
|
2360
2360
|
const topicArn = await ensureTopic(ctx, events, {
|
|
2361
2361
|
id: inbox.id,
|
|
2362
2362
|
topicName: require_workspace.inboxTopicName(ctx.identity.scope, ctx.stage, inbox.id),
|
|
@@ -2377,7 +2377,7 @@ async function ensureInbox(ctx, { SES, ses }, events, input) {
|
|
|
2377
2377
|
id: inbox.id,
|
|
2378
2378
|
topicArn,
|
|
2379
2379
|
region,
|
|
2380
|
-
key: (0, _geekmidas_manifest.
|
|
2380
|
+
key: (0, _geekmidas_manifest.providedKeyFor)(inbox.topic, "topic", "publisherConnectionString"),
|
|
2381
2381
|
urlKey
|
|
2382
2382
|
});
|
|
2383
2383
|
const rule = {
|
|
@@ -2472,7 +2472,7 @@ async function verifySes(ctx) {
|
|
|
2472
2472
|
if (inboxes.length === 0) return;
|
|
2473
2473
|
stageDomain(ctx);
|
|
2474
2474
|
for (const inbox of inboxes) {
|
|
2475
|
-
const missing = [(0, _geekmidas_manifest.
|
|
2475
|
+
const missing = [(0, _geekmidas_manifest.providedKeyFor)(inbox.id, inbox.kind, "url"), (0, _geekmidas_manifest.providedKeyFor)(inbox.topic, "topic", "publisherConnectionString")].filter((key) => ctx.secrets[key] === void 0);
|
|
2476
2476
|
if (missing.length > 0) throw new require_workspace.InboxNotProvisioned(ctx.stage, inbox.id, missing);
|
|
2477
2477
|
}
|
|
2478
2478
|
}
|
|
@@ -2483,7 +2483,7 @@ const sesProvider = {
|
|
|
2483
2483
|
provisioning: require_workspace.SES_PROVISIONING,
|
|
2484
2484
|
credentials: require_snsSubscriptions.awsProvisioningCredentials,
|
|
2485
2485
|
runtimeKeys(manifest) {
|
|
2486
|
-
return inboxConstructs(manifest).flatMap((inbox) => [(0, _geekmidas_manifest.
|
|
2486
|
+
return inboxConstructs(manifest).flatMap((inbox) => [(0, _geekmidas_manifest.providedKeyFor)(inbox.id, inbox.kind, "url"), (0, _geekmidas_manifest.providedKeyFor)(inbox.topic, "topic", "publisherConnectionString")]);
|
|
2487
2487
|
},
|
|
2488
2488
|
ensure: ensureSes,
|
|
2489
2489
|
verify: verifySes
|
|
@@ -2563,8 +2563,8 @@ function smtpKeySecret(urlKey, region) {
|
|
|
2563
2563
|
* that identity and nothing else, and **its access key**, written into the
|
|
2564
2564
|
* stage's secrets as `<ID>_URL` — `smtp://<key id>:<smtp password>@
|
|
2565
2565
|
* email-smtp.<region>.amazonaws.com:587`, the password derived from the key;
|
|
2566
|
-
* - **`<ID>_FROM`**: `from`, else what the secrets hold, else
|
|
2567
|
-
* stage's domain.
|
|
2566
|
+
* - **`<ID>_FROM`**: `from`, else what the secrets hold, else the construct's
|
|
2567
|
+
* local part (`noreply` without one) at the stage's domain.
|
|
2568
2568
|
*
|
|
2569
2569
|
* A `<ID>_URL` the stage's secrets already hold, and this provider did not
|
|
2570
2570
|
* write, wins: the construct sends with it and nothing is created for it — an
|
|
@@ -2606,7 +2606,7 @@ function identityArn(region, account, domain) {
|
|
|
2606
2606
|
* not write — one set by hand, or imported — which it then leaves alone.
|
|
2607
2607
|
*/
|
|
2608
2608
|
function urlSetElsewhere(ctx, email) {
|
|
2609
|
-
const given = ctx.secrets[(0, _geekmidas_manifest.
|
|
2609
|
+
const given = ctx.secrets[(0, _geekmidas_manifest.providedKeyFor)(email, "email", "url")];
|
|
2610
2610
|
if (given === void 0) return false;
|
|
2611
2611
|
const record = ctx.state.record(`iam-access-key:${email}`);
|
|
2612
2612
|
if (!record) return true;
|
|
@@ -2622,9 +2622,10 @@ function senderEntry(email) {
|
|
|
2622
2622
|
}
|
|
2623
2623
|
/**
|
|
2624
2624
|
* The address `email` sends from: `from`; else one the stage's secrets hold
|
|
2625
|
-
* that gkm did not write — set by hand, or imported; else
|
|
2626
|
-
* stage's domain. An address gkm wrote
|
|
2627
|
-
* `domains.<stage
|
|
2625
|
+
* that gkm did not write — set by hand, or imported; else the construct's
|
|
2626
|
+
* local part at the stage's domain (`senderAddress`). An address gkm wrote
|
|
2627
|
+
* follows both: after a change of `domains.<stage>` or of the construct's
|
|
2628
|
+
* `from`, mail is sent as the new one.
|
|
2628
2629
|
*
|
|
2629
2630
|
* @returns the address, and whether it is gkm's to write and record
|
|
2630
2631
|
* @throws {EmailSenderUnknown} with none of them
|
|
@@ -2634,11 +2635,12 @@ function senderOf(ctx, email) {
|
|
|
2634
2635
|
address: ctx.config.from,
|
|
2635
2636
|
ours: true
|
|
2636
2637
|
};
|
|
2637
|
-
const held = ctx.secrets[(0, _geekmidas_manifest.
|
|
2638
|
-
const wrote = ctx.state.record(senderEntry(email).key)?.id;
|
|
2638
|
+
const held = ctx.secrets[(0, _geekmidas_manifest.providedKeyFor)(email.id, "email", "from")];
|
|
2639
|
+
const wrote = ctx.state.record(senderEntry(email.id).key)?.id;
|
|
2639
2640
|
const domain = ctx.workspace.domains?.[ctx.stage];
|
|
2640
|
-
const fallback = domain ?
|
|
2641
|
-
|
|
2641
|
+
const fallback = domain ? (0, _geekmidas_manifest.senderAddress)(email, domain) : void 0;
|
|
2642
|
+
const adopted = [fallback, domain && (0, _geekmidas_manifest.senderAddress)({}, domain)];
|
|
2643
|
+
if (held && held !== wrote && !adopted.includes(held)) return {
|
|
2642
2644
|
address: held,
|
|
2643
2645
|
ours: false
|
|
2644
2646
|
};
|
|
@@ -2674,12 +2676,12 @@ async function iamClients(credential, region) {
|
|
|
2674
2676
|
async function ensureSesEmail(ctx) {
|
|
2675
2677
|
const owned = emailConstructs(ctx.manifest).filter((email) => {
|
|
2676
2678
|
if (!urlSetElsewhere(ctx, email.id)) return true;
|
|
2677
|
-
ctx.log(` ${email.id}: ${(0, _geekmidas_manifest.
|
|
2679
|
+
ctx.log(` ${email.id}: ${(0, _geekmidas_manifest.providedKeyFor)(email.id, "email", "url")} is set in the stage's secrets — it sends with that, and nothing is created for it`);
|
|
2678
2680
|
return false;
|
|
2679
2681
|
});
|
|
2680
2682
|
if (owned.length === 0) return;
|
|
2681
2683
|
const region = s3Region(ctx);
|
|
2682
|
-
const senders = new Map(owned.map((e) => [e.id, senderOf(ctx, e
|
|
2684
|
+
const senders = new Map(owned.map((e) => [e.id, senderOf(ctx, e)]));
|
|
2683
2685
|
const domains = [...new Set([...senders.values()].map((s) => domainOf(s.address)))].sort();
|
|
2684
2686
|
const ses = await sesClients(ctx.credential, region);
|
|
2685
2687
|
const clients = await iamClients(ctx.credential, region);
|
|
@@ -2699,10 +2701,10 @@ async function ensureSesEmail(ctx) {
|
|
|
2699
2701
|
});
|
|
2700
2702
|
await require_iam.ensureAccessKey(ctx, clients, {
|
|
2701
2703
|
id: email.id,
|
|
2702
|
-
secret: smtpKeySecret((0, _geekmidas_manifest.
|
|
2704
|
+
secret: smtpKeySecret((0, _geekmidas_manifest.providedKeyFor)(email.id, "email", "url"), region),
|
|
2703
2705
|
...user
|
|
2704
2706
|
});
|
|
2705
|
-
const fromKey = (0, _geekmidas_manifest.
|
|
2707
|
+
const fromKey = (0, _geekmidas_manifest.providedKeyFor)(email.id, "email", "from");
|
|
2706
2708
|
if (ctx.secrets[fromKey] !== from) await ctx.change({
|
|
2707
2709
|
construct: email.id,
|
|
2708
2710
|
resource: fromKey,
|
|
@@ -2767,7 +2769,7 @@ async function noteSandbox(ctx, { SES, ses }, region) {
|
|
|
2767
2769
|
/** The cheap check every deploy runs: each mail construct's keys are in the stage's secrets. */
|
|
2768
2770
|
async function verifySesEmail(ctx) {
|
|
2769
2771
|
for (const email of emailConstructs(ctx.manifest)) {
|
|
2770
|
-
const missing = [(0, _geekmidas_manifest.
|
|
2772
|
+
const missing = [(0, _geekmidas_manifest.providedKeyFor)(email.id, "email", "url"), (0, _geekmidas_manifest.providedKeyFor)(email.id, "email", "from")].filter((key) => ctx.secrets[key] === void 0);
|
|
2771
2773
|
if (missing.length > 0) throw new require_workspace.EmailNotProvisioned(ctx.stage, email.id, missing);
|
|
2772
2774
|
}
|
|
2773
2775
|
}
|
|
@@ -2778,7 +2780,7 @@ const sesEmailProvider = {
|
|
|
2778
2780
|
provisioning: require_workspace.SES_PROVISIONING,
|
|
2779
2781
|
credentials: require_snsSubscriptions.awsProvisioningCredentials,
|
|
2780
2782
|
runtimeKeys(manifest) {
|
|
2781
|
-
return emailConstructs(manifest).flatMap((email) => [(0, _geekmidas_manifest.
|
|
2783
|
+
return emailConstructs(manifest).flatMap((email) => [(0, _geekmidas_manifest.providedKeyFor)(email.id, "email", "url"), (0, _geekmidas_manifest.providedKeyFor)(email.id, "email", "from")]);
|
|
2782
2784
|
},
|
|
2783
2785
|
ensure: ensureSesEmail,
|
|
2784
2786
|
verify: verifySesEmail
|
|
@@ -3095,11 +3097,11 @@ function moveBucketKeys(manifest, custom) {
|
|
|
3095
3097
|
const entries = Object.entries(manifest);
|
|
3096
3098
|
for (const [id, declaration] of entries) {
|
|
3097
3099
|
if (declaration.kind !== "objects") continue;
|
|
3098
|
-
move((0, _geekmidas_manifest.
|
|
3100
|
+
move((0, _geekmidas_manifest.environmentCase)(`${id}_url`), (0, _geekmidas_manifest.providedKeyFor)(id, declaration.kind, "connectionString"), (value) => !/^https?:\/\//i.test(value));
|
|
3099
3101
|
}
|
|
3100
3102
|
for (const [id, declaration] of entries) {
|
|
3101
3103
|
if (declaration.kind !== "file-server") continue;
|
|
3102
|
-
move((0, _geekmidas_manifest.
|
|
3104
|
+
move((0, _geekmidas_manifest.environmentCase)(`${id}_url`), (0, _geekmidas_manifest.providedKeyFor)(id, "file-server", "url"));
|
|
3103
3105
|
}
|
|
3104
3106
|
return {
|
|
3105
3107
|
custom: next,
|
|
@@ -3899,4 +3901,4 @@ Object.defineProperty(exports, "deploy", {
|
|
|
3899
3901
|
}
|
|
3900
3902
|
});
|
|
3901
3903
|
|
|
3902
|
-
//# sourceMappingURL=deploy-
|
|
3904
|
+
//# sourceMappingURL=deploy-C1gf4bT-.cjs.map
|