@geekmidas/constructs 1.0.5 → 1.1.1
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 +12 -0
- package/dist/{AWSLambdaFunction-CDJX0Tr1.d.mts → AWSLambdaFunction-BF1gJJjG.d.mts} +3 -3
- package/dist/{AWSLambdaFunction-CDJX0Tr1.d.mts.map → AWSLambdaFunction-BF1gJJjG.d.mts.map} +1 -1
- package/dist/{AWSLambdaSubscriberAdaptor-Soie57uM.cjs → AWSLambdaSubscriberAdaptor-BtBKExsh.cjs} +38 -35
- package/dist/AWSLambdaSubscriberAdaptor-BtBKExsh.cjs.map +1 -0
- package/dist/{AWSLambdaSubscriberAdaptor-BfEGolJA.d.cts → AWSLambdaSubscriberAdaptor-Cj1wjkUP.d.cts} +3 -2
- package/dist/{AWSLambdaSubscriberAdaptor-BfEGolJA.d.cts.map → AWSLambdaSubscriberAdaptor-Cj1wjkUP.d.cts.map} +1 -1
- package/dist/{AWSLambdaSubscriberAdaptor-BUvb-v_n.mjs → AWSLambdaSubscriberAdaptor-DsRmmGm1.mjs} +38 -35
- package/dist/AWSLambdaSubscriberAdaptor-DsRmmGm1.mjs.map +1 -0
- package/dist/{AWSLambdaSubscriberAdaptor-Pb7Jof-i.d.mts → AWSLambdaSubscriberAdaptor-OQvj2lKI.d.mts} +4 -3
- package/dist/{AWSLambdaSubscriberAdaptor-Pb7Jof-i.d.mts.map → AWSLambdaSubscriberAdaptor-OQvj2lKI.d.mts.map} +1 -1
- package/dist/{AmazonApiGatewayEndpointAdaptor-DRG4hu-k.d.mts → AmazonApiGatewayEndpointAdaptor-CQSZArI6.d.mts} +4 -4
- package/dist/{AmazonApiGatewayEndpointAdaptor-DRG4hu-k.d.mts.map → AmazonApiGatewayEndpointAdaptor-CQSZArI6.d.mts.map} +1 -1
- package/dist/{AmazonApiGatewayV1EndpointAdaptor-Bj9BDhNM.d.mts → AmazonApiGatewayV1EndpointAdaptor-xTrFYt48.d.mts} +4 -4
- package/dist/{AmazonApiGatewayV1EndpointAdaptor-Bj9BDhNM.d.mts.map → AmazonApiGatewayV1EndpointAdaptor-xTrFYt48.d.mts.map} +1 -1
- package/dist/{AmazonApiGatewayV2EndpointAdaptor-C0199fdk.d.mts → AmazonApiGatewayV2EndpointAdaptor-BBayh2_k.d.mts} +4 -4
- package/dist/{AmazonApiGatewayV2EndpointAdaptor-C0199fdk.d.mts.map → AmazonApiGatewayV2EndpointAdaptor-BBayh2_k.d.mts.map} +1 -1
- package/dist/{Authorizer-BgjU8-z6.mjs → Authorizer-4unKN3Xn.mjs} +1 -1
- package/dist/{Authorizer-BgjU8-z6.mjs.map → Authorizer-4unKN3Xn.mjs.map} +1 -1
- package/dist/{Authorizer-DCcYOx3h.d.mts → Authorizer-DBsrDTuf.d.mts} +1 -1
- package/dist/{Authorizer-DCcYOx3h.d.mts.map → Authorizer-DBsrDTuf.d.mts.map} +1 -1
- package/dist/{Authorizer-BXxBee2P.cjs → Authorizer-Dx57psuM.cjs} +1 -1
- package/dist/{Authorizer-BXxBee2P.cjs.map → Authorizer-Dx57psuM.cjs.map} +1 -1
- package/dist/{BaseFunctionBuilder-JpN2FtB4.d.mts → BaseFunctionBuilder-CsvFjzA8.d.mts} +2 -2
- package/dist/{BaseFunctionBuilder-JpN2FtB4.d.mts.map → BaseFunctionBuilder-CsvFjzA8.d.mts.map} +1 -1
- package/dist/{Construct-DvXCkLOP.d.mts → Construct-C2SyofdS.d.mts} +1 -1
- package/dist/{Construct-DvXCkLOP.d.mts.map → Construct-C2SyofdS.d.mts.map} +1 -1
- package/dist/Construct.d.mts +1 -1
- package/dist/{Cron-D5NpDp6y.mjs → Cron-B3vrGuaD.mjs} +1 -1
- package/dist/{Cron-D5NpDp6y.mjs.map → Cron-B3vrGuaD.mjs.map} +1 -1
- package/dist/{Cron-BJWjEj3U.d.cts → Cron-BDxW6fYg.d.cts} +1 -1
- package/dist/{Cron-BJWjEj3U.d.cts.map → Cron-BDxW6fYg.d.cts.map} +1 -1
- package/dist/{Cron-BjNvt_Wj.d.mts → Cron-CWxjO2Fg.d.mts} +2 -2
- package/dist/{Cron-BjNvt_Wj.d.mts.map → Cron-CWxjO2Fg.d.mts.map} +1 -1
- package/dist/{Cron-BV6weqem.cjs → Cron-DEKZg5j4.cjs} +1 -1
- package/dist/{Cron-BV6weqem.cjs.map → Cron-DEKZg5j4.cjs.map} +1 -1
- package/dist/{CronBuilder-DzPkDCiP.cjs → CronBuilder-BHpY6w3b.cjs} +2 -2
- package/dist/{CronBuilder-DzPkDCiP.cjs.map → CronBuilder-BHpY6w3b.cjs.map} +1 -1
- package/dist/{CronBuilder-CmPYae1S.d.cts → CronBuilder-CginrW3H.d.cts} +2 -2
- package/dist/{CronBuilder-CmPYae1S.d.cts.map → CronBuilder-CginrW3H.d.cts.map} +1 -1
- package/dist/{CronBuilder-X4au0zTu.d.mts → CronBuilder-DJnXbDGK.d.mts} +4 -4
- package/dist/{CronBuilder-X4au0zTu.d.mts.map → CronBuilder-DJnXbDGK.d.mts.map} +1 -1
- package/dist/{CronBuilder-p1Ro6a0n.mjs → CronBuilder-VXpyNfp2.mjs} +2 -2
- package/dist/{CronBuilder-p1Ro6a0n.mjs.map → CronBuilder-VXpyNfp2.mjs.map} +1 -1
- package/dist/{Endpoint-DU20A9E8.d.mts → Endpoint-BiPM0glm.d.mts} +4 -4
- package/dist/{Endpoint-DU20A9E8.d.mts.map → Endpoint-BiPM0glm.d.mts.map} +1 -1
- package/dist/{EndpointBuilder-CuVlda7g.d.mts → EndpointBuilder-B0Aj5jbB.d.mts} +5 -5
- package/dist/{EndpointBuilder-CuVlda7g.d.mts.map → EndpointBuilder-B0Aj5jbB.d.mts.map} +1 -1
- package/dist/{EndpointBuilder-BfzI6Rpc.d.cts → EndpointBuilder-Bel6RS7W.d.cts} +1 -1
- package/dist/{EndpointBuilder-BfzI6Rpc.d.cts.map → EndpointBuilder-Bel6RS7W.d.cts.map} +1 -1
- package/dist/{EndpointBuilder-CF-ZWtdu.mjs → EndpointBuilder-D1RtrBu1.mjs} +3 -3
- package/dist/{EndpointBuilder-CF-ZWtdu.mjs.map → EndpointBuilder-D1RtrBu1.mjs.map} +1 -1
- package/dist/{EndpointBuilder-CyszO0bs.cjs → EndpointBuilder-fXmTxRyW.cjs} +3 -3
- package/dist/{EndpointBuilder-CyszO0bs.cjs.map → EndpointBuilder-fXmTxRyW.cjs.map} +1 -1
- package/dist/{EndpointFactory-B29PiUhj.d.mts → EndpointFactory-CWIeWCRG.d.mts} +4 -4
- package/dist/{EndpointFactory-B29PiUhj.d.mts.map → EndpointFactory-CWIeWCRG.d.mts.map} +1 -1
- package/dist/{EndpointFactory-CVT9quQD.d.cts → EndpointFactory-CXvakOkn.d.cts} +2 -2
- package/dist/{EndpointFactory-CVT9quQD.d.cts.map → EndpointFactory-CXvakOkn.d.cts.map} +1 -1
- package/dist/{EndpointFactory-B0D6d6t9.cjs → EndpointFactory-DBfTbSTX.cjs} +3 -3
- package/dist/{EndpointFactory-B0D6d6t9.cjs.map → EndpointFactory-DBfTbSTX.cjs.map} +1 -1
- package/dist/{EndpointFactory-Do498RmG.mjs → EndpointFactory-DkB8yxdQ.mjs} +3 -3
- package/dist/{EndpointFactory-Do498RmG.mjs.map → EndpointFactory-DkB8yxdQ.mjs.map} +1 -1
- package/dist/{Function-DEX2O-SB.d.mts → Function-CZw1DRQ6.d.mts} +2 -2
- package/dist/{Function-DEX2O-SB.d.mts.map → Function-CZw1DRQ6.d.mts.map} +1 -1
- package/dist/{FunctionBuilder-DRw1s5uT.d.mts → FunctionBuilder-m5BNA2Ap.d.mts} +4 -4
- package/dist/{FunctionBuilder-DRw1s5uT.d.mts.map → FunctionBuilder-m5BNA2Ap.d.mts.map} +1 -1
- package/dist/{FunctionExecutionWrapper-D2kbmPJG.d.mts → FunctionExecutionWrapper-C7yYXIq-.d.mts} +2 -2
- package/dist/{FunctionExecutionWrapper-D2kbmPJG.d.mts.map → FunctionExecutionWrapper-C7yYXIq-.d.mts.map} +1 -1
- package/dist/{HonoEndpointAdaptor-BCql3gLP.d.cts → HonoEndpointAdaptor-BuyXynoH.d.cts} +3 -3
- package/dist/{HonoEndpointAdaptor-BCql3gLP.d.cts.map → HonoEndpointAdaptor-BuyXynoH.d.cts.map} +1 -1
- package/dist/{HonoEndpointAdaptor-BMNAai8a.d.mts → HonoEndpointAdaptor-DuVb-H5h.d.mts} +3 -3
- package/dist/{HonoEndpointAdaptor-BMNAai8a.d.mts.map → HonoEndpointAdaptor-DuVb-H5h.d.mts.map} +1 -1
- package/dist/{Subscriber-DKQK5gLD.mjs → Subscriber-BEhOdNQi.mjs} +1 -1
- package/dist/{Subscriber-DKQK5gLD.mjs.map → Subscriber-BEhOdNQi.mjs.map} +1 -1
- package/dist/{Subscriber-DCgMSkQA.d.mts → Subscriber-BgB3RRxb.d.mts} +2 -2
- package/dist/{Subscriber-DCgMSkQA.d.mts.map → Subscriber-BgB3RRxb.d.mts.map} +1 -1
- package/dist/{Subscriber-ClqSPbIZ.cjs → Subscriber-Scz7hrV6.cjs} +1 -1
- package/dist/{Subscriber-ClqSPbIZ.cjs.map → Subscriber-Scz7hrV6.cjs.map} +1 -1
- package/dist/{SubscriberBuilder-BS5B_688.cjs → SubscriberBuilder-B82h4v-S.cjs} +2 -2
- package/dist/{SubscriberBuilder-BS5B_688.cjs.map → SubscriberBuilder-B82h4v-S.cjs.map} +1 -1
- package/dist/{SubscriberBuilder-UIwW_wIY.d.cts → SubscriberBuilder-B9uva8fZ.d.cts} +1 -1
- package/dist/{SubscriberBuilder-BcyK44e_.d.mts.map → SubscriberBuilder-B9uva8fZ.d.cts.map} +1 -1
- package/dist/{SubscriberBuilder-BcyK44e_.d.mts → SubscriberBuilder-DaQkh2Nt.d.mts} +2 -2
- package/dist/{SubscriberBuilder-UIwW_wIY.d.cts.map → SubscriberBuilder-DaQkh2Nt.d.mts.map} +1 -1
- package/dist/{SubscriberBuilder-BswTuvUc.mjs → SubscriberBuilder-DlUaG0Ej.mjs} +2 -2
- package/dist/{SubscriberBuilder-BswTuvUc.mjs.map → SubscriberBuilder-DlUaG0Ej.mjs.map} +1 -1
- package/dist/{TestEndpointAdaptor-oWNADEl4.d.mts → TestEndpointAdaptor-qSWV8dpS.d.mts} +3 -3
- package/dist/{TestEndpointAdaptor-oWNADEl4.d.mts.map → TestEndpointAdaptor-qSWV8dpS.d.mts.map} +1 -1
- package/dist/TestFunctionAdaptor-BHk2bDOV.d.cts +30 -0
- package/dist/TestFunctionAdaptor-BHk2bDOV.d.cts.map +1 -0
- package/dist/TestFunctionAdaptor-CK-dbKpO.mjs +67 -0
- package/dist/TestFunctionAdaptor-CK-dbKpO.mjs.map +1 -0
- package/dist/TestFunctionAdaptor-CSMX7myB.cjs +73 -0
- package/dist/TestFunctionAdaptor-CSMX7myB.cjs.map +1 -0
- package/dist/TestFunctionAdaptor-DzT8GRdR.d.mts +30 -0
- package/dist/TestFunctionAdaptor-DzT8GRdR.d.mts.map +1 -0
- package/dist/TestSubscriberAdaptor-1m-2bM_j.cjs +49 -0
- package/dist/TestSubscriberAdaptor-1m-2bM_j.cjs.map +1 -0
- package/dist/TestSubscriberAdaptor-CPEiqSfE.d.mts +26 -0
- package/dist/TestSubscriberAdaptor-CPEiqSfE.d.mts.map +1 -0
- package/dist/TestSubscriberAdaptor-CrqLkyUE.mjs +43 -0
- package/dist/TestSubscriberAdaptor-CrqLkyUE.mjs.map +1 -0
- package/dist/TestSubscriberAdaptor-DQk5xzb0.d.cts +26 -0
- package/dist/TestSubscriberAdaptor-DQk5xzb0.d.cts.map +1 -0
- package/dist/adaptors/aws.cjs +1 -1
- package/dist/adaptors/aws.d.cts +1 -1
- package/dist/adaptors/aws.d.mts +16 -16
- package/dist/adaptors/aws.mjs +1 -1
- package/dist/adaptors/hono.d.cts +1 -1
- package/dist/adaptors/hono.d.mts +9 -9
- package/dist/adaptors/testing.cjs +5 -1
- package/dist/adaptors/testing.d.cts +4 -1
- package/dist/adaptors/testing.d.mts +13 -10
- package/dist/adaptors/testing.mjs +3 -1
- package/dist/crons/Cron.cjs +1 -1
- package/dist/crons/Cron.d.cts +1 -1
- package/dist/crons/Cron.d.mts +6 -6
- package/dist/crons/Cron.mjs +1 -1
- package/dist/crons/CronBuilder.cjs +2 -2
- package/dist/crons/CronBuilder.d.cts +2 -2
- package/dist/crons/CronBuilder.d.mts +7 -7
- package/dist/crons/CronBuilder.mjs +2 -2
- package/dist/crons/index.cjs +2 -2
- package/dist/crons/index.d.cts +2 -2
- package/dist/crons/index.d.mts +7 -7
- package/dist/crons/index.mjs +2 -2
- package/dist/endpoints/AmazonApiGatewayEndpointAdaptor.d.mts +10 -10
- package/dist/endpoints/AmazonApiGatewayV1EndpointAdaptor.d.mts +11 -11
- package/dist/endpoints/AmazonApiGatewayV2EndpointAdaptor.d.mts +11 -11
- package/dist/endpoints/Authorizer.cjs +1 -1
- package/dist/endpoints/Authorizer.d.mts +1 -1
- package/dist/endpoints/Authorizer.mjs +1 -1
- package/dist/endpoints/Endpoint.d.mts +8 -8
- package/dist/endpoints/EndpointBuilder.cjs +3 -3
- package/dist/endpoints/EndpointBuilder.d.cts +1 -1
- package/dist/endpoints/EndpointBuilder.d.mts +9 -9
- package/dist/endpoints/EndpointBuilder.mjs +3 -3
- package/dist/endpoints/EndpointFactory.cjs +4 -4
- package/dist/endpoints/EndpointFactory.d.cts +2 -2
- package/dist/endpoints/EndpointFactory.d.mts +10 -10
- package/dist/endpoints/EndpointFactory.mjs +4 -4
- package/dist/endpoints/HonoEndpointAdaptor.d.cts +1 -1
- package/dist/endpoints/HonoEndpointAdaptor.d.mts +9 -9
- package/dist/endpoints/TestEndpointAdaptor.d.mts +9 -9
- package/dist/endpoints/audit.d.mts +8 -8
- package/dist/endpoints/helpers.d.mts +8 -8
- package/dist/endpoints/index.cjs +4 -4
- package/dist/endpoints/index.d.cts +6 -6
- package/dist/endpoints/index.d.mts +12 -12
- package/dist/endpoints/index.mjs +4 -4
- package/dist/endpoints/lazyAccessors.d.cts +1 -1
- package/dist/endpoints/lazyAccessors.d.mts +9 -9
- package/dist/endpoints/processAudits.d.mts +8 -8
- package/dist/endpoints/rls.cjs +1 -1
- package/dist/endpoints/rls.d.mts +8 -8
- package/dist/endpoints/rls.mjs +1 -1
- package/dist/functions/AWSLambdaFunction.d.mts +4 -4
- package/dist/functions/BaseFunctionBuilder.d.mts +2 -2
- package/dist/functions/Function.d.mts +2 -2
- package/dist/functions/FunctionBuilder.d.mts +4 -4
- package/dist/functions/FunctionExecutionWrapper.d.mts +3 -3
- package/dist/functions/TestFunctionAdaptor.cjs +4 -67
- package/dist/functions/TestFunctionAdaptor.d.cts +3 -30
- package/dist/functions/TestFunctionAdaptor.d.mts +4 -31
- package/dist/functions/TestFunctionAdaptor.mjs +4 -66
- package/dist/functions/index.d.mts +5 -5
- package/dist/{index-DHGtpWKA.d.mts → index-DQo_Csy7.d.mts} +2 -2
- package/dist/{index-DHGtpWKA.d.mts.map → index-DQo_Csy7.d.mts.map} +1 -1
- package/dist/index.d.mts +3 -3
- package/dist/{lazyAccessors-D1tbdxUk.d.mts → lazyAccessors-DXkJpnyX.d.mts} +2 -2
- package/dist/{lazyAccessors-D1tbdxUk.d.mts.map → lazyAccessors-DXkJpnyX.d.mts.map} +1 -1
- package/dist/{lazyAccessors-ZRbwOONj.d.cts → lazyAccessors-DdZaA716.d.cts} +1 -1
- package/dist/{lazyAccessors-ZRbwOONj.d.cts.map → lazyAccessors-DdZaA716.d.cts.map} +1 -1
- package/dist/{publisher-DdPDps5m.d.cts → publisher-BrzPGnm4.d.cts} +1 -1
- package/dist/{publisher-BeouS9lG.d.mts.map → publisher-BrzPGnm4.d.cts.map} +1 -1
- package/dist/{publisher-BeouS9lG.d.mts → publisher-CP4gpv-4.d.mts} +2 -2
- package/dist/{publisher-DdPDps5m.d.cts.map → publisher-CP4gpv-4.d.mts.map} +1 -1
- package/dist/publisher.d.cts +1 -1
- package/dist/publisher.d.mts +2 -2
- package/dist/{rls-C0cWOnk4.mjs → rls-7XXX7DvY.mjs} +1 -1
- package/dist/{rls-C0cWOnk4.mjs.map → rls-7XXX7DvY.mjs.map} +1 -1
- package/dist/{rls-BrywnrQb.cjs → rls-DxFqdIA0.cjs} +1 -1
- package/dist/{rls-BrywnrQb.cjs.map → rls-DxFqdIA0.cjs.map} +1 -1
- package/dist/subscribers/AWSLambdaSubscriberAdaptor.cjs +1 -1
- package/dist/subscribers/AWSLambdaSubscriberAdaptor.d.cts +1 -1
- package/dist/subscribers/AWSLambdaSubscriberAdaptor.d.mts +3 -3
- package/dist/subscribers/AWSLambdaSubscriberAdaptor.mjs +1 -1
- package/dist/subscribers/Subscriber.cjs +1 -1
- package/dist/subscribers/Subscriber.d.mts +2 -2
- package/dist/subscribers/Subscriber.mjs +1 -1
- package/dist/subscribers/SubscriberBuilder.cjs +2 -2
- package/dist/subscribers/SubscriberBuilder.d.cts +1 -1
- package/dist/subscribers/SubscriberBuilder.d.mts +3 -3
- package/dist/subscribers/SubscriberBuilder.mjs +2 -2
- package/dist/subscribers/TestSubscriberAdaptor.cjs +4 -0
- package/dist/subscribers/TestSubscriberAdaptor.d.cts +4 -0
- package/dist/subscribers/TestSubscriberAdaptor.d.mts +4 -0
- package/dist/subscribers/TestSubscriberAdaptor.mjs +4 -0
- package/dist/subscribers/index.cjs +2 -2
- package/dist/subscribers/index.d.cts +3 -3
- package/dist/subscribers/index.d.cts.map +1 -1
- package/dist/subscribers/index.d.mts +3 -3
- package/dist/subscribers/index.mjs +2 -2
- package/dist/{telemetry-yAHf5yDs.d.mts → telemetry-C-kNOW3C.d.mts} +1 -1
- package/dist/{telemetry-yAHf5yDs.d.mts.map → telemetry-C-kNOW3C.d.mts.map} +1 -1
- package/dist/telemetry.d.mts +1 -1
- package/dist/{types-Dw-iLd3Y.d.mts → types-aFmq5cKh.d.mts} +1 -1
- package/dist/{types-Dw-iLd3Y.d.mts.map → types-aFmq5cKh.d.mts.map} +1 -1
- package/dist/types.d.mts +1 -1
- package/package.json +13 -13
- package/src/adaptors/testing.ts +2 -0
- package/src/subscribers/AWSLambdaSubscriberAdaptor.ts +61 -37
- package/src/subscribers/TestSubscriberAdaptor.ts +127 -0
- package/src/subscribers/__tests__/AWSLambdaSubscriberAdaptor.spec.ts +239 -27
- package/src/subscribers/__tests__/TestSubscriberAdaptor.spec.ts +558 -0
- package/dist/AWSLambdaSubscriberAdaptor-BUvb-v_n.mjs.map +0 -1
- package/dist/AWSLambdaSubscriberAdaptor-Soie57uM.cjs.map +0 -1
- package/dist/functions/TestFunctionAdaptor.cjs.map +0 -1
- package/dist/functions/TestFunctionAdaptor.d.cts.map +0 -1
- package/dist/functions/TestFunctionAdaptor.d.mts.map +0 -1
- package/dist/functions/TestFunctionAdaptor.mjs.map +0 -1
|
@@ -662,41 +662,260 @@ describe('AWSLambdaSubscriber', () => {
|
|
|
662
662
|
);
|
|
663
663
|
});
|
|
664
664
|
|
|
665
|
-
it('should
|
|
666
|
-
const
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
665
|
+
it('should wrap non-JSON SNS message with type from MessageAttributes in SQS', async () => {
|
|
666
|
+
const handler = vi.fn(async ({ events }) => {
|
|
667
|
+
expect(events).toHaveLength(1);
|
|
668
|
+
expect(events[0]).toEqual({
|
|
669
|
+
type: 'notification.sent',
|
|
670
|
+
payload: 'this is not json',
|
|
671
|
+
});
|
|
672
|
+
});
|
|
673
|
+
|
|
674
|
+
const subscriber = new Subscriber(
|
|
675
|
+
handler,
|
|
676
|
+
30000,
|
|
677
|
+
undefined,
|
|
678
|
+
undefined,
|
|
679
|
+
[],
|
|
680
|
+
logger,
|
|
681
|
+
);
|
|
682
|
+
|
|
683
|
+
const adapter = new AWSLambdaSubscriber(envParser, subscriber);
|
|
684
|
+
const lambdaHandler = adapter.handler;
|
|
685
|
+
|
|
686
|
+
const sqsEvent: SQSEvent = {
|
|
687
|
+
Records: [
|
|
688
|
+
{
|
|
689
|
+
messageId: 'message-1',
|
|
690
|
+
receiptHandle: 'receipt-1',
|
|
691
|
+
body: JSON.stringify({
|
|
692
|
+
Type: 'Notification',
|
|
693
|
+
MessageId: 'sns-msg-1',
|
|
694
|
+
TopicArn: 'arn:aws:sns:region:account:topic',
|
|
695
|
+
Message: 'this is not json',
|
|
696
|
+
Timestamp: '2023-01-01T00:00:00.000Z',
|
|
697
|
+
MessageAttributes: {
|
|
698
|
+
type: { Type: 'String', Value: 'notification.sent' },
|
|
699
|
+
},
|
|
700
|
+
}),
|
|
701
|
+
attributes: {} as any,
|
|
702
|
+
messageAttributes: {},
|
|
703
|
+
md5OfBody: 'md5',
|
|
704
|
+
eventSource: 'aws:sqs',
|
|
705
|
+
eventSourceARN: 'arn:aws:sqs:region:account:queue-name',
|
|
706
|
+
awsRegion: 'us-east-1',
|
|
707
|
+
} as SQSRecord,
|
|
708
|
+
],
|
|
672
709
|
};
|
|
673
710
|
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
711
|
+
await lambdaHandler(sqsEvent, createMockContext(), vi.fn());
|
|
712
|
+
|
|
713
|
+
expect(handler).toHaveBeenCalled();
|
|
714
|
+
});
|
|
715
|
+
|
|
716
|
+
it('should pass through non-JSON SNS message without type as raw string', async () => {
|
|
717
|
+
const handler = vi.fn(async ({ events }) => {
|
|
718
|
+
expect(events).toHaveLength(1);
|
|
719
|
+
expect(events[0]).toBe('plain text without type');
|
|
720
|
+
});
|
|
721
|
+
|
|
722
|
+
const subscriber = new Subscriber(
|
|
723
|
+
handler,
|
|
724
|
+
30000,
|
|
725
|
+
undefined,
|
|
726
|
+
undefined,
|
|
727
|
+
[],
|
|
728
|
+
logger,
|
|
729
|
+
);
|
|
730
|
+
|
|
731
|
+
const adapter = new AWSLambdaSubscriber(envParser, subscriber);
|
|
732
|
+
const lambdaHandler = adapter.handler;
|
|
733
|
+
|
|
734
|
+
const sqsEvent: SQSEvent = {
|
|
735
|
+
Records: [
|
|
736
|
+
{
|
|
737
|
+
messageId: 'message-1',
|
|
738
|
+
receiptHandle: 'receipt-1',
|
|
739
|
+
body: JSON.stringify({
|
|
740
|
+
Type: 'Notification',
|
|
741
|
+
MessageId: 'sns-msg-1',
|
|
742
|
+
TopicArn: 'arn:aws:sns:region:account:topic',
|
|
743
|
+
Message: 'plain text without type',
|
|
744
|
+
Timestamp: '2023-01-01T00:00:00.000Z',
|
|
745
|
+
}),
|
|
746
|
+
attributes: {} as any,
|
|
747
|
+
messageAttributes: {},
|
|
748
|
+
md5OfBody: 'md5',
|
|
749
|
+
eventSource: 'aws:sqs',
|
|
750
|
+
eventSourceARN: 'arn:aws:sqs:region:account:queue-name',
|
|
751
|
+
awsRegion: 'us-east-1',
|
|
752
|
+
} as SQSRecord,
|
|
753
|
+
],
|
|
680
754
|
};
|
|
681
755
|
|
|
756
|
+
await lambdaHandler(sqsEvent, createMockContext(), vi.fn());
|
|
757
|
+
|
|
758
|
+
expect(handler).toHaveBeenCalled();
|
|
759
|
+
});
|
|
760
|
+
|
|
761
|
+
it('should wrap non-JSON SNS record with type from MessageAttributes', async () => {
|
|
682
762
|
const handler = vi.fn(async ({ events }) => {
|
|
683
|
-
// Should still process valid events
|
|
684
763
|
expect(events).toHaveLength(1);
|
|
764
|
+
expect(events[0]).toEqual({
|
|
765
|
+
type: 'alert.fired',
|
|
766
|
+
payload: 'plain text, not json',
|
|
767
|
+
});
|
|
685
768
|
});
|
|
686
769
|
|
|
687
770
|
const subscriber = new Subscriber(
|
|
688
771
|
handler,
|
|
689
|
-
30000,
|
|
690
|
-
undefined,
|
|
691
|
-
undefined,
|
|
692
|
-
[],
|
|
693
|
-
|
|
772
|
+
30000,
|
|
773
|
+
undefined,
|
|
774
|
+
undefined,
|
|
775
|
+
[],
|
|
776
|
+
logger,
|
|
777
|
+
);
|
|
778
|
+
|
|
779
|
+
const adapter = new AWSLambdaSubscriber(envParser, subscriber);
|
|
780
|
+
const lambdaHandler = adapter.handler;
|
|
781
|
+
|
|
782
|
+
const snsEvent: SNSEvent = {
|
|
783
|
+
Records: [
|
|
784
|
+
{
|
|
785
|
+
EventSource: 'aws:sns',
|
|
786
|
+
EventVersion: '1.0',
|
|
787
|
+
EventSubscriptionArn: 'arn:aws:sns:region:account:topic',
|
|
788
|
+
Sns: {
|
|
789
|
+
Type: 'Notification',
|
|
790
|
+
MessageId: 'msg-1',
|
|
791
|
+
TopicArn: 'arn:aws:sns:region:account:topic',
|
|
792
|
+
Subject: 'Test',
|
|
793
|
+
Message: 'plain text, not json',
|
|
794
|
+
Timestamp: '2023-01-01T00:00:00.000Z',
|
|
795
|
+
SignatureVersion: '1',
|
|
796
|
+
Signature: 'sig',
|
|
797
|
+
SigningCertUrl: 'https://example.com/cert',
|
|
798
|
+
UnsubscribeUrl: 'https://example.com/unsub',
|
|
799
|
+
MessageAttributes: {
|
|
800
|
+
type: { Type: 'String', Value: 'alert.fired' },
|
|
801
|
+
},
|
|
802
|
+
},
|
|
803
|
+
} as SNSEventRecord,
|
|
804
|
+
],
|
|
805
|
+
};
|
|
806
|
+
|
|
807
|
+
await lambdaHandler(snsEvent, createMockContext(), vi.fn());
|
|
808
|
+
|
|
809
|
+
expect(handler).toHaveBeenCalled();
|
|
810
|
+
});
|
|
811
|
+
|
|
812
|
+
it('should pass through non-JSON SNS record without type as raw string', async () => {
|
|
813
|
+
const handler = vi.fn(async ({ events }) => {
|
|
814
|
+
expect(events).toHaveLength(1);
|
|
815
|
+
expect(events[0]).toBe('plain text, no type attr');
|
|
816
|
+
});
|
|
817
|
+
|
|
818
|
+
const subscriber = new Subscriber(
|
|
819
|
+
handler,
|
|
820
|
+
30000,
|
|
821
|
+
undefined,
|
|
822
|
+
undefined,
|
|
823
|
+
[],
|
|
824
|
+
logger,
|
|
825
|
+
);
|
|
826
|
+
|
|
827
|
+
const adapter = new AWSLambdaSubscriber(envParser, subscriber);
|
|
828
|
+
const lambdaHandler = adapter.handler;
|
|
829
|
+
|
|
830
|
+
const snsEvent: SNSEvent = {
|
|
831
|
+
Records: [
|
|
832
|
+
{
|
|
833
|
+
EventSource: 'aws:sns',
|
|
834
|
+
EventVersion: '1.0',
|
|
835
|
+
EventSubscriptionArn: 'arn:aws:sns:region:account:topic',
|
|
836
|
+
Sns: {
|
|
837
|
+
Type: 'Notification',
|
|
838
|
+
MessageId: 'msg-1',
|
|
839
|
+
TopicArn: 'arn:aws:sns:region:account:topic',
|
|
840
|
+
Subject: 'Test',
|
|
841
|
+
Message: 'plain text, no type attr',
|
|
842
|
+
Timestamp: '2023-01-01T00:00:00.000Z',
|
|
843
|
+
SignatureVersion: '1',
|
|
844
|
+
Signature: 'sig',
|
|
845
|
+
SigningCertUrl: 'https://example.com/cert',
|
|
846
|
+
UnsubscribeUrl: 'https://example.com/unsub',
|
|
847
|
+
},
|
|
848
|
+
} as SNSEventRecord,
|
|
849
|
+
],
|
|
850
|
+
};
|
|
851
|
+
|
|
852
|
+
await lambdaHandler(snsEvent, createMockContext(), vi.fn());
|
|
853
|
+
|
|
854
|
+
expect(handler).toHaveBeenCalled();
|
|
855
|
+
});
|
|
856
|
+
|
|
857
|
+
it('should pass through non-JSON SQS body', async () => {
|
|
858
|
+
const handler = vi.fn(async ({ events }) => {
|
|
859
|
+
expect(events).toHaveLength(1);
|
|
860
|
+
expect(events[0]).toBe('raw text body');
|
|
861
|
+
});
|
|
862
|
+
|
|
863
|
+
const subscriber = new Subscriber(
|
|
864
|
+
handler,
|
|
865
|
+
30000,
|
|
866
|
+
undefined,
|
|
867
|
+
undefined,
|
|
868
|
+
[],
|
|
869
|
+
logger,
|
|
870
|
+
);
|
|
871
|
+
|
|
872
|
+
const adapter = new AWSLambdaSubscriber(envParser, subscriber);
|
|
873
|
+
const lambdaHandler = adapter.handler;
|
|
874
|
+
|
|
875
|
+
const sqsEvent: SQSEvent = {
|
|
876
|
+
Records: [
|
|
877
|
+
{
|
|
878
|
+
messageId: 'message-1',
|
|
879
|
+
receiptHandle: 'receipt-1',
|
|
880
|
+
body: 'raw text body',
|
|
881
|
+
attributes: {} as any,
|
|
882
|
+
messageAttributes: {},
|
|
883
|
+
md5OfBody: 'md5',
|
|
884
|
+
eventSource: 'aws:sqs',
|
|
885
|
+
eventSourceARN: 'arn:aws:sqs:region:account:queue-name',
|
|
886
|
+
awsRegion: 'us-east-1',
|
|
887
|
+
} as SQSRecord,
|
|
888
|
+
],
|
|
889
|
+
};
|
|
890
|
+
|
|
891
|
+
await lambdaHandler(sqsEvent, createMockContext(), vi.fn());
|
|
892
|
+
|
|
893
|
+
expect(handler).toHaveBeenCalled();
|
|
894
|
+
});
|
|
895
|
+
|
|
896
|
+
it('should pass through invalid JSON SQS records alongside valid ones', async () => {
|
|
897
|
+
const handler = vi.fn(async ({ events }) => {
|
|
898
|
+
// Both records should be passed through
|
|
899
|
+
expect(events).toHaveLength(2);
|
|
900
|
+
expect(events[0]).toBe('invalid json{');
|
|
901
|
+
expect(events[1]).toEqual({
|
|
902
|
+
type: 'user.created',
|
|
903
|
+
payload: { userId: '1', email: 'user1@example.com' },
|
|
904
|
+
});
|
|
905
|
+
});
|
|
906
|
+
|
|
907
|
+
const subscriber = new Subscriber(
|
|
908
|
+
handler,
|
|
909
|
+
30000,
|
|
910
|
+
undefined,
|
|
911
|
+
undefined,
|
|
912
|
+
[],
|
|
913
|
+
logger,
|
|
694
914
|
);
|
|
695
915
|
|
|
696
916
|
const adapter = new AWSLambdaSubscriber(envParser, subscriber);
|
|
697
917
|
const lambdaHandler = adapter.handler;
|
|
698
918
|
|
|
699
|
-
// Create event with one invalid record
|
|
700
919
|
const sqsEvent: SQSEvent = {
|
|
701
920
|
Records: [
|
|
702
921
|
{
|
|
@@ -729,13 +948,6 @@ describe('AWSLambdaSubscriber', () => {
|
|
|
729
948
|
|
|
730
949
|
await lambdaHandler(sqsEvent, createMockContext(), vi.fn());
|
|
731
950
|
|
|
732
|
-
expect(childLogger.error).toHaveBeenCalledWith(
|
|
733
|
-
expect.objectContaining({
|
|
734
|
-
error: expect.any(Error),
|
|
735
|
-
record: expect.any(Object),
|
|
736
|
-
}),
|
|
737
|
-
'Failed to parse SQS record body',
|
|
738
|
-
);
|
|
739
951
|
expect(handler).toHaveBeenCalled();
|
|
740
952
|
});
|
|
741
953
|
});
|