@geekmidas/constructs 10.0.0-alpha.98 → 10.0.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/CHANGELOG.md +437 -0
- package/README.md +193 -285
- package/dist/AWSScheduledFunction-BzGCUbkk.d.mts +117 -0
- package/dist/AWSScheduledFunction-BzGCUbkk.d.mts.map +1 -0
- package/dist/AWSScheduledFunction-C42adp8A.cjs +266 -0
- package/dist/AWSScheduledFunction-C42adp8A.cjs.map +1 -0
- package/dist/AWSScheduledFunction-CsNJhXQj.d.cts +117 -0
- package/dist/AWSScheduledFunction-CsNJhXQj.d.cts.map +1 -0
- package/dist/AWSScheduledFunction-KP6lqbsW.mjs +254 -0
- package/dist/AWSScheduledFunction-KP6lqbsW.mjs.map +1 -0
- package/dist/{Construct-B1vGBPme.mjs → Construct-BWF5HxaM.mjs} +37 -47
- package/dist/Construct-BWF5HxaM.mjs.map +1 -0
- package/dist/Construct-JlyQkBkv.d.cts +117 -0
- package/dist/Construct-JlyQkBkv.d.cts.map +1 -0
- package/dist/{Construct-DUSXuTHP.cjs → Construct-TGIM_E4o.cjs} +88 -67
- package/dist/Construct-TGIM_E4o.cjs.map +1 -0
- package/dist/Construct-pxwC6fDD.d.mts +117 -0
- package/dist/Construct-pxwC6fDD.d.mts.map +1 -0
- package/dist/{Endpoint-Du-NwPX2.d.mts → Endpoint-B0P_pEMr.d.mts} +85 -126
- package/dist/Endpoint-B0P_pEMr.d.mts.map +1 -0
- package/dist/{Endpoint-aCvBMPoH.d.cts → Endpoint-BLZ7r67m.d.cts} +84 -125
- package/dist/Endpoint-BLZ7r67m.d.cts.map +1 -0
- package/dist/{HonoEndpointAdaptor-PtPlbeKY.mjs → HonoEndpointAdaptor-BMVwx2cz.mjs} +69 -81
- package/dist/HonoEndpointAdaptor-BMVwx2cz.mjs.map +1 -0
- package/dist/{HonoEndpointAdaptor-zVzVLJEO.cjs → HonoEndpointAdaptor-DPDsDi-D.cjs} +77 -92
- package/dist/HonoEndpointAdaptor-DPDsDi-D.cjs.map +1 -0
- package/dist/Queue-BL68oDJ-.d.mts +66 -0
- package/dist/Queue-BL68oDJ-.d.mts.map +1 -0
- package/dist/Queue-DxJ6btRE.d.cts +66 -0
- package/dist/Queue-DxJ6btRE.d.cts.map +1 -0
- package/dist/Subscriber-BpVhcGhX.d.cts +47 -0
- package/dist/Subscriber-BpVhcGhX.d.cts.map +1 -0
- package/dist/Subscriber-DF6xsBAJ.d.mts +47 -0
- package/dist/Subscriber-DF6xsBAJ.d.mts.map +1 -0
- package/dist/Topic-DJXoDeMP.d.cts +60 -0
- package/dist/Topic-DJXoDeMP.d.cts.map +1 -0
- package/dist/Topic-DxWQBgMN.d.mts +60 -0
- package/dist/Topic-DxWQBgMN.d.mts.map +1 -0
- package/dist/adaptors/aws.cjs +205 -355
- package/dist/adaptors/aws.cjs.map +1 -1
- package/dist/adaptors/aws.d.cts +48 -126
- package/dist/adaptors/aws.d.cts.map +1 -1
- package/dist/adaptors/aws.d.mts +49 -127
- package/dist/adaptors/aws.d.mts.map +1 -1
- package/dist/adaptors/aws.mjs +178 -325
- package/dist/adaptors/aws.mjs.map +1 -1
- package/dist/adaptors/hono.cjs +9 -3
- package/dist/adaptors/hono.d.cts +15 -7
- package/dist/adaptors/hono.d.cts.map +1 -1
- package/dist/adaptors/hono.d.mts +17 -9
- package/dist/adaptors/hono.d.mts.map +1 -1
- package/dist/adaptors/hono.mjs +9 -2
- package/dist/adaptors/testing.cjs +209 -831
- package/dist/adaptors/testing.cjs.map +1 -1
- package/dist/adaptors/testing.d.cts +55 -351
- package/dist/adaptors/testing.d.cts.map +1 -1
- package/dist/adaptors/testing.d.mts +53 -349
- package/dist/adaptors/testing.d.mts.map +1 -1
- package/dist/adaptors/testing.mjs +195 -798
- package/dist/adaptors/testing.mjs.map +1 -1
- package/dist/{clone-UGJpvQnL.cjs → clone-I_WIpiFf.cjs} +8 -7
- package/dist/clone-I_WIpiFf.cjs.map +1 -0
- package/dist/{clone-EKNovYHu.mjs → clone-pdXxc0t3.mjs} +3 -3
- package/dist/clone-pdXxc0t3.mjs.map +1 -0
- package/dist/crons/index.cjs +66 -190
- package/dist/crons/index.cjs.map +1 -1
- package/dist/crons/index.d.cts +35 -70
- package/dist/crons/index.d.cts.map +1 -1
- package/dist/crons/index.d.mts +32 -70
- package/dist/crons/index.d.mts.map +1 -1
- package/dist/crons/index.mjs +63 -184
- package/dist/crons/index.mjs.map +1 -1
- package/dist/endpoints/index.cjs +761 -19
- package/dist/endpoints/index.cjs.map +1 -0
- package/dist/endpoints/index.d.cts +322 -22
- package/dist/endpoints/index.d.cts.map +1 -1
- package/dist/endpoints/index.d.mts +321 -22
- package/dist/endpoints/index.d.mts.map +1 -1
- package/dist/endpoints/index.mjs +751 -6
- package/dist/endpoints/index.mjs.map +1 -0
- package/dist/functions/index.cjs +5 -2
- package/dist/functions/index.d.cts +3 -3
- package/dist/functions/index.d.mts +3 -3
- package/dist/functions/index.mjs +5 -2
- package/dist/{functions-BFizikJU.mjs → functions-EqTloHjo.mjs} +331 -425
- package/dist/functions-EqTloHjo.mjs.map +1 -0
- package/dist/{functions-CfzJG9hK.cjs → functions-SqtCDc9c.cjs} +370 -459
- package/dist/functions-SqtCDc9c.cjs.map +1 -0
- package/dist/index-C7iynzLI.d.mts +139 -0
- package/dist/index-C7iynzLI.d.mts.map +1 -0
- package/dist/index-D4dM_WDY.d.cts +142 -0
- package/dist/index-D4dM_WDY.d.cts.map +1 -0
- package/dist/index.cjs +3 -6
- package/dist/index.d.cts +4 -27
- package/dist/index.d.mts +4 -27
- package/dist/index.mjs +3 -3
- package/dist/{Endpoint-BG4UJ9oA.mjs → lazyAccessors-CCTK19xj.mjs} +1040 -914
- package/dist/lazyAccessors-CCTK19xj.mjs.map +1 -0
- package/dist/{Endpoint-BoUg8ocM.cjs → lazyAccessors-D04oftGw.cjs} +1127 -960
- package/dist/lazyAccessors-D04oftGw.cjs.map +1 -0
- package/dist/monitors/index.cjs +49 -0
- package/dist/monitors/index.cjs.map +1 -0
- package/dist/monitors/index.d.cts +45 -0
- package/dist/monitors/index.d.cts.map +1 -0
- package/dist/monitors/index.d.mts +45 -0
- package/dist/monitors/index.d.mts.map +1 -0
- package/dist/monitors/index.mjs +48 -0
- package/dist/monitors/index.mjs.map +1 -0
- package/dist/processAudits-BJZT5gmy.cjs +92 -0
- package/dist/processAudits-BJZT5gmy.cjs.map +1 -0
- package/dist/processAudits-CwyaaSQc.mjs +80 -0
- package/dist/processAudits-CwyaaSQc.mjs.map +1 -0
- package/dist/publisher-BZgcrVPy.cjs +53 -0
- package/dist/publisher-BZgcrVPy.cjs.map +1 -0
- package/dist/publisher-CnpeMv-r.mjs +41 -0
- package/dist/publisher-CnpeMv-r.mjs.map +1 -0
- package/dist/queue/index.cjs +114 -6
- package/dist/queue/index.cjs.map +1 -0
- package/dist/queue/index.d.cts +45 -3
- package/dist/queue/index.d.cts.map +1 -0
- package/dist/queue/index.d.mts +44 -3
- package/dist/queue/index.d.mts.map +1 -0
- package/dist/queue/index.mjs +112 -3
- package/dist/queue/index.mjs.map +1 -0
- package/dist/subscribers/index.cjs +80 -111
- package/dist/subscribers/index.cjs.map +1 -1
- package/dist/subscribers/index.d.cts +43 -46
- package/dist/subscribers/index.d.cts.map +1 -1
- package/dist/subscribers/index.d.mts +42 -46
- package/dist/subscribers/index.d.mts.map +1 -1
- package/dist/subscribers/index.mjs +78 -108
- package/dist/subscribers/index.mjs.map +1 -1
- package/dist/{lambdaTelemetry-8vnmVZQ5.d.cts → telemetry-C--EgYVr.d.mts} +7 -4
- package/dist/telemetry-C--EgYVr.d.mts.map +1 -0
- package/dist/{lambdaTelemetry-8vnmVZQ5.d.mts → telemetry-Dqx-D3F7.d.cts} +7 -4
- package/dist/telemetry-Dqx-D3F7.d.cts.map +1 -0
- package/dist/topic/index.cjs +91 -3
- package/dist/topic/index.cjs.map +1 -0
- package/dist/topic/index.d.cts +32 -2
- package/dist/topic/index.d.cts.map +1 -0
- package/dist/topic/index.d.mts +32 -2
- package/dist/topic/index.d.mts.map +1 -0
- package/dist/topic/index.mjs +89 -2
- package/dist/topic/index.mjs.map +1 -0
- package/dist/{types-DMuSQeLL.d.cts → types-BdAaYDvd.d.cts} +5 -3
- package/dist/types-BdAaYDvd.d.cts.map +1 -0
- package/dist/{types-DMuSQeLL.d.mts → types-DNngH0fX.d.mts} +5 -3
- package/dist/types-DNngH0fX.d.mts.map +1 -0
- package/dist/types.d.cts +1 -1
- package/dist/types.d.mts +1 -1
- package/dist/types.mjs +0 -1
- package/package.json +55 -223
- package/src/Construct.ts +209 -0
- package/src/__benchmarks__/build-time-optimization.bench.ts +274 -0
- package/src/__benchmarks__/endpoint.bench.ts +494 -0
- package/src/__benchmarks__/fixtures.ts +241 -0
- package/src/__benchmarks__/hono-adaptor.bench.ts +533 -0
- package/src/__benchmarks__/hono-server.bench.ts +249 -0
- package/src/__benchmarks__/response-builder.bench.ts +428 -0
- package/src/__benchmarks__/strategies/strategy-a-lazy-services.ts +319 -0
- package/src/__benchmarks__/strategies/strategy-c-middleware.ts +530 -0
- package/src/__benchmarks__/strategies/strategy-d-opt-in-events.ts +567 -0
- package/src/__tests__/Construct.environment.spec.ts +704 -0
- package/src/__tests__/builder-reuse.spec.ts +587 -0
- package/src/__tests__/monitor.spec.ts +636 -0
- package/src/__tests__/publisher.setting.spec.ts +508 -0
- package/src/__tests__/publisher.spec.ts +452 -0
- package/src/adaptors/aws.ts +6 -0
- package/src/adaptors/hono.ts +1 -0
- package/src/adaptors/testing.ts +11 -0
- package/src/clone.ts +38 -0
- package/src/crons/AWSScheduledFunction.ts +73 -0
- package/src/crons/Cron.ts +149 -0
- package/src/crons/CronBuilder.ts +261 -0
- package/src/crons/__tests__/AWSScheduledFunction.spec.ts +152 -0
- package/src/crons/__tests__/Cron.spec.ts +472 -0
- package/src/crons/__tests__/CronBuilder.state-isolation.spec.ts +273 -0
- package/src/crons/index.ts +12 -0
- package/src/endpoints/AmazonApiGatewayEndpointAdaptor.ts +698 -0
- package/src/endpoints/AmazonApiGatewayV1EndpointAdaptor.ts +105 -0
- package/src/endpoints/AmazonApiGatewayV2EndpointAdaptor.ts +97 -0
- package/src/endpoints/Authorizer.ts +152 -0
- package/src/endpoints/Endpoint.ts +1287 -0
- package/src/endpoints/EndpointBuilder.ts +749 -0
- package/src/endpoints/EndpointFactory.ts +1179 -0
- package/src/endpoints/HonoEndpointAdaptor.ts +692 -0
- package/src/endpoints/MswEndpointAdaptor.ts +226 -0
- package/src/endpoints/TestEndpointAdaptor.ts +466 -0
- package/src/endpoints/__tests__/AmazonApiGatewayV1EndpointAdaptor.audits.spec.ts +499 -0
- package/src/endpoints/__tests__/AmazonApiGatewayV1EndpointAdaptor.events.spec.ts +560 -0
- package/src/endpoints/__tests__/AmazonApiGatewayV1EndpointAdaptor.spec.ts +1304 -0
- package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.audits.spec.ts +626 -0
- package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.events.spec.ts +732 -0
- package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.factory-publisher.spec.ts +296 -0
- package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.kysely-audit.integration.spec.ts +951 -0
- package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.responseType.spec.ts +111 -0
- package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.rls.spec.ts +307 -0
- package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.spec.ts +629 -0
- package/src/endpoints/__tests__/Authorizer.spec.ts +286 -0
- package/src/endpoints/__tests__/Endpoint.cookies.spec.ts +207 -0
- package/src/endpoints/__tests__/Endpoint.headers.spec.ts +187 -0
- package/src/endpoints/__tests__/Endpoint.manifest.spec.ts +175 -0
- package/src/endpoints/__tests__/Endpoint.spec.ts +857 -0
- package/src/endpoints/__tests__/EndpointBuilder.audit.spec.ts +451 -0
- package/src/endpoints/__tests__/EndpointBuilder.responseType.spec.ts +50 -0
- package/src/endpoints/__tests__/EndpointBuilder.spec.ts +531 -0
- package/src/endpoints/__tests__/EndpointFactory.authorizers.spec.ts +492 -0
- package/src/endpoints/__tests__/EndpointFactory.database-auditor.spec.ts +509 -0
- package/src/endpoints/__tests__/EndpointFactory.reference-audit.spec.ts +190 -0
- package/src/endpoints/__tests__/EndpointFactory.spec.ts +479 -0
- package/src/endpoints/__tests__/EndpointFactory.state-isolation.spec.ts +155 -0
- package/src/endpoints/__tests__/HonoEndpointAdaptor.audit-transactions.spec.ts +703 -0
- package/src/endpoints/__tests__/HonoEndpointAdaptor.audits.spec.ts +632 -0
- package/src/endpoints/__tests__/HonoEndpointAdaptor.events.spec.ts +577 -0
- package/src/endpoints/__tests__/HonoEndpointAdaptor.kysely-audit.integration.spec.ts +1067 -0
- package/src/endpoints/__tests__/HonoEndpointAdaptor.openapi.spec.ts +317 -0
- package/src/endpoints/__tests__/HonoEndpointAdaptor.pgboss-publisher.spec.ts +289 -0
- package/src/endpoints/__tests__/HonoEndpointAdaptor.responseType.spec.ts +128 -0
- package/src/endpoints/__tests__/HonoEndpointAdaptor.spec.ts +1207 -0
- package/src/endpoints/__tests__/MswEndpointAdaptor.spec.ts +211 -0
- package/src/endpoints/__tests__/ResponseBuilder.spec.ts +235 -0
- package/src/endpoints/__tests__/TestEndpointAdaptor.audits.spec.ts +602 -0
- package/src/endpoints/__tests__/TestEndpointAdaptor.spec.ts +1044 -0
- package/src/endpoints/__tests__/__snapshots__/HonoEndpointAdaptor.spec.ts.snap +54 -0
- package/src/endpoints/__tests__/endpoint-types.test.ts +88 -0
- package/src/endpoints/__tests__/helpers.spec.ts +37 -0
- package/src/endpoints/__tests__/lazyAccessors.spec.ts +330 -0
- package/src/endpoints/__tests__/processAudits.spec.ts +631 -0
- package/src/endpoints/audit.ts +87 -0
- package/src/endpoints/helpers.ts +98 -0
- package/src/endpoints/index.ts +42 -0
- package/src/endpoints/lazyAccessors.ts +241 -0
- package/src/endpoints/parseHonoQuery.ts +16 -0
- package/src/endpoints/parseQueryParams.ts +32 -0
- package/src/endpoints/processAudits.ts +371 -0
- package/src/endpoints/rls.ts +67 -0
- package/src/functions/AWSLambdaFunction.ts +374 -0
- package/src/functions/BaseFunctionBuilder.ts +212 -0
- package/src/functions/Function.ts +238 -0
- package/src/functions/FunctionBuilder.ts +381 -0
- package/src/functions/FunctionExecutionWrapper.ts +216 -0
- package/src/functions/TestFunctionAdaptor.ts +252 -0
- package/src/functions/__tests__/AWSLambdaFunctionAdaptor.spec.ts +513 -0
- package/src/functions/__tests__/Function.audits.spec.ts +393 -0
- package/src/functions/__tests__/Function.spec.ts +477 -0
- package/src/functions/__tests__/FunctionBuilder.state-isolation.spec.ts +250 -0
- package/src/functions/__tests__/TestFunctionAdaptor.spec.ts +480 -0
- package/src/functions/index.ts +12 -0
- package/src/index.ts +29 -0
- package/src/monitor.ts +145 -0
- package/src/monitors/heartbeat.ts +86 -0
- package/src/monitors/index.ts +6 -0
- package/src/publisher.ts +93 -0
- package/src/queue/AWSLambdaQueueAdaptor.ts +162 -0
- package/src/queue/Queue.ts +128 -0
- package/src/queue/QueueBuilder.ts +115 -0
- package/src/queue/TestQueueAdaptor.ts +63 -0
- package/src/queue/__tests__/QueueBuilder.spec.ts +137 -0
- package/src/queue/index.ts +12 -0
- package/src/subscribers/AWSLambdaSubscriberAdaptor.ts +342 -0
- package/src/subscribers/Subscriber.ts +117 -0
- package/src/subscribers/SubscriberBuilder.ts +183 -0
- package/src/subscribers/TestSubscriberAdaptor.ts +133 -0
- package/src/subscribers/__tests__/AWSLambdaSubscriberAdaptor.spec.ts +1018 -0
- package/src/subscribers/__tests__/Subscriber.spec.ts +430 -0
- package/src/subscribers/__tests__/TestSubscriberAdaptor.spec.ts +652 -0
- package/src/subscribers/index.ts +6 -0
- package/src/telemetry.ts +103 -0
- package/src/topic/Topic.ts +103 -0
- package/src/topic/TopicBuilder.ts +53 -0
- package/src/topic/__tests__/TopicBuilder.spec.ts +82 -0
- package/src/topic/index.ts +11 -0
- package/src/types.ts +13 -0
- package/test.ts +91 -0
- package/tsconfig.json +9 -0
- package/tsdown.config.ts +35 -0
- package/dist/Construct-B1vGBPme.mjs.map +0 -1
- package/dist/Construct-BQALFCh2.d.cts +0 -230
- package/dist/Construct-BQALFCh2.d.cts.map +0 -1
- package/dist/Construct-DUSXuTHP.cjs.map +0 -1
- package/dist/Construct-QXnl3VqT.d.mts +0 -230
- package/dist/Construct-QXnl3VqT.d.mts.map +0 -1
- package/dist/Cron-DI3nKoic.d.cts +0 -45
- package/dist/Cron-DI3nKoic.d.cts.map +0 -1
- package/dist/Cron-uYAHPnp7.d.mts +0 -45
- package/dist/Cron-uYAHPnp7.d.mts.map +0 -1
- package/dist/CronBuilder-C0Ek1-RA.cjs +0 -121
- package/dist/CronBuilder-C0Ek1-RA.cjs.map +0 -1
- package/dist/CronBuilder-DaSUm2Na.d.mts +0 -47
- package/dist/CronBuilder-DaSUm2Na.d.mts.map +0 -1
- package/dist/CronBuilder-Dmix_Pen.mjs +0 -109
- package/dist/CronBuilder-Dmix_Pen.mjs.map +0 -1
- package/dist/CronBuilder-g1lZLWyG.d.cts +0 -47
- package/dist/CronBuilder-g1lZLWyG.d.cts.map +0 -1
- package/dist/Endpoint-BG4UJ9oA.mjs.map +0 -1
- package/dist/Endpoint-BoUg8ocM.cjs.map +0 -1
- package/dist/Endpoint-Du-NwPX2.d.mts.map +0 -1
- package/dist/Endpoint-aCvBMPoH.d.cts.map +0 -1
- package/dist/EndpointFactory-BDtsrEvJ.mjs +0 -791
- package/dist/EndpointFactory-BDtsrEvJ.mjs.map +0 -1
- package/dist/EndpointFactory-DJ7gXLpR.cjs +0 -833
- package/dist/EndpointFactory-DJ7gXLpR.cjs.map +0 -1
- package/dist/EndpointFactory-DMYdJCOj.d.mts +0 -363
- package/dist/EndpointFactory-DMYdJCOj.d.mts.map +0 -1
- package/dist/EndpointFactory-I7s1co3Y.d.cts +0 -363
- package/dist/EndpointFactory-I7s1co3Y.d.cts.map +0 -1
- package/dist/Function-DuqGcbOI.d.mts +0 -76
- package/dist/Function-DuqGcbOI.d.mts.map +0 -1
- package/dist/Function-Pu-1kKZz.d.cts +0 -76
- package/dist/Function-Pu-1kKZz.d.cts.map +0 -1
- package/dist/HonoEndpointAdaptor-PtPlbeKY.mjs.map +0 -1
- package/dist/HonoEndpointAdaptor-zVzVLJEO.cjs.map +0 -1
- package/dist/Queue-A3wfD0it.cjs +0 -109
- package/dist/Queue-A3wfD0it.cjs.map +0 -1
- package/dist/Queue-D6USGS4q.mjs +0 -104
- package/dist/Queue-D6USGS4q.mjs.map +0 -1
- package/dist/Queue-DlsHRzUp.d.mts +0 -105
- package/dist/Queue-DlsHRzUp.d.mts.map +0 -1
- package/dist/Queue-HPyi0e1i.d.cts +0 -105
- package/dist/Queue-HPyi0e1i.d.cts.map +0 -1
- package/dist/QueueBuilder-BjuF0UBl.cjs +0 -135
- package/dist/QueueBuilder-BjuF0UBl.cjs.map +0 -1
- package/dist/QueueBuilder-Cue73M4t.mjs +0 -118
- package/dist/QueueBuilder-Cue73M4t.mjs.map +0 -1
- package/dist/QueueBuilder-OSi6LkV9.d.cts +0 -75
- package/dist/QueueBuilder-OSi6LkV9.d.cts.map +0 -1
- package/dist/QueueBuilder-QHsnVt1P.d.mts +0 -75
- package/dist/QueueBuilder-QHsnVt1P.d.mts.map +0 -1
- package/dist/Subscriber-Bpp02cGr.d.cts +0 -61
- package/dist/Subscriber-Bpp02cGr.d.cts.map +0 -1
- package/dist/Subscriber-CtN9R48-.d.mts +0 -61
- package/dist/Subscriber-CtN9R48-.d.mts.map +0 -1
- package/dist/SubscriberBuilder-CDy4nHCz.mjs +0 -134
- package/dist/SubscriberBuilder-CDy4nHCz.mjs.map +0 -1
- package/dist/SubscriberBuilder-CuCMFpYW.d.mts +0 -67
- package/dist/SubscriberBuilder-CuCMFpYW.d.mts.map +0 -1
- package/dist/SubscriberBuilder-D_owVoHo.cjs +0 -145
- package/dist/SubscriberBuilder-D_owVoHo.cjs.map +0 -1
- package/dist/SubscriberBuilder-g3fAVWgs.d.cts +0 -67
- package/dist/SubscriberBuilder-g3fAVWgs.d.cts.map +0 -1
- package/dist/Topic-D74b5cgs.mjs +0 -99
- package/dist/Topic-D74b5cgs.mjs.map +0 -1
- package/dist/Topic-GHxcU8AG.cjs +0 -104
- package/dist/Topic-GHxcU8AG.cjs.map +0 -1
- package/dist/auth-BMCJN30Y.d.cts +0 -268
- package/dist/auth-BMCJN30Y.d.cts.map +0 -1
- package/dist/auth-CcuceLYo.d.mts +0 -268
- package/dist/auth-CcuceLYo.d.mts.map +0 -1
- package/dist/auth.cjs +0 -433
- package/dist/auth.cjs.map +0 -1
- package/dist/auth.d.cts +0 -2
- package/dist/auth.d.mts +0 -2
- package/dist/auth.mjs +0 -426
- package/dist/auth.mjs.map +0 -1
- package/dist/cache-CXh6GIgb.d.mts +0 -44
- package/dist/cache-CXh6GIgb.d.mts.map +0 -1
- package/dist/cache-DnGDGly3.d.cts +0 -44
- package/dist/cache-DnGDGly3.d.cts.map +0 -1
- package/dist/cache.cjs +0 -69
- package/dist/cache.cjs.map +0 -1
- package/dist/cache.d.cts +0 -2
- package/dist/cache.d.mts +0 -2
- package/dist/cache.mjs +0 -68
- package/dist/cache.mjs.map +0 -1
- package/dist/cipher-C1lEFX63.mjs +0 -225
- package/dist/cipher-C1lEFX63.mjs.map +0 -1
- package/dist/cipher-CVxfwLjk.cjs +0 -332
- package/dist/cipher-CVxfwLjk.cjs.map +0 -1
- package/dist/clone-EKNovYHu.mjs.map +0 -1
- package/dist/clone-UGJpvQnL.cjs.map +0 -1
- package/dist/construct-interface-B1AfqRl4.d.cts +0 -162
- package/dist/construct-interface-B1AfqRl4.d.cts.map +0 -1
- package/dist/construct-interface-DluK3_da.d.mts +0 -162
- package/dist/construct-interface-DluK3_da.d.mts.map +0 -1
- package/dist/construct-interface.cjs +0 -114
- package/dist/construct-interface.cjs.map +0 -1
- package/dist/construct-interface.d.cts +0 -2
- package/dist/construct-interface.d.mts +0 -2
- package/dist/construct-interface.mjs +0 -107
- package/dist/construct-interface.mjs.map +0 -1
- package/dist/credential.cjs +0 -156
- package/dist/credential.cjs.map +0 -1
- package/dist/credential.d.cts +0 -86
- package/dist/credential.d.cts.map +0 -1
- package/dist/credential.d.mts +0 -86
- package/dist/credential.d.mts.map +0 -1
- package/dist/credential.mjs +0 -152
- package/dist/credential.mjs.map +0 -1
- package/dist/database/kysely.cjs +0 -4
- package/dist/database/kysely.d.cts +0 -2
- package/dist/database/kysely.d.mts +0 -2
- package/dist/database/kysely.mjs +0 -2
- package/dist/email.cjs +0 -72
- package/dist/email.cjs.map +0 -1
- package/dist/email.d.cts +0 -46
- package/dist/email.d.cts.map +0 -1
- package/dist/email.d.mts +0 -46
- package/dist/email.d.mts.map +0 -1
- package/dist/email.mjs +0 -71
- package/dist/email.mjs.map +0 -1
- package/dist/encryption.cjs +0 -96
- package/dist/encryption.cjs.map +0 -1
- package/dist/encryption.d.cts +0 -117
- package/dist/encryption.d.cts.map +0 -1
- package/dist/encryption.d.mts +0 -117
- package/dist/encryption.d.mts.map +0 -1
- package/dist/encryption.mjs +0 -83
- package/dist/encryption.mjs.map +0 -1
- package/dist/external-api-MJ8id87V.d.mts +0 -105
- package/dist/external-api-MJ8id87V.d.mts.map +0 -1
- package/dist/external-api-O107yzZJ.d.cts +0 -105
- package/dist/external-api-O107yzZJ.d.cts.map +0 -1
- package/dist/external-api.cjs +0 -142
- package/dist/external-api.cjs.map +0 -1
- package/dist/external-api.d.cts +0 -2
- package/dist/external-api.d.mts +0 -2
- package/dist/external-api.mjs +0 -139
- package/dist/external-api.mjs.map +0 -1
- package/dist/file-server.cjs +0 -186
- package/dist/file-server.cjs.map +0 -1
- package/dist/file-server.d.cts +0 -152
- package/dist/file-server.d.cts.map +0 -1
- package/dist/file-server.d.mts +0 -152
- package/dist/file-server.d.mts.map +0 -1
- package/dist/file-server.mjs +0 -184
- package/dist/file-server.mjs.map +0 -1
- package/dist/functions-BFizikJU.mjs.map +0 -1
- package/dist/functions-CfzJG9hK.cjs.map +0 -1
- package/dist/index-BuzRvKOQ.d.cts +0 -115
- package/dist/index-BuzRvKOQ.d.cts.map +0 -1
- package/dist/index-CTkKOer4.d.mts +0 -115
- package/dist/index-CTkKOer4.d.mts.map +0 -1
- package/dist/index-CeEtxDmK.d.cts +0 -79
- package/dist/index-CeEtxDmK.d.cts.map +0 -1
- package/dist/index-CeEtxDmK.d.mts +0 -79
- package/dist/index-CeEtxDmK.d.mts.map +0 -1
- package/dist/index.d.cts.map +0 -1
- package/dist/index.d.mts.map +0 -1
- package/dist/kms-B-Hm3d5r.cjs +0 -85
- package/dist/kms-B-Hm3d5r.cjs.map +0 -1
- package/dist/kms-BdUlMJEZ.mjs +0 -85
- package/dist/kms-BdUlMJEZ.mjs.map +0 -1
- package/dist/kysely-Bii4l6eP.mjs +0 -370
- package/dist/kysely-Bii4l6eP.mjs.map +0 -1
- package/dist/kysely-CO_Dk43W.cjs +0 -383
- package/dist/kysely-CO_Dk43W.cjs.map +0 -1
- package/dist/kysely-D0bpzgPs.d.cts +0 -175
- package/dist/kysely-D0bpzgPs.d.cts.map +0 -1
- package/dist/kysely-DUqC3Ie0.d.mts +0 -175
- package/dist/kysely-DUqC3Ie0.d.mts.map +0 -1
- package/dist/lambdaTelemetry-8vnmVZQ5.d.cts.map +0 -1
- package/dist/lambdaTelemetry-8vnmVZQ5.d.mts.map +0 -1
- package/dist/lazyAccessors-CFanua0O.mjs +0 -174
- package/dist/lazyAccessors-CFanua0O.mjs.map +0 -1
- package/dist/lazyAccessors-hJKGv8Ay.cjs +0 -221
- package/dist/lazyAccessors-hJKGv8Ay.cjs.map +0 -1
- package/dist/mobile-app.cjs +0 -73
- package/dist/mobile-app.cjs.map +0 -1
- package/dist/mobile-app.d.cts +0 -61
- package/dist/mobile-app.d.cts.map +0 -1
- package/dist/mobile-app.d.mts +0 -61
- package/dist/mobile-app.d.mts.map +0 -1
- package/dist/mobile-app.mjs +0 -72
- package/dist/mobile-app.mjs.map +0 -1
- package/dist/object-storage.cjs +0 -56
- package/dist/object-storage.cjs.map +0 -1
- package/dist/object-storage.d.cts +0 -32
- package/dist/object-storage.d.cts.map +0 -1
- package/dist/object-storage.d.mts +0 -32
- package/dist/object-storage.d.mts.map +0 -1
- package/dist/object-storage.mjs +0 -55
- package/dist/object-storage.mjs.map +0 -1
- package/dist/processAudits-BRRVVHUB.mjs +0 -131
- package/dist/processAudits-BRRVVHUB.mjs.map +0 -1
- package/dist/processAudits-DasOZjPl.cjs +0 -154
- package/dist/processAudits-DasOZjPl.cjs.map +0 -1
- package/dist/rest-api.cjs +0 -216
- package/dist/rest-api.cjs.map +0 -1
- package/dist/rest-api.d.cts +0 -241
- package/dist/rest-api.d.cts.map +0 -1
- package/dist/rest-api.d.mts +0 -241
- package/dist/rest-api.d.mts.map +0 -1
- package/dist/rest-api.mjs +0 -215
- package/dist/rest-api.mjs.map +0 -1
- package/dist/rolldown-runtime-y5ARvAq5.cjs +0 -35
- package/dist/runSubscriber-BHvJ8POr.mjs +0 -109
- package/dist/runSubscriber-BHvJ8POr.mjs.map +0 -1
- package/dist/runSubscriber-D8nLXIv1.cjs +0 -126
- package/dist/runSubscriber-D8nLXIv1.cjs.map +0 -1
- package/dist/shutdown-BMJmAhSt.cjs +0 -38
- package/dist/shutdown-BMJmAhSt.cjs.map +0 -1
- package/dist/shutdown-C7xa8x9S.mjs +0 -27
- package/dist/shutdown-C7xa8x9S.mjs.map +0 -1
- package/dist/site.cjs +0 -74
- package/dist/site.cjs.map +0 -1
- package/dist/site.d.cts +0 -104
- package/dist/site.d.cts.map +0 -1
- package/dist/site.d.mts +0 -104
- package/dist/site.d.mts.map +0 -1
- package/dist/site.mjs +0 -73
- package/dist/site.mjs.map +0 -1
- package/dist/stages-BSCF19o2.d.cts +0 -56
- package/dist/stages-BSCF19o2.d.cts.map +0 -1
- package/dist/stages-BSCF19o2.d.mts +0 -56
- package/dist/stages-BSCF19o2.d.mts.map +0 -1
- package/dist/surfaceEnv-CNimK76p.cjs +0 -56
- package/dist/surfaceEnv-CNimK76p.cjs.map +0 -1
- package/dist/surfaceEnv-wMT5QzgZ.mjs +0 -45
- package/dist/surfaceEnv-wMT5QzgZ.mjs.map +0 -1
- package/dist/telemetry-B48RLjyk.d.cts +0 -40
- package/dist/telemetry-B48RLjyk.d.cts.map +0 -1
- package/dist/telemetry-DRtT1_0A.d.mts +0 -40
- package/dist/telemetry-DRtT1_0A.d.mts.map +0 -1
- package/dist/telemetry.cjs +0 -56
- package/dist/telemetry.cjs.map +0 -1
- package/dist/telemetry.d.cts +0 -2
- package/dist/telemetry.d.mts +0 -2
- package/dist/telemetry.mjs +0 -55
- package/dist/telemetry.mjs.map +0 -1
- package/dist/tracing-CxaZ98IB.mjs +0 -110
- package/dist/tracing-CxaZ98IB.mjs.map +0 -1
- package/dist/tracing-DPMidF_r.cjs +0 -127
- package/dist/tracing-DPMidF_r.cjs.map +0 -1
- package/dist/types-DMuSQeLL.d.cts.map +0 -1
- package/dist/types-DMuSQeLL.d.mts.map +0 -1
- package/dist/worker.cjs +0 -191
- package/dist/worker.cjs.map +0 -1
- package/dist/worker.d.cts +0 -171
- package/dist/worker.d.cts.map +0 -1
- package/dist/worker.d.mts +0 -171
- package/dist/worker.d.mts.map +0 -1
- package/dist/worker.mjs +0 -190
- package/dist/worker.mjs.map +0 -1
package/dist/adaptors/aws.mjs
CHANGED
|
@@ -1,266 +1,30 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { n as executeWithAuditTransaction, t as createAuditContext } from "../processAudits-BRRVVHUB.mjs";
|
|
9
|
-
import { consumeBatchTraced } from "@geekmidas/events";
|
|
1
|
+
import { __toESM } from "../Construct-BWF5HxaM.mjs";
|
|
2
|
+
import { startMonitors } from "../functions-EqTloHjo.mjs";
|
|
3
|
+
import "../clone-pdXxc0t3.mjs";
|
|
4
|
+
import { publishConstructEvents } from "../publisher-CnpeMv-r.mjs";
|
|
5
|
+
import { AWSLambdaFunction, AWSScheduledFunction } from "../AWSScheduledFunction-KP6lqbsW.mjs";
|
|
6
|
+
import { Endpoint, ResponseBuilder, createApiGatewayCookies, require_lodash } from "../lazyAccessors-CCTK19xj.mjs";
|
|
7
|
+
import { createAuditContext, executeWithAuditTransaction } from "../processAudits-CwyaaSQc.mjs";
|
|
10
8
|
import { ForbiddenError, UnprocessableEntityError, wrapError } from "@geekmidas/errors";
|
|
11
9
|
import { ServiceDiscovery, runWithRequestContext } from "@geekmidas/services";
|
|
12
|
-
import qs from "qs";
|
|
13
10
|
import middy from "@middy/core";
|
|
14
|
-
import { DefaultAuditor } from "@geekmidas/audit";
|
|
15
|
-
import { withAuditableTransaction } from "@geekmidas/audit/kysely";
|
|
16
11
|
import { withRlsContext } from "@geekmidas/db/rls";
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
envParser;
|
|
20
|
-
fn;
|
|
21
|
-
constructor(envParser, fn) {
|
|
22
|
-
this.envParser = envParser;
|
|
23
|
-
this.fn = fn;
|
|
24
|
-
}
|
|
25
|
-
_logger;
|
|
26
|
-
get logger() {
|
|
27
|
-
return this._logger || this.fn.logger;
|
|
28
|
-
}
|
|
29
|
-
get serviceDiscovery() {
|
|
30
|
-
return ServiceDiscovery.getInstance(this.envParser);
|
|
31
|
-
}
|
|
32
|
-
getServices() {
|
|
33
|
-
return this.serviceDiscovery.register(this.fn.services);
|
|
34
|
-
}
|
|
35
|
-
async getDatabase() {
|
|
36
|
-
if (!this.fn.databaseService) return;
|
|
37
|
-
return (await this.serviceDiscovery.register([this.fn.databaseService]))[this.fn.databaseService.serviceName];
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Get the audit storage service if configured.
|
|
41
|
-
* Returns undefined if no auditor storage is configured.
|
|
42
|
-
*/
|
|
43
|
-
async getAuditStorage() {
|
|
44
|
-
if (!this.fn.auditorStorageService) return;
|
|
45
|
-
return (await this.serviceDiscovery.register([this.fn.auditorStorageService]))[this.fn.auditorStorageService.serviceName];
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Create an auditor instance for the function.
|
|
49
|
-
* Returns undefined if no auditor storage is configured.
|
|
50
|
-
*/
|
|
51
|
-
async createAuditor() {
|
|
52
|
-
const storage = await this.getAuditStorage();
|
|
53
|
-
if (!storage) return;
|
|
54
|
-
return new DefaultAuditor({
|
|
55
|
-
actor: {
|
|
56
|
-
id: "system",
|
|
57
|
-
type: "system"
|
|
58
|
-
},
|
|
59
|
-
storage,
|
|
60
|
-
metadata: { function: this.fn.type }
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Execute handler with audit transaction support.
|
|
65
|
-
* If the audit storage has a database (via getDatabase()), wraps execution
|
|
66
|
-
* in a transaction so audits are atomic with handler's database operations.
|
|
67
|
-
*
|
|
68
|
-
* @param handler - The handler function to execute (receives auditor and db)
|
|
69
|
-
* @returns The handler result
|
|
70
|
-
*/
|
|
71
|
-
async executeWithAudit(handler) {
|
|
72
|
-
const auditor = await this.createAuditor();
|
|
73
|
-
const storage = await this.getAuditStorage();
|
|
74
|
-
if (!auditor || !storage) return handler({ db: await this.getDatabase() });
|
|
75
|
-
const storageDb = storage.getDatabase?.();
|
|
76
|
-
const databaseServiceName = this.fn.databaseService?.serviceName;
|
|
77
|
-
const auditDbServiceName = this.fn.auditorStorageService?.serviceName;
|
|
78
|
-
if (storageDb && databaseServiceName && auditDbServiceName) return withAuditableTransaction(storageDb, auditor, async (trx) => {
|
|
79
|
-
return await handler({
|
|
80
|
-
auditor,
|
|
81
|
-
db: trx
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
const response = await handler({
|
|
85
|
-
auditor,
|
|
86
|
-
db: await this.getDatabase()
|
|
87
|
-
});
|
|
88
|
-
await auditor.flush();
|
|
89
|
-
return response;
|
|
90
|
-
}
|
|
91
|
-
async getFunctionInput(event) {
|
|
92
|
-
return await FunctionBuilder.parseComposableStandardSchema(event, this.fn.input);
|
|
93
|
-
}
|
|
94
|
-
async publishEvents(response) {
|
|
95
|
-
await publishEvents(this.logger, this.serviceDiscovery, this.fn.events, response);
|
|
96
|
-
}
|
|
97
|
-
async parseComposableStandardSchema(data, schema) {
|
|
98
|
-
return FunctionBuilder.parseComposableStandardSchema(data, schema);
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
//#endregion
|
|
102
|
-
//#region src/functions/AWSLambdaFunction.ts
|
|
103
|
-
var AWSLambdaFunction = class extends FunctionExecutionWrapper {
|
|
104
|
-
fn;
|
|
105
|
-
constructor(envParser, fn) {
|
|
106
|
-
super(envParser, fn);
|
|
107
|
-
this.fn = fn;
|
|
108
|
-
}
|
|
109
|
-
error() {
|
|
110
|
-
return { onError: (req) => {
|
|
111
|
-
(req.event?.logger || this.fn.logger).error(req.error || {}, "Error processing function");
|
|
112
|
-
throw wrapError(req.error);
|
|
113
|
-
} };
|
|
114
|
-
}
|
|
115
|
-
baseInput() {
|
|
116
|
-
return { before: (_req) => {} };
|
|
117
|
-
}
|
|
118
|
-
input() {
|
|
119
|
-
return { before: async (req) => {
|
|
120
|
-
try {
|
|
121
|
-
if (this.fn.input) {
|
|
122
|
-
const parsedInput = await FunctionBuilder.parseComposableStandardSchema(req.event, this.fn.input);
|
|
123
|
-
req.event.parsedInput = parsedInput;
|
|
124
|
-
} else req.event.parsedInput = req.event;
|
|
125
|
-
} catch (error) {
|
|
126
|
-
this.logger.error({
|
|
127
|
-
err: error,
|
|
128
|
-
event: req.event
|
|
129
|
-
}, "Failed to parse input");
|
|
130
|
-
throw error;
|
|
131
|
-
}
|
|
132
|
-
} };
|
|
133
|
-
}
|
|
134
|
-
loggerMiddleware() {
|
|
135
|
-
return { before: (req) => {
|
|
136
|
-
this._logger = this.fn.logger.child({
|
|
137
|
-
fn: {
|
|
138
|
-
name: req.context.functionName,
|
|
139
|
-
version: req.context.functionVersion,
|
|
140
|
-
memory: req.context.memoryLimitInMB
|
|
141
|
-
},
|
|
142
|
-
req: { id: req.context.awsRequestId }
|
|
143
|
-
});
|
|
144
|
-
req.event.logger = this._logger;
|
|
145
|
-
} };
|
|
146
|
-
}
|
|
147
|
-
services() {
|
|
148
|
-
return { before: async (req) => {
|
|
149
|
-
req.event.services = await this.getServices();
|
|
150
|
-
} };
|
|
151
|
-
}
|
|
152
|
-
database() {
|
|
153
|
-
return { before: async (req) => {
|
|
154
|
-
req.event.db = await this.getDatabase();
|
|
155
|
-
} };
|
|
156
|
-
}
|
|
157
|
-
auditor() {
|
|
158
|
-
return {
|
|
159
|
-
before: async (req) => {
|
|
160
|
-
req.event.auditor = await this.createAuditor();
|
|
161
|
-
},
|
|
162
|
-
after: async (req) => {
|
|
163
|
-
if (req.event.auditor) {
|
|
164
|
-
const records = req.event.auditor.getRecords();
|
|
165
|
-
if (records.length > 0) {
|
|
166
|
-
this.logger.debug({ auditCount: records.length }, "Flushing function audits");
|
|
167
|
-
await req.event.auditor.flush();
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
};
|
|
172
|
-
}
|
|
173
|
-
events() {
|
|
174
|
-
return { after: async (req) => {
|
|
175
|
-
const response = req.response || void 0;
|
|
176
|
-
await this.publishEvents(response);
|
|
177
|
-
} };
|
|
178
|
-
}
|
|
179
|
-
async _handler(event) {
|
|
180
|
-
const result = await this.fn.fn({
|
|
181
|
-
input: event.parsedInput,
|
|
182
|
-
services: event.services,
|
|
183
|
-
logger: event.logger,
|
|
184
|
-
db: event.db,
|
|
185
|
-
auditor: event.auditor
|
|
186
|
-
});
|
|
187
|
-
return await this.fn.parseOutput(result);
|
|
188
|
-
}
|
|
189
|
-
get handler() {
|
|
190
|
-
const handler = this._handler.bind(this);
|
|
191
|
-
const chain = middy(handler).use(this.loggerMiddleware()).use(this.baseInput()).use(this.error()).use(this.services()).use(this.database()).use(this.auditor()).use(this.input()).use(this.events());
|
|
192
|
-
const wrappedHandler = async (event, context) => {
|
|
193
|
-
const startTime = Date.now();
|
|
194
|
-
const requestId = context.awsRequestId;
|
|
195
|
-
const logger = this.fn.logger.child({ requestId });
|
|
196
|
-
return runWithRequestContext({
|
|
197
|
-
logger,
|
|
198
|
-
requestId,
|
|
199
|
-
startTime,
|
|
200
|
-
operation: context.functionName
|
|
201
|
-
}, () => chain(event, context));
|
|
202
|
-
};
|
|
203
|
-
return wrappedHandler;
|
|
204
|
-
}
|
|
205
|
-
};
|
|
206
|
-
//#endregion
|
|
207
|
-
//#region src/crons/AWSScheduledFunction.ts
|
|
208
|
-
/**
|
|
209
|
-
* AWS Lambda adaptor for {@link Cron} constructs.
|
|
210
|
-
*
|
|
211
|
-
* A `Cron` is a {@link import('../functions').Function} that is invoked on a
|
|
212
|
-
* schedule (an EventBridge rule) rather than by an API request. Because of
|
|
213
|
-
* that, the runtime execution pipeline is identical to a regular Lambda
|
|
214
|
-
* function: input parsing, service/database/auditor wiring, event publishing,
|
|
215
|
-
* error handling, and the `runWithRequestContext` wrapper that powers
|
|
216
|
-
* request-scoped logging via `serviceContext.getLogger()`.
|
|
217
|
-
*
|
|
218
|
-
* This adaptor therefore reuses {@link AWSLambdaFunction} wholesale and only
|
|
219
|
-
* narrows the constructor to accept a `Cron`. The schedule expression itself
|
|
220
|
-
* (`cron.schedule`) is **deploy-time** infrastructure consumed by the CLI to
|
|
221
|
-
* provision the EventBridge rule — it is not needed at runtime.
|
|
222
|
-
*
|
|
223
|
-
* @example
|
|
224
|
-
* ```typescript
|
|
225
|
-
* import { AWSScheduledFunction } from '@geekmidas/constructs/crons';
|
|
226
|
-
* import { cancelPastBookings } from '../../../src/crons/cancelPastBookings.js';
|
|
227
|
-
* import { envParser } from '../../../src/env';
|
|
228
|
-
*
|
|
229
|
-
* const adapter = new AWSScheduledFunction(envParser, cancelPastBookings);
|
|
230
|
-
*
|
|
231
|
-
* export const handler = adapter.handler;
|
|
232
|
-
* ```
|
|
233
|
-
*/
|
|
234
|
-
var AWSScheduledFunction = class extends AWSLambdaFunction {
|
|
235
|
-
constructor(envParser, cron) {
|
|
236
|
-
super(envParser, cron);
|
|
237
|
-
}
|
|
238
|
-
};
|
|
239
|
-
//#endregion
|
|
12
|
+
import qs from "qs";
|
|
13
|
+
|
|
240
14
|
//#region src/endpoints/AmazonApiGatewayEndpointAdaptor.ts
|
|
241
|
-
var
|
|
15
|
+
var import_lodash = __toESM(require_lodash(), 1);
|
|
242
16
|
var AmazonApiGatewayEndpoint = class {
|
|
243
|
-
endpoint;
|
|
244
17
|
options;
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
*
|
|
248
|
-
* Taken from the endpoint's surface rather than handed in. An endpoint built
|
|
249
|
-
* with `api.get()` carries its API, and the API carries the parser — so a
|
|
250
|
-
* generated handler is `new AmazonApiGatewayV2Endpoint(endpoint)` with no
|
|
251
|
-
* import written for it, which is the whole reason the surface is the
|
|
252
|
-
* factory.
|
|
253
|
-
*/
|
|
254
|
-
envParser;
|
|
255
|
-
constructor(endpoint, options = {}) {
|
|
18
|
+
constructor(envParser, endpoint, options = {}) {
|
|
19
|
+
this.envParser = envParser;
|
|
256
20
|
this.endpoint = endpoint;
|
|
257
21
|
this.options = options;
|
|
258
|
-
this.envParser = envParserFor(endpoint.surface);
|
|
259
22
|
}
|
|
260
23
|
error() {
|
|
261
24
|
return { onError: (req) => {
|
|
262
25
|
(req.event.logger || this.endpoint.logger).error(req.error || {}, "Error processing request");
|
|
263
26
|
const wrappedError = wrapError(req.error);
|
|
27
|
+
req.event.__error = req.error;
|
|
264
28
|
req.response = {
|
|
265
29
|
statusCode: wrappedError.statusCode,
|
|
266
30
|
body: wrappedError.body
|
|
@@ -278,7 +42,8 @@ var AmazonApiGatewayEndpoint = class {
|
|
|
278
42
|
static decodeBody(body, isBase64Encoded, contentType) {
|
|
279
43
|
if (!body) return void 0;
|
|
280
44
|
const raw = isBase64Encoded ? Buffer.from(body, "base64").toString("utf-8") : body;
|
|
281
|
-
|
|
45
|
+
const isJson = !contentType || contentType.toLowerCase().includes("application/json");
|
|
46
|
+
if (isJson) return JSON.parse(raw);
|
|
282
47
|
return raw;
|
|
283
48
|
}
|
|
284
49
|
getCookies(e) {
|
|
@@ -292,11 +57,11 @@ var AmazonApiGatewayEndpoint = class {
|
|
|
292
57
|
const headers = req.event.headers;
|
|
293
58
|
const header = Endpoint.createHeaders(headers);
|
|
294
59
|
const cookie = this.getCookies(req.event);
|
|
295
|
-
(0,
|
|
296
|
-
(0,
|
|
297
|
-
(0,
|
|
298
|
-
(0,
|
|
299
|
-
(0,
|
|
60
|
+
(0, import_lodash.default)(req.event, "body", await this.endpoint.parseInput(body, "body"));
|
|
61
|
+
(0, import_lodash.default)(req.event, "query", await this.endpoint.parseInput(query, "query"));
|
|
62
|
+
(0, import_lodash.default)(req.event, "params", await this.endpoint.parseInput(params, "params"));
|
|
63
|
+
(0, import_lodash.default)(req.event, "header", header);
|
|
64
|
+
(0, import_lodash.default)(req.event, "cookie", cookie);
|
|
300
65
|
} catch (error) {
|
|
301
66
|
if (error && typeof error === "object" && Array.isArray(error)) throw new UnprocessableEntityError("Validation failed", error);
|
|
302
67
|
throw error;
|
|
@@ -315,8 +80,9 @@ var AmazonApiGatewayEndpoint = class {
|
|
|
315
80
|
}
|
|
316
81
|
services() {
|
|
317
82
|
return { before: async (req) => {
|
|
318
|
-
req.event.logger;
|
|
319
|
-
const
|
|
83
|
+
const _logger = req.event.logger;
|
|
84
|
+
const serviceDiscovery = ServiceDiscovery.getInstance(this.envParser);
|
|
85
|
+
const services = await serviceDiscovery.register(this.endpoint.services);
|
|
320
86
|
req.event.services = services;
|
|
321
87
|
} };
|
|
322
88
|
}
|
|
@@ -327,7 +93,7 @@ var AmazonApiGatewayEndpoint = class {
|
|
|
327
93
|
const header = req.event.header;
|
|
328
94
|
const cookie = req.event.cookie;
|
|
329
95
|
const session = req.event.session;
|
|
330
|
-
|
|
96
|
+
const isAuthorized = await this.endpoint.authorize({
|
|
331
97
|
header,
|
|
332
98
|
cookie,
|
|
333
99
|
services,
|
|
@@ -337,7 +103,8 @@ var AmazonApiGatewayEndpoint = class {
|
|
|
337
103
|
body: req.event.body,
|
|
338
104
|
query: req.event.query,
|
|
339
105
|
params: req.event.params
|
|
340
|
-
})
|
|
106
|
+
});
|
|
107
|
+
if (!isAuthorized) {
|
|
341
108
|
logger.warn("Forbidden access attempt");
|
|
342
109
|
throw new ForbiddenError("Forbidden access to the endpoint", "You do not have permission to access this resource.");
|
|
343
110
|
}
|
|
@@ -346,8 +113,9 @@ var AmazonApiGatewayEndpoint = class {
|
|
|
346
113
|
database() {
|
|
347
114
|
return { before: async (req) => {
|
|
348
115
|
if (!this.endpoint.databaseService) return;
|
|
349
|
-
req.event.logger;
|
|
350
|
-
const
|
|
116
|
+
const _logger = req.event.logger;
|
|
117
|
+
const serviceDiscovery = ServiceDiscovery.getInstance(this.envParser);
|
|
118
|
+
const db = await serviceDiscovery.register([this.endpoint.databaseService]).then((s) => s[this.endpoint.databaseService?.serviceName]);
|
|
351
119
|
req.event.db = db;
|
|
352
120
|
} };
|
|
353
121
|
}
|
|
@@ -398,8 +166,9 @@ var AmazonApiGatewayEndpoint = class {
|
|
|
398
166
|
cookie: event.cookie,
|
|
399
167
|
logger
|
|
400
168
|
}) : void 0;
|
|
401
|
-
const
|
|
402
|
-
const
|
|
169
|
+
const result = await executeWithAuditTransaction(auditContext, async (auditor) => {
|
|
170
|
+
const sameDatabase = auditContext?.storage?.databaseServiceName && auditContext.storage.databaseServiceName === this.endpoint.databaseService?.serviceName;
|
|
171
|
+
const baseDb = sameDatabase ? auditor?.getTransaction?.() ?? rawDb : rawDb;
|
|
403
172
|
const executeHandler = async (db) => {
|
|
404
173
|
const responseBuilder = new ResponseBuilder();
|
|
405
174
|
const response = await this.endpoint.handler({
|
|
@@ -413,31 +182,33 @@ var AmazonApiGatewayEndpoint = class {
|
|
|
413
182
|
...input
|
|
414
183
|
}, responseBuilder);
|
|
415
184
|
let data = response;
|
|
416
|
-
let metadata = responseBuilder.getMetadata();
|
|
185
|
+
let metadata$1 = responseBuilder.getMetadata();
|
|
417
186
|
if (Endpoint.hasMetadata(response)) {
|
|
418
187
|
data = response.data;
|
|
419
|
-
metadata = response.metadata;
|
|
188
|
+
metadata$1 = response.metadata;
|
|
420
189
|
}
|
|
190
|
+
const output$1 = this.endpoint.outputSchema ? await this.endpoint.parseOutput(data) : void 0;
|
|
421
191
|
return {
|
|
422
|
-
output:
|
|
423
|
-
metadata,
|
|
192
|
+
output: output$1,
|
|
193
|
+
metadata: metadata$1,
|
|
424
194
|
responseBuilder
|
|
425
195
|
};
|
|
426
196
|
};
|
|
427
197
|
if (rlsActive && rlsContext && baseDb) return withRlsContext(baseDb, rlsContext, async (trx) => executeHandler(trx), { prefix: this.endpoint.rlsConfig?.prefix });
|
|
428
198
|
return executeHandler(baseDb);
|
|
429
|
-
}, async (result, auditor) => {
|
|
199
|
+
}, async (result$1, auditor) => {
|
|
430
200
|
if (!audits?.length) return;
|
|
431
201
|
for (const audit of audits) {
|
|
432
|
-
if (audit.when && !audit.when(result.output)) continue;
|
|
433
|
-
const payload = audit.payload(result.output);
|
|
434
|
-
const entityId = audit.entityId?.(result.output);
|
|
202
|
+
if (audit.when && !audit.when(result$1.output)) continue;
|
|
203
|
+
const payload = audit.payload(result$1.output);
|
|
204
|
+
const entityId = audit.entityId?.(result$1.output);
|
|
435
205
|
auditor.audit(audit.type, payload, {
|
|
436
206
|
table: audit.table,
|
|
437
207
|
entityId
|
|
438
208
|
});
|
|
439
209
|
}
|
|
440
210
|
}, { db: rawDb });
|
|
211
|
+
const { output, metadata } = result;
|
|
441
212
|
const isJsonResponse = this.endpoint.responseType === "application/json";
|
|
442
213
|
const body = output === void 0 ? void 0 : isJsonResponse ? JSON.stringify(output) : typeof output === "string" ? output : String(output);
|
|
443
214
|
event.__response = output;
|
|
@@ -496,17 +267,21 @@ var AmazonApiGatewayEndpoint = class {
|
|
|
496
267
|
const startTime = Date.now();
|
|
497
268
|
const requestId = context.awsRequestId;
|
|
498
269
|
const logger = this.endpoint.logger.child({ requestId });
|
|
499
|
-
const operation = `${this.endpoint.method} ${this.endpoint.route}`;
|
|
500
270
|
return runWithRequestContext({
|
|
501
271
|
logger,
|
|
502
272
|
requestId,
|
|
503
|
-
startTime
|
|
504
|
-
|
|
505
|
-
|
|
273
|
+
startTime
|
|
274
|
+
}, async () => {
|
|
275
|
+
const monitor = await startMonitors(this.endpoint, ServiceDiscovery.getInstance(this.envParser), logger);
|
|
276
|
+
const response = await chain(event, context);
|
|
277
|
+
await monitor.settle(response?.statusCode ?? 200, event.__error);
|
|
278
|
+
return response;
|
|
279
|
+
});
|
|
506
280
|
};
|
|
507
281
|
return wrappedHandler;
|
|
508
282
|
}
|
|
509
283
|
};
|
|
284
|
+
|
|
510
285
|
//#endregion
|
|
511
286
|
//#region src/endpoints/parseQueryParams.ts
|
|
512
287
|
/**
|
|
@@ -527,10 +302,10 @@ function parseQueryParams(queryParams) {
|
|
|
527
302
|
}
|
|
528
303
|
return qs.parse(parts.join("&"));
|
|
529
304
|
}
|
|
305
|
+
|
|
530
306
|
//#endregion
|
|
531
307
|
//#region src/endpoints/AmazonApiGatewayV1EndpointAdaptor.ts
|
|
532
308
|
var AmazonApiGatewayV1Endpoint = class extends AmazonApiGatewayEndpoint {
|
|
533
|
-
endpoint;
|
|
534
309
|
getInput(e) {
|
|
535
310
|
const multiValueParams = e.multiValueQueryStringParameters || {};
|
|
536
311
|
const singleValueParams = e.queryStringParameters || {};
|
|
@@ -558,21 +333,23 @@ var AmazonApiGatewayV1Endpoint = class extends AmazonApiGatewayEndpoint {
|
|
|
558
333
|
}
|
|
559
334
|
};
|
|
560
335
|
}
|
|
561
|
-
constructor(endpoint, options = {}) {
|
|
562
|
-
super(endpoint, options);
|
|
336
|
+
constructor(envParser, endpoint, options = {}) {
|
|
337
|
+
super(envParser, endpoint, options);
|
|
338
|
+
this.envParser = envParser;
|
|
563
339
|
this.endpoint = endpoint;
|
|
564
340
|
}
|
|
565
341
|
};
|
|
342
|
+
|
|
566
343
|
//#endregion
|
|
567
344
|
//#region src/endpoints/AmazonApiGatewayV2EndpointAdaptor.ts
|
|
568
345
|
var AmazonApiGatewayV2Endpoint = class extends AmazonApiGatewayEndpoint {
|
|
569
|
-
endpoint;
|
|
570
346
|
getCookies(e) {
|
|
571
347
|
return createApiGatewayCookies(e.cookies, e.headers?.cookie);
|
|
572
348
|
}
|
|
573
349
|
getInput(e) {
|
|
350
|
+
const raw = AmazonApiGatewayEndpoint.decodeBody(e.body, e.isBase64Encoded, e.headers?.["content-type"]);
|
|
574
351
|
return {
|
|
575
|
-
body:
|
|
352
|
+
body: raw,
|
|
576
353
|
query: qs.parse(e.rawQueryString),
|
|
577
354
|
params: e.pathParameters || {}
|
|
578
355
|
};
|
|
@@ -592,11 +369,13 @@ var AmazonApiGatewayV2Endpoint = class extends AmazonApiGatewayEndpoint {
|
|
|
592
369
|
}
|
|
593
370
|
};
|
|
594
371
|
}
|
|
595
|
-
constructor(endpoint, options = {}) {
|
|
596
|
-
super(endpoint, options);
|
|
372
|
+
constructor(envParser, endpoint, options = {}) {
|
|
373
|
+
super(envParser, endpoint, options);
|
|
374
|
+
this.envParser = envParser;
|
|
597
375
|
this.endpoint = endpoint;
|
|
598
376
|
}
|
|
599
377
|
};
|
|
378
|
+
|
|
600
379
|
//#endregion
|
|
601
380
|
//#region src/queue/AWSLambdaQueueAdaptor.ts
|
|
602
381
|
/**
|
|
@@ -611,8 +390,6 @@ var AmazonApiGatewayV2Endpoint = class extends AmazonApiGatewayEndpoint {
|
|
|
611
390
|
* retries only those records.
|
|
612
391
|
*/
|
|
613
392
|
var AWSLambdaQueue = class {
|
|
614
|
-
envParser;
|
|
615
|
-
queue;
|
|
616
393
|
_services;
|
|
617
394
|
constructor(envParser, queue) {
|
|
618
395
|
this.envParser = envParser;
|
|
@@ -627,12 +404,6 @@ var AWSLambdaQueue = class {
|
|
|
627
404
|
this._services = this.queue.services.length > 0 ? await serviceDiscovery.register(this.queue.services) : {};
|
|
628
405
|
return this._services;
|
|
629
406
|
}
|
|
630
|
-
/** The queue's database, registered as functions register theirs. */
|
|
631
|
-
async getDatabase() {
|
|
632
|
-
const service = this.queue.databaseService;
|
|
633
|
-
if (!service) return void 0;
|
|
634
|
-
return (await ServiceDiscovery.getInstance(this.envParser).register([service]))[service.serviceName];
|
|
635
|
-
}
|
|
636
407
|
safeJsonParse(value) {
|
|
637
408
|
try {
|
|
638
409
|
return JSON.parse(value);
|
|
@@ -658,7 +429,6 @@ var AWSLambdaQueue = class {
|
|
|
658
429
|
req: { id: context.awsRequestId }
|
|
659
430
|
});
|
|
660
431
|
const services = await this.getServices();
|
|
661
|
-
const db = await this.getDatabase();
|
|
662
432
|
const schema = this.queue.messageSchema;
|
|
663
433
|
const batchItemFailures = [];
|
|
664
434
|
const messages = [];
|
|
@@ -676,7 +446,7 @@ var AWSLambdaQueue = class {
|
|
|
676
446
|
messages.push(validation.value);
|
|
677
447
|
} catch (error) {
|
|
678
448
|
logger.error({
|
|
679
|
-
|
|
449
|
+
error,
|
|
680
450
|
messageId: record.messageId
|
|
681
451
|
}, "Failed to parse SQS record");
|
|
682
452
|
batchItemFailures.push({ itemIdentifier: record.messageId });
|
|
@@ -686,8 +456,7 @@ var AWSLambdaQueue = class {
|
|
|
686
456
|
await this.queue.handler({
|
|
687
457
|
messages,
|
|
688
458
|
services,
|
|
689
|
-
logger
|
|
690
|
-
db
|
|
459
|
+
logger
|
|
691
460
|
});
|
|
692
461
|
} catch (error) {
|
|
693
462
|
logger.error(wrapError(error), "Queue handler failed; retrying batch");
|
|
@@ -697,28 +466,24 @@ var AWSLambdaQueue = class {
|
|
|
697
466
|
}
|
|
698
467
|
get handler() {
|
|
699
468
|
const handler = this._handler.bind(this);
|
|
700
|
-
return
|
|
469
|
+
return async (event, context) => {
|
|
701
470
|
const startTime = Date.now();
|
|
702
471
|
const requestId = context.awsRequestId;
|
|
703
472
|
const logger = this.queue.logger.child({ requestId });
|
|
704
473
|
return runWithRequestContext({
|
|
705
474
|
logger,
|
|
706
475
|
requestId,
|
|
707
|
-
startTime
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
system: "aws_sqs",
|
|
711
|
-
destination: this.queue.name
|
|
712
|
-
}, event.Records.map(recordCarrier), () => handler(event, context)));
|
|
713
|
-
});
|
|
476
|
+
startTime
|
|
477
|
+
}, () => handler(event, context));
|
|
478
|
+
};
|
|
714
479
|
}
|
|
715
480
|
};
|
|
481
|
+
|
|
716
482
|
//#endregion
|
|
717
483
|
//#region src/subscribers/AWSLambdaSubscriberAdaptor.ts
|
|
718
484
|
var AWSLambdaSubscriber = class {
|
|
719
|
-
envParser;
|
|
720
|
-
subscriber;
|
|
721
485
|
_logger;
|
|
486
|
+
_services;
|
|
722
487
|
constructor(envParser, subscriber) {
|
|
723
488
|
this.envParser = envParser;
|
|
724
489
|
this.subscriber = subscriber;
|
|
@@ -727,9 +492,19 @@ var AWSLambdaSubscriber = class {
|
|
|
727
492
|
get logger() {
|
|
728
493
|
return this._logger;
|
|
729
494
|
}
|
|
495
|
+
async getServices() {
|
|
496
|
+
if (this._services) return this._services;
|
|
497
|
+
const serviceDiscovery = ServiceDiscovery.getInstance(this.envParser);
|
|
498
|
+
if (this.subscriber.services.length > 0) {
|
|
499
|
+
const registered = await serviceDiscovery.register(this.subscriber.services);
|
|
500
|
+
this._services = registered;
|
|
501
|
+
} else this._services = {};
|
|
502
|
+
return this._services;
|
|
503
|
+
}
|
|
730
504
|
error() {
|
|
731
505
|
return { onError: (req) => {
|
|
732
|
-
|
|
506
|
+
const logger = req.event?.logger || this.subscriber.logger;
|
|
507
|
+
logger.error(req.error || {}, "Error processing subscriber");
|
|
733
508
|
throw wrapError(req.error);
|
|
734
509
|
} };
|
|
735
510
|
}
|
|
@@ -748,26 +523,110 @@ var AWSLambdaSubscriber = class {
|
|
|
748
523
|
}
|
|
749
524
|
services() {
|
|
750
525
|
return { before: async (req) => {
|
|
751
|
-
|
|
752
|
-
req.event.services = services;
|
|
753
|
-
req.event.db = db;
|
|
526
|
+
req.event.services = await this.getServices();
|
|
754
527
|
} };
|
|
755
528
|
}
|
|
756
529
|
parseEvents() {
|
|
757
530
|
return { before: async (req) => {
|
|
758
|
-
const { logger
|
|
531
|
+
const { logger,...e } = req.event;
|
|
532
|
+
const rawEvent = e;
|
|
759
533
|
logger.info({ rawEvent });
|
|
760
|
-
|
|
534
|
+
const events = [];
|
|
535
|
+
if ("Records" in rawEvent) {
|
|
536
|
+
if (this.isSQSEvent(rawEvent)) for (const record of rawEvent.Records) try {
|
|
537
|
+
const event = this.parseSQSRecord(record);
|
|
538
|
+
if (this.shouldIncludeEvent(event)) events.push(event);
|
|
539
|
+
} catch (error) {
|
|
540
|
+
this.logger.error({
|
|
541
|
+
error,
|
|
542
|
+
record
|
|
543
|
+
}, "Failed to parse SQS record");
|
|
544
|
+
}
|
|
545
|
+
else if (this.isSNSEvent(rawEvent)) for (const record of rawEvent.Records) try {
|
|
546
|
+
const event = this.parseSNSRecord(record);
|
|
547
|
+
if (this.shouldIncludeEvent(event)) events.push(event);
|
|
548
|
+
} catch (error) {
|
|
549
|
+
this.logger.error({
|
|
550
|
+
error,
|
|
551
|
+
record
|
|
552
|
+
}, "Failed to parse SNS record");
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
req.event.events = events;
|
|
761
556
|
} };
|
|
762
557
|
}
|
|
558
|
+
isSQSEvent(event) {
|
|
559
|
+
const firstRecord = event.Records[0];
|
|
560
|
+
return "Records" in event && event.Records.length > 0 && firstRecord !== void 0 && "eventSource" in firstRecord && firstRecord.eventSource === "aws:sqs";
|
|
561
|
+
}
|
|
562
|
+
isSNSEvent(event) {
|
|
563
|
+
const firstRecord = event.Records[0];
|
|
564
|
+
return "Records" in event && event.Records.length > 0 && firstRecord !== void 0 && "EventSource" in firstRecord && firstRecord.EventSource === "aws:sns";
|
|
565
|
+
}
|
|
566
|
+
parseSNSRecord(record) {
|
|
567
|
+
const message = this.safeJsonParse(record.Sns.Message);
|
|
568
|
+
const messageType = record.Sns.MessageAttributes?.type?.Value;
|
|
569
|
+
if (message === null) return messageType ? {
|
|
570
|
+
type: messageType,
|
|
571
|
+
payload: record.Sns.Message
|
|
572
|
+
} : record.Sns.Message;
|
|
573
|
+
const resolvedType = messageType ?? message.type;
|
|
574
|
+
if (message.type) return message;
|
|
575
|
+
return resolvedType ? {
|
|
576
|
+
type: resolvedType,
|
|
577
|
+
payload: message
|
|
578
|
+
} : message;
|
|
579
|
+
}
|
|
580
|
+
parseSQSRecord(record) {
|
|
581
|
+
const body = this.safeJsonParse(record.body);
|
|
582
|
+
if (body === null) return record.body;
|
|
583
|
+
if (body.Type === "Notification" && body.Message) {
|
|
584
|
+
const snsMessage = this.safeJsonParse(body.Message);
|
|
585
|
+
const messageType = body.MessageAttributes?.type?.Value;
|
|
586
|
+
if (snsMessage === null) return messageType ? {
|
|
587
|
+
type: messageType,
|
|
588
|
+
payload: body.Message
|
|
589
|
+
} : body.Message;
|
|
590
|
+
if (snsMessage.type) return snsMessage;
|
|
591
|
+
const resolvedType = messageType ?? snsMessage.type;
|
|
592
|
+
return resolvedType ? {
|
|
593
|
+
type: resolvedType,
|
|
594
|
+
payload: snsMessage
|
|
595
|
+
} : snsMessage;
|
|
596
|
+
}
|
|
597
|
+
return body;
|
|
598
|
+
}
|
|
599
|
+
safeJsonParse(value) {
|
|
600
|
+
try {
|
|
601
|
+
return JSON.parse(value);
|
|
602
|
+
} catch {
|
|
603
|
+
return null;
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
shouldIncludeEvent(event) {
|
|
607
|
+
if (typeof event !== "object" || !event?.type) return true;
|
|
608
|
+
if (!this.subscriber.subscribedEvents) return true;
|
|
609
|
+
return this.subscriber.subscribedEvents.includes(event.type);
|
|
610
|
+
}
|
|
763
611
|
async _handler(event) {
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
612
|
+
if (event.events.length === 0) {
|
|
613
|
+
this.logger.info("No subscribed events to process");
|
|
614
|
+
return { batchItemFailures: [] };
|
|
615
|
+
}
|
|
616
|
+
const result = await this.subscriber.handler({
|
|
617
|
+
events: event.events,
|
|
618
|
+
services: event.services,
|
|
619
|
+
logger: event.logger
|
|
770
620
|
});
|
|
621
|
+
if (this.subscriber.outputSchema && result) {
|
|
622
|
+
const validationResult = await this.subscriber.outputSchema["~standard"].validate(result);
|
|
623
|
+
if (validationResult.issues) {
|
|
624
|
+
this.logger.error({ issues: validationResult.issues }, "Subscriber output validation failed");
|
|
625
|
+
throw new Error("Subscriber output validation failed");
|
|
626
|
+
}
|
|
627
|
+
return validationResult.value;
|
|
628
|
+
}
|
|
629
|
+
return result;
|
|
771
630
|
}
|
|
772
631
|
get handler() {
|
|
773
632
|
const handler = this._handler.bind(this);
|
|
@@ -776,22 +635,16 @@ var AWSLambdaSubscriber = class {
|
|
|
776
635
|
const startTime = Date.now();
|
|
777
636
|
const requestId = context.awsRequestId;
|
|
778
637
|
const logger = this.subscriber.logger.child({ requestId });
|
|
779
|
-
const operation = `subscriber ${this.subscriber.topicName ?? context.functionName}`;
|
|
780
|
-
const records = event?.Records ?? [];
|
|
781
638
|
return runWithRequestContext({
|
|
782
639
|
logger,
|
|
783
640
|
requestId,
|
|
784
|
-
startTime
|
|
785
|
-
|
|
786
|
-
}, () => consumeBatchTraced({
|
|
787
|
-
system: records[0]?.Sns ? "aws_sns" : "aws_sqs",
|
|
788
|
-
destination: this.subscriber.topicName ?? context.functionName
|
|
789
|
-
}, records.map(recordCarrier), () => chain(event, context)));
|
|
641
|
+
startTime
|
|
642
|
+
}, () => chain(event, context));
|
|
790
643
|
};
|
|
791
644
|
return wrappedHandler;
|
|
792
645
|
}
|
|
793
646
|
};
|
|
647
|
+
|
|
794
648
|
//#endregion
|
|
795
649
|
export { AWSLambdaFunction, AWSLambdaQueue, AWSLambdaSubscriber, AWSScheduledFunction, AmazonApiGatewayV1Endpoint, AmazonApiGatewayV2Endpoint };
|
|
796
|
-
|
|
797
650
|
//# sourceMappingURL=aws.mjs.map
|