@digitraffic/common 2024.1.10-1 → 2024.1.23-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 (292) hide show
  1. package/dist/aws/infra/api/{handler-factory.d.ts → handler-factory.d.mts} +2 -2
  2. package/dist/aws/infra/api/{handler-factory.js → handler-factory.mjs} +5 -10
  3. package/dist/aws/infra/api/{integration.d.ts → integration.d.mts} +1 -1
  4. package/dist/aws/infra/api/{integration.js → integration.mjs} +10 -14
  5. package/dist/aws/infra/api/{response.d.ts → response.d.mts} +2 -3
  6. package/dist/aws/infra/api/{response.js → response.mjs} +26 -31
  7. package/dist/aws/infra/api/{responses.d.ts → responses.d.mts} +2 -3
  8. package/dist/aws/infra/api/responses.mjs +78 -0
  9. package/dist/aws/infra/api/{static-integration.d.ts → static-integration.d.mts} +1 -1
  10. package/dist/aws/infra/api/{static-integration.js → static-integration.mjs} +8 -12
  11. package/dist/aws/infra/canaries/{canary-alarm.d.ts → canary-alarm.d.mts} +1 -1
  12. package/dist/aws/infra/canaries/canary-alarm.mjs +20 -0
  13. package/dist/aws/infra/canaries/canary-keys.mjs +4 -0
  14. package/dist/aws/infra/canaries/canary-parameters.mjs +2 -0
  15. package/dist/aws/infra/canaries/{canary-role.js → canary-role.mjs} +9 -13
  16. package/dist/aws/infra/canaries/{canary.d.ts → canary.d.mts} +2 -2
  17. package/dist/aws/infra/canaries/canary.mjs +26 -0
  18. package/dist/aws/infra/canaries/{database-canary.d.ts → database-canary.d.mts} +3 -3
  19. package/dist/aws/infra/canaries/{database-canary.js → database-canary.mjs} +9 -13
  20. package/dist/aws/infra/canaries/{database-checker.d.ts → database-checker.d.mts} +1 -1
  21. package/dist/aws/infra/canaries/{database-checker.js → database-checker.mjs} +12 -18
  22. package/dist/aws/infra/canaries/{url-canary.d.ts → url-canary.d.mts} +4 -4
  23. package/dist/aws/infra/canaries/{url-canary.js → url-canary.mjs} +9 -13
  24. package/dist/aws/infra/canaries/{url-checker.d.ts → url-checker.d.mts} +2 -2
  25. package/dist/aws/infra/canaries/{url-checker.js → url-checker.mjs} +35 -42
  26. package/dist/aws/infra/{documentation.js → documentation.mjs} +9 -17
  27. package/dist/aws/infra/{import-util.js → import-util.mjs} +11 -19
  28. package/dist/aws/infra/scheduler.mjs +27 -0
  29. package/dist/aws/infra/{security-rule.js → security-rule.mjs} +5 -9
  30. package/dist/aws/infra/{sqs-integration.d.ts → sqs-integration.d.mts} +1 -2
  31. package/dist/aws/infra/{sqs-integration.js → sqs-integration.mjs} +12 -16
  32. package/dist/aws/infra/{sqs-queue.d.ts → sqs-queue.d.mts} +1 -1
  33. package/dist/aws/infra/{sqs-queue.js → sqs-queue.mjs} +33 -41
  34. package/dist/aws/infra/stack/{lambda-configs.d.ts → lambda-configs.d.mts} +2 -2
  35. package/dist/aws/infra/stack/{lambda-configs.js → lambda-configs.mjs} +15 -21
  36. package/dist/aws/infra/stack/{monitoredfunction.d.ts → monitoredfunction.d.mts} +3 -3
  37. package/dist/aws/infra/stack/{monitoredfunction.js → monitoredfunction.mjs} +20 -28
  38. package/dist/aws/infra/stack/{parameters.d.ts → parameters.d.mts} +1 -1
  39. package/dist/aws/infra/stack/{parameters.js → parameters.mjs} +6 -11
  40. package/dist/aws/infra/stack/{rest_apis.d.ts → rest_apis.d.mts} +3 -3
  41. package/dist/aws/infra/stack/{rest_apis.js → rest_apis.mjs} +42 -55
  42. package/dist/aws/infra/stack/{stack-checking-aspect.d.ts → stack-checking-aspect.d.mts} +1 -1
  43. package/dist/aws/infra/stack/{stack-checking-aspect.js → stack-checking-aspect.mjs} +25 -32
  44. package/dist/aws/infra/stack/{stack.d.ts → stack.d.mts} +3 -4
  45. package/dist/aws/infra/stack/stack.mjs +63 -0
  46. package/dist/aws/infra/stack/{subscription.d.ts → subscription.d.mts} +2 -2
  47. package/dist/aws/infra/stack/{subscription.js → subscription.mjs} +6 -11
  48. package/dist/aws/infra/stacks/{db-dns-stack.d.ts → db-dns-stack.d.mts} +2 -2
  49. package/dist/aws/infra/stacks/db-dns-stack.mjs +60 -0
  50. package/dist/aws/infra/stacks/{db-proxy-stack.d.ts → db-proxy-stack.d.mts} +2 -2
  51. package/dist/aws/infra/stacks/db-proxy-stack.mjs +73 -0
  52. package/dist/aws/infra/stacks/{db-stack.d.ts → db-stack.d.mts} +3 -4
  53. package/dist/aws/infra/stacks/{db-stack.js → db-stack.mjs} +31 -35
  54. package/dist/aws/infra/stacks/intra-stack-configuration.mjs +2 -0
  55. package/dist/aws/infra/stacks/{network-stack.d.ts → network-stack.d.mts} +2 -2
  56. package/dist/aws/infra/stacks/network-stack.mjs +40 -0
  57. package/dist/aws/infra/{usage-plans.js → usage-plans.mjs} +3 -8
  58. package/dist/aws/runtime/apikey.mjs +9 -0
  59. package/dist/aws/runtime/{digitraffic-integration-response.d.ts → digitraffic-integration-response.d.mts} +1 -1
  60. package/dist/aws/runtime/digitraffic-integration-response.mjs +24 -0
  61. package/dist/aws/runtime/{dt-logger-default.d.ts → dt-logger-default.d.mts} +2 -2
  62. package/dist/aws/runtime/dt-logger-default.mjs +6 -0
  63. package/dist/aws/runtime/{dt-logger.d.ts → dt-logger.d.mts} +1 -1
  64. package/dist/aws/runtime/{dt-logger.js → dt-logger.mjs} +4 -11
  65. package/dist/aws/runtime/{environment.js → environment.mjs} +4 -8
  66. package/dist/aws/runtime/{messaging.js → messaging.mjs} +2 -6
  67. package/dist/aws/runtime/{s3.js → s3.mjs} +4 -8
  68. package/dist/aws/runtime/secrets/{dbsecret.d.ts → dbsecret.d.mts} +1 -1
  69. package/dist/aws/runtime/secrets/{dbsecret.js → dbsecret.mjs} +6 -10
  70. package/dist/aws/runtime/secrets/proxy-holder.mjs +24 -0
  71. package/dist/aws/runtime/secrets/rds-holder.mjs +24 -0
  72. package/dist/aws/runtime/secrets/{secret-holder.d.ts → secret-holder.d.mts} +1 -1
  73. package/dist/aws/runtime/secrets/{secret-holder.js → secret-holder.mjs} +14 -19
  74. package/dist/aws/runtime/secrets/{secret.js → secret.mjs} +8 -12
  75. package/dist/aws/types/errors.mjs +12 -0
  76. package/dist/aws/types/{lambda-response.js → lambda-response.mjs} +4 -11
  77. package/dist/aws/types/{mediatypes.js → mediatypes.mjs} +3 -6
  78. package/dist/aws/types/model-with-reference.mjs +2 -0
  79. package/dist/aws/types/proxytypes.mjs +2 -0
  80. package/dist/aws/types/tags.mjs +4 -0
  81. package/dist/database/{cached.d.ts → cached.d.mts} +1 -1
  82. package/dist/database/{cached.js → cached.mjs} +10 -15
  83. package/dist/database/{database.d.ts → database.d.mts} +1 -1
  84. package/dist/database/{database.js → database.mjs} +17 -24
  85. package/dist/database/{last-updated.d.ts → last-updated.d.mts} +1 -1
  86. package/dist/database/{last-updated.js → last-updated.mjs} +9 -18
  87. package/dist/database/models.mjs +2 -0
  88. package/dist/index.d.mts +1 -0
  89. package/dist/index.mjs +2 -0
  90. package/dist/marine/{id_utils.js → id_utils.mjs} +4 -10
  91. package/dist/marine/rtz.mjs +2 -0
  92. package/dist/test/{asserter.js → asserter.mjs} +2 -6
  93. package/dist/test/{db-testutils.d.ts → db-testutils.d.mts} +1 -1
  94. package/dist/test/db-testutils.mjs +29 -0
  95. package/dist/test/{httpserver.js → httpserver.mjs} +11 -15
  96. package/dist/test/secrets-manager.mjs +34 -0
  97. package/dist/test/testutils.mjs +33 -0
  98. package/dist/types/async-timeout-error.mjs +6 -0
  99. package/dist/types/aws-env.mjs +2 -0
  100. package/dist/types/either.mjs +2 -0
  101. package/dist/types/http-error.mjs +7 -0
  102. package/dist/types/input-error.mjs +3 -0
  103. package/dist/types/language.mjs +7 -0
  104. package/dist/types/{nullable.d.ts → nullable.d.mts} +1 -1
  105. package/dist/types/nullable.mjs +2 -0
  106. package/dist/types/{traffictype.js → traffictype.mjs} +3 -6
  107. package/dist/types/urn.mjs +2 -0
  108. package/dist/types/util-types.mjs +2 -0
  109. package/dist/types/validator.mjs +9 -0
  110. package/dist/utils/{api-model.d.ts → api-model.d.mts} +1 -1
  111. package/dist/utils/{api-model.js → api-model.mjs} +18 -28
  112. package/dist/utils/{base64.d.ts → base64.d.mts} +1 -1
  113. package/dist/utils/base64.mjs +16 -0
  114. package/dist/utils/date-utils.mjs +44 -0
  115. package/dist/utils/geojson-types.mjs +13 -0
  116. package/dist/utils/{geometry.js → geometry.mjs} +16 -49
  117. package/dist/utils/{logging.d.ts → logging.d.mts} +1 -1
  118. package/dist/utils/{logging.js → logging.mjs} +9 -14
  119. package/dist/utils/{retry.js → retry.mjs} +22 -27
  120. package/dist/utils/slack.mjs +23 -0
  121. package/dist/utils/{utils.d.ts → utils.d.mts} +2 -2
  122. package/dist/utils/{utils.js → utils.mjs} +15 -30
  123. package/package.json +99 -10
  124. package/src/aws/infra/api/{handler-factory.ts → handler-factory.mts} +3 -3
  125. package/src/aws/infra/api/{integration.ts → integration.mts} +2 -2
  126. package/src/aws/infra/api/{response.ts → response.mts} +3 -3
  127. package/src/aws/infra/api/{responses.ts → responses.mts} +4 -4
  128. package/src/aws/infra/api/{static-integration.ts → static-integration.mts} +2 -2
  129. package/src/aws/infra/canaries/Synthetics.d.mts +21 -0
  130. package/src/aws/infra/canaries/{canary-alarm.ts → canary-alarm.mts} +1 -1
  131. package/src/aws/infra/canaries/{canary.ts → canary.mts} +3 -3
  132. package/src/aws/infra/canaries/{database-canary.ts → database-canary.mts} +3 -3
  133. package/src/aws/infra/canaries/{database-checker.ts → database-checker.mts} +7 -10
  134. package/src/aws/infra/canaries/{url-canary.ts → url-canary.mts} +6 -6
  135. package/src/aws/infra/canaries/{url-checker.ts → url-checker.mts} +9 -29
  136. package/src/aws/infra/{sqs-integration.ts → sqs-integration.mts} +1 -1
  137. package/src/aws/infra/{sqs-queue.ts → sqs-queue.mts} +3 -6
  138. package/src/aws/infra/stack/{lambda-configs.ts → lambda-configs.mts} +2 -2
  139. package/src/aws/infra/stack/{monitoredfunction.ts → monitoredfunction.mts} +4 -4
  140. package/src/aws/infra/stack/{parameters.ts → parameters.mts} +1 -1
  141. package/src/aws/infra/stack/{rest_apis.ts → rest_apis.mts} +6 -6
  142. package/src/aws/infra/stack/{stack-checking-aspect.ts → stack-checking-aspect.mts} +1 -1
  143. package/src/aws/infra/stack/{stack.ts → stack.mts} +4 -5
  144. package/src/aws/infra/stack/{subscription.ts → subscription.mts} +2 -2
  145. package/src/aws/infra/stacks/{db-dns-stack.ts → db-dns-stack.mts} +4 -4
  146. package/src/aws/infra/stacks/{db-proxy-stack.ts → db-proxy-stack.mts} +5 -5
  147. package/src/aws/infra/stacks/{db-stack.ts → db-stack.mts} +5 -5
  148. package/src/aws/infra/stacks/{network-stack.ts → network-stack.mts} +3 -3
  149. package/src/aws/runtime/{digitraffic-integration-response.ts → digitraffic-integration-response.mts} +2 -2
  150. package/src/aws/runtime/{dt-logger-default.ts → dt-logger-default.mts} +2 -2
  151. package/src/aws/runtime/secrets/{dbsecret.ts → dbsecret.mts} +1 -1
  152. package/src/aws/runtime/secrets/node-ttl.d.mts +12 -0
  153. package/src/aws/runtime/secrets/{proxy-holder.ts → proxy-holder.mts} +4 -4
  154. package/src/aws/runtime/secrets/{rds-holder.ts → rds-holder.mts} +4 -4
  155. package/src/aws/runtime/secrets/{secret-holder.ts → secret-holder.mts} +8 -9
  156. package/src/aws/runtime/secrets/{secret.ts → secret.mts} +2 -2
  157. package/src/database/{cached.ts → cached.mts} +4 -2
  158. package/src/database/{database.ts → database.mts} +6 -6
  159. package/src/database/{last-updated.ts → last-updated.mts} +1 -1
  160. package/src/index.mts +2 -0
  161. package/src/test/{db-testutils.ts → db-testutils.mts} +2 -2
  162. package/src/test/{secrets-manager.ts → secrets-manager.mts} +3 -3
  163. package/src/types/{nullable.ts → nullable.mts} +1 -1
  164. package/src/utils/{api-model.ts → api-model.mts} +1 -1
  165. package/src/utils/{geometry.ts → geometry.mts} +5 -3
  166. package/src/utils/{logging.ts → logging.mts} +2 -2
  167. package/src/utils/{retry.ts → retry.mts} +3 -3
  168. package/src/utils/{slack.ts → slack.mts} +2 -2
  169. package/src/utils/{utils.ts → utils.mts} +3 -3
  170. package/dist/aws/infra/api/responses.js +0 -84
  171. package/dist/aws/infra/canaries/canary-alarm.js +0 -24
  172. package/dist/aws/infra/canaries/canary-keys.js +0 -7
  173. package/dist/aws/infra/canaries/canary-parameters.js +0 -3
  174. package/dist/aws/infra/canaries/canary.js +0 -30
  175. package/dist/aws/infra/scheduler.js +0 -31
  176. package/dist/aws/infra/stack/stack.js +0 -67
  177. package/dist/aws/infra/stacks/db-dns-stack.js +0 -64
  178. package/dist/aws/infra/stacks/db-proxy-stack.js +0 -77
  179. package/dist/aws/infra/stacks/intra-stack-configuration.js +0 -3
  180. package/dist/aws/infra/stacks/network-stack.js +0 -44
  181. package/dist/aws/runtime/apikey.js +0 -13
  182. package/dist/aws/runtime/digitraffic-integration-response.js +0 -28
  183. package/dist/aws/runtime/dt-logger-default.js +0 -9
  184. package/dist/aws/runtime/secrets/proxy-holder.js +0 -28
  185. package/dist/aws/runtime/secrets/rds-holder.js +0 -28
  186. package/dist/aws/types/errors.js +0 -16
  187. package/dist/aws/types/model-with-reference.js +0 -3
  188. package/dist/aws/types/proxytypes.js +0 -3
  189. package/dist/aws/types/tags.js +0 -7
  190. package/dist/database/models.js +0 -3
  191. package/dist/marine/rtz.js +0 -3
  192. package/dist/test/db-testutils.js +0 -34
  193. package/dist/test/secrets-manager.js +0 -62
  194. package/dist/test/testutils.js +0 -44
  195. package/dist/types/async-timeout-error.js +0 -10
  196. package/dist/types/aws-env.js +0 -3
  197. package/dist/types/either.js +0 -3
  198. package/dist/types/http-error.js +0 -11
  199. package/dist/types/input-error.js +0 -7
  200. package/dist/types/language.js +0 -10
  201. package/dist/types/nullable.js +0 -3
  202. package/dist/types/urn.js +0 -3
  203. package/dist/types/util-types.js +0 -3
  204. package/dist/types/validator.js +0 -14
  205. package/dist/utils/base64.js +0 -21
  206. package/dist/utils/date-utils.js +0 -51
  207. package/dist/utils/geojson-types.js +0 -18
  208. package/dist/utils/slack.js +0 -30
  209. /package/dist/aws/infra/canaries/{canary-keys.d.ts → canary-keys.d.mts} +0 -0
  210. /package/dist/aws/infra/canaries/{canary-parameters.d.ts → canary-parameters.d.mts} +0 -0
  211. /package/dist/aws/infra/canaries/{canary-role.d.ts → canary-role.d.mts} +0 -0
  212. /package/dist/aws/infra/{documentation.d.ts → documentation.d.mts} +0 -0
  213. /package/dist/aws/infra/{import-util.d.ts → import-util.d.mts} +0 -0
  214. /package/dist/aws/infra/{scheduler.d.ts → scheduler.d.mts} +0 -0
  215. /package/dist/aws/infra/{security-rule.d.ts → security-rule.d.mts} +0 -0
  216. /package/dist/aws/infra/stacks/{intra-stack-configuration.d.ts → intra-stack-configuration.d.mts} +0 -0
  217. /package/dist/aws/infra/{usage-plans.d.ts → usage-plans.d.mts} +0 -0
  218. /package/dist/aws/runtime/{apikey.d.ts → apikey.d.mts} +0 -0
  219. /package/dist/aws/runtime/{environment.d.ts → environment.d.mts} +0 -0
  220. /package/dist/aws/runtime/{messaging.d.ts → messaging.d.mts} +0 -0
  221. /package/dist/aws/runtime/{s3.d.ts → s3.d.mts} +0 -0
  222. /package/dist/aws/runtime/secrets/{proxy-holder.d.ts → proxy-holder.d.mts} +0 -0
  223. /package/dist/aws/runtime/secrets/{rds-holder.d.ts → rds-holder.d.mts} +0 -0
  224. /package/dist/aws/runtime/secrets/{secret.d.ts → secret.d.mts} +0 -0
  225. /package/dist/aws/types/{errors.d.ts → errors.d.mts} +0 -0
  226. /package/dist/aws/types/{lambda-response.d.ts → lambda-response.d.mts} +0 -0
  227. /package/dist/aws/types/{mediatypes.d.ts → mediatypes.d.mts} +0 -0
  228. /package/dist/aws/types/{model-with-reference.d.ts → model-with-reference.d.mts} +0 -0
  229. /package/dist/aws/types/{proxytypes.d.ts → proxytypes.d.mts} +0 -0
  230. /package/dist/aws/types/{tags.d.ts → tags.d.mts} +0 -0
  231. /package/dist/database/{models.d.ts → models.d.mts} +0 -0
  232. /package/dist/marine/{id_utils.d.ts → id_utils.d.mts} +0 -0
  233. /package/dist/marine/{rtz.d.ts → rtz.d.mts} +0 -0
  234. /package/dist/test/{asserter.d.ts → asserter.d.mts} +0 -0
  235. /package/dist/test/{httpserver.d.ts → httpserver.d.mts} +0 -0
  236. /package/dist/test/{secrets-manager.d.ts → secrets-manager.d.mts} +0 -0
  237. /package/dist/test/{testutils.d.ts → testutils.d.mts} +0 -0
  238. /package/dist/types/{async-timeout-error.d.ts → async-timeout-error.d.mts} +0 -0
  239. /package/dist/types/{aws-env.d.ts → aws-env.d.mts} +0 -0
  240. /package/dist/types/{either.d.ts → either.d.mts} +0 -0
  241. /package/dist/types/{http-error.d.ts → http-error.d.mts} +0 -0
  242. /package/dist/types/{input-error.d.ts → input-error.d.mts} +0 -0
  243. /package/dist/types/{language.d.ts → language.d.mts} +0 -0
  244. /package/dist/types/{traffictype.d.ts → traffictype.d.mts} +0 -0
  245. /package/dist/types/{urn.d.ts → urn.d.mts} +0 -0
  246. /package/dist/types/{util-types.d.ts → util-types.d.mts} +0 -0
  247. /package/dist/types/{validator.d.ts → validator.d.mts} +0 -0
  248. /package/dist/utils/{date-utils.d.ts → date-utils.d.mts} +0 -0
  249. /package/dist/utils/{geojson-types.d.ts → geojson-types.d.mts} +0 -0
  250. /package/dist/utils/{geometry.d.ts → geometry.d.mts} +0 -0
  251. /package/dist/utils/{retry.d.ts → retry.d.mts} +0 -0
  252. /package/dist/utils/{slack.d.ts → slack.d.mts} +0 -0
  253. /package/src/@types/geojson-validation/{index.d.ts → index.d.mts} +0 -0
  254. /package/src/aws/infra/canaries/{canary-keys.ts → canary-keys.mts} +0 -0
  255. /package/src/aws/infra/canaries/{canary-parameters.ts → canary-parameters.mts} +0 -0
  256. /package/src/aws/infra/canaries/{canary-role.ts → canary-role.mts} +0 -0
  257. /package/src/aws/infra/{documentation.ts → documentation.mts} +0 -0
  258. /package/src/aws/infra/{import-util.ts → import-util.mts} +0 -0
  259. /package/src/aws/infra/{scheduler.ts → scheduler.mts} +0 -0
  260. /package/src/aws/infra/{security-rule.ts → security-rule.mts} +0 -0
  261. /package/src/aws/infra/stacks/{intra-stack-configuration.ts → intra-stack-configuration.mts} +0 -0
  262. /package/src/aws/infra/{usage-plans.ts → usage-plans.mts} +0 -0
  263. /package/src/aws/runtime/{apikey.ts → apikey.mts} +0 -0
  264. /package/src/aws/runtime/{dt-logger.ts → dt-logger.mts} +0 -0
  265. /package/src/aws/runtime/{environment.ts → environment.mts} +0 -0
  266. /package/src/aws/runtime/{messaging.ts → messaging.mts} +0 -0
  267. /package/src/aws/runtime/{s3.ts → s3.mts} +0 -0
  268. /package/src/aws/types/{errors.ts → errors.mts} +0 -0
  269. /package/src/aws/types/{lambda-response.ts → lambda-response.mts} +0 -0
  270. /package/src/aws/types/{mediatypes.ts → mediatypes.mts} +0 -0
  271. /package/src/aws/types/{model-with-reference.ts → model-with-reference.mts} +0 -0
  272. /package/src/aws/types/{proxytypes.ts → proxytypes.mts} +0 -0
  273. /package/src/aws/types/{tags.ts → tags.mts} +0 -0
  274. /package/src/database/{models.ts → models.mts} +0 -0
  275. /package/src/marine/{id_utils.ts → id_utils.mts} +0 -0
  276. /package/src/marine/{rtz.ts → rtz.mts} +0 -0
  277. /package/src/test/{asserter.ts → asserter.mts} +0 -0
  278. /package/src/test/{httpserver.ts → httpserver.mts} +0 -0
  279. /package/src/test/{testutils.ts → testutils.mts} +0 -0
  280. /package/src/types/{async-timeout-error.ts → async-timeout-error.mts} +0 -0
  281. /package/src/types/{aws-env.ts → aws-env.mts} +0 -0
  282. /package/src/types/{either.ts → either.mts} +0 -0
  283. /package/src/types/{http-error.ts → http-error.mts} +0 -0
  284. /package/src/types/{input-error.ts → input-error.mts} +0 -0
  285. /package/src/types/{language.ts → language.mts} +0 -0
  286. /package/src/types/{traffictype.ts → traffictype.mts} +0 -0
  287. /package/src/types/{urn.ts → urn.mts} +0 -0
  288. /package/src/types/{util-types.ts → util-types.mts} +0 -0
  289. /package/src/types/{validator.ts → validator.mts} +0 -0
  290. /package/src/utils/{base64.ts → base64.mts} +0 -0
  291. /package/src/utils/{date-utils.ts → date-utils.mts} +0 -0
  292. /package/src/utils/{geojson-types.ts → geojson-types.mts} +0 -0
