@digitraffic/common 2026.9.4-1 → 2026.9.4-2
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__/imports.test.js +82 -304
- package/dist/__test__/infra/acl-builder.test.js +18 -0
- package/dist/__test__/infra/stack/dt-function.test.d.ts +1 -0
- package/dist/__test__/infra/stack/dt-function.test.js +70 -0
- package/dist/__test__/infra/stack/stack.test.d.ts +1 -0
- package/dist/__test__/infra/stack/stack.test.js +33 -0
- package/dist/__test__/stack/dt-function.test.js +3 -121
- package/dist/__test__/utils/lead-time-logging.test.d.ts +1 -0
- package/dist/__test__/utils/lead-time-logging.test.js +153 -0
- package/dist/aws/infra/acl-builder.d.ts +21 -2
- package/dist/aws/infra/acl-builder.js +54 -6
- package/dist/aws/infra/canaries/database-checker.js +2 -3
- package/dist/aws/infra/stack/dt-function.d.ts +19 -12
- package/dist/aws/infra/stack/dt-function.js +31 -48
- package/dist/aws/infra/stack/stack-checking-aspect.js +1 -2
- package/dist/aws/infra/stack/stack.d.ts +2 -0
- package/dist/aws/infra/stack/stack.js +9 -8
- package/dist/aws/runtime/dt-logger.d.ts +1 -0
- package/dist/aws/runtime/dt-logger.js +5 -0
- package/dist/aws/runtime/environment.d.ts +1 -0
- package/dist/aws/runtime/environment.js +1 -0
- package/dist/aws/runtime/secrets/proxy-holder.d.ts +6 -1
- package/dist/aws/runtime/secrets/proxy-holder.js +6 -4
- package/dist/aws/runtime/secrets/rds-holder.d.ts +4 -1
- package/dist/aws/runtime/secrets/rds-holder.js +6 -4
- package/dist/database/database.d.ts +1 -1
- package/dist/database/database.js +1 -1
- package/dist/utils/lead-time-logging.d.ts +10 -0
- package/dist/utils/lead-time-logging.js +33 -0
- package/package.json +1 -1
|
@@ -1,314 +1,92 @@
|
|
|
1
1
|
import { expect, test } from "vitest";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
test("logging import ok?", () => {
|
|
83
|
-
const logging = import("../utils/logging.js");
|
|
84
|
-
return expect(logging).resolves.toBeDefined();
|
|
85
|
-
});
|
|
86
|
-
test("base64 import ok?", () => {
|
|
87
|
-
const base64 = import("../utils/base64.js");
|
|
88
|
-
return expect(base64).resolves.toBeDefined();
|
|
89
|
-
});
|
|
90
|
-
test("dateUtils import ok?", () => {
|
|
91
|
-
const dateUtils = import("../utils/date-utils.js");
|
|
92
|
-
return expect(dateUtils).resolves.toBeDefined();
|
|
93
|
-
});
|
|
94
|
-
test("geojsonTypes import ok?", () => {
|
|
95
|
-
const geojsonTypes = import("../utils/geojson-types.js");
|
|
96
|
-
return expect(geojsonTypes).resolves.toBeDefined();
|
|
97
|
-
});
|
|
98
|
-
test("slack import ok?", () => {
|
|
99
|
-
const slack = import("../utils/slack.js");
|
|
100
|
-
return expect(slack).resolves.toBeDefined();
|
|
101
|
-
});
|
|
102
|
-
test("stopWatch import ok?", () => {
|
|
103
|
-
const stopWatch = import("../utils/stop-watch.js");
|
|
104
|
-
return expect(stopWatch).resolves.toBeDefined();
|
|
105
|
-
});
|
|
106
|
-
test("utils import ok?", () => {
|
|
107
|
-
const utils = import("../utils/utils.js");
|
|
108
|
-
return expect(utils).resolves.toBeDefined();
|
|
109
|
-
});
|
|
110
|
-
test("retry import ok?", () => {
|
|
111
|
-
const retry = import("../utils/retry.js");
|
|
112
|
-
return expect(retry).resolves.toBeDefined();
|
|
113
|
-
});
|
|
114
|
-
test("geometry import ok?", () => {
|
|
115
|
-
const geometry = import("../utils/geometry.js");
|
|
116
|
-
return expect(geometry).resolves.toBeDefined();
|
|
117
|
-
});
|
|
118
|
-
test("sqsIntegration import ok?", () => {
|
|
119
|
-
const sqsIntegration = import("../aws/infra/sqs-integration.js");
|
|
120
|
-
return expect(sqsIntegration).resolves.toBeDefined();
|
|
121
|
-
});
|
|
122
|
-
test("networkStack import ok?", () => {
|
|
123
|
-
const networkStack = import("../aws/infra/stacks/network-stack.js");
|
|
124
|
-
return expect(networkStack).resolves.toBeDefined();
|
|
125
|
-
});
|
|
126
|
-
test("dbStack import ok?", () => {
|
|
127
|
-
const dbStack = import("../aws/infra/stacks/db-stack.js");
|
|
128
|
-
return expect(dbStack).resolves.toBeDefined();
|
|
129
|
-
});
|
|
130
|
-
test("dbProxyStack import ok?", () => {
|
|
131
|
-
const dbProxyStack = import("../aws/infra/stacks/db-proxy-stack.js");
|
|
132
|
-
return expect(dbProxyStack).resolves.toBeDefined();
|
|
133
|
-
});
|
|
134
|
-
test("intraStackConfiguration import ok?", () => {
|
|
135
|
-
const intraStackConfiguration = import("../aws/infra/stacks/intra-stack-configuration.js");
|
|
136
|
-
return expect(intraStackConfiguration).resolves.toBeDefined();
|
|
137
|
-
});
|
|
138
|
-
test("dbDnsStack import ok?", () => {
|
|
139
|
-
const dbDnsStack = import("../aws/infra/stacks/db-dns-stack.js");
|
|
140
|
-
return expect(dbDnsStack).resolves.toBeDefined();
|
|
141
|
-
});
|
|
142
|
-
test("documentation import ok?", () => {
|
|
143
|
-
const documentation = import("../aws/infra/documentation.js");
|
|
144
|
-
return expect(documentation).resolves.toBeDefined();
|
|
145
|
-
});
|
|
146
|
-
test("usagePlans import ok?", () => {
|
|
147
|
-
const usagePlans = import("../aws/infra/usage-plans.js");
|
|
148
|
-
return expect(usagePlans).resolves.toBeDefined();
|
|
149
|
-
});
|
|
150
|
-
test("scheduler import ok?", () => {
|
|
151
|
-
const scheduler = import("../aws/infra/scheduler.js");
|
|
152
|
-
return expect(scheduler).resolves.toBeDefined();
|
|
153
|
-
});
|
|
154
|
-
test("importUtil import ok?", () => {
|
|
155
|
-
const importUtil = import("../aws/infra/import-util.js");
|
|
156
|
-
return expect(importUtil).resolves.toBeDefined();
|
|
157
|
-
});
|
|
158
|
-
test("sqsQueue import ok?", () => {
|
|
159
|
-
const sqsQueue = import("../aws/infra/sqs-queue.js");
|
|
160
|
-
return expect(sqsQueue).resolves.toBeDefined();
|
|
161
|
-
});
|
|
162
|
-
test("response import ok?", () => {
|
|
163
|
-
const response = import("../aws/infra/api/response.js");
|
|
164
|
-
return expect(response).resolves.toBeDefined();
|
|
165
|
-
});
|
|
166
|
-
test("staticIntegration import ok?", () => {
|
|
167
|
-
const staticIntegration = import("../aws/infra/api/static-integration.js");
|
|
168
|
-
return expect(staticIntegration).resolves.toBeDefined();
|
|
169
|
-
});
|
|
170
|
-
test("responses import ok?", () => {
|
|
171
|
-
const responses = import("../aws/infra/api/responses.js");
|
|
172
|
-
return expect(responses).resolves.toBeDefined();
|
|
173
|
-
});
|
|
174
|
-
test("handlerFactory import ok?", () => {
|
|
175
|
-
const handlerFactory = import("../aws/infra/api/handler-factory.js");
|
|
176
|
-
return expect(handlerFactory).resolves.toBeDefined();
|
|
177
|
-
});
|
|
178
|
-
test("integration import ok?", () => {
|
|
179
|
-
const integration = import("../aws/infra/api/integration.js");
|
|
180
|
-
return expect(integration).resolves.toBeDefined();
|
|
181
|
-
});
|
|
182
|
-
test("stackCheckingAspect import ok?", () => {
|
|
183
|
-
const stackCheckingAspect = import("../aws/infra/stack/stack-checking-aspect.js");
|
|
184
|
-
return expect(stackCheckingAspect).resolves.toBeDefined();
|
|
185
|
-
});
|
|
186
|
-
test("restApis import ok?", () => {
|
|
187
|
-
const restApis = import("../aws/infra/stack/rest-api.js");
|
|
188
|
-
return expect(restApis).resolves.toBeDefined();
|
|
189
|
-
});
|
|
190
|
-
test("lambdaConfigs import ok?", () => {
|
|
191
|
-
const lambdaConfigs = import("../aws/infra/stack/lambda-configs.js");
|
|
192
|
-
return expect(lambdaConfigs).resolves.toBeDefined();
|
|
193
|
-
});
|
|
194
|
-
test("monitoredfunction import ok?", () => {
|
|
195
|
-
const monitoredfunction = import("../aws/infra/stack/monitoredfunction.js");
|
|
196
|
-
return expect(monitoredfunction).resolves.toBeDefined();
|
|
197
|
-
});
|
|
198
|
-
test("subscription import ok?", () => {
|
|
199
|
-
const subscription = import("../aws/infra/stack/subscription.js");
|
|
200
|
-
return expect(subscription).resolves.toBeDefined();
|
|
201
|
-
});
|
|
202
|
-
test("parameters import ok?", () => {
|
|
203
|
-
const parameters = import("../aws/infra/stack/parameters.js");
|
|
204
|
-
return expect(parameters).resolves.toBeDefined();
|
|
205
|
-
});
|
|
206
|
-
test("stack import ok?", () => {
|
|
207
|
-
const stack = import("../aws/infra/stack/stack.js");
|
|
208
|
-
return expect(stack).resolves.toBeDefined();
|
|
209
|
-
});
|
|
210
|
-
test("securityRule import ok?", () => {
|
|
211
|
-
const securityRule = import("../aws/infra/security-rule.js");
|
|
212
|
-
return expect(securityRule).resolves.toBeDefined();
|
|
213
|
-
});
|
|
214
|
-
test("canary import ok?", () => {
|
|
215
|
-
const canary = import("../aws/infra/canaries/canary.js");
|
|
216
|
-
return expect(canary).resolves.toBeDefined();
|
|
217
|
-
});
|
|
218
|
-
test("databaseCanary import ok?", () => {
|
|
219
|
-
const databaseCanary = import("../aws/infra/canaries/database-canary.js");
|
|
220
|
-
return expect(databaseCanary).resolves.toBeDefined();
|
|
221
|
-
});
|
|
222
|
-
test("canaryAlarm import ok?", () => {
|
|
223
|
-
const canaryAlarm = import("../aws/infra/canaries/canary-alarm.js");
|
|
224
|
-
return expect(canaryAlarm).resolves.toBeDefined();
|
|
225
|
-
});
|
|
226
|
-
test("canaryRole import ok?", () => {
|
|
227
|
-
const canaryRole = import("../aws/infra/canaries/canary-role.js");
|
|
228
|
-
return expect(canaryRole).resolves.toBeDefined();
|
|
229
|
-
});
|
|
230
|
-
test("urlCanary import ok?", () => {
|
|
231
|
-
const urlCanary = import("../aws/infra/canaries/url-canary.js");
|
|
232
|
-
return expect(urlCanary).resolves.toBeDefined();
|
|
233
|
-
});
|
|
234
|
-
test("canaryParameters import ok?", () => {
|
|
235
|
-
const canaryParameters = import("../aws/infra/canaries/canary-parameters.js");
|
|
236
|
-
return expect(canaryParameters).resolves.toBeDefined();
|
|
237
|
-
});
|
|
238
|
-
test("canaryKeys import ok?", () => {
|
|
239
|
-
const canaryKeys = import("../aws/infra/canaries/canary-keys.js");
|
|
240
|
-
return expect(canaryKeys).resolves.toBeDefined();
|
|
241
|
-
});
|
|
242
|
-
test("lambda-proxy-types import ok?", () => {
|
|
243
|
-
const proxytypes = import("../aws/types/lambda-proxy-types.js");
|
|
244
|
-
return expect(proxytypes).resolves.toBeDefined();
|
|
245
|
-
});
|
|
246
|
-
test("tags import ok?", () => {
|
|
247
|
-
const tags = import("../aws/types/tags.js");
|
|
248
|
-
return expect(tags).resolves.toBeDefined();
|
|
249
|
-
});
|
|
250
|
-
test("mediatypes import ok?", () => {
|
|
251
|
-
const mediatypes = import("../aws/types/mediatypes.js");
|
|
252
|
-
return expect(mediatypes).resolves.toBeDefined();
|
|
253
|
-
});
|
|
254
|
-
test("modelWithReference import ok?", () => {
|
|
255
|
-
const modelWithReference = import("../aws/types/model-with-reference.js");
|
|
256
|
-
return expect(modelWithReference).resolves.toBeDefined();
|
|
257
|
-
});
|
|
258
|
-
test("errors import ok?", () => {
|
|
259
|
-
const errors = import("../aws/types/errors.js");
|
|
260
|
-
return expect(errors).resolves.toBeDefined();
|
|
261
|
-
});
|
|
262
|
-
test("lambdaResponse import ok?", () => {
|
|
263
|
-
const lambdaResponse = import("../aws/types/lambda-response.js");
|
|
264
|
-
return expect(lambdaResponse).resolves.toBeDefined();
|
|
265
|
-
});
|
|
266
|
-
test("dtLoggerDefault import ok?", () => {
|
|
267
|
-
const dtLoggerDefault = import("../aws/runtime/dt-logger-default.js");
|
|
268
|
-
return expect(dtLoggerDefault).resolves.toBeDefined();
|
|
269
|
-
});
|
|
270
|
-
test("secret import ok?", () => {
|
|
271
|
-
const secret = import("../aws/runtime/secrets/secret.js");
|
|
272
|
-
return expect(secret).resolves.toBeDefined();
|
|
273
|
-
});
|
|
274
|
-
test("proxyHolder import ok?", () => {
|
|
275
|
-
const proxyHolder = import("../aws/runtime/secrets/proxy-holder.js");
|
|
276
|
-
return expect(proxyHolder).resolves.toBeDefined();
|
|
277
|
-
});
|
|
278
|
-
test("dbsecret import ok?", () => {
|
|
279
|
-
const dbsecret = import("../aws/runtime/secrets/dbsecret.js");
|
|
280
|
-
return expect(dbsecret).resolves.toBeDefined();
|
|
281
|
-
});
|
|
282
|
-
test("rdsHolder import ok?", () => {
|
|
283
|
-
const rdsHolder = import("../aws/runtime/secrets/rds-holder.js");
|
|
284
|
-
return expect(rdsHolder).resolves.toBeDefined();
|
|
285
|
-
});
|
|
286
|
-
test("secretHolder import ok?", () => {
|
|
287
|
-
const secretHolder = import("../aws/runtime/secrets/secret-holder.js");
|
|
288
|
-
return expect(secretHolder).resolves.toBeDefined();
|
|
289
|
-
});
|
|
290
|
-
test("dtLogger import ok?", () => {
|
|
291
|
-
const dtLogger = import("../aws/runtime/dt-logger.js");
|
|
292
|
-
return expect(dtLogger).resolves.toBeDefined();
|
|
293
|
-
});
|
|
294
|
-
test("s3 import ok?", () => {
|
|
295
|
-
const s3 = import("../aws/runtime/s3.js");
|
|
296
|
-
return expect(s3).resolves.toBeDefined();
|
|
297
|
-
});
|
|
2
|
+
const IMPORT_TEST_TIMEOUT_MS = 15_000;
|
|
3
|
+
function expectImportOk(name, path) {
|
|
4
|
+
test(name, async () => {
|
|
5
|
+
await expect(import(path)).resolves.toBeDefined();
|
|
6
|
+
}, IMPORT_TEST_TIMEOUT_MS);
|
|
7
|
+
}
|
|
8
|
+
expectImportOk("index import ok?", "../index.js");
|
|
9
|
+
expectImportOk("database import ok?", "../database/database.js");
|
|
10
|
+
expectImportOk("models import ok?", "../database/models.js");
|
|
11
|
+
expectImportOk("lastUpdated import ok?", "../database/last-updated.js");
|
|
12
|
+
expectImportOk("urn import ok?", "../types/urn.js");
|
|
13
|
+
expectImportOk("utilTypes import ok?", "../types/util-types.js");
|
|
14
|
+
expectImportOk("either import ok?", "../types/either.js");
|
|
15
|
+
expectImportOk("validator import ok?", "../types/validator.js");
|
|
16
|
+
expectImportOk("nullable import ok?", "../types/nullable.js");
|
|
17
|
+
expectImportOk("asyncTimeoutError import ok?", "../types/async-timeout-error.js");
|
|
18
|
+
expectImportOk("inputError import ok?", "../types/input-error.js");
|
|
19
|
+
expectImportOk("httpError import ok?", "../types/http-error.js");
|
|
20
|
+
expectImportOk("language import ok?", "../types/language.js");
|
|
21
|
+
expectImportOk("traffictype import ok?", "../types/traffictype.js");
|
|
22
|
+
expectImportOk("testutils import ok?", "../__test__/testutils.js");
|
|
23
|
+
expectImportOk("dbTestutils import ok?", "../__test__/db-testutils.js");
|
|
24
|
+
expectImportOk("asserter import ok?", "../__test__/asserter.js");
|
|
25
|
+
expectImportOk("rtz import ok?", "../marine/rtz.js");
|
|
26
|
+
expectImportOk("idUtils import ok?", "../marine/id_utils.js");
|
|
27
|
+
expectImportOk("apiModel import ok?", "../utils/api-model.js");
|
|
28
|
+
expectImportOk("logging import ok?", "../utils/logging.js");
|
|
29
|
+
expectImportOk("base64 import ok?", "../utils/base64.js");
|
|
30
|
+
expectImportOk("dateUtils import ok?", "../utils/date-utils.js");
|
|
31
|
+
expectImportOk("geojsonTypes import ok?", "../utils/geojson-types.js");
|
|
32
|
+
expectImportOk("slack import ok?", "../utils/slack.js");
|
|
33
|
+
expectImportOk("stopWatch import ok?", "../utils/stop-watch.js");
|
|
34
|
+
expectImportOk("utils import ok?", "../utils/utils.js");
|
|
35
|
+
expectImportOk("retry import ok?", "../utils/retry.js");
|
|
36
|
+
expectImportOk("geometry import ok?", "../utils/geometry.js");
|
|
37
|
+
expectImportOk("sqsIntegration import ok?", "../aws/infra/sqs-integration.js");
|
|
38
|
+
expectImportOk("networkStack import ok?", "../aws/infra/stacks/network-stack.js");
|
|
39
|
+
expectImportOk("dbStack import ok?", "../aws/infra/stacks/db-stack.js");
|
|
40
|
+
expectImportOk("dbProxyStack import ok?", "../aws/infra/stacks/db-proxy-stack.js");
|
|
41
|
+
expectImportOk("intraStackConfiguration import ok?", "../aws/infra/stacks/intra-stack-configuration.js");
|
|
42
|
+
expectImportOk("dbDnsStack import ok?", "../aws/infra/stacks/db-dns-stack.js");
|
|
43
|
+
expectImportOk("documentation import ok?", "../aws/infra/documentation.js");
|
|
44
|
+
expectImportOk("usagePlans import ok?", "../aws/infra/usage-plans.js");
|
|
45
|
+
expectImportOk("scheduler import ok?", "../aws/infra/scheduler.js");
|
|
46
|
+
expectImportOk("importUtil import ok?", "../aws/infra/import-util.js");
|
|
47
|
+
expectImportOk("sqsQueue import ok?", "../aws/infra/sqs-queue.js");
|
|
48
|
+
expectImportOk("response import ok?", "../aws/infra/api/response.js");
|
|
49
|
+
expectImportOk("staticIntegration import ok?", "../aws/infra/api/static-integration.js");
|
|
50
|
+
expectImportOk("responses import ok?", "../aws/infra/api/responses.js");
|
|
51
|
+
expectImportOk("handlerFactory import ok?", "../aws/infra/api/handler-factory.js");
|
|
52
|
+
expectImportOk("integration import ok?", "../aws/infra/api/integration.js");
|
|
53
|
+
expectImportOk("stackCheckingAspect import ok?", "../aws/infra/stack/stack-checking-aspect.js");
|
|
54
|
+
expectImportOk("restApis import ok?", "../aws/infra/stack/rest-api.js");
|
|
55
|
+
expectImportOk("lambdaConfigs import ok?", "../aws/infra/stack/lambda-configs.js");
|
|
56
|
+
expectImportOk("monitoredfunction import ok?", "../aws/infra/stack/monitoredfunction.js");
|
|
57
|
+
expectImportOk("subscription import ok?", "../aws/infra/stack/subscription.js");
|
|
58
|
+
expectImportOk("parameters import ok?", "../aws/infra/stack/parameters.js");
|
|
59
|
+
expectImportOk("stack import ok?", "../aws/infra/stack/stack.js");
|
|
60
|
+
expectImportOk("securityRule import ok?", "../aws/infra/security-rule.js");
|
|
61
|
+
expectImportOk("canary import ok?", "../aws/infra/canaries/canary.js");
|
|
62
|
+
expectImportOk("databaseCanary import ok?", "../aws/infra/canaries/database-canary.js");
|
|
63
|
+
expectImportOk("canaryAlarm import ok?", "../aws/infra/canaries/canary-alarm.js");
|
|
64
|
+
expectImportOk("canaryRole import ok?", "../aws/infra/canaries/canary-role.js");
|
|
65
|
+
expectImportOk("urlCanary import ok?", "../aws/infra/canaries/url-canary.js");
|
|
66
|
+
expectImportOk("canaryParameters import ok?", "../aws/infra/canaries/canary-parameters.js");
|
|
67
|
+
expectImportOk("canaryKeys import ok?", "../aws/infra/canaries/canary-keys.js");
|
|
68
|
+
expectImportOk("lambda-proxy-types import ok?", "../aws/types/lambda-proxy-types.js");
|
|
69
|
+
expectImportOk("tags import ok?", "../aws/types/tags.js");
|
|
70
|
+
expectImportOk("mediatypes import ok?", "../aws/types/mediatypes.js");
|
|
71
|
+
expectImportOk("modelWithReference import ok?", "../aws/types/model-with-reference.js");
|
|
72
|
+
expectImportOk("errors import ok?", "../aws/types/errors.js");
|
|
73
|
+
expectImportOk("lambdaResponse import ok?", "../aws/types/lambda-response.js");
|
|
74
|
+
expectImportOk("dtLoggerDefault import ok?", "../aws/runtime/dt-logger-default.js");
|
|
75
|
+
expectImportOk("secret import ok?", "../aws/runtime/secrets/secret.js");
|
|
76
|
+
expectImportOk("proxyHolder import ok?", "../aws/runtime/secrets/proxy-holder.js");
|
|
77
|
+
expectImportOk("dbsecret import ok?", "../aws/runtime/secrets/dbsecret.js");
|
|
78
|
+
expectImportOk("rdsHolder import ok?", "../aws/runtime/secrets/rds-holder.js");
|
|
79
|
+
expectImportOk("secretHolder import ok?", "../aws/runtime/secrets/secret-holder.js");
|
|
80
|
+
expectImportOk("dtLogger import ok?", "../aws/runtime/dt-logger.js");
|
|
81
|
+
expectImportOk("s3 import ok?", "../aws/runtime/s3.js");
|
|
298
82
|
/*
|
|
299
83
|
temporary disable, enable after sdk v2 is kicked out
|
|
300
84
|
test('apikey import ok?', () => {
|
|
301
85
|
const apikey = import("../aws/runtime/apikey.js");
|
|
302
86
|
return expect(apikey).resolves.toBeDefined();
|
|
303
87
|
});*/
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
return expect(environment).resolves.toBeDefined();
|
|
307
|
-
});
|
|
308
|
-
test("digitrafficIntegrationResponse import ok?", () => {
|
|
309
|
-
const digitrafficIntegrationResponse = import("../aws/runtime/digitraffic-integration-response.js");
|
|
310
|
-
return expect(digitrafficIntegrationResponse).resolves.toBeDefined();
|
|
311
|
-
});
|
|
88
|
+
expectImportOk("environment import ok?", "../aws/runtime/environment.js");
|
|
89
|
+
expectImportOk("digitrafficIntegrationResponse import ok?", "../aws/runtime/digitraffic-integration-response.js");
|
|
312
90
|
/*
|
|
313
91
|
* Näitä ei testata, koska ne importtaa synthetics kirjaston, jolle ei ole mitään vastinetta npm:ssä. Lambdaympäristöstä
|
|
314
92
|
* löytyy toi kirjasto.
|
|
@@ -51,6 +51,24 @@ describe("acl-builder tests", () => {
|
|
|
51
51
|
expect(throttleRule.action.block).toBeDefined();
|
|
52
52
|
}
|
|
53
53
|
});
|
|
54
|
+
test("anonymous uri-path throttle can exclude a path", () => {
|
|
55
|
+
const acl = createBuilder()
|
|
56
|
+
.withThrottleAnonymousUserIpAndUriPath(100, /^\/roadnetwork\//)
|
|
57
|
+
.build();
|
|
58
|
+
const rule = acl.rules[0];
|
|
59
|
+
const statement = rule?.statement;
|
|
60
|
+
const rateBased = statement.rateBasedStatement;
|
|
61
|
+
const scopeDown = rateBased.scopeDownStatement;
|
|
62
|
+
const scopeDownStatement = scopeDown;
|
|
63
|
+
const andStatement = scopeDownStatement.andStatement;
|
|
64
|
+
const scopeDownStatements = (andStatement.statements ??
|
|
65
|
+
[]);
|
|
66
|
+
const excludedStatement = scopeDownStatements[1];
|
|
67
|
+
const excludedPathStatement = excludedStatement.notStatement;
|
|
68
|
+
const regexMatchStatement = excludedPathStatement.statement.regexMatchStatement;
|
|
69
|
+
expect(scopeDownStatements).toHaveLength(2);
|
|
70
|
+
expect(regexMatchStatement.regexString).toBe("^\\/roadnetwork\\/");
|
|
71
|
+
});
|
|
54
72
|
test("Cannot define two rules with the same name", () => {
|
|
55
73
|
expect(() => createBuilder()
|
|
56
74
|
.withThrottleAnonymousUserIp(10)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { App } from "aws-cdk-lib";
|
|
2
|
+
import { AssetCode } from "aws-cdk-lib/aws-lambda";
|
|
3
|
+
import { describe, expect, test } from "vitest";
|
|
4
|
+
import { FunctionBuilder } from "../../../aws/infra/stack/dt-function.js";
|
|
5
|
+
import { DigitrafficStack } from "../../../aws/infra/stack/stack.js";
|
|
6
|
+
function createStack() {
|
|
7
|
+
const app = new App();
|
|
8
|
+
return new DigitrafficStack(app, "TestStack", {
|
|
9
|
+
shortName: "TEST",
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
function getCode(builder) {
|
|
13
|
+
return builder.code;
|
|
14
|
+
}
|
|
15
|
+
function getHandler(builder) {
|
|
16
|
+
return builder.handler;
|
|
17
|
+
}
|
|
18
|
+
describe("FunctionBuilder.withAssetCode", () => {
|
|
19
|
+
test("uses lambdaName as default path", () => {
|
|
20
|
+
const stack = createStack();
|
|
21
|
+
const builder = FunctionBuilder.create(stack, "feature/subfeature/lambda-implementation");
|
|
22
|
+
const code = getCode(builder);
|
|
23
|
+
expect(code).toBeInstanceOf(AssetCode);
|
|
24
|
+
expect(code.path).toBe("dist/lambda/feature/subfeature/lambda-implementation");
|
|
25
|
+
});
|
|
26
|
+
test("uses custom path when provided", () => {
|
|
27
|
+
const stack = createStack();
|
|
28
|
+
const builder = FunctionBuilder.create(stack, "feature/subfeature/lambda-implementation").withAssetCode("feature/subfeature/lambda-implementation");
|
|
29
|
+
const code = getCode(builder);
|
|
30
|
+
expect(code.path).toBe("dist/lambda/feature/subfeature/lambda-implementation");
|
|
31
|
+
});
|
|
32
|
+
test("returns this for chaining when called without exclude", () => {
|
|
33
|
+
const stack = createStack();
|
|
34
|
+
const builder = FunctionBuilder.create(stack, "feature/subfeature/lambda-implementation");
|
|
35
|
+
expect(builder.withAssetCode("feature/subfeature/lambda-implementation")).toBe(builder);
|
|
36
|
+
});
|
|
37
|
+
test("accepts exclude list and uses correct path", () => {
|
|
38
|
+
const stack = createStack();
|
|
39
|
+
const builder = FunctionBuilder.create(stack, "feature/shared").withAssetCode("feature/shared", [
|
|
40
|
+
"handler-a/**",
|
|
41
|
+
"handler-b/**",
|
|
42
|
+
"handler-c/**",
|
|
43
|
+
]);
|
|
44
|
+
const code = getCode(builder);
|
|
45
|
+
expect(code).toBeInstanceOf(AssetCode);
|
|
46
|
+
expect(code.path).toBe("dist/lambda/feature/shared");
|
|
47
|
+
});
|
|
48
|
+
test("returns this for chaining when called with exclude", () => {
|
|
49
|
+
const stack = createStack();
|
|
50
|
+
const builder = FunctionBuilder.create(stack, "feature/shared");
|
|
51
|
+
expect(builder.withAssetCode("feature/shared", ["handler-a/**"])).toBe(builder);
|
|
52
|
+
});
|
|
53
|
+
test("exclude is optional — undefined behaves same as no exclude", () => {
|
|
54
|
+
const stack = createStack();
|
|
55
|
+
const builderWithout = FunctionBuilder.create(stack, "test/lambda");
|
|
56
|
+
const builderWithUndefined = FunctionBuilder.create(stack, "test/lambda2").withAssetCode("test/lambda2", undefined);
|
|
57
|
+
expect(getCode(builderWithout).path).toBe("dist/lambda/test/lambda");
|
|
58
|
+
expect(getCode(builderWithUndefined).path).toBe("dist/lambda/test/lambda2");
|
|
59
|
+
});
|
|
60
|
+
test("handler uses basename(path), not the full path", () => {
|
|
61
|
+
const stack = createStack();
|
|
62
|
+
// Without explicit withAssetCode — constructor default
|
|
63
|
+
const builderDefault = FunctionBuilder.create(stack, "feature/shared");
|
|
64
|
+
expect(getHandler(builderDefault)).toBe("shared.handler");
|
|
65
|
+
// With explicit withAssetCode (e.g. to pass exclude) — must also use basename
|
|
66
|
+
const builderExplicit = FunctionBuilder.create(stack, "feature/shared2").withAssetCode("feature/shared2", ["handler-a/**"]);
|
|
67
|
+
expect(getHandler(builderExplicit)).toBe("shared2.handler");
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
//# sourceMappingURL=dt-function.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { App } from "aws-cdk-lib";
|
|
2
|
+
import { describe, expect, test } from "vitest";
|
|
3
|
+
import { DigitrafficStack } from "../../../aws/infra/stack/stack.js";
|
|
4
|
+
import { EnvKeys } from "../../../aws/runtime/environment.js";
|
|
5
|
+
import { TrafficType } from "../../../types/traffictype.js";
|
|
6
|
+
function createStack(secretId) {
|
|
7
|
+
const configuration = {
|
|
8
|
+
shortName: "VS",
|
|
9
|
+
trafficType: TrafficType.ROAD,
|
|
10
|
+
secretId,
|
|
11
|
+
alarmTopicArn: "",
|
|
12
|
+
warningTopicArn: "",
|
|
13
|
+
production: false,
|
|
14
|
+
stackProps: {},
|
|
15
|
+
};
|
|
16
|
+
return new DigitrafficStack(new App(), "TestStack", configuration);
|
|
17
|
+
}
|
|
18
|
+
describe("DigitrafficStack.createDefaultLambdaEnvironment", () => {
|
|
19
|
+
test("includes the application name without a secret", () => {
|
|
20
|
+
expect(createStack().createDefaultLambdaEnvironment("variable-signs")).toEqual({
|
|
21
|
+
[EnvKeys.APP_NAME]: "road-vs",
|
|
22
|
+
DB_APPLICATION: "variable-signs",
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
test("preserves the secret configuration", () => {
|
|
26
|
+
expect(createStack("test-secret").createDefaultLambdaEnvironment("variable-signs")).toEqual({
|
|
27
|
+
[EnvKeys.APP_NAME]: "road-vs",
|
|
28
|
+
DB_APPLICATION: "variable-signs",
|
|
29
|
+
SECRET_ID: "test-secret",
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
//# sourceMappingURL=stack.test.js.map
|