From 44b021b51938f4e38c2a9a7877b4fee99fdd3bd1 Mon Sep 17 00:00:00 2001 From: Teddy Sterne Date: Mon, 4 Nov 2024 15:41:39 -0500 Subject: [PATCH 1/3] fix: Add Support for multiValueQueryStringParameters --- src/adapters/helpers/lambdaEvent.ts | 12 +++++++++++- test/lambda-event.test.ts | 8 ++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/adapters/helpers/lambdaEvent.ts b/src/adapters/helpers/lambdaEvent.ts index ccd7dba..257a645 100644 --- a/src/adapters/helpers/lambdaEvent.ts +++ b/src/adapters/helpers/lambdaEvent.ts @@ -14,6 +14,13 @@ export const lambdaEvent = (config: AlphaOptions, relativeUrl?: string) => { querystringWithArraySupport, ); const params = Object.assign({}, parts.query, config.params); + const multiValueQueryStringParameters: Record = { ...params }; + + Object.keys(multiValueQueryStringParameters).forEach((key) => { + if (!Array.isArray(multiValueQueryStringParameters[key])) { + delete multiValueQueryStringParameters[key]; + } + }); const httpMethod = (config.method as string).toUpperCase(); const requestTime = new Date(); @@ -64,7 +71,10 @@ export const lambdaEvent = (config: AlphaOptions, relativeUrl?: string) => { userArn: null, }, }, - multiValueQueryStringParameters: null, + multiValueQueryStringParameters: + Object.keys(multiValueQueryStringParameters).length > 0 + ? multiValueQueryStringParameters + : null, }; if (Buffer.isBuffer(event.body)) { diff --git a/test/lambda-event.test.ts b/test/lambda-event.test.ts index dd2e688..638ff71 100644 --- a/test/lambda-event.test.ts +++ b/test/lambda-event.test.ts @@ -38,6 +38,13 @@ test('Can parse URLs with duplicate parameters', () => { ], pageSize: '25', }, + multiValueQueryStringParameters: { + _tag: [ + 'http://lifeomic.com/fhir/questionnaire-type|survey-form', + 'http://lifeomic.com/fhir/dataset|0bb18fef-4e2d-4b91-a623-09527265a8b3', + 'http://lifeomic.com/fhir/primary|0343bfcf-4e2d-4b91-a623-095272783bf3', + ], + }, })); assertRequestId(result); }); @@ -55,6 +62,7 @@ test('Can parse URLs without duplicates', () => { pageSize: '25', test: 'diffValue', }, + multiValueQueryStringParameters: null, })); assertRequestId(result); }); From c5ef54a06d6a9bd4c692e0339f21161cbfbf1e3f Mon Sep 17 00:00:00 2001 From: Teddy Sterne Date: Mon, 4 Nov 2024 16:03:58 -0500 Subject: [PATCH 2/3] Remove array values from queryStringParameters --- src/adapters/helpers/lambdaEvent.ts | 7 +++---- test/lambda-event.test.ts | 7 +------ 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/adapters/helpers/lambdaEvent.ts b/src/adapters/helpers/lambdaEvent.ts index 257a645..6155942 100644 --- a/src/adapters/helpers/lambdaEvent.ts +++ b/src/adapters/helpers/lambdaEvent.ts @@ -19,6 +19,8 @@ export const lambdaEvent = (config: AlphaOptions, relativeUrl?: string) => { Object.keys(multiValueQueryStringParameters).forEach((key) => { if (!Array.isArray(multiValueQueryStringParameters[key])) { delete multiValueQueryStringParameters[key]; + } else { + delete params[key]; } }); @@ -71,10 +73,7 @@ export const lambdaEvent = (config: AlphaOptions, relativeUrl?: string) => { userArn: null, }, }, - multiValueQueryStringParameters: - Object.keys(multiValueQueryStringParameters).length > 0 - ? multiValueQueryStringParameters - : null, + multiValueQueryStringParameters, }; if (Buffer.isBuffer(event.body)) { diff --git a/test/lambda-event.test.ts b/test/lambda-event.test.ts index 638ff71..48498bf 100644 --- a/test/lambda-event.test.ts +++ b/test/lambda-event.test.ts @@ -31,11 +31,6 @@ test('Can parse URLs with duplicate parameters', () => { httpMethod: 'GET', path: '/lifeomic/dstu3/Questionnaire', queryStringParameters: { - _tag: [ - 'http://lifeomic.com/fhir/questionnaire-type|survey-form', - 'http://lifeomic.com/fhir/dataset|0bb18fef-4e2d-4b91-a623-09527265a8b3', - 'http://lifeomic.com/fhir/primary|0343bfcf-4e2d-4b91-a623-095272783bf3', - ], pageSize: '25', }, multiValueQueryStringParameters: { @@ -62,7 +57,7 @@ test('Can parse URLs without duplicates', () => { pageSize: '25', test: 'diffValue', }, - multiValueQueryStringParameters: null, + multiValueQueryStringParameters: {}, })); assertRequestId(result); }); From f3acd814604cd70f868653d0f10d4509a9df9402 Mon Sep 17 00:00:00 2001 From: Teddy Sterne Date: Mon, 4 Nov 2024 16:14:00 -0500 Subject: [PATCH 3/3] fix!: Make this a breaking change BREAKING CHANGE: multi-value query params are now sent using the multiValueQueryStringParameters request property.