@geekmidas/cli 10.0.0-alpha.15 → 10.0.0-alpha.151
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/README.md +313 -380
- package/bin/adjacent-tsconfig.mjs +46 -8
- package/bin/gkm.mjs +11 -3
- package/bin/owning-tsconfig-jsx-register.mjs +18 -0
- package/bin/owning-tsconfig-jsx.mjs +108 -0
- package/dist/EndpointGenerator-CusLH-9S.mjs +1037 -0
- package/dist/EndpointGenerator-CusLH-9S.mjs.map +1 -0
- package/dist/EndpointGenerator-DyLMYClE.cjs +1096 -0
- package/dist/EndpointGenerator-DyLMYClE.cjs.map +1 -0
- package/dist/GoDaddyProvider-BZYq0-nV.cjs +412 -0
- package/dist/GoDaddyProvider-BZYq0-nV.cjs.map +1 -0
- package/dist/GoDaddyProvider-D-8GW8cP.mjs +412 -0
- package/dist/GoDaddyProvider-D-8GW8cP.mjs.map +1 -0
- package/dist/{HostingerProvider-BZFGYYVA.cjs → HostingerProvider-BxRR2ibx.cjs} +23 -9
- package/dist/HostingerProvider-BxRR2ibx.cjs.map +1 -0
- package/dist/{HostingerProvider-BY26bWwB.mjs → HostingerProvider-C-C4aiKF.mjs} +23 -9
- package/dist/HostingerProvider-C-C4aiKF.mjs.map +1 -0
- package/dist/LegacyStateStore-BFkNiBxC.mjs +124 -0
- package/dist/LegacyStateStore-BFkNiBxC.mjs.map +1 -0
- package/dist/LegacyStateStore-DYaamZqR.cjs +124 -0
- package/dist/LegacyStateStore-DYaamZqR.cjs.map +1 -0
- package/dist/LocalStateStore-7pP4naiB.mjs +167 -0
- package/dist/LocalStateStore-7pP4naiB.mjs.map +1 -0
- package/dist/LocalStateStore-C0JSjyCg.cjs +178 -0
- package/dist/LocalStateStore-C0JSjyCg.cjs.map +1 -0
- package/dist/OpenApiTsGenerator-BTMuu1WS.mjs +534 -0
- package/dist/OpenApiTsGenerator-BTMuu1WS.mjs.map +1 -0
- package/dist/OpenApiTsGenerator-CI-tceXV.cjs +539 -0
- package/dist/OpenApiTsGenerator-CI-tceXV.cjs.map +1 -0
- package/dist/{Route53Provider-Cvj40A8I.mjs → Route53Provider-Di_SD9CF.mjs} +3 -3
- package/dist/Route53Provider-Di_SD9CF.mjs.map +1 -0
- package/dist/{Route53Provider-DVILBsvV.cjs → Route53Provider-emLuQHVw.cjs} +3 -3
- package/dist/Route53Provider-emLuQHVw.cjs.map +1 -0
- package/dist/S3StateStore-BnmbFco-.cjs +222 -0
- package/dist/S3StateStore-BnmbFco-.cjs.map +1 -0
- package/dist/S3StateStore-Dzyuiy3V.mjs +223 -0
- package/dist/S3StateStore-Dzyuiy3V.mjs.map +1 -0
- package/dist/SSMStateStore-BLbjoEFc.cjs +204 -0
- package/dist/SSMStateStore-BLbjoEFc.cjs.map +1 -0
- package/dist/SSMStateStore-BcNH7efc.mjs +205 -0
- package/dist/SSMStateStore-BcNH7efc.mjs.map +1 -0
- package/dist/SubscriberGenerator-BNJyPmXJ.cjs +848 -0
- package/dist/SubscriberGenerator-BNJyPmXJ.cjs.map +1 -0
- package/dist/SubscriberGenerator-CzPrixYu.mjs +783 -0
- package/dist/SubscriberGenerator-CzPrixYu.mjs.map +1 -0
- package/dist/add-SHsas9Yu.mjs +711 -0
- package/dist/add-SHsas9Yu.mjs.map +1 -0
- package/dist/add-moAE6nV4.cjs +713 -0
- package/dist/add-moAE6nV4.cjs.map +1 -0
- package/dist/appPorts-BoXMwolc.mjs +249 -0
- package/dist/appPorts-BoXMwolc.mjs.map +1 -0
- package/dist/appPorts-IW-OZmRi.cjs +296 -0
- package/dist/appPorts-IW-OZmRi.cjs.map +1 -0
- package/dist/apps-BOgA6AcI.mjs +5534 -0
- package/dist/apps-BOgA6AcI.mjs.map +1 -0
- package/dist/apps-DkxHjd59.cjs +6148 -0
- package/dist/apps-DkxHjd59.cjs.map +1 -0
- package/dist/aws-8QQ8n-t6.mjs +89 -0
- package/dist/aws-8QQ8n-t6.mjs.map +1 -0
- package/dist/aws-DY9NqQIT.cjs +100 -0
- package/dist/aws-DY9NqQIT.cjs.map +1 -0
- package/dist/awsStore-Bx5nCFnS.mjs +121 -0
- package/dist/awsStore-Bx5nCFnS.mjs.map +1 -0
- package/dist/awsStore-u3ehhMoY.cjs +138 -0
- package/dist/awsStore-u3ehhMoY.cjs.map +1 -0
- package/dist/{backup-provisioner-DIVCbfee.mjs → backup-provisioner-C8DnCmxK.mjs} +2 -2
- package/dist/backup-provisioner-C8DnCmxK.mjs.map +1 -0
- package/dist/{backup-provisioner-BmhIO_Yr.cjs → backup-provisioner-oDEsPj02.cjs} +2 -2
- package/dist/backup-provisioner-oDEsPj02.cjs.map +1 -0
- package/dist/backups/runner.cjs +519 -0
- package/dist/backups/runner.cjs.map +1 -0
- package/dist/backups/runner.d.cts +102 -0
- package/dist/backups/runner.d.cts.map +1 -0
- package/dist/backups/runner.d.mts +102 -0
- package/dist/backups/runner.d.mts.map +1 -0
- package/dist/backups/runner.mjs +506 -0
- package/dist/backups/runner.mjs.map +1 -0
- package/dist/{bundler-BeNDZdHQ.cjs → bundler-D0spRLb-.cjs} +59 -14
- package/dist/bundler-D0spRLb-.cjs.map +1 -0
- package/dist/{bundler-BodTL4kf.mjs → bundler-Dy-Dfchf.mjs} +59 -14
- package/dist/bundler-Dy-Dfchf.mjs.map +1 -0
- package/dist/cli-BmCyUTZf.cjs +71 -0
- package/dist/cli-BmCyUTZf.cjs.map +1 -0
- package/dist/cli-BpT_gg4n.mjs +71 -0
- package/dist/cli-BpT_gg4n.mjs.map +1 -0
- package/dist/compose-0HkjQywT.cjs +3046 -0
- package/dist/compose-0HkjQywT.cjs.map +1 -0
- package/dist/compose-B3OOowfE.mjs +1560 -0
- package/dist/compose-B3OOowfE.mjs.map +1 -0
- package/dist/compose-BIXEPrGA.mjs +2957 -0
- package/dist/compose-BIXEPrGA.mjs.map +1 -0
- package/dist/compose-BP8OeV7P.cjs +1919 -0
- package/dist/compose-BP8OeV7P.cjs.map +1 -0
- package/dist/config-BLrAd7Of.mjs +659 -0
- package/dist/config-BLrAd7Of.mjs.map +1 -0
- package/dist/config-CRk2vdSp.d.mts +268 -0
- package/dist/config-CRk2vdSp.d.mts.map +1 -0
- package/dist/config-juUyBlb1.cjs +772 -0
- package/dist/config-juUyBlb1.cjs.map +1 -0
- package/dist/config-oBgsbLip.d.cts +268 -0
- package/dist/config-oBgsbLip.d.cts.map +1 -0
- package/dist/config.cjs +11 -3
- package/dist/config.d.cts +4 -117
- package/dist/config.d.mts +4 -117
- package/dist/config.mjs +3 -3
- package/dist/credentialSchemas-BAklWDna.cjs +271 -0
- package/dist/credentialSchemas-BAklWDna.cjs.map +1 -0
- package/dist/credentialSchemas-mz9QZTYh.mjs +236 -0
- package/dist/credentialSchemas-mz9QZTYh.mjs.map +1 -0
- package/dist/credentials-B6ZwGsy-.cjs +2272 -0
- package/dist/credentials-B6ZwGsy-.cjs.map +1 -0
- package/dist/credentials-DRfP9aG7.mjs +1817 -0
- package/dist/credentials-DRfP9aG7.mjs.map +1 -0
- package/dist/databases-DawSdqBI.cjs +703 -0
- package/dist/databases-DawSdqBI.cjs.map +1 -0
- package/dist/databases-mzSUFBTw.mjs +588 -0
- package/dist/databases-mzSUFBTw.mjs.map +1 -0
- package/dist/define-6poNqm5O.mjs +106 -0
- package/dist/define-6poNqm5O.mjs.map +1 -0
- package/dist/define-crmMcXFS.cjs +153 -0
- package/dist/define-crmMcXFS.cjs.map +1 -0
- package/dist/deploy/public.cjs +211 -0
- package/dist/deploy/public.cjs.map +1 -0
- package/dist/deploy/public.d.cts +647 -0
- package/dist/deploy/public.d.cts.map +1 -0
- package/dist/deploy/public.d.mts +647 -0
- package/dist/deploy/public.d.mts.map +1 -0
- package/dist/deploy/public.mjs +144 -0
- package/dist/deploy/public.mjs.map +1 -0
- package/dist/deploy/sniffer-envparser-worker.cjs +54 -0
- package/dist/deploy/sniffer-envparser-worker.cjs.map +1 -0
- package/dist/deploy/sniffer-envparser-worker.d.cts +1 -0
- package/dist/deploy/sniffer-envparser-worker.d.mts +1 -0
- package/dist/deploy/sniffer-envparser-worker.mjs +55 -0
- package/dist/deploy/sniffer-envparser-worker.mjs.map +1 -0
- package/dist/deploy/sniffer-hooks.cjs +1 -1
- package/dist/deploy/sniffer-hooks.mjs +1 -1
- package/dist/deploy/sniffer-loader.cjs +2 -2
- package/dist/deploy/sniffer-loader.mjs +1 -1
- package/dist/deploy/sniffer-routes-worker.cjs +2 -2
- package/dist/deploy/sniffer-routes-worker.mjs +1 -1
- package/dist/deploy-BgOujGGL.mjs +3836 -0
- package/dist/deploy-BgOujGGL.mjs.map +1 -0
- package/dist/deploy-ciuNiVqo.cjs +3892 -0
- package/dist/deploy-ciuNiVqo.cjs.map +1 -0
- package/dist/discover-CRywE7yc.cjs +1085 -0
- package/dist/discover-CRywE7yc.cjs.map +1 -0
- package/dist/discover-DbDrCQ8h.mjs +940 -0
- package/dist/discover-DbDrCQ8h.mjs.map +1 -0
- package/dist/docker-74kvq2jQ.cjs +1514 -0
- package/dist/docker-74kvq2jQ.cjs.map +1 -0
- package/dist/docker-CXYz3W2U.mjs +1407 -0
- package/dist/docker-CXYz3W2U.mjs.map +1 -0
- package/dist/dokploy-CrxDMut1.cjs +38 -0
- package/dist/dokploy-CrxDMut1.cjs.map +1 -0
- package/dist/dokploy-tNy6ZU64.mjs +38 -0
- package/dist/dokploy-tNy6ZU64.mjs.map +1 -0
- package/dist/drivers-aM87NQJi.cjs +224 -0
- package/dist/drivers-aM87NQJi.cjs.map +1 -0
- package/dist/drivers-uxLBq3e3.mjs +195 -0
- package/dist/drivers-uxLBq3e3.mjs.map +1 -0
- package/dist/eas-B3yv_XVz.mjs +334 -0
- package/dist/eas-B3yv_XVz.mjs.map +1 -0
- package/dist/eas-CiORdzk0.cjs +337 -0
- package/dist/eas-CiORdzk0.cjs.map +1 -0
- package/dist/emit-Bj6XSivk.mjs +136 -0
- package/dist/emit-Bj6XSivk.mjs.map +1 -0
- package/dist/emit-CDC__ubE.cjs +147 -0
- package/dist/emit-CDC__ubE.cjs.map +1 -0
- package/dist/encryption-Birkm2_E.mjs +89 -0
- package/dist/encryption-Birkm2_E.mjs.map +1 -0
- package/dist/encryption-drgYmkGP.cjs +90 -0
- package/dist/encryption-drgYmkGP.cjs.map +1 -0
- package/dist/engine-CW78Wt8x.mjs +3217 -0
- package/dist/engine-CW78Wt8x.mjs.map +1 -0
- package/dist/engine-CfLaQ0bJ.cjs +3330 -0
- package/dist/engine-CfLaQ0bJ.cjs.map +1 -0
- package/dist/errors-D8Gwp5kU.mjs +23 -0
- package/dist/errors-D8Gwp5kU.mjs.map +1 -0
- package/dist/errors-DMC4Umsb.cjs +34 -0
- package/dist/errors-DMC4Umsb.cjs.map +1 -0
- package/dist/github-BfLlBWB5.cjs +901 -0
- package/dist/github-BfLlBWB5.cjs.map +1 -0
- package/dist/github-DphkHybE.mjs +900 -0
- package/dist/github-DphkHybE.mjs.map +1 -0
- package/dist/googlePlay-BWDhYvH_.cjs +931 -0
- package/dist/googlePlay-BWDhYvH_.cjs.map +1 -0
- package/dist/googlePlay-CjzqTF8t.mjs +931 -0
- package/dist/googlePlay-CjzqTF8t.mjs.map +1 -0
- package/dist/{index-D-iAVHx-.d.cts → index-B35vTdAW.d.cts} +39 -15
- package/dist/index-B35vTdAW.d.cts.map +1 -0
- package/dist/{index-Cd-qeOam.d.mts → index-Dv1Zj86i.d.mts} +39 -15
- package/dist/index-Dv1Zj86i.d.mts.map +1 -0
- package/dist/index.cjs +13594 -12347
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +13541 -12292
- package/dist/index.mjs.map +1 -1
- package/dist/local-Bt9jPziD.cjs +241 -0
- package/dist/local-Bt9jPziD.cjs.map +1 -0
- package/dist/local-DBtepRK5.mjs +224 -0
- package/dist/local-DBtepRK5.mjs.map +1 -0
- package/dist/migrate-2YESt4v9.mjs +267 -0
- package/dist/migrate-2YESt4v9.mjs.map +1 -0
- package/dist/migrate-B-_cASJt.cjs +272 -0
- package/dist/migrate-B-_cASJt.cjs.map +1 -0
- package/dist/migrate-BUhe0BuA.cjs +181 -0
- package/dist/migrate-BUhe0BuA.cjs.map +1 -0
- package/dist/migrate-Dp_Y2XGi.mjs +181 -0
- package/dist/migrate-Dp_Y2XGi.mjs.map +1 -0
- package/dist/notes-DHN4qThL.mjs +399 -0
- package/dist/notes-DHN4qThL.mjs.map +1 -0
- package/dist/notes-DUq6Bx1I.cjs +500 -0
- package/dist/notes-DUq6Bx1I.cjs.map +1 -0
- package/dist/openapi.cjs +213 -7
- package/dist/openapi.cjs.map +1 -0
- package/dist/openapi.d.cts +32 -8
- package/dist/openapi.d.cts.map +1 -1
- package/dist/openapi.d.mts +32 -8
- package/dist/openapi.d.mts.map +1 -1
- package/dist/openapi.mjs +208 -2
- package/dist/openapi.mjs.map +1 -0
- package/dist/projectBucket-CxsutB3D.cjs +263 -0
- package/dist/projectBucket-CxsutB3D.cjs.map +1 -0
- package/dist/projectBucket-DzLZlleB.mjs +222 -0
- package/dist/projectBucket-DzLZlleB.mjs.map +1 -0
- package/dist/provider-BqpjG9QM.cjs +57 -0
- package/dist/provider-BqpjG9QM.cjs.map +1 -0
- package/dist/provider-CEOKk8NS.mjs +46 -0
- package/dist/provider-CEOKk8NS.mjs.map +1 -0
- package/dist/publish-BVal0GFd.mjs +123 -0
- package/dist/publish-BVal0GFd.mjs.map +1 -0
- package/dist/publish-DmTJhVe8.cjs +124 -0
- package/dist/publish-DmTJhVe8.cjs.map +1 -0
- package/dist/ready-BNh3zsSn.cjs +404 -0
- package/dist/ready-BNh3zsSn.cjs.map +1 -0
- package/dist/ready-g25dcGzK.mjs +375 -0
- package/dist/ready-g25dcGzK.mjs.map +1 -0
- package/dist/reconcile/public.cjs +3 -5
- package/dist/reconcile/public.d.cts +31 -89
- package/dist/reconcile/public.d.cts.map +1 -1
- package/dist/reconcile/public.d.mts +31 -89
- package/dist/reconcile/public.d.mts.map +1 -1
- package/dist/reconcile/public.mjs +3 -3
- package/dist/{reconcile-DhQ00DpU.mjs → reconcile--I7V4Klj.mjs} +2 -2
- package/dist/{reconcile-DhQ00DpU.mjs.map → reconcile--I7V4Klj.mjs.map} +1 -1
- package/dist/{reconcile-Dd2iyILf.cjs → reconcile-CuCQBa5-.cjs} +3 -3
- package/dist/{reconcile-Dd2iyILf.cjs.map → reconcile-CuCQBa5-.cjs.map} +1 -1
- package/dist/resolve-BwTJI8K7.cjs +316 -0
- package/dist/resolve-BwTJI8K7.cjs.map +1 -0
- package/dist/resolve-UBq26cZc.mjs +263 -0
- package/dist/resolve-UBq26cZc.mjs.map +1 -0
- package/dist/rollback-BFKex9TO.cjs +165 -0
- package/dist/rollback-BFKex9TO.cjs.map +1 -0
- package/dist/rollback-DiOcLTRc.mjs +136 -0
- package/dist/rollback-DiOcLTRc.mjs.map +1 -0
- package/dist/runtime-CFvcLEJW.d.cts +82 -0
- package/dist/runtime-CFvcLEJW.d.cts.map +1 -0
- package/dist/runtime-dwsH6ddo.d.mts +82 -0
- package/dist/runtime-dwsH6ddo.d.mts.map +1 -0
- package/dist/s3-BgG_xW-D.cjs +215 -0
- package/dist/s3-BgG_xW-D.cjs.map +1 -0
- package/dist/s3-CkrerKdA.mjs +215 -0
- package/dist/s3-CkrerKdA.mjs.map +1 -0
- package/dist/sandbox/config-worker.cjs +43 -0
- package/dist/sandbox/config-worker.cjs.map +1 -0
- package/dist/sandbox/config-worker.d.cts +1 -0
- package/dist/sandbox/config-worker.d.mts +1 -0
- package/dist/sandbox/config-worker.mjs +44 -0
- package/dist/sandbox/config-worker.mjs.map +1 -0
- package/dist/sandbox/credentials-worker.cjs +53 -0
- package/dist/sandbox/credentials-worker.cjs.map +1 -0
- package/dist/sandbox/credentials-worker.d.cts +1 -0
- package/dist/sandbox/credentials-worker.d.mts +1 -0
- package/dist/sandbox/credentials-worker.mjs +54 -0
- package/dist/sandbox/credentials-worker.mjs.map +1 -0
- package/dist/sandbox/discover-worker.cjs +47 -0
- package/dist/sandbox/discover-worker.cjs.map +1 -0
- package/dist/sandbox/discover-worker.d.cts +1 -0
- package/dist/sandbox/discover-worker.d.mts +1 -0
- package/dist/sandbox/discover-worker.mjs +48 -0
- package/dist/sandbox/discover-worker.mjs.map +1 -0
- package/dist/sandbox/migrate-worker.cjs +75 -0
- package/dist/sandbox/migrate-worker.cjs.map +1 -0
- package/dist/sandbox/migrate-worker.d.cts +1 -0
- package/dist/sandbox/migrate-worker.d.mts +1 -0
- package/dist/sandbox/migrate-worker.mjs +76 -0
- package/dist/sandbox/migrate-worker.mjs.map +1 -0
- package/dist/{workspace-mFpI_ky_.cjs → schemas-BCwKKA42.mjs} +399 -1162
- package/dist/schemas-BCwKKA42.mjs.map +1 -0
- package/dist/{workspace-CgwmXEtc.mjs → schemas-BQ_v0lEX.cjs} +487 -971
- package/dist/schemas-BQ_v0lEX.cjs.map +1 -0
- package/dist/secretsManager-CQORubp9.mjs +97 -0
- package/dist/secretsManager-CQORubp9.mjs.map +1 -0
- package/dist/secretsManager-RAGcEDX1.cjs +108 -0
- package/dist/secretsManager-RAGcEDX1.cjs.map +1 -0
- package/dist/seeds-B3xvUAQf.cjs +363 -0
- package/dist/seeds-B3xvUAQf.cjs.map +1 -0
- package/dist/seeds-BCC8vAXR.mjs +298 -0
- package/dist/seeds-BCC8vAXR.mjs.map +1 -0
- package/dist/serverSetup-CUBu8_Mk.cjs +652 -0
- package/dist/serverSetup-CUBu8_Mk.cjs.map +1 -0
- package/dist/serverSetup-eh9MUdSN.mjs +652 -0
- package/dist/serverSetup-eh9MUdSN.mjs.map +1 -0
- package/dist/sniffer-CNTnUmhc.mjs +1824 -0
- package/dist/sniffer-CNTnUmhc.mjs.map +1 -0
- package/dist/sniffer-CaoQH_kk.cjs +1997 -0
- package/dist/sniffer-CaoQH_kk.cjs.map +1 -0
- package/dist/snsSubscriptions-DiqwM9Ms.cjs +1173 -0
- package/dist/snsSubscriptions-DiqwM9Ms.cjs.map +1 -0
- package/dist/snsSubscriptions-zOIIswN0.mjs +1048 -0
- package/dist/snsSubscriptions-zOIIswN0.mjs.map +1 -0
- package/dist/sst-D6Dvhr6H.mjs +462 -0
- package/dist/sst-D6Dvhr6H.mjs.map +1 -0
- package/dist/sst-DECRMgjv.cjs +485 -0
- package/dist/sst-DECRMgjv.cjs.map +1 -0
- package/dist/stack-BZG5HoVN.mjs +2206 -0
- package/dist/stack-BZG5HoVN.mjs.map +1 -0
- package/dist/stack-CLk9WojF.cjs +2381 -0
- package/dist/stack-CLk9WojF.cjs.map +1 -0
- package/dist/stage-Cl0DPJ7w.cjs +313 -0
- package/dist/stage-Cl0DPJ7w.cjs.map +1 -0
- package/dist/stage-DiLPb89O.mjs +302 -0
- package/dist/stage-DiLPb89O.mjs.map +1 -0
- package/dist/stages-Bs1THSy7.cjs +190 -0
- package/dist/stages-Bs1THSy7.cjs.map +1 -0
- package/dist/stages-_xCG4Ymu.mjs +190 -0
- package/dist/stages-_xCG4Ymu.mjs.map +1 -0
- package/dist/target/public.cjs +15 -0
- package/dist/target/public.d.cts +28 -0
- package/dist/target/public.d.cts.map +1 -0
- package/dist/target/public.d.mts +28 -0
- package/dist/target/public.d.mts.map +1 -0
- package/dist/target/public.mjs +4 -0
- package/dist/terminal-XQE106CG.cjs +85 -0
- package/dist/terminal-XQE106CG.cjs.map +1 -0
- package/dist/terminal-jGj9TtMQ.mjs +85 -0
- package/dist/terminal-jGj9TtMQ.mjs.map +1 -0
- package/dist/types-Bl_CwZC9.cjs +90 -0
- package/dist/types-Bl_CwZC9.cjs.map +1 -0
- package/dist/{types-BGo5TaNE.d.mts → types-Dk--xVOT.d.cts} +2234 -439
- package/dist/types-Dk--xVOT.d.cts.map +1 -0
- package/dist/{types-C5ZNpUad.d.cts → types-DwQYpd_0.d.mts} +2232 -439
- package/dist/types-DwQYpd_0.d.mts.map +1 -0
- package/dist/types-Y1NfWlyG.mjs +61 -0
- package/dist/types-Y1NfWlyG.mjs.map +1 -0
- package/dist/utils-D2Nk1Nv2.cjs +205 -0
- package/dist/utils-D2Nk1Nv2.cjs.map +1 -0
- package/dist/utils-D_fxUqvU.mjs +156 -0
- package/dist/utils-D_fxUqvU.mjs.map +1 -0
- package/dist/vitest.cjs +65 -0
- package/dist/vitest.cjs.map +1 -0
- package/dist/vitest.d.cts +29 -0
- package/dist/vitest.d.cts.map +1 -0
- package/dist/vitest.d.mts +29 -0
- package/dist/vitest.d.mts.map +1 -0
- package/dist/vitest.mjs +65 -0
- package/dist/vitest.mjs.map +1 -0
- package/dist/workerRuntime-BXfhbe13.cjs +108 -0
- package/dist/workerRuntime-BXfhbe13.cjs.map +1 -0
- package/dist/workerRuntime-CsOyBRx2.mjs +79 -0
- package/dist/workerRuntime-CsOyBRx2.mjs.map +1 -0
- package/dist/workspace/index.cjs +6 -2
- package/dist/workspace/index.d.cts +3 -3
- package/dist/workspace/index.d.mts +3 -3
- package/dist/workspace/index.mjs +2 -2
- package/dist/workspace-1szcahj9.cjs +2916 -0
- package/dist/workspace-1szcahj9.cjs.map +1 -0
- package/dist/workspace-DFGsrjGD.mjs +2480 -0
- package/dist/workspace-DFGsrjGD.mjs.map +1 -0
- package/package.json +66 -14
- package/dist/HostingerProvider-BY26bWwB.mjs.map +0 -1
- package/dist/HostingerProvider-BZFGYYVA.cjs.map +0 -1
- package/dist/LocalStateProvider-7HR6SS2t.cjs +0 -48
- package/dist/LocalStateProvider-7HR6SS2t.cjs.map +0 -1
- package/dist/LocalStateProvider-D7QyJoLM.mjs +0 -48
- package/dist/LocalStateProvider-D7QyJoLM.mjs.map +0 -1
- package/dist/Route53Provider-Cvj40A8I.mjs.map +0 -1
- package/dist/Route53Provider-DVILBsvV.cjs.map +0 -1
- package/dist/SSMStateProvider-B0Hu1MKZ.mjs +0 -75
- package/dist/SSMStateProvider-B0Hu1MKZ.mjs.map +0 -1
- package/dist/SSMStateProvider-VrQ-yeqd.cjs +0 -74
- package/dist/SSMStateProvider-VrQ-yeqd.cjs.map +0 -1
- package/dist/backup-provisioner-BmhIO_Yr.cjs.map +0 -1
- package/dist/backup-provisioner-DIVCbfee.mjs.map +0 -1
- package/dist/bundler-BeNDZdHQ.cjs.map +0 -1
- package/dist/bundler-BodTL4kf.mjs.map +0 -1
- package/dist/config-Q1rvKHvw.cjs +0 -467
- package/dist/config-Q1rvKHvw.cjs.map +0 -1
- package/dist/config-pqGD3hF9.mjs +0 -414
- package/dist/config-pqGD3hF9.mjs.map +0 -1
- package/dist/config.d.cts.map +0 -1
- package/dist/config.d.mts.map +0 -1
- package/dist/credentials-BekkKtY_.mjs +0 -2780
- package/dist/credentials-BekkKtY_.mjs.map +0 -1
- package/dist/credentials-Q6F0uqJq.cjs +0 -2917
- package/dist/credentials-Q6F0uqJq.cjs.map +0 -1
- package/dist/discover-BERGFg8v.cjs +0 -288
- package/dist/discover-BERGFg8v.cjs.map +0 -1
- package/dist/discover-CK-n3w6b.mjs +0 -244
- package/dist/discover-CK-n3w6b.mjs.map +0 -1
- package/dist/emit-BdoPFjZf.cjs +0 -253
- package/dist/emit-BdoPFjZf.cjs.map +0 -1
- package/dist/emit-Bzq7JsMP.mjs +0 -224
- package/dist/emit-Bzq7JsMP.mjs.map +0 -1
- package/dist/fullstack-secrets-BET8gqwK.mjs +0 -81
- package/dist/fullstack-secrets-BET8gqwK.mjs.map +0 -1
- package/dist/fullstack-secrets-DXsWO-5m.cjs +0 -92
- package/dist/fullstack-secrets-DXsWO-5m.cjs.map +0 -1
- package/dist/generator-LfZU7NlU.mjs +0 -247
- package/dist/generator-LfZU7NlU.mjs.map +0 -1
- package/dist/generator-Wdfp0jCS.cjs +0 -282
- package/dist/generator-Wdfp0jCS.cjs.map +0 -1
- package/dist/github-BfflNPVe.cjs +0 -203
- package/dist/github-BfflNPVe.cjs.map +0 -1
- package/dist/github-CRwnxKmD.mjs +0 -203
- package/dist/github-CRwnxKmD.mjs.map +0 -1
- package/dist/index-Cd-qeOam.d.mts.map +0 -1
- package/dist/index-D-iAVHx-.d.cts.map +0 -1
- package/dist/keystore-B4PRlbgE.mjs +0 -81
- package/dist/keystore-B4PRlbgE.mjs.map +0 -1
- package/dist/keystore-DgGRj2Yy.cjs +0 -98
- package/dist/keystore-DgGRj2Yy.cjs.map +0 -1
- package/dist/openapi-Dcbme-Us.cjs +0 -2038
- package/dist/openapi-Dcbme-Us.cjs.map +0 -1
- package/dist/openapi-vy4JzhUv.mjs +0 -1991
- package/dist/openapi-vy4JzhUv.mjs.map +0 -1
- package/dist/storage-C-30BD1e.cjs +0 -272
- package/dist/storage-C-30BD1e.cjs.map +0 -1
- package/dist/storage-P_b3w7uj.mjs +0 -231
- package/dist/storage-P_b3w7uj.mjs.map +0 -1
- package/dist/sync-B3xxXtJT.mjs +0 -88
- package/dist/sync-B3xxXtJT.mjs.map +0 -1
- package/dist/sync-D7uTIIEi.cjs +0 -111
- package/dist/sync-D7uTIIEi.cjs.map +0 -1
- package/dist/types-BGo5TaNE.d.mts.map +0 -1
- package/dist/types-C5ZNpUad.d.cts.map +0 -1
- package/dist/workspace-CgwmXEtc.mjs.map +0 -1
- package/dist/workspace-mFpI_ky_.cjs.map +0 -1
|
@@ -0,0 +1,940 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-BhDjJH2R.mjs";
|
|
2
|
+
import { t as GkmError } from "./errors-D8Gwp5kU.mjs";
|
|
3
|
+
import { a as discriminatedUnion, c as literal, d as object, f as record, n as array, p as string } from "./schemas-BCwKKA42.mjs";
|
|
4
|
+
import { t as WORKER_RESULT_MARKER } from "./workerRuntime-CsOyBRx2.mjs";
|
|
5
|
+
import { createRequire } from "node:module";
|
|
6
|
+
import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
7
|
+
import { existsSync, realpathSync } from "node:fs";
|
|
8
|
+
import { assertDerivations, canonicalId, dependenciesOf, provideKey } from "@geekmidas/manifest";
|
|
9
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
10
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
11
|
+
import { format } from "node:util";
|
|
12
|
+
import { Cron } from "@geekmidas/constructs/crons";
|
|
13
|
+
import { Endpoint } from "@geekmidas/constructs/endpoints";
|
|
14
|
+
import { Function } from "@geekmidas/constructs/functions";
|
|
15
|
+
import { Processor } from "@geekmidas/constructs/processors";
|
|
16
|
+
import { Queue } from "@geekmidas/constructs/queue";
|
|
17
|
+
import { Subscriber } from "@geekmidas/constructs/subscribers";
|
|
18
|
+
import { WebSocketRoute } from "@geekmidas/constructs/websocket-api";
|
|
19
|
+
import fg from "fast-glob";
|
|
20
|
+
import kebabCase$1 from "lodash.kebabcase";
|
|
21
|
+
//#region src/reconcile/edges.ts
|
|
22
|
+
/**
|
|
23
|
+
* Edges a process records for what its runnables consume, beyond the
|
|
24
|
+
* construct ids `.dependsOn()` names.
|
|
25
|
+
*/
|
|
26
|
+
const EVENTS_SUFFIX = "#events";
|
|
27
|
+
/**
|
|
28
|
+
* A bucket's events, as an edge: what a process running one of the bucket's
|
|
29
|
+
* subscribers consumes. Not the bucket's id — binding to a bucket's changes
|
|
30
|
+
* is not reading its objects, so the process is handed the events key alone.
|
|
31
|
+
*/
|
|
32
|
+
function eventsEdge(bucketId) {
|
|
33
|
+
return `${bucketId}${EVENTS_SUFFIX}`;
|
|
34
|
+
}
|
|
35
|
+
/** The bucket an events edge names, or nothing for any other edge. */
|
|
36
|
+
function eventsEdgeBucket(edge) {
|
|
37
|
+
return edge.endsWith(EVENTS_SUFFIX) ? edge.slice(0, -7) : void 0;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The env key a subscriber's deliveries come from: its topic's publisher
|
|
41
|
+
* connection string, or its bucket's events connection string.
|
|
42
|
+
*/
|
|
43
|
+
function subscriberConnectionKey(construct) {
|
|
44
|
+
if (construct.bucketName) return provideKey(canonicalId(construct.bucketName), "eventsConnectionString");
|
|
45
|
+
if (construct.topicName) return provideKey(canonicalId(construct.topicName), "publisherConnectionString");
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* The key a bucket's relay token is read from, by the process that runs the
|
|
49
|
+
* bucket's subscribers — beside its events connection string.
|
|
50
|
+
*/
|
|
51
|
+
function subscriberTokenKey(construct) {
|
|
52
|
+
return construct.bucketName ? provideKey(canonicalId(construct.bucketName), "eventsToken") : void 0;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* What a worker's process reaches: the worker's own edges, and those of
|
|
56
|
+
* everything it owns — its crons and functions, its queue consumers and the
|
|
57
|
+
* queue each drains, its subscribers and the topic each is bound to, or the
|
|
58
|
+
* events of the bucket each watches.
|
|
59
|
+
*
|
|
60
|
+
* Read off the manifest: the same nodes every command sees, so `gkm dev`
|
|
61
|
+
* hands a worker what a deploy grants it.
|
|
62
|
+
*/
|
|
63
|
+
function workerEdges(manifest, workerId) {
|
|
64
|
+
const worker = manifest[workerId];
|
|
65
|
+
if (worker?.kind !== "worker") return [];
|
|
66
|
+
const edges = dependenciesOf(worker).map((edge) => edge.target);
|
|
67
|
+
const owned = (fn, consumed) => {
|
|
68
|
+
if (fn?.owner !== workerId) return;
|
|
69
|
+
edges.push(...fn.dependencies.map((edge) => edge.target));
|
|
70
|
+
if (consumed) edges.push(consumed);
|
|
71
|
+
};
|
|
72
|
+
for (const declaration of Object.values(manifest)) switch (declaration.kind) {
|
|
73
|
+
case "cron":
|
|
74
|
+
case "function":
|
|
75
|
+
owned(declaration);
|
|
76
|
+
break;
|
|
77
|
+
case "queue":
|
|
78
|
+
owned(declaration.worker, declaration.id);
|
|
79
|
+
break;
|
|
80
|
+
case "topic":
|
|
81
|
+
for (const s of declaration.subscribers) owned(s, declaration.id);
|
|
82
|
+
break;
|
|
83
|
+
case "objects": for (const s of declaration.subscribers ?? []) owned(s, eventsEdge(declaration.id));
|
|
84
|
+
}
|
|
85
|
+
return [...new Set(edges)];
|
|
86
|
+
}
|
|
87
|
+
//#endregion
|
|
88
|
+
//#region src/output.ts
|
|
89
|
+
/**
|
|
90
|
+
* Where the CLI's progress lines go.
|
|
91
|
+
*
|
|
92
|
+
* Commands write their progress through `output` rather than `console`. Run
|
|
93
|
+
* from the terminal that is the same thing. Run inside `deploy()`, each line
|
|
94
|
+
* goes to the run that wrote it instead — as an event its caller can iterate,
|
|
95
|
+
* and to the logger it was handed — so a deploy embedded in another program
|
|
96
|
+
* does not print over that program's own output.
|
|
97
|
+
*
|
|
98
|
+
* Carried by `AsyncLocalStorage` rather than passed down, because the lines
|
|
99
|
+
* come from everywhere a deploy reaches — the Dockerfile generator, the env
|
|
100
|
+
* sniffer, construct discovery — and two deploys running in one process must
|
|
101
|
+
* not hear each other.
|
|
102
|
+
*/
|
|
103
|
+
const current = new AsyncLocalStorage();
|
|
104
|
+
/** Runs `fn` with every line written through `output` sent to `sink`. */
|
|
105
|
+
function withOutput(sink, fn) {
|
|
106
|
+
return current.run(sink, fn);
|
|
107
|
+
}
|
|
108
|
+
function write(level, fallback) {
|
|
109
|
+
return (...args) => {
|
|
110
|
+
const sink = current.getStore();
|
|
111
|
+
if (sink) sink(level, format(...args));
|
|
112
|
+
else fallback(...args);
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* `console`, for the methods the CLI logs through — routed to the current
|
|
117
|
+
* run's sink when there is one.
|
|
118
|
+
*/
|
|
119
|
+
const output = {
|
|
120
|
+
log: write("info", (...args) => console.log(...args)),
|
|
121
|
+
info: write("info", (...args) => console.info(...args)),
|
|
122
|
+
warn: write("warn", (...args) => console.warn(...args)),
|
|
123
|
+
error: write("error", (...args) => console.error(...args))
|
|
124
|
+
};
|
|
125
|
+
//#endregion
|
|
126
|
+
//#region src/generators/Generator.ts
|
|
127
|
+
/**
|
|
128
|
+
* Zod v4 maintains a process-wide registry of schemas registered via
|
|
129
|
+
* `.meta({ id })`. When we cache-bust user module imports (by appending a
|
|
130
|
+
* `?t=timestamp` query), those modules re-execute and try to register the
|
|
131
|
+
* same ids again, which throws `ID X already exists in the registry`.
|
|
132
|
+
*
|
|
133
|
+
* Clearing the registry in the CLI process is safe: the user's running
|
|
134
|
+
* server lives in a subprocess and has its own isolated registry.
|
|
135
|
+
*
|
|
136
|
+
* Exported for tests.
|
|
137
|
+
*/
|
|
138
|
+
function clearZodGlobalRegistry() {
|
|
139
|
+
const registry = globalThis.__zod_globalRegistry;
|
|
140
|
+
if (registry && typeof registry.clear === "function") registry.clear();
|
|
141
|
+
}
|
|
142
|
+
var ConstructGenerator = class {
|
|
143
|
+
static async build(context, outputDir, generator, patterns, options) {
|
|
144
|
+
const constructs = await generator.load(patterns);
|
|
145
|
+
return generator.build(context, constructs, outputDir, options);
|
|
146
|
+
}
|
|
147
|
+
async load(patterns, cwd = process.cwd(), bustCache = false) {
|
|
148
|
+
const logger = console;
|
|
149
|
+
const globPatterns = Array.isArray(patterns) ? patterns : patterns ? [patterns] : [];
|
|
150
|
+
const files = fg.stream(globPatterns, {
|
|
151
|
+
cwd,
|
|
152
|
+
absolute: true
|
|
153
|
+
});
|
|
154
|
+
if (bustCache) clearZodGlobalRegistry();
|
|
155
|
+
const constructs = [];
|
|
156
|
+
for await (const f of files) try {
|
|
157
|
+
const file = f.toString();
|
|
158
|
+
const module = await (bustCache ? import(`${file}?t=${Date.now()}`) : import(file));
|
|
159
|
+
for (const [key, construct] of Object.entries(module)) if (this.isConstruct(construct)) constructs.push({
|
|
160
|
+
key,
|
|
161
|
+
name: kebabCase$1(key),
|
|
162
|
+
construct,
|
|
163
|
+
path: {
|
|
164
|
+
absolute: file,
|
|
165
|
+
relative: relative(process.cwd(), file)
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
} catch (error) {
|
|
169
|
+
const err = error;
|
|
170
|
+
logger.error(`Failed to load ${f}: ${err.message}`);
|
|
171
|
+
if (err.stack) logger.error(err.stack);
|
|
172
|
+
throw error;
|
|
173
|
+
}
|
|
174
|
+
return constructs;
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
//#endregion
|
|
178
|
+
//#region src/sandbox/sandbox.ts
|
|
179
|
+
/**
|
|
180
|
+
* Where a deploy runs the project's own code.
|
|
181
|
+
*
|
|
182
|
+
* A deploy holds credentials — Dokploy's token, a registry login, an AWS key —
|
|
183
|
+
* and loading `gkm.config.ts`, sniffing an app's environment and building it
|
|
184
|
+
* all execute code from the repository being deployed. On a developer's own
|
|
185
|
+
* laptop that is the developer's code. On a CI job for a fork, or a shared
|
|
186
|
+
* build runner, it is not, and that code should not be able to read the
|
|
187
|
+
* credentials used to deploy it, hang the deploy, or reach outside the
|
|
188
|
+
* checkout.
|
|
189
|
+
*
|
|
190
|
+
* So every step that runs project code goes through a `Sandbox`: one call,
|
|
191
|
+
* with an argument array rather than a shell line, the complete environment
|
|
192
|
+
* the step needs rather than the host's, a timeout it cannot outlive, secrets
|
|
193
|
+
* as files rather than variables, and a working directory inside the project.
|
|
194
|
+
* The steps that need credentials — provisioning, pushing, releasing — are
|
|
195
|
+
* the deploy's own code and never run in one.
|
|
196
|
+
*
|
|
197
|
+
* `LocalSandbox` is the default: a child process on this machine with an
|
|
198
|
+
* allowlisted environment. A host that builds repositories it does not trust
|
|
199
|
+
* passes its own — a container per build, a VM — through `deploy()`'s
|
|
200
|
+
* `sandbox`.
|
|
201
|
+
*/
|
|
202
|
+
/** The variable naming the directory a command's secrets are mounted in. */
|
|
203
|
+
const SECRETS_DIR_ENV = "GKM_SECRETS_DIR";
|
|
204
|
+
/** A command was asked to run outside the project. */
|
|
205
|
+
var SandboxCwdEscape = class extends GkmError {
|
|
206
|
+
cwd;
|
|
207
|
+
root;
|
|
208
|
+
constructor(cwd, root) {
|
|
209
|
+
super(`Refusing to run in '${cwd}': it is outside the project at '${root}'. A sandboxed step only runs inside the project it was given — check the app paths in gkm.config.ts for \`..\` or an absolute path.`);
|
|
210
|
+
this.cwd = cwd;
|
|
211
|
+
this.root = root;
|
|
212
|
+
this.name = "SandboxCwdEscape";
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
/** A path with its symlinks resolved where it exists — `/tmp` is `/private/tmp`. */
|
|
216
|
+
function real(path) {
|
|
217
|
+
return existsSync(path) ? realpathSync(path) : path;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* `cwd` as an absolute directory inside `root`, or {@link SandboxCwdEscape}.
|
|
221
|
+
*
|
|
222
|
+
* Symlinks are resolved on both sides first, so a link inside the project
|
|
223
|
+
* that points out of it is an escape, and a project reached through a link
|
|
224
|
+
* (`/tmp` on macOS) is still itself. For a sandbox of a host's own to call
|
|
225
|
+
* before it runs anything.
|
|
226
|
+
*/
|
|
227
|
+
function confineCwd(root, cwd) {
|
|
228
|
+
const absolute = resolve(root, cwd);
|
|
229
|
+
const from = relative(real(resolve(root)), real(absolute));
|
|
230
|
+
if (from === ".." || from.startsWith(`..${sep}`) || isAbsolute(from)) throw new SandboxCwdEscape(cwd, root);
|
|
231
|
+
return absolute;
|
|
232
|
+
}
|
|
233
|
+
/** A secret's file name: one path segment, so it cannot be written elsewhere. */
|
|
234
|
+
var SecretNameInvalid = class extends GkmError {
|
|
235
|
+
secretName;
|
|
236
|
+
constructor(secretName) {
|
|
237
|
+
super(`'${secretName}' cannot be a secret's name: it becomes a file name in the secrets directory, so it must be one segment of letters, digits, '.', '-' or '_' and not start with '.'.`);
|
|
238
|
+
this.secretName = secretName;
|
|
239
|
+
this.name = "SecretNameInvalid";
|
|
240
|
+
}
|
|
241
|
+
};
|
|
242
|
+
const SECRET_NAME = /^[A-Za-z0-9_-][A-Za-z0-9._-]*$/;
|
|
243
|
+
/** Every secret name, checked before anything is written. */
|
|
244
|
+
function assertSecretNames(secrets) {
|
|
245
|
+
for (const name of Object.keys(secrets ?? {})) if (!SECRET_NAME.test(name)) throw new SecretNameInvalid(name);
|
|
246
|
+
}
|
|
247
|
+
const active = new AsyncLocalStorage();
|
|
248
|
+
/**
|
|
249
|
+
* Run `fn` with `sandbox` as the one its steps use.
|
|
250
|
+
*
|
|
251
|
+
* Per run rather than global, as `withOutput` routes a run's lines: two
|
|
252
|
+
* deploys in one host process each build in their own sandbox. A step deep in
|
|
253
|
+
* the engine — discovering constructs, sniffing an app — asks
|
|
254
|
+
* {@link activeSandbox} rather than every function between `deploy()` and it
|
|
255
|
+
* taking one more parameter.
|
|
256
|
+
*/
|
|
257
|
+
function withSandbox(sandbox, fn) {
|
|
258
|
+
return active.run({
|
|
259
|
+
sandbox,
|
|
260
|
+
answers: /* @__PURE__ */ new Map()
|
|
261
|
+
}, fn);
|
|
262
|
+
}
|
|
263
|
+
/** The sandbox of the run this is part of, if it was started with one. */
|
|
264
|
+
function activeSandbox() {
|
|
265
|
+
return active.getStore()?.sandbox;
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* `ask()`'s answer, asked once per run.
|
|
269
|
+
*
|
|
270
|
+
* A deploy loads its config and discovers its constructs from several places
|
|
271
|
+
* — the first load, the engine, the Dockerfile generator — and in a sandbox
|
|
272
|
+
* each was a child process of its own, for the same answer: the checkout does
|
|
273
|
+
* not change while it deploys. Within a run in `sandbox`, the first answer
|
|
274
|
+
* for `key` is the one every later ask gets. Outside one, or for another
|
|
275
|
+
* sandbox, `ask()` runs each time.
|
|
276
|
+
*/
|
|
277
|
+
function oncePerRun(sandbox, key, ask) {
|
|
278
|
+
const run = active.getStore();
|
|
279
|
+
if (!run || run.sandbox !== sandbox) return ask();
|
|
280
|
+
let answer = run.answers.get(key);
|
|
281
|
+
if (!answer) {
|
|
282
|
+
answer = ask();
|
|
283
|
+
run.answers.set(key, answer);
|
|
284
|
+
answer.catch(() => run.answers.delete(key));
|
|
285
|
+
}
|
|
286
|
+
return answer;
|
|
287
|
+
}
|
|
288
|
+
//#endregion
|
|
289
|
+
//#region src/owningTsconfigJsx.ts
|
|
290
|
+
const REGISTER = "owning-tsconfig-jsx-register.mjs";
|
|
291
|
+
/** The CLI's `bin/` was not found above the module looking for it. */
|
|
292
|
+
var OwningTsconfigJsxHookMissing = class extends Error {
|
|
293
|
+
from;
|
|
294
|
+
constructor(from) {
|
|
295
|
+
super(`Could not find bin/${REGISTER} in any directory above '${from}'. It ships with @geekmidas/cli beside bin/gkm.mjs; reinstall the package if it is missing.`);
|
|
296
|
+
this.from = from;
|
|
297
|
+
this.name = "OwningTsconfigJsxHookMissing";
|
|
298
|
+
}
|
|
299
|
+
};
|
|
300
|
+
/**
|
|
301
|
+
* The CLI's `bin/owning-tsconfig-jsx-register.mjs`, as a file URL. Searched
|
|
302
|
+
* upward because this module runs from `src/` in the repo and from a chunk in
|
|
303
|
+
* `dist/` once built, and `bin/` sits beside both.
|
|
304
|
+
*/
|
|
305
|
+
function registerUrl() {
|
|
306
|
+
const from = dirname(fileURLToPath(import.meta.url));
|
|
307
|
+
for (let dir = from;; dir = dirname(dir)) {
|
|
308
|
+
const candidate = join(dir, "bin", REGISTER);
|
|
309
|
+
if (existsSync(candidate)) return pathToFileURL(candidate).href;
|
|
310
|
+
if (dirname(dir) === dir) throw new OwningTsconfigJsxHookMissing(from);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* `NODE_OPTIONS` for a process that runs app code through tsx, with the hook
|
|
315
|
+
* that compiles each `.tsx` with its own tsconfig's JSX settings (see
|
|
316
|
+
* `bin/owning-tsconfig-jsx.mjs`) put in front of every other `--import`, so it
|
|
317
|
+
* is registered before tsx and reads the source on tsx's behalf.
|
|
318
|
+
*
|
|
319
|
+
* `bin/gkm.mjs` already starts the CLI this way, and its children inherit it;
|
|
320
|
+
* this is for those that set `NODE_OPTIONS` themselves, or whose CLI was
|
|
321
|
+
* started with tsx already imported.
|
|
322
|
+
*/
|
|
323
|
+
function withOwningTsconfigJsx(nodeOptions = "") {
|
|
324
|
+
if (nodeOptions.includes(REGISTER)) return nodeOptions;
|
|
325
|
+
return [`--import=${registerUrl()}`, nodeOptions].filter(Boolean).join(" ");
|
|
326
|
+
}
|
|
327
|
+
//#endregion
|
|
328
|
+
//#region src/sandbox/worker.ts
|
|
329
|
+
/**
|
|
330
|
+
* Running one of the CLI's own worker scripts inside a sandbox, and reading
|
|
331
|
+
* back the one JSON value it answers with.
|
|
332
|
+
*
|
|
333
|
+
* The worker imports the project's TypeScript — `gkm.config.ts`, construct
|
|
334
|
+
* modules, an app's entry — so it starts with the CLI's own tsx and the two
|
|
335
|
+
* hooks `gkm` itself runs with (JSX by the owning tsconfig, path aliases by
|
|
336
|
+
* the adjacent one). The host process needs none of them loaded: a program
|
|
337
|
+
* calling `deploy()` without `--import tsx` still loads a TypeScript config.
|
|
338
|
+
*/
|
|
339
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
340
|
+
/**
|
|
341
|
+
* A worker's file: `dist/sandbox/<name>.mjs` once built — whether this module
|
|
342
|
+
* was bundled into `dist/` or sits beside it — or the `.ts` source under tsx.
|
|
343
|
+
*/
|
|
344
|
+
function workerFile(name) {
|
|
345
|
+
return [
|
|
346
|
+
join(here, "sandbox", `${name}.mjs`),
|
|
347
|
+
join(here, `${name}.mjs`),
|
|
348
|
+
join(here, "..", "sandbox", `${name}.mjs`),
|
|
349
|
+
join(here, `${name}.ts`)
|
|
350
|
+
].find((path) => existsSync(path)) ?? join(here, `${name}.ts`);
|
|
351
|
+
}
|
|
352
|
+
/** tsx, from the CLI's own dependencies — never the project's. */
|
|
353
|
+
function tsxUrl() {
|
|
354
|
+
return pathToFileURL(createRequire(import.meta.url).resolve("tsx")).href;
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* `node`'s arguments for `script`: the CLI's TypeScript loaders, then any
|
|
358
|
+
* further `imports`, then the script and its `args` — an argument array, so
|
|
359
|
+
* nothing about a path is read by a shell.
|
|
360
|
+
*/
|
|
361
|
+
function nodeWithTsx(script, args, imports = []) {
|
|
362
|
+
return [
|
|
363
|
+
...withOwningTsconfigJsx(`--import=${tsxUrl()}`).split(" "),
|
|
364
|
+
...imports.map((path) => `--import=${pathToFileURL(path).href}`),
|
|
365
|
+
script,
|
|
366
|
+
...args
|
|
367
|
+
];
|
|
368
|
+
}
|
|
369
|
+
/** A worker ended without the answer it exists to give. */
|
|
370
|
+
var SandboxWorkerFailed = class extends Error {
|
|
371
|
+
step;
|
|
372
|
+
exitCode;
|
|
373
|
+
stderr;
|
|
374
|
+
constructor(step, exitCode, stderr) {
|
|
375
|
+
super(`The sandboxed ${step} ended (exit code ${exitCode}) without an answer.${stderr.trim() ? `\n${stderr.trim()}` : ""}\nIts output above says why; the sandbox must be able to run \`node\` with the CLI's own files at the paths they have here.`);
|
|
376
|
+
this.step = step;
|
|
377
|
+
this.exitCode = exitCode;
|
|
378
|
+
this.stderr = stderr;
|
|
379
|
+
this.name = "SandboxWorkerFailed";
|
|
380
|
+
}
|
|
381
|
+
};
|
|
382
|
+
/**
|
|
383
|
+
* Run worker `name` in `sandbox`, and parse its answer with `schema`.
|
|
384
|
+
*
|
|
385
|
+
* The answer is the last marked line on stdout. Anything else the project's
|
|
386
|
+
* code printed is ignored, and an answer the schema refuses is a failure
|
|
387
|
+
* rather than data — a worker in an isolating sandbox runs code the host does
|
|
388
|
+
* not trust.
|
|
389
|
+
*
|
|
390
|
+
* Within a run (`withSandbox`), the same worker asked the same question is
|
|
391
|
+
* started once; every ask gets its own copy of the answer, and its stderr, as
|
|
392
|
+
* though it had run again.
|
|
393
|
+
*/
|
|
394
|
+
async function runWorker(sandbox, step, options) {
|
|
395
|
+
if (options.secrets) return startWorker(sandbox, step, options);
|
|
396
|
+
const answer = await oncePerRun(sandbox, JSON.stringify([
|
|
397
|
+
options.name,
|
|
398
|
+
options.cwd,
|
|
399
|
+
options.args,
|
|
400
|
+
options.env ?? {}
|
|
401
|
+
]), () => startWorker(sandbox, step, options));
|
|
402
|
+
return structuredClone(answer);
|
|
403
|
+
}
|
|
404
|
+
async function startWorker(sandbox, step, options) {
|
|
405
|
+
const result = await sandbox.exec("node", nodeWithTsx(workerFile(options.name), options.args), {
|
|
406
|
+
cwd: options.cwd,
|
|
407
|
+
env: {
|
|
408
|
+
...sandbox.env,
|
|
409
|
+
...options.env
|
|
410
|
+
},
|
|
411
|
+
timeoutMs: options.timeoutMs,
|
|
412
|
+
output: "capture",
|
|
413
|
+
...options.secrets ? { secrets: options.secrets } : {},
|
|
414
|
+
...options.signal ? { signal: options.signal } : {}
|
|
415
|
+
});
|
|
416
|
+
const line = result.stdout.split("\n").reverse().find((l) => l.startsWith(WORKER_RESULT_MARKER));
|
|
417
|
+
if (line) try {
|
|
418
|
+
const parsed = options.schema.safeParse(JSON.parse(line.slice(WORKER_RESULT_MARKER.length)));
|
|
419
|
+
if (parsed.success) return {
|
|
420
|
+
value: parsed.data,
|
|
421
|
+
stderr: result.stderr
|
|
422
|
+
};
|
|
423
|
+
} catch {}
|
|
424
|
+
throw new SandboxWorkerFailed(step, result.exitCode, result.stderr);
|
|
425
|
+
}
|
|
426
|
+
//#endregion
|
|
427
|
+
//#region src/reconcile/discover.ts
|
|
428
|
+
/**
|
|
429
|
+
* Discovery — one glob, one structural test.
|
|
430
|
+
*
|
|
431
|
+
* A glob per kind is the same specialness the construct model removes, and
|
|
432
|
+
* resources have no kind to be listed under: a declared `ObjectStorage` would
|
|
433
|
+
* never be found by `routes:` or `crons:`. So there is one `constructs` glob,
|
|
434
|
+
* every export of every matching module is inspected, and the per-kind
|
|
435
|
+
* `isConstruct` checks collapse into a single question — does it have an id and
|
|
436
|
+
* can it declare?
|
|
437
|
+
*
|
|
438
|
+
* Structural rather than `instanceof` on purpose. A construct from a different
|
|
439
|
+
* copy of `@geekmidas/constructs` — a linked workspace, two versions in a
|
|
440
|
+
* lockfile — is still a construct, and `instanceof` is exactly the check that
|
|
441
|
+
* says otherwise.
|
|
442
|
+
*/
|
|
443
|
+
var discover_exports = /* @__PURE__ */ __exportAll({
|
|
444
|
+
ConstructDiscoveryFailed: () => ConstructDiscoveryFailed,
|
|
445
|
+
ConstructsNotSerializable: () => ConstructsNotSerializable,
|
|
446
|
+
DuplicateConstruct: () => DuplicateConstruct,
|
|
447
|
+
LiveConstructsUnavailable: () => LiveConstructsUnavailable,
|
|
448
|
+
ProcessorServerUnknown: () => ProcessorServerUnknown,
|
|
449
|
+
consumedBy: () => consumedBy,
|
|
450
|
+
discover: () => discover,
|
|
451
|
+
isDeclarable: () => isDeclarable
|
|
452
|
+
});
|
|
453
|
+
/** `console`, or the deploy run discovering the manifest. */
|
|
454
|
+
const logger = output;
|
|
455
|
+
/**
|
|
456
|
+
* Whether a module export is a construct.
|
|
457
|
+
*
|
|
458
|
+
* Deliberately loose about what else it carries — a construct that also has a
|
|
459
|
+
* `service` is still a construct, and requiring one would exclude the kinds that
|
|
460
|
+
* own no address.
|
|
461
|
+
*/
|
|
462
|
+
function isDeclarable(value) {
|
|
463
|
+
if (typeof value !== "object" || value === null) return false;
|
|
464
|
+
const candidate = value;
|
|
465
|
+
return typeof candidate.id === "string" && candidate.id.length > 0 && typeof candidate.declare === "function";
|
|
466
|
+
}
|
|
467
|
+
/** What the discovery worker answers. Checked: the worker ran project code. */
|
|
468
|
+
const DiscoverAnswer = discriminatedUnion("reason", [
|
|
469
|
+
object({
|
|
470
|
+
reason: literal("discovered"),
|
|
471
|
+
manifest: record(string(), object({
|
|
472
|
+
id: string(),
|
|
473
|
+
kind: string()
|
|
474
|
+
}).loose()),
|
|
475
|
+
background: record(string(), array(string())).optional(),
|
|
476
|
+
subscribers: record(string(), array(object({
|
|
477
|
+
name: string(),
|
|
478
|
+
connectionKey: string(),
|
|
479
|
+
events: array(string()).optional()
|
|
480
|
+
}))).optional()
|
|
481
|
+
}),
|
|
482
|
+
object({
|
|
483
|
+
reason: literal("live"),
|
|
484
|
+
paths: array(string())
|
|
485
|
+
}),
|
|
486
|
+
object({
|
|
487
|
+
reason: literal("failed"),
|
|
488
|
+
error: object({
|
|
489
|
+
name: string(),
|
|
490
|
+
message: string(),
|
|
491
|
+
id: string().optional(),
|
|
492
|
+
sources: array(string()).optional()
|
|
493
|
+
}).loose()
|
|
494
|
+
})
|
|
495
|
+
]);
|
|
496
|
+
/**
|
|
497
|
+
* The manifest, discovered in `sandbox` and handed back as JSON — or
|
|
498
|
+
* `undefined` when it holds something JSON cannot carry and the sandbox is
|
|
499
|
+
* not isolating, for the caller to discover here as before.
|
|
500
|
+
*/
|
|
501
|
+
async function discoverInSandbox(sandbox, options) {
|
|
502
|
+
const cwd = options.cwd ?? sandbox.root;
|
|
503
|
+
const patterns = typeof options.patterns === "string" ? [options.patterns] : [...options.patterns];
|
|
504
|
+
const { value, stderr } = await runWorker(sandbox, "construct discovery", {
|
|
505
|
+
name: "discover-worker",
|
|
506
|
+
args: [JSON.stringify({
|
|
507
|
+
patterns,
|
|
508
|
+
cwd
|
|
509
|
+
})],
|
|
510
|
+
cwd,
|
|
511
|
+
timeoutMs: DISCOVER_TIMEOUT_MS,
|
|
512
|
+
schema: DiscoverAnswer
|
|
513
|
+
});
|
|
514
|
+
if (stderr.trim()) logger.warn(stderr.replace(/\n$/, ""));
|
|
515
|
+
switch (value.reason) {
|
|
516
|
+
case "discovered":
|
|
517
|
+
if (options.background) for (const [owner, files] of Object.entries(value.background ?? {})) options.background[owner] = files;
|
|
518
|
+
if (options.subscribers) for (const [owner, bound] of Object.entries(value.subscribers ?? {})) options.subscribers[owner] = bound;
|
|
519
|
+
return value.manifest;
|
|
520
|
+
case "failed":
|
|
521
|
+
if (value.error.name === "DuplicateConstruct" && value.error.id) throw new DuplicateConstruct(value.error.id, value.error.sources ?? []);
|
|
522
|
+
throw new ConstructDiscoveryFailed(value.error.name, value.error.message);
|
|
523
|
+
case "live":
|
|
524
|
+
if (sandbox.isolating) throw new ConstructsNotSerializable(value.paths);
|
|
525
|
+
return;
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
/**
|
|
529
|
+
* A caller asked for the construct objects (`sources`) or a watcher's
|
|
530
|
+
* re-import under an isolating sandbox, where only data comes back.
|
|
531
|
+
*/
|
|
532
|
+
var LiveConstructsUnavailable = class extends Error {
|
|
533
|
+
constructor() {
|
|
534
|
+
super("Discovery was asked for the construct objects themselves under an isolating sandbox, which hands back only data. Run this step without one, or ask only for the manifest.");
|
|
535
|
+
this.name = "LiveConstructsUnavailable";
|
|
536
|
+
}
|
|
537
|
+
};
|
|
538
|
+
/** How long discovering a project's constructs may take in a sandbox. */
|
|
539
|
+
const DISCOVER_TIMEOUT_MS = 6e4;
|
|
540
|
+
/** Importing a construct module, or declaring one, threw in the sandbox. */
|
|
541
|
+
var ConstructDiscoveryFailed = class extends Error {
|
|
542
|
+
errorName;
|
|
543
|
+
detail;
|
|
544
|
+
constructor(errorName, detail) {
|
|
545
|
+
super(`Discovering constructs failed (${errorName}): ${detail}`);
|
|
546
|
+
this.errorName = errorName;
|
|
547
|
+
this.detail = detail;
|
|
548
|
+
this.name = "ConstructDiscoveryFailed";
|
|
549
|
+
}
|
|
550
|
+
};
|
|
551
|
+
/**
|
|
552
|
+
* The constructs' declarations hold something that is not data, and the
|
|
553
|
+
* sandbox they were discovered in hands the deploy nothing but data.
|
|
554
|
+
*/
|
|
555
|
+
var ConstructsNotSerializable = class extends Error {
|
|
556
|
+
paths;
|
|
557
|
+
constructor(paths) {
|
|
558
|
+
super(`The construct manifest holds values that are not plain data at: ${paths.join(", ")}. Under an isolating sandbox the deploy only receives what JSON can carry; deploy with a sandbox that is not isolating if the host trusts this project.`);
|
|
559
|
+
this.paths = paths;
|
|
560
|
+
this.name = "ConstructsNotSerializable";
|
|
561
|
+
}
|
|
562
|
+
};
|
|
563
|
+
/**
|
|
564
|
+
* Build the construct manifest for a project.
|
|
565
|
+
*
|
|
566
|
+
* Runs the manifest's own validation before returning, so an app is wrong here
|
|
567
|
+
* — where the error names a file — rather than at deploy.
|
|
568
|
+
*
|
|
569
|
+
* @throws {DuplicateConstruct} when two exports claim one id.
|
|
570
|
+
*/
|
|
571
|
+
async function discover(options) {
|
|
572
|
+
const sandbox = options.sandbox ?? activeSandbox();
|
|
573
|
+
if (sandbox) {
|
|
574
|
+
if (!options.sources && !options.bustCache) {
|
|
575
|
+
const sandboxed = await discoverInSandbox(sandbox, options);
|
|
576
|
+
if (sandboxed) return sandboxed;
|
|
577
|
+
} else if (sandbox.isolating) throw new LiveConstructsUnavailable();
|
|
578
|
+
}
|
|
579
|
+
const { patterns, cwd = process.cwd(), bustCache = false, sources: out } = options;
|
|
580
|
+
if (bustCache) clearZodGlobalRegistry();
|
|
581
|
+
const manifest = {};
|
|
582
|
+
/** Which file declared each id, for the error when two of them do. */
|
|
583
|
+
const sources = {};
|
|
584
|
+
/**
|
|
585
|
+
* Constructs already seen, by identity.
|
|
586
|
+
*
|
|
587
|
+
* A re-export is the *same object* reached through a second file — ESM
|
|
588
|
+
* bindings are live, so `export * from './database.js'` hands back the
|
|
589
|
+
* binding rather than a copy. Without this, a barrel file made every
|
|
590
|
+
* construct in it appear declared twice, and `constructs/index.ts` is the
|
|
591
|
+
* first thing anyone writes in a shared folder.
|
|
592
|
+
*
|
|
593
|
+
* Identity rather than file is also the more honest rule: what may not
|
|
594
|
+
* happen twice is two *different* constructs claiming one id, and that is
|
|
595
|
+
* still an error below.
|
|
596
|
+
*/
|
|
597
|
+
const seen = /* @__PURE__ */ new WeakSet();
|
|
598
|
+
const globs = Array.isArray(patterns) ? [...patterns] : [patterns];
|
|
599
|
+
const files = fg.stream(globs, {
|
|
600
|
+
cwd,
|
|
601
|
+
absolute: true
|
|
602
|
+
});
|
|
603
|
+
/** Matched files, for the diagnostic below. */
|
|
604
|
+
let matched = 0;
|
|
605
|
+
/** Each processor, once, by the export that first reached it. */
|
|
606
|
+
const processors = /* @__PURE__ */ new Map();
|
|
607
|
+
/** Each runnable, once, under the export most likely to define it. */
|
|
608
|
+
const runnables = /* @__PURE__ */ new Map();
|
|
609
|
+
for await (const found of files) {
|
|
610
|
+
matched++;
|
|
611
|
+
const file = found.toString();
|
|
612
|
+
const module = await (bustCache ? import(`${file}?t=${Date.now()}`) : import(file));
|
|
613
|
+
for (const [exportName, exported] of Object.entries(module)) {
|
|
614
|
+
if (options.background) recordBackground(options.background, exported, file);
|
|
615
|
+
if (options.served) recordServed(options.served, exported, file);
|
|
616
|
+
if (options.subscribers) recordSubscriber(options.subscribers, exported, exportName);
|
|
617
|
+
if (Processor.isProcessor(exported)) {
|
|
618
|
+
const seenAt = processors.get(exported);
|
|
619
|
+
if (!seenAt || definedIn(file, seenAt.file)) processors.set(exported, {
|
|
620
|
+
exportName,
|
|
621
|
+
file,
|
|
622
|
+
processor: exported
|
|
623
|
+
});
|
|
624
|
+
}
|
|
625
|
+
if (isRunnable(exported)) {
|
|
626
|
+
const seenAt = runnables.get(exported);
|
|
627
|
+
if (!seenAt || definedIn(file, seenAt.file)) runnables.set(exported, {
|
|
628
|
+
exportName,
|
|
629
|
+
file,
|
|
630
|
+
construct: exported
|
|
631
|
+
});
|
|
632
|
+
}
|
|
633
|
+
if (!isDeclarable(exported)) continue;
|
|
634
|
+
if (seen.has(exported)) continue;
|
|
635
|
+
seen.add(exported);
|
|
636
|
+
for (const declaration of exported.declare()) {
|
|
637
|
+
const id = canonicalId(declaration.id);
|
|
638
|
+
const source = relative(cwd, file);
|
|
639
|
+
const claimed = sources[id];
|
|
640
|
+
if (claimed !== void 0 && claimed !== source) throw new DuplicateConstruct(id, [claimed, source]);
|
|
641
|
+
manifest[id] = {
|
|
642
|
+
...declaration,
|
|
643
|
+
id
|
|
644
|
+
};
|
|
645
|
+
sources[id] = source;
|
|
646
|
+
if (out) out[id] = {
|
|
647
|
+
file,
|
|
648
|
+
exportName,
|
|
649
|
+
construct: exported
|
|
650
|
+
};
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
nestProcessors(manifest, [...processors.values()], cwd);
|
|
655
|
+
nestRunnables(manifest, [...runnables.values()], cwd);
|
|
656
|
+
assertDerivations(manifest);
|
|
657
|
+
warnIfNothingFound(globs, matched, Object.keys(manifest).length);
|
|
658
|
+
return manifest;
|
|
659
|
+
}
|
|
660
|
+
/**
|
|
661
|
+
* Record where a worker's background work is declared: a cron, a queue
|
|
662
|
+
* consumer or a topic subscriber, under the worker that owns it.
|
|
663
|
+
*/
|
|
664
|
+
function recordBackground(background, exported, file) {
|
|
665
|
+
if (!Cron.isCron(exported) && !Queue.isQueue(exported) && !Subscriber.isSubscriber(exported)) return;
|
|
666
|
+
const owner = exported.owner;
|
|
667
|
+
if (typeof owner !== "string") return;
|
|
668
|
+
const key = canonicalId(owner);
|
|
669
|
+
const files = background[key] ?? [];
|
|
670
|
+
background[key] = files;
|
|
671
|
+
if (!files.includes(file)) files.push(file);
|
|
672
|
+
}
|
|
673
|
+
/** Record the file of anything built from a surface, under that surface. */
|
|
674
|
+
function recordServed(served, exported, file) {
|
|
675
|
+
if (typeof exported !== "object" || exported === null) return;
|
|
676
|
+
const surface = exported.surface?.id;
|
|
677
|
+
if (typeof surface !== "string") return;
|
|
678
|
+
const key = canonicalId(surface);
|
|
679
|
+
const files = served[key] ?? [];
|
|
680
|
+
served[key] = files;
|
|
681
|
+
if (!files.includes(file)) files.push(file);
|
|
682
|
+
}
|
|
683
|
+
/** A processor built from a file server the discovery never found. */
|
|
684
|
+
var ProcessorServerUnknown = class extends GkmError {
|
|
685
|
+
processor;
|
|
686
|
+
server;
|
|
687
|
+
constructor(processor, server) {
|
|
688
|
+
super(`The processor '${processor}' answers on '${server}', which no discovered file declares. Export the FileServer from a file the workspace's constructs glob matches.`);
|
|
689
|
+
this.processor = processor;
|
|
690
|
+
this.server = server;
|
|
691
|
+
this.name = "ProcessorServerUnknown";
|
|
692
|
+
}
|
|
693
|
+
};
|
|
694
|
+
/**
|
|
695
|
+
* Whether `file` is the likelier home of an export also reached from
|
|
696
|
+
* `other`: not a barrel (`index.*`) where the other is, and otherwise the
|
|
697
|
+
* first by path — so the answer never depends on the order the glob
|
|
698
|
+
* streamed them in.
|
|
699
|
+
*/
|
|
700
|
+
function definedIn(file, other) {
|
|
701
|
+
const barrel = (path) => /(^|[/\\])index\.[cm]?[jt]s$/.test(path);
|
|
702
|
+
if (barrel(file) !== barrel(other)) return barrel(other);
|
|
703
|
+
return file < other;
|
|
704
|
+
}
|
|
705
|
+
/**
|
|
706
|
+
* Nest each processor in the file server it answers on.
|
|
707
|
+
*
|
|
708
|
+
* A processor is positional, as a subscriber is: it answers on its server's
|
|
709
|
+
* domain and nothing else. It is nested here, not only by the build, because
|
|
710
|
+
* every deploy path — the compose stack, the CDN in front of the bucket, the
|
|
711
|
+
* SST stack — reads the discovered manifest. Its handler is its source until a
|
|
712
|
+
* build replaces it with the generated one.
|
|
713
|
+
*/
|
|
714
|
+
function nestProcessors(manifest, processors, cwd) {
|
|
715
|
+
for (const { exportName, file, processor } of processors) {
|
|
716
|
+
const server = manifest[processor.surfaceId];
|
|
717
|
+
if (server?.kind !== "file-server") throw new ProcessorServerUnknown(exportName, processor.surfaceId);
|
|
718
|
+
const declaration = {
|
|
719
|
+
id: exportName,
|
|
720
|
+
handler: `${relative(cwd, file)}#${exportName}`,
|
|
721
|
+
path: processor.pattern,
|
|
722
|
+
prefix: processor.prefix,
|
|
723
|
+
...processor.native.length ? { native: [...processor.native] } : {},
|
|
724
|
+
...processor.timeout !== void 0 ? { timeout: processor.timeout } : {},
|
|
725
|
+
...processor.memorySize !== void 0 ? { memorySize: processor.memorySize } : {},
|
|
726
|
+
dependencies: processor.constructs.flatMap((id) => {
|
|
727
|
+
const target = manifest[canonicalId(id)];
|
|
728
|
+
return target ? [{
|
|
729
|
+
target: target.id,
|
|
730
|
+
kind: target.kind
|
|
731
|
+
}] : [];
|
|
732
|
+
})
|
|
733
|
+
};
|
|
734
|
+
manifest[server.id] = {
|
|
735
|
+
...server,
|
|
736
|
+
processors: [...(server.processors ?? []).filter((p) => p.id !== exportName), declaration].sort((a, b) => a.id.localeCompare(b.id))
|
|
737
|
+
};
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
/**
|
|
741
|
+
* Whether an export is something a process runs: an endpoint or a WebSocket
|
|
742
|
+
* route its surface serves, or a cron, function, queue consumer or subscriber
|
|
743
|
+
* a worker does.
|
|
744
|
+
*/
|
|
745
|
+
function isRunnable(value) {
|
|
746
|
+
return Endpoint.isEndpoint(value) || WebSocketRoute.isRoute(value) || Cron.isCron(value) || Function.isFunction(value) || Queue.isQueue(value) || Subscriber.isSubscriber(value);
|
|
747
|
+
}
|
|
748
|
+
/**
|
|
749
|
+
* Nest each runnable where it runs: an endpoint in its surface, a route in
|
|
750
|
+
* its WebSocket surface, a consumer in its queue, a subscriber in its topic or
|
|
751
|
+
* bucket; a cron or function as a node of its own.
|
|
752
|
+
*
|
|
753
|
+
* Here and not in the build, so the manifest is the whole application in every
|
|
754
|
+
* command: `gkm dev` reads the same edges `gkm build` writes and a deploy
|
|
755
|
+
* grants. Each handler is its source, `<file>#<export>`, until a build that
|
|
756
|
+
* generates one per function replaces it with the generated entry.
|
|
757
|
+
*/
|
|
758
|
+
function nestRunnables(manifest, found, cwd) {
|
|
759
|
+
const edges = (ids = []) => [...new Set(ids.map(canonicalId))].flatMap((id) => {
|
|
760
|
+
const target = manifest[id];
|
|
761
|
+
return target ? [{
|
|
762
|
+
target: target.id,
|
|
763
|
+
kind: target.kind
|
|
764
|
+
}] : [];
|
|
765
|
+
});
|
|
766
|
+
const ownerOf = (construct) => typeof construct.owner === "string" ? { owner: canonicalId(construct.owner) } : {};
|
|
767
|
+
const byId = (list, next) => [...list.filter((item) => item.id !== next.id), next].sort((a, b) => a.id.localeCompare(b.id));
|
|
768
|
+
const sorted = [...found].sort((a, b) => a.exportName.localeCompare(b.exportName));
|
|
769
|
+
for (const { exportName, file, construct } of sorted) {
|
|
770
|
+
const handler = `${relative(cwd, file)}#${exportName}`;
|
|
771
|
+
if (Endpoint.isEndpoint(construct)) {
|
|
772
|
+
const surfaceId = construct.surface?.id;
|
|
773
|
+
const surface = surfaceId ? manifest[canonicalId(surfaceId)] : void 0;
|
|
774
|
+
if (surface?.kind !== "rest-api") continue;
|
|
775
|
+
manifest[surface.id] = {
|
|
776
|
+
...surface,
|
|
777
|
+
endpoints: byId(surface.endpoints, {
|
|
778
|
+
id: `${surface.id}${construct.method}${construct._path}`,
|
|
779
|
+
handler,
|
|
780
|
+
method: construct.method,
|
|
781
|
+
path: construct._path,
|
|
782
|
+
dependencies: edges(construct.constructs),
|
|
783
|
+
authorizer: construct.authorizer?.name ?? "none"
|
|
784
|
+
})
|
|
785
|
+
};
|
|
786
|
+
continue;
|
|
787
|
+
}
|
|
788
|
+
if (WebSocketRoute.isRoute(construct)) {
|
|
789
|
+
const surface = manifest[canonicalId(construct.surface.id)];
|
|
790
|
+
if (surface?.kind !== "websocket-api") continue;
|
|
791
|
+
manifest[surface.id] = {
|
|
792
|
+
...surface,
|
|
793
|
+
routes: byId(surface.routes ?? [], {
|
|
794
|
+
id: `${surface.id}${construct.action}`,
|
|
795
|
+
handler,
|
|
796
|
+
action: construct.action,
|
|
797
|
+
dependencies: edges(construct.constructs)
|
|
798
|
+
})
|
|
799
|
+
};
|
|
800
|
+
continue;
|
|
801
|
+
}
|
|
802
|
+
if (Cron.isCron(construct)) {
|
|
803
|
+
manifest[exportName] = {
|
|
804
|
+
kind: "cron",
|
|
805
|
+
id: exportName,
|
|
806
|
+
handler,
|
|
807
|
+
schedule: construct.schedule || "rate(1 hour)",
|
|
808
|
+
dependencies: edges(construct.constructs),
|
|
809
|
+
...ownerOf(construct)
|
|
810
|
+
};
|
|
811
|
+
continue;
|
|
812
|
+
}
|
|
813
|
+
if (Function.isFunction(construct)) {
|
|
814
|
+
manifest[exportName] = {
|
|
815
|
+
kind: "function",
|
|
816
|
+
id: exportName,
|
|
817
|
+
handler,
|
|
818
|
+
dependencies: edges(construct.constructs),
|
|
819
|
+
provides: [provideKey(exportName, "url")],
|
|
820
|
+
...ownerOf(construct)
|
|
821
|
+
};
|
|
822
|
+
continue;
|
|
823
|
+
}
|
|
824
|
+
if (Queue.isQueue(construct)) {
|
|
825
|
+
const queue = manifest[construct.id];
|
|
826
|
+
if (queue?.kind !== "queue") continue;
|
|
827
|
+
manifest[queue.id] = {
|
|
828
|
+
...queue,
|
|
829
|
+
worker: {
|
|
830
|
+
...queue.worker,
|
|
831
|
+
handler,
|
|
832
|
+
dependencies: edges(construct.constructs),
|
|
833
|
+
...ownerOf(construct)
|
|
834
|
+
}
|
|
835
|
+
};
|
|
836
|
+
continue;
|
|
837
|
+
}
|
|
838
|
+
if (Subscriber.isSubscriber(construct)) {
|
|
839
|
+
const subscriber = {
|
|
840
|
+
id: exportName,
|
|
841
|
+
handler,
|
|
842
|
+
events: [...construct.subscribedEvents ?? []],
|
|
843
|
+
dependencies: edges(construct.constructs),
|
|
844
|
+
...ownerOf(construct)
|
|
845
|
+
};
|
|
846
|
+
if (construct.bucketName) {
|
|
847
|
+
const bucket = manifest[canonicalId(construct.bucketName)];
|
|
848
|
+
if (bucket?.kind !== "objects") continue;
|
|
849
|
+
manifest[bucket.id] = {
|
|
850
|
+
...bucket,
|
|
851
|
+
subscribers: byId(bucket.subscribers ?? [], {
|
|
852
|
+
...subscriber,
|
|
853
|
+
...construct.objectFilter
|
|
854
|
+
})
|
|
855
|
+
};
|
|
856
|
+
continue;
|
|
857
|
+
}
|
|
858
|
+
const topic = construct.topicName ? manifest[canonicalId(construct.topicName)] : void 0;
|
|
859
|
+
if (topic?.kind !== "topic") continue;
|
|
860
|
+
manifest[topic.id] = {
|
|
861
|
+
...topic,
|
|
862
|
+
subscribers: byId(topic.subscribers, subscriber)
|
|
863
|
+
};
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
/**
|
|
868
|
+
* Record a subscriber — to a topic or to a bucket — under the worker that
|
|
869
|
+
* runs it, by its export. Once per name: a file reached twice through a
|
|
870
|
+
* re-export finds it again.
|
|
871
|
+
*/
|
|
872
|
+
function recordSubscriber(subscribers, exported, exportName) {
|
|
873
|
+
if (!Subscriber.isSubscriber(exported)) return;
|
|
874
|
+
const owner = exported.owner;
|
|
875
|
+
const connectionKey = subscriberConnectionKey(exported);
|
|
876
|
+
if (typeof owner !== "string" || !connectionKey) return;
|
|
877
|
+
const key = canonicalId(owner);
|
|
878
|
+
const bound = subscribers[key] ?? [];
|
|
879
|
+
subscribers[key] = bound;
|
|
880
|
+
if (!bound.some((s) => s.connectionKey === connectionKey && s.name === exportName)) {
|
|
881
|
+
const events = exported.topicName && !exported.inboxName ? exported.subscribedEvents : void 0;
|
|
882
|
+
bound.push({
|
|
883
|
+
name: exportName,
|
|
884
|
+
connectionKey,
|
|
885
|
+
...events ? { events: [...events] } : {}
|
|
886
|
+
});
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
/**
|
|
890
|
+
* What a runnable consumes, by id: a queue's consumer drains that queue, a
|
|
891
|
+
* subscriber its topic. Nothing for anything else.
|
|
892
|
+
*/
|
|
893
|
+
function consumedBy(runnable) {
|
|
894
|
+
if (Queue.isQueue(runnable)) return [runnable.id];
|
|
895
|
+
if (Subscriber.isSubscriber(runnable) && runnable.topicName) return [canonicalId(runnable.topicName)];
|
|
896
|
+
if (Subscriber.isSubscriber(runnable) && runnable.bucketName) return [canonicalId(runnable.bucketName)];
|
|
897
|
+
return [];
|
|
898
|
+
}
|
|
899
|
+
/**
|
|
900
|
+
* Say so when a glob was configured and found nothing.
|
|
901
|
+
*
|
|
902
|
+
* The glob is not a filter over declarations already known — it is *how they
|
|
903
|
+
* are found*, by importing what it matches. So a file it misses is a
|
|
904
|
+
* declaration that does not exist, and every symptom of that appears somewhere
|
|
905
|
+
* other than the cause: no container starts, no env key is written, and the
|
|
906
|
+
* application fails on first use against a resource it can see in its own
|
|
907
|
+
* source.
|
|
908
|
+
*
|
|
909
|
+
* Nothing reported it before, because an unmatched file is indistinguishable
|
|
910
|
+
* from a file nobody wrote. These two cases are the ones that are *not*
|
|
911
|
+
* ambiguous — a glob was configured, so something was expected.
|
|
912
|
+
*
|
|
913
|
+
* Silent when no glob is configured at all: that is a project which has not
|
|
914
|
+
* adopted constructs, and has nothing to be missing.
|
|
915
|
+
*/
|
|
916
|
+
function warnIfNothingFound(globs, matched, declared) {
|
|
917
|
+
if (globs.length === 0) return;
|
|
918
|
+
if (matched === 0) {
|
|
919
|
+
logger.warn(`\n⚠️ The constructs glob matched no files, so nothing was declared.\n Patterns: ${globs.join(", ")}\n Nothing will be provisioned — no containers, no env keys, no resources.\n A common cause is depth: '*.ts' matches one level, '**/*.ts' matches any.`);
|
|
920
|
+
return;
|
|
921
|
+
}
|
|
922
|
+
if (declared === 0) logger.warn(`\n⚠️ The constructs glob matched ${matched} file(s) but none declared anything.\n Patterns: ${globs.join(", ")}\n Discovery keeps exports with an 'id' that can 'declare()'. A construct that is\n built but never exported is invisible to it.`);
|
|
923
|
+
}
|
|
924
|
+
/** Two constructs claiming one id. */
|
|
925
|
+
var DuplicateConstruct = class extends GkmError {
|
|
926
|
+
/** The id claimed twice. */
|
|
927
|
+
id;
|
|
928
|
+
/** The files that claimed it. */
|
|
929
|
+
sources;
|
|
930
|
+
constructor(id, sources) {
|
|
931
|
+
super("Two constructs declare the same id");
|
|
932
|
+
this.name = "DuplicateConstruct";
|
|
933
|
+
this.id = id;
|
|
934
|
+
this.sources = sources;
|
|
935
|
+
}
|
|
936
|
+
};
|
|
937
|
+
//#endregion
|
|
938
|
+
export { subscriberTokenKey as C, subscriberConnectionKey as S, withSandbox as _, discover_exports as a, withOutput as b, nodeWithTsx as c, SECRETS_DIR_ENV as d, SandboxCwdEscape as f, confineCwd as g, assertSecretNames as h, discover as i, runWorker as l, activeSandbox as m, ConstructsNotSerializable as n, isDeclarable as o, SecretNameInvalid as p, consumedBy as r, SandboxWorkerFailed as s, ConstructDiscoveryFailed as t, withOwningTsconfigJsx as u, ConstructGenerator as v, workerEdges as w, eventsEdgeBucket as x, output as y };
|
|
939
|
+
|
|
940
|
+
//# sourceMappingURL=discover-DbDrCQ8h.mjs.map
|