@digitraffic/common 2026.8.31-2 → 2026.9.4-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 (30) hide show
  1. package/dist/__test__/imports.test.js +304 -82
  2. package/dist/__test__/infra/acl-builder.test.js +0 -18
  3. package/dist/__test__/stack/dt-function.test.js +121 -3
  4. package/dist/aws/infra/acl-builder.d.ts +2 -21
  5. package/dist/aws/infra/acl-builder.js +6 -54
  6. package/dist/aws/infra/canaries/database-checker.js +3 -2
  7. package/dist/aws/infra/stack/dt-function.d.ts +11 -13
  8. package/dist/aws/infra/stack/dt-function.js +49 -23
  9. package/dist/aws/infra/stack/stack-checking-aspect.js +2 -1
  10. package/dist/aws/infra/stack/stack.d.ts +0 -2
  11. package/dist/aws/infra/stack/stack.js +8 -9
  12. package/dist/aws/runtime/dt-logger.d.ts +0 -1
  13. package/dist/aws/runtime/dt-logger.js +0 -5
  14. package/dist/aws/runtime/environment.d.ts +0 -1
  15. package/dist/aws/runtime/environment.js +0 -1
  16. package/dist/aws/runtime/secrets/proxy-holder.d.ts +1 -6
  17. package/dist/aws/runtime/secrets/proxy-holder.js +4 -6
  18. package/dist/aws/runtime/secrets/rds-holder.d.ts +1 -4
  19. package/dist/aws/runtime/secrets/rds-holder.js +4 -6
  20. package/dist/database/database.d.ts +1 -1
  21. package/dist/database/database.js +1 -1
  22. package/package.json +1 -1
  23. package/dist/__test__/infra/stack/dt-function.test.d.ts +0 -1
  24. package/dist/__test__/infra/stack/dt-function.test.js +0 -70
  25. package/dist/__test__/infra/stack/stack.test.d.ts +0 -1
  26. package/dist/__test__/infra/stack/stack.test.js +0 -33
  27. package/dist/__test__/utils/lead-time-logging.test.d.ts +0 -1
  28. package/dist/__test__/utils/lead-time-logging.test.js +0 -153
  29. package/dist/utils/lead-time-logging.d.ts +0 -10
  30. package/dist/utils/lead-time-logging.js +0 -33
@@ -1,92 +1,314 @@
1
1
  import { expect, test } from "vitest";
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");
2
+ test("index import ok?", () => {
3
+ const index = import("../index.js");
4
+ return expect(index).resolves.toBeDefined();
5
+ });
6
+ test("database import ok?", () => {
7
+ const database = import("../database/database.js");
8
+ return expect(database).resolves.toBeDefined();
9
+ });
10
+ test("models import ok?", () => {
11
+ const models = import("../database/models.js");
12
+ return expect(models).resolves.toBeDefined();
13
+ });
14
+ test("lastUpdated import ok?", () => {
15
+ const lastUpdated = import("../database/last-updated.js");
16
+ return expect(lastUpdated).resolves.toBeDefined();
17
+ });
18
+ test("urn import ok?", () => {
19
+ const urn = import("../types/urn.js");
20
+ return expect(urn).resolves.toBeDefined();
21
+ });
22
+ test("utilTypes import ok?", () => {
23
+ const utilTypes = import("../types/util-types.js");
24
+ return expect(utilTypes).resolves.toBeDefined();
25
+ });
26
+ test("either import ok?", () => {
27
+ const either = import("../types/either.js");
28
+ return expect(either).resolves.toBeDefined();
29
+ });
30
+ test("validator import ok?", () => {
31
+ const validator = import("../types/validator.js");
32
+ return expect(validator).resolves.toBeDefined();
33
+ });
34
+ test("nullable import ok?", () => {
35
+ const nullable = import("../types/nullable.js");
36
+ return expect(nullable).resolves.toBeDefined();
37
+ });
38
+ test("asyncTimeoutError import ok?", () => {
39
+ const asyncTimeoutError = import("../types/async-timeout-error.js");
40
+ return expect(asyncTimeoutError).resolves.toBeDefined();
41
+ });
42
+ test("inputError import ok?", () => {
43
+ const inputError = import("../types/input-error.js");
44
+ return expect(inputError).resolves.toBeDefined();
45
+ });
46
+ test("httpError import ok?", () => {
47
+ const httpError = import("../types/http-error.js");
48
+ return expect(httpError).resolves.toBeDefined();
49
+ });
50
+ test("language import ok?", () => {
51
+ const language = import("../types/language.js");
52
+ return expect(language).resolves.toBeDefined();
53
+ });
54
+ test("traffictype import ok?", () => {
55
+ const traffictype = import("../types/traffictype.js");
56
+ return expect(traffictype).resolves.toBeDefined();
57
+ });
58
+ test("testutils import ok?", () => {
59
+ const testutils = import("../__test__/testutils.js");
60
+ return expect(testutils).resolves.toBeDefined();
61
+ });
62
+ test("dbTestutils import ok?", () => {
63
+ const dbTestutils = import("../__test__/db-testutils.js");
64
+ return expect(dbTestutils).resolves.toBeDefined();
65
+ });
66
+ test("asserter import ok?", () => {
67
+ const asserter = import("../__test__/asserter.js");
68
+ return expect(asserter).resolves.toBeDefined();
69
+ });
70
+ test("rtz import ok?", () => {
71
+ const rtz = import("../marine/rtz.js");
72
+ return expect(rtz).resolves.toBeDefined();
73
+ });
74
+ test("idUtils import ok?", () => {
75
+ const idUtils = import("../marine/id_utils.js");
76
+ return expect(idUtils).resolves.toBeDefined();
77
+ });
78
+ test("apiModel import ok?", () => {
79
+ const apiModel = import("../utils/api-model.js");
80
+ return expect(apiModel).resolves.toBeDefined();
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
+ });
82
298
  /*
83
299
  temporary disable, enable after sdk v2 is kicked out
84
300
  test('apikey import ok?', () => {
85
301
  const apikey = import("../aws/runtime/apikey.js");
86
302
  return expect(apikey).resolves.toBeDefined();
87
303
  });*/
