@digitraffic/common 2023.9.8-1 → 2023.9.11-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.
@@ -1,7 +1,7 @@
|
|
1
1
|
import { IntegrationResponse, LambdaIntegration } from "aws-cdk-lib/aws-apigateway";
|
2
2
|
import { IFunction } from "aws-cdk-lib/aws-lambda";
|
3
3
|
import { MediaType } from "../../types/mediatypes";
|
4
|
-
type ParameterType = "path" | "querystring" | "context" | "header";
|
4
|
+
type ParameterType = "path" | "querystring" | "multivaluequerystring" | "context" | "header";
|
5
5
|
interface ApiParameter {
|
6
6
|
type: ParameterType;
|
7
7
|
name: string;
|
@@ -14,6 +14,7 @@ export declare class DigitrafficIntegration {
|
|
14
14
|
constructor(lambda: IFunction, mediaType?: MediaType, sunset?: string);
|
15
15
|
addPathParameter(...names: string[]): this;
|
16
16
|
addQueryParameter(...names: string[]): this;
|
17
|
+
addMultiValueQueryParameter(...names: string[]): this;
|
17
18
|
/**
|
18
19
|
* Note that context parameter values needs to be in json format as they will be parsed in template as json.
|
19
20
|
* See createRequestTemplates below.
|
@@ -19,6 +19,10 @@ class DigitrafficIntegration {
|
|
19
19
|
names.forEach((name) => this.parameters.push({ type: "querystring", name }));
|
20
20
|
return this;
|
21
21
|
}
|
22
|
+
addMultiValueQueryParameter(...names) {
|
23
|
+
names.forEach((name) => this.parameters.push({ type: "multivaluequerystring", name }));
|
24
|
+
return this;
|
25
|
+
}
|
22
26
|
/**
|
23
27
|
* Note that context parameter values needs to be in json format as they will be parsed in template as json.
|
24
28
|
* See createRequestTemplates below.
|
@@ -58,7 +62,7 @@ class DigitrafficIntegration {
|
|
58
62
|
this.parameters
|
59
63
|
.filter((parameter) => parameter.type !== "context")
|
60
64
|
.forEach((parameter) => {
|
61
|
-
requestParameters[`integration.request.${parameter.type}.${parameter.name}`] = `method.request.${parameter.type}.${parameter.name}`;
|
65
|
+
requestParameters[`integration.request.${parameter.type.replace("multivaluequerystring", "querystring")}.${parameter.name}`] = `method.request.${parameter.type}.${parameter.name}`;
|
62
66
|
});
|
63
67
|
return requestParameters;
|
64
68
|
}
|
@@ -68,6 +72,10 @@ class DigitrafficIntegration {
|
|
68
72
|
if (parameter.type === "context") {
|
69
73
|
requestJson[parameter.name] = `$util.parseJson($context.${parameter.name})`;
|
70
74
|
}
|
75
|
+
else if (parameter.type === "multivaluequerystring") {
|
76
|
+
// make multivaluequerystring values to array
|
77
|
+
requestJson[parameter.name] = `[#foreach($val in $method.request.multivaluequerystring.get('${parameter.name}'))"$util.escapeJavaScript($val)"#if($foreach.hasNext),#end#end]`;
|
78
|
+
}
|
71
79
|
else {
|
72
80
|
requestJson[parameter.name] = `$util.escapeJavaScript($input.params('${parameter.name}'))`;
|
73
81
|
}
|
package/package.json
CHANGED
@@ -7,7 +7,12 @@ import { IFunction } from "aws-cdk-lib/aws-lambda";
|
|
7
7
|
import { MediaType } from "../../types/mediatypes";
|
8
8
|
import { DigitrafficIntegrationResponse } from "../../runtime/digitraffic-integration-response";
|
9
9
|
|
10
|
-
type ParameterType =
|
10
|
+
type ParameterType =
|
11
|
+
| "path"
|
12
|
+
| "querystring"
|
13
|
+
| "multivaluequerystring"
|
14
|
+
| "context"
|
15
|
+
| "header";
|
11
16
|
|
12
17
|
interface ApiParameter {
|
13
18
|
type: ParameterType;
|
@@ -43,6 +48,13 @@ export class DigitrafficIntegration {
|
|
43
48
|
return this;
|
44
49
|
}
|
45
50
|
|
51
|
+
addMultiValueQueryParameter(...names: string[]): this {
|
52
|
+
names.forEach((name) =>
|
53
|
+
this.parameters.push({ type: "multivaluequerystring", name })
|
54
|
+
);
|
55
|
+
return this;
|
56
|
+
}
|
57
|
+
|
46
58
|
/**
|
47
59
|
* Note that context parameter values needs to be in json format as they will be parsed in template as json.
|
48
60
|
* See createRequestTemplates below.
|
@@ -94,7 +106,10 @@ export class DigitrafficIntegration {
|
|
94
106
|
.filter((parameter) => parameter.type !== "context")
|
95
107
|
.forEach((parameter: ApiParameter) => {
|
96
108
|
requestParameters[
|
97
|
-
`integration.request.${parameter.type
|
109
|
+
`integration.request.${parameter.type.replace(
|
110
|
+
"multivaluequerystring",
|
111
|
+
"querystring"
|
112
|
+
)}.${parameter.name}`
|
98
113
|
] = `method.request.${parameter.type}.${parameter.name}`;
|
99
114
|
});
|
100
115
|
|
@@ -109,6 +124,11 @@ export class DigitrafficIntegration {
|
|
109
124
|
requestJson[
|
110
125
|
parameter.name
|
111
126
|
] = `$util.parseJson($context.${parameter.name})`;
|
127
|
+
} else if (parameter.type === "multivaluequerystring") {
|
128
|
+
// make multivaluequerystring values to array
|
129
|
+
requestJson[
|
130
|
+
parameter.name
|
131
|
+
] = `[#foreach($val in $method.request.multivaluequerystring.get('${parameter.name}'))"$util.escapeJavaScript($val)"#if($foreach.hasNext),#end#end]`;
|
112
132
|
} else {
|
113
133
|
requestJson[
|
114
134
|
parameter.name
|