@digitraffic/common 2024.8.14-1 → 2024.8.27-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 (225) hide show
  1. package/dist/{test/asserter.mjs → __test__/asserter.js} +3 -3
  2. package/dist/{test/db-testutils.d.mts → __test__/db-testutils.d.ts} +1 -1
  3. package/dist/{test/db-testutils.mjs → __test__/db-testutils.js} +4 -3
  4. package/dist/__test__/{dependencies.test.mjs → dependencies.test.js} +1 -1
  5. package/dist/__test__/{imports.test.mjs → imports.test.js} +79 -79
  6. package/dist/__test__/infra/{acl-builder.test.mjs → acl-builder.test.js} +4 -4
  7. package/dist/__test__/infra/api/{handler-factory.test.mjs → handler-factory.test.js} +3 -4
  8. package/dist/__test__/infra/api/{response.test.mjs → response.test.js} +3 -11
  9. package/dist/__test__/infra/api/{static-integration.test.mjs → static-integration.test.js} +3 -3
  10. package/dist/__test__/infra/{documentation.test.mjs → documentation.test.js} +2 -2
  11. package/dist/__test__/infra/{scheduler.test.mjs → scheduler.test.js} +2 -2
  12. package/dist/__test__/infra/{security-rule.test.mjs → security-rule.test.js} +2 -2
  13. package/dist/__test__/marine/{id_utils.test.mjs → id_utils.test.js} +3 -3
  14. package/dist/{test/mock-ky.mjs → __test__/mock-ky.js} +1 -1
  15. package/dist/__test__/promise/{promise.test.mjs → promise.test.js} +9 -13
  16. package/dist/__test__/runtime/{dt-logger.test.mjs → dt-logger.test.js} +7 -7
  17. package/dist/__test__/secrets/{secret-holder.test.mjs → secret-holder.test.js} +6 -4
  18. package/dist/__test__/secrets/{secret.test.mjs → secret.test.js} +4 -2
  19. package/dist/__test__/stack/{rest-apis.test.mjs → rest-apis.test.js} +4 -4
  20. package/dist/__test__/test/{mock-ky.test.mjs → mock-ky.test.js} +3 -3
  21. package/dist/{test/testutils.mjs → __test__/testutils.js} +1 -2
  22. package/dist/__test__/types/{lambda-response.test.mjs → lambda-response.test.js} +2 -2
  23. package/dist/__test__/utils/{date-utils.test.mjs → date-utils.test.js} +3 -3
  24. package/dist/__test__/utils/{geometry.test.mjs → geometry.test.js} +3 -3
  25. package/dist/__test__/utils/{logging.test.mjs → logging.test.js} +4 -4
  26. package/dist/__test__/utils/{utils.test.mjs → utils.test.js} +2 -3
  27. package/dist/aws/infra/acl-builder.d.ts +41 -0
  28. package/dist/aws/infra/{acl-builder.mjs → acl-builder.js} +82 -57
  29. package/dist/aws/infra/api/{handler-factory.d.mts → handler-factory.d.ts} +4 -4
  30. package/dist/aws/infra/api/{handler-factory.mjs → handler-factory.js} +7 -5
  31. package/dist/aws/infra/api/{integration.d.mts → integration.d.ts} +3 -1
  32. package/dist/aws/infra/api/{integration.mjs → integration.js} +34 -13
  33. package/dist/aws/infra/api/{response.d.mts → response.d.ts} +2 -2
  34. package/dist/aws/infra/api/{response.mjs → response.js} +4 -4
  35. package/dist/aws/infra/api/{responses.d.mts → responses.d.ts} +3 -3
  36. package/dist/aws/infra/api/{responses.mjs → responses.js} +4 -6
  37. package/dist/aws/infra/api/{static-integration.d.mts → static-integration.d.ts} +2 -2
  38. package/dist/aws/infra/api/{static-integration.mjs → static-integration.js} +3 -3
  39. package/dist/aws/infra/canaries/canary-alarm.d.ts +6 -0
  40. package/dist/aws/infra/canaries/{canary-alarm.mjs → canary-alarm.js} +1 -3
  41. package/dist/aws/infra/canaries/{canary-keys.mjs → canary-keys.js} +1 -1
  42. package/dist/aws/infra/canaries/{canary-parameters.d.mts → canary-parameters.d.ts} +1 -1
  43. package/dist/aws/infra/canaries/canary-parameters.js +2 -0
  44. package/dist/aws/infra/canaries/{canary-role.d.mts → canary-role.d.ts} +1 -1
  45. package/dist/aws/infra/canaries/{canary-role.mjs → canary-role.js} +2 -5
  46. package/dist/aws/infra/canaries/{canary.d.mts → canary.d.ts} +4 -4
  47. package/dist/aws/infra/canaries/{canary.mjs → canary.js} +3 -4
  48. package/dist/aws/infra/canaries/{database-canary.d.mts → database-canary.d.ts} +4 -5
  49. package/dist/aws/infra/canaries/{database-canary.mjs → database-canary.js} +4 -11
  50. package/dist/aws/infra/canaries/{database-checker.d.mts → database-checker.d.ts} +5 -5
  51. package/dist/aws/infra/canaries/{database-checker.mjs → database-checker.js} +15 -12
  52. package/dist/aws/infra/canaries/{url-canary.d.mts → url-canary.d.ts} +5 -5
  53. package/dist/aws/infra/canaries/{url-canary.mjs → url-canary.js} +7 -12
  54. package/dist/aws/infra/canaries/{url-checker.d.mts → url-checker.d.ts} +2 -2
  55. package/dist/aws/infra/canaries/{url-checker.mjs → url-checker.js} +12 -21
  56. package/dist/aws/infra/{documentation.d.mts → documentation.d.ts} +2 -2
  57. package/dist/aws/infra/{documentation.mjs → documentation.js} +4 -3
  58. package/dist/aws/infra/{import-util.d.mts → import-util.d.ts} +2 -2
  59. package/dist/aws/infra/{import-util.mjs → import-util.js} +3 -3
  60. package/dist/aws/infra/{scheduler.d.mts → scheduler.d.ts} +2 -2
  61. package/dist/aws/infra/{scheduler.mjs → scheduler.js} +1 -3
  62. package/dist/aws/infra/{security-rule.d.mts → security-rule.d.ts} +1 -1
  63. package/dist/aws/infra/{security-rule.mjs → security-rule.js} +1 -2
  64. package/dist/aws/infra/{sqs-integration.d.mts → sqs-integration.d.ts} +3 -3
  65. package/dist/aws/infra/{sqs-integration.mjs → sqs-integration.js} +3 -7
  66. package/dist/aws/infra/{sqs-queue.d.mts → sqs-queue.d.ts} +1 -1
  67. package/dist/aws/infra/{sqs-queue.mjs → sqs-queue.js} +19 -19
  68. package/dist/aws/infra/stack/{lambda-configs.d.mts → lambda-configs.d.ts} +4 -4
  69. package/dist/aws/infra/stack/{lambda-configs.mjs → lambda-configs.js} +3 -7
  70. package/dist/aws/infra/stack/{monitoredfunction.d.mts → monitoredfunction.d.ts} +15 -15
  71. package/dist/aws/infra/stack/{monitoredfunction.mjs → monitoredfunction.js} +42 -43
  72. package/dist/aws/infra/stack/{parameters.mjs → parameters.js} +1 -1
  73. package/dist/aws/infra/stack/{rest_apis.d.mts → rest_apis.d.ts} +12 -6
  74. package/dist/aws/infra/stack/{rest_apis.mjs → rest_apis.js} +26 -24
  75. package/dist/aws/infra/stack/{stack-checking-aspect.mjs → stack-checking-aspect.js} +7 -2
  76. package/dist/aws/infra/stack/{stack.d.mts → stack.d.ts} +4 -4
  77. package/dist/aws/infra/stack/{stack.mjs → stack.js} +2 -5
  78. package/dist/aws/infra/stack/{subscription.d.mts → subscription.d.ts} +4 -4
  79. package/dist/aws/infra/stack/{subscription.mjs → subscription.js} +2 -6
  80. package/dist/aws/infra/stacks/{db-dns-stack.d.mts → db-dns-stack.d.ts} +1 -1
  81. package/dist/aws/infra/stacks/{db-dns-stack.mjs → db-dns-stack.js} +4 -4
  82. package/dist/aws/infra/stacks/{db-proxy-stack.d.mts → db-proxy-stack.d.ts} +2 -2
  83. package/dist/aws/infra/stacks/{db-proxy-stack.mjs → db-proxy-stack.js} +5 -6
  84. package/dist/aws/infra/stacks/{db-stack.d.mts → db-stack.d.ts} +4 -4
  85. package/dist/aws/infra/stacks/{db-stack.mjs → db-stack.js} +7 -10
  86. package/dist/aws/infra/stacks/intra-stack-configuration.js +2 -0
  87. package/dist/aws/infra/stacks/{network-stack.d.mts → network-stack.d.ts} +2 -2
  88. package/dist/aws/infra/stacks/{network-stack.mjs → network-stack.js} +4 -7
  89. package/dist/aws/infra/{usage-plans.d.mts → usage-plans.d.ts} +1 -1
  90. package/dist/aws/infra/{usage-plans.mjs → usage-plans.js} +1 -2
  91. package/dist/aws/runtime/{apikey.mjs → apikey.js} +1 -1
  92. package/dist/aws/runtime/{digitraffic-integration-response.d.mts → digitraffic-integration-response.d.ts} +1 -1
  93. package/dist/aws/runtime/{digitraffic-integration-response.mjs → digitraffic-integration-response.js} +4 -6
  94. package/dist/aws/runtime/{dt-logger-default.d.mts → dt-logger-default.d.ts} +2 -2
  95. package/dist/aws/runtime/{dt-logger-default.mjs → dt-logger-default.js} +2 -2
  96. package/dist/aws/runtime/{dt-logger.mjs → dt-logger.js} +9 -4
  97. package/dist/aws/runtime/{environment.mjs → environment.js} +2 -2
  98. package/dist/aws/runtime/{s3.d.mts → s3.d.ts} +1 -1
  99. package/dist/aws/runtime/{s3.mjs → s3.js} +3 -3
  100. package/dist/aws/runtime/secrets/{dbsecret.d.mts → dbsecret.d.ts} +1 -1
  101. package/dist/aws/runtime/secrets/{dbsecret.mjs → dbsecret.js} +6 -2
  102. package/dist/aws/runtime/secrets/proxy-holder.js +25 -0
  103. package/dist/aws/runtime/secrets/rds-holder.js +25 -0
  104. package/dist/aws/runtime/secrets/{secret-holder.d.mts → secret-holder.d.ts} +6 -5
  105. package/dist/aws/runtime/secrets/{secret-holder.mjs → secret-holder.js} +11 -12
  106. package/dist/aws/runtime/secrets/{secret.mjs → secret.js} +7 -3
  107. package/dist/aws/types/{errors.mjs → errors.js} +1 -1
  108. package/dist/aws/types/{lambda-response.mjs → lambda-response.js} +1 -1
  109. package/dist/aws/types/{mediatypes.mjs → mediatypes.js} +1 -1
  110. package/dist/aws/types/{model-with-reference.d.mts → model-with-reference.d.ts} +1 -1
  111. package/dist/aws/types/model-with-reference.js +2 -0
  112. package/dist/aws/types/proxytypes.js +2 -0
  113. package/dist/aws/types/tags.js +4 -0
  114. package/dist/database/{cached.d.mts → cached.d.ts} +1 -1
  115. package/dist/database/{cached.mjs → cached.js} +2 -4
  116. package/dist/database/{database.mjs → database.js} +4 -8
  117. package/dist/database/{last-updated.d.mts → last-updated.d.ts} +1 -1
  118. package/dist/database/{last-updated.mjs → last-updated.js} +3 -1
  119. package/dist/database/models.js +2 -0
  120. package/dist/index.d.ts +1 -0
  121. package/dist/index.js +2 -0
  122. package/dist/marine/{id_utils.mjs → id_utils.js} +2 -2
  123. package/dist/marine/rtz.js +2 -0
  124. package/dist/types/{async-timeout-error.mjs → async-timeout-error.js} +1 -1
  125. package/dist/types/aws-env.js +2 -0
  126. package/dist/types/either.js +2 -0
  127. package/dist/types/{http-error.mjs → http-error.js} +1 -1
  128. package/dist/types/{input-error.mjs → input-error.js} +1 -1
  129. package/dist/types/{language.mjs → language.js} +1 -1
  130. package/dist/types/{nullable.d.mts → nullable.d.ts} +1 -1
  131. package/dist/types/nullable.js +2 -0
  132. package/dist/types/{traffictype.mjs → traffictype.js} +1 -1
  133. package/dist/types/urn.js +2 -0
  134. package/dist/types/util-types.js +2 -0
  135. package/dist/types/{validator.mjs → validator.js} +1 -1
  136. package/dist/utils/{api-model.d.mts → api-model.d.ts} +6 -5
  137. package/dist/utils/{api-model.mjs → api-model.js} +14 -15
  138. package/dist/utils/{base64.mjs → base64.js} +3 -3
  139. package/dist/utils/{date-utils.mjs → date-utils.js} +1 -1
  140. package/dist/utils/{geojson-types.d.mts → geojson-types.d.ts} +2 -2
  141. package/dist/utils/{geojson-types.mjs → geojson-types.js} +1 -1
  142. package/dist/utils/{geometry.d.mts → geometry.d.ts} +4 -3
  143. package/dist/utils/{geometry.mjs → geometry.js} +7 -4
  144. package/dist/utils/{logging.d.mts → logging.d.ts} +1 -1
  145. package/dist/utils/{logging.mjs → logging.js} +5 -8
  146. package/dist/utils/{retry.mjs → retry.js} +6 -8
  147. package/dist/utils/{slack.mjs → slack.js} +3 -3
  148. package/dist/utils/{utils.d.mts → utils.d.ts} +2 -3
  149. package/dist/utils/{utils.mjs → utils.js} +9 -5
  150. package/package.json +132 -129
  151. package/dist/aws/infra/acl-builder.d.mts +0 -31
  152. package/dist/aws/infra/canaries/canary-alarm.d.mts +0 -6
  153. package/dist/aws/infra/canaries/canary-parameters.mjs +0 -2
  154. package/dist/aws/infra/stacks/intra-stack-configuration.mjs +0 -2
  155. package/dist/aws/runtime/secrets/proxy-holder.mjs +0 -25
  156. package/dist/aws/runtime/secrets/rds-holder.mjs +0 -25
  157. package/dist/aws/types/model-with-reference.mjs +0 -2
  158. package/dist/aws/types/proxytypes.mjs +0 -2
  159. package/dist/aws/types/tags.mjs +0 -4
  160. package/dist/database/models.mjs +0 -2
  161. package/dist/index.d.mts +0 -1
  162. package/dist/index.mjs +0 -2
  163. package/dist/marine/rtz.mjs +0 -2
  164. package/dist/types/aws-env.mjs +0 -2
  165. package/dist/types/either.mjs +0 -2
  166. package/dist/types/nullable.mjs +0 -2
  167. package/dist/types/urn.mjs +0 -2
  168. package/dist/types/util-types.mjs +0 -2
  169. /package/dist/{test/asserter.d.mts → __test__/asserter.d.ts} +0 -0
  170. /package/dist/__test__/{dependencies.test.d.mts → dependencies.test.d.ts} +0 -0
  171. /package/dist/__test__/{imports.test.d.mts → imports.test.d.ts} +0 -0
  172. /package/dist/__test__/infra/{acl-builder.test.d.mts → acl-builder.test.d.ts} +0 -0
  173. /package/dist/__test__/infra/api/{handler-factory.test.d.mts → handler-factory.test.d.ts} +0 -0
  174. /package/dist/__test__/infra/api/{response.test.d.mts → response.test.d.ts} +0 -0
  175. /package/dist/__test__/infra/api/{static-integration.test.d.mts → static-integration.test.d.ts} +0 -0
  176. /package/dist/__test__/infra/{documentation.test.d.mts → documentation.test.d.ts} +0 -0
  177. /package/dist/__test__/infra/{scheduler.test.d.mts → scheduler.test.d.ts} +0 -0
  178. /package/dist/__test__/infra/{security-rule.test.d.mts → security-rule.test.d.ts} +0 -0
  179. /package/dist/__test__/marine/{id_utils.test.d.mts → id_utils.test.d.ts} +0 -0
  180. /package/dist/{test/mock-ky.d.mts → __test__/mock-ky.d.ts} +0 -0
  181. /package/dist/__test__/promise/{promise.test.d.mts → promise.test.d.ts} +0 -0
  182. /package/dist/__test__/runtime/{dt-logger.test.d.mts → dt-logger.test.d.ts} +0 -0
  183. /package/dist/__test__/secrets/{secret-holder.test.d.mts → secret-holder.test.d.ts} +0 -0
  184. /package/dist/__test__/secrets/{secret.test.d.mts → secret.test.d.ts} +0 -0
  185. /package/dist/__test__/stack/{rest-apis.test.d.mts → rest-apis.test.d.ts} +0 -0
  186. /package/dist/__test__/test/{mock-ky.test.d.mts → mock-ky.test.d.ts} +0 -0
  187. /package/dist/{test/testutils.d.mts → __test__/testutils.d.ts} +0 -0
  188. /package/dist/__test__/types/{lambda-response.test.d.mts → lambda-response.test.d.ts} +0 -0
  189. /package/dist/__test__/utils/{date-utils.test.d.mts → date-utils.test.d.ts} +0 -0
  190. /package/dist/__test__/utils/{geometry.test.d.mts → geometry.test.d.ts} +0 -0
  191. /package/dist/__test__/utils/{logging.test.d.mts → logging.test.d.ts} +0 -0
  192. /package/dist/__test__/utils/{utils.test.d.mts → utils.test.d.ts} +0 -0
  193. /package/dist/aws/infra/canaries/{canary-keys.d.mts → canary-keys.d.ts} +0 -0
  194. /package/dist/aws/infra/stack/{parameters.d.mts → parameters.d.ts} +0 -0
  195. /package/dist/aws/infra/stack/{stack-checking-aspect.d.mts → stack-checking-aspect.d.ts} +0 -0
  196. /package/dist/aws/infra/stacks/{intra-stack-configuration.d.mts → intra-stack-configuration.d.ts} +0 -0
  197. /package/dist/aws/runtime/{apikey.d.mts → apikey.d.ts} +0 -0
  198. /package/dist/aws/runtime/{dt-logger.d.mts → dt-logger.d.ts} +0 -0
  199. /package/dist/aws/runtime/{environment.d.mts → environment.d.ts} +0 -0
  200. /package/dist/aws/runtime/secrets/{proxy-holder.d.mts → proxy-holder.d.ts} +0 -0
  201. /package/dist/aws/runtime/secrets/{rds-holder.d.mts → rds-holder.d.ts} +0 -0
  202. /package/dist/aws/runtime/secrets/{secret.d.mts → secret.d.ts} +0 -0
  203. /package/dist/aws/types/{errors.d.mts → errors.d.ts} +0 -0
  204. /package/dist/aws/types/{lambda-response.d.mts → lambda-response.d.ts} +0 -0
  205. /package/dist/aws/types/{mediatypes.d.mts → mediatypes.d.ts} +0 -0
  206. /package/dist/aws/types/{proxytypes.d.mts → proxytypes.d.ts} +0 -0
  207. /package/dist/aws/types/{tags.d.mts → tags.d.ts} +0 -0
  208. /package/dist/database/{database.d.mts → database.d.ts} +0 -0
  209. /package/dist/database/{models.d.mts → models.d.ts} +0 -0
  210. /package/dist/marine/{id_utils.d.mts → id_utils.d.ts} +0 -0
  211. /package/dist/marine/{rtz.d.mts → rtz.d.ts} +0 -0
  212. /package/dist/types/{async-timeout-error.d.mts → async-timeout-error.d.ts} +0 -0
  213. /package/dist/types/{aws-env.d.mts → aws-env.d.ts} +0 -0
  214. /package/dist/types/{either.d.mts → either.d.ts} +0 -0
  215. /package/dist/types/{http-error.d.mts → http-error.d.ts} +0 -0
  216. /package/dist/types/{input-error.d.mts → input-error.d.ts} +0 -0
  217. /package/dist/types/{language.d.mts → language.d.ts} +0 -0
  218. /package/dist/types/{traffictype.d.mts → traffictype.d.ts} +0 -0
  219. /package/dist/types/{urn.d.mts → urn.d.ts} +0 -0
  220. /package/dist/types/{util-types.d.mts → util-types.d.ts} +0 -0
  221. /package/dist/types/{validator.d.mts → validator.d.ts} +0 -0
  222. /package/dist/utils/{base64.d.mts → base64.d.ts} +0 -0
  223. /package/dist/utils/{date-utils.d.mts → date-utils.d.ts} +0 -0
  224. /package/dist/utils/{retry.d.mts → retry.d.ts} +0 -0
  225. /package/dist/utils/{slack.d.mts → slack.d.ts} +0 -0