@@ -0,0 +1,44 @@
1
+ import { formatInTimeZone } from "date-fns-tz";
2
+ /**
3
+ * Constant for the 1970-01-01T00:00:00Z epoch Date.
4
+ */
5
+ export const EPOCH = new Date(Date.UTC(1970, 0, 1));
6
+ export const UTC = "UTC";
7
+ export const MYSQL_DATETIME_FORMAT = "yyyy-MM-dd HH:mm";
8
+ /**
9
+ * Counts difference in milliseconds between dates.
10
+ * @param start
11
+ * @param end
12
+ */
13
+ export function countDiffMs(start, end) {
14
+ return end.getTime() - start.getTime();
15
+ }
16
+ /**
17
+ * Counts difference in seconds between dates.
18
+ * @param start
19
+ * @param end
20
+ */
21
+ export function countDiffInSeconds(start, end) {
22
+ return countDiffMs(start, end) / 1000;
23
+ }
24
+ /**
25
+ * Converts ISO 8601 date-time -string to Date object
26
+ * @param isoString to convert
27
+ */
28
+ export function dateFromIsoString(isoString) {
29
+ const parsed = new Date(isoString);
30
+ if (!isValidDate(parsed)) {
31
+ throw new Error(`Could not parse iso date-time string: "${isoString}" to date`);
32
+ }
33
+ return parsed;
34
+ }
35
+ function isValidDate(d) {
36
+ return d instanceof Date && !isNaN(d.getTime());
37
+ }
38
+ /**
39
+ * Formats a date in UTC in the given format, regardless of system time zone
40
+ */
41
+ export function dateToUTCString(date, format) {
42
+ return formatInTimeZone(date, UTC, format);
43
+ }
44
+ //# sourceMappingURL=date-utils.mjs.map
@@ -0,0 +1,13 @@
1
+ export class GeoJsonPoint {
2
+ constructor(coordinates) {
3
+ this.type = "Point";
4
+ this.coordinates = coordinates;
5
+ }
6
+ }
7
+ export class GeoJsonLineString {
8
+ constructor(coordinates) {
9
+ this.type = "LineString";
10
+ this.coordinates = coordinates;
11
+ }
12
+ }
13
+ //# sourceMappingURL=geojson-types.mjs.map
@@ -1,37 +1,11 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.positionToList = exports.createGmlLineString = exports.distanceBetweenPositionsInM = exports.areDistinctPositions = exports.distanceBetweenPositionsInKm = exports.isFeatureCollection = exports.isValidGeoJson = exports.createFeatureCollection = exports.createGeometry = exports.SRID_WGS84 = void 0;
27
- const geoJsonValidator = __importStar(require("geojson-validation"));
28
- const dt_logger_default_1 = require("../aws/runtime/dt-logger-default");
29
- exports.SRID_WGS84 = 4326;
1
+ import * as geoJsonValidator from "geojson-validation";
2
+ import { logger } from "../aws/runtime/dt-logger-default.mjs";
3
+ export const SRID_WGS84 = 4326;
30
4
  /**
31
5
  * Creates WKT geometry from GeoJSON geometry
32
6
  * @param geometry GeoJson geometry to convert to WKT
33
7
  */
