@aligent/aws-wrappers 0.3.0 → 0.4.0

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.
package/esm/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { LogLevelThreshold, Logger } from '@aws-lambda-powertools/logger';
2
2
  import { DynamoDBClient } from '@aws-sdk/client-dynamodb';
3
- import { DynamoDBDocumentClient, paginateQuery, paginateScan, GetCommand, PutCommand, UpdateCommand, DeleteCommand, QueryCommand, ScanCommand, BatchGetCommand, BatchWriteCommand } from '@aws-sdk/lib-dynamodb';
3
+ import { DynamoDBDocumentClient, GetCommand, PutCommand, UpdateCommand, DeleteCommand, QueryCommand, ScanCommand, BatchGetCommand, BatchWriteCommand, paginateQuery, paginateScan } from '@aws-sdk/lib-dynamodb';
4
4
  import xray from 'aws-xray-sdk-core';
5
5
  import { S3Client, PutObjectCommand, GetObjectCommand, HeadObjectCommand, CopyObjectCommand, paginateListObjectsV2, DeleteObjectCommand, DeleteObjectsCommand } from '@aws-sdk/client-s3';
6
6
  import { getSignedUrl } from '@aws-sdk/s3-request-presigner';
@@ -11,126 +11,6 @@ import { SNSClient, PublishCommand, PublishBatchCommand } from '@aws-sdk/client-
11
11
  import { SQSClient, SendMessageCommand, ReceiveMessageCommand, DeleteMessageCommand, SendMessageBatchCommand, DeleteMessageBatchCommand } from '@aws-sdk/client-sqs';
12
12
  import { SSMClient, GetParameterCommand, GetParametersCommand, PutParameterCommand, DeleteParameterCommand, paginateGetParametersByPath } from '@aws-sdk/client-ssm';
13
13
 
14
- /******************************************************************************
15
- Copyright (c) Microsoft Corporation.
16
-
17
- Permission to use, copy, modify, and/or distribute this software for any
18
- purpose with or without fee is hereby granted.
19
-
20
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
21
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
22
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
23
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
24
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
25
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
26
- PERFORMANCE OF THIS SOFTWARE.
27
- ***************************************************************************** */
28
- /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
29
-
30
-
31
- var __assign = function() {
32
- __assign = Object.assign || function __assign(t) {
33
- for (var s, i = 1, n = arguments.length; i < n; i++) {
34
- s = arguments[i];
35
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
36
- }
37
- return t;
38
- };
39
- return __assign.apply(this, arguments);
40
- };
41
-
42
- function __rest(s, e) {
43
- var t = {};
44
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
45
- t[p] = s[p];
46
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
47
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
48
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
49
- t[p[i]] = s[p[i]];
50
- }
51
- return t;
52
- }
53
-
54
- function __awaiter(thisArg, _arguments, P, generator) {
55
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
56
- return new (P || (P = Promise))(function (resolve, reject) {
57
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
58
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
59
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
60
- step((generator = generator.apply(thisArg, _arguments || [])).next());
61
- });
62
- }
63
-
64
- function __generator(thisArg, body) {
65
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
66
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
67
- function verb(n) { return function (v) { return step([n, v]); }; }
68
- function step(op) {
69
- if (f) throw new TypeError("Generator is already executing.");
70
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
71
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
72
- if (y = 0, t) op = [op[0] & 2, t.value];
73
- switch (op[0]) {
74
- case 0: case 1: t = op; break;
75
- case 4: _.label++; return { value: op[1], done: false };
76
- case 5: _.label++; y = op[1]; op = [0]; continue;
77
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
78
- default:
79
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
80
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
81
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
82
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
83
- if (t[2]) _.ops.pop();
84
- _.trys.pop(); continue;
85
- }
86
- op = body.call(thisArg, _);
87
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
88
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
89
- }
90
- }
91
-
92
- function __values(o) {
93
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
94
- if (m) return m.call(o);
95
- if (o && typeof o.length === "number") return {
96
- next: function () {
97
- if (o && i >= o.length) o = void 0;
98
- return { value: o && o[i++], done: !o };
99
- }
100
- };
101
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
102
- }
103
-
104
- function __await(v) {
105
- return this instanceof __await ? (this.v = v, this) : new __await(v);
106
- }
107
-
108
- function __asyncGenerator(thisArg, _arguments, generator) {
109
- if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
110
- var g = generator.apply(thisArg, _arguments || []), i, q = [];
111
- return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
112
- function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
113
- function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
114
- function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
115
- function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
116
- function fulfill(value) { resume("next", value); }
117
- function reject(value) { resume("throw", value); }
118
- function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
119
- }
120
-
121
- function __asyncValues(o) {
122
- if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
123
- var m = o[Symbol.asyncIterator], i;
124
- return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
125
- function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
126
- function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
127
- }
128
-
129
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
130
- var e = new Error(message);
131
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
132
- };
133
-
134
14
  /**
135
15
  * Whether the logger is verbose enough that full SDK inputs — payloads, secret
136
16
  * material and PII — may be written to the log.
@@ -162,21 +42,20 @@ function shouldLogFullInput(logger) {
162
42
  function filterFieldsForLogLevel(logger, input, safeFields) {
163
43
  if (shouldLogFullInput(logger))
164
44
  return input;
165
- var out = {};
166
- for (var _i = 0, safeFields_1 = safeFields; _i < safeFields_1.length; _i++) {
167
- var key = safeFields_1[_i];
45
+ const out = {};
46
+ for (const key of safeFields) {
168
47
  if (key in input)
169
48
  out[key] = input[key];
170
49
  }
171
50
  return out;
172
51
  }
173
52
 
174
- var BATCH_WRITE_MAX_ATTEMPTS = 5;
175
- var BATCH_WRITE_BASE_DELAY_MS = 200;
53
+ const BATCH_WRITE_MAX_ATTEMPTS = 5;
54
+ const BATCH_WRITE_BASE_DELAY_MS = 200;
176
55
  /**
177
56
  * Fields safe to log at INFO. Omits `Key` (may carry customer IDs / tenant IDs).
178
57
  */
