@digitraffic/common 2026.3.17-1 → 2026.3.26-1-beta

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 (238) hide show
  1. package/README.md +18 -1
  2. package/dist/__test__/asserter.d.ts +13 -0
  3. package/dist/__test__/asserter.js +39 -0
  4. package/dist/__test__/db-testutils.d.ts +3 -0
  5. package/dist/__test__/db-testutils.js +38 -0
  6. package/dist/__test__/dependencies.test.d.ts +1 -0
  7. package/dist/__test__/dependencies.test.js +21 -0
  8. package/dist/__test__/imports.test.d.ts +1 -0
  9. package/dist/__test__/imports.test.js +318 -0
  10. package/dist/__test__/infra/acl-builder.test.d.ts +1 -0
  11. package/dist/__test__/infra/acl-builder.test.js +72 -0
  12. package/dist/__test__/infra/api/handler-factory.test.d.ts +1 -0
  13. package/dist/__test__/infra/api/handler-factory.test.js +42 -0
  14. package/dist/__test__/infra/api/integration.test.d.ts +1 -0
  15. package/dist/__test__/infra/api/integration.test.js +162 -0
  16. package/dist/__test__/infra/api/response.test.d.ts +1 -0
  17. package/dist/__test__/infra/api/response.test.js +77 -0
  18. package/dist/__test__/infra/api/static-integration.test.d.ts +1 -0
  19. package/dist/__test__/infra/api/static-integration.test.js +35 -0
  20. package/dist/__test__/infra/documentation.test.d.ts +1 -0
  21. package/dist/__test__/infra/documentation.test.js +38 -0
  22. package/dist/__test__/infra/scheduler.test.d.ts +1 -0
  23. package/dist/__test__/infra/scheduler.test.js +23 -0
  24. package/dist/__test__/infra/security-rule.test.d.ts +1 -0
  25. package/dist/__test__/infra/security-rule.test.js +21 -0
  26. package/dist/__test__/infra/stack/rest-apis.test.d.ts +1 -0
  27. package/dist/__test__/infra/stack/rest-apis.test.js +47 -0
  28. package/dist/__test__/marine/id_utils.test.d.ts +1 -0
  29. package/dist/__test__/marine/id_utils.test.js +45 -0
  30. package/dist/__test__/mock-ky.d.ts +2 -0
  31. package/dist/__test__/mock-ky.js +15 -0
  32. package/dist/__test__/promise/promise.test.d.ts +1 -0
  33. package/dist/__test__/promise/promise.test.js +126 -0
  34. package/dist/__test__/runtime/dt-logger.test.d.ts +1 -0
  35. package/dist/__test__/runtime/dt-logger.test.js +193 -0
  36. package/dist/__test__/secrets/secret-holder.test.d.ts +1 -0
  37. package/dist/__test__/secrets/secret-holder.test.js +96 -0
  38. package/dist/__test__/secrets/secret.test.d.ts +1 -0
  39. package/dist/__test__/secrets/secret.test.js +57 -0
  40. package/dist/__test__/stack/dt-function.test.d.ts +1 -0
  41. package/dist/__test__/stack/dt-function.test.js +340 -0
  42. package/dist/__test__/stack/rest-apis.test.d.ts +1 -0
  43. package/dist/__test__/stack/rest-apis.test.js +45 -0
  44. package/dist/__test__/test/mock-ky.test.d.ts +1 -0
  45. package/dist/__test__/test/mock-ky.test.js +46 -0
  46. package/dist/__test__/testutils.d.ts +12 -0
  47. package/dist/__test__/testutils.js +32 -0
  48. package/dist/__test__/types/lambda-proxy-types.test.d.ts +8 -0
  49. package/dist/__test__/types/lambda-proxy-types.test.js +155 -0
  50. package/dist/__test__/types/lambda-response-builder.test.d.ts +1 -0
  51. package/dist/__test__/types/lambda-response-builder.test.js +81 -0
  52. package/dist/__test__/types/lambda-response.test.d.ts +9 -0
  53. package/dist/__test__/types/lambda-response.test.js +73 -0
  54. package/dist/__test__/utils/base64.test.d.ts +1 -0
  55. package/dist/__test__/utils/base64.test.js +38 -0
  56. package/dist/__test__/utils/date-utils.test.d.ts +1 -0
  57. package/dist/__test__/utils/date-utils.test.js +32 -0
  58. package/dist/__test__/utils/geometry.test.d.ts +1 -0
  59. package/dist/__test__/utils/geometry.test.js +25 -0
  60. package/dist/__test__/utils/lambda-proxy-event.test.d.ts +1 -0
  61. package/dist/__test__/utils/lambda-proxy-event.test.js +45 -0
  62. package/dist/__test__/utils/logging.test.d.ts +1 -0
  63. package/dist/__test__/utils/logging.test.js +75 -0
  64. package/dist/__test__/utils/stop-watch.test.d.ts +1 -0
  65. package/dist/__test__/utils/stop-watch.test.js +118 -0
  66. package/dist/__test__/utils/utils.test.d.ts +1 -0
  67. package/dist/__test__/utils/utils.test.js +48 -0
  68. package/dist/aws/infra/acl-builder.d.ts +53 -0
  69. package/dist/aws/infra/acl-builder.js +407 -0
  70. package/dist/aws/infra/api/handler-factory.d.ts +22 -0
  71. package/dist/aws/infra/api/handler-factory.js +68 -0
  72. package/dist/aws/infra/api/integration.d.ts +49 -0
  73. package/dist/aws/infra/api/integration.js +162 -0
  74. package/dist/aws/infra/api/response.d.ts +62 -0
  75. package/dist/aws/infra/api/response.js +132 -0
  76. package/dist/aws/infra/api/responses.d.ts +60 -0
  77. package/dist/aws/infra/api/responses.js +90 -0
  78. package/dist/aws/infra/api/static-integration.d.ts +16 -0
  79. package/dist/aws/infra/api/static-integration.js +76 -0
  80. package/dist/aws/infra/bucket-policy.d.ts +38 -0
  81. package/dist/aws/infra/bucket-policy.js +30 -0
  82. package/dist/aws/infra/canaries/canary-alarm.d.ts +6 -0
  83. package/dist/aws/infra/canaries/canary-alarm.js +20 -0
  84. package/dist/aws/infra/canaries/canary-keys.d.ts +3 -0
  85. package/dist/aws/infra/canaries/canary-keys.js +4 -0
  86. package/dist/aws/infra/canaries/canary-parameters.d.ts +19 -0
  87. package/dist/aws/infra/canaries/canary-parameters.js +2 -0
  88. package/dist/aws/infra/canaries/canary-role.d.ts +14 -0
  89. package/dist/aws/infra/canaries/canary-role.js +51 -0
  90. package/dist/aws/infra/canaries/canary.d.ts +8 -0
  91. package/dist/aws/infra/canaries/canary.js +26 -0
  92. package/dist/aws/infra/canaries/database-canary.d.ts +17 -0
  93. package/dist/aws/infra/canaries/database-canary.js +65 -0
  94. package/dist/aws/infra/canaries/database-checker.d.ts +33 -0
  95. package/dist/aws/infra/canaries/database-checker.js +119 -0
  96. package/dist/aws/infra/canaries/url-canary.d.ts +16 -0
  97. package/dist/aws/infra/canaries/url-canary.js +55 -0
  98. package/dist/aws/infra/canaries/url-checker.d.ts +45 -0
  99. package/dist/aws/infra/canaries/url-checker.js +256 -0
  100. package/dist/aws/infra/documentation.d.ts +56 -0
  101. package/dist/aws/infra/documentation.js +90 -0
  102. package/dist/aws/infra/import-util.d.ts +17 -0
  103. package/dist/aws/infra/import-util.js +41 -0
  104. package/dist/aws/infra/scheduler.d.ts +12 -0
  105. package/dist/aws/infra/scheduler.js +27 -0
  106. package/dist/aws/infra/security-rule.d.ts +12 -0
  107. package/dist/aws/infra/security-rule.js +35 -0
  108. package/dist/aws/infra/sqs-integration.d.ts +4 -0
  109. package/dist/aws/infra/sqs-integration.js +85 -0
  110. package/dist/aws/infra/sqs-queue.d.ts +19 -0
  111. package/dist/aws/infra/sqs-queue.js +145 -0
  112. package/dist/aws/infra/stack/dt-function-alarms.d.ts +29 -0
  113. package/dist/aws/infra/stack/dt-function-alarms.js +54 -0
  114. package/dist/aws/infra/stack/dt-function.d.ts +124 -0
  115. package/dist/aws/infra/stack/dt-function.js +315 -0
  116. package/dist/aws/infra/stack/lambda-configs.d.ts +44 -0
  117. package/dist/aws/infra/stack/lambda-configs.js +71 -0
  118. package/dist/aws/infra/stack/lambda-log-group.d.ts +15 -0
  119. package/dist/aws/infra/stack/lambda-log-group.js +24 -0
  120. package/dist/aws/infra/stack/monitoredfunction.d.ts +85 -0
  121. package/dist/aws/infra/stack/monitoredfunction.js +147 -0
  122. package/dist/aws/infra/stack/parameters.d.ts +40 -0
  123. package/dist/aws/infra/stack/parameters.js +50 -0
  124. package/dist/aws/infra/stack/rest-api.d.ts +74 -0
  125. package/dist/aws/infra/stack/rest-api.js +235 -0
  126. package/dist/aws/infra/stack/stack-checking-aspect.d.ts +20 -0
  127. package/dist/aws/infra/stack/stack-checking-aspect.js +183 -0
  128. package/dist/aws/infra/stack/stack.d.ts +56 -0
  129. package/dist/aws/infra/stack/stack.js +71 -0
  130. package/dist/aws/infra/stack/subscription.d.ts +17 -0
  131. package/dist/aws/infra/stack/subscription.js +37 -0
  132. package/dist/aws/infra/stacks/db-dns-stack.d.ts +13 -0
  133. package/dist/aws/infra/stacks/db-dns-stack.js +60 -0
  134. package/dist/aws/infra/stacks/db-proxy-stack.d.ts +24 -0
  135. package/dist/aws/infra/stacks/db-proxy-stack.js +74 -0
  136. package/dist/aws/infra/stacks/db-stack.d.ts +65 -0
  137. package/dist/aws/infra/stacks/db-stack.js +189 -0
  138. package/dist/aws/infra/stacks/intra-stack-configuration.d.ts +5 -0
  139. package/dist/aws/infra/stacks/intra-stack-configuration.js +2 -0
  140. package/dist/aws/infra/stacks/network-stack.d.ts +14 -0
  141. package/dist/aws/infra/stacks/network-stack.js +45 -0
  142. package/dist/aws/infra/usage-plans.d.ts +16 -0
  143. package/dist/aws/infra/usage-plans.js +38 -0
  144. package/dist/aws/runtime/apikey.d.ts +2 -0
  145. package/dist/aws/runtime/apikey.js +13 -0
  146. package/dist/aws/runtime/digitraffic-integration-response.d.ts +8 -0
  147. package/dist/aws/runtime/digitraffic-integration-response.js +25 -0
  148. package/dist/aws/runtime/dt-logger-default.d.ts +9 -0
  149. package/dist/aws/runtime/dt-logger-default.js +6 -0
  150. package/dist/aws/runtime/dt-logger.d.ts +117 -0
  151. package/dist/aws/runtime/dt-logger.js +159 -0
  152. package/dist/aws/runtime/environment.d.ts +5 -0
  153. package/dist/aws/runtime/environment.js +7 -0
  154. package/dist/aws/runtime/s3.d.ts +3 -0
  155. package/dist/aws/runtime/s3.js +21 -0
  156. package/dist/aws/runtime/secrets/dbsecret.d.ts +16 -0
  157. package/dist/aws/runtime/secrets/dbsecret.js +26 -0
  158. package/dist/aws/runtime/secrets/proxy-holder.d.ts +9 -0
  159. package/dist/aws/runtime/secrets/proxy-holder.js +25 -0
  160. package/dist/aws/runtime/secrets/rds-holder.d.ts +9 -0
  161. package/dist/aws/runtime/secrets/rds-holder.js +25 -0
  162. package/dist/aws/runtime/secrets/secret-holder.d.ts +30 -0
  163. package/dist/aws/runtime/secrets/secret-holder.js +81 -0
  164. package/dist/aws/runtime/secrets/secret.d.ts +8 -0
  165. package/dist/aws/runtime/secrets/secret.js +61 -0
  166. package/dist/aws/types/errors.d.ts +8 -0
  167. package/dist/aws/types/errors.js +13 -0
  168. package/dist/aws/types/lambda-proxy-types.d.ts +59 -0
  169. package/dist/aws/types/lambda-proxy-types.js +210 -0
  170. package/dist/aws/types/lambda-response.d.ts +89 -0
  171. package/dist/aws/types/lambda-response.js +204 -0
  172. package/dist/aws/types/mediatypes.d.ts +11 -0
  173. package/dist/aws/types/mediatypes.js +14 -0
  174. package/dist/aws/types/model-with-reference.d.ts +7 -0
  175. package/dist/aws/types/model-with-reference.js +2 -0
  176. package/dist/aws/types/tags.d.ts +2 -0
  177. package/dist/aws/types/tags.js +4 -0
  178. package/dist/database/database.d.ts +27 -0
  179. package/dist/database/database.js +95 -0
  180. package/dist/database/last-updated.d.ts +15 -0
  181. package/dist/database/last-updated.js +46 -0
  182. package/dist/database/models.d.ts +6 -0
  183. package/dist/database/models.js +2 -0
  184. package/dist/index.d.ts +2 -0
  185. package/dist/index.js +2 -0
  186. package/dist/marine/id_utils.d.ts +3 -0
  187. package/dist/marine/id_utils.js +36 -0
  188. package/dist/marine/rtz.d.ts +48 -0
  189. package/dist/marine/rtz.js +2 -0
  190. package/dist/types/async-timeout-error.d.ts +3 -0
  191. package/dist/types/async-timeout-error.js +6 -0
  192. package/dist/types/either.d.ts +9 -0
  193. package/dist/types/either.js +2 -0
  194. package/dist/types/geojson.d.ts +47 -0
  195. package/dist/types/geojson.js +51 -0
  196. package/dist/types/http-error.d.ts +4 -0
  197. package/dist/types/http-error.js +8 -0
  198. package/dist/types/input-error.d.ts +2 -0
  199. package/dist/types/input-error.js +3 -0
  200. package/dist/types/language.d.ts +5 -0
  201. package/dist/types/language.js +7 -0
  202. package/dist/types/nullable.d.ts +24 -0
  203. package/dist/types/nullable.js +2 -0
  204. package/dist/types/openapi-schema.d.ts +932 -0
  205. package/dist/types/openapi-schema.js +151 -0
  206. package/dist/types/traffictype.d.ts +11 -0
  207. package/dist/types/traffictype.js +13 -0
  208. package/dist/types/urn.d.ts +1 -0
  209. package/dist/types/urn.js +2 -0
  210. package/dist/types/util-types.d.ts +11 -0
  211. package/dist/types/util-types.js +2 -0
  212. package/dist/types/validator.d.ts +4 -0
  213. package/dist/types/validator.js +9 -0
  214. package/dist/utils/api-model.d.ts +51 -0
  215. package/dist/utils/api-model.js +118 -0
  216. package/dist/utils/base64.d.ts +34 -0
  217. package/dist/utils/base64.js +53 -0
  218. package/dist/utils/date-utils.d.ts +27 -0
  219. package/dist/utils/date-utils.js +45 -0
  220. package/dist/utils/geojson-types.d.ts +14 -0
  221. package/dist/utils/geojson-types.js +15 -0
  222. package/dist/utils/geometry.d.ts +44 -0
  223. package/dist/utils/geometry.js +154 -0
  224. package/dist/utils/lambda-proxy-event.d.ts +9 -0
  225. package/dist/utils/lambda-proxy-event.js +31 -0
  226. package/dist/utils/logging.d.ts +40 -0
  227. package/dist/utils/logging.js +88 -0
  228. package/dist/utils/retry.d.ts +33 -0
  229. package/dist/utils/retry.js +135 -0
  230. package/dist/utils/slack.d.ts +5 -0
  231. package/dist/utils/slack.js +24 -0
  232. package/dist/utils/stop-watch.d.ts +46 -0
  233. package/dist/utils/stop-watch.js +114 -0
  234. package/dist/utils/utils.d.ts +95 -0
  235. package/dist/utils/utils.js +178 -0
  236. package/dist/utils/zod-utils.d.ts +27 -0
  237. package/dist/utils/zod-utils.js +57 -0
  238. package/package.json +30 -28
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,45 @@
1
+ import { App } from "aws-cdk-lib";
2
+ import { Match, Template } from "aws-cdk-lib/assertions";
3
+ import { describe, test } from "vitest";
4
+ import { DigitrafficRestApi } from "../../aws/infra/stack/rest-api.js";
5
+ import { DigitrafficStack } from "../../aws/infra/stack/stack.js";
6
+ import { TrafficType } from "../../types/traffictype.js";
7
+ describe("Rest api test", () => {
8
+ test("OPTIONS method is added to API-gateway", () => {
9
+ const app = new App();
10
+ const stack = new DigitrafficStack(app, "test-stack", {
11
+ alarmTopicArn: "",
12
+ production: false,
13
+ shortName: "test",
14
+ stackProps: {},
15
+ trafficType: TrafficType.ROAD,
16
+ warningTopicArn: "",
17
+ });
18
+ const publicApi = new DigitrafficRestApi(stack, "test", "testName");
19
+ const apiResource = publicApi.root.addResource("api");
20
+ const versionResource = apiResource.addResource("v1");
21
+ const testsResource = publicApi.addResourceWithCorsOptionsSubTree(versionResource, "tests");
22
+ testsResource.addResource("{testId}");
23
+ const template = Template.fromStack(stack);
24
+ template.resourcePropertiesCountIs("AWS::ApiGateway::Method", {
25
+ HttpMethod: "OPTIONS",
26
+ }, 2);
27
+ template.hasResource("AWS::ApiGateway::Method", {
28
+ Properties: {
29
+ HttpMethod: "OPTIONS",
30
+ Integration: {
31
+ IntegrationResponses: Match.arrayWith([
32
+ Match.objectLike({
33
+ ResponseParameters: Match.objectEquals({
34
+ "method.response.header.Access-Control-Allow-Headers": "'Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token,Digitraffic-User'",
35
+ "method.response.header.Access-Control-Allow-Origin": "'*'",
36
+ "method.response.header.Access-Control-Allow-Methods": "'OPTIONS,GET,HEAD'",
37
+ }),
38
+ }),
39
+ ]),
40
+ },
41
+ },
42
+ });
43
+ });
44
+ });
45
+ //# sourceMappingURL=rest-apis.test.js.map
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,46 @@
1
+ import { afterEach, describe, expect, test, vi } from "vitest";
2
+ import { mockKyResponse } from "../../__test__/mock-ky.js";
3
+ const ky = (await import("ky")).default;
4
+ describe("mockKyResponse", () => {
5
+ const testObj = { test: "data" };
6
+ const testJson = JSON.stringify(testObj);
7
+ const url = "https://example.com";
8
+ afterEach(() => {
9
+ vi.restoreAllMocks();
10
+ });
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));
16
+ expect(await ky.get(url).text()).toEqual(testJson);
17
+ expect(await ky.put(url).text()).toEqual(testJson);
18
+ expect(await ky.post(url).text()).toEqual(testJson);
19
+ expect(await ky.delete(url).text()).toEqual(testJson);
20
+ });
21
+ test("returns correct status", async () => {
22
+ vi.spyOn(ky, "get").mockImplementation(() => mockKyResponse(200, testJson));
23
+ expect((await ky.get(url)).status).toEqual(200);
24
+ vi.spyOn(ky, "get").mockImplementation(() => mockKyResponse(400, testJson));
25
+ expect((await ky.get(url)).status).toEqual(400);
26
+ });
27
+ test("returns correct ok", async () => {
28
+ vi.spyOn(ky, "get").mockImplementation(() => mockKyResponse(200, testJson));
29
+ expect((await ky.get(url)).ok).toEqual(true);
30
+ vi.spyOn(ky, "get").mockImplementation(() => mockKyResponse(299, testJson));
31
+ expect((await ky.get(url)).ok).toEqual(true);
32
+ vi.spyOn(ky, "get").mockImplementation(() => mockKyResponse(300, testJson));
33
+ expect((await ky.get(url)).ok).toEqual(false);
34
+ });
35
+ test("convenience methods work: text", async () => {
36
+ vi.spyOn(ky, "get").mockImplementation(() => mockKyResponse(200, testJson));
37
+ expect(await ky.get(url).text()).toEqual(testJson);
38
+ expect(await (await ky.get(url)).text()).toEqual(testJson);
39
+ });
40
+ test("convenience methods work: json", async () => {
41
+ vi.spyOn(ky, "get").mockImplementation(() => mockKyResponse(200, testJson));
42
+ expect(await ky.get(url).json()).toEqual(testObj);
43
+ expect(await (await ky.get(url)).json()).toEqual(testObj);
44
+ });
45
+ });
46
+ //# sourceMappingURL=mock-ky.test.js.map
@@ -0,0 +1,12 @@
1
+ export declare function randomString(): string;
2
+ export declare function getRandomNumber(min: number, max: number): number;
3
+ export declare function getRandomNumberAsString(min: number, max: number): string;
4
+ export declare function getRandomInteger(min: number, max: number): number;
5
+ export declare function getRandomIntegerAsString(min: number, max: number): string;
6
+ export declare function getRandomBigInt(min: number, max: number): bigint;
7
+ export declare function randomBoolean(): boolean;
8
+ /**
9
+ * Returns a new copy of an array, shuffled using Math.random()
10
+ * @param array Array
11
+ */
12
+ export declare function shuffle<T>(array: T[]): T[];
@@ -0,0 +1,32 @@
1
+ export function randomString() {
2
+ return Math.random().toString(36).substring(2);
3
+ }
4
+ export function getRandomNumber(min, max) {
5
+ return Math.random() * (max - min) + min;
6
+ }
7
+ export function getRandomNumberAsString(min, max) {
8
+ return getRandomNumber(min, max).toString();
9
+ }
10
+ export function getRandomInteger(min, max) {
11
+ return Math.round(getRandomNumber(min, max));
12
+ }
13
+ export function getRandomIntegerAsString(min, max) {
14
+ return Math.round(getRandomInteger(min, max)).toString();
15
+ }
16
+ export function getRandomBigInt(min, max) {
17
+ return BigInt(getRandomInteger(min, max));
18
+ }
19
+ export function randomBoolean() {
20
+ return Math.random() < 0.5;
21
+ }
22
+ /**
23
+ * Returns a new copy of an array, shuffled using Math.random()
24
+ * @param array Array
25
+ */
26
+ export function shuffle(array) {
27
+ // pretty fast way to copy an array, not necessarily the fastest
28
+ const newArray = array.slice(0);
29
+ newArray.sort((_) => 0.5 - Math.random());
30
+ return newArray;
31
+ }
32
+ //# sourceMappingURL=testutils.js.map
@@ -0,0 +1,8 @@
1
+ export declare const TEST_BIG_JSON: {
2
+ items: {
3
+ id: number;
4
+ name: string;
5
+ description: string;
6
+ value: number;
7
+ }[];
8
+ };
@@ -0,0 +1,155 @@
1
+ import { describe, expect, test } from "vitest";
2
+ import { LambdaProxyResponseBuilder } from "../../aws/types/lambda-proxy-types.js";
3
+ import { MediaType } from "../../aws/types/mediatypes.js";
4
+ import { decodeBase64ToUtf8 } from "../../utils/base64.js";
5
+ // About 18 MB will be compressed to 2 MB
6
+ export const TEST_BIG_JSON = {
7
+ items: Array.from({ length: 10 }, (_, i) => ({
8
+ id: i,
9
+ name: `Item ${i}`,
10
+ description: "This is a test description that repeats to allow compression",
11
+ value: Math.random(),
12
+ })),
13
+ };
14
+ describe("lambda-response", () => {
15
+ const TEST_MESSAGE = "HELLO";
16
+ const TEST_COUNT = 12;
17
+ const TEST_FILENAME = "file.txt";
18
+ const TEST_TIMESTAMP = new Date();
19
+ const TEST_TIMESTAMP_STR = TEST_TIMESTAMP.toISOString();
20
+ const TEST_JSON = {
21
+ message: TEST_MESSAGE,
22
+ count: TEST_COUNT,
23
+ };
24
+ function isCompressed(response) {
25
+ return response.headers?.["Content-Encoding"] === "gzip";
26
+ }
27
+ function assertContent(response, expectedBody, expectedStatus, expectedFilename, expectedTimestamp, expectContentType = MediaType.APPLICATION_JSON, compressed = false, isBase64Encoded = false) {
28
+ const isBinary = typeof expectedBody !== "string";
29
+ const decodedBody = response.isBase64Encoded
30
+ ? decodeBase64ToUtf8(response.body, isCompressed(response))
31
+ : response.body;
32
+ const body = isBinary ? JSON.parse(decodedBody) : decodedBody;
33
+ expect(body).toEqual(expectedBody);
34
+ // compressed responses are always base64 encoded
35
+ expect(response.isBase64Encoded).toEqual(compressed || isBase64Encoded);
36
+ expect(response.statusCode).toEqual(expectedStatus);
37
+ if (expectedFilename) {
38
+ expect(response.headers?.["Content-Disposition"]).toEqual(`attachment; filename="${expectedFilename}"`);
39
+ }
40
+ else {
41
+ expect(response.headers?.["Content-Disposition"]).toBeUndefined();
42
+ }
43
+ if (expectedTimestamp) {
44
+ expect(response.headers?.["Last-Modified"]).toEqual(expectedTimestamp?.toUTCString());
45
+ }
46
+ else {
47
+ expect(response.headers?.["Last-Modified"]).toBeUndefined();
48
+ }
49
+ if (compressed) {
50
+ expect(response.headers?.["Content-Encoding"]).toEqual("gzip");
51
+ }
52
+ else {
53
+ // No content-encoding header for uncompressed content
54
+ expect(response.headers?.["Content-Encoding"]).toBeUndefined();
55
+ }
56
+ expect(response.headers?.["Content-Type"]).toEqual(expectContentType);
57
+ }
58
+ test("okJson - create json", () => {
59
+ const response = LambdaProxyResponseBuilder.create(TEST_JSON).build();
60
+ assertContent(response, TEST_JSON, 200);
61
+ });
62
+ test("okJson - with json", () => {
63
+ const response = LambdaProxyResponseBuilder.create()
64
+ .withBody(TEST_JSON)
65
+ .build();
66
+ assertContent(response, TEST_JSON, 200);
67
+ });
68
+ test("okJson - with json and fileName", () => {
69
+ const response = LambdaProxyResponseBuilder.create()
70
+ .withBody(TEST_JSON)
71
+ .withFileName(TEST_FILENAME)
72
+ .build();
73
+ assertContent(response, TEST_JSON, 200, TEST_FILENAME);
74
+ });
75
+ test("okJson - with json, fileName and timestamp", () => {
76
+ const response = LambdaProxyResponseBuilder.create()
77
+ .withBody(TEST_JSON)
78
+ .withFileName(TEST_FILENAME)
79
+ .withTimestamp(TEST_TIMESTAMP)
80
+ .build();
81
+ const response2 = LambdaProxyResponseBuilder.create()
82
+ .withBody(TEST_JSON)
83
+ .withFileName(TEST_FILENAME)
84
+ .withTimestamp(TEST_TIMESTAMP_STR)
85
+ .build();
86
+ assertContent(response, TEST_JSON, 200, TEST_FILENAME, TEST_TIMESTAMP);
87
+ assertContent(response2, TEST_JSON, 200, TEST_FILENAME, TEST_TIMESTAMP);
88
+ });
89
+ test("okBinary - create binary, fileName and timestamp", () => {
90
+ const response = LambdaProxyResponseBuilder.create(Buffer.from(TEST_MESSAGE).toString("base64"), true)
91
+ .withFileName(TEST_FILENAME)
92
+ .withTimestamp(TEST_TIMESTAMP)
93
+ .withContentType(MediaType.TEXT_PLAIN)
94
+ .build();
95
+ assertContent(response, TEST_MESSAGE, 200, TEST_FILENAME, TEST_TIMESTAMP, MediaType.TEXT_PLAIN, false, true);
96
+ });
97
+ test("badRequest", () => {
98
+ const response = LambdaProxyResponseBuilder.badRequest(TEST_MESSAGE);
99
+ assertContent(response, TEST_MESSAGE, 400, undefined, undefined, MediaType.TEXT_PLAIN);
100
+ });
101
+ test("notFound", () => {
102
+ const response = LambdaProxyResponseBuilder.notFound();
103
+ assertContent(response, "Not Found", 404, undefined, undefined, MediaType.TEXT_PLAIN);
104
+ });
105
+ test("internalError", () => {
106
+ const response = LambdaProxyResponseBuilder.internalError();
107
+ assertContent(response, "Internal Error", 500, undefined, undefined, MediaType.TEXT_PLAIN);
108
+ });
109
+ test("notImplemented", () => {
110
+ const response = LambdaProxyResponseBuilder.notImplemented();
111
+ assertContent(response, "Not Implemented", 501, undefined, undefined, MediaType.TEXT_PLAIN);
112
+ });
113
+ test("notImplemented", () => {
114
+ const response = LambdaProxyResponseBuilder.unauthorized();
115
+ assertContent(response, "Unauthorized", 401, undefined, undefined, MediaType.TEXT_PLAIN);
116
+ });
117
+ test("okText - with fileName and timestamp", () => {
118
+ const response = LambdaProxyResponseBuilder.create()
119
+ .withBody(TEST_MESSAGE)
120
+ .withFileName(TEST_FILENAME)
121
+ .withTimestamp(TEST_TIMESTAMP)
122
+ .build();
123
+ assertContent(response, TEST_MESSAGE, 200, TEST_FILENAME, TEST_TIMESTAMP);
124
+ });
125
+ test("okJson - compression uneffective for small json", () => {
126
+ const response = LambdaProxyResponseBuilder.create()
127
+ .withBody(TEST_JSON)
128
+ .withFileName(TEST_FILENAME)
129
+ .withTimestamp(TEST_TIMESTAMP)
130
+ .withCompression()
131
+ .withDebug()
132
+ .build();
133
+ assertContent(response, TEST_JSON, 200, TEST_FILENAME, TEST_TIMESTAMP, MediaType.APPLICATION_JSON, false);
134
+ });
135
+ test("okJson - compression effective for large json", () => {
136
+ const response = LambdaProxyResponseBuilder.create()
137
+ .withBody(TEST_BIG_JSON)
138
+ .withFileName(TEST_FILENAME)
139
+ .withTimestamp(TEST_TIMESTAMP)
140
+ .withCompression()
141
+ .withDebug()
142
+ .build();
143
+ assertContent(response, TEST_BIG_JSON, 200, TEST_FILENAME, TEST_TIMESTAMP, MediaType.APPLICATION_JSON, true);
144
+ });
145
+ test("okText - as binary", () => {
146
+ const response = LambdaProxyResponseBuilder.create()
147
+ .withBody(Buffer.from(TEST_MESSAGE).toString("base64"), true)
148
+ .withFileName(TEST_FILENAME)
149
+ .withTimestamp(TEST_TIMESTAMP)
150
+ .withContentType(MediaType.TEXT_PLAIN)
151
+ .build();
152
+ assertContent(response, TEST_MESSAGE, 200, TEST_FILENAME, TEST_TIMESTAMP, MediaType.TEXT_PLAIN, false, true);
153
+ });
154
+ });
155
+ //# sourceMappingURL=lambda-proxy-types.test.js.map
@@ -0,0 +1,81 @@
1
+ import { describe, expect, test } from "vitest";
2
+ import { LambdaResponseBuilder } from "../../aws/types/lambda-response.js";
3
+ import { decodeBase64ToUtf8 } from "../../utils/base64.js";
4
+ import { TEST_FILENAME, TEST_JSON, TEST_MESSAGE, TEST_TIMESTAMP, TEST_TIMESTAMP_STR, } from "./lambda-response.test.js";
5
+ describe("lambda-response", () => {
6
+ function assertJson(response, expectedJson, expectedStatus, expectedFilename, expectedTimestamp) {
7
+ const body = JSON.parse(decodeBase64ToUtf8(response.body));
8
+ expect(body).toEqual(expectedJson);
9
+ expect(response.status).toEqual(expectedStatus);
10
+ expect(response.fileName).toEqual(expectedFilename);
11
+ expect(response.timestamp).toEqual(expectedTimestamp?.toUTCString());
12
+ }
13
+ function assertBinary(response, expectedString, expectedStatus, expectedFilename, expectedTimestamp) {
14
+ const body = decodeBase64ToUtf8(response.body);
15
+ expect(body).toEqual(expectedString);
16
+ expect(response.status).toEqual(expectedStatus);
17
+ expect(response.fileName).toEqual(expectedFilename);
18
+ expect(response.timestamp).toEqual(expectedTimestamp?.toUTCString());
19
+ }
20
+ test("okJson - without fileName", () => {
21
+ const response = LambdaResponseBuilder.create(TEST_JSON).build();
22
+ assertJson(response, TEST_JSON, 200);
23
+ });
24
+ test("okJson - with fileName", () => {
25
+ const response = LambdaResponseBuilder.create(TEST_JSON)
26
+ .withFileName(TEST_FILENAME)
27
+ .build();
28
+ assertJson(response, TEST_JSON, 200, TEST_FILENAME);
29
+ });
30
+ test("okJson - with fileName and timestamp", () => {
31
+ const responseWithTimestampDate = LambdaResponseBuilder.create()
32
+ .withBody(TEST_JSON)
33
+ .withFileName(TEST_FILENAME)
34
+ .withTimestamp(TEST_TIMESTAMP)
35
+ .build();
36
+ const responseWithTimestampString = LambdaResponseBuilder.create()
37
+ .withBody(TEST_JSON)
38
+ .withFileName(TEST_FILENAME)
39
+ .withTimestamp(TEST_TIMESTAMP_STR)
40
+ .build();
41
+ assertJson(responseWithTimestampDate, TEST_JSON, 200, TEST_FILENAME, TEST_TIMESTAMP);
42
+ assertJson(responseWithTimestampString, TEST_JSON, 200, TEST_FILENAME, TEST_TIMESTAMP);
43
+ });
44
+ test("okBinary - with fileName and timestamp", () => {
45
+ const response = LambdaResponseBuilder.create()
46
+ .withBody(TEST_MESSAGE)
47
+ .withFileName(TEST_FILENAME)
48
+ .withTimestamp(TEST_TIMESTAMP)
49
+ .build();
50
+ assertBinary(response, TEST_MESSAGE, 200, TEST_FILENAME, TEST_TIMESTAMP);
51
+ });
52
+ test("badRequest", () => {
53
+ const response = LambdaResponseBuilder.badRequest(TEST_MESSAGE);
54
+ assertBinary(response, TEST_MESSAGE, 400);
55
+ });
56
+ test("notFound", () => {
57
+ const response = LambdaResponseBuilder.notFound();
58
+ assertBinary(response, "Not Found", 404);
59
+ });
60
+ test("internalError", () => {
61
+ const response = LambdaResponseBuilder.internalError();
62
+ assertBinary(response, "Internal Error", 500);
63
+ });
64
+ test("notImplemented", () => {
65
+ const response = LambdaResponseBuilder.notImplemented();
66
+ assertBinary(response, "Not Implemented", 501);
67
+ });
68
+ // Builder
69
+ test("Builder - okJson - without fileName", () => {
70
+ const response = LambdaResponseBuilder.create().withBody(TEST_JSON).build();
71
+ assertJson(response, TEST_JSON, 200);
72
+ });
73
+ test("Builder - okJson - with fileName", () => {
74
+ const response = LambdaResponseBuilder.create()
75
+ .withBody(TEST_JSON)
76
+ .withFileName(TEST_FILENAME)
77
+ .build();
78
+ assertJson(response, TEST_JSON, 200, TEST_FILENAME);
79
+ });
80
+ });
81
+ //# sourceMappingURL=lambda-response-builder.test.js.map
@@ -0,0 +1,9 @@
1
+ export declare const TEST_MESSAGE = "HELLO";
2
+ export declare const TEST_COUNT = 12;
3
+ export declare const TEST_FILENAME = "file.txt";
4
+ export declare const TEST_TIMESTAMP: Date;
5
+ export declare const TEST_TIMESTAMP_STR: string;
6
+ export declare const TEST_JSON: {
7
+ message: string;
8
+ count: number;
9
+ };
@@ -0,0 +1,73 @@
1
+ import { describe, expect, test } from "vitest";
2
+ import { LambdaResponse, LambdaResponseBuilder, } from "../../aws/types/lambda-response.js";
3
+ import { decodeBase64ToUtf8 } from "../../utils/base64.js";
4
+ export const TEST_MESSAGE = "HELLO";
5
+ export const TEST_COUNT = 12;
6
+ export const TEST_FILENAME = "file.txt";
7
+ export const TEST_TIMESTAMP = new Date();
8
+ export const TEST_TIMESTAMP_STR = TEST_TIMESTAMP.toISOString();
9
+ export const TEST_JSON = {
10
+ message: TEST_MESSAGE,
11
+ count: TEST_COUNT,
12
+ };
13
+ describe("lambda-response", () => {
14
+ function assertJson(response, expectedJson, expectedStatus, expectedFilename, expectedTimestamp) {
15
+ const body = JSON.parse(decodeBase64ToUtf8(response.body));
16
+ expect(body).toEqual(expectedJson);
17
+ expect(response.status).toEqual(expectedStatus);
18
+ expect(response.fileName).toEqual(expectedFilename);
19
+ expect(response.timestamp).toEqual(expectedTimestamp?.toUTCString());
20
+ }
21
+ function assertBinary(response, expectedString, expectedStatus, expectedFilename, expectedTimestamp) {
22
+ const body = decodeBase64ToUtf8(response.body);
23
+ expect(body).toEqual(expectedString);
24
+ expect(response.status).toEqual(expectedStatus);
25
+ expect(response.fileName).toEqual(expectedFilename);
26
+ expect(response.timestamp).toEqual(expectedTimestamp?.toUTCString());
27
+ }
28
+ test("okJson - without fileName", () => {
29
+ const response = LambdaResponse.okJson(TEST_JSON);
30
+ assertJson(response, TEST_JSON, 200);
31
+ });
32
+ test("okJson - with fileName", () => {
33
+ const response = LambdaResponse.okJson(TEST_JSON, TEST_FILENAME);
34
+ assertJson(response, TEST_JSON, 200, TEST_FILENAME);
35
+ });
36
+ test("okJson - with fileName and timestamp", () => {
37
+ const response = LambdaResponse.okJson(TEST_JSON, TEST_FILENAME).withTimestamp(TEST_TIMESTAMP);
38
+ assertJson(response, TEST_JSON, 200, TEST_FILENAME, TEST_TIMESTAMP);
39
+ });
40
+ test("okBinary - with fileName and timestamp", () => {
41
+ const response = LambdaResponse.okBinary(Buffer.from(TEST_MESSAGE).toString("base64"), TEST_FILENAME).withTimestamp(TEST_TIMESTAMP);
42
+ assertBinary(response, TEST_MESSAGE, 200, TEST_FILENAME, TEST_TIMESTAMP);
43
+ });
44
+ test("badRequest", () => {
45
+ const response = LambdaResponse.badRequest(TEST_MESSAGE);
46
+ assertBinary(response, TEST_MESSAGE, 400);
47
+ });
48
+ test("notFound", () => {
49
+ const response = LambdaResponse.notFound();
50
+ assertBinary(response, "Not Found", 404);
51
+ });
52
+ test("internalError", () => {
53
+ const response = LambdaResponse.internalError();
54
+ assertBinary(response, "Internal Error", 500);
55
+ });
56
+ test("notImplemented", () => {
57
+ const response = LambdaResponse.notImplemented();
58
+ assertBinary(response, "Not Implemented", 501);
59
+ });
60
+ // Builder
61
+ test("Builder - okJson - without fileName", () => {
62
+ const response = LambdaResponseBuilder.create().withBody(TEST_JSON).build();
63
+ assertJson(response, TEST_JSON, 200);
64
+ });
65
+ test("Builder - okJson - with fileName", () => {
66
+ const response = LambdaResponseBuilder.create()
67
+ .withBody(TEST_JSON)
68
+ .withFileName(TEST_FILENAME)
69
+ .build();
70
+ assertJson(response, TEST_JSON, 200, TEST_FILENAME);
71
+ });
72
+ });
73
+ //# sourceMappingURL=lambda-response.test.js.map
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,38 @@
1
+ import { describe, expect, test } from "vitest";
2
+ import { compressBuffer, decodeBase64ToAscii, decodeBase64ToUtf8, encodeAsciiToBase64, encodeUtf8ToBase64, } from "../../utils/base64.js";
3
+ describe("Base64UtilTest", () => {
4
+ const EXPECTED_ASCII = "0a9f4967-faaa-445a-ba11-078f7f9556b4";
5
+ const EXPECTED_ASCII_BASE64 = "MGE5ZjQ5NjctZmFhYS00NDVhLWJhMTEtMDc4ZjdmOTU1NmI0";
6
+ const EXPECTED_UTF8 = '욤頶ɠ_񝝉T񶅶𞜫7郣Ҧ㒢,"鏤ځ峡蟅͆뼐񭫟ؐԓ外󦸴ԉȺꥅ_񟵭';
7
+ const EXPECTED_UTF8_BASE64 = "7Jqk6aC2yaBf8Z2diVTxtoW28J6cqzfug6Ppg6PSpuOSou6Usywi6Y+k2oHls6Hon4XNhuu8kPGtq5/YkNST5aSW86a4tNSJyLrqpYVf8Z+1rQ==";
8
+ test("encode and decode ascii", () => {
9
+ const encodedAscii = encodeAsciiToBase64(EXPECTED_ASCII);
10
+ const decodedAscii = decodeBase64ToAscii(EXPECTED_ASCII_BASE64);
11
+ // encoding/decoding ascii with utf8 should be the same as ascii
12
+ const encodedUtf8 = encodeUtf8ToBase64(EXPECTED_ASCII);
13
+ const decodedUtf8 = decodeBase64ToUtf8(EXPECTED_ASCII_BASE64);
14
+ expect(encodedAscii).toEqual(EXPECTED_ASCII_BASE64);
15
+ expect(decodedAscii).toEqual(EXPECTED_ASCII);
16
+ expect(encodedUtf8).toEqual(EXPECTED_ASCII_BASE64);
17
+ expect(decodedUtf8).toEqual(EXPECTED_ASCII);
18
+ expect(encodedUtf8).toEqual(encodedAscii);
19
+ expect(decodedUtf8).toEqual(decodedAscii);
20
+ });
21
+ test("encode and decode utf8", () => {
22
+ const encodedUtf8 = encodeUtf8ToBase64(EXPECTED_UTF8);
23
+ const decodedUtf8 = decodeBase64ToUtf8(EXPECTED_UTF8_BASE64);
24
+ expect(encodedUtf8).toEqual(EXPECTED_UTF8_BASE64);
25
+ expect(decodedUtf8).toEqual(EXPECTED_UTF8);
26
+ });
27
+ test("decode utf8 compressed", () => {
28
+ const originalBody = { message: EXPECTED_UTF8 };
29
+ const body = JSON.stringify(originalBody);
30
+ const rawBuffer = Buffer.from(body, "utf8");
31
+ const compressed = compressBuffer(rawBuffer);
32
+ const compressedBase64 = compressed.toString("base64");
33
+ const uncompressedBody = decodeBase64ToUtf8(compressedBase64, true);
34
+ const restoredBody = JSON.parse(uncompressedBody);
35
+ expect(originalBody).toEqual(restoredBody);
36
+ });
37
+ });
38
+ //# sourceMappingURL=base64.test.js.map
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,32 @@
1
+ import { parseISO } from "date-fns";
2
+ import { describe, expect, test } from "vitest";
3
+ import * as CommonDateUtils from "../../utils/date-utils.js";
4
+ const ISO = "2022-01-02T01:02:03.004Z";
5
+ describe("CommonDateUtilsTest", () => {
6
+ test("dateFromIsoString", () => {
7
+ const parsed = CommonDateUtils.dateFromIsoString(ISO);
8
+ expect(parsed.toISOString()).toEqual(ISO);
9
+ });
10
+ test("dateFromIsoString fails", () => {
11
+ expect(() => CommonDateUtils.dateFromIsoString(`${ISO}foobar`)).toThrow();
12
+ });
13
+ test("countDiffMs", () => {
14
+ const start = new Date();
15
+ const end = new Date(start.getTime() + 1234);
16
+ expect(CommonDateUtils.countDiffMs(start, end)).toEqual(1234);
17
+ });
18
+ test("countDiffMs", () => {
19
+ const start = new Date();
20
+ const end = new Date(start.getTime() + 1234 * 1000);
21
+ expect(CommonDateUtils.countDiffInSeconds(start, end)).toEqual(1234);
22
+ });
23
+ test("dateToUTCString - preserves UTC from parsed string", () => {
24
+ const date = parseISO("2023-01-01T00:00Z");
25
+ expect(CommonDateUtils.dateToUTCString(date, CommonDateUtils.MYSQL_DATETIME_FORMAT)).toEqual("2023-01-01 00:00");
26
+ });
27
+ test("dateToUTCString - +02:00 to UTC from parsed string", () => {
28
+ const date = parseISO("2023-01-01T00:00+02:00");
29
+ expect(CommonDateUtils.dateToUTCString(date, CommonDateUtils.MYSQL_DATETIME_FORMAT)).toEqual("2022-12-31 22:00");
30
+ });
31
+ });
32
+ //# sourceMappingURL=date-utils.test.js.map
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,25 @@
1
+ import { describe, expect, test } from "vitest";
2
+ import * as Geometry from "../../utils/geometry.js";
3
+ import { Asserter } from "../asserter.js";
4
+ const TAMPERE_WGS84_X = 23.761290078;
5
+ const TAMPERE_WGS84_Y = 61.49774257;
6
+ const KUOPIO_WGS84_X = 27.688935;
7
+ const KUOPIO_WGS84_Y = 62.892983;
8
+ const TAMPERE_KUOPIO_DISTANCE_KM = 255.8;
9
+ describe("CommonGeometryTest", () => {
10
+ test("distanceBetweenWGS84PointsInKm", () => {
11
+ Asserter.assertToBeCloseTo(Geometry.distanceBetweenPositionsInKm([TAMPERE_WGS84_X, TAMPERE_WGS84_Y], [KUOPIO_WGS84_X, KUOPIO_WGS84_Y]), TAMPERE_KUOPIO_DISTANCE_KM, 0.5);
12
+ console.info(Geometry.distanceBetweenPositionsInKm([TAMPERE_WGS84_X, TAMPERE_WGS84_Y], [KUOPIO_WGS84_X, KUOPIO_WGS84_Y]));
13
+ });
14
+ test("distanceBetweenWGS84PointsInKm", () => {
15
+ Asserter.assertToBeCloseTo(Geometry.distanceBetweenPositionsInM([TAMPERE_WGS84_X, TAMPERE_WGS84_Y], [KUOPIO_WGS84_X, KUOPIO_WGS84_Y]), TAMPERE_KUOPIO_DISTANCE_KM * 1000, 500);
16
+ console.info(Geometry.distanceBetweenPositionsInM([TAMPERE_WGS84_X, TAMPERE_WGS84_Y], [KUOPIO_WGS84_X, KUOPIO_WGS84_Y]));
17
+ });
18
+ test("areDistinctPositions", () => {
19
+ expect(Geometry.areDistinctPositions([1, 2], [1, 2])).toBe(false);
20
+ expect(Geometry.areDistinctPositions([1.1, 2.2], [1.1, 2.2])).toBe(false);
21
+ expect(Geometry.areDistinctPositions([1, 2.1], [1, 2])).toBe(true);
22
+ expect(Geometry.areDistinctPositions([1, 2], [1, 2.000000000000001])).toBe(true);
23
+ });
24
+ });
25
+ //# sourceMappingURL=geometry.test.js.map
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,45 @@
1
+ import { describe, expect, test } from "vitest";
2
+ import { parseQueryParams } from "../../utils/lambda-proxy-event.js";
3
+ describe("lambda-proxy-event.test", () => {
4
+ test("StopWatch start-stop", async () => {
5
+ const event = {
6
+ body: null,
7
+ headers: {},
8
+ multiValueHeaders: {},
9
+ httpMethod: "GET",
10
+ isBase64Encoded: false,
11
+ multiValueQueryStringParameters: {
12
+ evseStatus: ["CHARGING", "OUTOFORDER"],
13
+ operatorPartyId: ["LDL"],
14
+ },
15
+ queryStringParameters: {
16
+ evseStatus: "OUTOFORDER",
17
+ operatorPartyId: "LDL",
18
+ },
19
+ };
20
+ const parsed = parseQueryParams(event, ["evseStatus"]);
21
+ expect(parsed.evseStatus).toEqual(["CHARGING", "OUTOFORDER"]);
22
+ expect(parsed.operatorPartyId).toEqual("LDL");
23
+ });
24
+ test("StopWatch start-stop", async () => {
25
+ const event = {
26
+ body: null,
27
+ headers: {},
28
+ multiValueHeaders: {},
29
+ httpMethod: "GET",
30
+ isBase64Encoded: false,
31
+ multiValueQueryStringParameters: {
32
+ evseStatus: ["CHARGING", "OUTOFORDER"],
33
+ operatorPartyId: ["LDL"],
34
+ },
35
+ queryStringParameters: {
36
+ evseStatus: "OUTOFORDER",
37
+ operatorPartyId: "LDL",
38
+ },
39
+ };
40
+ const parsed = parseQueryParams(event, ["evseStatus"]);
41
+ expect(parsed.evseStatus).toEqual(["CHARGING", "OUTOFORDER"]);
42
+ expect(parsed.operatorPartyId).toEqual("LDL");
43
+ });
44
+ });
45
+ //# sourceMappingURL=lambda-proxy-event.test.js.map
@@ -0,0 +1 @@
1
+ export {};