@digitraffic/common 2023.12.15-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.
Files changed (168) hide show
  1. package/dist/aws/infra/api/handler-factory.d.ts +2 -2
  2. package/dist/aws/infra/api/handler-factory.js +4 -9
  3. package/dist/aws/infra/api/integration.d.ts +1 -1
  4. package/dist/aws/infra/api/integration.js +9 -13
  5. package/dist/aws/infra/api/response.d.ts +2 -3
  6. package/dist/aws/infra/api/response.js +25 -30
  7. package/dist/aws/infra/api/responses.d.ts +2 -3
  8. package/dist/aws/infra/api/responses.js +25 -31
  9. package/dist/aws/infra/api/static-integration.d.ts +1 -1
  10. package/dist/aws/infra/api/static-integration.js +7 -11
  11. package/dist/aws/infra/canaries/canary-alarm.d.ts +1 -1
  12. package/dist/aws/infra/canaries/canary-alarm.js +7 -11
  13. package/dist/aws/infra/canaries/canary-keys.js +3 -6
  14. package/dist/aws/infra/canaries/canary-parameters.js +1 -2
  15. package/dist/aws/infra/canaries/canary-role.js +8 -12
  16. package/dist/aws/infra/canaries/canary.d.ts +2 -2
  17. package/dist/aws/infra/canaries/canary.js +9 -13
  18. package/dist/aws/infra/canaries/database-canary.d.ts +3 -3
  19. package/dist/aws/infra/canaries/database-canary.js +8 -12
  20. package/dist/aws/infra/canaries/database-checker.d.ts +1 -1
  21. package/dist/aws/infra/canaries/database-checker.js +10 -14
  22. package/dist/aws/infra/canaries/url-canary.d.ts +4 -4
  23. package/dist/aws/infra/canaries/url-canary.js +8 -12
  24. package/dist/aws/infra/canaries/url-checker.d.ts +2 -2
  25. package/dist/aws/infra/canaries/url-checker.js +33 -40
  26. package/dist/aws/infra/documentation.js +8 -16
  27. package/dist/aws/infra/import-util.js +10 -18
  28. package/dist/aws/infra/scheduler.js +10 -14
  29. package/dist/aws/infra/security-rule.js +4 -8
  30. package/dist/aws/infra/sqs-integration.d.ts +1 -2
  31. package/dist/aws/infra/sqs-integration.js +11 -15
  32. package/dist/aws/infra/sqs-queue.d.ts +1 -1
  33. package/dist/aws/infra/sqs-queue.js +51 -50
  34. package/dist/aws/infra/stack/lambda-configs.d.ts +2 -2
  35. package/dist/aws/infra/stack/lambda-configs.js +14 -20
  36. package/dist/aws/infra/stack/monitoredfunction.d.ts +3 -3
  37. package/dist/aws/infra/stack/monitoredfunction.js +19 -27
  38. package/dist/aws/infra/stack/parameters.d.ts +1 -1
  39. package/dist/aws/infra/stack/parameters.js +5 -10
  40. package/dist/aws/infra/stack/rest_apis.d.ts +3 -3
  41. package/dist/aws/infra/stack/rest_apis.js +41 -54
  42. package/dist/aws/infra/stack/stack-checking-aspect.d.ts +1 -1
  43. package/dist/aws/infra/stack/stack-checking-aspect.js +28 -39
  44. package/dist/aws/infra/stack/stack.d.ts +5 -6
  45. package/dist/aws/infra/stack/stack.js +16 -20
  46. package/dist/aws/infra/stack/subscription.d.ts +2 -2
  47. package/dist/aws/infra/stack/subscription.js +5 -10
  48. package/dist/aws/infra/stacks/db-dns-stack.d.ts +2 -2
  49. package/dist/aws/infra/stacks/db-dns-stack.js +25 -29
  50. package/dist/aws/infra/stacks/db-proxy-stack.d.ts +2 -2
  51. package/dist/aws/infra/stacks/db-proxy-stack.js +23 -27
  52. package/dist/aws/infra/stacks/db-stack.d.ts +3 -4
  53. package/dist/aws/infra/stacks/db-stack.js +30 -34
  54. package/dist/aws/infra/stacks/intra-stack-configuration.js +1 -2
  55. package/dist/aws/infra/stacks/network-stack.d.ts +2 -2
  56. package/dist/aws/infra/stacks/network-stack.js +15 -19
  57. package/dist/aws/infra/usage-plans.js +2 -7
  58. package/dist/aws/runtime/apikey.js +3 -7
  59. package/dist/aws/runtime/digitraffic-integration-response.d.ts +1 -1
  60. package/dist/aws/runtime/digitraffic-integration-response.js +7 -11
  61. package/dist/aws/runtime/dt-logger-default.d.ts +2 -2
  62. package/dist/aws/runtime/dt-logger-default.js +2 -5
  63. package/dist/aws/runtime/dt-logger.d.ts +1 -1
  64. package/dist/aws/runtime/dt-logger.js +3 -10
  65. package/dist/aws/runtime/environment.js +3 -7
  66. package/dist/aws/runtime/messaging.js +1 -5
  67. package/dist/aws/runtime/s3.js +3 -7
  68. package/dist/aws/runtime/secrets/dbsecret.d.ts +1 -1
  69. package/dist/aws/runtime/secrets/dbsecret.js +5 -9
  70. package/dist/aws/runtime/secrets/proxy-holder.js +12 -16
  71. package/dist/aws/runtime/secrets/rds-holder.js +12 -16
  72. package/dist/aws/runtime/secrets/secret-holder.d.ts +1 -1
  73. package/dist/aws/runtime/secrets/secret-holder.js +9 -13
  74. package/dist/aws/runtime/secrets/secret.js +7 -11
  75. package/dist/aws/types/errors.js +5 -9
  76. package/dist/aws/types/lambda-response.js +3 -10
  77. package/dist/aws/types/mediatypes.js +2 -5
  78. package/dist/aws/types/model-with-reference.js +1 -2
  79. package/dist/aws/types/proxytypes.js +1 -2
  80. package/dist/aws/types/tags.js +2 -5
  81. package/dist/database/cached.d.ts +1 -1
  82. package/dist/database/cached.js +8 -14
  83. package/dist/database/database.js +14 -21
  84. package/dist/database/last-updated.d.ts +1 -1
  85. package/dist/database/last-updated.js +8 -17
  86. package/dist/database/models.js +1 -2
  87. package/dist/index.d.ts +1 -0
  88. package/dist/index.js +2 -0
  89. package/dist/marine/id_utils.js +3 -9
  90. package/dist/marine/rtz.js +1 -2
  91. package/dist/test/asserter.js +1 -5
  92. package/dist/test/db-testutils.d.ts +1 -1
  93. package/dist/test/db-testutils.js +8 -13
  94. package/dist/test/httpserver.d.ts +1 -1
  95. package/dist/test/httpserver.js +19 -18
  96. package/dist/test/secrets-manager.js +9 -35
  97. package/dist/test/testutils.js +8 -19
  98. package/dist/types/async-timeout-error.js +1 -5
  99. package/dist/types/aws-env.js +1 -2
  100. package/dist/types/either.js +1 -2
  101. package/dist/types/http-error.js +1 -5
  102. package/dist/types/input-error.js +1 -5
  103. package/dist/types/language.js +2 -5
  104. package/dist/types/nullable.d.ts +1 -1
  105. package/dist/types/nullable.js +1 -2
  106. package/dist/types/traffictype.js +2 -5
  107. package/dist/types/urn.js +1 -2
  108. package/dist/types/util-types.js +1 -2
  109. package/dist/types/validator.js +4 -9
  110. package/dist/utils/api-model.d.ts +1 -1
  111. package/dist/utils/api-model.js +17 -27
  112. package/dist/utils/base64.d.ts +1 -1
  113. package/dist/utils/base64.js +2 -7
  114. package/dist/utils/date-utils.js +9 -16
  115. package/dist/utils/geojson-types.js +2 -7
  116. package/dist/utils/geometry.js +15 -48
  117. package/dist/utils/logging.d.ts +1 -1
  118. package/dist/utils/logging.js +8 -13
  119. package/dist/utils/retry.js +21 -26
  120. package/dist/utils/slack.js +7 -14
  121. package/dist/utils/utils.d.ts +2 -2
  122. package/dist/utils/utils.js +14 -29
  123. package/package.json +127 -41
  124. package/src/aws/infra/api/handler-factory.ts +3 -3
  125. package/src/aws/infra/api/integration.ts +2 -2
  126. package/src/aws/infra/api/response.ts +3 -3
  127. package/src/aws/infra/api/responses.ts +4 -4
  128. package/src/aws/infra/api/static-integration.ts +2 -2
  129. package/src/aws/infra/canaries/canary-alarm.ts +1 -1
  130. package/src/aws/infra/canaries/canary.ts +3 -3
  131. package/src/aws/infra/canaries/database-canary.ts +3 -3
  132. package/src/aws/infra/canaries/database-checker.ts +6 -6
  133. package/src/aws/infra/canaries/url-canary.ts +6 -6
  134. package/src/aws/infra/canaries/url-checker.ts +8 -8
  135. package/src/aws/infra/sqs-integration.ts +1 -1
  136. package/src/aws/infra/sqs-queue.ts +29 -44
  137. package/src/aws/infra/stack/lambda-configs.ts +9 -9
  138. package/src/aws/infra/stack/monitoredfunction.ts +4 -4
  139. package/src/aws/infra/stack/parameters.ts +1 -1
  140. package/src/aws/infra/stack/rest_apis.ts +6 -6
  141. package/src/aws/infra/stack/stack-checking-aspect.ts +20 -72
  142. package/src/aws/infra/stack/stack.ts +4 -5
  143. package/src/aws/infra/stack/subscription.ts +2 -2
  144. package/src/aws/infra/stacks/db-dns-stack.ts +4 -4
  145. package/src/aws/infra/stacks/db-proxy-stack.ts +5 -5
  146. package/src/aws/infra/stacks/db-stack.ts +5 -5
  147. package/src/aws/infra/stacks/network-stack.ts +3 -3
  148. package/src/aws/runtime/digitraffic-integration-response.ts +2 -2
  149. package/src/aws/runtime/dt-logger-default.ts +2 -2
  150. package/src/aws/runtime/secrets/dbsecret.ts +1 -1
  151. package/src/aws/runtime/secrets/proxy-holder.ts +4 -4
  152. package/src/aws/runtime/secrets/rds-holder.ts +4 -4
  153. package/src/aws/runtime/secrets/secret-holder.ts +4 -4
  154. package/src/aws/runtime/secrets/secret.ts +2 -2
  155. package/src/database/cached.ts +1 -1
  156. package/src/database/database.ts +3 -3
  157. package/src/database/last-updated.ts +1 -1
  158. package/src/index.ts +2 -0
  159. package/src/test/db-testutils.ts +2 -2
  160. package/src/test/httpserver.ts +13 -7
  161. package/src/test/secrets-manager.ts +2 -2
  162. package/src/types/nullable.ts +1 -1
  163. package/src/utils/api-model.ts +1 -1
  164. package/src/utils/geometry.ts +5 -3
  165. package/src/utils/logging.ts +2 -2
  166. package/src/utils/retry.ts +3 -3
  167. package/src/utils/slack.ts +2 -2
  168. package/src/utils/utils.ts +3 -3
