@digitraffic/common 2024.9.25-1 → 2024.10.9-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/dist/__test__/infra/api/static-integration.test.js +8 -2
- package/dist/aws/infra/api/static-integration.d.ts +4 -4
- package/dist/aws/infra/api/static-integration.js +9 -6
- package/dist/aws/infra/canaries/canary.js +1 -1
- package/dist/aws/runtime/apikey.d.ts +2 -2
- package/dist/aws/runtime/apikey.js +7 -15
- package/dist/aws/runtime/environment.d.ts +0 -4
- package/dist/aws/runtime/environment.js +0 -13
- package/package.json +33 -33
@@ -1,3 +1,4 @@
|
|
1
|
+
import { Model } from "aws-cdk-lib/aws-apigateway";
|
1
2
|
import { DigitrafficStaticIntegration } from "../../../aws/infra/api/static-integration.js";
|
2
3
|
import { MediaType } from "../../../aws/types/mediatypes.js";
|
3
4
|
describe("response tests", () => {
|
@@ -15,9 +16,14 @@ describe("response tests", () => {
|
|
15
16
|
});
|
16
17
|
it("createMethodResponse works", () => {
|
17
18
|
const methodResponse = DigitrafficStaticIntegration.createMethodResponse({
|
18
|
-
"test-header": "test-value"
|
19
|
-
});
|
19
|
+
"test-header": "test-value"
|
20
|
+
}, MediaType.TEXT_PLAIN, Model.EMPTY_MODEL);
|
20
21
|
expect(methodResponse).toEqual({
|
22
|
+
responseModels: {
|
23
|
+
"text/plain": {
|
24
|
+
modelId: "Empty"
|
25
|
+
}
|
26
|
+
},
|
21
27
|
responseParameters: {
|
22
28
|
"method.response.header.test-header": true,
|
23
29
|
},
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { type IntegrationResponse, type MethodResponse, MockIntegration, type Resource } from "aws-cdk-lib/aws-apigateway";
|
1
|
+
import { type IModel, type IntegrationResponse, type MethodResponse, MockIntegration, type Resource } from "aws-cdk-lib/aws-apigateway";
|
2
2
|
import { MediaType } from "../../types/mediatypes.js";
|
3
3
|
/**
|
4
4
|
* Static integration, that returns the given response with given mediaType from given resource.
|
@@ -8,8 +8,8 @@ import { MediaType } from "../../types/mediatypes.js";
|
|
8
8
|
* @param response
|
9
9
|
*/
|
10
10
|
export declare class DigitrafficStaticIntegration extends MockIntegration {
|
11
|
-
constructor(resource: Resource, mediaType: MediaType, response: string, enableCors?: boolean, apiKeyRequired?: boolean, headers?: Record<string, string>);
|
12
|
-
static json<K>(resource: Resource, response: K, enableCors?: boolean, apiKeyRequired?: boolean, headers?: Record<string, string>): DigitrafficStaticIntegration;
|
11
|
+
constructor(resource: Resource, mediaType: MediaType, response: string, model: IModel, enableCors?: boolean, apiKeyRequired?: boolean, headers?: Record<string, string>);
|
12
|
+
static json<K>(resource: Resource, response: K, model: IModel, enableCors?: boolean, apiKeyRequired?: boolean, headers?: Record<string, string>): DigitrafficStaticIntegration;
|
13
13
|
static createIntegrationResponse(response: string, mediaType: MediaType, headers?: Record<string, string>): IntegrationResponse;
|
14
|
-
static createMethodResponse(headers: Record<string, string
|
14
|
+
static createMethodResponse(headers: Record<string, string>, mediaType: MediaType, model: IModel): MethodResponse;
|
15
15
|
}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { MockIntegration, PassthroughBehavior } from "aws-cdk-lib/aws-apigateway";
|
1
|
+
import { MockIntegration, PassthroughBehavior, } from "aws-cdk-lib/aws-apigateway";
|
2
2
|
import { MediaType } from "../../types/mediatypes.js";
|
3
3
|
const INTEGRATION_RESPONSE_200 = `{
|
4
4
|
"statusCode": 200
|
@@ -11,7 +11,7 @@ const INTEGRATION_RESPONSE_200 = `{
|
|
11
11
|
* @param response
|
12
12
|
*/
|
13
13
|
export class DigitrafficStaticIntegration extends MockIntegration {
|
14
|
-
constructor(resource, mediaType, response, enableCors = true, apiKeyRequired = true, headers = {}) {
|
14
|
+
constructor(resource, mediaType, response, model, enableCors = true, apiKeyRequired = true, headers = {}) {
|
15
15
|
if (enableCors) {
|
16
16
|
headers = { ...headers, "Access-Control-Allow-Origin": "*" };
|
17
17
|
}
|
@@ -26,12 +26,12 @@ export class DigitrafficStaticIntegration extends MockIntegration {
|
|
26
26
|
["GET", "HEAD"].forEach((httpMethod) => {
|
27
27
|
resource.addMethod(httpMethod, this, {
|
28
28
|
apiKeyRequired,
|
29
|
-
methodResponses: [DigitrafficStaticIntegration.createMethodResponse(headers)],
|
29
|
+
methodResponses: [DigitrafficStaticIntegration.createMethodResponse(headers, mediaType, model)],
|
30
30
|
});
|
31
31
|
});
|
32
32
|
}
|
33
|
-
static json(resource, response, enableCors = true, apiKeyRequired = true, headers = {}) {
|
34
|
-
return new DigitrafficStaticIntegration(resource, MediaType.APPLICATION_JSON, JSON.stringify(response), enableCors, apiKeyRequired, headers);
|
33
|
+
static json(resource, response, model, enableCors = true, apiKeyRequired = true, headers = {}) {
|
34
|
+
return new DigitrafficStaticIntegration(resource, MediaType.APPLICATION_JSON, JSON.stringify(response), model, enableCors, apiKeyRequired, headers);
|
35
35
|
}
|
36
36
|
static createIntegrationResponse(response, mediaType, headers = {}) {
|
37
37
|
const params = mapRecord(headers, (entry) => ["method.response.header." + entry[0], `'${entry[1]}'`]);
|
@@ -43,12 +43,15 @@ export class DigitrafficStaticIntegration extends MockIntegration {
|
|
43
43
|
responseParameters: params,
|
44
44
|
};
|
45
45
|
}
|
46
|
-
static createMethodResponse(headers) {
|
46
|
+
static createMethodResponse(headers, mediaType, model) {
|
47
47
|
const allowedHeaders = Object.keys(headers);
|
48
48
|
const entries = Object.fromEntries(allowedHeaders.map((key) => [key, true]));
|
49
49
|
return {
|
50
50
|
statusCode: "200",
|
51
51
|
responseParameters: prefixKeys("method.response.header.", entries),
|
52
|
+
responseModels: {
|
53
|
+
[mediaType]: model
|
54
|
+
}
|
52
55
|
};
|
53
56
|
}
|
54
57
|
}
|
@@ -4,7 +4,7 @@ import { CanaryAlarm } from "./canary-alarm.js";
|
|
4
4
|
export class DigitrafficCanary extends Canary {
|
5
5
|
constructor(scope, canaryName, role, params, environmentVariables) {
|
6
6
|
super(scope, canaryName, {
|
7
|
-
runtime: params.runtime ?? Runtime.
|
7
|
+
runtime: params.runtime ?? Runtime.SYNTHETICS_NODEJS_PUPPETEER_9_0,
|
8
8
|
role,
|
9
9
|
test: Test.custom({
|
10
10
|
code: new AssetCode("dist", {
|
@@ -1,2 +1,2 @@
|
|
1
|
-
import type
|
2
|
-
export declare function getApiKeyFromAPIGateway(keyId: string): Promise<
|
1
|
+
import { type GetApiKeyCommandOutput } from "@aws-sdk/client-api-gateway";
|
2
|
+
export declare function getApiKeyFromAPIGateway(keyId: string): Promise<GetApiKeyCommandOutput>;
|
@@ -1,21 +1,13 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
import { APIGateway } from "aws-sdk";
|
1
|
+
import { APIGatewayClient, GetApiKeyCommand } from "@aws-sdk/client-api-gateway";
|
2
|
+
import { FetchHttpHandler } from "@smithy/fetch-http-handler";
|
4
3
|
export async function getApiKeyFromAPIGateway(keyId) {
|
5
|
-
const
|
6
|
-
|
7
|
-
|
8
|
-
apiKey: keyId,
|
9
|
-
includeValue: true,
|
10
|
-
})
|
11
|
-
.promise();
|
12
|
-
/*
|
13
|
-
const client = new APIGatewayClient();
|
4
|
+
const client = new APIGatewayClient({
|
5
|
+
requestHandler: new FetchHttpHandler()
|
6
|
+
});
|
14
7
|
const command = new GetApiKeyCommand({
|
15
8
|
apiKey: keyId,
|
16
|
-
includeValue: true
|
9
|
+
includeValue: true
|
17
10
|
});
|
18
|
-
|
19
|
-
return client.send(command);*/
|
11
|
+
return (await client.send(command));
|
20
12
|
}
|
21
13
|
//# sourceMappingURL=apikey.js.map
|
@@ -3,7 +3,3 @@ export declare enum EnvKeys {
|
|
3
3
|
SECRET_ID = "SECRET_ID",
|
4
4
|
SECRET_OVERRIDE_AWS_REGION = "SECRET_OVERRIDE_AWS_REGION"
|
5
5
|
}
|
6
|
-
/**
|
7
|
-
* @deprecated Use digitraffic/common/utils/utils#getEnvVariable
|
8
|
-
*/
|
9
|
-
export declare function envValue(key: string, defaultValue?: string): string;
|
@@ -4,17 +4,4 @@ export var EnvKeys;
|
|
4
4
|
EnvKeys["SECRET_ID"] = "SECRET_ID";
|
5
5
|
EnvKeys["SECRET_OVERRIDE_AWS_REGION"] = "SECRET_OVERRIDE_AWS_REGION";
|
6
6
|
})(EnvKeys || (EnvKeys = {}));
|
7
|
-
/**
|
8
|
-
* @deprecated Use digitraffic/common/utils/utils#getEnvVariable
|
9
|
-
*/
|
10
|
-
export function envValue(key, defaultValue) {
|
11
|
-
const value = process.env[key];
|
12
|
-
if (value === null || value === undefined) {
|
13
|
-
if (defaultValue) {
|
14
|
-
return defaultValue;
|
15
|
-
}
|
16
|
-
throw new Error(`Missing environment value ${key}`);
|
17
|
-
}
|
18
|
-
return value;
|
19
|
-
}
|
20
7
|
//# sourceMappingURL=environment.js.map
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@digitraffic/common",
|
3
|
-
"version": "2024.9
|
3
|
+
"version": "2024.10.9-1",
|
4
4
|
"description": "",
|
5
5
|
"type": "module",
|
6
6
|
"repository": {
|
@@ -104,69 +104,69 @@
|
|
104
104
|
"./dist/aws/runtime/digitraffic-integration-response": "./dist/aws/runtime/digitraffic-integration-response.js"
|
105
105
|
},
|
106
106
|
"peerDependencies": {
|
107
|
-
"@aws-sdk/client-api-gateway": "^3.
|
108
|
-
"@aws-sdk/client-s3": "^3.
|
109
|
-
"@aws-sdk/client-secrets-manager": "^3.
|
110
|
-
"@aws-sdk/client-sns": "^3.
|
111
|
-
"@aws-sdk/lib-storage": "^3.
|
112
|
-
"
|
113
|
-
"aws-
|
107
|
+
"@aws-sdk/client-api-gateway": "^3.667.0",
|
108
|
+
"@aws-sdk/client-s3": "^3.667.0",
|
109
|
+
"@aws-sdk/client-secrets-manager": "^3.667.0",
|
110
|
+
"@aws-sdk/client-sns": "^3.667.0",
|
111
|
+
"@aws-sdk/lib-storage": "^3.667.0",
|
112
|
+
"@smithy/fetch-http-handler": "3.2.9",
|
113
|
+
"aws-cdk-lib": "^2.161.1",
|
114
114
|
"change-case": "^5.4.4",
|
115
115
|
"constructs": "~10.3.0",
|
116
|
-
"date-fns": "
|
117
|
-
"date-fns-tz": "
|
116
|
+
"date-fns": "3.6.0",
|
117
|
+
"date-fns-tz": "3.2.0",
|
118
118
|
"etag": "^1.8.1",
|
119
119
|
"geojson-validation": "^1.0.2",
|
120
|
-
"ky": "^1.
|
120
|
+
"ky": "^1.7.2",
|
121
121
|
"lodash-es": "~4.17.21",
|
122
122
|
"node-ttl": "^0.2.0",
|
123
|
-
"pg-native": "^3.
|
123
|
+
"pg-native": "^3.2.0",
|
124
124
|
"pg-promise": "^11.9.1",
|
125
125
|
"zod": "~3.23.8"
|
126
126
|
},
|
127
127
|
"devDependencies": {
|
128
|
-
"@aws-sdk/client-api-gateway": "^3.
|
129
|
-
"@aws-sdk/client-s3": "^3.
|
130
|
-
"@aws-sdk/client-secrets-manager": "^3.
|
131
|
-
"@aws-sdk/client-sns": "^3.
|
132
|
-
"@aws-sdk/lib-storage": "^3.
|
133
|
-
"@digitraffic/eslint-config": "^
|
128
|
+
"@aws-sdk/client-api-gateway": "^3.667.0",
|
129
|
+
"@aws-sdk/client-s3": "^3.667.0",
|
130
|
+
"@aws-sdk/client-secrets-manager": "^3.667.0",
|
131
|
+
"@aws-sdk/client-sns": "^3.667.0",
|
132
|
+
"@aws-sdk/lib-storage": "^3.667.0",
|
133
|
+
"@digitraffic/eslint-config": "^3.0.1",
|
134
134
|
"@jest/globals": "^29.7.0",
|
135
135
|
"@rushstack/eslint-config": "^3.7.1",
|
136
|
-
"@rushstack/heft": "^0.67.
|
137
|
-
"@rushstack/heft-jest-plugin": "^0.12.
|
138
|
-
"@rushstack/heft-lint-plugin": "^0.4.
|
139
|
-
"@rushstack/heft-typescript-plugin": "^0.5.
|
140
|
-
"@smithy/
|
141
|
-
"@types
|
136
|
+
"@rushstack/heft": "^0.67.2",
|
137
|
+
"@rushstack/heft-jest-plugin": "^0.12.14",
|
138
|
+
"@rushstack/heft-lint-plugin": "^0.4.6",
|
139
|
+
"@rushstack/heft-typescript-plugin": "^0.5.30",
|
140
|
+
"@smithy/fetch-http-handler": "3.2.9",
|
141
|
+
"@smithy/types": "^3.5.0",
|
142
|
+
"@types/aws-lambda": "8.10.145",
|
142
143
|
"@types/etag": "^1.8.3",
|
143
144
|
"@types/geojson": "7946.0.14",
|
144
145
|
"@types/geojson-validation": "^1.0.3",
|
145
|
-
"@types/jest": "29.5.
|
146
|
-
"@types/lodash-es": "4.17.
|
146
|
+
"@types/jest": "29.5.13",
|
147
|
+
"@types/lodash-es": "4.17.12",
|
147
148
|
"@types/madge": "5.0.3",
|
148
149
|
"@types/node": "20.14.9",
|
149
150
|
"@typescript-eslint/eslint-plugin": "~7.14.1",
|
150
151
|
"@typescript-eslint/parser": "^7.18.0",
|
151
|
-
"aws-cdk-lib": "^2.
|
152
|
-
"aws-sdk": "^2.1686.0",
|
152
|
+
"aws-cdk-lib": "^2.161.1",
|
153
153
|
"change-case": "^5.4.4",
|
154
154
|
"constructs": "~10.3.0",
|
155
|
-
"date-fns": "
|
156
|
-
"date-fns-tz": "
|
157
|
-
"eslint": "^8.57.
|
155
|
+
"date-fns": "3.6.0",
|
156
|
+
"date-fns-tz": "3.2.0",
|
157
|
+
"eslint": "^8.57.1",
|
158
158
|
"eslint-config-prettier": "^9.1.0",
|
159
159
|
"eslint-plugin-deprecation": "~3.0.0",
|
160
160
|
"etag": "^1.8.1",
|
161
161
|
"geojson-validation": "^1.0.2",
|
162
162
|
"jest": "^29.7.0",
|
163
163
|
"jest-junit": "^16.0.0",
|
164
|
-
"ky": "^1.7.
|
164
|
+
"ky": "^1.7.2",
|
165
165
|
"lodash": "^4.17.21",
|
166
166
|
"lodash-es": "~4.17.21",
|
167
167
|
"madge": "^8.0.0",
|
168
168
|
"node-ttl": "^0.2.0",
|
169
|
-
"pg-native": "^3.
|
169
|
+
"pg-native": "^3.2.0",
|
170
170
|
"pg-promise": "^11.9.1",
|
171
171
|
"prettier": "^3.3.3",
|
172
172
|
"rimraf": "^6.0.1",
|