34
- function createGeometry(geometry) {
8
+ export function createGeometry(geometry) {
35
9
  if (geometry.type === "LineString") {
36
10
  const coordinates = linestring(geometry.coordinates);
37
11
  return `LINESTRING(${coordinates})`;
@@ -48,13 +22,12 @@ function createGeometry(geometry) {
48
22
  const coordinates = multiPolygon(geometry.coordinates);
49
23
  return `MULTIPOLYGON(${coordinates})`;
50
24
  }
51
- dt_logger_default_1.logger.error({
25
+ logger.error({
52
26
  method: "Geometry.createGeometry",
53
27
  message: "Unsupported locationType " + geometry.type,
54
28
  });
55
29
  return "POLYGON EMPTY";
56
30
  }
57
- exports.createGeometry = createGeometry;
58
31
  function linestring(coordinates) {
59
32
  return coordinates.map((c) => coordinatePair(c)).join(",");
60
33
  }
@@ -74,22 +47,21 @@ function coordinatePair(coordinate) {
74
47
  * @param features List of Features
75
48
  * @param lastUpdated Last updated date
76
49
  */
77
- function createFeatureCollection(features, lastUpdated) {
50
+ export function createFeatureCollection(features, lastUpdated) {
78
51
  return {
79
52
  type: "FeatureCollection",
80
53
  lastUpdated: lastUpdated,
81
54
  features: features,
82
55
  };
83
56
  }
84
- exports.createFeatureCollection = createFeatureCollection;
85
- function isValidGeoJson(json) {
57
+ export function isValidGeoJson(json) {
58
+ // Tests complain about this method returning type string[] which is obviously wrong. Therefore, this casting.
86
59
  return geoJsonValidator.valid(json);
87
60
  }
88
- exports.isValidGeoJson = isValidGeoJson;
89
- function isFeatureCollection(json) {
61
+ export function isFeatureCollection(json) {
62
+ // Tests complain about this method returning type string[] which is obviously wrong. Therefore, this casting.
90
63
  return geoJsonValidator.isFeatureCollection(json);
91
64
  }
92
- exports.isFeatureCollection = isFeatureCollection;
93
65
  const DEGREES_TO_RADIANS = 0.017453292519943295; // = Math.PI / 180
94
66
  const EARTH_RADIUS_KM = 6371;
95
67
  /**
@@ -114,31 +86,27 @@ function distanceBetweenWGS84PointsInKm(fromXLon, fromYLat, toXLon, toYLat) {
114
86
  * @param pos1
115
87
  * @param pos2
116
88
  */
117
- function distanceBetweenPositionsInKm(pos1, pos2) {
89
+ export function distanceBetweenPositionsInKm(pos1, pos2) {
118
90
  return distanceBetweenWGS84PointsInKm(pos1[0], pos1[1], pos2[0], pos2[1]);
119
91
  }
120
- exports.distanceBetweenPositionsInKm = distanceBetweenPositionsInKm;
121
- function areDistinctPositions(previous, next) {
92
+ export function areDistinctPositions(previous, next) {
122
93
  return previous[0] !== next[0] || previous[1] !== next[1];
123
94
  }
124
- exports.areDistinctPositions = areDistinctPositions;
125
95
  /**
126
96
  * Calculates distance between two GeoJSON points (WGS84)
127
97
  * @param pos1
128
98
  * @param pos2
129
99
  */
130
- function distanceBetweenPositionsInM(pos1, pos2) {
100
+ export function distanceBetweenPositionsInM(pos1, pos2) {
131
101
  return distanceBetweenPositionsInKm(pos1, pos2) * 1000; // km -> m
132
102
  }
133
- exports.distanceBetweenPositionsInM = distanceBetweenPositionsInM;
134
- function createGmlLineString(geometry, srsName = "EPSG:4326") {
103
+ export function createGmlLineString(geometry, srsName = "EPSG:4326") {
135
104
  const posList = createPosList(geometry);
136
105
  return {
137
106
  srsName,
138
107
  posList,
139
108
  };
140
109
  }
141
- exports.createGmlLineString = createGmlLineString;
142
110
  function createPosList(geometry) {
143
111
  if (geometry.type === "Point") {
144
112
  return positionToList(geometry.coordinates);
@@ -157,12 +125,11 @@ function polygonToList(positions, precision = 8) {
157
125
  function lineStringToList(positions, precision = 8) {
158
126
  return positions.map((p) => positionToList(p, precision)).join(" ");
159
127
  }
160
- function positionToList(position, precision = 8) {
128
+ export function positionToList(position, precision = 8) {
161
129
  return position.map((n) => n.toPrecision(precision)).join(" ");
162
130
  }
163
- exports.positionToList = positionToList;
164
131
  // Converts numeric degrees to radians
165
132
  function toRadians(angdeg) {
166
133
  return angdeg * DEGREES_TO_RADIANS;
167
134
  }
168
- //# sourceMappingURL=geometry.js.map
135
+ //# sourceMappingURL=geometry.mjs.map
@@ -1,4 +1,4 @@
1
- import { DtLogger } from "../aws/runtime/dt-logger";
1
+ import { DtLogger } from "../aws/runtime/dt-logger.mjs";
2
2
  /**
3
3
  * Curried version of logException.
4
4
  *
@@ -1,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.logException = exports.createExceptionLogger = void 0;
4
- const axios_1 = require("axios");
5
- const dt_logger_1 = require("../aws/runtime/dt-logger");
6
- const utils_1 = require("./utils");
7
- const functionName = (0, utils_1.getEnvVariableOrElse)("AWS_LAMBDA_FUNCTION_NAME", "test");
1
+ import { AxiosError } from "axios";
2
+ import { DtLogger } from "../aws/runtime/dt-logger.mjs";
3
+ import { getEnvVariableOrElse } from "./utils.mjs";
4
+ const functionName = getEnvVariableOrElse("AWS_LAMBDA_FUNCTION_NAME", "test");
8
5
  /**
9
6
  * Curried version of logException.
10
7
  *
@@ -21,19 +18,18 @@ const functionName = (0, utils_1.getEnvVariableOrElse)("AWS_LAMBDA_FUNCTION_NAME
21
18
  * @returns Logs the error without rethrowing.
22
19
  * @see {@link logException}
23
20
  */
24
- function createExceptionLogger(logger = undefined, includeStack = false) {
21
+ export function createExceptionLogger(logger = undefined, includeStack = false) {
25
22
  let thatLogger;
26
23
  if (logger) {
27
24
  thatLogger = logger;
28
25
  }
29
26
  else {
30
- thatLogger = new dt_logger_1.DtLogger();
27
+ thatLogger = new DtLogger();
31
28
  }
32
29
  return (error) => {
33
30
  logException(thatLogger, error, includeStack);
34
31
  };
35
32
  }
36
- exports.createExceptionLogger = createExceptionLogger;
37
33
  /**
38
34
  * Log given exception with level ERROR to given logger.
39
35
  *
@@ -46,14 +42,14 @@ exports.createExceptionLogger = createExceptionLogger;
46
42
  * @see {@link DtLogger.log}
47
43
  * @see {@link createExceptionLogger} for a curried setup
48
44
  */
49
- function logException(logger, error, includeStack = false) {
45
+ export function logException(logger, error, includeStack = false) {
50
46
  const message = error instanceof Error
51
47
  ? error.message
52
48
  : typeof error === "string"
53
49
  ? error
54
50
  : JSON.stringify(error);
55
51
  const stack = error instanceof Error && includeStack ? error.stack : undefined;
56
- const customCode = error instanceof axios_1.AxiosError ? error.code : undefined;
52
+ const customCode = error instanceof AxiosError ? error.code : undefined;
57
53
  logger.error({
58
54
  type: "Error",
59
55
  method: `${functionName}.logException`,
@@ -62,5 +58,4 @@ function logException(logger, error, includeStack = false) {
62
58
  stack,
63
59
  });
64
60
  }
65
- exports.logException = logException;
66
- //# sourceMappingURL=logging.js.map
61
+ //# sourceMappingURL=logging.mjs.map
@@ -1,19 +1,16 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.retryRequest = exports.retry = exports.retryCount = exports.retryPredicates = exports.timeoutFunctions = exports.RetryLogError = void 0;
4
- const http_error_1 = require("../types/http-error");
5
- const async_timeout_error_1 = require("../types/async-timeout-error");
6
- const dt_logger_default_1 = require("../aws/runtime/dt-logger-default");
7
- var RetryLogError;
1
+ import { HttpError } from "../types/http-error.mjs";
2
+ import { AsyncTimeoutError } from "../types/async-timeout-error.mjs";
3
+ import { logger } from "../aws/runtime/dt-logger-default.mjs";
4
+ export var RetryLogError;
8
5
  (function (RetryLogError) {
9
6
  RetryLogError[RetryLogError["LOG_ALL_AS_ERRORS"] = 0] = "LOG_ALL_AS_ERRORS";
10
7
  RetryLogError[RetryLogError["LOG_LAST_RETRY_AS_ERROR_OTHERS_AS_WARNS"] = 1] = "LOG_LAST_RETRY_AS_ERROR_OTHERS_AS_WARNS";
11
8
  RetryLogError[RetryLogError["NO_LOGGING"] = 2] = "NO_LOGGING";
12
- })(RetryLogError || (exports.RetryLogError = RetryLogError = {}));
9
+ })(RetryLogError || (RetryLogError = {}));
13
10
  /**
14
11
  * Utility timeout functions for "retry" function.
15
12
  */
16
- exports.timeoutFunctions = (function () {
13
+ export const timeoutFunctions = (function () {
17
14
  return {
18
15
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
19
16
  noTimeout: (retryCount) => {
@@ -27,7 +24,7 @@ exports.timeoutFunctions = (function () {
27
24
  /**
28
25
  * Utility retry predicates for "retry" function.
29
26
  */
30
- exports.retryPredicates = (function () {
27
+ export const retryPredicates = (function () {
31
28
  const retryStatusCodes = new Set([
32
29
  // service might return 403 for no apparent reason
33
30
  403,
@@ -36,7 +33,7 @@ exports.retryPredicates = (function () {
36
33
  ]);
37
34
  return {
38
35
  retryBasedOnStatusCode: (error) => {
39
- if (error instanceof http_error_1.HttpError) {
36
+ if (error instanceof HttpError) {
40
37
  return retryStatusCodes.has(error.statusCode);
41
38
  }
42
39
  return false;
@@ -54,7 +51,7 @@ function readPossibleErrorMessage(error) {
54
51
  return "Something else than an Error object was thrown";
55
52
  }
56
53
  // Tämä muuttuja on testejä varten määritelty täällä.
57
- exports.retryCount = 0;
54
+ export let retryCount = 0;
58
55
  async function retryRecursive(asyncFn, retries, retryCountInj, logError, timeoutBetweenRetries, retryPredicate) {
59
56
  const asyncFnTimeout = 30 * 60 * 1000; // 30 minutes
60
57
  if (!isFinite(retries)) {
@@ -68,46 +65,46 @@ async function retryRecursive(asyncFn, retries, retryCountInj, logError, timeout
68
65
  // then the rest of async/await pairs will be called even though AysncTimeoutError is allready thrown.
69
66
  const result = await Promise.race([
70
67
  asyncFn(),
71
- new Promise((_, reject) => setTimeout(() => reject(new async_timeout_error_1.AsyncTimeoutError()), asyncFnTimeout)),
68
+ new Promise((_, reject) => setTimeout(() => reject(new AsyncTimeoutError()), asyncFnTimeout)),
72
69
  ]);
73
70
  return result;
74
71
  }
75
72
  catch (error) {
76
73
  const remainingRetries = retries - 1;
77
74
  if (logError === RetryLogError.LOG_ALL_AS_ERRORS) {
78
- dt_logger_default_1.logger.error({
75
+ logger.error({
79
76
  message: readPossibleErrorMessage(error),
80
77
  method: "retry.retryRecursive",
81
78
  });
82
79
  }
83
80
  else if (logError === RetryLogError.LOG_LAST_RETRY_AS_ERROR_OTHERS_AS_WARNS) {
84
81
  if (remainingRetries < 0) {
85
- dt_logger_default_1.logger.error({
82
+ logger.error({
86
83
  message: readPossibleErrorMessage(error),
87
84
  method: "retry.retryRecursive",
88
85
  });
89
86
  }
90
87
  else {
91
- dt_logger_default_1.logger.warn({
88
+ logger.warn({
92
89
  message: readPossibleErrorMessage(error),
93
90
  method: "retry.retryRecursive",
94
91
  });
95
92
  }
96
93
  }
97
94
  if (remainingRetries < 0) {
98
- dt_logger_default_1.logger.warn({
95
+ logger.warn({
99
96
  message: "No retries left",
100
97
  method: "retry.retryRecursive",
101
98
  });
102
99
  throw new Error("No retries left");
103
100
  }
104
- dt_logger_default_1.logger.warn({
101
+ logger.warn({
105
102
  message: `Retrying with remaining retries ${remainingRetries}`,
106
103
  method: "retry.retryRecursive",
107
104
  });
108
105
  if (retryPredicate(error)) {
109
106
  retryCountInj++;
110
- exports.retryCount = retryCountInj;
107
+ retryCount = retryCountInj;
111
108
  const milliseconds = timeoutBetweenRetries(retryCountInj);
112
109
  if (milliseconds > 0) {
113
110
  await new Promise((resolve) => setTimeout(resolve, milliseconds));
@@ -128,21 +125,19 @@ async function retryRecursive(asyncFn, retries, retryCountInj, logError, timeout
128
125
  * @param retryPredicate A function that returns true if the error should be retried. Default is a function that always returns true. The function is called with the error object.
129
126
  * @return Promise return value
130
127
  */
131
- async function retry(asyncFn, retries = 3, logError = RetryLogError.LOG_LAST_RETRY_AS_ERROR_OTHERS_AS_WARNS, timeoutBetweenRetries = exports.timeoutFunctions.noTimeout, retryPredicate = exports.retryPredicates.alwaysRetry) {
132
- exports.retryCount = 0;
133
- dt_logger_default_1.logger.debug({
128
+ export async function retry(asyncFn, retries = 3, logError = RetryLogError.LOG_LAST_RETRY_AS_ERROR_OTHERS_AS_WARNS, timeoutBetweenRetries = timeoutFunctions.noTimeout, retryPredicate = retryPredicates.alwaysRetry) {
129
+ retryCount = 0;
130
+ logger.debug({
134
131
  message: `Retrying with ${retries} retries`,
135
132
  method: "retry.retry",
136
133
  });
137
134
  return retryRecursive(asyncFn, retries, 0, logError, timeoutBetweenRetries, retryPredicate);
138
135
  }
139
- exports.retry = retry;
140
136
  function wrapArgsToFn(fn, ...args) {
141
137
  return async () => await fn(...args);
142
138
  }
143
- async function retryRequest(request, ...args) {
139
+ export async function retryRequest(request, ...args) {
144
140
  const asyncFn = wrapArgsToFn(request, ...args);
145
- return retry(asyncFn, 5, RetryLogError.LOG_LAST_RETRY_AS_ERROR_OTHERS_AS_WARNS, exports.timeoutFunctions.exponentialTimeout, exports.retryPredicates.retryBasedOnStatusCode);
141
+ return retry(asyncFn, 5, RetryLogError.LOG_LAST_RETRY_AS_ERROR_OTHERS_AS_WARNS, timeoutFunctions.exponentialTimeout, retryPredicates.retryBasedOnStatusCode);
146
142
  }
147
- exports.retryRequest = retryRequest;
148
- //# sourceMappingURL=retry.js.map
143
+ //# sourceMappingURL=retry.mjs.map
@@ -0,0 +1,23 @@
1
+ import axios from "axios";
2
+ import { logger } from "../aws/runtime/dt-logger-default.mjs";
3
+ import { logException } from "./logging.mjs";
4
+ export class SlackApi {
5
+ constructor(url) {
6
+ this.url = url;
7
+ }
8
+ async notify(text) {
9
+ try {
10
+ logger.info({
11
+ method: "SlackApi.notify",
12
+ message: "Sending slack notification",
13
+ });
14
+ await axios.post(this.url, {
15
+ text,
16
+ });
17
+ }
18
+ catch (error) {
19
+ logException(logger, error);
20
+ }
21
+ }
22
+ }
23
+ //# sourceMappingURL=slack.mjs.map
@@ -1,5 +1,5 @@
1
- import { AwsEnv } from "../types/aws-env";
2
- import { Either } from "../types/either";
1
+ import { AwsEnv } from "../types/aws-env.mjs";
2
+ import { Either } from "../types/either.mjs";
3
3
  /**
4
4
  * Check if arrays have only elements that also exists also in other array.
5
5
  * Individual element count doesn't matter.
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getErrorMessage = exports.hasOwnPropertySafe = exports.setSecretOverideAwsRegionEnv = exports.getEnvVariableOrElse = exports.getEnvVariableOr = exports.setEnvVariable = exports.getEnvVariableSafe = exports.getEnvVariable = exports.getAwsEnv = exports.getFirst = exports.getLast = exports.bothArraysHasSameValues = void 0;
4
- const environment_1 = require("../aws/runtime/environment");
1
+ import { EnvKeys } from "../aws/runtime/environment.mjs";
5
2
  /**
6
3
  * Check if arrays have only elements that also exists also in other array.
7
4
  * Individual element count doesn't matter.
@@ -23,7 +20,7 @@ const environment_1 = require("../aws/runtime/environment");
23
20
  * @param a first array to compare
24
21
  * @param b second array to compare
25
22
  */
26
- function bothArraysHasSameValues(a, b) {
23
+ export function bothArraysHasSameValues(a, b) {
27
24
  if ((a && !b) || (!a && b)) {
28
25
  return false;
29
26
  }
@@ -37,21 +34,18 @@ function bothArraysHasSameValues(a, b) {
37
34
  }
38
35
  return Array.from(aSet).every((value) => bSet.has(value));
39
36
  }
40
- exports.bothArraysHasSameValues = bothArraysHasSameValues;
41
37
  /**
42
38
  * Returns the last item on the array. If the array is empty, throws an error!
43
39
  */
44
- function getLast(array, sortFunction) {
40
+ export function getLast(array, sortFunction) {
45
41
  return getFirstOrLast(false, array, sortFunction);
46
42
  }
47
- exports.getLast = getLast;
48
43
  /**
49
44
  * Returns the first item on the array. If the array is empty, throws an error!
50
45
  */
51
- function getFirst(array, sortFunction) {
46
+ export function getFirst(array, sortFunction) {
52
47
  return getFirstOrLast(true, array, sortFunction);
53
48
  }
54
- exports.getFirst = getFirst;
55
49
  function getFirstOrLast(getFirst, array, sortFunction) {
56
50
  if (array.length == 0) {
57
51
  throw new Error(`can't get ${getFirst ? "first" : "last"} from empty array!`);
@@ -69,26 +63,24 @@ function getFirstOrLast(getFirst, array, sortFunction) {
69
63
  * @return string
70
64
  * @See https://docs.aws.amazon.com/lambda/latest/dg/configuration-envvars.html
71
65
  */
72
- function getAwsEnv() {
66
+ export function getAwsEnv() {
73
67
  return {
74
68
  region: getEnvVariable("AWS_REGION"),
75
69
  };
76
70
  }
77
- exports.getAwsEnv = getAwsEnv;
78
71
  /**
79
72
  * Gets environment variable. Throws error if variable is not found.
80
73
  *
81
74
  * @param key Environment key
82
75
  * @return string
83
76
  */
84
- function getEnvVariable(key) {
77
+ export function getEnvVariable(key) {
85
78
  const either = getEnvVariableSafe(key);
86
79
  if (either.result === "error") {
87
80
  throw new Error(either.message);
88
81
  }
89
82
  return either.value;
90
83
  }
91
- exports.getEnvVariable = getEnvVariable;
92
84
  /**
93
85
  * Gets environment variable. Safe version returns object with either ok or error status.
94
86
  * Easier to use for recovery than catching an error.
@@ -96,7 +88,7 @@ exports.getEnvVariable = getEnvVariable;
96
88
  * @param key Environment key
97
89
  * @return Either<string>
98
90
  */
99
- function getEnvVariableSafe(key) {
91
+ export function getEnvVariableSafe(key) {
100
92
  const value = process.env[key];
101
93
  if (value === undefined) {
102
94
  return {
@@ -106,31 +98,28 @@ function getEnvVariableSafe(key) {
106
98
  }
107
99
  return { result: "ok", value };
108
100
  }
109
- exports.getEnvVariableSafe = getEnvVariableSafe;
110
101
  /**
111
102
  * Sets environment variable.
112
103
  *
113
104
  * @param key Environment key
114
105
  * @param value Environment variable value
115
106
  */
116
- function setEnvVariable(key, value) {
107
+ export function setEnvVariable(key, value) {
117
108
  process.env[key] = value;
118
109
  }
119
- exports.setEnvVariable = setEnvVariable;
120
110
  /**
121
111
  * Gets environment variable. If environment variable is undefined, returns value of given function.
122
112
  *
123
113
  * @param key Environment key
124
114
  * @param fn Alternative function
125
115
  */
126
- function getEnvVariableOr(key, fn) {
116
+ export function getEnvVariableOr(key, fn) {
127
117
  const either = getEnvVariableSafe(key);
128
118
  if (either.result === "ok") {
129
119
  return either.value;
130
120
  }
131
121
  return fn();
132
122
  }
133
- exports.getEnvVariableOr = getEnvVariableOr;
134
123
  /**
135
124
  * Gets environment variable. If environment variable is undefined, returns given value.
136
125
  * Use to return an explicit alternative value e.g. in cases where environment variable may be undefined.
@@ -138,14 +127,12 @@ exports.getEnvVariableOr = getEnvVariableOr;
138
127
  * @param key Environment key
139
128
  * @param orElse Alternative value
140
129
  */
141
- function getEnvVariableOrElse(key, orElse) {
130
+ export function getEnvVariableOrElse(key, orElse) {
142
131
  return getEnvVariableOr(key, () => orElse);
143
132
  }
144
- exports.getEnvVariableOrElse = getEnvVariableOrElse;
145
- function setSecretOverideAwsRegionEnv(region) {
146
- setEnvVariable(environment_1.EnvKeys.SECRET_OVERRIDE_AWS_REGION, region);
133
+ export function setSecretOverideAwsRegionEnv(region) {
134
+ setEnvVariable(EnvKeys.SECRET_OVERRIDE_AWS_REGION, region);
147
135
  }
148
- exports.setSecretOverideAwsRegionEnv = setSecretOverideAwsRegionEnv;
149
136
  /**
150
137
  * ESLint won't allow to call Object.prototype builtin methods.
151
138
  * To call hasOwnProperty we must use Object.prototype.hasOwnProperty.call()
@@ -153,19 +140,17 @@ exports.setSecretOverideAwsRegionEnv = setSecretOverideAwsRegionEnv;
153
140
  * @param propertyName property name to check
154
141
  * @see https://eslint.org/docs/latest/rules/no-prototype-builtins
155
142
  */
156
- function hasOwnPropertySafe(object, propertyName) {
143
+ export function hasOwnPropertySafe(object, propertyName) {
157
144
  return Object.prototype.hasOwnProperty.call(object, propertyName);
158
145
  }
159
- exports.hasOwnPropertySafe = hasOwnPropertySafe;
160
146
  /**
161
147
  * Return an error message from the given object hat might be an Error object.
162
148
  * @param maybeError
163
149
  */
164
- function getErrorMessage(maybeError) {
150
+ export function getErrorMessage(maybeError) {
165
151
  if (maybeError instanceof Error) {
166
152
  return maybeError.name + ": " + maybeError.message;
167
153
  }
168
154
  return String(maybeError);
169
155
  }
170
- exports.getErrorMessage = getErrorMessage;
171
- //# sourceMappingURL=utils.js.map
156
+ //# sourceMappingURL=utils.mjs.map