@@ -19,12 +19,12 @@ import {
19
19
  PolicyStatement,
20
20
  } from "aws-cdk-lib/aws-iam";
21
21
  import { Construct } from "constructs";
22
- import { getModelReference } from "../../../utils/api-model";
23
- import { MediaType } from "../../types/mediatypes";
24
- import { ModelWithReference } from "../../types/model-with-reference";
25
- import { DocumentationPart, DocumentationProperties } from "../documentation";
26
- import { createDefaultUsagePlan, createUsagePlan } from "../usage-plans";
27
- import { DigitrafficStack } from "./stack";
22
+ import { getModelReference } from "../../../utils/api-model.js";
23
+ import { MediaType } from "../../types/mediatypes.js";
24
+ import { ModelWithReference } from "../../types/model-with-reference.js";
25
+ import { DocumentationPart, DocumentationProperties } from "../documentation.js";
26
+ import { createDefaultUsagePlan, createUsagePlan } from "../usage-plans.js";
27
+ import { DigitrafficStack } from "./stack.js";
28
28
 
29
29
  import _ from "lodash";
30
30
 
@@ -1,17 +1,17 @@
1
1
  import { Annotations, IAspect, Stack } from "aws-cdk-lib";
2
2
  import { CfnFunction, Runtime } from "aws-cdk-lib/aws-lambda";
