@geekmidas/constructs 10.0.0-alpha.13 → 10.0.0-alpha.130
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,78 @@
|
|
|
1
|
+
import { _ as parsePattern, a as ProcessorCache, c as ProcessorParams, d as ParsedPattern, f as PatternParams, g as matchPattern, h as fillPattern, i as Processor, l as ProcessorResult, m as ProcessorPatternInvalid, n as ProcessorNativeInvalid, o as ProcessorContext, p as ProcessorParamMissing, r as DERIVED_PREFIX, s as ProcessorHandler, t as ProcessorBuilder, u as SourceObject } from "../ProcessorBuilder-B2_stA8f.mjs";
|
|
2
|
+
import { ServiceDiscovery } from "@geekmidas/services";
|
|
3
|
+
import { EnvironmentParser } from "@geekmidas/envkit";
|
|
4
|
+
//#region src/processors/AWSLambdaProcessor.d.ts
|
|
5
|
+
/** The parts of a Lambda function URL event a processor reads. */
|
|
6
|
+
interface FunctionUrlEvent {
|
|
7
|
+
rawPath: string;
|
|
8
|
+
requestContext: {
|
|
9
|
+
http: {
|
|
10
|
+
method: string;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
/** What a function URL answers with. */
|
|
15
|
+
interface FunctionUrlResult {
|
|
16
|
+
statusCode: number;
|
|
17
|
+
headers: Record<string, string>;
|
|
18
|
+
body: string;
|
|
19
|
+
isBase64Encoded: boolean;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* A processor as a Lambda behind a function URL — the CDN's origin for its
|
|
23
|
+
* pattern on AWS. The URL takes IAM auth and the CDN signs each request, so
|
|
24
|
+
* the function cannot be called around the cache.
|
|
25
|
+
*/
|
|
26
|
+
export declare class AWSLambdaProcessor {
|
|
27
|
+
private readonly serve;
|
|
28
|
+
constructor(processor: Processor<string, any, any, any>, envParser?: EnvironmentParser<{}>);
|
|
29
|
+
handler: (event: FunctionUrlEvent) => Promise<FunctionUrlResult>;
|
|
30
|
+
}
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region src/processors/runProcessor.d.ts
|
|
33
|
+
/** What a processor answers, for whichever server or function carries it. */
|
|
34
|
+
interface ProcessorResponse {
|
|
35
|
+
status: number;
|
|
36
|
+
headers: Record<string, string>;
|
|
37
|
+
body?: Uint8Array | string;
|
|
38
|
+
}
|
|
39
|
+
/** The object a request addressed is not in the bucket. */
|
|
40
|
+
export declare class ProcessorSourceMissing extends Error {
|
|
41
|
+
readonly key: string;
|
|
42
|
+
constructor(key: string);
|
|
43
|
+
}
|
|
44
|
+
/** The header a response carries, by how long it may be kept. */
|
|
45
|
+
export declare function cacheControl(cache: ProcessorCache | undefined): string;
|
|
46
|
+
/** Where a processor keeps the derivative for one request. */
|
|
47
|
+
export declare function derivedKey(processor: Processor<string, any, any, any>, params: Readonly<Record<string, string>>, key: string): string;
|
|
48
|
+
interface ProcessorRequestOptions {
|
|
49
|
+
serviceDiscovery: ServiceDiscovery<any>;
|
|
50
|
+
/** How the bucket is read through a presigned address. */
|
|
51
|
+
fetch?: typeof fetch;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Answer one request with the first processor whose pattern matches it, or
|
|
55
|
+
* `undefined` when none does.
|
|
56
|
+
*
|
|
57
|
+
* In order: the parameters are parsed by the processor's schema (400 when it
|
|
58
|
+
* refuses them); the key must be one of the file server's open paths (404
|
|
59
|
+
* otherwise, as an unsigned read of it would be); a derivative already in the
|
|
60
|
+
* bucket is answered without running anything; and only then is the handler
|
|
61
|
+
* run, its `immutable` result written through for next time.
|
|
62
|
+
*/
|
|
63
|
+
export declare function handleProcessorRequest(processors: readonly Processor<string, any, any, any>[], request: {
|
|
64
|
+
method: string;
|
|
65
|
+
path: string;
|
|
66
|
+
}, options: ProcessorRequestOptions): Promise<ProcessorResponse | undefined>;
|
|
67
|
+
/**
|
|
68
|
+
* A request handler for a set of processors — what a generated entry serves
|
|
69
|
+
* — with its services discovered from the default environment parser: the
|
|
70
|
+
* process's environment and the credentials `gkm` injected.
|
|
71
|
+
*/
|
|
72
|
+
export declare function processorServer(processors: readonly Processor<string, any, any, any>[], envParser?: EnvironmentParser<{}>): (request: {
|
|
73
|
+
method: string;
|
|
74
|
+
path: string;
|
|
75
|
+
}) => Promise<ProcessorResponse | undefined>;
|
|
76
|
+
//#endregion
|
|
77
|
+
export { DERIVED_PREFIX, type ParsedPattern, type PatternParams, Processor, ProcessorBuilder, type ProcessorCache, type ProcessorContext, type ProcessorHandler, ProcessorNativeInvalid, ProcessorParamMissing, type ProcessorParams, ProcessorPatternInvalid, type ProcessorRequestOptions, type ProcessorResponse, type ProcessorResult, type SourceObject, fillPattern, matchPattern, parsePattern };
|
|
78
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/processors/AWSLambdaProcessor.ts","../../src/processors/runProcessor.ts"],"mappings":";;;;;UAMiB;EAChB;EACA;IAAkB;MAAQ;;;;;UAIV;EAChB;EACA,SAAS;EACT;EACA;;;;;;;qBAQY;mBACK;EAEjB,YACC,WAAW,kCACX,YAAW;EAKZ,UAAO,OAAiB,qBAAmB,QAAQ;;;;;UCpBnC;EAChB;EACA,SAAS;EACT,OAAO;;;qBAIK,+BAA+B;WACtB;EAArB,YAAqB;;;wBAUN,aAAa,OAAO;;wBAOpB,WACf,WAAW,kCACX,QAAQ,SAAS,yBACjB;UAKgB;EAChB,kBAAkB;;EAElB,eAAe;;;;;;;;;;;;wBAaM,uBACrB,qBAAqB,oCACrB;EAAW;EAAgB;GAC3B,SAAS,0BACP,QAAQ;;;;;;wBAgCK,gBACf,qBAAqB,oCACrB,YAAW,yBACR;EACH;EACA;MACK,QAAQ"}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { a as parsePattern, c as DERIVED_PREFIX, i as matchPattern, l as Processor, n as ProcessorPatternInvalid, o as ProcessorBuilder, r as fillPattern, s as ProcessorNativeInvalid, t as ProcessorParamMissing } from "../pattern-C1CEcglD.mjs";
|
|
2
|
+
import { t as defaultEnvParser } from "../surfaceEnv-wMT5QzgZ.mjs";
|
|
3
|
+
import { ServiceDiscovery, runWithRequestContext } from "@geekmidas/services";
|
|
4
|
+
//#region src/processors/runProcessor.ts
|
|
5
|
+
/** The object a request addressed is not in the bucket. */
|
|
6
|
+
var ProcessorSourceMissing = class extends Error {
|
|
7
|
+
key;
|
|
8
|
+
constructor(key) {
|
|
9
|
+
super(`'${key}' is not in the bucket, so there is nothing to process.`);
|
|
10
|
+
this.key = key;
|
|
11
|
+
this.name = "ProcessorSourceMissing";
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
/** What a refusal or a miss may be kept for: long enough to absorb a burst. */
|
|
15
|
+
const SHORT = "public, max-age=60";
|
|
16
|
+
/** The header a response carries, by how long it may be kept. */
|
|
17
|
+
function cacheControl(cache) {
|
|
18
|
+
if (cache === "immutable") return "public, max-age=31536000, immutable";
|
|
19
|
+
if (cache === "none") return "no-store";
|
|
20
|
+
return `public, max-age=${cache?.maxAge ?? 3600}`;
|
|
21
|
+
}
|
|
22
|
+
/** Where a processor keeps the derivative for one request. */
|
|
23
|
+
function derivedKey(processor, params, key) {
|
|
24
|
+
return `${DERIVED_PREFIX}${fillPattern(processor.parsed, params, key).slice(1)}`;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Answer one request with the first processor whose pattern matches it, or
|
|
28
|
+
* `undefined` when none does.
|
|
29
|
+
*
|
|
30
|
+
* In order: the parameters are parsed by the processor's schema (400 when it
|
|
31
|
+
* refuses them); the key must be one of the file server's open paths (404
|
|
32
|
+
* otherwise, as an unsigned read of it would be); a derivative already in the
|
|
33
|
+
* bucket is answered without running anything; and only then is the handler
|
|
34
|
+
* run, its `immutable` result written through for next time.
|
|
35
|
+
*/
|
|
36
|
+
async function handleProcessorRequest(processors, request, options) {
|
|
37
|
+
const method = request.method.toUpperCase();
|
|
38
|
+
for (const processor of processors) {
|
|
39
|
+
const match = matchPattern(processor.parsed, request.path);
|
|
40
|
+
if (!match) continue;
|
|
41
|
+
if (method !== "GET" && method !== "HEAD") return text(405, "Method Not Allowed", "no-store", { allow: "GET, HEAD" });
|
|
42
|
+
return runWithRequestContext({
|
|
43
|
+
logger: processor.logger,
|
|
44
|
+
requestId: `processor-${Date.now()}`,
|
|
45
|
+
startTime: Date.now(),
|
|
46
|
+
operation: `processor ${processor.pattern}`
|
|
47
|
+
}, () => run(processor, match, options));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* A request handler for a set of processors — what a generated entry serves
|
|
52
|
+
* — with its services discovered from the default environment parser: the
|
|
53
|
+
* process's environment and the credentials `gkm` injected.
|
|
54
|
+
*/
|
|
55
|
+
function processorServer(processors, envParser = defaultEnvParser()) {
|
|
56
|
+
const serviceDiscovery = ServiceDiscovery.getInstance(envParser);
|
|
57
|
+
return (request) => handleProcessorRequest(processors, request, { serviceDiscovery });
|
|
58
|
+
}
|
|
59
|
+
async function run(processor, match, options) {
|
|
60
|
+
const logger = processor.logger;
|
|
61
|
+
const fetcher = options.fetch ?? fetch;
|
|
62
|
+
const { key } = match;
|
|
63
|
+
const schema = processor.options.paramsSchema;
|
|
64
|
+
let params = match.params;
|
|
65
|
+
if (schema) {
|
|
66
|
+
const parsed = await schema["~standard"].validate(match.params);
|
|
67
|
+
if (parsed.issues) return text(400, "Bad Request", SHORT);
|
|
68
|
+
params = parsed.value;
|
|
69
|
+
}
|
|
70
|
+
if (key.startsWith(DERIVED_PREFIX) || !processor.options.serves(key)) return text(404, "Not Found", SHORT);
|
|
71
|
+
const services = await options.serviceDiscovery.register(processor.services);
|
|
72
|
+
const storage = services[processor.options.origin.serviceName];
|
|
73
|
+
const derived = derivedKey(processor, match.params, key);
|
|
74
|
+
const kept = await read(storage, derived, fetcher);
|
|
75
|
+
if (kept) return {
|
|
76
|
+
status: 200,
|
|
77
|
+
headers: {
|
|
78
|
+
"content-type": kept.contentType ?? "application/octet-stream",
|
|
79
|
+
"cache-control": cacheControl("immutable"),
|
|
80
|
+
"x-gkm-processor": "kept"
|
|
81
|
+
},
|
|
82
|
+
body: new Uint8Array(await kept.response.arrayBuffer())
|
|
83
|
+
};
|
|
84
|
+
let source;
|
|
85
|
+
const load = async () => {
|
|
86
|
+
if (source) return source;
|
|
87
|
+
const found = await read(storage, key, fetcher);
|
|
88
|
+
if (!found) throw new ProcessorSourceMissing(key);
|
|
89
|
+
source = found.response;
|
|
90
|
+
return source;
|
|
91
|
+
};
|
|
92
|
+
const object = {
|
|
93
|
+
key,
|
|
94
|
+
bytes: async () => new Uint8Array(await (await load()).arrayBuffer()),
|
|
95
|
+
stream: async () => {
|
|
96
|
+
const body = (await load()).body;
|
|
97
|
+
if (!body) throw new ProcessorSourceMissing(key);
|
|
98
|
+
return body;
|
|
99
|
+
},
|
|
100
|
+
contentType: async () => (await load()).headers.get("content-type") ?? void 0
|
|
101
|
+
};
|
|
102
|
+
let result;
|
|
103
|
+
try {
|
|
104
|
+
result = await processor.handler({
|
|
105
|
+
params,
|
|
106
|
+
key,
|
|
107
|
+
object,
|
|
108
|
+
logger,
|
|
109
|
+
services
|
|
110
|
+
});
|
|
111
|
+
} catch (error) {
|
|
112
|
+
if (error instanceof ProcessorSourceMissing) return text(404, "Not Found", SHORT);
|
|
113
|
+
logger.error({
|
|
114
|
+
err: error,
|
|
115
|
+
key
|
|
116
|
+
}, "Processor failed");
|
|
117
|
+
return text(500, "Internal Server Error", "no-store");
|
|
118
|
+
}
|
|
119
|
+
const body = typeof result.body === "string" ? new TextEncoder().encode(result.body) : result.body;
|
|
120
|
+
if (result.cache === "immutable") await storage.upload(derived, Buffer.from(body), result.contentType).catch((error) => logger.warn({
|
|
121
|
+
err: error,
|
|
122
|
+
key: derived
|
|
123
|
+
}, "Could not keep derivative"));
|
|
124
|
+
return {
|
|
125
|
+
status: 200,
|
|
126
|
+
headers: {
|
|
127
|
+
"content-type": result.contentType,
|
|
128
|
+
"cache-control": cacheControl(result.cache),
|
|
129
|
+
"x-gkm-processor": "made"
|
|
130
|
+
},
|
|
131
|
+
body
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
/** An object through a presigned address, or nothing when it is not there. */
|
|
135
|
+
async function read(storage, key, fetcher) {
|
|
136
|
+
const response = await fetcher(await storage.getDownloadURL({ path: key }));
|
|
137
|
+
if (!response.ok) {
|
|
138
|
+
await response.body?.cancel().catch(() => void 0);
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
const contentType = response.headers.get("content-type") ?? void 0;
|
|
142
|
+
return {
|
|
143
|
+
response,
|
|
144
|
+
...contentType ? { contentType } : {}
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
function text(status, body, cache, extra = {}) {
|
|
148
|
+
return {
|
|
149
|
+
status,
|
|
150
|
+
headers: {
|
|
151
|
+
"content-type": "text/plain; charset=utf-8",
|
|
152
|
+
"cache-control": cache,
|
|
153
|
+
...extra
|
|
154
|
+
},
|
|
155
|
+
body
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
//#endregion
|
|
159
|
+
//#region src/processors/AWSLambdaProcessor.ts
|
|
160
|
+
/**
|
|
161
|
+
* A processor as a Lambda behind a function URL — the CDN's origin for its
|
|
162
|
+
* pattern on AWS. The URL takes IAM auth and the CDN signs each request, so
|
|
163
|
+
* the function cannot be called around the cache.
|
|
164
|
+
*/
|
|
165
|
+
var AWSLambdaProcessor = class {
|
|
166
|
+
serve;
|
|
167
|
+
constructor(processor, envParser = defaultEnvParser()) {
|
|
168
|
+
this.serve = processorServer([processor], envParser);
|
|
169
|
+
}
|
|
170
|
+
handler = async (event) => {
|
|
171
|
+
const response = await this.serve({
|
|
172
|
+
method: event.requestContext.http.method,
|
|
173
|
+
path: event.rawPath
|
|
174
|
+
});
|
|
175
|
+
if (!response) return {
|
|
176
|
+
statusCode: 404,
|
|
177
|
+
headers: { "cache-control": "public, max-age=60" },
|
|
178
|
+
body: "",
|
|
179
|
+
isBase64Encoded: false
|
|
180
|
+
};
|
|
181
|
+
const body = response.body ?? "";
|
|
182
|
+
return {
|
|
183
|
+
statusCode: response.status,
|
|
184
|
+
headers: response.headers,
|
|
185
|
+
body: typeof body === "string" ? body : Buffer.from(body).toString("base64"),
|
|
186
|
+
isBase64Encoded: typeof body !== "string"
|
|
187
|
+
};
|
|
188
|
+
};
|
|
189
|
+
};
|
|
190
|
+
//#endregion
|
|
191
|
+
export { AWSLambdaProcessor, DERIVED_PREFIX, Processor, ProcessorBuilder, ProcessorNativeInvalid, ProcessorParamMissing, ProcessorPatternInvalid, ProcessorSourceMissing, cacheControl, derivedKey, fillPattern, handleProcessorRequest, matchPattern, parsePattern, processorServer };
|
|
192
|
+
|
|
193
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/processors/runProcessor.ts","../../src/processors/AWSLambdaProcessor.ts"],"sourcesContent":["import type { EnvironmentParser } from '@geekmidas/envkit';\nimport type { Logger } from '@geekmidas/logger';\nimport { runWithRequestContext, ServiceDiscovery } from '@geekmidas/services';\nimport type { StorageClient } from '@geekmidas/storage';\nimport { defaultEnvParser } from '../endpoints/surfaceEnv';\nimport {\n\tDERIVED_PREFIX,\n\ttype Processor,\n\ttype ProcessorCache,\n\ttype SourceObject,\n} from './Processor';\nimport { fillPattern, matchPattern } from './pattern';\n\n/** What a processor answers, for whichever server or function carries it. */\nexport interface ProcessorResponse {\n\tstatus: number;\n\theaders: Record<string, string>;\n\tbody?: Uint8Array | string;\n}\n\n/** The object a request addressed is not in the bucket. */\nexport class ProcessorSourceMissing extends Error {\n\tconstructor(readonly key: string) {\n\t\tsuper(`'${key}' is not in the bucket, so there is nothing to process.`);\n\t\tthis.name = 'ProcessorSourceMissing';\n\t}\n}\n\n/** What a refusal or a miss may be kept for: long enough to absorb a burst. */\nconst SHORT = 'public, max-age=60';\n\n/** The header a response carries, by how long it may be kept. */\nexport function cacheControl(cache: ProcessorCache | undefined): string {\n\tif (cache === 'immutable') return 'public, max-age=31536000, immutable';\n\tif (cache === 'none') return 'no-store';\n\treturn `public, max-age=${cache?.maxAge ?? 3600}`;\n}\n\n/** Where a processor keeps the derivative for one request. */\nexport function derivedKey(\n\tprocessor: Processor<string, any, any, any>,\n\tparams: Readonly<Record<string, string>>,\n\tkey: string,\n): string {\n\treturn `${DERIVED_PREFIX}${fillPattern(processor.parsed, params, key).slice(1)}`;\n}\n\nexport interface ProcessorRequestOptions {\n\tserviceDiscovery: ServiceDiscovery<any>;\n\t/** How the bucket is read through a presigned address. */\n\tfetch?: typeof fetch;\n}\n\n/**\n * Answer one request with the first processor whose pattern matches it, or\n * `undefined` when none does.\n *\n * In order: the parameters are parsed by the processor's schema (400 when it\n * refuses them); the key must be one of the file server's open paths (404\n * otherwise, as an unsigned read of it would be); a derivative already in the\n * bucket is answered without running anything; and only then is the handler\n * run, its `immutable` result written through for next time.\n */\nexport async function handleProcessorRequest(\n\tprocessors: readonly Processor<string, any, any, any>[],\n\trequest: { method: string; path: string },\n\toptions: ProcessorRequestOptions,\n): Promise<ProcessorResponse | undefined> {\n\tconst method = request.method.toUpperCase();\n\n\tfor (const processor of processors) {\n\t\tconst match = matchPattern(processor.parsed, request.path);\n\t\tif (!match) continue;\n\n\t\tif (method !== 'GET' && method !== 'HEAD') {\n\t\t\treturn text(405, 'Method Not Allowed', 'no-store', {\n\t\t\t\tallow: 'GET, HEAD',\n\t\t\t});\n\t\t}\n\n\t\treturn runWithRequestContext(\n\t\t\t{\n\t\t\t\tlogger: processor.logger,\n\t\t\t\trequestId: `processor-${Date.now()}`,\n\t\t\t\tstartTime: Date.now(),\n\t\t\t\toperation: `processor ${processor.pattern}`,\n\t\t\t},\n\t\t\t() => run(processor, match, options),\n\t\t);\n\t}\n\n\treturn undefined;\n}\n\n/**\n * A request handler for a set of processors — what a generated entry serves\n * — with its services discovered from the default environment parser: the\n * process's environment and the credentials `gkm` injected.\n */\nexport function processorServer(\n\tprocessors: readonly Processor<string, any, any, any>[],\n\tenvParser: EnvironmentParser<{}> = defaultEnvParser(),\n): (request: {\n\tmethod: string;\n\tpath: string;\n}) => Promise<ProcessorResponse | undefined> {\n\tconst serviceDiscovery = ServiceDiscovery.getInstance(envParser);\n\treturn (request) =>\n\t\thandleProcessorRequest(processors, request, { serviceDiscovery });\n}\n\nasync function run(\n\tprocessor: Processor<string, any, any, any>,\n\tmatch: { params: Record<string, string>; key: string },\n\toptions: ProcessorRequestOptions,\n): Promise<ProcessorResponse> {\n\tconst logger = processor.logger as Logger;\n\tconst fetcher = options.fetch ?? fetch;\n\tconst { key } = match;\n\n\tconst schema = processor.options.paramsSchema;\n\tlet params: unknown = match.params;\n\tif (schema) {\n\t\tconst parsed = await schema['~standard'].validate(match.params);\n\t\tif (parsed.issues) return text(400, 'Bad Request', SHORT);\n\t\tparams = parsed.value;\n\t}\n\n\t// A derivative is never itself a source, and a private object is never\n\t// processed: a processor serves exactly what an unsigned read would.\n\tif (key.startsWith(DERIVED_PREFIX) || !processor.options.serves(key)) {\n\t\treturn text(404, 'Not Found', SHORT);\n\t}\n\n\tconst services: Record<string, unknown> =\n\t\tawait options.serviceDiscovery.register(processor.services);\n\tconst storage = services[\n\t\tprocessor.options.origin.serviceName\n\t] as StorageClient;\n\n\tconst derived = derivedKey(processor, match.params, key);\n\tconst kept = await read(storage, derived, fetcher);\n\tif (kept) {\n\t\treturn {\n\t\t\tstatus: 200,\n\t\t\theaders: {\n\t\t\t\t'content-type': kept.contentType ?? 'application/octet-stream',\n\t\t\t\t'cache-control': cacheControl('immutable'),\n\t\t\t\t'x-gkm-processor': 'kept',\n\t\t\t},\n\t\t\tbody: new Uint8Array(await kept.response.arrayBuffer()),\n\t\t};\n\t}\n\n\tlet source: Response | undefined;\n\tconst load = async (): Promise<Response> => {\n\t\tif (source) return source;\n\t\tconst found = await read(storage, key, fetcher);\n\t\tif (!found) throw new ProcessorSourceMissing(key);\n\t\tsource = found.response;\n\t\treturn source;\n\t};\n\tconst object: SourceObject = {\n\t\tkey,\n\t\tbytes: async () => new Uint8Array(await (await load()).arrayBuffer()),\n\t\tstream: async () => {\n\t\t\tconst body = (await load()).body;\n\t\t\tif (!body) throw new ProcessorSourceMissing(key);\n\t\t\treturn body;\n\t\t},\n\t\tcontentType: async () =>\n\t\t\t(await load()).headers.get('content-type') ?? undefined,\n\t};\n\n\tlet result: Awaited<ReturnType<typeof processor.handler>>;\n\ttry {\n\t\tresult = await processor.handler({\n\t\t\tparams,\n\t\t\tkey,\n\t\t\tobject,\n\t\t\tlogger,\n\t\t\tservices,\n\t\t} as never);\n\t} catch (error) {\n\t\tif (error instanceof ProcessorSourceMissing) {\n\t\t\treturn text(404, 'Not Found', SHORT);\n\t\t}\n\t\tlogger.error({ err: error, key }, 'Processor failed');\n\t\treturn text(500, 'Internal Server Error', 'no-store');\n\t}\n\n\tconst body =\n\t\ttypeof result.body === 'string'\n\t\t\t? new TextEncoder().encode(result.body)\n\t\t\t: result.body;\n\n\t// Kept only when it can never change: anything else would be served from\n\t// the bucket long after its handler would have answered differently.\n\tif (result.cache === 'immutable') {\n\t\tawait storage\n\t\t\t.upload(derived, Buffer.from(body), result.contentType)\n\t\t\t.catch((error: unknown) =>\n\t\t\t\tlogger.warn({ err: error, key: derived }, 'Could not keep derivative'),\n\t\t\t);\n\t}\n\n\treturn {\n\t\tstatus: 200,\n\t\theaders: {\n\t\t\t'content-type': result.contentType,\n\t\t\t'cache-control': cacheControl(result.cache),\n\t\t\t'x-gkm-processor': 'made',\n\t\t},\n\t\tbody,\n\t};\n}\n\n/** An object through a presigned address, or nothing when it is not there. */\nasync function read(\n\tstorage: StorageClient,\n\tkey: string,\n\tfetcher: typeof fetch,\n): Promise<{ response: Response; contentType?: string } | undefined> {\n\tconst url = await storage.getDownloadURL({ path: key });\n\tconst response = await fetcher(url);\n\tif (!response.ok) {\n\t\tawait response.body?.cancel().catch(() => undefined);\n\t\treturn undefined;\n\t}\n\tconst contentType = response.headers.get('content-type') ?? undefined;\n\treturn { response, ...(contentType ? { contentType } : {}) };\n}\n\nfunction text(\n\tstatus: number,\n\tbody: string,\n\tcache: string,\n\textra: Record<string, string> = {},\n): ProcessorResponse {\n\treturn {\n\t\tstatus,\n\t\theaders: {\n\t\t\t'content-type': 'text/plain; charset=utf-8',\n\t\t\t'cache-control': cache,\n\t\t\t...extra,\n\t\t},\n\t\tbody,\n\t};\n}\n","import type { EnvironmentParser } from '@geekmidas/envkit';\nimport { defaultEnvParser } from '../endpoints/surfaceEnv';\nimport type { Processor } from './Processor';\nimport { processorServer } from './runProcessor';\n\n/** The parts of a Lambda function URL event a processor reads. */\nexport interface FunctionUrlEvent {\n\trawPath: string;\n\trequestContext: { http: { method: string } };\n}\n\n/** What a function URL answers with. */\nexport interface FunctionUrlResult {\n\tstatusCode: number;\n\theaders: Record<string, string>;\n\tbody: string;\n\tisBase64Encoded: boolean;\n}\n\n/**\n * A processor as a Lambda behind a function URL — the CDN's origin for its\n * pattern on AWS. The URL takes IAM auth and the CDN signs each request, so\n * the function cannot be called around the cache.\n */\nexport class AWSLambdaProcessor {\n\tprivate readonly serve: ReturnType<typeof processorServer>;\n\n\tconstructor(\n\t\tprocessor: Processor<string, any, any, any>,\n\t\tenvParser: EnvironmentParser<{}> = defaultEnvParser(),\n\t) {\n\t\tthis.serve = processorServer([processor], envParser);\n\t}\n\n\thandler = async (event: FunctionUrlEvent): Promise<FunctionUrlResult> => {\n\t\tconst response = await this.serve({\n\t\t\tmethod: event.requestContext.http.method,\n\t\t\tpath: event.rawPath,\n\t\t});\n\t\tif (!response) {\n\t\t\treturn {\n\t\t\t\tstatusCode: 404,\n\t\t\t\theaders: { 'cache-control': 'public, max-age=60' },\n\t\t\t\tbody: '',\n\t\t\t\tisBase64Encoded: false,\n\t\t\t};\n\t\t}\n\t\tconst body = response.body ?? '';\n\t\treturn {\n\t\t\tstatusCode: response.status,\n\t\t\theaders: response.headers,\n\t\t\tbody:\n\t\t\t\ttypeof body === 'string' ? body : Buffer.from(body).toString('base64'),\n\t\t\tisBase64Encoded: typeof body !== 'string',\n\t\t};\n\t};\n}\n"],"mappings":"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"}
|
package/dist/queue/index.cjs
CHANGED
|
@@ -1,193 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
let _geekmidas_events = require("@geekmidas/events");
|
|
8
|
-
//#region src/queue/Queue.ts
|
|
9
|
-
/**
|
|
10
|
-
* A queue worker — a point-to-point SQS-style queue and its single consumer.
|
|
11
|
-
* Unlike a `Subscriber` (topic fan-out, filtered by `subscribedEvents`), a queue
|
|
12
|
-
* drains every message of its one `message` type. Build one with `q` (see
|
|
13
|
-
* `QueueBuilder`); `gkm build` discovers it into the manifest's `queues` field.
|
|
14
|
-
*
|
|
15
|
-
* The producer side is {@link Queue.publisher} — a ready-to-inject `Service`
|
|
16
|
-
* that any endpoint/function drops into `.services([...])` to send messages.
|
|
17
|
-
*/
|
|
18
|
-
var Queue = class extends require_Construct.Construct {
|
|
19
|
-
name;
|
|
20
|
-
handler;
|
|
21
|
-
messageSchema;
|
|
22
|
-
timeout;
|
|
23
|
-
services;
|
|
24
|
-
logger;
|
|
25
|
-
batchSize;
|
|
26
|
-
fifo;
|
|
27
|
-
__IS_QUEUE__ = true;
|
|
28
|
-
static isQueue(obj) {
|
|
29
|
-
return Boolean(obj && obj.__IS_QUEUE__ === true && obj.type === "dev.geekmidas.function.queue");
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* The canonical id this queue is declared under.
|
|
33
|
-
*
|
|
34
|
-
* Derived from the name rather than given separately, so `emails` and
|
|
35
|
-
* `Emails` are one queue. The name stays what it was: it is the wire `type`
|
|
36
|
-
* a producer sends and the worker subscribes to, and changing that would
|
|
37
|
-
* silently orphan in-flight messages.
|
|
38
|
-
*/
|
|
39
|
-
id;
|
|
40
|
-
/**
|
|
41
|
-
* The producer's env key. Read by both {@link declare} and
|
|
42
|
-
* {@link publisher}, so what the target publishes and what the producer
|
|
43
|
-
* looks up cannot drift.
|
|
44
|
-
*/
|
|
45
|
-
connectionKey;
|
|
46
|
-
constructor(name, handler, messageSchema, timeout = 3e4, services = [], logger = _geekmidas_logger_console.DEFAULT_LOGGER, batchSize, fifo, constructs = []) {
|
|
47
|
-
super("dev.geekmidas.function.queue", logger, services, [], void 0, void 0, timeout, void 0, void 0, constructs);
|
|
48
|
-
this.name = name;
|
|
49
|
-
this.handler = handler;
|
|
50
|
-
this.messageSchema = messageSchema;
|
|
51
|
-
this.timeout = timeout;
|
|
52
|
-
this.services = services;
|
|
53
|
-
this.logger = logger;
|
|
54
|
-
this.batchSize = batchSize;
|
|
55
|
-
this.fifo = fifo;
|
|
56
|
-
this.id = (0, _geekmidas_manifest.canonicalId)(name);
|
|
57
|
-
this.connectionKey = (0, _geekmidas_manifest.provideKey)(this.id, "publisherConnectionString");
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* What this queue is in the manifest.
|
|
61
|
-
*
|
|
62
|
-
* A queue is a resource, not a handler: the worker is reached *through* it,
|
|
63
|
-
* so the declaration carries the producer's key and nothing about the code
|
|
64
|
-
* that drains it. The local target reads this to know which broker has to be
|
|
65
|
-
* running and what connection string to inject.
|
|
66
|
-
*/
|
|
67
|
-
declare() {
|
|
68
|
-
return [{
|
|
69
|
-
kind: "queue",
|
|
70
|
-
id: this.id,
|
|
71
|
-
provides: [this.connectionKey],
|
|
72
|
-
...this.fifo ? { fifo: true } : {},
|
|
73
|
-
worker: {
|
|
74
|
-
id: `${this.id}Worker`,
|
|
75
|
-
handler: `${this.id}.handler`,
|
|
76
|
-
dependencies: []
|
|
77
|
-
}
|
|
78
|
-
}];
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* The producer side — a `Service` exposing an `EventPublisher` typed to this
|
|
82
|
-
* queue's message. Inject it via `.services([queue.publisher])`; the handler
|
|
83
|
-
* then calls `services.<name>Publisher.publish([{ type, payload }])`.
|
|
84
|
-
*
|
|
85
|
-
* It reads `<NAME>_PUBLISHER_CONNECTION_STRING` and builds the transport from
|
|
86
|
-
* the URL protocol — `pgboss://` locally, `sqs://` deployed — so the same
|
|
87
|
-
* code publishes to Postgres in dev and SQS in prod. Because it's a `Service`,
|
|
88
|
-
* `Construct.getEnvironment()` sniffs it, so the env requirement flows into
|
|
89
|
-
* the manifest and infra links exactly this queue with least privilege.
|
|
90
|
-
*/
|
|
91
|
-
/**
|
|
92
|
-
* The queue as a dependency — what `.dependsOn([emailsQueue])` dissolves
|
|
93
|
-
* into, reachable as `services.emails`.
|
|
94
|
-
*
|
|
95
|
-
* It is the producer: a consumer is the worker written right here, so the
|
|
96
|
-
* only thing another construct can want from a queue is the ability to send
|
|
97
|
-
* to it. {@link publisher} is the same service under its older
|
|
98
|
-
* `<name>Publisher` key, kept for `.services([queue.publisher])`.
|
|
99
|
-
*/
|
|
100
|
-
get service() {
|
|
101
|
-
const { register } = this.publisher;
|
|
102
|
-
return {
|
|
103
|
-
serviceName: (0, _geekmidas_manifest.serviceKey)(this.id),
|
|
104
|
-
register
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
get publisher() {
|
|
108
|
-
const envVar = this.connectionKey;
|
|
109
|
-
return {
|
|
110
|
-
serviceName: `${this.name}Publisher`,
|
|
111
|
-
async register({ envParser }) {
|
|
112
|
-
const { connectionString } = envParser.create((get) => ({ connectionString: get(envVar).string() })).parse();
|
|
113
|
-
return _geekmidas_events.Publisher.fromConnectionString(connectionString);
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
};
|
|
118
|
-
//#endregion
|
|
119
|
-
//#region src/queue/QueueBuilder.ts
|
|
120
|
-
/**
|
|
121
|
-
* Builds a {@link Queue} worker — `q.queue('orders').services([db]).message(schema).handle(fn)`.
|
|
122
|
-
* Services are an array (sniffed for required env vars); `message` is the typed
|
|
123
|
-
* job payload; `handle` is the single consumer. The queue name is captured as a
|
|
124
|
-
* literal so `queue.publisher` is typed to `{ type: '<name>', payload }`.
|
|
125
|
-
*/
|
|
126
|
-
var QueueBuilder = class {
|
|
127
|
-
_name;
|
|
128
|
-
_messageSchema;
|
|
129
|
-
_timeout = 3e4;
|
|
130
|
-
_batchSize;
|
|
131
|
-
_fifo;
|
|
132
|
-
_services = [];
|
|
133
|
-
/** The construct ids `.dependsOn()` named — what the manifest records. */
|
|
134
|
-
_constructs = [];
|
|
135
|
-
_logger = _geekmidas_logger_console.DEFAULT_LOGGER;
|
|
136
|
-
/** The queue name — drives the infra queue and its `<NAME>_*` env vars. */
|
|
137
|
-
queue(name) {
|
|
138
|
-
return require_clone.cloneWith(this, { _name: name });
|
|
139
|
-
}
|
|
140
|
-
timeout(timeout) {
|
|
141
|
-
return require_clone.cloneWith(this, { _timeout: timeout });
|
|
142
|
-
}
|
|
143
|
-
/** SQS event-source batch size (deployed). */
|
|
144
|
-
batchSize(batchSize) {
|
|
145
|
-
return require_clone.cloneWith(this, { _batchSize: batchSize });
|
|
146
|
-
}
|
|
147
|
-
/** Mark the queue as FIFO (deployed). */
|
|
148
|
-
fifo(fifo = true) {
|
|
149
|
-
return require_clone.cloneWith(this, { _fifo: fifo });
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* Depend on constructs — a database, a bucket, a mail sender, a queue, a
|
|
153
|
-
* topic.
|
|
154
|
-
*
|
|
155
|
-
* It records the edge and dissolves each construct's client into the
|
|
156
|
-
* handler's service record under the construct's own id, so
|
|
157
|
-
* `.dependsOn([uploads])` is what makes `services.uploads` exist and type.
|
|
158
|
-
*
|
|
159
|
-
* Constructs only. A `Service` does not match the shape, which is what keeps
|
|
160
|
-
* env sniffing confined to `.services()` and the explicit lift.
|
|
161
|
-
*/
|
|
162
|
-
dependsOn(constructs) {
|
|
163
|
-
const services = require_construct_interface.servicesOf(constructs);
|
|
164
|
-
return require_clone.cloneWith(this, {
|
|
165
|
-
_services: [...this._services, ...services],
|
|
166
|
-
_constructs: require_construct_interface.idsOf(constructs, this._constructs)
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
services(services) {
|
|
170
|
-
return require_clone.cloneWith(this, { _services: [...this._services, ...services] });
|
|
171
|
-
}
|
|
172
|
-
logger(logger) {
|
|
173
|
-
return require_clone.cloneWith(this, { _logger: logger });
|
|
174
|
-
}
|
|
175
|
-
/** The typed message (job) payload the queue carries. */
|
|
176
|
-
message(schema) {
|
|
177
|
-
return require_clone.cloneWith(this, { _messageSchema: schema });
|
|
178
|
-
}
|
|
179
|
-
handle(fn) {
|
|
180
|
-
if (!this._name) throw new Error("Queue requires a name — call .queue(name) before .handle().");
|
|
181
|
-
if (!this._messageSchema) throw new Error("Queue requires a message schema — call .message(schema) before .handle().");
|
|
182
|
-
return new Queue(this._name, fn, this._messageSchema, this._timeout, this._services, this._logger, this._batchSize, this._fifo, this._constructs);
|
|
183
|
-
}
|
|
184
|
-
};
|
|
185
|
-
//#endregion
|
|
186
|
-
//#region src/queue/index.ts
|
|
187
|
-
const q = new QueueBuilder();
|
|
188
|
-
//#endregion
|
|
189
|
-
exports.Queue = Queue;
|
|
190
|
-
exports.QueueBuilder = QueueBuilder;
|
|
191
|
-
exports.q = q;
|
|
192
|
-
|
|
193
|
-
//# sourceMappingURL=index.cjs.map
|
|
2
|
+
const require_Queue = require("../Queue-D4Iaidrs.cjs");
|
|
3
|
+
const require_QueueBuilder = require("../QueueBuilder-BxsZ9o5z.cjs");
|
|
4
|
+
exports.Queue = require_Queue.Queue;
|
|
5
|
+
exports.QueueNeedsMessage = require_QueueBuilder.QueueNeedsMessage;
|
|
6
|
+
exports.QueueNeedsName = require_QueueBuilder.QueueNeedsName;
|
package/dist/queue/index.d.cts
CHANGED
|
@@ -1,53 +1,3 @@
|
|
|
1
|
-
import { t as
|
|
2
|
-
import { n as
|
|
3
|
-
|
|
4
|
-
import { Logger as Logger$1 } from "@geekmidas/logger";
|
|
5
|
-
import { Service } from "@geekmidas/services";
|
|
6
|
-
//#region src/queue/QueueBuilder.d.ts
|
|
7
|
-
/**
|
|
8
|
-
* Builds a {@link Queue} worker — `q.queue('orders').services([db]).message(schema).handle(fn)`.
|
|
9
|
-
* Services are an array (sniffed for required env vars); `message` is the typed
|
|
10
|
-
* job payload; `handle` is the single consumer. The queue name is captured as a
|
|
11
|
-
* literal so `queue.publisher` is typed to `{ type: '<name>', payload }`.
|
|
12
|
-
*/
|
|
13
|
-
export declare class QueueBuilder<TName extends string = string, TMessage extends StandardSchemaV1 | undefined = undefined, TServices extends Service[] = [], TLogger extends Logger$1 = Logger$1> {
|
|
14
|
-
private _name?;
|
|
15
|
-
private _messageSchema?;
|
|
16
|
-
private _timeout;
|
|
17
|
-
private _batchSize?;
|
|
18
|
-
private _fifo?;
|
|
19
|
-
private _services;
|
|
20
|
-
/** The construct ids `.dependsOn()` named — what the manifest records. */
|
|
21
|
-
_constructs: string[];
|
|
22
|
-
private _logger;
|
|
23
|
-
/** The queue name — drives the infra queue and its `<NAME>_*` env vars. */
|
|
24
|
-
queue<T extends string>(name: T): QueueBuilder<T, TMessage, TServices, TLogger>;
|
|
25
|
-
timeout(timeout: number): this;
|
|
26
|
-
/** SQS event-source batch size (deployed). */
|
|
27
|
-
batchSize(batchSize: number): this;
|
|
28
|
-
/** Mark the queue as FIFO (deployed). */
|
|
29
|
-
fifo(fifo?: boolean): this;
|
|
30
|
-
/**
|
|
31
|
-
* Depend on constructs — a database, a bucket, a mail sender, a queue, a
|
|
32
|
-
* topic.
|
|
33
|
-
*
|
|
34
|
-
* It records the edge and dissolves each construct's client into the
|
|
35
|
-
* handler's service record under the construct's own id, so
|
|
36
|
-
* `.dependsOn([uploads])` is what makes `services.uploads` exist and type.
|
|
37
|
-
*
|
|
38
|
-
* Constructs only. A `Service` does not match the shape, which is what keeps
|
|
39
|
-
* env sniffing confined to `.services()` and the explicit lift.
|
|
40
|
-
*/
|
|
41
|
-
dependsOn<const T extends readonly Consumable[]>(constructs: T): QueueBuilder<TName, TMessage, [...TServices, ...ServicesOf<T>], TLogger>;
|
|
42
|
-
services<T extends Service[]>(services: T): QueueBuilder<TName, TMessage, [...TServices, ...T], TLogger>;
|
|
43
|
-
logger<T extends Logger$1>(logger: T): QueueBuilder<TName, TMessage, TServices, T>;
|
|
44
|
-
/** The typed message (job) payload the queue carries. */
|
|
45
|
-
message<T extends StandardSchemaV1>(schema: T): QueueBuilder<TName, T, TServices, TLogger>;
|
|
46
|
-
handle(fn: QueueHandler<NonNullable<TMessage>, TServices, TLogger>): Queue<TName, NonNullable<TMessage>, TServices, TLogger>;
|
|
47
|
-
}
|
|
48
|
-
//#endregion
|
|
49
|
-
//#region src/queue/index.d.ts
|
|
50
|
-
export declare const q: QueueBuilder<string, undefined, [], Logger>;
|
|
51
|
-
//#endregion
|
|
52
|
-
export { Queue, type QueueContext, type QueueHandler, type QueueMessage };
|
|
53
|
-
//# sourceMappingURL=index.d.cts.map
|
|
1
|
+
import { i as QueueMessage, n as QueueContext, r as QueueHandler, t as Queue } from "../Queue-C4rijiM7.cjs";
|
|
2
|
+
import { n as QueueNeedsMessage, r as QueueNeedsName } from "../QueueBuilder-BcPBQSSX.cjs";
|
|
3
|
+
export { Queue, type QueueContext, type QueueHandler, type QueueMessage, QueueNeedsMessage, QueueNeedsName };
|
package/dist/queue/index.d.mts
CHANGED
|
@@ -1,53 +1,3 @@
|
|
|
1
|
-
import { t as
|
|
2
|
-
import { n as
|
|
3
|
-
|
|
4
|
-
import { Service } from "@geekmidas/services";
|
|
5
|
-
import { Logger as Logger$1 } from "@geekmidas/logger";
|
|
6
|
-
//#region src/queue/QueueBuilder.d.ts
|
|
7
|
-
/**
|
|
8
|
-
* Builds a {@link Queue} worker — `q.queue('orders').services([db]).message(schema).handle(fn)`.
|
|
9
|
-
* Services are an array (sniffed for required env vars); `message` is the typed
|
|
10
|
-
* job payload; `handle` is the single consumer. The queue name is captured as a
|
|
11
|
-
* literal so `queue.publisher` is typed to `{ type: '<name>', payload }`.
|
|
12
|
-
*/
|
|
13
|
-
export declare class QueueBuilder<TName extends string = string, TMessage extends StandardSchemaV1 | undefined = undefined, TServices extends Service[] = [], TLogger extends Logger$1 = Logger$1> {
|
|
14
|
-
private _name?;
|
|
15
|
-
private _messageSchema?;
|
|
16
|
-
private _timeout;
|
|
17
|
-
private _batchSize?;
|
|
18
|
-
private _fifo?;
|
|
19
|
-
private _services;
|
|
20
|
-
/** The construct ids `.dependsOn()` named — what the manifest records. */
|
|
21
|
-
_constructs: string[];
|
|
22
|
-
private _logger;
|
|
23
|
-
/** The queue name — drives the infra queue and its `<NAME>_*` env vars. */
|
|
24
|
-
queue<T extends string>(name: T): QueueBuilder<T, TMessage, TServices, TLogger>;
|
|
25
|
-
timeout(timeout: number): this;
|
|
26
|
-
/** SQS event-source batch size (deployed). */
|
|
27
|
-
batchSize(batchSize: number): this;
|
|
28
|
-
/** Mark the queue as FIFO (deployed). */
|
|
29
|
-
fifo(fifo?: boolean): this;
|
|
30
|
-
/**
|
|
31
|
-
* Depend on constructs — a database, a bucket, a mail sender, a queue, a
|
|
32
|
-
* topic.
|
|
33
|
-
*
|
|
34
|
-
* It records the edge and dissolves each construct's client into the
|
|
35
|
-
* handler's service record under the construct's own id, so
|
|
36
|
-
* `.dependsOn([uploads])` is what makes `services.uploads` exist and type.
|
|
37
|
-
*
|
|
38
|
-
* Constructs only. A `Service` does not match the shape, which is what keeps
|
|
39
|
-
* env sniffing confined to `.services()` and the explicit lift.
|
|
40
|
-
*/
|
|
41
|
-
dependsOn<const T extends readonly Consumable[]>(constructs: T): QueueBuilder<TName, TMessage, [...TServices, ...ServicesOf<T>], TLogger>;
|
|
42
|
-
services<T extends Service[]>(services: T): QueueBuilder<TName, TMessage, [...TServices, ...T], TLogger>;
|
|
43
|
-
logger<T extends Logger$1>(logger: T): QueueBuilder<TName, TMessage, TServices, T>;
|
|
44
|
-
/** The typed message (job) payload the queue carries. */
|
|
45
|
-
message<T extends StandardSchemaV1>(schema: T): QueueBuilder<TName, T, TServices, TLogger>;
|
|
46
|
-
handle(fn: QueueHandler<NonNullable<TMessage>, TServices, TLogger>): Queue<TName, NonNullable<TMessage>, TServices, TLogger>;
|
|
47
|
-
}
|
|
48
|
-
//#endregion
|
|
49
|
-
//#region src/queue/index.d.ts
|
|
50
|
-
export declare const q: QueueBuilder<string, undefined, [], Logger>;
|
|
51
|
-
//#endregion
|
|
52
|
-
export { Queue, type QueueContext, type QueueHandler, type QueueMessage };
|
|
53
|
-
//# sourceMappingURL=index.d.mts.map
|
|
1
|
+
import { i as QueueMessage, n as QueueContext, r as QueueHandler, t as Queue } from "../Queue-BnK3UH8r.mjs";
|
|
2
|
+
import { n as QueueNeedsMessage, r as QueueNeedsName } from "../QueueBuilder-B3vL1ED2.mjs";
|
|
3
|
+
export { Queue, type QueueContext, type QueueHandler, type QueueMessage, QueueNeedsMessage, QueueNeedsName };
|