@geekmidas/constructs 10.0.0-alpha.16 → 10.0.0-alpha.160
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 +246 -158
- package/dist/Construct-127M7yrl.d.cts +231 -0
- package/dist/Construct-127M7yrl.d.cts.map +1 -0
- package/dist/Construct-BMk_CRSD.d.mts +231 -0
- package/dist/Construct-BMk_CRSD.d.mts.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/{Cron-l4Wlz6G9.d.mts → Cron-D6Y7BBt3.d.mts} +15 -8
- package/dist/Cron-D6Y7BBt3.d.mts.map +1 -0
- package/dist/{Cron-zsoSAwZo.d.cts → Cron-D_sfaMGz.d.cts} +14 -7
- package/dist/Cron-D_sfaMGz.d.cts.map +1 -0
- package/dist/CronBuilder-4BZhkChG.d.mts +47 -0
- package/dist/CronBuilder-4BZhkChG.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-C91MVLSr.d.cts +47 -0
- package/dist/CronBuilder-C91MVLSr.d.cts.map +1 -0
- package/dist/Endpoint-52z1P0Ue.cjs +581 -0
- package/dist/Endpoint-52z1P0Ue.cjs.map +1 -0
- package/dist/{Endpoint-oS-Fe3d_.d.mts → Endpoint-BUoDD96P.d.mts} +104 -23
- package/dist/Endpoint-BUoDD96P.d.mts.map +1 -0
- package/dist/{Endpoint-DBflWAe4.d.cts → Endpoint-YYwjqtS1.d.cts} +101 -20
- package/dist/Endpoint-YYwjqtS1.d.cts.map +1 -0
- package/dist/Endpoint-sUOU7uLx.mjs +552 -0
- package/dist/Endpoint-sUOU7uLx.mjs.map +1 -0
- package/dist/{index-Cc4kKPag.d.mts → EndpointFactory-BbVOeryo.d.mts} +189 -106
- package/dist/EndpointFactory-BbVOeryo.d.mts.map +1 -0
- package/dist/{EndpointFactory-Bm3aKRdV.mjs → EndpointFactory-Bzi9Sl7r.mjs} +269 -53
- package/dist/EndpointFactory-Bzi9Sl7r.mjs.map +1 -0
- package/dist/{EndpointFactory-CLvWuHyt.cjs → EndpointFactory-Cf_Cs1ym.cjs} +309 -51
- package/dist/EndpointFactory-Cf_Cs1ym.cjs.map +1 -0
- package/dist/{index-C1ZwNOOk.d.cts → EndpointFactory-Hh1r6J_C.d.cts} +187 -104
- package/dist/EndpointFactory-Hh1r6J_C.d.cts.map +1 -0
- package/dist/Function-BIEsY0Hm.d.cts +76 -0
- package/dist/Function-BIEsY0Hm.d.cts.map +1 -0
- package/dist/Function-BKReud5p.d.mts +76 -0
- package/dist/Function-BKReud5p.d.mts.map +1 -0
- package/dist/{HonoEndpointAdaptor-92zavCsV.cjs → HonoEndpointAdaptor-BTbqfSaa.cjs} +115 -41
- package/dist/HonoEndpointAdaptor-BTbqfSaa.cjs.map +1 -0
- package/dist/{HonoEndpointAdaptor-yYaU7jVJ.mjs → HonoEndpointAdaptor-CBVey2cY.mjs} +112 -38
- package/dist/HonoEndpointAdaptor-CBVey2cY.mjs.map +1 -0
- package/dist/ObjectSubscriberBuilder-DfzXQEKW.d.mts +129 -0
- package/dist/ObjectSubscriberBuilder-DfzXQEKW.d.mts.map +1 -0
- package/dist/ObjectSubscriberBuilder-LWkey_oq.d.cts +129 -0
- package/dist/ObjectSubscriberBuilder-LWkey_oq.d.cts.map +1 -0
- package/dist/ProcessorBuilder-D4oYvZeG.d.mts +216 -0
- package/dist/ProcessorBuilder-D4oYvZeG.d.mts.map +1 -0
- package/dist/ProcessorBuilder-_jdZlbfW.d.cts +216 -0
- package/dist/ProcessorBuilder-_jdZlbfW.d.cts.map +1 -0
- package/dist/{Queue-D9X6OoON.d.mts → Queue-B8HGg439.d.mts} +42 -41
- package/dist/Queue-B8HGg439.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-BxsZ9o5z.cjs +135 -0
- package/dist/QueueBuilder-BxsZ9o5z.cjs.map +1 -0
- package/dist/QueueBuilder-CVS_qPuo.d.mts +75 -0
- package/dist/QueueBuilder-CVS_qPuo.d.mts.map +1 -0
- package/dist/QueueBuilder-SQli59An.d.cts +75 -0
- package/dist/QueueBuilder-SQli59An.d.cts.map +1 -0
- package/dist/Subscriber-5rCX1Nph.d.cts +83 -0
- package/dist/Subscriber-5rCX1Nph.d.cts.map +1 -0
- package/dist/Subscriber-CtQXhcL7.d.mts +83 -0
- package/dist/Subscriber-CtQXhcL7.d.mts.map +1 -0
- package/dist/SubscriberBuilder-CpFhShTJ.mjs +238 -0
- package/dist/SubscriberBuilder-CpFhShTJ.mjs.map +1 -0
- package/dist/SubscriberBuilder-DJEvNRdD.cjs +261 -0
- package/dist/SubscriberBuilder-DJEvNRdD.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 +147 -168
- 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 +142 -164
- package/dist/adaptors/aws.mjs.map +1 -1
- package/dist/adaptors/awsWebsocket.cjs +354 -0
- package/dist/adaptors/awsWebsocket.cjs.map +1 -0
- package/dist/adaptors/awsWebsocket.d.cts +156 -0
- package/dist/adaptors/awsWebsocket.d.cts.map +1 -0
- package/dist/adaptors/awsWebsocket.d.mts +156 -0
- package/dist/adaptors/awsWebsocket.d.mts.map +1 -0
- package/dist/adaptors/awsWebsocket.mjs +347 -0
- package/dist/adaptors/awsWebsocket.mjs.map +1 -0
- package/dist/adaptors/hono.cjs +1 -1
- package/dist/adaptors/hono.d.cts +8 -7
- package/dist/adaptors/hono.d.cts.map +1 -1
- package/dist/adaptors/hono.d.mts +10 -9
- package/dist/adaptors/hono.d.mts.map +1 -1
- package/dist/adaptors/hono.mjs +1 -1
- package/dist/adaptors/testing.cjs +1174 -41
- package/dist/adaptors/testing.cjs.map +1 -1
- package/dist/adaptors/testing.d.cts +517 -40
- package/dist/adaptors/testing.d.cts.map +1 -1
- package/dist/adaptors/testing.d.mts +517 -40
- package/dist/adaptors/testing.d.mts.map +1 -1
- package/dist/adaptors/testing.mjs +1140 -36
- package/dist/adaptors/testing.mjs.map +1 -1
- package/dist/auth-BqWz2JxC.d.cts +274 -0
- package/dist/auth-BqWz2JxC.d.cts.map +1 -0
- package/dist/auth-DnB9H9KL.d.mts +274 -0
- package/dist/auth-DnB9H9KL.d.mts.map +1 -0
- package/dist/auth.cjs +308 -23
- 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 +304 -25
- package/dist/auth.mjs.map +1 -1
- package/dist/cache-CCHcO9Oo.d.mts +44 -0
- package/dist/cache-CCHcO9Oo.d.mts.map +1 -0
- package/dist/cache-CQjMNPrC.d.cts +44 -0
- package/dist/cache-CQjMNPrC.d.cts.map +1 -0
- package/dist/cache.cjs +3 -19
- package/dist/cache.cjs.map +1 -1
- package/dist/cache.d.cts +2 -43
- package/dist/cache.d.mts +2 -43
- package/dist/cache.mjs +2 -18
- package/dist/cache.mjs.map +1 -1
- 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-CSA9VeWM.d.mts} +47 -8
- package/dist/construct-interface-CSA9VeWM.d.mts.map +1 -0
- package/dist/{construct-interface-DgXTJcOD.d.cts → construct-interface-DugP0E5q.d.cts} +47 -8
- package/dist/construct-interface-DugP0E5q.d.cts.map +1 -0
- package/dist/construct-interface.cjs +38 -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 +37 -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 +127 -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 +126 -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.cjs +4 -16
- package/dist/email.cjs.map +1 -1
- 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/email.mjs +2 -14
- package/dist/email.mjs.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-BqhP8RRQ.d.mts +201 -0
- package/dist/fake-BqhP8RRQ.d.mts.map +1 -0
- package/dist/fake-DqieDYYA.d.cts +201 -0
- package/dist/fake-DqieDYYA.d.cts.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-CR3L1fOI.d.cts +195 -0
- package/dist/inbox-CR3L1fOI.d.cts.map +1 -0
- package/dist/inbox-YOdxlyfj.d.mts +195 -0
- package/dist/inbox-YOdxlyfj.d.mts.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-BoQ3-M-K.d.mts +115 -0
- package/dist/index-BoQ3-M-K.d.mts.map +1 -0
- package/dist/index-DPTHa6Ud.d.cts +115 -0
- package/dist/index-DPTHa6Ud.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.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-CebjCWTl.d.cts +216 -0
- package/dist/kysely-CebjCWTl.d.cts.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/kysely-De5rAC-E.d.mts +216 -0
- package/dist/kysely-De5rAC-E.d.mts.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/optionalPeers-D7Wt6dnF.mjs +140 -0
- package/dist/optionalPeers-D7Wt6dnF.mjs.map +1 -0
- package/dist/optionalPeers-DuNQXXe1.cjs +223 -0
- package/dist/optionalPeers-DuNQXXe1.cjs.map +1 -0
- package/dist/origins-BjxYht13.cjs +96 -0
- package/dist/origins-BjxYht13.cjs.map +1 -0
- package/dist/origins-Boc9qbo-.mjs +73 -0
- package/dist/origins-Boc9qbo-.mjs.map +1 -0
- 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/privateAddress-Bg5fUsbp.mjs +21 -0
- package/dist/privateAddress-Bg5fUsbp.mjs.map +1 -0
- package/dist/privateAddress-CqGyuFHn.cjs +26 -0
- package/dist/privateAddress-CqGyuFHn.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/readRequestBody-BmKnPl0a.mjs +293 -0
- package/dist/readRequestBody-BmKnPl0a.mjs.map +1 -0
- package/dist/{lazyAccessors-Dx9NLwJZ.cjs → readRequestBody-CN9GVdeE.cjs} +141 -47
- package/dist/readRequestBody-CN9GVdeE.cjs.map +1 -0
- package/dist/{processAudits-D_2W5x8k.cjs → requestLogger-CnoYd-Ah.cjs} +63 -3
- package/dist/requestLogger-CnoYd-Ah.cjs.map +1 -0
- package/dist/{processAudits-BpRlPQMW.mjs → requestLogger-D2JS7pPM.mjs} +51 -3
- package/dist/requestLogger-D2JS7pPM.mjs.map +1 -0
- package/dist/rest-api.cjs +85 -70
- package/dist/rest-api.cjs.map +1 -1
- package/dist/rest-api.d.cts +77 -59
- package/dist/rest-api.d.cts.map +1 -1
- package/dist/rest-api.d.mts +77 -59
- package/dist/rest-api.d.mts.map +1 -1
- package/dist/rest-api.mjs +87 -72
- package/dist/rest-api.mjs.map +1 -1
- package/dist/runSubscriber-HEqXkin1.mjs +117 -0
- package/dist/runSubscriber-HEqXkin1.mjs.map +1 -0
- package/dist/runSubscriber-sVJfLA0-.cjs +134 -0
- package/dist/runSubscriber-sVJfLA0-.cjs.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 +104 -8
- package/dist/site.cjs.map +1 -1
- package/dist/site.d.cts +132 -2
- package/dist/site.d.cts.map +1 -1
- package/dist/site.d.mts +132 -2
- package/dist/site.d.mts.map +1 -1
- package/dist/site.mjs +102 -11
- 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-C1oqncFY.d.cts +40 -0
- package/dist/telemetry-C1oqncFY.d.cts.map +1 -0
- package/dist/telemetry-CObow3Dn.d.mts +40 -0
- package/dist/telemetry-CObow3Dn.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-Bg9SowJ5.mjs +1710 -0
- package/dist/websocket-api-Bg9SowJ5.mjs.map +1 -0
- package/dist/websocket-api-CPEzJyDt.d.mts +1201 -0
- package/dist/websocket-api-CPEzJyDt.d.mts.map +1 -0
- package/dist/websocket-api-DkF8Hva-.d.cts +1201 -0
- package/dist/websocket-api-DkF8Hva-.d.cts.map +1 -0
- package/dist/websocket-api-czxhekGG.cjs +1889 -0
- package/dist/websocket-api-czxhekGG.cjs.map +1 -0
- package/dist/websocket-api.cjs +35 -0
- package/dist/websocket-api.d.cts +2 -0
- package/dist/websocket-api.d.mts +2 -0
- package/dist/websocket-api.mjs +3 -0
- package/dist/worker.cjs +174 -32
- package/dist/worker.cjs.map +1 -1
- package/dist/worker.d.cts +147 -47
- package/dist/worker.d.cts.map +1 -1
- package/dist/worker.d.mts +147 -47
- package/dist/worker.d.mts.map +1 -1
- package/dist/worker.mjs +175 -33
- package/dist/worker.mjs.map +1 -1
- package/package.json +180 -43
- 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-l4Wlz6G9.d.mts.map +0 -1
- package/dist/Cron-zsoSAwZo.d.cts.map +0 -1
- package/dist/CronBuilder-BdnI6lxF.cjs.map +0 -1
- package/dist/CronBuilder-CyT71Nzg.d.cts +0 -41
- package/dist/CronBuilder-CyT71Nzg.d.cts.map +0 -1
- package/dist/CronBuilder-D_0HNBTr.mjs.map +0 -1
- package/dist/CronBuilder-UoNgFe8S.d.mts +0 -41
- package/dist/CronBuilder-UoNgFe8S.d.mts.map +0 -1
- package/dist/Endpoint-BpZHtJ2W.cjs +0 -1689
- package/dist/Endpoint-BpZHtJ2W.cjs.map +0 -1
- package/dist/Endpoint-DBflWAe4.d.cts.map +0 -1
- package/dist/Endpoint-ONsly_dq.mjs +0 -1671
- package/dist/Endpoint-ONsly_dq.mjs.map +0 -1
- package/dist/Endpoint-oS-Fe3d_.d.mts.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-C1ZwNOOk.d.cts.map +0 -1
- package/dist/index-Cc4kKPag.d.mts.map +0 -1
- package/dist/index-DMCDvnsM.d.mts +0 -26
- package/dist/index-DMCDvnsM.d.mts.map +0 -1
- package/dist/index-D_frT6MP.d.cts +0 -165
- package/dist/index-D_frT6MP.d.cts.map +0 -1
- package/dist/index-DcyIYbDS.d.mts +0 -165
- package/dist/index-DcyIYbDS.d.mts.map +0 -1
- package/dist/lazyAccessors-BHtcqgz2.mjs +0 -211
- package/dist/lazyAccessors-BHtcqgz2.mjs.map +0 -1
- package/dist/lazyAccessors-Dx9NLwJZ.cjs.map +0 -1
- package/dist/processAudits-BpRlPQMW.mjs.map +0 -1
- 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/worker.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker.mjs","names":[],"sources":["../src/worker.ts"],"sourcesContent":["/**\n * A process with no port.\n *\n * `RestApi` is the process that answers HTTP. This is the one that does not —\n * the thing that runs a schedule, drains a queue, consumes a topic. Until it\n * existed, those had nowhere to say they belonged: a cron declared a schedule\n * and nothing else, and which container ran it was decided by the directory the\n * file sat in. A glob owned it.\n *\n * The cost of that shows up in the scaffolds. `gkm init --template worker` —\n * a project that is background jobs and nothing else — declared\n * `new RestApi('Api', { defaultAuthorizer: 'none', logger })`: an HTTP surface\n * with no HTTP on it, written because it was the only construct that made an\n * app exist and the only way to get a logger into the generated runtime.\n *\n * It takes no authorizer, and that is the tell that these are two constructs\n * rather than one with a flag: a `RestApi` needs one because an HTTP surface\n * can ship open by omission, and nothing reaches a worker from outside.\n *\n * ## Crons on a server target need a database\n *\n * A cron becomes an EventBridge rule on AWS and nothing here is consulted. A\n * server has nothing firing its crons but itself, and a process that schedules\n * in memory fires every job once per replica while reporting success — so the\n * schedule is kept in Postgres, and the worker says which one with\n * `.database(db)`.\n *\n * A worker with crons and no `.database(…)` schedules nothing on a server\n * target and says so at startup. That is a limitation of workers today rather\n * than a design: the store could be a cache, or something the target\n * provisions, and Postgres is what exists.\n *\n * It is not an app. A worker names the process that runs its crons and\n * subscribers, and that process is the app's server — the same one the\n * endpoints run in, minus the HTTP surface. Giving a worker a container of its\n * own made a second thing to build, deploy and keep alive for work that was\n * always going to run somewhere already. Declare as many as the shape of the\n * work wants: they are groupings, not deployments.\n *\n * @example\n * ```ts\n * // constructs/worker.ts\n * import { Worker } from '@geekmidas/constructs/worker';\n * import { logger } from './logger.js';\n *\n * export const worker = new Worker('Worker', { logger }).calls([database]);\n *\n * // crons/cleanup.ts\n * import { worker } from '@acme/constructs/worker.js';\n *\n * export const cleanup = worker\n * .cron('rate(1 day)')\n * .handle(async ({ logger }) => { … });\n * ```\n */\n\nimport type { EnvironmentParser } from '@geekmidas/envkit';\nimport type { EventPublisher } from '@geekmidas/events';\nimport type { Logger } from '@geekmidas/logger';\nimport { DEFAULT_LOGGER } from '@geekmidas/logger/console';\nimport {\n\ttype ConstructName,\n\tcanonicalId,\n\ttype Declaration,\n\ttype Dependency,\n} from '@geekmidas/manifest';\nimport type { ComposableStandardSchema } from '@geekmidas/schema';\nimport type { Service } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport {\n\ttype Consumable,\n\ttype Declarable,\n\tedgeTo,\n} from './construct-interface';\nimport type { ScheduleExpression } from './crons/Cron';\nimport { CronBuilder } from './crons/CronBuilder';\nimport { envParserFor } from './endpoints/surfaceEnv';\nimport { FunctionBuilder } from './functions/FunctionBuilder';\nimport { SubscriberBuilder } from './subscribers/SubscriberBuilder';\nimport type { Topic, TopicEvents } from './topic/Topic';\n\nexport interface WorkerConfig {\n\t/**\n\t * The logger everything built from this worker runs with.\n\t *\n\t * The actual logger, not a path to one — the same reason `RestApi` takes\n\t * one. Every cron and subscriber in a scaffolded project used to open with\n\t * `import { logger } from '…/constructs/logger.js'`, which is the line this\n\t * removes.\n\t */\n\tlogger?: Logger;\n\t/**\n\t * The environment parser everything built from this worker runs with.\n\t *\n\t * Defaults to `process.env` merged with the credentials `gkm dev` injected,\n\t * which is what an application's own `config/env.ts` always was.\n\t */\n\tenvParser?: EnvironmentParser<{}>;\n}\n\nexport class Worker<TName extends string = string>\n\timplements Declarable<TName>\n{\n\treadonly id: TName;\n\n\t/** Always defined — the worker's own, or the console logger. */\n\treadonly logger: Logger;\n\n\t/** Always defined, and normally the default. */\n\treadonly envParser: EnvironmentParser<{}>;\n\n\t/**\n\t * Where this worker's schedules live, when it has crons and a server runs\n\t * them. `undefined` until `.database(…)` says.\n\t */\n\treadonly scheduleStore?: Consumable<string, unknown>;\n\n\tconstructor(\n\t\tid: ConstructName<TName>,\n\t\tprivate readonly config: WorkerConfig = {},\n\t\t/** Internal: how `.calls()` carries edges into the copy it returns. */\n\t\tprivate readonly dependencies: readonly Dependency[] = [],\n\t\tscheduleStore?: Consumable<string, unknown>,\n\t) {\n\t\tconst canonical = canonicalId(id as string);\n\n\t\tthis.id = canonical as TName;\n\t\tthis.logger = config.logger ?? DEFAULT_LOGGER;\n\t\tthis.envParser = envParserFor(\n\t\t\tconfig.envParser\n\t\t\t\t? { id: canonical, envParser: config.envParser }\n\t\t\t\t: undefined,\n\t\t);\n\t\tthis.scheduleStore = scheduleStore;\n\t}\n\n\t/**\n\t * The database this worker keeps its schedules in.\n\t *\n\t * Only a server target uses it. On AWS a cron is an EventBridge rule\n\t * invoking a Lambda and nothing here is consulted — but a server has nothing\n\t * firing its crons except itself, and a process that schedules in memory\n\t * fires every job once per replica while reporting that all is well.\n\t *\n\t * So the store is declared rather than discovered. It could have been\n\t * inferred — from a database the app happens to declare, or from the events\n\t * backend when that backend is pg-boss — and both would work until an app\n\t * had two databases, or moved its events to SNS, at which point the\n\t * schedules would quietly move or stop. Naming it is one line and cannot\n\t * drift.\n\t *\n\t * @example\n\t * ```ts\n\t * export const jobs = new Worker('Jobs', { logger }).database(database);\n\t * ```\n\t */\n\tdatabase<T, TDbName extends string>(\n\t\tsource: Consumable<TDbName, T>,\n\t): Worker<TName> {\n\t\treturn new Worker<TName>(\n\t\t\tthis.id as ConstructName<TName>,\n\t\t\tthis.config,\n\t\t\t[...this.dependencies, edgeTo(source)],\n\t\t\tsource as unknown as Consumable<string, unknown>,\n\t\t);\n\t}\n\n\t/**\n\t * A scheduled runnable.\n\t *\n\t * @example `worker.cron('rate(1 day)').handle(async ({ logger }) => { … })`\n\t */\n\tcron(schedule: ScheduleExpression) {\n\t\treturn this.own(new CronBuilder().logger(this.logger)).schedule(schedule);\n\t}\n\n\t/**\n\t * A runnable that consumes a topic.\n\t *\n\t * Binding is not publishing: a consumer is handed the topic's event types\n\t * and no connection string it could publish with. Chain `.publishes(…)` when\n\t * the handler emits follow-up events, which is the only reason it would need\n\t * one.\n\t *\n\t * @example `worker.topic(users).subscribe(['user.created']).handle(…)`\n\t */\n\ttopic<TTopicName extends string, TEvents extends TopicEvents>(\n\t\ttopic: Topic<TTopicName, TEvents>,\n\t) {\n\t\treturn this.own(new SubscriberBuilder().logger(this.logger)).topic(topic);\n\t}\n\n\t/**\n\t * A runnable that consumes events typed from a publisher service.\n\t *\n\t * The older of the two ways to bind a subscriber, kept for a project whose\n\t * events come from a hand-written publisher rather than a `Topic`\n\t * construct. `topic()` is the one to reach for: it types the events the same\n\t * way and hands the consumer no connection string it could publish with.\n\t */\n\tpublisher<T extends EventPublisher<any>, TPubName extends string>(\n\t\tservice: Service<TPubName, T> | Consumable<TPubName, T>,\n\t) {\n\t\treturn this.own(new SubscriberBuilder().logger(this.logger)).publisher(\n\t\t\tservice as never,\n\t\t);\n\t}\n\n\t/**\n\t * Everything below builds a function — the runnable with no schedule and no\n\t * topic, invoked by something else.\n\t *\n\t * These sit on the worker rather than behind a `functions` namespace because\n\t * the namespace was a hop that said nothing: `worker.functions.input(…)`\n\t * names a collection to reach one member of it. What kind of runnable is\n\t * being built is decided by which of these is called first — a schedule\n\t * makes a cron, a topic makes a subscriber, and anything else makes a\n\t * function.\n\t */\n\tinput<T extends ComposableStandardSchema>(schema: T) {\n\t\treturn this.functions.input(schema);\n\t}\n\n\toutput<T extends StandardSchemaV1>(schema: T) {\n\t\treturn this.functions.output(schema);\n\t}\n\n\ttimeout(ms: number) {\n\t\treturn this.functions.timeout(ms);\n\t}\n\n\tmemorySize(mb: number) {\n\t\treturn this.functions.memorySize(mb);\n\t}\n\n\tdependsOn<const T extends readonly Consumable[]>(constructs: T) {\n\t\treturn this.functions.dependsOn(constructs);\n\t}\n\n\tservices<T extends Service[]>(services: T) {\n\t\treturn this.functions.services(services);\n\t}\n\n\t/**\n\t * A function with no input schema — the shortest runnable there is.\n\t *\n\t * @example `worker.handle(async ({ logger }) => { … })`\n\t */\n\thandle(\n\t\t...args: Parameters<\n\t\t\tReturnType<Worker<TName>['schemalessFunction']>['handle']\n\t\t>\n\t) {\n\t\treturn this.schemalessFunction().handle(...args);\n\t}\n\n\t/** The builder `handle` delegates to, named so its type can be referred to. */\n\tprivate schemalessFunction() {\n\t\treturn this.functions;\n\t}\n\n\t/** The function builder the delegating methods above are built on. */\n\tprivate get functions() {\n\t\treturn this.own(new FunctionBuilder().logger(this.logger));\n\t}\n\n\t/**\n\t * Resources and surfaces this worker calls.\n\t *\n\t * Not `.dependsOn()`: this records the edge that derives the worker's\n\t * environment and its access, the same distinction `RestApi.calls()` draws.\n\t */\n\tcalls(constructs: readonly Declarable[]): Worker<TName> {\n\t\treturn new Worker<TName>(\n\t\t\tthis.id as ConstructName<TName>,\n\t\t\tthis.config,\n\t\t\t[...this.dependencies, ...constructs.map(edgeTo)],\n\t\t\tthis.scheduleStore,\n\t\t);\n\t}\n\n\t/**\n\t * Stamps this worker's id onto a builder, so everything built from it says\n\t * which process runs it.\n\t */\n\tprivate own<T extends { _owner?: string; _scheduleStore?: unknown }>(\n\t\tbuilder: T,\n\t): T {\n\t\tbuilder._owner = this.id;\n\t\tbuilder._scheduleStore = this.scheduleStore;\n\n\t\treturn builder;\n\t}\n\n\tdeclare(): Declaration[] {\n\t\treturn [\n\t\t\t{\n\t\t\t\tkind: 'worker',\n\t\t\t\tid: this.id,\n\t\t\t\t...(this.dependencies.length\n\t\t\t\t\t? { dependencies: this.dependencies }\n\t\t\t\t\t: {}),\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OAAO,KAAK,UAAU,WAAW,EAAE;CACpC;CAEA,UAAiD,YAAe;EAC/D,OAAO,KAAK,UAAU,UAAU,UAAU;CAC3C;CAEA,SAA8B,UAAa;EAC1C,OAAO,KAAK,UAAU,SAAS,QAAQ;CACxC;;;;;;CAOA,OACC,GAAG,MAGF;EACD,OAAO,KAAK,mBAAmB,CAAC,CAAC,OAAO,GAAG,IAAI;CAChD;;CAGA,qBAA6B;EAC5B,OAAO,KAAK;CACb;;CAGA,IAAY,YAAY;EACvB,OAAO,KAAK,IAAI,IAAI,gBAAgB,CAAC,CAAC,OAAO,KAAK,MAAM,CAAC;CAC1D;;;;;;;CAQA,MAAM,YAAkD;EACvD,OAAO,IAAI,OACV,KAAK,IACL,KAAK,QACL,CAAC,GAAG,KAAK,cAAc,GAAG,WAAW,IAAI,MAAM,CAAC,GAChD,KAAK,aACN;CACD;;;;;CAMA,IACC,SACI;EACJ,QAAQ,SAAS,KAAK;EACtB,QAAQ,iBAAiB,KAAK;EAE9B,OAAO;CACR;CAEA,UAAyB;EACxB,OAAO,CACN;GACC,MAAM;GACN,IAAI,KAAK;GACT,GAAI,KAAK,aAAa,SACnB,EAAE,cAAc,KAAK,aAAa,IAClC,CAAC;GAEJ,UAAU,CAAC;EACZ,CACD;CACD;AACD"}
|
|
1
|
+
{"version":3,"file":"worker.mjs","names":[],"sources":["../src/subscribers/InboxSubscriberBuilder.ts","../src/worker.ts"],"sourcesContent":["/**\n * A subscriber bound to an inbox: a topic subscriber whose topic the inbox\n * declares and the provider publishes to, so it runs through the same adaptors\n * — Lambda, SNS push, a polled broker, a feature test.\n *\n * What it is delivered is a receipt notification; what its handler is handed\n * is the messages, parsed, one per envelope recipient the inbox receives at.\n * The inbox's own client does that, which is also why the handler can read\n * its inbox's raw messages without naming it in `.dependsOn`.\n *\n * **Loops.** Mail sent while the handler runs is marked\n * `Auto-Submitted: auto-replied`, and mail that arrives marked automatic is\n * dropped before the handler sees it (RFC 3834). Together they stop a reply\n * coming back to an inbox and being answered again — the app's own inboxes, or\n * someone's out-of-office. `.automated()` hands a handler that mail instead.\n * This is the handler every adaptor runs, so dev, tests and SES drop alike.\n */\n\nimport type { EventPublisher } from '@geekmidas/events';\nimport type { Logger } from '@geekmidas/logger';\nimport { INBOX_EVENT, serviceKey } from '@geekmidas/manifest';\nimport type { InferStandardSchema } from '@geekmidas/schema';\nimport type { Service, ServiceRecord } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport type { Consumable, ServicesOf } from '../construct-interface';\nimport type { DatabaseContext } from '../functions/Function';\nimport type {\n\tInbox,\n\tInboxClient,\n\tInboxMessage,\n\tReceiptNotification,\n} from '../inbox';\nimport type { Subscriber } from './Subscriber';\nimport type { SubscriberBuilder } from './SubscriberBuilder';\n\nexport type InboxSubscriber<\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n\tOutSchema extends StandardSchemaV1 | undefined = undefined,\n\tTDatabase = undefined,\n\tTDatabaseServiceName extends string = string,\n> = Subscriber<\n\tTServices,\n\tTLogger,\n\tOutSchema,\n\tEventPublisher<{ type: typeof INBOX_EVENT; payload: ReceiptNotification }>,\n\t[typeof INBOX_EVENT],\n\tTDatabase,\n\tTDatabaseServiceName\n>;\n\nexport type InboxSubscriberContext<\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n\tTDatabase = undefined,\n> = {\n\t/** The messages received, one per envelope recipient the inbox takes. */\n\tmessages: InboxMessage[];\n\t/** The inbox, under its own id too: its domain and its raw messages. */\n\tinbox: InboxClient;\n\tservices: ServiceRecord<TServices>;\n\tlogger: TLogger;\n} & DatabaseContext<TDatabase>;\n\nexport type InboxSubscriberHandler<\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n\tOutSchema extends StandardSchemaV1 | undefined = undefined,\n\tTDatabase = undefined,\n> = (\n\tctx: InboxSubscriberContext<TServices, TLogger, TDatabase>,\n) => OutSchema extends StandardSchemaV1\n\t? InferStandardSchema<OutSchema> | Promise<InferStandardSchema<OutSchema>>\n\t: any | Promise<any>;\n\nexport class InboxSubscriberBuilder<\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n\tOutSchema extends StandardSchemaV1 | undefined = undefined,\n\tTDatabase = undefined,\n\tTDatabaseServiceName extends string = string,\n> {\n\tconstructor(\n\t\tprivate readonly inner: SubscriberBuilder<\n\t\t\tany,\n\t\t\tany,\n\t\t\tany,\n\t\t\tany,\n\t\t\tany,\n\t\t\tany,\n\t\t\tany\n\t\t>,\n\t\tprivate readonly inbox: Inbox<string>,\n\t\tprivate readonly acceptsAutomated = false,\n\t) {}\n\n\t/**\n\t * Hands this handler mail marked `Auto-Submitted` too — auto-replies,\n\t * out-of-office notices, bounces — which are otherwise dropped so a reply\n\t * can never be answered by another. A handler that takes them should not\n\t * reply to them.\n\t */\n\tautomated(): this {\n\t\treturn new InboxSubscriberBuilder<any, any, any, any, any>(\n\t\t\tthis.inner,\n\t\t\tthis.inbox,\n\t\t\ttrue,\n\t\t) as this;\n\t}\n\n\tdependsOn<const T extends readonly Consumable[]>(\n\t\tconstructs: T,\n\t): InboxSubscriberBuilder<\n\t\t[...TServices, ...ServicesOf<T>],\n\t\tTLogger,\n\t\tOutSchema,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\treturn this.with(this.inner.dependsOn(constructs));\n\t}\n\n\tservices<T extends Service[]>(\n\t\tservices: T,\n\t): InboxSubscriberBuilder<\n\t\t[...TServices, ...T],\n\t\tTLogger,\n\t\tOutSchema,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\treturn this.with(this.inner.services(services));\n\t}\n\n\tdatabase<T, TDbName extends string>(\n\t\tsource: Consumable<TDbName, T> | Service<TDbName, T>,\n\t): InboxSubscriberBuilder<TServices, TLogger, OutSchema, T, TDbName> {\n\t\treturn this.with(this.inner.database(source));\n\t}\n\n\ttimeout(timeout: number): this {\n\t\treturn this.with(this.inner.timeout(timeout)) as this;\n\t}\n\n\toutput<T extends StandardSchemaV1>(\n\t\tschema: T,\n\t): InboxSubscriberBuilder<\n\t\tTServices,\n\t\tTLogger,\n\t\tT,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\treturn this.with(this.inner.output(schema));\n\t}\n\n\tlogger<T extends Logger>(\n\t\tlogger: T,\n\t): InboxSubscriberBuilder<\n\t\tTServices,\n\t\tT,\n\t\tOutSchema,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\treturn this.with(this.inner.logger(logger));\n\t}\n\n\thandle(\n\t\tfn: InboxSubscriberHandler<TServices, TLogger, OutSchema, TDatabase>,\n\t): InboxSubscriber<\n\t\tTServices,\n\t\tTLogger,\n\t\tOutSchema,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\tconst key = serviceKey(this.inbox.id);\n\t\tconst acceptsAutomated = this.acceptsAutomated;\n\n\t\t// Every adaptor hands the handler `{ type, payload }` messages; each\n\t\t// payload here is a receipt notification, and the inbox's client turns\n\t\t// it into the messages for the recipients it receives at.\n\t\tconst handler = async (ctx: Record<string, any>) => {\n\t\t\tconst inbox = ctx.services[key] as InboxClient;\n\t\t\tconst notifications = (ctx.events as unknown[]).filter(\n\t\t\t\t(event): event is { type: string; payload: ReceiptNotification } =>\n\t\t\t\t\t(event as { type?: string })?.type === INBOX_EVENT,\n\t\t\t);\n\t\t\tif (notifications.length === 0) return undefined;\n\t\t\t// emailkit is an optional peer: loaded here, by a worker that\n\t\t\t// receives mail, so a worker that never does still starts without it.\n\t\t\t// The `.catch` is what lets a bundler (esbuild, `gkm build`) leave a\n\t\t\t// missing emailkit to run time instead of failing the build — and it\n\t\t\t// is bundled in like any import wherever it is installed.\n\t\t\tconst { autoReplying, isAutoSubmitted } = await import(\n\t\t\t\t'@geekmidas/emailkit/autoSubmitted'\n\t\t\t).catch((error: unknown) => {\n\t\t\t\tthrow new InboxNeedsEmailkit(error);\n\t\t\t});\n\t\t\tconst messages: InboxMessage[] = [];\n\t\t\tfor (const { payload } of notifications) {\n\t\t\t\tfor (const message of await inbox.messages(payload)) {\n\t\t\t\t\tif (!acceptsAutomated && isAutoSubmitted(message.headers)) {\n\t\t\t\t\t\tctx.logger.debug(\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\trecipient: message.recipient.address,\n\t\t\t\t\t\t\t\tautoSubmitted: message.headers['auto-submitted'],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t'Dropped automatic mail: it is never answered',\n\t\t\t\t\t\t);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tmessages.push(message);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (messages.length === 0) return undefined;\n\t\t\treturn autoReplying(() =>\n\t\t\t\tfn({\n\t\t\t\t\t...ctx,\n\t\t\t\t\tmessages,\n\t\t\t\t\tinbox,\n\t\t\t\t} as unknown as InboxSubscriberContext<TServices, TLogger, TDatabase>),\n\t\t\t);\n\t\t};\n\n\t\tconst subscriber = this.inner\n\t\t\t.subscribe([INBOX_EVENT] as never)\n\t\t\t.handle(handler as never) as unknown as InboxSubscriber<\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tOutSchema,\n\t\t\tTDatabase,\n\t\t\tTDatabaseServiceName\n\t\t>;\n\t\tsubscriber.inboxName = this.inbox.id;\n\t\tsubscriber.inboxAddressing = this.inbox.addressing;\n\t\treturn subscriber;\n\t}\n\n\tprivate with(inner: SubscriberBuilder<any, any, any, any, any, any, any>) {\n\t\treturn new InboxSubscriberBuilder<any, any, any, any, any>(\n\t\t\tinner,\n\t\t\tthis.inbox,\n\t\t\tthis.acceptsAutomated,\n\t\t);\n\t}\n}\n\n/** A worker received mail for an inbox, and `@geekmidas/emailkit` is not installed. */\nexport class InboxNeedsEmailkit extends Error {\n\tconstructor(override readonly cause: unknown) {\n\t\tsuper(\n\t\t\t'A worker received mail for an inbox, and reading it needs ' +\n\t\t\t\t'@geekmidas/emailkit, which is not installed. Add it to the app that ' +\n\t\t\t\t'runs the worker: pnpm add @geekmidas/emailkit',\n\t\t);\n\t\tthis.name = 'InboxNeedsEmailkit';\n\t}\n}\n","/**\n * A process with no port.\n *\n * `RestApi` is the process that answers HTTP. This is the one that does not —\n * the thing that runs a schedule, drains a queue, consumes a topic. Until it\n * existed, those had nowhere to say they belonged: a cron declared a schedule\n * and nothing else, and which container ran it was decided by the directory the\n * file sat in. A glob owned it.\n *\n * The cost of that shows up in the scaffolds. `gkm init --template worker` —\n * a project that is background jobs and nothing else — declared\n * `new RestApi('Api', { defaultAuthorizer: 'none', logger })`: an HTTP surface\n * with no HTTP on it, written because it was the only construct that made an\n * app exist and the only way to get a logger into the generated runtime.\n *\n * It takes no authorizer, and that is the tell that these are two constructs\n * rather than one with a flag: a `RestApi` needs one because an HTTP surface\n * can ship open by omission, and nothing reaches a worker from outside.\n *\n * ## Crons on a server target need a database\n *\n * A cron becomes an EventBridge rule on AWS and nothing here is consulted. A\n * server has nothing firing its crons but itself, and a process that schedules\n * in memory fires every job once per replica while reporting success — so the\n * schedule is kept in Postgres, and the worker says which one with\n * `.database(db)`.\n *\n * A worker with crons and no `.database(…)` schedules nothing on a server\n * target and says so at startup. That is a limitation of workers today rather\n * than a design: the store could be a cache, or something the target\n * provisions, and Postgres is what exists.\n *\n * ## The database is everything's default\n *\n * The same `.database(db)` is the database every cron, queue, subscriber and\n * function built from the worker receives as `db`. The work a worker groups is\n * usually work against one database, and naming it per handler was a line\n * repeated in every file that could drift in any one of them. A runnable that\n * works against another names its own with `.database(other)`, which replaces\n * the worker's — client and manifest edge both — rather than adding to it.\n *\n * It is not an app: it declares no path, and its code lives in an app's\n * directory. But it is a process of its own. On a server target each worker\n * with work to do is built — from the app that holds that work — into an image\n * that runs its crons, consumers and subscribers and answers only a health\n * check, so a slow queue never shares a process with the requests an API\n * serves. `gkm dev` still runs everything in one process. Declare as many as\n * the shape of the work wants: each is one container.\n *\n * @example\n * ```ts\n * // constructs/worker.ts\n * import { Worker } from '@geekmidas/constructs/worker';\n * import { logger } from './logger.js';\n *\n * export const worker = new Worker('Worker', { logger }).database(database);\n *\n * // crons/cleanup.ts\n * import { worker } from '@acme/constructs/worker.js';\n *\n * export const cleanup = worker\n * .cron('rate(1 day)')\n * .handle(async ({ db, logger }) => { … });\n *\n * // queues/reports.ts — against another database than the worker's\n * export const reports = worker\n * .queue('Reports')\n * .database(analytics)\n * .message(z.object({ id: z.uuid() }))\n * .handle(async ({ messages, db }) => { … });\n * ```\n */\n\nimport type { EnvironmentParser } from '@geekmidas/envkit';\nimport type { Logger } from '@geekmidas/logger';\nimport { DEFAULT_LOGGER } from '@geekmidas/logger/console';\nimport {\n\ttype ConstructName,\n\tcanonicalId,\n\ttype Declaration,\n\ttype Dependency,\n} from '@geekmidas/manifest';\nimport type { ComposableStandardSchema } from '@geekmidas/schema';\nimport type { Service } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport {\n\ttype Consumable,\n\ttype Declarable,\n\tedgeTo,\n} from './construct-interface';\nimport type { ScheduleExpression } from './crons/Cron';\nimport { CronBuilder } from './crons/CronBuilder';\nimport { envParserFor } from './endpoints/surfaceEnv';\nimport { FunctionBuilder } from './functions/FunctionBuilder';\nimport type { Inbox } from './inbox';\nimport type { ObjectStorage } from './object-storage';\nimport { QueueBuilder } from './queue/QueueBuilder';\nimport { InboxSubscriberBuilder } from './subscribers/InboxSubscriberBuilder';\nimport { ObjectSubscriberBuilder } from './subscribers/ObjectSubscriberBuilder';\nimport { SubscriberBuilder } from './subscribers/SubscriberBuilder';\nimport type { Telemetry } from './telemetry';\nimport type { Topic, TopicEvents } from './topic/Topic';\n\nexport interface WorkerConfig {\n\t/**\n\t * The logger everything built from this worker runs with.\n\t *\n\t * The actual logger, not a path to one — the same reason `RestApi` takes\n\t * one. Every cron and subscriber in a scaffolded project used to open with\n\t * `import { logger } from '…/constructs/logger.js'`, which is the line this\n\t * removes.\n\t */\n\tlogger?: Logger;\n\t/**\n\t * The environment parser everything built from this worker runs with.\n\t *\n\t * Defaults to `process.env` merged with the credentials `gkm dev` injected,\n\t * which is what an application's own `config/env.ts` always was.\n\t */\n\tenvParser?: EnvironmentParser<{}>;\n\t/**\n\t * What the worker's process emits — the `Telemetry` construct, passed like\n\t * the logger. An edge to the node: the deploy hands the process the\n\t * `OTEL_*` keys its stage resolves.\n\t */\n\ttelemetry?: Telemetry;\n}\n\nexport class Worker<\n\tTName extends string = string,\n\tTDatabase = undefined,\n\tTDatabaseServiceName extends string = string,\n> implements Declarable<TName>\n{\n\treadonly id: TName;\n\n\t/** Always defined — the worker's own, or the console logger. */\n\treadonly logger: Logger;\n\n\t/** Always defined, and normally the default. */\n\treadonly envParser: EnvironmentParser<{}>;\n\n\t/**\n\t * Where this worker's schedules live, when it has crons and a server runs\n\t * them — and the database everything built from it receives as `db`.\n\t * `undefined` until `.database(…)` says.\n\t */\n\treadonly scheduleStore?: Consumable<string, unknown>;\n\n\tconstructor(\n\t\tid: ConstructName<TName>,\n\t\tprivate readonly config: WorkerConfig = {},\n\t\t/** Internal: how `.database()` carries its edge into the copy it returns. */\n\t\tprivate readonly dependencies: readonly Dependency[] = [],\n\t\tscheduleStore?: Consumable<string, unknown>,\n\t) {\n\t\tconst canonical = canonicalId(id as string);\n\n\t\tthis.id = canonical as TName;\n\t\tthis.logger = config.logger ?? DEFAULT_LOGGER;\n\t\tthis.envParser = envParserFor(\n\t\t\tconfig.envParser\n\t\t\t\t? { id: canonical, envParser: config.envParser }\n\t\t\t\t: undefined,\n\t\t);\n\t\tthis.scheduleStore = scheduleStore;\n\t}\n\n\t/**\n\t * The database this worker keeps its schedules in, and the one everything\n\t * built from it — crons, queues, subscribers, functions — receives as `db`.\n\t * One of them that works against another database names it with its own\n\t * `.database(other)`, which replaces this one for that runnable alone.\n\t *\n\t * Only a server target uses it. On AWS a cron is an EventBridge rule\n\t * invoking a Lambda and nothing here is consulted — but a server has nothing\n\t * firing its crons except itself, and a process that schedules in memory\n\t * fires every job once per replica while reporting that all is well.\n\t *\n\t * So the store is declared rather than discovered. It could have been\n\t * inferred — from a database the app happens to declare, or from the events\n\t * backend when that backend is pg-boss — and both would work until an app\n\t * had two databases, or moved its events to SNS, at which point the\n\t * schedules would quietly move or stop. Naming it is one line and cannot\n\t * drift.\n\t *\n\t * @example\n\t * ```ts\n\t * export const jobs = new Worker('Jobs', { logger }).database(database);\n\t *\n\t * export const sweep = jobs\n\t * .cron('rate(1 hour)')\n\t * .handle(async ({ db }) => db.deleteFrom('sessions').execute());\n\t * ```\n\t */\n\tdatabase<T, TDbName extends string>(\n\t\tsource: Consumable<TDbName, T>,\n\t): Worker<TName, T, TDbName> {\n\t\treturn new Worker<TName, T, TDbName>(\n\t\t\tthis.id as ConstructName<TName>,\n\t\t\tthis.config,\n\t\t\t[...this.dependencies, edgeTo(source)],\n\t\t\tsource as unknown as Consumable<string, unknown>,\n\t\t);\n\t}\n\n\t/**\n\t * A scheduled runnable.\n\t *\n\t * @example `worker.cron('rate(1 day)').handle(async ({ logger }) => { … })`\n\t */\n\tcron(schedule: ScheduleExpression) {\n\t\treturn this.own(\n\t\t\tnew CronBuilder<\n\t\t\t\tComposableStandardSchema,\n\t\t\t\tService[],\n\t\t\t\tLogger,\n\t\t\t\tundefined,\n\t\t\t\tTDatabase,\n\t\t\t\tTDatabaseServiceName\n\t\t\t>().logger(this.logger),\n\t\t).schedule(schedule);\n\t}\n\n\t/**\n\t * A queue and its one consumer, run by this worker.\n\t *\n\t * One construct, because a queue has exactly one consumer: nothing else can\n\t * attach a second, or forget to attach the first. Producers send to it by\n\t * depending on it — `.dependsOn([emails])` makes `services.emails` the\n\t * publisher.\n\t *\n\t * @example\n\t * ```ts\n\t * export const emails = worker\n\t * .queue('Emails')\n\t * .message(z.object({ userId: z.uuid(), template: z.string() }))\n\t * .handle(async ({ messages, services }) => { … });\n\t * ```\n\t */\n\tqueue<TQueueName extends string>(name: TQueueName) {\n\t\treturn this.own(\n\t\t\tnew QueueBuilder<\n\t\t\t\tstring,\n\t\t\t\tundefined,\n\t\t\t\t[],\n\t\t\t\tLogger,\n\t\t\t\tTDatabase,\n\t\t\t\tTDatabaseServiceName\n\t\t\t>().logger(this.logger),\n\t\t).queue(name);\n\t}\n\n\t/**\n\t * A runnable that reacts to a bucket's objects changing.\n\t *\n\t * A bucket is a topic whose publisher is the storage: the binding is the\n\t * same as {@link Worker.topic}'s, and so is everything after it — the\n\t * services, the database, how it is delivered. The handler is handed the\n\t * objects; reading one still means depending on the bucket,\n\t * `.dependsOn([uploads])`.\n\t *\n\t * @example\n\t * ```ts\n\t * export const onAvatar = worker\n\t * .objects(uploads)\n\t * .on(['object.created'], { prefix: 'avatars/', suffix: '.png' })\n\t * .handle(async ({ objects }) => { … });\n\t * ```\n\t */\n\tobjects<TBucketName extends string>(bucket: ObjectStorage<TBucketName>) {\n\t\tconst inner = this.own(\n\t\t\tnew SubscriberBuilder<\n\t\t\t\t[],\n\t\t\t\tLogger,\n\t\t\t\tundefined,\n\t\t\t\tundefined,\n\t\t\t\t[],\n\t\t\t\tTDatabase,\n\t\t\t\tTDatabaseServiceName\n\t\t\t>().logger(this.logger),\n\t\t);\n\t\treturn new ObjectSubscriberBuilder<\n\t\t\t[],\n\t\t\tLogger,\n\t\t\tundefined,\n\t\t\t[],\n\t\t\tTDatabase,\n\t\t\tTDatabaseServiceName\n\t\t>(inner, bucket.id);\n\t}\n\n\t/**\n\t * A runnable handed the mail an {@link Inbox} receives.\n\t *\n\t * Bound, as a topic subscriber is: the inbox's topic is what it consumes,\n\t * and what it is handed is the messages on it, parsed — one per envelope\n\t * recipient the inbox receives at. It reads its inbox's raw messages\n\t * without depending on it; anything else it uses it names, as ever.\n\t *\n\t * @example\n\t * ```ts\n\t * export const onRequest = worker\n\t * .inbox(requests)\n\t * .handle(async ({ messages, db }) => {\n\t * for (const message of messages) message.recipient.subdomain;\n\t * });\n\t * ```\n\t */\n\tinbox<TInboxName extends string>(inbox: Inbox<TInboxName>) {\n\t\tconst inner = this.own(\n\t\t\tnew SubscriberBuilder<\n\t\t\t\t[],\n\t\t\t\tLogger,\n\t\t\t\tundefined,\n\t\t\t\tundefined,\n\t\t\t\t[],\n\t\t\t\tTDatabase,\n\t\t\t\tTDatabaseServiceName\n\t\t\t>().logger(this.logger),\n\t\t)\n\t\t\t.topic(inbox.topic)\n\t\t\t// The inbox itself: its client reads the raw messages from the\n\t\t\t// inbox's own bucket, which is what the edge grants — and nothing\n\t\t\t// the handler did not name besides.\n\t\t\t.dependsOn([inbox]);\n\t\treturn new InboxSubscriberBuilder<\n\t\t\t[],\n\t\t\tLogger,\n\t\t\tundefined,\n\t\t\tTDatabase,\n\t\t\tTDatabaseServiceName\n\t\t>(inner, inbox);\n\t}\n\n\t/**\n\t * A runnable that consumes a topic.\n\t *\n\t * Binding is not publishing: a consumer is handed the topic's event types\n\t * and no connection string it could publish with. A handler that emits\n\t * follow-up events depends on the topic it emits to —\n\t * `.dependsOn([orders])` — which is the only reason it would need one.\n\t *\n\t * @example `worker.topic(users).subscribe(['user.created']).handle(…)`\n\t */\n\ttopic<TTopicName extends string, TEvents extends TopicEvents>(\n\t\ttopic: Topic<TTopicName, TEvents>,\n\t) {\n\t\treturn this.own(\n\t\t\tnew SubscriberBuilder<\n\t\t\t\t[],\n\t\t\t\tLogger,\n\t\t\t\tundefined,\n\t\t\t\tundefined,\n\t\t\t\t[],\n\t\t\t\tTDatabase,\n\t\t\t\tTDatabaseServiceName\n\t\t\t>().logger(this.logger),\n\t\t).topic(topic);\n\t}\n\n\t/**\n\t * Everything below builds a function — the runnable with no schedule and no\n\t * topic, invoked by something else.\n\t *\n\t * These sit on the worker rather than behind a `functions` namespace because\n\t * the namespace was a hop that said nothing: `worker.functions.input(…)`\n\t * names a collection to reach one member of it. What kind of runnable is\n\t * being built is decided by which of these is called first — a schedule\n\t * makes a cron, a topic makes a subscriber, and anything else makes a\n\t * function.\n\t */\n\tinput<T extends ComposableStandardSchema>(schema: T) {\n\t\treturn this.functions.input(schema);\n\t}\n\n\toutput<T extends StandardSchemaV1>(schema: T) {\n\t\treturn this.functions.output(schema);\n\t}\n\n\ttimeout(ms: number) {\n\t\treturn this.functions.timeout(ms);\n\t}\n\n\tmemorySize(mb: number) {\n\t\treturn this.functions.memorySize(mb);\n\t}\n\n\tdependsOn<const T extends readonly Consumable[]>(constructs: T) {\n\t\treturn this.functions.dependsOn(constructs);\n\t}\n\n\tservices<T extends Service[]>(services: T) {\n\t\treturn this.functions.services(services);\n\t}\n\n\t/**\n\t * A function with no input schema — the shortest runnable there is.\n\t *\n\t * @example `worker.handle(async ({ logger }) => { … })`\n\t */\n\thandle(\n\t\t...args: Parameters<\n\t\t\tReturnType<\n\t\t\t\tWorker<TName, TDatabase, TDatabaseServiceName>['schemalessFunction']\n\t\t\t>['handle']\n\t\t>\n\t) {\n\t\treturn this.schemalessFunction().handle(...args);\n\t}\n\n\t/** The builder `handle` delegates to, named so its type can be referred to. */\n\tprivate schemalessFunction() {\n\t\treturn this.functions;\n\t}\n\n\t/** The function builder the delegating methods above are built on. */\n\tprivate get functions() {\n\t\treturn this.own(\n\t\t\tnew FunctionBuilder<\n\t\t\t\tany,\n\t\t\t\tundefined,\n\t\t\t\t[],\n\t\t\t\tLogger,\n\t\t\t\tundefined,\n\t\t\t\tstring,\n\t\t\t\tTDatabase,\n\t\t\t\tTDatabaseServiceName\n\t\t\t>().logger(this.logger),\n\t\t);\n\t}\n\n\t/**\n\t * Stamps this worker's id onto a builder, so everything built from it says\n\t * which process runs it — and hands it the worker's database.\n\t *\n\t * The database goes through the builder's own `.database()` rather than\n\t * being written into its fields, so the default is recorded exactly as an\n\t * explicit one would be: the client the handler gets, and the edge the\n\t * manifest reads. That is also what lets a later `.database(other)` replace\n\t * it outright. The builder arrives already typed with this worker's\n\t * database; this is the runtime half of that.\n\t */\n\tprivate own<\n\t\tT extends {\n\t\t\t_owner?: string;\n\t\t\t_scheduleStore?: unknown;\n\t\t\tdatabase(source: Consumable<string, unknown>): unknown;\n\t\t},\n\t>(builder: T): T {\n\t\tconst owned = this.scheduleStore\n\t\t\t? (builder.database(this.scheduleStore) as T)\n\t\t\t: builder;\n\n\t\towned._owner = this.id;\n\t\towned._scheduleStore = this.scheduleStore;\n\n\t\treturn owned;\n\t}\n\n\tdeclare(): Declaration[] {\n\t\treturn [\n\t\t\t{\n\t\t\t\tkind: 'worker',\n\t\t\t\tid: this.id,\n\t\t\t\t...(this.dependencies.length\n\t\t\t\t\t? { dependencies: this.dependencies }\n\t\t\t\t\t: {}),\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// Nothing calls a worker, so it publishes no address.\n\t\t\t\tprovides: [],\n\t\t\t},\n\t\t];\n\t}\n}\n"],"mappings":";;;;;;;;;AA2EA,IAAa,yBAAb,MAAa,uBAMX;CAEiB;CASA;CACA;CAXlB,YACC,OASA,OACA,mBAAoC,OACnC;EAXgB,KAAA,QAAA;EASA,KAAA,QAAA;EACA,KAAA,mBAAA;CACf;;;;;;;CAQH,YAAkB;EACjB,OAAO,IAAI,uBACV,KAAK,OACL,KAAK,OACL,IACD;CACD;CAEA,UACC,YAOC;EACD,OAAO,KAAK,KAAK,KAAK,MAAM,UAAU,UAAU,CAAC;CAClD;CAEA,SACC,UAOC;EACD,OAAO,KAAK,KAAK,KAAK,MAAM,SAAS,QAAQ,CAAC;CAC/C;CAEA,SACC,QACoE;EACpE,OAAO,KAAK,KAAK,KAAK,MAAM,SAAS,MAAM,CAAC;CAC7C;CAEA,QAAQ,SAAuB;EAC9B,OAAO,KAAK,KAAK,KAAK,MAAM,QAAQ,OAAO,CAAC;CAC7C;CAEA,OACC,QAOC;EACD,OAAO,KAAK,KAAK,KAAK,MAAM,OAAO,MAAM,CAAC;CAC3C;CAEA,OACC,QAOC;EACD,OAAO,KAAK,KAAK,KAAK,MAAM,OAAO,MAAM,CAAC;CAC3C;CAEA,OACC,IAOC;EACD,MAAM,MAAM,WAAW,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AAK,UAAU,MAAM,MAAM;CACnC;CAEA,OAAmC,QAAW;EAC7C,OAAO,KAAK,UAAU,OAAO,MAAM;CACpC;CAEA,QAAQ,IAAY;EACnB,OAAO,KAAK,UAAU,QAAQ,EAAE;CACjC;CAEA,WAAW,IAAY;EACtB,OAAO,KAAK,UAAU,WAAW,EAAE;CACpC;CAEA,UAAiD,YAAe;EAC/D,OAAO,KAAK,UAAU,UAAU,UAAU;CAC3C;CAEA,SAA8B,UAAa;EAC1C,OAAO,KAAK,UAAU,SAAS,QAAQ;CACxC;;;;;;CAOA,OACC,GAAG,MAKF;EACD,OAAO,KAAK,mBAAmB,CAAC,CAAC,OAAO,GAAG,IAAI;CAChD;;CAGA,qBAA6B;EAC5B,OAAO,KAAK;CACb;;CAGA,IAAY,YAAY;EACvB,OAAO,KAAK,IACX,IAAI,gBASF,CAAC,CAAC,OAAO,KAAK,MAAM,CACvB;CACD;;;;;;;;;;;;CAaA,IAME,SAAe;EAChB,MAAM,QAAQ,KAAK,gBACf,QAAQ,SAAS,KAAK,aAAa,IACpC;EAEH,MAAM,SAAS,KAAK;EACpB,MAAM,iBAAiB,KAAK;EAE5B,OAAO;CACR;CAEA,UAAyB;EACxB,OAAO,CACN;GACC,MAAM;GACN,IAAI,KAAK;GACT,GAAI,KAAK,aAAa,SACnB,EAAE,cAAc,KAAK,aAAa,IAClC,CAAC;GACJ,GAAI,KAAK,OAAO,YACb,EAAE,WAAW,KAAK,OAAO,UAAU,GAAG,IACtC,CAAC;GAEJ,UAAU,CAAC;EACZ,CACD;CACD;AACD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geekmidas/constructs",
|
|
3
|
-
"version": "10.0.0-alpha.
|
|
3
|
+
"version": "10.0.0-alpha.160",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -104,6 +104,16 @@
|
|
|
104
104
|
"default": "./dist/adaptors/aws.cjs"
|
|
105
105
|
}
|
|
106
106
|
},
|
|
107
|
+
"./aws-websocket": {
|
|
108
|
+
"import": {
|
|
109
|
+
"types": "./dist/adaptors/awsWebsocket.d.mts",
|
|
110
|
+
"default": "./dist/adaptors/awsWebsocket.mjs"
|
|
111
|
+
},
|
|
112
|
+
"require": {
|
|
113
|
+
"types": "./dist/adaptors/awsWebsocket.d.cts",
|
|
114
|
+
"default": "./dist/adaptors/awsWebsocket.cjs"
|
|
115
|
+
}
|
|
116
|
+
},
|
|
107
117
|
"./testing": {
|
|
108
118
|
"import": {
|
|
109
119
|
"types": "./dist/adaptors/testing.d.mts",
|
|
@@ -144,6 +154,16 @@
|
|
|
144
154
|
"default": "./dist/file-server.cjs"
|
|
145
155
|
}
|
|
146
156
|
},
|
|
157
|
+
"./processors": {
|
|
158
|
+
"import": {
|
|
159
|
+
"types": "./dist/processors/index.d.mts",
|
|
160
|
+
"default": "./dist/processors/index.mjs"
|
|
161
|
+
},
|
|
162
|
+
"require": {
|
|
163
|
+
"types": "./dist/processors/index.d.cts",
|
|
164
|
+
"default": "./dist/processors/index.cjs"
|
|
165
|
+
}
|
|
166
|
+
},
|
|
147
167
|
"./email": {
|
|
148
168
|
"import": {
|
|
149
169
|
"types": "./dist/email.d.mts",
|
|
@@ -154,6 +174,16 @@
|
|
|
154
174
|
"default": "./dist/email.cjs"
|
|
155
175
|
}
|
|
156
176
|
},
|
|
177
|
+
"./inbox": {
|
|
178
|
+
"import": {
|
|
179
|
+
"types": "./dist/inbox.d.mts",
|
|
180
|
+
"default": "./dist/inbox.mjs"
|
|
181
|
+
},
|
|
182
|
+
"require": {
|
|
183
|
+
"types": "./dist/inbox.d.cts",
|
|
184
|
+
"default": "./dist/inbox.cjs"
|
|
185
|
+
}
|
|
186
|
+
},
|
|
157
187
|
"./cache": {
|
|
158
188
|
"import": {
|
|
159
189
|
"types": "./dist/cache.d.mts",
|
|
@@ -164,6 +194,36 @@
|
|
|
164
194
|
"default": "./dist/cache.cjs"
|
|
165
195
|
}
|
|
166
196
|
},
|
|
197
|
+
"./encryption": {
|
|
198
|
+
"import": {
|
|
199
|
+
"types": "./dist/encryption.d.mts",
|
|
200
|
+
"default": "./dist/encryption.mjs"
|
|
201
|
+
},
|
|
202
|
+
"require": {
|
|
203
|
+
"types": "./dist/encryption.d.cts",
|
|
204
|
+
"default": "./dist/encryption.cjs"
|
|
205
|
+
}
|
|
206
|
+
},
|
|
207
|
+
"./encryption/kms": {
|
|
208
|
+
"import": {
|
|
209
|
+
"types": "./dist/encryption/kms.d.mts",
|
|
210
|
+
"default": "./dist/encryption/kms.mjs"
|
|
211
|
+
},
|
|
212
|
+
"require": {
|
|
213
|
+
"types": "./dist/encryption/kms.d.cts",
|
|
214
|
+
"default": "./dist/encryption/kms.cjs"
|
|
215
|
+
}
|
|
216
|
+
},
|
|
217
|
+
"./random-password": {
|
|
218
|
+
"import": {
|
|
219
|
+
"types": "./dist/random-password.d.mts",
|
|
220
|
+
"default": "./dist/random-password.mjs"
|
|
221
|
+
},
|
|
222
|
+
"require": {
|
|
223
|
+
"types": "./dist/random-password.d.cts",
|
|
224
|
+
"default": "./dist/random-password.cjs"
|
|
225
|
+
}
|
|
226
|
+
},
|
|
167
227
|
"./credential": {
|
|
168
228
|
"import": {
|
|
169
229
|
"types": "./dist/credential.d.mts",
|
|
@@ -174,6 +234,16 @@
|
|
|
174
234
|
"default": "./dist/credential.cjs"
|
|
175
235
|
}
|
|
176
236
|
},
|
|
237
|
+
"./external-api": {
|
|
238
|
+
"import": {
|
|
239
|
+
"types": "./dist/external-api.d.mts",
|
|
240
|
+
"default": "./dist/external-api.mjs"
|
|
241
|
+
},
|
|
242
|
+
"require": {
|
|
243
|
+
"types": "./dist/external-api.d.cts",
|
|
244
|
+
"default": "./dist/external-api.cjs"
|
|
245
|
+
}
|
|
246
|
+
},
|
|
177
247
|
"./auth": {
|
|
178
248
|
"import": {
|
|
179
249
|
"types": "./dist/auth.d.mts",
|
|
@@ -194,6 +264,16 @@
|
|
|
194
264
|
"default": "./dist/rest-api.cjs"
|
|
195
265
|
}
|
|
196
266
|
},
|
|
267
|
+
"./websocket-api": {
|
|
268
|
+
"import": {
|
|
269
|
+
"types": "./dist/websocket-api.d.mts",
|
|
270
|
+
"default": "./dist/websocket-api.mjs"
|
|
271
|
+
},
|
|
272
|
+
"require": {
|
|
273
|
+
"types": "./dist/websocket-api.d.cts",
|
|
274
|
+
"default": "./dist/websocket-api.cjs"
|
|
275
|
+
}
|
|
276
|
+
},
|
|
197
277
|
"./site": {
|
|
198
278
|
"import": {
|
|
199
279
|
"types": "./dist/site.d.mts",
|
|
@@ -204,6 +284,16 @@
|
|
|
204
284
|
"default": "./dist/site.cjs"
|
|
205
285
|
}
|
|
206
286
|
},
|
|
287
|
+
"./mobile-app": {
|
|
288
|
+
"import": {
|
|
289
|
+
"types": "./dist/mobile-app.d.mts",
|
|
290
|
+
"default": "./dist/mobile-app.mjs"
|
|
291
|
+
},
|
|
292
|
+
"require": {
|
|
293
|
+
"types": "./dist/mobile-app.d.cts",
|
|
294
|
+
"default": "./dist/mobile-app.cjs"
|
|
295
|
+
}
|
|
296
|
+
},
|
|
207
297
|
"./worker": {
|
|
208
298
|
"import": {
|
|
209
299
|
"types": "./dist/worker.d.mts",
|
|
@@ -214,6 +304,16 @@
|
|
|
214
304
|
"default": "./dist/worker.cjs"
|
|
215
305
|
}
|
|
216
306
|
},
|
|
307
|
+
"./telemetry": {
|
|
308
|
+
"import": {
|
|
309
|
+
"types": "./dist/telemetry.d.mts",
|
|
310
|
+
"default": "./dist/telemetry.mjs"
|
|
311
|
+
},
|
|
312
|
+
"require": {
|
|
313
|
+
"types": "./dist/telemetry.d.cts",
|
|
314
|
+
"default": "./dist/telemetry.cjs"
|
|
315
|
+
}
|
|
316
|
+
},
|
|
217
317
|
"./database/kysely": {
|
|
218
318
|
"import": {
|
|
219
319
|
"types": "./dist/database/kysely.d.mts",
|
|
@@ -237,68 +337,92 @@
|
|
|
237
337
|
"access": "public"
|
|
238
338
|
},
|
|
239
339
|
"dependencies": {
|
|
340
|
+
"@opentelemetry/api": "~1.9.1",
|
|
341
|
+
"cron-parser": "~5.10.1",
|
|
240
342
|
"fast-glob": "~3.3.3",
|
|
241
343
|
"lodash.compact": "~3.0.1",
|
|
242
344
|
"lodash.get": "~4.4.2",
|
|
243
|
-
"lodash.pick": "~4.4.0",
|
|
244
|
-
"lodash.set": "~4.3.2",
|
|
245
345
|
"lodash.uniqby": "~4.7.0",
|
|
246
346
|
"openapi-types": "~12.1.3",
|
|
247
347
|
"qs": "~6.16.0",
|
|
248
|
-
"@geekmidas/envkit": "
|
|
249
|
-
"@geekmidas/errors": "
|
|
250
|
-
"@geekmidas/events": "
|
|
251
|
-
"@geekmidas/logger": "
|
|
252
|
-
"@geekmidas/manifest": "
|
|
253
|
-
"@geekmidas/schema": "
|
|
254
|
-
"@geekmidas/services": "
|
|
348
|
+
"@geekmidas/envkit": ">=10.0.0-alpha.160 <10.0.0",
|
|
349
|
+
"@geekmidas/errors": ">=10.0.0-alpha.160 <10.0.0",
|
|
350
|
+
"@geekmidas/events": ">=10.0.0-alpha.160 <10.0.0",
|
|
351
|
+
"@geekmidas/logger": ">=10.0.0-alpha.160 <10.0.0",
|
|
352
|
+
"@geekmidas/manifest": ">=10.0.0-alpha.160 <10.0.0",
|
|
353
|
+
"@geekmidas/schema": ">=10.0.0-alpha.160 <10.0.0",
|
|
354
|
+
"@geekmidas/services": ">=10.0.0-alpha.160 <10.0.0"
|
|
255
355
|
},
|
|
256
356
|
"devDependencies": {
|
|
357
|
+
"@aws-sdk/client-apigatewaymanagementapi": "~3.1136.0",
|
|
358
|
+
"@aws-sdk/client-apigatewayv2": "~3.1136.0",
|
|
359
|
+
"@aws-sdk/client-dynamodb": "~3.1136.0",
|
|
360
|
+
"@aws-sdk/client-kms": "~3.1136.0",
|
|
361
|
+
"@better-auth/expo": "~1.7.6",
|
|
362
|
+
"@opentelemetry/sdk-trace-node": "~2.11.0",
|
|
257
363
|
"@types/lodash.compact": "~3.0.9",
|
|
258
364
|
"@types/lodash.get": "~4.4.9",
|
|
259
|
-
"@types/lodash.pick": "~4.4.9",
|
|
260
|
-
"@types/lodash.set": "~4.3.9",
|
|
261
365
|
"@types/lodash.uniqby": "~4.7.9",
|
|
262
366
|
"@types/pg": "~8.23.1",
|
|
263
367
|
"@types/qs": "~6.15.1",
|
|
368
|
+
"@types/ws": "~8.18.1",
|
|
264
369
|
"better-auth": "~1.7.6",
|
|
370
|
+
"electrodb": "~3.9.3",
|
|
371
|
+
"ioredis": "~6.0.0",
|
|
265
372
|
"kysely": "~0.29.6",
|
|
266
373
|
"msw": "~2.15.0",
|
|
267
374
|
"pg": "~8.23.0",
|
|
375
|
+
"ws": "~8.22.0",
|
|
268
376
|
"zod": "~4.6.5",
|
|
269
|
-
"@geekmidas/audit": "
|
|
270
|
-
"@geekmidas/auth": "10.0.0-alpha.
|
|
271
|
-
"@geekmidas/cache": "
|
|
272
|
-
"@geekmidas/db": "
|
|
273
|
-
"@geekmidas/emailkit": "
|
|
274
|
-
"@geekmidas/envkit": "
|
|
275
|
-
"@geekmidas/errors": "
|
|
276
|
-
"@geekmidas/events": "
|
|
277
|
-
"@geekmidas/logger": "
|
|
278
|
-
"@geekmidas/rate-limit": "
|
|
279
|
-
"@geekmidas/schema": "
|
|
280
|
-
"@geekmidas/services": "
|
|
281
|
-
"@geekmidas/telescope": "10.0.0-alpha.
|
|
282
|
-
"@geekmidas/testkit": "
|
|
377
|
+
"@geekmidas/audit": ">=10.0.0-alpha.160 <10.0.0",
|
|
378
|
+
"@geekmidas/auth": "10.0.0-alpha.160",
|
|
379
|
+
"@geekmidas/cache": ">=10.0.0-alpha.160 <10.0.0",
|
|
380
|
+
"@geekmidas/db": ">=10.0.0-alpha.160 <10.0.0",
|
|
381
|
+
"@geekmidas/emailkit": ">=10.0.0-alpha.160 <10.0.0",
|
|
382
|
+
"@geekmidas/envkit": ">=10.0.0-alpha.160 <10.0.0",
|
|
383
|
+
"@geekmidas/errors": ">=10.0.0-alpha.160 <10.0.0",
|
|
384
|
+
"@geekmidas/events": ">=10.0.0-alpha.160 <10.0.0",
|
|
385
|
+
"@geekmidas/logger": ">=10.0.0-alpha.160 <10.0.0",
|
|
386
|
+
"@geekmidas/rate-limit": ">=10.0.0-alpha.160 <10.0.0",
|
|
387
|
+
"@geekmidas/schema": ">=10.0.0-alpha.160 <10.0.0",
|
|
388
|
+
"@geekmidas/services": ">=10.0.0-alpha.160 <10.0.0",
|
|
389
|
+
"@geekmidas/telescope": "10.0.0-alpha.160",
|
|
390
|
+
"@geekmidas/testkit": ">=10.0.0-alpha.160 <10.0.0"
|
|
283
391
|
},
|
|
284
392
|
"peerDependencies": {
|
|
393
|
+
"@aws-sdk/client-apigatewaymanagementapi": ">=3.1136.0",
|
|
394
|
+
"@aws-sdk/client-dynamodb": ">=3.1136.0",
|
|
395
|
+
"@aws-sdk/client-kms": ">=3.1136.0",
|
|
285
396
|
"@middy/core": ">=7.9.2",
|
|
286
397
|
"@types/aws-lambda": ">=8.10.163",
|
|
287
398
|
"better-auth": ">=1.7.5",
|
|
399
|
+
"electrodb": ">=3.9.3",
|
|
288
400
|
"hono": ">=4.13.8",
|
|
401
|
+
"ioredis": ">=6.0.0",
|
|
289
402
|
"kysely": "~0.29.6",
|
|
290
403
|
"msw": ">=2.15.0",
|
|
291
404
|
"pg": ">=8.23.0",
|
|
292
|
-
"
|
|
293
|
-
"@geekmidas/
|
|
294
|
-
"@geekmidas/
|
|
295
|
-
"@geekmidas/
|
|
296
|
-
"@geekmidas/
|
|
297
|
-
"@geekmidas/
|
|
298
|
-
"@geekmidas/
|
|
299
|
-
"@geekmidas/
|
|
405
|
+
"ws": ">=8.22.0",
|
|
406
|
+
"@geekmidas/audit": ">=10.0.0-alpha.160 <10.0.0",
|
|
407
|
+
"@geekmidas/auth": "10.0.0-alpha.160",
|
|
408
|
+
"@geekmidas/cache": ">=10.0.0-alpha.160 <10.0.0",
|
|
409
|
+
"@geekmidas/db": ">=10.0.0-alpha.160 <10.0.0",
|
|
410
|
+
"@geekmidas/emailkit": ">=10.0.0-alpha.160 <10.0.0",
|
|
411
|
+
"@geekmidas/rate-limit": ">=10.0.0-alpha.160 <10.0.0",
|
|
412
|
+
"@geekmidas/storage": ">=10.0.0-alpha.160 <10.0.0",
|
|
413
|
+
"@geekmidas/telescope": "10.0.0-alpha.160",
|
|
414
|
+
"@geekmidas/testkit": ">=10.0.0-alpha.160 <10.0.0"
|
|
300
415
|
},
|
|
301
416
|
"peerDependenciesMeta": {
|
|
417
|
+
"@aws-sdk/client-apigatewaymanagementapi": {
|
|
418
|
+
"optional": true
|
|
419
|
+
},
|
|
420
|
+
"@aws-sdk/client-dynamodb": {
|
|
421
|
+
"optional": true
|
|
422
|
+
},
|
|
423
|
+
"@aws-sdk/client-kms": {
|
|
424
|
+
"optional": true
|
|
425
|
+
},
|
|
302
426
|
"@geekmidas/audit": {
|
|
303
427
|
"optional": true
|
|
304
428
|
},
|
|
@@ -308,41 +432,54 @@
|
|
|
308
432
|
"@geekmidas/db": {
|
|
309
433
|
"optional": true
|
|
310
434
|
},
|
|
435
|
+
"@geekmidas/emailkit": {
|
|
436
|
+
"optional": true
|
|
437
|
+
},
|
|
311
438
|
"@geekmidas/rate-limit": {
|
|
312
439
|
"optional": true
|
|
313
440
|
},
|
|
441
|
+
"@geekmidas/storage": {
|
|
442
|
+
"optional": true
|
|
443
|
+
},
|
|
444
|
+
"@geekmidas/telescope": {
|
|
445
|
+
"optional": true
|
|
446
|
+
},
|
|
447
|
+
"@geekmidas/testkit": {
|
|
448
|
+
"optional": true
|
|
449
|
+
},
|
|
314
450
|
"@middy/core": {
|
|
315
451
|
"optional": true
|
|
316
452
|
},
|
|
317
453
|
"@types/aws-lambda": {
|
|
318
454
|
"optional": true
|
|
319
455
|
},
|
|
320
|
-
"
|
|
456
|
+
"better-auth": {
|
|
321
457
|
"optional": true
|
|
322
458
|
},
|
|
323
|
-
"
|
|
459
|
+
"electrodb": {
|
|
324
460
|
"optional": true
|
|
325
461
|
},
|
|
326
|
-
"
|
|
462
|
+
"hono": {
|
|
327
463
|
"optional": true
|
|
328
464
|
},
|
|
329
|
-
"
|
|
465
|
+
"ioredis": {
|
|
330
466
|
"optional": true
|
|
331
467
|
},
|
|
332
|
-
"
|
|
468
|
+
"kysely": {
|
|
333
469
|
"optional": true
|
|
334
470
|
},
|
|
335
|
-
"
|
|
471
|
+
"msw": {
|
|
336
472
|
"optional": true
|
|
337
473
|
},
|
|
338
|
-
"
|
|
474
|
+
"pg": {
|
|
339
475
|
"optional": true
|
|
340
476
|
},
|
|
341
|
-
"
|
|
477
|
+
"ws": {
|
|
342
478
|
"optional": true
|
|
343
479
|
}
|
|
344
480
|
},
|
|
345
481
|
"scripts": {
|
|
346
|
-
"ts": "tsc --noEmit --skipLibCheck src/**/*.ts"
|
|
482
|
+
"ts": "tsc --noEmit --skipLibCheck src/**/*.ts",
|
|
483
|
+
"build": "tsdown --config ../../tsdown.config.ts --filter ."
|
|
347
484
|
}
|
|
348
485
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Construct-BeYVu_QF.mjs","names":["compact"],"sources":["../../../node_modules/.pnpm/lodash.compact@3.0.1/node_modules/lodash.compact/index.js","../src/Construct.ts"],"sourcesContent":["/**\n * lodash 3.0.1 (Custom Build) <https://lodash.com/>\n * Build: `lodash modularize exports=\"npm\" -o ./`\n * Copyright 2012-2016 The Dojo Foundation <http://dojofoundation.org/>\n * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>\n * Copyright 2009-2016 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors\n * Available under MIT license <https://lodash.com/license>\n */\n\n/**\n * Creates an array with all falsey values removed. The values `false`, `null`,\n * `0`, `\"\"`, `undefined`, and `NaN` are falsey.\n *\n * @static\n * @memberOf _\n * @category Array\n * @param {Array} array The array to compact.\n * @returns {Array} Returns the new array of filtered values.\n * @example\n *\n * _.compact([0, 1, false, 2, '', 3]);\n * // => [1, 2, 3]\n */\nfunction compact(array) {\n var index = -1,\n length = array ? array.length : 0,\n resIndex = 0,\n result = [];\n\n while (++index < length) {\n var value = array[index];\n if (value) {\n result[resIndex++] = value;\n }\n }\n return result;\n}\n\nmodule.exports = compact;\n","import type { AuditStorage } from '@geekmidas/audit';\nimport {\n\tSnifferEnvironmentParser,\n\ttype SniffResult,\n\tsniffWithFireAndForget,\n} from '@geekmidas/envkit/sniffer';\nimport type { EventPublisher, MappedEvent } from '@geekmidas/events';\nimport type { Logger } from '@geekmidas/logger';\nimport type { Service, ServiceContext } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport compact from 'lodash.compact';\n\n// Cache for service environment variables to handle singleton services\n// Stores both the full list and the optional subset so the same sniff result\n// can satisfy both getEnvironment() and getEnvironment({ markOptional: true }).\nconst serviceEnvCache = new Map<\n\tService,\n\t{ envVars: string[]; optionalEnvVars: string[] }\n>();\n\n/**\n * Noop context for environment sniffing.\n * Used when calling service.register() to detect env vars without a real request.\n * Returns dummy values since services should only use context in instance methods,\n * not during registration.\n */\nconst snifferContext: ServiceContext = {\n\tgetLogger() {\n\t\t// Return a noop logger for sniffing - services shouldn't log during registration\n\t\treturn {\n\t\t\tdebug: () => {},\n\t\t\tinfo: () => {},\n\t\t\twarn: () => {},\n\t\t\terror: () => {},\n\t\t\tchild: () => snifferContext.getLogger(),\n\t\t} as unknown as Logger;\n\t},\n\tgetRequestId() {\n\t\treturn 'sniffer-context';\n\t},\n\tgetRequestStartTime() {\n\t\treturn Date.now();\n\t},\n\thasContext() {\n\t\treturn false;\n\t},\n};\n\nexport abstract class Construct<\n\tTLogger extends Logger = Logger,\n\tTServiceName extends string = string,\n\tT extends EventPublisher<any> | undefined = undefined,\n\tOutSchema extends StandardSchemaV1 | undefined = undefined,\n\tTServices extends Service[] = [],\n\tTAuditStorageServiceName extends string = string,\n\tTAuditStorage extends AuditStorage | undefined = undefined,\n\tTDatabaseServiceName extends string = string,\n\tTDatabase = unknown,\n> {\n\t/** Database service for this construct (used by Endpoint for RLS/audit context) */\n\tpublic databaseService?: Service<TDatabaseServiceName, TDatabase>;\n\n\t/**\n\t * The deploy unit that runs this, by construct id.\n\t *\n\t * What an endpoint's `surface` is to it, and for the same reason: something\n\t * has to say which process a runnable belongs to, and until this existed the\n\t * only thing that said so was the directory its file sat in. Set by the\n\t * factory it was built from — `worker.crons`, `api.endpoints` — so it is\n\t * carried rather than configured.\n\t *\n\t * Undefined for a construct built from a free-standing builder, which is\n\t * still how `c`, `s` and `f` work.\n\t */\n\tpublic owner?: string;\n\n\tconstructor(\n\t\tpublic readonly type: ConstructType,\n\t\tpublic readonly logger: TLogger,\n\t\tpublic readonly services: TServices,\n\t\tpublic readonly events: MappedEvent<T, any>[] = [],\n\t\tpublic readonly publisherService?: Service<TServiceName, T>,\n\t\tpublic outputSchema?: OutSchema,\n\t\tpublic readonly timeout?: number,\n\t\tpublic readonly memorySize?: number,\n\t\tpublic readonly auditorStorageService?: Service<\n\t\t\tTAuditStorageServiceName,\n\t\t\tTAuditStorage\n\t\t>,\n\t\t/**\n\t\t * The constructs this one declared an edge to, by id.\n\t\t *\n\t\t * What the manifest records. `services` is the same information in the\n\t\t * form a handler runs with — clients, keyed by name — and an id cannot be\n\t\t * recovered from one of those reliably, so both are kept.\n\t\t *\n\t\t * Last in the list because every other parameter is positional and already\n\t\t * spoken for; a new one anywhere else silently rebinds existing callers.\n\t\t */\n\t\tpublic readonly constructs: string[] = [],\n\t) {}\n\n\t/**\n\t * Returns an array of environment variable names required by this construct's services.\n\t * This is determined by running a \"sniffer\" EnvironmentParser through each service's\n\t * register method to track which environment variables are accessed.\n\t *\n\t * Results are cached per service class to handle singleton patterns where\n\t * subsequent register() calls may short-circuit and not access env vars.\n\t *\n\t * @param markOptional - When true, optional vars (those accessed via `.optional()` or\n\t * `.default()`) are suffixed with `?` in the returned array (e.g. `'PORT?'`).\n\t * @returns Promise that resolves to array of environment variable names, sorted alphabetically\n\t *\n\t * @example\n\t * ```typescript\n\t * const endpoint = e\n\t * .services([databaseService, authService])\n\t * .get('/users')\n\t * .handle(async () => []);\n\t *\n\t * await endpoint.getEnvironment(); // ['AUTH_SECRET', 'DATABASE_URL']\n\t * await endpoint.getEnvironment({ markOptional: true }); // ['AUTH_SECRET', 'DATABASE_URL', 'PORT?']\n\t * ```\n\t */\n\tasync getEnvironment(\n\t\topts: { markOptional?: boolean } = {},\n\t): Promise<string[]> {\n\t\tconst { markOptional = false } = opts;\n\t\tconst envVars = new Set<string>();\n\t\tconst optionalVars = new Set<string>();\n\t\tconst services: Service[] = compact([\n\t\t\t...this.services,\n\t\t\tthis.publisherService,\n\t\t\tthis.publisherService,\n\t\t\tthis.auditorStorageService,\n\t\t\tthis.databaseService,\n\t\t]);\n\n\t\ttry {\n\t\t\tfor (const service of services) {\n\t\t\t\t// Check cache first - handles singleton services that short-circuit\n\t\t\t\tif (serviceEnvCache.has(service)) {\n\t\t\t\t\tconst cached = serviceEnvCache.get(service)!;\n\t\t\t\t\tcached.envVars.forEach((v) => envVars.add(v));\n\t\t\t\t\tcached.optionalEnvVars.forEach((v) => optionalVars.add(v));\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\t// Use sniffService to properly handle all error scenarios\n\t\t\t\tconst result = await sniffService(service);\n\n\t\t\t\t// Log any issues for debugging\n\t\t\t\tif (result.error) {\n\t\t\t\t\tthis.logger.warn(\n\t\t\t\t\t\t{ error: result.error.message, service: service.serviceName },\n\t\t\t\t\t\t'Service threw error during env sniffing (env vars still captured)',\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (result.unhandledRejections.length > 0) {\n\t\t\t\t\tthis.logger.warn(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\terrors: result.unhandledRejections.map((e) => e.message),\n\t\t\t\t\t\t\tservice: service.serviceName,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t'Fire-and-forget rejections during env sniffing (suppressed)',\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\t// Cache and collect env vars (both required and optional)\n\t\t\t\tserviceEnvCache.set(service, {\n\t\t\t\t\tenvVars: result.envVars,\n\t\t\t\t\toptionalEnvVars: result.optionalEnvVars,\n\t\t\t\t});\n\t\t\t\tresult.envVars.forEach((v) => envVars.add(v));\n\t\t\t\tresult.optionalEnvVars.forEach((v) => optionalVars.add(v));\n\t\t\t}\n\n\t\t\tconst sorted = Array.from(envVars).sort();\n\t\t\tif (!markOptional || optionalVars.size === 0) return sorted;\n\t\t\treturn sorted.map((v) => (optionalVars.has(v) ? `${v}?` : v));\n\t\t} catch (error) {\n\t\t\tthis.logger.error(\n\t\t\t\t{ error },\n\t\t\t\t'Error determining environment variables for construct',\n\t\t\t);\n\n\t\t\treturn [];\n\t\t}\n\t}\n}\n\nexport enum ConstructType {\n\tCron = 'dev.geekmidas.function.cron',\n\tEndpoint = 'dev.geekmidas.function.endpoint',\n\tFunction = 'dev.geekmidas.function.function',\n\tSubscriber = 'dev.geekmidas.function.subscriber',\n\tQueue = 'dev.geekmidas.function.queue',\n\tTopic = 'dev.geekmidas.resource.topic',\n}\n\n/**\n * Utility to test sniffing a service for environment variables.\n * Useful for debugging services that throw errors during sniffing.\n *\n * @example\n * ```typescript\n * import { sniffService } from '@geekmidas/constructs';\n * import { authService } from './services/AuthService';\n *\n * const result = await sniffService(authService);\n * console.log('Env vars:', result.envVars);\n * console.log('Error:', result.error);\n * ```\n */\nexport async function sniffService(service: Service): Promise<SniffResult> {\n\tconst sniffer = new SnifferEnvironmentParser();\n\n\treturn sniffWithFireAndForget(sniffer, () =>\n\t\tservice.register({\n\t\t\tenvParser: sniffer as any,\n\t\t\tcontext: snifferContext,\n\t\t}),\n\t);\n}\n\n// Export for testing\nexport { snifferContext };\n"],"x_google_ignoreList":[0],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuBA,SAAS,QAAQ,OAAO;EACtB,I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CACF;AACD"}
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import { t as StandardSchemaV1 } from "./index-CeEtxDmK.cjs";
|
|
2
|
-
import { EventPublisher, MappedEvent } from "@geekmidas/events";
|
|
3
|
-
import { Logger } from "@geekmidas/logger";
|
|
4
|
-
import { Service, ServiceContext } from "@geekmidas/services";
|
|
5
|
-
import { AuditStorage } from "@geekmidas/audit";
|
|
6
|
-
import { SniffResult } from "@geekmidas/envkit/sniffer";
|
|
7
|
-
//#region src/Construct.d.ts
|
|
8
|
-
/**
|
|
9
|
-
* Noop context for environment sniffing.
|
|
10
|
-
* Used when calling service.register() to detect env vars without a real request.
|
|
11
|
-
* Returns dummy values since services should only use context in instance methods,
|
|
12
|
-
* not during registration.
|
|
13
|
-
*/
|
|
14
|
-
declare const snifferContext: ServiceContext;
|
|
15
|
-
declare abstract class Construct<TLogger extends Logger = Logger, TServiceName extends string = string, T extends EventPublisher<any> | undefined = undefined, OutSchema extends StandardSchemaV1 | undefined = undefined, TServices extends Service[] = [], TAuditStorageServiceName extends string = string, TAuditStorage extends AuditStorage | undefined = undefined, TDatabaseServiceName extends string = string, TDatabase = unknown> {
|
|
16
|
-
readonly type: ConstructType;
|
|
17
|
-
readonly logger: TLogger;
|
|
18
|
-
readonly services: TServices;
|
|
19
|
-
readonly events: MappedEvent<T, any>[];
|
|
20
|
-
readonly publisherService?: Service<TServiceName, T>;
|
|
21
|
-
outputSchema?: OutSchema | undefined;
|
|
22
|
-
readonly timeout?: number | undefined;
|
|
23
|
-
readonly memorySize?: number | undefined;
|
|
24
|
-
readonly auditorStorageService?: Service<TAuditStorageServiceName, TAuditStorage>;
|
|
25
|
-
/**
|
|
26
|
-
* The constructs this one declared an edge to, by id.
|
|
27
|
-
*
|
|
28
|
-
* What the manifest records. `services` is the same information in the
|
|
29
|
-
* form a handler runs with — clients, keyed by name — and an id cannot be
|
|
30
|
-
* recovered from one of those reliably, so both are kept.
|
|
31
|
-
*
|
|
32
|
-
* Last in the list because every other parameter is positional and already
|
|
33
|
-
* spoken for; a new one anywhere else silently rebinds existing callers.
|
|
34
|
-
*/
|
|
35
|
-
readonly constructs: string[];
|
|
36
|
-
/** Database service for this construct (used by Endpoint for RLS/audit context) */
|
|
37
|
-
databaseService?: Service<TDatabaseServiceName, TDatabase>;
|
|
38
|
-
/**
|
|
39
|
-
* The deploy unit that runs this, by construct id.
|
|
40
|
-
*
|
|
41
|
-
* What an endpoint's `surface` is to it, and for the same reason: something
|
|
42
|
-
* has to say which process a runnable belongs to, and until this existed the
|
|
43
|
-
* only thing that said so was the directory its file sat in. Set by the
|
|
44
|
-
* factory it was built from — `worker.crons`, `api.endpoints` — so it is
|
|
45
|
-
* carried rather than configured.
|
|
46
|
-
*
|
|
47
|
-
* Undefined for a construct built from a free-standing builder, which is
|
|
48
|
-
* still how `c`, `s` and `f` work.
|
|
49
|
-
*/
|
|
50
|
-
owner?: string;
|
|
51
|
-
constructor(type: ConstructType, logger: TLogger, services: TServices, events?: MappedEvent<T, any>[], publisherService?: Service<TServiceName, T>, outputSchema?: OutSchema | undefined, timeout?: number | undefined, memorySize?: number | undefined, auditorStorageService?: Service<TAuditStorageServiceName, TAuditStorage>,
|
|
52
|
-
/**
|
|
53
|
-
* The constructs this one declared an edge to, by id.
|
|
54
|
-
*
|
|
55
|
-
* What the manifest records. `services` is the same information in the
|
|
56
|
-
* form a handler runs with — clients, keyed by name — and an id cannot be
|
|
57
|
-
* recovered from one of those reliably, so both are kept.
|
|
58
|
-
*
|
|
59
|
-
* Last in the list because every other parameter is positional and already
|
|
60
|
-
* spoken for; a new one anywhere else silently rebinds existing callers.
|
|
61
|
-
*/
|
|
62
|
-
constructs?: string[]);
|
|
63
|
-
/**
|
|
64
|
-
* Returns an array of environment variable names required by this construct's services.
|
|
65
|
-
* This is determined by running a "sniffer" EnvironmentParser through each service's
|
|
66
|
-
* register method to track which environment variables are accessed.
|
|
67
|
-
*
|
|
68
|
-
* Results are cached per service class to handle singleton patterns where
|
|
69
|
-
* subsequent register() calls may short-circuit and not access env vars.
|
|
70
|
-
*
|
|
71
|
-
* @param markOptional - When true, optional vars (those accessed via `.optional()` or
|
|
72
|
-
* `.default()`) are suffixed with `?` in the returned array (e.g. `'PORT?'`).
|
|
73
|
-
* @returns Promise that resolves to array of environment variable names, sorted alphabetically
|
|
74
|
-
*
|
|
75
|
-
* @example
|
|
76
|
-
* ```typescript
|
|
77
|
-
* const endpoint = e
|
|
78
|
-
* .services([databaseService, authService])
|
|
79
|
-
* .get('/users')
|
|
80
|
-
* .handle(async () => []);
|
|
81
|
-
*
|
|
82
|
-
* await endpoint.getEnvironment(); // ['AUTH_SECRET', 'DATABASE_URL']
|
|
83
|
-
* await endpoint.getEnvironment({ markOptional: true }); // ['AUTH_SECRET', 'DATABASE_URL', 'PORT?']
|
|
84
|
-
* ```
|
|
85
|
-
*/
|
|
86
|
-
getEnvironment(opts?: {
|
|
87
|
-
markOptional?: boolean;
|
|
88
|
-
}): Promise<string[]>;
|
|
89
|
-
}
|
|
90
|
-
declare enum ConstructType {
|
|
91
|
-
Cron = "dev.geekmidas.function.cron",
|
|
92
|
-
Endpoint = "dev.geekmidas.function.endpoint",
|
|
93
|
-
Function = "dev.geekmidas.function.function",
|
|
94
|
-
Subscriber = "dev.geekmidas.function.subscriber",
|
|
95
|
-
Queue = "dev.geekmidas.function.queue",
|
|
96
|
-
Topic = "dev.geekmidas.resource.topic"
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Utility to test sniffing a service for environment variables.
|
|
100
|
-
* Useful for debugging services that throw errors during sniffing.
|
|
101
|
-
*
|
|
102
|
-
* @example
|
|
103
|
-
* ```typescript
|
|
104
|
-
* import { sniffService } from '@geekmidas/constructs';
|
|
105
|
-
* import { authService } from './services/AuthService';
|
|
106
|
-
*
|
|
107
|
-
* const result = await sniffService(authService);
|
|
108
|
-
* console.log('Env vars:', result.envVars);
|
|
109
|
-
* console.log('Error:', result.error);
|
|
110
|
-
* ```
|
|
111
|
-
*/
|
|
112
|
-
declare function sniffService(service: Service): Promise<SniffResult>;
|
|
113
|
-
//#endregion
|
|
114
|
-
export { snifferContext as i, ConstructType as n, sniffService as r, Construct as t };
|
|
115
|
-
//# sourceMappingURL=Construct-DfbwIntp.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Construct-DfbwIntp.d.cts","names":[],"sources":["../src/Construct.ts"],"mappings":";;;;;;;;;;;;;cA0BM,gBAAgB;uBAsBA,UACrB,gBAAgB,SAAS,QACzB,sCACA,UAAU,6CACV,kBAAkB,0CAClB,kBAAkB,gBAClB,kDACA,sBAAsB,sCACtB,8CACA;WAoBiB,MAAM;WACN,QAAQ;WACR,UAAU;WACV,QAAQ,YAAY;WACpB,mBAAmB,QAAQ,cAAc;EAClD,eAAe;WACN;WACA;WACA,wBAAwB,QACvC,0BACA;;;;;;;;;;;WAYe;;EAvCV,kBAAkB,QAAQ,sBAAsB;;;;;;;;;;;;;EAchD;EAEP,YACiB,MAAM,eACN,QAAQ,SACR,UAAU,WACV,SAAQ,YAAY,WACpB,mBAAmB,QAAQ,cAAc,IAClD,eAAe,uBACN,8BACA,iCACA,wBAAwB,QACvC,0BACA,gBAYe;;;;;;;;;;;EAAA;;;;;;;;;;;;;;;;;;;;;;;;EA0BX,eACL;IAAQ;MACN;;aAiEQ;EACX;EACA;EACA;EACA;EACA;EACA;;;;;;;;;;;;;;;;iBAiBqB,aAAa,SAAS,UAAU,QAAQ"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Construct-DqdlARxq.cjs","names":["compact","SnifferEnvironmentParser","sniffWithFireAndForget"],"sources":["../../../node_modules/.pnpm/lodash.compact@3.0.1/node_modules/lodash.compact/index.js","../src/Construct.ts"],"sourcesContent":["/**\n * lodash 3.0.1 (Custom Build) <https://lodash.com/>\n * Build: `lodash modularize exports=\"npm\" -o ./`\n * Copyright 2012-2016 The Dojo Foundation <http://dojofoundation.org/>\n * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>\n * Copyright 2009-2016 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors\n * Available under MIT license <https://lodash.com/license>\n */\n\n/**\n * Creates an array with all falsey values removed. The values `false`, `null`,\n * `0`, `\"\"`, `undefined`, and `NaN` are falsey.\n *\n * @static\n * @memberOf _\n * @category Array\n * @param {Array} array The array to compact.\n * @returns {Array} Returns the new array of filtered values.\n * @example\n *\n * _.compact([0, 1, false, 2, '', 3]);\n * // => [1, 2, 3]\n */\nfunction compact(array) {\n var index = -1,\n length = array ? array.length : 0,\n resIndex = 0,\n result = [];\n\n while (++index < length) {\n var value = array[index];\n if (value) {\n result[resIndex++] = value;\n }\n }\n return result;\n}\n\nmodule.exports = compact;\n","import type { AuditStorage } from '@geekmidas/audit';\nimport {\n\tSnifferEnvironmentParser,\n\ttype SniffResult,\n\tsniffWithFireAndForget,\n} from '@geekmidas/envkit/sniffer';\nimport type { EventPublisher, MappedEvent } from '@geekmidas/events';\nimport type { Logger } from '@geekmidas/logger';\nimport type { Service, ServiceContext } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport compact from 'lodash.compact';\n\n// Cache for service environment variables to handle singleton services\n// Stores both the full list and the optional subset so the same sniff result\n// can satisfy both getEnvironment() and getEnvironment({ markOptional: true }).\nconst serviceEnvCache = new Map<\n\tService,\n\t{ envVars: string[]; optionalEnvVars: string[] }\n>();\n\n/**\n * Noop context for environment sniffing.\n * Used when calling service.register() to detect env vars without a real request.\n * Returns dummy values since services should only use context in instance methods,\n * not during registration.\n */\nconst snifferContext: ServiceContext = {\n\tgetLogger() {\n\t\t// Return a noop logger for sniffing - services shouldn't log during registration\n\t\treturn {\n\t\t\tdebug: () => {},\n\t\t\tinfo: () => {},\n\t\t\twarn: () => {},\n\t\t\terror: () => {},\n\t\t\tchild: () => snifferContext.getLogger(),\n\t\t} as unknown as Logger;\n\t},\n\tgetRequestId() {\n\t\treturn 'sniffer-context';\n\t},\n\tgetRequestStartTime() {\n\t\treturn Date.now();\n\t},\n\thasContext() {\n\t\treturn false;\n\t},\n};\n\nexport abstract class Construct<\n\tTLogger extends Logger = Logger,\n\tTServiceName extends string = string,\n\tT extends EventPublisher<any> | undefined = undefined,\n\tOutSchema extends StandardSchemaV1 | undefined = undefined,\n\tTServices extends Service[] = [],\n\tTAuditStorageServiceName extends string = string,\n\tTAuditStorage extends AuditStorage | undefined = undefined,\n\tTDatabaseServiceName extends string = string,\n\tTDatabase = unknown,\n> {\n\t/** Database service for this construct (used by Endpoint for RLS/audit context) */\n\tpublic databaseService?: Service<TDatabaseServiceName, TDatabase>;\n\n\t/**\n\t * The deploy unit that runs this, by construct id.\n\t *\n\t * What an endpoint's `surface` is to it, and for the same reason: something\n\t * has to say which process a runnable belongs to, and until this existed the\n\t * only thing that said so was the directory its file sat in. Set by the\n\t * factory it was built from — `worker.crons`, `api.endpoints` — so it is\n\t * carried rather than configured.\n\t *\n\t * Undefined for a construct built from a free-standing builder, which is\n\t * still how `c`, `s` and `f` work.\n\t */\n\tpublic owner?: string;\n\n\tconstructor(\n\t\tpublic readonly type: ConstructType,\n\t\tpublic readonly logger: TLogger,\n\t\tpublic readonly services: TServices,\n\t\tpublic readonly events: MappedEvent<T, any>[] = [],\n\t\tpublic readonly publisherService?: Service<TServiceName, T>,\n\t\tpublic outputSchema?: OutSchema,\n\t\tpublic readonly timeout?: number,\n\t\tpublic readonly memorySize?: number,\n\t\tpublic readonly auditorStorageService?: Service<\n\t\t\tTAuditStorageServiceName,\n\t\t\tTAuditStorage\n\t\t>,\n\t\t/**\n\t\t * The constructs this one declared an edge to, by id.\n\t\t *\n\t\t * What the manifest records. `services` is the same information in the\n\t\t * form a handler runs with — clients, keyed by name — and an id cannot be\n\t\t * recovered from one of those reliably, so both are kept.\n\t\t *\n\t\t * Last in the list because every other parameter is positional and already\n\t\t * spoken for; a new one anywhere else silently rebinds existing callers.\n\t\t */\n\t\tpublic readonly constructs: string[] = [],\n\t) {}\n\n\t/**\n\t * Returns an array of environment variable names required by this construct's services.\n\t * This is determined by running a \"sniffer\" EnvironmentParser through each service's\n\t * register method to track which environment variables are accessed.\n\t *\n\t * Results are cached per service class to handle singleton patterns where\n\t * subsequent register() calls may short-circuit and not access env vars.\n\t *\n\t * @param markOptional - When true, optional vars (those accessed via `.optional()` or\n\t * `.default()`) are suffixed with `?` in the returned array (e.g. `'PORT?'`).\n\t * @returns Promise that resolves to array of environment variable names, sorted alphabetically\n\t *\n\t * @example\n\t * ```typescript\n\t * const endpoint = e\n\t * .services([databaseService, authService])\n\t * .get('/users')\n\t * .handle(async () => []);\n\t *\n\t * await endpoint.getEnvironment(); // ['AUTH_SECRET', 'DATABASE_URL']\n\t * await endpoint.getEnvironment({ markOptional: true }); // ['AUTH_SECRET', 'DATABASE_URL', 'PORT?']\n\t * ```\n\t */\n\tasync getEnvironment(\n\t\topts: { markOptional?: boolean } = {},\n\t): Promise<string[]> {\n\t\tconst { markOptional = false } = opts;\n\t\tconst envVars = new Set<string>();\n\t\tconst optionalVars = new Set<string>();\n\t\tconst services: Service[] = compact([\n\t\t\t...this.services,\n\t\t\tthis.publisherService,\n\t\t\tthis.publisherService,\n\t\t\tthis.auditorStorageService,\n\t\t\tthis.databaseService,\n\t\t]);\n\n\t\ttry {\n\t\t\tfor (const service of services) {\n\t\t\t\t// Check cache first - handles singleton services that short-circuit\n\t\t\t\tif (serviceEnvCache.has(service)) {\n\t\t\t\t\tconst cached = serviceEnvCache.get(service)!;\n\t\t\t\t\tcached.envVars.forEach((v) => envVars.add(v));\n\t\t\t\t\tcached.optionalEnvVars.forEach((v) => optionalVars.add(v));\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\t// Use sniffService to properly handle all error scenarios\n\t\t\t\tconst result = await sniffService(service);\n\n\t\t\t\t// Log any issues for debugging\n\t\t\t\tif (result.error) {\n\t\t\t\t\tthis.logger.warn(\n\t\t\t\t\t\t{ error: result.error.message, service: service.serviceName },\n\t\t\t\t\t\t'Service threw error during env sniffing (env vars still captured)',\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (result.unhandledRejections.length > 0) {\n\t\t\t\t\tthis.logger.warn(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\terrors: result.unhandledRejections.map((e) => e.message),\n\t\t\t\t\t\t\tservice: service.serviceName,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t'Fire-and-forget rejections during env sniffing (suppressed)',\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\t// Cache and collect env vars (both required and optional)\n\t\t\t\tserviceEnvCache.set(service, {\n\t\t\t\t\tenvVars: result.envVars,\n\t\t\t\t\toptionalEnvVars: result.optionalEnvVars,\n\t\t\t\t});\n\t\t\t\tresult.envVars.forEach((v) => envVars.add(v));\n\t\t\t\tresult.optionalEnvVars.forEach((v) => optionalVars.add(v));\n\t\t\t}\n\n\t\t\tconst sorted = Array.from(envVars).sort();\n\t\t\tif (!markOptional || optionalVars.size === 0) return sorted;\n\t\t\treturn sorted.map((v) => (optionalVars.has(v) ? `${v}?` : v));\n\t\t} catch (error) {\n\t\t\tthis.logger.error(\n\t\t\t\t{ error },\n\t\t\t\t'Error determining environment variables for construct',\n\t\t\t);\n\n\t\t\treturn [];\n\t\t}\n\t}\n}\n\nexport enum ConstructType {\n\tCron = 'dev.geekmidas.function.cron',\n\tEndpoint = 'dev.geekmidas.function.endpoint',\n\tFunction = 'dev.geekmidas.function.function',\n\tSubscriber = 'dev.geekmidas.function.subscriber',\n\tQueue = 'dev.geekmidas.function.queue',\n\tTopic = 'dev.geekmidas.resource.topic',\n}\n\n/**\n * Utility to test sniffing a service for environment variables.\n * Useful for debugging services that throw errors during sniffing.\n *\n * @example\n * ```typescript\n * import { sniffService } from '@geekmidas/constructs';\n * import { authService } from './services/AuthService';\n *\n * const result = await sniffService(authService);\n * console.log('Env vars:', result.envVars);\n * console.log('Error:', result.error);\n * ```\n */\nexport async function sniffService(service: Service): Promise<SniffResult> {\n\tconst sniffer = new SnifferEnvironmentParser();\n\n\treturn sniffWithFireAndForget(sniffer, () =>\n\t\tservice.register({\n\t\t\tenvParser: sniffer as any,\n\t\t\tcontext: snifferContext,\n\t\t}),\n\t);\n}\n\n// Export for testing\nexport { snifferContext };\n"],"x_google_ignoreList":[0],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;CAuBA,SAAS,QAAQ,OAAO;EACtB,IAAI,QAAQ,IACR,SAAS,QAAQ,MAAM,SAAS,GAChC,WAAW,GACX,SAAS,CAAC;EAEd,OAAO,EAAE,QAAQ,QAAQ;GACvB,IAAI,QAAQ,MAAM;GAClB,IAAI,OACF,OAAO,cAAc;EAEzB;EACA,OAAO;CACT;CAEA,OAAO,UAAU;;;;;ACvBjB,MAAM,kCAAkB,IAAI,IAG1B;;;;;;;AAQF,MAAM,iBAAiC;CACtC,YAAY;EAEX,OAAO;GACN,aAAa,CAAC;GACd,YAAY,CAAC;GACb,YAAY,CAAC;GACb,aAAa,CAAC;GACd,aAAa,eAAe,UAAU;EACvC;CACD;CACA,eAAe;EACd,OAAO;CACR;CACA,sBAAsB;EACrB,OAAO,KAAK,IAAI;CACjB;CACA,aAAa;EACZ,OAAO;CACR;AACD;AAEA,IAAsB,YAAtB,MAUE;CAmBgB;CACA;CACA;CACA;CACA;CACT;CACS;CACA;CACA;CAcA;;CAvCjB;;;;;;;;;;;;;CAcA;CAEA,YACC,MACA,QACA,UACA,SAAgD,CAAC,GACjD,kBACA,cACA,SACA,YACA,uBAcA,aAAuC,CAAC,GACvC;EAvBe,KAAA,OAAA;EACA,KAAA,SAAA;EACA,KAAA,WAAA;EACA,KAAA,SAAA;EACA,KAAA,mBAAA;EACT,KAAA,eAAA;EACS,KAAA,UAAA;EACA,KAAA,aAAA;EACA,KAAA,wBAAA;EAcA,KAAA,aAAA;CACd;;;;;;;;;;;;;;;;;;;;;;;;CAyBH,MAAM,eACL,OAAmC,CAAC,GAChB;EACpB,MAAM,EAAE,eAAe,UAAU;EAC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