3
3
  import { CfnBucket } from "aws-cdk-lib/aws-s3";
4
- import { DigitrafficStack, SOLUTION_KEY } from "./stack";
4
+ import { DigitrafficStack, SOLUTION_KEY } from "./stack.js";
5
5
  import { IConstruct } from "constructs";
6
6
  import { CfnMethod, CfnResource } from "aws-cdk-lib/aws-apigateway";
7
7
  import { CfnQueue } from "aws-cdk-lib/aws-sqs";
8
8
  import { LogRetention } from "aws-cdk-lib/aws-logs";
9
- import { paramCase } from "change-case";
9
+ import { kebabCase } from "change-case";
10
10
  import _ from "lodash";
11
11
  import IntegrationProperty = CfnMethod.IntegrationProperty;
12
12
 
13
13
  const MAX_CONCURRENCY_LIMIT = 100;
14
- const NODE_RUNTIMES = [Runtime.NODEJS_16_X.name, Runtime.NODEJS_18_X.name];
14
+ const NODE_RUNTIMES = [Runtime.NODEJS_20_X.name, Runtime.NODEJS_18_X.name];
15
15
 
16
16
  enum ResourceType {
17
17
  stackName = "STACK_NAME",
@@ -61,12 +61,7 @@ export class StackCheckingAspect implements IAspect {
61
61
  });
62
62
  }
63
63
 
