@digitraffic/common 2026.4.14-1 → 2026.4.17-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 (41) hide show
  1. package/dist/__test__/asserter.js +3 -1
  2. package/dist/__test__/db-testutils.js +0 -1
  3. package/dist/__test__/dependencies.test.js +1 -1
  4. package/dist/__test__/imports.test.js +1 -1
  5. package/dist/__test__/infra/acl-builder.test.js +1 -1
  6. package/dist/__test__/infra/api/handler-factory.test.js +6 -6
  7. package/dist/__test__/infra/api/integration.test.js +0 -1
  8. package/dist/__test__/infra/api/response.test.js +0 -1
  9. package/dist/__test__/infra/api/static-integration.test.js +2 -3
  10. package/dist/__test__/infra/documentation.test.js +0 -1
  11. package/dist/__test__/infra/scheduler.test.js +0 -1
  12. package/dist/__test__/infra/security-rule.test.js +0 -1
  13. package/dist/__test__/infra/stack/rest-apis.test.js +0 -1
  14. package/dist/__test__/marine/id_utils.test.js +0 -1
  15. package/dist/__test__/promise/promise.test.js +17 -17
  16. package/dist/__test__/runtime/dt-logger.test.js +0 -1
  17. package/dist/__test__/secrets/secret-holder.test.js +5 -3
  18. package/dist/__test__/secrets/secret.test.js +5 -7
  19. package/dist/__test__/stack/dt-function.test.js +0 -1
  20. package/dist/__test__/stack/rest-apis.test.js +0 -1
  21. package/dist/__test__/test/mock-ky.test.js +35 -13
  22. package/dist/__test__/types/lambda-proxy-types.test.js +0 -1
  23. package/dist/__test__/types/lambda-response-builder.test.js +0 -1
  24. package/dist/__test__/types/lambda-response.test.js +0 -1
  25. package/dist/__test__/utils/base64.test.js +0 -1
  26. package/dist/__test__/utils/date-utils.test.js +0 -1
  27. package/dist/__test__/utils/geometry.test.js +0 -1
  28. package/dist/__test__/utils/lambda-proxy-event.test.js +0 -1
  29. package/dist/__test__/utils/logging.test.js +0 -1
  30. package/dist/__test__/utils/stop-watch.test.js +1 -1
  31. package/dist/__test__/utils/utils.test.js +0 -1
  32. package/dist/aws/infra/stack/dt-function.d.ts +4 -11
  33. package/dist/aws/infra/stack/dt-function.js +0 -9
  34. package/dist/aws/infra/stack/lambda-log-group.d.ts +2 -2
  35. package/dist/aws/infra/stack/rest-api.d.ts +2 -3
  36. package/dist/aws/infra/stack/stack-checking-aspect.js +2 -8
  37. package/dist/aws/infra/stack/stack.d.ts +1 -12
  38. package/dist/aws/infra/stacks/network-stack.d.ts +0 -1
  39. package/dist/aws/infra/stacks/network-stack.js +0 -2
  40. package/dist/index.d.ts +0 -1
  41. package/package.json +29 -29
