@digitraffic/common 2026.3.4-1 → 2026.3.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 (238) hide show
  1. package/README.md +10 -0
  2. package/package.json +11 -11
  3. package/dist/__test__/asserter.d.ts +0 -13
  4. package/dist/__test__/asserter.js +0 -39
  5. package/dist/__test__/db-testutils.d.ts +0 -3
  6. package/dist/__test__/db-testutils.js +0 -38
  7. package/dist/__test__/dependencies.test.d.ts +0 -1
  8. package/dist/__test__/dependencies.test.js +0 -21
  9. package/dist/__test__/imports.test.d.ts +0 -1
  10. package/dist/__test__/imports.test.js +0 -318
  11. package/dist/__test__/infra/acl-builder.test.d.ts +0 -1
  12. package/dist/__test__/infra/acl-builder.test.js +0 -72
  13. package/dist/__test__/infra/api/handler-factory.test.d.ts +0 -1
  14. package/dist/__test__/infra/api/handler-factory.test.js +0 -42
  15. package/dist/__test__/infra/api/integration.test.d.ts +0 -1
  16. package/dist/__test__/infra/api/integration.test.js +0 -162
  17. package/dist/__test__/infra/api/response.test.d.ts +0 -1
  18. package/dist/__test__/infra/api/response.test.js +0 -77
  19. package/dist/__test__/infra/api/static-integration.test.d.ts +0 -1
  20. package/dist/__test__/infra/api/static-integration.test.js +0 -35
  21. package/dist/__test__/infra/documentation.test.d.ts +0 -1
  22. package/dist/__test__/infra/documentation.test.js +0 -38
  23. package/dist/__test__/infra/scheduler.test.d.ts +0 -1
  24. package/dist/__test__/infra/scheduler.test.js +0 -23
  25. package/dist/__test__/infra/security-rule.test.d.ts +0 -1
  26. package/dist/__test__/infra/security-rule.test.js +0 -21
  27. package/dist/__test__/infra/stack/rest-apis.test.d.ts +0 -1
  28. package/dist/__test__/infra/stack/rest-apis.test.js +0 -47
  29. package/dist/__test__/marine/id_utils.test.d.ts +0 -1
  30. package/dist/__test__/marine/id_utils.test.js +0 -45
  31. package/dist/__test__/mock-ky.d.ts +0 -2
  32. package/dist/__test__/mock-ky.js +0 -15
  33. package/dist/__test__/promise/promise.test.d.ts +0 -1
  34. package/dist/__test__/promise/promise.test.js +0 -126
  35. package/dist/__test__/runtime/dt-logger.test.d.ts +0 -1
  36. package/dist/__test__/runtime/dt-logger.test.js +0 -193
  37. package/dist/__test__/secrets/secret-holder.test.d.ts +0 -1
  38. package/dist/__test__/secrets/secret-holder.test.js +0 -96
  39. package/dist/__test__/secrets/secret.test.d.ts +0 -1
  40. package/dist/__test__/secrets/secret.test.js +0 -57
  41. package/dist/__test__/stack/dt-function.test.d.ts +0 -1
  42. package/dist/__test__/stack/dt-function.test.js +0 -340
  43. package/dist/__test__/stack/rest-apis.test.d.ts +0 -1
  44. package/dist/__test__/stack/rest-apis.test.js +0 -45
  45. package/dist/__test__/test/mock-ky.test.d.ts +0 -1
  46. package/dist/__test__/test/mock-ky.test.js +0 -46
  47. package/dist/__test__/testutils.d.ts +0 -12
  48. package/dist/__test__/testutils.js +0 -32
  49. package/dist/__test__/types/lambda-proxy-types.test.d.ts +0 -8
  50. package/dist/__test__/types/lambda-proxy-types.test.js +0 -155
  51. package/dist/__test__/types/lambda-response-builder.test.d.ts +0 -1
  52. package/dist/__test__/types/lambda-response-builder.test.js +0 -81
  53. package/dist/__test__/types/lambda-response.test.d.ts +0 -9
  54. package/dist/__test__/types/lambda-response.test.js +0 -73
  55. package/dist/__test__/utils/base64.test.d.ts +0 -1
  56. package/dist/__test__/utils/base64.test.js +0 -38
  57. package/dist/__test__/utils/date-utils.test.d.ts +0 -1
  58. package/dist/__test__/utils/date-utils.test.js +0 -32
  59. package/dist/__test__/utils/geometry.test.d.ts +0 -1
  60. package/dist/__test__/utils/geometry.test.js +0 -25
  61. package/dist/__test__/utils/lambda-proxy-event.test.d.ts +0 -1
  62. package/dist/__test__/utils/lambda-proxy-event.test.js +0 -45
  63. package/dist/__test__/utils/logging.test.d.ts +0 -1
  64. package/dist/__test__/utils/logging.test.js +0 -75
  65. package/dist/__test__/utils/stop-watch.test.d.ts +0 -1
  66. package/dist/__test__/utils/stop-watch.test.js +0 -118
  67. package/dist/__test__/utils/utils.test.d.ts +0 -1
  68. package/dist/__test__/utils/utils.test.js +0 -48
  69. package/dist/aws/infra/acl-builder.d.ts +0 -53
  70. package/dist/aws/infra/acl-builder.js +0 -407
  71. package/dist/aws/infra/api/handler-factory.d.ts +0 -22
  72. package/dist/aws/infra/api/handler-factory.js +0 -68
  73. package/dist/aws/infra/api/integration.d.ts +0 -49
  74. package/dist/aws/infra/api/integration.js +0 -162
  75. package/dist/aws/infra/api/response.d.ts +0 -62
  76. package/dist/aws/infra/api/response.js +0 -132
  77. package/dist/aws/infra/api/responses.d.ts +0 -60
  78. package/dist/aws/infra/api/responses.js +0 -90
  79. package/dist/aws/infra/api/static-integration.d.ts +0 -16
  80. package/dist/aws/infra/api/static-integration.js +0 -76
  81. package/dist/aws/infra/bucket-policy.d.ts +0 -38
  82. package/dist/aws/infra/bucket-policy.js +0 -30
  83. package/dist/aws/infra/canaries/canary-alarm.d.ts +0 -6
  84. package/dist/aws/infra/canaries/canary-alarm.js +0 -20
  85. package/dist/aws/infra/canaries/canary-keys.d.ts +0 -3
  86. package/dist/aws/infra/canaries/canary-keys.js +0 -4
  87. package/dist/aws/infra/canaries/canary-parameters.d.ts +0 -19
  88. package/dist/aws/infra/canaries/canary-parameters.js +0 -2
  89. package/dist/aws/infra/canaries/canary-role.d.ts +0 -14
  90. package/dist/aws/infra/canaries/canary-role.js +0 -51
  91. package/dist/aws/infra/canaries/canary.d.ts +0 -8
  92. package/dist/aws/infra/canaries/canary.js +0 -26
  93. package/dist/aws/infra/canaries/database-canary.d.ts +0 -17
  94. package/dist/aws/infra/canaries/database-canary.js +0 -65
  95. package/dist/aws/infra/canaries/database-checker.d.ts +0 -33
  96. package/dist/aws/infra/canaries/database-checker.js +0 -119
  97. package/dist/aws/infra/canaries/url-canary.d.ts +0 -16
  98. package/dist/aws/infra/canaries/url-canary.js +0 -55
  99. package/dist/aws/infra/canaries/url-checker.d.ts +0 -45
  100. package/dist/aws/infra/canaries/url-checker.js +0 -256
  101. package/dist/aws/infra/documentation.d.ts +0 -56
  102. package/dist/aws/infra/documentation.js +0 -90
  103. package/dist/aws/infra/import-util.d.ts +0 -17
  104. package/dist/aws/infra/import-util.js +0 -41
  105. package/dist/aws/infra/scheduler.d.ts +0 -12
  106. package/dist/aws/infra/scheduler.js +0 -27
  107. package/dist/aws/infra/security-rule.d.ts +0 -12
  108. package/dist/aws/infra/security-rule.js +0 -35
  109. package/dist/aws/infra/sqs-integration.d.ts +0 -4
  110. package/dist/aws/infra/sqs-integration.js +0 -85
  111. package/dist/aws/infra/sqs-queue.d.ts +0 -19
  112. package/dist/aws/infra/sqs-queue.js +0 -145
  113. package/dist/aws/infra/stack/dt-function-alarms.d.ts +0 -29
  114. package/dist/aws/infra/stack/dt-function-alarms.js +0 -54
  115. package/dist/aws/infra/stack/dt-function.d.ts +0 -117
  116. package/dist/aws/infra/stack/dt-function.js +0 -306
  117. package/dist/aws/infra/stack/lambda-configs.d.ts +0 -44
  118. package/dist/aws/infra/stack/lambda-configs.js +0 -71
  119. package/dist/aws/infra/stack/lambda-log-group.d.ts +0 -15
  120. package/dist/aws/infra/stack/lambda-log-group.js +0 -24
  121. package/dist/aws/infra/stack/monitoredfunction.d.ts +0 -85
  122. package/dist/aws/infra/stack/monitoredfunction.js +0 -147
  123. package/dist/aws/infra/stack/parameters.d.ts +0 -40
  124. package/dist/aws/infra/stack/parameters.js +0 -50
  125. package/dist/aws/infra/stack/rest-api.d.ts +0 -73
  126. package/dist/aws/infra/stack/rest-api.js +0 -235
  127. package/dist/aws/infra/stack/stack-checking-aspect.d.ts +0 -20
  128. package/dist/aws/infra/stack/stack-checking-aspect.js +0 -177
  129. package/dist/aws/infra/stack/stack.d.ts +0 -45
  130. package/dist/aws/infra/stack/stack.js +0 -71
  131. package/dist/aws/infra/stack/subscription.d.ts +0 -17
  132. package/dist/aws/infra/stack/subscription.js +0 -37
  133. package/dist/aws/infra/stacks/db-dns-stack.d.ts +0 -13
  134. package/dist/aws/infra/stacks/db-dns-stack.js +0 -60
  135. package/dist/aws/infra/stacks/db-proxy-stack.d.ts +0 -24
  136. package/dist/aws/infra/stacks/db-proxy-stack.js +0 -74
  137. package/dist/aws/infra/stacks/db-stack.d.ts +0 -65
  138. package/dist/aws/infra/stacks/db-stack.js +0 -189
  139. package/dist/aws/infra/stacks/intra-stack-configuration.d.ts +0 -5
  140. package/dist/aws/infra/stacks/intra-stack-configuration.js +0 -2
  141. package/dist/aws/infra/stacks/network-stack.d.ts +0 -14
  142. package/dist/aws/infra/stacks/network-stack.js +0 -45
  143. package/dist/aws/infra/usage-plans.d.ts +0 -16
  144. package/dist/aws/infra/usage-plans.js +0 -38
  145. package/dist/aws/runtime/apikey.d.ts +0 -2
  146. package/dist/aws/runtime/apikey.js +0 -13
  147. package/dist/aws/runtime/digitraffic-integration-response.d.ts +0 -8
  148. package/dist/aws/runtime/digitraffic-integration-response.js +0 -25
  149. package/dist/aws/runtime/dt-logger-default.d.ts +0 -9
  150. package/dist/aws/runtime/dt-logger-default.js +0 -6
  151. package/dist/aws/runtime/dt-logger.d.ts +0 -117
  152. package/dist/aws/runtime/dt-logger.js +0 -159
  153. package/dist/aws/runtime/environment.d.ts +0 -5
  154. package/dist/aws/runtime/environment.js +0 -7
  155. package/dist/aws/runtime/s3.d.ts +0 -3
  156. package/dist/aws/runtime/s3.js +0 -21
  157. package/dist/aws/runtime/secrets/dbsecret.d.ts +0 -16
  158. package/dist/aws/runtime/secrets/dbsecret.js +0 -26
  159. package/dist/aws/runtime/secrets/proxy-holder.d.ts +0 -9
  160. package/dist/aws/runtime/secrets/proxy-holder.js +0 -25
  161. package/dist/aws/runtime/secrets/rds-holder.d.ts +0 -9
  162. package/dist/aws/runtime/secrets/rds-holder.js +0 -25
  163. package/dist/aws/runtime/secrets/secret-holder.d.ts +0 -30
  164. package/dist/aws/runtime/secrets/secret-holder.js +0 -81
  165. package/dist/aws/runtime/secrets/secret.d.ts +0 -8
  166. package/dist/aws/runtime/secrets/secret.js +0 -61
  167. package/dist/aws/types/errors.d.ts +0 -8
  168. package/dist/aws/types/errors.js +0 -13
  169. package/dist/aws/types/lambda-proxy-types.d.ts +0 -59
  170. package/dist/aws/types/lambda-proxy-types.js +0 -210
  171. package/dist/aws/types/lambda-response.d.ts +0 -89
  172. package/dist/aws/types/lambda-response.js +0 -204
  173. package/dist/aws/types/mediatypes.d.ts +0 -11
  174. package/dist/aws/types/mediatypes.js +0 -14
  175. package/dist/aws/types/model-with-reference.d.ts +0 -7
  176. package/dist/aws/types/model-with-reference.js +0 -2
  177. package/dist/aws/types/tags.d.ts +0 -2
  178. package/dist/aws/types/tags.js +0 -4
  179. package/dist/database/database.d.ts +0 -27
  180. package/dist/database/database.js +0 -95
  181. package/dist/database/last-updated.d.ts +0 -15
  182. package/dist/database/last-updated.js +0 -46
  183. package/dist/database/models.d.ts +0 -6
  184. package/dist/database/models.js +0 -2
  185. package/dist/index.d.ts +0 -1
  186. package/dist/index.js +0 -2
  187. package/dist/marine/id_utils.d.ts +0 -3
  188. package/dist/marine/id_utils.js +0 -36
  189. package/dist/marine/rtz.d.ts +0 -48
  190. package/dist/marine/rtz.js +0 -2
  191. package/dist/types/async-timeout-error.d.ts +0 -3
  192. package/dist/types/async-timeout-error.js +0 -6
  193. package/dist/types/either.d.ts +0 -9
  194. package/dist/types/either.js +0 -2
  195. package/dist/types/geojson.d.ts +0 -47
  196. package/dist/types/geojson.js +0 -51
  197. package/dist/types/http-error.d.ts +0 -4
  198. package/dist/types/http-error.js +0 -8
  199. package/dist/types/input-error.d.ts +0 -2
  200. package/dist/types/input-error.js +0 -3
  201. package/dist/types/language.d.ts +0 -5
  202. package/dist/types/language.js +0 -7
  203. package/dist/types/nullable.d.ts +0 -24
  204. package/dist/types/nullable.js +0 -2
  205. package/dist/types/openapi-schema.d.ts +0 -932
  206. package/dist/types/openapi-schema.js +0 -151
  207. package/dist/types/traffictype.d.ts +0 -11
  208. package/dist/types/traffictype.js +0 -13
  209. package/dist/types/urn.d.ts +0 -1
  210. package/dist/types/urn.js +0 -2
  211. package/dist/types/util-types.d.ts +0 -11
  212. package/dist/types/util-types.js +0 -2
  213. package/dist/types/validator.d.ts +0 -4
  214. package/dist/types/validator.js +0 -9
  215. package/dist/utils/api-model.d.ts +0 -51
  216. package/dist/utils/api-model.js +0 -118
  217. package/dist/utils/base64.d.ts +0 -34
  218. package/dist/utils/base64.js +0 -53
  219. package/dist/utils/date-utils.d.ts +0 -27
  220. package/dist/utils/date-utils.js +0 -45
  221. package/dist/utils/geojson-types.d.ts +0 -14
  222. package/dist/utils/geojson-types.js +0 -15
  223. package/dist/utils/geometry.d.ts +0 -44
  224. package/dist/utils/geometry.js +0 -154
  225. package/dist/utils/lambda-proxy-event.d.ts +0 -9
  226. package/dist/utils/lambda-proxy-event.js +0 -31
  227. package/dist/utils/logging.d.ts +0 -40
  228. package/dist/utils/logging.js +0 -88
  229. package/dist/utils/retry.d.ts +0 -33
  230. package/dist/utils/retry.js +0 -135
  231. package/dist/utils/slack.d.ts +0 -5
  232. package/dist/utils/slack.js +0 -24
  233. package/dist/utils/stop-watch.d.ts +0 -46
  234. package/dist/utils/stop-watch.js +0 -114
  235. package/dist/utils/utils.d.ts +0 -95
  236. package/dist/utils/utils.js +0 -178
  237. package/dist/utils/zod-utils.d.ts +0 -27
  238. package/dist/utils/zod-utils.js +0 -57