88
- expectImportOk("environment import ok?", "../aws/runtime/environment.js");
89
- expectImportOk("digitrafficIntegrationResponse import ok?", "../aws/runtime/digitraffic-integration-response.js");
304
+ test("environment import ok?", () => {
305
+ const environment = import("../aws/runtime/environment.js");
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
+ });
90
312
  /*
91
313
  * Näitä ei testata, koska ne importtaa synthetics kirjaston, jolle ei ole mitään vastinetta npm:ssä. Lambdaympäristöstä
92
314
  * löytyy toi kirjasto.
@@ -51,24 +51,6 @@ 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
- });
72
54
  test("Cannot define two rules with the same name", () => {
73
55
  expect(() => createBuilder()
74
56
  .withThrottleAnonymousUserIp(10)
@@ -61,7 +61,6 @@ describe("FunctionBuilder test", () => {
61
61
  template.hasResourceProperties("AWS::Lambda::Function", {
62
62
  Environment: {
63
63
  Variables: {
64
- [EnvKeys.APP_NAME]: "road-test",
65
64
  [EnvKeys.SECRET_ID]: "testSecret",
66
65
  [TEST_ENV_VAR]: TEST_ENV_VALUE,
67
66
  },
@@ -140,9 +139,11 @@ describe("FunctionBuilder test", () => {
140
139
  });
141
140
  });
142
141
  test("Lambda handler module is resolved from path last element", () => {
143
- const template = createTemplate((_builder) => { }, false, "api/feature/v1/get-items");
142
+ const template = createTemplate((_builder) => { }, false, "api/charging-network/v1/operators");
143
+ // const lambdas = template.findResources("AWS::Lambda::Function");
144
+ // console.debug(JSON.stringify(lambdas, null, 2));
144
145
  template.hasResourceProperties("AWS::Lambda::Function", {
145
- Handler: "get-items.handler",
146
+ Handler: "operators.handler",
146
147
  });
147
148
  });
148
149
  test("Lambda handler module is same as lambda name", () => {
@@ -335,5 +336,122 @@ describe("FunctionBuilder test", () => {
335
336
  .build();
336
337
  }).toThrow('Lambda test-Test cannot use wildcard action "*" in withAllowedActions');
337
338
  });
339
+ describe("withAdotTracing", () => {
340
+ test("given withAdotTracing is called / when lambda is built / then AWS_LAMBDA_EXEC_WRAPPER is set", () => {
341
+ // given/when
342
+ const template = createTemplate((builder) => {
343
+ builder.withAdotTracing();
344
+ });
345
+ // then
346
+ expectEnvironmentValue(template, "AWS_LAMBDA_EXEC_WRAPPER", "/opt/otel-instrument");
347
+ });
348
+ test("given withAdotTracing is called / when lambda is built / then OTEL_AWS_APPLICATION_SIGNALS_ENABLED is false", () => {
349
+ // given/when
350
+ const template = createTemplate((builder) => {
351
+ builder.withAdotTracing();
352
+ });
353
+ // then
354
+ expectEnvironmentValue(template, "OTEL_AWS_APPLICATION_SIGNALS_ENABLED", "false");
355
+ });
356
+ test("given withAdotTracing is called / when lambda is built / then X-Ray active tracing is enabled", () => {
357
+ // given/when
358
+ const template = createTemplate((builder) => {
359
+ builder.withAdotTracing();
360
+ });
361
+ // then
362
+ template.hasResourceProperties("AWS::Lambda::Function", {
363
+ TracingConfig: { Mode: "Active" },
364
+ });
365
+ });
366
+ test("given withAdotTracing is called / when lambda is built / then CloudWatch Lambda Application Signals policy is attached", () => {
367
+ // given/when
368
+ const template = createTemplate((builder) => {
369
+ builder.withAdotTracing();
370
+ });
371
+ // then — the managed policy ARN contains CloudWatchLambdaApplicationSignalsExecutionRolePolicy
372
+ const roles = template.findResources("AWS::IAM::Role");
373
+ const lambdaRoleKey = Object.keys(roles).find((key) => key.includes("ServiceRole"));
374
+ expect(lambdaRoleKey).toBeDefined();
375
+ const role = roles[lambdaRoleKey];
376
+ const managedPolicyArns = JSON.stringify(role["Properties"]?.["ManagedPolicyArns"]);
377
+ expect(managedPolicyArns).toContain("CloudWatchLambdaApplicationSignalsExecutionRolePolicy");
378
+ });
379
+ test("given withAdotTracing on Node.js runtime / when lambda is built / then JS ADOT layer is attached", () => {
380
+ // given/when — default runtime is NODEJS_24_X
381
+ const template = createTemplate((builder) => {
382
+ builder.withAdotTracing();
383
+ });
384
+ // then
385
+ template.hasResourceProperties("AWS::Lambda::Function", {
386
+ Layers: Match.arrayWith([
387
+ Match.stringLikeRegexp("AWSOpenTelemetryDistroJs"),
388
+ ]),
389
+ });
390
+ });
391
+ test("given withAdotTracing on Python runtime / when lambda is built / then Python ADOT layer is attached", () => {
392
+ // given/when
393
+ const template = createTemplate((builder) => {
394
+ builder.withRuntime(Runtime.PYTHON_3_12).withAdotTracing();
395
+ });
396
+ // then
397
+ template.hasResourceProperties("AWS::Lambda::Function", {
398
+ Layers: Match.arrayWith([
399
+ Match.stringLikeRegexp("AWSOpenTelemetryDistroPython"),
400
+ ]),
401
+ });
402
+ });
403
+ test("given withAdotTracing is NOT called / when lambda is built / then ADOT env vars are absent", () => {
404
+ // given/when
405
+ const template = createTemplate((_builder) => { });
406
+ // then
407
+ expectEnvironmentValueMissing(template, "AWS_LAMBDA_EXEC_WRAPPER");
408
+ expectEnvironmentValueMissing(template, "OTEL_AWS_APPLICATION_SIGNALS_ENABLED");
409
+ });
410
+ test("given withAdotTracing is NOT called / when lambda is built / then tracing is not Active", () => {
411
+ // given/when
412
+ const template = createTemplate((_builder) => { });
413
+ // then
414
+ template.hasResourceProperties("AWS::Lambda::Function", {
415
+ TracingConfig: Match.absent(),
416
+ });
417
+ });
418
+ test("given withAdotTracing combined with other builder methods / when lambda is built / then all properties are present", () => {
419
+ // given/when
420
+ const template = createTemplate((builder) => {
421
+ builder
422
+ .withAdotTracing()
423
+ .withMemorySize(512)
424
+ .withTimeout(Duration.seconds(30))
425
+ .withEnvironment({ CUSTOM_KEY: "custom_value" });
426
+ });
427
+ // then — ADOT config present
428
+ expectEnvironmentValue(template, "AWS_LAMBDA_EXEC_WRAPPER", "/opt/otel-instrument");
429
+ template.hasResourceProperties("AWS::Lambda::Function", {
430
+ TracingConfig: { Mode: "Active" },
431
+ });
432
+ // then — other builder settings also present
433
+ template.hasResourceProperties("AWS::Lambda::Function", {
434
+ MemorySize: 512,
435
+ Timeout: 30,
436
+ });
437
+ expectEnvironmentValue(template, "CUSTOM_KEY", "custom_value");
438
+ });
439
+ test("given withAdotTracing on plain builder / when lambda is built / then ADOT config is applied without database env vars", () => {
440
+ // given/when
441
+ const template = createTemplate((builder) => {
442
+ builder.withAdotTracing();
443
+ }, true);
444
+ // then — ADOT config present
445
+ expectEnvironmentValue(template, "AWS_LAMBDA_EXEC_WRAPPER", "/opt/otel-instrument");
446
+ template.hasResourceProperties("AWS::Lambda::Function", {
447
+ TracingConfig: { Mode: "Active" },
448
+ Layers: Match.arrayWith([
449
+ Match.stringLikeRegexp("AWSOpenTelemetryDistroJs"),
450
+ ]),
451
+ });
452
+ // then — no database env vars
453
+ expectEnvironmentValueMissing(template, "DB_APPLICATION");
454
+ });
455
+ });
338
456
  });
339
457
  //# sourceMappingURL=dt-function.test.js.map
@@ -32,32 +32,13 @@ export declare class AclBuilder {
32
32
  * Allow access only from the given addresses
33
33
  */
