@digitraffic/common 2024.1.24-3 → 2024.1.30-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__/api/handler-factory.test.d.mts +1 -0
- package/dist/__test__/api/handler-factory.test.mjs +43 -0
- package/dist/__test__/api/response.test.d.mts +1 -0
- package/dist/__test__/api/response.test.mjs +86 -0
- package/dist/__test__/imports.test.d.mts +1 -0
- package/dist/__test__/imports.test.mjs +332 -0
- package/dist/__test__/marine/id_utils.test.d.mts +1 -0
- package/dist/__test__/marine/id_utils.test.mjs +44 -0
- package/dist/__test__/promise/promise.test.d.mts +1 -0
- package/dist/__test__/promise/promise.test.mjs +130 -0
- package/dist/__test__/runtime/dt-logger.test.d.mts +1 -0
- package/dist/__test__/runtime/dt-logger.test.mjs +108 -0
- package/dist/__test__/secrets/secret-holder.test.d.mts +1 -0
- package/dist/__test__/secrets/secret-holder.test.mjs +89 -0
- package/dist/__test__/secrets/secret.test.d.mts +1 -0
- package/dist/__test__/secrets/secret.test.mjs +42 -0
- package/dist/__test__/test/httpserver.test.d.mts +1 -0
- package/dist/__test__/test/httpserver.test.mjs +154 -0
- package/dist/__test__/types/lambda-response.test.d.mts +1 -0
- package/dist/__test__/types/lambda-response.test.mjs +58 -0
- package/dist/__test__/utils/date-utils.test.d.mts +1 -0
- package/dist/__test__/utils/date-utils.test.mjs +27 -0
- package/dist/__test__/utils/geometry.test.d.mts +1 -0
- package/dist/__test__/utils/geometry.test.mjs +24 -0
- package/dist/__test__/utils/logging.test.d.mts +1 -0
- package/dist/__test__/utils/logging.test.mjs +78 -0
- package/dist/__test__/utils/utils.test.d.mts +1 -0
- package/dist/__test__/utils/utils.test.mjs +43 -0
- package/dist/aws/infra/api/handler-factory.mjs +4 -0
- package/dist/aws/infra/api/integration.d.mts +2 -2
- package/dist/aws/infra/api/integration.mjs +4 -1
- package/dist/aws/infra/api/response.d.mts +1 -1
- package/dist/aws/infra/api/responses.d.mts +1 -1
- package/dist/aws/infra/api/responses.mjs +2 -0
- package/dist/aws/infra/api/static-integration.mjs +1 -1
- package/dist/aws/infra/canaries/canary-alarm.d.mts +1 -1
- package/dist/aws/infra/canaries/canary-alarm.mjs +2 -0
- package/dist/aws/infra/canaries/canary-parameters.mjs +1 -1
- package/dist/aws/infra/canaries/canary-role.mjs +1 -0
- package/dist/aws/infra/canaries/canary.d.mts +2 -2
- package/dist/aws/infra/canaries/canary.mjs +2 -0
- package/dist/aws/infra/canaries/database-canary.d.mts +2 -2
- package/dist/aws/infra/canaries/database-canary.mjs +2 -0
- package/dist/aws/infra/canaries/database-checker.d.mts +1 -1
- package/dist/aws/infra/canaries/database-checker.mjs +7 -1
- package/dist/aws/infra/canaries/url-canary.d.mts +2 -2
- package/dist/aws/infra/canaries/url-canary.mjs +3 -0
- package/dist/aws/infra/canaries/url-checker.d.mts +1 -1
- package/dist/aws/infra/canaries/url-checker.mjs +4 -1
- package/dist/aws/infra/documentation.mjs +5 -1
- package/dist/aws/infra/import-util.d.mts +1 -1
- package/dist/aws/infra/import-util.mjs +4 -3
- package/dist/aws/infra/scheduler.mjs +2 -0
- package/dist/aws/infra/security-rule.d.mts +1 -1
- package/dist/aws/infra/security-rule.mjs +1 -0
- package/dist/aws/infra/sqs-integration.d.mts +1 -1
- package/dist/aws/infra/sqs-integration.mjs +3 -1
- package/dist/aws/infra/sqs-queue.d.mts +1 -1
- package/dist/aws/infra/sqs-queue.mjs +2 -1
- package/dist/aws/infra/stack/lambda-configs.d.mts +4 -4
- package/dist/aws/infra/stack/lambda-configs.mjs +4 -2
- package/dist/aws/infra/stack/monitoredfunction.d.mts +3 -3
- package/dist/aws/infra/stack/monitoredfunction.mjs +20 -16
- package/dist/aws/infra/stack/parameters.mjs +1 -0
- package/dist/aws/infra/stack/rest_apis.d.mts +2 -2
- package/dist/aws/infra/stack/rest_apis.mjs +6 -1
- package/dist/aws/infra/stack/stack-checking-aspect.d.mts +2 -2
- package/dist/aws/infra/stack/stack-checking-aspect.mjs +6 -1
- package/dist/aws/infra/stack/stack.d.mts +5 -5
- package/dist/aws/infra/stack/stack.mjs +9 -0
- package/dist/aws/infra/stack/subscription.mjs +4 -0
- package/dist/aws/infra/stacks/db-dns-stack.d.mts +1 -1
- package/dist/aws/infra/stacks/db-dns-stack.mjs +1 -0
- package/dist/aws/infra/stacks/db-proxy-stack.d.mts +3 -3
- package/dist/aws/infra/stacks/db-proxy-stack.mjs +4 -2
- package/dist/aws/infra/stacks/db-stack.d.mts +3 -3
- package/dist/aws/infra/stacks/db-stack.mjs +11 -7
- package/dist/aws/infra/stacks/intra-stack-configuration.d.mts +1 -1
- package/dist/aws/infra/stacks/network-stack.d.mts +2 -2
- package/dist/aws/infra/stacks/network-stack.mjs +8 -0
- package/dist/aws/infra/usage-plans.d.mts +1 -1
- package/dist/aws/infra/usage-plans.mjs +1 -0
- package/dist/aws/runtime/apikey.d.mts +2 -2
- package/dist/aws/runtime/apikey.mjs +2 -1
- package/dist/aws/runtime/digitraffic-integration-response.d.mts +1 -1
- package/dist/aws/runtime/dt-logger.mjs +6 -2
- package/dist/aws/runtime/messaging.d.mts +2 -2
- package/dist/aws/runtime/s3.d.mts +2 -2
- package/dist/aws/runtime/s3.mjs +2 -1
- package/dist/aws/runtime/secrets/dbsecret.d.mts +1 -1
- package/dist/aws/runtime/secrets/proxy-holder.mjs +1 -0
- package/dist/aws/runtime/secrets/rds-holder.mjs +1 -0
- package/dist/aws/runtime/secrets/secret-holder.d.mts +1 -1
- package/dist/aws/runtime/secrets/secret-holder.mjs +6 -1
- package/dist/aws/runtime/secrets/secret.mjs +4 -2
- package/dist/aws/types/errors.mjs +1 -0
- package/dist/aws/types/lambda-response.mjs +5 -0
- package/dist/aws/types/model-with-reference.mjs +1 -1
- package/dist/database/cached.d.mts +1 -1
- package/dist/database/database.mjs +1 -0
- package/dist/database/last-updated.d.mts +1 -1
- package/dist/test/db-testutils.d.mts +1 -1
- package/dist/test/db-testutils.mjs +1 -1
- package/dist/test/httpserver.mjs +7 -3
- package/dist/test/secrets-manager.d.mts +1 -1
- package/dist/test/secrets-manager.mjs +1 -1
- package/dist/test/testutils.mjs +1 -1
- package/dist/types/http-error.mjs +1 -0
- package/dist/types/nullable.d.mts +1 -1
- package/dist/utils/api-model.d.mts +2 -2
- package/dist/utils/api-model.mjs +1 -1
- package/dist/utils/geojson-types.d.mts +1 -1
- package/dist/utils/geojson-types.mjs +4 -2
- package/dist/utils/geometry.d.mts +1 -1
- package/dist/utils/geometry.mjs +3 -0
- package/dist/utils/retry.d.mts +2 -2
- package/dist/utils/retry.mjs +2 -2
- package/dist/utils/slack.mjs +1 -0
- package/dist/utils/utils.d.mts +2 -2
- package/package.json +11 -6
- package/src/@types/geojson-validation/index.d.mts +0 -4
- package/src/aws/infra/api/handler-factory.mts +0 -86
- package/src/aws/infra/api/integration.mts +0 -147
- package/src/aws/infra/api/response.mts +0 -165
- package/src/aws/infra/api/responses.mts +0 -127
- package/src/aws/infra/api/static-integration.mts +0 -108
- package/src/aws/infra/canaries/Synthetics.d.mts +0 -21
- package/src/aws/infra/canaries/canary-alarm.mts +0 -33
- package/src/aws/infra/canaries/canary-keys.mts +0 -3
- package/src/aws/infra/canaries/canary-parameters.mts +0 -19
- package/src/aws/infra/canaries/canary-role.mts +0 -73
- package/src/aws/infra/canaries/canary.mts +0 -44
- package/src/aws/infra/canaries/database-canary.mts +0 -98
- package/src/aws/infra/canaries/database-checker.mts +0 -163
- package/src/aws/infra/canaries/url-canary.mts +0 -98
- package/src/aws/infra/canaries/url-checker.mts +0 -388
- package/src/aws/infra/documentation.mts +0 -142
- package/src/aws/infra/import-util.mts +0 -57
- package/src/aws/infra/scheduler.mts +0 -59
- package/src/aws/infra/security-rule.mts +0 -38
- package/src/aws/infra/sqs-integration.mts +0 -106
- package/src/aws/infra/sqs-queue.mts +0 -162
- package/src/aws/infra/stack/lambda-configs.mts +0 -135
- package/src/aws/infra/stack/monitoredfunction.mts +0 -352
- package/src/aws/infra/stack/parameters.mts +0 -74
- package/src/aws/infra/stack/rest_apis.mts +0 -322
- package/src/aws/infra/stack/stack-checking-aspect.mts +0 -233
- package/src/aws/infra/stack/stack.mts +0 -144
- package/src/aws/infra/stack/subscription.mts +0 -58
- package/src/aws/infra/stacks/db-dns-stack.mts +0 -77
- package/src/aws/infra/stacks/db-proxy-stack.mts +0 -134
- package/src/aws/infra/stacks/db-stack.mts +0 -292
- package/src/aws/infra/stacks/intra-stack-configuration.mts +0 -6
- package/src/aws/infra/stacks/network-stack.mts +0 -76
- package/src/aws/infra/usage-plans.mts +0 -50
- package/src/aws/runtime/apikey.mts +0 -9
- package/src/aws/runtime/digitraffic-integration-response.mts +0 -35
- package/src/aws/runtime/dt-logger-default.mts +0 -11
- package/src/aws/runtime/dt-logger.mts +0 -184
- package/src/aws/runtime/environment.mts +0 -22
- package/src/aws/runtime/messaging.mts +0 -26
- package/src/aws/runtime/s3.mts +0 -44
- package/src/aws/runtime/secrets/dbsecret.mts +0 -31
- package/src/aws/runtime/secrets/node-ttl.d.mts +0 -12
- package/src/aws/runtime/secrets/proxy-holder.mts +0 -34
- package/src/aws/runtime/secrets/rds-holder.mts +0 -34
- package/src/aws/runtime/secrets/secret-holder.mts +0 -106
- package/src/aws/runtime/secrets/secret.mts +0 -58
- package/src/aws/types/errors.mts +0 -14
- package/src/aws/types/lambda-response.mts +0 -100
- package/src/aws/types/mediatypes.mts +0 -12
- package/src/aws/types/model-with-reference.mts +0 -8
- package/src/aws/types/proxytypes.mts +0 -27
- package/src/aws/types/tags.mts +0 -3
- package/src/database/cached.mts +0 -64
- package/src/database/database.mts +0 -107
- package/src/database/last-updated.mts +0 -103
- package/src/database/models.mts +0 -7
- package/src/index.mts +0 -2
- package/src/marine/id_utils.mts +0 -30
- package/src/marine/rtz.mts +0 -57
- package/src/test/asserter.mts +0 -58
- package/src/test/db-testutils.mts +0 -52
- package/src/test/httpserver.mts +0 -111
- package/src/test/secrets-manager.mts +0 -37
- package/src/test/testutils.mts +0 -39
- package/src/types/async-timeout-error.mts +0 -5
- package/src/types/aws-env.mts +0 -3
- package/src/types/either.mts +0 -9
- package/src/types/http-error.mts +0 -8
- package/src/types/input-error.mts +0 -2
- package/src/types/language.mts +0 -3
- package/src/types/nullable.mts +0 -21
- package/src/types/traffictype.mts +0 -8
- package/src/types/urn.mts +0 -1
- package/src/types/util-types.mts +0 -10
- package/src/types/validator.mts +0 -10
- package/src/utils/api-model.mts +0 -133
- package/src/utils/base64.mts +0 -16
- package/src/utils/date-utils.mts +0 -53
- package/src/utils/geojson-types.mts +0 -22
- package/src/utils/geometry.mts +0 -171
- package/src/utils/logging.mts +0 -75
- package/src/utils/retry.mts +0 -200
- package/src/utils/slack.mts +0 -26
- package/src/utils/utils.mts +0 -184
@@ -1,7 +1,7 @@
|
|
1
|
-
import { InstanceType, IVpc, type ISecurityGroup } from "aws-cdk-lib/aws-ec2";
|
2
|
-
import { AuroraPostgresEngineVersion, DatabaseCluster, DatabaseClusterProps, IParameterGroup } from "aws-cdk-lib/aws-rds";
|
1
|
+
import { InstanceType, type IVpc, type ISecurityGroup } from "aws-cdk-lib/aws-ec2";
|
2
|
+
import { AuroraPostgresEngineVersion, DatabaseCluster, type DatabaseClusterProps, type IParameterGroup } from "aws-cdk-lib/aws-rds";
|
3
3
|
import { Construct } from "constructs/lib/construct.js";
|
4
|
-
import { InfraStackConfiguration } from "./intra-stack-configuration.mjs";
|
4
|
+
import type { InfraStackConfiguration } from "./intra-stack-configuration.mjs";
|
5
5
|
import { Stack } from "aws-cdk-lib/core";
|
6
6
|
export interface DbConfiguration {
|
7
7
|
readonly cluster?: ClusterConfiguration;
|
@@ -1,5 +1,6 @@
|
|
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";
|
1
|
+
import { InstanceType, SecurityGroup, SubnetType, } from "aws-cdk-lib/aws-ec2";
|
2
|
+
import { AuroraPostgresEngineVersion, CfnDBInstance, Credentials, DatabaseCluster, DatabaseClusterEngine, DatabaseClusterFromSnapshot, InstanceUpdateBehaviour, ParameterGroup, } from "aws-cdk-lib/aws-rds";
|
3
|
+
import { Construct } from "constructs/lib/construct.js";
|
3
4
|
import { Secret } from "aws-cdk-lib/aws-secretsmanager";
|
4
5
|
import { exportValue, importVpc } from "../import-util.mjs";
|
5
6
|
import { Duration, RemovalPolicy, Stack } from "aws-cdk-lib/core";
|
@@ -14,11 +15,15 @@ import { createParameter } from "../stack/parameters.mjs";
|
|
14
15
|
* stack, but cluster is not part of the stack after that.
|
15
16
|
*/
|
16
17
|
export class DbStack extends Stack {
|
18
|
+
static CLUSTER_PORT = 5432;
|
19
|
+
static CLUSTER_IDENTIFIER_EXPORT_NAME = "db-cluster";
|
20
|
+
static CLUSTER_READ_ENDPOINT_EXPORT_NAME = "db-cluster-reader-endpoint";
|
21
|
+
static CLUSTER_WRITE_ENDPOINT_EXPORT_NAME = "db-cluster-writer-endpoint";
|
22
|
+
clusterIdentifier = "";
|
17
23
|
constructor(scope, id, isc, configuration) {
|
18
24
|
super(scope, id, {
|
19
25
|
env: isc.env,
|
20
26
|
});
|
21
|
-
this.clusterIdentifier = "";
|
22
27
|
const parameterGroups = this.createParameterGroups(configuration.customParameterGroups, configuration.workmem ?? 524288);
|
23
28
|
if ((configuration.cluster && configuration.clusterImport) ||
|
24
29
|
(!configuration.cluster && !configuration.clusterImport)) {
|
@@ -100,6 +105,9 @@ export class DbStack extends Stack {
|
|
100
105
|
const vpc = configuration.vpc
|
101
106
|
? configuration.vpc
|
102
107
|
: importVpc(this, isc.environmentName);
|
108
|
+
if (parameterGroups[0] === undefined) {
|
109
|
+
throw Error('ParameterGroups should not be empty');
|
110
|
+
}
|
103
111
|
const parameters = this.createClusterParameters(configuration.secretArn, clusterConfiguration, instanceName, vpc, securityGroup, parameterGroups[0]);
|
104
112
|
// create cluster from the snapshot or from the scratch
|
105
113
|
const cluster = clusterConfiguration.snapshotIdentifier
|
@@ -119,8 +127,4 @@ export class DbStack extends Stack {
|
|
119
127
|
return cluster;
|
120
128
|
}
|
121
129
|
}
|
122
|
-
DbStack.CLUSTER_PORT = 5432;
|
123
|
-
DbStack.CLUSTER_IDENTIFIER_EXPORT_NAME = "db-cluster";
|
124
|
-
DbStack.CLUSTER_READ_ENDPOINT_EXPORT_NAME = "db-cluster-reader-endpoint";
|
125
|
-
DbStack.CLUSTER_WRITE_ENDPOINT_EXPORT_NAME = "db-cluster-writer-endpoint";
|
126
130
|
//# sourceMappingURL=db-stack.mjs.map
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import { IVpc, Vpc } from "aws-cdk-lib/aws-ec2";
|
2
|
-
import { InfraStackConfiguration } from "./intra-stack-configuration.mjs";
|
1
|
+
import { type IVpc, Vpc } from "aws-cdk-lib/aws-ec2";
|
2
|
+
import type { InfraStackConfiguration } from "./intra-stack-configuration.mjs";
|
3
3
|
import { Stack } from "aws-cdk-lib/core";
|
4
4
|
import { Construct } from "constructs/lib/construct.js";
|
5
5
|
export interface NetworkConfiguration {
|
@@ -1,12 +1,20 @@
|
|
1
1
|
import { IpAddresses, SubnetType, Vpc } from "aws-cdk-lib/aws-ec2";
|
2
2
|
import { exportValue } from "../import-util.mjs";
|
3
3
|
import { Stack } from "aws-cdk-lib/core";
|
4
|
+
import { Construct } from "constructs/lib/construct.js";
|
4
5
|
export class NetworkStack extends Stack {
|
6
|
+
vpc;
|
5
7
|
constructor(scope, id, isc, configuration) {
|
6
8
|
super(scope, id, {
|
7
9
|
env: isc.env,
|
8
10
|
});
|
9
11
|
this.vpc = this.createVpc(configuration);
|
12
|
+
if (this.vpc.publicSubnets[0] === undefined ||
|
13
|
+
this.vpc.publicSubnets[1] === undefined ||
|
14
|
+
this.vpc.privateSubnets[0] === undefined ||
|
15
|
+
this.vpc.privateSubnets[1] === undefined) {
|
16
|
+
throw Error('Subnets are not set correctly');
|
17
|
+
}
|
10
18
|
exportValue(this, isc.environmentName, "VPCID", this.vpc.vpcId);
|
11
19
|
exportValue(this, isc.environmentName, "digitrafficpublicASubnet", this.vpc.publicSubnets[0].subnetId);
|
12
20
|
exportValue(this, isc.environmentName, "digitrafficpublicBSubnet", this.vpc.publicSubnets[1].subnetId);
|
@@ -1,2 +1,2 @@
|
|
1
|
-
import { APIGateway } from "aws-sdk";
|
2
|
-
export declare function getApiKeyFromAPIGateway(keyId: string): Promise<
|
1
|
+
import type { APIGateway as APIGatewayType } from "aws-sdk";
|
2
|
+
export declare function getApiKeyFromAPIGateway(keyId: string): Promise<APIGatewayType.Types.ApiKey>;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { IntegrationResponse } from "aws-cdk-lib/aws-apigateway";
|
1
|
+
import type { IntegrationResponse } from "aws-cdk-lib/aws-apigateway";
|
2
2
|
import { MediaType } from "../types/mediatypes.mjs";
|
3
3
|
export declare abstract class DigitrafficIntegrationResponse {
|
4
4
|
static ok(mediaType: MediaType, sunset?: string): IntegrationResponse;
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import { Writable } from "stream";
|
1
2
|
import _ from "lodash";
|
2
3
|
/**
|
3
4
|
* Helper class for json-logging.
|
@@ -9,6 +10,9 @@ import _ from "lodash";
|
|
9
10
|
* * the actual message (as json or as string)
|
10
11
|
*/
|
11
12
|
export class DtLogger {
|
13
|
+
lambdaName;
|
14
|
+
runtime;
|
15
|
+
writeStream;
|
12
16
|
/**
|
13
17
|
* Create a new Logger instance.
|
14
18
|
* @constructor
|
@@ -16,8 +20,8 @@ export class DtLogger {
|
|
16
20
|
*/
|
17
21
|
constructor(config) {
|
18
22
|
this.lambdaName =
|
19
|
-
config?.lambdaName ?? process.env
|
20
|
-
this.runtime = config?.runTime ?? process.env
|
23
|
+
config?.lambdaName ?? process.env['AWS_LAMBDA_FUNCTION_NAME'];
|
24
|
+
this.runtime = config?.runTime ?? process.env['AWS_EXECUTION_ENV'];
|
21
25
|
this.writeStream = config?.writeStream ?? process.stdout;
|
22
26
|
}
|
23
27
|
/**
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { SNS } from "aws-sdk";
|
1
|
+
import type { SNS as SNSType } from "aws-sdk";
|
2
2
|
/**
|
3
3
|
* Utility function for publishing SNS messages.
|
4
4
|
* Made because using *await* with AWS APIs doesn't require calling promise() but nothing works if it isn't called.
|
@@ -7,4 +7,4 @@ import { SNS } from "aws-sdk";
|
|
7
7
|
* @param topicArn
|
8
8
|
* @param sns
|
9
9
|
*/
|
10
|
-
export declare function snsPublish(message: string, topicArn: string, sns:
|
10
|
+
export declare function snsPublish(message: string, topicArn: string, sns: SNSType): Promise<void>;
|
@@ -1,2 +1,2 @@
|
|
1
|
-
import { S3 } from "aws-sdk";
|
2
|
-
export declare function uploadToS3<Body extends
|
1
|
+
import type { S3 as S3Type } from "aws-sdk";
|
2
|
+
export declare function uploadToS3<Body extends S3Type.Body | undefined>(bucketName: string, body: Body, objectName: string, cannedAcl?: string, contentType?: string): Promise<void>;
|
package/dist/aws/runtime/s3.mjs
CHANGED
@@ -7,6 +7,7 @@ const RDS_PROXY_SECRET_KEYS = Object.values(RdsProxySecretKey);
|
|
7
7
|
* Holds credentials for RDS Proxy access.
|
8
8
|
*/
|
9
9
|
export class ProxyHolder {
|
10
|
+
secretHolder;
|
10
11
|
constructor(secretId) {
|
11
12
|
this.secretHolder = new SecretHolder(secretId, "", RDS_PROXY_SECRET_KEYS);
|
12
13
|
}
|
@@ -21,6 +21,10 @@ const DEFAULT_CONFIGURATION = {
|
|
21
21
|
*
|
22
22
|
*/
|
23
23
|
export class SecretHolder {
|
24
|
+
secretId;
|
25
|
+
prefix;
|
26
|
+
expectedKeys;
|
27
|
+
secretCache;
|
24
28
|
constructor(secretId, prefix = "", expectedKeys = [], configuration = DEFAULT_CONFIGURATION) {
|
25
29
|
this.secretId = secretId;
|
26
30
|
this.prefix = prefix;
|
@@ -55,7 +59,8 @@ export class SecretHolder {
|
|
55
59
|
const skip = prefix.length;
|
56
60
|
for (const key in secret) {
|
57
61
|
if (key.startsWith(prefix)) {
|
58
|
-
|
62
|
+
const withoutPrefix = key.substring(skip);
|
63
|
+
parsed[withoutPrefix] = secret[key];
|
59
64
|
}
|
60
65
|
}
|
61
66
|
return parsed;
|
@@ -1,6 +1,7 @@
|
|
1
|
-
import
|
1
|
+
import awsSdk from "aws-sdk";
|
2
2
|
import { getEnvVariable, getEnvVariableOrElse } from "../../../utils/utils.mjs";
|
3
3
|
import { EnvKeys } from "../environment.mjs";
|
4
|
+
const { SecretsManager } = awsSdk;
|
4
5
|
// SECRET_OVERRIDE_AWS_REGION might not have been set before import of
|
5
6
|
// secret, so we need to lazy initialize SecretsManager
|
6
7
|
let smClient;
|
@@ -33,7 +34,8 @@ function parseSecret(secret, prefix) {
|
|
33
34
|
const skip = prefix.length;
|
34
35
|
for (const key in secret) {
|
35
36
|
if (key.startsWith(prefix)) {
|
36
|
-
|
37
|
+
const withoutPrefix = key.substring(skip);
|
38
|
+
parsed[withoutPrefix] = secret[key];
|
37
39
|
}
|
38
40
|
}
|
39
41
|
return parsed;
|
@@ -1,2 +1,2 @@
|
|
1
|
-
|
1
|
+
import { Model } from "aws-cdk-lib/aws-apigateway";
|
2
2
|
//# sourceMappingURL=model-with-reference.mjs.map
|
@@ -1,3 +1,3 @@
|
|
1
|
-
import { DTDatabase } from "../database/database.mjs";
|
1
|
+
import { type DTDatabase } from "../database/database.mjs";
|
2
2
|
export declare function assertCount(db: DTDatabase, sql: string, count: number): Promise<void>;
|
3
3
|
export declare function dbTestBase(fn: (db: DTDatabase) => void, truncateFn: (db: DTDatabase) => Promise<void>, dbUser: string, dbPass: string, dbUri: string): () => void;
|
@@ -3,7 +3,7 @@ export async function assertCount(db, sql, count) {
|
|
3
3
|
await db.one(sql).then((x) => expect(x.count).toEqual(count));
|
4
4
|
}
|
5
5
|
export function dbTestBase(fn, truncateFn, dbUser, dbPass, dbUri) {
|
6
|
-
const theDbUri = process.env
|
6
|
+
const theDbUri = process.env['DB_URI'] ?? dbUri;
|
7
7
|
console.log(`Test database URI: ${theDbUri}`);
|
8
8
|
return () => {
|
9
9
|
const db = initDbConnection(dbUser, dbPass, "test", theDbUri, {
|
package/dist/test/httpserver.mjs
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { createServer } from "http";
|
1
|
+
import { Server, createServer } from "http";
|
2
2
|
import { parse } from "url";
|
3
3
|
export const ERROR_NO_MATCH = "NO MATCH";
|
4
4
|
export const ERRORCODE_NOT_FOUND = 404;
|
@@ -6,6 +6,9 @@ export const ERRORCODE_NOT_FOUND = 404;
|
|
6
6
|
* A mock HTTP server created for testing connections from a Lambda to an outside integration
|
7
7
|
*/
|
8
8
|
export class TestHttpServer {
|
9
|
+
server;
|
10
|
+
debug;
|
11
|
+
messageStack;
|
9
12
|
constructor() {
|
10
13
|
this.debug = false;
|
11
14
|
this.messageStack = [];
|
@@ -14,7 +17,7 @@ export class TestHttpServer {
|
|
14
17
|
return this.messageStack.length;
|
15
18
|
}
|
16
19
|
getRequestBody(callNumber) {
|
17
|
-
return this.messageStack[callNumber];
|
20
|
+
return this.messageStack[callNumber] ?? '';
|
18
21
|
}
|
19
22
|
listen(port, props, debug = false, statusCode = 200) {
|
20
23
|
this.debug = debug;
|
@@ -45,7 +48,8 @@ export class TestHttpServer {
|
|
45
48
|
req.on("end", () => {
|
46
49
|
// assume sent data is in JSON format
|
47
50
|
this.messageStack[this.messageStack.length] = dataStr;
|
48
|
-
|
51
|
+
const invokable = props[path];
|
52
|
+
res.end(invokable(req.url, dataStr));
|
49
53
|
});
|
50
54
|
}
|
51
55
|
else {
|
package/dist/test/testutils.mjs
CHANGED
@@ -27,7 +27,7 @@ export function shuffle(array) {
|
|
27
27
|
// pretty fast way to copy an array, not necessarily the fastest
|
28
28
|
const newArray = array.slice(0);
|
29
29
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
30
|
-
newArray.sort((
|
30
|
+
newArray.sort((_) => 0.5 - Math.random());
|
31
31
|
return newArray;
|
32
32
|
}
|
33
33
|
//# sourceMappingURL=testutils.mjs.map
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import { RestApi, Model, JsonSchema, RequestValidator, JsonSchemaType, JsonSchemaVersion } from 'aws-cdk-lib/aws-apigateway';
|
2
|
-
import { ModelWithReference } from "../aws/types/model-with-reference.mjs";
|
1
|
+
import { RestApi, Model, type JsonSchema, RequestValidator, JsonSchemaType, JsonSchemaVersion } from 'aws-cdk-lib/aws-apigateway';
|
2
|
+
import type { ModelWithReference } from "../aws/types/model-with-reference.mjs";
|
3
3
|
/**
|
4
4
|
* Get a reference to an OpenAPI model object in a REST API.
|
5
5
|
* Can be used to supply a reference to properties of a GeoJSON feature.
|
package/dist/utils/api-model.mjs
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { JsonSchemaType, JsonSchemaVersion, } from 'aws-cdk-lib/aws-apigateway';
|
1
|
+
import { RestApi, Model, RequestValidator, JsonSchemaType, JsonSchemaVersion, } from 'aws-cdk-lib/aws-apigateway';
|
2
2
|
/**
|
3
3
|
* Get a reference to an OpenAPI model object in a REST API.
|
4
4
|
* Can be used to supply a reference to properties of a GeoJSON feature.
|
@@ -1,12 +1,14 @@
|
|
1
1
|
export class GeoJsonPoint {
|
2
|
+
type = "Point";
|
3
|
+
coordinates;
|
2
4
|
constructor(coordinates) {
|
3
|
-
this.type = "Point";
|
4
5
|
this.coordinates = coordinates;
|
5
6
|
}
|
6
7
|
}
|
7
8
|
export class GeoJsonLineString {
|
9
|
+
type = "LineString";
|
10
|
+
coordinates;
|
8
11
|
constructor(coordinates) {
|
9
|
-
this.type = "LineString";
|
10
12
|
this.coordinates = coordinates;
|
11
13
|
}
|
12
14
|
}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
/**
|
2
2
|
* GeoJSON functions and tools
|
3
3
|
*/
|
4
|
-
import { Feature, FeatureCollection, Geometry, Position } from "geojson";
|
4
|
+
import type { Feature, FeatureCollection, Geometry, Position } from "geojson";
|
5
5
|
export declare const SRID_WGS84 = 4326;
|
6
6
|
/**
|
7
7
|
* Creates WKT geometry from GeoJSON geometry
|
package/dist/utils/geometry.mjs
CHANGED
@@ -87,6 +87,9 @@ function distanceBetweenWGS84PointsInKm(fromXLon, fromYLat, toXLon, toYLat) {
|
|
87
87
|
* @param pos2
|
88
88
|
*/
|
89
89
|
export function distanceBetweenPositionsInKm(pos1, pos2) {
|
90
|
+
if (pos1.length !== 2 && pos2.length !== 2) {
|
91
|
+
throw Error(`Positions ${pos1.toString()} and ${pos2.toString()} both must be arrays of length two`);
|
92
|
+
}
|
90
93
|
return distanceBetweenWGS84PointsInKm(pos1[0], pos1[1], pos2[0], pos2[1]);
|
91
94
|
}
|
92
95
|
export function areDistinctPositions(previous, next) {
|
package/dist/utils/retry.d.mts
CHANGED
@@ -9,7 +9,7 @@ export type RetryPredicate = (error: unknown) => boolean;
|
|
9
9
|
* Utility timeout functions for "retry" function.
|
10
10
|
*/
|
11
11
|
export declare const timeoutFunctions: {
|
12
|
-
noTimeout: (
|
12
|
+
noTimeout: (_: number) => number;
|
13
13
|
exponentialTimeout: (retryCount: number) => number;
|
14
14
|
};
|
15
15
|
/**
|
@@ -17,7 +17,7 @@ export declare const timeoutFunctions: {
|
|
17
17
|
*/
|
18
18
|
export declare const retryPredicates: {
|
19
19
|
retryBasedOnStatusCode: (error: unknown) => boolean;
|
20
|
-
alwaysRetry: (
|
20
|
+
alwaysRetry: (_: unknown) => boolean;
|
21
21
|
};
|
22
22
|
export declare let retryCount: number;
|
23
23
|
/**
|
package/dist/utils/retry.mjs
CHANGED
@@ -13,7 +13,7 @@ export var RetryLogError;
|
|
13
13
|
export const timeoutFunctions = (function () {
|
14
14
|
return {
|
15
15
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
16
|
-
noTimeout: (
|
16
|
+
noTimeout: (_) => {
|
17
17
|
return 0;
|
18
18
|
},
|
19
19
|
exponentialTimeout: (retryCount) => {
|
@@ -39,7 +39,7 @@ export const retryPredicates = (function () {
|
|
39
39
|
return false;
|
40
40
|
},
|
41
41
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
42
|
-
alwaysRetry: (
|
42
|
+
alwaysRetry: (_) => {
|
43
43
|
return true;
|
44
44
|
},
|
45
45
|
};
|
package/dist/utils/slack.mjs
CHANGED
package/dist/utils/utils.d.mts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
import { AwsEnv } from "../types/aws-env.mjs";
|
2
|
-
import { Either } from "../types/either.mjs";
|
1
|
+
import type { AwsEnv } from "../types/aws-env.mjs";
|
2
|
+
import type { Either } from "../types/either.mjs";
|
3
3
|
/**
|
4
4
|
* Check if arrays have only elements that also exists also in other array.
|
5
5
|
* Individual element count doesn't matter.
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@digitraffic/common",
|
3
|
-
"version": "2024.1.
|
3
|
+
"version": "2024.1.30-1",
|
4
4
|
"description": "",
|
5
5
|
"type": "module",
|
6
6
|
"repository": {
|
@@ -14,8 +14,7 @@
|
|
14
14
|
"private": false,
|
15
15
|
"files": [
|
16
16
|
"dist/**/*.mjs",
|
17
|
-
"dist/**/*.d.mts"
|
18
|
-
"src/**/*.mts"
|
17
|
+
"dist/**/*.d.mts"
|
19
18
|
],
|
20
19
|
"exports": {
|
21
20
|
".": "./dist/index.mjs",
|
@@ -121,6 +120,11 @@
|
|
121
120
|
},
|
122
121
|
"devDependencies": {
|
123
122
|
"@jest/globals": "^29.7.0",
|
123
|
+
"@rushstack/eslint-config": "^3.6.2",
|
124
|
+
"@rushstack/heft": "^0.64.3",
|
125
|
+
"@rushstack/heft-jest-plugin": "^0.11.3",
|
126
|
+
"@rushstack/heft-lint-plugin": "^0.3.3",
|
127
|
+
"@rushstack/heft-typescript-plugin": "^0.3.3",
|
124
128
|
"@types/aws-lambda": "8.10.131",
|
125
129
|
"@types/etag": "1.8.3",
|
126
130
|
"@types/geojson": "7946.0.13",
|
@@ -130,10 +134,10 @@
|
|
130
134
|
"@types/node": "20.10.7",
|
131
135
|
"@types/sinon": "17.0.2",
|
132
136
|
"@typescript-eslint/eslint-plugin": "~6.18.1",
|
133
|
-
"@typescript-eslint/parser": "^6.
|
137
|
+
"@typescript-eslint/parser": "^6.20.0",
|
134
138
|
"aws-cdk-lib": "~2.118.0",
|
135
139
|
"aws-sdk": "~2.1531.0",
|
136
|
-
"axios": "^1.6.
|
140
|
+
"axios": "^1.6.7",
|
137
141
|
"change-case": "5.3.0",
|
138
142
|
"constructs": "10.3.0",
|
139
143
|
"date-fns": "~2.30.0",
|
@@ -166,7 +170,8 @@
|
|
166
170
|
"eslint-report": "eslint . --format html",
|
167
171
|
"ci:eslint-report": "eslint . --format html -o report.html || true",
|
168
172
|
"clean": "rimraf dist output",
|
169
|
-
"test": "
|
173
|
+
"test": "NODE_OPTIONS='--experimental-vm-modules' heft test --clean --max-workers=1",
|
174
|
+
"test:jest": "node --trace-warnings --experimental-vm-modules --max-old-space-size=1536 --expose-gc ./node_modules/jest/bin/jest.js --detectOpenHandles --forceExit --coverage --coverageDirectory=output/coverage/jest --logHeapUsage --runInBand --verbose",
|
170
175
|
"test:inspect": "node --inspect-brk --expose-gc ./node_modules/jest/bin/jest.js --detectOpenHandles --forceExit --coverage --coverageDirectory=output/coverage/jest --logHeapUsage --runInBand",
|
171
176
|
"test:watch": "jest --detectOpenHandles --forceExit --coverage --coverageDirectory=output/coverage/jest --watch"
|
172
177
|
}
|