@geekmidas/constructs 10.0.0-alpha.14 → 10.0.0-alpha.141
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-Bm3aKRdV.mjs → EndpointFactory-C1NlpCAS.mjs} +269 -53
- 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-CLvWuHyt.cjs → EndpointFactory-gqmIRVWg.cjs} +309 -51
- 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-92zavCsV.cjs → HonoEndpointAdaptor-BJlj20fQ.cjs} +79 -31
- package/dist/HonoEndpointAdaptor-BJlj20fQ.cjs.map +1 -0
- package/dist/{HonoEndpointAdaptor-yYaU7jVJ.mjs → HonoEndpointAdaptor-BlbkUDNo.mjs} +76 -28
- package/dist/HonoEndpointAdaptor-BlbkUDNo.mjs.map +1 -0
- package/dist/ObjectSubscriberBuilder-BuuaYcrm.d.cts +129 -0
- package/dist/ObjectSubscriberBuilder-BuuaYcrm.d.cts.map +1 -0
- package/dist/ObjectSubscriberBuilder-CzgYmOUH.d.mts +129 -0
- package/dist/ObjectSubscriberBuilder-CzgYmOUH.d.mts.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-5rCX1Nph.d.cts +83 -0
- package/dist/Subscriber-5rCX1Nph.d.cts.map +1 -0
- package/dist/Subscriber-CW_Dl-YR.d.mts +83 -0
- package/dist/Subscriber-CW_Dl-YR.d.mts.map +1 -0
- package/dist/SubscriberBuilder-BL_GTcwh.mjs +237 -0
- package/dist/SubscriberBuilder-BL_GTcwh.mjs.map +1 -0
- package/dist/SubscriberBuilder-CWzKwX1p.cjs +260 -0
- package/dist/SubscriberBuilder-CWzKwX1p.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 +955 -38
- package/dist/adaptors/testing.cjs.map +1 -1
- package/dist/adaptors/testing.d.cts +437 -39
- package/dist/adaptors/testing.d.cts.map +1 -1
- package/dist/adaptors/testing.d.mts +436 -38
- package/dist/adaptors/testing.d.mts.map +1 -1
- package/dist/adaptors/testing.mjs +929 -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 +290 -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 +286 -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 +32 -10
- package/dist/endpoints/index.d.cts +106 -3
- package/dist/endpoints/index.d.cts.map +1 -0
- package/dist/endpoints/index.d.mts +106 -3
- package/dist/endpoints/index.d.mts.map +1 -0
- package/dist/endpoints/index.mjs +6 -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/inbox-DZdICa8F.d.mts +195 -0
- package/dist/inbox-DZdICa8F.d.mts.map +1 -0
- package/dist/inbox-DqaxrpEk.d.cts +195 -0
- package/dist/inbox-DqaxrpEk.d.cts.map +1 -0
- package/dist/inbox.cjs +291 -0
- package/dist/inbox.cjs.map +1 -0
- package/dist/inbox.d.cts +2 -0
- package/dist/inbox.d.mts +2 -0
- package/dist/inbox.mjs +283 -0
- package/dist/inbox.mjs.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 +74 -70
- package/dist/rest-api.cjs.map +1 -1
- package/dist/rest-api.d.cts +69 -58
- package/dist/rest-api.d.cts.map +1 -1
- package/dist/rest-api.d.mts +69 -58
- package/dist/rest-api.d.mts.map +1 -1
- package/dist/rest-api.mjs +74 -70
- package/dist/rest-api.mjs.map +1 -1
- package/dist/runSubscriber-CC_2C9F2.cjs +133 -0
- package/dist/runSubscriber-CC_2C9F2.cjs.map +1 -0
- package/dist/runSubscriber-DyHWp_Lf.mjs +116 -0
- package/dist/runSubscriber-DyHWp_Lf.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 +64 -4
- package/dist/site.cjs.map +1 -1
- package/dist/site.d.cts +90 -1
- package/dist/site.d.cts.map +1 -1
- package/dist/site.d.mts +90 -1
- package/dist/site.d.mts.map +1 -1
- package/dist/site.mjs +62 -6
- 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 +762 -0
- package/dist/websocket-api.cjs.map +1 -0
- package/dist/websocket-api.d.cts +443 -0
- package/dist/websocket-api.d.cts.map +1 -0
- package/dist/websocket-api.d.mts +443 -0
- package/dist/websocket-api.d.mts.map +1 -0
- package/dist/websocket-api.mjs +748 -0
- package/dist/websocket-api.mjs.map +1 -0
- package/dist/worker.cjs +140 -32
- package/dist/worker.cjs.map +1 -1
- package/dist/worker.d.cts +139 -47
- package/dist/worker.d.cts.map +1 -1
- package/dist/worker.d.mts +139 -47
- package/dist/worker.d.mts.map +1 -1
- package/dist/worker.mjs +141 -33
- package/dist/worker.mjs.map +1 -1
- package/package.json +155 -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-BpZHtJ2W.cjs +0 -1689
- package/dist/Endpoint-BpZHtJ2W.cjs.map +0 -1
- package/dist/Endpoint-C6yyHpRS.d.cts.map +0 -1
- package/dist/Endpoint-DuT4TEEq.d.mts.map +0 -1
- package/dist/Endpoint-ONsly_dq.mjs +0 -1671
- package/dist/Endpoint-ONsly_dq.mjs.map +0 -1
- package/dist/EndpointFactory-Bm3aKRdV.mjs.map +0 -1
- package/dist/EndpointFactory-CLvWuHyt.cjs.map +0 -1
- package/dist/HonoEndpointAdaptor-92zavCsV.cjs.map +0 -1
- package/dist/HonoEndpointAdaptor-yYaU7jVJ.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
package/dist/site.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { edgeTo } from "./construct-interface.mjs";
|
|
2
|
-
import { canonicalId, provideKey } from "@geekmidas/manifest";
|
|
2
|
+
import { WILDCARD_SUBDOMAIN, canonicalId, provideKey } from "@geekmidas/manifest";
|
|
3
3
|
//#region src/site.ts
|
|
4
4
|
/**
|
|
5
5
|
* `StaticSite` — a frontend, declared like anything else.
|
|
@@ -20,10 +20,50 @@ 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
|
+
/** `subdomain: '*'` without `hosts`: nothing would say which hosts are tenants. */
|
|
28
|
+
var WildcardSiteNeedsHosts = class extends Error {
|
|
29
|
+
id;
|
|
30
|
+
constructor(id) {
|
|
31
|
+
super(`'${id}' answers on every subdomain, so it has to say which of them are tenants: pass \`hosts\`, a GET endpoint answering 200 for a host it serves and 404 otherwise.`);
|
|
32
|
+
this.id = id;
|
|
33
|
+
this.name = "WildcardSiteNeedsHosts";
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
/** `hosts` on a site with one host, where there is nothing to check. */
|
|
37
|
+
var SiteHostsNeedsWildcard = class extends Error {
|
|
38
|
+
id;
|
|
39
|
+
constructor(id) {
|
|
40
|
+
super(`'${id}' names a \`hosts\` check but answers on one host. Declare \`subdomain: '*'\` to serve every subdomain, or drop \`hosts\`.`);
|
|
41
|
+
this.id = id;
|
|
42
|
+
this.name = "SiteHostsNeedsWildcard";
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
/** A `hosts` endpoint that is not a `GET`: the edge only ever asks with one. */
|
|
46
|
+
var SiteHostsNotGet = class extends Error {
|
|
47
|
+
id;
|
|
48
|
+
method;
|
|
49
|
+
route;
|
|
50
|
+
constructor(id, method, route) {
|
|
51
|
+
super(`'${id}' checks its hosts with ${method} ${route}, but the edge asks with GET ${route}?domain=<host>. Make it a GET endpoint.`);
|
|
52
|
+
this.id = id;
|
|
53
|
+
this.method = method;
|
|
54
|
+
this.route = route;
|
|
55
|
+
this.name = "SiteHostsNotGet";
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
/** A wildcard site that says it holds the base domain. */
|
|
59
|
+
var WildcardSiteCannotBeRoot = class extends Error {
|
|
60
|
+
id;
|
|
61
|
+
constructor(id) {
|
|
62
|
+
super(`'${id}' answers on every subdomain, so it cannot also hold the base domain. Drop \`root: true\`, and declare the site the base domain points at separately.`);
|
|
63
|
+
this.id = id;
|
|
64
|
+
this.name = "WildcardSiteCannotBeRoot";
|
|
65
|
+
}
|
|
66
|
+
};
|
|
27
67
|
var StaticSite = class StaticSite {
|
|
28
68
|
config;
|
|
29
69
|
dependencies;
|
|
@@ -34,6 +74,11 @@ var StaticSite = class StaticSite {
|
|
|
34
74
|
this.dependencies = dependencies;
|
|
35
75
|
this.id = canonicalId(id);
|
|
36
76
|
this.keys = { url: provideKey(this.id, "url") };
|
|
77
|
+
const wildcard = config.subdomain === WILDCARD_SUBDOMAIN;
|
|
78
|
+
if (wildcard && !config.hosts) throw new WildcardSiteNeedsHosts(this.id);
|
|
79
|
+
if (!wildcard && config.hosts) throw new SiteHostsNeedsWildcard(this.id);
|
|
80
|
+
if (wildcard && config.root) throw new WildcardSiteCannotBeRoot(this.id);
|
|
81
|
+
if (config.hosts && config.hosts.method.toUpperCase() !== "GET") throw new SiteHostsNotGet(this.id, config.hosts.method, config.hosts.route);
|
|
37
82
|
}
|
|
38
83
|
/**
|
|
39
84
|
* What this site calls.
|
|
@@ -50,10 +95,16 @@ var StaticSite = class StaticSite {
|
|
|
50
95
|
return new StaticSite(this.id, this.config, [...this.dependencies, ...constructs.map(edgeTo)]);
|
|
51
96
|
}
|
|
52
97
|
declare() {
|
|
98
|
+
const { hosts } = this.config;
|
|
53
99
|
return [{
|
|
54
100
|
kind: "site",
|
|
55
101
|
id: this.id,
|
|
56
102
|
variant: this.config.variant ?? "static",
|
|
103
|
+
...this.config.subdomain ? { subdomain: this.config.subdomain } : {},
|
|
104
|
+
...hosts ? { hosts: {
|
|
105
|
+
surface: canonicalId(hosts.surface.id),
|
|
106
|
+
path: hosts.route
|
|
107
|
+
} } : {},
|
|
57
108
|
app: {
|
|
58
109
|
path: this.config.path,
|
|
59
110
|
...this.config.port ? { port: this.config.port } : {},
|
|
@@ -61,11 +112,16 @@ var StaticSite = class StaticSite {
|
|
|
61
112
|
},
|
|
62
113
|
...this.config.root ? { root: true } : {},
|
|
63
114
|
dependencies: this.dependencies,
|
|
64
|
-
|
|
115
|
+
...this.config.telemetry ? { telemetry: this.config.telemetry.id } : {},
|
|
116
|
+
...this.config.password ? { password: {
|
|
117
|
+
secret: this.config.password.secret.id,
|
|
118
|
+
stages: [...this.config.password.stages]
|
|
119
|
+
} } : {},
|
|
120
|
+
provides: [this.keys.url, ...hosts ? [provideKey(this.id, "domain"), provideKey(this.id, "protectedSubdomains")] : []]
|
|
65
121
|
}];
|
|
66
122
|
}
|
|
67
123
|
};
|
|
68
124
|
//#endregion
|
|
69
|
-
export { StaticSite };
|
|
125
|
+
export { SiteHostsNeedsWildcard, SiteHostsNotGet, StaticSite, WildcardSiteCannotBeRoot, WildcardSiteNeedsHosts };
|
|
70
126
|
|
|
71
127
|
//# sourceMappingURL=site.mjs.map
|
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; Expo and\n * mobile are out of scope entirely, because an app store is not infrastructure\n * and there is no URL to hand anyone.\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';\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 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}\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\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\tprovides: [this.keys.url],\n\t\t\t},\n\t\t];\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAkFA,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,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,UAAU,CAAC,KAAK,KAAK,GAAG;EACzB,CACD;CACD;AACD"}
|
|
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\tWILDCARD_SUBDOMAIN,\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\t * `'*'` answers on every subdomain nothing else does — one host per\n\t * tenant, `acme.myapp.com` — and then `hosts` names which of them are\n\t * real. Every other app keeps its own host, and a project has at most one\n\t * such site.\n\t */\n\tsubdomain?: string;\n\t/**\n\t * With `subdomain: '*'`, the route that says which hosts are tenants: an\n\t * exported `GET` endpoint the edge asks before it serves a host,\n\t * `?domain=<host>`, answering `200` for a tenant and `404` otherwise.\n\t *\n\t * It runs without a session and belongs to no public API.\n\t */\n\thosts?: SiteHostsEndpoint;\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\n/**\n * The shape of the endpoint `hosts` names — read structurally, so a site\n * module never loads the endpoint machinery to say which route it means.\n */\nexport interface SiteHostsEndpoint {\n\troute: string;\n\tmethod: string;\n\tsurface: { id: string };\n}\n\n/** `subdomain: '*'` without `hosts`: nothing would say which hosts are tenants. */\nexport class WildcardSiteNeedsHosts extends Error {\n\tconstructor(readonly id: string) {\n\t\tsuper(\n\t\t\t`'${id}' answers on every subdomain, so it has to say which of them ` +\n\t\t\t\t`are tenants: pass \\`hosts\\`, a GET endpoint answering 200 for a ` +\n\t\t\t\t`host it serves and 404 otherwise.`,\n\t\t);\n\t\tthis.name = 'WildcardSiteNeedsHosts';\n\t}\n}\n\n/** `hosts` on a site with one host, where there is nothing to check. */\nexport class SiteHostsNeedsWildcard extends Error {\n\tconstructor(readonly id: string) {\n\t\tsuper(\n\t\t\t`'${id}' names a \\`hosts\\` check but answers on one host. ` +\n\t\t\t\t`Declare \\`subdomain: '*'\\` to serve every subdomain, or drop \\`hosts\\`.`,\n\t\t);\n\t\tthis.name = 'SiteHostsNeedsWildcard';\n\t}\n}\n\n/** A `hosts` endpoint that is not a `GET`: the edge only ever asks with one. */\nexport class SiteHostsNotGet extends Error {\n\tconstructor(\n\t\treadonly id: string,\n\t\treadonly method: string,\n\t\treadonly route: string,\n\t) {\n\t\tsuper(\n\t\t\t`'${id}' checks its hosts with ${method} ${route}, but the edge asks ` +\n\t\t\t\t`with GET ${route}?domain=<host>. Make it a GET endpoint.`,\n\t\t);\n\t\tthis.name = 'SiteHostsNotGet';\n\t}\n}\n\n/** A wildcard site that says it holds the base domain. */\nexport class WildcardSiteCannotBeRoot extends Error {\n\tconstructor(readonly id: string) {\n\t\tsuper(\n\t\t\t`'${id}' answers on every subdomain, so it cannot also hold the base ` +\n\t\t\t\t`domain. Drop \\`root: true\\`, and declare the site the base domain ` +\n\t\t\t\t`points at separately.`,\n\t\t);\n\t\tthis.name = 'WildcardSiteCannotBeRoot';\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\n\t\tconst wildcard = config.subdomain === WILDCARD_SUBDOMAIN;\n\t\tif (wildcard && !config.hosts) throw new WildcardSiteNeedsHosts(this.id);\n\t\tif (!wildcard && config.hosts) throw new SiteHostsNeedsWildcard(this.id);\n\t\tif (wildcard && config.root) throw new WildcardSiteCannotBeRoot(this.id);\n\t\tif (config.hosts && config.hosts.method.toUpperCase() !== 'GET') {\n\t\t\tthrow new SiteHostsNotGet(\n\t\t\t\tthis.id,\n\t\t\t\tconfig.hosts.method,\n\t\t\t\tconfig.hosts.route,\n\t\t\t);\n\t\t}\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\tconst { hosts } = this.config;\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\t...(hosts\n\t\t\t\t\t? {\n\t\t\t\t\t\t\thosts: {\n\t\t\t\t\t\t\t\tsurface: canonicalId(hosts.surface.id),\n\t\t\t\t\t\t\t\tpath: hosts.route,\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\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: [\n\t\t\t\t\tthis.keys.url,\n\t\t\t\t\t...(hosts\n\t\t\t\t\t\t? [\n\t\t\t\t\t\t\t\tprovideKey(this.id, 'domain'),\n\t\t\t\t\t\t\t\tprovideKey(this.id, 'protectedSubdomains'),\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t: []),\n\t\t\t\t],\n\t\t\t},\n\t\t];\n\t}\n}\n"],"mappings":"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"}
|
|
@@ -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"}
|
|
@@ -1,4 +1,137 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_SubscriberBuilder = require("../SubscriberBuilder-
|
|
2
|
+
const require_SubscriberBuilder = require("../SubscriberBuilder-CWzKwX1p.cjs");
|
|
3
|
+
const require_runSubscriber = require("../runSubscriber-CC_2C9F2.cjs");
|
|
4
|
+
let _geekmidas_events = require("@geekmidas/events");
|
|
5
|
+
let _geekmidas_services = require("@geekmidas/services");
|
|
6
|
+
let _geekmidas_errors = require("@geekmidas/errors");
|
|
7
|
+
let _geekmidas_events_sns = require("@geekmidas/events/sns");
|
|
8
|
+
//#region src/subscribers/SnsPushSubscriberAdaptor.ts
|
|
9
|
+
/**
|
|
10
|
+
* A topic subscriber run by SNS pushing to an HTTP endpoint, rather than by a
|
|
11
|
+
* poller.
|
|
12
|
+
*
|
|
13
|
+
* The notification is read as the Lambda event SNS would have invoked a
|
|
14
|
+
* function with, and run through the same parsing, services and handler as the
|
|
15
|
+
* Lambda adaptor — without its middy wrapper, which is Lambda's alone: a
|
|
16
|
+
* server serving this route has no reason to install `@middy/core`.
|
|
17
|
+
*/
|
|
18
|
+
var SnsPushSubscriberAdaptor = class {
|
|
19
|
+
envParser;
|
|
20
|
+
subscriber;
|
|
21
|
+
options;
|
|
22
|
+
constructor(envParser, subscriber, options) {
|
|
23
|
+
this.envParser = envParser;
|
|
24
|
+
this.subscriber = subscriber;
|
|
25
|
+
this.options = options;
|
|
26
|
+
}
|
|
27
|
+
async handle(body, request = {}) {
|
|
28
|
+
const message = body;
|
|
29
|
+
if (typeof message?.Type !== "string" || !message.TopicArn) return refuse(400, "not an SNS message");
|
|
30
|
+
if (message.TopicArn !== this.options.topicArn) return refuse(403, `not subscribed to ${message.TopicArn}`);
|
|
31
|
+
if (this.options.verify) try {
|
|
32
|
+
await (0, _geekmidas_events_sns.verifySnsMessage)(message);
|
|
33
|
+
} catch (error) {
|
|
34
|
+
this.subscriber.logger.warn({
|
|
35
|
+
err: error,
|
|
36
|
+
topicArn: message.TopicArn
|
|
37
|
+
}, "Refused an SNS message that did not verify");
|
|
38
|
+
return refuse(403, error.name);
|
|
39
|
+
}
|
|
40
|
+
switch (message.Type) {
|
|
41
|
+
case "SubscriptionConfirmation":
|
|
42
|
+
if (this.options.confirm) {
|
|
43
|
+
await this.options.confirm(message);
|
|
44
|
+
this.subscriber.logger.info({ topicArn: message.TopicArn }, "Confirmed SNS subscription");
|
|
45
|
+
return {
|
|
46
|
+
status: 200,
|
|
47
|
+
body: { status: "confirmed" }
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
await (0, _geekmidas_events_sns.confirmSnsSubscription)(this.options.emulatorEndpoint && message.SubscribeURL ? {
|
|
51
|
+
...message,
|
|
52
|
+
SubscribeURL: throughEndpoint(message.SubscribeURL, this.options.emulatorEndpoint)
|
|
53
|
+
} : message);
|
|
54
|
+
this.subscriber.logger.info({ topicArn: message.TopicArn }, "Confirmed SNS subscription");
|
|
55
|
+
return {
|
|
56
|
+
status: 200,
|
|
57
|
+
body: { status: "confirmed" }
|
|
58
|
+
};
|
|
59
|
+
case "Notification":
|
|
60
|
+
if (this.options.subscriptionArn && request.subscriptionArn !== this.options.subscriptionArn) {
|
|
61
|
+
this.subscriber.logger.warn({
|
|
62
|
+
topicArn: message.TopicArn,
|
|
63
|
+
subscriptionArn: request.subscriptionArn
|
|
64
|
+
}, "Refused an SNS notification from a subscription the deploy did not make");
|
|
65
|
+
return refuse(403, "not the recorded subscription");
|
|
66
|
+
}
|
|
67
|
+
try {
|
|
68
|
+
await this.notify(message);
|
|
69
|
+
return {
|
|
70
|
+
status: 200,
|
|
71
|
+
body: { status: "ok" }
|
|
72
|
+
};
|
|
73
|
+
} catch (error) {
|
|
74
|
+
return refuse(500, error.name);
|
|
75
|
+
}
|
|
76
|
+
default: return {
|
|
77
|
+
status: 200,
|
|
78
|
+
body: { status: "ignored" }
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
async notify(message) {
|
|
83
|
+
const requestId = message.MessageId;
|
|
84
|
+
const logger = this.subscriber.logger.child({ requestId });
|
|
85
|
+
await (0, _geekmidas_services.runWithRequestContext)({
|
|
86
|
+
logger,
|
|
87
|
+
requestId,
|
|
88
|
+
startTime: Date.now(),
|
|
89
|
+
operation: `subscriber ${this.subscriber.topicName ?? "sns"}`
|
|
90
|
+
}, () => (0, _geekmidas_events.consumeTraced)({
|
|
91
|
+
system: "aws_sns",
|
|
92
|
+
destination: this.subscriber.topicName ?? message.TopicArn.split(":").pop() ?? message.TopicArn,
|
|
93
|
+
type: message.MessageAttributes?.type?.Value,
|
|
94
|
+
messageId: message.MessageId
|
|
95
|
+
}, (0, _geekmidas_events.carrierFromAttributes)(message.MessageAttributes), () => this.run(message, logger)));
|
|
96
|
+
}
|
|
97
|
+
async run(message, logger) {
|
|
98
|
+
try {
|
|
99
|
+
const { services, db } = await require_runSubscriber.subscriberContext(this.subscriber, this.envParser);
|
|
100
|
+
const events = await require_runSubscriber.subscribedEvents(this.subscriber, (0, _geekmidas_events_sns.toSnsEvent)(message), logger);
|
|
101
|
+
await require_runSubscriber.runSubscriber(this.subscriber, {
|
|
102
|
+
events,
|
|
103
|
+
services,
|
|
104
|
+
logger,
|
|
105
|
+
db
|
|
106
|
+
});
|
|
107
|
+
} catch (error) {
|
|
108
|
+
logger.error(error, "Error processing subscriber");
|
|
109
|
+
throw (0, _geekmidas_errors.wrapError)(error);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
/** `url`, sent to `endpoint`'s origin instead of its own. */
|
|
114
|
+
function throughEndpoint(url, endpoint) {
|
|
115
|
+
const target = new URL(url);
|
|
116
|
+
const origin = new URL(endpoint);
|
|
117
|
+
target.protocol = origin.protocol;
|
|
118
|
+
target.host = origin.host;
|
|
119
|
+
return target.toString();
|
|
120
|
+
}
|
|
121
|
+
function refuse(status, error) {
|
|
122
|
+
return {
|
|
123
|
+
status,
|
|
124
|
+
body: {
|
|
125
|
+
status: "refused",
|
|
126
|
+
error
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
//#endregion
|
|
131
|
+
exports.ObjectSubscriberBuilder = require_SubscriberBuilder.ObjectSubscriberBuilder;
|
|
132
|
+
exports.ObjectSubscriberHasNoEvents = require_SubscriberBuilder.ObjectSubscriberHasNoEvents;
|
|
133
|
+
exports.SnsPushSubscriberAdaptor = SnsPushSubscriberAdaptor;
|
|
3
134
|
exports.Subscriber = require_SubscriberBuilder.Subscriber;
|
|
4
135
|
exports.SubscriberBuilder = require_SubscriberBuilder.SubscriberBuilder;
|
|
136
|
+
|
|
137
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["verifySnsMessage","confirmSnsSubscription","runWithRequestContext","consumeTraced","carrierFromAttributes","subscriberContext","subscribedEvents","toSnsEvent","runSubscriber","wrapError"],"sources":["../../src/subscribers/SnsPushSubscriberAdaptor.ts"],"sourcesContent":["import type { EnvironmentParser } from '@geekmidas/envkit';\nimport { wrapError } from '@geekmidas/errors';\nimport { carrierFromAttributes, consumeTraced } from '@geekmidas/events';\nimport {\n\tconfirmSnsSubscription,\n\ttype SnsHttpMessage,\n\ttoSnsEvent,\n\tverifySnsMessage,\n} from '@geekmidas/events/sns';\nimport { runWithRequestContext } from '@geekmidas/services';\nimport {\n\trunSubscriber,\n\tsubscribedEvents,\n\tsubscriberContext,\n} from './runSubscriber';\nimport type { Subscriber } from './Subscriber';\n\nexport interface SnsPushOptions {\n\t/** The topic this subscriber is subscribed to. Anything else is refused. */\n\ttopicArn: string;\n\t/**\n\t * Verify each message's signature. Off only against an emulator, which\n\t * signs nothing — decided by the connection string's endpoint, never by\n\t * anything the request says about itself.\n\t */\n\tverify: boolean;\n\t/**\n\t * The emulator's address, as this server was configured with it. An\n\t * emulator names itself in `SubscribeURL` by the port it listens on inside\n\t * its container, which is not the port published to the host — so against\n\t * one, the confirmation is sent here instead. From configuration, never\n\t * from the request.\n\t */\n\temulatorEndpoint?: string;\n\t/**\n\t * The subscription the deploy made for this route, as it recorded it\n\t * (`GKM_SNS_SUBSCRIPTIONS`). A notification naming another one in its\n\t * `x-amz-sns-subscription-arn` header is refused — a subscription someone\n\t * added by hand, pointing at this route.\n\t *\n\t * Defence in depth, not authentication: SNS does not sign its headers.\n\t * What authenticates a message is its signature and its `TopicArn`.\n\t */\n\tsubscriptionArn?: string;\n\t/**\n\t * How a confirmation is confirmed. By visiting its `SubscribeURL` when\n\t * unset — what an emulator takes. Against SNS itself, the server confirms\n\t * through the API with `AuthenticateOnUnsubscribe`, so the `UnsubscribeURL`\n\t * every notification carries cannot cut the route off.\n\t */\n\tconfirm?: (message: SnsHttpMessage) => Promise<unknown>;\n}\n\n/** What SNS said about a request, outside its signed body. */\nexport interface SnsPushRequest {\n\t/** The `x-amz-sns-subscription-arn` header. */\n\tsubscriptionArn?: string;\n}\n\n/** What to answer SNS with. A non-2xx tells SNS to retry. */\nexport interface SnsPushResponse {\n\tstatus: 200 | 400 | 403 | 500;\n\tbody: { status: string; error?: string };\n}\n\n/**\n * A topic subscriber run by SNS pushing to an HTTP endpoint, rather than by a\n * poller.\n *\n * The notification is read as the Lambda event SNS would have invoked a\n * function with, and run through the same parsing, services and handler as the\n * Lambda adaptor — without its middy wrapper, which is Lambda's alone: a\n * server serving this route has no reason to install `@middy/core`.\n */\nexport class SnsPushSubscriberAdaptor {\n\tconstructor(\n\t\tprivate readonly envParser: EnvironmentParser<{}>,\n\t\treadonly subscriber: Subscriber<any, any, any, any, any, any, any>,\n\t\tprivate readonly options: SnsPushOptions,\n\t) {}\n\n\tasync handle(\n\t\tbody: unknown,\n\t\trequest: SnsPushRequest = {},\n\t): Promise<SnsPushResponse> {\n\t\tconst message = body as SnsHttpMessage;\n\t\tif (typeof message?.Type !== 'string' || !message.TopicArn) {\n\t\t\treturn refuse(400, 'not an SNS message');\n\t\t}\n\t\t// Checked before the signature: a genuine message for another topic is\n\t\t// still not this subscriber's to confirm or to handle.\n\t\tif (message.TopicArn !== this.options.topicArn) {\n\t\t\treturn refuse(403, `not subscribed to ${message.TopicArn}`);\n\t\t}\n\n\t\tif (this.options.verify) {\n\t\t\ttry {\n\t\t\t\tawait verifySnsMessage(message);\n\t\t\t} catch (error) {\n\t\t\t\tthis.subscriber.logger.warn(\n\t\t\t\t\t{ err: error, topicArn: message.TopicArn },\n\t\t\t\t\t'Refused an SNS message that did not verify',\n\t\t\t\t);\n\t\t\t\treturn refuse(403, (error as Error).name);\n\t\t\t}\n\t\t}\n\n\t\tswitch (message.Type) {\n\t\t\tcase 'SubscriptionConfirmation':\n\t\t\t\tif (this.options.confirm) {\n\t\t\t\t\tawait this.options.confirm(message);\n\t\t\t\t\tthis.subscriber.logger.info(\n\t\t\t\t\t\t{ topicArn: message.TopicArn },\n\t\t\t\t\t\t'Confirmed SNS subscription',\n\t\t\t\t\t);\n\t\t\t\t\treturn { status: 200, body: { status: 'confirmed' } };\n\t\t\t\t}\n\t\t\t\tawait confirmSnsSubscription(\n\t\t\t\t\tthis.options.emulatorEndpoint && message.SubscribeURL\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t...message,\n\t\t\t\t\t\t\t\tSubscribeURL: throughEndpoint(\n\t\t\t\t\t\t\t\t\tmessage.SubscribeURL,\n\t\t\t\t\t\t\t\t\tthis.options.emulatorEndpoint,\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: message,\n\t\t\t\t);\n\t\t\t\tthis.subscriber.logger.info(\n\t\t\t\t\t{ topicArn: message.TopicArn },\n\t\t\t\t\t'Confirmed SNS subscription',\n\t\t\t\t);\n\t\t\t\treturn { status: 200, body: { status: 'confirmed' } };\n\t\t\tcase 'Notification':\n\t\t\t\tif (\n\t\t\t\t\tthis.options.subscriptionArn &&\n\t\t\t\t\trequest.subscriptionArn !== this.options.subscriptionArn\n\t\t\t\t) {\n\t\t\t\t\tthis.subscriber.logger.warn(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttopicArn: message.TopicArn,\n\t\t\t\t\t\t\tsubscriptionArn: request.subscriptionArn,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t'Refused an SNS notification from a subscription the deploy did not make',\n\t\t\t\t\t);\n\t\t\t\t\treturn refuse(403, 'not the recorded subscription');\n\t\t\t\t}\n\t\t\t\ttry {\n\t\t\t\t\tawait this.notify(message);\n\t\t\t\t\treturn { status: 200, body: { status: 'ok' } };\n\t\t\t\t} catch (error) {\n\t\t\t\t\t// Already logged. A 500 makes SNS retry, which is the point of\n\t\t\t\t\t// answering at all.\n\t\t\t\t\treturn refuse(500, (error as Error).name);\n\t\t\t\t}\n\t\t\tdefault:\n\t\t\t\treturn { status: 200, body: { status: 'ignored' } };\n\t\t}\n\t}\n\n\tprivate async notify(message: SnsHttpMessage): Promise<void> {\n\t\tconst requestId = message.MessageId;\n\t\tconst logger = this.subscriber.logger.child({ requestId });\n\n\t\tawait runWithRequestContext(\n\t\t\t{\n\t\t\t\tlogger,\n\t\t\t\trequestId,\n\t\t\t\tstartTime: Date.now(),\n\t\t\t\toperation: `subscriber ${this.subscriber.topicName ?? 'sns'}`,\n\t\t\t},\n\t\t\t// A CONSUMER span, child of the publisher's: SNS hands the trace\n\t\t\t// context on in the message attributes it was published with.\n\t\t\t() =>\n\t\t\t\tconsumeTraced(\n\t\t\t\t\t{\n\t\t\t\t\t\tsystem: 'aws_sns',\n\t\t\t\t\t\tdestination:\n\t\t\t\t\t\t\tthis.subscriber.topicName ??\n\t\t\t\t\t\t\tmessage.TopicArn.split(':').pop() ??\n\t\t\t\t\t\t\tmessage.TopicArn,\n\t\t\t\t\t\ttype: message.MessageAttributes?.type?.Value,\n\t\t\t\t\t\tmessageId: message.MessageId,\n\t\t\t\t\t},\n\t\t\t\t\tcarrierFromAttributes(message.MessageAttributes),\n\t\t\t\t\t() => this.run(message, logger),\n\t\t\t\t),\n\t\t);\n\t}\n\n\tprivate async run(\n\t\tmessage: SnsHttpMessage,\n\t\tlogger: Subscriber<any, any, any, any, any, any, any>['logger'],\n\t): Promise<void> {\n\t\ttry {\n\t\t\tconst { services, db } = await subscriberContext(\n\t\t\t\tthis.subscriber,\n\t\t\t\tthis.envParser,\n\t\t\t);\n\t\t\tconst events = await subscribedEvents(\n\t\t\t\tthis.subscriber,\n\t\t\t\ttoSnsEvent(message),\n\t\t\t\tlogger,\n\t\t\t);\n\t\t\tawait runSubscriber(this.subscriber, {\n\t\t\t\tevents,\n\t\t\t\tservices,\n\t\t\t\tlogger,\n\t\t\t\tdb,\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tlogger.error(error as object, 'Error processing subscriber');\n\t\t\tthrow wrapError(error);\n\t\t}\n\t}\n}\n\n/** `url`, sent to `endpoint`'s origin instead of its own. */\nfunction throughEndpoint(url: string, endpoint: string): string {\n\tconst target = new URL(url);\n\tconst origin = new URL(endpoint);\n\ttarget.protocol = origin.protocol;\n\ttarget.host = origin.host;\n\treturn target.toString();\n}\n\nfunction refuse(\n\tstatus: SnsPushResponse['status'],\n\terror: string,\n): SnsPushResponse {\n\treturn { status, body: { status: 'refused', error } };\n}\n"],"mappings":"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"}
|
|
@@ -1,3 +1,74 @@
|
|
|
1
|
-
import { t as Subscriber } from "../Subscriber-
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { t as Subscriber } from "../Subscriber-5rCX1Nph.cjs";
|
|
2
|
+
import { a as ObjectSubscriberHasNoEvents, i as ObjectSubscriberHandler, n as ObjectSubscriberBuilder, o as SubscriberBuilder, r as ObjectSubscriberContext, t as ObjectSubscriber } from "../ObjectSubscriberBuilder-BuuaYcrm.cjs";
|
|
3
|
+
import { EnvironmentParser } from "@geekmidas/envkit";
|
|
4
|
+
import { SnsHttpMessage } from "@geekmidas/events/sns";
|
|
5
|
+
//#region src/subscribers/SnsPushSubscriberAdaptor.d.ts
|
|
6
|
+
interface SnsPushOptions {
|
|
7
|
+
/** The topic this subscriber is subscribed to. Anything else is refused. */
|
|
8
|
+
topicArn: string;
|
|
9
|
+
/**
|
|
10
|
+
* Verify each message's signature. Off only against an emulator, which
|
|
11
|
+
* signs nothing — decided by the connection string's endpoint, never by
|
|
12
|
+
* anything the request says about itself.
|
|
13
|
+
*/
|
|
14
|
+
verify: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* The emulator's address, as this server was configured with it. An
|
|
17
|
+
* emulator names itself in `SubscribeURL` by the port it listens on inside
|
|
18
|
+
* its container, which is not the port published to the host — so against
|
|
19
|
+
* one, the confirmation is sent here instead. From configuration, never
|
|
20
|
+
* from the request.
|
|
21
|
+
*/
|
|
22
|
+
emulatorEndpoint?: string;
|
|
23
|
+
/**
|
|
24
|
+
* The subscription the deploy made for this route, as it recorded it
|
|
25
|
+
* (`GKM_SNS_SUBSCRIPTIONS`). A notification naming another one in its
|
|
26
|
+
* `x-amz-sns-subscription-arn` header is refused — a subscription someone
|
|
27
|
+
* added by hand, pointing at this route.
|
|
28
|
+
*
|
|
29
|
+
* Defence in depth, not authentication: SNS does not sign its headers.
|
|
30
|
+
* What authenticates a message is its signature and its `TopicArn`.
|
|
31
|
+
*/
|
|
32
|
+
subscriptionArn?: string;
|
|
33
|
+
/**
|
|
34
|
+
* How a confirmation is confirmed. By visiting its `SubscribeURL` when
|
|
35
|
+
* unset — what an emulator takes. Against SNS itself, the server confirms
|
|
36
|
+
* through the API with `AuthenticateOnUnsubscribe`, so the `UnsubscribeURL`
|
|
37
|
+
* every notification carries cannot cut the route off.
|
|
38
|
+
*/
|
|
39
|
+
confirm?: (message: SnsHttpMessage) => Promise<unknown>;
|
|
40
|
+
}
|
|
41
|
+
/** What SNS said about a request, outside its signed body. */
|
|
42
|
+
interface SnsPushRequest {
|
|
43
|
+
/** The `x-amz-sns-subscription-arn` header. */
|
|
44
|
+
subscriptionArn?: string;
|
|
45
|
+
}
|
|
46
|
+
/** What to answer SNS with. A non-2xx tells SNS to retry. */
|
|
47
|
+
interface SnsPushResponse {
|
|
48
|
+
status: 200 | 400 | 403 | 500;
|
|
49
|
+
body: {
|
|
50
|
+
status: string;
|
|
51
|
+
error?: string;
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* A topic subscriber run by SNS pushing to an HTTP endpoint, rather than by a
|
|
56
|
+
* poller.
|
|
57
|
+
*
|
|
58
|
+
* The notification is read as the Lambda event SNS would have invoked a
|
|
59
|
+
* function with, and run through the same parsing, services and handler as the
|
|
60
|
+
* Lambda adaptor — without its middy wrapper, which is Lambda's alone: a
|
|
61
|
+
* server serving this route has no reason to install `@middy/core`.
|
|
62
|
+
*/
|
|
63
|
+
export declare class SnsPushSubscriberAdaptor {
|
|
64
|
+
private readonly envParser;
|
|
65
|
+
readonly subscriber: Subscriber<any, any, any, any, any, any, any>;
|
|
66
|
+
private readonly options;
|
|
67
|
+
constructor(envParser: EnvironmentParser<{}>, subscriber: Subscriber<any, any, any, any, any, any, any>, options: SnsPushOptions);
|
|
68
|
+
handle(body: unknown, request?: SnsPushRequest): Promise<SnsPushResponse>;
|
|
69
|
+
private notify;
|
|
70
|
+
private run;
|
|
71
|
+
}
|
|
72
|
+
//#endregion
|
|
73
|
+
export { type ObjectSubscriber, ObjectSubscriberBuilder, type ObjectSubscriberContext, type ObjectSubscriberHandler, ObjectSubscriberHasNoEvents, type SnsPushOptions, type SnsPushRequest, type SnsPushResponse, Subscriber, SubscriberBuilder };
|
|
74
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/subscribers/SnsPushSubscriberAdaptor.ts"],"mappings":";;;;;UAiBiB;;EAEhB;;;;;;EAMA;;;;;;;;EAQA;;;;;;;;;;EAUA;;;;;;;EAOA,WAAW,SAAS,mBAAmB;;;UAIvB;;EAEhB;;;UAIgB;EAChB;EACA;IAAQ;IAAgB;;;;;;;;;;;;qBAYZ;mBAEM;WACR,YAAY;mBACJ;EAHlB,YACkB,WAAW,uBACnB,YAAY,+CACJ,SAAS;EAGrB,OACL,eACA,UAAS,iBACP,QAAQ;UA4EG;UA8BA"}
|
|
@@ -1,3 +1,74 @@
|
|
|
1
|
-
import { t as Subscriber } from "../Subscriber-
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { t as Subscriber } from "../Subscriber-CW_Dl-YR.mjs";
|
|
2
|
+
import { a as ObjectSubscriberHasNoEvents, i as ObjectSubscriberHandler, n as ObjectSubscriberBuilder, o as SubscriberBuilder, r as ObjectSubscriberContext, t as ObjectSubscriber } from "../ObjectSubscriberBuilder-CzgYmOUH.mjs";
|
|
3
|
+
import { EnvironmentParser } from "@geekmidas/envkit";
|
|
4
|
+
import { SnsHttpMessage } from "@geekmidas/events/sns";
|
|
5
|
+
//#region src/subscribers/SnsPushSubscriberAdaptor.d.ts
|
|
6
|
+
interface SnsPushOptions {
|
|
7
|
+
/** The topic this subscriber is subscribed to. Anything else is refused. */
|
|
8
|
+
topicArn: string;
|
|
9
|
+
/**
|
|
10
|
+
* Verify each message's signature. Off only against an emulator, which
|
|
11
|
+
* signs nothing — decided by the connection string's endpoint, never by
|
|
12
|
+
* anything the request says about itself.
|
|
13
|
+
*/
|
|
14
|
+
verify: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* The emulator's address, as this server was configured with it. An
|
|
17
|
+
* emulator names itself in `SubscribeURL` by the port it listens on inside
|
|
18
|
+
* its container, which is not the port published to the host — so against
|
|
19
|
+
* one, the confirmation is sent here instead. From configuration, never
|
|
20
|
+
* from the request.
|
|
21
|
+
*/
|
|
22
|
+
emulatorEndpoint?: string;
|
|
23
|
+
/**
|
|
24
|
+
* The subscription the deploy made for this route, as it recorded it
|
|
25
|
+
* (`GKM_SNS_SUBSCRIPTIONS`). A notification naming another one in its
|
|
26
|
+
* `x-amz-sns-subscription-arn` header is refused — a subscription someone
|
|
27
|
+
* added by hand, pointing at this route.
|
|
28
|
+
*
|
|
29
|
+
* Defence in depth, not authentication: SNS does not sign its headers.
|
|
30
|
+
* What authenticates a message is its signature and its `TopicArn`.
|
|
31
|
+
*/
|
|
32
|
+
subscriptionArn?: string;
|
|
33
|
+
/**
|
|
34
|
+
* How a confirmation is confirmed. By visiting its `SubscribeURL` when
|
|
35
|
+
* unset — what an emulator takes. Against SNS itself, the server confirms
|
|
36
|
+
* through the API with `AuthenticateOnUnsubscribe`, so the `UnsubscribeURL`
|
|
37
|
+
* every notification carries cannot cut the route off.
|
|
38
|
+
*/
|
|
39
|
+
confirm?: (message: SnsHttpMessage) => Promise<unknown>;
|
|
40
|
+
}
|
|
41
|
+
/** What SNS said about a request, outside its signed body. */
|
|
42
|
+
interface SnsPushRequest {
|
|
43
|
+
/** The `x-amz-sns-subscription-arn` header. */
|
|
44
|
+
subscriptionArn?: string;
|
|
45
|
+
}
|
|
46
|
+
/** What to answer SNS with. A non-2xx tells SNS to retry. */
|
|
47
|
+
interface SnsPushResponse {
|
|
48
|
+
status: 200 | 400 | 403 | 500;
|
|
49
|
+
body: {
|
|
50
|
+
status: string;
|
|
51
|
+
error?: string;
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* A topic subscriber run by SNS pushing to an HTTP endpoint, rather than by a
|
|
56
|
+
* poller.
|
|
57
|
+
*
|
|
58
|
+
* The notification is read as the Lambda event SNS would have invoked a
|
|
59
|
+
* function with, and run through the same parsing, services and handler as the
|
|
60
|
+
* Lambda adaptor — without its middy wrapper, which is Lambda's alone: a
|
|
61
|
+
* server serving this route has no reason to install `@middy/core`.
|
|
62
|
+
*/
|
|
63
|
+
export declare class SnsPushSubscriberAdaptor {
|
|
64
|
+
private readonly envParser;
|
|
65
|
+
readonly subscriber: Subscriber<any, any, any, any, any, any, any>;
|
|
66
|
+
private readonly options;
|
|
67
|
+
constructor(envParser: EnvironmentParser<{}>, subscriber: Subscriber<any, any, any, any, any, any, any>, options: SnsPushOptions);
|
|
68
|
+
handle(body: unknown, request?: SnsPushRequest): Promise<SnsPushResponse>;
|
|
69
|
+
private notify;
|
|
70
|
+
private run;
|
|
71
|
+
}
|
|
72
|
+
//#endregion
|
|
73
|
+
export { type ObjectSubscriber, ObjectSubscriberBuilder, type ObjectSubscriberContext, type ObjectSubscriberHandler, ObjectSubscriberHasNoEvents, type SnsPushOptions, type SnsPushRequest, type SnsPushResponse, Subscriber, SubscriberBuilder };
|
|
74
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/subscribers/SnsPushSubscriberAdaptor.ts"],"mappings":";;;;;UAiBiB;;EAEhB;;;;;;EAMA;;;;;;;;EAQA;;;;;;;;;;EAUA;;;;;;;EAOA,WAAW,SAAS,mBAAmB;;;UAIvB;;EAEhB;;;UAIgB;EAChB;EACA;IAAQ;IAAgB;;;;;;;;;;;;qBAYZ;mBAEM;WACR,YAAY;mBACJ;EAHlB,YACkB,WAAW,uBACnB,YAAY,+CACJ,SAAS;EAGrB,OACL,eACA,UAAS,iBACP,QAAQ;UA4EG;UA8BA"}
|