@@ -1,7 +1,7 @@
1
- import { getRandomInteger } from "../../test/testutils.mjs";
2
- import { retry, RetryLogError } from "../../utils/retry.mjs";
3
- import { logger } from "../../aws/runtime/dt-logger-default.mjs";
4
- import { jest } from '@jest/globals';
1
+ import { getRandomInteger } from "../../__test__/testutils.js";
2
+ import { retry, RetryLogError } from "../../utils/retry.js";
3
+ import { logger } from "../../aws/runtime/dt-logger-default.js";
4
+ import { jest } from "@jest/globals";
5
5
  jest.useFakeTimers();
6
6
  describe("Promise utils tests", () => {
7
7
  test("retry - no retries", async () => {
@@ -32,8 +32,7 @@ describe("Promise utils tests", () => {
32
32
  });
33
33
  test("retry - errors with no error logging", async () => {
34
34
  const fn = jest.fn(() => Promise.reject("error"));
35
- const consoleErrorSpy = jest
36
- .spyOn(logger, "error");
35
+ const consoleErrorSpy = jest.spyOn(logger, "error");
37
36
  try {
38
37
  await retry(fn, getRandomInteger(0, 10), RetryLogError.NO_LOGGING);
39
38
  }
@@ -47,8 +46,7 @@ describe("Promise utils tests", () => {
47
46
  });
48
47
  test("retry - no retries with error logging", async () => {
49
48
  const fn = jest.fn(() => Promise.reject("error"));
50
- const consoleErrorSpy = jest
51
- .spyOn(logger, "error");
49
+ const consoleErrorSpy = jest.spyOn(logger, "error");
52
50
  try {
53
51
  await retry(fn, 0, RetryLogError.LOG_ALL_AS_ERRORS);
54
52
  }
@@ -63,8 +61,7 @@ describe("Promise utils tests", () => {
63
61
  test("retry - retries with error logging", async () => {
64
62
  const fn = jest.fn(() => Promise.reject("error"));
65
63
  const retries = getRandomInteger(1, 10);
66
- const consoleErrorSpy = jest
67
- .spyOn(logger, "error");
64
+ const consoleErrorSpy = jest.spyOn(logger, "error");
68
65
  try {
69
66
  await retry(fn, retries, RetryLogError.LOG_ALL_AS_ERRORS);
70
67
  }
@@ -82,8 +79,7 @@ describe("Promise utils tests", () => {
82
79
  });
83
80
  test("retry - defaults", async () => {
84
81
  const fn = jest.fn(() => Promise.reject("error"));
85
- const consoleErrorSpy = jest
86
- .spyOn(logger, "error");
82
+ const consoleErrorSpy = jest.spyOn(logger, "error");
87
83
  try {
88
84
  await retry(fn);
89
85
  }
@@ -127,4 +123,4 @@ describe("Promise utils tests", () => {
127
123
  expect(ret).toBe(val);
128
124
  });
129
125
  });
130
- //# sourceMappingURL=promise.test.mjs.map
126
+ //# sourceMappingURL=promise.test.js.map
@@ -1,5 +1,5 @@
1
1
  import { Writable } from "stream";
2
- import { DtLogger } from "../../aws/runtime/dt-logger.mjs";
2
+ import { DtLogger } from "../../aws/runtime/dt-logger.js";
3
3
  const LOG_LINE = {
4
4
  method: "dt-logger.test",
5
5
  message: "FOO",
@@ -30,11 +30,11 @@ describe("dt-logger", () => {
30
30
  expect(logged.length).toBe(1);
31
31
  const loggedLine = JSON.parse(logged[0]);
32
32
  console.info(loggedLine);
33
- if (typeof expected === "object" &&
34
- "stack" in expected &&
35
- expected.stack) {
36
- const stack = loggedLine['stack'];
37
- delete loggedLine['stack'];
33
+ if (typeof expected === "object" && "stack" in expected && expected.stack) {
34
+ // eslint-disable-next-line dot-notation
35
+ const stack = loggedLine["stack"];
36
+ // eslint-disable-next-line dot-notation
37
+ delete loggedLine["stack"];
38
38
  delete expected.stack;
39
39
  expect(stack).toBeDefined();
40
40
  }
@@ -105,4 +105,4 @@ describe("dt-logger", () => {
105
105
  });
106
106
  });
107
107
  });
108
- //# sourceMappingURL=dt-logger.test.mjs.map
108
+ //# sourceMappingURL=dt-logger.test.js.map
@@ -10,8 +10,9 @@ const emptySecret = { $metadata: {} };
10
10
  const getSecretValueMock = jest.fn();
11
11
  // eslint-disable-next-line @typescript-eslint/no-misused-promises
12
12
  jest.spyOn(SecretsManager.prototype, "getSecretValue").mockImplementation(getSecretValueMock);
13
- const { SecretHolder } = await import("../../aws/runtime/secrets/secret-holder.mjs");
14
- const { DatabaseEnvironmentKeys } = await import("../../database/database.mjs");
13
+ const { SecretHolder } = await import("../../aws/runtime/secrets/secret-holder.js");
14
+ const { DatabaseEnvironmentKeys } = await import("../../database/database.js");
15
+ // eslint-disable-next-line @rushstack/no-new-null
15
16
  function mockSecret(secret) {
16
17
  if (!secret) {
17
18
  getSecretValueMock.mockImplementation(() => Promise.resolve(emptySecret));
@@ -22,11 +23,12 @@ function mockSecret(secret) {
22
23
  }
23
24
  describe("SecretHolder - tests", () => {
24
25
  beforeEach(() => {
26
+ // eslint-disable-next-line dot-notation
25
27
  process.env["SECRET_ID"] = "test-id";
28
+ // eslint-disable-next-line dot-notation
26
29
  process.env["AWS_REGION"] = "eu-west-1";
27
30
  });
28
31
  afterEach(() => {
29
- // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
30
32
  delete process.env[DatabaseEnvironmentKeys.DB_USER];
31
33
  });
32
34
  test("get - no secret", () => {
@@ -93,4 +95,4 @@ describe("SecretHolder - tests", () => {
93
95
  expect(getSecretValueMock).toHaveBeenCalledTimes(callCount + 2);
94
96
  });
95
97
  });
96
- //# sourceMappingURL=secret-holder.test.mjs.map
98
+ //# sourceMappingURL=secret-holder.test.js.map
@@ -10,6 +10,7 @@ const emptySecret = { $metadata: {} };
10
10
  const getSecretValueMock = jest.fn();
11
11
  // eslint-disable-next-line @typescript-eslint/no-misused-promises
12
12
  jest.spyOn(SecretsManager.prototype, "getSecretValue").mockImplementation(getSecretValueMock);
13
+ // eslint-disable-next-line @rushstack/no-new-null
13
14
  function mockSecret(secret) {
14
15
  if (!secret) {
15
16
  getSecretValueMock.mockImplementation(() => Promise.resolve(emptySecret));
@@ -18,8 +19,9 @@ function mockSecret(secret) {
18
19
  getSecretValueMock.mockImplementation(() => Promise.resolve({ ...emptySecret, ...{ SecretString: JSON.stringify(secret) } }));
19
20
  }
20
21
  }
22
+ // eslint-disable-next-line dot-notation
21
23
  process.env["AWS_REGION"] = "eu-west-1";
22
- const secret = await import("../../aws/runtime/secrets/secret.mjs");
24
+ const secret = await import("../../aws/runtime/secrets/secret.js");
23
25
  const { getSecret } = secret;
24
26
  describe("secret - test", () => {
25
27
  test("getSecret - no secret", async () => {
@@ -47,4 +49,4 @@ describe("secret - test", () => {
47
49
  });
48
50
  });
49
51
  });
50
- //# sourceMappingURL=secret.test.mjs.map
52
+ //# sourceMappingURL=secret.test.js.map
@@ -1,7 +1,7 @@
1
1
  import { App } from "aws-cdk-lib";
2
- import { DigitrafficRestApi } from "../../aws/infra/stack/rest_apis.mjs";
3
- import { DigitrafficStack } from "../../aws/infra/stack/stack.mjs";
4
- import { TrafficType } from "../../types/traffictype.mjs";
2
+ import { DigitrafficRestApi } from "../../aws/infra/stack/rest_apis.js";
3
+ import { DigitrafficStack } from "../../aws/infra/stack/stack.js";
4
+ import { TrafficType } from "../../types/traffictype.js";
5
5
  import { Match, Template } from "aws-cdk-lib/assertions";
6
6
  describe("Rest api test", () => {
7
7
  test("OPTIONS method is added to API-gateway", () => {
@@ -39,4 +39,4 @@ describe("Rest api test", () => {
39
39
  });
40
40
  });
41
41
  });
42
- //# sourceMappingURL=rest-apis.test.mjs.map
42
+ //# sourceMappingURL=rest-apis.test.js.map
@@ -1,5 +1,5 @@
1
- import { mockKyResponse } from "../../test/mock-ky.mjs";
2
- import { describe, test, jest } from "@jest/globals";
1
+ import { mockKyResponse } from "../../__test__/mock-ky.js";
2
+ import { describe, jest, test } from "@jest/globals";
3
3
  const ky = (await import("ky")).default;
4
4
  describe("mockKyResponse", () => {
5
5
  const testObj = { test: "data" };
@@ -43,4 +43,4 @@ describe("mockKyResponse", () => {
43
43
  expect(await (await ky.get(url)).json()).toEqual(testObj);
44
44
  });
45
45
  });
46
- //# sourceMappingURL=mock-ky.test.mjs.map
46
+ //# sourceMappingURL=mock-ky.test.js.map
@@ -26,8 +26,7 @@ export function randomBoolean() {
26
26
  export function shuffle(array) {
27
27
  // pretty fast way to copy an array, not necessarily the fastest
28
28
  const newArray = array.slice(0);
29
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
30
29
  newArray.sort((_) => 0.5 - Math.random());
31
30
  return newArray;
32
31
  }
33
- //# sourceMappingURL=testutils.mjs.map
32
+ //# sourceMappingURL=testutils.js.map
@@ -1,4 +1,4 @@
1
- import { LambdaResponse } from "../../aws/types/lambda-response.mjs";
1
+ import { LambdaResponse } from "../../aws/types/lambda-response.js";
2
2
  describe("lambda-response", () => {
3
3
  const TEST_MESSAGE = "HELLO";
4
4
  const TEST_COUNT = 12;
@@ -55,4 +55,4 @@ describe("lambda-response", () => {
55
55
  assertBinary(response, "Not implemented", 501);
56
56
  });
57
57
  });
58
- //# sourceMappingURL=lambda-response.test.mjs.map
58
+ //# sourceMappingURL=lambda-response.test.js.map
@@ -1,5 +1,5 @@
1
1
  import { parseISO } from "date-fns";
2
- import * as CommonDateUtils from "../../utils/date-utils.mjs";
2
+ import * as CommonDateUtils from "../../utils/date-utils.js";
3
3
  const ISO = "2022-01-02T01:02:03.004Z";
4
4
  describe("CommonDateUtilsTest", () => {
5
5
  test("dateFromIsoString", () => {
@@ -7,7 +7,7 @@ describe("CommonDateUtilsTest", () => {
7
7
  expect(parsed.toISOString()).toEqual(ISO);
8
8
  });
9
9
  test("dateFromIsoString fails", () => {
10
- expect(() => CommonDateUtils.dateFromIsoString(ISO + "foobar")).toThrowError();
10
+ expect(() => CommonDateUtils.dateFromIsoString(ISO + "foobar")).toThrow();
11
11
  });
12
12
  test("countDiffMs", () => {
13
13
  const start = new Date();
@@ -24,4 +24,4 @@ describe("CommonDateUtilsTest", () => {
24
24
  expect(CommonDateUtils.dateToUTCString(date, CommonDateUtils.MYSQL_DATETIME_FORMAT)).toEqual("2023-01-01 00:00");
25
25
  });
26
26
  });
27
- //# sourceMappingURL=date-utils.test.mjs.map
27
+ //# sourceMappingURL=date-utils.test.js.map
@@ -1,5 +1,5 @@
1
- import { Asserter } from "../../test/asserter.mjs";
2
- import * as Geometry from "../../utils/geometry.mjs";
1
+ import { Asserter } from "../asserter.js";
2
+ import * as Geometry from "../../utils/geometry.js";
3
3
  const TAMPERE_WGS84_X = 23.761290078;
4
4
  const TAMPERE_WGS84_Y = 61.49774257;
5
5
  const KUOPIO_WGS84_X = 27.688935;
@@ -21,4 +21,4 @@ describe("CommonGeometryTest", () => {
21
21
  expect(Geometry.areDistinctPositions([1, 2], [1, 2.000000000000001])).toBe(true);
22
22
  });
23
23
  });
24
- //# sourceMappingURL=geometry.test.mjs.map
24
+ //# sourceMappingURL=geometry.test.js.map
@@ -1,6 +1,6 @@
1
1
  import { Writable } from "stream";
2
- import { DtLogger } from "../../aws/runtime/dt-logger.mjs";
3
- import { logException } from "../../utils/logging.mjs";
2
+ import { DtLogger } from "../../aws/runtime/dt-logger.js";
3
+ import { logException } from "../../utils/logging.js";
4
4
  const TEST_METHODNAME = "test.logException";
5
5
  describe("dt-logger", () => {
6
6
  function assertLogError(error, expected, includeStack = false) {
@@ -33,7 +33,7 @@ describe("dt-logger", () => {
33
33
  delete expected.stack;
34
34
  expect(stack).toBeDefined();
35
35
  }
36
- expect(loggedLine).toEqual(expected);
36
+ expect(loggedLine).toMatchObject(expected);
37
37
  }
38
38
  test("log error - string", () => {
39
39
  const STRING_ERROR = "string error";
@@ -75,4 +75,4 @@ describe("dt-logger", () => {
75
75
  });
76
76
  });
77
77
  });
78
- //# sourceMappingURL=logging.test.mjs.map
78
+ //# sourceMappingURL=logging.test.js.map
@@ -1,4 +1,4 @@
1
- import * as ArrayUtils from "../../utils/utils.mjs";
1
+ import * as ArrayUtils from "../../utils/utils.js";
2
2
  describe("ArrayUtils", () => {
3
3
  test("bothArraysHasSameValues", () => {
4
4
  expect(ArrayUtils.bothArraysHasSameValues([], [])).toEqual(true);
@@ -10,7 +10,6 @@ describe("ArrayUtils", () => {
10
10
  expect(ArrayUtils.bothArraysHasSameValues(null, undefined)).toEqual(true);
11
11
  expect(ArrayUtils.bothArraysHasSameValues(["a"], undefined)).toEqual(false);
12
12
  expect(ArrayUtils.bothArraysHasSameValues(["a"], null)).toEqual(false);
13
- /* eslint-enable */
14
13
  expect(ArrayUtils.bothArraysHasSameValues(["a", "b"], ["a", "a"])).toEqual(false);
15
14
  expect(ArrayUtils.bothArraysHasSameValues(["a", "a", "a"], ["a", "b", "c"])).toEqual(false);
16
15
  const o1 = { a: 1, b: 2 };
@@ -43,4 +42,4 @@ describe("ArrayUtils", () => {
43
42
  expect([1, 2, undefined, null, 3].filter(ArrayUtils.isDefined)).toEqual([1, 2, 3]);
44
43
  });
45
44
  });
46
- //# sourceMappingURL=utils.test.mjs.map
45
+ //# sourceMappingURL=utils.test.js.map
@@ -0,0 +1,41 @@
1
+ import { CfnWebACL } from "aws-cdk-lib/aws-wafv2";
2
+ import type { Construct } from "constructs";
3
+ export type AWSManagedWafRule = "CommonRuleSet" | "AmazonIpReputationList" | "KnownBadInputsRuleSet" | "SQLiRuleSet";
4
+ export type ExcludedAWSRules = {
5
+ [key in AWSManagedWafRule]?: string[];
6
+ };
7
+ export type CfnWebAclRuleProperty = {
8
+ [P in keyof CfnWebACL.RuleProperty as Exclude<P, "priority">]: (CfnWebACL.RuleProperty)[P];
9
+ };
10
+ /**
11
+ * Builder class for building CfnWebACL.
12
+ *
13
+ * Currently supports:
14
+ * * Some AWS managed WAF rules
15
+ * * IP blacklisting
16
+ */
17
+ export declare class AclBuilder {
18
+ readonly _construct: Construct;
19
+ readonly _countRules: CfnWebAclRuleProperty[];
20
+ readonly _blockRules: CfnWebAclRuleProperty[];
21
+ readonly _name: string;
22
+ _scope: string;
23
+ _customResponseBodies: Record<string, CfnWebACL.CustomResponseBodyProperty>;
24
+ constructor(construct: Construct, name?: string);
25
+ isRuleDefined(rules: AWSManagedWafRule[] | "all", rule: AWSManagedWafRule): boolean;
26
+ withAWSManagedRules(rules?: AWSManagedWafRule[] | "all", excludedRules?: ExcludedAWSRules): AclBuilder;
27
+ withIpRestrictionRule(addresses: string[]): AclBuilder;
28
+ withThrottleRule(name: string, limit: number, isHeaderRequired: boolean, isBasedOnIpAndUriPath: boolean, customResponseBodyKey?: string): AclBuilder;
29
+ withCustomResponseBody(key: string, customResponseBody: CfnWebACL.CustomResponseBodyProperty): AclBuilder;
30
+ withThrottleDigitrafficUserIp(limit: number | undefined): AclBuilder;
31
+ withThrottleDigitrafficUserIpAndUriPath(limit: number | undefined): AclBuilder;
32
+ withThrottleAnonymousUserIp(limit: number | undefined): AclBuilder;
33
+ withThrottleAnonymousUserIpAndUriPath(limit: number | undefined): AclBuilder;
34
+ withCountDigitrafficUserIp(limit: number | undefined): AclBuilder;
35
+ withCountDigitrafficUserIpAndUriPath(limit: number | undefined): AclBuilder;
36
+ withCountAnonymousUserIp(limit: number | undefined): AclBuilder;
37
+ withCountAnonymousUserIpAndUriPath(limit: number | undefined): AclBuilder;
38
+ _isCustomResponseBodyKeySet(key: string): boolean;
39
+ _addThrottleResponseBody(customResponseBodyKey: string, limit: number): void;
40
+ build(): CfnWebACL;
41
+ }
@@ -1,5 +1,6 @@
1
1
  import { CfnIPSet, CfnWebACL } from "aws-cdk-lib/aws-wafv2";
2
- import { logger } from "../runtime/dt-logger-default.mjs";
2
+ import { logger } from "../runtime/dt-logger-default.js";
3
+ import { zipWith, range, concat } from "lodash-es";
3
4
  /**
4
5
  * Builder class for building CfnWebACL.
5
6
  *
@@ -9,8 +10,9 @@ import { logger } from "../runtime/dt-logger-default.mjs";
9
10
  */
10
11
  export class AclBuilder {
11
12
  _construct;
12
- _rules = [];
13
- _name;
13
+ _countRules = [];
14
+ _blockRules = [];
15
+ _name = "WebACL";
14
16
  _scope = "CLOUDFRONT";
15
17
  _customResponseBodies = {};
16
18
  constructor(construct, name = "WebACL") {
@@ -20,18 +22,18 @@ export class AclBuilder {
20
22
  isRuleDefined(rules, rule) {
21
23
  return rules === "all" || rules.includes(rule);
22
24
  }
23
- withAWSManagedRules(rules = "all") {
25
+ withAWSManagedRules(rules = "all", excludedRules = {}) {
24
26
  if (this.isRuleDefined(rules, "CommonRuleSet")) {
25
- this._rules.push(createAWSCommonRuleSet());
27
+ this._blockRules.push(createAWSCommonRuleSet(excludedRules?.CommonRuleSet));
26
28
  }
27
29
  if (this.isRuleDefined(rules, "AmazonIpReputationList")) {
28
- this._rules.push(createAWSReputationList());
30
+ this._blockRules.push(createAWSReputationList(excludedRules?.AmazonIpReputationList));
29
31
  }
30
32
  if (this.isRuleDefined(rules, "KnownBadInputsRuleSet")) {
31
- this._rules.push(createAWSKnownBadInput());
33
+ this._blockRules.push(createAWSKnownBadInput(excludedRules?.KnownBadInputsRuleSet));
32
34
  }
33
35
  if (this.isRuleDefined(rules, "SQLiRuleSet")) {
34
- this._rules.push(createAWSAntiSQLInjection());
36
+ this._blockRules.push(createAWSAntiSQLInjection(excludedRules?.SQLiRuleSet));
35
37
  }
36
38
  return this;
37
39
  }
@@ -41,9 +43,8 @@ export class AclBuilder {
41
43
  scope: this._scope,
42
44
  addresses,
43
45
  });
44
- this._rules.push({
46
+ this._blockRules.push({
45
47
  name: "IpBlocklist",
46
- priority: 10,
47
48
  action: { block: {} },
48
49
  statement: {
49
50
  ipSetReferenceStatement: {
@@ -58,23 +59,27 @@ export class AclBuilder {
58
59
  });
59
60
  return this;
60
61
  }
61
- withThrottleRule(name, priority, limit, customResponseBodyKey, isHeaderRequired, isBasedOnIpAndUriPath) {
62
- this._rules.push({
62
+ withThrottleRule(name, limit, isHeaderRequired, isBasedOnIpAndUriPath, customResponseBodyKey) {
63
+ const isBlockRule = !!customResponseBodyKey;
64
+ const rules = isBlockRule ? this._blockRules : this._countRules;
65
+ const action = isBlockRule ? {
66
+ block: {
67
+ customResponse: {
68
+ responseCode: 429,
69
+ customResponseBodyKey,
70
+ },
71
+ },
72
+ } : {
73
+ count: {}
74
+ };
75
+ rules.push({
63
76
  name,
64
- priority,
65
77
  visibilityConfig: {
66
78
  sampledRequestsEnabled: true,
67
79
  cloudWatchMetricsEnabled: true,
68
80
  metricName: name,
69
81
  },
70
- action: {
71
- block: {
72
- customResponse: {
73
- responseCode: 429,
74
- customResponseBodyKey,
75
- },
76
- },
77
- },
82
+ action,
78
83
  statement: createThrottleStatement(limit, isHeaderRequired, isBasedOnIpAndUriPath),
79
84
  });
80
85
  return this;
@@ -90,40 +95,60 @@ export class AclBuilder {
90
95
  return this;
91
96
  }
92
97
  withThrottleDigitrafficUserIp(limit) {
93
- if (limit == null) {
94
- this._logMissingLimit("withThrottleDigitrafficUserIp");
98
+ if (limit === undefined) {
95
99
  return this;
96
100
  }
97
101
  const customResponseBodyKey = `IP_THROTTLE_DIGITRAFFIC_USER_${limit}`;
98
102
  this._addThrottleResponseBody(customResponseBodyKey, limit);
99
- return this.withThrottleRule("ThrottleRuleWithDigitrafficUser", 1, limit, customResponseBodyKey, true, false);
103
+ return this.withThrottleRule("ThrottleRuleWithDigitrafficUser", limit, true, false, customResponseBodyKey);
100
104
  }
101
105
  withThrottleDigitrafficUserIpAndUriPath(limit) {
102
- if (limit == null) {
103
- this._logMissingLimit("withThrottleDigitrafficUserIpAndUriPath");
106
+ if (limit === undefined) {
104
107
  return this;
105
108
  }
106
109
  const customResponseBodyKey = `IP_PATH_THROTTLE_DIGITRAFFIC_USER_${limit}`;
107
110
  this._addThrottleResponseBody(customResponseBodyKey, limit);
108
- return this.withThrottleRule("ThrottleRuleIPQueryWithDigitrafficUser", 2, limit, customResponseBodyKey, true, true);
111
+ return this.withThrottleRule("ThrottleRuleIPQueryWithDigitrafficUser", limit, true, true, customResponseBodyKey);
109
112
  }
110
113
  withThrottleAnonymousUserIp(limit) {
111
- if (limit == null) {
112
- this._logMissingLimit("withThrottleAnonymousUserIp");
114
+ if (limit === undefined) {
113
115
  return this;
114
116
  }
115
117
  const customResponseBodyKey = `IP_THROTTLE_ANONYMOUS_USER_${limit}`;
116
118
  this._addThrottleResponseBody(customResponseBodyKey, limit);
117
- return this.withThrottleRule("ThrottleRuleWithAnonymousUser", 3, limit, customResponseBodyKey, false, false);
119
+ return this.withThrottleRule("ThrottleRuleWithAnonymousUser", limit, false, false, customResponseBodyKey);
118
120
  }
119
121
  withThrottleAnonymousUserIpAndUriPath(limit) {
120
- if (limit == null) {
121
- this._logMissingLimit("withThrottleAnonymousUserIpAndUriPath");
122
+ if (limit === undefined) {
122
123
  return this;
123
124
  }
124
125
  const customResponseBodyKey = `IP_PATH_THROTTLE_ANONYMOUS_USER_${limit}`;
125
126
  this._addThrottleResponseBody(customResponseBodyKey, limit);
126
- return this.withThrottleRule("ThrottleRuleIPQueryWithAnonymousUser", 4, limit, customResponseBodyKey, false, true);
127
+ return this.withThrottleRule("ThrottleRuleIPQueryWithAnonymousUser", limit, false, true, customResponseBodyKey);
128
+ }
129
+ withCountDigitrafficUserIp(limit) {
130
+ if (limit === undefined) {
131
+ return this;
132
+ }
133
+ return this.withThrottleRule(`CountRuleWithDigitrafficUser${limit}`, limit, true, false);
134
+ }
135
+ withCountDigitrafficUserIpAndUriPath(limit) {
136
+ if (limit === undefined) {
137
+ return this;
138
+ }
139
+ return this.withThrottleRule(`CountRuleIPQueryWithDigitrafficUser${limit}`, limit, true, true);
140
+ }
141
+ withCountAnonymousUserIp(limit) {
142
+ if (limit === undefined) {
143
+ return this;
144
+ }
145
+ return this.withThrottleRule(`CountRuleWithAnonymousUser${limit}`, limit, false, false);
146
+ }
147
+ withCountAnonymousUserIpAndUriPath(limit) {
148
+ if (limit === undefined) {
149
+ return this;
150
+ }
151
+ return this.withThrottleRule(`CountRuleIPQueryWithAnonymousUser${limit}`, limit, false, true);
127
152
  }
128
153
  _isCustomResponseBodyKeySet(key) {
129
154
  return key in this._customResponseBodies;
@@ -136,21 +161,20 @@ export class AclBuilder {
136
161
  });
137
162
  }
138
163
  }
139
- _logMissingLimit(method) {
140
- logger.warn({
141
- method: `acl-builder.${method}`,
142
- message: `'limit' was not defined. Not setting a throttle rule for ${this._name}`,
143
- });
144
- }
145
164
  build() {
146
- if (this._rules.length === 0) {
165
+ const addPriority = (rule, priority) => ({
166
+ ...rule,
167
+ priority
168
+ });
169
+ const rules = concat(zipWith(this._countRules, range(this._countRules.length), addPriority), zipWith(this._blockRules, range(this._blockRules.length).map(n => n + this._countRules.length), addPriority));
170
+ if (rules.length === 0) {
147
171
  throw new Error("No rules defined for WebACL");
148
172
  }
149
- const uniqueRuleNames = new Set(this._rules.map((rule) => rule.name));
150
- if (uniqueRuleNames.size != this._rules.length) {
173
+ const uniqueRuleNames = new Set(rules.map((rule) => rule.name));
174
+ if (uniqueRuleNames.size !== rules.length) {
151
175
  throw new Error("Tried to create an Access Control List with multiple rules having the same name");
152
176
  }
153
- const acl = new CfnWebACL(this._construct, this._name, {
177
+ return new CfnWebACL(this._construct, this._name, {
154
178
  defaultAction: { allow: {} },
155
179
  scope: this._scope,
156
180
  visibilityConfig: {
@@ -158,10 +182,9 @@ export class AclBuilder {
158
182
  metricName: "WAF-Blocked",
159
183
  sampledRequestsEnabled: false,
160
184
  },
161
- rules: this._rules,
185
+ rules,
162
186
  customResponseBodies: this._customResponseBodies,
163
187
  });
164
- return acl;
165
188
  }
166
189
  }
167
190
  const CUSTOM_KEYS_IP_AND_URI_PATH = [
@@ -228,8 +251,8 @@ function createThrottleStatement(limit, isHeaderRequired, isBasedOnIpAndUriPath)
228
251
  },
229
252
  };
230
253
  }
231
- function createAWSCommonRuleSet() {
232
- return createRuleProperty("AWS-AWSManagedRulesCommonRuleSet", 70, {
254
+ function createAWSCommonRuleSet(excludedRules = []) {
255
+ return createRuleProperty("AWS-AWSManagedRulesCommonRuleSet", {
233
256
  statement: {
234
257
  managedRuleGroupStatement: {
235
258
  vendorName: "AWS",
@@ -238,46 +261,48 @@ function createAWSCommonRuleSet() {
238
261
  { name: "NoUserAgent_HEADER" },
239
262
  { name: "SizeRestrictions_BODY" },
240
263
  { name: "GenericRFI_BODY" },
241
- ],
264
+ ].concat((excludedRules ?? []).map((rule) => ({ name: rule }))),
242
265
  },
243
266
  },
244
267
  });
245
268
  }
246
- function createAWSReputationList() {
247
- return createRuleProperty("AWS-AWSManagedRulesAmazonIpReputationList", 80, {
269
+ function createAWSReputationList(excludedRules = []) {
270
+ return createRuleProperty("AWS-AWSManagedRulesAmazonIpReputationList", {
248
271
  statement: {
249
272
  managedRuleGroupStatement: {
250
273
  vendorName: "AWS",
251
274
  name: "AWSManagedRulesAmazonIpReputationList",
275
+ excludedRules: (excludedRules ?? []).map((rule) => ({ name: rule })),
252
276
  },
253
277
  },
254
278
  });
255
279
  }
256
- function createAWSKnownBadInput() {
257
- return createRuleProperty("AWS-AWSManagedRulesKnownBadInputsRuleSet", 90, {
280
+ function createAWSKnownBadInput(excludedRules = []) {
281
+ return createRuleProperty("AWS-AWSManagedRulesKnownBadInputsRuleSet", {
258
282
  statement: {
259
283
  managedRuleGroupStatement: {
260
284
  vendorName: "AWS",
261
285
  name: "AWSManagedRulesKnownBadInputsRuleSet",
286
+ excludedRules: (excludedRules ?? []).map((rule) => ({ name: rule })),
262
287
  },
263
288
  },
264
289
  });
265
290
  }
266
- function createAWSAntiSQLInjection() {
267
- return createRuleProperty("AWS-AWSManagedRulesSQLiRuleSet", 100, {
291
+ function createAWSAntiSQLInjection(excludedRules = []) {
292
+ return createRuleProperty("AWS-AWSManagedRulesSQLiRuleSet", {
268
293
  statement: {
269
294
  managedRuleGroupStatement: {
270
295
  vendorName: "AWS",
271
296
  name: "AWSManagedRulesSQLiRuleSet",
297
+ excludedRules: (excludedRules ?? []).map((rule) => ({ name: rule })),
272
298
  },
273
299
  },
274
300
  });
275
301
  }
276
- function createRuleProperty(name, priority, rule, overrideAction = true) {
302
+ function createRuleProperty(name, rule, overrideAction = true) {
277
303
  return {
278
304
  ...{
279
305
  name,
280
- priority,
281
306
  visibilityConfig: {
282
307
  sampledRequestsEnabled: true,
283
308
  cloudWatchMetricsEnabled: true,
@@ -288,4 +313,4 @@ function createRuleProperty(name, priority, rule, overrideAction = true) {
288
313
  ...(overrideAction ? { overrideAction: { none: {} } } : {}),
289
314
  };
290
315
  }
291
- //# sourceMappingURL=acl-builder.mjs.map
316
+ //# sourceMappingURL=acl-builder.js.map
@@ -1,5 +1,5 @@
1
- import { DtLogger } from "../../runtime/dt-logger.mjs";
2
- import { LambdaResponse } from "../../types/lambda-response.mjs";
1
+ import type { DtLogger } from "../../runtime/dt-logger.js";
2
+ import type { LambdaResponse } from "../../types/lambda-response.js";
3
3
  export type LoggingHandler = (method: () => Promise<LambdaResponse>, logger: DtLogger) => Promise<LambdaResponse>;
4
4
  export type ErrorHandler = (error: unknown, logger: DtLogger) => LambdaResponse;
5
5
  /**
@@ -15,8 +15,8 @@ export declare class HandlerFactory {
15
15
  private loggingHandler;
16
16
  private errorHandler;
17
17
  constructor();
18
- withLoggingHandler(loggingHandler: LoggingHandler): this;
19
- withErrorHandler(errorHandler: ErrorHandler): this;
18
+ withLoggingHandler(loggingHandler: LoggingHandler): HandlerFactory;
19
+ withErrorHandler(errorHandler: ErrorHandler): HandlerFactory;
20
20
  createEventHandler(handler: (event: unknown) => Promise<LambdaResponse>, logger: DtLogger): (event: unknown) => Promise<LambdaResponse>;
21
21
  }
22
22
  export declare function createJsonLoggingHandler(): LoggingHandler;
@@ -1,6 +1,5 @@
1
- import { getEnvVariableOrElse } from "../../../utils/utils.mjs";
2
- import { DtLogger } from "../../runtime/dt-logger.mjs";
3
- import { LambdaResponse } from "../../types/lambda-response.mjs";
1
+ import { getEnvVariableOrElse } from "../../../utils/utils.js";
2
+ import { logger } from "../../runtime/dt-logger-default.js";
4
3
  const functionName = getEnvVariableOrElse("AWS_LAMBDA_FUNCTION_NAME", "test");
5
4
  /**
6
5
  * Factory class for creating lambda-handler functions. You can set functionality to handle logging and error-handling,
@@ -21,7 +20,10 @@ export class HandlerFactory {
21
20
  return await method();
22
21
  }
23
22
  finally {
24
- console.info("method=%s.handler tookMs=%d", functionName, Date.now() - start);
23
+ logger.info({
24
+ method: `${functionName}.handler`,
25
+ tookMs: Date.now() - start,
26
+ });
25
27
  }
26
28
  };
27
29
  this.errorHandler = (error) => {
@@ -63,4 +65,4 @@ export function createJsonLoggingHandler() {
63
65
  }
64
66
  };
65
67
  }
66
- //# sourceMappingURL=handler-factory.mjs.map
68
+ //# sourceMappingURL=handler-factory.js.map