@geekmidas/constructs 9.0.2 → 10.0.0-alpha.0
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 +71 -44
- package/dist/{AWSScheduledFunction-Bn99MceY.d.cts → AWSScheduledFunction-BvFvBsBN.d.cts} +8 -3
- package/dist/{AWSScheduledFunction-ysaCsdWx.d.mts.map → AWSScheduledFunction-BvFvBsBN.d.cts.map} +1 -1
- package/dist/{AWSScheduledFunction-ysaCsdWx.d.mts → AWSScheduledFunction-CVccZO-L.d.mts} +9 -4
- package/dist/{AWSScheduledFunction-Bn99MceY.d.cts.map → AWSScheduledFunction-CVccZO-L.d.mts.map} +1 -1
- package/dist/{AWSScheduledFunction-CufMMhGB.mjs → AWSScheduledFunction-Db1lttJH.mjs} +3 -3
- package/dist/{AWSScheduledFunction-CufMMhGB.mjs.map → AWSScheduledFunction-Db1lttJH.mjs.map} +1 -1
- package/dist/{AWSScheduledFunction-DbkDr8CA.cjs → AWSScheduledFunction-qu4ieRZR.cjs} +9 -9
- package/dist/{AWSScheduledFunction-DbkDr8CA.cjs.map → AWSScheduledFunction-qu4ieRZR.cjs.map} +1 -1
- package/dist/{Construct-_1wX7p_Y.d.cts → Construct-B-xc0SE9.d.mts} +27 -5
- package/dist/Construct-B-xc0SE9.d.mts.map +1 -0
- package/dist/{Construct-r0U2zBwW.mjs → Construct-HmWM6YYu.mjs} +4 -3
- package/dist/Construct-HmWM6YYu.mjs.map +1 -0
- package/dist/{Construct-DCMuYOox.d.mts → Construct-WhCXIOPV.d.cts} +29 -7
- package/dist/Construct-WhCXIOPV.d.cts.map +1 -0
- package/dist/{Construct-vXMZJgRp.cjs → Construct-roId57cU.cjs} +7 -43
- package/dist/Construct-roId57cU.cjs.map +1 -0
- package/dist/{lazyAccessors-DmTG8sQH.cjs → Endpoint-BBkV6l0k.cjs} +869 -1079
- package/dist/Endpoint-BBkV6l0k.cjs.map +1 -0
- package/dist/{lazyAccessors-DfqZR6C4.mjs → Endpoint-BGwpNEX4.mjs} +840 -1003
- package/dist/Endpoint-BGwpNEX4.mjs.map +1 -0
- package/dist/{Endpoint-DgfRslct.d.cts → Endpoint-BnxZqIX-.d.cts} +53 -4
- package/dist/Endpoint-BnxZqIX-.d.cts.map +1 -0
- package/dist/{Endpoint-CLPSIl6S.d.mts → Endpoint-ROcXU-eH.d.mts} +55 -6
- package/dist/Endpoint-ROcXU-eH.d.mts.map +1 -0
- package/dist/EndpointFactory-DYoGLaIT.cjs +850 -0
- package/dist/EndpointFactory-DYoGLaIT.cjs.map +1 -0
- package/dist/EndpointFactory-Di0X9AWp.mjs +808 -0
- package/dist/EndpointFactory-Di0X9AWp.mjs.map +1 -0
- package/dist/{HonoEndpointAdaptor-DJDT3PMx.mjs → HonoEndpointAdaptor-DFKIIG2o.mjs} +5 -4
- package/dist/HonoEndpointAdaptor-DFKIIG2o.mjs.map +1 -0
- package/dist/{HonoEndpointAdaptor-CkJENANP.cjs → HonoEndpointAdaptor-wMsCyMgt.cjs} +24 -23
- package/dist/HonoEndpointAdaptor-wMsCyMgt.cjs.map +1 -0
- package/dist/{Queue-DaxjwmOQ.d.cts → Queue-D6WeziRD.d.cts} +43 -4
- package/dist/Queue-D6WeziRD.d.cts.map +1 -0
- package/dist/{Queue-HBDf0fqz.d.mts → Queue-DpUeqdC8.d.mts} +43 -4
- package/dist/Queue-DpUeqdC8.d.mts.map +1 -0
- package/dist/{Subscriber-B69ngPwl.d.cts → Subscriber-4rBJgDKI.d.mts} +9 -4
- package/dist/{Subscriber-B69ngPwl.d.cts.map → Subscriber-4rBJgDKI.d.mts.map} +1 -1
- package/dist/{Subscriber-D8Xm-86W.d.mts → Subscriber-DVQowdyj.d.cts} +11 -6
- package/dist/Subscriber-DVQowdyj.d.cts.map +1 -0
- package/dist/{Topic-C5ZMfveW.d.cts → Topic-Ohx9dvWr.d.cts} +33 -2
- package/dist/Topic-Ohx9dvWr.d.cts.map +1 -0
- package/dist/{Topic-DT10AqHk.d.mts → Topic-cmy2jOUy.d.mts} +33 -2
- package/dist/Topic-cmy2jOUy.d.mts.map +1 -0
- package/dist/adaptors/aws.cjs +39 -26
- package/dist/adaptors/aws.cjs.map +1 -1
- package/dist/adaptors/aws.d.cts +24 -16
- package/dist/adaptors/aws.d.cts.map +1 -1
- package/dist/adaptors/aws.d.mts +25 -17
- package/dist/adaptors/aws.d.mts.map +1 -1
- package/dist/adaptors/aws.mjs +26 -14
- package/dist/adaptors/aws.mjs.map +1 -1
- package/dist/adaptors/hono.cjs +9 -6
- package/dist/adaptors/hono.d.cts +7 -6
- package/dist/adaptors/hono.d.cts.map +1 -1
- package/dist/adaptors/hono.d.mts +8 -7
- package/dist/adaptors/hono.d.mts.map +1 -1
- package/dist/adaptors/hono.mjs +9 -6
- package/dist/adaptors/testing.cjs +18 -14
- package/dist/adaptors/testing.cjs.map +1 -1
- package/dist/adaptors/testing.d.cts +7 -6
- package/dist/adaptors/testing.d.cts.map +1 -1
- package/dist/adaptors/testing.d.mts +11 -10
- package/dist/adaptors/testing.d.mts.map +1 -1
- package/dist/adaptors/testing.mjs +10 -7
- package/dist/adaptors/testing.mjs.map +1 -1
- package/dist/auth.cjs +165 -0
- package/dist/auth.cjs.map +1 -0
- package/dist/auth.d.cts +108 -0
- package/dist/auth.d.cts.map +1 -0
- package/dist/auth.d.mts +108 -0
- package/dist/auth.d.mts.map +1 -0
- package/dist/auth.mjs +164 -0
- package/dist/auth.mjs.map +1 -0
- package/dist/cache-0ANvRQnD.mjs +51 -0
- package/dist/cache-0ANvRQnD.mjs.map +1 -0
- package/dist/cache-3WSvAulx.cjs +57 -0
- package/dist/cache-3WSvAulx.cjs.map +1 -0
- package/dist/cache-CdQ7OLpR.d.cts +47 -0
- package/dist/cache-CdQ7OLpR.d.cts.map +1 -0
- package/dist/cache-DYoJFcfd.d.mts +47 -0
- package/dist/cache-DYoJFcfd.d.mts.map +1 -0
- package/dist/cache.cjs +3 -0
- package/dist/cache.d.cts +3 -0
- package/dist/cache.d.mts +3 -0
- package/dist/cache.mjs +3 -0
- package/dist/chunk-DWy1uDak.cjs +39 -0
- package/dist/clone-DblgEZZa.mjs +39 -0
- package/dist/clone-DblgEZZa.mjs.map +1 -0
- package/dist/clone-Dy0cR2SZ.cjs +45 -0
- package/dist/clone-Dy0cR2SZ.cjs.map +1 -0
- package/dist/construct-interface-BfjcOD_E.cjs +117 -0
- package/dist/construct-interface-BfjcOD_E.cjs.map +1 -0
- package/dist/construct-interface-BqwRNYA2.d.mts +131 -0
- package/dist/construct-interface-BqwRNYA2.d.mts.map +1 -0
- package/dist/construct-interface-D2nNkHUN.d.cts +131 -0
- package/dist/construct-interface-D2nNkHUN.d.cts.map +1 -0
- package/dist/construct-interface-Z4CpS8tK.mjs +81 -0
- package/dist/construct-interface-Z4CpS8tK.mjs.map +1 -0
- package/dist/construct-interface.cjs +8 -0
- package/dist/construct-interface.d.cts +2 -0
- package/dist/construct-interface.d.mts +2 -0
- package/dist/construct-interface.mjs +3 -0
- package/dist/credential.cjs +96 -0
- package/dist/credential.cjs.map +1 -0
- package/dist/credential.d.cts +61 -0
- package/dist/credential.d.cts.map +1 -0
- package/dist/credential.d.mts +61 -0
- package/dist/credential.d.mts.map +1 -0
- package/dist/credential.mjs +94 -0
- package/dist/credential.mjs.map +1 -0
- package/dist/crons/index.cjs +39 -37
- package/dist/crons/index.cjs.map +1 -1
- package/dist/crons/index.d.cts +21 -8
- package/dist/crons/index.d.cts.map +1 -1
- package/dist/crons/index.d.mts +29 -13
- package/dist/crons/index.d.mts.map +1 -1
- package/dist/crons/index.mjs +37 -36
- package/dist/crons/index.mjs.map +1 -1
- package/dist/database/kysely.cjs +181 -0
- package/dist/database/kysely.cjs.map +1 -0
- package/dist/database/kysely.d.cts +152 -0
- package/dist/database/kysely.d.cts.map +1 -0
- package/dist/database/kysely.d.mts +152 -0
- package/dist/database/kysely.d.mts.map +1 -0
- package/dist/database/kysely.mjs +180 -0
- package/dist/database/kysely.mjs.map +1 -0
- package/dist/email.cjs +59 -0
- package/dist/email.cjs.map +1 -0
- package/dist/email.d.cts +50 -0
- package/dist/email.d.cts.map +1 -0
- package/dist/email.d.mts +50 -0
- package/dist/email.d.mts.map +1 -0
- package/dist/email.mjs +58 -0
- package/dist/email.mjs.map +1 -0
- package/dist/endpoints/index.cjs +21 -747
- package/dist/endpoints/index.d.cts +7 -343
- package/dist/endpoints/index.d.mts +7 -342
- package/dist/endpoints/index.mjs +11 -738
- package/dist/file-server.cjs +154 -0
- package/dist/file-server.cjs.map +1 -0
- package/dist/file-server.d.cts +156 -0
- package/dist/file-server.d.cts.map +1 -0
- package/dist/file-server.d.mts +156 -0
- package/dist/file-server.d.mts.map +1 -0
- package/dist/file-server.mjs +152 -0
- package/dist/file-server.mjs.map +1 -0
- package/dist/functions/index.cjs +4 -2
- package/dist/functions/index.d.cts +3 -2
- package/dist/functions/index.d.mts +3 -2
- package/dist/functions/index.mjs +4 -2
- package/dist/{functions-B-qt91O7.mjs → functions-CvT_q7Y4.mjs} +55 -51
- package/dist/functions-CvT_q7Y4.mjs.map +1 -0
- package/dist/{functions-C8i1kCMM.cjs → functions-DukjG8ov.cjs} +62 -57
- package/dist/functions-DukjG8ov.cjs.map +1 -0
- package/dist/index-7OcOWe75.d.cts +419 -0
- package/dist/index-7OcOWe75.d.cts.map +1 -0
- package/dist/index-Bt-F7u8L.d.mts +419 -0
- package/dist/index-Bt-F7u8L.d.mts.map +1 -0
- package/dist/{index-DP6fqv0I.d.mts → index-CPeqtKgq.d.mts} +48 -19
- package/dist/index-CPeqtKgq.d.mts.map +1 -0
- package/dist/{index-BVs9DvIj.d.cts → index-Dadljnh_.d.cts} +36 -9
- package/dist/index-Dadljnh_.d.cts.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +1 -1
- package/dist/lazyAccessors-DM6HcXQk.mjs +175 -0
- package/dist/lazyAccessors-DM6HcXQk.mjs.map +1 -0
- package/dist/lazyAccessors-DrJj8NpA.cjs +223 -0
- package/dist/lazyAccessors-DrJj8NpA.cjs.map +1 -0
- package/dist/object-storage.cjs +48 -0
- package/dist/object-storage.cjs.map +1 -0
- package/dist/object-storage.d.cts +36 -0
- package/dist/object-storage.d.cts.map +1 -0
- package/dist/object-storage.d.mts +36 -0
- package/dist/object-storage.d.mts.map +1 -0
- package/dist/object-storage.mjs +47 -0
- package/dist/object-storage.mjs.map +1 -0
- package/dist/{processAudits-CKjjivyz.cjs → processAudits-Bc8rz6Ev.cjs} +3 -3
- package/dist/{processAudits-CKjjivyz.cjs.map → processAudits-Bc8rz6Ev.cjs.map} +1 -1
- package/dist/{processAudits-ySnizdMG.mjs → processAudits-D89tICM4.mjs} +1 -1
- package/dist/{processAudits-ySnizdMG.mjs.map → processAudits-D89tICM4.mjs.map} +1 -1
- package/dist/{publisher-BrFOF847.mjs → publisher-CGEo8UKD.mjs} +1 -1
- package/dist/{publisher-BrFOF847.mjs.map → publisher-CGEo8UKD.mjs.map} +1 -1
- package/dist/{publisher-lFQleddL.cjs → publisher-CqGsXB2X.cjs} +1 -1
- package/dist/{publisher-lFQleddL.cjs.map → publisher-CqGsXB2X.cjs.map} +1 -1
- package/dist/queue/index.cjs +92 -30
- package/dist/queue/index.cjs.map +1 -1
- package/dist/queue/index.d.cts +19 -4
- package/dist/queue/index.d.cts.map +1 -1
- package/dist/queue/index.d.mts +22 -6
- package/dist/queue/index.d.mts.map +1 -1
- package/dist/queue/index.mjs +90 -29
- package/dist/queue/index.mjs.map +1 -1
- package/dist/rest-api.cjs +187 -0
- package/dist/rest-api.cjs.map +1 -0
- package/dist/rest-api.d.cts +221 -0
- package/dist/rest-api.d.cts.map +1 -0
- package/dist/rest-api.d.mts +221 -0
- package/dist/rest-api.d.mts.map +1 -0
- package/dist/rest-api.mjs +186 -0
- package/dist/rest-api.mjs.map +1 -0
- package/dist/site.cjs +48 -0
- package/dist/site.cjs.map +1 -0
- package/dist/site.d.cts +101 -0
- package/dist/site.d.cts.map +1 -0
- package/dist/site.d.mts +101 -0
- package/dist/site.d.mts.map +1 -0
- package/dist/site.mjs +47 -0
- package/dist/site.mjs.map +1 -0
- package/dist/subscribers/index.cjs +35 -27
- package/dist/subscribers/index.cjs.map +1 -1
- package/dist/subscribers/index.d.cts +20 -5
- package/dist/subscribers/index.d.cts.map +1 -1
- package/dist/subscribers/index.d.mts +23 -7
- package/dist/subscribers/index.d.mts.map +1 -1
- package/dist/subscribers/index.mjs +34 -27
- package/dist/subscribers/index.mjs.map +1 -1
- package/dist/surfaceEnv-BFXEms2f.cjs +39 -0
- package/dist/surfaceEnv-BFXEms2f.cjs.map +1 -0
- package/dist/surfaceEnv-C3Ktahea.mjs +27 -0
- package/dist/surfaceEnv-C3Ktahea.mjs.map +1 -0
- package/dist/{telemetry-3vdxGn4q.d.mts → telemetry-C3L0iS28.d.cts} +2 -2
- package/dist/{telemetry-3vdxGn4q.d.mts.map → telemetry-C3L0iS28.d.cts.map} +1 -1
- package/dist/{telemetry-Dqx-D3F7.d.cts → telemetry-D7bVFLGi.d.mts} +2 -2
- package/dist/{telemetry-Dqx-D3F7.d.cts.map → telemetry-D7bVFLGi.d.mts.map} +1 -1
- package/dist/topic/index.cjs +56 -13
- package/dist/topic/index.cjs.map +1 -1
- package/dist/topic/index.d.cts +2 -2
- package/dist/topic/index.d.cts.map +1 -1
- package/dist/topic/index.d.mts +2 -2
- package/dist/topic/index.d.mts.map +1 -1
- package/dist/topic/index.mjs +54 -12
- package/dist/topic/index.mjs.map +1 -1
- package/dist/{types-BDNGr7pv.d.mts → types-BlAkSuGI.d.cts} +1 -1
- package/dist/{types-BDNGr7pv.d.mts.map → types-BlAkSuGI.d.cts.map} +1 -1
- package/dist/{types-BdAaYDvd.d.cts → types-aKksMEWL.d.mts} +1 -1
- package/dist/{types-BdAaYDvd.d.cts.map → types-aKksMEWL.d.mts.map} +1 -1
- package/dist/types.d.cts +1 -1
- package/dist/types.d.mts +1 -1
- package/package.json +155 -23
- package/CHANGELOG.md +0 -396
- package/dist/Construct-DCMuYOox.d.mts.map +0 -1
- package/dist/Construct-_1wX7p_Y.d.cts.map +0 -1
- package/dist/Construct-r0U2zBwW.mjs.map +0 -1
- package/dist/Construct-vXMZJgRp.cjs.map +0 -1
- package/dist/Endpoint-CLPSIl6S.d.mts.map +0 -1
- package/dist/Endpoint-DgfRslct.d.cts.map +0 -1
- package/dist/HonoEndpointAdaptor-CkJENANP.cjs.map +0 -1
- package/dist/HonoEndpointAdaptor-DJDT3PMx.mjs.map +0 -1
- package/dist/Queue-DaxjwmOQ.d.cts.map +0 -1
- package/dist/Queue-HBDf0fqz.d.mts.map +0 -1
- package/dist/Subscriber-D8Xm-86W.d.mts.map +0 -1
- package/dist/Topic-C5ZMfveW.d.cts.map +0 -1
- package/dist/Topic-DT10AqHk.d.mts.map +0 -1
- package/dist/endpoints/index.cjs.map +0 -1
- package/dist/endpoints/index.d.cts.map +0 -1
- package/dist/endpoints/index.d.mts.map +0 -1
- package/dist/endpoints/index.mjs.map +0 -1
- package/dist/functions-B-qt91O7.mjs.map +0 -1
- package/dist/functions-C8i1kCMM.cjs.map +0 -1
- package/dist/index-BVs9DvIj.d.cts.map +0 -1
- package/dist/index-DP6fqv0I.d.mts.map +0 -1
- package/dist/lazyAccessors-DfqZR6C4.mjs.map +0 -1
- package/dist/lazyAccessors-DmTG8sQH.cjs.map +0 -1
- package/src/Construct.ts +0 -204
- package/src/__benchmarks__/build-time-optimization.bench.ts +0 -274
- package/src/__benchmarks__/endpoint.bench.ts +0 -494
- package/src/__benchmarks__/fixtures.ts +0 -241
- package/src/__benchmarks__/hono-adaptor.bench.ts +0 -533
- package/src/__benchmarks__/hono-server.bench.ts +0 -249
- package/src/__benchmarks__/response-builder.bench.ts +0 -428
- package/src/__benchmarks__/strategies/strategy-a-lazy-services.ts +0 -319
- package/src/__benchmarks__/strategies/strategy-c-middleware.ts +0 -530
- package/src/__benchmarks__/strategies/strategy-d-opt-in-events.ts +0 -567
- package/src/__tests__/Construct.environment.spec.ts +0 -704
- package/src/__tests__/publisher.setting.spec.ts +0 -508
- package/src/__tests__/publisher.spec.ts +0 -452
- package/src/adaptors/aws.ts +0 -6
- package/src/adaptors/hono.ts +0 -1
- package/src/adaptors/testing.ts +0 -11
- package/src/crons/AWSScheduledFunction.ts +0 -73
- package/src/crons/Cron.ts +0 -149
- package/src/crons/CronBuilder.ts +0 -271
- package/src/crons/__tests__/AWSScheduledFunction.spec.ts +0 -152
- package/src/crons/__tests__/Cron.spec.ts +0 -464
- package/src/crons/__tests__/CronBuilder.state-isolation.spec.ts +0 -227
- package/src/crons/index.ts +0 -12
- package/src/endpoints/AmazonApiGatewayEndpointAdaptor.ts +0 -677
- package/src/endpoints/AmazonApiGatewayV1EndpointAdaptor.ts +0 -105
- package/src/endpoints/AmazonApiGatewayV2EndpointAdaptor.ts +0 -97
- package/src/endpoints/Authorizer.ts +0 -152
- package/src/endpoints/Endpoint.ts +0 -1287
- package/src/endpoints/EndpointBuilder.ts +0 -758
- package/src/endpoints/EndpointFactory.ts +0 -1148
- package/src/endpoints/HonoEndpointAdaptor.ts +0 -677
- package/src/endpoints/MswEndpointAdaptor.ts +0 -226
- package/src/endpoints/TestEndpointAdaptor.ts +0 -422
- package/src/endpoints/__tests__/AmazonApiGatewayV1EndpointAdaptor.audits.spec.ts +0 -499
- package/src/endpoints/__tests__/AmazonApiGatewayV1EndpointAdaptor.events.spec.ts +0 -560
- package/src/endpoints/__tests__/AmazonApiGatewayV1EndpointAdaptor.spec.ts +0 -1304
- package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.audits.spec.ts +0 -626
- package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.events.spec.ts +0 -732
- package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.factory-publisher.spec.ts +0 -296
- package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.kysely-audit.integration.spec.ts +0 -951
- package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.responseType.spec.ts +0 -111
- package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.rls.spec.ts +0 -307
- package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.spec.ts +0 -629
- package/src/endpoints/__tests__/Authorizer.spec.ts +0 -286
- package/src/endpoints/__tests__/Endpoint.cookies.spec.ts +0 -207
- package/src/endpoints/__tests__/Endpoint.headers.spec.ts +0 -187
- package/src/endpoints/__tests__/Endpoint.manifest.spec.ts +0 -175
- package/src/endpoints/__tests__/Endpoint.spec.ts +0 -857
- package/src/endpoints/__tests__/EndpointBuilder.audit.spec.ts +0 -448
- package/src/endpoints/__tests__/EndpointBuilder.responseType.spec.ts +0 -47
- package/src/endpoints/__tests__/EndpointBuilder.spec.ts +0 -523
- package/src/endpoints/__tests__/EndpointFactory.authorizers.spec.ts +0 -492
- package/src/endpoints/__tests__/EndpointFactory.database-auditor.spec.ts +0 -509
- package/src/endpoints/__tests__/EndpointFactory.reference-audit.spec.ts +0 -190
- package/src/endpoints/__tests__/EndpointFactory.spec.ts +0 -479
- package/src/endpoints/__tests__/EndpointFactory.state-isolation.spec.ts +0 -155
- package/src/endpoints/__tests__/HonoEndpointAdaptor.audit-transactions.spec.ts +0 -703
- package/src/endpoints/__tests__/HonoEndpointAdaptor.audits.spec.ts +0 -632
- package/src/endpoints/__tests__/HonoEndpointAdaptor.events.spec.ts +0 -577
- package/src/endpoints/__tests__/HonoEndpointAdaptor.kysely-audit.integration.spec.ts +0 -1067
- package/src/endpoints/__tests__/HonoEndpointAdaptor.openapi.spec.ts +0 -317
- package/src/endpoints/__tests__/HonoEndpointAdaptor.pgboss-publisher.spec.ts +0 -289
- package/src/endpoints/__tests__/HonoEndpointAdaptor.responseType.spec.ts +0 -128
- package/src/endpoints/__tests__/HonoEndpointAdaptor.spec.ts +0 -1207
- package/src/endpoints/__tests__/MswEndpointAdaptor.spec.ts +0 -211
- package/src/endpoints/__tests__/ResponseBuilder.spec.ts +0 -235
- package/src/endpoints/__tests__/TestEndpointAdaptor.audits.spec.ts +0 -602
- package/src/endpoints/__tests__/TestEndpointAdaptor.spec.ts +0 -1044
- package/src/endpoints/__tests__/__snapshots__/HonoEndpointAdaptor.spec.ts.snap +0 -54
- package/src/endpoints/__tests__/endpoint-types.test.ts +0 -88
- package/src/endpoints/__tests__/helpers.spec.ts +0 -37
- package/src/endpoints/__tests__/lazyAccessors.spec.ts +0 -330
- package/src/endpoints/__tests__/processAudits.spec.ts +0 -631
- package/src/endpoints/audit.ts +0 -87
- package/src/endpoints/helpers.ts +0 -98
- package/src/endpoints/index.ts +0 -42
- package/src/endpoints/lazyAccessors.ts +0 -241
- package/src/endpoints/parseHonoQuery.ts +0 -16
- package/src/endpoints/parseQueryParams.ts +0 -32
- package/src/endpoints/processAudits.ts +0 -371
- package/src/endpoints/rls.ts +0 -67
- package/src/functions/AWSLambdaFunction.ts +0 -348
- package/src/functions/BaseFunctionBuilder.ts +0 -201
- package/src/functions/Function.ts +0 -238
- package/src/functions/FunctionBuilder.ts +0 -391
- package/src/functions/FunctionExecutionWrapper.ts +0 -216
- package/src/functions/TestFunctionAdaptor.ts +0 -217
- package/src/functions/__tests__/AWSLambdaFunctionAdaptor.spec.ts +0 -513
- package/src/functions/__tests__/Function.audits.spec.ts +0 -393
- package/src/functions/__tests__/Function.spec.ts +0 -477
- package/src/functions/__tests__/FunctionBuilder.state-isolation.spec.ts +0 -207
- package/src/functions/__tests__/TestFunctionAdaptor.spec.ts +0 -480
- package/src/functions/index.ts +0 -12
- package/src/index.ts +0 -23
- package/src/publisher.ts +0 -93
- package/src/queue/AWSLambdaQueueAdaptor.ts +0 -162
- package/src/queue/Queue.ts +0 -128
- package/src/queue/QueueBuilder.ts +0 -115
- package/src/queue/TestQueueAdaptor.ts +0 -63
- package/src/queue/__tests__/QueueBuilder.spec.ts +0 -137
- package/src/queue/index.ts +0 -12
- package/src/subscribers/AWSLambdaSubscriberAdaptor.ts +0 -342
- package/src/subscribers/Subscriber.ts +0 -117
- package/src/subscribers/SubscriberBuilder.ts +0 -186
- package/src/subscribers/TestSubscriberAdaptor.ts +0 -133
- package/src/subscribers/__tests__/AWSLambdaSubscriberAdaptor.spec.ts +0 -1018
- package/src/subscribers/__tests__/Subscriber.spec.ts +0 -430
- package/src/subscribers/__tests__/TestSubscriberAdaptor.spec.ts +0 -652
- package/src/subscribers/index.ts +0 -6
- package/src/telemetry.ts +0 -103
- package/src/topic/Topic.ts +0 -103
- package/src/topic/TopicBuilder.ts +0 -51
- package/src/topic/__tests__/TopicBuilder.spec.ts +0 -82
- package/src/topic/index.ts +0 -11
- package/src/types.ts +0 -13
- package/test.ts +0 -91
- package/tsconfig.json +0 -9
- package/tsdown.config.ts +0 -34
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publisher-
|
|
1
|
+
{"version":3,"file":"publisher-CqGsXB2X.cjs","names":["logger: Logger","serviceDiscovery: ServiceDiscovery<any>","ev: MappedEvent<T, OutSchema>[]","response: InferStandardSchema<OutSchema>","publisherService: TPublisherService","events: MappedEvent<T, OutSchema>[]","construct: Construct<\n\t\tLogger,\n\t\tTServiceName,\n\t\tT,\n\t\tOutSchema,\n\t\tTServices,\n\t\tTAuditStorageServiceName,\n\t\tTAuditStorage\n\t>"],"sources":["../src/publisher.ts"],"sourcesContent":["import type { AuditStorage } from '@geekmidas/audit';\nimport type { EventPublisher, MappedEvent } from '@geekmidas/events';\nimport type { Logger } from '@geekmidas/logger';\nimport type { InferStandardSchema } from '@geekmidas/schema';\nimport type { Service, ServiceDiscovery } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport type { Construct } from './Construct';\n\nexport async function publishEvents<\n\tT extends EventPublisher<any> | undefined,\n\tOutSchema extends StandardSchemaV1 | undefined = undefined,\n\tTServiceName extends string = string,\n\tTPublisherService extends Service<TServiceName, T> | undefined = undefined,\n>(\n\tlogger: Logger,\n\tserviceDiscovery: ServiceDiscovery<any>,\n\tev: MappedEvent<T, OutSchema>[] = [],\n\tresponse: InferStandardSchema<OutSchema>,\n\tpublisherService: TPublisherService,\n) {\n\ttry {\n\t\tif (!ev?.length) {\n\t\t\tlogger.debug('No events to publish');\n\t\t\treturn;\n\t\t}\n\t\tif (!publisherService) {\n\t\t\tlogger.warn('No publisher service available');\n\t\t\treturn;\n\t\t}\n\n\t\tconst services = await serviceDiscovery.register([publisherService]);\n\n\t\tconst publisher = services[\n\t\t\tpublisherService.serviceName\n\t\t] as EventPublisher<any>;\n\n\t\tconst events: MappedEvent<T, OutSchema>[] = [];\n\n\t\tfor (const { when, payload, type, ...e } of ev) {\n\t\t\tlogger.debug({ event: type }, 'Processing event');\n\t\t\tconst resolvedPayload = await payload(response);\n\t\t\tconst event = {\n\t\t\t\t...e,\n\t\t\t\ttype,\n\t\t\t\tpayload: resolvedPayload,\n\t\t\t};\n\n\t\t\tif (!when || when(response as any)) {\n\t\t\t\tevents.push(event);\n\t\t\t}\n\t\t}\n\n\t\tif (events.length) {\n\t\t\tlogger.debug({ eventCount: ev.length }, 'Publishing events');\n\n\t\t\tawait publisher.publish(events).catch((err) => {\n\t\t\t\tlogger.error(err, 'Failed to publish events');\n\t\t\t});\n\t\t}\n\t} catch (error) {\n\t\tlogger.error(error as any, 'Something went wrong publishing events');\n\t}\n}\n\nexport async function publishConstructEvents<\n\tT extends EventPublisher<any> | undefined,\n\tOutSchema extends StandardSchemaV1 | undefined = undefined,\n\tTServiceName extends string = string,\n\tTServices extends Service[] = [],\n\tTAuditStorageServiceName extends string = string,\n\tTAuditStorage extends AuditStorage | undefined = undefined,\n>(\n\tconstruct: Construct<\n\t\tLogger,\n\t\tTServiceName,\n\t\tT,\n\t\tOutSchema,\n\t\tTServices,\n\t\tTAuditStorageServiceName,\n\t\tTAuditStorage\n\t>,\n\tresponse: InferStandardSchema<OutSchema>,\n\tserviceDiscovery: ServiceDiscovery<any>,\n\tlogger: Logger = construct.logger,\n) {\n\treturn publishEvents(\n\t\tlogger,\n\t\tserviceDiscovery,\n\t\tconstruct.events,\n\t\tresponse,\n\t\tconstruct.publisherService,\n\t);\n}\n"],"mappings":";;AAQA,eAAsB,cAMrBA,QACAC,kBACAC,KAAkC,CAAE,GACpCC,UACAC,kBACC;AACD,KAAI;AACH,OAAK,IAAI,QAAQ;AAChB,UAAO,MAAM,uBAAuB;AACpC;EACA;AACD,OAAK,kBAAkB;AACtB,UAAO,KAAK,iCAAiC;AAC7C;EACA;EAED,MAAM,WAAW,MAAM,iBAAiB,SAAS,CAAC,gBAAiB,EAAC;EAEpE,MAAM,YAAY,SACjB,iBAAiB;EAGlB,MAAMC,SAAsC,CAAE;AAE9C,OAAK,MAAM,EAAE,MAAM,SAAS,KAAM,GAAG,GAAG,IAAI,IAAI;AAC/C,UAAO,MAAM,EAAE,OAAO,KAAM,GAAE,mBAAmB;GACjD,MAAM,kBAAkB,MAAM,QAAQ,SAAS;GAC/C,MAAM,QAAQ;IACb,GAAG;IACH;IACA,SAAS;GACT;AAED,QAAK,QAAQ,KAAK,SAAgB,CACjC,QAAO,KAAK,MAAM;EAEnB;AAED,MAAI,OAAO,QAAQ;AAClB,UAAO,MAAM,EAAE,YAAY,GAAG,OAAQ,GAAE,oBAAoB;AAE5D,SAAM,UAAU,QAAQ,OAAO,CAAC,MAAM,CAAC,QAAQ;AAC9C,WAAO,MAAM,KAAK,2BAA2B;GAC7C,EAAC;EACF;CACD,SAAQ,OAAO;AACf,SAAO,MAAM,OAAc,yCAAyC;CACpE;AACD;AAED,eAAsB,uBAQrBC,WASAH,UACAF,kBACAD,SAAiB,UAAU,QAC1B;AACD,QAAO,cACN,QACA,kBACA,UAAU,QACV,UACA,UAAU,iBACV;AACD"}
|
package/dist/queue/index.cjs
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
const
|
|
1
|
+
const require_chunk = require('../chunk-DWy1uDak.cjs');
|
|
2
|
+
const require_construct_interface = require('../construct-interface-BfjcOD_E.cjs');
|
|
3
|
+
const require_Construct = require('../Construct-roId57cU.cjs');
|
|
4
|
+
const require_clone = require('../clone-Dy0cR2SZ.cjs');
|
|
5
|
+
const __geekmidas_manifest = require_chunk.__toESM(require("@geekmidas/manifest"));
|
|
6
|
+
const __geekmidas_logger_console = require_chunk.__toESM(require("@geekmidas/logger/console"));
|
|
7
|
+
const __geekmidas_events = require_chunk.__toESM(require("@geekmidas/events"));
|
|
5
8
|
|
|
6
9
|
//#region src/queue/Queue.ts
|
|
7
|
-
const DEFAULT_LOGGER$1 = new __geekmidas_logger_console.ConsoleLogger();
|
|
8
10
|
/**
|
|
9
11
|
* A queue worker — a point-to-point SQS-style queue and its single consumer.
|
|
10
12
|
* Unlike a `Subscriber` (topic fan-out, filtered by `subscribedEvents`), a queue
|
|
@@ -19,8 +21,23 @@ var Queue = class extends require_Construct.Construct {
|
|
|
19
21
|
static isQueue(obj) {
|
|
20
22
|
return Boolean(obj && obj.__IS_QUEUE__ === true && obj.type === require_Construct.ConstructType.Queue);
|
|
21
23
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
+
/**
|
|
25
|
+
* The canonical id this queue is declared under.
|
|
26
|
+
*
|
|
27
|
+
* Derived from the name rather than given separately, so `emails` and
|
|
28
|
+
* `Emails` are one queue. The name stays what it was: it is the wire `type`
|
|
29
|
+
* a producer sends and the worker subscribes to, and changing that would
|
|
30
|
+
* silently orphan in-flight messages.
|
|
31
|
+
*/
|
|
32
|
+
id;
|
|
33
|
+
/**
|
|
34
|
+
* The producer's env key. Read by both {@link declare} and
|
|
35
|
+
* {@link publisher}, so what the target publishes and what the producer
|
|
36
|
+
* looks up cannot drift.
|
|
37
|
+
*/
|
|
38
|
+
connectionKey;
|
|
39
|
+
constructor(name, handler, messageSchema, timeout = 3e4, services = [], logger = __geekmidas_logger_console.DEFAULT_LOGGER, batchSize, fifo, constructs = []) {
|
|
40
|
+
super(require_Construct.ConstructType.Queue, logger, services, [], void 0, void 0, timeout, void 0, void 0, constructs);
|
|
24
41
|
this.name = name;
|
|
25
42
|
this.handler = handler;
|
|
26
43
|
this.messageSchema = messageSchema;
|
|
@@ -29,6 +46,29 @@ var Queue = class extends require_Construct.Construct {
|
|
|
29
46
|
this.logger = logger;
|
|
30
47
|
this.batchSize = batchSize;
|
|
31
48
|
this.fifo = fifo;
|
|
49
|
+
this.id = (0, __geekmidas_manifest.canonicalId)(name);
|
|
50
|
+
this.connectionKey = (0, __geekmidas_manifest.provideKey)(this.id, "publisherConnectionString");
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* What this queue is in the manifest.
|
|
54
|
+
*
|
|
55
|
+
* A queue is a resource, not a handler: the worker is reached *through* it,
|
|
56
|
+
* so the declaration carries the producer's key and nothing about the code
|
|
57
|
+
* that drains it. The local target reads this to know which broker has to be
|
|
58
|
+
* running and what connection string to inject.
|
|
59
|
+
*/
|
|
60
|
+
declare() {
|
|
61
|
+
return [{
|
|
62
|
+
kind: "queue",
|
|
63
|
+
id: this.id,
|
|
64
|
+
provides: [this.connectionKey],
|
|
65
|
+
...this.fifo ? { fifo: true } : {},
|
|
66
|
+
worker: {
|
|
67
|
+
id: `${this.id}Worker`,
|
|
68
|
+
handler: `${this.id}.handler`,
|
|
69
|
+
dependencies: []
|
|
70
|
+
}
|
|
71
|
+
}];
|
|
32
72
|
}
|
|
33
73
|
/**
|
|
34
74
|
* The producer side — a `Service` exposing an `EventPublisher` typed to this
|
|
@@ -41,8 +81,24 @@ var Queue = class extends require_Construct.Construct {
|
|
|
41
81
|
* `Construct.getEnvironment()` sniffs it, so the env requirement flows into
|
|
42
82
|
* the manifest and infra links exactly this queue with least privilege.
|
|
43
83
|
*/
|
|
84
|
+
/**
|
|
85
|
+
* The queue as a dependency — what `.dependsOn([emailsQueue])` dissolves
|
|
86
|
+
* into, reachable as `services.emails`.
|
|
87
|
+
*
|
|
88
|
+
* It is the producer: a consumer is the worker written right here, so the
|
|
89
|
+
* only thing another construct can want from a queue is the ability to send
|
|
90
|
+
* to it. {@link publisher} is the same service under its older
|
|
91
|
+
* `<name>Publisher` key, kept for `.services([queue.publisher])`.
|
|
92
|
+
*/
|
|
93
|
+
get service() {
|
|
94
|
+
const { register } = this.publisher;
|
|
95
|
+
return {
|
|
96
|
+
serviceName: (0, __geekmidas_manifest.serviceKey)(this.id),
|
|
97
|
+
register
|
|
98
|
+
};
|
|
99
|
+
}
|
|
44
100
|
get publisher() {
|
|
45
|
-
const envVar =
|
|
101
|
+
const envVar = this.connectionKey;
|
|
46
102
|
return {
|
|
47
103
|
serviceName: `${this.name}Publisher`,
|
|
48
104
|
async register({ envParser }) {
|
|
@@ -68,50 +124,56 @@ var QueueBuilder = class {
|
|
|
68
124
|
_batchSize;
|
|
69
125
|
_fifo;
|
|
70
126
|
_services = [];
|
|
127
|
+
/** The construct ids `.dependsOn()` named — what the manifest records. */
|
|
128
|
+
_constructs = [];
|
|
71
129
|
_logger = __geekmidas_logger_console.DEFAULT_LOGGER;
|
|
72
130
|
/** The queue name — drives the infra queue and its `<NAME>_*` env vars. */
|
|
73
131
|
queue(name) {
|
|
74
|
-
this
|
|
75
|
-
return this;
|
|
132
|
+
return require_clone.cloneWith(this, { _name: name });
|
|
76
133
|
}
|
|
77
134
|
timeout(timeout) {
|
|
78
|
-
this
|
|
79
|
-
return this;
|
|
135
|
+
return require_clone.cloneWith(this, { _timeout: timeout });
|
|
80
136
|
}
|
|
81
137
|
/** SQS event-source batch size (deployed). */
|
|
82
138
|
batchSize(batchSize) {
|
|
83
|
-
this
|
|
84
|
-
return this;
|
|
139
|
+
return require_clone.cloneWith(this, { _batchSize: batchSize });
|
|
85
140
|
}
|
|
86
141
|
/** Mark the queue as FIFO (deployed). */
|
|
87
142
|
fifo(fifo = true) {
|
|
88
|
-
this
|
|
89
|
-
|
|
143
|
+
return require_clone.cloneWith(this, { _fifo: fifo });
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Depend on constructs — a database, a bucket, a mail sender, a queue, a
|
|
147
|
+
* topic.
|
|
148
|
+
*
|
|
149
|
+
* It records the edge and dissolves each construct's client into the
|
|
150
|
+
* handler's service record under the construct's own id, so
|
|
151
|
+
* `.dependsOn([uploads])` is what makes `services.uploads` exist and type.
|
|
152
|
+
*
|
|
153
|
+
* Constructs only. A `Service` does not match the shape, which is what keeps
|
|
154
|
+
* env sniffing confined to `.services()` and the explicit lift.
|
|
155
|
+
*/
|
|
156
|
+
dependsOn(constructs) {
|
|
157
|
+
const services = require_construct_interface.servicesOf(constructs);
|
|
158
|
+
return require_clone.cloneWith(this, {
|
|
159
|
+
_services: [...this._services, ...services],
|
|
160
|
+
_constructs: require_construct_interface.idsOf(constructs, this._constructs)
|
|
161
|
+
});
|
|
90
162
|
}
|
|
91
163
|
services(services) {
|
|
92
|
-
this
|
|
93
|
-
return this;
|
|
164
|
+
return require_clone.cloneWith(this, { _services: [...this._services, ...services] });
|
|
94
165
|
}
|
|
95
166
|
logger(logger) {
|
|
96
|
-
this
|
|
97
|
-
return this;
|
|
167
|
+
return require_clone.cloneWith(this, { _logger: logger });
|
|
98
168
|
}
|
|
99
169
|
/** The typed message (job) payload the queue carries. */
|
|
100
170
|
message(schema) {
|
|
101
|
-
this
|
|
102
|
-
return this;
|
|
171
|
+
return require_clone.cloneWith(this, { _messageSchema: schema });
|
|
103
172
|
}
|
|
104
173
|
handle(fn) {
|
|
105
174
|
if (!this._name) throw new Error("Queue requires a name — call .queue(name) before .handle().");
|
|
106
175
|
if (!this._messageSchema) throw new Error("Queue requires a message schema — call .message(schema) before .handle().");
|
|
107
|
-
const queue = new Queue(this._name, fn, this._messageSchema, this._timeout, this._services, this._logger, this._batchSize, this._fifo);
|
|
108
|
-
this._name = void 0;
|
|
109
|
-
this._messageSchema = void 0;
|
|
110
|
-
this._timeout = 3e4;
|
|
111
|
-
this._batchSize = void 0;
|
|
112
|
-
this._fifo = void 0;
|
|
113
|
-
this._services = [];
|
|
114
|
-
this._logger = __geekmidas_logger_console.DEFAULT_LOGGER;
|
|
176
|
+
const queue = new Queue(this._name, fn, this._messageSchema, this._timeout, this._services, this._logger, this._batchSize, this._fifo, this._constructs);
|
|
115
177
|
return queue;
|
|
116
178
|
}
|
|
117
179
|
};
|
package/dist/queue/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["DEFAULT_LOGGER","ConsoleLogger","Construct","obj: unknown","ConstructType","name: TName","handler: QueueHandler<TMessage, TServices, TLogger>","messageSchema: TMessage","timeout: number","services: TServices","logger: TLogger","batchSize?: number","fifo?: boolean","DEFAULT_LOGGER","name: T","timeout: number","batchSize: number","services: T","logger: T","schema: T","fn: QueueHandler<NonNullable<TMessage>, TServices, TLogger>"],"sources":["../../src/queue/Queue.ts","../../src/queue/QueueBuilder.ts","../../src/queue/index.ts"],"sourcesContent":["import { environmentCase } from '@geekmidas/envkit';\nimport {\n\ttype EventPublisher,\n\ttype EventPublisherConnectionString,\n\ttype PublishableMessage,\n\tPublisher,\n} from '@geekmidas/events';\nimport type { Logger } from '@geekmidas/logger';\nimport { ConsoleLogger } from '@geekmidas/logger/console';\nimport type { InferStandardSchema } from '@geekmidas/schema';\nimport type { Service, ServiceRecord } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport { Construct, ConstructType } from '../Construct';\n\nconst DEFAULT_LOGGER = new ConsoleLogger() as unknown as Logger;\n\n/**\n * The wire message a queue carries: `{ type: <queue name>, payload: <message> }`.\n * The producer publishes this shape and the worker receives the `payload`s as\n * its `messages`. Typing `type` to the queue name keeps the publisher fully\n * typed and lets pg-boss (local) / SQS (deployed) route by name.\n */\nexport type QueueMessage<\n\tTName extends string,\n\tTMessage extends StandardSchemaV1,\n> = PublishableMessage<TName, InferStandardSchema<TMessage>>;\n\n/**\n * A queue worker — a point-to-point SQS-style queue and its single consumer.\n * Unlike a `Subscriber` (topic fan-out, filtered by `subscribedEvents`), a queue\n * drains every message of its one `message` type. Build one with `q` (see\n * `QueueBuilder`); `gkm build` discovers it into the manifest's `queues` field.\n *\n * The producer side is {@link Queue.publisher} — a ready-to-inject `Service`\n * that any endpoint/function drops into `.services([...])` to send messages.\n */\nexport class Queue<\n\tTName extends string = string,\n\tTMessage extends StandardSchemaV1 = StandardSchemaV1,\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n> extends Construct<TLogger, string, undefined, undefined, TServices> {\n\t__IS_QUEUE__ = true;\n\n\tstatic isQueue(\n\t\tobj: unknown,\n\t): obj is Queue<string, StandardSchemaV1, Service[], Logger> {\n\t\treturn Boolean(\n\t\t\tobj &&\n\t\t\t\t(obj as { __IS_QUEUE__?: boolean }).__IS_QUEUE__ === true &&\n\t\t\t\t(obj as Construct).type === ConstructType.Queue,\n\t\t);\n\t}\n\n\tconstructor(\n\t\tpublic readonly name: TName,\n\t\tpublic readonly handler: QueueHandler<TMessage, TServices, TLogger>,\n\t\tpublic readonly messageSchema: TMessage,\n\t\tpublic override readonly timeout: number = 30000,\n\t\tpublic override readonly services: TServices = [] as unknown as TServices,\n\t\tpublic override readonly logger: TLogger = DEFAULT_LOGGER as TLogger,\n\t\t/** SQS event-source batch size (deployed). */\n\t\tpublic readonly batchSize?: number,\n\t\t/** Whether the queue is FIFO (deployed). */\n\t\tpublic readonly fifo?: boolean,\n\t) {\n\t\tsuper(\n\t\t\tConstructType.Queue,\n\t\t\tlogger,\n\t\t\tservices,\n\t\t\t[],\n\t\t\tundefined,\n\t\t\tundefined,\n\t\t\ttimeout,\n\t\t);\n\t}\n\n\t/**\n\t * The producer side — a `Service` exposing an `EventPublisher` typed to this\n\t * queue's message. Inject it via `.services([queue.publisher])`; the handler\n\t * then calls `services.<name>Publisher.publish([{ type, payload }])`.\n\t *\n\t * It reads `<NAME>_PUBLISHER_CONNECTION_STRING` and builds the transport from\n\t * the URL protocol — `pgboss://` locally, `sqs://` deployed — so the same\n\t * code publishes to Postgres in dev and SQS in prod. Because it's a `Service`,\n\t * `Construct.getEnvironment()` sniffs it, so the env requirement flows into\n\t * the manifest and infra links exactly this queue with least privilege.\n\t */\n\tget publisher(): Service<\n\t\t`${TName}Publisher`,\n\t\tEventPublisher<QueueMessage<TName, TMessage>>\n\t> {\n\t\tconst envVar = `${environmentCase(this.name)}_PUBLISHER_CONNECTION_STRING`;\n\t\treturn {\n\t\t\tserviceName: `${this.name}Publisher`,\n\t\t\tasync register({ envParser }) {\n\t\t\t\tconst { connectionString } = envParser\n\t\t\t\t\t.create((get) => ({\n\t\t\t\t\t\tconnectionString: get(envVar).string(),\n\t\t\t\t\t}))\n\t\t\t\t\t.parse();\n\n\t\t\t\treturn Publisher.fromConnectionString<QueueMessage<TName, TMessage>>(\n\t\t\t\t\tconnectionString as EventPublisherConnectionString,\n\t\t\t\t);\n\t\t\t},\n\t\t};\n\t}\n}\n\n/** The context a queue handler receives — a batch of typed messages. */\nexport type QueueContext<\n\tTMessage extends StandardSchemaV1,\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n> = {\n\tmessages: InferStandardSchema<TMessage>[];\n\tservices: ServiceRecord<TServices>;\n\tlogger: TLogger;\n};\n\nexport type QueueHandler<\n\tTMessage extends StandardSchemaV1,\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n> = (\n\tctx: QueueContext<TMessage, TServices, TLogger>,\n) => unknown | Promise<unknown>;\n","import type { Logger } from '@geekmidas/logger';\nimport { DEFAULT_LOGGER } from '@geekmidas/logger/console';\nimport type { Service } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport { Queue, type QueueHandler } from './Queue';\n\n/**\n * Builds a {@link Queue} worker — `q.queue('orders').services([db]).message(schema).handle(fn)`.\n * Services are an array (sniffed for required env vars); `message` is the typed\n * job payload; `handle` is the single consumer. The queue name is captured as a\n * literal so `queue.publisher` is typed to `{ type: '<name>', payload }`.\n */\nexport class QueueBuilder<\n\tTName extends string = string,\n\tTMessage extends StandardSchemaV1 | undefined = undefined,\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n> {\n\tprivate _name?: string;\n\tprivate _messageSchema?: TMessage;\n\tprivate _timeout = 30000;\n\tprivate _batchSize?: number;\n\tprivate _fifo?: boolean;\n\tprivate _services: TServices = [] as Service[] as TServices;\n\tprivate _logger: TLogger = DEFAULT_LOGGER as TLogger;\n\n\t/** The queue name — drives the infra queue and its `<NAME>_*` env vars. */\n\tqueue<T extends string>(\n\t\tname: T,\n\t): QueueBuilder<T, TMessage, TServices, TLogger> {\n\t\tthis._name = name;\n\t\treturn this as unknown as QueueBuilder<T, TMessage, TServices, TLogger>;\n\t}\n\n\ttimeout(timeout: number): this {\n\t\tthis._timeout = timeout;\n\t\treturn this;\n\t}\n\n\t/** SQS event-source batch size (deployed). */\n\tbatchSize(batchSize: number): this {\n\t\tthis._batchSize = batchSize;\n\t\treturn this;\n\t}\n\n\t/** Mark the queue as FIFO (deployed). */\n\tfifo(fifo = true): this {\n\t\tthis._fifo = fifo;\n\t\treturn this;\n\t}\n\n\tservices<T extends Service[]>(\n\t\tservices: T,\n\t): QueueBuilder<TName, TMessage, [...TServices, ...T], TLogger> {\n\t\tthis._services = [...this._services, ...services] as unknown as TServices;\n\t\treturn this as unknown as QueueBuilder<\n\t\t\tTName,\n\t\t\tTMessage,\n\t\t\t[...TServices, ...T],\n\t\t\tTLogger\n\t\t>;\n\t}\n\n\tlogger<T extends Logger>(\n\t\tlogger: T,\n\t): QueueBuilder<TName, TMessage, TServices, T> {\n\t\tthis._logger = logger as unknown as TLogger;\n\t\treturn this as unknown as QueueBuilder<TName, TMessage, TServices, T>;\n\t}\n\n\t/** The typed message (job) payload the queue carries. */\n\tmessage<T extends StandardSchemaV1>(\n\t\tschema: T,\n\t): QueueBuilder<TName, T, TServices, TLogger> {\n\t\tthis._messageSchema = schema as unknown as TMessage;\n\t\treturn this as unknown as QueueBuilder<TName, T, TServices, TLogger>;\n\t}\n\n\thandle(\n\t\tfn: QueueHandler<NonNullable<TMessage>, TServices, TLogger>,\n\t): Queue<TName, NonNullable<TMessage>, TServices, TLogger> {\n\t\tif (!this._name) {\n\t\t\tthrow new Error(\n\t\t\t\t'Queue requires a name — call .queue(name) before .handle().',\n\t\t\t);\n\t\t}\n\t\tif (!this._messageSchema) {\n\t\t\tthrow new Error(\n\t\t\t\t'Queue requires a message schema — call .message(schema) before .handle().',\n\t\t\t);\n\t\t}\n\n\t\tconst queue = new Queue<TName, NonNullable<TMessage>, TServices, TLogger>(\n\t\t\tthis._name as TName,\n\t\t\tfn,\n\t\t\tthis._messageSchema as NonNullable<TMessage>,\n\t\t\tthis._timeout,\n\t\t\tthis._services,\n\t\t\tthis._logger,\n\t\t\tthis._batchSize,\n\t\t\tthis._fifo,\n\t\t);\n\n\t\t// Reset builder state to prevent pollution across reuse.\n\t\tthis._name = undefined;\n\t\tthis._messageSchema = undefined;\n\t\tthis._timeout = 30000;\n\t\tthis._batchSize = undefined;\n\t\tthis._fifo = undefined;\n\t\tthis._services = [] as Service[] as TServices;\n\t\tthis._logger = DEFAULT_LOGGER as TLogger;\n\n\t\treturn queue;\n\t}\n}\n","export {\n\tQueue,\n\ttype QueueContext,\n\ttype QueueHandler,\n\ttype QueueMessage,\n} from './Queue';\n\nimport { QueueBuilder } from './QueueBuilder';\n\nexport { QueueBuilder } from './QueueBuilder';\n\nexport const q = new QueueBuilder();\n"],"mappings":";;;;;;AAcA,MAAMA,mBAAiB,IAAIC;;;;;;;;;;AAsB3B,IAAa,QAAb,cAKUC,4BAA4D;CACrE,eAAe;CAEf,OAAO,QACNC,KAC4D;AAC5D,SAAO,QACN,OACE,IAAmC,iBAAiB,QACpD,IAAkB,SAASC,gCAAc,MAC3C;CACD;CAED,YACiBC,MACAC,SACAC,eACSC,UAAkB,KAClBC,WAAsB,CAAE,GACxBC,SAAkBV,kBAE3BW,WAEAC,MACf;AACD,QACCR,gCAAc,OACd,QACA,UACA,CAAE,mBAGF,QACA;EAnBe;EACA;EACA;EACS;EACA;EACA;EAET;EAEA;CAWhB;;;;;;;;;;;;CAaD,IAAI,YAGF;EACD,MAAM,UAAU,EAAE,wCAAgB,KAAK,KAAK,CAAC;AAC7C,SAAO;GACN,cAAc,EAAE,KAAK,KAAK;GAC1B,MAAM,SAAS,EAAE,WAAW,EAAE;IAC7B,MAAM,EAAE,kBAAkB,GAAG,UAC3B,OAAO,CAAC,SAAS,EACjB,kBAAkB,IAAI,OAAO,CAAC,QAAQ,CACtC,GAAE,CACF,OAAO;AAET,WAAO,6BAAU,qBAChB,iBACA;GACD;EACD;CACD;AACD;;;;;;;;;;AChGD,IAAa,eAAb,MAKE;CACD,AAAQ;CACR,AAAQ;CACR,AAAQ,WAAW;CACnB,AAAQ;CACR,AAAQ;CACR,AAAQ,YAAuB,CAAE;CACjC,AAAQ,UAAmBS;;CAG3B,MACCC,MACgD;AAChD,OAAK,QAAQ;AACb,SAAO;CACP;CAED,QAAQC,SAAuB;AAC9B,OAAK,WAAW;AAChB,SAAO;CACP;;CAGD,UAAUC,WAAyB;AAClC,OAAK,aAAa;AAClB,SAAO;CACP;;CAGD,KAAK,OAAO,MAAY;AACvB,OAAK,QAAQ;AACb,SAAO;CACP;CAED,SACCC,UAC+D;AAC/D,OAAK,YAAY,CAAC,GAAG,KAAK,WAAW,GAAG,QAAS;AACjD,SAAO;CAMP;CAED,OACCC,QAC8C;AAC9C,OAAK,UAAU;AACf,SAAO;CACP;;CAGD,QACCC,QAC6C;AAC7C,OAAK,iBAAiB;AACtB,SAAO;CACP;CAED,OACCC,IAC0D;AAC1D,OAAK,KAAK,MACT,OAAM,IAAI,MACT;AAGF,OAAK,KAAK,eACT,OAAM,IAAI,MACT;EAIF,MAAM,QAAQ,IAAI,MACjB,KAAK,OACL,IACA,KAAK,gBACL,KAAK,UACL,KAAK,WACL,KAAK,SACL,KAAK,YACL,KAAK;AAIN,OAAK;AACL,OAAK;AACL,OAAK,WAAW;AAChB,OAAK;AACL,OAAK;AACL,OAAK,YAAY,CAAE;AACnB,OAAK,UAAUP;AAEf,SAAO;CACP;AACD;;;;ACvGD,MAAa,IAAI,IAAI"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["Construct","obj: unknown","ConstructType","name: TName","handler: QueueHandler<TMessage, TServices, TLogger>","messageSchema: TMessage","timeout: number","services: TServices","logger: TLogger","DEFAULT_LOGGER","batchSize?: number","fifo?: boolean","constructs: string[]","DEFAULT_LOGGER","name: T","timeout: number","batchSize: number","constructs: T","services: T","logger: T","schema: T","fn: QueueHandler<NonNullable<TMessage>, TServices, TLogger>"],"sources":["../../src/queue/Queue.ts","../../src/queue/QueueBuilder.ts","../../src/queue/index.ts"],"sourcesContent":["import {\n\ttype EventPublisher,\n\ttype EventPublisherConnectionString,\n\ttype PublishableMessage,\n\tPublisher,\n} from '@geekmidas/events';\nimport type { Logger } from '@geekmidas/logger';\nimport { DEFAULT_LOGGER } from '@geekmidas/logger/console';\nimport {\n\tcanonicalId,\n\ttype Declaration,\n\tprovideKey,\n\tserviceKey,\n} from '@geekmidas/manifest';\nimport type { InferStandardSchema } from '@geekmidas/schema';\nimport type { Service, ServiceRecord } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport { Construct, ConstructType } from '../Construct';\n\n/**\n * The wire message a queue carries: `{ type: <queue name>, payload: <message> }`.\n * The producer publishes this shape and the worker receives the `payload`s as\n * its `messages`. Typing `type` to the queue name keeps the publisher fully\n * typed and lets pg-boss (local) / SQS (deployed) route by name.\n */\nexport type QueueMessage<\n\tTName extends string,\n\tTMessage extends StandardSchemaV1,\n> = PublishableMessage<TName, InferStandardSchema<TMessage>>;\n\n/**\n * A queue worker — a point-to-point SQS-style queue and its single consumer.\n * Unlike a `Subscriber` (topic fan-out, filtered by `subscribedEvents`), a queue\n * drains every message of its one `message` type. Build one with `q` (see\n * `QueueBuilder`); `gkm build` discovers it into the manifest's `queues` field.\n *\n * The producer side is {@link Queue.publisher} — a ready-to-inject `Service`\n * that any endpoint/function drops into `.services([...])` to send messages.\n */\nexport class Queue<\n\tTName extends string = string,\n\tTMessage extends StandardSchemaV1 = StandardSchemaV1,\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n> extends Construct<TLogger, string, undefined, undefined, TServices> {\n\t__IS_QUEUE__ = true;\n\n\tstatic isQueue(\n\t\tobj: unknown,\n\t): obj is Queue<string, StandardSchemaV1, Service[], Logger> {\n\t\treturn Boolean(\n\t\t\tobj &&\n\t\t\t\t(obj as { __IS_QUEUE__?: boolean }).__IS_QUEUE__ === true &&\n\t\t\t\t(obj as Construct).type === ConstructType.Queue,\n\t\t);\n\t}\n\n\t/**\n\t * The canonical id this queue is declared under.\n\t *\n\t * Derived from the name rather than given separately, so `emails` and\n\t * `Emails` are one queue. The name stays what it was: it is the wire `type`\n\t * a producer sends and the worker subscribes to, and changing that would\n\t * silently orphan in-flight messages.\n\t */\n\treadonly id: string;\n\n\t/**\n\t * The producer's env key. Read by both {@link declare} and\n\t * {@link publisher}, so what the target publishes and what the producer\n\t * looks up cannot drift.\n\t */\n\tprivate readonly connectionKey: string;\n\n\tconstructor(\n\t\tpublic readonly name: TName,\n\t\tpublic readonly handler: QueueHandler<TMessage, TServices, TLogger>,\n\t\tpublic readonly messageSchema: TMessage,\n\t\tpublic override readonly timeout: number = 30000,\n\t\tpublic override readonly services: TServices = [] as unknown as TServices,\n\t\tpublic override readonly logger: TLogger = DEFAULT_LOGGER as TLogger,\n\t\t/** SQS event-source batch size (deployed). */\n\t\tpublic readonly batchSize?: number,\n\t\t/** Whether the queue is FIFO (deployed). */\n\t\tpublic readonly fifo?: boolean,\n\t\t/**\n\t\t * The construct ids the *worker* `.dependsOn()` named — last, so no\n\t\t * existing positional argument moves.\n\t\t */\n\t\tconstructs: string[] = [],\n\t) {\n\t\tsuper(\n\t\t\tConstructType.Queue,\n\t\t\tlogger,\n\t\t\tservices,\n\t\t\t[],\n\t\t\tundefined,\n\t\t\tundefined,\n\t\t\ttimeout,\n\t\t\tundefined, // memorySize\n\t\t\tundefined, // auditorStorageService\n\t\t\tconstructs,\n\t\t);\n\n\t\tthis.id = canonicalId(name);\n\t\tthis.connectionKey = provideKey(this.id, 'publisherConnectionString');\n\t}\n\n\t/**\n\t * What this queue is in the manifest.\n\t *\n\t * A queue is a resource, not a handler: the worker is reached *through* it,\n\t * so the declaration carries the producer's key and nothing about the code\n\t * that drains it. The local target reads this to know which broker has to be\n\t * running and what connection string to inject.\n\t */\n\tdeclare(): Declaration[] {\n\t\treturn [\n\t\t\t{\n\t\t\t\tkind: 'queue',\n\t\t\t\tid: this.id,\n\t\t\t\tprovides: [this.connectionKey],\n\t\t\t\t...(this.fifo ? { fifo: true } : {}),\n\t\t\t\t// Nested rather than a sibling node, because position carries the\n\t\t\t\t// trigger: this handler is reached by messages on this queue and\n\t\t\t\t// by nothing else, so there is no `trigger` field to keep in step.\n\t\t\t\t//\n\t\t\t\t// `handler` is the export name; which directory the build wrote it\n\t\t\t\t// to is the target's business, and a path with a cloud in it does\n\t\t\t\t// not belong in a neutral declaration.\n\t\t\t\tworker: {\n\t\t\t\t\tid: `${this.id}Worker`,\n\t\t\t\t\thandler: `${this.id}.handler`,\n\t\t\t\t\t// Filled by the build from what the worker declared. Empty is a\n\t\t\t\t\t// stated gap, not a claim that it reaches nothing.\n\t\t\t\t\tdependencies: [],\n\t\t\t\t},\n\t\t\t},\n\t\t];\n\t}\n\n\t/**\n\t * The producer side — a `Service` exposing an `EventPublisher` typed to this\n\t * queue's message. Inject it via `.services([queue.publisher])`; the handler\n\t * then calls `services.<name>Publisher.publish([{ type, payload }])`.\n\t *\n\t * It reads `<NAME>_PUBLISHER_CONNECTION_STRING` and builds the transport from\n\t * the URL protocol — `pgboss://` locally, `sqs://` deployed — so the same\n\t * code publishes to Postgres in dev and SQS in prod. Because it's a `Service`,\n\t * `Construct.getEnvironment()` sniffs it, so the env requirement flows into\n\t * the manifest and infra links exactly this queue with least privilege.\n\t */\n\t/**\n\t * The queue as a dependency — what `.dependsOn([emailsQueue])` dissolves\n\t * into, reachable as `services.emails`.\n\t *\n\t * It is the producer: a consumer is the worker written right here, so the\n\t * only thing another construct can want from a queue is the ability to send\n\t * to it. {@link publisher} is the same service under its older\n\t * `<name>Publisher` key, kept for `.services([queue.publisher])`.\n\t */\n\tget service(): Service<\n\t\tUncapitalize<TName>,\n\t\tEventPublisher<QueueMessage<TName, TMessage>>\n\t> {\n\t\tconst { register } = this.publisher;\n\n\t\treturn {\n\t\t\tserviceName: serviceKey(this.id) as Uncapitalize<TName>,\n\t\t\tregister,\n\t\t};\n\t}\n\n\tget publisher(): Service<\n\t\t`${TName}Publisher`,\n\t\tEventPublisher<QueueMessage<TName, TMessage>>\n\t> {\n\t\tconst envVar = this.connectionKey;\n\t\treturn {\n\t\t\tserviceName: `${this.name}Publisher`,\n\t\t\tasync register({ envParser }) {\n\t\t\t\tconst { connectionString } = envParser\n\t\t\t\t\t.create((get) => ({\n\t\t\t\t\t\tconnectionString: get(envVar).string(),\n\t\t\t\t\t}))\n\t\t\t\t\t.parse();\n\n\t\t\t\treturn Publisher.fromConnectionString<QueueMessage<TName, TMessage>>(\n\t\t\t\t\tconnectionString as EventPublisherConnectionString,\n\t\t\t\t);\n\t\t\t},\n\t\t};\n\t}\n}\n\n/** The context a queue handler receives — a batch of typed messages. */\nexport type QueueContext<\n\tTMessage extends StandardSchemaV1,\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n> = {\n\tmessages: InferStandardSchema<TMessage>[];\n\tservices: ServiceRecord<TServices>;\n\tlogger: TLogger;\n};\n\nexport type QueueHandler<\n\tTMessage extends StandardSchemaV1,\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n> = (\n\tctx: QueueContext<TMessage, TServices, TLogger>,\n) => unknown | Promise<unknown>;\n","import type { Logger } from '@geekmidas/logger';\nimport { DEFAULT_LOGGER } from '@geekmidas/logger/console';\nimport type { Service } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport { cloneWith } from '../clone';\nimport {\n\ttype Consumable,\n\tidsOf,\n\ttype ServicesOf,\n\tservicesOf,\n} from '../construct-interface';\nimport { Queue, type QueueHandler } from './Queue';\n\n/**\n * Builds a {@link Queue} worker — `q.queue('orders').services([db]).message(schema).handle(fn)`.\n * Services are an array (sniffed for required env vars); `message` is the typed\n * job payload; `handle` is the single consumer. The queue name is captured as a\n * literal so `queue.publisher` is typed to `{ type: '<name>', payload }`.\n */\nexport class QueueBuilder<\n\tTName extends string = string,\n\tTMessage extends StandardSchemaV1 | undefined = undefined,\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n> {\n\tprivate _name?: string;\n\tprivate _messageSchema?: TMessage;\n\tprivate _timeout = 30000;\n\tprivate _batchSize?: number;\n\tprivate _fifo?: boolean;\n\tprivate _services: TServices = [] as Service[] as TServices;\n\t/** The construct ids `.dependsOn()` named — what the manifest records. */\n\tpublic _constructs: string[] = [];\n\tprivate _logger: TLogger = DEFAULT_LOGGER as TLogger;\n\n\t/** The queue name — drives the infra queue and its `<NAME>_*` env vars. */\n\tqueue<T extends string>(\n\t\tname: T,\n\t): QueueBuilder<T, TMessage, TServices, TLogger> {\n\t\treturn cloneWith(this, { _name: name }) as unknown as QueueBuilder<\n\t\t\tT,\n\t\t\tTMessage,\n\t\t\tTServices,\n\t\t\tTLogger\n\t\t>;\n\t}\n\n\ttimeout(timeout: number): this {\n\t\treturn cloneWith(this, { _timeout: timeout });\n\t}\n\n\t/** SQS event-source batch size (deployed). */\n\tbatchSize(batchSize: number): this {\n\t\treturn cloneWith(this, { _batchSize: batchSize });\n\t}\n\n\t/** Mark the queue as FIFO (deployed). */\n\tfifo(fifo = true): this {\n\t\treturn cloneWith(this, { _fifo: fifo });\n\t}\n\n\t/**\n\t * Depend on constructs — a database, a bucket, a mail sender, a queue, a\n\t * topic.\n\t *\n\t * It records the edge and dissolves each construct's client into the\n\t * handler's service record under the construct's own id, so\n\t * `.dependsOn([uploads])` is what makes `services.uploads` exist and type.\n\t *\n\t * Constructs only. A `Service` does not match the shape, which is what keeps\n\t * env sniffing confined to `.services()` and the explicit lift.\n\t */\n\tdependsOn<const T extends readonly Consumable[]>(\n\t\tconstructs: T,\n\t): QueueBuilder<TName, TMessage, [...TServices, ...ServicesOf<T>], TLogger> {\n\t\t// Both halves of the edge, from one call and one clone: the services the\n\t\t// handler runs with, and the ids the manifest records. Recording them\n\t\t// separately is what let them drift apart.\n\t\t//\n\t\t// `servicesOf` is the half that validates, so it runs first — recording\n\t\t// ids ahead of it left a caught `NotAConstruct` with `undefined` already\n\t\t// on a `string[]`.\n\t\tconst services = servicesOf(constructs) as unknown as Service[];\n\n\t\treturn cloneWith(this, {\n\t\t\t_services: [...this._services, ...services],\n\t\t\t_constructs: idsOf(constructs, this._constructs),\n\t\t}) as unknown as QueueBuilder<\n\t\t\tTName,\n\t\t\tTMessage,\n\t\t\t[...TServices, ...ServicesOf<T>],\n\t\t\tTLogger\n\t\t>;\n\t}\n\n\tservices<T extends Service[]>(\n\t\tservices: T,\n\t): QueueBuilder<TName, TMessage, [...TServices, ...T], TLogger> {\n\t\treturn cloneWith(this, {\n\t\t\t_services: [...this._services, ...services] as unknown as TServices,\n\t\t}) as unknown as QueueBuilder<\n\t\t\tTName,\n\t\t\tTMessage,\n\t\t\t[...TServices, ...T],\n\t\t\tTLogger\n\t\t>;\n\t}\n\n\tlogger<T extends Logger>(\n\t\tlogger: T,\n\t): QueueBuilder<TName, TMessage, TServices, T> {\n\t\treturn cloneWith(this, {\n\t\t\t_logger: logger as unknown as TLogger,\n\t\t}) as unknown as QueueBuilder<TName, TMessage, TServices, T>;\n\t}\n\n\t/** The typed message (job) payload the queue carries. */\n\tmessage<T extends StandardSchemaV1>(\n\t\tschema: T,\n\t): QueueBuilder<TName, T, TServices, TLogger> {\n\t\treturn cloneWith(this, {\n\t\t\t_messageSchema: schema as unknown as TMessage,\n\t\t}) as unknown as QueueBuilder<TName, T, TServices, TLogger>;\n\t}\n\n\thandle(\n\t\tfn: QueueHandler<NonNullable<TMessage>, TServices, TLogger>,\n\t): Queue<TName, NonNullable<TMessage>, TServices, TLogger> {\n\t\tif (!this._name) {\n\t\t\tthrow new Error(\n\t\t\t\t'Queue requires a name — call .queue(name) before .handle().',\n\t\t\t);\n\t\t}\n\t\tif (!this._messageSchema) {\n\t\t\tthrow new Error(\n\t\t\t\t'Queue requires a message schema — call .message(schema) before .handle().',\n\t\t\t);\n\t\t}\n\n\t\tconst queue = new Queue<TName, NonNullable<TMessage>, TServices, TLogger>(\n\t\t\tthis._name as TName,\n\t\t\tfn,\n\t\t\tthis._messageSchema as NonNullable<TMessage>,\n\t\t\tthis._timeout,\n\t\t\tthis._services,\n\t\t\tthis._logger,\n\t\t\tthis._batchSize,\n\t\t\tthis._fifo,\n\t\t\tthis._constructs,\n\t\t);\n\n\t\t// No reset. `.handle()` reads this builder and leaves it alone, so a\n\t\t// configured base — `const fn = f.logger(log).timeout(60_000)` — keeps\n\t\t// its configuration for every construct built from it. The reset that\n\t\t// used to be here wiped the base on first use, which made a base usable\n\t\t// exactly once, and quietly reverted the logger to the default.\n\n\t\treturn queue;\n\t}\n}\n","export {\n\tQueue,\n\ttype QueueContext,\n\ttype QueueHandler,\n\ttype QueueMessage,\n} from './Queue';\n\nimport { QueueBuilder } from './QueueBuilder';\n\nexport { QueueBuilder } from './QueueBuilder';\n\nexport const q = new QueueBuilder();\n"],"mappings":";;;;;;;;;;;;;;;;;;AAuCA,IAAa,QAAb,cAKUA,4BAA4D;CACrE,eAAe;CAEf,OAAO,QACNC,KAC4D;AAC5D,SAAO,QACN,OACE,IAAmC,iBAAiB,QACpD,IAAkB,SAASC,gCAAc,MAC3C;CACD;;;;;;;;;CAUD,AAAS;;;;;;CAOT,AAAiB;CAEjB,YACiBC,MACAC,SACAC,eACSC,UAAkB,KAClBC,WAAsB,CAAE,GACxBC,SAAkBC,2CAE3BC,WAEAC,MAKhBC,aAAuB,CAAE,GACxB;AACD,QACCV,gCAAc,OACd,QACA,UACA,CAAE,mBAGF,yBAGA,WACA;EA3Be;EACA;EACA;EACS;EACA;EACA;EAET;EAEA;AAoBhB,OAAK,KAAK,sCAAY,KAAK;AAC3B,OAAK,gBAAgB,qCAAW,KAAK,IAAI,4BAA4B;CACrE;;;;;;;;;CAUD,UAAyB;AACxB,SAAO,CACN;GACC,MAAM;GACN,IAAI,KAAK;GACT,UAAU,CAAC,KAAK,aAAc;GAC9B,GAAI,KAAK,OAAO,EAAE,MAAM,KAAM,IAAG,CAAE;GAQnC,QAAQ;IACP,KAAK,EAAE,KAAK,GAAG;IACf,UAAU,EAAE,KAAK,GAAG;IAGpB,cAAc,CAAE;GAChB;EACD,CACD;CACD;;;;;;;;;;;;;;;;;;;;;CAsBD,IAAI,UAGF;EACD,MAAM,EAAE,UAAU,GAAG,KAAK;AAE1B,SAAO;GACN,aAAa,qCAAW,KAAK,GAAG;GAChC;EACA;CACD;CAED,IAAI,YAGF;EACD,MAAM,SAAS,KAAK;AACpB,SAAO;GACN,cAAc,EAAE,KAAK,KAAK;GAC1B,MAAM,SAAS,EAAE,WAAW,EAAE;IAC7B,MAAM,EAAE,kBAAkB,GAAG,UAC3B,OAAO,CAAC,SAAS,EACjB,kBAAkB,IAAI,OAAO,CAAC,QAAQ,CACtC,GAAE,CACF,OAAO;AAET,WAAO,6BAAU,qBAChB,iBACA;GACD;EACD;CACD;AACD;;;;;;;;;;AC9KD,IAAa,eAAb,MAKE;CACD,AAAQ;CACR,AAAQ;CACR,AAAQ,WAAW;CACnB,AAAQ;CACR,AAAQ;CACR,AAAQ,YAAuB,CAAE;;CAEjC,AAAO,cAAwB,CAAE;CACjC,AAAQ,UAAmBW;;CAG3B,MACCC,MACgD;AAChD,SAAO,wBAAU,MAAM,EAAE,OAAO,KAAM,EAAC;CAMvC;CAED,QAAQC,SAAuB;AAC9B,SAAO,wBAAU,MAAM,EAAE,UAAU,QAAS,EAAC;CAC7C;;CAGD,UAAUC,WAAyB;AAClC,SAAO,wBAAU,MAAM,EAAE,YAAY,UAAW,EAAC;CACjD;;CAGD,KAAK,OAAO,MAAY;AACvB,SAAO,wBAAU,MAAM,EAAE,OAAO,KAAM,EAAC;CACvC;;;;;;;;;;;;CAaD,UACCC,YAC2E;EAQ3E,MAAM,WAAW,uCAAW,WAAW;AAEvC,SAAO,wBAAU,MAAM;GACtB,WAAW,CAAC,GAAG,KAAK,WAAW,GAAG,QAAS;GAC3C,aAAa,kCAAM,YAAY,KAAK,YAAY;EAChD,EAAC;CAMF;CAED,SACCC,UAC+D;AAC/D,SAAO,wBAAU,MAAM,EACtB,WAAW,CAAC,GAAG,KAAK,WAAW,GAAG,QAAS,EAC3C,EAAC;CAMF;CAED,OACCC,QAC8C;AAC9C,SAAO,wBAAU,MAAM,EACtB,SAAS,OACT,EAAC;CACF;;CAGD,QACCC,QAC6C;AAC7C,SAAO,wBAAU,MAAM,EACtB,gBAAgB,OAChB,EAAC;CACF;CAED,OACCC,IAC0D;AAC1D,OAAK,KAAK,MACT,OAAM,IAAI,MACT;AAGF,OAAK,KAAK,eACT,OAAM,IAAI,MACT;EAIF,MAAM,QAAQ,IAAI,MACjB,KAAK,OACL,IACA,KAAK,gBACL,KAAK,UACL,KAAK,WACL,KAAK,SACL,KAAK,YACL,KAAK,OACL,KAAK;AASN,SAAO;CACP;AACD;;;;ACpJD,MAAa,IAAI,IAAI"}
|
package/dist/queue/index.d.cts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import "../Construct-
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
1
|
+
import "../Construct-WhCXIOPV.cjs";
|
|
2
|
+
import { Consumable, ServicesOf } from "../construct-interface-D2nNkHUN.cjs";
|
|
3
|
+
import { Queue, QueueContext, QueueHandler, QueueMessage } from "../Queue-D6WeziRD.cjs";
|
|
4
|
+
import * as _geekmidas_logger18 from "@geekmidas/logger";
|
|
4
5
|
import { Logger } from "@geekmidas/logger";
|
|
5
6
|
import { Service } from "@geekmidas/services";
|
|
6
7
|
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
@@ -20,6 +21,8 @@ declare class QueueBuilder<TName extends string = string, TMessage extends Stand
|
|
|
20
21
|
private _batchSize?;
|
|
21
22
|
private _fifo?;
|
|
22
23
|
private _services;
|
|
24
|
+
/** The construct ids `.dependsOn()` named — what the manifest records. */
|
|
25
|
+
_constructs: string[];
|
|
23
26
|
private _logger;
|
|
24
27
|
/** The queue name — drives the infra queue and its `<NAME>_*` env vars. */
|
|
25
28
|
queue<T extends string>(name: T): QueueBuilder<T, TMessage, TServices, TLogger>;
|
|
@@ -28,6 +31,18 @@ declare class QueueBuilder<TName extends string = string, TMessage extends Stand
|
|
|
28
31
|
batchSize(batchSize: number): this;
|
|
29
32
|
/** Mark the queue as FIFO (deployed). */
|
|
30
33
|
fifo(fifo?: boolean): this;
|
|
34
|
+
/**
|
|
35
|
+
* Depend on constructs — a database, a bucket, a mail sender, a queue, a
|
|
36
|
+
* topic.
|
|
37
|
+
*
|
|
38
|
+
* It records the edge and dissolves each construct's client into the
|
|
39
|
+
* handler's service record under the construct's own id, so
|
|
40
|
+
* `.dependsOn([uploads])` is what makes `services.uploads` exist and type.
|
|
41
|
+
*
|
|
42
|
+
* Constructs only. A `Service` does not match the shape, which is what keeps
|
|
43
|
+
* env sniffing confined to `.services()` and the explicit lift.
|
|
44
|
+
*/
|
|
45
|
+
dependsOn<const T extends readonly Consumable[]>(constructs: T): QueueBuilder<TName, TMessage, [...TServices, ...ServicesOf<T>], TLogger>;
|
|
31
46
|
services<T extends Service[]>(services: T): QueueBuilder<TName, TMessage, [...TServices, ...T], TLogger>;
|
|
32
47
|
logger<T extends Logger>(logger: T): QueueBuilder<TName, TMessage, TServices, T>;
|
|
33
48
|
/** The typed message (job) payload the queue carries. */
|
|
@@ -37,7 +52,7 @@ declare class QueueBuilder<TName extends string = string, TMessage extends Stand
|
|
|
37
52
|
//# sourceMappingURL=QueueBuilder.d.ts.map
|
|
38
53
|
//#endregion
|
|
39
54
|
//#region src/queue/index.d.ts
|
|
40
|
-
declare const q: QueueBuilder<string, undefined, [],
|
|
55
|
+
declare const q: QueueBuilder<string, undefined, [], _geekmidas_logger18.Logger>;
|
|
41
56
|
//# sourceMappingURL=index.d.ts.map
|
|
42
57
|
|
|
43
58
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/queue/QueueBuilder.ts","../../src/queue/index.ts"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/queue/QueueBuilder.ts","../../src/queue/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;AAmBA;;AAEkB,cAFL,YAEK,CAAA,cAAA,MAAA,GAAA,MAAA,EAAA,iBAAA,gBAAA,GAAA,SAAA,GAAA,SAAA,EAAA,kBACC,OADD,EAAA,GAAA,EAAA,EAAA,gBAED,MAFC,GAEQ,MAFR,CAAA,CAAA;EAAgB,QACf,KAAA;EAAO,QACT,cAAA;EAAM,QAAG,QAAA;EAAM,QAcxB,UAAA;EAAC,QACQ,KAAA;EAAC,QAAE,SAAA;EAAQ;EAAW,WAAE,EAAA,MAAA,EAAA;EAAO,QAA5C,OAAA;EAAY;EAkC8B,KAChC,CAAA,UAAA,MAAA,CAAA,CAAA,IAAA,EApCN,CAoCM,CAAA,EAnCV,YAmCU,CAnCG,CAmCH,EAnCM,QAmCN,EAnCgB,SAmChB,EAnC2B,OAmC3B,CAAA;EAAC,OACE,CAAA,OAAA,EAAA,MAAA,CAAA,EAAA,IAAA;EAAK;EAAU,SAAM,CAAA,SAAA,EAAA,MAAA,CAAA,EAAA,IAAA;EAAS;EAAiB,IAAZ,CAAA,IAAA,CAAA,EAAA,OAAA,CAAA,EAAA,IAAA;EAAU;;;;;;;;;;;EAkCtC,SACd,CAAA,gBAAA,SArC0B,UAqC1B,EAAA,CAAA,CAAA,UAAA,EApCI,CAoCJ,CAAA,EAnCN,YAmCM,CAnCO,KAmCP,EAnCc,QAmCd,EAAA,CAAA,GAnC4B,SAmC5B,EAAA,GAnC0C,UAmC1C,CAnCqD,CAmCrD,CAAA,CAAA,EAnC0D,OAmC1D,CAAA;EAAC,QACM,CAAA,UAfG,OAeH,EAAA,CAAA,CAAA,QAAA,EAdL,CAcK,CAAA,EAbb,YAaa,CAbA,KAaA,EAbO,QAaP,EAAA,CAAA,GAbqB,SAarB,EAAA,GAbmC,CAanC,CAAA,EAbuC,OAavC,CAAA;EAAK,MAAE,CAAA,UAFN,MAEM,CAAA,CAAA,MAAA,EADd,CACc,CAAA,EAApB,YAAoB,CAAP,KAAO,EAAA,QAAA,EAAU,SAAV,EAAqB,CAArB,CAAA;EAAQ;EAAW,OAAE,CAAA,UAO1B,gBAP0B,CAAA,CAAA,MAAA,EAQnC,CARmC,CAAA,EASzC,YATyC,CAS5B,KAT4B,EASrB,CATqB,EASlB,SATkB,EASP,OATO,CAAA;EAAC,MAA1C,CAAA,EAAA,EAgBE,YAhBF,CAgBe,WAhBf,CAgB2B,QAhB3B,CAAA,EAgBsC,SAhBtC,EAgBiD,OAhBjD,CAAA,CAAA,EAiBA,KAjBA,CAiBM,KAjBN,EAiBa,WAjBb,CAiByB,QAjBzB,CAAA,EAiBoC,SAjBpC,EAiB+C,OAjB/C,CAAA;;;;;cCnGS,GAAC,oCAAqB,mBAAA,CAArB,MAAA"}
|
package/dist/queue/index.d.mts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import "../Construct-
|
|
2
|
-
import {
|
|
1
|
+
import "../Construct-B-xc0SE9.mjs";
|
|
2
|
+
import { Consumable, ServicesOf } from "../construct-interface-BqwRNYA2.mjs";
|
|
3
|
+
import { Queue, QueueContext, QueueHandler, QueueMessage } from "../Queue-DpUeqdC8.mjs";
|
|
3
4
|
import { Service } from "@geekmidas/services";
|
|
4
|
-
import
|
|
5
|
+
import * as _geekmidas_logger15 from "@geekmidas/logger";
|
|
6
|
+
import { Logger } from "@geekmidas/logger";
|
|
5
7
|
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
6
8
|
|
|
7
9
|
//#region src/queue/QueueBuilder.d.ts
|
|
@@ -12,13 +14,15 @@ import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
|
12
14
|
* job payload; `handle` is the single consumer. The queue name is captured as a
|
|
13
15
|
* literal so `queue.publisher` is typed to `{ type: '<name>', payload }`.
|
|
14
16
|
*/
|
|
15
|
-
declare class QueueBuilder<TName extends string = string, TMessage extends StandardSchemaV1 | undefined = undefined, TServices extends Service[] = [], TLogger extends Logger
|
|
17
|
+
declare class QueueBuilder<TName extends string = string, TMessage extends StandardSchemaV1 | undefined = undefined, TServices extends Service[] = [], TLogger extends Logger = Logger> {
|
|
16
18
|
private _name?;
|
|
17
19
|
private _messageSchema?;
|
|
18
20
|
private _timeout;
|
|
19
21
|
private _batchSize?;
|
|
20
22
|
private _fifo?;
|
|
21
23
|
private _services;
|
|
24
|
+
/** The construct ids `.dependsOn()` named — what the manifest records. */
|
|
25
|
+
_constructs: string[];
|
|
22
26
|
private _logger;
|
|
23
27
|
/** The queue name — drives the infra queue and its `<NAME>_*` env vars. */
|
|
24
28
|
queue<T extends string>(name: T): QueueBuilder<T, TMessage, TServices, TLogger>;
|
|
@@ -27,8 +31,20 @@ declare class QueueBuilder<TName extends string = string, TMessage extends Stand
|
|
|
27
31
|
batchSize(batchSize: number): this;
|
|
28
32
|
/** Mark the queue as FIFO (deployed). */
|
|
29
33
|
fifo(fifo?: boolean): this;
|
|
34
|
+
/**
|
|
35
|
+
* Depend on constructs — a database, a bucket, a mail sender, a queue, a
|
|
36
|
+
* topic.
|
|
37
|
+
*
|
|
38
|
+
* It records the edge and dissolves each construct's client into the
|
|
39
|
+
* handler's service record under the construct's own id, so
|
|
40
|
+
* `.dependsOn([uploads])` is what makes `services.uploads` exist and type.
|
|
41
|
+
*
|
|
42
|
+
* Constructs only. A `Service` does not match the shape, which is what keeps
|
|
43
|
+
* env sniffing confined to `.services()` and the explicit lift.
|
|
44
|
+
*/
|
|
45
|
+
dependsOn<const T extends readonly Consumable[]>(constructs: T): QueueBuilder<TName, TMessage, [...TServices, ...ServicesOf<T>], TLogger>;
|
|
30
46
|
services<T extends Service[]>(services: T): QueueBuilder<TName, TMessage, [...TServices, ...T], TLogger>;
|
|
31
|
-
logger<T extends Logger
|
|
47
|
+
logger<T extends Logger>(logger: T): QueueBuilder<TName, TMessage, TServices, T>;
|
|
32
48
|
/** The typed message (job) payload the queue carries. */
|
|
33
49
|
message<T extends StandardSchemaV1>(schema: T): QueueBuilder<TName, T, TServices, TLogger>;
|
|
34
50
|
handle(fn: QueueHandler<NonNullable<TMessage>, TServices, TLogger>): Queue<TName, NonNullable<TMessage>, TServices, TLogger>;
|
|
@@ -36,7 +52,7 @@ declare class QueueBuilder<TName extends string = string, TMessage extends Stand
|
|
|
36
52
|
//# sourceMappingURL=QueueBuilder.d.ts.map
|
|
37
53
|
//#endregion
|
|
38
54
|
//#region src/queue/index.d.ts
|
|
39
|
-
declare const q: QueueBuilder<string, undefined, [], Logger>;
|
|
55
|
+
declare const q: QueueBuilder<string, undefined, [], _geekmidas_logger15.Logger>;
|
|
40
56
|
//# sourceMappingURL=index.d.ts.map
|
|
41
57
|
|
|
42
58
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/queue/QueueBuilder.ts","../../src/queue/index.ts"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/queue/QueueBuilder.ts","../../src/queue/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;AAmBA;;AAEkB,cAFL,YAEK,CAAA,cAAA,MAAA,GAAA,MAAA,EAAA,iBAAA,gBAAA,GAAA,SAAA,GAAA,SAAA,EAAA,kBACC,OADD,EAAA,GAAA,EAAA,EAAA,gBAED,MAFC,GAEQ,MAFR,CAAA,CAAA;EAAgB,QACf,KAAA;EAAO,QACT,cAAA;EAAM,QAAG,QAAA;EAAM,QAcxB,UAAA;EAAC,QACQ,KAAA;EAAC,QAAE,SAAA;EAAQ;EAAW,WAAE,EAAA,MAAA,EAAA;EAAO,QAA5C,OAAA;EAAY;EAkC8B,KAChC,CAAA,UAAA,MAAA,CAAA,CAAA,IAAA,EApCN,CAoCM,CAAA,EAnCV,YAmCU,CAnCG,CAmCH,EAnCM,QAmCN,EAnCgB,SAmChB,EAnC2B,OAmC3B,CAAA;EAAC,OACE,CAAA,OAAA,EAAA,MAAA,CAAA,EAAA,IAAA;EAAK;EAAU,SAAM,CAAA,SAAA,EAAA,MAAA,CAAA,EAAA,IAAA;EAAS;EAAiB,IAAZ,CAAA,IAAA,CAAA,EAAA,OAAA,CAAA,EAAA,IAAA;EAAU;;;;;;;;;;;EAkCtC,SACd,CAAA,gBAAA,SArC0B,UAqC1B,EAAA,CAAA,CAAA,UAAA,EApCI,CAoCJ,CAAA,EAnCN,YAmCM,CAnCO,KAmCP,EAnCc,QAmCd,EAAA,CAAA,GAnC4B,SAmC5B,EAAA,GAnC0C,UAmC1C,CAnCqD,CAmCrD,CAAA,CAAA,EAnC0D,OAmC1D,CAAA;EAAC,QACM,CAAA,UAfG,OAeH,EAAA,CAAA,CAAA,QAAA,EAdL,CAcK,CAAA,EAbb,YAaa,CAbA,KAaA,EAbO,QAaP,EAAA,CAAA,GAbqB,SAarB,EAAA,GAbmC,CAanC,CAAA,EAbuC,OAavC,CAAA;EAAK,MAAE,CAAA,UAFN,MAEM,CAAA,CAAA,MAAA,EADd,CACc,CAAA,EAApB,YAAoB,CAAP,KAAO,EAAA,QAAA,EAAU,SAAV,EAAqB,CAArB,CAAA;EAAQ;EAAW,OAAE,CAAA,UAO1B,gBAP0B,CAAA,CAAA,MAAA,EAQnC,CARmC,CAAA,EASzC,YATyC,CAS5B,KAT4B,EASrB,CATqB,EASlB,SATkB,EASP,OATO,CAAA;EAAC,MAA1C,CAAA,EAAA,EAgBE,YAhBF,CAgBe,WAhBf,CAgB2B,QAhB3B,CAAA,EAgBsC,SAhBtC,EAgBiD,OAhBjD,CAAA,CAAA,EAiBA,KAjBA,CAiBM,KAjBN,EAiBa,WAjBb,CAiByB,QAjBzB,CAAA,EAiBoC,SAjBpC,EAiB+C,OAjB/C,CAAA;;;;;cCnGS,GAAC,oCAAqB,mBAAA,CAArB,MAAA"}
|
package/dist/queue/index.mjs
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { Construct, ConstructType } from "../Construct-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { Construct, ConstructType } from "../Construct-HmWM6YYu.mjs";
|
|
2
|
+
import { idsOf, servicesOf } from "../construct-interface-Z4CpS8tK.mjs";
|
|
3
|
+
import { cloneWith } from "../clone-DblgEZZa.mjs";
|
|
4
|
+
import { canonicalId, provideKey, serviceKey } from "@geekmidas/manifest";
|
|
5
|
+
import { DEFAULT_LOGGER } from "@geekmidas/logger/console";
|
|
4
6
|
import { Publisher } from "@geekmidas/events";
|
|
5
7
|
|
|
6
8
|
//#region src/queue/Queue.ts
|
|
7
|
-
const DEFAULT_LOGGER$1 = new ConsoleLogger();
|
|
8
9
|
/**
|
|
9
10
|
* A queue worker — a point-to-point SQS-style queue and its single consumer.
|
|
10
11
|
* Unlike a `Subscriber` (topic fan-out, filtered by `subscribedEvents`), a queue
|
|
@@ -19,8 +20,23 @@ var Queue = class extends Construct {
|
|
|
19
20
|
static isQueue(obj) {
|
|
20
21
|
return Boolean(obj && obj.__IS_QUEUE__ === true && obj.type === ConstructType.Queue);
|
|
21
22
|
}
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
/**
|
|
24
|
+
* The canonical id this queue is declared under.
|
|
25
|
+
*
|
|
26
|
+
* Derived from the name rather than given separately, so `emails` and
|
|
27
|
+
* `Emails` are one queue. The name stays what it was: it is the wire `type`
|
|
28
|
+
* a producer sends and the worker subscribes to, and changing that would
|
|
29
|
+
* silently orphan in-flight messages.
|
|
30
|
+
*/
|
|
31
|
+
id;
|
|
32
|
+
/**
|
|
33
|
+
* The producer's env key. Read by both {@link declare} and
|
|
34
|
+
* {@link publisher}, so what the target publishes and what the producer
|
|
35
|
+
* looks up cannot drift.
|
|
36
|
+
*/
|
|
37
|
+
connectionKey;
|
|
38
|
+
constructor(name, handler, messageSchema, timeout = 3e4, services = [], logger = DEFAULT_LOGGER, batchSize, fifo, constructs = []) {
|
|
39
|
+
super(ConstructType.Queue, logger, services, [], void 0, void 0, timeout, void 0, void 0, constructs);
|
|
24
40
|
this.name = name;
|
|
25
41
|
this.handler = handler;
|
|
26
42
|
this.messageSchema = messageSchema;
|
|
@@ -29,6 +45,29 @@ var Queue = class extends Construct {
|
|
|
29
45
|
this.logger = logger;
|
|
30
46
|
this.batchSize = batchSize;
|
|
31
47
|
this.fifo = fifo;
|
|
48
|
+
this.id = canonicalId(name);
|
|
49
|
+
this.connectionKey = provideKey(this.id, "publisherConnectionString");
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* What this queue is in the manifest.
|
|
53
|
+
*
|
|
54
|
+
* A queue is a resource, not a handler: the worker is reached *through* it,
|
|
55
|
+
* so the declaration carries the producer's key and nothing about the code
|
|
56
|
+
* that drains it. The local target reads this to know which broker has to be
|
|
57
|
+
* running and what connection string to inject.
|
|
58
|
+
*/
|
|
59
|
+
declare() {
|
|
60
|
+
return [{
|
|
61
|
+
kind: "queue",
|
|
62
|
+
id: this.id,
|
|
63
|
+
provides: [this.connectionKey],
|
|
64
|
+
...this.fifo ? { fifo: true } : {},
|
|
65
|
+
worker: {
|
|
66
|
+
id: `${this.id}Worker`,
|
|
67
|
+
handler: `${this.id}.handler`,
|
|
68
|
+
dependencies: []
|
|
69
|
+
}
|
|
70
|
+
}];
|
|
32
71
|
}
|
|
33
72
|
/**
|
|
34
73
|
* The producer side — a `Service` exposing an `EventPublisher` typed to this
|
|
@@ -41,8 +80,24 @@ var Queue = class extends Construct {
|
|
|
41
80
|
* `Construct.getEnvironment()` sniffs it, so the env requirement flows into
|
|
42
81
|
* the manifest and infra links exactly this queue with least privilege.
|
|
43
82
|
*/
|
|
83
|
+
/**
|
|
84
|
+
* The queue as a dependency — what `.dependsOn([emailsQueue])` dissolves
|
|
85
|
+
* into, reachable as `services.emails`.
|
|
86
|
+
*
|
|
87
|
+
* It is the producer: a consumer is the worker written right here, so the
|
|
88
|
+
* only thing another construct can want from a queue is the ability to send
|
|
89
|
+
* to it. {@link publisher} is the same service under its older
|
|
90
|
+
* `<name>Publisher` key, kept for `.services([queue.publisher])`.
|
|
91
|
+
*/
|
|
92
|
+
get service() {
|
|
93
|
+
const { register } = this.publisher;
|
|
94
|
+
return {
|
|
95
|
+
serviceName: serviceKey(this.id),
|
|
96
|
+
register
|
|
97
|
+
};
|
|
98
|
+
}
|
|
44
99
|
get publisher() {
|
|
45
|
-
const envVar =
|
|
100
|
+
const envVar = this.connectionKey;
|
|
46
101
|
return {
|
|
47
102
|
serviceName: `${this.name}Publisher`,
|
|
48
103
|
async register({ envParser }) {
|
|
@@ -68,50 +123,56 @@ var QueueBuilder = class {
|
|
|
68
123
|
_batchSize;
|
|
69
124
|
_fifo;
|
|
70
125
|
_services = [];
|
|
126
|
+
/** The construct ids `.dependsOn()` named — what the manifest records. */
|
|
127
|
+
_constructs = [];
|
|
71
128
|
_logger = DEFAULT_LOGGER;
|
|
72
129
|
/** The queue name — drives the infra queue and its `<NAME>_*` env vars. */
|
|
73
130
|
queue(name) {
|
|
74
|
-
this
|
|
75
|
-
return this;
|
|
131
|
+
return cloneWith(this, { _name: name });
|
|
76
132
|
}
|
|
77
133
|
timeout(timeout) {
|
|
78
|
-
this
|
|
79
|
-
return this;
|
|
134
|
+
return cloneWith(this, { _timeout: timeout });
|
|
80
135
|
}
|
|
81
136
|
/** SQS event-source batch size (deployed). */
|
|
82
137
|
batchSize(batchSize) {
|
|
83
|
-
this
|
|
84
|
-
return this;
|
|
138
|
+
return cloneWith(this, { _batchSize: batchSize });
|
|
85
139
|
}
|
|
86
140
|
/** Mark the queue as FIFO (deployed). */
|
|
87
141
|
fifo(fifo = true) {
|
|
88
|
-
this
|
|
89
|
-
|
|
142
|
+
return cloneWith(this, { _fifo: fifo });
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Depend on constructs — a database, a bucket, a mail sender, a queue, a
|
|
146
|
+
* topic.
|
|
147
|
+
*
|
|
148
|
+
* It records the edge and dissolves each construct's client into the
|
|
149
|
+
* handler's service record under the construct's own id, so
|
|
150
|
+
* `.dependsOn([uploads])` is what makes `services.uploads` exist and type.
|
|
151
|
+
*
|
|
152
|
+
* Constructs only. A `Service` does not match the shape, which is what keeps
|
|
153
|
+
* env sniffing confined to `.services()` and the explicit lift.
|
|
154
|
+
*/
|
|
155
|
+
dependsOn(constructs) {
|
|
156
|
+
const services = servicesOf(constructs);
|
|
157
|
+
return cloneWith(this, {
|
|
158
|
+
_services: [...this._services, ...services],
|
|
159
|
+
_constructs: idsOf(constructs, this._constructs)
|
|
160
|
+
});
|
|
90
161
|
}
|
|
91
162
|
services(services) {
|
|
92
|
-
this
|
|
93
|
-
return this;
|
|
163
|
+
return cloneWith(this, { _services: [...this._services, ...services] });
|
|
94
164
|
}
|
|
95
165
|
logger(logger) {
|
|
96
|
-
this
|
|
97
|
-
return this;
|
|
166
|
+
return cloneWith(this, { _logger: logger });
|
|
98
167
|
}
|
|
99
168
|
/** The typed message (job) payload the queue carries. */
|
|
100
169
|
message(schema) {
|
|
101
|
-
this
|
|
102
|
-
return this;
|
|
170
|
+
return cloneWith(this, { _messageSchema: schema });
|
|
103
171
|
}
|
|
104
172
|
handle(fn) {
|
|
105
173
|
if (!this._name) throw new Error("Queue requires a name — call .queue(name) before .handle().");
|
|
106
174
|
if (!this._messageSchema) throw new Error("Queue requires a message schema — call .message(schema) before .handle().");
|
|
107
|
-
const queue = new Queue(this._name, fn, this._messageSchema, this._timeout, this._services, this._logger, this._batchSize, this._fifo);
|
|
108
|
-
this._name = void 0;
|
|
109
|
-
this._messageSchema = void 0;
|
|
110
|
-
this._timeout = 3e4;
|
|
111
|
-
this._batchSize = void 0;
|
|
112
|
-
this._fifo = void 0;
|
|
113
|
-
this._services = [];
|
|
114
|
-
this._logger = DEFAULT_LOGGER;
|
|
175
|
+
const queue = new Queue(this._name, fn, this._messageSchema, this._timeout, this._services, this._logger, this._batchSize, this._fifo, this._constructs);
|
|
115
176
|
return queue;
|
|
116
177
|
}
|
|
117
178
|
};
|