package/README.md CHANGED
@@ -50,6 +50,16 @@ pnpm up --latest
50
50
 
51
51
  After updating, run `pnpm audit` to check for vulnerabilities. If vulnerabilities exist in transitive dependencies, you may need to add overrides in `package.json` and/or exclusions in `.npmrc`. See [DEPENDENCY_OVERRIDES.md](./DEPENDENCY_OVERRIDES.md) for details.
52
52
 
53
+ ## Publishing to [npmjs.com](https://www.npmjs.com/)
54
+
55
+ See https://www.npmjs.com/package/@digitraffic/common
56
+
57
+ Run the following command to publish a new version:
58
+
59
+ ```bash
60
+ ./scripts/publish.sh 2026.3.5-1
61
+ ```
62
+
53
63
  ## How to use
54
64
 
55
65
  In package.json dependencies:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digitraffic/common",
3
- "version": "2026.3.4-1",
3
+ "version": "2026.3.17-1",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "repository": {
@@ -108,15 +108,15 @@
108
108
  "dist/**/*.d.ts"
109
109
  ],
110
110
  "devDependencies": {
111
- "@aws-sdk/client-api-gateway": "3.997.0",
112
- "@aws-sdk/client-s3": "3.997.0",
113
- "@aws-sdk/client-secrets-manager": "3.997.0",
114
- "@aws-sdk/client-sns": "3.997.0",
115
- "@aws-sdk/lib-storage": "3.997.0",
111
+ "@aws-sdk/client-api-gateway": "3.998.0",
112
+ "@aws-sdk/client-s3": "3.998.0",
113
+ "@aws-sdk/client-secrets-manager": "3.998.0",
114
+ "@aws-sdk/client-sns": "3.998.0",
115
+ "@aws-sdk/lib-storage": "3.998.0",
116
116
  "@biomejs/biome": "2.4.4",
117
117
  "@date-fns/tz": "1.4.1",
118
- "@rushstack/heft": "1.2.5",
119
- "@rushstack/heft-typescript-plugin": "1.3.0",
118
+ "@rushstack/heft": "1.2.6",
119
+ "@rushstack/heft-typescript-plugin": "1.3.1",
120
120
  "@smithy/fetch-http-handler": "5.3.11",
121
121
  "@smithy/types": "4.13.0",
122
122
  "@types/aws-lambda": "8.10.160",
@@ -125,7 +125,7 @@
125
125
  "@types/geojson-validation": "1.0.3",
126
126
  "@types/lodash-es": "4.17.12",
127
127
  "@types/madge": "5.0.3",
128
- "@types/node": "25.3.0",
128
+ "@types/node": "25.3.1",
129
129
  "@vitest/coverage-v8": "4.0.18",
130
130
  "aws-cdk-lib": "2.240.0",
131
131
  "change-case": "5.4.4",
@@ -138,9 +138,9 @@
138
138
  "lefthook": "2.1.1",
139
139
  "lodash-es": "4.17.23",
140
140
  "madge": "8.0.0",
141
- "pg-native": "3.5.2",
141
+ "pg-native": "3.6.0",
142
142
  "pg-promise": "12.6.1",
143
- "pg-query-stream": "4.12.0",
143
+ "pg-query-stream": "4.13.0",
144
144
  "rimraf": "6.1.3",
145
145
  "sort-package-json": "3.6.1",
146
146
  "typescript": "5.9.3",
@@ -1,13 +0,0 @@
1
- /**
2
- * A simple asserter-class for writing canaries without dependency to testing-libraries.
3
- */
4
- type AssertedValue = string | number;
5
- export declare const Asserter: {
6
- assertEquals(value: AssertedValue, expected: AssertedValue): void;
7
- assertTrue(value: boolean): void;
8
- assertLength<T>(data: T[] | undefined, expected: number): void;
9
- assertLengthGreaterThan<T>(data: T[] | undefined, expected: number): void;
10
- assertGreaterThan(value: number, expected: number): void;
11
- assertToBeCloseTo(value: number, expected: number, delta: number): void;
12
- };
13
- export {};
@@ -1,39 +0,0 @@
1
- import { expect } from "vitest";
2
- export const Asserter = {
3
- assertEquals(value, expected) {
4
- if (value !== expected) {
5
- throw new Error(`Given value ${value} was not expected ${expected}`);
6
- }
7
- },
8
- assertTrue(value) {
9
- if (!value) {
10
- throw new Error(`Given value was not true`);
11
- }
12
- },
13
- assertLength(data, expected) {
14
- if (!data) {
15
- throw new Error("Given array was not defined");
16
- }
17
- if (data.length !== expected) {
18
- throw new Error(`Given array length ${data.length} was not expected ${expected}`);
19
- }
20
- },
21
- assertLengthGreaterThan(data, expected) {
22
- if (!data) {
23
- throw new Error("Given array was not defined");
24
- }
25
- if (data.length <= expected) {
26
- throw new Error(`Given array length ${data.length} was not greater than ${expected}`);
27
- }
28
- },
29
- assertGreaterThan(value, expected) {
30
- if (value <= expected) {
31
- throw new Error(`Value ${value} was expected to be greater than ${expected}`);
32
- }
33
- },
34
- assertToBeCloseTo(value, expected, delta) {
35
- expect(expected - value).toBeGreaterThanOrEqual(-1 * delta);
36
- expect(expected - value).toBeLessThanOrEqual(delta);
37
- },
38
- };
39
- //# sourceMappingURL=asserter.js.map
@@ -1,3 +0,0 @@
1
- import type { DTDatabase } from "../database/database.js";
2
- export declare function assertCount(db: DTDatabase, sql: string, count: number): Promise<void>;
3
- export declare function dbTestBase(fn: (db: DTDatabase) => void, truncateFn: (db: DTDatabase) => Promise<void>, dbUser: string, dbPass: string, dbUri: string, convertNullsToUndefined?: boolean): () => void;
@@ -1,38 +0,0 @@
1
- import { afterAll, beforeAll, beforeEach, expect } from "vitest";
2
- import { DatabaseEnvironmentKeys, initDbConnection, } from "../database/database.js";
3
- import { getEnvVariableOrElse } from "../utils/utils.js";
4
- export async function assertCount(db, sql, count) {
5
- await db.one(sql).then((x) => expect(x.count).toEqual(count));
6
- }
7
- export function dbTestBase(fn, truncateFn, dbUser, dbPass, dbUri, convertNullsToUndefined = false) {
8
- const theDbUri = getEnvVariableOrElse("DB_URI", dbUri);
9
- console.log(`Test database URI: ${theDbUri}, convertNullsToUndefined: ${convertNullsToUndefined}`);
10
- return () => {
11
- const db = initDbConnection(dbUser, dbPass, "test", theDbUri, convertNullsToUndefined, {
12
- noWarnings: true, // ignore duplicate connection warning for tests
13
- });
14
- beforeAll(async () => {
15
- process.env[DatabaseEnvironmentKeys.DB_USER] = dbUser;
16
- process.env[DatabaseEnvironmentKeys.DB_PASS] = dbPass;
17
- process.env[DatabaseEnvironmentKeys.DB_URI] = theDbUri;
18
- process.env[DatabaseEnvironmentKeys.DB_RO_URI] = theDbUri;
19
- // if there's no connection to the database, it will be caught here
20
- try {
21
- await truncateFn(db);
22
- }
23
- catch (e) {
24
- console.info(`cought in commonDbTest:${JSON.stringify(e)}`);
25
- throw e;
26
- }
27
- });
28
- afterAll(async () => {
29
- await truncateFn(db);
30
- await db.$pool.end();
31
- });
32
- beforeEach(async () => {
33
- await truncateFn(db);
34
- });
35
- fn(db);
36
- };
37
- }
38
- //# sourceMappingURL=db-testutils.js.map
@@ -1 +0,0 @@
1
- export {};
@@ -1,21 +0,0 @@
1
- const madge = await import("madge");
2
- import { expect, test } from "vitest";
3
- const WHITELISTED_DEPENDENCIES = [
4
- // aspect is using DigitrafficStack with instanceof, can't remove
5
- `["aws/infra/stack/stack.mjs","aws/infra/stack/stack-checking-aspect.mjs"]`,
6
- ];
7
- function whitelist(circular) {
8
- return !WHITELISTED_DEPENDENCIES.includes(JSON.stringify(circular));
9
- }
10
- function assertNoErrors(errors) {
11
- expect(errors).toHaveLength(0);
12
- }
13
- test("circular dependencies", async () => {
14
- const instance = await madge.default("dist", {
15
- fileExtensions: ["mts", "mjs"],
16
- });
17
- const circulars = instance.circular();
18
- const errors = circulars.filter(whitelist);
19
- assertNoErrors(errors);
20
- });
21
- //# sourceMappingURL=dependencies.test.js.map
@@ -1 +0,0 @@
1
- export {};
@@ -1,318 +0,0 @@
1
- import { expect, test } from "vitest";
2
- test("index import ok?", () => {
3
- const index = import("../index.js");
4
- return expect(index).resolves.toBeDefined();
5
- });
6
- test("database import ok?", () => {
7
- const database = import("../database/database.js");
8
- return expect(database).resolves.toBeDefined();
9
- });
10
- test("models import ok?", () => {
11
- const models = import("../database/models.js");
12
- return expect(models).resolves.toBeDefined();
13
- });
14
- test("lastUpdated import ok?", () => {
15
- const lastUpdated = import("../database/last-updated.js");
16
- return expect(lastUpdated).resolves.toBeDefined();
17
- });
18
- test("urn import ok?", () => {
19
- const urn = import("../types/urn.js");
20
- return expect(urn).resolves.toBeDefined();
21
- });
22
- test("utilTypes import ok?", () => {
23
- const utilTypes = import("../types/util-types.js");
24
- return expect(utilTypes).resolves.toBeDefined();
25
- });
26
- test("either import ok?", () => {
27
- const either = import("../types/either.js");
28
- return expect(either).resolves.toBeDefined();
29
- });
30
- test("validator import ok?", () => {
31
- const validator = import("../types/validator.js");
32
- return expect(validator).resolves.toBeDefined();
33
- });
34
- test("nullable import ok?", () => {
35
- const nullable = import("../types/nullable.js");
36
- return expect(nullable).resolves.toBeDefined();
37
- });
38
- test("asyncTimeoutError import ok?", () => {
39
- const asyncTimeoutError = import("../types/async-timeout-error.js");
40
- return expect(asyncTimeoutError).resolves.toBeDefined();
41
- });
42
- test("inputError import ok?", () => {
43
- const inputError = import("../types/input-error.js");
44
- return expect(inputError).resolves.toBeDefined();
45
- });
46
- test("httpError import ok?", () => {
47
- const httpError = import("../types/http-error.js");
48
- return expect(httpError).resolves.toBeDefined();
49
- });
50
- test("language import ok?", () => {
51
- const language = import("../types/language.js");
52
- return expect(language).resolves.toBeDefined();
53
- });
54
- test("traffictype import ok?", () => {
55
- const traffictype = import("../types/traffictype.js");
56
- return expect(traffictype).resolves.toBeDefined();
57
- });
58
- test("testutils import ok?", () => {
59
- const testutils = import("../__test__/testutils.js");
60
- return expect(testutils).resolves.toBeDefined();
61
- });
62
- test("dbTestutils import ok?", () => {
63
- const dbTestutils = import("../__test__/db-testutils.js");
64
- return expect(dbTestutils).resolves.toBeDefined();
65
- });
66
- test("asserter import ok?", () => {
67
- const asserter = import("../__test__/asserter.js");
68
- return expect(asserter).resolves.toBeDefined();
69
- });
70
- test("rtz import ok?", () => {
71
- const rtz = import("../marine/rtz.js");
72
- return expect(rtz).resolves.toBeDefined();
73
- });
74
- test("idUtils import ok?", () => {
75
- const idUtils = import("../marine/id_utils.js");
76
- return expect(idUtils).resolves.toBeDefined();
77
- });
78
- test("apiModel import ok?", () => {
79
- const apiModel = import("../utils/api-model.js");
80
- return expect(apiModel).resolves.toBeDefined();
81
- });
82
- test("logging import ok?", () => {
83
- const logging = import("../utils/logging.js");
84
- return expect(logging).resolves.toBeDefined();
85
- });
86
- test("base64 import ok?", () => {
87
- const base64 = import("../utils/base64.js");
88
- return expect(base64).resolves.toBeDefined();
89
- });
90
- test("dateUtils import ok?", () => {
91
- const dateUtils = import("../utils/date-utils.js");
92
- return expect(dateUtils).resolves.toBeDefined();
93
- });
94
- test("geojsonTypes import ok?", () => {
95
- const geojsonTypes = import("../utils/geojson-types.js");
96
- return expect(geojsonTypes).resolves.toBeDefined();
97
- });
98
- test("slack import ok?", () => {
99
- const slack = import("../utils/slack.js");
100
- return expect(slack).resolves.toBeDefined();
101
- });
102
- test("stopWatch import ok?", () => {
103
- const stopWatch = import("../utils/stop-watch.js");
104
- return expect(stopWatch).resolves.toBeDefined();
105
- });
106
- test("utils import ok?", () => {
107
- const utils = import("../utils/utils.js");
108
- return expect(utils).resolves.toBeDefined();
109
- });
110
- test("retry import ok?", () => {
111
- const retry = import("../utils/retry.js");
112
- return expect(retry).resolves.toBeDefined();
113
- });
114
- test("geometry import ok?", () => {
115
- const geometry = import("../utils/geometry.js");
116
- return expect(geometry).resolves.toBeDefined();
117
- });
118
- test("sqsIntegration import ok?", () => {
119
- const sqsIntegration = import("../aws/infra/sqs-integration.js");
120
- return expect(sqsIntegration).resolves.toBeDefined();
121
- });
122
- test("networkStack import ok?", () => {
123
- const networkStack = import("../aws/infra/stacks/network-stack.js");
124
- return expect(networkStack).resolves.toBeDefined();
125
- });
126
- test("dbStack import ok?", () => {
127
- const dbStack = import("../aws/infra/stacks/db-stack.js");
128
- return expect(dbStack).resolves.toBeDefined();
129
- });
130
- test("dbProxyStack import ok?", () => {
131
- const dbProxyStack = import("../aws/infra/stacks/db-proxy-stack.js");
132
- return expect(dbProxyStack).resolves.toBeDefined();
133
- });
134
- test("intraStackConfiguration import ok?", () => {
135
- const intraStackConfiguration = import("../aws/infra/stacks/intra-stack-configuration.js");
136
- return expect(intraStackConfiguration).resolves.toBeDefined();
137
- });
138
- test("dbDnsStack import ok?", () => {
139
- const dbDnsStack = import("../aws/infra/stacks/db-dns-stack.js");
140
- return expect(dbDnsStack).resolves.toBeDefined();
141
- });
142
- test("documentation import ok?", () => {
143
- const documentation = import("../aws/infra/documentation.js");
144
- return expect(documentation).resolves.toBeDefined();
145
- });
146
- test("usagePlans import ok?", () => {
147
- const usagePlans = import("../aws/infra/usage-plans.js");
148
- return expect(usagePlans).resolves.toBeDefined();
149
- });
150
- test("scheduler import ok?", () => {
151
- const scheduler = import("../aws/infra/scheduler.js");
152
- return expect(scheduler).resolves.toBeDefined();
153
- });
154
- test("importUtil import ok?", () => {
155
- const importUtil = import("../aws/infra/import-util.js");
156
- return expect(importUtil).resolves.toBeDefined();
157
- });
158
- test("sqsQueue import ok?", () => {
159
- const sqsQueue = import("../aws/infra/sqs-queue.js");
160
- return expect(sqsQueue).resolves.toBeDefined();
161
- });
162
- test("response import ok?", () => {
163
- const response = import("../aws/infra/api/response.js");
164
- return expect(response).resolves.toBeDefined();
165
- });
166
- test("staticIntegration import ok?", () => {
167
- const staticIntegration = import("../aws/infra/api/static-integration.js");
168
- return expect(staticIntegration).resolves.toBeDefined();
169
- });
170
- test("responses import ok?", () => {
171
- const responses = import("../aws/infra/api/responses.js");
172
- return expect(responses).resolves.toBeDefined();
173
- });
174
- test("handlerFactory import ok?", () => {
175
- const handlerFactory = import("../aws/infra/api/handler-factory.js");
176
- return expect(handlerFactory).resolves.toBeDefined();
177
- });
178
- test("integration import ok?", () => {
179
- const integration = import("../aws/infra/api/integration.js");
180
- return expect(integration).resolves.toBeDefined();
181
- });
182
- test("stackCheckingAspect import ok?", () => {
183
- const stackCheckingAspect = import("../aws/infra/stack/stack-checking-aspect.js");
184
- return expect(stackCheckingAspect).resolves.toBeDefined();
185
- });
186
- test("restApis import ok?", () => {
187
- const restApis = import("../aws/infra/stack/rest-api.js");
188
- return expect(restApis).resolves.toBeDefined();
189
- });
190
- test("lambdaConfigs import ok?", () => {
191
- const lambdaConfigs = import("../aws/infra/stack/lambda-configs.js");
192
- return expect(lambdaConfigs).resolves.toBeDefined();
193
- });
194
- test("monitoredfunction import ok?", () => {
195
- const monitoredfunction = import("../aws/infra/stack/monitoredfunction.js");
196
- return expect(monitoredfunction).resolves.toBeDefined();
197
- });
198
- test("subscription import ok?", () => {
199
- const subscription = import("../aws/infra/stack/subscription.js");
200
- return expect(subscription).resolves.toBeDefined();
201
- });
202
- test("parameters import ok?", () => {
203
- const parameters = import("../aws/infra/stack/parameters.js");
204
- return expect(parameters).resolves.toBeDefined();
205
- });
206
- test("stack import ok?", () => {
207
- const stack = import("../aws/infra/stack/stack.js");
208
- return expect(stack).resolves.toBeDefined();
209
- });
210
- test("securityRule import ok?", () => {
211
- const securityRule = import("../aws/infra/security-rule.js");
212
- return expect(securityRule).resolves.toBeDefined();
213
- });
214
- test("canary import ok?", () => {
215
- const canary = import("../aws/infra/canaries/canary.js");
216
- return expect(canary).resolves.toBeDefined();
217
- });
218
- test("databaseCanary import ok?", () => {
219
- const databaseCanary = import("../aws/infra/canaries/database-canary.js");
220
- return expect(databaseCanary).resolves.toBeDefined();
221
- });
222
- test("canaryAlarm import ok?", () => {
223
- const canaryAlarm = import("../aws/infra/canaries/canary-alarm.js");
224
- return expect(canaryAlarm).resolves.toBeDefined();
225
- });
226
- test("canaryRole import ok?", () => {
227
- const canaryRole = import("../aws/infra/canaries/canary-role.js");
228
- return expect(canaryRole).resolves.toBeDefined();
229
- });
230
- test("urlCanary import ok?", () => {
231
- const urlCanary = import("../aws/infra/canaries/url-canary.js");
232
- return expect(urlCanary).resolves.toBeDefined();
233
- });
234
- test("canaryParameters import ok?", () => {
235
- const canaryParameters = import("../aws/infra/canaries/canary-parameters.js");
236
- return expect(canaryParameters).resolves.toBeDefined();
237
- });
238
- test("canaryKeys import ok?", () => {
239
- const canaryKeys = import("../aws/infra/canaries/canary-keys.js");
240
- return expect(canaryKeys).resolves.toBeDefined();
241
- });
242
- test("lambda-proxy-types import ok?", () => {
243
- const proxytypes = import("../aws/types/lambda-proxy-types.js");
244
- return expect(proxytypes).resolves.toBeDefined();
245
- });
246
- test("tags import ok?", () => {
247
- const tags = import("../aws/types/tags.js");
248
- return expect(tags).resolves.toBeDefined();
249
- });
250
- test("mediatypes import ok?", () => {
251
- const mediatypes = import("../aws/types/mediatypes.js");
252
- return expect(mediatypes).resolves.toBeDefined();
253
- });
254
- test("modelWithReference import ok?", () => {
255
- const modelWithReference = import("../aws/types/model-with-reference.js");
256
- return expect(modelWithReference).resolves.toBeDefined();
257
- });
258
- test("errors import ok?", () => {
259
- const errors = import("../aws/types/errors.js");
260
- return expect(errors).resolves.toBeDefined();
261
- });
262
- test("lambdaResponse import ok?", () => {
263
- const lambdaResponse = import("../aws/types/lambda-response.js");
264
- return expect(lambdaResponse).resolves.toBeDefined();
265
- });
266
- test("dtLoggerDefault import ok?", () => {
267
- const dtLoggerDefault = import("../aws/runtime/dt-logger-default.js");
268
- return expect(dtLoggerDefault).resolves.toBeDefined();
269
- });
270
- test("secret import ok?", () => {
271
- const secret = import("../aws/runtime/secrets/secret.js");
272
- return expect(secret).resolves.toBeDefined();
273
- });
274
- test("proxyHolder import ok?", () => {
275
- const proxyHolder = import("../aws/runtime/secrets/proxy-holder.js");
276
- return expect(proxyHolder).resolves.toBeDefined();
277
- });
278
- test("dbsecret import ok?", () => {
279
- const dbsecret = import("../aws/runtime/secrets/dbsecret.js");
280
- return expect(dbsecret).resolves.toBeDefined();
281
- });
282
- test("rdsHolder import ok?", () => {
283
- const rdsHolder = import("../aws/runtime/secrets/rds-holder.js");
284
- return expect(rdsHolder).resolves.toBeDefined();
285
- });
286
- test("secretHolder import ok?", () => {
287
- const secretHolder = import("../aws/runtime/secrets/secret-holder.js");
288
- return expect(secretHolder).resolves.toBeDefined();
289
- });
290
- test("dtLogger import ok?", () => {
291
- const dtLogger = import("../aws/runtime/dt-logger.js");
292
- return expect(dtLogger).resolves.toBeDefined();
293
- });
294
- test("s3 import ok?", () => {
295
- const s3 = import("../aws/runtime/s3.js");
296
- return expect(s3).resolves.toBeDefined();
297
- });
298
- /*
299
- temporary disable, enable after sdk v2 is kicked out
300
- test('apikey import ok?', () => {
301
- const apikey = import("../aws/runtime/apikey.js");
302
- return expect(apikey).resolves.toBeDefined();
303
- });*/
304
- test("environment import ok?", () => {
305
- const environment = import("../aws/runtime/environment.js");
306
- return expect(environment).resolves.toBeDefined();
307
- });
308
- test("digitrafficIntegrationResponse import ok?", () => {
309
- const digitrafficIntegrationResponse = import("../aws/runtime/digitraffic-integration-response.js");
310
- return expect(digitrafficIntegrationResponse).resolves.toBeDefined();
311
- });
312
- /*
313
- * Näitä ei testata, koska ne importtaa synthetics kirjaston, jolle ei ole mitään vastinetta npm:ssä. Lambdaympäristöstä
314
- * löytyy toi kirjasto.
315
- */
316
- //const databaseChecker = import("../aws/infra/canaries/database-checker.mjs");
317
- //const urlChecker = import("../aws/infra/canaries/url-checker.mjs");
318
- //# sourceMappingURL=imports.test.js.map
@@ -1 +0,0 @@
1
- export {};
@@ -1,72 +0,0 @@
1
- import { App, Stack } from "aws-cdk-lib";
2
- import { describe, expect, test } from "vitest";
3
- import { AclBuilder } from "../../aws/infra/acl-builder.js";
4
- describe("acl-builder tests", () => {
5
- function createBuilder() {
6
- const app = new App();
7
- const stack = new Stack(app);
8
- return new AclBuilder(stack);
9
- }
10
- test("no rules", () => {
11
- expect(() => createBuilder().build()).toThrow();
12
- });
13
- test("default rules", () => {
14
- const acl = createBuilder().withAWSManagedRules().build();
15
- expect(acl.rules).toHaveLength(4);
16
- });
17
- test("two aws rules", () => {
18
- const acl = createBuilder()
19
- .withAWSManagedRules(["CommonRuleSet", "AmazonIpReputationList"])
20
- .build();
21
- expect(acl.rules).toHaveLength(2);
22
- });
23
- test("ip blacklist", () => {
24
- const acl = createBuilder()
25
- .withIpBlacklistRule(["1.2.3.4", "1.2.6.6"])
26
- .build();
27
- expect(acl.rules).toHaveLength(1);
28
- });
29
- test("ip whitelist", () => {
30
- const acl = createBuilder()
31
- .withIpWhitelistRule(["1.2.3.4", "1.2.6.6"])
32
- .build();
33
- expect(acl.rules).toHaveLength(1);
34
- });
35
- test("throttle rules", () => {
36
- for (const aclBuilder of [
37
- createBuilder().withThrottleDigitrafficUserIp(100),
38
- createBuilder().withThrottleDigitrafficUserIpAndUriPath(100),
39
- createBuilder().withThrottleAnonymousUserIp(100),
40
- createBuilder().withThrottleAnonymousUserIpAndUriPath(100),
41
- createBuilder().withThrottleAnonymousUserIpByUriPath(500, /abc/),
42
- ]) {
43
- const acl = aclBuilder.build();
44
- // Check that the rule exists and a custom response is defined
45
- expect(acl.rules).toHaveLength(1);
46
- expect(Object.keys(acl.customResponseBodies)).toHaveLength(1);
47
- // Check that the rule does throttle
48
- const throttleRule = acl.rules[0];
49
- expect(throttleRule.statement
50
- .rateBasedStatement).toBeDefined();
51
- expect(throttleRule.action.block).toBeDefined();
52
- }
53
- });
54
- test("Cannot define two rules with the same name", () => {
55
- expect(() => createBuilder()
56
- .withThrottleAnonymousUserIp(10)
57
- .withThrottleAnonymousUserIp(200)
58
- .build()).toThrow();
59
- });
60
- test("throtle rule without limit does nothing", () => {
61
- for (const aclBuilder of [
62
- createBuilder().withThrottleDigitrafficUserIp(undefined),
63
- createBuilder().withThrottleDigitrafficUserIpAndUriPath(undefined),
64
- createBuilder().withThrottleAnonymousUserIp(undefined),
65
- createBuilder().withThrottleAnonymousUserIpAndUriPath(undefined),
66
- createBuilder().withThrottleAnonymousUserIpByUriPath(undefined, undefined),
67
- ]) {
68
- expect(() => aclBuilder.build()).toThrow("No rules");
69
- }
70
- });
71
- });
72
- //# sourceMappingURL=acl-builder.test.js.map
@@ -1 +0,0 @@
1
- export {};
@@ -1,42 +0,0 @@
1
- import { describe, expect, test, vi } from "vitest";
2
- import { HandlerFactory } from "../../../aws/infra/api/handler-factory.js";
3
- import { DtLogger } from "../../../aws/runtime/dt-logger.js";
4
- const logger = new DtLogger();
5
- describe("handler-factory tests", () => {
6
- test("test defaults", async () => {
7
- const factory = new HandlerFactory();
8
- const method = vi.fn((method) => {
9
- return method;
10
- });
11
- const handler = factory.createEventHandler(method, logger);
12
- await handler({});
13
- expect(method).toHaveBeenCalledTimes(1);
14
- });
15
- test("test logging", async () => {
16
- const loggingHandler = vi.fn((method) => {
17
- return method();
18
- });
19
- const factory = new HandlerFactory().withLoggingHandler(loggingHandler);
20
- const method = vi.fn((method) => {
21
- return method;
22
- });
23
- const handler = factory.createEventHandler(method, logger);
24
- await handler({});
25
- expect(method).toHaveBeenCalledTimes(1);
26
- expect(loggingHandler).toHaveBeenCalledTimes(1);
27
- });
28
- test("test error handling", async () => {
29
- const eh = vi.fn((method) => {
30
- return method;
31
- });
32
- const factory = new HandlerFactory().withErrorHandler(eh);
33
- const method = vi.fn(() => {
34
- throw new Error("MAGIC");
35
- });
36
- const handler = factory.createEventHandler(method, logger);
37
- await handler({});
38
- expect(method).toHaveBeenCalledTimes(1);
39
- expect(eh).toHaveBeenCalledTimes(1);
40
- });
41
- });
42
- //# sourceMappingURL=handler-factory.test.js.map
@@ -1 +0,0 @@
1
- export {};