64
- private addAnnotation(
65
- node: IConstruct,
66
- key: ResourceType | string,
67
- message: string,
68
- isError = true
69
- ) {
64
+ private addAnnotation(node: IConstruct, key: ResourceType | string, message: string, isError = true) {
70
65
  const resourceKey = `${node.node.path}/${key}`;
71
66
  const isWhiteListed = this.isWhitelisted(resourceKey);
72
67
  const annotationMessage = `${resourceKey}:${message}`;
@@ -83,20 +78,14 @@ export class StackCheckingAspect implements IAspect {
83
78
  private checkStack(node: IConstruct) {
84
79
  if (node instanceof DigitrafficStack) {
85
80
  if (
86
- (node.stackName.includes("Test") ||
87
- node.stackName.includes("Tst")) &&
81
+ (node.stackName.includes("Test") || node.stackName.includes("Tst")) &&
88
82
  node.configuration.production
89
83
  ) {
90
- this.addAnnotation(
91
- node,
92
- ResourceType.stackName,
93
- "Production is set for Test-stack"
94
- );
84
+ this.addAnnotation(node, ResourceType.stackName, "Production is set for Test-stack");
95
85
  }
96
86
 
97
87
  if (
98
- (node.stackName.includes("Prod") ||
99
- node.stackName.includes("Prd")) &&
88
+ (node.stackName.includes("Prod") || node.stackName.includes("Prd")) &&
100
89
  !node.configuration.production
101
90
  ) {
102
91
  this.addAnnotation(
@@ -116,9 +105,7 @@ export class StackCheckingAspect implements IAspect {
116
105
  ResourceType.reservedConcurrentConcurrency,
117
106
  "Function must have reservedConcurrentConcurrency"
118
107
  );
119
- } else if (
120
- node.reservedConcurrentExecutions > MAX_CONCURRENCY_LIMIT
121
- ) {
108
+ } else if (node.reservedConcurrentExecutions > MAX_CONCURRENCY_LIMIT) {
122
109
  this.addAnnotation(
123
110
  node,
124
111
  ResourceType.reservedConcurrentConcurrency,
@@ -127,25 +114,14 @@ export class StackCheckingAspect implements IAspect {
127
114
  }
128
115
 
129
116
  if (!node.timeout) {
130
- this.addAnnotation(
131
- node,
132
- ResourceType.functionTimeout,
133
- "Function must have timeout"
134
- );
117
+ this.addAnnotation(node, ResourceType.functionTimeout, "Function must have timeout");
135
118
  }
136
119
 
137
120
  if (!node.memorySize) {
138
- this.addAnnotation(
139
- node,
140
- ResourceType.functionMemorySize,
141
- "Function must have memorySize"
142
- );
121
+ this.addAnnotation(node, ResourceType.functionMemorySize, "Function must have memorySize");
143
122
  }
144
123
 
145
- if (
146
- node.runtime !== undefined &&
147
- !NODE_RUNTIMES.includes(node.runtime)
148
- ) {
124
+ if (node.runtime !== undefined && !NODE_RUNTIMES.includes(node.runtime)) {
149
125
  this.addAnnotation(
150
126
  node,
151
127
  ResourceType.functionRuntime,
@@ -170,11 +146,7 @@ export class StackCheckingAspect implements IAspect {
170
146
  private checkTags(node: IConstruct) {
171
147
  if (node instanceof Stack) {
172
148
  if (!node.tags.tagValues()[SOLUTION_KEY]) {
173
- this.addAnnotation(
174
- node,
175
- ResourceType.tagSolution,
176
- "Solution tag is missing"
177
- );
149
+ this.addAnnotation(node, ResourceType.tagSolution, "Solution tag is missing");
178
150
  }
179
151
  }
180
152
  }
@@ -192,11 +164,7 @@ export class StackCheckingAspect implements IAspect {
192
164
  !c.ignorePublicAcls ||
193
165
  !c.restrictPublicBuckets)
194
166
  ) {
195
- this.addAnnotation(
196
- node,
197
- ResourceType.bucketPublicity,
198
- "Check bucket publicity"
199
- );
167
+ this.addAnnotation(node, ResourceType.bucketPublicity, "Check bucket publicity");
200
168
  }
201
169
  }
202
170
  }
@@ -211,7 +179,7 @@ export class StackCheckingAspect implements IAspect {
211
179
  return this.isValidPath(path.split("{")[0]);
212
180
  }
213
181
 
214
- return paramCase(path) === path;
182
+ return kebabCase(path) === path;
215
183
  }
216
184
 
217
185
  private static isValidQueryString(name: string) {
@@ -221,16 +189,10 @@ export class StackCheckingAspect implements IAspect {
221
189
  private checkResourceCasing(node: IConstruct) {
222
190
  if (node instanceof CfnResource) {
223
191
  if (!StackCheckingAspect.isValidPath(node.pathPart)) {
224
- this.addAnnotation(
225
- node,
226
- ResourceType.resourcePath,
227
- "Path part should be in kebab-case"
228
- );
192
+ this.addAnnotation(node, ResourceType.resourcePath, "Path part should be in kebab-case");
229
193
  }
230
194
  } else if (node instanceof CfnMethod) {
231
- const integration = node.integration as
232
- | IntegrationProperty
233
- | undefined;
195
+ const integration = node.integration as IntegrationProperty | undefined;
234
196
 
235
197
  if (integration?.requestParameters) {
236
198
  Object.keys(integration.requestParameters).forEach((key) => {
@@ -238,15 +200,8 @@ export class StackCheckingAspect implements IAspect {
238
200
  const type = split[2];
239
201
  const name = split[3];
240
202
 
241
- if (
242
- type === "querystring" &&
243
- !StackCheckingAspect.isValidQueryString(name)
244
- ) {
245
- this.addAnnotation(
246
- node,
247
- name,
248
- "Querystring should be in snake_case"
249
- );
203
+ if (type === "querystring" && !StackCheckingAspect.isValidQueryString(name)) {
204
+ this.addAnnotation(node, name, "Querystring should be in snake_case");
250
205
  }
251
206
  });
252
207
  }
@@ -256,21 +211,14 @@ export class StackCheckingAspect implements IAspect {
256
211
  private checkQueueEncryption(node: IConstruct) {
257
212
  if (node instanceof CfnQueue) {
258
213
  if (!node.kmsMasterKeyId) {
259
- this.addAnnotation(
260
- node,
261
- ResourceType.queueEncryption,
262
- "Queue must have encryption enabled"
263
- );
214
+ this.addAnnotation(node, ResourceType.queueEncryption, "Queue must have encryption enabled");
264
215
  }
265
216
  }
266
217
  }
267
218
 
268
219
  private checkLogGroupRetention(node: IConstruct) {
269
220
  if (node instanceof LogRetention) {
270
- const child = node.node.defaultChild as unknown as Record<
271
- string,
272
- Record<string, string>
273
- >;
221
+ const child = node.node.defaultChild as unknown as Record<string, Record<string, string>>;
274
222
  const retention = child._cfnProperties.RetentionInDays;
275
223
 
276
224
  if (!retention) {
@@ -1,15 +1,14 @@
1
1
  import { Aspects, Stack, StackProps } from "aws-cdk-lib";
2
- import { IVpc, SecurityGroup, Vpc } from "aws-cdk-lib/aws-ec2";
3
- import { ISecurityGroup } from "aws-cdk-lib/aws-ec2/lib/security-group";
2
+ import { type ISecurityGroup, IVpc, SecurityGroup, Vpc } from "aws-cdk-lib/aws-ec2";
4
3
  import { ITopic, Topic } from "aws-cdk-lib/aws-sns";
5
4
  import { StringParameter } from "aws-cdk-lib/aws-ssm";
6
5
  import { ISecret, Secret } from "aws-cdk-lib/aws-secretsmanager";
7
6
  import { Function as AWSFunction } from "aws-cdk-lib/aws-lambda";
8
7
 
9
- import { StackCheckingAspect } from "./stack-checking-aspect";
8
+ import { StackCheckingAspect } from "./stack-checking-aspect.js";
10
9
  import { Construct } from "constructs";
11
- import { TrafficType } from "../../../types/traffictype";
12
- import { DBLambdaEnvironment } from "./lambda-configs";
10
+ import { TrafficType } from "../../../types/traffictype.js";
11
+ import { DBLambdaEnvironment } from "./lambda-configs.js";
13
12
 
14
13
  const SSM_ROOT = "/digitraffic";
15
14
  export const SOLUTION_KEY = "Solution";
@@ -1,8 +1,8 @@
1
1
  import { CfnSubscriptionFilter } from "aws-cdk-lib/aws-logs";
2
2
  import { Function as AWSFunction } from "aws-cdk-lib/aws-lambda";
3
- import { DigitrafficStack } from "./stack";
3
+ import { DigitrafficStack } from "./stack.js";
4
4
  import { Construct } from "constructs";
5
- import { MonitoredFunction } from "./monitoredfunction";
5
+ import { MonitoredFunction } from "./monitoredfunction.js";
6
6
 
7
7
  /**
8
8
  * Creates a subscription filter that subscribes to a Lambda Log Group and delivers the logs to another destination.
@@ -1,14 +1,14 @@
1
1
  import { Duration, RemovalPolicy, Stack } from "aws-cdk-lib";
2
- import { Construct } from "constructs/lib/construct";
2
+ import { type Construct } from "constructs";
3
3
  import {
4
4
  PrivateHostedZone,
5
5
  RecordSet,
6
6
  RecordTarget,
7
7
  RecordType,
8
8
  } from "aws-cdk-lib/aws-route53";
9
- import { InfraStackConfiguration } from "./intra-stack-configuration";
10
- import { importVpc } from "../import-util";
11
- import { getParameterValue } from "../stack/parameters";
9
+ import { InfraStackConfiguration } from "./intra-stack-configuration.js";
10
+ import { importVpc } from "../import-util.js";
11
+ import { getParameterValue } from "../stack/parameters.js";
12
12
 
13
13
  const DEFAULT_RECORD_TTL = Duration.seconds(30);
14
14
 
@@ -7,12 +7,12 @@ import {
7
7
  } from "aws-cdk-lib/aws-rds";
8
8
  import { ISecret, Secret } from "aws-cdk-lib/aws-secretsmanager";
9
9
  import { IVpc, SecurityGroup } from "aws-cdk-lib/aws-ec2";
10
- import { InfraStackConfiguration } from "./intra-stack-configuration";
11
- import { DbStack } from "./db-stack";
12
- import { exportValue, importVpc } from "../import-util";
13
- import { createParameter } from "../stack/parameters";
10
+ import { InfraStackConfiguration } from "./intra-stack-configuration.js";
11
+ import { DbStack } from "./db-stack.js";
12
+ import { exportValue, importVpc } from "../import-util.js";
13
+ import { createParameter } from "../stack/parameters.js";
14
14
  import { Stack, Duration } from "aws-cdk-lib/core";
15
- import { Construct } from "constructs/lib/construct";
15
+ import { Construct } from "constructs/lib/construct.js";
16
16
 
17
17
  export interface ProxyConfiguration {
18
18
  readonly secretArn: string;
@@ -3,8 +3,8 @@ import {
3
3
  IVpc,
4
4
  SecurityGroup,
5
5
  SubnetType,
6
+ type ISecurityGroup,
6
7
  } from "aws-cdk-lib/aws-ec2";
7
- import { ISecurityGroup } from "aws-cdk-lib/aws-ec2/lib/security-group";
8
8
  import {
9
9
  AuroraPostgresEngineVersion,
10
10
  CfnDBInstance,
@@ -17,12 +17,12 @@ import {
17
17
  IParameterGroup,
18
18
  ParameterGroup,
19
19
  } from "aws-cdk-lib/aws-rds";
20
- import { Construct } from "constructs/lib/construct";
20
+ import { Construct } from "constructs/lib/construct.js";
21
21
  import { Secret } from "aws-cdk-lib/aws-secretsmanager";
22
- import { InfraStackConfiguration } from "./intra-stack-configuration";
23
- import { exportValue, importVpc } from "../import-util";
22
+ import { InfraStackConfiguration } from "./intra-stack-configuration.js";
23
+ import { exportValue, importVpc } from "../import-util.js";
24
24
  import { Duration, RemovalPolicy, Stack } from "aws-cdk-lib/core";
25
- import { createParameter } from "../stack/parameters";
25
+ import { createParameter } from "../stack/parameters.js";
26
26
 
27
27
  export interface DbConfiguration {
28
28
  readonly cluster?: ClusterConfiguration;
@@ -1,8 +1,8 @@
1
1
  import { IpAddresses, IVpc, SubnetType, Vpc } from "aws-cdk-lib/aws-ec2";
2
- import { InfraStackConfiguration } from "./intra-stack-configuration";
3
- import { exportValue } from "../import-util";
2
+ import { InfraStackConfiguration } from "./intra-stack-configuration.js";
3
+ import { exportValue } from "../import-util.js";
4
4
  import { Stack } from "aws-cdk-lib/core";
5
- import { Construct } from "constructs/lib/construct";
5
+ import { Construct } from "constructs/lib/construct.js";
6
6
 
7
7
  export interface NetworkConfiguration {
8
8
  readonly vpcName: string;
@@ -1,9 +1,9 @@
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
  import {
4
4
  getDeprecatedDefaultLambdaResponse,
5
5
  RESPONSE_DEFAULT_LAMBDA,
6
- } from "../infra/api/response";
6
+ } from "../infra/api/response.js";
7
7
 
8
8
  export abstract class DigitrafficIntegrationResponse {
9
9
  static ok(mediaType: MediaType, sunset?: string): IntegrationResponse {
@@ -1,9 +1,9 @@
1
- import { DtLogger } from "./dt-logger";
1
+ import { DtLogger } from "./dt-logger.js";
2
2
 
3
3
  /**
4
4
  * You can use this for method name definition to match DtLogger LoggableType.method parameter.
5
5
  */
6
- export type { LoggerMethodType } from "./dt-logger";
6
+ export type { LoggerMethodType } from "./dt-logger.js";
7
7
 
8
8
  /**
9
9
  * You can use this for your logging needs or create one locally and configure it as you wish.
@@ -1,4 +1,4 @@
1
- import { GenericSecret } from "./secret";
1
+ import { GenericSecret } from "./secret.js";
2
2
 
3
3
  export enum RdsProxySecretKey {
4
4
  username = "username",
@@ -1,7 +1,7 @@
1
- import { SecretHolder } from "./secret-holder";
2
- import { RdsProxySecretKey, RdsProxySecret } from "./dbsecret";
3
- import { getEnvVariable } from "../../../utils/utils";
4
- import { DatabaseEnvironmentKeys } from "../../../database/database";
1
+ import { SecretHolder } from "./secret-holder.js";
2
+ import { RdsProxySecretKey, RdsProxySecret } from "./dbsecret.js";
3
+ import { getEnvVariable } from "../../../utils/utils.js";
4
+ import { DatabaseEnvironmentKeys } from "../../../database/database.js";
5
5
 
6
6
  const RDS_PROXY_SECRET_KEYS = Object.values(RdsProxySecretKey);
7
7
 
@@ -1,7 +1,7 @@
1
- import { SecretHolder } from "./secret-holder";
2
- import { RdsSecret, RdsSecretKey } from "./dbsecret";
3
- import { getEnvVariable } from "../../../utils/utils";
4
- import { DatabaseEnvironmentKeys } from "../../../database/database";
1
+ import { SecretHolder } from "./secret-holder.js";
2
+ import { RdsSecret, RdsSecretKey } from "./dbsecret.js";
3
+ import { getEnvVariable } from "../../../utils/utils.js";
4
+ import { DatabaseEnvironmentKeys } from "../../../database/database.js";
5
5
 
6
6
  const RDS_SECRET_KEYS = Object.values(RdsSecretKey);
7
7
 
@@ -1,7 +1,7 @@
1
- import { GenericSecret, getSecret } from "./secret";
2
- import { checkExpectedSecretKeys } from "./dbsecret";
3
- import { getEnvVariable } from "../../../utils/utils";
4
- import { logger } from "../dt-logger-default";
1
+ import { GenericSecret, getSecret } from "./secret.js";
2
+ import { checkExpectedSecretKeys } from "./dbsecret.js";
3
+ import { getEnvVariable } from "../../../utils/utils.js";
4
+ import { logger } from "../dt-logger-default.js";
5
5
 
6
6
  // eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-unsafe-assignment
7
7
  const NodeTtl = require("node-ttl");
@@ -1,6 +1,6 @@
1
1
  import { SecretsManager } from "aws-sdk";
2
- import { getEnvVariable, getEnvVariableOrElse } from "../../../utils/utils";
3
- import { EnvKeys } from "../environment";
2
+ import { getEnvVariable, getEnvVariableOrElse } from "../../../utils/utils.js";
3
+ import { EnvKeys } from "../environment.js";
4
4
 
5
5
  // SECRET_OVERRIDE_AWS_REGION might not have been set before import of
6
6
  // secret, so we need to lazy initialize SecretsManager
@@ -1,5 +1,5 @@
1
1
  import { PreparedStatement } from "pg-promise";
2
- import { DTDatabase, DTTransaction } from "./database";
2
+ import { DTDatabase, DTTransaction } from "./database.js";
3
3
 
4
4
  export interface CachedValue<T> {
5
5
  content: T;
@@ -1,7 +1,7 @@
1
1
  import { IDatabase, ITask } from "pg-promise";
2
- import { getEnvVariable, getEnvVariableOrElse } from "../utils/utils";
3
- import { logger } from "../aws/runtime/dt-logger-default";
4
- import { logException } from "../utils/logging";
2
+ import { getEnvVariable, getEnvVariableOrElse } from "../utils/utils.js";
3
+ import { logger } from "../aws/runtime/dt-logger-default.js";
4
+ import { logException } from "../utils/logging.js";
5
5
 
6
6
  export enum DatabaseEnvironmentKeys {
7
7
  DB_USER = "DB_USER",
@@ -1,4 +1,4 @@
1
- import { DTDatabase, DTTransaction } from "./database";
1
+ import { DTDatabase, DTTransaction } from "./database.js";
2
2
 
3
3
  export enum DataType {
4
4
  VS_DATEX2 = "VS_DATEX2",
package/src/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export { DigitrafficStack } from "./aws/infra/stack/stack.js";
2
+
@@ -2,8 +2,8 @@ import {
2
2
  DatabaseEnvironmentKeys,
3
3
  DTDatabase,
4
4
  initDbConnection,
5
- } from "../database/database";
6
- import { Countable } from "../database/models";
5
+ } from "../database/database.js";
6
+ import { Countable } from "../database/models.js";
7
7
 
8
8
  export async function assertCount(db: DTDatabase, sql: string, count: number) {
9
9
  await db.one(sql).then((x: Countable) => expect(x.count).toEqual(count));
@@ -30,7 +30,7 @@ export class TestHttpServer {
30
30
  port: number,
31
31
  props: ListenProperties,
32
32
  debug = false,
33
- statusCode = 200
33
+ statusCode = 200,
34
34
  ) {
35
35
  this.debug = debug;
36
36
  this.messageStack = [];
@@ -62,7 +62,7 @@ export class TestHttpServer {
62
62
  res.setHeader("Access-Control-Allow-Origin", "*");
63
63
  res.setHeader(
64
64
  "Access-Control-Allow-Headers",
65
- "Authorization,X-User-Id,X-Auth-Token"
65
+ "Authorization,X-User-Id,X-Auth-Token",
66
66
  );
67
67
  res.writeHead(statusCode);
68
68
 
@@ -85,11 +85,17 @@ export class TestHttpServer {
85
85
  this.server.listen(port);
86
86
  }
87
87
 
88
- close() {
89
- this.debuglog("Closing test server");
90
- if (this.server !== undefined) {
91
- this.server.close();
92
- }
88
+ close(): Promise<boolean> {
89
+ return new Promise((resolve, reject) => {
90
+ this.debuglog("Closing test server");
91
+ if (this.server !== undefined) {
92
+ this.server.close((error) =>
93
+ error != null ? reject(false) : resolve(true),
94
+ );
95
+ } else {
96
+ resolve(true);
97
+ }
98
+ });
93
99
  }
94
100
 
95
101
  private debuglog(str: string) {
@@ -1,7 +1,7 @@
1
1
  import AWS = require("aws-sdk");
2
2
  import * as sinon from "sinon";
3
- import { EnvKeys } from "../aws/runtime/environment";
4
- import { setEnvVariable } from "../utils/utils";
3
+ import { EnvKeys } from "../aws/runtime/environment.js";
4
+ import { setEnvVariable } from "../utils/utils.js";
5
5
 
6
6
  setEnvVariable(EnvKeys.AWS_REGION, "eu-west-1");
7
7
  const secretValue = sinon.stub();
@@ -1,4 +1,4 @@
1
- import { ValueOf } from "./util-types";
1
+ import { ValueOf } from "./util-types.js";
2
2
 
3
3
  /**
4
4
  * Adds `null` as an accepted type to all properties in given type.
@@ -6,7 +6,7 @@ import {
6
6
  JsonSchemaType,
7
7
  JsonSchemaVersion,
8
8
  } from 'aws-cdk-lib/aws-apigateway';
9
- import {ModelWithReference} from "../aws/types/model-with-reference";
9
+ import {ModelWithReference} from "../aws/types/model-with-reference.js";
10
10
 
11
11
  /**
12
12
  * Get a reference to an OpenAPI model object in a REST API.
@@ -3,7 +3,7 @@
3
3
  */
4
4
  import { Feature, FeatureCollection, Geometry, Position } from "geojson";
5
5
  import * as geoJsonValidator from "geojson-validation";
6
- import { logger } from "../aws/runtime/dt-logger-default";
6
+ import { logger } from "../aws/runtime/dt-logger-default.js";
7
7
 
8
8
  export const SRID_WGS84 = 4326;
9
9
 
@@ -73,11 +73,13 @@ export function createFeatureCollection(
73
73
  }
74
74
 
75
75
  export function isValidGeoJson<T>(json: T): boolean {
76
- return geoJsonValidator.valid(json);
76
+ // Tests complain about this method returning type string[] which is obviously wrong. Therefore, this casting.
77
+ return geoJsonValidator.valid(json) as unknown as boolean;
77
78
  }
78
79
 
79
80
  export function isFeatureCollection<T>(json: T): boolean {
80
- return geoJsonValidator.isFeatureCollection(json);
81
+ // Tests complain about this method returning type string[] which is obviously wrong. Therefore, this casting.
82
+ return geoJsonValidator.isFeatureCollection(json) as unknown as boolean;
81
83
  }
82
84
 
83
85
  const DEGREES_TO_RADIANS = 0.017453292519943295; // = Math.PI / 180
@@ -1,6 +1,6 @@
1
1
  import { AxiosError } from "axios";
2
- import { DtLogger } from "../aws/runtime/dt-logger";
3
- import { getEnvVariableOrElse } from "./utils";
2
+ import { DtLogger } from "../aws/runtime/dt-logger.js";
3
+ import { getEnvVariableOrElse } from "./utils.js";
4
4
 
5
5
  const functionName = getEnvVariableOrElse("AWS_LAMBDA_FUNCTION_NAME", "test");
6
6
 
@@ -1,6 +1,6 @@
1
- import { HttpError } from "../types/http-error";
2
- import { AsyncTimeoutError } from "../types/async-timeout-error";
3
- import { logger } from "../aws/runtime/dt-logger-default";
1
+ import { HttpError } from "../types/http-error.js";
2
+ import { AsyncTimeoutError } from "../types/async-timeout-error.js";
3
+ import { logger } from "../aws/runtime/dt-logger-default.js";
4
4
 
5
5
  export enum RetryLogError {
6
6
  LOG_ALL_AS_ERRORS,
@@ -1,6 +1,6 @@
1
1
  import axios from "axios";
2
- import { logger } from "../aws/runtime/dt-logger-default";
3
- import { logException } from "./logging";
2
+ import { logger } from "../aws/runtime/dt-logger-default.js";
3
+ import { logException } from "./logging.js";
4
4
 
5
5
  export class SlackApi {
6
6
  private readonly url: string;
@@ -1,6 +1,6 @@
1
- import { AwsEnv } from "../types/aws-env";
2
- import { Either } from "../types/either";
3
- import { EnvKeys } from "../aws/runtime/environment";
1
+ import { AwsEnv } from "../types/aws-env.js";
2
+ import { Either } from "../types/either.js";
3
+ import { EnvKeys } from "../aws/runtime/environment.js";
4
4
 
5
5
  /**
6
6
  * Check if arrays have only elements that also exists also in other array.