@digitraffic/common 2024.3.22-2 → 2024.4.4-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.
@@ -3,321 +3,317 @@ test("index import ok?", () => {
3
3
  const index = import("../index.mjs");
4
4
  return expect(index).resolves.toBeDefined();
5
5
  });
6
- test('database import ok?', () => {
6
+ test("database import ok?", () => {
7
7
  const database = import("../database/database.mjs");
8
8
  return expect(database).resolves.toBeDefined();
9
9
  });
10
- test('cached import ok?', () => {
10
+ test("cached import ok?", () => {
11
11
  const cached = import("../database/cached.mjs");
12
12
  return expect(cached).resolves.toBeDefined();
13
13
  });
14
- test('models import ok?', () => {
14
+ test("models import ok?", () => {
15
15
  const models = import("../database/models.mjs");
16
16
  return expect(models).resolves.toBeDefined();
17
17
  });
18
- test('lastUpdated import ok?', () => {
18
+ test("lastUpdated import ok?", () => {
19
19
  const lastUpdated = import("../database/last-updated.mjs");
20
20
  return expect(lastUpdated).resolves.toBeDefined();
21
21
  });
22
- test('urn import ok?', () => {
22
+ test("urn import ok?", () => {
23
23
  const urn = import("../types/urn.mjs");
24
24
  return expect(urn).resolves.toBeDefined();
25
25
  });
26
- test('utilTypes import ok?', () => {
26
+ test("utilTypes import ok?", () => {
27
27
  const utilTypes = import("../types/util-types.mjs");
28
28
  return expect(utilTypes).resolves.toBeDefined();
29
29
  });
30
- test('either import ok?', () => {
30
+ test("either import ok?", () => {
31
31
  const either = import("../types/either.mjs");
32
32
  return expect(either).resolves.toBeDefined();
33
33
  });
34
- test('validator import ok?', () => {
34
+ test("validator import ok?", () => {
35
35
  const validator = import("../types/validator.mjs");
36
36
  return expect(validator).resolves.toBeDefined();
37
37
  });
38
- test('nullable import ok?', () => {
38
+ test("nullable import ok?", () => {
39
39
  const nullable = import("../types/nullable.mjs");
40
40
  return expect(nullable).resolves.toBeDefined();
41
41
  });
42
- test('awsEnv import ok?', () => {
42
+ test("awsEnv import ok?", () => {
43
43
  const awsEnv = import("../types/aws-env.mjs");
44
44
  return expect(awsEnv).resolves.toBeDefined();
45
45
  });
46
- test('asyncTimeoutError import ok?', () => {
46
+ test("asyncTimeoutError import ok?", () => {
47
47
  const asyncTimeoutError = import("../types/async-timeout-error.mjs");
48
48
  return expect(asyncTimeoutError).resolves.toBeDefined();
49
49
  });
50
- test('inputError import ok?', () => {
50
+ test("inputError import ok?", () => {
51
51
  const inputError = import("../types/input-error.mjs");
52
52
  return expect(inputError).resolves.toBeDefined();
53
53
  });
54
- test('httpError import ok?', () => {
54
+ test("httpError import ok?", () => {
55
55
  const httpError = import("../types/http-error.mjs");
56
56
  return expect(httpError).resolves.toBeDefined();
57
57
  });
58
- test('language import ok?', () => {
58
+ test("language import ok?", () => {
59
59
  const language = import("../types/language.mjs");
60
60
  return expect(language).resolves.toBeDefined();
61
61
  });
62
- test('traffictype import ok?', () => {
62
+ test("traffictype import ok?", () => {
63
63
  const traffictype = import("../types/traffictype.mjs");
64
64
  return expect(traffictype).resolves.toBeDefined();
65
65
  });
66
- test('testutils import ok?', () => {
66
+ test("testutils import ok?", () => {
67
67
  const testutils = import("../test/testutils.mjs");
68
68
  return expect(testutils).resolves.toBeDefined();
69
69
  });
70
- test('dbTestutils import ok?', () => {
70
+ test("dbTestutils import ok?", () => {
71
71
  const dbTestutils = import("../test/db-testutils.mjs");
72
72
  return expect(dbTestutils).resolves.toBeDefined();
73
73
  });
74
- test('httpserver import ok?', () => {
74
+ test("httpserver import ok?", () => {
75
75
  const httpserver = import("../test/httpserver.mjs");
76
76
  return expect(httpserver).resolves.toBeDefined();
77
77
  });
78
- test('asserter import ok?', () => {
78
+ test("asserter import ok?", () => {
79
79
  const asserter = import("../test/asserter.mjs");
80
80
  return expect(asserter).resolves.toBeDefined();
81
81
  });
82
- test('rtz import ok?', () => {
82
+ test("rtz import ok?", () => {
83
83
  const rtz = import("../marine/rtz.mjs");
84
84
  return expect(rtz).resolves.toBeDefined();
85
85
  });
86
- test('idUtils import ok?', () => {
86
+ test("idUtils import ok?", () => {
87
87
  const idUtils = import("../marine/id_utils.mjs");
88
88
  return expect(idUtils).resolves.toBeDefined();
89
89
  });
90
- test('apiModel import ok?', () => {
90
+ test("apiModel import ok?", () => {
91
91
  const apiModel = import("../utils/api-model.mjs");
92
92
  return expect(apiModel).resolves.toBeDefined();
93
93
  });
94
- test('logging import ok?', () => {
94
+ test("logging import ok?", () => {
95
95
  const logging = import("../utils/logging.mjs");
96
96
  return expect(logging).resolves.toBeDefined();
97
97
  });
98
- test('base64 import ok?', () => {
98
+ test("base64 import ok?", () => {
99
99
  const base64 = import("../utils/base64.mjs");
100
100
  return expect(base64).resolves.toBeDefined();
101
101
  });
102
- test('dateUtils import ok?', () => {
102
+ test("dateUtils import ok?", () => {
103
103
  const dateUtils = import("../utils/date-utils.mjs");
104
104
  return expect(dateUtils).resolves.toBeDefined();
105
105
  });
106
- test('geojsonTypes import ok?', () => {
106
+ test("geojsonTypes import ok?", () => {
107
107
  const geojsonTypes = import("../utils/geojson-types.mjs");
108
108
  return expect(geojsonTypes).resolves.toBeDefined();
109
109
  });
110
- test('slack import ok?', () => {
110
+ test("slack import ok?", () => {
111
111
  const slack = import("../utils/slack.mjs");
112
112
  return expect(slack).resolves.toBeDefined();
113
113
  });
114
- test('utils import ok?', () => {
114
+ test("utils import ok?", () => {
115
115
  const utils = import("../utils/utils.mjs");
116
116
  return expect(utils).resolves.toBeDefined();
117
117
  });
118
- test('retry import ok?', () => {
118
+ test("retry import ok?", () => {
119
119
  const retry = import("../utils/retry.mjs");
120
120
  return expect(retry).resolves.toBeDefined();
121
121
  });
122
- test('geometry import ok?', () => {
122
+ test("geometry import ok?", () => {
123
123
  const geometry = import("../utils/geometry.mjs");
124
124
  return expect(geometry).resolves.toBeDefined();
125
125
  });
126
- test('sqsIntegration import ok?', () => {
126
+ test("sqsIntegration import ok?", () => {
127
127
  const sqsIntegration = import("../aws/infra/sqs-integration.mjs");
128
128
  return expect(sqsIntegration).resolves.toBeDefined();
129
129
  });
130
- test('networkStack import ok?', () => {
130
+ test("networkStack import ok?", () => {
131
131
  const networkStack = import("../aws/infra/stacks/network-stack.mjs");
132
132
  return expect(networkStack).resolves.toBeDefined();
133
133
  });
134
- test('dbStack import ok?', () => {
134
+ test("dbStack import ok?", () => {
135
135
  const dbStack = import("../aws/infra/stacks/db-stack.mjs");
136
136
  return expect(dbStack).resolves.toBeDefined();
137
137
  });
138
- test('dbProxyStack import ok?', () => {
138
+ test("dbProxyStack import ok?", () => {
139
139
  const dbProxyStack = import("../aws/infra/stacks/db-proxy-stack.mjs");
140
140
  return expect(dbProxyStack).resolves.toBeDefined();
141
141
  });
142
- test('intraStackConfiguration import ok?', () => {
142
+ test("intraStackConfiguration import ok?", () => {
143
143
  const intraStackConfiguration = import("../aws/infra/stacks/intra-stack-configuration.mjs");
144
144
  return expect(intraStackConfiguration).resolves.toBeDefined();
145
145
  });
146
- test('dbDnsStack import ok?', () => {
146
+ test("dbDnsStack import ok?", () => {
147
147
  const dbDnsStack = import("../aws/infra/stacks/db-dns-stack.mjs");
148
148
  return expect(dbDnsStack).resolves.toBeDefined();
149
149
  });
150
- test('documentation import ok?', () => {
150
+ test("documentation import ok?", () => {
151
151
  const documentation = import("../aws/infra/documentation.mjs");
152
152
  return expect(documentation).resolves.toBeDefined();
153
153
  });
154
- test('usagePlans import ok?', () => {
154
+ test("usagePlans import ok?", () => {
155
155
  const usagePlans = import("../aws/infra/usage-plans.mjs");
156
156
  return expect(usagePlans).resolves.toBeDefined();
157
157
  });
158
- test('scheduler import ok?', () => {
158
+ test("scheduler import ok?", () => {
159
159
  const scheduler = import("../aws/infra/scheduler.mjs");
160
160
  return expect(scheduler).resolves.toBeDefined();
161
161
  });
162
- test('importUtil import ok?', () => {
162
+ test("importUtil import ok?", () => {
163
163
  const importUtil = import("../aws/infra/import-util.mjs");
164
164
  return expect(importUtil).resolves.toBeDefined();
165
165
  });
166
- test('sqsQueue import ok?', () => {
166
+ test("sqsQueue import ok?", () => {
167
167
  const sqsQueue = import("../aws/infra/sqs-queue.mjs");
168
168
  return expect(sqsQueue).resolves.toBeDefined();
169
169
  });
170
- test('response import ok?', () => {
170
+ test("response import ok?", () => {
171
171
  const response = import("../aws/infra/api/response.mjs");
172
172
  return expect(response).resolves.toBeDefined();
173
173
  });
174
- test('staticIntegration import ok?', () => {
174
+ test("staticIntegration import ok?", () => {
175
175
  const staticIntegration = import("../aws/infra/api/static-integration.mjs");
176
176
  return expect(staticIntegration).resolves.toBeDefined();
177
177
  });
178
- test('responses import ok?', () => {
178
+ test("responses import ok?", () => {
179
179
  const responses = import("../aws/infra/api/responses.mjs");
180
180
  return expect(responses).resolves.toBeDefined();
181
181
  });
182
- test('handlerFactory import ok?', () => {
182
+ test("handlerFactory import ok?", () => {
183
183
  const handlerFactory = import("../aws/infra/api/handler-factory.mjs");
184
184
  return expect(handlerFactory).resolves.toBeDefined();
185
185
  });
186
- test('integration import ok?', () => {
186
+ test("integration import ok?", () => {
187
187
  const integration = import("../aws/infra/api/integration.mjs");
188
188
  return expect(integration).resolves.toBeDefined();
189
189
  });
190
- test('stackCheckingAspect import ok?', () => {
190
+ test("stackCheckingAspect import ok?", () => {
191
191
  const stackCheckingAspect = import("../aws/infra/stack/stack-checking-aspect.mjs");
192
192
  return expect(stackCheckingAspect).resolves.toBeDefined();
193
193
  });
194
- test('restApis import ok?', () => {
194
+ test("restApis import ok?", () => {
195
195
  const restApis = import("../aws/infra/stack/rest_apis.mjs");
196
196
  return expect(restApis).resolves.toBeDefined();
197
197
  });
198
- test('lambdaConfigs import ok?', () => {
198
+ test("lambdaConfigs import ok?", () => {
199
199
  const lambdaConfigs = import("../aws/infra/stack/lambda-configs.mjs");
200
200
  return expect(lambdaConfigs).resolves.toBeDefined();
201
201
  });
202
- test('monitoredfunction import ok?', () => {
202
+ test("monitoredfunction import ok?", () => {
203
203
  const monitoredfunction = import("../aws/infra/stack/monitoredfunction.mjs");
204
204
  return expect(monitoredfunction).resolves.toBeDefined();
205
205
  });
206
- test('subscription import ok?', () => {
206
+ test("subscription import ok?", () => {
207
207
  const subscription = import("../aws/infra/stack/subscription.mjs");
208
208
  return expect(subscription).resolves.toBeDefined();
209
209
  });
210
- test('parameters import ok?', () => {
210
+ test("parameters import ok?", () => {
211
211
  const parameters = import("../aws/infra/stack/parameters.mjs");
212
212
  return expect(parameters).resolves.toBeDefined();
213
213
  });
214
- test('stack import ok?', () => {
214
+ test("stack import ok?", () => {
215
215
  const stack = import("../aws/infra/stack/stack.mjs");
216
216
  return expect(stack).resolves.toBeDefined();
217
217
  });
218
- test('securityRule import ok?', () => {
218
+ test("securityRule import ok?", () => {
219
219
  const securityRule = import("../aws/infra/security-rule.mjs");
220
220
  return expect(securityRule).resolves.toBeDefined();
221
221
  });
222
- test('canary import ok?', () => {
222
+ test("canary import ok?", () => {
223
223
  const canary = import("../aws/infra/canaries/canary.mjs");
224
224
  return expect(canary).resolves.toBeDefined();
225
225
  });
226
- test('databaseCanary import ok?', () => {
226
+ test("databaseCanary import ok?", () => {
227
227
  const databaseCanary = import("../aws/infra/canaries/database-canary.mjs");
228
228
  return expect(databaseCanary).resolves.toBeDefined();
229
229
  });
230
- test('canaryAlarm import ok?', () => {
230
+ test("canaryAlarm import ok?", () => {
231
231
  const canaryAlarm = import("../aws/infra/canaries/canary-alarm.mjs");
232
232
  return expect(canaryAlarm).resolves.toBeDefined();
233
233
  });
234
- test('canaryRole import ok?', () => {
234
+ test("canaryRole import ok?", () => {
235
235
  const canaryRole = import("../aws/infra/canaries/canary-role.mjs");
236
236
  return expect(canaryRole).resolves.toBeDefined();
237
237
  });
238
- test('urlCanary import ok?', () => {
238
+ test("urlCanary import ok?", () => {
239
239
  const urlCanary = import("../aws/infra/canaries/url-canary.mjs");
240
240
  return expect(urlCanary).resolves.toBeDefined();
241
241
  });
242
- test('canaryParameters import ok?', () => {
242
+ test("canaryParameters import ok?", () => {
243
243
  const canaryParameters = import("../aws/infra/canaries/canary-parameters.mjs");
244
244
  return expect(canaryParameters).resolves.toBeDefined();
245
245
  });
246
- test('canaryKeys import ok?', () => {
246
+ test("canaryKeys import ok?", () => {
247
247
  const canaryKeys = import("../aws/infra/canaries/canary-keys.mjs");
248
248
  return expect(canaryKeys).resolves.toBeDefined();
249
249
  });
250
- test('proxytypes import ok?', () => {
250
+ test("proxytypes import ok?", () => {
251
251
  const proxytypes = import("../aws/types/proxytypes.mjs");
252
252
  return expect(proxytypes).resolves.toBeDefined();
253
253
  });
254
- test('tags import ok?', () => {
254
+ test("tags import ok?", () => {
255
255
  const tags = import("../aws/types/tags.mjs");
256
256
  return expect(tags).resolves.toBeDefined();
257
257
  });
258
- test('mediatypes import ok?', () => {
258
+ test("mediatypes import ok?", () => {
259
259
  const mediatypes = import("../aws/types/mediatypes.mjs");
260
260
  return expect(mediatypes).resolves.toBeDefined();
261
261
  });
262
- test('modelWithReference import ok?', () => {
262
+ test("modelWithReference import ok?", () => {
263
263
  const modelWithReference = import("../aws/types/model-with-reference.mjs");
264
264
  return expect(modelWithReference).resolves.toBeDefined();
265
265
  });
266
- test('errors import ok?', () => {
266
+ test("errors import ok?", () => {
267
267
  const errors = import("../aws/types/errors.mjs");
268
268
  return expect(errors).resolves.toBeDefined();
269
269
  });
270
- test('lambdaResponse import ok?', () => {
270
+ test("lambdaResponse import ok?", () => {
271
271
  const lambdaResponse = import("../aws/types/lambda-response.mjs");
272
272
  return expect(lambdaResponse).resolves.toBeDefined();
273
273
  });
274
- test('dtLoggerDefault import ok?', () => {
274
+ test("dtLoggerDefault import ok?", () => {
275
275
  const dtLoggerDefault = import("../aws/runtime/dt-logger-default.mjs");
276
276
  return expect(dtLoggerDefault).resolves.toBeDefined();
277
277
  });
278
- test('secret import ok?', () => {
278
+ test("secret import ok?", () => {
279
279
  const secret = import("../aws/runtime/secrets/secret.mjs");
280
280
  return expect(secret).resolves.toBeDefined();
281
281
  });
282
- test('proxyHolder import ok?', () => {
282
+ test("proxyHolder import ok?", () => {
283
283
  const proxyHolder = import("../aws/runtime/secrets/proxy-holder.mjs");
284
284
  return expect(proxyHolder).resolves.toBeDefined();
285
285
  });
286
- test('dbsecret import ok?', () => {
286
+ test("dbsecret import ok?", () => {
287
287
  const dbsecret = import("../aws/runtime/secrets/dbsecret.mjs");
288
288
  return expect(dbsecret).resolves.toBeDefined();
289
289
  });
290
- test('rdsHolder import ok?', () => {
290
+ test("rdsHolder import ok?", () => {
291
291
  const rdsHolder = import("../aws/runtime/secrets/rds-holder.mjs");
292
292
  return expect(rdsHolder).resolves.toBeDefined();
293
293
  });
294
- test('secretHolder import ok?', () => {
294
+ test("secretHolder import ok?", () => {
295
295
  const secretHolder = import("../aws/runtime/secrets/secret-holder.mjs");
296
296
  return expect(secretHolder).resolves.toBeDefined();
297
297
  });
298
- test('dtLogger import ok?', () => {
298
+ test("dtLogger import ok?", () => {
299
299
  const dtLogger = import("../aws/runtime/dt-logger.mjs");
300
300
  return expect(dtLogger).resolves.toBeDefined();
301
301
  });
302
- test('s3 import ok?', () => {
302
+ test("s3 import ok?", () => {
303
303
  const s3 = import("../aws/runtime/s3.mjs");
304
304
  return expect(s3).resolves.toBeDefined();
305
305
  });
306
- test('messaging import ok?', () => {
307
- const messaging = import("../aws/runtime/messaging.mjs");
308
- return expect(messaging).resolves.toBeDefined();
309
- });
310
306
  /*
311
307
  temporary disable, enable after sdk v2 is kicked out
312
308
  test('apikey import ok?', () => {
313
309
  const apikey = import("../aws/runtime/apikey.mjs");
314
310
  return expect(apikey).resolves.toBeDefined();
315
311
  });*/
316
- test('environment import ok?', () => {
312
+ test("environment import ok?", () => {
317
313
  const environment = import("../aws/runtime/environment.mjs");
318
314
  return expect(environment).resolves.toBeDefined();
319
315
  });
320
- test('digitrafficIntegrationResponse import ok?', () => {
316
+ test("digitrafficIntegrationResponse import ok?", () => {
321
317
  const digitrafficIntegrationResponse = import("../aws/runtime/digitraffic-integration-response.mjs");
322
318
  return expect(digitrafficIntegrationResponse).resolves.toBeDefined();
323
319
  });
@@ -0,0 +1,25 @@
1
+ import { AclBuilder } from "../../aws/infra/acl-builder.mjs";
2
+ import { App, Stack } from "aws-cdk-lib";
3
+ describe("acl-builder tests", () => {
4
+ function createBuilder() {
5
+ const app = new App();
6
+ const stack = new Stack(app);
7
+ return new AclBuilder(stack);
8
+ }
9
+ test("no rules", () => {
10
+ expect(() => createBuilder().build()).toThrow();
11
+ });
12
+ test("default rules", () => {
13
+ const acl = createBuilder().withAWSManagedRules().build();
14
+ expect(acl.rules).toHaveLength(4);
15
+ });
16
+ test("two aws rules", () => {
17
+ const acl = createBuilder().withAWSManagedRules(["CommonRuleSet", "AmazonIpReputationList"]).build();
18
+ expect(acl.rules).toHaveLength(2);
19
+ });
20
+ test("ip restriction", () => {
21
+ const acl = createBuilder().withIpRestrictionRule(["1.2.3.4", "1.2.6.6"]).build();
22
+ expect(acl.rules).toHaveLength(1);
23
+ });
24
+ });
25
+ //# sourceMappingURL=acl-builder.test.mjs.map
@@ -1,6 +1,6 @@
1
- import { HandlerFactory } from "../../aws/infra/api/handler-factory.mjs";
2
- import { DtLogger } from "../../aws/runtime/dt-logger.mjs";
3
- import { LambdaResponse } from "../../aws/types/lambda-response.mjs";
1
+ import { HandlerFactory } from "../../../aws/infra/api/handler-factory.mjs";
2
+ import { DtLogger } from "../../../aws/runtime/dt-logger.mjs";
3
+ import { LambdaResponse } from "../../../aws/types/lambda-response.mjs";
4
4
  import { jest } from "@jest/globals";
5
5
  const logger = new DtLogger();
6
6
  describe("handler-factory tests", () => {
@@ -1,4 +1,4 @@
1
- import { RESPONSE_DEFAULT_LAMBDA } from "../../aws/infra/api/response.mjs";
1
+ import { RESPONSE_DEFAULT_LAMBDA } from "../../../aws/infra/api/response.mjs";
2
2
  import etag from "etag";
3
3
  // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-var-requires
4
4
  //const velocity = require("velocityjs");
@@ -1,5 +1,5 @@
1
- import { DigitrafficStaticIntegration } from "../../aws/infra/api/static-integration.mjs";
2
- import { MediaType } from "../../aws/types/mediatypes.mjs";
1
+ import { DigitrafficStaticIntegration } from "../../../aws/infra/api/static-integration.mjs";
2
+ import { MediaType } from "../../../aws/types/mediatypes.mjs";
3
3
  describe("response tests", () => {
4
4
  it("createIntegrationResponse works", () => {
5
5
  const integrationResponse = DigitrafficStaticIntegration.createIntegrationResponse("FakeResource", MediaType.APPLICATION_JSON, { "test-header": "test-value" });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,37 @@
1
+ import { DocumentationPart } from "../../aws/infra/documentation.mjs";
2
+ const METHOD_NAME = "test";
3
+ const SUMMARY = "summary";
4
+ const PARAMETER_NAME = "parameter";
5
+ const DESCRIPTION = "description";
6
+ const DEPRECATION_NOTE = "note";
7
+ describe("DocumentationPart tests", () => {
8
+ test("method", () => {
9
+ const part = DocumentationPart.method([], METHOD_NAME, SUMMARY);
10
+ expect(part.type).toEqual("METHOD");
11
+ expect(part.parameterName).toEqual(METHOD_NAME);
12
+ expect(part.documentationProperties.summary).toEqual(SUMMARY);
13
+ expect(part.documentationProperties.deprecated).toBeFalsy();
14
+ });
15
+ test("method - deprecated", () => {
16
+ const part = DocumentationPart.method([], METHOD_NAME, SUMMARY).deprecated(DEPRECATION_NOTE);
17
+ expect(part.type).toEqual("METHOD");
18
+ expect(part.parameterName).toEqual(METHOD_NAME);
19
+ expect(part.documentationProperties.summary).toEqual(`${SUMMARY}. ${DEPRECATION_NOTE}`);
20
+ expect(part.documentationProperties.deprecated).toBeTruthy();
21
+ });
22
+ test("queryparameter", () => {
23
+ const part = DocumentationPart.queryParameter(PARAMETER_NAME, DESCRIPTION);
24
+ expect(part.type).toEqual("QUERY_PARAMETER");
25
+ expect(part.parameterName).toEqual(PARAMETER_NAME);
26
+ expect(part.documentationProperties.description).toEqual(DESCRIPTION);
27
+ expect(part.documentationProperties.deprecated).toBeFalsy();
28
+ });
29
+ test("pathparameter", () => {
30
+ const part = DocumentationPart.pathParameter(PARAMETER_NAME, DESCRIPTION);
31
+ expect(part.type).toEqual("PATH_PARAMETER");
32
+ expect(part.parameterName).toEqual(PARAMETER_NAME);
33
+ expect(part.documentationProperties.description).toEqual(DESCRIPTION);
34
+ expect(part.documentationProperties.deprecated).toBeFalsy();
35
+ });
36
+ });
37
+ //# sourceMappingURL=documentation.test.mjs.map
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,22 @@
1
+ import { App, Stack } from "aws-cdk-lib";
2
+ import { Scheduler } from "../../aws/infra/scheduler.mjs";
3
+ import { Template } from "aws-cdk-lib/assertions";
4
+ describe("scheduler tests", () => {
5
+ function expectRate(createScheduler, expectedRate) {
6
+ const app = new App();
7
+ const stack = new Stack(app);
8
+ createScheduler(stack);
9
+ const template = Template.fromStack(stack);
10
+ template.hasResource("AWS::Events::Rule", {
11
+ Properties: {
12
+ ScheduleExpression: expectedRate,
13
+ State: "ENABLED"
14
+ }
15
+ });
16
+ }
17
+ test("everyMinute", () => expectRate((stack) => Scheduler.everyMinute(stack, "test"), "rate(1 minute)"));
18
+ test("everyMinutes", () => expectRate((stack) => Scheduler.everyMinutes(stack, "test", 12), "rate(12 minutes)"));
19
+ test("everyHour", () => expectRate((stack) => Scheduler.everyHour(stack, "test"), "rate(1 hour)"));
20
+ test("everyDay", () => expectRate((stack) => Scheduler.everyDay(stack, "test"), "rate(1 day)"));
21
+ });
22
+ //# sourceMappingURL=scheduler.test.mjs.map
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,20 @@
1
+ import { App, Stack } from "aws-cdk-lib";
2
+ import { Template } from "aws-cdk-lib/assertions";
3
+ import { DigitrafficSecurityRule } from "../../aws/infra/security-rule.mjs";
4
+ import { Topic } from "aws-cdk-lib/aws-sns";
5
+ describe("security-rule tests", () => {
6
+ test("create", () => {
7
+ const app = new App();
8
+ const stack = new Stack(app);
9
+ const topic = new Topic(stack, "test");
10
+ new DigitrafficSecurityRule(stack, topic);
11
+ const template = Template.fromStack(stack);
12
+ template.hasResource("AWS::Events::Rule", {
13
+ Properties: {
14
+ EventPattern: {},
15
+ State: "ENABLED"
16
+ }
17
+ });
18
+ });
19
+ });
20
+ //# sourceMappingURL=security-rule.test.mjs.map
@@ -0,0 +1,21 @@
1
+ import { CfnWebACL } from "aws-cdk-lib/aws-wafv2";
2
+ import type { Construct } from "constructs";
3
+ export type AWSManagedWafRule = "CommonRuleSet" | "AmazonIpReputationList" | "KnownBadInputsRuleSet" | "SQLiRuleSet";
4
+ /**
5
+ * Builder class for building CfnWebACL.
6
+ *
7
+ * Currently supports:
8
+ * * Some AWS managed WAF rules
9
+ * * IP blacklisting
10
+ */
11
+ export declare class AclBuilder {
12
+ readonly _construct: Construct;
13
+ readonly _rules: CfnWebACL.RuleProperty[];
14
+ _scope: string;
15
+ _name: string;
16
+ constructor(construct: Construct);
17
+ isRuleDefined(rules: AWSManagedWafRule[] | "all", rule: AWSManagedWafRule): boolean;
18
+ withAWSManagedRules(rules?: AWSManagedWafRule[] | "all"): AclBuilder;
19
+ withIpRestrictionRule(addresses: string[]): AclBuilder;
20
+ build(): CfnWebACL;
21
+ }
@@ -0,0 +1,136 @@
1
+ import { CfnIPSet, CfnWebACL } from "aws-cdk-lib/aws-wafv2";
2
+ /**
3
+ * Builder class for building CfnWebACL.
4
+ *
5
+ * Currently supports:
6
+ * * Some AWS managed WAF rules
7
+ * * IP blacklisting
8
+ */
9
+ export class AclBuilder {
10
+ _construct;
11
+ _rules = [];
12
+ _scope = "CLOUDFRONT";
13
+ _name = "WebACL";
14
+ constructor(construct) {
15
+ this._construct = construct;
16
+ }
17
+ isRuleDefined(rules, rule) {
18
+ return rules === "all" || rules.includes(rule);
19
+ }
20
+ withAWSManagedRules(rules = "all") {
21
+ if (this.isRuleDefined(rules, "CommonRuleSet")) {
22
+ this._rules.push(createAWSCommonRuleSet());
23
+ }
24
+ if (this.isRuleDefined(rules, "AmazonIpReputationList")) {
25
+ this._rules.push(createAWSReputationList());
26
+ }
27
+ if (this.isRuleDefined(rules, "KnownBadInputsRuleSet")) {
28
+ this._rules.push(createAWSKnownBadInput());
29
+ }
30
+ if (this.isRuleDefined(rules, "SQLiRuleSet")) {
31
+ this._rules.push(createAWSAntiSQLInjection());
32
+ }
33
+ return this;
34
+ }
35
+ withIpRestrictionRule(addresses) {
36
+ const blocklistIpSet = new CfnIPSet(this._construct, "BlocklistIpSet", {
37
+ ipAddressVersion: "IPV4",
38
+ scope: this._scope,
39
+ addresses,
40
+ });
41
+ this._rules.push({
42
+ name: "IpBlocklist",
43
+ priority: 10,
44
+ action: { block: {} },
45
+ statement: {
46
+ ipSetReferenceStatement: {
47
+ arn: blocklistIpSet.attrArn,
48
+ },
49
+ },
50
+ visibilityConfig: {
51
+ sampledRequestsEnabled: false,
52
+ cloudWatchMetricsEnabled: true,
53
+ metricName: "IpBlocklist",
54
+ },
55
+ });
56
+ return this;
57
+ }
58
+ build() {
59
+ if (this._rules.length === 0) {
60
+ throw new Error("No rules defined for WebACL");
61
+ }
62
+ const acl = new CfnWebACL(this._construct, this._name, {
63
+ defaultAction: { allow: {} },
64
+ scope: this._scope,
65
+ visibilityConfig: {
66
+ cloudWatchMetricsEnabled: true,
67
+ metricName: "WAF-Blocked",
68
+ sampledRequestsEnabled: false
69
+ },
70
+ rules: this._rules,
71
+ // customResponseBodies
72
+ });
73
+ return acl;
74
+ }
75
+ }
76
+ function createAWSCommonRuleSet() {
77
+ return createRuleProperty("AWS-AWSManagedRulesCommonRuleSet", 70, {
78
+ statement: {
79
+ managedRuleGroupStatement: {
80
+ vendorName: "AWS",
81
+ name: "AWSManagedRulesCommonRuleSet",
82
+ excludedRules: [
83
+ { name: "NoUserAgent_HEADER" },
84
+ { name: "SizeRestrictions_BODY" },
85
+ { name: "GenericRFI_BODY" }
86
+ ]
87
+ }
88
+ }
89
+ });
90
+ }
91
+ function createAWSReputationList() {
92
+ return createRuleProperty("AWS-AWSManagedRulesAmazonIpReputationList", 80, {
93
+ statement: {
94
+ managedRuleGroupStatement: {
95
+ vendorName: "AWS",
96
+ name: "AWSManagedRulesAmazonIpReputationList"
97
+ }
98
+ }
99
+ });
100
+ }
101
+ function createAWSKnownBadInput() {
102
+ return createRuleProperty("AWS-AWSManagedRulesKnownBadInputsRuleSet", 90, {
103
+ statement: {
104
+ managedRuleGroupStatement: {
105
+ vendorName: "AWS",
106
+ name: "AWSManagedRulesKnownBadInputsRuleSet"
107
+ }
108
+ }
109
+ });
110
+ }
111
+ function createAWSAntiSQLInjection() {
112
+ return createRuleProperty("AWS-AWSManagedRulesSQLiRuleSet", 100, {
113
+ statement: {
114
+ managedRuleGroupStatement: {
115
+ vendorName: "AWS",
116
+ name: "AWSManagedRulesSQLiRuleSet"
117
+ }
118
+ }
119
+ });
120
+ }
121
+ function createRuleProperty(name, priority, rule, overrideAction = true) {
122
+ return {
123
+ ...{
124
+ name,
125
+ priority,
126
+ visibilityConfig: {
127
+ sampledRequestsEnabled: true,
128
+ cloudWatchMetricsEnabled: true,
129
+ metricName: name
130
+ }
131
+ },
132
+ ...rule,
133
+ ...(overrideAction ? { overrideAction: { none: {} } } : {})
134
+ };
135
+ }
136
+ //# sourceMappingURL=acl-builder.mjs.map
@@ -9,11 +9,11 @@ import { SnsTopic } from "aws-cdk-lib/aws-events-targets";
9
9
  */
10
10
  export class DigitrafficSecurityRule extends Rule {
11
11
  constructor(scope, topic) {
12
- const ruleName = 'SecurityHubRule';
12
+ const ruleName = "SecurityHubRule";
13
13
  super(scope, ruleName, {
14
14
  ruleName,
15
15
  eventPattern: {
16
- source: ['aws.securityhub'],
16
+ source: ["aws.securityhub"],
17
17
  detailType: ["Security Hub Findings - Imported"],
18
18
  detail: {
19
19
  findings: {
@@ -7,10 +7,10 @@ import { RetentionDays } from "aws-cdk-lib/aws-logs";
7
7
  import { SqsEventSource } from "aws-cdk-lib/aws-lambda-event-sources";
8
8
  import { ComparisonOperator, TreatMissingData } from "aws-cdk-lib/aws-cloudwatch";
9
9
  import { SnsAction } from "aws-cdk-lib/aws-cloudwatch-actions";
10
- import { S3, S3Client } from "@aws-sdk/client-s3";
11
- import { Upload } from "@aws-sdk/lib-storage";
12
10
  import { DigitrafficStack } from "./stack/stack.mjs";
13
11
  import { MonitoredFunction } from "./stack/monitoredfunction.mjs";
12
+ import { ObjectCannedACL, PutObjectCommand, S3Client } from "@aws-sdk/client-s3";
13
+ import { logger } from "../runtime/dt-logger-default.mjs";
14
14
  /**
15
15
  * Construct for creating SQS-queues.
16
16
  *
@@ -83,36 +83,25 @@ function addDLQAlarm(stack, dlqName, dlq) {
83
83
  function getDlqCode(Bucket) {
84
84
  const functionBody = DLQ_LAMBDA_CODE.replace("__bucketName__", Bucket)
85
85
  .replace("__upload__", uploadToS3.toString())
86
- .replace("__doUpload__", doUpload.toString())
87
86
  .replace("__handler__", createHandler().toString().substring(23)); // remove function handler() from signature
88
87
  return new InlineCode(functionBody);
89
88
  }
90
- async function uploadToS3(s3, Bucket, Body, Key) {
89
+ async function uploadToS3(s3, bucketName, body, objectName, cannedAcl, contentType) {
90
+ const command = new PutObjectCommand({
91
+ Bucket: bucketName,
92
+ Key: objectName,
93
+ Body: body,
94
+ ACL: cannedAcl,
95
+ ContentType: contentType,
96
+ });
91
97
  try {
92
- console.info("writing %s to %s", Key, Bucket);
93
- await doUpload(s3, Bucket, Body, Key);
98
+ await s3.send(command);
94
99
  }
95
100
  catch (error) {
96
- console.warn(error);
97
- console.warn("method=uploadToS3 retrying upload to bucket %s", Bucket);
98
- try {
99
- await doUpload(s3, Bucket, Body, Key);
100
- }
101
- catch (e2) {
102
- console.error("method=uploadToS3 failed retrying upload to bucket %s", Bucket);
103
- }
104
- }
105
- }
106
- async function doUpload(s3, Bucket, Body, Key) {
107
- try {
108
- const upload = new Upload({
109
- client: s3,
110
- params: { Bucket, Key, Body },
101
+ logger.error({
102
+ method: "s3.uploadToS3",
103
+ message: `upload failed to bucket ${bucketName}`,
111
104
  });
112
- await upload.done();
113
- }
114
- catch (error) {
115
- console.error(error);
116
105
  }
117
106
  }
118
107
  // bucketName is unused, will be overridden in the actual lambda code below
@@ -120,16 +109,22 @@ const bucketName = "";
120
109
  function createHandler() {
121
110
  return async function handler(event) {
122
111
  const millis = new Date().getTime();
123
- await Promise.all(event.Records.map((e, idx) => uploadToS3(new S3(), bucketName, e.body, `dlq-${millis}-${idx}.json`)));
112
+ const s3 = new S3Client({});
113
+ await Promise.all(event.Records.map((e, idx) => {
114
+ uploadToS3(s3, bucketName, e.body, `dlq-${millis}-${idx}.json`);
115
+ }));
124
116
  };
125
117
  }
126
118
  const DLQ_LAMBDA_CODE = `
127
- import { S3, S3Client } from "@aws-sdk/client-s3";
128
- import { Upload } from "@aws-sdk/lib-storage";
119
+ import type { ObjectCannedACL } from "@aws-sdk/client-s3";
120
+ import { PutObjectCommand, S3Client } from "@aws-sdk/client-s3";
121
+ import { type NodeJsRuntimeStreamingBlobPayloadInputTypes } from "@smithy/types";
122
+ import { logger } from "./dt-logger-default.mjs";
123
+
124
+
129
125
  const bucketName = "__bucketName__";
130
126
 
131
127
  __upload__
132
- __doUpload__
133
128
 
134
129
  exports.handler = async (event) => __handler__
135
130
  `;
@@ -1,4 +1,4 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
1
  import type { ObjectCannedACL } from "@aws-sdk/client-s3";
3
- import { Readable } from "node:stream";
4
- export declare function uploadToS3(bucketName: string, body: Readable, objectName: string, cannedAcl?: ObjectCannedACL, contentType?: string): Promise<void>;
2
+ import { S3Client } from "@aws-sdk/client-s3";
3
+ import { type NodeJsRuntimeStreamingBlobPayloadInputTypes } from "@smithy/types";
4
+ export declare function uploadToS3(s3: S3Client, bucketName: string, body: NodeJsRuntimeStreamingBlobPayloadInputTypes, objectName: string, cannedAcl?: ObjectCannedACL, contentType?: string): Promise<void>;
@@ -1,31 +1,22 @@
1
- import { Upload } from "@aws-sdk/lib-storage";
2
- import { S3 } from "@aws-sdk/client-s3";
3
- import { Readable } from "node:stream";
4
- export async function uploadToS3(bucketName, body, objectName, cannedAcl, contentType) {
5
- const s3 = new S3();
1
+ import { PutObjectCommand, S3Client } from "@aws-sdk/client-s3";
2
+ import {} from "@smithy/types";
3
+ import { logger } from "./dt-logger-default.mjs";
4
+ export async function uploadToS3(s3, bucketName, body, objectName, cannedAcl, contentType) {
5
+ const command = new PutObjectCommand({
6
+ Bucket: bucketName,
7
+ Key: objectName,
8
+ Body: body,
9
+ ACL: cannedAcl,
10
+ ContentType: contentType,
11
+ });
6
12
  try {
7
- await doUpload(s3, bucketName, body, objectName, cannedAcl, contentType);
13
+ await s3.send(command);
8
14
  }
9
15
  catch (error) {
10
- console.warn("method=uploadToS3 retrying upload to bucket %s", bucketName);
11
- try {
12
- await doUpload(s3, bucketName, body, objectName, cannedAcl, contentType);
13
- }
14
- catch (e2) {
15
- console.error("method=uploadToS3 failed retrying upload to bucket %s", bucketName);
16
- }
16
+ logger.error({
17
+ method: "s3.uploadToS3",
18
+ message: `upload failed to bucket ${bucketName}`,
19
+ });
17
20
  }
18
21
  }
19
- function doUpload(s3, bucketName, body, filename, cannedAcl, contentType) {
20
- return new Upload({
21
- client: s3,
22
- params: {
23
- Bucket: bucketName,
24
- Body: body,
25
- Key: filename,
26
- ACL: cannedAcl,
27
- ContentType: contentType,
28
- },
29
- }).done();
30
- }
31
22
  //# sourceMappingURL=s3.mjs.map
@@ -1,3 +1,4 @@
1
+ import { logger } from "../aws/runtime/dt-logger-default.mjs";
1
2
  export function isValidIMO(imo) {
2
3
  return imo >= 1000000 && imo <= 9999999 && imoChecksumIsValid(imo);
3
4
  }
@@ -10,10 +11,10 @@ function imoChecksumIsValid(imo) {
10
11
  const imoDigit5 = Number(imoStr[4]);
11
12
  const imoDigit6 = Number(imoStr[5]);
12
13
  const checkDigit = Number(imoStr[6]);
13
- const checkCalculation = Number(((imoDigit1 * 7) + (imoDigit2 * 6) + (imoDigit3 * 5) + (imoDigit4 * 4) + (imoDigit5 * 3) + (imoDigit6 * 2)));
14
+ const checkCalculation = Number(imoDigit1 * 7 + imoDigit2 * 6 + imoDigit3 * 5 + imoDigit4 * 4 + imoDigit5 * 3 + imoDigit6 * 2);
14
15
  const checkResult = checkCalculation % 10 === checkDigit;
15
16
  if (!checkResult) {
16
- console.warn('method=imoChecksumIsValid IMO checksum failed %d', imo);
17
+ logger.warn({ method: "idUtils.imoChecksumIsValid", message: `IMO checksum failed ${imo}` });
17
18
  }
18
19
  return checkResult;
19
20
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digitraffic/common",
3
- "version": "2024.3.22-2",
3
+ "version": "2024.4.4-1",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "repository": {
@@ -56,6 +56,7 @@
56
56
  "./dist/aws/infra/stacks/db-proxy-stack": "./dist/aws/infra/stacks/db-proxy-stack.mjs",
57
57
  "./dist/aws/infra/stacks/intra-stack-configuration": "./dist/aws/infra/stacks/intra-stack-configuration.mjs",
58
58
  "./dist/aws/infra/stacks/db-dns-stack": "./dist/aws/infra/stacks/db-dns-stack.mjs",
59
+ "./dist/aws/infra/acl-builder": "./dist/aws/infra/acl-builder.mjs",
59
60
  "./dist/aws/infra/documentation": "./dist/aws/infra/documentation.mjs",
60
61
  "./dist/aws/infra/usage-plans": "./dist/aws/infra/usage-plans.mjs",
61
62
  "./dist/aws/infra/scheduler": "./dist/aws/infra/scheduler.mjs",
@@ -97,44 +98,44 @@
97
98
  "./dist/aws/runtime/secrets/secret-holder": "./dist/aws/runtime/secrets/secret-holder.mjs",
98
99
  "./dist/aws/runtime/dt-logger": "./dist/aws/runtime/dt-logger.mjs",
99
100
  "./dist/aws/runtime/s3": "./dist/aws/runtime/s3.mjs",
100
- "./dist/aws/runtime/messaging": "./dist/aws/runtime/messaging.mjs",
101
101
  "./dist/aws/runtime/apikey": "./dist/aws/runtime/apikey.mjs",
102
102
  "./dist/aws/runtime/environment": "./dist/aws/runtime/environment.mjs",
103
103
  "./dist/aws/runtime/digitraffic-integration-response": "./dist/aws/runtime/digitraffic-integration-response.mjs"
104
104
  },
105
105
  "peerDependencies": {
106
- "@aws-sdk/client-s3": "^3.533.0",
107
- "@aws-sdk/lib-storage": "^3.533.0",
108
- "@aws-sdk/client-secrets-manager": "^3.533.0",
109
- "@aws-sdk/client-api-gateway": "^3.533.0",
110
- "@aws-sdk/client-sns": "^3.533.0",
106
+ "@aws-sdk/client-s3": "^3.540.0",
107
+ "@aws-sdk/lib-storage": "^3.540.0",
108
+ "@aws-sdk/client-secrets-manager": "^3.540.0",
109
+ "@aws-sdk/client-api-gateway": "^3.540.0",
110
+ "@aws-sdk/client-sns": "^3.540.0",
111
111
  "@types/geojson": "^7946.0.14",
112
- "aws-cdk-lib": "^2.133.0",
112
+ "aws-cdk-lib": "^2.134.0",
113
113
  "change-case": "5.0.0",
114
114
  "constructs": "^10.3.0",
115
115
  "date-fns": "~2.30.0",
116
116
  "date-fns-tz": "~2.0.0",
117
117
  "etag": "^1.8.1",
118
118
  "geojson-validation": "^1.0.2",
119
- "ky": "^1.2.2",
119
+ "ky": "^1.2.3",
120
120
  "lodash": "~4.17.21",
121
121
  "node-ttl": "^0.2.0",
122
122
  "pg-native": "^3.0.1",
123
123
  "pg-promise": "^11.5.4"
124
124
  },
125
125
  "devDependencies": {
126
- "aws-sdk": "2.1577.0",
127
- "@aws-sdk/client-s3": "3.533.0",
128
- "@aws-sdk/lib-storage": "3.533.0",
129
- "@aws-sdk/client-secrets-manager": "3.533.0",
130
- "@aws-sdk/client-api-gateway": "3.533.0",
131
- "@aws-sdk/client-sns": "3.533.0",
126
+ "aws-sdk": "2.1586.0",
127
+ "@aws-sdk/client-s3": "3.540.0",
128
+ "@aws-sdk/lib-storage": "3.540.0",
129
+ "@aws-sdk/client-secrets-manager": "3.540.0",
130
+ "@aws-sdk/client-api-gateway": "3.540.0",
131
+ "@aws-sdk/client-sns": "3.540.0",
132
132
  "@jest/globals": "^29.7.0",
133
133
  "@rushstack/eslint-config": "^3.6.4",
134
134
  "@rushstack/heft": "^0.66.0",
135
135
  "@rushstack/heft-jest-plugin": "^0.11.21",
136
136
  "@rushstack/heft-lint-plugin": "^0.3.20",
137
137
  "@rushstack/heft-typescript-plugin": "^0.3.20",
138
+ "@smithy/types": "2.12.0",
138
139
  "@types/aws-lambda": "8.10.136",
139
140
  "@types/etag": "1.8.3",
140
141
  "@types/geojson": "^7946.0.14",
@@ -142,10 +143,9 @@
142
143
  "@types/jest": "29.5.12",
143
144
  "@types/lodash": "4.14.202",
144
145
  "@types/node": "20.11.27",
145
- "@types/sinon": "17.0.3",
146
146
  "@typescript-eslint/eslint-plugin": "~6.18.1",
147
147
  "@typescript-eslint/parser": "^6.20.0",
148
- "aws-cdk-lib": "^2.133.0",
148
+ "aws-cdk-lib": "^2.134.0",
149
149
  "change-case": "5.3.0",
150
150
  "constructs": "10.3.0",
151
151
  "date-fns": "~2.30.0",
@@ -157,13 +157,12 @@
157
157
  "geojson-validation": "^1.0.2",
158
158
  "jest": "^29.7.0",
159
159
  "jest-junit": "^16.0.0",
160
- "ky": "^1.2.2",
160
+ "ky": "^1.2.3",
161
161
  "lodash": "~4.17.21",
162
162
  "node-ttl": "^0.2.0",
163
163
  "pg-promise": "^11.5.4",
164
164
  "prettier": "^3.2.5",
165
165
  "rimraf": "^5.0.5",
166
- "sinon": "17.0.1",
167
166
  "ts-jest": "^29.1.2",
168
167
  "typescript": "~5.3.3",
169
168
  "velocityjs": "2.0.6"
@@ -1,10 +0,0 @@
1
- import { SNS as SNSType } from "@aws-sdk/client-sns";
2
- /**
3
- * Utility function for publishing SNS messages.
4
- * Made because using *await* with AWS APIs doesn't require calling promise() but nothing works if it isn't called.
5
- * Retries a single time in case of failure.
6
- * @param message
7
- * @param topicArn
8
- * @param sns
9
- */
10
- export declare function snsPublish(message: string, topicArn: string, sns: SNSType): Promise<void>;
@@ -1,28 +0,0 @@
1
- import { SNS as SNSType } from "@aws-sdk/client-sns";
2
- /**
3
- * Utility function for publishing SNS messages.
4
- * Made because using *await* with AWS APIs doesn't require calling promise() but nothing works if it isn't called.
5
- * Retries a single time in case of failure.
6
- * @param message
7
- * @param topicArn
8
- * @param sns
9
- */
10
- export async function snsPublish(message, topicArn, sns) {
11
- const publishParams = {
12
- Message: message,
13
- TopicArn: topicArn,
14
- };
15
- try {
16
- await sns.publish(publishParams);
17
- }
18
- catch (error) {
19
- console.error("method=snsPublish error, retrying", error);
20
- try {
21
- await sns.publish(publishParams);
22
- }
23
- catch (e2) {
24
- console.error("method=snsPublish error after retry", e2);
25
- }
26
- }
27
- }
28
- //# sourceMappingURL=messaging.mjs.map