@@ -1,4 +1,6 @@
1
- import { expect } from "vitest";
1
+ /**
2
+ * A simple asserter-class for writing canaries without dependency to testing-libraries.
3
+ */
2
4
  export const Asserter = {
3
5
  assertEquals(value, expected) {
4
6
  if (value !== expected) {
@@ -1,4 +1,3 @@
1
- import { afterAll, beforeAll, beforeEach, expect } from "vitest";
2
1
  import { DatabaseEnvironmentKeys, initDbConnection, } from "../database/database.js";
3
2
  import { getEnvVariableOrElse } from "../utils/utils.js";
4
3
  export async function assertCount(db, sql, count) {
@@ -1,5 +1,4 @@
1
1
  const madge = await import("madge");
2
- import { expect, test } from "vitest";
3
2
  const WHITELISTED_DEPENDENCIES = [
4
3
  // aspect is using DigitrafficStack with instanceof, can't remove
5
4
  `["aws/infra/stack/stack.mjs","aws/infra/stack/stack-checking-aspect.mjs"]`,
@@ -18,4 +17,5 @@ test("circular dependencies", async () => {
18
17
  const errors = circulars.filter(whitelist);
19
18
  assertNoErrors(errors);
20
19
  });
20
+ export {};
21
21
  //# sourceMappingURL=dependencies.test.js.map
@@ -1,4 +1,4 @@
1
- import { expect, test } from "vitest";
1
+ import { expect } from "@jest/globals";
2
2
  test("index import ok?", () => {
3
3
  const index = import("../index.js");
4
4
  return expect(index).resolves.toBeDefined();
@@ -1,5 +1,5 @@
1
+ import { expect } from "@jest/globals";
1
2
  import { App, Stack } from "aws-cdk-lib";
2
- import { describe, expect, test } from "vitest";
3
3
  import { AclBuilder } from "../../aws/infra/acl-builder.js";
4
4
  describe("acl-builder tests", () => {
5
5
  function createBuilder() {
@@ -1,11 +1,11 @@
1
- import { describe, expect, test, vi } from "vitest";
1
+ import { jest } from "@jest/globals";
2
2
  import { HandlerFactory } from "../../../aws/infra/api/handler-factory.js";
3
3
  import { DtLogger } from "../../../aws/runtime/dt-logger.js";
4
4
  const logger = new DtLogger();
5
5
  describe("handler-factory tests", () => {
6
6
  test("test defaults", async () => {
7
7
  const factory = new HandlerFactory();
8
- const method = vi.fn((method) => {
8
+ const method = jest.fn((method) => {
9
9
  return method;
10
10
  });
11
11
  const handler = factory.createEventHandler(method, logger);
@@ -13,11 +13,11 @@ describe("handler-factory tests", () => {
13
13
  expect(method).toHaveBeenCalledTimes(1);
14
14
  });
15
15
  test("test logging", async () => {
16
- const loggingHandler = vi.fn((method) => {
16
+ const loggingHandler = jest.fn((method) => {
17
17
  return method();
18
18
  });
19
19
  const factory = new HandlerFactory().withLoggingHandler(loggingHandler);
20
- const method = vi.fn((method) => {
20
+ const method = jest.fn((method) => {
21
21
  return method;
22
22
  });
23
23
  const handler = factory.createEventHandler(method, logger);
@@ -26,11 +26,11 @@ describe("handler-factory tests", () => {
26
26
  expect(loggingHandler).toHaveBeenCalledTimes(1);
27
27
  });
28
28
  test("test error handling", async () => {
29
- const eh = vi.fn((method) => {
29
+ const eh = jest.fn((method) => {
30
30
  return method;
31
31
  });
32
32
  const factory = new HandlerFactory().withErrorHandler(eh);
33
- const method = vi.fn(() => {
33
+ const method = jest.fn(() => {
34
34
  throw new Error("MAGIC");
35
35
  });
36
36
  const handler = factory.createEventHandler(method, logger);
@@ -1,7 +1,6 @@
1
1
  import { App, Stack } from "aws-cdk-lib";
2
2
  import { Code, Function as LambdaFunction, Runtime, } from "aws-cdk-lib/aws-lambda";
3
3
  import velocity from "velocityjs";
4
- import { describe, expect, test } from "vitest";
5
4
  import { DigitrafficIntegration } from "../../../aws/infra/api/integration.js";
6
5
  import { MediaType } from "../../../aws/types/mediatypes.js";
7
6
  import { decodeBase64ToAscii } from "../../../utils/base64.js";
@@ -1,6 +1,5 @@
1
1
  import etag from "etag";
2
2
  import velocity from "velocityjs";
3
- import { describe, expect, test } from "vitest";
4
3
  import { RESPONSE_DEFAULT_LAMBDA } from "../../../aws/infra/api/response.js";
5
4
  const TEST_BODY = "Hello world!";
6
5
  describe("response tests", () => {
@@ -1,9 +1,8 @@
1
1
  import { Model } from "aws-cdk-lib/aws-apigateway";
2
- import { describe, expect, test } from "vitest";
3
2
  import { DigitrafficStaticIntegration } from "../../../aws/infra/api/static-integration.js";
4
3
  import { MediaType } from "../../../aws/types/mediatypes.js";
5
4
  describe("response tests", () => {
6
- test("createIntegrationResponse works", () => {
5
+ it("createIntegrationResponse works", () => {
7
6
  const integrationResponse = DigitrafficStaticIntegration.createIntegrationResponse("FakeResource", MediaType.APPLICATION_JSON, { "test-header": "test-value" });
8
7
  expect(integrationResponse).toEqual({
9
8
  responseParameters: {
@@ -15,7 +14,7 @@ describe("response tests", () => {
15
14
  statusCode: "200",
16
15
  });
17
16
  });
18
- test("createMethodResponse works", () => {
17
+ it("createMethodResponse works", () => {
19
18
  const methodResponse = DigitrafficStaticIntegration.createMethodResponse({
20
19
  "test-header": "test-value",
21
20
  }, MediaType.TEXT_PLAIN, Model.EMPTY_MODEL);
@@ -1,4 +1,3 @@
1
- import { describe, expect, test } from "vitest";
2
1
  import { DocumentationPart } from "../../aws/infra/documentation.js";
3
2
  const METHOD_NAME = "test";
4
3
  const SUMMARY = "summary";
@@ -1,6 +1,5 @@
1
1
  import { App, Stack } from "aws-cdk-lib";
2
2
  import { Template } from "aws-cdk-lib/assertions";
3
- import { describe, test } from "vitest";
4
3
  import { Scheduler } from "../../aws/infra/scheduler.js";
5
4
  describe("scheduler tests", () => {
6
5
  function expectRate(createScheduler, expectedRate) {
@@ -1,7 +1,6 @@
1
1
  import { App, Stack } from "aws-cdk-lib";
2
2
  import { Template } from "aws-cdk-lib/assertions";
3
3
  import { Topic } from "aws-cdk-lib/aws-sns";
4
- import { describe, test } from "vitest";
5
4
  import { DigitrafficSecurityRule } from "../../aws/infra/security-rule.js";
6
5
  describe("security-rule tests", () => {
7
6
  test("create", () => {
@@ -1,5 +1,4 @@
1
1
  import { App } from "aws-cdk-lib";
2
- import { describe, expect, test } from "vitest";
3
2
  import { DigitrafficRestApi } from "../../../aws/infra/stack/rest-api.js";
4
3
  import { DigitrafficStack } from "../../../aws/infra/stack/stack.js";
5
4
  describe("DigitrafficRestApi tests", () => {
@@ -1,4 +1,3 @@
1
- import { describe, expect, test } from "vitest";
2
1
  import { getRandomNumber } from "../../__test__/testutils.js";
3
2
  import * as IdUtils from "../../marine/id_utils.js";
4
3
  describe("IdUtils tests", () => {
@@ -1,17 +1,17 @@
1
- import { describe, expect, test, vi } from "vitest";
1
+ import { jest } from "@jest/globals";
2
2
  import { getRandomInteger } from "../../__test__/testutils.js";
3
3
  import { logger } from "../../aws/runtime/dt-logger-default.js";
4
4
  import { RetryLogError, retry } from "../../utils/retry.js";
5
- vi.useFakeTimers();
5
+ jest.useFakeTimers();
6
6
  describe("Promise utils tests", () => {
7
7
  test("retry - no retries", async () => {
8
- const fn = vi.fn(() => Promise.resolve(1));
8
+ const fn = jest.fn(() => Promise.resolve(1));
9
9
  const ret = await retry(fn, 0, RetryLogError.NO_LOGGING);
10
10
  expect(ret).toBe(1);
11
11
  expect(fn.mock.calls.length).toBe(1);
12
12
  });
13
13
  test("retry - error with n+1 retries", async () => {
14
- const fn = vi.fn(() => Promise.reject("error"));
14
+ const fn = jest.fn(() => Promise.reject("error"));
15
15
  const retries = getRandomInteger(1, 10);
16
16
  try {
17
17
  await retry(fn, retries, RetryLogError.NO_LOGGING);
@@ -24,15 +24,15 @@ describe("Promise utils tests", () => {
24
24
  }
25
25
  });
26
26
  test("retry - no error with n+1 retries", async () => {
27
- const fn = vi.fn(() => Promise.resolve(1));
27
+ const fn = jest.fn(() => Promise.resolve(1));
28
28
  const retries = getRandomInteger(1, 10);
29
29
  const ret = await retry(fn, retries, RetryLogError.NO_LOGGING);
30
30
  expect(ret).toBe(1);
31
31
  expect(fn.mock.calls.length).toBe(1);
32
32
  });
33
33
  test("retry - errors with no error logging", async () => {
34
- const fn = vi.fn(() => Promise.reject("error"));
35
- const consoleErrorSpy = vi.spyOn(logger, "error");
34
+ const fn = jest.fn(() => Promise.reject("error"));
35
+ const consoleErrorSpy = jest.spyOn(logger, "error");
36
36
  try {
37
37
  await retry(fn, getRandomInteger(0, 10), RetryLogError.NO_LOGGING);
38
38
  }
@@ -45,8 +45,8 @@ describe("Promise utils tests", () => {
45
45
  }
46
46
  });
47
47
  test("retry - no retries with error logging", async () => {
48
- const fn = vi.fn(() => Promise.reject("error"));
49
- const consoleErrorSpy = vi.spyOn(logger, "error");
48
+ const fn = jest.fn(() => Promise.reject("error"));
49
+ const consoleErrorSpy = jest.spyOn(logger, "error");
50
50
  try {
51
51
  await retry(fn, 0, RetryLogError.LOG_ALL_AS_ERRORS);
52
52
  }
@@ -59,9 +59,9 @@ describe("Promise utils tests", () => {
59
59
  }
60
60
  });
61
61
  test("retry - retries with error logging", async () => {
62
- const fn = vi.fn(() => Promise.reject("error"));
62
+ const fn = jest.fn(() => Promise.reject("error"));
63
63
  const retries = getRandomInteger(1, 10);
64
- const consoleErrorSpy = vi.spyOn(logger, "error");
64
+ const consoleErrorSpy = jest.spyOn(logger, "error");
65
65
  try {
66
66
  await retry(fn, retries, RetryLogError.LOG_ALL_AS_ERRORS);
67
67
  }
@@ -74,12 +74,12 @@ describe("Promise utils tests", () => {
74
74
  }
75
75
  });
76
76
  test("retry - exceeded retry count throws error", async () => {
77
- const fn = vi.fn(() => Promise.reject("error"));
77
+ const fn = jest.fn(() => Promise.reject("error"));
78
78
  await expect(() => retry(fn, 3, RetryLogError.LOG_ALL_AS_ERRORS)).rejects.toThrow();
79
79
  });
80
80
  test("retry - defaults", async () => {
81
- const fn = vi.fn(() => Promise.reject("error"));
82
- const consoleErrorSpy = vi.spyOn(logger, "error");
81
+ const fn = jest.fn(() => Promise.reject("error"));
82
+ const consoleErrorSpy = jest.spyOn(logger, "error");
83
83
  try {
84
84
  await retry(fn);
85
85
  }
@@ -92,15 +92,15 @@ describe("Promise utils tests", () => {
92
92
  }
93
93
  });
94
94
  test("retry - NaN throws error", async () => {
95
- const fn = vi.fn(() => Promise.resolve(NaN));
95
+ const fn = jest.fn(() => Promise.resolve(NaN));
96
96
  await expect(() => retry(fn, NaN, RetryLogError.NO_LOGGING)).rejects.toThrow();
97
97
  });
98
98
  test("retry - Infinity throws error", async () => {
99
- const fn = vi.fn(() => Promise.resolve(NaN));
99
+ const fn = jest.fn(() => Promise.resolve(NaN));
100
100
  await expect(() => retry(fn, Infinity, RetryLogError.NO_LOGGING)).rejects.toThrow();
101
101
  });
102
102
  test("retry - exceeded maximum retry count throws error", async () => {
103
- const fn = vi.fn(() => Promise.resolve(NaN));
103
+ const fn = jest.fn(() => Promise.resolve(NaN));
104
104
  await expect(() => retry(fn, getRandomInteger(101, 1000000), RetryLogError.NO_LOGGING)).rejects.toThrow();
105
105
  });
106
106
  test("retry - use without mocks without retry", async () => {
@@ -1,5 +1,4 @@
1
1
  import { Writable } from "node:stream";
2
- import { describe, expect, test } from "vitest";
3
2
  import { DtLogger } from "../../aws/runtime/dt-logger.js";
4
3
  const LOG_LINE = {
5
4
  method: "dt-logger.test",
@@ -1,5 +1,5 @@
1
1
  import { SecretsManager } from "@aws-sdk/client-secrets-manager";
2
- import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";
2
+ import { jest } from "@jest/globals";
3
3
  import { setEnvVariable, setEnvVariableAwsRegion } from "../../utils/utils.js";
4
4
  const SECRET_WITH_PREFIX = {
5
5
  "prefix.value": "value",
@@ -8,8 +8,10 @@ const SECRET_WITH_PREFIX = {
8
8
  username: "DB_USER",
9
9
  };
10
10
  const emptySecret = { $metadata: {} };
11
- const getSecretValueMock = vi.fn();
12
- vi.spyOn(SecretsManager.prototype, "getSecretValue").mockImplementation(getSecretValueMock);
11
+ const getSecretValueMock = jest.fn();
12
+ jest
13
+ .spyOn(SecretsManager.prototype, "getSecretValue")
14
+ .mockImplementation(getSecretValueMock);
13
15
  const { SecretHolder } = await import("../../aws/runtime/secrets/secret-holder.js");
14
16
  const { DatabaseEnvironmentKeys } = await import("../../database/database.js");
15
17
  function mockSecret(secret) {
@@ -1,6 +1,5 @@
1
- import { afterEach } from "node:test";
2
1
  import { SecretsManager } from "@aws-sdk/client-secrets-manager";
3
- import { describe, expect, test, vi } from "vitest";
2
+ import { jest } from "@jest/globals";
4
3
  import { setEnvVariableAwsRegion } from "../../utils/utils.js";
5
4
  const SECRET_ID = "test_secret";
6
5
  const SECRET_WITH_PREFIX = {
@@ -9,8 +8,10 @@ const SECRET_WITH_PREFIX = {
9
8
  "wrong.value": "value",
10
9
  };
11
10
  const emptySecret = { $metadata: {} };
12
- const getSecretValueMock = vi.fn();
13
- vi.spyOn(SecretsManager.prototype, "getSecretValue").mockImplementation(getSecretValueMock);
11
+ const getSecretValueMock = jest.fn();
12
+ jest
13
+ .spyOn(SecretsManager.prototype, "getSecretValue")
14
+ .mockImplementation(getSecretValueMock);
14
15
  function mockSecret(secret) {
15
16
  if (!secret) {
16
17
  getSecretValueMock.mockImplementation(() => Promise.resolve(emptySecret));
@@ -26,9 +27,6 @@ setEnvVariableAwsRegion("eu-west-1");
26
27
  const secret = await import("../../aws/runtime/secrets/secret.js");
27
28
  const { getSecret } = secret;
28
29
  describe("secret - test", () => {
29
- afterEach(() => {
30
- vi.restoreAllMocks();
31
- });
32
30
  test("getSecret - no secret", async () => {
33
31
  mockSecret(null);
34
32
  await expect(async () => {
@@ -2,7 +2,6 @@ import { App, Duration } from "aws-cdk-lib";
2
2
  import { Match, Template } from "aws-cdk-lib/assertions";
3
3
  import { PolicyStatement, Role, ServicePrincipal } from "aws-cdk-lib/aws-iam";
4
4
  import { Architecture, Code, Runtime } from "aws-cdk-lib/aws-lambda";
5
- import { describe, expect, test } from "vitest";
6
5
  import { FunctionBuilder } from "../../aws/infra/stack/dt-function.js";
7
6
  import { DigitrafficStack } from "../../aws/infra/stack/stack.js";
8
7
  import { EnvKeys } from "../../aws/runtime/environment.js";
@@ -1,6 +1,5 @@
1
1
  import { App } from "aws-cdk-lib";
2
2
  import { Match, Template } from "aws-cdk-lib/assertions";
3
- import { describe, test } from "vitest";
4
3
  import { DigitrafficRestApi } from "../../aws/infra/stack/rest-api.js";
5
4
  import { DigitrafficStack } from "../../aws/infra/stack/stack.js";
6
5
  import { TrafficType } from "../../types/traffictype.js";
@@ -1,4 +1,4 @@
1
- import { afterEach, describe, expect, test, vi } from "vitest";
1
+ import { describe, jest, test } from "@jest/globals";
2
2
  import { mockKyResponse } from "../../__test__/mock-ky.js";
3
3
  const ky = (await import("ky")).default;
4
4
  describe("mockKyResponse", () => {
@@ -6,39 +6,61 @@ describe("mockKyResponse", () => {
6
6
  const testJson = JSON.stringify(testObj);
7
7
  const url = "https://example.com";
8
8
  afterEach(() => {
9
- vi.restoreAllMocks();
9
+ jest.restoreAllMocks();
10
10
  });
11
11
  test("works with all methods", async () => {
12
- vi.spyOn(ky, "get").mockImplementation(() => mockKyResponse(200, testJson));
13
- vi.spyOn(ky, "post").mockImplementation(() => mockKyResponse(200, testJson));
14
- vi.spyOn(ky, "put").mockImplementation(() => mockKyResponse(200, testJson));
15
- vi.spyOn(ky, "delete").mockImplementation(() => mockKyResponse(200, testJson));
12
+ jest
13
+ .spyOn(ky, "get")
14
+ .mockImplementation(() => mockKyResponse(200, testJson));
15
+ jest
16
+ .spyOn(ky, "post")
17
+ .mockImplementation(() => mockKyResponse(200, testJson));
18
+ jest
19
+ .spyOn(ky, "put")
20
+ .mockImplementation(() => mockKyResponse(200, testJson));
21
+ jest
22
+ .spyOn(ky, "delete")
23
+ .mockImplementation(() => mockKyResponse(200, testJson));
16
24
  expect(await ky.get(url).text()).toEqual(testJson);
17
25
  expect(await ky.put(url).text()).toEqual(testJson);
18
26
  expect(await ky.post(url).text()).toEqual(testJson);
19
27
  expect(await ky.delete(url).text()).toEqual(testJson);
20
28
  });
21
29
  test("returns correct status", async () => {
22
- vi.spyOn(ky, "get").mockImplementation(() => mockKyResponse(200, testJson));
30
+ jest
31
+ .spyOn(ky, "get")
32
+ .mockImplementation(() => mockKyResponse(200, testJson));
23
33
  expect((await ky.get(url)).status).toEqual(200);
24
- vi.spyOn(ky, "get").mockImplementation(() => mockKyResponse(400, testJson));
34
+ jest
35
+ .spyOn(ky, "get")
36
+ .mockImplementation(() => mockKyResponse(400, testJson));
25
37
  expect((await ky.get(url)).status).toEqual(400);
26
38
  });
27
39
  test("returns correct ok", async () => {
28
- vi.spyOn(ky, "get").mockImplementation(() => mockKyResponse(200, testJson));
40
+ jest
41
+ .spyOn(ky, "get")
42
+ .mockImplementation(() => mockKyResponse(200, testJson));
29
43
  expect((await ky.get(url)).ok).toEqual(true);
30
- vi.spyOn(ky, "get").mockImplementation(() => mockKyResponse(299, testJson));
44
+ jest
45
+ .spyOn(ky, "get")
46
+ .mockImplementation(() => mockKyResponse(299, testJson));
31
47
  expect((await ky.get(url)).ok).toEqual(true);
32
- vi.spyOn(ky, "get").mockImplementation(() => mockKyResponse(300, testJson));
48
+ jest
49
+ .spyOn(ky, "get")
50
+ .mockImplementation(() => mockKyResponse(300, testJson));
33
51
  expect((await ky.get(url)).ok).toEqual(false);
34
52
  });
35
53
  test("convenience methods work: text", async () => {
36
- vi.spyOn(ky, "get").mockImplementation(() => mockKyResponse(200, testJson));
54
+ jest
55
+ .spyOn(ky, "get")
56
+ .mockImplementation(() => mockKyResponse(200, testJson));
37
57
  expect(await ky.get(url).text()).toEqual(testJson);
38
58
  expect(await (await ky.get(url)).text()).toEqual(testJson);
39
59
  });
40
60
  test("convenience methods work: json", async () => {
41
- vi.spyOn(ky, "get").mockImplementation(() => mockKyResponse(200, testJson));
61
+ jest
62
+ .spyOn(ky, "get")
63
+ .mockImplementation(() => mockKyResponse(200, testJson));
42
64
  expect(await ky.get(url).json()).toEqual(testObj);
43
65
  expect(await (await ky.get(url)).json()).toEqual(testObj);
44
66
  });
@@ -1,4 +1,3 @@
1
- import { describe, expect, test } from "vitest";
2
1
  import { LambdaProxyResponseBuilder } from "../../aws/types/lambda-proxy-types.js";
3
2
  import { MediaType } from "../../aws/types/mediatypes.js";
4
3
  import { decodeBase64ToUtf8 } from "../../utils/base64.js";
@@ -1,4 +1,3 @@
1
- import { describe, expect, test } from "vitest";
2
1
  import { LambdaResponseBuilder } from "../../aws/types/lambda-response.js";
3
2
  import { decodeBase64ToUtf8 } from "../../utils/base64.js";
4
3
  import { TEST_FILENAME, TEST_JSON, TEST_MESSAGE, TEST_TIMESTAMP, TEST_TIMESTAMP_STR, } from "./lambda-response.test.js";
@@ -1,4 +1,3 @@
1
- import { describe, expect, test } from "vitest";
2
1
  import { LambdaResponse, LambdaResponseBuilder, } from "../../aws/types/lambda-response.js";
3
2
  import { decodeBase64ToUtf8 } from "../../utils/base64.js";
4
3
  export const TEST_MESSAGE = "HELLO";
@@ -1,4 +1,3 @@
1
- import { describe, expect, test } from "vitest";
2
1
  import { compressBuffer, decodeBase64ToAscii, decodeBase64ToUtf8, encodeAsciiToBase64, encodeUtf8ToBase64, } from "../../utils/base64.js";
3
2
  describe("Base64UtilTest", () => {
4
3
  const EXPECTED_ASCII = "0a9f4967-faaa-445a-ba11-078f7f9556b4";
@@ -1,5 +1,4 @@
1
1
  import { parseISO } from "date-fns";
2
- import { describe, expect, test } from "vitest";
3
2
  import * as CommonDateUtils from "../../utils/date-utils.js";
4
3
  const ISO = "2022-01-02T01:02:03.004Z";
5
4
  describe("CommonDateUtilsTest", () => {
@@ -1,4 +1,3 @@
1
- import { describe, expect, test } from "vitest";
2
1
  import * as Geometry from "../../utils/geometry.js";
3
2
  import { Asserter } from "../asserter.js";
4
3
  const TAMPERE_WGS84_X = 23.761290078;
@@ -1,4 +1,3 @@
1
- import { describe, expect, test } from "vitest";
2
1
  import { parseQueryParams } from "../../utils/lambda-proxy-event.js";
3
2
  describe("lambda-proxy-event.test", () => {
4
3
  test("StopWatch start-stop", async () => {
@@ -1,5 +1,4 @@
1
1
  import { Writable } from "node:stream";
2
- import { describe, expect, test } from "vitest";
3
2
  import { DtLogger } from "../../aws/runtime/dt-logger.js";
4
3
  import { logException, truncateEnd, truncateMiddle, } from "../../utils/logging.js";
5
4
  const TEST_METHODNAME = "test.logException";
@@ -1,4 +1,4 @@
1
- import { describe, expect, test } from "vitest";
1
+ import { expect } from "@jest/globals";
2
2
  import { StopWatch } from "../../utils/stop-watch.js";
3
3
  describe("stop-watch.test.ts", () => {
4
4
  test("StopWatch start-stop", async () => {
@@ -1,4 +1,3 @@
1
- import { describe, expect, test } from "vitest";
2
1
  import * as ArrayUtils from "../../utils/utils.js";
3
2
  describe("ArrayUtils", () => {
4
3
  test("bothArraysHasSameValues", () => {
@@ -1,13 +1,11 @@
1
- import type { Stack } from "aws-cdk-lib";
2
1
  import { Duration } from "aws-cdk-lib";
3
2
  import type { ISecurityGroup } from "aws-cdk-lib/aws-ec2";
4
3
  import type { IRole } from "aws-cdk-lib/aws-iam";
5
4
  import { PolicyStatement } from "aws-cdk-lib/aws-iam";
6
- import type { ILayerVersion } from "aws-cdk-lib/aws-lambda";
7
5
  import { Architecture, Function as AwsFunction, Code, Runtime } from "aws-cdk-lib/aws-lambda";
8
6
  import { DtFunctionAlarms } from "./dt-function-alarms.js";
9
7
  import type { LambdaEnvironment } from "./lambda-configs.js";
10
- import type { DigitrafficStackInterface } from "./stack.js";
8
+ import type { DigitrafficStack } from "./stack.js";
11
9
  export declare class FunctionBuilder {
12
10
  private readonly _stack;
13
11
  private readonly _name;
@@ -24,21 +22,20 @@ export declare class FunctionBuilder {
24
22
  private alarms;
25
23
  private code;
26
24
  private handler;
27
- private readonly layers;
28
25
  private readonly securityGroups;
29
26
  private readonly policyStatements;
30
27
  private readonly allowedActions;
31
28
  private readonly _features;
32
- constructor(stack: Stack & DigitrafficStackInterface, lambdaName: string);
29
+ constructor(stack: DigitrafficStack, lambdaName: string);
33
30
  /**
34
31
  * Creates a new builder with defaults, using the lambdaName as a source for the lambda implementation (dist/lambdaName/lambdaName.js).
35
32
  * Database access is given by default.
36
33
  */
37
- static create(stack: Stack & DigitrafficStackInterface, lambdaName: string): FunctionBuilder;
34
+ static create(stack: DigitrafficStack, lambdaName: string): FunctionBuilder;
38
35
  /**
39
36
  * Creates a new builder with defaults, but without database or secret access.
40
37
  */
41
- static plain(stack: Stack & DigitrafficStackInterface, lambdaName: string): FunctionBuilder;
38
+ static plain(stack: DigitrafficStack, lambdaName: string): FunctionBuilder;
42
39
  /**
43
40
  * Stack only has one lambda. Default is that it has multiple lambdas.
44
41
  */
@@ -76,10 +73,6 @@ export declare class FunctionBuilder {
76
73
  * Set runtime for the lambda. Default is Runtime.NODEJS_24_X.
77
74
  */
78
75
  withRuntime(runtime: Runtime): this;
79
- /**
80
- * Add Lambda layers.
81
- */
82
- withLayers(...layers: ILayerVersion[]): this;
83
76
  /**
84
77
  * Set architecture for the lambda. Default is Architecture.ARM_64.
85
78
  */
@@ -25,7 +25,6 @@ export class FunctionBuilder {
25
25
  // these will be overridden in constructor, but inspection won't see it, so set some default values.
26
26
  code = Code.fromInline("placeholder");
27
27
  handler = "";
28
- layers = [];
29
28
  securityGroups = [];
30
29
  policyStatements = [];
31
30
  allowedActions = [];
@@ -134,13 +133,6 @@ export class FunctionBuilder {
134
133
  this.runtime = runtime;
135
134
  return this;
136
135
  }
137
- /**
138
- * Add Lambda layers.
139
- */
140
- withLayers(...layers) {
141
- this.layers.push(...layers);
142
- return this;
143
- }
144
136
  /**
145
137
  * Set architecture for the lambda. Default is Architecture.ARM_64.
146
138
  */
@@ -238,7 +230,6 @@ export class FunctionBuilder {
238
230
  securityGroups,
239
231
  environment: this.getEnvironment(),
240
232
  description: this.description,
241
- layers: this.layers.length > 0 ? this.layers : undefined,
242
233
  });
243
234
  if (this._features.secretAccess) {
244
235
  this._stack.grantSecret(createdFunction);
@@ -1,6 +1,6 @@
1
1
  import type { Stack } from "aws-cdk-lib";
2
2
  import { LogGroup, RetentionDays } from "aws-cdk-lib/aws-logs";
3
- import type { DigitrafficStackInterface } from "./stack.js";
3
+ import type { DigitrafficStack } from "./stack.js";
4
4
  export interface CreateLambdaLogGroupParams {
5
5
  functionName: string;
6
6
  retention?: RetentionDays;
@@ -10,6 +10,6 @@ export interface CreateLambdaLogGroupParamsForStack extends CreateLambdaLogGroup
10
10
  shortName: string;
11
11
  }
12
12
  export interface CreateLambdaLogGroupParamsForDigitrafficStack extends CreateLambdaLogGroupParams {
13
- stack: Stack & DigitrafficStackInterface;
13
+ stack: DigitrafficStack;
14
14
  }
15
15
  export declare function createLambdaLogGroup(params: CreateLambdaLogGroupParamsForStack | CreateLambdaLogGroupParamsForDigitrafficStack): LogGroup;
@@ -1,4 +1,3 @@
1
- import type { Stack } from "aws-cdk-lib";
2
1
  import type { IResource, JsonSchema, Resource, ResourceOptions, RestApiProps } from "aws-cdk-lib/aws-apigateway";
3
2
  import { RestApi } from "aws-cdk-lib/aws-apigateway";
4
3
  import { PolicyDocument } from "aws-cdk-lib/aws-iam";
@@ -6,7 +5,7 @@ import { StringParameter } from "aws-cdk-lib/aws-ssm";
6
5
  import type { Construct } from "constructs";
7
6
  import type { ModelWithReference } from "../../types/model-with-reference.js";
8
7
  import type { DocumentationPart } from "../documentation.js";
9
- import type { DigitrafficStackInterface } from "./stack.js";
8
+ import type { DigitrafficStack } from "./stack.js";
10
9
  export declare const PUBLIC_REST_API_CORS_CONFIG: {
11
10
  readonly defaultCorsPreflightOptions: {
12
11
  readonly allowOrigins: string[];
@@ -24,7 +23,7 @@ export declare class DigitrafficRestApi extends RestApi {
24
23
  readonly apiKeyIds: string[];
25
24
  readonly enableDocumentation: boolean;
26
25
  private readonly _stack;
27
- constructor(stack: Stack & DigitrafficStackInterface, apiId: string, apiName: string, allowFromIpAddresses?: string[] | undefined, config?: Partial<RestApiProps>);
26
+ constructor(stack: DigitrafficStack, apiId: string, apiName: string, allowFromIpAddresses?: string[] | undefined, config?: Partial<RestApiProps>);
28
27
  hostname(): string;
29
28
  /** Export end point and api key to Parameter store */
30
29
  exportEndpoint(): [StringParameter, StringParameter];
@@ -8,12 +8,7 @@ import { kebabCase } from "change-case";
8
8
  import { snakeCase } from "es-toolkit";
9
9
  import { DigitrafficStack, SOLUTION_KEY } from "./stack.js";
10
10
  const MAX_CONCURRENCY_LIMIT = 100;
11
- const ALLOWED_RUNTIMES = [
12
- Runtime.NODEJS_24_X.name,
13
- Runtime.NODEJS_22_X.name,
14
- Runtime.PYTHON_3_12.name,
15
- Runtime.PYTHON_3_13.name,
16
- ];
11
+ const NODE_RUNTIMES = [Runtime.NODEJS_24_X.name, Runtime.NODEJS_22_X.name];
17
12
  var ResourceType;
18
13
  (function (ResourceType) {
19
14
  ResourceType["stackName"] = "STACK_NAME";
@@ -93,8 +88,7 @@ export class StackCheckingAspect {
93
88
  if (!node.memorySize) {
94
89
  this.addAnnotation(node, ResourceType.functionMemorySize, "Function must have memorySize");
95
90
  }
96
- if (node.runtime !== undefined &&
97
- !ALLOWED_RUNTIMES.includes(node.runtime)) {
91
+ if (node.runtime !== undefined && !NODE_RUNTIMES.includes(node.runtime)) {
98
92
  this.addAnnotation(node, ResourceType.functionRuntime, `Function has wrong runtime ${node.runtime}!`);
99
93
  }
100
94
  if (this.stackShortName &&
@@ -29,18 +29,7 @@ export interface StackConfiguration {
29
29
  };
30
30
  readonly whitelistedResources?: string[];
31
31
  }
32
- export interface DigitrafficStackInterface {
33
- readonly configuration: StackConfiguration;
34
- readonly vpc?: IVpc;
35
- readonly lambdaDbSg?: ISecurityGroup;
36
- readonly alarmTopic: ITopic;
37
- readonly warningTopic: ITopic;
38
- createLambdaEnvironment(): DBLambdaEnvironment;
39
- createDefaultLambdaEnvironment(dbApplication: string): DBLambdaEnvironment;
40
- getSecret(): ISecret;
41
- grantSecret(...lambdas: AWSFunction[]): void;
42
- }
43
- export declare class DigitrafficStack extends Stack implements DigitrafficStackInterface {
32
+ export declare class DigitrafficStack extends Stack {
44
33
  readonly vpc?: IVpc;
45
34
  readonly lambdaDbSg?: ISecurityGroup;
46
35
  readonly alarmTopic: ITopic;
@@ -6,7 +6,6 @@ import type { InfraStackConfiguration } from "./intra-stack-configuration.js";
6
6
  export interface NetworkConfiguration {
7
7
  readonly vpcName: string;
8
8
  readonly cidr: string;
9
- readonly natGateways?: number;
10
9
  }
11
10
  export declare class NetworkStack extends Stack {
12
11
  readonly vpc: IVpc;
@@ -23,11 +23,9 @@ export class NetworkStack extends Stack {
23
23
  createVpc(configuration) {
24
24
  return new Vpc(this, "DigitrafficVPC", {
25
25
  vpcName: configuration.vpcName,
26
- restrictDefaultSecurityGroup: false,
27
26
  availabilityZones: Stack.of(this).availabilityZones.sort().slice(0, 2), // take two first azs
28
27
  enableDnsHostnames: true,
29
28
  enableDnsSupport: true,
30
- natGateways: configuration.natGateways ?? 2, // one for each AZ
31
29
  ipAddresses: IpAddresses.cidr(configuration.cidr),
32
30
  subnetConfiguration: [
33
31
  {
package/dist/index.d.ts CHANGED
@@ -1,2 +1 @@
1
- export type { DigitrafficStackInterface } from "./aws/infra/stack/stack.js";
2
1
  export { DigitrafficStack } from "./aws/infra/stack/stack.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digitraffic/common",
3
- "version": "2026.4.14-1",
3
+ "version": "2026.4.17-1",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "repository": {
@@ -108,36 +108,36 @@
108
108
  "dist/**/*.d.ts"
109
109
  ],
110
110
  "devDependencies": {
111
- "@aws-sdk/client-api-gateway": "3.1013.0",
112
- "@aws-sdk/client-s3": "3.1013.0",
113
- "@aws-sdk/client-secrets-manager": "3.1013.0",
114
- "@aws-sdk/client-sns": "3.1013.0",
115
- "@aws-sdk/lib-storage": "3.1013.0",
116
- "@biomejs/biome": "2.4.8",
111
+ "@aws-sdk/client-api-gateway": "3.1028.0",
112
+ "@aws-sdk/client-s3": "3.1028.0",
113
+ "@aws-sdk/client-secrets-manager": "3.1028.0",
114
+ "@aws-sdk/client-sns": "3.1028.0",
115
+ "@aws-sdk/lib-storage": "3.1028.0",
116
+ "@biomejs/biome": "2.4.11",
117
117
  "@date-fns/tz": "1.4.1",
118
- "@rushstack/heft": "1.2.7",
119
- "@rushstack/heft-typescript-plugin": "1.3.2",
120
- "@smithy/fetch-http-handler": "5.3.15",
121
- "@smithy/node-http-handler": "4.5.0",
122
- "@smithy/types": "4.13.1",
118
+ "@rushstack/heft": "1.2.11",
119
+ "@rushstack/heft-typescript-plugin": "1.3.6",
120
+ "@smithy/fetch-http-handler": "5.3.16",
121
+ "@smithy/node-http-handler": "4.5.2",
122
+ "@smithy/types": "4.14.0",
123
123
  "@types/aws-lambda": "8.10.161",
124
124
  "@types/etag": "1.8.4",
125
125
  "@types/geojson": "7946.0.16",
126
126
  "@types/geojson-validation": "1.0.3",
127
127
  "@types/lodash-es": "4.17.12",
128
128
  "@types/madge": "5.0.3",
129
- "@types/node": "25.5.0",
130
- "@vitest/coverage-v8": "4.1.0",
131
- "aws-cdk-lib": "2.244.0",
129
+ "@types/node": "24.12.2",
130
+ "@vitest/coverage-v8": "4.1.4",
131
+ "aws-cdk-lib": "2.248.0",
132
132
  "change-case": "5.4.4",
133
- "constructs": "10.5.1",
133
+ "constructs": "10.6.0",
134
134
  "date-fns": "4.1.0",
135
135
  "es-toolkit": "1.45.1",
136
136
  "etag": "1.8.1",
137
137
  "geojson-validation": "1.0.2",
138
138
  "ky": "1.14.3",
139
- "lefthook": "2.1.4",
140
- "lodash-es": "4.17.23",
139
+ "lefthook": "2.1.5",
140
+ "lodash-es": "4.18.1",
141
141
  "madge": "8.0.0",
142
142
  "pg-native": "3.7.0",
143
143
  "pg-promise": "12.6.2",
@@ -146,26 +146,26 @@
146
146
  "sort-package-json": "3.6.1",
147
147
  "typescript": "5.9.3",
148
148
  "velocityjs": "2.1.5",
149
- "vitest": "4.1.0",
149
+ "vitest": "4.1.4",
150
150
  "zod": "4.3.6"
151
151
  },
152
152
  "peerDependencies": {
153
- "@aws-sdk/client-api-gateway": "3.1013.0",
154
- "@aws-sdk/client-s3": "3.1013.0",
155
- "@aws-sdk/client-secrets-manager": "3.1013.0",
156
- "@aws-sdk/client-sns": "3.1013.0",
157
- "@aws-sdk/lib-storage": "3.1013.0",
153
+ "@aws-sdk/client-api-gateway": "3.1028.0",
154
+ "@aws-sdk/client-s3": "3.1028.0",
155
+ "@aws-sdk/client-secrets-manager": "3.1028.0",
156
+ "@aws-sdk/client-sns": "3.1028.0",
157
+ "@aws-sdk/lib-storage": "3.1028.0",
158
158
  "@date-fns/tz": "1.4.1",
159
- "@smithy/fetch-http-handler": "5.3.15",
160
- "@smithy/node-http-handler": "4.5.0",
161
- "aws-cdk-lib": "2.244.0",
159
+ "@smithy/fetch-http-handler": "5.3.16",
160
+ "@smithy/node-http-handler": "4.5.2",
161
+ "aws-cdk-lib": "2.248.0",
162
162
  "change-case": "5.4.4",
163
- "constructs": "10.5.1",
163
+ "constructs": "10.6.0",
164
164
  "date-fns": "4.1.0",
165
165
  "es-toolkit": "1.45.1",
166
166
  "geojson-validation": "1.0.2",
167
167
  "ky": "1.14.3",
168
- "lodash-es": "4.17.23",
168
+ "lodash-es": "4.18.1",
169
169
  "pg-native": "3.7.0",
170
170
  "pg-promise": "12.6.2",
171
171
  "zod": "4.3.6"