@digitraffic/common 2022.10.31-4 → 2022.11.2-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 (172) hide show
  1. package/dist/aws/infra/api/integration.d.ts +21 -0
  2. package/dist/aws/infra/api/integration.js.map +1 -0
  3. package/dist/aws/infra/api/response.d.ts +22 -0
  4. package/dist/aws/infra/api/response.js.map +1 -0
  5. package/dist/aws/infra/api/responses.d.ts +39 -0
  6. package/dist/aws/infra/api/responses.js.map +1 -0
  7. package/dist/aws/infra/api/static-integration.d.ts +15 -0
  8. package/dist/aws/infra/api/static-integration.js.map +1 -0
  9. package/dist/aws/infra/canaries/canary-alarm.d.ts +6 -0
  10. package/dist/aws/infra/canaries/canary-alarm.js.map +1 -0
  11. package/dist/aws/infra/canaries/canary-keys.d.ts +3 -0
  12. package/dist/aws/infra/canaries/canary-keys.js.map +1 -0
  13. package/dist/aws/infra/canaries/canary-parameters.d.ts +18 -0
  14. package/dist/aws/infra/canaries/canary-parameters.js.map +1 -0
  15. package/dist/aws/infra/canaries/canary-role.d.ts +6 -0
  16. package/dist/aws/infra/canaries/canary-role.js.map +1 -0
  17. package/dist/aws/infra/canaries/canary.d.ts +8 -0
  18. package/dist/aws/infra/canaries/canary.js +1 -1
  19. package/dist/aws/infra/canaries/canary.js.map +1 -0
  20. package/dist/aws/infra/canaries/database-canary.d.ts +18 -0
  21. package/dist/aws/infra/canaries/database-canary.js.map +1 -0
  22. package/dist/aws/infra/canaries/database-checker.d.ts +21 -0
  23. package/dist/aws/infra/canaries/database-checker.js.map +1 -0
  24. package/dist/aws/infra/canaries/url-canary.d.ts +16 -0
  25. package/dist/aws/infra/canaries/url-canary.js.map +1 -0
  26. package/dist/aws/infra/canaries/url-checker.d.ts +46 -0
  27. package/dist/aws/infra/canaries/url-checker.js +1 -1
  28. package/dist/aws/infra/canaries/url-checker.js.map +1 -0
  29. package/dist/aws/infra/documentation.d.ts +56 -0
  30. package/dist/aws/infra/documentation.js.map +1 -0
  31. package/dist/aws/infra/scheduler.d.ts +12 -0
  32. package/dist/aws/infra/scheduler.js.map +1 -0
  33. package/dist/aws/infra/security-rule.d.ts +12 -0
  34. package/dist/aws/infra/security-rule.js.map +1 -0
  35. package/dist/aws/infra/sqs-integration.d.ts +7 -0
  36. package/dist/aws/infra/sqs-integration.js.map +1 -0
  37. package/dist/aws/infra/sqs-queue.d.ts +16 -0
  38. package/dist/aws/infra/sqs-queue.js.map +1 -0
  39. package/dist/aws/infra/stack/lambda-configs.d.ts +72 -0
  40. package/dist/aws/infra/stack/lambda-configs.js.map +1 -0
  41. package/dist/aws/infra/stack/monitoredfunction.d.ts +84 -0
  42. package/dist/aws/infra/stack/monitoredfunction.js.map +1 -0
  43. package/dist/aws/infra/stack/rest_apis.d.ts +41 -0
  44. package/dist/aws/infra/stack/rest_apis.js +27 -31
  45. package/dist/aws/infra/stack/rest_apis.js.map +1 -0
  46. package/dist/aws/infra/stack/stack-checking-aspect.d.ts +21 -0
  47. package/dist/aws/infra/stack/stack-checking-aspect.js +3 -2
  48. package/dist/aws/infra/stack/stack-checking-aspect.js.map +1 -0
  49. package/dist/aws/infra/stack/stack.d.ts +45 -0
  50. package/dist/aws/infra/stack/stack.js.map +1 -0
  51. package/dist/aws/infra/stack/subscription.d.ts +17 -0
  52. package/dist/aws/infra/stack/subscription.js.map +1 -0
  53. package/dist/aws/infra/usage-plans.d.ts +15 -0
  54. package/dist/aws/infra/usage-plans.js.map +1 -0
  55. package/dist/aws/runtime/apikey.d.ts +2 -0
  56. package/dist/aws/runtime/apikey.js.map +1 -0
  57. package/dist/aws/runtime/digitraffic-integration-response.d.ts +8 -0
  58. package/dist/aws/runtime/digitraffic-integration-response.js.map +1 -0
  59. package/dist/aws/runtime/environment.d.ts +1 -0
  60. package/dist/aws/runtime/environment.js +4 -1
  61. package/dist/aws/runtime/environment.js.map +1 -0
  62. package/dist/aws/runtime/messaging.d.ts +10 -0
  63. package/dist/aws/runtime/messaging.js.map +1 -0
  64. package/dist/aws/runtime/s3.d.ts +2 -0
  65. package/dist/aws/runtime/s3.js.map +1 -0
  66. package/dist/aws/runtime/secrets/dbsecret.d.ts +54 -0
  67. package/dist/aws/runtime/secrets/dbsecret.js.map +1 -0
  68. package/dist/aws/runtime/secrets/proxy-holder.d.ts +9 -0
  69. package/dist/aws/runtime/secrets/proxy-holder.js.map +1 -0
  70. package/dist/aws/runtime/secrets/rds-holder.d.ts +9 -0
  71. package/dist/aws/runtime/secrets/rds-holder.js.map +1 -0
  72. package/dist/aws/runtime/secrets/secret-holder.d.ts +26 -0
  73. package/dist/aws/runtime/secrets/secret-holder.js.map +1 -0
  74. package/dist/aws/runtime/secrets/secret.d.ts +8 -0
  75. package/dist/aws/runtime/secrets/secret.js.map +1 -0
  76. package/dist/aws/types/errors.d.ts +8 -0
  77. package/dist/aws/types/errors.js.map +1 -0
  78. package/dist/aws/types/lambda-response.d.ts +13 -0
  79. package/dist/aws/types/lambda-response.js.map +1 -0
  80. package/dist/aws/types/mediatypes.d.ts +11 -0
  81. package/dist/aws/types/mediatypes.js +2 -1
  82. package/dist/aws/types/mediatypes.js.map +1 -0
  83. package/dist/aws/types/model-with-reference.d.ts +7 -0
  84. package/dist/aws/types/model-with-reference.js.map +1 -0
  85. package/dist/aws/types/proxytypes.d.ts +26 -0
  86. package/dist/aws/types/proxytypes.js.map +1 -0
  87. package/dist/aws/types/tags.d.ts +2 -0
  88. package/dist/aws/types/tags.js.map +1 -0
  89. package/dist/database/cached.d.ts +7 -0
  90. package/dist/database/cached.js.map +1 -0
  91. package/dist/database/database.d.ts +19 -0
  92. package/dist/database/database.js +6 -8
  93. package/dist/database/database.js.map +1 -0
  94. package/dist/database/last-updated.d.ts +16 -0
  95. package/dist/database/last-updated.js.map +1 -0
  96. package/dist/database/models.d.ts +6 -0
  97. package/dist/database/models.js.map +1 -0
  98. package/dist/marine/id_utils.d.ts +3 -0
  99. package/dist/marine/id_utils.js.map +1 -0
  100. package/dist/marine/rtz.d.ts +48 -0
  101. package/dist/marine/rtz.js.map +1 -0
  102. package/dist/test/asserter.d.ts +11 -0
  103. package/dist/test/asserter.js.map +1 -0
  104. package/dist/test/db-testutils.d.ts +3 -0
  105. package/dist/test/db-testutils.js +5 -1
  106. package/dist/test/db-testutils.js.map +1 -0
  107. package/dist/test/httpserver.d.ts +19 -0
  108. package/dist/test/httpserver.js.map +1 -0
  109. package/dist/test/secret.d.ts +3 -0
  110. package/dist/test/secret.js.map +1 -0
  111. package/dist/test/secrets-manager.d.ts +9 -0
  112. package/dist/test/secrets-manager.js.map +1 -0
  113. package/dist/test/testutils.d.ts +12 -0
  114. package/dist/test/testutils.js.map +1 -0
  115. package/dist/types/either.d.ts +9 -0
  116. package/dist/types/either.js.map +1 -0
  117. package/dist/types/input-error.d.ts +2 -0
  118. package/dist/types/input-error.js.map +1 -0
  119. package/dist/types/language.d.ts +5 -0
  120. package/dist/types/language.js.map +1 -0
  121. package/dist/types/traffictype.d.ts +8 -0
  122. package/dist/types/traffictype.js.map +1 -0
  123. package/dist/types/validator.d.ts +4 -0
  124. package/dist/types/validator.js.map +1 -0
  125. package/dist/utils/api-model.d.ts +87 -0
  126. package/dist/utils/api-model.js.map +1 -0
  127. package/dist/utils/base64.d.ts +12 -0
  128. package/dist/utils/base64.js.map +1 -0
  129. package/dist/utils/date-utils.d.ts +17 -0
  130. package/dist/utils/date-utils.js.map +1 -0
  131. package/dist/utils/geojson-types.d.ts +14 -0
  132. package/dist/utils/geojson-types.js.map +1 -0
  133. package/dist/utils/geometry.d.ts +36 -0
  134. package/dist/utils/geometry.js.map +1 -0
  135. package/dist/utils/retry.d.ts +13 -0
  136. package/dist/utils/retry.js.map +1 -0
  137. package/dist/utils/slack.d.ts +5 -0
  138. package/dist/utils/slack.js.map +1 -0
  139. package/dist/utils/utils.d.ts +46 -0
  140. package/dist/utils/utils.js.map +1 -0
  141. package/package.json +3 -3
  142. package/src/aws/infra/canaries/canary.ts +1 -1
  143. package/src/aws/infra/canaries/url-checker.ts +1 -1
  144. package/src/aws/infra/stack/rest_apis.ts +144 -91
  145. package/src/aws/infra/stack/stack-checking-aspect.ts +5 -2
  146. package/src/aws/runtime/environment.ts +5 -1
  147. package/src/aws/types/mediatypes.ts +2 -1
  148. package/src/database/database.ts +9 -10
  149. package/src/test/db-testutils.ts +5 -0
  150. package/.editorconfig +0 -9
  151. package/.eslintignore +0 -4
  152. package/.eslintrc.json +0 -27
  153. package/.github/CODEOWNERS +0 -2
  154. package/.github/workflows/build.yml +0 -36
  155. package/.github/workflows/eslint.yml +0 -38
  156. package/.github/workflows/mirror.yml +0 -15
  157. package/.gitignore +0 -29
  158. package/.husky/pre-commit +0 -4
  159. package/.prettierrc.json +0 -10
  160. package/jest.config.js +0 -15
  161. package/test/marine/id_utils.test.ts +0 -57
  162. package/test/promise/promise.test.ts +0 -143
  163. package/test/secrets/dbsecret.test.ts +0 -59
  164. package/test/secrets/secret-holder.test.ts +0 -143
  165. package/test/secrets/secret.test.ts +0 -49
  166. package/test/test/httpserver.test.ts +0 -128
  167. package/test/utils/date-utils.test.ts +0 -28
  168. package/test/utils/geometry.test.ts +0 -29
  169. package/test/utils/utils.test.ts +0 -64
  170. package/tsconfig.eslint.json +0 -4
  171. package/tsconfig.json +0 -22
  172. package/yarn.lock +0 -4060
