@geekmidas/constructs 10.0.0-alpha.13 → 10.0.0-alpha.131
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 +222 -158
- package/dist/Construct-127M7yrl.d.cts +231 -0
- package/dist/Construct-127M7yrl.d.cts.map +1 -0
- package/dist/{Construct-BeYVu_QF.mjs → Construct-CGuc_Ijk.mjs} +8 -9
- package/dist/Construct-CGuc_Ijk.mjs.map +1 -0
- package/dist/{Construct-DqdlARxq.cjs → Construct-DorKS0Ua.cjs} +8 -9
- package/dist/Construct-DorKS0Ua.cjs.map +1 -0
- package/dist/Construct-DySlwh8o.d.mts +231 -0
- package/dist/Construct-DySlwh8o.d.mts.map +1 -0
- package/dist/{Cron-DKqnnTdH.d.cts → Cron-CFkpEys6.d.cts} +14 -7
- package/dist/Cron-CFkpEys6.d.cts.map +1 -0
- package/dist/{Cron-SyqS5oWJ.d.mts → Cron-CQoDSu-n.d.mts} +14 -7
- package/dist/Cron-CQoDSu-n.d.mts.map +1 -0
- package/dist/CronBuilder-1W-G_i15.d.mts +47 -0
- package/dist/CronBuilder-1W-G_i15.d.mts.map +1 -0
- package/dist/{CronBuilder-D_0HNBTr.mjs → CronBuilder-BJ5LoadF.mjs} +28 -11
- package/dist/CronBuilder-BJ5LoadF.mjs.map +1 -0
- package/dist/{CronBuilder-BdnI6lxF.cjs → CronBuilder-B_NSP-Y5.cjs} +27 -10
- package/dist/CronBuilder-B_NSP-Y5.cjs.map +1 -0
- package/dist/CronBuilder-OaCRRFVk.d.cts +47 -0
- package/dist/CronBuilder-OaCRRFVk.d.cts.map +1 -0
- package/dist/{Endpoint-C6yyHpRS.d.cts → Endpoint-BEh-jW-f.d.cts} +122 -41
- package/dist/Endpoint-BEh-jW-f.d.cts.map +1 -0
- package/dist/Endpoint-BcUorcBa.cjs +576 -0
- package/dist/Endpoint-BcUorcBa.cjs.map +1 -0
- package/dist/Endpoint-BgvG36NO.mjs +547 -0
- package/dist/Endpoint-BgvG36NO.mjs.map +1 -0
- package/dist/{Endpoint-DuT4TEEq.d.mts → Endpoint-DTXDggNl.d.mts} +124 -43
- package/dist/Endpoint-DTXDggNl.d.mts.map +1 -0
- package/dist/{index-BPSZ_Lp_.d.cts → EndpointFactory-B2dCS9dy.d.cts} +187 -104
- package/dist/EndpointFactory-B2dCS9dy.d.cts.map +1 -0
- package/dist/{EndpointFactory-ptPR1cXw.mjs → EndpointFactory-C1NlpCAS.mjs} +270 -54
- package/dist/EndpointFactory-C1NlpCAS.mjs.map +1 -0
- package/dist/{index-BoZ-iisU.d.mts → EndpointFactory-D2HXcUrJ.d.mts} +188 -105
- package/dist/EndpointFactory-D2HXcUrJ.d.mts.map +1 -0
- package/dist/{EndpointFactory-M8OQKZRY.cjs → EndpointFactory-gqmIRVWg.cjs} +310 -52
- package/dist/EndpointFactory-gqmIRVWg.cjs.map +1 -0
- package/dist/Function-BIEsY0Hm.d.cts +76 -0
- package/dist/Function-BIEsY0Hm.d.cts.map +1 -0
- package/dist/Function-DfMzTGS4.d.mts +76 -0
- package/dist/Function-DfMzTGS4.d.mts.map +1 -0
- package/dist/{HonoEndpointAdaptor-7QagYKdP.cjs → HonoEndpointAdaptor-BJlj20fQ.cjs} +79 -31
- package/dist/HonoEndpointAdaptor-BJlj20fQ.cjs.map +1 -0
- package/dist/{HonoEndpointAdaptor-CYHA0WAt.mjs → HonoEndpointAdaptor-BlbkUDNo.mjs} +76 -28
- package/dist/HonoEndpointAdaptor-BlbkUDNo.mjs.map +1 -0
- package/dist/ObjectSubscriberBuilder-HmBwFn2o.d.mts +129 -0
- package/dist/ObjectSubscriberBuilder-HmBwFn2o.d.mts.map +1 -0
- package/dist/ObjectSubscriberBuilder-l-64yUiF.d.cts +129 -0
- package/dist/ObjectSubscriberBuilder-l-64yUiF.d.cts.map +1 -0
- package/dist/ProcessorBuilder-B2_stA8f.d.mts +216 -0
- package/dist/ProcessorBuilder-B2_stA8f.d.mts.map +1 -0
- package/dist/ProcessorBuilder-C62bIOwj.d.cts +216 -0
- package/dist/ProcessorBuilder-C62bIOwj.d.cts.map +1 -0
- package/dist/{Queue-D9X6OoON.d.mts → Queue-BnK3UH8r.d.mts} +42 -41
- package/dist/Queue-BnK3UH8r.d.mts.map +1 -0
- package/dist/{Queue-DYPB2KWL.d.cts → Queue-C4rijiM7.d.cts} +43 -42
- package/dist/Queue-C4rijiM7.d.cts.map +1 -0
- package/dist/Queue-D4Iaidrs.cjs +109 -0
- package/dist/Queue-D4Iaidrs.cjs.map +1 -0
- package/dist/Queue-u8w8_HpE.mjs +104 -0
- package/dist/Queue-u8w8_HpE.mjs.map +1 -0
- package/dist/QueueBuilder-2wP5lEC8.mjs +118 -0
- package/dist/QueueBuilder-2wP5lEC8.mjs.map +1 -0
- package/dist/QueueBuilder-B3vL1ED2.d.mts +75 -0
- package/dist/QueueBuilder-B3vL1ED2.d.mts.map +1 -0
- package/dist/QueueBuilder-BcPBQSSX.d.cts +75 -0
- package/dist/QueueBuilder-BcPBQSSX.d.cts.map +1 -0
- package/dist/QueueBuilder-BxsZ9o5z.cjs +135 -0
- package/dist/QueueBuilder-BxsZ9o5z.cjs.map +1 -0
- package/dist/Subscriber-BdCtfFXL.d.cts +73 -0
- package/dist/Subscriber-BdCtfFXL.d.cts.map +1 -0
- package/dist/Subscriber-DDo4HFNn.d.mts +73 -0
- package/dist/Subscriber-DDo4HFNn.d.mts.map +1 -0
- package/dist/SubscriberBuilder-3msj1U2w.mjs +230 -0
- package/dist/SubscriberBuilder-3msj1U2w.mjs.map +1 -0
- package/dist/SubscriberBuilder-CQst6Iz3.cjs +253 -0
- package/dist/SubscriberBuilder-CQst6Iz3.cjs.map +1 -0
- package/dist/Topic-DN2gYJ-p.mjs +99 -0
- package/dist/Topic-DN2gYJ-p.mjs.map +1 -0
- package/dist/Topic-Dp9Q7Lj2.cjs +104 -0
- package/dist/Topic-Dp9Q7Lj2.cjs.map +1 -0
- package/dist/adaptors/aws.cjs +134 -160
- package/dist/adaptors/aws.cjs.map +1 -1
- package/dist/adaptors/aws.d.cts +57 -48
- package/dist/adaptors/aws.d.cts.map +1 -1
- package/dist/adaptors/aws.d.mts +58 -49
- package/dist/adaptors/aws.d.mts.map +1 -1
- package/dist/adaptors/aws.mjs +130 -157
- package/dist/adaptors/aws.mjs.map +1 -1
- package/dist/adaptors/hono.cjs +1 -1
- package/dist/adaptors/hono.d.cts +5 -6
- package/dist/adaptors/hono.d.cts.map +1 -1
- package/dist/adaptors/hono.d.mts +6 -7
- package/dist/adaptors/hono.d.mts.map +1 -1
- package/dist/adaptors/hono.mjs +1 -1
- package/dist/adaptors/testing.cjs +824 -38
- package/dist/adaptors/testing.cjs.map +1 -1
- package/dist/adaptors/testing.d.cts +368 -39
- package/dist/adaptors/testing.d.cts.map +1 -1
- package/dist/adaptors/testing.d.mts +367 -38
- package/dist/adaptors/testing.d.mts.map +1 -1
- package/dist/adaptors/testing.mjs +802 -34
- package/dist/adaptors/testing.mjs.map +1 -1
- package/dist/auth-BMCJN30Y.d.cts +268 -0
- package/dist/auth-BMCJN30Y.d.cts.map +1 -0
- package/dist/auth-D_0788uW.d.mts +268 -0
- package/dist/auth-D_0788uW.d.mts.map +1 -0
- package/dist/auth.cjs +289 -46
- package/dist/auth.cjs.map +1 -1
- package/dist/auth.d.cts +2 -104
- package/dist/auth.d.mts +2 -104
- package/dist/auth.mjs +285 -48
- package/dist/auth.mjs.map +1 -1
- package/dist/cache-5QZzh5Er.d.mts +44 -0
- package/dist/cache-5QZzh5Er.d.mts.map +1 -0
- package/dist/cache-DnGDGly3.d.cts +44 -0
- package/dist/cache-DnGDGly3.d.cts.map +1 -0
- package/dist/cache.d.cts +2 -43
- package/dist/cache.d.mts +2 -43
- package/dist/cipher-C1lEFX63.mjs +225 -0
- package/dist/cipher-C1lEFX63.mjs.map +1 -0
- package/dist/cipher-CVxfwLjk.cjs +332 -0
- package/dist/cipher-CVxfwLjk.cjs.map +1 -0
- package/dist/cipher-DSDxPRIp.d.cts +106 -0
- package/dist/cipher-DSDxPRIp.d.cts.map +1 -0
- package/dist/cipher-DSDxPRIp.d.mts +106 -0
- package/dist/cipher-DSDxPRIp.d.mts.map +1 -0
- package/dist/{construct-interface-DPlxfpoS.d.mts → construct-interface-B1AfqRl4.d.cts} +42 -8
- package/dist/construct-interface-B1AfqRl4.d.cts.map +1 -0
- package/dist/{construct-interface-DgXTJcOD.d.cts → construct-interface-ZvYQbivO.d.mts} +42 -8
- package/dist/construct-interface-ZvYQbivO.d.mts.map +1 -0
- package/dist/construct-interface.cjs +30 -4
- package/dist/construct-interface.cjs.map +1 -1
- package/dist/construct-interface.d.cts +2 -2
- package/dist/construct-interface.d.mts +2 -2
- package/dist/construct-interface.mjs +30 -5
- package/dist/construct-interface.mjs.map +1 -1
- package/dist/credential-DYymbp_7.cjs +257 -0
- package/dist/credential-DYymbp_7.cjs.map +1 -0
- package/dist/credential-DfSAOOdY.mjs +222 -0
- package/dist/credential-DfSAOOdY.mjs.map +1 -0
- package/dist/credential.cjs +7 -129
- package/dist/credential.d.cts +2 -58
- package/dist/credential.d.mts +2 -58
- package/dist/credential.mjs +2 -128
- package/dist/crons/index.cjs +126 -1
- package/dist/crons/index.cjs.map +1 -1
- package/dist/crons/index.d.cts +43 -3
- package/dist/crons/index.d.cts.map +1 -1
- package/dist/crons/index.d.mts +43 -3
- package/dist/crons/index.d.mts.map +1 -1
- package/dist/crons/index.mjs +125 -2
- package/dist/crons/index.mjs.map +1 -1
- package/dist/database/kysely.cjs +3 -194
- package/dist/database/kysely.d.cts +2 -149
- package/dist/database/kysely.d.mts +2 -149
- package/dist/database/kysely.mjs +2 -192
- package/dist/email.d.cts +1 -1
- package/dist/email.d.cts.map +1 -1
- package/dist/email.d.mts +2 -2
- package/dist/email.d.mts.map +1 -1
- package/dist/encryption/kms.cjs +95 -0
- package/dist/encryption/kms.cjs.map +1 -0
- package/dist/encryption/kms.d.cts +7 -0
- package/dist/encryption/kms.d.cts.map +1 -0
- package/dist/encryption/kms.d.mts +7 -0
- package/dist/encryption/kms.d.mts.map +1 -0
- package/dist/encryption/kms.mjs +93 -0
- package/dist/encryption/kms.mjs.map +1 -0
- package/dist/encryption.cjs +116 -0
- package/dist/encryption.cjs.map +1 -0
- package/dist/encryption.d.cts +37 -0
- package/dist/encryption.d.cts.map +1 -0
- package/dist/encryption.d.mts +37 -0
- package/dist/encryption.d.mts.map +1 -0
- package/dist/encryption.mjs +101 -0
- package/dist/encryption.mjs.map +1 -0
- package/dist/endpoints/index.cjs +25 -10
- package/dist/endpoints/index.d.cts +105 -3
- package/dist/endpoints/index.d.cts.map +1 -0
- package/dist/endpoints/index.d.mts +105 -3
- package/dist/endpoints/index.d.mts.map +1 -0
- package/dist/endpoints/index.mjs +5 -4
- package/dist/expire-C586zznE.d.cts +38 -0
- package/dist/expire-C586zznE.d.cts.map +1 -0
- package/dist/expire-C586zznE.d.mts +38 -0
- package/dist/expire-C586zznE.d.mts.map +1 -0
- package/dist/expire-CieftS01.cjs +67 -0
- package/dist/expire-CieftS01.cjs.map +1 -0
- package/dist/expire-CpzUAfr9.mjs +50 -0
- package/dist/expire-CpzUAfr9.mjs.map +1 -0
- package/dist/external-api.cjs +106 -0
- package/dist/external-api.cjs.map +1 -0
- package/dist/external-api.d.cts +2 -0
- package/dist/external-api.d.mts +2 -0
- package/dist/external-api.mjs +103 -0
- package/dist/external-api.mjs.map +1 -0
- package/dist/fake-BUgcX2Dk.d.cts +201 -0
- package/dist/fake-BUgcX2Dk.d.cts.map +1 -0
- package/dist/fake-D472nkKb.d.mts +201 -0
- package/dist/fake-D472nkKb.d.mts.map +1 -0
- package/dist/file-server.cjs +123 -30
- package/dist/file-server.cjs.map +1 -1
- package/dist/file-server.d.cts +115 -1
- package/dist/file-server.d.cts.map +1 -1
- package/dist/file-server.d.mts +115 -1
- package/dist/file-server.d.mts.map +1 -1
- package/dist/file-server.mjs +122 -32
- package/dist/file-server.mjs.map +1 -1
- package/dist/functions/index.cjs +1 -1
- package/dist/functions/index.d.cts +2 -1
- package/dist/functions/index.d.mts +2 -1
- package/dist/functions/index.mjs +1 -1
- package/dist/{functions-C53GW2eQ.mjs → functions-BvIDQKAA.mjs} +117 -22
- package/dist/functions-BvIDQKAA.mjs.map +1 -0
- package/dist/{functions-B6qCvfmy.cjs → functions-DLF6-IK8.cjs} +122 -18
- package/dist/functions-DLF6-IK8.cjs.map +1 -0
- package/dist/index-BtzMzhMA.d.cts +115 -0
- package/dist/index-BtzMzhMA.d.cts.map +1 -0
- package/dist/{index-CeEtxDmK.d.cts → index-DdRjYhiJ.d.cts} +42 -2
- package/dist/{index-CeEtxDmK.d.cts.map → index-DdRjYhiJ.d.cts.map} +1 -1
- package/dist/{index-CeEtxDmK.d.mts → index-DdRjYhiJ.d.mts} +42 -2
- package/dist/{index-CeEtxDmK.d.mts.map → index-DdRjYhiJ.d.mts.map} +1 -1
- package/dist/index-DuriFjYD.d.mts +115 -0
- package/dist/index-DuriFjYD.d.mts.map +1 -0
- package/dist/index.cjs +4 -1
- package/dist/index.d.cts +26 -3
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +26 -3
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +3 -2
- package/dist/kysely-BHYV-WC-.d.cts +216 -0
- package/dist/kysely-BHYV-WC-.d.cts.map +1 -0
- package/dist/kysely-CAW3QSqp.d.mts +216 -0
- package/dist/kysely-CAW3QSqp.d.mts.map +1 -0
- package/dist/kysely-Cs4uPO8k.mjs +371 -0
- package/dist/kysely-Cs4uPO8k.mjs.map +1 -0
- package/dist/kysely-CukArHJ0.cjs +384 -0
- package/dist/kysely-CukArHJ0.cjs.map +1 -0
- package/dist/{telemetry-DGcFlVpB.d.cts → lambdaTelemetry-8vnmVZQ5.d.cts} +2 -2
- package/dist/lambdaTelemetry-8vnmVZQ5.d.cts.map +1 -0
- package/dist/{telemetry-DGcFlVpB.d.mts → lambdaTelemetry-8vnmVZQ5.d.mts} +2 -2
- package/dist/lambdaTelemetry-8vnmVZQ5.d.mts.map +1 -0
- package/dist/mobile-app.cjs +74 -0
- package/dist/mobile-app.cjs.map +1 -0
- package/dist/mobile-app.d.cts +73 -0
- package/dist/mobile-app.d.cts.map +1 -0
- package/dist/mobile-app.d.mts +73 -0
- package/dist/mobile-app.d.mts.map +1 -0
- package/dist/mobile-app.mjs +73 -0
- package/dist/mobile-app.mjs.map +1 -0
- package/dist/object-storage.cjs +8 -1
- package/dist/object-storage.cjs.map +1 -1
- package/dist/object-storage.d.cts +10 -1
- package/dist/object-storage.d.cts.map +1 -1
- package/dist/object-storage.d.mts +10 -1
- package/dist/object-storage.d.mts.map +1 -1
- package/dist/object-storage.mjs +7 -2
- package/dist/object-storage.mjs.map +1 -1
- package/dist/pattern-C1CEcglD.mjs +241 -0
- package/dist/pattern-C1CEcglD.mjs.map +1 -0
- package/dist/pattern-QFaUIr77.cjs +288 -0
- package/dist/pattern-QFaUIr77.cjs.map +1 -0
- package/dist/processors/index.cjs +214 -0
- package/dist/processors/index.cjs.map +1 -0
- package/dist/processors/index.d.cts +78 -0
- package/dist/processors/index.d.cts.map +1 -0
- package/dist/processors/index.d.mts +78 -0
- package/dist/processors/index.d.mts.map +1 -0
- package/dist/processors/index.mjs +193 -0
- package/dist/processors/index.mjs.map +1 -0
- package/dist/queue/index.cjs +5 -192
- package/dist/queue/index.d.cts +3 -53
- package/dist/queue/index.d.mts +3 -53
- package/dist/queue/index.mjs +3 -190
- package/dist/random-password.cjs +86 -0
- package/dist/random-password.cjs.map +1 -0
- package/dist/random-password.d.cts +30 -0
- package/dist/random-password.d.cts.map +1 -0
- package/dist/random-password.d.mts +30 -0
- package/dist/random-password.d.mts.map +1 -0
- package/dist/random-password.mjs +84 -0
- package/dist/random-password.mjs.map +1 -0
- package/dist/{lazyAccessors-BHtcqgz2.mjs → readRequestBody-BTIl3k-D.mjs} +99 -39
- package/dist/readRequestBody-BTIl3k-D.mjs.map +1 -0
- package/dist/{lazyAccessors-Dx9NLwJZ.cjs → readRequestBody-Dej_L3c4.cjs} +118 -46
- package/dist/readRequestBody-Dej_L3c4.cjs.map +1 -0
- package/dist/requestLogger-BZcXwdBs.cjs +207 -0
- package/dist/requestLogger-BZcXwdBs.cjs.map +1 -0
- package/dist/requestLogger-pA4gi3E1.mjs +178 -0
- package/dist/requestLogger-pA4gi3E1.mjs.map +1 -0
- package/dist/rest-api.cjs +76 -43
- package/dist/rest-api.cjs.map +1 -1
- package/dist/rest-api.d.cts +64 -31
- package/dist/rest-api.d.cts.map +1 -1
- package/dist/rest-api.d.mts +64 -31
- package/dist/rest-api.d.mts.map +1 -1
- package/dist/rest-api.mjs +76 -43
- package/dist/rest-api.mjs.map +1 -1
- package/dist/runSubscriber-B1Yg4dID.cjs +128 -0
- package/dist/runSubscriber-B1Yg4dID.cjs.map +1 -0
- package/dist/runSubscriber-JCgkeYbE.mjs +111 -0
- package/dist/runSubscriber-JCgkeYbE.mjs.map +1 -0
- package/dist/shutdown-BMJmAhSt.cjs +38 -0
- package/dist/shutdown-BMJmAhSt.cjs.map +1 -0
- package/dist/shutdown-C7xa8x9S.mjs +27 -0
- package/dist/shutdown-C7xa8x9S.mjs.map +1 -0
- package/dist/site.cjs +9 -3
- package/dist/site.cjs.map +1 -1
- package/dist/site.d.cts +44 -1
- package/dist/site.d.cts.map +1 -1
- package/dist/site.d.mts +44 -1
- package/dist/site.d.mts.map +1 -1
- package/dist/site.mjs +9 -3
- package/dist/site.mjs.map +1 -1
- package/dist/stages-DaTaoQei.d.cts +73 -0
- package/dist/stages-DaTaoQei.d.cts.map +1 -0
- package/dist/stages-DaTaoQei.d.mts +73 -0
- package/dist/stages-DaTaoQei.d.mts.map +1 -0
- package/dist/subscribers/index.cjs +134 -1
- package/dist/subscribers/index.cjs.map +1 -0
- package/dist/subscribers/index.d.cts +74 -3
- package/dist/subscribers/index.d.cts.map +1 -0
- package/dist/subscribers/index.d.mts +74 -3
- package/dist/subscribers/index.d.mts.map +1 -0
- package/dist/subscribers/index.mjs +132 -2
- package/dist/subscribers/index.mjs.map +1 -0
- package/dist/telemetry-B48RLjyk.d.cts +40 -0
- package/dist/telemetry-B48RLjyk.d.cts.map +1 -0
- package/dist/telemetry-BEoBn6GO.d.mts +40 -0
- package/dist/telemetry-BEoBn6GO.d.mts.map +1 -0
- package/dist/telemetry.cjs +56 -0
- package/dist/telemetry.cjs.map +1 -0
- package/dist/telemetry.d.cts +2 -0
- package/dist/telemetry.d.mts +2 -0
- package/dist/telemetry.mjs +55 -0
- package/dist/telemetry.mjs.map +1 -0
- package/dist/topic/index.cjs +2 -134
- package/dist/topic/index.d.cts +2 -3
- package/dist/topic/index.d.mts +2 -3
- package/dist/topic/index.mjs +2 -132
- package/dist/tracing-Bbj1uoFJ.mjs +127 -0
- package/dist/tracing-Bbj1uoFJ.mjs.map +1 -0
- package/dist/tracing-C0ooU0V2.cjs +150 -0
- package/dist/tracing-C0ooU0V2.cjs.map +1 -0
- package/dist/websocket-api.cjs +769 -0
- package/dist/websocket-api.cjs.map +1 -0
- package/dist/websocket-api.d.cts +449 -0
- package/dist/websocket-api.d.cts.map +1 -0
- package/dist/websocket-api.d.mts +449 -0
- package/dist/websocket-api.d.mts.map +1 -0
- package/dist/websocket-api.mjs +755 -0
- package/dist/websocket-api.mjs.map +1 -0
- package/dist/worker.cjs +70 -23
- package/dist/worker.cjs.map +1 -1
- package/dist/worker.d.cts +86 -36
- package/dist/worker.d.cts.map +1 -1
- package/dist/worker.d.mts +87 -37
- package/dist/worker.d.mts.map +1 -1
- package/dist/worker.mjs +70 -23
- package/dist/worker.mjs.map +1 -1
- package/package.json +145 -44
- package/dist/Construct-BeYVu_QF.mjs.map +0 -1
- package/dist/Construct-DfbwIntp.d.cts +0 -115
- package/dist/Construct-DfbwIntp.d.cts.map +0 -1
- package/dist/Construct-DqdlARxq.cjs.map +0 -1
- package/dist/Construct-l5aOn_jv.d.mts +0 -115
- package/dist/Construct-l5aOn_jv.d.mts.map +0 -1
- package/dist/Cron-DKqnnTdH.d.cts.map +0 -1
- package/dist/Cron-SyqS5oWJ.d.mts.map +0 -1
- package/dist/CronBuilder-BdnI6lxF.cjs.map +0 -1
- package/dist/CronBuilder-CRGnDfTq.d.mts +0 -41
- package/dist/CronBuilder-CRGnDfTq.d.mts.map +0 -1
- package/dist/CronBuilder-D_0HNBTr.mjs.map +0 -1
- package/dist/CronBuilder-Df1q9PNy.d.cts +0 -41
- package/dist/CronBuilder-Df1q9PNy.d.cts.map +0 -1
- package/dist/Endpoint-BCiCYvx2.mjs +0 -1665
- package/dist/Endpoint-BCiCYvx2.mjs.map +0 -1
- package/dist/Endpoint-C6yyHpRS.d.cts.map +0 -1
- package/dist/Endpoint-DuT4TEEq.d.mts.map +0 -1
- package/dist/Endpoint-s0AyrQGC.cjs +0 -1683
- package/dist/Endpoint-s0AyrQGC.cjs.map +0 -1
- package/dist/EndpointFactory-M8OQKZRY.cjs.map +0 -1
- package/dist/EndpointFactory-ptPR1cXw.mjs.map +0 -1
- package/dist/HonoEndpointAdaptor-7QagYKdP.cjs.map +0 -1
- package/dist/HonoEndpointAdaptor-CYHA0WAt.mjs.map +0 -1
- package/dist/Queue-D9X6OoON.d.mts.map +0 -1
- package/dist/Queue-DYPB2KWL.d.cts.map +0 -1
- package/dist/Subscriber-C4heaAyO.d.mts +0 -51
- package/dist/Subscriber-C4heaAyO.d.mts.map +0 -1
- package/dist/Subscriber-CotDUELC.d.cts +0 -51
- package/dist/Subscriber-CotDUELC.d.cts.map +0 -1
- package/dist/SubscriberBuilder-BEv0eoHy.d.cts +0 -59
- package/dist/SubscriberBuilder-BEv0eoHy.d.cts.map +0 -1
- package/dist/SubscriberBuilder-C0ZEtGDI.cjs +0 -125
- package/dist/SubscriberBuilder-C0ZEtGDI.cjs.map +0 -1
- package/dist/SubscriberBuilder-h7B_cHMr.mjs +0 -114
- package/dist/SubscriberBuilder-h7B_cHMr.mjs.map +0 -1
- package/dist/SubscriberBuilder-tyH5yTk5.d.mts +0 -59
- package/dist/SubscriberBuilder-tyH5yTk5.d.mts.map +0 -1
- package/dist/Topic-DEVGo0Dm.d.cts +0 -89
- package/dist/Topic-DEVGo0Dm.d.cts.map +0 -1
- package/dist/Topic-zk_6Gthr.d.mts +0 -89
- package/dist/Topic-zk_6Gthr.d.mts.map +0 -1
- package/dist/auth.d.cts.map +0 -1
- package/dist/auth.d.mts.map +0 -1
- package/dist/cache.d.cts.map +0 -1
- package/dist/cache.d.mts.map +0 -1
- package/dist/construct-interface-DPlxfpoS.d.mts.map +0 -1
- package/dist/construct-interface-DgXTJcOD.d.cts.map +0 -1
- package/dist/credential.cjs.map +0 -1
- package/dist/credential.d.cts.map +0 -1
- package/dist/credential.d.mts.map +0 -1
- package/dist/credential.mjs.map +0 -1
- package/dist/database/kysely.cjs.map +0 -1
- package/dist/database/kysely.d.cts.map +0 -1
- package/dist/database/kysely.d.mts.map +0 -1
- package/dist/database/kysely.mjs.map +0 -1
- package/dist/functions-B6qCvfmy.cjs.map +0 -1
- package/dist/functions-C53GW2eQ.mjs.map +0 -1
- package/dist/index-B2urf3YI.d.cts +0 -26
- package/dist/index-B2urf3YI.d.cts.map +0 -1
- package/dist/index-BPSZ_Lp_.d.cts.map +0 -1
- package/dist/index-BoZ-iisU.d.mts.map +0 -1
- package/dist/index-CdaU--_B.d.cts +0 -165
- package/dist/index-CdaU--_B.d.cts.map +0 -1
- package/dist/index-DMCDvnsM.d.mts +0 -26
- package/dist/index-DMCDvnsM.d.mts.map +0 -1
- package/dist/index-PQRWOQj4.d.mts +0 -165
- package/dist/index-PQRWOQj4.d.mts.map +0 -1
- package/dist/lazyAccessors-BHtcqgz2.mjs.map +0 -1
- package/dist/lazyAccessors-Dx9NLwJZ.cjs.map +0 -1
- package/dist/processAudits-BpRlPQMW.mjs +0 -77
- package/dist/processAudits-BpRlPQMW.mjs.map +0 -1
- package/dist/processAudits-D_2W5x8k.cjs +0 -88
- package/dist/processAudits-D_2W5x8k.cjs.map +0 -1
- package/dist/queue/index.cjs.map +0 -1
- package/dist/queue/index.d.cts.map +0 -1
- package/dist/queue/index.d.mts.map +0 -1
- package/dist/queue/index.mjs.map +0 -1
- package/dist/telemetry-DGcFlVpB.d.cts.map +0 -1
- package/dist/telemetry-DGcFlVpB.d.mts.map +0 -1
- package/dist/topic/index.cjs.map +0 -1
- package/dist/topic/index.mjs.map +0 -1
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { ServiceDiscovery } from "@geekmidas/services";
|
|
2
|
+
//#region src/subscribers/runSubscriber.ts
|
|
3
|
+
/** The subscriber's output did not match its `.output()` schema. */
|
|
4
|
+
var SubscriberOutputInvalid = class extends Error {
|
|
5
|
+
issues;
|
|
6
|
+
constructor(issues) {
|
|
7
|
+
super("Subscriber output validation failed: the handler's result does not match its .output() schema.");
|
|
8
|
+
this.issues = issues;
|
|
9
|
+
this.name = "SubscriberOutputInvalid";
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
/** The events in an SQS or SNS batch (a Lambda event's `Records`) that `subscriber` subscribed to. */
|
|
13
|
+
async function subscribedEvents(subscriber, rawEvent, logger) {
|
|
14
|
+
const events = [];
|
|
15
|
+
const records = rawEvent.Records ?? [];
|
|
16
|
+
const first = records[0];
|
|
17
|
+
const parse = first?.eventSource === "aws:sqs" ? (record) => parseSQSRecord(record) : first?.EventSource === "aws:sns" ? (record) => parseSNSRecord(record) : void 0;
|
|
18
|
+
if (!parse) return events;
|
|
19
|
+
const toObjectEvents = subscriber.bucketName ? (await import("@geekmidas/storage/events")).toObjectEvents : void 0;
|
|
20
|
+
for (const record of records) try {
|
|
21
|
+
const event = parse(record);
|
|
22
|
+
const parsed = toObjectEvents && !(typeof event === "object" && event?.type) ? toObjectEvents(event) : [event];
|
|
23
|
+
for (const one of parsed) if (isSubscribed(subscriber, one)) events.push(one);
|
|
24
|
+
} catch (error) {
|
|
25
|
+
logger.error({
|
|
26
|
+
err: error,
|
|
27
|
+
record
|
|
28
|
+
}, "Failed to parse record");
|
|
29
|
+
}
|
|
30
|
+
return events;
|
|
31
|
+
}
|
|
32
|
+
/** The subscriber's services and database, registered as functions do. */
|
|
33
|
+
async function subscriberContext(subscriber, envParser) {
|
|
34
|
+
const discovery = ServiceDiscovery.getInstance(envParser);
|
|
35
|
+
const services = subscriber.services.length > 0 ? await discovery.register(subscriber.services) : {};
|
|
36
|
+
const service = subscriber.databaseService;
|
|
37
|
+
return {
|
|
38
|
+
services,
|
|
39
|
+
db: service ? (await discovery.register([service]))[service.serviceName] : void 0
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/** Runs the handler on `events`, and checks its output against its schema. */
|
|
43
|
+
async function runSubscriber(subscriber, context) {
|
|
44
|
+
if (context.events.length === 0) {
|
|
45
|
+
context.logger.info("No subscribed events to process");
|
|
46
|
+
return { batchItemFailures: [] };
|
|
47
|
+
}
|
|
48
|
+
const { events, services, db, logger } = context;
|
|
49
|
+
const result = await subscriber.handler({
|
|
50
|
+
events,
|
|
51
|
+
services,
|
|
52
|
+
logger,
|
|
53
|
+
db
|
|
54
|
+
});
|
|
55
|
+
if (subscriber.outputSchema && result) {
|
|
56
|
+
const validation = await subscriber.outputSchema["~standard"].validate(result);
|
|
57
|
+
if (validation.issues) {
|
|
58
|
+
context.logger.error({ issues: validation.issues }, "Subscriber output validation failed");
|
|
59
|
+
throw new SubscriberOutputInvalid(validation.issues);
|
|
60
|
+
}
|
|
61
|
+
return validation.value;
|
|
62
|
+
}
|
|
63
|
+
return result;
|
|
64
|
+
}
|
|
65
|
+
function isSubscribed(subscriber, event) {
|
|
66
|
+
if (typeof event !== "object" || !event?.type) return true;
|
|
67
|
+
if (!subscriber.subscribedEvents) return true;
|
|
68
|
+
return subscriber.subscribedEvents.includes(event.type);
|
|
69
|
+
}
|
|
70
|
+
function parseSNSRecord(record) {
|
|
71
|
+
const message = safeJsonParse(record.Sns.Message);
|
|
72
|
+
const messageType = record.Sns.MessageAttributes?.type?.Value;
|
|
73
|
+
if (message === null) return messageType ? {
|
|
74
|
+
type: messageType,
|
|
75
|
+
payload: record.Sns.Message
|
|
76
|
+
} : record.Sns.Message;
|
|
77
|
+
if (message.type) return message;
|
|
78
|
+
return messageType ? {
|
|
79
|
+
type: messageType,
|
|
80
|
+
payload: message
|
|
81
|
+
} : message;
|
|
82
|
+
}
|
|
83
|
+
function parseSQSRecord(record) {
|
|
84
|
+
const body = safeJsonParse(record.body);
|
|
85
|
+
if (body === null) return record.body;
|
|
86
|
+
if (body.Type === "Notification" && body.Message) {
|
|
87
|
+
const snsMessage = safeJsonParse(body.Message);
|
|
88
|
+
const messageType = body.MessageAttributes?.type?.Value;
|
|
89
|
+
if (snsMessage === null) return messageType ? {
|
|
90
|
+
type: messageType,
|
|
91
|
+
payload: body.Message
|
|
92
|
+
} : body.Message;
|
|
93
|
+
if (snsMessage.type) return snsMessage;
|
|
94
|
+
return messageType ? {
|
|
95
|
+
type: messageType,
|
|
96
|
+
payload: snsMessage
|
|
97
|
+
} : snsMessage;
|
|
98
|
+
}
|
|
99
|
+
return body;
|
|
100
|
+
}
|
|
101
|
+
function safeJsonParse(value) {
|
|
102
|
+
try {
|
|
103
|
+
return JSON.parse(value);
|
|
104
|
+
} catch {
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
//#endregion
|
|
109
|
+
export { subscribedEvents as n, subscriberContext as r, runSubscriber as t };
|
|
110
|
+
|
|
111
|
+
//# sourceMappingURL=runSubscriber-JCgkeYbE.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runSubscriber-JCgkeYbE.mjs","names":[],"sources":["../src/subscribers/runSubscriber.ts"],"sourcesContent":["/**\n * What a subscriber does with a batch of records, however they arrived: parse\n * them into events, keep the ones it subscribed to, and run its handler with\n * its services and database.\n *\n * Shared by the Lambda adaptor, which wraps it in middy, and the SNS push\n * adaptor, which a server runs and which must not need middy to load.\n */\n\nimport type { EnvironmentParser } from '@geekmidas/envkit';\nimport type { Logger } from '@geekmidas/logger';\nimport { ServiceDiscovery } from '@geekmidas/services';\nimport type { SNSEvent, SNSEventRecord, SQSEvent, SQSRecord } from 'aws-lambda';\nimport type { Subscriber } from './Subscriber';\n\ntype AnySubscriber = Subscriber<any, any, any, any, any, any, any>;\n\n/** The subscriber's output did not match its `.output()` schema. */\nexport class SubscriberOutputInvalid extends Error {\n\tconstructor(readonly issues: ReadonlyArray<unknown>) {\n\t\tsuper(\n\t\t\t\"Subscriber output validation failed: the handler's result does not match its .output() schema.\",\n\t\t);\n\t\tthis.name = 'SubscriberOutputInvalid';\n\t}\n}\n\n/** The events in an SQS or SNS batch (a Lambda event's `Records`) that `subscriber` subscribed to. */\nexport async function subscribedEvents(\n\tsubscriber: AnySubscriber,\n\trawEvent: { Records?: readonly unknown[] },\n\tlogger: Logger,\n): Promise<any[]> {\n\tconst events: any[] = [];\n\tconst records = rawEvent.Records ?? [];\n\tconst first = records[0] as any;\n\tconst parse =\n\t\tfirst?.eventSource === 'aws:sqs'\n\t\t\t? (record: any) => parseSQSRecord(record)\n\t\t\t: first?.EventSource === 'aws:sns'\n\t\t\t\t? (record: any) => parseSNSRecord(record)\n\t\t\t\t: undefined;\n\tif (!parse) return events;\n\n\t// A bucket's subscriber is sent what the storage sends — a notification\n\t// of records — and reads it as object events. Loaded only then: an app\n\t// with no bucket never installs the storage package.\n\tconst toObjectEvents = subscriber.bucketName\n\t\t? (await import('@geekmidas/storage/events')).toObjectEvents\n\t\t: undefined;\n\n\tfor (const record of records) {\n\t\ttry {\n\t\t\tconst event = parse(record);\n\t\t\tconst parsed =\n\t\t\t\ttoObjectEvents && !(typeof event === 'object' && event?.type)\n\t\t\t\t\t? toObjectEvents(event)\n\t\t\t\t\t: [event];\n\t\t\tfor (const one of parsed) {\n\t\t\t\tif (isSubscribed(subscriber, one)) events.push(one);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tlogger.error({ err: error, record }, 'Failed to parse record');\n\t\t}\n\t}\n\treturn events;\n}\n\n/** The subscriber's services and database, registered as functions do. */\nexport async function subscriberContext(\n\tsubscriber: AnySubscriber,\n\tenvParser: EnvironmentParser<{}>,\n): Promise<{ services: Record<string, unknown>; db: unknown }> {\n\tconst discovery = ServiceDiscovery.getInstance(envParser);\n\tconst services =\n\t\tsubscriber.services.length > 0\n\t\t\t? await discovery.register(subscriber.services)\n\t\t\t: {};\n\tconst service = subscriber.databaseService;\n\tconst db = service\n\t\t? (await discovery.register([service]))[service.serviceName]\n\t\t: undefined;\n\treturn { services, db };\n}\n\n/** Runs the handler on `events`, and checks its output against its schema. */\nexport async function runSubscriber(\n\tsubscriber: AnySubscriber,\n\tcontext: {\n\t\tevents: any[];\n\t\tservices: Record<string, unknown>;\n\t\tdb: unknown;\n\t\tlogger: Logger;\n\t},\n): Promise<unknown> {\n\tif (context.events.length === 0) {\n\t\tcontext.logger.info('No subscribed events to process');\n\t\treturn { batchItemFailures: [] };\n\t}\n\n\tconst { events, services, db, logger } = context;\n\tconst result = await subscriber.handler({\n\t\tevents,\n\t\tservices,\n\t\tlogger,\n\t\tdb,\n\t} as any);\n\n\tif (subscriber.outputSchema && result) {\n\t\tconst validation =\n\t\t\tawait subscriber.outputSchema['~standard'].validate(result);\n\t\tif (validation.issues) {\n\t\t\tcontext.logger.error(\n\t\t\t\t{ issues: validation.issues },\n\t\t\t\t'Subscriber output validation failed',\n\t\t\t);\n\t\t\tthrow new SubscriberOutputInvalid(validation.issues);\n\t\t}\n\t\treturn validation.value;\n\t}\n\n\treturn result;\n}\n\nfunction isSubscribed(subscriber: AnySubscriber, event: any): boolean {\n\t// No event type (raw string/non-object) — always include\n\tif (typeof event !== 'object' || !event?.type) return true;\n\t// No filter configured — accept all\n\tif (!subscriber.subscribedEvents) return true;\n\treturn subscriber.subscribedEvents.includes(event.type);\n}\n\nfunction parseSNSRecord(record: SNSEventRecord): any {\n\tconst message = safeJsonParse(record.Sns.Message);\n\tconst messageType = record.Sns.MessageAttributes?.type?.Value;\n\n\t// Not JSON — wrap raw string with type from MessageAttributes if available\n\tif (message === null) {\n\t\treturn messageType\n\t\t\t? { type: messageType, payload: record.Sns.Message }\n\t\t\t: record.Sns.Message;\n\t}\n\n\tif (message.type) {\n\t\treturn message; // Full event format: { type, payload }\n\t}\n\n\t// Payload-only format: type is in MessageAttributes\n\treturn messageType ? { type: messageType, payload: message } : message;\n}\n\nfunction parseSQSRecord(record: SQSRecord): any {\n\tconst body = safeJsonParse(record.body);\n\n\t// Not JSON — return raw body as-is\n\tif (body === null) {\n\t\treturn record.body;\n\t}\n\n\t// Check if this is an SNS message wrapped in SQS\n\tif (body.Type === 'Notification' && body.Message) {\n\t\tconst snsMessage = safeJsonParse(body.Message);\n\t\tconst messageType = body.MessageAttributes?.type?.Value;\n\n\t\t// SNS Message not JSON — wrap with type from MessageAttributes if available\n\t\tif (snsMessage === null) {\n\t\t\treturn messageType\n\t\t\t\t? { type: messageType, payload: body.Message }\n\t\t\t\t: body.Message;\n\t\t}\n\n\t\tif (snsMessage.type) {\n\t\t\treturn snsMessage; // Full event format: { type, payload }\n\t\t}\n\n\t\t// Payload-only format: type is in MessageAttributes\n\t\treturn messageType\n\t\t\t? { type: messageType, payload: snsMessage }\n\t\t\t: snsMessage;\n\t}\n\n\t// Direct SQS message\n\treturn body;\n}\n\nfunction safeJsonParse(value: string): any | null {\n\ttry {\n\t\treturn JSON.parse(value);\n\t} catch {\n\t\treturn null;\n\t}\n}\n"],"mappings":";;;AAkBA,IAAa,0BAAb,cAA6C,MAAM;CAC7B;CAArB,YAAY,QAAyC;EACpD,MACC,gGACD;EAHoB,KAAA,SAAA;EAIpB,KAAK,OAAO;CACb;AACD;;AAGA,eAAsB,iBACrB,YACA,UACA,QACiB;CACjB,MAAM,SAAgB,CAAC;CACvB,MAAM,UAAU,SAAS,WAAW,CAAC;CACrC,MAAM,QAAQ,QAAQ;CACtB,MAAM,QACL,OAAO,gBAAgB,aACnB,WAAgB,eAAe,MAAM,IACtC,OAAO,gBAAgB,aACrB,WAAgB,eAAe,MAAM,IACtC,KAAA;CACL,IAAI,CAAC,OAAO,OAAO;CAKnB,MAAM,iBAAiB,WAAW,cAC9B,MAAM,OAAO,6BAAA,CAA8B,iBAC5C,KAAA;CAEH,KAAK,MAAM,UAAU,SACpB,IAAI;EACH,MAAM,QAAQ,MAAM,MAAM;EAC1B,MAAM,SACL,kBAAkB,EAAE,OAAO,UAAU,YAAY,OAAO,QACrD,eAAe,KAAK,IACpB,CAAC,KAAK;EACV,KAAK,MAAM,OAAO,QACjB,IAAI,aAAa,YAAY,GAAG,GAAG,OAAO,KAAK,GAAG;CAEpD,SAAS,OAAO;EACf,OAAO,MAAM;GAAE,KAAK;GAAO;EAAO,GAAG,wBAAwB;CAC9D;CAED,OAAO;AACR;;AAGA,eAAsB,kBACrB,YACA,WAC8D;CAC9D,MAAM,YAAY,iBAAiB,YAAY,SAAS;CACxD,MAAM,WACL,WAAW,SAAS,SAAS,IAC1B,MAAM,UAAU,SAAS,WAAW,QAAQ,IAC5C,CAAC;CACL,MAAM,UAAU,WAAW;CAI3B,OAAO;EAAE;EAAU,IAHR,WACP,MAAM,UAAU,SAAS,CAAC,OAAO,CAAC,EAAA,CAAG,QAAQ,eAC9C,KAAA;CACmB;AACvB;;AAGA,eAAsB,cACrB,YACA,SAMmB;CACnB,IAAI,QAAQ,OAAO,WAAW,GAAG;EAChC,QAAQ,OAAO,KAAK,iCAAiC;EACrD,OAAO,EAAE,mBAAmB,CAAC,EAAE;CAChC;CAEA,MAAM,EAAE,QAAQ,UAAU,IAAI,WAAW;CACzC,MAAM,SAAS,MAAM,WAAW,QAAQ;EACvC;EACA;EACA;EACA;CACD,CAAQ;CAER,IAAI,WAAW,gBAAgB,QAAQ;EACtC,MAAM,aACL,MAAM,WAAW,aAAa,YAAY,CAAC,SAAS,MAAM;EAC3D,IAAI,WAAW,QAAQ;GACtB,QAAQ,OAAO,MACd,EAAE,QAAQ,WAAW,OAAO,GAC5B,qCACD;GACA,MAAM,IAAI,wBAAwB,WAAW,MAAM;EACpD;EACA,OAAO,WAAW;CACnB;CAEA,OAAO;AACR;AAEA,SAAS,aAAa,YAA2B,OAAqB;CAErE,IAAI,OAAO,UAAU,YAAY,CAAC,OAAO,MAAM,OAAO;CAEtD,IAAI,CAAC,WAAW,kBAAkB,OAAO;CACzC,OAAO,WAAW,iBAAiB,SAAS,MAAM,IAAI;AACvD;AAEA,SAAS,eAAe,QAA6B;CACpD,MAAM,UAAU,cAAc,OAAO,IAAI,OAAO;CAChD,MAAM,cAAc,OAAO,IAAI,mBAAmB,MAAM;CAGxD,IAAI,YAAY,MACf,OAAO,cACJ;EAAE,MAAM;EAAa,SAAS,OAAO,IAAI;CAAQ,IACjD,OAAO,IAAI;CAGf,IAAI,QAAQ,MACX,OAAO;CAIR,OAAO,cAAc;EAAE,MAAM;EAAa,SAAS;CAAQ,IAAI;AAChE;AAEA,SAAS,eAAe,QAAwB;CAC/C,MAAM,OAAO,cAAc,OAAO,IAAI;CAGtC,IAAI,SAAS,MACZ,OAAO,OAAO;CAIf,IAAI,KAAK,SAAS,kBAAkB,KAAK,SAAS;EACjD,MAAM,aAAa,cAAc,KAAK,OAAO;EAC7C,MAAM,cAAc,KAAK,mBAAmB,MAAM;EAGlD,IAAI,eAAe,MAClB,OAAO,cACJ;GAAE,MAAM;GAAa,SAAS,KAAK;EAAQ,IAC3C,KAAK;EAGT,IAAI,WAAW,MACd,OAAO;EAIR,OAAO,cACJ;GAAE,MAAM;GAAa,SAAS;EAAW,IACzC;CACJ;CAGA,OAAO;AACR;AAEA,SAAS,cAAc,OAA2B;CACjD,IAAI;EACH,OAAO,KAAK,MAAM,KAAK;CACxB,QAAQ;EACP,OAAO;CACR;AACD"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
//#region src/shutdown.ts
|
|
2
|
+
const key = Symbol.for("@geekmidas/constructs/shutdown");
|
|
3
|
+
const registry = globalThis;
|
|
4
|
+
registry[key] ??= /* @__PURE__ */ new Set();
|
|
5
|
+
const hooks = registry[key];
|
|
6
|
+
/** Run `hook` when the server shuts down. Returns a function that removes it. */
|
|
7
|
+
function onShutdown(hook) {
|
|
8
|
+
hooks.add(hook);
|
|
9
|
+
return () => hooks.delete(hook);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Run every registered hook, together, and wait for them. A hook that fails is
|
|
13
|
+
* reported to `onError` and does not stop the others.
|
|
14
|
+
*/
|
|
15
|
+
async function runShutdownHooks(onError = () => {}) {
|
|
16
|
+
await Promise.all([...hooks].map(async (hook) => {
|
|
17
|
+
try {
|
|
18
|
+
await hook();
|
|
19
|
+
} catch (error) {
|
|
20
|
+
onError(error);
|
|
21
|
+
}
|
|
22
|
+
}));
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
Object.defineProperty(exports, "onShutdown", {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function() {
|
|
28
|
+
return onShutdown;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
Object.defineProperty(exports, "runShutdownHooks", {
|
|
32
|
+
enumerable: true,
|
|
33
|
+
get: function() {
|
|
34
|
+
return runShutdownHooks;
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
//# sourceMappingURL=shutdown-BMJmAhSt.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shutdown-BMJmAhSt.cjs","names":[],"sources":["../src/shutdown.ts"],"sourcesContent":["/**\n * What a server releases when it stops: the connections constructs opened.\n *\n * A construct that holds something open — a database's pool — registers how to\n * close it here, and the generated server runs every hook once it has stopped\n * taking requests. Without that, a rolling deploy has the old task and the new\n * one both holding connections until the old process dies.\n *\n * Kept free of any driver import so the server entry can always import it,\n * whether or not the app has a database.\n */\n\ntype ShutdownHook = () => Promise<void> | void;\n\n// On globalThis, as Credentials are: a package loaded twice (ESM and CJS)\n// would otherwise keep two registries, and the server would run the empty one.\nconst key = Symbol.for('@geekmidas/constructs/shutdown');\nconst registry = globalThis as Record<symbol, Set<ShutdownHook> | undefined>;\nregistry[key] ??= new Set<ShutdownHook>();\nconst hooks = registry[key];\n\n/** Run `hook` when the server shuts down. Returns a function that removes it. */\nexport function onShutdown(hook: ShutdownHook): () => void {\n\thooks.add(hook);\n\treturn () => hooks.delete(hook);\n}\n\n/**\n * Run every registered hook, together, and wait for them. A hook that fails is\n * reported to `onError` and does not stop the others.\n */\nexport async function runShutdownHooks(\n\tonError: (error: unknown) => void = () => {},\n): Promise<void> {\n\tawait Promise.all(\n\t\t[...hooks].map(async (hook) => {\n\t\t\ttry {\n\t\t\t\tawait hook();\n\t\t\t} catch (error) {\n\t\t\t\tonError(error);\n\t\t\t}\n\t\t}),\n\t);\n}\n"],"mappings":";AAgBA,MAAM,MAAM,OAAO,IAAI,gCAAgC;AACvD,MAAM,WAAW;AACjB,SAAS,yBAAS,IAAI,IAAkB;AACxC,MAAM,QAAQ,SAAS;;AAGvB,SAAgB,WAAW,MAAgC;CAC1D,MAAM,IAAI,IAAI;CACd,aAAa,MAAM,OAAO,IAAI;AAC/B;;;;;AAMA,eAAsB,iBACrB,gBAA0C,CAAC,GAC3B;CAChB,MAAM,QAAQ,IACb,CAAC,GAAG,KAAK,CAAC,CAAC,IAAI,OAAO,SAAS;EAC9B,IAAI;GACH,MAAM,KAAK;EACZ,SAAS,OAAO;GACf,QAAQ,KAAK;EACd;CACD,CAAC,CACF;AACD"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
//#region src/shutdown.ts
|
|
2
|
+
const key = Symbol.for("@geekmidas/constructs/shutdown");
|
|
3
|
+
const registry = globalThis;
|
|
4
|
+
registry[key] ??= /* @__PURE__ */ new Set();
|
|
5
|
+
const hooks = registry[key];
|
|
6
|
+
/** Run `hook` when the server shuts down. Returns a function that removes it. */
|
|
7
|
+
function onShutdown(hook) {
|
|
8
|
+
hooks.add(hook);
|
|
9
|
+
return () => hooks.delete(hook);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Run every registered hook, together, and wait for them. A hook that fails is
|
|
13
|
+
* reported to `onError` and does not stop the others.
|
|
14
|
+
*/
|
|
15
|
+
async function runShutdownHooks(onError = () => {}) {
|
|
16
|
+
await Promise.all([...hooks].map(async (hook) => {
|
|
17
|
+
try {
|
|
18
|
+
await hook();
|
|
19
|
+
} catch (error) {
|
|
20
|
+
onError(error);
|
|
21
|
+
}
|
|
22
|
+
}));
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
export { runShutdownHooks as n, onShutdown as t };
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=shutdown-C7xa8x9S.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shutdown-C7xa8x9S.mjs","names":[],"sources":["../src/shutdown.ts"],"sourcesContent":["/**\n * What a server releases when it stops: the connections constructs opened.\n *\n * A construct that holds something open — a database's pool — registers how to\n * close it here, and the generated server runs every hook once it has stopped\n * taking requests. Without that, a rolling deploy has the old task and the new\n * one both holding connections until the old process dies.\n *\n * Kept free of any driver import so the server entry can always import it,\n * whether or not the app has a database.\n */\n\ntype ShutdownHook = () => Promise<void> | void;\n\n// On globalThis, as Credentials are: a package loaded twice (ESM and CJS)\n// would otherwise keep two registries, and the server would run the empty one.\nconst key = Symbol.for('@geekmidas/constructs/shutdown');\nconst registry = globalThis as Record<symbol, Set<ShutdownHook> | undefined>;\nregistry[key] ??= new Set<ShutdownHook>();\nconst hooks = registry[key];\n\n/** Run `hook` when the server shuts down. Returns a function that removes it. */\nexport function onShutdown(hook: ShutdownHook): () => void {\n\thooks.add(hook);\n\treturn () => hooks.delete(hook);\n}\n\n/**\n * Run every registered hook, together, and wait for them. A hook that fails is\n * reported to `onError` and does not stop the others.\n */\nexport async function runShutdownHooks(\n\tonError: (error: unknown) => void = () => {},\n): Promise<void> {\n\tawait Promise.all(\n\t\t[...hooks].map(async (hook) => {\n\t\t\ttry {\n\t\t\t\tawait hook();\n\t\t\t} catch (error) {\n\t\t\t\tonError(error);\n\t\t\t}\n\t\t}),\n\t);\n}\n"],"mappings":";AAgBA,MAAM,MAAM,OAAO,IAAI,gCAAgC;AACvD,MAAM,WAAW;AACjB,SAAS,yBAAS,IAAI,IAAkB;AACxC,MAAM,QAAQ,SAAS;;AAGvB,SAAgB,WAAW,MAAgC;CAC1D,MAAM,IAAI,IAAI;CACd,aAAa,MAAM,OAAO,IAAI;AAC/B;;;;;AAMA,eAAsB,iBACrB,gBAA0C,CAAC,GAC3B;CAChB,MAAM,QAAQ,IACb,CAAC,GAAG,KAAK,CAAC,CAAC,IAAI,OAAO,SAAS;EAC9B,IAAI;GACH,MAAM,KAAK;EACZ,SAAS,OAAO;GACf,QAAQ,KAAK;EACd;CACD,CAAC,CACF;AACD"}
|
package/dist/site.cjs
CHANGED
|
@@ -21,9 +21,9 @@ let _geekmidas_manifest = require("@geekmidas/manifest");
|
|
|
21
21
|
* asymmetry is the honest one: a site consumes addresses, not connections.
|
|
22
22
|
*
|
|
23
23
|
* Only the static variant ships. SSR deploy shapes are unstable and each one is
|
|
24
|
-
* its own maintenance, so they follow rather than arrive together
|
|
25
|
-
*
|
|
26
|
-
*
|
|
24
|
+
* its own maintenance, so they follow rather than arrive together. A mobile app
|
|
25
|
+
* is not a site — it is reached by a scheme, not a URL — and is its own
|
|
26
|
+
* construct: see `MobileApp`.
|
|
27
27
|
*/
|
|
28
28
|
var StaticSite = class StaticSite {
|
|
29
29
|
config;
|
|
@@ -55,6 +55,7 @@ var StaticSite = class StaticSite {
|
|
|
55
55
|
kind: "site",
|
|
56
56
|
id: this.id,
|
|
57
57
|
variant: this.config.variant ?? "static",
|
|
58
|
+
...this.config.subdomain ? { subdomain: this.config.subdomain } : {},
|
|
58
59
|
app: {
|
|
59
60
|
path: this.config.path,
|
|
60
61
|
...this.config.port ? { port: this.config.port } : {},
|
|
@@ -62,6 +63,11 @@ var StaticSite = class StaticSite {
|
|
|
62
63
|
},
|
|
63
64
|
...this.config.root ? { root: true } : {},
|
|
64
65
|
dependencies: this.dependencies,
|
|
66
|
+
...this.config.telemetry ? { telemetry: this.config.telemetry.id } : {},
|
|
67
|
+
...this.config.password ? { password: {
|
|
68
|
+
secret: this.config.password.secret.id,
|
|
69
|
+
stages: [...this.config.password.stages]
|
|
70
|
+
} } : {},
|
|
65
71
|
provides: [this.keys.url]
|
|
66
72
|
}];
|
|
67
73
|
}
|
package/dist/site.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"site.cjs","names":["canonicalId","provideKey","edgeTo"],"sources":["../src/site.ts"],"sourcesContent":["/**\n * `StaticSite` — a frontend, declared like anything else.\n *\n * The point is not that a site needs provisioning; it is that a site is the\n * *consumer* whose edges make four hand-maintained lists derivable. Declaring it\n * is what turns \"which origins does the API allow\" from something a person keeps\n * in step into something the graph already knows.\n *\n * ```ts\n * export const console = new StaticSite('Console', { path: 'apps/console' })\n * .dependsOn([api, auth]);\n * ```\n *\n * It has no `.service`. A site is not a process that registers clients — it is\n * built, and the values it needs are inlined or fetched by its own framework —\n * so the edge is {@link Declarable} rather than {@link Consumable}, and the\n * asymmetry is the honest one: a site consumes addresses, not connections.\n *\n * Only the static variant ships. SSR deploy shapes are unstable and each one is\n * its own maintenance, so they follow rather than arrive together
|
|
1
|
+
{"version":3,"file":"site.cjs","names":["canonicalId","provideKey","edgeTo"],"sources":["../src/site.ts"],"sourcesContent":["/**\n * `StaticSite` — a frontend, declared like anything else.\n *\n * The point is not that a site needs provisioning; it is that a site is the\n * *consumer* whose edges make four hand-maintained lists derivable. Declaring it\n * is what turns \"which origins does the API allow\" from something a person keeps\n * in step into something the graph already knows.\n *\n * ```ts\n * export const console = new StaticSite('Console', { path: 'apps/console' })\n * .dependsOn([api, auth]);\n * ```\n *\n * It has no `.service`. A site is not a process that registers clients — it is\n * built, and the values it needs are inlined or fetched by its own framework —\n * so the edge is {@link Declarable} rather than {@link Consumable}, and the\n * asymmetry is the honest one: a site consumes addresses, not connections.\n *\n * Only the static variant ships. SSR deploy shapes are unstable and each one is\n * its own maintenance, so they follow rather than arrive together. A mobile app\n * is not a site — it is reached by a scheme, not a URL — and is its own\n * construct: see `MobileApp`.\n */\n\nimport {\n\ttype ConstructName,\n\tcanonicalId,\n\ttype Declaration,\n\ttype Dependency,\n\tprovideKey,\n\ttype SiteDeclaration,\n} from '@geekmidas/manifest';\nimport { type Declarable, edgeTo } from './construct-interface';\nimport type { RandomPassword } from './random-password';\nimport type { DeployedStage } from './stages';\nimport type { Telemetry } from './telemetry';\n\n/**\n * Where a site's source lives, and the little else a layout can differ by.\n *\n * Only `path` is required: `new StaticSite('Web', { path: 'apps/web' })` is a\n * complete site.\n */\nexport interface StaticSiteConfig {\n\t/**\n\t * Where its source lives, relative to the workspace root — `'apps/web'`.\n\t *\n\t * Required, the same field `RestApi` and `BetterAuth` take. It was\n\t * inferred from the id, which made a site's home whatever was on disk.\n\t */\n\tpath: string;\n\t/**\n\t * The label it answers on under a stage's domain — `api` for\n\t * `api.myapp.com`, from `domains` — and under the project locally,\n\t * `api.myapp.localhost`. Absent, its id kebab-cased.\n\t */\n\tsubdomain?: string;\n\t/**\n\t * The port it answers on locally.\n\t *\n\t * Normally omitted: ports are assigned in a stable order, so adding a site\n\t * does not renumber the ones already running.\n\t */\n\tport?: number;\n\t/**\n\t * Modules to import when sniffing which env vars this site reads.\n\t *\n\t * A frontend's values are inlined at build time, so the build has to know\n\t * which ones it reads before it reads them.\n\t */\n\tconfig?: { client?: string; server?: string };\n\t/**\n\t * Whether the base domain points at this site.\n\t *\n\t * A project with one site needs this no more than a project with one\n\t * database needs to say which database. It matters when there are several\n\t * and none is called `web`: the base domain then belongs to whichever site\n\t * says so, rather than to whichever file the glob happened to reach first.\n\t */\n\troot?: boolean;\n\t/**\n\t * Which framework builds it.\n\t *\n\t * It selects how values are delivered — `VITE_`, `NEXT_PUBLIC_`, a fetched\n\t * `config.json` — and never which values there are. One neutral name from the\n\t * construct, one serialisation per framework, the same rule as everywhere\n\t * else.\n\t */\n\tvariant?: SiteDeclaration['variant'];\n\t/**\n\t * What the site emits — the `Telemetry` construct. An edge to the node and\n\t * nothing more for now: a site is handed none of its server keys, and the\n\t * browser half (propagation from the generated client, then a browser SDK\n\t * exporting through the API) builds on this edge.\n\t */\n\ttelemetry?: Telemetry;\n\t/**\n\t * A login the site is served behind on the stages named, so a staging\n\t * build is not public while it is tried.\n\t *\n\t * ```ts\n\t * export const sitePassword = new RandomPassword('SitePassword');\n\t *\n\t * export const web = new StaticSite('Web', {\n\t * path: 'apps/web',\n\t * password: { secret: sitePassword, stages: ['staging'] },\n\t * });\n\t * ```\n\t *\n\t * The edge asks for it with HTTP basic auth before a request reaches the\n\t * site: the user is the stage's name, the password the `RandomPassword`'s\n\t * value on that stage. Like any `RandomPassword` it is generated on the\n\t * first deploy and kept, and one set by hand wins. It is not an edge — the\n\t * site is handed none of it — so export it from a constructs file of its\n\t * own, as any construct is.\n\t *\n\t * The compose target alone serves it so far; another refuses the stage\n\t * rather than serving it publicly.\n\t */\n\tpassword?: {\n\t\tsecret: RandomPassword;\n\t\tstages: readonly [DeployedStage, ...DeployedStage[]];\n\t};\n}\n\nexport class StaticSite<TName extends string = string>\n\timplements Declarable<TName>\n{\n\treadonly id: TName;\n\treadonly keys: { url: string };\n\n\tconstructor(\n\t\tid: ConstructName<TName>,\n\t\tprivate readonly config: StaticSiteConfig,\n\t\t/**\n\t\t * Internal: how `.dependsOn()` carries edges into the copy it returns.\n\t\t * Written as a parameter rather than a mutable field so the builder can\n\t\t * stay immutable without a clone method, the same shape\n\t\t * `KyselyDatabase` uses for its derived forms.\n\t\t */\n\t\tprivate readonly dependencies: readonly Dependency[] = [],\n\t) {\n\t\tthis.id = canonicalId(id as string) as TName;\n\t\tthis.keys = { url: provideKey(this.id, 'url') };\n\t}\n\n\t/**\n\t * What this site calls.\n\t *\n\t * Immutable, like every other builder here: it returns a new site rather than\n\t * mutating this one, so a module that exports both a base and a variant of it\n\t * cannot have the second silently change the first.\n\t *\n\t * Takes {@link Declarable} rather than {@link Consumable} because a site's\n\t * edge is a build-time link and not a service injection — requiring a client\n\t * would exclude exactly the surfaces a frontend actually depends on.\n\t */\n\tdependsOn(constructs: readonly Declarable[]): StaticSite<TName> {\n\t\treturn new StaticSite<TName>(this.id as ConstructName<TName>, this.config, [\n\t\t\t...this.dependencies,\n\t\t\t...constructs.map(edgeTo),\n\t\t]);\n\t}\n\n\tdeclare(): Declaration[] {\n\t\treturn [\n\t\t\t{\n\t\t\t\tkind: 'site',\n\t\t\t\tid: this.id,\n\t\t\t\tvariant: this.config.variant ?? 'static',\n\t\t\t\t...(this.config.subdomain ? { subdomain: this.config.subdomain } : {}),\n\t\t\t\tapp: {\n\t\t\t\t\tpath: this.config.path,\n\t\t\t\t\t...(this.config.port ? { port: this.config.port } : {}),\n\t\t\t\t\t...(this.config.config ? { config: this.config.config } : {}),\n\t\t\t\t},\n\t\t\t\t...(this.config.root ? { root: true } : {}),\n\t\t\t\tdependencies: this.dependencies,\n\t\t\t\t...(this.config.telemetry\n\t\t\t\t\t? { telemetry: this.config.telemetry.id }\n\t\t\t\t\t: {}),\n\t\t\t\t...(this.config.password\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tpassword: {\n\t\t\t\t\t\t\t\tsecret: this.config.password.secret.id,\n\t\t\t\t\t\t\t\tstages: [...this.config.password.stages],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t}\n\t\t\t\t\t: {}),\n\t\t\t\tprovides: [this.keys.url],\n\t\t\t},\n\t\t];\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA6HA,IAAa,aAAb,MAAa,WAEb;CAMmB;CAOA;CAZlB;CACA;CAEA,YACC,IACA,QAOA,eAAuD,CAAC,GACvD;EARgB,KAAA,SAAA;EAOA,KAAA,eAAA;EAEjB,KAAK,MAAA,GAAKA,oBAAAA,YAAAA,CAAY,EAAY;EAClC,KAAK,OAAO,EAAE,MAAA,GAAKC,oBAAAA,WAAAA,CAAW,KAAK,IAAI,KAAK,EAAE;CAC/C;;;;;;;;;;;;CAaA,UAAU,YAAsD;EAC/D,OAAO,IAAI,WAAkB,KAAK,IAA4B,KAAK,QAAQ,CAC1E,GAAG,KAAK,cACR,GAAG,WAAW,IAAIC,4BAAAA,MAAM,CACzB,CAAC;CACF;CAEA,UAAyB;EACxB,OAAO,CACN;GACC,MAAM;GACN,IAAI,KAAK;GACT,SAAS,KAAK,OAAO,WAAW;GAChC,GAAI,KAAK,OAAO,YAAY,EAAE,WAAW,KAAK,OAAO,UAAU,IAAI,CAAC;GACpE,KAAK;IACJ,MAAM,KAAK,OAAO;IAClB,GAAI,KAAK,OAAO,OAAO,EAAE,MAAM,KAAK,OAAO,KAAK,IAAI,CAAC;IACrD,GAAI,KAAK,OAAO,SAAS,EAAE,QAAQ,KAAK,OAAO,OAAO,IAAI,CAAC;GAC5D;GACA,GAAI,KAAK,OAAO,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;GACzC,cAAc,KAAK;GACnB,GAAI,KAAK,OAAO,YACb,EAAE,WAAW,KAAK,OAAO,UAAU,GAAG,IACtC,CAAC;GACJ,GAAI,KAAK,OAAO,WACb,EACA,UAAU;IACT,QAAQ,KAAK,OAAO,SAAS,OAAO;IACpC,QAAQ,CAAC,GAAG,KAAK,OAAO,SAAS,MAAM;GACxC,EACD,IACC,CAAC;GACJ,UAAU,CAAC,KAAK,KAAK,GAAG;EACzB,CACD;CACD;AACD"}
|
package/dist/site.d.cts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { i as Declarable } from "./construct-interface-B1AfqRl4.cjs";
|
|
2
|
+
import { n as Telemetry } from "./telemetry-B48RLjyk.cjs";
|
|
3
|
+
import { n as DeployedStage } from "./stages-DaTaoQei.cjs";
|
|
4
|
+
import { RandomPassword } from "./random-password.cjs";
|
|
2
5
|
import { ConstructName, Declaration, Dependency, SiteDeclaration } from "@geekmidas/manifest";
|
|
3
6
|
//#region src/site.d.ts
|
|
4
7
|
/**
|
|
@@ -15,6 +18,12 @@ export interface StaticSiteConfig {
|
|
|
15
18
|
* inferred from the id, which made a site's home whatever was on disk.
|
|
16
19
|
*/
|
|
17
20
|
path: string;
|
|
21
|
+
/**
|
|
22
|
+
* The label it answers on under a stage's domain — `api` for
|
|
23
|
+
* `api.myapp.com`, from `domains` — and under the project locally,
|
|
24
|
+
* `api.myapp.localhost`. Absent, its id kebab-cased.
|
|
25
|
+
*/
|
|
26
|
+
subdomain?: string;
|
|
18
27
|
/**
|
|
19
28
|
* The port it answers on locally.
|
|
20
29
|
*
|
|
@@ -50,6 +59,40 @@ export interface StaticSiteConfig {
|
|
|
50
59
|
* else.
|
|
51
60
|
*/
|
|
52
61
|
variant?: SiteDeclaration['variant'];
|
|
62
|
+
/**
|
|
63
|
+
* What the site emits — the `Telemetry` construct. An edge to the node and
|
|
64
|
+
* nothing more for now: a site is handed none of its server keys, and the
|
|
65
|
+
* browser half (propagation from the generated client, then a browser SDK
|
|
66
|
+
* exporting through the API) builds on this edge.
|
|
67
|
+
*/
|
|
68
|
+
telemetry?: Telemetry;
|
|
69
|
+
/**
|
|
70
|
+
* A login the site is served behind on the stages named, so a staging
|
|
71
|
+
* build is not public while it is tried.
|
|
72
|
+
*
|
|
73
|
+
* ```ts
|
|
74
|
+
* export const sitePassword = new RandomPassword('SitePassword');
|
|
75
|
+
*
|
|
76
|
+
* export const web = new StaticSite('Web', {
|
|
77
|
+
* path: 'apps/web',
|
|
78
|
+
* password: { secret: sitePassword, stages: ['staging'] },
|
|
79
|
+
* });
|
|
80
|
+
* ```
|
|
81
|
+
*
|
|
82
|
+
* The edge asks for it with HTTP basic auth before a request reaches the
|
|
83
|
+
* site: the user is the stage's name, the password the `RandomPassword`'s
|
|
84
|
+
* value on that stage. Like any `RandomPassword` it is generated on the
|
|
85
|
+
* first deploy and kept, and one set by hand wins. It is not an edge — the
|
|
86
|
+
* site is handed none of it — so export it from a constructs file of its
|
|
87
|
+
* own, as any construct is.
|
|
88
|
+
*
|
|
89
|
+
* The compose target alone serves it so far; another refuses the stage
|
|
90
|
+
* rather than serving it publicly.
|
|
91
|
+
*/
|
|
92
|
+
password?: {
|
|
93
|
+
secret: RandomPassword;
|
|
94
|
+
stages: readonly [DeployedStage, ...DeployedStage[]];
|
|
95
|
+
};
|
|
53
96
|
}
|
|
54
97
|
export declare class StaticSite<TName extends string = string> implements Declarable<TName> {
|
|
55
98
|
private readonly config;
|
package/dist/site.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"site.d.cts","names":[],"sources":["../src/site.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"site.d.cts","names":[],"sources":["../src/site.ts"],"mappings":";;;;;;;;;;;;iBA2CiB;;;;;;;EAOhB;;;;;;EAMA;;;;;;;EAOA;;;;;;;EAOA;IAAW;IAAiB;;;;;;;;;;EAS5B;;;;;;;;;EASA,UAAU;;;;;;;EAOV,YAAY;;;;;;;;;;;;;;;;;;;;;;;;EAwBZ;IACC,QAAQ;IACR,kBAAkB,kBAAkB;;;qBAIzB,WAAW,0CACZ,WAAW;mBAOJ;;;;;;;mBAOA;WAZT,IAAI;WACJ;IAAQ;;EAEjB,YACC,IAAI,cAAc,QACD,QAAQ,kBAOR;;;;;;;EAAA,wBAAuB;;;;;;;;;;;;EAiBzC,UAAU,qBAAqB,eAAe,WAAW;EAOzD,WAAW"}
|
package/dist/site.d.mts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { i as Declarable } from "./construct-interface-ZvYQbivO.mjs";
|
|
2
|
+
import { n as Telemetry } from "./telemetry-BEoBn6GO.mjs";
|
|
3
|
+
import { n as DeployedStage } from "./stages-DaTaoQei.mjs";
|
|
4
|
+
import { RandomPassword } from "./random-password.mjs";
|
|
2
5
|
import { ConstructName, Declaration, Dependency, SiteDeclaration } from "@geekmidas/manifest";
|
|
3
6
|
//#region src/site.d.ts
|
|
4
7
|
/**
|
|
@@ -15,6 +18,12 @@ export interface StaticSiteConfig {
|
|
|
15
18
|
* inferred from the id, which made a site's home whatever was on disk.
|
|
16
19
|
*/
|
|
17
20
|
path: string;
|
|
21
|
+
/**
|
|
22
|
+
* The label it answers on under a stage's domain — `api` for
|
|
23
|
+
* `api.myapp.com`, from `domains` — and under the project locally,
|
|
24
|
+
* `api.myapp.localhost`. Absent, its id kebab-cased.
|
|
25
|
+
*/
|
|
26
|
+
subdomain?: string;
|
|
18
27
|
/**
|
|
19
28
|
* The port it answers on locally.
|
|
20
29
|
*
|
|
@@ -50,6 +59,40 @@ export interface StaticSiteConfig {
|
|
|
50
59
|
* else.
|
|
51
60
|
*/
|
|
52
61
|
variant?: SiteDeclaration['variant'];
|
|
62
|
+
/**
|
|
63
|
+
* What the site emits — the `Telemetry` construct. An edge to the node and
|
|
64
|
+
* nothing more for now: a site is handed none of its server keys, and the
|
|
65
|
+
* browser half (propagation from the generated client, then a browser SDK
|
|
66
|
+
* exporting through the API) builds on this edge.
|
|
67
|
+
*/
|
|
68
|
+
telemetry?: Telemetry;
|
|
69
|
+
/**
|
|
70
|
+
* A login the site is served behind on the stages named, so a staging
|
|
71
|
+
* build is not public while it is tried.
|
|
72
|
+
*
|
|
73
|
+
* ```ts
|
|
74
|
+
* export const sitePassword = new RandomPassword('SitePassword');
|
|
75
|
+
*
|
|
76
|
+
* export const web = new StaticSite('Web', {
|
|
77
|
+
* path: 'apps/web',
|
|
78
|
+
* password: { secret: sitePassword, stages: ['staging'] },
|
|
79
|
+
* });
|
|
80
|
+
* ```
|
|
81
|
+
*
|
|
82
|
+
* The edge asks for it with HTTP basic auth before a request reaches the
|
|
83
|
+
* site: the user is the stage's name, the password the `RandomPassword`'s
|
|
84
|
+
* value on that stage. Like any `RandomPassword` it is generated on the
|
|
85
|
+
* first deploy and kept, and one set by hand wins. It is not an edge — the
|
|
86
|
+
* site is handed none of it — so export it from a constructs file of its
|
|
87
|
+
* own, as any construct is.
|
|
88
|
+
*
|
|
89
|
+
* The compose target alone serves it so far; another refuses the stage
|
|
90
|
+
* rather than serving it publicly.
|
|
91
|
+
*/
|
|
92
|
+
password?: {
|
|
93
|
+
secret: RandomPassword;
|
|
94
|
+
stages: readonly [DeployedStage, ...DeployedStage[]];
|
|
95
|
+
};
|
|
53
96
|
}
|
|
54
97
|
export declare class StaticSite<TName extends string = string> implements Declarable<TName> {
|
|
55
98
|
private readonly config;
|
package/dist/site.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"site.d.mts","names":[],"sources":["../src/site.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"site.d.mts","names":[],"sources":["../src/site.ts"],"mappings":";;;;;;;;;;;;iBA2CiB;;;;;;;EAOhB;;;;;;EAMA;;;;;;;EAOA;;;;;;;EAOA;IAAW;IAAiB;;;;;;;;;;EAS5B;;;;;;;;;EASA,UAAU;;;;;;;EAOV,YAAY;;;;;;;;;;;;;;;;;;;;;;;;EAwBZ;IACC,QAAQ;IACR,kBAAkB,kBAAkB;;;qBAIzB,WAAW,0CACZ,WAAW;mBAOJ;;;;;;;mBAOA;WAZT,IAAI;WACJ;IAAQ;;EAEjB,YACC,IAAI,cAAc,QACD,QAAQ,kBAOR;;;;;;;EAAA,wBAAuB;;;;;;;;;;;;EAiBzC,UAAU,qBAAqB,eAAe,WAAW;EAOzD,WAAW"}
|
package/dist/site.mjs
CHANGED
|
@@ -20,9 +20,9 @@ import { canonicalId, provideKey } from "@geekmidas/manifest";
|
|
|
20
20
|
* asymmetry is the honest one: a site consumes addresses, not connections.
|
|
21
21
|
*
|
|
22
22
|
* Only the static variant ships. SSR deploy shapes are unstable and each one is
|
|
23
|
-
* its own maintenance, so they follow rather than arrive together
|
|
24
|
-
*
|
|
25
|
-
*
|
|
23
|
+
* its own maintenance, so they follow rather than arrive together. A mobile app
|
|
24
|
+
* is not a site — it is reached by a scheme, not a URL — and is its own
|
|
25
|
+
* construct: see `MobileApp`.
|
|
26
26
|
*/
|
|
27
27
|
var StaticSite = class StaticSite {
|
|
28
28
|
config;
|
|
@@ -54,6 +54,7 @@ var StaticSite = class StaticSite {
|
|
|
54
54
|
kind: "site",
|
|
55
55
|
id: this.id,
|
|
56
56
|
variant: this.config.variant ?? "static",
|
|
57
|
+
...this.config.subdomain ? { subdomain: this.config.subdomain } : {},
|
|
57
58
|
app: {
|
|
58
59
|
path: this.config.path,
|
|
59
60
|
...this.config.port ? { port: this.config.port } : {},
|
|
@@ -61,6 +62,11 @@ var StaticSite = class StaticSite {
|
|
|
61
62
|
},
|
|
62
63
|
...this.config.root ? { root: true } : {},
|
|
63
64
|
dependencies: this.dependencies,
|
|
65
|
+
...this.config.telemetry ? { telemetry: this.config.telemetry.id } : {},
|
|
66
|
+
...this.config.password ? { password: {
|
|
67
|
+
secret: this.config.password.secret.id,
|
|
68
|
+
stages: [...this.config.password.stages]
|
|
69
|
+
} } : {},
|
|
64
70
|
provides: [this.keys.url]
|
|
65
71
|
}];
|
|
66
72
|
}
|
package/dist/site.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"site.mjs","names":[],"sources":["../src/site.ts"],"sourcesContent":["/**\n * `StaticSite` — a frontend, declared like anything else.\n *\n * The point is not that a site needs provisioning; it is that a site is the\n * *consumer* whose edges make four hand-maintained lists derivable. Declaring it\n * is what turns \"which origins does the API allow\" from something a person keeps\n * in step into something the graph already knows.\n *\n * ```ts\n * export const console = new StaticSite('Console', { path: 'apps/console' })\n * .dependsOn([api, auth]);\n * ```\n *\n * It has no `.service`. A site is not a process that registers clients — it is\n * built, and the values it needs are inlined or fetched by its own framework —\n * so the edge is {@link Declarable} rather than {@link Consumable}, and the\n * asymmetry is the honest one: a site consumes addresses, not connections.\n *\n * Only the static variant ships. SSR deploy shapes are unstable and each one is\n * its own maintenance, so they follow rather than arrive together
|
|
1
|
+
{"version":3,"file":"site.mjs","names":[],"sources":["../src/site.ts"],"sourcesContent":["/**\n * `StaticSite` — a frontend, declared like anything else.\n *\n * The point is not that a site needs provisioning; it is that a site is the\n * *consumer* whose edges make four hand-maintained lists derivable. Declaring it\n * is what turns \"which origins does the API allow\" from something a person keeps\n * in step into something the graph already knows.\n *\n * ```ts\n * export const console = new StaticSite('Console', { path: 'apps/console' })\n * .dependsOn([api, auth]);\n * ```\n *\n * It has no `.service`. A site is not a process that registers clients — it is\n * built, and the values it needs are inlined or fetched by its own framework —\n * so the edge is {@link Declarable} rather than {@link Consumable}, and the\n * asymmetry is the honest one: a site consumes addresses, not connections.\n *\n * Only the static variant ships. SSR deploy shapes are unstable and each one is\n * its own maintenance, so they follow rather than arrive together. A mobile app\n * is not a site — it is reached by a scheme, not a URL — and is its own\n * construct: see `MobileApp`.\n */\n\nimport {\n\ttype ConstructName,\n\tcanonicalId,\n\ttype Declaration,\n\ttype Dependency,\n\tprovideKey,\n\ttype SiteDeclaration,\n} from '@geekmidas/manifest';\nimport { type Declarable, edgeTo } from './construct-interface';\nimport type { RandomPassword } from './random-password';\nimport type { DeployedStage } from './stages';\nimport type { Telemetry } from './telemetry';\n\n/**\n * Where a site's source lives, and the little else a layout can differ by.\n *\n * Only `path` is required: `new StaticSite('Web', { path: 'apps/web' })` is a\n * complete site.\n */\nexport interface StaticSiteConfig {\n\t/**\n\t * Where its source lives, relative to the workspace root — `'apps/web'`.\n\t *\n\t * Required, the same field `RestApi` and `BetterAuth` take. It was\n\t * inferred from the id, which made a site's home whatever was on disk.\n\t */\n\tpath: string;\n\t/**\n\t * The label it answers on under a stage's domain — `api` for\n\t * `api.myapp.com`, from `domains` — and under the project locally,\n\t * `api.myapp.localhost`. Absent, its id kebab-cased.\n\t */\n\tsubdomain?: string;\n\t/**\n\t * The port it answers on locally.\n\t *\n\t * Normally omitted: ports are assigned in a stable order, so adding a site\n\t * does not renumber the ones already running.\n\t */\n\tport?: number;\n\t/**\n\t * Modules to import when sniffing which env vars this site reads.\n\t *\n\t * A frontend's values are inlined at build time, so the build has to know\n\t * which ones it reads before it reads them.\n\t */\n\tconfig?: { client?: string; server?: string };\n\t/**\n\t * Whether the base domain points at this site.\n\t *\n\t * A project with one site needs this no more than a project with one\n\t * database needs to say which database. It matters when there are several\n\t * and none is called `web`: the base domain then belongs to whichever site\n\t * says so, rather than to whichever file the glob happened to reach first.\n\t */\n\troot?: boolean;\n\t/**\n\t * Which framework builds it.\n\t *\n\t * It selects how values are delivered — `VITE_`, `NEXT_PUBLIC_`, a fetched\n\t * `config.json` — and never which values there are. One neutral name from the\n\t * construct, one serialisation per framework, the same rule as everywhere\n\t * else.\n\t */\n\tvariant?: SiteDeclaration['variant'];\n\t/**\n\t * What the site emits — the `Telemetry` construct. An edge to the node and\n\t * nothing more for now: a site is handed none of its server keys, and the\n\t * browser half (propagation from the generated client, then a browser SDK\n\t * exporting through the API) builds on this edge.\n\t */\n\ttelemetry?: Telemetry;\n\t/**\n\t * A login the site is served behind on the stages named, so a staging\n\t * build is not public while it is tried.\n\t *\n\t * ```ts\n\t * export const sitePassword = new RandomPassword('SitePassword');\n\t *\n\t * export const web = new StaticSite('Web', {\n\t * path: 'apps/web',\n\t * password: { secret: sitePassword, stages: ['staging'] },\n\t * });\n\t * ```\n\t *\n\t * The edge asks for it with HTTP basic auth before a request reaches the\n\t * site: the user is the stage's name, the password the `RandomPassword`'s\n\t * value on that stage. Like any `RandomPassword` it is generated on the\n\t * first deploy and kept, and one set by hand wins. It is not an edge — the\n\t * site is handed none of it — so export it from a constructs file of its\n\t * own, as any construct is.\n\t *\n\t * The compose target alone serves it so far; another refuses the stage\n\t * rather than serving it publicly.\n\t */\n\tpassword?: {\n\t\tsecret: RandomPassword;\n\t\tstages: readonly [DeployedStage, ...DeployedStage[]];\n\t};\n}\n\nexport class StaticSite<TName extends string = string>\n\timplements Declarable<TName>\n{\n\treadonly id: TName;\n\treadonly keys: { url: string };\n\n\tconstructor(\n\t\tid: ConstructName<TName>,\n\t\tprivate readonly config: StaticSiteConfig,\n\t\t/**\n\t\t * Internal: how `.dependsOn()` carries edges into the copy it returns.\n\t\t * Written as a parameter rather than a mutable field so the builder can\n\t\t * stay immutable without a clone method, the same shape\n\t\t * `KyselyDatabase` uses for its derived forms.\n\t\t */\n\t\tprivate readonly dependencies: readonly Dependency[] = [],\n\t) {\n\t\tthis.id = canonicalId(id as string) as TName;\n\t\tthis.keys = { url: provideKey(this.id, 'url') };\n\t}\n\n\t/**\n\t * What this site calls.\n\t *\n\t * Immutable, like every other builder here: it returns a new site rather than\n\t * mutating this one, so a module that exports both a base and a variant of it\n\t * cannot have the second silently change the first.\n\t *\n\t * Takes {@link Declarable} rather than {@link Consumable} because a site's\n\t * edge is a build-time link and not a service injection — requiring a client\n\t * would exclude exactly the surfaces a frontend actually depends on.\n\t */\n\tdependsOn(constructs: readonly Declarable[]): StaticSite<TName> {\n\t\treturn new StaticSite<TName>(this.id as ConstructName<TName>, this.config, [\n\t\t\t...this.dependencies,\n\t\t\t...constructs.map(edgeTo),\n\t\t]);\n\t}\n\n\tdeclare(): Declaration[] {\n\t\treturn [\n\t\t\t{\n\t\t\t\tkind: 'site',\n\t\t\t\tid: this.id,\n\t\t\t\tvariant: this.config.variant ?? 'static',\n\t\t\t\t...(this.config.subdomain ? { subdomain: this.config.subdomain } : {}),\n\t\t\t\tapp: {\n\t\t\t\t\tpath: this.config.path,\n\t\t\t\t\t...(this.config.port ? { port: this.config.port } : {}),\n\t\t\t\t\t...(this.config.config ? { config: this.config.config } : {}),\n\t\t\t\t},\n\t\t\t\t...(this.config.root ? { root: true } : {}),\n\t\t\t\tdependencies: this.dependencies,\n\t\t\t\t...(this.config.telemetry\n\t\t\t\t\t? { telemetry: this.config.telemetry.id }\n\t\t\t\t\t: {}),\n\t\t\t\t...(this.config.password\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tpassword: {\n\t\t\t\t\t\t\t\tsecret: this.config.password.secret.id,\n\t\t\t\t\t\t\t\tstages: [...this.config.password.stages],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t}\n\t\t\t\t\t: {}),\n\t\t\t\tprovides: [this.keys.url],\n\t\t\t},\n\t\t];\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA6HA,IAAa,aAAb,MAAa,WAEb;CAMmB;CAOA;CAZlB;CACA;CAEA,YACC,IACA,QAOA,eAAuD,CAAC,GACvD;EARgB,KAAA,SAAA;EAOA,KAAA,eAAA;EAEjB,KAAK,KAAK,YAAY,EAAY;EAClC,KAAK,OAAO,EAAE,KAAK,WAAW,KAAK,IAAI,KAAK,EAAE;CAC/C;;;;;;;;;;;;CAaA,UAAU,YAAsD;EAC/D,OAAO,IAAI,WAAkB,KAAK,IAA4B,KAAK,QAAQ,CAC1E,GAAG,KAAK,cACR,GAAG,WAAW,IAAI,MAAM,CACzB,CAAC;CACF;CAEA,UAAyB;EACxB,OAAO,CACN;GACC,MAAM;GACN,IAAI,KAAK;GACT,SAAS,KAAK,OAAO,WAAW;GAChC,GAAI,KAAK,OAAO,YAAY,EAAE,WAAW,KAAK,OAAO,UAAU,IAAI,CAAC;GACpE,KAAK;IACJ,MAAM,KAAK,OAAO;IAClB,GAAI,KAAK,OAAO,OAAO,EAAE,MAAM,KAAK,OAAO,KAAK,IAAI,CAAC;IACrD,GAAI,KAAK,OAAO,SAAS,EAAE,QAAQ,KAAK,OAAO,OAAO,IAAI,CAAC;GAC5D;GACA,GAAI,KAAK,OAAO,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;GACzC,cAAc,KAAK;GACnB,GAAI,KAAK,OAAO,YACb,EAAE,WAAW,KAAK,OAAO,UAAU,GAAG,IACtC,CAAC;GACJ,GAAI,KAAK,OAAO,WACb,EACA,UAAU;IACT,QAAQ,KAAK,OAAO,SAAS,OAAO;IACpC,QAAQ,CAAC,GAAG,KAAK,OAAO,SAAS,MAAM;GACxC,EACD,IACC,CAAC;GACJ,UAAU,CAAC,KAAK,KAAK,GAAG;EACzB,CACD;CACD;AACD"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
//#region src/stages.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* The project's stage names, as types.
|
|
4
|
+
*
|
|
5
|
+
* `gkm.config.ts` declares the stages — `stages: { local: 'dev', deployed:
|
|
6
|
+
* ['staging', 'prod'] }` — but constructs and application code cannot import
|
|
7
|
+
* the config, so a stage name written anywhere else was a bare `string`: a
|
|
8
|
+
* typo'd key in an `ExternalApi`'s `url` map was silently never read, and a
|
|
9
|
+
* seed's `stage === 'prodution'` branch silently never ran.
|
|
10
|
+
*
|
|
11
|
+
* `gkm dev`, `gkm build` and `gkm test --prepare` write `.gkm/stages.d.ts`,
|
|
12
|
+
* which fills this interface in from the loaded workspace:
|
|
13
|
+
*
|
|
14
|
+
* ```ts
|
|
15
|
+
* declare module '@geekmidas/constructs' {
|
|
16
|
+
* interface Stages { local: 'dev'; deployed: 'staging' | 'prod' }
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* Until that file exists — a fresh clone, before the first run — the interface
|
|
21
|
+
* is empty and every stage type below is `string`, so nothing fails to compile
|
|
22
|
+
* for want of a generated file.
|
|
23
|
+
*/
|
|
24
|
+
interface Stages {}
|
|
25
|
+
/** What `Stages` says under `key`, or `string` while it says nothing. */
|
|
26
|
+
type Declared<TKey extends string> = Stages extends { [K in TKey]: infer TStage extends string; } ? TStage : string;
|
|
27
|
+
/** The stage `gkm dev`, `exec`, `setup` and `test` run as: `stages.local`. */
|
|
28
|
+
type LocalStage = Declared<'local'>;
|
|
29
|
+
/** A stage `gkm deploy --stage` accepts: one of `stages.deployed`. */
|
|
30
|
+
type DeployedStage = Declared<'deployed'>;
|
|
31
|
+
/** What `gkm test` runs as. The CLI's own; no project stage may take it. */
|
|
32
|
+
type TestStage = 'test';
|
|
33
|
+
/** Any stage the project's code can find itself running as. */
|
|
34
|
+
type AnyStage = LocalStage | TestStage | DeployedStage;
|
|
35
|
+
/**
|
|
36
|
+
* What a seed is handed beside its database.
|
|
37
|
+
*
|
|
38
|
+
* Seeds run on every stage, production included, so a seed that should write
|
|
39
|
+
* something only somewhere — a demo tenant on the local stage, never on a
|
|
40
|
+
* deployed one — decides by the stage it is given:
|
|
41
|
+
*
|
|
42
|
+
* ```ts
|
|
43
|
+
* import type { SeedContext } from '@geekmidas/constructs';
|
|
44
|
+
*
|
|
45
|
+
* export async function seed(db: Kysely<Database>, { stage }: SeedContext) {
|
|
46
|
+
* if (stage === 'dev') await insertDemoTenant(db);
|
|
47
|
+
* }
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* A seed reaching a construct's service — a bucket, a cache — builds it from
|
|
51
|
+
* the stage's `env`, as a handler's service is built from its own:
|
|
52
|
+
*
|
|
53
|
+
* ```ts
|
|
54
|
+
* export async function seed(db, { stage, env }: SeedContext) {
|
|
55
|
+
* const bucket = await assets.service.register({
|
|
56
|
+
* envParser: new EnvironmentParser(env),
|
|
57
|
+
* context: serviceContext,
|
|
58
|
+
* });
|
|
59
|
+
* }
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
interface SeedContext {
|
|
63
|
+
/** The stage being seeded: the local one, `test`, or a deployed one. */
|
|
64
|
+
stage: AnyStage;
|
|
65
|
+
/**
|
|
66
|
+
* The stage's resolved environment — every construct's URL, as the runner
|
|
67
|
+
* resolved it. Not `process.env`, which a seed run never populates.
|
|
68
|
+
*/
|
|
69
|
+
env: Readonly<Record<string, string | undefined>>;
|
|
70
|
+
}
|
|
71
|
+
//#endregion
|
|
72
|
+
export { Stages as a, SeedContext as i, DeployedStage as n, TestStage as o, LocalStage as r, AnyStage as t };
|
|
73
|
+
//# sourceMappingURL=stages-DaTaoQei.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stages-DaTaoQei.d.cts","names":[],"sources":["../src/stages.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;UAuBiB;;KAGZ,SAAS,uBAAuB,kBACnC,KAAK,aAAa,2BAEjB;;KAIS,aAAa;;KAGb,gBAAgB;;KAGhB;;KAGA,WAAW,aAAa,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;UA6B/B;;EAEhB,OAAO;;;;;EAKP,KAAK,SAAS"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
//#region src/stages.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* The project's stage names, as types.
|
|
4
|
+
*
|
|
5
|
+
* `gkm.config.ts` declares the stages — `stages: { local: 'dev', deployed:
|
|
6
|
+
* ['staging', 'prod'] }` — but constructs and application code cannot import
|
|
7
|
+
* the config, so a stage name written anywhere else was a bare `string`: a
|
|
8
|
+
* typo'd key in an `ExternalApi`'s `url` map was silently never read, and a
|
|
9
|
+
* seed's `stage === 'prodution'` branch silently never ran.
|
|
10
|
+
*
|
|
11
|
+
* `gkm dev`, `gkm build` and `gkm test --prepare` write `.gkm/stages.d.ts`,
|
|
12
|
+
* which fills this interface in from the loaded workspace:
|
|
13
|
+
*
|
|
14
|
+
* ```ts
|
|
15
|
+
* declare module '@geekmidas/constructs' {
|
|
16
|
+
* interface Stages { local: 'dev'; deployed: 'staging' | 'prod' }
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* Until that file exists — a fresh clone, before the first run — the interface
|
|
21
|
+
* is empty and every stage type below is `string`, so nothing fails to compile
|
|
22
|
+
* for want of a generated file.
|
|
23
|
+
*/
|
|
24
|
+
interface Stages {}
|
|
25
|
+
/** What `Stages` says under `key`, or `string` while it says nothing. */
|
|
26
|
+
type Declared<TKey extends string> = Stages extends { [K in TKey]: infer TStage extends string; } ? TStage : string;
|
|
27
|
+
/** The stage `gkm dev`, `exec`, `setup` and `test` run as: `stages.local`. */
|
|
28
|
+
type LocalStage = Declared<'local'>;
|
|
29
|
+
/** A stage `gkm deploy --stage` accepts: one of `stages.deployed`. */
|
|
30
|
+
type DeployedStage = Declared<'deployed'>;
|
|
31
|
+
/** What `gkm test` runs as. The CLI's own; no project stage may take it. */
|
|
32
|
+
type TestStage = 'test';
|
|
33
|
+
/** Any stage the project's code can find itself running as. */
|
|
34
|
+
type AnyStage = LocalStage | TestStage | DeployedStage;
|
|
35
|
+
/**
|
|
36
|
+
* What a seed is handed beside its database.
|
|
37
|
+
*
|
|
38
|
+
* Seeds run on every stage, production included, so a seed that should write
|
|
39
|
+
* something only somewhere — a demo tenant on the local stage, never on a
|
|
40
|
+
* deployed one — decides by the stage it is given:
|
|
41
|
+
*
|
|
42
|
+
* ```ts
|
|
43
|
+
* import type { SeedContext } from '@geekmidas/constructs';
|
|
44
|
+
*
|
|
45
|
+
* export async function seed(db: Kysely<Database>, { stage }: SeedContext) {
|
|
46
|
+
* if (stage === 'dev') await insertDemoTenant(db);
|
|
47
|
+
* }
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* A seed reaching a construct's service — a bucket, a cache — builds it from
|
|
51
|
+
* the stage's `env`, as a handler's service is built from its own:
|
|
52
|
+
*
|
|
53
|
+
* ```ts
|
|
54
|
+
* export async function seed(db, { stage, env }: SeedContext) {
|
|
55
|
+
* const bucket = await assets.service.register({
|
|
56
|
+
* envParser: new EnvironmentParser(env),
|
|
57
|
+
* context: serviceContext,
|
|
58
|
+
* });
|
|
59
|
+
* }
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
interface SeedContext {
|
|
63
|
+
/** The stage being seeded: the local one, `test`, or a deployed one. */
|
|
64
|
+
stage: AnyStage;
|
|
65
|
+
/**
|
|
66
|
+
* The stage's resolved environment — every construct's URL, as the runner
|
|
67
|
+
* resolved it. Not `process.env`, which a seed run never populates.
|
|
68
|
+
*/
|
|
69
|
+
env: Readonly<Record<string, string | undefined>>;
|
|
70
|
+
}
|
|
71
|
+
//#endregion
|
|
72
|
+
export { Stages as a, SeedContext as i, DeployedStage as n, TestStage as o, LocalStage as r, AnyStage as t };
|
|
73
|
+
//# sourceMappingURL=stages-DaTaoQei.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stages-DaTaoQei.d.mts","names":[],"sources":["../src/stages.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;UAuBiB;;KAGZ,SAAS,uBAAuB,kBACnC,KAAK,aAAa,2BAEjB;;KAIS,aAAa;;KAGb,gBAAgB;;KAGhB;;KAGA,WAAW,aAAa,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;UA6B/B;;EAEhB,OAAO;;;;;EAKP,KAAK,SAAS"}
|