34
34
  withIpWhitelistRule(addresses: string[]): this;
35
- /**
36
- * Adds a rate-based WAF rule for either blocking or counting requests.
37
- *
38
- * @param name WAF rule name and CloudWatch metric name.
39
- * @param limit Maximum requests allowed in the WAF evaluation window.
40
- * @param isHeaderRequired Whether the rule applies when the digitraffic-user header is present.
41
- * @param isBasedOnIpAndUriPath Whether requests are aggregated by IP address and URI path.
42
- * @param customResponseBodyKey Custom response body key; when provided, matching requests are blocked instead of counted.
43
- * @param path Optional URI path pattern that limits which requests are included.
44
- * @param excludedPath Optional URI path pattern that excludes matching requests from the rule.
45
- */
46
- withThrottleRule(name: string, limit: number, isHeaderRequired: boolean, isBasedOnIpAndUriPath: boolean, customResponseBodyKey?: string, path?: RegExp, excludedPath?: RegExp): this;
35
+ withThrottleRule(name: string, limit: number, isHeaderRequired: boolean, isBasedOnIpAndUriPath: boolean, customResponseBodyKey?: string, path?: RegExp): this;
47
36
  withCustomResponseBody(key: string, customResponseBody: CfnWebACL.CustomResponseBodyProperty): this;
48
37
  withThrottleDigitrafficUserIp(limit: number | undefined): this;
49
38
  withThrottleDigitrafficUserIpAndUriPath(limit: number | undefined): this;
50
39
  withThrottleAnonymousUserIp(limit: number | undefined): AclBuilder;
51
40
  withThrottleAnonymousUserIpByUriPath(limit: number | undefined, path: RegExp | undefined): AclBuilder;
52
- /**
53
- * Throttles anonymous requests by IP address and URI path.
54
- *
55
- * Existing callers that omit `excludedPath` retain the previous behavior.
56
- *
57
- * @param limit Maximum requests allowed for each IP and URI path combination.
58
- * @param excludedPath Optional URI path pattern excluded from this throttle rule.
59
- */
60
- withThrottleAnonymousUserIpAndUriPath(limit: number | undefined, excludedPath?: RegExp): this;
41
+ withThrottleAnonymousUserIpAndUriPath(limit: number | undefined): this;
61
42
  withCountDigitrafficUserIp(limit: number | undefined): this;
62
43
  withCountDigitrafficUserIpAndUriPath(limit: number | undefined): this;
63
44
  withCountAnonymousUserIp(limit: number | undefined): this;