@@ -1,128 +0,0 @@
1
- import {
2
- TestHttpServer,
3
- ListenProperties,
4
- ERROR_NO_MATCH,
5
- ERRORCODE_NOT_FOUND,
6
- } from "../../src/test/httpserver";
7
- import { IncomingMessage } from "http";
8
- import http = require("http");
9
-
10
- const DEFAULT_PATH = "/";
11
- const PORT = 8091;
12
-
13
- const DEFAULT_PROPS = {
14
- "/": () => "",
15
- };
16
-
17
- describe("TestHttpServer - test", () => {
18
- async function withServer(
19
- fn: (server: TestHttpServer) => Promise<void>,
20
- props: ListenProperties = DEFAULT_PROPS,
21
- statusCode = 200
22
- ) {
23
- const server = new TestHttpServer();
24
-
25
- server.listen(PORT, props, false, statusCode);
26
-
27
- try {
28
- await fn(server);
29
- } finally {
30
- server.close();
31
- }
32
- }
33
-
34
- function sendGetRequest(path = DEFAULT_PATH): Promise<IncomingMessage> {
35
- return sendRequest("GET", path);
36
- }
37
-
38
- function sendPostRequest(
39
- path = DEFAULT_PATH,
40
- body: string
41
- ): Promise<IncomingMessage> {
42
- return sendRequest("POST", path, body);
43
- }
44
-
45
- function sendRequest(
46
- method: string,
47
- path: string,
48
- body?: string
49
- ): Promise<IncomingMessage> {
50
- return new Promise((resolve, reject) => {
51
- const request = http.request(
52
- {
53
- path,
54
- port: PORT,
55
- method,
56
- },
57
- (response: IncomingMessage) => {
58
- response.on("data", () => {
59
- // do nothing
60
- });
61
-
62
- //the whole response has been received, so we just print it out here
63
- response.on("end", () => {
64
- resolve(response);
65
- });
66
-
67
- response.on("error", (error: Error) => {
68
- reject(error);
69
- });
70
- }
71
- );
72
-
73
- if (method === "POST") {
74
- request.write(body);
75
- }
76
- request.end();
77
- });
78
- }
79
-
80
- test("no calls", () => {
81
- return withServer(async (server: TestHttpServer) => {
82
- await expect(server.getCallCount()).toEqual(0);
83
- });
84
- });
85
-
86
- test("one get", async () => {
87
- await withServer(async (server: TestHttpServer) => {
88
- await sendGetRequest();
89
-
90
- expect(server.getCallCount()).toEqual(1);
91
- });
92
- });
93
-
94
- test("one get - no MATCH", async () => {
95
- await withServer(async (server: TestHttpServer) => {
96
- const response = await sendGetRequest("/no-match");
97
-
98
- expect(server.getCallCount()).toEqual(1);
99
- expect(server.getRequestBody(0)).toEqual(ERROR_NO_MATCH);
100
- expect(response.statusCode).toEqual(ERRORCODE_NOT_FOUND);
101
- });
102
- });
103
-
104
- test("get - error 405", async () => {
105
- const ERROR_CODE = 405;
106
-
107
- await withServer(
108
- async (server: TestHttpServer) => {
109
- const response = await sendGetRequest();
110
-
111
- expect(server.getCallCount()).toEqual(1);
112
- expect(response.statusCode).toEqual(ERROR_CODE);
113
- },
114
- DEFAULT_PROPS,
115
- ERROR_CODE
116
- );
117
- });
118
-
119
- test("one post", async () => {
120
- await withServer(async (server: TestHttpServer) => {
121
- const testBody = "Testing123!";
122
- await sendPostRequest(DEFAULT_PATH, testBody);
123
-
124
- expect(server.getCallCount()).toEqual(1);
125
- expect(server.getRequestBody(0)).toEqual(testBody);
126
- });
127
- });
128
- });
@@ -1,28 +0,0 @@
1
- import moment from "moment";
2
- import * as CommonDateUtils from "../../src/utils/date-utils";
3
-
4
- const ISO = "2022-01-02T01:02:03.004Z";
5
-
6
- describe('CommonDateUtilsTest', () => {
7
-
8
- test('dateFromIsoString', () => {
9
- const parsed = CommonDateUtils.dateFromIsoString(ISO);
10
- expect(parsed.toISOString()).toEqual(ISO);
11
- });
12
-
13
- test('dateFromIsoString fails', () => {
14
- expect(() => CommonDateUtils.dateFromIsoString(ISO + "foobar")).toThrowError();
15
- });
16
-
17
- test('countDiffMs', () => {
18
- const start = new Date();
19
- const end = moment(start).add(1234, 'milliseconds').toDate();
20
- expect (CommonDateUtils.countDiffMs(start, end)).toEqual(1234);
21
- });
22
-
23
- test('countDiffMs', () => {
24
- const start = new Date();
25
- const end = moment(start).add(1234, 'seconds').toDate();
26
- expect (CommonDateUtils.countDiffInSeconds(start, end)).toEqual(1234);
27
- });
28
- });
@@ -1,29 +0,0 @@
1
- import {Asserter} from "../../src/test/asserter";
2
- import * as Geometry from '../../src/utils/geometry';
3
-
4
- const TAMPERE_WGS84_X = 23.761290078;
5
- const TAMPERE_WGS84_Y = 61.497742570;
6
-
7
- const KUOPIO_WGS84_X = 27.688935;
8
- const KUOPIO_WGS84_Y = 62.892983;
9
- const TAMPERE_KUOPIO_DISTANCE_KM = 255.8;
10
-
11
- describe('CommonGeometryTest', () => {
12
-
13
- test('distanceBetweenWGS84PointsInKm', () => {
14
- Asserter.assertToBeCloseTo(Geometry.distanceBetweenPositionsInKm([TAMPERE_WGS84_X, TAMPERE_WGS84_Y], [KUOPIO_WGS84_X, KUOPIO_WGS84_Y]),TAMPERE_KUOPIO_DISTANCE_KM, 0.5);
15
- console.info(Geometry.distanceBetweenPositionsInKm([TAMPERE_WGS84_X, TAMPERE_WGS84_Y], [KUOPIO_WGS84_X, KUOPIO_WGS84_Y]));
16
- });
17
-
18
- test('distanceBetweenWGS84PointsInKm', () => {
19
- Asserter.assertToBeCloseTo(Geometry.distanceBetweenPositionsInM([TAMPERE_WGS84_X, TAMPERE_WGS84_Y], [KUOPIO_WGS84_X, KUOPIO_WGS84_Y]),TAMPERE_KUOPIO_DISTANCE_KM*1000, 500);
20
- console.info(Geometry.distanceBetweenPositionsInM([TAMPERE_WGS84_X, TAMPERE_WGS84_Y], [KUOPIO_WGS84_X, KUOPIO_WGS84_Y]));
21
- });
22
-
23
- test('areDistinctPositions', () => {
24
- expect(Geometry.areDistinctPositions([1,2],[1,2])).toBe(false);
25
- expect(Geometry.areDistinctPositions([1.1,2.2],[1.1,2.2])).toBe(false);
26
- expect(Geometry.areDistinctPositions([1,2.1],[1,2])).toBe(true);
27
- expect(Geometry.areDistinctPositions([1,2],[1,2.000000000000001])).toBe(true);
28
- });
29
- });
@@ -1,64 +0,0 @@
1
- import * as ArrayUtils from "../../src/utils/utils";
2
-
3
- describe("ArrayUtils", () => {
4
- test("bothArraysHasSameValues", () => {
5
- expect(ArrayUtils.bothArraysHasSameValues([], [])).toEqual(true);
6
- expect(ArrayUtils.bothArraysHasSameValues(["a"], ["a"])).toEqual(true);
7
- expect(ArrayUtils.bothArraysHasSameValues(["a"], ["a", "a"])).toEqual(
8
- true
9
- );
10
- expect(
11
- ArrayUtils.bothArraysHasSameValues(["a", "a"], ["a", "a"])
12
- ).toEqual(true);
13
-
14
- expect(ArrayUtils.bothArraysHasSameValues(null, null)).toEqual(true);
15
- expect(
16
- ArrayUtils.bothArraysHasSameValues(undefined, undefined)
17
- ).toEqual(true);
18
- expect(ArrayUtils.bothArraysHasSameValues(null, undefined)).toEqual(
19
- true
20
- );
21
- expect(ArrayUtils.bothArraysHasSameValues(["a"], undefined)).toEqual(
22
- false
23
- );
24
- expect(ArrayUtils.bothArraysHasSameValues(["a"], null)).toEqual(false);
25
- /* eslint-enable */
26
- expect(
27
- ArrayUtils.bothArraysHasSameValues(["a", "b"], ["a", "a"])
28
- ).toEqual(false);
29
- expect(
30
- ArrayUtils.bothArraysHasSameValues(["a", "a", "a"], ["a", "b", "c"])
31
- ).toEqual(false);
32
-
33
- const o1 = { a: 1, b: 2 };
34
- const o2 = { a: 1, b: 2 };
35
- // Objects are references to same
36
- expect(ArrayUtils.bothArraysHasSameValues([o1], [o1])).toEqual(true);
37
- // Object's are not the same but the contents are the same
38
- expect(ArrayUtils.bothArraysHasSameValues([o1], [o2])).toEqual(false);
39
- });
40
-
41
- test("getFirst - empty throws", () => {
42
- expect(() => {
43
- ArrayUtils.getFirst([]);
44
- }).toThrow();
45
- });
46
-
47
- test("getFirst - two objects", () => {
48
- expect(ArrayUtils.getFirst([1, 2])).toEqual(1);
49
- });
50
-
51
- test("getFirst - two objects with sort function", () => {
52
- expect(ArrayUtils.getFirst([1, 2], (a) => -a)).toEqual(2);
53
- });
54
-
55
- test("getLast - empty throws", () => {
56
- expect(() => {
57
- ArrayUtils.getLast([]);
58
- }).toThrow();
59
- });
60
-
61
- test("getLast - two objects", () => {
62
- expect(ArrayUtils.getLast([1, 2])).toEqual(2);
63
- });
64
- });
@@ -1,4 +0,0 @@
1
- {
2
- "extends": "./tsconfig.json",
3
- "include": ["src/**/*.ts", "test/**/*.ts"],
4
- }
package/tsconfig.json DELETED
@@ -1,22 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2020",
4
- "module": "commonjs",
5
- "lib": ["es2020"],
6
- "outDir": "dist",
7
- "declaration": true,
8
- "sourceMap": true,
9
- "moduleResolution": "node",
10
- "strict": true,
11
- "exactOptionalPropertyTypes": false,
12
- "esModuleInterop": true,
13
- "forceConsistentCasingInFileNames": true,
14
- "skipLibCheck": true,
15
-
16
- "noImplicitReturns": true,
17
- "noFallthroughCasesInSwitch": true,
18
- "experimentalDecorators": true
19
- },
20
- "include": ["src/**/*.ts"],
21
- "$schema": "https://json.schemastore.org/tsconfig"
22
- }