@aligent/aws-wrappers 0.1.2 → 0.3.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/README.md +57 -1
- package/cjs/index.cjs +343 -49
- package/cjs/package.json +2 -1
- package/cjs/src/dynamodb/dynamodb.d.ts +4 -0
- package/cjs/src/index.d.ts +1 -0
- package/cjs/src/s3/s3.d.ts +4 -0
- package/cjs/src/scheduler/scheduler.d.ts +85 -0
- package/cjs/src/secrets-manager/secrets-manager.d.ts +7 -6
- package/cjs/src/sfn/sfn.d.ts +4 -0
- package/cjs/src/sns/sns.d.ts +5 -2
- package/cjs/src/sqs/sqs.d.ts +5 -2
- package/cjs/src/ssm/ssm.d.ts +4 -0
- package/cjs/src/util/redact.d.ts +14 -4
- package/docs/classes/DynamoDBService.md +69 -34
- package/docs/classes/S3Service.md +77 -33
- package/docs/classes/SNSService.md +31 -8
- package/docs/classes/SQSService.md +33 -11
- package/docs/classes/SSMService.md +70 -9
- package/docs/classes/SchedulerService.md +271 -0
- package/docs/classes/SecretsManagerService.md +120 -7
- package/docs/classes/StepFunctionsService.md +13 -9
- package/docs/modules.md +1 -0
- package/esm/index.mjs +344 -51
- package/esm/package.json +2 -1
- package/esm/src/dynamodb/dynamodb.d.ts +4 -0
- package/esm/src/index.d.ts +1 -0
- package/esm/src/s3/s3.d.ts +4 -0
- package/esm/src/scheduler/scheduler.d.ts +85 -0
- package/esm/src/secrets-manager/secrets-manager.d.ts +7 -6
- package/esm/src/sfn/sfn.d.ts +4 -0
- package/esm/src/sns/sns.d.ts +5 -2
- package/esm/src/sqs/sqs.d.ts +5 -2
- package/esm/src/ssm/ssm.d.ts +4 -0
- package/esm/src/util/redact.d.ts +14 -4
- package/package.json +2 -1
package/cjs/index.cjs
CHANGED
|
@@ -6,6 +6,7 @@ var libDynamodb = require('@aws-sdk/lib-dynamodb');
|
|
|
6
6
|
var xray = require('aws-xray-sdk-core');
|
|
7
7
|
var clientS3 = require('@aws-sdk/client-s3');
|
|
8
8
|
var s3RequestPresigner = require('@aws-sdk/s3-request-presigner');
|
|
9
|
+
var clientScheduler = require('@aws-sdk/client-scheduler');
|
|
9
10
|
var clientSecretsManager = require('@aws-sdk/client-secrets-manager');
|
|
10
11
|
var clientSfn = require('@aws-sdk/client-sfn');
|
|
11
12
|
var clientSns = require('@aws-sdk/client-sns');
|
|
@@ -40,6 +41,18 @@ var __assign = function() {
|
|
|
40
41
|
return __assign.apply(this, arguments);
|
|
41
42
|
};
|
|
42
43
|
|
|
44
|
+
function __rest(s, e) {
|
|
45
|
+
var t = {};
|
|
46
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
47
|
+
t[p] = s[p];
|
|
48
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
49
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
50
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
51
|
+
t[p[i]] = s[p[i]];
|
|
52
|
+
}
|
|
53
|
+
return t;
|
|
54
|
+
}
|
|
55
|
+
|
|
43
56
|
function __awaiter(thisArg, _arguments, P, generator) {
|
|
44
57
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
45
58
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -120,13 +133,25 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
120
133
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
121
134
|
};
|
|
122
135
|
|
|
136
|
+
/**
|
|
137
|
+
* Whether the logger is verbose enough that full SDK inputs — payloads, secret
|
|
138
|
+
* material and PII — may be written to the log.
|
|
139
|
+
*
|
|
140
|
+
* **This is the only place in the package that reads the log level.** Never
|
|
141
|
+
* compare `logger.getLevelName()` yourself: Powertools orders `TRACE` as *more*
|
|
142
|
+
* verbose than `DEBUG` (thresholds 6 and 8), so the obvious
|
|
143
|
+
* `getLevelName() === 'DEBUG'` check silently redacts at the most verbose level
|
|
144
|
+
* available. Route every disclosure decision through this predicate instead.
|
|
145
|
+
*/
|
|
146
|
+
function shouldLogFullInput(logger$1) {
|
|
147
|
+
return logger.LogLevelThreshold[logger$1.getLevelName()] <= logger.LogLevelThreshold.DEBUG;
|
|
148
|
+
}
|
|
123
149
|
/**
|
|
124
150
|
* Return a log-safe projection of `input` based on the logger's configured level.
|
|
125
151
|
*
|
|
126
|
-
* At
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
* and PII.
|
|
152
|
+
* At the verbose levels — see {@link shouldLogFullInput} — the full input is
|
|
153
|
+
* returned unchanged: operators who asked for that verbosity have explicitly
|
|
154
|
+
* opted into seeing everything, including payloads, secret material and PII.
|
|
130
155
|
*
|
|
131
156
|
* At any other level, only the fields listed in `safeFields` are included.
|
|
132
157
|
* Missing fields are silently skipped — the result type narrows to
|
|
@@ -137,7 +162,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
137
162
|
* the design rationale and conventions on building the safe-field lists.
|
|
138
163
|
*/
|
|
139
164
|
function filterFieldsForLogLevel(logger, input, safeFields) {
|
|
140
|
-
if (logger
|
|
165
|
+
if (shouldLogFullInput(logger))
|
|
141
166
|
return input;
|
|
142
167
|
var out = {};
|
|
143
168
|
for (var _i = 0, safeFields_1 = safeFields; _i < safeFields_1.length; _i++) {
|
|
@@ -152,7 +177,6 @@ var BATCH_WRITE_MAX_ATTEMPTS = 5;
|
|
|
152
177
|
var BATCH_WRITE_BASE_DELAY_MS = 200;
|
|
153
178
|
/**
|
|
154
179
|
* Fields safe to log at INFO. Omits `Key` (may carry customer IDs / tenant IDs).
|
|
155
|
-
* `POWERTOOLS_LOG_LEVEL=DEBUG` unlocks the full input.
|
|
156
180
|
*/
|
|
157
181
|
var GET_ITEM_SAFE_FIELDS = [
|
|
158
182
|
'TableName',
|
|
@@ -164,7 +188,6 @@ var GET_ITEM_SAFE_FIELDS = [
|
|
|
164
188
|
/**
|
|
165
189
|
* Fields safe to log at INFO. Omits `Item` (the payload itself) and
|
|
166
190
|
* `ExpressionAttributeValues` (values bound to ConditionExpression, often PII).
|
|
167
|
-
* `POWERTOOLS_LOG_LEVEL=DEBUG` unlocks the full input.
|
|
168
191
|
*/
|
|
169
192
|
var PUT_ITEM_SAFE_FIELDS = [
|
|
170
193
|
'TableName',
|
|
@@ -177,7 +200,6 @@ var PUT_ITEM_SAFE_FIELDS = [
|
|
|
177
200
|
];
|
|
178
201
|
/**
|
|
179
202
|
* Fields safe to log at INFO. Omits `Key` and `ExpressionAttributeValues`.
|
|
180
|
-
* `POWERTOOLS_LOG_LEVEL=DEBUG` unlocks the full input.
|
|
181
203
|
*/
|
|
182
204
|
var UPDATE_ITEM_SAFE_FIELDS = [
|
|
183
205
|
'TableName',
|
|
@@ -192,7 +214,6 @@ var UPDATE_ITEM_SAFE_FIELDS = [
|
|
|
192
214
|
/**
|
|
193
215
|
* Fields safe to log at INFO. Omits `Key` and `ExpressionAttributeValues`
|
|
194
216
|
* (the latter binds to ConditionExpression and may carry PII).
|
|
195
|
-
* `POWERTOOLS_LOG_LEVEL=DEBUG` unlocks the full input.
|
|
196
217
|
*/
|
|
197
218
|
var DELETE_ITEM_SAFE_FIELDS = [
|
|
198
219
|
'TableName',
|
|
@@ -206,8 +227,7 @@ var DELETE_ITEM_SAFE_FIELDS = [
|
|
|
206
227
|
/**
|
|
207
228
|
* Fields safe to log at INFO for `query` and `paginateItems`. Omits
|
|
208
229
|
* `ExpressionAttributeValues` (values often carry PII) and `ExclusiveStartKey`
|
|
209
|
-
* (pagination cursor includes Key shape).
|
|
210
|
-
* the full input.
|
|
230
|
+
* (pagination cursor includes Key shape).
|
|
211
231
|
*/
|
|
212
232
|
var QUERY_SAFE_FIELDS = [
|
|
213
233
|
'TableName',
|
|
@@ -225,7 +245,6 @@ var QUERY_SAFE_FIELDS = [
|
|
|
225
245
|
/**
|
|
226
246
|
* Fields safe to log at INFO for `scan` and `paginateScan`. Omits
|
|
227
247
|
* `ExpressionAttributeValues` and `ExclusiveStartKey`.
|
|
228
|
-
* `POWERTOOLS_LOG_LEVEL=DEBUG` unlocks the full input.
|
|
229
248
|
*/
|
|
230
249
|
var SCAN_SAFE_FIELDS = [
|
|
231
250
|
'TableName',
|
|
@@ -249,6 +268,10 @@ var backoffDelay = function (attempt) {
|
|
|
249
268
|
* Wrapper around the AWS DynamoDB Document client providing structured
|
|
250
269
|
* Powertools logging and X-Ray tracing by default.
|
|
251
270
|
*
|
|
271
|
+
* Where a method's input carries payloads, secret material or PII, the INFO
|
|
272
|
+
* log line omits them; the verbose levels (`POWERTOOLS_LOG_LEVEL=DEBUG` or
|
|
273
|
+
* `TRACE`) log full SDK inputs.
|
|
274
|
+
*
|
|
252
275
|
* Items are automatically marshalled / unmarshalled via the document client —
|
|
253
276
|
* callers work with plain TypeScript objects in both directions.
|
|
254
277
|
*/
|
|
@@ -427,12 +450,12 @@ var DynamoDBService = /** @class */ (function () {
|
|
|
427
450
|
*/
|
|
428
451
|
DynamoDBService.prototype.batchGet = function (input) {
|
|
429
452
|
return __awaiter(this, void 0, void 0, function () {
|
|
430
|
-
var
|
|
453
|
+
var logFullInput;
|
|
431
454
|
var _a;
|
|
432
455
|
return __generator(this, function (_b) {
|
|
433
|
-
|
|
456
|
+
logFullInput = shouldLogFullInput(this.logger);
|
|
434
457
|
this.logger.info('Batch getting DynamoDB items', {
|
|
435
|
-
input:
|
|
458
|
+
input: logFullInput ? input : { tables: Object.keys((_a = input.RequestItems) !== null && _a !== void 0 ? _a : {}) },
|
|
436
459
|
});
|
|
437
460
|
return [2 /*return*/, this.client.send(new libDynamodb.BatchGetCommand(input))];
|
|
438
461
|
});
|
|
@@ -445,14 +468,14 @@ var DynamoDBService = /** @class */ (function () {
|
|
|
445
468
|
*/
|
|
446
469
|
DynamoDBService.prototype.batchWrite = function (input) {
|
|
447
470
|
return __awaiter(this, void 0, void 0, function () {
|
|
448
|
-
var
|
|
471
|
+
var logFullInput, current, attempt, response, unprocessed;
|
|
449
472
|
var _a;
|
|
450
473
|
return __generator(this, function (_b) {
|
|
451
474
|
switch (_b.label) {
|
|
452
475
|
case 0:
|
|
453
|
-
|
|
476
|
+
logFullInput = shouldLogFullInput(this.logger);
|
|
454
477
|
this.logger.info('Batch writing DynamoDB items', {
|
|
455
|
-
input:
|
|
478
|
+
input: logFullInput ? input : { tables: Object.keys((_a = input.RequestItems) !== null && _a !== void 0 ? _a : {}) },
|
|
456
479
|
});
|
|
457
480
|
current = input;
|
|
458
481
|
attempt = 0;
|
|
@@ -624,13 +647,11 @@ var DEFAULT_PRESIGNED_URL_EXPIRES_IN_SECONDS = 3600;
|
|
|
624
647
|
var DELETE_OBJECTS_BATCH_LIMIT = 1000;
|
|
625
648
|
/**
|
|
626
649
|
* Fields safe to log at INFO for `putObject`. Omits `Body` (object payload).
|
|
627
|
-
* `POWERTOOLS_LOG_LEVEL=DEBUG` unlocks the full input.
|
|
628
650
|
*/
|
|
629
651
|
var PUT_OBJECT_SAFE_FIELDS = ['Bucket', 'Key'];
|
|
630
652
|
/**
|
|
631
653
|
* Fields safe to log at INFO for `putJsonObject`. Omits `Body` (the
|
|
632
654
|
* unserialised JSON payload). `Metadata` is included (operational labels).
|
|
633
|
-
* `POWERTOOLS_LOG_LEVEL=DEBUG` unlocks the full input.
|
|
634
655
|
*/
|
|
635
656
|
var PUT_JSON_OBJECT_SAFE_FIELDS = [
|
|
636
657
|
'Bucket',
|
|
@@ -641,6 +662,10 @@ var PUT_JSON_OBJECT_SAFE_FIELDS = [
|
|
|
641
662
|
* Wrapper around the AWS S3 client providing structured Powertools logging
|
|
642
663
|
* and X-Ray tracing by default.
|
|
643
664
|
*
|
|
665
|
+
* Where a method's input carries payloads, secret material or PII, the INFO
|
|
666
|
+
* log line omits them; the verbose levels (`POWERTOOLS_LOG_LEVEL=DEBUG` or
|
|
667
|
+
* `TRACE`) log full SDK inputs.
|
|
668
|
+
*
|
|
644
669
|
* Input shapes are intentionally tight (Bucket/Key/Body only). Callers
|
|
645
670
|
* needing SDK-level options not exposed here (server-side encryption,
|
|
646
671
|
* tagging, version IDs) should use `S3Client` directly.
|
|
@@ -963,13 +988,13 @@ var S3Service = /** @class */ (function () {
|
|
|
963
988
|
*/
|
|
964
989
|
S3Service.prototype.deleteObjects = function (bucket, keys) {
|
|
965
990
|
return __awaiter(this, void 0, void 0, function () {
|
|
966
|
-
var
|
|
991
|
+
var logFullInput, results, i, batch, _a, _b;
|
|
967
992
|
return __generator(this, function (_c) {
|
|
968
993
|
switch (_c.label) {
|
|
969
994
|
case 0:
|
|
970
|
-
|
|
995
|
+
logFullInput = shouldLogFullInput(this.logger);
|
|
971
996
|
this.logger.info('Deleting S3 objects', {
|
|
972
|
-
input:
|
|
997
|
+
input: logFullInput ? { bucket: bucket, keys: keys } : { bucket: bucket, keyCount: keys.length },
|
|
973
998
|
});
|
|
974
999
|
results = [];
|
|
975
1000
|
i = 0;
|
|
@@ -1057,10 +1082,265 @@ var S3Service = /** @class */ (function () {
|
|
|
1057
1082
|
return S3Service;
|
|
1058
1083
|
}());
|
|
1059
1084
|
|
|
1085
|
+
/**
|
|
1086
|
+
* `CreateSchedule` / `UpdateSchedule` inputs carry the payload handed to the
|
|
1087
|
+
* target at `Target.Input` — arbitrary text or JSON that routinely contains
|
|
1088
|
+
* PII (customer IDs, order contents, etc.), the same risk profile as SFN's
|
|
1089
|
+
* execution `input`.
|
|
1090
|
+
*
|
|
1091
|
+
* This can't go through the package's usual `filterFieldsForLogLevel` helper:
|
|
1092
|
+
* that helper picks **top-level** keys only, and the sensitive field is nested
|
|
1093
|
+
* one level down inside `Target`. Allowlisting `Target` would leak `Input`;
|
|
1094
|
+
* omitting `Target` would lose operationally-useful fields (`Arn`, `RoleArn`,
|
|
1095
|
+
* `RetryPolicy`, `DeadLetterConfig`, the target-type params). So this is a
|
|
1096
|
+
* bespoke case: keep every top-level field and shallow-strip only
|
|
1097
|
+
* `Target.Input`.
|
|
1098
|
+
*
|
|
1099
|
+
* At the verbose levels — see {@link shouldLogFullInput} — the input is
|
|
1100
|
+
* returned unchanged: operators who asked for that verbosity have opted into
|
|
1101
|
+
* seeing payloads and PII.
|
|
1102
|
+
*/
|
|
1103
|
+
function redactTargetInput(logger, input) {
|
|
1104
|
+
var _a;
|
|
1105
|
+
if (shouldLogFullInput(logger))
|
|
1106
|
+
return input;
|
|
1107
|
+
if (((_a = input.Target) === null || _a === void 0 ? void 0 : _a.Input) === undefined)
|
|
1108
|
+
return input;
|
|
1109
|
+
var _b = input.Target; _b.Input; var safeTarget = __rest(_b, ["Input"]);
|
|
1110
|
+
return __assign(__assign({}, input), { Target: safeTarget });
|
|
1111
|
+
}
|
|
1112
|
+
/**
|
|
1113
|
+
* Wrapper around the AWS EventBridge Scheduler client providing structured
|
|
1114
|
+
* Powertools logging and X-Ray tracing by default.
|
|
1115
|
+
*
|
|
1116
|
+
* Where a method's input carries payloads, secret material or PII, the INFO
|
|
1117
|
+
* log line omits them; the verbose levels (`POWERTOOLS_LOG_LEVEL=DEBUG` or
|
|
1118
|
+
* `TRACE`) log full SDK inputs.
|
|
1119
|
+
*
|
|
1120
|
+
* Covers CRUD on schedules and their groups. Named `SchedulerService` (not
|
|
1121
|
+
* `EventBridgeSchedulerService`) so it doesn't collide with a future wrapper
|
|
1122
|
+
* over the separate EventBridge bus/rules API (`@aws-sdk/client-eventbridge`).
|
|
1123
|
+
*
|
|
1124
|
+
* `FlexibleTimeWindow` is required by `CreateSchedule` and is passed through
|
|
1125
|
+
* untouched — the wrapper bakes in no default, so the caller must state their
|
|
1126
|
+
* intent (`{ Mode: 'OFF' }` for a fixed-time schedule).
|
|
1127
|
+
*/
|
|
1128
|
+
var SchedulerService = /** @class */ (function () {
|
|
1129
|
+
/**
|
|
1130
|
+
* @param opts.logger - Optional Powertools logger. Defaults to `new Logger()`,
|
|
1131
|
+
* which picks up `POWERTOOLS_SERVICE_NAME` from the environment.
|
|
1132
|
+
* @param opts.client - Optional pre-configured `SchedulerClient`. When
|
|
1133
|
+
* supplied, the wrapper does not apply X-Ray instrumentation.
|
|
1134
|
+
*/
|
|
1135
|
+
function SchedulerService(opts) {
|
|
1136
|
+
var _a, _b;
|
|
1137
|
+
this.client = (_a = opts === null || opts === void 0 ? void 0 : opts.client) !== null && _a !== void 0 ? _a : xray.captureAWSv3Client(new clientScheduler.SchedulerClient());
|
|
1138
|
+
this.logger = (_b = opts === null || opts === void 0 ? void 0 : opts.logger) !== null && _b !== void 0 ? _b : new logger.Logger();
|
|
1139
|
+
}
|
|
1140
|
+
/**
|
|
1141
|
+
* Create a new schedule. At INFO the log line omits `Target.Input` (the
|
|
1142
|
+
* target payload, a PII carrier).
|
|
1143
|
+
*/
|
|
1144
|
+
SchedulerService.prototype.createSchedule = function (input) {
|
|
1145
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1146
|
+
return __generator(this, function (_a) {
|
|
1147
|
+
this.logger.info('Creating schedule', { input: redactTargetInput(this.logger, input) });
|
|
1148
|
+
return [2 /*return*/, this.client.send(new clientScheduler.CreateScheduleCommand(input))];
|
|
1149
|
+
});
|
|
1150
|
+
});
|
|
1151
|
+
};
|
|
1152
|
+
/**
|
|
1153
|
+
* Fetch a schedule's full configuration.
|
|
1154
|
+
*/
|
|
1155
|
+
SchedulerService.prototype.getSchedule = function (input) {
|
|
1156
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1157
|
+
return __generator(this, function (_a) {
|
|
1158
|
+
this.logger.info('Getting schedule', { input: input });
|
|
1159
|
+
return [2 /*return*/, this.client.send(new clientScheduler.GetScheduleCommand(input))];
|
|
1160
|
+
});
|
|
1161
|
+
});
|
|
1162
|
+
};
|
|
1163
|
+
/**
|
|
1164
|
+
* Update an existing schedule.
|
|
1165
|
+
*
|
|
1166
|
+
* **`UpdateSchedule` has PUT (full-replacement) semantics.** Any field you
|
|
1167
|
+
* omit is reset to its default — this is not a partial patch. To change one
|
|
1168
|
+
* attribute, `getSchedule` first and resend the complete configuration with
|
|
1169
|
+
* that attribute modified, or you will silently erase `ScheduleExpression`,
|
|
1170
|
+
* `Target`, `Description`, `StartDate`, etc. The wrapper does not merge on
|
|
1171
|
+
* your behalf: deep-merging a `Target` (with its mutually-exclusive
|
|
1172
|
+
* target-type params) has no single correct semantics.
|
|
1173
|
+
*
|
|
1174
|
+
* At INFO the log line omits `Target.Input`.
|
|
1175
|
+
*/
|
|
1176
|
+
SchedulerService.prototype.updateSchedule = function (input) {
|
|
1177
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1178
|
+
return __generator(this, function (_a) {
|
|
1179
|
+
this.logger.info('Updating schedule', { input: redactTargetInput(this.logger, input) });
|
|
1180
|
+
return [2 /*return*/, this.client.send(new clientScheduler.UpdateScheduleCommand(input))];
|
|
1181
|
+
});
|
|
1182
|
+
});
|
|
1183
|
+
};
|
|
1184
|
+
/**
|
|
1185
|
+
* Delete a schedule.
|
|
1186
|
+
*/
|
|
1187
|
+
SchedulerService.prototype.deleteSchedule = function (input) {
|
|
1188
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1189
|
+
return __generator(this, function (_a) {
|
|
1190
|
+
this.logger.info('Deleting schedule', { input: input });
|
|
1191
|
+
return [2 /*return*/, this.client.send(new clientScheduler.DeleteScheduleCommand(input))];
|
|
1192
|
+
});
|
|
1193
|
+
});
|
|
1194
|
+
};
|
|
1195
|
+
/**
|
|
1196
|
+
* List schedules, auto-paginating across all pages. Bounded in practice by
|
|
1197
|
+
* the account's schedule count and the `GroupName` / `NamePrefix` / `State`
|
|
1198
|
+
* filters, so the flat-array shape is safe.
|
|
1199
|
+
*/
|
|
1200
|
+
SchedulerService.prototype.listSchedules = function (input) {
|
|
1201
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1202
|
+
var paginator, schedules, _a, paginator_1, paginator_1_1, page, e_1_1;
|
|
1203
|
+
var _b, e_1, _c, _d;
|
|
1204
|
+
return __generator(this, function (_e) {
|
|
1205
|
+
switch (_e.label) {
|
|
1206
|
+
case 0:
|
|
1207
|
+
this.logger.info('Listing schedules', { input: input });
|
|
1208
|
+
paginator = clientScheduler.paginateListSchedules({ client: this.client }, input !== null && input !== void 0 ? input : {});
|
|
1209
|
+
schedules = [];
|
|
1210
|
+
_e.label = 1;
|
|
1211
|
+
case 1:
|
|
1212
|
+
_e.trys.push([1, 6, 7, 12]);
|
|
1213
|
+
_a = true, paginator_1 = __asyncValues(paginator);
|
|
1214
|
+
_e.label = 2;
|
|
1215
|
+
case 2: return [4 /*yield*/, paginator_1.next()];
|
|
1216
|
+
case 3:
|
|
1217
|
+
if (!(paginator_1_1 = _e.sent(), _b = paginator_1_1.done, !_b)) return [3 /*break*/, 5];
|
|
1218
|
+
_d = paginator_1_1.value;
|
|
1219
|
+
_a = false;
|
|
1220
|
+
page = _d;
|
|
1221
|
+
if (page.Schedules)
|
|
1222
|
+
schedules.push.apply(schedules, page.Schedules);
|
|
1223
|
+
_e.label = 4;
|
|
1224
|
+
case 4:
|
|
1225
|
+
_a = true;
|
|
1226
|
+
return [3 /*break*/, 2];
|
|
1227
|
+
case 5: return [3 /*break*/, 12];
|
|
1228
|
+
case 6:
|
|
1229
|
+
e_1_1 = _e.sent();
|
|
1230
|
+
e_1 = { error: e_1_1 };
|
|
1231
|
+
return [3 /*break*/, 12];
|
|
1232
|
+
case 7:
|
|
1233
|
+
_e.trys.push([7, , 10, 11]);
|
|
1234
|
+
if (!(!_a && !_b && (_c = paginator_1.return))) return [3 /*break*/, 9];
|
|
1235
|
+
return [4 /*yield*/, _c.call(paginator_1)];
|
|
1236
|
+
case 8:
|
|
1237
|
+
_e.sent();
|
|
1238
|
+
_e.label = 9;
|
|
1239
|
+
case 9: return [3 /*break*/, 11];
|
|
1240
|
+
case 10:
|
|
1241
|
+
if (e_1) throw e_1.error;
|
|
1242
|
+
return [7 /*endfinally*/];
|
|
1243
|
+
case 11: return [7 /*endfinally*/];
|
|
1244
|
+
case 12: return [2 /*return*/, schedules];
|
|
1245
|
+
}
|
|
1246
|
+
});
|
|
1247
|
+
});
|
|
1248
|
+
};
|
|
1249
|
+
/**
|
|
1250
|
+
* Create a new schedule group. Groups are containers for schedules and are
|
|
1251
|
+
* typically IaC-managed; use this for dynamically-provisioned groups only.
|
|
1252
|
+
*/
|
|
1253
|
+
SchedulerService.prototype.createScheduleGroup = function (input) {
|
|
1254
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1255
|
+
return __generator(this, function (_a) {
|
|
1256
|
+
this.logger.info('Creating schedule group', { input: input });
|
|
1257
|
+
return [2 /*return*/, this.client.send(new clientScheduler.CreateScheduleGroupCommand(input))];
|
|
1258
|
+
});
|
|
1259
|
+
});
|
|
1260
|
+
};
|
|
1261
|
+
/**
|
|
1262
|
+
* Fetch a schedule group's configuration.
|
|
1263
|
+
*/
|
|
1264
|
+
SchedulerService.prototype.getScheduleGroup = function (input) {
|
|
1265
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1266
|
+
return __generator(this, function (_a) {
|
|
1267
|
+
this.logger.info('Getting schedule group', { input: input });
|
|
1268
|
+
return [2 /*return*/, this.client.send(new clientScheduler.GetScheduleGroupCommand(input))];
|
|
1269
|
+
});
|
|
1270
|
+
});
|
|
1271
|
+
};
|
|
1272
|
+
/**
|
|
1273
|
+
* Delete a schedule group. Deleting a group also deletes every schedule it
|
|
1274
|
+
* contains, asynchronously — the API has no `UpdateScheduleGroup`, so this
|
|
1275
|
+
* is the only mutating group operation besides create.
|
|
1276
|
+
*/
|
|
1277
|
+
SchedulerService.prototype.deleteScheduleGroup = function (input) {
|
|
1278
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1279
|
+
return __generator(this, function (_a) {
|
|
1280
|
+
this.logger.info('Deleting schedule group', { input: input });
|
|
1281
|
+
return [2 /*return*/, this.client.send(new clientScheduler.DeleteScheduleGroupCommand(input))];
|
|
1282
|
+
});
|
|
1283
|
+
});
|
|
1284
|
+
};
|
|
1285
|
+
/**
|
|
1286
|
+
* List schedule groups, auto-paginating across all pages. Bounded in
|
|
1287
|
+
* practice by the account's group count and the `NamePrefix` filter.
|
|
1288
|
+
*/
|
|
1289
|
+
SchedulerService.prototype.listScheduleGroups = function (input) {
|
|
1290
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1291
|
+
var paginator, groups, _a, paginator_2, paginator_2_1, page, e_2_1;
|
|
1292
|
+
var _b, e_2, _c, _d;
|
|
1293
|
+
return __generator(this, function (_e) {
|
|
1294
|
+
switch (_e.label) {
|
|
1295
|
+
case 0:
|
|
1296
|
+
this.logger.info('Listing schedule groups', { input: input });
|
|
1297
|
+
paginator = clientScheduler.paginateListScheduleGroups({ client: this.client }, input !== null && input !== void 0 ? input : {});
|
|
1298
|
+
groups = [];
|
|
1299
|
+
_e.label = 1;
|
|
1300
|
+
case 1:
|
|
1301
|
+
_e.trys.push([1, 6, 7, 12]);
|
|
1302
|
+
_a = true, paginator_2 = __asyncValues(paginator);
|
|
1303
|
+
_e.label = 2;
|
|
1304
|
+
case 2: return [4 /*yield*/, paginator_2.next()];
|
|
1305
|
+
case 3:
|
|
1306
|
+
if (!(paginator_2_1 = _e.sent(), _b = paginator_2_1.done, !_b)) return [3 /*break*/, 5];
|
|
1307
|
+
_d = paginator_2_1.value;
|
|
1308
|
+
_a = false;
|
|
1309
|
+
page = _d;
|
|
1310
|
+
if (page.ScheduleGroups)
|
|
1311
|
+
groups.push.apply(groups, page.ScheduleGroups);
|
|
1312
|
+
_e.label = 4;
|
|
1313
|
+
case 4:
|
|
1314
|
+
_a = true;
|
|
1315
|
+
return [3 /*break*/, 2];
|
|
1316
|
+
case 5: return [3 /*break*/, 12];
|
|
1317
|
+
case 6:
|
|
1318
|
+
e_2_1 = _e.sent();
|
|
1319
|
+
e_2 = { error: e_2_1 };
|
|
1320
|
+
return [3 /*break*/, 12];
|
|
1321
|
+
case 7:
|
|
1322
|
+
_e.trys.push([7, , 10, 11]);
|
|
1323
|
+
if (!(!_a && !_b && (_c = paginator_2.return))) return [3 /*break*/, 9];
|
|
1324
|
+
return [4 /*yield*/, _c.call(paginator_2)];
|
|
1325
|
+
case 8:
|
|
1326
|
+
_e.sent();
|
|
1327
|
+
_e.label = 9;
|
|
1328
|
+
case 9: return [3 /*break*/, 11];
|
|
1329
|
+
case 10:
|
|
1330
|
+
if (e_2) throw e_2.error;
|
|
1331
|
+
return [7 /*endfinally*/];
|
|
1332
|
+
case 11: return [7 /*endfinally*/];
|
|
1333
|
+
case 12: return [2 /*return*/, groups];
|
|
1334
|
+
}
|
|
1335
|
+
});
|
|
1336
|
+
});
|
|
1337
|
+
};
|
|
1338
|
+
return SchedulerService;
|
|
1339
|
+
}());
|
|
1340
|
+
|
|
1060
1341
|
/**
|
|
1061
1342
|
* Fields safe to log at INFO level. Omits `SecretString` and `SecretBinary` —
|
|
1062
|
-
* the secret material itself.
|
|
1063
|
-
* input.
|
|
1343
|
+
* the secret material itself.
|
|
1064
1344
|
*/
|
|
1065
1345
|
var CREATE_SECRET_SAFE_FIELDS = [
|
|
1066
1346
|
'Name',
|
|
@@ -1096,6 +1376,10 @@ var DELETE_SECRET_SAFE_FIELDS = [
|
|
|
1096
1376
|
* Wrapper around the AWS Secrets Manager client providing structured
|
|
1097
1377
|
* Powertools logging and X-Ray tracing by default.
|
|
1098
1378
|
*
|
|
1379
|
+
* Where a method's input carries payloads, secret material or PII, the INFO
|
|
1380
|
+
* log line omits them; the verbose levels (`POWERTOOLS_LOG_LEVEL=DEBUG` or
|
|
1381
|
+
* `TRACE`) log full SDK inputs.
|
|
1382
|
+
*
|
|
1099
1383
|
* Write operations (`createSecret`, `updateSecret`, `putSecretValue`,
|
|
1100
1384
|
* `deleteSecret`) are exposed for convenience but should be used with care:
|
|
1101
1385
|
* secret lifecycle is usually managed by IaC (CDK / Terraform). Prefer IaC
|
|
@@ -1155,8 +1439,7 @@ var SecretsManagerService = /** @class */ (function () {
|
|
|
1155
1439
|
};
|
|
1156
1440
|
/**
|
|
1157
1441
|
* Create a new secret. At INFO level the log line includes only identity
|
|
1158
|
-
* and non-secret metadata
|
|
1159
|
-
* input (including `SecretString` / `SecretBinary`).
|
|
1442
|
+
* and non-secret metadata.
|
|
1160
1443
|
*
|
|
1161
1444
|
* Prefer IaC (CDK / Terraform) for secret lifecycle — use this for
|
|
1162
1445
|
* dynamically-issued credentials only.
|
|
@@ -1173,8 +1456,7 @@ var SecretsManagerService = /** @class */ (function () {
|
|
|
1173
1456
|
};
|
|
1174
1457
|
/**
|
|
1175
1458
|
* Update an existing secret's metadata or value. At INFO level the log
|
|
1176
|
-
* line omits `SecretString` / `SecretBinary
|
|
1177
|
-
* unlocks the full input.
|
|
1459
|
+
* line omits `SecretString` / `SecretBinary`.
|
|
1178
1460
|
*
|
|
1179
1461
|
* Prefer IaC (CDK / Terraform) for secret lifecycle — use this for
|
|
1180
1462
|
* runtime metadata updates only.
|
|
@@ -1191,8 +1473,7 @@ var SecretsManagerService = /** @class */ (function () {
|
|
|
1191
1473
|
};
|
|
1192
1474
|
/**
|
|
1193
1475
|
* Store a new version of a secret's value. At INFO level the log line
|
|
1194
|
-
* omits `SecretString` / `SecretBinary
|
|
1195
|
-
* unlocks the full input.
|
|
1476
|
+
* omits `SecretString` / `SecretBinary`.
|
|
1196
1477
|
*
|
|
1197
1478
|
* Typically used by rotation flows.
|
|
1198
1479
|
*/
|
|
@@ -1244,7 +1525,7 @@ var SecretsManagerService = /** @class */ (function () {
|
|
|
1244
1525
|
/**
|
|
1245
1526
|
* Fields safe to log at INFO for `startExecution`. Omits `input` — the SFN
|
|
1246
1527
|
* execution payload, which routinely carries PII (customer IDs, addresses,
|
|
1247
|
-
* order contents, etc.).
|
|
1528
|
+
* order contents, etc.).
|
|
1248
1529
|
*/
|
|
1249
1530
|
var START_EXECUTION_SAFE_FIELDS = [
|
|
1250
1531
|
'stateMachineArn',
|
|
@@ -1254,6 +1535,10 @@ var START_EXECUTION_SAFE_FIELDS = [
|
|
|
1254
1535
|
/**
|
|
1255
1536
|
* Wrapper around the AWS Step Functions client providing structured
|
|
1256
1537
|
* Powertools logging and X-Ray tracing by default.
|
|
1538
|
+
*
|
|
1539
|
+
* Where a method's input carries payloads, secret material or PII, the INFO
|
|
1540
|
+
* log line omits them; the verbose levels (`POWERTOOLS_LOG_LEVEL=DEBUG` or
|
|
1541
|
+
* `TRACE`) log full SDK inputs.
|
|
1257
1542
|
*/
|
|
1258
1543
|
var StepFunctionsService = /** @class */ (function () {
|
|
1259
1544
|
/**
|
|
@@ -1399,7 +1684,7 @@ var SNS_SUBJECT_MAX_CHARS = 100;
|
|
|
1399
1684
|
* Fields safe to log at INFO level for `publish`. Omits `Message`, `Subject`,
|
|
1400
1685
|
* `MessageAttributes`, and `PhoneNumber` — payloads, user-visible content
|
|
1401
1686
|
* (subjects often carry order numbers / customer names), and PII recipient
|
|
1402
|
-
* identifiers.
|
|
1687
|
+
* identifiers.
|
|
1403
1688
|
*/
|
|
1404
1689
|
var PUBLISH_SAFE_FIELDS = [
|
|
1405
1690
|
'TopicArn',
|
|
@@ -1411,6 +1696,10 @@ var PUBLISH_SAFE_FIELDS = [
|
|
|
1411
1696
|
/**
|
|
1412
1697
|
* Wrapper around the AWS SNS client providing structured Powertools logging
|
|
1413
1698
|
* and X-Ray tracing by default.
|
|
1699
|
+
*
|
|
1700
|
+
* Where a method's input carries payloads, secret material or PII, the INFO
|
|
1701
|
+
* log line omits them; the verbose levels (`POWERTOOLS_LOG_LEVEL=DEBUG` or
|
|
1702
|
+
* `TRACE`) log full SDK inputs.
|
|
1414
1703
|
*/
|
|
1415
1704
|
var SNSService = /** @class */ (function () {
|
|
1416
1705
|
/**
|
|
@@ -1434,8 +1723,7 @@ var SNSService = /** @class */ (function () {
|
|
|
1434
1723
|
* Publish a single message to an SNS topic.
|
|
1435
1724
|
*
|
|
1436
1725
|
* At INFO level the log line includes only routing / dedup metadata; see
|
|
1437
|
-
* `PUBLISH_SAFE_FIELDS` for the list.
|
|
1438
|
-
* unlocks the full input.
|
|
1726
|
+
* `PUBLISH_SAFE_FIELDS` for the list.
|
|
1439
1727
|
*
|
|
1440
1728
|
* @param input - PublishCommandInput including TopicArn and Message.
|
|
1441
1729
|
*/
|
|
@@ -1479,15 +1767,15 @@ var SNSService = /** @class */ (function () {
|
|
|
1479
1767
|
*/
|
|
1480
1768
|
SNSService.prototype.publishBatch = function (input) {
|
|
1481
1769
|
return __awaiter(this, void 0, void 0, function () {
|
|
1482
|
-
var entries,
|
|
1770
|
+
var entries, logFullInput, results, i, chunk, _a, _b;
|
|
1483
1771
|
var _c;
|
|
1484
1772
|
return __generator(this, function (_d) {
|
|
1485
1773
|
switch (_d.label) {
|
|
1486
1774
|
case 0:
|
|
1487
1775
|
entries = (_c = input.PublishBatchRequestEntries) !== null && _c !== void 0 ? _c : [];
|
|
1488
|
-
|
|
1776
|
+
logFullInput = shouldLogFullInput(this.logger);
|
|
1489
1777
|
this.logger.info('Publishing SNS message batch', {
|
|
1490
|
-
input:
|
|
1778
|
+
input: logFullInput ? input : { TopicArn: input.TopicArn, entryCount: entries.length },
|
|
1491
1779
|
});
|
|
1492
1780
|
results = [];
|
|
1493
1781
|
i = 0;
|
|
@@ -1516,7 +1804,6 @@ var SQS_MESSAGE_BODY_MAX_BYTES = 256 * 1024;
|
|
|
1516
1804
|
/**
|
|
1517
1805
|
* Fields safe to log at INFO level for `sendMessage`. Omits `MessageBody` and
|
|
1518
1806
|
* `MessageAttributes` — both carry payload content.
|
|
1519
|
-
* `POWERTOOLS_LOG_LEVEL=DEBUG` unlocks the full input.
|
|
1520
1807
|
*/
|
|
1521
1808
|
var SEND_MESSAGE_SAFE_FIELDS = [
|
|
1522
1809
|
'QueueUrl',
|
|
@@ -1527,6 +1814,10 @@ var SEND_MESSAGE_SAFE_FIELDS = [
|
|
|
1527
1814
|
/**
|
|
1528
1815
|
* Wrapper around the AWS SQS client providing structured Powertools logging
|
|
1529
1816
|
* and X-Ray tracing by default.
|
|
1817
|
+
*
|
|
1818
|
+
* Where a method's input carries payloads, secret material or PII, the INFO
|
|
1819
|
+
* log line omits them; the verbose levels (`POWERTOOLS_LOG_LEVEL=DEBUG` or
|
|
1820
|
+
* `TRACE`) log full SDK inputs.
|
|
1530
1821
|
*/
|
|
1531
1822
|
var SQSService = /** @class */ (function () {
|
|
1532
1823
|
/**
|
|
@@ -1549,8 +1840,7 @@ var SQSService = /** @class */ (function () {
|
|
|
1549
1840
|
* Send a single message to an SQS queue.
|
|
1550
1841
|
*
|
|
1551
1842
|
* At INFO level the log line includes only queue routing / FIFO metadata;
|
|
1552
|
-
* see `SEND_MESSAGE_SAFE_FIELDS`.
|
|
1553
|
-
* full input.
|
|
1843
|
+
* see `SEND_MESSAGE_SAFE_FIELDS`.
|
|
1554
1844
|
*/
|
|
1555
1845
|
SQSService.prototype.sendMessage = function (input, opts) {
|
|
1556
1846
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -1619,15 +1909,15 @@ var SQSService = /** @class */ (function () {
|
|
|
1619
1909
|
*/
|
|
1620
1910
|
SQSService.prototype.sendMessageBatch = function (input) {
|
|
1621
1911
|
return __awaiter(this, void 0, void 0, function () {
|
|
1622
|
-
var entries,
|
|
1912
|
+
var entries, logFullInput, results, i, chunk, _a, _b;
|
|
1623
1913
|
var _c;
|
|
1624
1914
|
return __generator(this, function (_d) {
|
|
1625
1915
|
switch (_d.label) {
|
|
1626
1916
|
case 0:
|
|
1627
1917
|
entries = (_c = input.Entries) !== null && _c !== void 0 ? _c : [];
|
|
1628
|
-
|
|
1918
|
+
logFullInput = shouldLogFullInput(this.logger);
|
|
1629
1919
|
this.logger.info('Sending SQS message batch', {
|
|
1630
|
-
input:
|
|
1920
|
+
input: logFullInput ? input : { QueueUrl: input.QueueUrl, entryCount: entries.length },
|
|
1631
1921
|
});
|
|
1632
1922
|
results = [];
|
|
1633
1923
|
i = 0;
|
|
@@ -1655,15 +1945,15 @@ var SQSService = /** @class */ (function () {
|
|
|
1655
1945
|
*/
|
|
1656
1946
|
SQSService.prototype.deleteMessageBatch = function (input) {
|
|
1657
1947
|
return __awaiter(this, void 0, void 0, function () {
|
|
1658
|
-
var entries,
|
|
1948
|
+
var entries, logFullInput, results, i, chunk, _a, _b;
|
|
1659
1949
|
var _c;
|
|
1660
1950
|
return __generator(this, function (_d) {
|
|
1661
1951
|
switch (_d.label) {
|
|
1662
1952
|
case 0:
|
|
1663
1953
|
entries = (_c = input.Entries) !== null && _c !== void 0 ? _c : [];
|
|
1664
|
-
|
|
1954
|
+
logFullInput = shouldLogFullInput(this.logger);
|
|
1665
1955
|
this.logger.info('Deleting SQS message batch', {
|
|
1666
|
-
input:
|
|
1956
|
+
input: logFullInput ? input : { QueueUrl: input.QueueUrl, entryCount: entries.length },
|
|
1667
1957
|
});
|
|
1668
1958
|
results = [];
|
|
1669
1959
|
i = 0;
|
|
@@ -1689,8 +1979,7 @@ var SQSService = /** @class */ (function () {
|
|
|
1689
1979
|
|
|
1690
1980
|
/**
|
|
1691
1981
|
* Fields safe to log at INFO level for `putParameter`. Omits `Value` (the
|
|
1692
|
-
* parameter content itself).
|
|
1693
|
-
* input.
|
|
1982
|
+
* parameter content itself).
|
|
1694
1983
|
*/
|
|
1695
1984
|
var PUT_PARAMETER_SAFE_FIELDS = [
|
|
1696
1985
|
'Name',
|
|
@@ -1710,6 +1999,10 @@ var PUT_PARAMETER_SAFE_FIELDS = [
|
|
|
1710
1999
|
* `WithDecryption` — callers needing plaintext should use `SSMClient`
|
|
1711
2000
|
* directly.
|
|
1712
2001
|
*
|
|
2002
|
+
* Where a method's input carries payloads, secret material or PII, the INFO
|
|
2003
|
+
* log line omits them; the verbose levels (`POWERTOOLS_LOG_LEVEL=DEBUG` or
|
|
2004
|
+
* `TRACE`) log full SDK inputs.
|
|
2005
|
+
*
|
|
1713
2006
|
* Write operations (`putParameter`, `deleteParameter`) are exposed for
|
|
1714
2007
|
* convenience but should be used with care: parameter lifecycle is usually
|
|
1715
2008
|
* managed by IaC (CDK / Terraform). Prefer IaC for anything that exists at
|
|
@@ -1907,5 +2200,6 @@ exports.S3Service = S3Service;
|
|
|
1907
2200
|
exports.SNSService = SNSService;
|
|
1908
2201
|
exports.SQSService = SQSService;
|
|
1909
2202
|
exports.SSMService = SSMService;
|
|
2203
|
+
exports.SchedulerService = SchedulerService;
|
|
1910
2204
|
exports.SecretsManagerService = SecretsManagerService;
|
|
1911
2205
|
exports.StepFunctionsService = StepFunctionsService;
|
package/cjs/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aligent/aws-wrappers",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Opinionated AWS SDK wrappers with Powertools logging and X-Ray tracing",
|
|
5
5
|
"main": "./index.cjs.js",
|
|
6
6
|
"module": "./esm/index.mjs",
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
"@aws-lambda-powertools/logger": "^2.33.1",
|
|
34
34
|
"@aws-sdk/client-dynamodb": "^3.1068.0",
|
|
35
35
|
"@aws-sdk/client-s3": "^3.1068.0",
|
|
36
|
+
"@aws-sdk/client-scheduler": "^3.1077.0",
|
|
36
37
|
"@aws-sdk/client-secrets-manager": "^3.1068.0",
|
|
37
38
|
"@aws-sdk/client-sfn": "^3.1068.0",
|
|
38
39
|
"@aws-sdk/client-sns": "^3.1068.0",
|