@digitraffic/common 2024.1.10-1 → 2024.1.19-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/aws/infra/api/handler-factory.d.ts +2 -2
- package/dist/aws/infra/api/handler-factory.js +4 -9
- package/dist/aws/infra/api/integration.d.ts +1 -1
- package/dist/aws/infra/api/integration.js +9 -13
- package/dist/aws/infra/api/response.d.ts +2 -3
- package/dist/aws/infra/api/response.js +25 -30
- package/dist/aws/infra/api/responses.d.ts +2 -3
- package/dist/aws/infra/api/responses.js +25 -31
- package/dist/aws/infra/api/static-integration.d.ts +1 -1
- package/dist/aws/infra/api/static-integration.js +7 -11
- package/dist/aws/infra/canaries/canary-alarm.d.ts +1 -1
- package/dist/aws/infra/canaries/canary-alarm.js +7 -11
- package/dist/aws/infra/canaries/canary-keys.js +3 -6
- package/dist/aws/infra/canaries/canary-parameters.js +1 -2
- package/dist/aws/infra/canaries/canary-role.js +8 -12
- package/dist/aws/infra/canaries/canary.d.ts +2 -2
- package/dist/aws/infra/canaries/canary.js +9 -13
- package/dist/aws/infra/canaries/database-canary.d.ts +3 -3
- package/dist/aws/infra/canaries/database-canary.js +8 -12
- package/dist/aws/infra/canaries/database-checker.d.ts +1 -1
- package/dist/aws/infra/canaries/database-checker.js +10 -14
- package/dist/aws/infra/canaries/url-canary.d.ts +4 -4
- package/dist/aws/infra/canaries/url-canary.js +8 -12
- package/dist/aws/infra/canaries/url-checker.d.ts +2 -2
- package/dist/aws/infra/canaries/url-checker.js +33 -40
- package/dist/aws/infra/documentation.js +8 -16
- package/dist/aws/infra/import-util.js +10 -18
- package/dist/aws/infra/scheduler.js +10 -14
- package/dist/aws/infra/security-rule.js +4 -8
- package/dist/aws/infra/sqs-integration.d.ts +1 -2
- package/dist/aws/infra/sqs-integration.js +11 -15
- package/dist/aws/infra/sqs-queue.d.ts +1 -1
- package/dist/aws/infra/sqs-queue.js +30 -35
- package/dist/aws/infra/stack/lambda-configs.d.ts +2 -2
- package/dist/aws/infra/stack/lambda-configs.js +14 -20
- package/dist/aws/infra/stack/monitoredfunction.d.ts +3 -3
- package/dist/aws/infra/stack/monitoredfunction.js +19 -27
- package/dist/aws/infra/stack/parameters.d.ts +1 -1
- package/dist/aws/infra/stack/parameters.js +5 -10
- package/dist/aws/infra/stack/rest_apis.d.ts +3 -3
- package/dist/aws/infra/stack/rest_apis.js +41 -54
- package/dist/aws/infra/stack/stack-checking-aspect.d.ts +1 -1
- package/dist/aws/infra/stack/stack-checking-aspect.js +24 -31
- package/dist/aws/infra/stack/stack.d.ts +3 -4
- package/dist/aws/infra/stack/stack.js +16 -20
- package/dist/aws/infra/stack/subscription.d.ts +2 -2
- package/dist/aws/infra/stack/subscription.js +5 -10
- package/dist/aws/infra/stacks/db-dns-stack.d.ts +2 -2
- package/dist/aws/infra/stacks/db-dns-stack.js +25 -29
- package/dist/aws/infra/stacks/db-proxy-stack.d.ts +2 -2
- package/dist/aws/infra/stacks/db-proxy-stack.js +23 -27
- package/dist/aws/infra/stacks/db-stack.d.ts +3 -4
- package/dist/aws/infra/stacks/db-stack.js +30 -34
- package/dist/aws/infra/stacks/intra-stack-configuration.js +1 -2
- package/dist/aws/infra/stacks/network-stack.d.ts +2 -2
- package/dist/aws/infra/stacks/network-stack.js +14 -18
- package/dist/aws/infra/usage-plans.js +2 -7
- package/dist/aws/runtime/apikey.js +3 -7
- package/dist/aws/runtime/digitraffic-integration-response.d.ts +1 -1
- package/dist/aws/runtime/digitraffic-integration-response.js +7 -11
- package/dist/aws/runtime/dt-logger-default.d.ts +2 -2
- package/dist/aws/runtime/dt-logger-default.js +2 -5
- package/dist/aws/runtime/dt-logger.d.ts +1 -1
- package/dist/aws/runtime/dt-logger.js +3 -10
- package/dist/aws/runtime/environment.js +3 -7
- package/dist/aws/runtime/messaging.js +1 -5
- package/dist/aws/runtime/s3.js +3 -7
- package/dist/aws/runtime/secrets/dbsecret.d.ts +1 -1
- package/dist/aws/runtime/secrets/dbsecret.js +5 -9
- package/dist/aws/runtime/secrets/proxy-holder.js +12 -16
- package/dist/aws/runtime/secrets/rds-holder.js +12 -16
- package/dist/aws/runtime/secrets/secret-holder.d.ts +1 -1
- package/dist/aws/runtime/secrets/secret-holder.js +9 -13
- package/dist/aws/runtime/secrets/secret.js +7 -11
- package/dist/aws/types/errors.js +5 -9
- package/dist/aws/types/lambda-response.js +3 -10
- package/dist/aws/types/mediatypes.js +2 -5
- package/dist/aws/types/model-with-reference.js +1 -2
- package/dist/aws/types/proxytypes.js +1 -2
- package/dist/aws/types/tags.js +2 -5
- package/dist/database/cached.d.ts +1 -1
- package/dist/database/cached.js +8 -14
- package/dist/database/database.js +14 -21
- package/dist/database/last-updated.d.ts +1 -1
- package/dist/database/last-updated.js +8 -17
- package/dist/database/models.js +1 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/marine/id_utils.js +3 -9
- package/dist/marine/rtz.js +1 -2
- package/dist/test/asserter.js +1 -5
- package/dist/test/db-testutils.d.ts +1 -1
- package/dist/test/db-testutils.js +8 -13
- package/dist/test/httpserver.js +10 -14
- package/dist/test/secrets-manager.js +9 -35
- package/dist/test/testutils.js +8 -19
- package/dist/types/async-timeout-error.js +1 -5
- package/dist/types/aws-env.js +1 -2
- package/dist/types/either.js +1 -2
- package/dist/types/http-error.js +1 -5
- package/dist/types/input-error.js +1 -5
- package/dist/types/language.js +2 -5
- package/dist/types/nullable.d.ts +1 -1
- package/dist/types/nullable.js +1 -2
- package/dist/types/traffictype.js +2 -5
- package/dist/types/urn.js +1 -2
- package/dist/types/util-types.js +1 -2
- package/dist/types/validator.js +4 -9
- package/dist/utils/api-model.d.ts +1 -1
- package/dist/utils/api-model.js +17 -27
- package/dist/utils/base64.d.ts +1 -1
- package/dist/utils/base64.js +2 -7
- package/dist/utils/date-utils.js +9 -16
- package/dist/utils/geojson-types.js +2 -7
- package/dist/utils/geometry.js +15 -48
- package/dist/utils/logging.d.ts +1 -1
- package/dist/utils/logging.js +8 -13
- package/dist/utils/retry.js +21 -26
- package/dist/utils/slack.js +7 -14
- package/dist/utils/utils.d.ts +2 -2
- package/dist/utils/utils.js +14 -29
- package/package.json +107 -18
- package/src/aws/infra/api/handler-factory.ts +3 -3
- package/src/aws/infra/api/integration.ts +2 -2
- package/src/aws/infra/api/response.ts +3 -3
- package/src/aws/infra/api/responses.ts +4 -4
- package/src/aws/infra/api/static-integration.ts +2 -2
- package/src/aws/infra/canaries/canary-alarm.ts +1 -1
- package/src/aws/infra/canaries/canary.ts +3 -3
- package/src/aws/infra/canaries/database-canary.ts +3 -3
- package/src/aws/infra/canaries/database-checker.ts +6 -6
- package/src/aws/infra/canaries/url-canary.ts +6 -6
- package/src/aws/infra/canaries/url-checker.ts +8 -8
- package/src/aws/infra/sqs-integration.ts +1 -1
- package/src/aws/infra/sqs-queue.ts +2 -2
- package/src/aws/infra/stack/lambda-configs.ts +2 -2
- package/src/aws/infra/stack/monitoredfunction.ts +4 -4
- package/src/aws/infra/stack/parameters.ts +1 -1
- package/src/aws/infra/stack/rest_apis.ts +6 -6
- package/src/aws/infra/stack/stack-checking-aspect.ts +1 -1
- package/src/aws/infra/stack/stack.ts +4 -5
- package/src/aws/infra/stack/subscription.ts +2 -2
- package/src/aws/infra/stacks/db-dns-stack.ts +4 -4
- package/src/aws/infra/stacks/db-proxy-stack.ts +5 -5
- package/src/aws/infra/stacks/db-stack.ts +5 -5
- package/src/aws/infra/stacks/network-stack.ts +3 -3
- package/src/aws/runtime/digitraffic-integration-response.ts +2 -2
- package/src/aws/runtime/dt-logger-default.ts +2 -2
- package/src/aws/runtime/secrets/dbsecret.ts +1 -1
- package/src/aws/runtime/secrets/proxy-holder.ts +4 -4
- package/src/aws/runtime/secrets/rds-holder.ts +4 -4
- package/src/aws/runtime/secrets/secret-holder.ts +4 -4
- package/src/aws/runtime/secrets/secret.ts +2 -2
- package/src/database/cached.ts +1 -1
- package/src/database/database.ts +3 -3
- package/src/database/last-updated.ts +1 -1
- package/src/index.ts +2 -0
- package/src/test/db-testutils.ts +2 -2
- package/src/test/secrets-manager.ts +2 -2
- package/src/types/nullable.ts +1 -1
- package/src/utils/api-model.ts +1 -1
- package/src/utils/geometry.ts +5 -3
- package/src/utils/logging.ts +2 -2
- package/src/utils/retry.ts +3 -3
- package/src/utils/slack.ts +2 -2
- package/src/utils/utils.ts +3 -3
@@ -1,12 +1,9 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
const import_util_1 = require("../import-util");
|
8
|
-
const core_1 = require("aws-cdk-lib/core");
|
9
|
-
const parameters_1 = require("../stack/parameters");
|
1
|
+
import { SecurityGroup, SubnetType, } from "aws-cdk-lib/aws-ec2";
|
2
|
+
import { CfnDBInstance, Credentials, DatabaseCluster, DatabaseClusterEngine, DatabaseClusterFromSnapshot, InstanceUpdateBehaviour, ParameterGroup, } from "aws-cdk-lib/aws-rds";
|
3
|
+
import { Secret } from "aws-cdk-lib/aws-secretsmanager";
|
4
|
+
import { exportValue, importVpc } from "../import-util.js";
|
5
|
+
import { Duration, RemovalPolicy, Stack } from "aws-cdk-lib/core";
|
6
|
+
import { createParameter } from "../stack/parameters.js";
|
10
7
|
/**
|
11
8
|
* Stack that creates DatabaseCluster.
|
12
9
|
*
|
@@ -16,7 +13,7 @@ const parameters_1 = require("../stack/parameters");
|
|
16
13
|
* You should deploy once with cluster and then without. This way you can create the cluster with this
|
17
14
|
* stack, but cluster is not part of the stack after that.
|
18
15
|
*/
|
19
|
-
class DbStack extends
|
16
|
+
export class DbStack extends Stack {
|
20
17
|
constructor(scope, id, isc, configuration) {
|
21
18
|
super(scope, id, {
|
22
19
|
env: isc.env,
|
@@ -30,23 +27,23 @@ class DbStack extends core_1.Stack {
|
|
30
27
|
// create cluster if this is wanted, should do it only once
|
31
28
|
if (configuration.cluster) {
|
32
29
|
const cluster = this.createAuroraCluster(isc, configuration, configuration.cluster, parameterGroups);
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
30
|
+
exportValue(this, isc.environmentName, DbStack.CLUSTER_IDENTIFIER_EXPORT_NAME, cluster.clusterIdentifier);
|
31
|
+
exportValue(this, isc.environmentName, DbStack.CLUSTER_WRITE_ENDPOINT_EXPORT_NAME, cluster.clusterEndpoint.hostname);
|
32
|
+
exportValue(this, isc.environmentName, DbStack.CLUSTER_READ_ENDPOINT_EXPORT_NAME, cluster.clusterReadEndpoint.hostname);
|
33
|
+
createParameter(this, "cluster.reader", cluster.clusterReadEndpoint.hostname);
|
34
|
+
createParameter(this, "cluster.writer", cluster.clusterEndpoint.hostname);
|
35
|
+
createParameter(this, "cluster.identifier", cluster.clusterIdentifier);
|
39
36
|
this.clusterIdentifier = cluster.clusterIdentifier;
|
40
37
|
}
|
41
38
|
if (configuration.clusterImport) {
|
42
|
-
|
43
|
-
|
39
|
+
createParameter(this, "cluster.reader", configuration.clusterImport.clusterReadEndpoint);
|
40
|
+
createParameter(this, "cluster.writer", configuration.clusterImport.clusterWriteEndpoint);
|
44
41
|
}
|
45
42
|
}
|
46
43
|
createParameterGroups(customVersions, workmem) {
|
47
44
|
return customVersions.map((version) => {
|
48
|
-
const pg = new
|
49
|
-
engine:
|
45
|
+
const pg = new ParameterGroup(this, `parameter-group-${version.auroraPostgresMajorVersion}`, {
|
46
|
+
engine: DatabaseClusterEngine.auroraPostgres({
|
50
47
|
version,
|
51
48
|
}),
|
52
49
|
parameters: {
|
@@ -62,22 +59,22 @@ class DbStack extends core_1.Stack {
|
|
62
59
|
});
|
63
60
|
}
|
64
61
|
createClusterParameters(secretArn, clusterConfiguration, instanceName, vpc, securityGroup, parameterGroup) {
|
65
|
-
const secret =
|
62
|
+
const secret = Secret.fromSecretCompleteArn(this, "DBSecret", secretArn);
|
66
63
|
return {
|
67
|
-
engine:
|
64
|
+
engine: DatabaseClusterEngine.auroraPostgres({
|
68
65
|
version: clusterConfiguration.dbVersion,
|
69
66
|
}),
|
70
67
|
instances: clusterConfiguration.instances,
|
71
|
-
instanceUpdateBehaviour:
|
68
|
+
instanceUpdateBehaviour: InstanceUpdateBehaviour.ROLLING,
|
72
69
|
instanceIdentifierBase: instanceName + "-",
|
73
70
|
cloudwatchLogsExports: ["postgresql"],
|
74
71
|
backup: {
|
75
|
-
retention:
|
72
|
+
retention: Duration.days(35),
|
76
73
|
preferredWindow: "01:00-02:00",
|
77
74
|
},
|
78
75
|
preferredMaintenanceWindow: "mon:03:00-mon:04:00",
|
79
76
|
deletionProtection: true,
|
80
|
-
removalPolicy:
|
77
|
+
removalPolicy: RemovalPolicy.RETAIN,
|
81
78
|
port: DbStack.CLUSTER_PORT,
|
82
79
|
instanceProps: {
|
83
80
|
autoMinorVersionUpgrade: true,
|
@@ -86,35 +83,35 @@ class DbStack extends core_1.Stack {
|
|
86
83
|
vpc,
|
87
84
|
securityGroups: [securityGroup],
|
88
85
|
vpcSubnets: {
|
89
|
-
subnetType:
|
86
|
+
subnetType: SubnetType.PRIVATE_WITH_EGRESS,
|
90
87
|
},
|
91
88
|
instanceType: clusterConfiguration.dbInstanceType,
|
92
89
|
parameterGroup,
|
93
90
|
},
|
94
|
-
credentials:
|
91
|
+
credentials: Credentials.fromPassword(secret.secretValueFromJson("db.superuser").unsafeUnwrap(), secret.secretValueFromJson("db.superuser.password")),
|
95
92
|
parameterGroup,
|
96
93
|
// storageEncrypted: clusterConfiguration.storageEncrypted ?? true,
|
97
|
-
monitoringInterval:
|
94
|
+
monitoringInterval: Duration.seconds(30),
|
98
95
|
};
|
99
96
|
}
|
100
97
|
createAuroraCluster(isc, configuration, clusterConfiguration, parameterGroups) {
|
101
98
|
const instanceName = isc.environmentName + "-db";
|
102
|
-
const securityGroup =
|
99
|
+
const securityGroup = SecurityGroup.fromSecurityGroupId(this, "securitygroup", clusterConfiguration.securityGroupId);
|
103
100
|
const vpc = configuration.vpc
|
104
101
|
? configuration.vpc
|
105
|
-
:
|
102
|
+
: importVpc(this, isc.environmentName);
|
106
103
|
const parameters = this.createClusterParameters(configuration.secretArn, clusterConfiguration, instanceName, vpc, securityGroup, parameterGroups[0]);
|
107
104
|
// create cluster from the snapshot or from the scratch
|
108
105
|
const cluster = clusterConfiguration.snapshotIdentifier
|
109
|
-
? new
|
106
|
+
? new DatabaseClusterFromSnapshot(this, instanceName, {
|
110
107
|
...parameters,
|
111
108
|
...{
|
112
109
|
snapshotIdentifier: clusterConfiguration.snapshotIdentifier,
|
113
110
|
},
|
114
111
|
})
|
115
|
-
: new
|
112
|
+
: new DatabaseCluster(this, instanceName, parameters);
|
116
113
|
// this workaround should prevent stack failing on version upgrade
|
117
|
-
const cfnInstances = cluster.node.children.filter((child) => child instanceof
|
114
|
+
const cfnInstances = cluster.node.children.filter((child) => child instanceof CfnDBInstance);
|
118
115
|
if (cfnInstances.length === 0) {
|
119
116
|
throw new Error("Couldn't pull CfnDBInstances from the L1 constructs!");
|
120
117
|
}
|
@@ -122,7 +119,6 @@ class DbStack extends core_1.Stack {
|
|
122
119
|
return cluster;
|
123
120
|
}
|
124
121
|
}
|
125
|
-
exports.DbStack = DbStack;
|
126
122
|
DbStack.CLUSTER_PORT = 5432;
|
127
123
|
DbStack.CLUSTER_IDENTIFIER_EXPORT_NAME = "db-cluster";
|
128
124
|
DbStack.CLUSTER_READ_ENDPOINT_EXPORT_NAME = "db-cluster-reader-endpoint";
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { IVpc, Vpc } from "aws-cdk-lib/aws-ec2";
|
2
|
-
import { InfraStackConfiguration } from "./intra-stack-configuration";
|
2
|
+
import { InfraStackConfiguration } from "./intra-stack-configuration.js";
|
3
3
|
import { Stack } from "aws-cdk-lib/core";
|
4
|
-
import { Construct } from "constructs/lib/construct";
|
4
|
+
import { Construct } from "constructs/lib/construct.js";
|
5
5
|
export interface NetworkConfiguration {
|
6
6
|
readonly vpcName: string;
|
7
7
|
readonly cidr: string;
|
@@ -1,44 +1,40 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
const import_util_1 = require("../import-util");
|
6
|
-
const core_1 = require("aws-cdk-lib/core");
|
7
|
-
class NetworkStack extends core_1.Stack {
|
1
|
+
import { IpAddresses, SubnetType, Vpc } from "aws-cdk-lib/aws-ec2";
|
2
|
+
import { exportValue } from "../import-util.js";
|
3
|
+
import { Stack } from "aws-cdk-lib/core";
|
4
|
+
export class NetworkStack extends Stack {
|
8
5
|
constructor(scope, id, isc, configuration) {
|
9
6
|
super(scope, id, {
|
10
7
|
env: isc.env,
|
11
8
|
});
|
12
9
|
this.vpc = this.createVpc(configuration);
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
10
|
+
exportValue(this, isc.environmentName, "VPCID", this.vpc.vpcId);
|
11
|
+
exportValue(this, isc.environmentName, "digitrafficpublicASubnet", this.vpc.publicSubnets[0].subnetId);
|
12
|
+
exportValue(this, isc.environmentName, "digitrafficpublicBSubnet", this.vpc.publicSubnets[1].subnetId);
|
13
|
+
exportValue(this, isc.environmentName, "digitrafficprivateASubnet", this.vpc.privateSubnets[0].subnetId);
|
14
|
+
exportValue(this, isc.environmentName, "digitrafficprivateBSubnet", this.vpc.privateSubnets[1].subnetId);
|
18
15
|
}
|
19
16
|
createVpc(configuration) {
|
20
|
-
return new
|
17
|
+
return new Vpc(this, "DigitrafficVPC", {
|
21
18
|
vpcName: configuration.vpcName,
|
22
|
-
availabilityZones:
|
19
|
+
availabilityZones: Stack.of(this)
|
23
20
|
.availabilityZones.sort()
|
24
21
|
.slice(0, 2), // take two first azs
|
25
22
|
enableDnsHostnames: true,
|
26
23
|
enableDnsSupport: true,
|
27
|
-
ipAddresses:
|
24
|
+
ipAddresses: IpAddresses.cidr(configuration.cidr),
|
28
25
|
subnetConfiguration: [
|
29
26
|
{
|
30
27
|
name: "public",
|
31
28
|
cidrMask: 24,
|
32
|
-
subnetType:
|
29
|
+
subnetType: SubnetType.PUBLIC,
|
33
30
|
},
|
34
31
|
{
|
35
32
|
name: "private",
|
36
33
|
cidrMask: 24,
|
37
|
-
subnetType:
|
34
|
+
subnetType: SubnetType.PRIVATE_WITH_EGRESS,
|
38
35
|
},
|
39
36
|
],
|
40
37
|
});
|
41
38
|
}
|
42
39
|
}
|
43
|
-
exports.NetworkStack = NetworkStack;
|
44
40
|
//# sourceMappingURL=network-stack.js.map
|
@@ -1,6 +1,3 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.createDefaultUsagePlan = exports.createUsagePlan = void 0;
|
4
1
|
/**
|
5
2
|
* Creates an usage plan for a REST API with a single API key
|
6
3
|
* @param api The REST API
|
@@ -8,7 +5,7 @@ exports.createDefaultUsagePlan = exports.createUsagePlan = void 0;
|
|
8
5
|
* @param apiKeyName Name for the API key, this is displayed in the AWS Console
|
9
6
|
* @deprecated Creates randomized API key names, use createDefaultUsagePlan instead
|
10
7
|
*/
|
11
|
-
function createUsagePlan(api, apiKeyId, apiKeyName) {
|
8
|
+
export function createUsagePlan(api, apiKeyId, apiKeyName) {
|
12
9
|
const apiKey = api.addApiKey(apiKeyId);
|
13
10
|
const plan = api.addUsagePlan(apiKeyName, {
|
14
11
|
name: apiKeyName,
|
@@ -19,14 +16,13 @@ function createUsagePlan(api, apiKeyId, apiKeyName) {
|
|
19
16
|
plan.addApiKey(apiKey);
|
20
17
|
return apiKey;
|
21
18
|
}
|
22
|
-
exports.createUsagePlan = createUsagePlan;
|
23
19
|
/**
|
24
20
|
* Creates a default usage plan for a REST API with a single API key
|
25
21
|
* @param api The REST API
|
26
22
|
* @param apiName Name of the api. Will generate key: apiName + ' API Key' and plan: apiName + ' API Usage Plan'
|
27
23
|
* @param value Optional value for the API key
|
28
24
|
*/
|
29
|
-
function createDefaultUsagePlan(api, apiName, value) {
|
25
|
+
export function createDefaultUsagePlan(api, apiName, value) {
|
30
26
|
const apiKeyName = apiName + " API Key";
|
31
27
|
const usagePlanName = apiName + " API Usage Plan";
|
32
28
|
const apiKey = api.addApiKey(apiKeyName, { apiKeyName: apiKeyName, value });
|
@@ -39,5 +35,4 @@ function createDefaultUsagePlan(api, apiName, value) {
|
|
39
35
|
plan.addApiKey(apiKey);
|
40
36
|
return apiKey;
|
41
37
|
}
|
42
|
-
exports.createDefaultUsagePlan = createDefaultUsagePlan;
|
43
38
|
//# sourceMappingURL=usage-plans.js.map
|
@@ -1,13 +1,9 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
const aws_sdk_1 = require("aws-sdk");
|
5
|
-
function getApiKeyFromAPIGateway(keyId) {
|
6
|
-
const agw = new aws_sdk_1.APIGateway();
|
1
|
+
import { APIGateway } from "aws-sdk";
|
2
|
+
export function getApiKeyFromAPIGateway(keyId) {
|
3
|
+
const agw = new APIGateway();
|
7
4
|
return agw.getApiKey({
|
8
5
|
apiKey: keyId,
|
9
6
|
includeValue: true,
|
10
7
|
}).promise();
|
11
8
|
}
|
12
|
-
exports.getApiKeyFromAPIGateway = getApiKeyFromAPIGateway;
|
13
9
|
//# sourceMappingURL=apikey.js.map
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { IntegrationResponse } from "aws-cdk-lib/aws-apigateway";
|
2
|
-
import { MediaType } from "../types/mediatypes";
|
2
|
+
import { MediaType } from "../types/mediatypes.js";
|
3
3
|
export declare abstract class DigitrafficIntegrationResponse {
|
4
4
|
static ok(mediaType: MediaType, sunset?: string): IntegrationResponse;
|
5
5
|
static badRequest(mediaType?: MediaType): IntegrationResponse;
|
@@ -1,28 +1,24 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
const mediatypes_1 = require("../types/mediatypes");
|
5
|
-
const response_1 = require("../infra/api/response");
|
6
|
-
class DigitrafficIntegrationResponse {
|
1
|
+
import { MediaType } from "../types/mediatypes.js";
|
2
|
+
import { getDeprecatedDefaultLambdaResponse, RESPONSE_DEFAULT_LAMBDA, } from "../infra/api/response.js";
|
3
|
+
export class DigitrafficIntegrationResponse {
|
7
4
|
static ok(mediaType, sunset) {
|
8
5
|
return this.create("200", mediaType, sunset);
|
9
6
|
}
|
10
7
|
static badRequest(mediaType) {
|
11
|
-
return this.create("400", mediaType ??
|
8
|
+
return this.create("400", mediaType ?? MediaType.TEXT_PLAIN);
|
12
9
|
}
|
13
10
|
static notImplemented(mediaType) {
|
14
|
-
return this.create("501", mediaType ??
|
11
|
+
return this.create("501", mediaType ?? MediaType.TEXT_PLAIN);
|
15
12
|
}
|
16
13
|
static create(statusCode, mediaType, sunset) {
|
17
14
|
return {
|
18
15
|
statusCode,
|
19
16
|
responseTemplates: {
|
20
17
|
[mediaType]: sunset
|
21
|
-
?
|
22
|
-
:
|
18
|
+
? getDeprecatedDefaultLambdaResponse(sunset)
|
19
|
+
: RESPONSE_DEFAULT_LAMBDA,
|
23
20
|
},
|
24
21
|
};
|
25
22
|
}
|
26
23
|
}
|
27
|
-
exports.DigitrafficIntegrationResponse = DigitrafficIntegrationResponse;
|
28
24
|
//# sourceMappingURL=digitraffic-integration-response.js.map
|
@@ -1,8 +1,8 @@
|
|
1
|
-
import { DtLogger } from "./dt-logger";
|
1
|
+
import { DtLogger } from "./dt-logger.js";
|
2
2
|
/**
|
3
3
|
* You can use this for method name definition to match DtLogger LoggableType.method parameter.
|
4
4
|
*/
|
5
|
-
export type { LoggerMethodType } from "./dt-logger";
|
5
|
+
export type { LoggerMethodType } from "./dt-logger.js";
|
6
6
|
/**
|
7
7
|
* You can use this for your logging needs or create one locally and configure it as you wish.
|
8
8
|
*/
|
@@ -1,9 +1,6 @@
|
|
1
|
-
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.logger = void 0;
|
4
|
-
const dt_logger_1 = require("./dt-logger");
|
1
|
+
import { DtLogger } from "./dt-logger.js";
|
5
2
|
/**
|
6
3
|
* You can use this for your logging needs or create one locally and configure it as you wish.
|
7
4
|
*/
|
8
|
-
|
5
|
+
export const logger = new DtLogger();
|
9
6
|
//# sourceMappingURL=dt-logger-default.js.map
|
@@ -1,10 +1,4 @@
|
|
1
|
-
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
-
};
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
exports.DtLogger = void 0;
|
7
|
-
const lodash_1 = __importDefault(require("lodash"));
|
1
|
+
import _ from "lodash";
|
8
2
|
/**
|
9
3
|
* Helper class for json-logging.
|
10
4
|
*
|
@@ -14,7 +8,7 @@ const lodash_1 = __importDefault(require("lodash"));
|
|
14
8
|
* * runtime (taken from process environment)
|
15
9
|
* * the actual message (as json or as string)
|
16
10
|
*/
|
17
|
-
class DtLogger {
|
11
|
+
export class DtLogger {
|
18
12
|
/**
|
19
13
|
* Create a new Logger instance.
|
20
14
|
* @constructor
|
@@ -100,8 +94,7 @@ class DtLogger {
|
|
100
94
|
this.writeStream.write(JSON.stringify(logMessage) + "\n");
|
101
95
|
}
|
102
96
|
}
|
103
|
-
exports.DtLogger = DtLogger;
|
104
97
|
function removePrefix(prefix, loggable) {
|
105
|
-
return
|
98
|
+
return _.mapKeys(loggable, (_index, key) => key.startsWith(prefix) ? _.lowerFirst(key.replace(prefix, "")) : key);
|
106
99
|
}
|
107
100
|
//# sourceMappingURL=dt-logger.js.map
|
@@ -1,16 +1,13 @@
|
|
1
|
-
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.envValue = exports.EnvKeys = void 0;
|
4
|
-
var EnvKeys;
|
1
|
+
export var EnvKeys;
|
5
2
|
(function (EnvKeys) {
|
6
3
|
EnvKeys["AWS_REGION"] = "AWS_REGION";
|
7
4
|
EnvKeys["SECRET_ID"] = "SECRET_ID";
|
8
5
|
EnvKeys["SECRET_OVERRIDE_AWS_REGION"] = "SECRET_OVERRIDE_AWS_REGION";
|
9
|
-
})(EnvKeys || (
|
6
|
+
})(EnvKeys || (EnvKeys = {}));
|
10
7
|
/**
|
11
8
|
* @deprecated Use digitraffic/common/utils/utils#getEnvVariable
|
12
9
|
*/
|
13
|
-
function envValue(key, defaultValue) {
|
10
|
+
export function envValue(key, defaultValue) {
|
14
11
|
const value = process.env[key];
|
15
12
|
if (value == null) {
|
16
13
|
if (defaultValue) {
|
@@ -20,5 +17,4 @@ function envValue(key, defaultValue) {
|
|
20
17
|
}
|
21
18
|
return value;
|
22
19
|
}
|
23
|
-
exports.envValue = envValue;
|
24
20
|
//# sourceMappingURL=environment.js.map
|
@@ -1,6 +1,3 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.snsPublish = void 0;
|
4
1
|
/**
|
5
2
|
* Utility function for publishing SNS messages.
|
6
3
|
* Made because using *await* with AWS APIs doesn't require calling promise() but nothing works if it isn't called.
|
@@ -9,7 +6,7 @@ exports.snsPublish = void 0;
|
|
9
6
|
* @param topicArn
|
10
7
|
* @param sns
|
11
8
|
*/
|
12
|
-
async function snsPublish(message, topicArn, sns) {
|
9
|
+
export async function snsPublish(message, topicArn, sns) {
|
13
10
|
const publishParams = {
|
14
11
|
Message: message,
|
15
12
|
TopicArn: topicArn,
|
@@ -27,5 +24,4 @@ async function snsPublish(message, topicArn, sns) {
|
|
27
24
|
}
|
28
25
|
}
|
29
26
|
}
|
30
|
-
exports.snsPublish = snsPublish;
|
31
27
|
//# sourceMappingURL=messaging.js.map
|
package/dist/aws/runtime/s3.js
CHANGED
@@ -1,9 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
const aws_sdk_1 = require("aws-sdk");
|
5
|
-
async function uploadToS3(bucketName, body, objectName, cannedAcl, contentType) {
|
6
|
-
const s3 = new aws_sdk_1.S3();
|
1
|
+
import { S3 } from "aws-sdk";
|
2
|
+
export async function uploadToS3(bucketName, body, objectName, cannedAcl, contentType) {
|
3
|
+
const s3 = new S3();
|
7
4
|
try {
|
8
5
|
await doUpload(s3, bucketName, body, objectName, cannedAcl, contentType);
|
9
6
|
}
|
@@ -17,7 +14,6 @@ async function uploadToS3(bucketName, body, objectName, cannedAcl, contentType)
|
|
17
14
|
}
|
18
15
|
}
|
19
16
|
}
|
20
|
-
exports.uploadToS3 = uploadToS3;
|
21
17
|
function doUpload(s3, bucketName, body, filename, cannedAcl, contentType) {
|
22
18
|
return s3.upload({
|
23
19
|
Bucket: bucketName,
|
@@ -1,26 +1,22 @@
|
|
1
|
-
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.checkExpectedSecretKeys = exports.RdsSecretKey = exports.RdsProxySecretKey = void 0;
|
4
|
-
var RdsProxySecretKey;
|
1
|
+
export var RdsProxySecretKey;
|
5
2
|
(function (RdsProxySecretKey) {
|
6
3
|
RdsProxySecretKey["username"] = "username";
|
7
4
|
RdsProxySecretKey["password"] = "password";
|
8
5
|
RdsProxySecretKey["proxy_host"] = "proxy_host";
|
9
6
|
RdsProxySecretKey["proxy_ro_host"] = "proxy_ro_host";
|
10
|
-
})(RdsProxySecretKey || (
|
11
|
-
var RdsSecretKey;
|
7
|
+
})(RdsProxySecretKey || (RdsProxySecretKey = {}));
|
8
|
+
export var RdsSecretKey;
|
12
9
|
(function (RdsSecretKey) {
|
13
10
|
RdsSecretKey["username"] = "username";
|
14
11
|
RdsSecretKey["password"] = "password";
|
15
12
|
RdsSecretKey["host"] = "host";
|
16
13
|
RdsSecretKey["ro_host"] = "ro_host";
|
17
|
-
})(RdsSecretKey || (
|
18
|
-
function checkExpectedSecretKeys(keys, secret) {
|
14
|
+
})(RdsSecretKey || (RdsSecretKey = {}));
|
15
|
+
export function checkExpectedSecretKeys(keys, secret) {
|
19
16
|
const missingKeys = keys.filter((key) => !(key in secret));
|
20
17
|
if (missingKeys.length) {
|
21
18
|
console.error(`method=checkExpectedSecretKeys secret didn't contain the key(s) ${missingKeys.toString()}`);
|
22
19
|
throw new Error("Expected keys were not found");
|
23
20
|
}
|
24
21
|
}
|
25
|
-
exports.checkExpectedSecretKeys = checkExpectedSecretKeys;
|
26
22
|
//# sourceMappingURL=dbsecret.js.map
|
@@ -1,28 +1,24 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
const
|
6
|
-
const utils_1 = require("../../../utils/utils");
|
7
|
-
const database_1 = require("../../../database/database");
|
8
|
-
const RDS_PROXY_SECRET_KEYS = Object.values(dbsecret_1.RdsProxySecretKey);
|
1
|
+
import { SecretHolder } from "./secret-holder.js";
|
2
|
+
import { RdsProxySecretKey } from "./dbsecret.js";
|
3
|
+
import { getEnvVariable } from "../../../utils/utils.js";
|
4
|
+
import { DatabaseEnvironmentKeys } from "../../../database/database.js";
|
5
|
+
const RDS_PROXY_SECRET_KEYS = Object.values(RdsProxySecretKey);
|
9
6
|
/**
|
10
7
|
* Holds credentials for RDS Proxy access.
|
11
8
|
*/
|
12
|
-
class ProxyHolder {
|
9
|
+
export class ProxyHolder {
|
13
10
|
constructor(secretId) {
|
14
|
-
this.secretHolder = new
|
11
|
+
this.secretHolder = new SecretHolder(secretId, "", RDS_PROXY_SECRET_KEYS);
|
15
12
|
}
|
16
13
|
static create() {
|
17
|
-
return new ProxyHolder(
|
14
|
+
return new ProxyHolder(getEnvVariable("SECRET_ID"));
|
18
15
|
}
|
19
16
|
async setCredentials() {
|
20
17
|
const secret = await this.secretHolder.get();
|
21
|
-
process.env[
|
22
|
-
process.env[
|
23
|
-
process.env[
|
24
|
-
process.env[
|
18
|
+
process.env[DatabaseEnvironmentKeys.DB_USER] = secret.username;
|
19
|
+
process.env[DatabaseEnvironmentKeys.DB_PASS] = secret.password;
|
20
|
+
process.env[DatabaseEnvironmentKeys.DB_URI] = secret.proxy_host;
|
21
|
+
process.env[DatabaseEnvironmentKeys.DB_RO_URI] = secret.proxy_ro_host;
|
25
22
|
}
|
26
23
|
}
|
27
|
-
exports.ProxyHolder = ProxyHolder;
|
28
24
|
//# sourceMappingURL=proxy-holder.js.map
|
@@ -1,28 +1,24 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
const
|
6
|
-
const utils_1 = require("../../../utils/utils");
|
7
|
-
const database_1 = require("../../../database/database");
|
8
|
-
const RDS_SECRET_KEYS = Object.values(dbsecret_1.RdsSecretKey);
|
1
|
+
import { SecretHolder } from "./secret-holder.js";
|
2
|
+
import { RdsSecretKey } from "./dbsecret.js";
|
3
|
+
import { getEnvVariable } from "../../../utils/utils.js";
|
4
|
+
import { DatabaseEnvironmentKeys } from "../../../database/database.js";
|
5
|
+
const RDS_SECRET_KEYS = Object.values(RdsSecretKey);
|
9
6
|
/**
|
10
7
|
* Holds credentials for RDS access.
|
11
8
|
*/
|
12
|
-
class RdsHolder {
|
9
|
+
export class RdsHolder {
|
13
10
|
constructor(secretId) {
|
14
|
-
this.secretHolder = new
|
11
|
+
this.secretHolder = new SecretHolder(secretId, "", RDS_SECRET_KEYS);
|
15
12
|
}
|
16
13
|
static create() {
|
17
|
-
return new RdsHolder(
|
14
|
+
return new RdsHolder(getEnvVariable("SECRET_ID"));
|
18
15
|
}
|
19
16
|
async setCredentials() {
|
20
17
|
const secret = await this.secretHolder.get();
|
21
|
-
process.env[
|
22
|
-
process.env[
|
23
|
-
process.env[
|
24
|
-
process.env[
|
18
|
+
process.env[DatabaseEnvironmentKeys.DB_USER] = secret.username;
|
19
|
+
process.env[DatabaseEnvironmentKeys.DB_PASS] = secret.password;
|
20
|
+
process.env[DatabaseEnvironmentKeys.DB_URI] = secret.host;
|
21
|
+
process.env[DatabaseEnvironmentKeys.DB_RO_URI] = secret.ro_host;
|
25
22
|
}
|
26
23
|
}
|
27
|
-
exports.RdsHolder = RdsHolder;
|
28
24
|
//# sourceMappingURL=rds-holder.js.map
|