179
- var GET_ITEM_SAFE_FIELDS = [
58
+ const GET_ITEM_SAFE_FIELDS = [
180
59
  'TableName',
181
60
  'ConsistentRead',
182
61
  'ProjectionExpression',
@@ -187,7 +66,7 @@ var GET_ITEM_SAFE_FIELDS = [
187
66
  * Fields safe to log at INFO. Omits `Item` (the payload itself) and
188
67
  * `ExpressionAttributeValues` (values bound to ConditionExpression, often PII).
189
68
  */
190
- var PUT_ITEM_SAFE_FIELDS = [
69
+ const PUT_ITEM_SAFE_FIELDS = [
191
70
  'TableName',
192
71
  'ConditionExpression',
193
72
  'ExpressionAttributeNames',
@@ -199,7 +78,7 @@ var PUT_ITEM_SAFE_FIELDS = [
199
78
  /**
200
79
  * Fields safe to log at INFO. Omits `Key` and `ExpressionAttributeValues`.
201
80
  */
202
- var UPDATE_ITEM_SAFE_FIELDS = [
81
+ const UPDATE_ITEM_SAFE_FIELDS = [
203
82
  'TableName',
204
83
  'UpdateExpression',
205
84
  'ConditionExpression',
@@ -213,7 +92,7 @@ var UPDATE_ITEM_SAFE_FIELDS = [
213
92
  * Fields safe to log at INFO. Omits `Key` and `ExpressionAttributeValues`
214
93
  * (the latter binds to ConditionExpression and may carry PII).
215
94
  */
216
- var DELETE_ITEM_SAFE_FIELDS = [
95
+ const DELETE_ITEM_SAFE_FIELDS = [
217
96
  'TableName',
218
97
  'ConditionExpression',
219
98
  'ExpressionAttributeNames',
@@ -227,7 +106,7 @@ var DELETE_ITEM_SAFE_FIELDS = [
227
106
  * `ExpressionAttributeValues` (values often carry PII) and `ExclusiveStartKey`
228
107
  * (pagination cursor includes Key shape).
229
108
  */
230
- var QUERY_SAFE_FIELDS = [
109
+ const QUERY_SAFE_FIELDS = [
231
110
  'TableName',
232
111
  'IndexName',
233
112
  'KeyConditionExpression',
@@ -244,7 +123,7 @@ var QUERY_SAFE_FIELDS = [
244
123
  * Fields safe to log at INFO for `scan` and `paginateScan`. Omits
245
124
  * `ExpressionAttributeValues` and `ExclusiveStartKey`.
246
125
  */
247
- var SCAN_SAFE_FIELDS = [
126
+ const SCAN_SAFE_FIELDS = [
248
127
  'TableName',
249
128
  'IndexName',
250
129
  'FilterExpression',
@@ -257,9 +136,9 @@ var SCAN_SAFE_FIELDS = [
257
136
  'TotalSegments',
258
137
  'ReturnConsumedCapacity',
259
138
  ];
260
- var sleep = function (ms) { return new Promise(function (resolve) { return setTimeout(resolve, ms); }); };
261
- var backoffDelay = function (attempt) {
262
- var exp = BATCH_WRITE_BASE_DELAY_MS * Math.pow(2, attempt);
139
+ const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));
140
+ const backoffDelay = (attempt) => {
141
+ const exp = BATCH_WRITE_BASE_DELAY_MS * 2 ** attempt;
263
142
  return exp + Math.random() * exp;
264
143
  };
265
144
  /**
@@ -273,7 +152,9 @@ var backoffDelay = function (attempt) {
273
152
  * Items are automatically marshalled / unmarshalled via the document client —
274
153
  * callers work with plain TypeScript objects in both directions.
275
154
  */
276
- var DynamoDBService = /** @class */ (function () {
155
+ class DynamoDBService {
156
+ client;
157
+ logger;
277
158
  /**
278
159
  * @param opts.logger - Optional Powertools logger. Defaults to `new Logger()`,
279
160
  * which picks up `POWERTOOLS_SERVICE_NAME` from the environment.
@@ -283,13 +164,13 @@ var DynamoDBService = /** @class */ (function () {
283
164
  * *before* being passed to `DynamoDBDocumentClient.from`, so X-Ray
284
165
  * tracing captures every DynamoDB call.
285
166
  */
286
- function DynamoDBService(opts) {
287
- var _a, _b;
167
+ constructor(opts) {
288
168
  this.client =
289
- (_a = opts === null || opts === void 0 ? void 0 : opts.client) !== null && _a !== void 0 ? _a : DynamoDBDocumentClient.from(xray.captureAWSv3Client(new DynamoDBClient({})), {
290
- marshallOptions: { removeUndefinedValues: true },
291
- });
292
- this.logger = (_b = opts === null || opts === void 0 ? void 0 : opts.logger) !== null && _b !== void 0 ? _b : new Logger();
169
+ opts?.client ??
170
+ DynamoDBDocumentClient.from(xray.captureAWSv3Client(new DynamoDBClient({})), {
171
+ marshallOptions: { removeUndefinedValues: true },
172
+ });
173
+ this.logger = opts?.logger ?? new Logger();
293
174
  }
294
175
  /**
295
176
  * Get an item from DynamoDB.
@@ -297,38 +178,24 @@ var DynamoDBService = /** @class */ (function () {
297
178
  * @template R - Expected unmarshalled item shape.
298
179
  * @returns The item, or `undefined` if not found.
299
180
  */
300
- DynamoDBService.prototype.getItem = function (input) {
301
- return __awaiter(this, void 0, void 0, function () {
302
- var response;
303
- return __generator(this, function (_a) {
304
- switch (_a.label) {
305
- case 0:
306
- this.logger.info('Getting DynamoDB item', {
307
- input: filterFieldsForLogLevel(this.logger, input, GET_ITEM_SAFE_FIELDS),
308
- });
309
- return [4 /*yield*/, this.client.send(new GetCommand(input))];
310
- case 1:
311
- response = _a.sent();
312
- return [2 /*return*/, response.Item];
313
- }
314
- });
181
+ async getItem(input) {
182
+ this.logger.info('Getting DynamoDB item', {
183
+ input: filterFieldsForLogLevel(this.logger, input, GET_ITEM_SAFE_FIELDS),
315
184
  });
316
- };
185
+ const response = await this.client.send(new GetCommand(input));
186
+ return response.Item;
187
+ }
317
188
  /**
318
189
  * Put an item into DynamoDB. The caller's `Item` is typed as `T`, which
319
190
  * the document client marshalls automatically.
320
191
  * @template T - Type of the item being stored.
321
192
  */
322
- DynamoDBService.prototype.putItem = function (input) {
323
- return __awaiter(this, void 0, void 0, function () {
324
- return __generator(this, function (_a) {
325
- this.logger.info('Putting DynamoDB item', {
326
- input: filterFieldsForLogLevel(this.logger, input, PUT_ITEM_SAFE_FIELDS),
327
- });
328
- return [2 /*return*/, this.client.send(new PutCommand(input))];
329
- });
193
+ async putItem(input) {
194
+ this.logger.info('Putting DynamoDB item', {
195
+ input: filterFieldsForLogLevel(this.logger, input, PUT_ITEM_SAFE_FIELDS),
330
196
  });
331
- };
197
+ return this.client.send(new PutCommand(input));
198
+ }
332
199
  /**
333
200
  * Update an item in DynamoDB. The `Attributes` field on the response is
334
201
  * typed as `R` — the caller should choose `R` to match their
@@ -339,69 +206,39 @@ var DynamoDBService = /** @class */ (function () {
339
206
  * @template K - Shape of the partition / sort key.
340
207
  * @template R - Expected shape of the returned `Attributes`.
341
208
  */
342
- DynamoDBService.prototype.updateItem = function (input) {
343
- return __awaiter(this, void 0, void 0, function () {
344
- var response;
345
- return __generator(this, function (_a) {
346
- switch (_a.label) {
347
- case 0:
348
- this.logger.info('Updating DynamoDB item', {
349
- input: filterFieldsForLogLevel(this.logger, input, UPDATE_ITEM_SAFE_FIELDS),
350
- });
351
- return [4 /*yield*/, this.client.send(new UpdateCommand(input))];
352
- case 1:
353
- response = _a.sent();
354
- return [2 /*return*/, response];
355
- }
356
- });
209
+ async updateItem(input) {
210
+ this.logger.info('Updating DynamoDB item', {
211
+ input: filterFieldsForLogLevel(this.logger, input, UPDATE_ITEM_SAFE_FIELDS),
357
212
  });
358
- };
213
+ const response = await this.client.send(new UpdateCommand(input));
214
+ return response;
215
+ }
359
216
  /**
360
217
  * Delete an item from DynamoDB. The `Attributes` field on the response is
361
218
  * typed as `R` — relevant when `ReturnValues: 'ALL_OLD'` is set.
362
219
  * @template K - Shape of the partition / sort key.
363
220
  * @template R - Expected shape of the returned `Attributes`.
364
221
  */
365
- DynamoDBService.prototype.deleteItem = function (input) {
366
- return __awaiter(this, void 0, void 0, function () {
367
- var response;
368
- return __generator(this, function (_a) {
369
- switch (_a.label) {
370
- case 0:
371
- this.logger.info('Deleting DynamoDB item', {
372
- input: filterFieldsForLogLevel(this.logger, input, DELETE_ITEM_SAFE_FIELDS),
373
- });
374
- return [4 /*yield*/, this.client.send(new DeleteCommand(input))];
375
- case 1:
376
- response = _a.sent();
377
- return [2 /*return*/, response];
378
- }
379
- });
222
+ async deleteItem(input) {
223
+ this.logger.info('Deleting DynamoDB item', {
224
+ input: filterFieldsForLogLevel(this.logger, input, DELETE_ITEM_SAFE_FIELDS),
380
225
  });
381
- };
226
+ const response = await this.client.send(new DeleteCommand(input));
227
+ return response;
228
+ }
382
229
  /**
383
230
  * Execute a DynamoDB Query. The full `QueryCommandOutput` is returned with
384
231
  * `Items` typed as `T[]` so callers retain pagination metadata
385
232
  * (`LastEvaluatedKey`, `Count`, etc.).
386
233
  * @template T - Expected shape of each unmarshalled item.
387
234
  */
388
- DynamoDBService.prototype.query = function (input) {
389
- return __awaiter(this, void 0, void 0, function () {
390
- var response;
391
- return __generator(this, function (_a) {
392
- switch (_a.label) {
393
- case 0:
394
- this.logger.info('Querying DynamoDB', {
395
- input: filterFieldsForLogLevel(this.logger, input, QUERY_SAFE_FIELDS),
396
- });
397
- return [4 /*yield*/, this.client.send(new QueryCommand(input))];
398
- case 1:
399
- response = _a.sent();
400
- return [2 /*return*/, response];
401
- }
402
- });
235
+ async query(input) {
236
+ this.logger.info('Querying DynamoDB', {
237
+ input: filterFieldsForLogLevel(this.logger, input, QUERY_SAFE_FIELDS),
403
238
  });
404
- };
239
+ const response = await this.client.send(new QueryCommand(input));
240
+ return response;
241
+ }
405
242
  /**
406
243
  * Scan a DynamoDB table. The full `ScanCommandOutput` is returned with
407
244
  * `Items` typed as `T[]` so callers retain pagination metadata.
@@ -421,23 +258,13 @@ var DynamoDBService = /** @class */ (function () {
421
258
  *
422
259
  * @template T - Expected shape of each unmarshalled item.
423
260
  */
424
- DynamoDBService.prototype.scan = function (input) {
425
- return __awaiter(this, void 0, void 0, function () {
426
- var response;
427
- return __generator(this, function (_a) {
428
- switch (_a.label) {
429
- case 0:
430
- this.logger.info('Scanning DynamoDB', {
431
- input: filterFieldsForLogLevel(this.logger, input, SCAN_SAFE_FIELDS),
432
- });
433
- return [4 /*yield*/, this.client.send(new ScanCommand(input))];
434
- case 1:
435
- response = _a.sent();
436
- return [2 /*return*/, response];
437
- }
438
- });
261
+ async scan(input) {
262
+ this.logger.info('Scanning DynamoDB', {
263
+ input: filterFieldsForLogLevel(this.logger, input, SCAN_SAFE_FIELDS),
439
264
  });
440
- };
265
+ const response = await this.client.send(new ScanCommand(input));
266
+ return response;
267
+ }
441
268
  /**
442
269
  * Batch-get items from one or more DynamoDB tables.
443
270
  *
@@ -446,212 +273,119 @@ var DynamoDBService = /** @class */ (function () {
446
273
  * shapes can differ per table — no single `T` can soundly describe it.
447
274
  * Callers should narrow the result type at the call site.
448
275
  */
449
- DynamoDBService.prototype.batchGet = function (input) {
450
- return __awaiter(this, void 0, void 0, function () {
451
- var logFullInput;
452
- var _a;
453
- return __generator(this, function (_b) {
454
- logFullInput = shouldLogFullInput(this.logger);
455
- this.logger.info('Batch getting DynamoDB items', {
456
- input: logFullInput ? input : { tables: Object.keys((_a = input.RequestItems) !== null && _a !== void 0 ? _a : {}) },
457
- });
458
- return [2 /*return*/, this.client.send(new BatchGetCommand(input))];
459
- });
276
+ async batchGet(input) {
277
+ // Inline verbosity check rather than `filterFieldsForLogLevel` because
278
+ // `RequestItems` is a `Record<tableName, KeysAndAttributes>` — the
279
+ // payload (`Keys[]`) lives inside the value, not as a top-level key
280
+ // the helper could pick or drop.
281
+ const logFullInput = shouldLogFullInput(this.logger);
282
+ this.logger.info('Batch getting DynamoDB items', {
283
+ input: logFullInput ? input : { tables: Object.keys(input.RequestItems ?? {}) },
460
284
  });
461
- };
285
+ return this.client.send(new BatchGetCommand(input));
286
+ }
462
287
  /**
463
288
  * Batch-write items to DynamoDB, retrying `UnprocessedItems` with jittered
464
289
  * exponential backoff. Up to 5 attempts (200ms base delay). Throws when
465
290
  * items remain unprocessed after the final attempt.
466
291
  */
467
- DynamoDBService.prototype.batchWrite = function (input) {
468
- return __awaiter(this, void 0, void 0, function () {
469
- var logFullInput, current, attempt, response, unprocessed;
470
- var _a;
471
- return __generator(this, function (_b) {
472
- switch (_b.label) {
473
- case 0:
474
- logFullInput = shouldLogFullInput(this.logger);
475
- this.logger.info('Batch writing DynamoDB items', {
476
- input: logFullInput ? input : { tables: Object.keys((_a = input.RequestItems) !== null && _a !== void 0 ? _a : {}) },
477
- });
478
- current = input;
479
- attempt = 0;
480
- _b.label = 1;
481
- case 1:
482
- if (!(attempt < BATCH_WRITE_MAX_ATTEMPTS)) return [3 /*break*/, 6];
483
- return [4 /*yield*/, this.client.send(new BatchWriteCommand(current))];
484
- case 2:
485
- response = _b.sent();
486
- unprocessed = response.UnprocessedItems;
487
- if (!unprocessed || Object.keys(unprocessed).length === 0)
488
- return [2 /*return*/, response];
489
- this.logger.warn('Retrying unprocessed DynamoDB items', {
490
- attempt: attempt + 1,
491
- tables: Object.keys(unprocessed),
492
- });
493
- if (!(attempt < BATCH_WRITE_MAX_ATTEMPTS - 1)) return [3 /*break*/, 4];
494
- return [4 /*yield*/, sleep(backoffDelay(attempt))];
495
- case 3:
496
- _b.sent();
497
- _b.label = 4;
498
- case 4:
499
- current = __assign(__assign({}, input), { RequestItems: unprocessed });
500
- _b.label = 5;
501
- case 5:
502
- attempt++;
503
- return [3 /*break*/, 1];
504
- case 6: throw new Error("batchWrite failed after ".concat(BATCH_WRITE_MAX_ATTEMPTS, " attempts"));
505
- }
506
- });
292
+ async batchWrite(input) {
293
+ // Inline verbosity check rather than `filterFieldsForLogLevel` because
294
+ // `RequestItems` is a `Record<tableName, WriteRequest[]>` — the
295
+ // payload (`PutRequest.Item` / `DeleteRequest.Key`) lives inside the
296
+ // value, not as a top-level key the helper could pick or drop.
297
+ const logFullInput = shouldLogFullInput(this.logger);
298
+ this.logger.info('Batch writing DynamoDB items', {
299
+ input: logFullInput ? input : { tables: Object.keys(input.RequestItems ?? {}) },
507
300
  });
508
- };
301
+ let current = input;
302
+ for (let attempt = 0; attempt < BATCH_WRITE_MAX_ATTEMPTS; attempt++) {
303
+ const response = await this.client.send(new BatchWriteCommand(current));
304
+ const unprocessed = response.UnprocessedItems;
305
+ if (!unprocessed || Object.keys(unprocessed).length === 0)
306
+ return response;
307
+ this.logger.warn('Retrying unprocessed DynamoDB items', {
308
+ attempt: attempt + 1,
309
+ tables: Object.keys(unprocessed),
310
+ });
311
+ if (attempt < BATCH_WRITE_MAX_ATTEMPTS - 1)
312
+ await sleep(backoffDelay(attempt));
313
+ current = { ...input, RequestItems: unprocessed };
314
+ }
315
+ throw new Error(`batchWrite failed after ${BATCH_WRITE_MAX_ATTEMPTS} attempts`);
316
+ }
509
317
  /**
510
318
  * Paginate over Query results, yielding one unmarshalled item at a time.
319
+ *
320
+ * **`Limit` is a page size, not a total cap.** DynamoDB applies it per
321
+ * request, and this method walks every page until `LastEvaluatedKey` is
322
+ * exhausted — so `paginateItems({ Limit: 10 })` yields *every* matching
323
+ * item, in pages of 10, not the first 10 items.
324
+ *
325
+ * To bound the number of items, `break` out of the loop. This is an
326
+ * `AsyncGenerator`, so `break` calls its `return()`, which unwinds the
327
+ * pagination and issues no further requests:
328
+ *
329
+ * ```ts
330
+ * const firstTen: Item[] = [];
331
+ * for await (const item of ddb.paginateItems<Item>(input)) {
332
+ * firstTen.push(item);
333
+ * if (firstTen.length === 10) break;
334
+ * }
335
+ * ```
336
+ *
337
+ * `Limit` remains the right knob for tuning per-request consumed capacity
338
+ * and page memory — set it deliberately, just don't expect it to stop the
339
+ * walk.
340
+ *
511
341
  * @template T - Expected shape of each yielded item.
512
342
  */
513
- DynamoDBService.prototype.paginateItems = function (input) {
514
- return __asyncGenerator(this, arguments, function paginateItems_1() {
515
- var paginator, _a, paginator_1, paginator_1_1, page, _i, _b, item, e_1_1;
516
- var _c, e_1, _d, _e;
517
- return __generator(this, function (_f) {
518
- switch (_f.label) {
519
- case 0:
520
- this.logger.info('Paginating DynamoDB query', {
521
- input: filterFieldsForLogLevel(this.logger, input, QUERY_SAFE_FIELDS),
522
- });
523
- paginator = paginateQuery({ client: this.client }, input);
524
- _f.label = 1;
525
- case 1:
526
- _f.trys.push([1, 10, 11, 16]);
527
- _a = true, paginator_1 = __asyncValues(paginator);
528
- _f.label = 2;
529
- case 2: return [4 /*yield*/, __await(paginator_1.next())];
530
- case 3:
531
- if (!(paginator_1_1 = _f.sent(), _c = paginator_1_1.done, !_c)) return [3 /*break*/, 9];
532
- _e = paginator_1_1.value;
533
- _a = false;
534
- page = _e;
535
- if (!page.Items)
536
- return [3 /*break*/, 8];
537
- _i = 0, _b = page.Items;
538
- _f.label = 4;
539
- case 4:
540
- if (!(_i < _b.length)) return [3 /*break*/, 8];
541
- item = _b[_i];
542
- return [4 /*yield*/, __await(item)];
543
- case 5: return [4 /*yield*/, _f.sent()];
544
- case 6:
545
- _f.sent();
546
- _f.label = 7;
547
- case 7:
548
- _i++;
549
- return [3 /*break*/, 4];
550
- case 8:
551
- _a = true;
552
- return [3 /*break*/, 2];
553
- case 9: return [3 /*break*/, 16];
554
- case 10:
555
- e_1_1 = _f.sent();
556
- e_1 = { error: e_1_1 };
557
- return [3 /*break*/, 16];
558
- case 11:
559
- _f.trys.push([11, , 14, 15]);
560
- if (!(!_a && !_c && (_d = paginator_1.return))) return [3 /*break*/, 13];
561
- return [4 /*yield*/, __await(_d.call(paginator_1))];
562
- case 12:
563
- _f.sent();
564
- _f.label = 13;
565
- case 13: return [3 /*break*/, 15];
566
- case 14:
567
- if (e_1) throw e_1.error;
568
- return [7 /*endfinally*/];
569
- case 15: return [7 /*endfinally*/];
570
- case 16: return [2 /*return*/];
571
- }
572
- });
343
+ async *paginateItems(input) {
344
+ this.logger.info('Paginating DynamoDB query', {
345
+ input: filterFieldsForLogLevel(this.logger, input, QUERY_SAFE_FIELDS),
573
346
  });
574
- };
347
+ const paginator = paginateQuery({ client: this.client }, input);
348
+ for await (const page of paginator) {
349
+ if (!page.Items)
350
+ continue;
351
+ for (const item of page.Items)
352
+ yield item;
353
+ }
354
+ }
575
355
  /**
576
356
  * Paginate over Scan results, yielding one unmarshalled item at a time.
357
+ *
358
+ * **`Limit` is a page size, not a total cap** — see `paginateItems` for the
359
+ * detail. `break` out of the loop to bound the number of items; `Limit`
360
+ * stays the right knob for per-request consumed capacity and page memory.
361
+ *
577
362
  * @template T - Expected shape of each yielded item.
578
363
  */
579
- DynamoDBService.prototype.paginateScan = function (input) {
580
- return __asyncGenerator(this, arguments, function paginateScan_1() {
581
- var paginator, _a, paginator_2, paginator_2_1, page, _i, _b, item, e_2_1;
582
- var _c, e_2, _d, _e;
583
- return __generator(this, function (_f) {
584
- switch (_f.label) {
585
- case 0:
586
- this.logger.info('Paginating DynamoDB scan', {
587
- input: filterFieldsForLogLevel(this.logger, input, SCAN_SAFE_FIELDS),
588
- });
589
- paginator = paginateScan({ client: this.client }, input);
590
- _f.label = 1;
591
- case 1:
592
- _f.trys.push([1, 10, 11, 16]);
593
- _a = true, paginator_2 = __asyncValues(paginator);
594
- _f.label = 2;
595
- case 2: return [4 /*yield*/, __await(paginator_2.next())];
596
- case 3:
597
- if (!(paginator_2_1 = _f.sent(), _c = paginator_2_1.done, !_c)) return [3 /*break*/, 9];
598
- _e = paginator_2_1.value;
599
- _a = false;
600
- page = _e;
601
- if (!page.Items)
602
- return [3 /*break*/, 8];
603
- _i = 0, _b = page.Items;
604
- _f.label = 4;
605
- case 4:
606
- if (!(_i < _b.length)) return [3 /*break*/, 8];
607
- item = _b[_i];
608
- return [4 /*yield*/, __await(item)];
609
- case 5: return [4 /*yield*/, _f.sent()];
610
- case 6:
611
- _f.sent();
612
- _f.label = 7;
613
- case 7:
614
- _i++;
615
- return [3 /*break*/, 4];
616
- case 8:
617
- _a = true;
618
- return [3 /*break*/, 2];
619
- case 9: return [3 /*break*/, 16];
620
- case 10:
621
- e_2_1 = _f.sent();
622
- e_2 = { error: e_2_1 };
623
- return [3 /*break*/, 16];
624
- case 11:
625
- _f.trys.push([11, , 14, 15]);
626
- if (!(!_a && !_c && (_d = paginator_2.return))) return [3 /*break*/, 13];
627
- return [4 /*yield*/, __await(_d.call(paginator_2))];
628
- case 12:
629
- _f.sent();
630
- _f.label = 13;
631
- case 13: return [3 /*break*/, 15];
632
- case 14:
633
- if (e_2) throw e_2.error;
634
- return [7 /*endfinally*/];
635
- case 15: return [7 /*endfinally*/];
636
- case 16: return [2 /*return*/];
637
- }
638
- });
364
+ async *paginateScan(input) {
365
+ this.logger.info('Paginating DynamoDB scan', {
366
+ input: filterFieldsForLogLevel(this.logger, input, SCAN_SAFE_FIELDS),
639
367
  });
640
- };
641
- return DynamoDBService;
642
- }());
368
+ const paginator = paginateScan({ client: this.client }, input);
369
+ for await (const page of paginator) {
370
+ if (!page.Items)
371
+ continue;
372
+ for (const item of page.Items)
373
+ yield item;
374
+ }
375
+ }
376
+ }
643
377
 
644
- var DEFAULT_PRESIGNED_URL_EXPIRES_IN_SECONDS = 3600;
645
- var DELETE_OBJECTS_BATCH_LIMIT = 1000;
378
+ const DEFAULT_PRESIGNED_URL_EXPIRES_IN_SECONDS = 3600;
379
+ const DELETE_OBJECTS_BATCH_LIMIT = 1000;
646
380
  /**
647
381
  * Fields safe to log at INFO for `putObject`. Omits `Body` (object payload).
648
382
  */
649
- var PUT_OBJECT_SAFE_FIELDS = ['Bucket', 'Key'];
383
+ const PUT_OBJECT_SAFE_FIELDS = ['Bucket', 'Key'];
650
384
  /**
651
385
  * Fields safe to log at INFO for `putJsonObject`. Omits `Body` (the
652
386
  * unserialised JSON payload). `Metadata` is included (operational labels).
653
387
  */
654
- var PUT_JSON_OBJECT_SAFE_FIELDS = [
388
+ const PUT_JSON_OBJECT_SAFE_FIELDS = [
655
389
  'Bucket',
656
390
  'Key',
657
391
  'Metadata',
@@ -668,17 +402,18 @@ var PUT_JSON_OBJECT_SAFE_FIELDS = [
668
402
  * needing SDK-level options not exposed here (server-side encryption,
669
403
  * tagging, version IDs) should use `S3Client` directly.
670
404
  */
671
- var S3Service = /** @class */ (function () {
405
+ class S3Service {
406
+ client;
407
+ logger;
672
408
  /**
673
409
  * @param opts.logger - Optional Powertools logger. Defaults to `new Logger()`,
674
410
  * which picks up `POWERTOOLS_SERVICE_NAME` from the environment.
675
411
  * @param opts.client - Optional pre-configured `S3Client`. When supplied,
676
412
  * the wrapper does not apply X-Ray instrumentation.
677
413
  */
678
- function S3Service(opts) {
679
- var _a, _b;
680
- this.client = (_a = opts === null || opts === void 0 ? void 0 : opts.client) !== null && _a !== void 0 ? _a : xray.captureAWSv3Client(new S3Client());
681
- this.logger = (_b = opts === null || opts === void 0 ? void 0 : opts.logger) !== null && _b !== void 0 ? _b : new Logger();
414
+ constructor(opts) {
415
+ this.client = opts?.client ?? xray.captureAWSv3Client(new S3Client());
416
+ this.logger = opts?.logger ?? new Logger();
682
417
  }
683
418
  /**
684
419
  * Put an object into S3.
@@ -689,16 +424,12 @@ var S3Service = /** @class */ (function () {
689
424
  *
690
425
  * @param input - Bucket, Key, and Body of the object to store.
691
426
  */
692
- S3Service.prototype.putObject = function (input) {
693
- return __awaiter(this, void 0, void 0, function () {
694
- return __generator(this, function (_a) {
695
- this.logger.info('Putting S3 object', {
696
- input: filterFieldsForLogLevel(this.logger, input, PUT_OBJECT_SAFE_FIELDS),
697
- });
698
- return [2 /*return*/, this.client.send(new PutObjectCommand(input))];
699
- });
427
+ async putObject(input) {
428
+ this.logger.info('Putting S3 object', {
429
+ input: filterFieldsForLogLevel(this.logger, input, PUT_OBJECT_SAFE_FIELDS),
700
430
  });
701
- };
431
+ return this.client.send(new PutObjectCommand(input));
432
+ }
702
433
  /**
703
434
  * Serialise a value to JSON and store it as an S3 object.
704
435
  *
@@ -708,228 +439,97 @@ var S3Service = /** @class */ (function () {
708
439
  *
709
440
  * @template T - Type of the value being stored.
710
441
  */
711
- S3Service.prototype.putJsonObject = function (input) {
712
- return __awaiter(this, void 0, void 0, function () {
713
- return __generator(this, function (_a) {
714
- this.logger.info('Putting S3 JSON object', {
715
- input: filterFieldsForLogLevel(this.logger, input, PUT_JSON_OBJECT_SAFE_FIELDS),
716
- });
717
- return [2 /*return*/, this.client.send(new PutObjectCommand({
718
- Bucket: input.Bucket,
719
- Key: input.Key,
720
- Body: JSON.stringify(input.Body),
721
- Metadata: input.Metadata,
722
- }))];
723
- });
442
+ async putJsonObject(input) {
443
+ this.logger.info('Putting S3 JSON object', {
444
+ input: filterFieldsForLogLevel(this.logger, input, PUT_JSON_OBJECT_SAFE_FIELDS),
724
445
  });
725
- };
446
+ return this.client.send(new PutObjectCommand({
447
+ Bucket: input.Bucket,
448
+ Key: input.Key,
449
+ Body: JSON.stringify(input.Body),
450
+ Metadata: input.Metadata,
451
+ }));
452
+ }
726
453
  /**
727
454
  * Get an object from S3.
728
455
  */
729
- S3Service.prototype.getObject = function (input) {
730
- return __awaiter(this, void 0, void 0, function () {
731
- return __generator(this, function (_a) {
732
- this.logger.info('Getting S3 object', { input: input });
733
- return [2 /*return*/, this.client.send(new GetObjectCommand(input))];
734
- });
735
- });
736
- };
456
+ async getObject(input) {
457
+ this.logger.info('Getting S3 object', { input });
458
+ return this.client.send(new GetObjectCommand(input));
459
+ }
737
460
  /**
738
461
  * Get an object from S3 and return its body as a string.
739
462
  * @returns The object body as a string, or `undefined` if the response
740
463
  * has no body.
741
464
  */
742
- S3Service.prototype.getObjectBody = function (input) {
743
- return __awaiter(this, void 0, void 0, function () {
744
- var response;
745
- var _a;
746
- return __generator(this, function (_b) {
747
- switch (_b.label) {
748
- case 0:
749
- this.logger.info('Getting S3 object body', { input: input });
750
- return [4 /*yield*/, this.client.send(new GetObjectCommand(input))];
751
- case 1:
752
- response = _b.sent();
753
- return [2 /*return*/, (_a = response.Body) === null || _a === void 0 ? void 0 : _a.transformToString()];
754
- }
755
- });
756
- });
757
- };
465
+ async getObjectBody(input) {
466
+ this.logger.info('Getting S3 object body', { input });
467
+ const response = await this.client.send(new GetObjectCommand(input));
468
+ return response.Body?.transformToString();
469
+ }
758
470
  /**
759
471
  * Get an object from S3 and parse it as JSON.
760
472
  * @template T - Expected type of the parsed value.
761
473
  * @returns The parsed value, or `undefined` if the response has no body.
762
474
  * @throws If the body is non-empty and not valid JSON.
763
475
  */
764
- S3Service.prototype.getJsonObject = function (input) {
765
- return __awaiter(this, void 0, void 0, function () {
766
- var response, body;
767
- var _a;
768
- return __generator(this, function (_b) {
769
- switch (_b.label) {
770
- case 0:
771
- this.logger.info('Getting S3 JSON object', { input: input });
772
- return [4 /*yield*/, this.client.send(new GetObjectCommand(input))];
773
- case 1:
774
- response = _b.sent();
775
- return [4 /*yield*/, ((_a = response.Body) === null || _a === void 0 ? void 0 : _a.transformToString())];
776
- case 2:
777
- body = _b.sent();
778
- return [2 /*return*/, body ? JSON.parse(body) : undefined];
779
- }
780
- });
781
- });
782
- };
476
+ async getJsonObject(input) {
477
+ this.logger.info('Getting S3 JSON object', { input });
478
+ const response = await this.client.send(new GetObjectCommand(input));
479
+ const body = await response.Body?.transformToString();
480
+ return body ? JSON.parse(body) : undefined;
481
+ }
783
482
  /**
784
483
  * Fetch the metadata for an S3 object without downloading its body.
785
484
  */
786
- S3Service.prototype.headObject = function (input) {
787
- return __awaiter(this, void 0, void 0, function () {
788
- return __generator(this, function (_a) {
789
- this.logger.info('Fetching S3 object metadata', { input: input });
790
- return [2 /*return*/, this.client.send(new HeadObjectCommand(input))];
791
- });
792
- });
793
- };
485
+ async headObject(input) {
486
+ this.logger.info('Fetching S3 object metadata', { input });
487
+ return this.client.send(new HeadObjectCommand(input));
488
+ }
794
489
  /**
795
490
  * Copy an object within S3.
796
491
  */
797
- S3Service.prototype.copyObject = function (input) {
798
- return __awaiter(this, void 0, void 0, function () {
799
- return __generator(this, function (_a) {
800
- this.logger.info('Copying S3 object', { input: input });
801
- return [2 /*return*/, this.client.send(new CopyObjectCommand(input))];
802
- });
803
- });
804
- };
492
+ async copyObject(input) {
493
+ this.logger.info('Copying S3 object', { input });
494
+ return this.client.send(new CopyObjectCommand(input));
495
+ }
805
496
  /**
806
497
  * List object keys under a bucket and optional prefix, auto-paginating
807
498
  * across all pages.
808
499
  */
809
- S3Service.prototype.listObjects = function (bucket, prefix) {
810
- return __awaiter(this, void 0, void 0, function () {
811
- var paginator, keys, _a, paginator_1, paginator_1_1, page, _i, _b, object, e_1_1;
812
- var _c, e_1, _d, _e;
813
- var _f;
814
- return __generator(this, function (_g) {
815
- switch (_g.label) {
816
- case 0:
817
- this.logger.info('Listing S3 objects', { input: { bucket: bucket, prefix: prefix } });
818
- paginator = paginateListObjectsV2({ client: this.client }, { Bucket: bucket, Prefix: prefix });
819
- keys = [];
820
- _g.label = 1;
821
- case 1:
822
- _g.trys.push([1, 6, 7, 12]);
823
- _a = true, paginator_1 = __asyncValues(paginator);
824
- _g.label = 2;
825
- case 2: return [4 /*yield*/, paginator_1.next()];
826
- case 3:
827
- if (!(paginator_1_1 = _g.sent(), _c = paginator_1_1.done, !_c)) return [3 /*break*/, 5];
828
- _e = paginator_1_1.value;
829
- _a = false;
830
- page = _e;
831
- for (_i = 0, _b = (_f = page.Contents) !== null && _f !== void 0 ? _f : []; _i < _b.length; _i++) {
832
- object = _b[_i];
833
- if (object.Key)
834
- keys.push(object.Key);
835
- }
836
- _g.label = 4;
837
- case 4:
838
- _a = true;
839
- return [3 /*break*/, 2];
840
- case 5: return [3 /*break*/, 12];
841
- case 6:
842
- e_1_1 = _g.sent();
843
- e_1 = { error: e_1_1 };
844
- return [3 /*break*/, 12];
845
- case 7:
846
- _g.trys.push([7, , 10, 11]);
847
- if (!(!_a && !_c && (_d = paginator_1.return))) return [3 /*break*/, 9];
848
- return [4 /*yield*/, _d.call(paginator_1)];
849
- case 8:
850
- _g.sent();
851
- _g.label = 9;
852
- case 9: return [3 /*break*/, 11];
853
- case 10:
854
- if (e_1) throw e_1.error;
855
- return [7 /*endfinally*/];
856
- case 11: return [7 /*endfinally*/];
857
- case 12: return [2 /*return*/, keys];
858
- }
859
- });
860
- });
861
- };
500
+ async listObjects(bucket, prefix) {
501
+ this.logger.info('Listing S3 objects', { input: { bucket, prefix } });
502
+ const paginator = paginateListObjectsV2({ client: this.client }, { Bucket: bucket, Prefix: prefix });
503
+ const keys = [];
504
+ for await (const page of paginator) {
505
+ for (const object of page.Contents ?? []) {
506
+ if (object.Key)
507
+ keys.push(object.Key);
508
+ }
509
+ }
510
+ return keys;
511
+ }
862
512
  /**
863
513
  * List and JSON-parse every object under a bucket and optional prefix.
864
514
  * Auto-paginated. Objects without a body are skipped.
865
515
  * @template T - Expected type of each parsed object.
866
516
  */
867
- S3Service.prototype.getAllObjects = function (bucket, prefix) {
868
- return __awaiter(this, void 0, void 0, function () {
869
- var paginator, bodies, _a, paginator_2, paginator_2_1, page, _i, _b, object, response, body, e_2_1;
870
- var _c, e_2, _d, _e;
871
- var _f, _g;
872
- return __generator(this, function (_h) {
873
- switch (_h.label) {
874
- case 0:
875
- this.logger.info('Getting all S3 objects', { input: { bucket: bucket, prefix: prefix } });
876
- paginator = paginateListObjectsV2({ client: this.client }, { Bucket: bucket, Prefix: prefix });
877
- bodies = [];
878
- _h.label = 1;
879
- case 1:
880
- _h.trys.push([1, 10, 11, 16]);
881
- _a = true, paginator_2 = __asyncValues(paginator);
882
- _h.label = 2;
883
- case 2: return [4 /*yield*/, paginator_2.next()];
884
- case 3:
885
- if (!(paginator_2_1 = _h.sent(), _c = paginator_2_1.done, !_c)) return [3 /*break*/, 9];
886
- _e = paginator_2_1.value;
887
- _a = false;
888
- page = _e;
889
- _i = 0, _b = (_f = page.Contents) !== null && _f !== void 0 ? _f : [];
890
- _h.label = 4;
891
- case 4:
892
- if (!(_i < _b.length)) return [3 /*break*/, 8];
893
- object = _b[_i];
894
- if (!object.Key)
895
- return [3 /*break*/, 7];
896
- return [4 /*yield*/, this.client.send(new GetObjectCommand({ Bucket: bucket, Key: object.Key }))];
897
- case 5:
898
- response = _h.sent();
899
- return [4 /*yield*/, ((_g = response.Body) === null || _g === void 0 ? void 0 : _g.transformToString())];
900
- case 6:
901
- body = _h.sent();
902
- if (body)
903
- bodies.push(JSON.parse(body));
904
- _h.label = 7;
905
- case 7:
906
- _i++;
907
- return [3 /*break*/, 4];
908
- case 8:
909
- _a = true;
910
- return [3 /*break*/, 2];
911
- case 9: return [3 /*break*/, 16];
912
- case 10:
913
- e_2_1 = _h.sent();
914
- e_2 = { error: e_2_1 };
915
- return [3 /*break*/, 16];
916
- case 11:
917
- _h.trys.push([11, , 14, 15]);
918
- if (!(!_a && !_c && (_d = paginator_2.return))) return [3 /*break*/, 13];
919
- return [4 /*yield*/, _d.call(paginator_2)];
920
- case 12:
921
- _h.sent();
922
- _h.label = 13;
923
- case 13: return [3 /*break*/, 15];
924
- case 14:
925
- if (e_2) throw e_2.error;
926
- return [7 /*endfinally*/];
927
- case 15: return [7 /*endfinally*/];
928
- case 16: return [2 /*return*/, bodies];
929
- }
930
- });
931
- });
932
- };
517
+ async getAllObjects(bucket, prefix) {
518
+ this.logger.info('Getting all S3 objects', { input: { bucket, prefix } });
519
+ const paginator = paginateListObjectsV2({ client: this.client }, { Bucket: bucket, Prefix: prefix });
520
+ const bodies = [];
521
+ for await (const page of paginator) {
522
+ for (const object of page.Contents ?? []) {
523
+ if (!object.Key)
524
+ continue;
525
+ const response = await this.client.send(new GetObjectCommand({ Bucket: bucket, Key: object.Key }));
526
+ const body = await response.Body?.transformToString();
527
+ if (body)
528
+ bodies.push(JSON.parse(body));
529
+ }
530
+ }
531
+ return bodies;
532
+ }
933
533
  /**
934
534
  * Generate a presigned URL that callers can use to GET or PUT an S3 object
935
535
  * directly, without going through the wrapper. The signing happens against
@@ -948,137 +548,81 @@ var S3Service = /** @class */ (function () {
948
548
  * @param input.action - `'get'` to download, `'put'` to upload.
949
549
  * @param input.expiresIn - URL lifetime in seconds. Defaults to 3600 (1 hour).
950
550
  */
951
- S3Service.prototype.getPresignedUrl = function (input) {
952
- return __awaiter(this, void 0, void 0, function () {
953
- var expiresIn, command;
954
- var _a;
955
- return __generator(this, function (_b) {
956
- expiresIn = (_a = input.expiresIn) !== null && _a !== void 0 ? _a : DEFAULT_PRESIGNED_URL_EXPIRES_IN_SECONDS;
957
- this.logger.info('Generating S3 presigned URL', {
958
- input: { Bucket: input.Bucket, Key: input.Key, action: input.action, expiresIn: expiresIn },
959
- });
960
- command = input.action === 'get'
961
- ? new GetObjectCommand({
962
- Bucket: input.Bucket,
963
- Key: input.Key,
964
- ResponseContentDisposition: 'attachment',
965
- })
966
- : new PutObjectCommand({ Bucket: input.Bucket, Key: input.Key });
967
- return [2 /*return*/, getSignedUrl(this.client, command, { expiresIn: expiresIn })];
968
- });
551
+ async getPresignedUrl(input) {
552
+ const expiresIn = input.expiresIn ?? DEFAULT_PRESIGNED_URL_EXPIRES_IN_SECONDS;
553
+ this.logger.info('Generating S3 presigned URL', {
554
+ input: { Bucket: input.Bucket, Key: input.Key, action: input.action, expiresIn },
969
555
  });
970
- };
556
+ const command = input.action === 'get'
557
+ ? new GetObjectCommand({
558
+ Bucket: input.Bucket,
559
+ Key: input.Key,
560
+ ResponseContentDisposition: 'attachment',
561
+ })
562
+ : new PutObjectCommand({ Bucket: input.Bucket, Key: input.Key });
563
+ return getSignedUrl(this.client, command, { expiresIn });
564
+ }
971
565
  /**
972
566
  * Delete a single object from S3.
973
567
  */
974
- S3Service.prototype.deleteObject = function (input) {
975
- return __awaiter(this, void 0, void 0, function () {
976
- return __generator(this, function (_a) {
977
- this.logger.info('Deleting S3 object', { input: input });
978
- return [2 /*return*/, this.client.send(new DeleteObjectCommand(input))];
979
- });
980
- });
981
- };
568
+ async deleteObject(input) {
569
+ this.logger.info('Deleting S3 object', { input });
570
+ return this.client.send(new DeleteObjectCommand(input));
571
+ }
982
572
  /**
983
573
  * Delete multiple objects from S3, auto-chunking the request into batches
984
574
  * of 1000 keys (the S3-enforced DeleteObjects limit). Returns one output
985
575
  * per chunk.
986
576
  */
987
- S3Service.prototype.deleteObjects = function (bucket, keys) {
988
- return __awaiter(this, void 0, void 0, function () {
989
- var logFullInput, results, i, batch, _a, _b;
990
- return __generator(this, function (_c) {
991
- switch (_c.label) {
992
- case 0:
993
- logFullInput = shouldLogFullInput(this.logger);
994
- this.logger.info('Deleting S3 objects', {
995
- input: logFullInput ? { bucket: bucket, keys: keys } : { bucket: bucket, keyCount: keys.length },
996
- });
997
- results = [];
998
- i = 0;
999
- _c.label = 1;
1000
- case 1:
1001
- if (!(i < keys.length)) return [3 /*break*/, 4];
1002
- batch = keys.slice(i, i + DELETE_OBJECTS_BATCH_LIMIT);
1003
- _b = (_a = results).push;
1004
- return [4 /*yield*/, this.client.send(new DeleteObjectsCommand({
1005
- Bucket: bucket,
1006
- Delete: { Objects: batch.map(function (Key) { return ({ Key: Key }); }) },
1007
- }))];
1008
- case 2:
1009
- _b.apply(_a, [_c.sent()]);
1010
- _c.label = 3;
1011
- case 3:
1012
- i += DELETE_OBJECTS_BATCH_LIMIT;
1013
- return [3 /*break*/, 1];
1014
- case 4: return [2 /*return*/, results];
1015
- }
1016
- });
577
+ async deleteObjects(bucket, keys) {
578
+ // Inline verbosity check rather than `filterFieldsForLogLevel` because the
579
+ // safe log shape includes the computed `keyCount`, which isn't a key
580
+ // on any SDK input type.
581
+ const logFullInput = shouldLogFullInput(this.logger);
582
+ this.logger.info('Deleting S3 objects', {
583
+ input: logFullInput ? { bucket, keys } : { bucket, keyCount: keys.length },
1017
584
  });
1018
- };
1019
- /**
1020
- * Delete every object in a bucket. Streams the listing page-by-page and
1021
- * delegates each page's deletion to `deleteObjects`, so peak memory stays
1022
- * bounded by one page (~1000 keys) regardless of bucket size.
1023
- * @returns The keys of every deleted object.
1024
- */
1025
- S3Service.prototype.emptyBucket = function (bucket) {
1026
- return __awaiter(this, void 0, void 0, function () {
1027
- var paginator, deletedKeys, _a, paginator_3, paginator_3_1, page, keys, e_3_1;
1028
- var _b, e_3, _c, _d;
1029
- var _e;
1030
- return __generator(this, function (_f) {
1031
- switch (_f.label) {
1032
- case 0:
1033
- this.logger.info('Emptying S3 bucket', { input: { bucket: bucket } });
1034
- paginator = paginateListObjectsV2({ client: this.client }, { Bucket: bucket });
1035
- deletedKeys = [];
1036
- _f.label = 1;
1037
- case 1:
1038
- _f.trys.push([1, 7, 8, 13]);
1039
- _a = true, paginator_3 = __asyncValues(paginator);
1040
- _f.label = 2;
1041
- case 2: return [4 /*yield*/, paginator_3.next()];
1042
- case 3:
1043
- if (!(paginator_3_1 = _f.sent(), _b = paginator_3_1.done, !_b)) return [3 /*break*/, 6];
1044
- _d = paginator_3_1.value;
1045
- _a = false;
1046
- page = _d;
1047
- keys = ((_e = page.Contents) !== null && _e !== void 0 ? _e : []).flatMap(function (o) { return (o.Key ? [o.Key] : []); });
1048
- if (keys.length === 0)
1049
- return [3 /*break*/, 5];
1050
- return [4 /*yield*/, this.deleteObjects(bucket, keys)];
1051
- case 4:
1052
- _f.sent();
1053
- deletedKeys.push.apply(deletedKeys, keys);
1054
- _f.label = 5;
1055
- case 5:
1056
- _a = true;
1057
- return [3 /*break*/, 2];
1058
- case 6: return [3 /*break*/, 13];
1059
- case 7:
1060
- e_3_1 = _f.sent();
1061
- e_3 = { error: e_3_1 };
1062
- return [3 /*break*/, 13];
1063
- case 8:
1064
- _f.trys.push([8, , 11, 12]);
1065
- if (!(!_a && !_b && (_c = paginator_3.return))) return [3 /*break*/, 10];
1066
- return [4 /*yield*/, _c.call(paginator_3)];
1067
- case 9:
1068
- _f.sent();
1069
- _f.label = 10;
1070
- case 10: return [3 /*break*/, 12];
1071
- case 11:
1072
- if (e_3) throw e_3.error;
1073
- return [7 /*endfinally*/];
1074
- case 12: return [7 /*endfinally*/];
1075
- case 13: return [2 /*return*/, deletedKeys];
1076
- }
1077
- });
1078
- });
1079
- };
1080
- return S3Service;
1081
- }());
585
+ const results = [];
586
+ for (let i = 0; i < keys.length; i += DELETE_OBJECTS_BATCH_LIMIT) {
587
+ const batch = keys.slice(i, i + DELETE_OBJECTS_BATCH_LIMIT);
588
+ results.push(await this.client.send(new DeleteObjectsCommand({
589
+ Bucket: bucket,
590
+ Delete: { Objects: batch.map(Key => ({ Key })) },
591
+ })));
592
+ }
593
+ return results;
594
+ }
595
+ /**
596
+ * Delete every object in an **unversioned** bucket. Streams the listing
597
+ * page-by-page and delegates each page's deletion to `deleteObjects`, so
598
+ * peak memory stays bounded by one page (~1000 keys) regardless of bucket
599
+ * size.
600
+ *
601
+ * **Versioned buckets are out of scope.** This paginates `ListObjectsV2`,
602
+ * which reports only current object versions — never noncurrent versions or
603
+ * delete markers. Against a versioned bucket the call therefore succeeds and
604
+ * the bucket then *looks* empty to `ListObjectsV2`, but the deletes only
605
+ * added delete markers: every object version is still stored, still billed,
606
+ * and `DeleteBucket` will still fail with `BucketNotEmpty`. Emptying a
607
+ * versioned bucket requires `ListObjectVersions` and per-version deletes;
608
+ * use `S3Client` directly for that.
609
+ *
610
+ * @returns The keys this call issued deletes for.
611
+ */
612
+ async emptyBucket(bucket) {
613
+ this.logger.info('Emptying S3 bucket', { input: { bucket } });
614
+ const paginator = paginateListObjectsV2({ client: this.client }, { Bucket: bucket });
615
+ const deletedKeys = [];
616
+ for await (const page of paginator) {
617
+ const keys = (page.Contents ?? []).flatMap(o => (o.Key ? [o.Key] : []));
618
+ if (keys.length === 0)
619
+ continue;
620
+ await this.deleteObjects(bucket, keys);
621
+ deletedKeys.push(...keys);
622
+ }
623
+ return deletedKeys;
624
+ }
625
+ }
1082
626
 
1083
627
  /**
1084
628
  * `CreateSchedule` / `UpdateSchedule` inputs carry the payload handed to the
@@ -1099,13 +643,12 @@ var S3Service = /** @class */ (function () {
1099
643
  * seeing payloads and PII.
1100
644
  */
1101
645
  function redactTargetInput(logger, input) {
1102
- var _a;
1103
646
  if (shouldLogFullInput(logger))
1104
647
  return input;
1105
- if (((_a = input.Target) === null || _a === void 0 ? void 0 : _a.Input) === undefined)
648
+ if (input.Target?.Input === undefined)
1106
649
  return input;
1107
- var _b = input.Target; _b.Input; var safeTarget = __rest(_b, ["Input"]);
1108
- return __assign(__assign({}, input), { Target: safeTarget });
650
+ const { Input: _input, ...safeTarget } = input.Target;
651
+ return { ...input, Target: safeTarget };
1109
652
  }
1110
653
  /**
1111
654
  * Wrapper around the AWS EventBridge Scheduler client providing structured
@@ -1123,41 +666,34 @@ function redactTargetInput(logger, input) {
1123
666
  * untouched — the wrapper bakes in no default, so the caller must state their
1124
667
  * intent (`{ Mode: 'OFF' }` for a fixed-time schedule).
1125
668
  */
1126
- var SchedulerService = /** @class */ (function () {
669
+ class SchedulerService {
670
+ client;
671
+ logger;
1127
672
  /**
1128
673
  * @param opts.logger - Optional Powertools logger. Defaults to `new Logger()`,
1129
674
  * which picks up `POWERTOOLS_SERVICE_NAME` from the environment.
1130
675
  * @param opts.client - Optional pre-configured `SchedulerClient`. When
1131
676
  * supplied, the wrapper does not apply X-Ray instrumentation.
1132
677
  */
1133
- function SchedulerService(opts) {
1134
- var _a, _b;
1135
- this.client = (_a = opts === null || opts === void 0 ? void 0 : opts.client) !== null && _a !== void 0 ? _a : xray.captureAWSv3Client(new SchedulerClient());
1136
- this.logger = (_b = opts === null || opts === void 0 ? void 0 : opts.logger) !== null && _b !== void 0 ? _b : new Logger();
678
+ constructor(opts) {
679
+ this.client = opts?.client ?? xray.captureAWSv3Client(new SchedulerClient());
680
+ this.logger = opts?.logger ?? new Logger();
1137
681
  }
1138
682
  /**
1139
683
  * Create a new schedule. At INFO the log line omits `Target.Input` (the
1140
684
  * target payload, a PII carrier).
1141
685
  */
1142
- SchedulerService.prototype.createSchedule = function (input) {
1143
- return __awaiter(this, void 0, void 0, function () {
1144
- return __generator(this, function (_a) {
1145
- this.logger.info('Creating schedule', { input: redactTargetInput(this.logger, input) });
1146
- return [2 /*return*/, this.client.send(new CreateScheduleCommand(input))];
1147
- });
1148
- });
1149
- };
686
+ async createSchedule(input) {
687
+ this.logger.info('Creating schedule', { input: redactTargetInput(this.logger, input) });
688
+ return this.client.send(new CreateScheduleCommand(input));
689
+ }
1150
690
  /**
1151
691
  * Fetch a schedule's full configuration.
1152
692
  */
1153
- SchedulerService.prototype.getSchedule = function (input) {
1154
- return __awaiter(this, void 0, void 0, function () {
1155
- return __generator(this, function (_a) {
1156
- this.logger.info('Getting schedule', { input: input });
1157
- return [2 /*return*/, this.client.send(new GetScheduleCommand(input))];
1158
- });
1159
- });
1160
- };
693
+ async getSchedule(input) {
694
+ this.logger.info('Getting schedule', { input });
695
+ return this.client.send(new GetScheduleCommand(input));
696
+ }
1161
697
  /**
1162
698
  * Update an existing schedule.
1163
699
  *
@@ -1171,176 +707,77 @@ var SchedulerService = /** @class */ (function () {
1171
707
  *
1172
708
  * At INFO the log line omits `Target.Input`.
1173
709
  */
1174
- SchedulerService.prototype.updateSchedule = function (input) {
1175
- return __awaiter(this, void 0, void 0, function () {
1176
- return __generator(this, function (_a) {
1177
- this.logger.info('Updating schedule', { input: redactTargetInput(this.logger, input) });
1178
- return [2 /*return*/, this.client.send(new UpdateScheduleCommand(input))];
1179
- });
1180
- });
1181
- };
710
+ async updateSchedule(input) {
711
+ this.logger.info('Updating schedule', { input: redactTargetInput(this.logger, input) });
712
+ return this.client.send(new UpdateScheduleCommand(input));
713
+ }
1182
714
  /**
1183
715
  * Delete a schedule.
1184
716
  */
1185
- SchedulerService.prototype.deleteSchedule = function (input) {
1186
- return __awaiter(this, void 0, void 0, function () {
1187
- return __generator(this, function (_a) {
1188
- this.logger.info('Deleting schedule', { input: input });
1189
- return [2 /*return*/, this.client.send(new DeleteScheduleCommand(input))];
1190
- });
1191
- });
1192
- };
717
+ async deleteSchedule(input) {
718
+ this.logger.info('Deleting schedule', { input });
719
+ return this.client.send(new DeleteScheduleCommand(input));
720
+ }
1193
721
  /**
1194
722
  * List schedules, auto-paginating across all pages. Bounded in practice by
1195
723
  * the account's schedule count and the `GroupName` / `NamePrefix` / `State`
1196
724
  * filters, so the flat-array shape is safe.
1197
725
  */
1198
- SchedulerService.prototype.listSchedules = function (input) {
1199
- return __awaiter(this, void 0, void 0, function () {
1200
- var paginator, schedules, _a, paginator_1, paginator_1_1, page, e_1_1;
1201
- var _b, e_1, _c, _d;
1202
- return __generator(this, function (_e) {
1203
- switch (_e.label) {
1204
- case 0:
1205
- this.logger.info('Listing schedules', { input: input });
1206
- paginator = paginateListSchedules({ client: this.client }, input !== null && input !== void 0 ? input : {});
1207
- schedules = [];
1208
- _e.label = 1;
1209
- case 1:
1210
- _e.trys.push([1, 6, 7, 12]);
1211
- _a = true, paginator_1 = __asyncValues(paginator);
1212
- _e.label = 2;
1213
- case 2: return [4 /*yield*/, paginator_1.next()];
1214
- case 3:
1215
- if (!(paginator_1_1 = _e.sent(), _b = paginator_1_1.done, !_b)) return [3 /*break*/, 5];
1216
- _d = paginator_1_1.value;
1217
- _a = false;
1218
- page = _d;
1219
- if (page.Schedules)
1220
- schedules.push.apply(schedules, page.Schedules);
1221
- _e.label = 4;
1222
- case 4:
1223
- _a = true;
1224
- return [3 /*break*/, 2];
1225
- case 5: return [3 /*break*/, 12];
1226
- case 6:
1227
- e_1_1 = _e.sent();
1228
- e_1 = { error: e_1_1 };
1229
- return [3 /*break*/, 12];
1230
- case 7:
1231
- _e.trys.push([7, , 10, 11]);
1232
- if (!(!_a && !_b && (_c = paginator_1.return))) return [3 /*break*/, 9];
1233
- return [4 /*yield*/, _c.call(paginator_1)];
1234
- case 8:
1235
- _e.sent();
1236
- _e.label = 9;
1237
- case 9: return [3 /*break*/, 11];
1238
- case 10:
1239
- if (e_1) throw e_1.error;
1240
- return [7 /*endfinally*/];
1241
- case 11: return [7 /*endfinally*/];
1242
- case 12: return [2 /*return*/, schedules];
1243
- }
1244
- });
1245
- });
1246
- };
726
+ async listSchedules(input) {
727
+ this.logger.info('Listing schedules', { input });
728
+ const paginator = paginateListSchedules({ client: this.client }, input ?? {});
729
+ const schedules = [];
730
+ for await (const page of paginator) {
731
+ if (page.Schedules)
732
+ schedules.push(...page.Schedules);
733
+ }
734
+ return schedules;
735
+ }
1247
736
  /**
1248
737
  * Create a new schedule group. Groups are containers for schedules and are
1249
738
  * typically IaC-managed; use this for dynamically-provisioned groups only.
1250
739
  */
1251
- SchedulerService.prototype.createScheduleGroup = function (input) {
1252
- return __awaiter(this, void 0, void 0, function () {
1253
- return __generator(this, function (_a) {
1254
- this.logger.info('Creating schedule group', { input: input });
1255
- return [2 /*return*/, this.client.send(new CreateScheduleGroupCommand(input))];
1256
- });
1257
- });
1258
- };
740
+ async createScheduleGroup(input) {
741
+ this.logger.info('Creating schedule group', { input });
742
+ return this.client.send(new CreateScheduleGroupCommand(input));
743
+ }
1259
744
  /**
1260
745
  * Fetch a schedule group's configuration.
1261
746
  */
1262
- SchedulerService.prototype.getScheduleGroup = function (input) {
1263
- return __awaiter(this, void 0, void 0, function () {
1264
- return __generator(this, function (_a) {
1265
- this.logger.info('Getting schedule group', { input: input });
1266
- return [2 /*return*/, this.client.send(new GetScheduleGroupCommand(input))];
1267
- });
1268
- });
1269
- };
747
+ async getScheduleGroup(input) {
748
+ this.logger.info('Getting schedule group', { input });
749
+ return this.client.send(new GetScheduleGroupCommand(input));
750
+ }
1270
751
  /**
1271
752
  * Delete a schedule group. Deleting a group also deletes every schedule it
1272
753
  * contains, asynchronously — the API has no `UpdateScheduleGroup`, so this
1273
754
  * is the only mutating group operation besides create.
1274
755
  */
1275
- SchedulerService.prototype.deleteScheduleGroup = function (input) {
1276
- return __awaiter(this, void 0, void 0, function () {
1277
- return __generator(this, function (_a) {
1278
- this.logger.info('Deleting schedule group', { input: input });
1279
- return [2 /*return*/, this.client.send(new DeleteScheduleGroupCommand(input))];
1280
- });
1281
- });
1282
- };
756
+ async deleteScheduleGroup(input) {
757
+ this.logger.info('Deleting schedule group', { input });
758
+ return this.client.send(new DeleteScheduleGroupCommand(input));
759
+ }
1283
760
  /**
1284
761
  * List schedule groups, auto-paginating across all pages. Bounded in
1285
762
  * practice by the account's group count and the `NamePrefix` filter.
1286
763
  */
1287
- SchedulerService.prototype.listScheduleGroups = function (input) {
1288
- return __awaiter(this, void 0, void 0, function () {
1289
- var paginator, groups, _a, paginator_2, paginator_2_1, page, e_2_1;
1290
- var _b, e_2, _c, _d;
1291
- return __generator(this, function (_e) {
1292
- switch (_e.label) {
1293
- case 0:
1294
- this.logger.info('Listing schedule groups', { input: input });
1295
- paginator = paginateListScheduleGroups({ client: this.client }, input !== null && input !== void 0 ? input : {});
1296
- groups = [];
1297
- _e.label = 1;
1298
- case 1:
1299
- _e.trys.push([1, 6, 7, 12]);
1300
- _a = true, paginator_2 = __asyncValues(paginator);
1301
- _e.label = 2;
1302
- case 2: return [4 /*yield*/, paginator_2.next()];
1303
- case 3:
1304
- if (!(paginator_2_1 = _e.sent(), _b = paginator_2_1.done, !_b)) return [3 /*break*/, 5];
1305
- _d = paginator_2_1.value;
1306
- _a = false;
1307
- page = _d;
1308
- if (page.ScheduleGroups)
1309
- groups.push.apply(groups, page.ScheduleGroups);
1310
- _e.label = 4;
1311
- case 4:
1312
- _a = true;
1313
- return [3 /*break*/, 2];
1314
- case 5: return [3 /*break*/, 12];
1315
- case 6:
1316
- e_2_1 = _e.sent();
1317
- e_2 = { error: e_2_1 };
1318
- return [3 /*break*/, 12];
1319
- case 7:
1320
- _e.trys.push([7, , 10, 11]);
1321
- if (!(!_a && !_b && (_c = paginator_2.return))) return [3 /*break*/, 9];
1322
- return [4 /*yield*/, _c.call(paginator_2)];
1323
- case 8:
1324
- _e.sent();
1325
- _e.label = 9;
1326
- case 9: return [3 /*break*/, 11];
1327
- case 10:
1328
- if (e_2) throw e_2.error;
1329
- return [7 /*endfinally*/];
1330
- case 11: return [7 /*endfinally*/];
1331
- case 12: return [2 /*return*/, groups];
1332
- }
1333
- });
1334
- });
1335
- };
1336
- return SchedulerService;
1337
- }());
764
+ async listScheduleGroups(input) {
765
+ this.logger.info('Listing schedule groups', { input });
766
+ const paginator = paginateListScheduleGroups({ client: this.client }, input ?? {});
767
+ const groups = [];
768
+ for await (const page of paginator) {
769
+ if (page.ScheduleGroups)
770
+ groups.push(...page.ScheduleGroups);
771
+ }
772
+ return groups;
773
+ }
774
+ }
1338
775
 
1339
776
  /**
1340
777
  * Fields safe to log at INFO level. Omits `SecretString` and `SecretBinary` —
1341
778
  * the secret material itself.
1342
779
  */
1343
- var CREATE_SECRET_SAFE_FIELDS = [
780
+ const CREATE_SECRET_SAFE_FIELDS = [
1344
781
  'Name',
1345
782
  'Description',
1346
783
  'KmsKeyId',
@@ -1349,13 +786,13 @@ var CREATE_SECRET_SAFE_FIELDS = [
1349
786
  'AddReplicaRegions',
1350
787
  'ForceOverwriteReplicaSecret',
1351
788
  ];
1352
- var UPDATE_SECRET_SAFE_FIELDS = [
789
+ const UPDATE_SECRET_SAFE_FIELDS = [
1353
790
  'SecretId',
1354
791
  'Description',
1355
792
  'KmsKeyId',
1356
793
  'ClientRequestToken',
1357
794
  ];
1358
- var PUT_SECRET_VALUE_SAFE_FIELDS = [
795
+ const PUT_SECRET_VALUE_SAFE_FIELDS = [
1359
796
  'SecretId',
1360
797
  'VersionStages',
1361
798
  'ClientRequestToken',
@@ -1365,7 +802,7 @@ var PUT_SECRET_VALUE_SAFE_FIELDS = [
1365
802
  * explicit allowlist keeps the log shape consistent with the other write
1366
803
  * methods and protects against future field additions.
1367
804
  */
1368
- var DELETE_SECRET_SAFE_FIELDS = [
805
+ const DELETE_SECRET_SAFE_FIELDS = [
1369
806
  'SecretId',
1370
807
  'RecoveryWindowInDays',
1371
808
  'ForceDeleteWithoutRecovery',
@@ -1385,7 +822,9 @@ var DELETE_SECRET_SAFE_FIELDS = [
1385
822
  * dynamically-issued credentials, rotation flows, or other genuinely
1386
823
  * mutable values.
1387
824
  */
1388
- var SecretsManagerService = /** @class */ (function () {
825
+ class SecretsManagerService {
826
+ client;
827
+ logger;
1389
828
  /**
1390
829
  * @param opts.logger - Optional Powertools logger. Defaults to `new Logger()`,
1391
830
  * which picks up `POWERTOOLS_SERVICE_NAME` from the environment.
@@ -1393,10 +832,9 @@ var SecretsManagerService = /** @class */ (function () {
1393
832
  * supplied, the wrapper does not apply X-Ray instrumentation — the caller
1394
833
  * owns that decision.
1395
834
  */
1396
- function SecretsManagerService(opts) {
1397
- var _a, _b;
1398
- this.client = (_a = opts === null || opts === void 0 ? void 0 : opts.client) !== null && _a !== void 0 ? _a : xray.captureAWSv3Client(new SecretsManagerClient());
1399
- this.logger = (_b = opts === null || opts === void 0 ? void 0 : opts.logger) !== null && _b !== void 0 ? _b : new Logger();
835
+ constructor(opts) {
836
+ this.client = opts?.client ?? xray.captureAWSv3Client(new SecretsManagerClient());
837
+ this.logger = opts?.logger ?? new Logger();
1400
838
  }
1401
839
  /**
1402
840
  * Fetch a secret's string value from Secrets Manager.
@@ -1405,14 +843,10 @@ var SecretsManagerService = /** @class */ (function () {
1405
843
  * @throws If the response does not contain a `SecretString` (e.g. the secret
1406
844
  * stores binary data).
1407
845
  */
1408
- SecretsManagerService.prototype.getSecret = function (secretId) {
1409
- return __awaiter(this, void 0, void 0, function () {
1410
- return __generator(this, function (_a) {
1411
- this.logger.info('Fetching secret', { input: { secretId: secretId } });
1412
- return [2 /*return*/, this.fetchSecretString(secretId)];
1413
- });
1414
- });
1415
- };
846
+ async getSecret(secretId) {
847
+ this.logger.info('Fetching secret', { input: { secretId } });
848
+ return this.fetchSecretString(secretId);
849
+ }
1416
850
  /**
1417
851
  * Fetch a secret and parse it as JSON.
1418
852
  * @param secretId - The ARN or friendly name of the secret.
@@ -1420,21 +854,11 @@ var SecretsManagerService = /** @class */ (function () {
1420
854
  * @returns The parsed secret value.
1421
855
  * @throws If the secret has no `SecretString` or the value is not valid JSON.
1422
856
  */
1423
- SecretsManagerService.prototype.getJsonSecret = function (secretId) {
1424
- return __awaiter(this, void 0, void 0, function () {
1425
- var secretString;
1426
- return __generator(this, function (_a) {
1427
- switch (_a.label) {
1428
- case 0:
1429
- this.logger.info('Fetching JSON secret', { input: { secretId: secretId } });
1430
- return [4 /*yield*/, this.fetchSecretString(secretId)];
1431
- case 1:
1432
- secretString = _a.sent();
1433
- return [2 /*return*/, JSON.parse(secretString)];
1434
- }
1435
- });
1436
- });
1437
- };
857
+ async getJsonSecret(secretId) {
858
+ this.logger.info('Fetching JSON secret', { input: { secretId } });
859
+ const secretString = await this.fetchSecretString(secretId);
860
+ return JSON.parse(secretString);
861
+ }
1438
862
  /**
1439
863
  * Create a new secret. At INFO level the log line includes only identity
1440
864
  * and non-secret metadata.
@@ -1442,16 +866,12 @@ var SecretsManagerService = /** @class */ (function () {
1442
866
  * Prefer IaC (CDK / Terraform) for secret lifecycle — use this for
1443
867
  * dynamically-issued credentials only.
1444
868
  */
1445
- SecretsManagerService.prototype.createSecret = function (input) {
1446
- return __awaiter(this, void 0, void 0, function () {
1447
- return __generator(this, function (_a) {
1448
- this.logger.info('Creating secret', {
1449
- input: filterFieldsForLogLevel(this.logger, input, CREATE_SECRET_SAFE_FIELDS),
1450
- });
1451
- return [2 /*return*/, this.client.send(new CreateSecretCommand(input))];
1452
- });
869
+ async createSecret(input) {
870
+ this.logger.info('Creating secret', {
871
+ input: filterFieldsForLogLevel(this.logger, input, CREATE_SECRET_SAFE_FIELDS),
1453
872
  });
1454
- };
873
+ return this.client.send(new CreateSecretCommand(input));
874
+ }
1455
875
  /**
1456
876
  * Update an existing secret's metadata or value. At INFO level the log
1457
877
  * line omits `SecretString` / `SecretBinary`.
@@ -1459,73 +879,51 @@ var SecretsManagerService = /** @class */ (function () {
1459
879
  * Prefer IaC (CDK / Terraform) for secret lifecycle — use this for
1460
880
  * runtime metadata updates only.
1461
881
  */
1462
- SecretsManagerService.prototype.updateSecret = function (input) {
1463
- return __awaiter(this, void 0, void 0, function () {
1464
- return __generator(this, function (_a) {
1465
- this.logger.info('Updating secret', {
1466
- input: filterFieldsForLogLevel(this.logger, input, UPDATE_SECRET_SAFE_FIELDS),
1467
- });
1468
- return [2 /*return*/, this.client.send(new UpdateSecretCommand(input))];
1469
- });
882
+ async updateSecret(input) {
883
+ this.logger.info('Updating secret', {
884
+ input: filterFieldsForLogLevel(this.logger, input, UPDATE_SECRET_SAFE_FIELDS),
1470
885
  });
1471
- };
886
+ return this.client.send(new UpdateSecretCommand(input));
887
+ }
1472
888
  /**
1473
889
  * Store a new version of a secret's value. At INFO level the log line
1474
890
  * omits `SecretString` / `SecretBinary`.
1475
891
  *
1476
892
  * Typically used by rotation flows.
1477
893
  */
1478
- SecretsManagerService.prototype.putSecretValue = function (input) {
1479
- return __awaiter(this, void 0, void 0, function () {
1480
- return __generator(this, function (_a) {
1481
- this.logger.info('Putting secret value', {
1482
- input: filterFieldsForLogLevel(this.logger, input, PUT_SECRET_VALUE_SAFE_FIELDS),
1483
- });
1484
- return [2 /*return*/, this.client.send(new PutSecretValueCommand(input))];
1485
- });
894
+ async putSecretValue(input) {
895
+ this.logger.info('Putting secret value', {
896
+ input: filterFieldsForLogLevel(this.logger, input, PUT_SECRET_VALUE_SAFE_FIELDS),
1486
897
  });
1487
- };
898
+ return this.client.send(new PutSecretValueCommand(input));
899
+ }
1488
900
  /**
1489
901
  * Delete a secret. Pass `ForceDeleteWithoutRecovery: true` to bypass the
1490
902
  * default 7-30 day recovery window (irreversible).
1491
903
  *
1492
904
  * Prefer IaC (CDK / Terraform) for secret lifecycle.
1493
905
  */
1494
- SecretsManagerService.prototype.deleteSecret = function (input) {
1495
- return __awaiter(this, void 0, void 0, function () {
1496
- return __generator(this, function (_a) {
1497
- this.logger.info('Deleting secret', {
1498
- input: filterFieldsForLogLevel(this.logger, input, DELETE_SECRET_SAFE_FIELDS),
1499
- });
1500
- return [2 /*return*/, this.client.send(new DeleteSecretCommand(input))];
1501
- });
1502
- });
1503
- };
1504
- SecretsManagerService.prototype.fetchSecretString = function (secretId) {
1505
- return __awaiter(this, void 0, void 0, function () {
1506
- var response;
1507
- return __generator(this, function (_a) {
1508
- switch (_a.label) {
1509
- case 0: return [4 /*yield*/, this.client.send(new GetSecretValueCommand({ SecretId: secretId }))];
1510
- case 1:
1511
- response = _a.sent();
1512
- if (response.SecretString === undefined) {
1513
- throw new Error("Secret '".concat(secretId, "' does not contain a string value"));
1514
- }
1515
- return [2 /*return*/, response.SecretString];
1516
- }
1517
- });
906
+ async deleteSecret(input) {
907
+ this.logger.info('Deleting secret', {
908
+ input: filterFieldsForLogLevel(this.logger, input, DELETE_SECRET_SAFE_FIELDS),
1518
909
  });
1519
- };
1520
- return SecretsManagerService;
1521
- }());
910
+ return this.client.send(new DeleteSecretCommand(input));
911
+ }
912
+ async fetchSecretString(secretId) {
913
+ const response = await this.client.send(new GetSecretValueCommand({ SecretId: secretId }));
914
+ if (response.SecretString === undefined) {
915
+ throw new Error(`Secret '${secretId}' does not contain a string value`);
916
+ }
917
+ return response.SecretString;
918
+ }
919
+ }
1522
920
 
1523
921
  /**
1524
922
  * Fields safe to log at INFO for `startExecution`. Omits `input` — the SFN
1525
923
  * execution payload, which routinely carries PII (customer IDs, addresses,
1526
924
  * order contents, etc.).
1527
925
  */
1528
- var START_EXECUTION_SAFE_FIELDS = [
926
+ const START_EXECUTION_SAFE_FIELDS = [
1529
927
  'stateMachineArn',
1530
928
  'name',
1531
929
  'traceHeader',
@@ -1538,109 +936,58 @@ var START_EXECUTION_SAFE_FIELDS = [
1538
936
  * log line omits them; the verbose levels (`POWERTOOLS_LOG_LEVEL=DEBUG` or
1539
937
  * `TRACE`) log full SDK inputs.
1540
938
  */
1541
- var StepFunctionsService = /** @class */ (function () {
939
+ class StepFunctionsService {
940
+ client;
941
+ logger;
1542
942
  /**
1543
943
  * @param opts.logger - Optional Powertools logger. Defaults to `new Logger()`,
1544
944
  * which picks up `POWERTOOLS_SERVICE_NAME` from the environment.
1545
945
  * @param opts.client - Optional pre-configured `SFNClient`. When supplied,
1546
946
  * the wrapper does not apply X-Ray instrumentation.
1547
947
  */
1548
- function StepFunctionsService(opts) {
1549
- var _a, _b;
1550
- this.client = (_a = opts === null || opts === void 0 ? void 0 : opts.client) !== null && _a !== void 0 ? _a : xray.captureAWSv3Client(new SFNClient());
1551
- this.logger = (_b = opts === null || opts === void 0 ? void 0 : opts.logger) !== null && _b !== void 0 ? _b : new Logger();
948
+ constructor(opts) {
949
+ this.client = opts?.client ?? xray.captureAWSv3Client(new SFNClient());
950
+ this.logger = opts?.logger ?? new Logger();
1552
951
  }
1553
952
  /**
1554
953
  * List all executions for a state machine, auto-paginating across all
1555
954
  * pages. Typically bounded by `statusFilter` and state-machine retention,
1556
955
  * so the flat-array shape is safe in practice.
1557
956
  */
1558
- StepFunctionsService.prototype.listExecutions = function (input) {
1559
- return __awaiter(this, void 0, void 0, function () {
1560
- var paginator, executions, _a, paginator_1, paginator_1_1, page, e_1_1;
1561
- var _b, e_1, _c, _d;
1562
- return __generator(this, function (_e) {
1563
- switch (_e.label) {
1564
- case 0:
1565
- this.logger.info('Listing Step Functions executions', { input: input });
1566
- paginator = paginateListExecutions({ client: this.client }, input);
1567
- executions = [];
1568
- _e.label = 1;
1569
- case 1:
1570
- _e.trys.push([1, 6, 7, 12]);
1571
- _a = true, paginator_1 = __asyncValues(paginator);
1572
- _e.label = 2;
1573
- case 2: return [4 /*yield*/, paginator_1.next()];
1574
- case 3:
1575
- if (!(paginator_1_1 = _e.sent(), _b = paginator_1_1.done, !_b)) return [3 /*break*/, 5];
1576
- _d = paginator_1_1.value;
1577
- _a = false;
1578
- page = _d;
1579
- if (page.executions)
1580
- executions.push.apply(executions, page.executions);
1581
- _e.label = 4;
1582
- case 4:
1583
- _a = true;
1584
- return [3 /*break*/, 2];
1585
- case 5: return [3 /*break*/, 12];
1586
- case 6:
1587
- e_1_1 = _e.sent();
1588
- e_1 = { error: e_1_1 };
1589
- return [3 /*break*/, 12];
1590
- case 7:
1591
- _e.trys.push([7, , 10, 11]);
1592
- if (!(!_a && !_b && (_c = paginator_1.return))) return [3 /*break*/, 9];
1593
- return [4 /*yield*/, _c.call(paginator_1)];
1594
- case 8:
1595
- _e.sent();
1596
- _e.label = 9;
1597
- case 9: return [3 /*break*/, 11];
1598
- case 10:
1599
- if (e_1) throw e_1.error;
1600
- return [7 /*endfinally*/];
1601
- case 11: return [7 /*endfinally*/];
1602
- case 12: return [2 /*return*/, executions];
1603
- }
1604
- });
1605
- });
1606
- };
957
+ async listExecutions(input) {
958
+ this.logger.info('Listing Step Functions executions', { input });
959
+ const paginator = paginateListExecutions({ client: this.client }, input);
960
+ const executions = [];
961
+ for await (const page of paginator) {
962
+ if (page.executions)
963
+ executions.push(...page.executions);
964
+ }
965
+ return executions;
966
+ }
1607
967
  /**
1608
968
  * Start a new Step Functions execution.
1609
969
  */
1610
- StepFunctionsService.prototype.startExecution = function (input) {
1611
- return __awaiter(this, void 0, void 0, function () {
1612
- return __generator(this, function (_a) {
1613
- this.logger.info('Starting Step Functions execution', {
1614
- input: filterFieldsForLogLevel(this.logger, input, START_EXECUTION_SAFE_FIELDS),
1615
- });
1616
- return [2 /*return*/, this.client.send(new StartExecutionCommand(input))];
1617
- });
970
+ async startExecution(input) {
971
+ this.logger.info('Starting Step Functions execution', {
972
+ input: filterFieldsForLogLevel(this.logger, input, START_EXECUTION_SAFE_FIELDS),
1618
973
  });
1619
- };
974
+ return this.client.send(new StartExecutionCommand(input));
975
+ }
1620
976
  /**
1621
977
  * Describe an existing Step Functions execution.
1622
978
  */
1623
- StepFunctionsService.prototype.describeExecution = function (input) {
1624
- return __awaiter(this, void 0, void 0, function () {
1625
- return __generator(this, function (_a) {
1626
- this.logger.info('Describing Step Functions execution', { input: input });
1627
- return [2 /*return*/, this.client.send(new DescribeExecutionCommand(input))];
1628
- });
1629
- });
1630
- };
979
+ async describeExecution(input) {
980
+ this.logger.info('Describing Step Functions execution', { input });
981
+ return this.client.send(new DescribeExecutionCommand(input));
982
+ }
1631
983
  /**
1632
984
  * Stop an in-progress Step Functions execution.
1633
985
  */
1634
- StepFunctionsService.prototype.stopExecution = function (input) {
1635
- return __awaiter(this, void 0, void 0, function () {
1636
- return __generator(this, function (_a) {
1637
- this.logger.info('Stopping Step Functions execution', { input: input });
1638
- return [2 /*return*/, this.client.send(new StopExecutionCommand(input))];
1639
- });
1640
- });
1641
- };
1642
- return StepFunctionsService;
1643
- }());
986
+ async stopExecution(input) {
987
+ this.logger.info('Stopping Step Functions execution', { input });
988
+ return this.client.send(new StopExecutionCommand(input));
989
+ }
990
+ }
1644
991
 
1645
992
  /**
1646
993
  * Truncate a UTF-8 string to fit within `maxBytes` when encoded as UTF-8.
@@ -1650,12 +997,12 @@ var StepFunctionsService = /** @class */ (function () {
1650
997
  * it already fits.
1651
998
  */
1652
999
  function truncateUtf8(str, maxBytes) {
1653
- var buf = Buffer.from(str, 'utf8');
1000
+ const buf = Buffer.from(str, 'utf8');
1654
1001
  if (buf.length <= maxBytes)
1655
1002
  return str;
1656
- var end = maxBytes;
1003
+ let end = maxBytes;
1657
1004
  while (end > 0) {
1658
- var byte = buf[end];
1005
+ const byte = buf[end];
1659
1006
  if (byte === undefined || (byte & 0xc0) !== 0x80)
1660
1007
  break;
1661
1008
  end--;
@@ -1669,22 +1016,22 @@ function truncateUtf8(str, maxBytes) {
1669
1016
  * it already fits.
1670
1017
  */
1671
1018
  function truncateCodepoints(str, maxChars) {
1672
- var codepoints = Array.from(str);
1019
+ const codepoints = Array.from(str);
1673
1020
  if (codepoints.length <= maxChars)
1674
1021
  return str;
1675
1022
  return codepoints.slice(0, maxChars).join('');
1676
1023
  }
1677
1024
 
1678
- var PUBLISH_BATCH_LIMIT = 10;
1679
- var SNS_MESSAGE_MAX_BYTES = 256 * 1024;
1680
- var SNS_SUBJECT_MAX_CHARS = 100;
1025
+ const PUBLISH_BATCH_LIMIT = 10;
1026
+ const SNS_MESSAGE_MAX_BYTES = 256 * 1024;
1027
+ const SNS_SUBJECT_MAX_CHARS = 100;
1681
1028
  /**
1682
1029
  * Fields safe to log at INFO level for `publish`. Omits `Message`, `Subject`,
1683
1030
  * `MessageAttributes`, and `PhoneNumber` — payloads, user-visible content
1684
1031
  * (subjects often carry order numbers / customer names), and PII recipient
1685
1032
  * identifiers.
1686
1033
  */
1687
- var PUBLISH_SAFE_FIELDS = [
1034
+ const PUBLISH_SAFE_FIELDS = [
1688
1035
  'TopicArn',
1689
1036
  'TargetArn',
1690
1037
  'MessageStructure',
@@ -1699,7 +1046,10 @@ var PUBLISH_SAFE_FIELDS = [
1699
1046
  * log line omits them; the verbose levels (`POWERTOOLS_LOG_LEVEL=DEBUG` or
1700
1047
  * `TRACE`) log full SDK inputs.
1701
1048
  */
1702
- var SNSService = /** @class */ (function () {
1049
+ class SNSService {
1050
+ client;
1051
+ logger;
1052
+ truncate;
1703
1053
  /**
1704
1054
  * @param opts.logger - Optional Powertools logger. Defaults to `new Logger()`,
1705
1055
  * which picks up `POWERTOOLS_SERVICE_NAME` from the environment.
@@ -1711,11 +1061,10 @@ var SNSService = /** @class */ (function () {
1711
1061
  * usually the right failure mode. Each `publish` call can override via
1712
1062
  * its own `truncate` option.
1713
1063
  */
1714
- function SNSService(opts) {
1715
- var _a, _b, _c;
1716
- this.client = (_a = opts === null || opts === void 0 ? void 0 : opts.client) !== null && _a !== void 0 ? _a : xray.captureAWSv3Client(new SNSClient());
1717
- this.logger = (_b = opts === null || opts === void 0 ? void 0 : opts.logger) !== null && _b !== void 0 ? _b : new Logger();
1718
- this.truncate = (_c = opts === null || opts === void 0 ? void 0 : opts.truncate) !== null && _c !== void 0 ? _c : false;
1064
+ constructor(opts) {
1065
+ this.client = opts?.client ?? xray.captureAWSv3Client(new SNSClient());
1066
+ this.logger = opts?.logger ?? new Logger();
1067
+ this.truncate = opts?.truncate ?? false;
1719
1068
  }
1720
1069
  /**
1721
1070
  * Publish a single message to an SNS topic.
@@ -1725,37 +1074,43 @@ var SNSService = /** @class */ (function () {
1725
1074
  *
1726
1075
  * @param input - PublishCommandInput including TopicArn and Message.
1727
1076
  */
1728
- SNSService.prototype.publish = function (input, opts) {
1729
- return __awaiter(this, void 0, void 0, function () {
1730
- var shouldTruncate, effective;
1731
- var _a;
1732
- return __generator(this, function (_b) {
1733
- shouldTruncate = (_a = opts === null || opts === void 0 ? void 0 : opts.truncate) !== null && _a !== void 0 ? _a : this.truncate;
1734
- effective = shouldTruncate ? this.applyTruncation(input) : input;
1735
- this.logger.info('Publishing SNS message', {
1736
- input: filterFieldsForLogLevel(this.logger, effective, PUBLISH_SAFE_FIELDS),
1737
- });
1738
- return [2 /*return*/, this.client.send(new PublishCommand(effective))];
1739
- });
1077
+ async publish(input, opts) {
1078
+ const shouldTruncate = opts?.truncate ?? this.truncate;
1079
+ const effective = shouldTruncate ? this.applyTruncation(input) : input;
1080
+ this.logger.info('Publishing SNS message', {
1081
+ input: filterFieldsForLogLevel(this.logger, effective, PUBLISH_SAFE_FIELDS),
1740
1082
  });
1741
- };
1742
- SNSService.prototype.applyTruncation = function (input) {
1743
- var truncated = [];
1744
- var Message = input.Message;
1745
- if (Message !== undefined && Buffer.byteLength(Message, 'utf8') > SNS_MESSAGE_MAX_BYTES) {
1746
- Message = truncateUtf8(Message, SNS_MESSAGE_MAX_BYTES);
1747
- truncated.push('Message');
1083
+ return this.client.send(new PublishCommand(effective));
1084
+ }
1085
+ /**
1086
+ * The truncation helpers return the input unchanged when it already fits, so
1087
+ * a `!==` comparison against their result is what decides whether a field
1088
+ * was modified. Don't reintroduce a size guard here: that would state each
1089
+ * limit twice, encode the string to a `Buffer` twice, and let the two
1090
+ * expressions drift into warning without truncating (or the reverse).
1091
+ */
1092
+ applyTruncation(input) {
1093
+ const truncated = [];
1094
+ const out = { ...input };
1095
+ if (out.Message !== undefined) {
1096
+ const next = truncateUtf8(out.Message, SNS_MESSAGE_MAX_BYTES);
1097
+ if (next !== out.Message) {
1098
+ out.Message = next;
1099
+ truncated.push('Message');
1100
+ }
1748
1101
  }
1749
- var Subject = input.Subject;
1750
- if (Subject !== undefined && Array.from(Subject).length > SNS_SUBJECT_MAX_CHARS) {
1751
- Subject = truncateCodepoints(Subject, SNS_SUBJECT_MAX_CHARS);
1752
- truncated.push('Subject');
1102
+ if (out.Subject !== undefined) {
1103
+ const next = truncateCodepoints(out.Subject, SNS_SUBJECT_MAX_CHARS);
1104
+ if (next !== out.Subject) {
1105
+ out.Subject = next;
1106
+ truncated.push('Subject');
1107
+ }
1753
1108
  }
1754
1109
  if (truncated.length > 0) {
1755
1110
  this.logger.warn('Truncated SNS publish input', { fields: truncated });
1756
1111
  }
1757
- return __assign(__assign({}, input), { Message: Message, Subject: Subject });
1758
- };
1112
+ return out;
1113
+ }
1759
1114
  /**
1760
1115
  * Publish a batch of messages to an SNS topic. The SNS API caps
1761
1116
  * PublishBatch at 10 entries per request, so this method auto-chunks
@@ -1763,47 +1118,34 @@ var SNSService = /** @class */ (function () {
1763
1118
  * chunk, returning the array of outputs.
1764
1119
  * @param input - PublishBatchCommandInput including TopicArn and entries.
1765
1120
  */
1766
- SNSService.prototype.publishBatch = function (input) {
1767
- return __awaiter(this, void 0, void 0, function () {
1768
- var entries, logFullInput, results, i, chunk, _a, _b;
1769
- var _c;
1770
- return __generator(this, function (_d) {
1771
- switch (_d.label) {
1772
- case 0:
1773
- entries = (_c = input.PublishBatchRequestEntries) !== null && _c !== void 0 ? _c : [];
1774
- logFullInput = shouldLogFullInput(this.logger);
1775
- this.logger.info('Publishing SNS message batch', {
1776
- input: logFullInput ? input : { TopicArn: input.TopicArn, entryCount: entries.length },
1777
- });
1778
- results = [];
1779
- i = 0;
1780
- _d.label = 1;
1781
- case 1:
1782
- if (!(i < entries.length)) return [3 /*break*/, 4];
1783
- chunk = entries.slice(i, i + PUBLISH_BATCH_LIMIT);
1784
- _b = (_a = results).push;
1785
- return [4 /*yield*/, this.client.send(new PublishBatchCommand(__assign(__assign({}, input), { PublishBatchRequestEntries: chunk })))];
1786
- case 2:
1787
- _b.apply(_a, [_d.sent()]);
1788
- _d.label = 3;
1789
- case 3:
1790
- i += PUBLISH_BATCH_LIMIT;
1791
- return [3 /*break*/, 1];
1792
- case 4: return [2 /*return*/, results];
1793
- }
1794
- });
1121
+ async publishBatch(input) {
1122
+ const entries = input.PublishBatchRequestEntries ?? [];
1123
+ // Inline verbosity check rather than `filterFieldsForLogLevel` because the
1124
+ // safe log shape includes the computed `entryCount`, which isn't a key
1125
+ // on `PublishBatchCommandInput`.
1126
+ const logFullInput = shouldLogFullInput(this.logger);
1127
+ this.logger.info('Publishing SNS message batch', {
1128
+ input: logFullInput ? input : { TopicArn: input.TopicArn, entryCount: entries.length },
1795
1129
  });
1796
- };
1797
- return SNSService;
1798
- }());
1130
+ const results = [];
1131
+ for (let i = 0; i < entries.length; i += PUBLISH_BATCH_LIMIT) {
1132
+ const chunk = entries.slice(i, i + PUBLISH_BATCH_LIMIT);
1133
+ results.push(await this.client.send(new PublishBatchCommand({
1134
+ ...input,
1135
+ PublishBatchRequestEntries: chunk,
1136
+ })));
1137
+ }
1138
+ return results;
1139
+ }
1140
+ }
1799
1141
 
1800
- var SQS_BATCH_LIMIT = 10;
1801
- var SQS_MESSAGE_BODY_MAX_BYTES = 256 * 1024;
1142
+ const SQS_BATCH_LIMIT = 10;
1143
+ const SQS_MESSAGE_BODY_MAX_BYTES = 256 * 1024;
1802
1144
  /**
1803
1145
  * Fields safe to log at INFO level for `sendMessage`. Omits `MessageBody` and
1804
1146
  * `MessageAttributes` — both carry payload content.
1805
1147
  */
1806
- var SEND_MESSAGE_SAFE_FIELDS = [
1148
+ const SEND_MESSAGE_SAFE_FIELDS = [
1807
1149
  'QueueUrl',
1808
1150
  'DelaySeconds',
1809
1151
  'MessageGroupId',
@@ -1817,7 +1159,10 @@ var SEND_MESSAGE_SAFE_FIELDS = [
1817
1159
  * log line omits them; the verbose levels (`POWERTOOLS_LOG_LEVEL=DEBUG` or
1818
1160
  * `TRACE`) log full SDK inputs.
1819
1161
  */
1820
- var SQSService = /** @class */ (function () {
1162
+ class SQSService {
1163
+ client;
1164
+ logger;
1165
+ truncate;
1821
1166
  /**
1822
1167
  * @param opts.logger - Optional Powertools logger. Defaults to `new Logger()`,
1823
1168
  * which picks up `POWERTOOLS_SERVICE_NAME` from the environment.
@@ -1828,11 +1173,10 @@ var SQSService = /** @class */ (function () {
1828
1173
  * `false`. Each `sendMessage` call can override via its own `truncate`
1829
1174
  * option.
1830
1175
  */
1831
- function SQSService(opts) {
1832
- var _a, _b, _c;
1833
- this.client = (_a = opts === null || opts === void 0 ? void 0 : opts.client) !== null && _a !== void 0 ? _a : xray.captureAWSv3Client(new SQSClient());
1834
- this.logger = (_b = opts === null || opts === void 0 ? void 0 : opts.logger) !== null && _b !== void 0 ? _b : new Logger();
1835
- this.truncate = (_c = opts === null || opts === void 0 ? void 0 : opts.truncate) !== null && _c !== void 0 ? _c : false;
1176
+ constructor(opts) {
1177
+ this.client = opts?.client ?? xray.captureAWSv3Client(new SQSClient());
1178
+ this.logger = opts?.logger ?? new Logger();
1179
+ this.truncate = opts?.truncate ?? false;
1836
1180
  }
1837
1181
  /**
1838
1182
  * Send a single message to an SQS queue.
@@ -1840,146 +1184,103 @@ var SQSService = /** @class */ (function () {
1840
1184
  * At INFO level the log line includes only queue routing / FIFO metadata;
1841
1185
  * see `SEND_MESSAGE_SAFE_FIELDS`.
1842
1186
  */
1843
- SQSService.prototype.sendMessage = function (input, opts) {
1844
- return __awaiter(this, void 0, void 0, function () {
1845
- var shouldTruncate, effective;
1846
- var _a;
1847
- return __generator(this, function (_b) {
1848
- shouldTruncate = (_a = opts === null || opts === void 0 ? void 0 : opts.truncate) !== null && _a !== void 0 ? _a : this.truncate;
1849
- effective = shouldTruncate ? this.applyTruncation(input) : input;
1850
- this.logger.info('Sending SQS message', {
1851
- input: filterFieldsForLogLevel(this.logger, effective, SEND_MESSAGE_SAFE_FIELDS),
1852
- });
1853
- return [2 /*return*/, this.client.send(new SendMessageCommand(effective))];
1854
- });
1187
+ async sendMessage(input, opts) {
1188
+ const shouldTruncate = opts?.truncate ?? this.truncate;
1189
+ const effective = shouldTruncate ? this.applyTruncation(input) : input;
1190
+ this.logger.info('Sending SQS message', {
1191
+ input: filterFieldsForLogLevel(this.logger, effective, SEND_MESSAGE_SAFE_FIELDS),
1855
1192
  });
1856
- };
1857
- SQSService.prototype.applyTruncation = function (input) {
1858
- var truncated = [];
1859
- var MessageBody = input.MessageBody;
1860
- if (MessageBody !== undefined &&
1861
- Buffer.byteLength(MessageBody, 'utf8') > SQS_MESSAGE_BODY_MAX_BYTES) {
1862
- MessageBody = truncateUtf8(MessageBody, SQS_MESSAGE_BODY_MAX_BYTES);
1863
- truncated.push('MessageBody');
1193
+ return this.client.send(new SendMessageCommand(effective));
1194
+ }
1195
+ /**
1196
+ * `truncateUtf8` returns the input unchanged when it already fits, so a
1197
+ * `!==` comparison against its result is what decides whether the body was
1198
+ * modified. Don't reintroduce a size guard here: that would state the limit
1199
+ * twice, encode the string to a `Buffer` twice, and let the two expressions
1200
+ * drift into warning without truncating (or the reverse).
1201
+ */
1202
+ applyTruncation(input) {
1203
+ const truncated = [];
1204
+ const out = { ...input };
1205
+ if (out.MessageBody !== undefined) {
1206
+ const next = truncateUtf8(out.MessageBody, SQS_MESSAGE_BODY_MAX_BYTES);
1207
+ if (next !== out.MessageBody) {
1208
+ out.MessageBody = next;
1209
+ truncated.push('MessageBody');
1210
+ }
1864
1211
  }
1865
1212
  if (truncated.length > 0) {
1866
1213
  this.logger.warn('Truncated SQS sendMessage input', { fields: truncated });
1867
1214
  }
1868
- return __assign(__assign({}, input), { MessageBody: MessageBody });
1869
- };
1215
+ return out;
1216
+ }
1870
1217
  /**
1871
1218
  * Receive messages from an SQS queue. Returns an empty array when no
1872
1219
  * messages are available. No automatic deletion is performed — visibility
1873
1220
  * timeout semantics are the caller's responsibility.
1874
1221
  * @returns The `Messages` array from the response, or `[]` if absent.
1875
1222
  */
1876
- SQSService.prototype.receiveMessages = function (input) {
1877
- return __awaiter(this, void 0, void 0, function () {
1878
- var response;
1879
- var _a;
1880
- return __generator(this, function (_b) {
1881
- switch (_b.label) {
1882
- case 0:
1883
- this.logger.info('Receiving SQS messages', { input: input });
1884
- return [4 /*yield*/, this.client.send(new ReceiveMessageCommand(input))];
1885
- case 1:
1886
- response = _b.sent();
1887
- return [2 /*return*/, (_a = response.Messages) !== null && _a !== void 0 ? _a : []];
1888
- }
1889
- });
1890
- });
1891
- };
1223
+ async receiveMessages(input) {
1224
+ this.logger.info('Receiving SQS messages', { input });
1225
+ const response = await this.client.send(new ReceiveMessageCommand(input));
1226
+ return response.Messages ?? [];
1227
+ }
1892
1228
  /**
1893
1229
  * Delete a single message from an SQS queue.
1894
1230
  */
1895
- SQSService.prototype.deleteMessage = function (input) {
1896
- return __awaiter(this, void 0, void 0, function () {
1897
- return __generator(this, function (_a) {
1898
- this.logger.info('Deleting SQS message', { input: input });
1899
- return [2 /*return*/, this.client.send(new DeleteMessageCommand(input))];
1900
- });
1901
- });
1902
- };
1231
+ async deleteMessage(input) {
1232
+ this.logger.info('Deleting SQS message', { input });
1233
+ return this.client.send(new DeleteMessageCommand(input));
1234
+ }
1903
1235
  /**
1904
1236
  * Send a batch of messages to an SQS queue. The SQS API caps
1905
1237
  * SendMessageBatch at 10 entries per request, so this method auto-chunks
1906
1238
  * the caller's entries and sends one request per chunk.
1907
1239
  */
1908
- SQSService.prototype.sendMessageBatch = function (input) {
1909
- return __awaiter(this, void 0, void 0, function () {
1910
- var entries, logFullInput, results, i, chunk, _a, _b;
1911
- var _c;
1912
- return __generator(this, function (_d) {
1913
- switch (_d.label) {
1914
- case 0:
1915
- entries = (_c = input.Entries) !== null && _c !== void 0 ? _c : [];
1916
- logFullInput = shouldLogFullInput(this.logger);
1917
- this.logger.info('Sending SQS message batch', {
1918
- input: logFullInput ? input : { QueueUrl: input.QueueUrl, entryCount: entries.length },
1919
- });
1920
- results = [];
1921
- i = 0;
1922
- _d.label = 1;
1923
- case 1:
1924
- if (!(i < entries.length)) return [3 /*break*/, 4];
1925
- chunk = entries.slice(i, i + SQS_BATCH_LIMIT);
1926
- _b = (_a = results).push;
1927
- return [4 /*yield*/, this.client.send(new SendMessageBatchCommand(__assign(__assign({}, input), { Entries: chunk })))];
1928
- case 2:
1929
- _b.apply(_a, [_d.sent()]);
1930
- _d.label = 3;
1931
- case 3:
1932
- i += SQS_BATCH_LIMIT;
1933
- return [3 /*break*/, 1];
1934
- case 4: return [2 /*return*/, results];
1935
- }
1936
- });
1240
+ async sendMessageBatch(input) {
1241
+ const entries = input.Entries ?? [];
1242
+ // Inline verbosity check rather than `filterFieldsForLogLevel` because the
1243
+ // safe log shape includes the computed `entryCount`, which isn't a key
1244
+ // on `SendMessageBatchCommandInput`.
1245
+ const logFullInput = shouldLogFullInput(this.logger);
1246
+ this.logger.info('Sending SQS message batch', {
1247
+ input: logFullInput ? input : { QueueUrl: input.QueueUrl, entryCount: entries.length },
1937
1248
  });
1938
- };
1249
+ const results = [];
1250
+ for (let i = 0; i < entries.length; i += SQS_BATCH_LIMIT) {
1251
+ const chunk = entries.slice(i, i + SQS_BATCH_LIMIT);
1252
+ results.push(await this.client.send(new SendMessageBatchCommand({ ...input, Entries: chunk })));
1253
+ }
1254
+ return results;
1255
+ }
1939
1256
  /**
1940
1257
  * Delete a batch of messages from an SQS queue. The SQS API caps
1941
1258
  * DeleteMessageBatch at 10 entries per request, so this method auto-chunks
1942
1259
  * the caller's entries and sends one request per chunk.
1943
1260
  */
1944
- SQSService.prototype.deleteMessageBatch = function (input) {
1945
- return __awaiter(this, void 0, void 0, function () {
1946
- var entries, logFullInput, results, i, chunk, _a, _b;
1947
- var _c;
1948
- return __generator(this, function (_d) {
1949
- switch (_d.label) {
1950
- case 0:
1951
- entries = (_c = input.Entries) !== null && _c !== void 0 ? _c : [];
1952
- logFullInput = shouldLogFullInput(this.logger);
1953
- this.logger.info('Deleting SQS message batch', {
1954
- input: logFullInput ? input : { QueueUrl: input.QueueUrl, entryCount: entries.length },
1955
- });
1956
- results = [];
1957
- i = 0;
1958
- _d.label = 1;
1959
- case 1:
1960
- if (!(i < entries.length)) return [3 /*break*/, 4];
1961
- chunk = entries.slice(i, i + SQS_BATCH_LIMIT);
1962
- _b = (_a = results).push;
1963
- return [4 /*yield*/, this.client.send(new DeleteMessageBatchCommand(__assign(__assign({}, input), { Entries: chunk })))];
1964
- case 2:
1965
- _b.apply(_a, [_d.sent()]);
1966
- _d.label = 3;
1967
- case 3:
1968
- i += SQS_BATCH_LIMIT;
1969
- return [3 /*break*/, 1];
1970
- case 4: return [2 /*return*/, results];
1971
- }
1972
- });
1261
+ async deleteMessageBatch(input) {
1262
+ const entries = input.Entries ?? [];
1263
+ // Inline verbosity check rather than `filterFieldsForLogLevel` because the
1264
+ // safe log shape includes the computed `entryCount`, which isn't a key
1265
+ // on `DeleteMessageBatchCommandInput`.
1266
+ const logFullInput = shouldLogFullInput(this.logger);
1267
+ this.logger.info('Deleting SQS message batch', {
1268
+ input: logFullInput ? input : { QueueUrl: input.QueueUrl, entryCount: entries.length },
1973
1269
  });
1974
- };
1975
- return SQSService;
1976
- }());
1270
+ const results = [];
1271
+ for (let i = 0; i < entries.length; i += SQS_BATCH_LIMIT) {
1272
+ const chunk = entries.slice(i, i + SQS_BATCH_LIMIT);
1273
+ results.push(await this.client.send(new DeleteMessageBatchCommand({ ...input, Entries: chunk })));
1274
+ }
1275
+ return results;
1276
+ }
1277
+ }
1977
1278
 
1978
1279
  /**
1979
1280
  * Fields safe to log at INFO level for `putParameter`. Omits `Value` (the
1980
1281
  * parameter content itself).
1981
1282
  */
1982
- var PUT_PARAMETER_SAFE_FIELDS = [
1283
+ const PUT_PARAMETER_SAFE_FIELDS = [
1983
1284
  'Name',
1984
1285
  'Type',
1985
1286
  'Description',
@@ -2007,17 +1308,18 @@ var PUT_PARAMETER_SAFE_FIELDS = [
2007
1308
  * deploy time; reserve runtime writes for values that genuinely need to
2008
1309
  * mutate within the application.
2009
1310
  */
2010
- var SSMService = /** @class */ (function () {
1311
+ class SSMService {
1312
+ client;
1313
+ logger;
2011
1314
  /**
2012
1315
  * @param opts.logger - Optional Powertools logger. Defaults to `new Logger()`,
2013
1316
  * which picks up `POWERTOOLS_SERVICE_NAME` from the environment.
2014
1317
  * @param opts.client - Optional pre-configured `SSMClient`. When supplied,
2015
1318
  * the wrapper does not apply X-Ray instrumentation.
2016
1319
  */
2017
- function SSMService(opts) {
2018
- var _a, _b;
2019
- this.client = (_a = opts === null || opts === void 0 ? void 0 : opts.client) !== null && _a !== void 0 ? _a : xray.captureAWSv3Client(new SSMClient());
2020
- this.logger = (_b = opts === null || opts === void 0 ? void 0 : opts.logger) !== null && _b !== void 0 ? _b : new Logger();
1320
+ constructor(opts) {
1321
+ this.client = opts?.client ?? xray.captureAWSv3Client(new SSMClient());
1322
+ this.logger = opts?.logger ?? new Logger();
2021
1323
  }
2022
1324
  /**
2023
1325
  * Fetch a single SSM parameter's value.
@@ -2025,22 +1327,11 @@ var SSMService = /** @class */ (function () {
2025
1327
  * @returns The parameter value, or `undefined` if the parameter has no
2026
1328
  * value set.
2027
1329
  */
2028
- SSMService.prototype.getParameter = function (name) {
2029
- return __awaiter(this, void 0, void 0, function () {
2030
- var response;
2031
- var _a;
2032
- return __generator(this, function (_b) {
2033
- switch (_b.label) {
2034
- case 0:
2035
- this.logger.info('Fetching SSM parameter', { input: { name: name } });
2036
- return [4 /*yield*/, this.client.send(new GetParameterCommand({ Name: name, WithDecryption: true }))];
2037
- case 1:
2038
- response = _b.sent();
2039
- return [2 /*return*/, (_a = response.Parameter) === null || _a === void 0 ? void 0 : _a.Value];
2040
- }
2041
- });
2042
- });
2043
- };
1330
+ async getParameter(name) {
1331
+ this.logger.info('Fetching SSM parameter', { input: { name } });
1332
+ const response = await this.client.send(new GetParameterCommand({ Name: name, WithDecryption: true }));
1333
+ return response.Parameter?.Value;
1334
+ }
2044
1335
  /**
2045
1336
  * Fetch multiple SSM parameters in a single request. Callers supply an
2046
1337
  * alias-to-path record, and the returned record is keyed by the same
@@ -2060,36 +1351,23 @@ var SSMService = /** @class */ (function () {
2060
1351
  * parameter's value, or `undefined` when the parameter is missing or has
2061
1352
  * no value.
2062
1353
  */
2063
- SSMService.prototype.getParameters = function (aliases) {
2064
- return __awaiter(this, void 0, void 0, function () {
2065
- var response, byPath, _i, _a, parameter, result, _b, _c, alias;
2066
- var _d;
2067
- return __generator(this, function (_e) {
2068
- switch (_e.label) {
2069
- case 0:
2070
- this.logger.info('Fetching SSM parameters', { input: { aliases: aliases } });
2071
- return [4 /*yield*/, this.client.send(new GetParametersCommand({
2072
- Names: Object.values(aliases),
2073
- WithDecryption: true,
2074
- }))];
2075
- case 1:
2076
- response = _e.sent();
2077
- byPath = new Map();
2078
- for (_i = 0, _a = (_d = response.Parameters) !== null && _d !== void 0 ? _d : []; _i < _a.length; _i++) {
2079
- parameter = _a[_i];
2080
- if (parameter.Name !== undefined)
2081
- byPath.set(parameter.Name, parameter.Value);
2082
- }
2083
- result = {};
2084
- for (_b = 0, _c = Object.keys(aliases); _b < _c.length; _b++) {
2085
- alias = _c[_b];
2086
- result[alias] = byPath.get(aliases[alias]);
2087
- }
2088
- return [2 /*return*/, result];
2089
- }
2090
- });
2091
- });
2092
- };
1354
+ async getParameters(aliases) {
1355
+ this.logger.info('Fetching SSM parameters', { input: { aliases } });
1356
+ const response = await this.client.send(new GetParametersCommand({
1357
+ Names: Object.values(aliases),
1358
+ WithDecryption: true,
1359
+ }));
1360
+ const byPath = new Map();
1361
+ for (const parameter of response.Parameters ?? []) {
1362
+ if (parameter.Name !== undefined)
1363
+ byPath.set(parameter.Name, parameter.Value);
1364
+ }
1365
+ const result = {};
1366
+ for (const alias of Object.keys(aliases)) {
1367
+ result[alias] = byPath.get(aliases[alias]);
1368
+ }
1369
+ return result;
1370
+ }
2093
1371
  /**
2094
1372
  * Create or update an SSM parameter. The log line omits `Value` to avoid
2095
1373
  * leaking secret material.
@@ -2097,36 +1375,22 @@ var SSMService = /** @class */ (function () {
2097
1375
  * Prefer IaC (CDK / Terraform) for parameter lifecycle — use this for
2098
1376
  * runtime values only.
2099
1377
  */
2100
- SSMService.prototype.putParameter = function (input) {
2101
- return __awaiter(this, void 0, void 0, function () {
2102
- return __generator(this, function (_a) {
2103
- this.logger.info('Putting SSM parameter', {
2104
- input: filterFieldsForLogLevel(this.logger, input, PUT_PARAMETER_SAFE_FIELDS),
2105
- });
2106
- return [2 /*return*/, this.client.send(new PutParameterCommand(input))];
2107
- });
1378
+ async putParameter(input) {
1379
+ this.logger.info('Putting SSM parameter', {
1380
+ input: filterFieldsForLogLevel(this.logger, input, PUT_PARAMETER_SAFE_FIELDS),
2108
1381
  });
2109
- };
1382
+ return this.client.send(new PutParameterCommand(input));
1383
+ }
2110
1384
  /**
2111
1385
  * Delete an SSM parameter by name.
2112
1386
  *
2113
1387
  * Prefer IaC (CDK / Terraform) for parameter lifecycle — use this for
2114
1388
  * runtime cleanup only.
2115
1389
  */
2116
- SSMService.prototype.deleteParameter = function (name) {
2117
- return __awaiter(this, void 0, void 0, function () {
2118
- return __generator(this, function (_a) {
2119
- switch (_a.label) {
2120
- case 0:
2121
- this.logger.info('Deleting SSM parameter', { input: { name: name } });
2122
- return [4 /*yield*/, this.client.send(new DeleteParameterCommand({ Name: name }))];
2123
- case 1:
2124
- _a.sent();
2125
- return [2 /*return*/];
2126
- }
2127
- });
2128
- });
2129
- };
1390
+ async deleteParameter(name) {
1391
+ this.logger.info('Deleting SSM parameter', { input: { name } });
1392
+ await this.client.send(new DeleteParameterCommand({ Name: name }));
1393
+ }
2130
1394
  /**
2131
1395
  * Fetch all parameters under an SSM hierarchy path, auto-paginating across
2132
1396
  * all pages. `Recursive` defaults to `true` (overriding the AWS SDK
@@ -2138,59 +1402,18 @@ var SSMService = /** @class */ (function () {
2138
1402
  * @returns The full `Parameter` objects (including `Version`,
2139
1403
  * `LastModifiedDate`, etc.).
2140
1404
  */
2141
- SSMService.prototype.getParametersByPath = function (path, opts) {
2142
- return __awaiter(this, void 0, void 0, function () {
2143
- var recursive, paginator, parameters, _a, paginator_1, paginator_1_1, page, e_1_1;
2144
- var _b, e_1, _c, _d;
2145
- var _e, _f;
2146
- return __generator(this, function (_g) {
2147
- switch (_g.label) {
2148
- case 0:
2149
- recursive = (_e = opts === null || opts === void 0 ? void 0 : opts.recursive) !== null && _e !== void 0 ? _e : true;
2150
- this.logger.info('Fetching SSM parameters by path', {
2151
- input: { path: path, recursive: recursive },
2152
- });
2153
- paginator = paginateGetParametersByPath({ client: this.client }, { Path: path, Recursive: recursive, WithDecryption: true });
2154
- parameters = [];
2155
- _g.label = 1;
2156
- case 1:
2157
- _g.trys.push([1, 6, 7, 12]);
2158
- _a = true, paginator_1 = __asyncValues(paginator);
2159
- _g.label = 2;
2160
- case 2: return [4 /*yield*/, paginator_1.next()];
2161
- case 3:
2162
- if (!(paginator_1_1 = _g.sent(), _b = paginator_1_1.done, !_b)) return [3 /*break*/, 5];
2163
- _d = paginator_1_1.value;
2164
- _a = false;
2165
- page = _d;
2166
- parameters.push.apply(parameters, ((_f = page.Parameters) !== null && _f !== void 0 ? _f : []));
2167
- _g.label = 4;
2168
- case 4:
2169
- _a = true;
2170
- return [3 /*break*/, 2];
2171
- case 5: return [3 /*break*/, 12];
2172
- case 6:
2173
- e_1_1 = _g.sent();
2174
- e_1 = { error: e_1_1 };
2175
- return [3 /*break*/, 12];
2176
- case 7:
2177
- _g.trys.push([7, , 10, 11]);
2178
- if (!(!_a && !_b && (_c = paginator_1.return))) return [3 /*break*/, 9];
2179
- return [4 /*yield*/, _c.call(paginator_1)];
2180
- case 8:
2181
- _g.sent();
2182
- _g.label = 9;
2183
- case 9: return [3 /*break*/, 11];
2184
- case 10:
2185
- if (e_1) throw e_1.error;
2186
- return [7 /*endfinally*/];
2187
- case 11: return [7 /*endfinally*/];
2188
- case 12: return [2 /*return*/, parameters];
2189
- }
2190
- });
1405
+ async getParametersByPath(path, opts) {
1406
+ const recursive = opts?.recursive ?? true;
1407
+ this.logger.info('Fetching SSM parameters by path', {
1408
+ input: { path, recursive },
2191
1409
  });
2192
- };
2193
- return SSMService;
2194
- }());
1410
+ const paginator = paginateGetParametersByPath({ client: this.client }, { Path: path, Recursive: recursive, WithDecryption: true });
1411
+ const parameters = [];
1412
+ for await (const page of paginator) {
1413
+ parameters.push(...(page.Parameters ?? []));
1414
+ }
1415
+ return parameters;
1416
+ }
1417
+ }
2195
1418
 
2196
1419
  export { DynamoDBService, S3Service, SNSService, SQSService, SSMService, SchedulerService, SecretsManagerService, StepFunctionsService };