@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/esm/index.mjs
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { Logger } from '@aws-lambda-powertools/logger';
|
|
1
|
+
import { LogLevelThreshold, Logger } from '@aws-lambda-powertools/logger';
|
|
2
2
|
import { DynamoDBClient } from '@aws-sdk/client-dynamodb';
|
|
3
3
|
import { DynamoDBDocumentClient, paginateQuery, paginateScan, GetCommand, PutCommand, UpdateCommand, DeleteCommand, QueryCommand, ScanCommand, BatchGetCommand, BatchWriteCommand } 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';
|
|
7
|
+
import { SchedulerClient, CreateScheduleCommand, GetScheduleCommand, UpdateScheduleCommand, DeleteScheduleCommand, paginateListSchedules, CreateScheduleGroupCommand, GetScheduleGroupCommand, DeleteScheduleGroupCommand, paginateListScheduleGroups } from '@aws-sdk/client-scheduler';
|
|
7
8
|
import { SecretsManagerClient, CreateSecretCommand, UpdateSecretCommand, PutSecretValueCommand, DeleteSecretCommand, GetSecretValueCommand } from '@aws-sdk/client-secrets-manager';
|
|
8
9
|
import { SFNClient, paginateListExecutions, StartExecutionCommand, DescribeExecutionCommand, StopExecutionCommand } from '@aws-sdk/client-sfn';
|
|
9
10
|
import { SNSClient, PublishCommand, PublishBatchCommand } from '@aws-sdk/client-sns';
|
|
@@ -38,6 +39,18 @@ var __assign = function() {
|
|
|
38
39
|
return __assign.apply(this, arguments);
|
|
39
40
|
};
|
|
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
|
+
|
|
41
54
|
function __awaiter(thisArg, _arguments, P, generator) {
|
|
42
55
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
43
56
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -118,13 +131,25 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
118
131
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
119
132
|
};
|
|
120
133
|
|
|
134
|
+
/**
|
|
135
|
+
* Whether the logger is verbose enough that full SDK inputs — payloads, secret
|
|
136
|
+
* material and PII — may be written to the log.
|
|
137
|
+
*
|
|
138
|
+
* **This is the only place in the package that reads the log level.** Never
|
|
139
|
+
* compare `logger.getLevelName()` yourself: Powertools orders `TRACE` as *more*
|
|
140
|
+
* verbose than `DEBUG` (thresholds 6 and 8), so the obvious
|
|
141
|
+
* `getLevelName() === 'DEBUG'` check silently redacts at the most verbose level
|
|
142
|
+
* available. Route every disclosure decision through this predicate instead.
|
|
143
|
+
*/
|
|
144
|
+
function shouldLogFullInput(logger) {
|
|
145
|
+
return LogLevelThreshold[logger.getLevelName()] <= LogLevelThreshold.DEBUG;
|
|
146
|
+
}
|
|
121
147
|
/**
|
|
122
148
|
* Return a log-safe projection of `input` based on the logger's configured level.
|
|
123
149
|
*
|
|
124
|
-
* At
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
* and PII.
|
|
150
|
+
* At the verbose levels — see {@link shouldLogFullInput} — the full input is
|
|
151
|
+
* returned unchanged: operators who asked for that verbosity have explicitly
|
|
152
|
+
* opted into seeing everything, including payloads, secret material and PII.
|
|
128
153
|
*
|
|
129
154
|
* At any other level, only the fields listed in `safeFields` are included.
|
|
130
155
|
* Missing fields are silently skipped — the result type narrows to
|
|
@@ -135,7 +160,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
135
160
|
* the design rationale and conventions on building the safe-field lists.
|
|
136
161
|
*/
|
|
137
162
|
function filterFieldsForLogLevel(logger, input, safeFields) {
|
|
138
|
-
if (logger
|
|
163
|
+
if (shouldLogFullInput(logger))
|
|
139
164
|
return input;
|
|
140
165
|
var out = {};
|
|
141
166
|
for (var _i = 0, safeFields_1 = safeFields; _i < safeFields_1.length; _i++) {
|
|
@@ -150,7 +175,6 @@ var BATCH_WRITE_MAX_ATTEMPTS = 5;
|
|
|
150
175
|
var BATCH_WRITE_BASE_DELAY_MS = 200;
|
|
151
176
|
/**
|
|
152
177
|
* Fields safe to log at INFO. Omits `Key` (may carry customer IDs / tenant IDs).
|
|
153
|
-
* `POWERTOOLS_LOG_LEVEL=DEBUG` unlocks the full input.
|
|
154
178
|
*/
|
|
155
179
|
var GET_ITEM_SAFE_FIELDS = [
|
|
156
180
|
'TableName',
|
|
@@ -162,7 +186,6 @@ var GET_ITEM_SAFE_FIELDS = [
|
|
|
162
186
|
/**
|
|
163
187
|
* Fields safe to log at INFO. Omits `Item` (the payload itself) and
|
|
164
188
|
* `ExpressionAttributeValues` (values bound to ConditionExpression, often PII).
|
|
165
|
-
* `POWERTOOLS_LOG_LEVEL=DEBUG` unlocks the full input.
|
|
166
189
|
*/
|
|
167
190
|
var PUT_ITEM_SAFE_FIELDS = [
|
|
168
191
|
'TableName',
|
|
@@ -175,7 +198,6 @@ var PUT_ITEM_SAFE_FIELDS = [
|
|
|
175
198
|
];
|
|
176
199
|
/**
|
|
177
200
|
* Fields safe to log at INFO. Omits `Key` and `ExpressionAttributeValues`.
|
|
178
|
-
* `POWERTOOLS_LOG_LEVEL=DEBUG` unlocks the full input.
|
|
179
201
|
*/
|
|
180
202
|
var UPDATE_ITEM_SAFE_FIELDS = [
|
|
181
203
|
'TableName',
|
|
@@ -190,7 +212,6 @@ var UPDATE_ITEM_SAFE_FIELDS = [
|
|
|
190
212
|
/**
|
|
191
213
|
* Fields safe to log at INFO. Omits `Key` and `ExpressionAttributeValues`
|
|
192
214
|
* (the latter binds to ConditionExpression and may carry PII).
|
|
193
|
-
* `POWERTOOLS_LOG_LEVEL=DEBUG` unlocks the full input.
|
|
194
215
|
*/
|
|
195
216
|
var DELETE_ITEM_SAFE_FIELDS = [
|
|
196
217
|
'TableName',
|
|
@@ -204,8 +225,7 @@ var DELETE_ITEM_SAFE_FIELDS = [
|
|
|
204
225
|
/**
|
|
205
226
|
* Fields safe to log at INFO for `query` and `paginateItems`. Omits
|
|
206
227
|
* `ExpressionAttributeValues` (values often carry PII) and `ExclusiveStartKey`
|
|
207
|
-
* (pagination cursor includes Key shape).
|
|
208
|
-
* the full input.
|
|
228
|
+
* (pagination cursor includes Key shape).
|
|
209
229
|
*/
|
|
210
230
|
var QUERY_SAFE_FIELDS = [
|
|
211
231
|
'TableName',
|
|
@@ -223,7 +243,6 @@ var QUERY_SAFE_FIELDS = [
|
|
|
223
243
|
/**
|
|
224
244
|
* Fields safe to log at INFO for `scan` and `paginateScan`. Omits
|
|
225
245
|
* `ExpressionAttributeValues` and `ExclusiveStartKey`.
|
|
226
|
-
* `POWERTOOLS_LOG_LEVEL=DEBUG` unlocks the full input.
|
|
227
246
|
*/
|
|
228
247
|
var SCAN_SAFE_FIELDS = [
|
|
229
248
|
'TableName',
|
|
@@ -247,6 +266,10 @@ var backoffDelay = function (attempt) {
|
|
|
247
266
|
* Wrapper around the AWS DynamoDB Document client providing structured
|
|
248
267
|
* Powertools logging and X-Ray tracing by default.
|
|
249
268
|
*
|
|
269
|
+
* Where a method's input carries payloads, secret material or PII, the INFO
|
|
270
|
+
* log line omits them; the verbose levels (`POWERTOOLS_LOG_LEVEL=DEBUG` or
|
|
271
|
+
* `TRACE`) log full SDK inputs.
|
|
272
|
+
*
|
|
250
273
|
* Items are automatically marshalled / unmarshalled via the document client —
|
|
251
274
|
* callers work with plain TypeScript objects in both directions.
|
|
252
275
|
*/
|
|
@@ -425,12 +448,12 @@ var DynamoDBService = /** @class */ (function () {
|
|
|
425
448
|
*/
|
|
426
449
|
DynamoDBService.prototype.batchGet = function (input) {
|
|
427
450
|
return __awaiter(this, void 0, void 0, function () {
|
|
428
|
-
var
|
|
451
|
+
var logFullInput;
|
|
429
452
|
var _a;
|
|
430
453
|
return __generator(this, function (_b) {
|
|
431
|
-
|
|
454
|
+
logFullInput = shouldLogFullInput(this.logger);
|
|
432
455
|
this.logger.info('Batch getting DynamoDB items', {
|
|
433
|
-
input:
|
|
456
|
+
input: logFullInput ? input : { tables: Object.keys((_a = input.RequestItems) !== null && _a !== void 0 ? _a : {}) },
|
|
434
457
|
});
|
|
435
458
|
return [2 /*return*/, this.client.send(new BatchGetCommand(input))];
|
|
436
459
|
});
|
|
@@ -443,14 +466,14 @@ var DynamoDBService = /** @class */ (function () {
|
|
|
443
466
|
*/
|
|
444
467
|
DynamoDBService.prototype.batchWrite = function (input) {
|
|
445
468
|
return __awaiter(this, void 0, void 0, function () {
|
|
446
|
-
var
|
|
469
|
+
var logFullInput, current, attempt, response, unprocessed;
|
|
447
470
|
var _a;
|
|
448
471
|
return __generator(this, function (_b) {
|
|
449
472
|
switch (_b.label) {
|
|
450
473
|
case 0:
|
|
451
|
-
|
|
474
|
+
logFullInput = shouldLogFullInput(this.logger);
|
|
452
475
|
this.logger.info('Batch writing DynamoDB items', {
|
|
453
|
-
input:
|
|
476
|
+
input: logFullInput ? input : { tables: Object.keys((_a = input.RequestItems) !== null && _a !== void 0 ? _a : {}) },
|
|
454
477
|
});
|
|
455
478
|
current = input;
|
|
456
479
|
attempt = 0;
|
|
@@ -622,13 +645,11 @@ var DEFAULT_PRESIGNED_URL_EXPIRES_IN_SECONDS = 3600;
|
|
|
622
645
|
var DELETE_OBJECTS_BATCH_LIMIT = 1000;
|
|
623
646
|
/**
|
|
624
647
|
* Fields safe to log at INFO for `putObject`. Omits `Body` (object payload).
|
|
625
|
-
* `POWERTOOLS_LOG_LEVEL=DEBUG` unlocks the full input.
|
|
626
648
|
*/
|
|
627
649
|
var PUT_OBJECT_SAFE_FIELDS = ['Bucket', 'Key'];
|
|
628
650
|
/**
|
|
629
651
|
* Fields safe to log at INFO for `putJsonObject`. Omits `Body` (the
|
|
630
652
|
* unserialised JSON payload). `Metadata` is included (operational labels).
|
|
631
|
-
* `POWERTOOLS_LOG_LEVEL=DEBUG` unlocks the full input.
|
|
632
653
|
*/
|
|
633
654
|
var PUT_JSON_OBJECT_SAFE_FIELDS = [
|
|
634
655
|
'Bucket',
|
|
@@ -639,6 +660,10 @@ var PUT_JSON_OBJECT_SAFE_FIELDS = [
|
|
|
639
660
|
* Wrapper around the AWS S3 client providing structured Powertools logging
|
|
640
661
|
* and X-Ray tracing by default.
|
|
641
662
|
*
|
|
663
|
+
* Where a method's input carries payloads, secret material or PII, the INFO
|
|
664
|
+
* log line omits them; the verbose levels (`POWERTOOLS_LOG_LEVEL=DEBUG` or
|
|
665
|
+
* `TRACE`) log full SDK inputs.
|
|
666
|
+
*
|
|
642
667
|
* Input shapes are intentionally tight (Bucket/Key/Body only). Callers
|
|
643
668
|
* needing SDK-level options not exposed here (server-side encryption,
|
|
644
669
|
* tagging, version IDs) should use `S3Client` directly.
|
|
@@ -961,13 +986,13 @@ var S3Service = /** @class */ (function () {
|
|
|
961
986
|
*/
|
|
962
987
|
S3Service.prototype.deleteObjects = function (bucket, keys) {
|
|
963
988
|
return __awaiter(this, void 0, void 0, function () {
|
|
964
|
-
var
|
|
989
|
+
var logFullInput, results, i, batch, _a, _b;
|
|
965
990
|
return __generator(this, function (_c) {
|
|
966
991
|
switch (_c.label) {
|
|
967
992
|
case 0:
|
|
968
|
-
|
|
993
|
+
logFullInput = shouldLogFullInput(this.logger);
|
|
969
994
|
this.logger.info('Deleting S3 objects', {
|
|
970
|
-
input:
|
|
995
|
+
input: logFullInput ? { bucket: bucket, keys: keys } : { bucket: bucket, keyCount: keys.length },
|
|
971
996
|
});
|
|
972
997
|
results = [];
|
|
973
998
|
i = 0;
|
|
@@ -1055,10 +1080,265 @@ var S3Service = /** @class */ (function () {
|
|
|
1055
1080
|
return S3Service;
|
|
1056
1081
|
}());
|
|
1057
1082
|
|
|
1083
|
+
/**
|
|
1084
|
+
* `CreateSchedule` / `UpdateSchedule` inputs carry the payload handed to the
|
|
1085
|
+
* target at `Target.Input` — arbitrary text or JSON that routinely contains
|
|
1086
|
+
* PII (customer IDs, order contents, etc.), the same risk profile as SFN's
|
|
1087
|
+
* execution `input`.
|
|
1088
|
+
*
|
|
1089
|
+
* This can't go through the package's usual `filterFieldsForLogLevel` helper:
|
|
1090
|
+
* that helper picks **top-level** keys only, and the sensitive field is nested
|
|
1091
|
+
* one level down inside `Target`. Allowlisting `Target` would leak `Input`;
|
|
1092
|
+
* omitting `Target` would lose operationally-useful fields (`Arn`, `RoleArn`,
|
|
1093
|
+
* `RetryPolicy`, `DeadLetterConfig`, the target-type params). So this is a
|
|
1094
|
+
* bespoke case: keep every top-level field and shallow-strip only
|
|
1095
|
+
* `Target.Input`.
|
|
1096
|
+
*
|
|
1097
|
+
* At the verbose levels — see {@link shouldLogFullInput} — the input is
|
|
1098
|
+
* returned unchanged: operators who asked for that verbosity have opted into
|
|
1099
|
+
* seeing payloads and PII.
|
|
1100
|
+
*/
|
|
1101
|
+
function redactTargetInput(logger, input) {
|
|
1102
|
+
var _a;
|
|
1103
|
+
if (shouldLogFullInput(logger))
|
|
1104
|
+
return input;
|
|
1105
|
+
if (((_a = input.Target) === null || _a === void 0 ? void 0 : _a.Input) === undefined)
|
|
1106
|
+
return input;
|
|
1107
|
+
var _b = input.Target; _b.Input; var safeTarget = __rest(_b, ["Input"]);
|
|
1108
|
+
return __assign(__assign({}, input), { Target: safeTarget });
|
|
1109
|
+
}
|
|
1110
|
+
/**
|
|
1111
|
+
* Wrapper around the AWS EventBridge Scheduler client providing structured
|
|
1112
|
+
* Powertools logging and X-Ray tracing by default.
|
|
1113
|
+
*
|
|
1114
|
+
* Where a method's input carries payloads, secret material or PII, the INFO
|
|
1115
|
+
* log line omits them; the verbose levels (`POWERTOOLS_LOG_LEVEL=DEBUG` or
|
|
1116
|
+
* `TRACE`) log full SDK inputs.
|
|
1117
|
+
*
|
|
1118
|
+
* Covers CRUD on schedules and their groups. Named `SchedulerService` (not
|
|
1119
|
+
* `EventBridgeSchedulerService`) so it doesn't collide with a future wrapper
|
|
1120
|
+
* over the separate EventBridge bus/rules API (`@aws-sdk/client-eventbridge`).
|
|
1121
|
+
*
|
|
1122
|
+
* `FlexibleTimeWindow` is required by `CreateSchedule` and is passed through
|
|
1123
|
+
* untouched — the wrapper bakes in no default, so the caller must state their
|
|
1124
|
+
* intent (`{ Mode: 'OFF' }` for a fixed-time schedule).
|
|
1125
|
+
*/
|
|
1126
|
+
var SchedulerService = /** @class */ (function () {
|
|
1127
|
+
/**
|
|
1128
|
+
* @param opts.logger - Optional Powertools logger. Defaults to `new Logger()`,
|
|
1129
|
+
* which picks up `POWERTOOLS_SERVICE_NAME` from the environment.
|
|
1130
|
+
* @param opts.client - Optional pre-configured `SchedulerClient`. When
|
|
1131
|
+
* supplied, the wrapper does not apply X-Ray instrumentation.
|
|
1132
|
+
*/
|
|
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();
|
|
1137
|
+
}
|
|
1138
|
+
/**
|
|
1139
|
+
* Create a new schedule. At INFO the log line omits `Target.Input` (the
|
|
1140
|
+
* target payload, a PII carrier).
|
|
1141
|
+
*/
|
|
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
|
+
};
|
|
1150
|
+
/**
|
|
1151
|
+
* Fetch a schedule's full configuration.
|
|
1152
|
+
*/
|
|
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
|
+
};
|
|
1161
|
+
/**
|
|
1162
|
+
* Update an existing schedule.
|
|
1163
|
+
*
|
|
1164
|
+
* **`UpdateSchedule` has PUT (full-replacement) semantics.** Any field you
|
|
1165
|
+
* omit is reset to its default — this is not a partial patch. To change one
|
|
1166
|
+
* attribute, `getSchedule` first and resend the complete configuration with
|
|
1167
|
+
* that attribute modified, or you will silently erase `ScheduleExpression`,
|
|
1168
|
+
* `Target`, `Description`, `StartDate`, etc. The wrapper does not merge on
|
|
1169
|
+
* your behalf: deep-merging a `Target` (with its mutually-exclusive
|
|
1170
|
+
* target-type params) has no single correct semantics.
|
|
1171
|
+
*
|
|
1172
|
+
* At INFO the log line omits `Target.Input`.
|
|
1173
|
+
*/
|
|
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
|
+
};
|
|
1182
|
+
/**
|
|
1183
|
+
* Delete a schedule.
|
|
1184
|
+
*/
|
|
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
|
+
};
|
|
1193
|
+
/**
|
|
1194
|
+
* List schedules, auto-paginating across all pages. Bounded in practice by
|
|
1195
|
+
* the account's schedule count and the `GroupName` / `NamePrefix` / `State`
|
|
1196
|
+
* filters, so the flat-array shape is safe.
|
|
1197
|
+
*/
|
|
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
|
+
};
|
|
1247
|
+
/**
|
|
1248
|
+
* Create a new schedule group. Groups are containers for schedules and are
|
|
1249
|
+
* typically IaC-managed; use this for dynamically-provisioned groups only.
|
|
1250
|
+
*/
|
|
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
|
+
};
|
|
1259
|
+
/**
|
|
1260
|
+
* Fetch a schedule group's configuration.
|
|
1261
|
+
*/
|
|
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
|
+
};
|
|
1270
|
+
/**
|
|
1271
|
+
* Delete a schedule group. Deleting a group also deletes every schedule it
|
|
1272
|
+
* contains, asynchronously — the API has no `UpdateScheduleGroup`, so this
|
|
1273
|
+
* is the only mutating group operation besides create.
|
|
1274
|
+
*/
|
|
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
|
+
};
|
|
1283
|
+
/**
|
|
1284
|
+
* List schedule groups, auto-paginating across all pages. Bounded in
|
|
1285
|
+
* practice by the account's group count and the `NamePrefix` filter.
|
|
1286
|
+
*/
|
|
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
|
+
}());
|
|
1338
|
+
|
|
1058
1339
|
/**
|
|
1059
1340
|
* Fields safe to log at INFO level. Omits `SecretString` and `SecretBinary` —
|
|
1060
|
-
* the secret material itself.
|
|
1061
|
-
* input.
|
|
1341
|
+
* the secret material itself.
|
|
1062
1342
|
*/
|
|
1063
1343
|
var CREATE_SECRET_SAFE_FIELDS = [
|
|
1064
1344
|
'Name',
|
|
@@ -1094,6 +1374,10 @@ var DELETE_SECRET_SAFE_FIELDS = [
|
|
|
1094
1374
|
* Wrapper around the AWS Secrets Manager client providing structured
|
|
1095
1375
|
* Powertools logging and X-Ray tracing by default.
|
|
1096
1376
|
*
|
|
1377
|
+
* Where a method's input carries payloads, secret material or PII, the INFO
|
|
1378
|
+
* log line omits them; the verbose levels (`POWERTOOLS_LOG_LEVEL=DEBUG` or
|
|
1379
|
+
* `TRACE`) log full SDK inputs.
|
|
1380
|
+
*
|
|
1097
1381
|
* Write operations (`createSecret`, `updateSecret`, `putSecretValue`,
|
|
1098
1382
|
* `deleteSecret`) are exposed for convenience but should be used with care:
|
|
1099
1383
|
* secret lifecycle is usually managed by IaC (CDK / Terraform). Prefer IaC
|
|
@@ -1153,8 +1437,7 @@ var SecretsManagerService = /** @class */ (function () {
|
|
|
1153
1437
|
};
|
|
1154
1438
|
/**
|
|
1155
1439
|
* Create a new secret. At INFO level the log line includes only identity
|
|
1156
|
-
* and non-secret metadata
|
|
1157
|
-
* input (including `SecretString` / `SecretBinary`).
|
|
1440
|
+
* and non-secret metadata.
|
|
1158
1441
|
*
|
|
1159
1442
|
* Prefer IaC (CDK / Terraform) for secret lifecycle — use this for
|
|
1160
1443
|
* dynamically-issued credentials only.
|
|
@@ -1171,8 +1454,7 @@ var SecretsManagerService = /** @class */ (function () {
|
|
|
1171
1454
|
};
|
|
1172
1455
|
/**
|
|
1173
1456
|
* Update an existing secret's metadata or value. At INFO level the log
|
|
1174
|
-
* line omits `SecretString` / `SecretBinary
|
|
1175
|
-
* unlocks the full input.
|
|
1457
|
+
* line omits `SecretString` / `SecretBinary`.
|
|
1176
1458
|
*
|
|
1177
1459
|
* Prefer IaC (CDK / Terraform) for secret lifecycle — use this for
|
|
1178
1460
|
* runtime metadata updates only.
|
|
@@ -1189,8 +1471,7 @@ var SecretsManagerService = /** @class */ (function () {
|
|
|
1189
1471
|
};
|
|
1190
1472
|
/**
|
|
1191
1473
|
* Store a new version of a secret's value. At INFO level the log line
|
|
1192
|
-
* omits `SecretString` / `SecretBinary
|
|
1193
|
-
* unlocks the full input.
|
|
1474
|
+
* omits `SecretString` / `SecretBinary`.
|
|
1194
1475
|
*
|
|
1195
1476
|
* Typically used by rotation flows.
|
|
1196
1477
|
*/
|
|
@@ -1242,7 +1523,7 @@ var SecretsManagerService = /** @class */ (function () {
|
|
|
1242
1523
|
/**
|
|
1243
1524
|
* Fields safe to log at INFO for `startExecution`. Omits `input` — the SFN
|
|
1244
1525
|
* execution payload, which routinely carries PII (customer IDs, addresses,
|
|
1245
|
-
* order contents, etc.).
|
|
1526
|
+
* order contents, etc.).
|
|
1246
1527
|
*/
|
|
1247
1528
|
var START_EXECUTION_SAFE_FIELDS = [
|
|
1248
1529
|
'stateMachineArn',
|
|
@@ -1252,6 +1533,10 @@ var START_EXECUTION_SAFE_FIELDS = [
|
|
|
1252
1533
|
/**
|
|
1253
1534
|
* Wrapper around the AWS Step Functions client providing structured
|
|
1254
1535
|
* Powertools logging and X-Ray tracing by default.
|
|
1536
|
+
*
|
|
1537
|
+
* Where a method's input carries payloads, secret material or PII, the INFO
|
|
1538
|
+
* log line omits them; the verbose levels (`POWERTOOLS_LOG_LEVEL=DEBUG` or
|
|
1539
|
+
* `TRACE`) log full SDK inputs.
|
|
1255
1540
|
*/
|
|
1256
1541
|
var StepFunctionsService = /** @class */ (function () {
|
|
1257
1542
|
/**
|
|
@@ -1397,7 +1682,7 @@ var SNS_SUBJECT_MAX_CHARS = 100;
|
|
|
1397
1682
|
* Fields safe to log at INFO level for `publish`. Omits `Message`, `Subject`,
|
|
1398
1683
|
* `MessageAttributes`, and `PhoneNumber` — payloads, user-visible content
|
|
1399
1684
|
* (subjects often carry order numbers / customer names), and PII recipient
|
|
1400
|
-
* identifiers.
|
|
1685
|
+
* identifiers.
|
|
1401
1686
|
*/
|
|
1402
1687
|
var PUBLISH_SAFE_FIELDS = [
|
|
1403
1688
|
'TopicArn',
|
|
@@ -1409,6 +1694,10 @@ var PUBLISH_SAFE_FIELDS = [
|
|
|
1409
1694
|
/**
|
|
1410
1695
|
* Wrapper around the AWS SNS client providing structured Powertools logging
|
|
1411
1696
|
* and X-Ray tracing by default.
|
|
1697
|
+
*
|
|
1698
|
+
* Where a method's input carries payloads, secret material or PII, the INFO
|
|
1699
|
+
* log line omits them; the verbose levels (`POWERTOOLS_LOG_LEVEL=DEBUG` or
|
|
1700
|
+
* `TRACE`) log full SDK inputs.
|
|
1412
1701
|
*/
|
|
1413
1702
|
var SNSService = /** @class */ (function () {
|
|
1414
1703
|
/**
|
|
@@ -1432,8 +1721,7 @@ var SNSService = /** @class */ (function () {
|
|
|
1432
1721
|
* Publish a single message to an SNS topic.
|
|
1433
1722
|
*
|
|
1434
1723
|
* At INFO level the log line includes only routing / dedup metadata; see
|
|
1435
|
-
* `PUBLISH_SAFE_FIELDS` for the list.
|
|
1436
|
-
* unlocks the full input.
|
|
1724
|
+
* `PUBLISH_SAFE_FIELDS` for the list.
|
|
1437
1725
|
*
|
|
1438
1726
|
* @param input - PublishCommandInput including TopicArn and Message.
|
|
1439
1727
|
*/
|
|
@@ -1477,15 +1765,15 @@ var SNSService = /** @class */ (function () {
|
|
|
1477
1765
|
*/
|
|
1478
1766
|
SNSService.prototype.publishBatch = function (input) {
|
|
1479
1767
|
return __awaiter(this, void 0, void 0, function () {
|
|
1480
|
-
var entries,
|
|
1768
|
+
var entries, logFullInput, results, i, chunk, _a, _b;
|
|
1481
1769
|
var _c;
|
|
1482
1770
|
return __generator(this, function (_d) {
|
|
1483
1771
|
switch (_d.label) {
|
|
1484
1772
|
case 0:
|
|
1485
1773
|
entries = (_c = input.PublishBatchRequestEntries) !== null && _c !== void 0 ? _c : [];
|
|
1486
|
-
|
|
1774
|
+
logFullInput = shouldLogFullInput(this.logger);
|
|
1487
1775
|
this.logger.info('Publishing SNS message batch', {
|
|
1488
|
-
input:
|
|
1776
|
+
input: logFullInput ? input : { TopicArn: input.TopicArn, entryCount: entries.length },
|
|
1489
1777
|
});
|
|
1490
1778
|
results = [];
|
|
1491
1779
|
i = 0;
|
|
@@ -1514,7 +1802,6 @@ var SQS_MESSAGE_BODY_MAX_BYTES = 256 * 1024;
|
|
|
1514
1802
|
/**
|
|
1515
1803
|
* Fields safe to log at INFO level for `sendMessage`. Omits `MessageBody` and
|
|
1516
1804
|
* `MessageAttributes` — both carry payload content.
|
|
1517
|
-
* `POWERTOOLS_LOG_LEVEL=DEBUG` unlocks the full input.
|
|
1518
1805
|
*/
|
|
1519
1806
|
var SEND_MESSAGE_SAFE_FIELDS = [
|
|
1520
1807
|
'QueueUrl',
|
|
@@ -1525,6 +1812,10 @@ var SEND_MESSAGE_SAFE_FIELDS = [
|
|
|
1525
1812
|
/**
|
|
1526
1813
|
* Wrapper around the AWS SQS client providing structured Powertools logging
|
|
1527
1814
|
* and X-Ray tracing by default.
|
|
1815
|
+
*
|
|
1816
|
+
* Where a method's input carries payloads, secret material or PII, the INFO
|
|
1817
|
+
* log line omits them; the verbose levels (`POWERTOOLS_LOG_LEVEL=DEBUG` or
|
|
1818
|
+
* `TRACE`) log full SDK inputs.
|
|
1528
1819
|
*/
|
|
1529
1820
|
var SQSService = /** @class */ (function () {
|
|
1530
1821
|
/**
|
|
@@ -1547,8 +1838,7 @@ var SQSService = /** @class */ (function () {
|
|
|
1547
1838
|
* Send a single message to an SQS queue.
|
|
1548
1839
|
*
|
|
1549
1840
|
* At INFO level the log line includes only queue routing / FIFO metadata;
|
|
1550
|
-
* see `SEND_MESSAGE_SAFE_FIELDS`.
|
|
1551
|
-
* full input.
|
|
1841
|
+
* see `SEND_MESSAGE_SAFE_FIELDS`.
|
|
1552
1842
|
*/
|
|
1553
1843
|
SQSService.prototype.sendMessage = function (input, opts) {
|
|
1554
1844
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -1617,15 +1907,15 @@ var SQSService = /** @class */ (function () {
|
|
|
1617
1907
|
*/
|
|
1618
1908
|
SQSService.prototype.sendMessageBatch = function (input) {
|
|
1619
1909
|
return __awaiter(this, void 0, void 0, function () {
|
|
1620
|
-
var entries,
|
|
1910
|
+
var entries, logFullInput, results, i, chunk, _a, _b;
|
|
1621
1911
|
var _c;
|
|
1622
1912
|
return __generator(this, function (_d) {
|
|
1623
1913
|
switch (_d.label) {
|
|
1624
1914
|
case 0:
|
|
1625
1915
|
entries = (_c = input.Entries) !== null && _c !== void 0 ? _c : [];
|
|
1626
|
-
|
|
1916
|
+
logFullInput = shouldLogFullInput(this.logger);
|
|
1627
1917
|
this.logger.info('Sending SQS message batch', {
|
|
1628
|
-
input:
|
|
1918
|
+
input: logFullInput ? input : { QueueUrl: input.QueueUrl, entryCount: entries.length },
|
|
1629
1919
|
});
|
|
1630
1920
|
results = [];
|
|
1631
1921
|
i = 0;
|
|
@@ -1653,15 +1943,15 @@ var SQSService = /** @class */ (function () {
|
|
|
1653
1943
|
*/
|
|
1654
1944
|
SQSService.prototype.deleteMessageBatch = function (input) {
|
|
1655
1945
|
return __awaiter(this, void 0, void 0, function () {
|
|
1656
|
-
var entries,
|
|
1946
|
+
var entries, logFullInput, results, i, chunk, _a, _b;
|
|
1657
1947
|
var _c;
|
|
1658
1948
|
return __generator(this, function (_d) {
|
|
1659
1949
|
switch (_d.label) {
|
|
1660
1950
|
case 0:
|
|
1661
1951
|
entries = (_c = input.Entries) !== null && _c !== void 0 ? _c : [];
|
|
1662
|
-
|
|
1952
|
+
logFullInput = shouldLogFullInput(this.logger);
|
|
1663
1953
|
this.logger.info('Deleting SQS message batch', {
|
|
1664
|
-
input:
|
|
1954
|
+
input: logFullInput ? input : { QueueUrl: input.QueueUrl, entryCount: entries.length },
|
|
1665
1955
|
});
|
|
1666
1956
|
results = [];
|
|
1667
1957
|
i = 0;
|
|
@@ -1687,8 +1977,7 @@ var SQSService = /** @class */ (function () {
|
|
|
1687
1977
|
|
|
1688
1978
|
/**
|
|
1689
1979
|
* Fields safe to log at INFO level for `putParameter`. Omits `Value` (the
|
|
1690
|
-
* parameter content itself).
|
|
1691
|
-
* input.
|
|
1980
|
+
* parameter content itself).
|
|
1692
1981
|
*/
|
|
1693
1982
|
var PUT_PARAMETER_SAFE_FIELDS = [
|
|
1694
1983
|
'Name',
|
|
@@ -1708,6 +1997,10 @@ var PUT_PARAMETER_SAFE_FIELDS = [
|
|
|
1708
1997
|
* `WithDecryption` — callers needing plaintext should use `SSMClient`
|
|
1709
1998
|
* directly.
|
|
1710
1999
|
*
|
|
2000
|
+
* Where a method's input carries payloads, secret material or PII, the INFO
|
|
2001
|
+
* log line omits them; the verbose levels (`POWERTOOLS_LOG_LEVEL=DEBUG` or
|
|
2002
|
+
* `TRACE`) log full SDK inputs.
|
|
2003
|
+
*
|
|
1711
2004
|
* Write operations (`putParameter`, `deleteParameter`) are exposed for
|
|
1712
2005
|
* convenience but should be used with care: parameter lifecycle is usually
|
|
1713
2006
|
* managed by IaC (CDK / Terraform). Prefer IaC for anything that exists at
|
|
@@ -1900,4 +2193,4 @@ var SSMService = /** @class */ (function () {
|
|
|
1900
2193
|
return SSMService;
|
|
1901
2194
|
}());
|
|
1902
2195
|
|
|
1903
|
-
export { DynamoDBService, S3Service, SNSService, SQSService, SSMService, SecretsManagerService, StepFunctionsService };
|
|
2196
|
+
export { DynamoDBService, S3Service, SNSService, SQSService, SSMService, SchedulerService, SecretsManagerService, StepFunctionsService };
|