@digitraffic/common 2024.8.14-1 → 2024.8.27-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/asserter.mjs → __test__/asserter.js} +3 -3
- package/dist/{test/db-testutils.d.mts → __test__/db-testutils.d.ts} +1 -1
- package/dist/{test/db-testutils.mjs → __test__/db-testutils.js} +4 -3
- package/dist/__test__/{dependencies.test.mjs → dependencies.test.js} +1 -1
- package/dist/__test__/{imports.test.mjs → imports.test.js} +79 -79
- package/dist/__test__/infra/{acl-builder.test.mjs → acl-builder.test.js} +4 -4
- package/dist/__test__/infra/api/{handler-factory.test.mjs → handler-factory.test.js} +3 -4
- package/dist/__test__/infra/api/{response.test.mjs → response.test.js} +3 -11
- package/dist/__test__/infra/api/{static-integration.test.mjs → static-integration.test.js} +3 -3
- package/dist/__test__/infra/{documentation.test.mjs → documentation.test.js} +2 -2
- package/dist/__test__/infra/{scheduler.test.mjs → scheduler.test.js} +2 -2
- package/dist/__test__/infra/{security-rule.test.mjs → security-rule.test.js} +2 -2
- package/dist/__test__/marine/{id_utils.test.mjs → id_utils.test.js} +3 -3
- package/dist/{test/mock-ky.mjs → __test__/mock-ky.js} +1 -1
- package/dist/__test__/promise/{promise.test.mjs → promise.test.js} +9 -13
- package/dist/__test__/runtime/{dt-logger.test.mjs → dt-logger.test.js} +7 -7
- package/dist/__test__/secrets/{secret-holder.test.mjs → secret-holder.test.js} +6 -4
- package/dist/__test__/secrets/{secret.test.mjs → secret.test.js} +4 -2
- package/dist/__test__/stack/{rest-apis.test.mjs → rest-apis.test.js} +4 -4
- package/dist/__test__/test/{mock-ky.test.mjs → mock-ky.test.js} +3 -3
- package/dist/{test/testutils.mjs → __test__/testutils.js} +1 -2
- package/dist/__test__/types/{lambda-response.test.mjs → lambda-response.test.js} +2 -2
- package/dist/__test__/utils/{date-utils.test.mjs → date-utils.test.js} +3 -3
- package/dist/__test__/utils/{geometry.test.mjs → geometry.test.js} +3 -3
- package/dist/__test__/utils/{logging.test.mjs → logging.test.js} +4 -4
- package/dist/__test__/utils/{utils.test.mjs → utils.test.js} +2 -3
- package/dist/aws/infra/acl-builder.d.ts +41 -0
- package/dist/aws/infra/{acl-builder.mjs → acl-builder.js} +82 -57
- package/dist/aws/infra/api/{handler-factory.d.mts → handler-factory.d.ts} +4 -4
- package/dist/aws/infra/api/{handler-factory.mjs → handler-factory.js} +7 -5
- package/dist/aws/infra/api/{integration.d.mts → integration.d.ts} +3 -1
- package/dist/aws/infra/api/{integration.mjs → integration.js} +34 -13
- package/dist/aws/infra/api/{response.d.mts → response.d.ts} +2 -2
- package/dist/aws/infra/api/{response.mjs → response.js} +4 -4
- package/dist/aws/infra/api/{responses.d.mts → responses.d.ts} +3 -3
- package/dist/aws/infra/api/{responses.mjs → responses.js} +4 -6
- package/dist/aws/infra/api/{static-integration.d.mts → static-integration.d.ts} +2 -2
- package/dist/aws/infra/api/{static-integration.mjs → static-integration.js} +3 -3
- package/dist/aws/infra/canaries/canary-alarm.d.ts +6 -0
- package/dist/aws/infra/canaries/{canary-alarm.mjs → canary-alarm.js} +1 -3
- package/dist/aws/infra/canaries/{canary-keys.mjs → canary-keys.js} +1 -1
- package/dist/aws/infra/canaries/{canary-parameters.d.mts → canary-parameters.d.ts} +1 -1
- package/dist/aws/infra/canaries/canary-parameters.js +2 -0
- package/dist/aws/infra/canaries/{canary-role.d.mts → canary-role.d.ts} +1 -1
- package/dist/aws/infra/canaries/{canary-role.mjs → canary-role.js} +2 -5
- package/dist/aws/infra/canaries/{canary.d.mts → canary.d.ts} +4 -4
- package/dist/aws/infra/canaries/{canary.mjs → canary.js} +3 -4
- package/dist/aws/infra/canaries/{database-canary.d.mts → database-canary.d.ts} +4 -5
- package/dist/aws/infra/canaries/{database-canary.mjs → database-canary.js} +4 -11
- package/dist/aws/infra/canaries/{database-checker.d.mts → database-checker.d.ts} +5 -5
- package/dist/aws/infra/canaries/{database-checker.mjs → database-checker.js} +15 -12
- package/dist/aws/infra/canaries/{url-canary.d.mts → url-canary.d.ts} +5 -5
- package/dist/aws/infra/canaries/{url-canary.mjs → url-canary.js} +7 -12
- package/dist/aws/infra/canaries/{url-checker.d.mts → url-checker.d.ts} +2 -2
- package/dist/aws/infra/canaries/{url-checker.mjs → url-checker.js} +12 -21
- package/dist/aws/infra/{documentation.d.mts → documentation.d.ts} +2 -2
- package/dist/aws/infra/{documentation.mjs → documentation.js} +4 -3
- package/dist/aws/infra/{import-util.d.mts → import-util.d.ts} +2 -2
- package/dist/aws/infra/{import-util.mjs → import-util.js} +3 -3
- package/dist/aws/infra/{scheduler.d.mts → scheduler.d.ts} +2 -2
- package/dist/aws/infra/{scheduler.mjs → scheduler.js} +1 -3
- package/dist/aws/infra/{security-rule.d.mts → security-rule.d.ts} +1 -1
- package/dist/aws/infra/{security-rule.mjs → security-rule.js} +1 -2
- package/dist/aws/infra/{sqs-integration.d.mts → sqs-integration.d.ts} +3 -3
- package/dist/aws/infra/{sqs-integration.mjs → sqs-integration.js} +3 -7
- package/dist/aws/infra/{sqs-queue.d.mts → sqs-queue.d.ts} +1 -1
- package/dist/aws/infra/{sqs-queue.mjs → sqs-queue.js} +19 -19
- package/dist/aws/infra/stack/{lambda-configs.d.mts → lambda-configs.d.ts} +4 -4
- package/dist/aws/infra/stack/{lambda-configs.mjs → lambda-configs.js} +3 -7
- package/dist/aws/infra/stack/{monitoredfunction.d.mts → monitoredfunction.d.ts} +15 -15
- package/dist/aws/infra/stack/{monitoredfunction.mjs → monitoredfunction.js} +42 -43
- package/dist/aws/infra/stack/{parameters.mjs → parameters.js} +1 -1
- package/dist/aws/infra/stack/{rest_apis.d.mts → rest_apis.d.ts} +12 -6
- package/dist/aws/infra/stack/{rest_apis.mjs → rest_apis.js} +26 -24
- package/dist/aws/infra/stack/{stack-checking-aspect.mjs → stack-checking-aspect.js} +7 -2
- package/dist/aws/infra/stack/{stack.d.mts → stack.d.ts} +4 -4
- package/dist/aws/infra/stack/{stack.mjs → stack.js} +2 -5
- package/dist/aws/infra/stack/{subscription.d.mts → subscription.d.ts} +4 -4
- package/dist/aws/infra/stack/{subscription.mjs → subscription.js} +2 -6
- package/dist/aws/infra/stacks/{db-dns-stack.d.mts → db-dns-stack.d.ts} +1 -1
- package/dist/aws/infra/stacks/{db-dns-stack.mjs → db-dns-stack.js} +4 -4
- package/dist/aws/infra/stacks/{db-proxy-stack.d.mts → db-proxy-stack.d.ts} +2 -2
- package/dist/aws/infra/stacks/{db-proxy-stack.mjs → db-proxy-stack.js} +5 -6
- package/dist/aws/infra/stacks/{db-stack.d.mts → db-stack.d.ts} +4 -4
- package/dist/aws/infra/stacks/{db-stack.mjs → db-stack.js} +7 -10
- package/dist/aws/infra/stacks/intra-stack-configuration.js +2 -0
- package/dist/aws/infra/stacks/{network-stack.d.mts → network-stack.d.ts} +2 -2
- package/dist/aws/infra/stacks/{network-stack.mjs → network-stack.js} +4 -7
- package/dist/aws/infra/{usage-plans.d.mts → usage-plans.d.ts} +1 -1
- package/dist/aws/infra/{usage-plans.mjs → usage-plans.js} +1 -2
- package/dist/aws/runtime/{apikey.mjs → apikey.js} +1 -1
- package/dist/aws/runtime/{digitraffic-integration-response.d.mts → digitraffic-integration-response.d.ts} +1 -1
- package/dist/aws/runtime/{digitraffic-integration-response.mjs → digitraffic-integration-response.js} +4 -6
- package/dist/aws/runtime/{dt-logger-default.d.mts → dt-logger-default.d.ts} +2 -2
- package/dist/aws/runtime/{dt-logger-default.mjs → dt-logger-default.js} +2 -2
- package/dist/aws/runtime/{dt-logger.mjs → dt-logger.js} +9 -4
- package/dist/aws/runtime/{environment.mjs → environment.js} +2 -2
- package/dist/aws/runtime/{s3.d.mts → s3.d.ts} +1 -1
- package/dist/aws/runtime/{s3.mjs → s3.js} +3 -3
- package/dist/aws/runtime/secrets/{dbsecret.d.mts → dbsecret.d.ts} +1 -1
- package/dist/aws/runtime/secrets/{dbsecret.mjs → dbsecret.js} +6 -2
- package/dist/aws/runtime/secrets/proxy-holder.js +25 -0
- package/dist/aws/runtime/secrets/rds-holder.js +25 -0
- package/dist/aws/runtime/secrets/{secret-holder.d.mts → secret-holder.d.ts} +6 -5
- package/dist/aws/runtime/secrets/{secret-holder.mjs → secret-holder.js} +11 -12
- package/dist/aws/runtime/secrets/{secret.mjs → secret.js} +7 -3
- package/dist/aws/types/{errors.mjs → errors.js} +1 -1
- package/dist/aws/types/{lambda-response.mjs → lambda-response.js} +1 -1
- package/dist/aws/types/{mediatypes.mjs → mediatypes.js} +1 -1
- package/dist/aws/types/{model-with-reference.d.mts → model-with-reference.d.ts} +1 -1
- package/dist/aws/types/model-with-reference.js +2 -0
- package/dist/aws/types/proxytypes.js +2 -0
- package/dist/aws/types/tags.js +4 -0
- package/dist/database/{cached.d.mts → cached.d.ts} +1 -1
- package/dist/database/{cached.mjs → cached.js} +2 -4
- package/dist/database/{database.mjs → database.js} +4 -8
- package/dist/database/{last-updated.d.mts → last-updated.d.ts} +1 -1
- package/dist/database/{last-updated.mjs → last-updated.js} +3 -1
- package/dist/database/models.js +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/marine/{id_utils.mjs → id_utils.js} +2 -2
- package/dist/marine/rtz.js +2 -0
- package/dist/types/{async-timeout-error.mjs → async-timeout-error.js} +1 -1
- package/dist/types/aws-env.js +2 -0
- package/dist/types/either.js +2 -0
- package/dist/types/{http-error.mjs → http-error.js} +1 -1
- package/dist/types/{input-error.mjs → input-error.js} +1 -1
- package/dist/types/{language.mjs → language.js} +1 -1
- package/dist/types/{nullable.d.mts → nullable.d.ts} +1 -1
- package/dist/types/nullable.js +2 -0
- package/dist/types/{traffictype.mjs → traffictype.js} +1 -1
- package/dist/types/urn.js +2 -0
- package/dist/types/util-types.js +2 -0
- package/dist/types/{validator.mjs → validator.js} +1 -1
- package/dist/utils/{api-model.d.mts → api-model.d.ts} +6 -5
- package/dist/utils/{api-model.mjs → api-model.js} +14 -15
- package/dist/utils/{base64.mjs → base64.js} +3 -3
- package/dist/utils/{date-utils.mjs → date-utils.js} +1 -1
- package/dist/utils/{geojson-types.d.mts → geojson-types.d.ts} +2 -2
- package/dist/utils/{geojson-types.mjs → geojson-types.js} +1 -1
- package/dist/utils/{geometry.d.mts → geometry.d.ts} +4 -3
- package/dist/utils/{geometry.mjs → geometry.js} +7 -4
- package/dist/utils/{logging.d.mts → logging.d.ts} +1 -1
- package/dist/utils/{logging.mjs → logging.js} +5 -8
- package/dist/utils/{retry.mjs → retry.js} +6 -8
- package/dist/utils/{slack.mjs → slack.js} +3 -3
- package/dist/utils/{utils.d.mts → utils.d.ts} +2 -3
- package/dist/utils/{utils.mjs → utils.js} +9 -5
- package/package.json +132 -129
- package/dist/aws/infra/acl-builder.d.mts +0 -31
- package/dist/aws/infra/canaries/canary-alarm.d.mts +0 -6
- package/dist/aws/infra/canaries/canary-parameters.mjs +0 -2
- package/dist/aws/infra/stacks/intra-stack-configuration.mjs +0 -2
- package/dist/aws/runtime/secrets/proxy-holder.mjs +0 -25
- package/dist/aws/runtime/secrets/rds-holder.mjs +0 -25
- package/dist/aws/types/model-with-reference.mjs +0 -2
- package/dist/aws/types/proxytypes.mjs +0 -2
- package/dist/aws/types/tags.mjs +0 -4
- package/dist/database/models.mjs +0 -2
- package/dist/index.d.mts +0 -1
- package/dist/index.mjs +0 -2
- package/dist/marine/rtz.mjs +0 -2
- package/dist/types/aws-env.mjs +0 -2
- package/dist/types/either.mjs +0 -2
- package/dist/types/nullable.mjs +0 -2
- package/dist/types/urn.mjs +0 -2
- package/dist/types/util-types.mjs +0 -2
- /package/dist/{test/asserter.d.mts → __test__/asserter.d.ts} +0 -0
- /package/dist/__test__/{dependencies.test.d.mts → dependencies.test.d.ts} +0 -0
- /package/dist/__test__/{imports.test.d.mts → imports.test.d.ts} +0 -0
- /package/dist/__test__/infra/{acl-builder.test.d.mts → acl-builder.test.d.ts} +0 -0
- /package/dist/__test__/infra/api/{handler-factory.test.d.mts → handler-factory.test.d.ts} +0 -0
- /package/dist/__test__/infra/api/{response.test.d.mts → response.test.d.ts} +0 -0
- /package/dist/__test__/infra/api/{static-integration.test.d.mts → static-integration.test.d.ts} +0 -0
- /package/dist/__test__/infra/{documentation.test.d.mts → documentation.test.d.ts} +0 -0
- /package/dist/__test__/infra/{scheduler.test.d.mts → scheduler.test.d.ts} +0 -0
- /package/dist/__test__/infra/{security-rule.test.d.mts → security-rule.test.d.ts} +0 -0
- /package/dist/__test__/marine/{id_utils.test.d.mts → id_utils.test.d.ts} +0 -0
- /package/dist/{test/mock-ky.d.mts → __test__/mock-ky.d.ts} +0 -0
- /package/dist/__test__/promise/{promise.test.d.mts → promise.test.d.ts} +0 -0
- /package/dist/__test__/runtime/{dt-logger.test.d.mts → dt-logger.test.d.ts} +0 -0
- /package/dist/__test__/secrets/{secret-holder.test.d.mts → secret-holder.test.d.ts} +0 -0
- /package/dist/__test__/secrets/{secret.test.d.mts → secret.test.d.ts} +0 -0
- /package/dist/__test__/stack/{rest-apis.test.d.mts → rest-apis.test.d.ts} +0 -0
- /package/dist/__test__/test/{mock-ky.test.d.mts → mock-ky.test.d.ts} +0 -0
- /package/dist/{test/testutils.d.mts → __test__/testutils.d.ts} +0 -0
- /package/dist/__test__/types/{lambda-response.test.d.mts → lambda-response.test.d.ts} +0 -0
- /package/dist/__test__/utils/{date-utils.test.d.mts → date-utils.test.d.ts} +0 -0
- /package/dist/__test__/utils/{geometry.test.d.mts → geometry.test.d.ts} +0 -0
- /package/dist/__test__/utils/{logging.test.d.mts → logging.test.d.ts} +0 -0
- /package/dist/__test__/utils/{utils.test.d.mts → utils.test.d.ts} +0 -0
- /package/dist/aws/infra/canaries/{canary-keys.d.mts → canary-keys.d.ts} +0 -0
- /package/dist/aws/infra/stack/{parameters.d.mts → parameters.d.ts} +0 -0
- /package/dist/aws/infra/stack/{stack-checking-aspect.d.mts → stack-checking-aspect.d.ts} +0 -0
- /package/dist/aws/infra/stacks/{intra-stack-configuration.d.mts → intra-stack-configuration.d.ts} +0 -0
- /package/dist/aws/runtime/{apikey.d.mts → apikey.d.ts} +0 -0
- /package/dist/aws/runtime/{dt-logger.d.mts → dt-logger.d.ts} +0 -0
- /package/dist/aws/runtime/{environment.d.mts → environment.d.ts} +0 -0
- /package/dist/aws/runtime/secrets/{proxy-holder.d.mts → proxy-holder.d.ts} +0 -0
- /package/dist/aws/runtime/secrets/{rds-holder.d.mts → rds-holder.d.ts} +0 -0
- /package/dist/aws/runtime/secrets/{secret.d.mts → secret.d.ts} +0 -0
- /package/dist/aws/types/{errors.d.mts → errors.d.ts} +0 -0
- /package/dist/aws/types/{lambda-response.d.mts → lambda-response.d.ts} +0 -0
- /package/dist/aws/types/{mediatypes.d.mts → mediatypes.d.ts} +0 -0
- /package/dist/aws/types/{proxytypes.d.mts → proxytypes.d.ts} +0 -0
- /package/dist/aws/types/{tags.d.mts → tags.d.ts} +0 -0
- /package/dist/database/{database.d.mts → database.d.ts} +0 -0
- /package/dist/database/{models.d.mts → models.d.ts} +0 -0
- /package/dist/marine/{id_utils.d.mts → id_utils.d.ts} +0 -0
- /package/dist/marine/{rtz.d.mts → rtz.d.ts} +0 -0
- /package/dist/types/{async-timeout-error.d.mts → async-timeout-error.d.ts} +0 -0
- /package/dist/types/{aws-env.d.mts → aws-env.d.ts} +0 -0
- /package/dist/types/{either.d.mts → either.d.ts} +0 -0
- /package/dist/types/{http-error.d.mts → http-error.d.ts} +0 -0
- /package/dist/types/{input-error.d.mts → input-error.d.ts} +0 -0
- /package/dist/types/{language.d.mts → language.d.ts} +0 -0
- /package/dist/types/{traffictype.d.mts → traffictype.d.ts} +0 -0
- /package/dist/types/{urn.d.mts → urn.d.ts} +0 -0
- /package/dist/types/{util-types.d.mts → util-types.d.ts} +0 -0
- /package/dist/types/{validator.d.mts → validator.d.ts} +0 -0
- /package/dist/utils/{base64.d.mts → base64.d.ts} +0 -0
- /package/dist/utils/{date-utils.d.mts → date-utils.d.ts} +0 -0
- /package/dist/utils/{retry.d.mts → retry.d.ts} +0 -0
- /package/dist/utils/{slack.d.mts → slack.d.ts} +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
import { type IntegrationResponse, LambdaIntegration } from "aws-cdk-lib/aws-apigateway";
|
2
2
|
import type { IFunction } from "aws-cdk-lib/aws-lambda";
|
3
|
-
import { MediaType } from "../../types/mediatypes.
|
3
|
+
import { MediaType } from "../../types/mediatypes.js";
|
4
4
|
type ParameterType = "path" | "querystring" | "multivaluequerystring" | "context" | "header";
|
5
5
|
interface ApiParameter {
|
6
6
|
type: ParameterType;
|
@@ -11,7 +11,9 @@ export declare class DigitrafficIntegration<T extends string> {
|
|
11
11
|
readonly mediaType: MediaType;
|
12
12
|
readonly parameters: ApiParameter[];
|
13
13
|
readonly sunset?: string;
|
14
|
+
_passAllQueryParameters: boolean;
|
14
15
|
constructor(lambda: IFunction, mediaType?: MediaType, sunset?: string);
|
16
|
+
passAllQueryParameters(): this;
|
15
17
|
addPathParameter(...names: T[]): this;
|
16
18
|
addQueryParameter(...names: T[]): this;
|
17
19
|
addMultiValueQueryParameter(...names: T[]): this;
|
@@ -1,21 +1,37 @@
|
|
1
|
-
import { LambdaIntegration, PassthroughBehavior
|
2
|
-
import { MediaType } from "../../types/mediatypes.
|
3
|
-
import { DigitrafficIntegrationResponse } from "../../runtime/digitraffic-integration-response.
|
1
|
+
import { LambdaIntegration, PassthroughBehavior } from "aws-cdk-lib/aws-apigateway";
|
2
|
+
import { MediaType } from "../../types/mediatypes.js";
|
3
|
+
import { DigitrafficIntegrationResponse } from "../../runtime/digitraffic-integration-response.js";
|
4
|
+
const VELOCITY_ALL_PARAMS = `#set($params = $input.params().get("querystring"))
|
5
|
+
#foreach($paramName in $params.keySet())
|
6
|
+
"$paramName":"$util.escapeJavaScript($params.get($paramName))" #if($foreach.hasNext),#end
|
7
|
+
#end
|
8
|
+
`;
|
4
9
|
export class DigitrafficIntegration {
|
5
10
|
lambda;
|
6
11
|
mediaType;
|
7
12
|
parameters = [];
|
8
13
|
sunset;
|
14
|
+
_passAllQueryParameters;
|
9
15
|
constructor(lambda, mediaType = MediaType.TEXT_PLAIN, sunset) {
|
10
16
|
this.lambda = lambda;
|
11
17
|
this.mediaType = mediaType;
|
12
18
|
this.sunset = sunset;
|
19
|
+
this._passAllQueryParameters = false;
|
20
|
+
}
|
21
|
+
passAllQueryParameters() {
|
22
|
+
if (this.parameters.some((p) => p.type === "querystring")) {
|
23
|
+
throw new Error("Can't add query parameters with pass all");
|
24
|
+
}
|
25
|
+
this._passAllQueryParameters = true;
|
26
|
+
return this;
|
13
27
|
}
|
14
28
|
addPathParameter(...names) {
|
15
29
|
names.forEach((name) => this.parameters.push({ type: "path", name }));
|
16
30
|
return this;
|
17
31
|
}
|
18
32
|
addQueryParameter(...names) {
|
33
|
+
if (this._passAllQueryParameters)
|
34
|
+
throw new Error("Can't add query parameters with pass all");
|
19
35
|
names.forEach((name) => this.parameters.push({ type: "querystring", name }));
|
20
36
|
return this;
|
21
37
|
}
|
@@ -47,10 +63,11 @@ export class DigitrafficIntegration {
|
|
47
63
|
return new LambdaIntegration(this.lambda, {
|
48
64
|
proxy: false,
|
49
65
|
integrationResponses,
|
50
|
-
requestParameters:
|
51
|
-
|
52
|
-
|
53
|
-
|
66
|
+
requestParameters: undefined,
|
67
|
+
// this.parameters.length === 0
|
68
|
+
// ? undefined
|
69
|
+
// : this.createRequestParameters(),
|
70
|
+
requestTemplates: this.parameters.length === 0 && !this._passAllQueryParameters
|
54
71
|
? undefined
|
55
72
|
: this.createRequestTemplates(),
|
56
73
|
passthroughBehavior: PassthroughBehavior.WHEN_NO_MATCH,
|
@@ -67,25 +84,29 @@ export class DigitrafficIntegration {
|
|
67
84
|
return requestParameters;
|
68
85
|
}
|
69
86
|
createRequestTemplates() {
|
70
|
-
const
|
87
|
+
const parameterAssignments = [];
|
88
|
+
if (this._passAllQueryParameters) {
|
89
|
+
parameterAssignments.push(VELOCITY_ALL_PARAMS);
|
90
|
+
}
|
71
91
|
this.parameters.forEach((parameter) => {
|
72
92
|
if (parameter.type === "context") {
|
73
|
-
|
93
|
+
parameterAssignments.push(`"${parameter.name}":"$util.parseJson($context.${parameter.name}"`);
|
74
94
|
}
|
75
95
|
else if (parameter.type === "multivaluequerystring") {
|
76
96
|
// make multivaluequerystring values to array
|
77
|
-
|
97
|
+
parameterAssignments.push(`"${parameter.name}":[#foreach($val in $method.request.multivaluequerystring.get('${parameter.name}'))"$util.escapeJavaScript($val)"#if($foreach.hasNext),#end#end]`);
|
78
98
|
}
|
79
99
|
else {
|
80
|
-
|
100
|
+
parameterAssignments.push(`"${parameter.name}":"$util.escapeJavaScript($input.params('${parameter.name}'))"`);
|
81
101
|
}
|
82
102
|
});
|
83
103
|
return {
|
84
|
-
[MediaType.APPLICATION_JSON]:
|
104
|
+
[MediaType.APPLICATION_JSON]: `{
|
105
|
+
${parameterAssignments.length > 0 ? parameterAssignments.join(",\n ") + "\n" : ""}}`,
|
85
106
|
};
|
86
107
|
}
|
87
108
|
createResponses() {
|
88
109
|
return [DigitrafficIntegrationResponse.ok(this.mediaType, this.sunset)];
|
89
110
|
}
|
90
111
|
}
|
91
|
-
//# sourceMappingURL=integration.
|
112
|
+
//# sourceMappingURL=integration.js.map
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import { MediaType } from "../../types/mediatypes.
|
2
|
-
import { type
|
1
|
+
import { MediaType } from "../../types/mediatypes.js";
|
2
|
+
import { type IModel, type JsonSchema, type MethodResponse } from "aws-cdk-lib/aws-apigateway";
|
3
3
|
/**
|
4
4
|
* This is velocity-script, that assumes the response to be LambdaResponse(status and body).
|
5
5
|
* It will always return the body and status, but if status in something else than 200 OK the content-type
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import { MediaType } from "../../types/mediatypes.
|
2
|
-
import { JsonSchemaType, JsonSchemaVersion, Model } from "aws-cdk-lib/aws-apigateway";
|
3
|
-
import { dateFromIsoString } from "../../../utils/date-utils.
|
1
|
+
import { MediaType } from "../../types/mediatypes.js";
|
2
|
+
import { JsonSchemaType, JsonSchemaVersion, Model, } from "aws-cdk-lib/aws-apigateway";
|
3
|
+
import { dateFromIsoString } from "../../../utils/date-utils.js";
|
4
4
|
/**
|
5
5
|
* This is velocity-script, that assumes the response to be LambdaResponse(status and body).
|
6
6
|
* It will always return the body and status, but if status in something else than 200 OK the content-type
|
@@ -113,4 +113,4 @@ export class DigitrafficMethodResponse {
|
|
113
113
|
return DigitrafficMethodResponse.response("400", model, mediaType, false);
|
114
114
|
}
|
115
115
|
}
|
116
|
-
//# sourceMappingURL=response.
|
116
|
+
//# sourceMappingURL=response.js.map
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import {
|
2
|
-
import { Function as AWSFunction } from "aws-cdk-lib/aws-lambda";
|
3
|
-
import { MediaType } from "../../types/mediatypes.
|
1
|
+
import { type IModel, type IntegrationResponse, LambdaIntegration, type MethodResponse, PassthroughBehavior } from "aws-cdk-lib/aws-apigateway";
|
2
|
+
import type { Function as AWSFunction } from "aws-cdk-lib/aws-lambda";
|
3
|
+
import type { MediaType } from "../../types/mediatypes.js";
|
4
4
|
export declare const RESPONSE_200_OK: IntegrationResponse;
|
5
5
|
export declare const RESPONSE_400_BAD_REQUEST: IntegrationResponse;
|
6
6
|
export declare const RESPONSE_500_SERVER_ERROR: IntegrationResponse;
|
@@ -1,8 +1,6 @@
|
|
1
|
-
import {
|
2
|
-
import { LambdaIntegration, PassthroughBehavior } from "aws-cdk-lib/aws-apigateway";
|
3
|
-
import {
|
4
|
-
import { BAD_REQUEST_MESSAGE, ERROR_MESSAGE, NOT_FOUND_MESSAGE, } from "../../types/errors.mjs";
|
5
|
-
import { MediaType } from "../../types/mediatypes.mjs";
|
1
|
+
import { BadRequestResponseTemplate, InternalServerErrorResponseTemplate, NotFoundResponseTemplate, XmlResponseTemplate, } from "./response.js";
|
2
|
+
import { LambdaIntegration, PassthroughBehavior, } from "aws-cdk-lib/aws-apigateway";
|
3
|
+
import { BAD_REQUEST_MESSAGE, ERROR_MESSAGE, NOT_FOUND_MESSAGE } from "../../types/errors.js";
|
6
4
|
/// @deprecated
|
7
5
|
export const RESPONSE_200_OK = {
|
8
6
|
statusCode: "200",
|
@@ -77,4 +75,4 @@ export function getResponse(response, options) {
|
|
77
75
|
}
|
78
76
|
return response;
|
79
77
|
}
|
80
|
-
//# sourceMappingURL=responses.
|
78
|
+
//# sourceMappingURL=responses.js.map
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import { MockIntegration, Resource } from "aws-cdk-lib/aws-apigateway";
|
2
|
-
import { MediaType } from "../../types/mediatypes.
|
1
|
+
import { MockIntegration, type Resource } from "aws-cdk-lib/aws-apigateway";
|
2
|
+
import { MediaType } from "../../types/mediatypes.js";
|
3
3
|
/**
|
4
4
|
* Static integration, that returns the given response with given mediaType from given resource.
|
5
5
|
*
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import { MockIntegration, PassthroughBehavior
|
2
|
-
import { MediaType } from "../../types/mediatypes.
|
1
|
+
import { MockIntegration, PassthroughBehavior } from "aws-cdk-lib/aws-apigateway";
|
2
|
+
import { MediaType } from "../../types/mediatypes.js";
|
3
3
|
const INTEGRATION_RESPONSE_200 = `{
|
4
4
|
"statusCode": 200
|
5
5
|
}`;
|
@@ -65,4 +65,4 @@ function mapRecord(obj, func) {
|
|
65
65
|
function prefixKeys(prefix, obj) {
|
66
66
|
return mapRecord(obj, (entry) => [prefix + entry[0], entry[1]]);
|
67
67
|
}
|
68
|
-
//# sourceMappingURL=static-integration.
|
68
|
+
//# sourceMappingURL=static-integration.js.map
|
@@ -0,0 +1,6 @@
|
|
1
|
+
import type { Construct } from "constructs";
|
2
|
+
import type { CanaryParameters } from "./canary-parameters.js";
|
3
|
+
import type { Canary } from "aws-cdk-lib/aws-synthetics";
|
4
|
+
export declare class CanaryAlarm {
|
5
|
+
constructor(stack: Construct, canary: Canary, params: CanaryParameters);
|
6
|
+
}
|
@@ -1,6 +1,4 @@
|
|
1
|
-
import { Construct } from "constructs";
|
2
1
|
import { Alarm, ComparisonOperator } from "aws-cdk-lib/aws-cloudwatch";
|
3
|
-
import { Canary } from "aws-cdk-lib/aws-synthetics";
|
4
2
|
import { SnsAction } from "aws-cdk-lib/aws-cloudwatch-actions";
|
5
3
|
import { Topic } from "aws-cdk-lib/aws-sns";
|
6
4
|
export class CanaryAlarm {
|
@@ -19,4 +17,4 @@ export class CanaryAlarm {
|
|
19
17
|
}
|
20
18
|
}
|
21
19
|
}
|
22
|
-
//# sourceMappingURL=canary-alarm.
|
20
|
+
//# sourceMappingURL=canary-alarm.js.map
|
@@ -1,5 +1,4 @@
|
|
1
1
|
import { ManagedPolicy, PolicyStatement, Role, ServicePrincipal, } from "aws-cdk-lib/aws-iam";
|
2
|
-
import { Construct } from "constructs";
|
3
2
|
const BASE_POLICY_STATEMENT_PROPS = {
|
4
3
|
actions: [
|
5
4
|
"logs:CreateLogStream",
|
@@ -23,9 +22,7 @@ export class DigitrafficCanaryRole extends Role {
|
|
23
22
|
constructor(stack, canaryName) {
|
24
23
|
super(stack, "canary-role-" + canaryName, {
|
25
24
|
assumedBy: new ServicePrincipal("lambda.amazonaws.com"),
|
26
|
-
managedPolicies: [
|
27
|
-
ManagedPolicy.fromAwsManagedPolicyName("CloudWatchSyntheticsFullAccess"),
|
28
|
-
],
|
25
|
+
managedPolicies: [ManagedPolicy.fromAwsManagedPolicyName("CloudWatchSyntheticsFullAccess")],
|
29
26
|
});
|
30
27
|
this.addToPolicy(new PolicyStatement(BASE_POLICY_STATEMENT_PROPS));
|
31
28
|
this.addToPolicy(new PolicyStatement(CLOUDWATCH_STATEMENT_PROPS));
|
@@ -49,4 +46,4 @@ export class DigitrafficCanaryRole extends Role {
|
|
49
46
|
return this;
|
50
47
|
}
|
51
48
|
}
|
52
|
-
//# sourceMappingURL=canary-role.
|
49
|
+
//# sourceMappingURL=canary-role.js.map
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import { Canary } from "aws-cdk-lib/aws-synthetics";
|
2
|
-
import { Role } from "aws-cdk-lib/aws-iam";
|
3
|
-
import type { CanaryParameters } from "./canary-parameters.
|
4
|
-
import { Construct } from "constructs";
|
5
|
-
import type { LambdaEnvironment } from "../stack/lambda-configs.
|
2
|
+
import type { Role } from "aws-cdk-lib/aws-iam";
|
3
|
+
import type { CanaryParameters } from "./canary-parameters.js";
|
4
|
+
import type { Construct } from "constructs";
|
5
|
+
import type { LambdaEnvironment } from "../stack/lambda-configs.js";
|
6
6
|
export declare class DigitrafficCanary extends Canary {
|
7
7
|
constructor(scope: Construct, canaryName: string, role: Role, params: CanaryParameters, environmentVariables: LambdaEnvironment);
|
8
8
|
}
|
@@ -1,8 +1,6 @@
|
|
1
1
|
import { Duration } from "aws-cdk-lib";
|
2
2
|
import { AssetCode, Canary, Runtime, Schedule, Test } from "aws-cdk-lib/aws-synthetics";
|
3
|
-
import {
|
4
|
-
import { CanaryAlarm } from "./canary-alarm.mjs";
|
5
|
-
import { Construct } from "constructs";
|
3
|
+
import { CanaryAlarm } from "./canary-alarm.js";
|
6
4
|
export class DigitrafficCanary extends Canary {
|
7
5
|
constructor(scope, canaryName, role, params, environmentVariables) {
|
8
6
|
super(scope, canaryName, {
|
@@ -22,7 +20,8 @@ export class DigitrafficCanary extends Canary {
|
|
22
20
|
schedule: params.schedule ?? Schedule.rate(Duration.minutes(15)),
|
23
21
|
});
|
24
22
|
this.artifactsBucket.grantWrite(role);
|
23
|
+
// eslint-disable-next-line no-new
|
25
24
|
new CanaryAlarm(scope, this, params);
|
26
25
|
}
|
27
26
|
}
|
28
|
-
//# sourceMappingURL=canary.
|
27
|
+
//# sourceMappingURL=canary.js.map
|
@@ -1,13 +1,12 @@
|
|
1
|
-
import { Role } from "aws-cdk-lib/aws-iam";
|
1
|
+
import type { Role } from "aws-cdk-lib/aws-iam";
|
2
2
|
import type { ISecret } from "aws-cdk-lib/aws-secretsmanager";
|
3
|
-
import type { CanaryParameters } from "./canary-parameters.
|
4
|
-
import { DigitrafficCanary } from "./canary.
|
5
|
-
import { DigitrafficStack } from "../stack/stack.
|
3
|
+
import type { CanaryParameters } from "./canary-parameters.js";
|
4
|
+
import { DigitrafficCanary } from "./canary.js";
|
5
|
+
import type { DigitrafficStack } from "../stack/stack.js";
|
6
6
|
export declare class DatabaseCanary extends DigitrafficCanary {
|
7
7
|
constructor(stack: DigitrafficStack, role: Role, secret: ISecret, params: CanaryParameters);
|
8
8
|
static create(stack: DigitrafficStack, role: Role, params: CanaryParameters): DatabaseCanary;
|
9
9
|
/**
|
10
|
-
*
|
11
10
|
* @param stack
|
12
11
|
* @param role
|
13
12
|
* @param name name of the typescipt file without -db -suffix. Max len is 10 char if @param canaryName is not given.
|
@@ -1,9 +1,7 @@
|
|
1
|
-
import { Role } from "aws-cdk-lib/aws-iam";
|
2
1
|
import { CfnCanary } from "aws-cdk-lib/aws-synthetics";
|
3
2
|
import { Schedule } from "aws-cdk-lib/aws-events";
|
4
3
|
import { Duration } from "aws-cdk-lib";
|
5
|
-
import { DigitrafficCanary } from "./canary.
|
6
|
-
import { DigitrafficStack } from "../stack/stack.mjs";
|
4
|
+
import { DigitrafficCanary } from "./canary.js";
|
7
5
|
export class DatabaseCanary extends DigitrafficCanary {
|
8
6
|
constructor(stack, role, secret, params) {
|
9
7
|
const canaryName = `${params.name}-db`;
|
@@ -14,12 +12,8 @@ export class DatabaseCanary extends DigitrafficCanary {
|
|
14
12
|
secret.grantRead(this.role);
|
15
13
|
// need to override vpc and security group, can't do this with cdk
|
16
14
|
if (this.node.defaultChild instanceof CfnCanary) {
|
17
|
-
const subnetIds = stack.vpc === undefined
|
18
|
-
|
19
|
-
: stack.vpc.privateSubnets.map((subnet) => subnet.subnetId);
|
20
|
-
const securityGroupIds = stack.lambdaDbSg === undefined
|
21
|
-
? []
|
22
|
-
: [stack.lambdaDbSg.securityGroupId];
|
15
|
+
const subnetIds = stack.vpc === undefined ? [] : stack.vpc.privateSubnets.map((subnet) => subnet.subnetId);
|
16
|
+
const securityGroupIds = stack.lambdaDbSg === undefined ? [] : [stack.lambdaDbSg.securityGroupId];
|
23
17
|
this.node.defaultChild.vpcConfig = {
|
24
18
|
vpcId: stack.vpc?.vpcId,
|
25
19
|
securityGroupIds,
|
@@ -39,7 +33,6 @@ export class DatabaseCanary extends DigitrafficCanary {
|
|
39
33
|
});
|
40
34
|
}
|
41
35
|
/**
|
42
|
-
*
|
43
36
|
* @param stack
|
44
37
|
* @param role
|
45
38
|
* @param name name of the typescipt file without -db -suffix. Max len is 10 char if @param canaryName is not given.
|
@@ -65,4 +58,4 @@ export class DatabaseCanary extends DigitrafficCanary {
|
|
65
58
|
});
|
66
59
|
}
|
67
60
|
}
|
68
|
-
//# sourceMappingURL=database-canary.
|
61
|
+
//# sourceMappingURL=database-canary.js.map
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import type { Countable } from "../../../database/models.
|
1
|
+
import type { Countable } from "../../../database/models.js";
|
2
2
|
declare abstract class DatabaseCheck<T> {
|
3
3
|
readonly name: string;
|
4
4
|
readonly sql: string;
|
@@ -19,15 +19,15 @@ export declare class DatabaseCountChecker {
|
|
19
19
|
/**
|
20
20
|
* Expect that the count is 1
|
21
21
|
*/
|
22
|
-
expectOne(name: string, sql: string):
|
22
|
+
expectOne(name: string, sql: string): DatabaseCountChecker;
|
23
23
|
/**
|
24
24
|
* Expect that the count is 0
|
25
25
|
*/
|
26
|
-
expectZero(name: string, sql: string):
|
26
|
+
expectZero(name: string, sql: string): DatabaseCountChecker;
|
27
27
|
/**
|
28
28
|
* Expect that the count is 1 or more
|
29
29
|
*/
|
30
|
-
expectOneOrMore(name: string, sql: string):
|
31
|
-
expect(): Promise<
|
30
|
+
expectOneOrMore(name: string, sql: string): DatabaseCountChecker;
|
31
|
+
expect(): Promise<"OK">;
|
32
32
|
}
|
33
33
|
export {};
|
@@ -1,8 +1,8 @@
|
|
1
|
-
import { inDatabaseReadonly } from "../../../database/database.
|
2
|
-
import { ProxyHolder } from "../../runtime/secrets/proxy-holder.
|
3
|
-
import { RdsHolder } from "../../runtime/secrets/rds-holder.
|
4
|
-
import { getEnvVariable } from "../../../utils/utils.
|
5
|
-
import { logger } from "../../runtime/dt-logger-default.
|
1
|
+
import { inDatabaseReadonly } from "../../../database/database.js";
|
2
|
+
import { ProxyHolder } from "../../runtime/secrets/proxy-holder.js";
|
3
|
+
import { RdsHolder } from "../../runtime/secrets/rds-holder.js";
|
4
|
+
import { getEnvVariable } from "../../../utils/utils.js";
|
5
|
+
import { logger } from "../../runtime/dt-logger-default.js";
|
6
6
|
import synthetics from "Synthetics";
|
7
7
|
class DatabaseCheck {
|
8
8
|
name;
|
@@ -15,15 +15,20 @@ class DatabaseCheck {
|
|
15
15
|
}
|
16
16
|
}
|
17
17
|
class CountDatabaseCheck extends DatabaseCheck {
|
18
|
+
// eslint-disable-next-line @rushstack/no-new-null
|
18
19
|
minCount;
|
20
|
+
// eslint-disable-next-line @rushstack/no-new-null
|
19
21
|
maxCount;
|
20
|
-
constructor(name, sql,
|
22
|
+
constructor(name, sql,
|
23
|
+
// eslint-disable-next-line @rushstack/no-new-null
|
24
|
+
minCount,
|
25
|
+
// eslint-disable-next-line @rushstack/no-new-null
|
26
|
+
maxCount) {
|
21
27
|
super(name, sql);
|
22
|
-
if (!sql.toLowerCase().includes("select") ||
|
23
|
-
!sql.toLowerCase().includes("count")) {
|
28
|
+
if (!sql.toLowerCase().includes("select") || !sql.toLowerCase().includes("count")) {
|
24
29
|
throw new Error("sql must contain select count(*)");
|
25
30
|
}
|
26
|
-
if (minCount
|
31
|
+
if ((minCount === null || minCount === undefined) && (maxCount === null || maxCount === undefined)) {
|
27
32
|
throw new Error("no max or min given");
|
28
33
|
}
|
29
34
|
this.minCount = minCount;
|
@@ -61,9 +66,7 @@ export class DatabaseCountChecker {
|
|
61
66
|
checks = [];
|
62
67
|
constructor(credentialsFunction) {
|
63
68
|
this.credentialsFunction = credentialsFunction;
|
64
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
|
65
69
|
synthetics.getConfiguration().disableRequestMetrics();
|
66
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
|
67
70
|
synthetics.getConfiguration().withFailedCanaryMetric(true);
|
68
71
|
}
|
69
72
|
static createForProxy() {
|
@@ -117,4 +120,4 @@ export class DatabaseCountChecker {
|
|
117
120
|
return "OK";
|
118
121
|
}
|
119
122
|
}
|
120
|
-
//# sourceMappingURL=database-checker.
|
123
|
+
//# sourceMappingURL=database-checker.js.map
|
@@ -1,9 +1,9 @@
|
|
1
|
-
import { Role } from "aws-cdk-lib/aws-iam";
|
1
|
+
import type { Role } from "aws-cdk-lib/aws-iam";
|
2
2
|
import type { ISecret } from "aws-cdk-lib/aws-secretsmanager";
|
3
|
-
import { DigitrafficRestApi } from "../stack/rest_apis.
|
4
|
-
import { DigitrafficStack } from "../stack/stack.
|
5
|
-
import { DigitrafficCanary } from "./canary.
|
6
|
-
import type { CanaryParameters } from "./canary-parameters.
|
3
|
+
import type { DigitrafficRestApi } from "../stack/rest_apis.js";
|
4
|
+
import type { DigitrafficStack } from "../stack/stack.js";
|
5
|
+
import { DigitrafficCanary } from "./canary.js";
|
6
|
+
import type { CanaryParameters } from "./canary-parameters.js";
|
7
7
|
export interface UrlCanaryParameters extends CanaryParameters {
|
8
8
|
readonly hostname: string;
|
9
9
|
readonly apiKeyId: string;
|
@@ -1,9 +1,6 @@
|
|
1
|
-
import { Role } from "aws-cdk-lib/aws-iam";
|
2
1
|
import { CfnCanary } from "aws-cdk-lib/aws-synthetics";
|
3
|
-
import {
|
4
|
-
import {
|
5
|
-
import { DigitrafficCanary } from "./canary.mjs";
|
6
|
-
import { ENV_API_KEY, ENV_HOSTNAME, ENV_SECRET } from "./canary-keys.mjs";
|
2
|
+
import { DigitrafficCanary } from "./canary.js";
|
3
|
+
import { ENV_API_KEY, ENV_HOSTNAME, ENV_SECRET } from "./canary-keys.js";
|
7
4
|
export class UrlCanary extends DigitrafficCanary {
|
8
5
|
constructor(stack, role, params, secret) {
|
9
6
|
const canaryName = `${params.name}-url`;
|
@@ -21,12 +18,8 @@ export class UrlCanary extends DigitrafficCanary {
|
|
21
18
|
// the handler code is defined at the actual project using this
|
22
19
|
super(stack, canaryName, role, params, environmentVariables);
|
23
20
|
if (params.inVpc && this.node.defaultChild instanceof CfnCanary) {
|
24
|
-
const subnetIds = stack.vpc === undefined
|
25
|
-
|
26
|
-
: stack.vpc.privateSubnets.map((subnet) => subnet.subnetId);
|
27
|
-
const securityGroupIds = stack.lambdaDbSg === undefined
|
28
|
-
? []
|
29
|
-
: [stack.lambdaDbSg.securityGroupId];
|
21
|
+
const subnetIds = stack.vpc === undefined ? [] : stack.vpc.privateSubnets.map((subnet) => subnet.subnetId);
|
22
|
+
const securityGroupIds = stack.lambdaDbSg === undefined ? [] : [stack.lambdaDbSg.securityGroupId];
|
30
23
|
this.node.defaultChild.vpcConfig = {
|
31
24
|
vpcId: stack.vpc?.vpcId,
|
32
25
|
securityGroupIds,
|
@@ -46,9 +39,11 @@ export class UrlCanary extends DigitrafficCanary {
|
|
46
39
|
static getApiKey(publicApi) {
|
47
40
|
const apiKeys = publicApi.apiKeyIds;
|
48
41
|
if (apiKeys.length > 1) {
|
42
|
+
// eslint-disable-next-line no-console
|
49
43
|
console.info("rest api has more than one api key");
|
50
44
|
}
|
51
45
|
if (apiKeys.length === 0) {
|
46
|
+
// eslint-disable-next-line no-console
|
52
47
|
console.info("rest api has no api keys");
|
53
48
|
return undefined;
|
54
49
|
}
|
@@ -56,4 +51,4 @@ export class UrlCanary extends DigitrafficCanary {
|
|
56
51
|
return publicApi.apiKeyIds[0];
|
57
52
|
}
|
58
53
|
}
|
59
|
-
//# sourceMappingURL=url-canary.
|
54
|
+
//# sourceMappingURL=url-canary.js.map
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import { IncomingMessage } from "http";
|
2
|
-
import { MediaType } from "../../types/mediatypes.
|
1
|
+
import type { IncomingMessage } from "http";
|
2
|
+
import { MediaType } from "../../types/mediatypes.js";
|
3
3
|
import type { FeatureCollection } from "geojson";
|
4
4
|
export declare const API_KEY_HEADER = "x-api-key";
|
5
5
|
type CheckerFunction = (Res: IncomingMessage) => Promise<void>;
|
@@ -1,15 +1,13 @@
|
|
1
|
-
import {
|
2
|
-
import { Asserter } from "../../../test/asserter.mjs";
|
3
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-var-requires
|
1
|
+
import { Asserter } from "../../../__test__/asserter.js";
|
4
2
|
import synthetics from "Synthetics";
|
5
3
|
import zlib from "zlib";
|
6
|
-
import { MediaType } from "../../types/mediatypes.
|
7
|
-
import { getApiKeyFromAPIGateway } from "../../runtime/apikey.
|
8
|
-
import { isValidGeoJson } from "../../../utils/geometry.
|
9
|
-
import { getEnvVariable } from "../../../utils/utils.
|
10
|
-
import { ENV_API_KEY, ENV_HOSTNAME } from "./canary-keys.
|
11
|
-
import { logger } from "../../runtime/dt-logger-default.
|
12
|
-
import { logException } from "../../../utils/logging.
|
4
|
+
import { MediaType } from "../../types/mediatypes.js";
|
5
|
+
import { getApiKeyFromAPIGateway } from "../../runtime/apikey.js";
|
6
|
+
import { isValidGeoJson } from "../../../utils/geometry.js";
|
7
|
+
import { getEnvVariable } from "../../../utils/utils.js";
|
8
|
+
import { ENV_API_KEY, ENV_HOSTNAME } from "./canary-keys.js";
|
9
|
+
import { logger } from "../../runtime/dt-logger-default.js";
|
10
|
+
import { logException } from "../../../utils/logging.js";
|
13
11
|
export const API_KEY_HEADER = "x-api-key";
|
14
12
|
const baseHeaders = {
|
15
13
|
"Digitraffic-User": "internal-digitraffic-canary",
|
@@ -45,15 +43,14 @@ export class UrlChecker {
|
|
45
43
|
static createV2() {
|
46
44
|
return this.create(getEnvVariable(ENV_HOSTNAME), getEnvVariable(ENV_API_KEY));
|
47
45
|
}
|
48
|
-
expectStatus(statusCode, url, callback) {
|
46
|
+
async expectStatus(statusCode, url, callback) {
|
49
47
|
const requestOptions = {
|
50
48
|
...this.requestOptions,
|
51
49
|
...{
|
52
50
|
path: url,
|
53
51
|
},
|
54
52
|
};
|
55
|
-
|
56
|
-
return synthetics.executeHttpStep(`Verify ${statusCode} for ${url.replace(/auth=.*/, "")}`, requestOptions, callback);
|
53
|
+
await synthetics.executeHttpStep(`Verify ${statusCode} for ${url.replace(/auth=.*/, "")}`, requestOptions, callback);
|
57
54
|
}
|
58
55
|
expect200(url, ...callbacks) {
|
59
56
|
const callback = async (json, body, res) => {
|
@@ -68,7 +65,6 @@ export class UrlChecker {
|
|
68
65
|
path: url,
|
69
66
|
},
|
70
67
|
};
|
71
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-return
|
72
68
|
return synthetics.executeHttpStep(`Verify 404 for ${url}`, requestOptions, validateStatusCodeAndContentType(404, MediaType.TEXT_PLAIN));
|
73
69
|
}
|
74
70
|
expect400(url) {
|
@@ -78,14 +74,10 @@ export class UrlChecker {
|
|
78
74
|
path: url,
|
79
75
|
},
|
80
76
|
};
|
81
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-return
|
82
77
|
return synthetics.executeHttpStep(`Verify 400 for ${url}`, requestOptions, validateStatusCodeAndContentType(400, MediaType.TEXT_PLAIN));
|
83
78
|
}
|
84
79
|
expect403WithoutApiKey(url, mediaType) {
|
85
|
-
if (
|
86
|
-
// eslint-disable-next-line @typescript-eslint/prefer-optional-chain
|
87
|
-
!this.requestOptions.headers ||
|
88
|
-
!this.requestOptions.headers[API_KEY_HEADER]) {
|
80
|
+
if (!this.requestOptions.headers || !this.requestOptions.headers[API_KEY_HEADER]) {
|
89
81
|
logger.error({
|
90
82
|
method: "UrlChecker.expect403WithoutApiKey",
|
91
83
|
message: "No Api-key defined",
|
@@ -98,7 +90,6 @@ export class UrlChecker {
|
|
98
90
|
headers: baseHeaders,
|
99
91
|
},
|
100
92
|
};
|
101
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-return
|
102
93
|
return synthetics.executeHttpStep(`Verify 403 for ${url}`, requestOptions, validateStatusCodeAndContentType(403, mediaType ?? MediaType.APPLICATION_JSON));
|
103
94
|
}
|
104
95
|
done() {
|
@@ -265,4 +256,4 @@ export class HeaderChecker {
|
|
265
256
|
};
|
266
257
|
}
|
267
258
|
}
|
268
|
-
//# sourceMappingURL=url-checker.
|
259
|
+
//# sourceMappingURL=url-checker.js.map
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import { Construct } from "constructs";
|
2
|
-
import { Resource } from "aws-cdk-lib/aws-apigateway";
|
1
|
+
import type { Construct } from "constructs";
|
2
|
+
import { type Resource } from "aws-cdk-lib/aws-apigateway";
|
3
3
|
/**
|
4
4
|
* Add description to a query parameter
|
5
5
|
* @param name query parameter name
|
@@ -1,5 +1,4 @@
|
|
1
|
-
import {
|
2
|
-
import { CfnDocumentationPart, Resource } from "aws-cdk-lib/aws-apigateway";
|
1
|
+
import { CfnDocumentationPart } from "aws-cdk-lib/aws-apigateway";
|
3
2
|
// Documentation parts are objects that describe an API Gateway API or parts of an API
|
4
3
|
// https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-documenting-api.html
|
5
4
|
/**
|
@@ -12,6 +11,7 @@ import { CfnDocumentationPart, Resource } from "aws-cdk-lib/aws-apigateway";
|
|
12
11
|
* @deprecated Use DigitrafficRestApi.documentResource
|
13
12
|
*/
|
14
13
|
export function addQueryParameterDescription(name, description, resource, stack) {
|
14
|
+
// eslint-disable-next-line no-new
|
15
15
|
new CfnDocumentationPart(stack, `${name}Documentation`, {
|
16
16
|
restApiId: resource.api.restApiId,
|
17
17
|
location: {
|
@@ -30,6 +30,7 @@ export function addQueryParameterDescription(name, description, resource, stack)
|
|
30
30
|
* @param stack CloudFormation stack
|
31
31
|
*/
|
32
32
|
export function addDocumentation(methodDescription, documentationProperties, resource, stack) {
|
33
|
+
// eslint-disable-next-line no-new
|
33
34
|
new CfnDocumentationPart(stack, `${methodDescription}Documentation`, {
|
34
35
|
restApiId: resource.api.restApiId,
|
35
36
|
location: {
|
@@ -88,4 +89,4 @@ export class DocumentationPart {
|
|
88
89
|
return new DocumentationPart(name, { tags, summary }, "METHOD");
|
89
90
|
}
|
90
91
|
}
|
91
|
-
//# sourceMappingURL=documentation.
|
92
|
+
//# sourceMappingURL=documentation.js.map
|