@aligent/aws-wrappers 0.1.2 → 0.2.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 +56 -0
- package/cjs/index.cjs +267 -0
- package/cjs/package.json +2 -1
- package/cjs/src/index.d.ts +1 -0
- package/cjs/src/scheduler/scheduler.d.ts +83 -0
- package/docs/classes/DynamoDBService.md +65 -34
- package/docs/classes/S3Service.md +73 -33
- package/docs/classes/SNSService.md +28 -8
- package/docs/classes/SQSService.md +30 -11
- package/docs/classes/SSMService.md +66 -9
- package/docs/classes/SchedulerService.md +269 -0
- package/docs/classes/SecretsManagerService.md +119 -7
- package/docs/classes/StepFunctionsService.md +9 -9
- package/docs/modules.md +1 -0
- package/esm/index.mjs +267 -1
- package/esm/package.json +2 -1
- package/esm/src/index.d.ts +1 -0
- package/esm/src/scheduler/scheduler.d.ts +83 -0
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -187,6 +187,62 @@ const description = await sfn.describeExecution({ executionArn });
|
|
|
187
187
|
await sfn.stopExecution({ executionArn });
|
|
188
188
|
```
|
|
189
189
|
|
|
190
|
+
## EventBridge Scheduler
|
|
191
|
+
|
|
192
|
+
```ts
|
|
193
|
+
import { SchedulerService } from '@aligent/aws-wrappers';
|
|
194
|
+
|
|
195
|
+
const scheduler = new SchedulerService();
|
|
196
|
+
|
|
197
|
+
// FlexibleTimeWindow is required — pass { Mode: 'OFF' } for a fixed-time
|
|
198
|
+
// schedule. The wrapper bakes in no default.
|
|
199
|
+
await scheduler.createSchedule({
|
|
200
|
+
Name: 'nightly-sync',
|
|
201
|
+
GroupName: 'default',
|
|
202
|
+
ScheduleExpression: 'rate(1 day)',
|
|
203
|
+
FlexibleTimeWindow: { Mode: 'OFF' },
|
|
204
|
+
Target: {
|
|
205
|
+
Arn: 'arn:aws:lambda:us-east-1:0:function:my-fn',
|
|
206
|
+
RoleArn: 'arn:aws:iam::0:role/scheduler-invoke',
|
|
207
|
+
Input: JSON.stringify({ job: 'sync' }),
|
|
208
|
+
},
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
const schedule = await scheduler.getSchedule({ Name: 'nightly-sync' });
|
|
212
|
+
|
|
213
|
+
// UpdateSchedule is a FULL REPLACEMENT, not a patch. Any omitted field is
|
|
214
|
+
// reset to its default, so resend the complete configuration and override
|
|
215
|
+
// only what changes. GetSchedule types every field as optional, so the
|
|
216
|
+
// required fields (Name, ScheduleExpression, FlexibleTimeWindow, Target) must
|
|
217
|
+
// be re-asserted after the spread.
|
|
218
|
+
await scheduler.updateSchedule({
|
|
219
|
+
...schedule,
|
|
220
|
+
Name: 'nightly-sync',
|
|
221
|
+
ScheduleExpression: 'rate(12 hours)', // the change
|
|
222
|
+
FlexibleTimeWindow: schedule.FlexibleTimeWindow ?? { Mode: 'OFF' },
|
|
223
|
+
Target: schedule.Target ?? {
|
|
224
|
+
Arn: 'arn:aws:lambda:us-east-1:0:function:my-fn',
|
|
225
|
+
RoleArn: 'arn:aws:iam::0:role/scheduler-invoke',
|
|
226
|
+
},
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
// Auto-paginated — returns every summary across all pages.
|
|
230
|
+
const schedules = await scheduler.listSchedules({ GroupName: 'default' });
|
|
231
|
+
|
|
232
|
+
await scheduler.deleteSchedule({ Name: 'nightly-sync' });
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
`Target.Input` is the payload handed to the target and is omitted from INFO logs (it routinely carries PII); `POWERTOOLS_LOG_LEVEL=DEBUG` unlocks the full input.
|
|
236
|
+
|
|
237
|
+
```ts
|
|
238
|
+
// Schedule groups. Groups have no update operation — only create, get,
|
|
239
|
+
// delete, and list. Deleting a group deletes every schedule it contains.
|
|
240
|
+
await scheduler.createScheduleGroup({ Name: 'integrations' });
|
|
241
|
+
const group = await scheduler.getScheduleGroup({ Name: 'integrations' });
|
|
242
|
+
const groups = await scheduler.listScheduleGroups();
|
|
243
|
+
await scheduler.deleteScheduleGroup({ Name: 'integrations' });
|
|
244
|
+
```
|
|
245
|
+
|
|
190
246
|
## SSM Parameter Store
|
|
191
247
|
|
|
192
248
|
```ts
|
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) {
|
|
@@ -1057,6 +1070,259 @@ var S3Service = /** @class */ (function () {
|
|
|
1057
1070
|
return S3Service;
|
|
1058
1071
|
}());
|
|
1059
1072
|
|
|
1073
|
+
/**
|
|
1074
|
+
* `CreateSchedule` / `UpdateSchedule` inputs carry the payload handed to the
|
|
1075
|
+
* target at `Target.Input` — arbitrary text or JSON that routinely contains
|
|
1076
|
+
* PII (customer IDs, order contents, etc.), the same risk profile as SFN's
|
|
1077
|
+
* execution `input`.
|
|
1078
|
+
*
|
|
1079
|
+
* This can't go through the package's usual `filterFieldsForLogLevel` helper:
|
|
1080
|
+
* that helper picks **top-level** keys only, and the sensitive field is nested
|
|
1081
|
+
* one level down inside `Target`. Allowlisting `Target` would leak `Input`;
|
|
1082
|
+
* omitting `Target` would lose operationally-useful fields (`Arn`, `RoleArn`,
|
|
1083
|
+
* `RetryPolicy`, `DeadLetterConfig`, the target-type params). So this is a
|
|
1084
|
+
* bespoke case: keep every top-level field and shallow-strip only
|
|
1085
|
+
* `Target.Input`.
|
|
1086
|
+
*
|
|
1087
|
+
* At `DEBUG` the input is returned unchanged — operators who set
|
|
1088
|
+
* `POWERTOOLS_LOG_LEVEL=DEBUG` have opted into seeing payloads and PII.
|
|
1089
|
+
*/
|
|
1090
|
+
function redactTargetInput(logger, input) {
|
|
1091
|
+
var _a;
|
|
1092
|
+
if (logger.getLevelName() === 'DEBUG')
|
|
1093
|
+
return input;
|
|
1094
|
+
if (((_a = input.Target) === null || _a === void 0 ? void 0 : _a.Input) === undefined)
|
|
1095
|
+
return input;
|
|
1096
|
+
var _b = input.Target; _b.Input; var safeTarget = __rest(_b, ["Input"]);
|
|
1097
|
+
return __assign(__assign({}, input), { Target: safeTarget });
|
|
1098
|
+
}
|
|
1099
|
+
/**
|
|
1100
|
+
* Wrapper around the AWS EventBridge Scheduler client providing structured
|
|
1101
|
+
* Powertools logging and X-Ray tracing by default.
|
|
1102
|
+
*
|
|
1103
|
+
* Covers CRUD on schedules and their groups. Named `SchedulerService` (not
|
|
1104
|
+
* `EventBridgeSchedulerService`) so it doesn't collide with a future wrapper
|
|
1105
|
+
* over the separate EventBridge bus/rules API (`@aws-sdk/client-eventbridge`).
|
|
1106
|
+
*
|
|
1107
|
+
* `FlexibleTimeWindow` is required by `CreateSchedule` and is passed through
|
|
1108
|
+
* untouched — the wrapper bakes in no default, so the caller must state their
|
|
1109
|
+
* intent (`{ Mode: 'OFF' }` for a fixed-time schedule).
|
|
1110
|
+
*/
|
|
1111
|
+
var SchedulerService = /** @class */ (function () {
|
|
1112
|
+
/**
|
|
1113
|
+
* @param opts.logger - Optional Powertools logger. Defaults to `new Logger()`,
|
|
1114
|
+
* which picks up `POWERTOOLS_SERVICE_NAME` from the environment.
|
|
1115
|
+
* @param opts.client - Optional pre-configured `SchedulerClient`. When
|
|
1116
|
+
* supplied, the wrapper does not apply X-Ray instrumentation.
|
|
1117
|
+
*/
|
|
1118
|
+
function SchedulerService(opts) {
|
|
1119
|
+
var _a, _b;
|
|
1120
|
+
this.client = (_a = opts === null || opts === void 0 ? void 0 : opts.client) !== null && _a !== void 0 ? _a : xray.captureAWSv3Client(new clientScheduler.SchedulerClient());
|
|
1121
|
+
this.logger = (_b = opts === null || opts === void 0 ? void 0 : opts.logger) !== null && _b !== void 0 ? _b : new logger.Logger();
|
|
1122
|
+
}
|
|
1123
|
+
/**
|
|
1124
|
+
* Create a new schedule. At INFO the log line omits `Target.Input` (the
|
|
1125
|
+
* target payload, a PII carrier); `POWERTOOLS_LOG_LEVEL=DEBUG` unlocks the
|
|
1126
|
+
* full input.
|
|
1127
|
+
*/
|
|
1128
|
+
SchedulerService.prototype.createSchedule = function (input) {
|
|
1129
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1130
|
+
return __generator(this, function (_a) {
|
|
1131
|
+
this.logger.info('Creating schedule', { input: redactTargetInput(this.logger, input) });
|
|
1132
|
+
return [2 /*return*/, this.client.send(new clientScheduler.CreateScheduleCommand(input))];
|
|
1133
|
+
});
|
|
1134
|
+
});
|
|
1135
|
+
};
|
|
1136
|
+
/**
|
|
1137
|
+
* Fetch a schedule's full configuration.
|
|
1138
|
+
*/
|
|
1139
|
+
SchedulerService.prototype.getSchedule = function (input) {
|
|
1140
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1141
|
+
return __generator(this, function (_a) {
|
|
1142
|
+
this.logger.info('Getting schedule', { input: input });
|
|
1143
|
+
return [2 /*return*/, this.client.send(new clientScheduler.GetScheduleCommand(input))];
|
|
1144
|
+
});
|
|
1145
|
+
});
|
|
1146
|
+
};
|
|
1147
|
+
/**
|
|
1148
|
+
* Update an existing schedule.
|
|
1149
|
+
*
|
|
1150
|
+
* **`UpdateSchedule` has PUT (full-replacement) semantics.** Any field you
|
|
1151
|
+
* omit is reset to its default — this is not a partial patch. To change one
|
|
1152
|
+
* attribute, `getSchedule` first and resend the complete configuration with
|
|
1153
|
+
* that attribute modified, or you will silently erase `ScheduleExpression`,
|
|
1154
|
+
* `Target`, `Description`, `StartDate`, etc. The wrapper does not merge on
|
|
1155
|
+
* your behalf: deep-merging a `Target` (with its mutually-exclusive
|
|
1156
|
+
* target-type params) has no single correct semantics.
|
|
1157
|
+
*
|
|
1158
|
+
* At INFO the log line omits `Target.Input`; `POWERTOOLS_LOG_LEVEL=DEBUG`
|
|
1159
|
+
* unlocks the full input.
|
|
1160
|
+
*/
|
|
1161
|
+
SchedulerService.prototype.updateSchedule = function (input) {
|
|
1162
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1163
|
+
return __generator(this, function (_a) {
|
|
1164
|
+
this.logger.info('Updating schedule', { input: redactTargetInput(this.logger, input) });
|
|
1165
|
+
return [2 /*return*/, this.client.send(new clientScheduler.UpdateScheduleCommand(input))];
|
|
1166
|
+
});
|
|
1167
|
+
});
|
|
1168
|
+
};
|
|
1169
|
+
/**
|
|
1170
|
+
* Delete a schedule.
|
|
1171
|
+
*/
|
|
1172
|
+
SchedulerService.prototype.deleteSchedule = function (input) {
|
|
1173
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1174
|
+
return __generator(this, function (_a) {
|
|
1175
|
+
this.logger.info('Deleting schedule', { input: input });
|
|
1176
|
+
return [2 /*return*/, this.client.send(new clientScheduler.DeleteScheduleCommand(input))];
|
|
1177
|
+
});
|
|
1178
|
+
});
|
|
1179
|
+
};
|
|
1180
|
+
/**
|
|
1181
|
+
* List schedules, auto-paginating across all pages. Bounded in practice by
|
|
1182
|
+
* the account's schedule count and the `GroupName` / `NamePrefix` / `State`
|
|
1183
|
+
* filters, so the flat-array shape is safe.
|
|
1184
|
+
*/
|
|
1185
|
+
SchedulerService.prototype.listSchedules = function (input) {
|
|
1186
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1187
|
+
var paginator, schedules, _a, paginator_1, paginator_1_1, page, e_1_1;
|
|
1188
|
+
var _b, e_1, _c, _d;
|
|
1189
|
+
return __generator(this, function (_e) {
|
|
1190
|
+
switch (_e.label) {
|
|
1191
|
+
case 0:
|
|
1192
|
+
this.logger.info('Listing schedules', { input: input });
|
|
1193
|
+
paginator = clientScheduler.paginateListSchedules({ client: this.client }, input !== null && input !== void 0 ? input : {});
|
|
1194
|
+
schedules = [];
|
|
1195
|
+
_e.label = 1;
|
|
1196
|
+
case 1:
|
|
1197
|
+
_e.trys.push([1, 6, 7, 12]);
|
|
1198
|
+
_a = true, paginator_1 = __asyncValues(paginator);
|
|
1199
|
+
_e.label = 2;
|
|
1200
|
+
case 2: return [4 /*yield*/, paginator_1.next()];
|
|
1201
|
+
case 3:
|
|
1202
|
+
if (!(paginator_1_1 = _e.sent(), _b = paginator_1_1.done, !_b)) return [3 /*break*/, 5];
|
|
1203
|
+
_d = paginator_1_1.value;
|
|
1204
|
+
_a = false;
|
|
1205
|
+
page = _d;
|
|
1206
|
+
if (page.Schedules)
|
|
1207
|
+
schedules.push.apply(schedules, page.Schedules);
|
|
1208
|
+
_e.label = 4;
|
|
1209
|
+
case 4:
|
|
1210
|
+
_a = true;
|
|
1211
|
+
return [3 /*break*/, 2];
|
|
1212
|
+
case 5: return [3 /*break*/, 12];
|
|
1213
|
+
case 6:
|
|
1214
|
+
e_1_1 = _e.sent();
|
|
1215
|
+
e_1 = { error: e_1_1 };
|
|
1216
|
+
return [3 /*break*/, 12];
|
|
1217
|
+
case 7:
|
|
1218
|
+
_e.trys.push([7, , 10, 11]);
|
|
1219
|
+
if (!(!_a && !_b && (_c = paginator_1.return))) return [3 /*break*/, 9];
|
|
1220
|
+
return [4 /*yield*/, _c.call(paginator_1)];
|
|
1221
|
+
case 8:
|
|
1222
|
+
_e.sent();
|
|
1223
|
+
_e.label = 9;
|
|
1224
|
+
case 9: return [3 /*break*/, 11];
|
|
1225
|
+
case 10:
|
|
1226
|
+
if (e_1) throw e_1.error;
|
|
1227
|
+
return [7 /*endfinally*/];
|
|
1228
|
+
case 11: return [7 /*endfinally*/];
|
|
1229
|
+
case 12: return [2 /*return*/, schedules];
|
|
1230
|
+
}
|
|
1231
|
+
});
|
|
1232
|
+
});
|
|
1233
|
+
};
|
|
1234
|
+
/**
|
|
1235
|
+
* Create a new schedule group. Groups are containers for schedules and are
|
|
1236
|
+
* typically IaC-managed; use this for dynamically-provisioned groups only.
|
|
1237
|
+
*/
|
|
1238
|
+
SchedulerService.prototype.createScheduleGroup = function (input) {
|
|
1239
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1240
|
+
return __generator(this, function (_a) {
|
|
1241
|
+
this.logger.info('Creating schedule group', { input: input });
|
|
1242
|
+
return [2 /*return*/, this.client.send(new clientScheduler.CreateScheduleGroupCommand(input))];
|
|
1243
|
+
});
|
|
1244
|
+
});
|
|
1245
|
+
};
|
|
1246
|
+
/**
|
|
1247
|
+
* Fetch a schedule group's configuration.
|
|
1248
|
+
*/
|
|
1249
|
+
SchedulerService.prototype.getScheduleGroup = function (input) {
|
|
1250
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1251
|
+
return __generator(this, function (_a) {
|
|
1252
|
+
this.logger.info('Getting schedule group', { input: input });
|
|
1253
|
+
return [2 /*return*/, this.client.send(new clientScheduler.GetScheduleGroupCommand(input))];
|
|
1254
|
+
});
|
|
1255
|
+
});
|
|
1256
|
+
};
|
|
1257
|
+
/**
|
|
1258
|
+
* Delete a schedule group. Deleting a group also deletes every schedule it
|
|
1259
|
+
* contains, asynchronously — the API has no `UpdateScheduleGroup`, so this
|
|
1260
|
+
* is the only mutating group operation besides create.
|
|
1261
|
+
*/
|
|
1262
|
+
SchedulerService.prototype.deleteScheduleGroup = function (input) {
|
|
1263
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1264
|
+
return __generator(this, function (_a) {
|
|
1265
|
+
this.logger.info('Deleting schedule group', { input: input });
|
|
1266
|
+
return [2 /*return*/, this.client.send(new clientScheduler.DeleteScheduleGroupCommand(input))];
|
|
1267
|
+
});
|
|
1268
|
+
});
|
|
1269
|
+
};
|
|
1270
|
+
/**
|
|
1271
|
+
* List schedule groups, auto-paginating across all pages. Bounded in
|
|
1272
|
+
* practice by the account's group count and the `NamePrefix` filter.
|
|
1273
|
+
*/
|
|
1274
|
+
SchedulerService.prototype.listScheduleGroups = function (input) {
|
|
1275
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1276
|
+
var paginator, groups, _a, paginator_2, paginator_2_1, page, e_2_1;
|
|
1277
|
+
var _b, e_2, _c, _d;
|
|
1278
|
+
return __generator(this, function (_e) {
|
|
1279
|
+
switch (_e.label) {
|
|
1280
|
+
case 0:
|
|
1281
|
+
this.logger.info('Listing schedule groups', { input: input });
|
|
1282
|
+
paginator = clientScheduler.paginateListScheduleGroups({ client: this.client }, input !== null && input !== void 0 ? input : {});
|
|
1283
|
+
groups = [];
|
|
1284
|
+
_e.label = 1;
|
|
1285
|
+
case 1:
|
|
1286
|
+
_e.trys.push([1, 6, 7, 12]);
|
|
1287
|
+
_a = true, paginator_2 = __asyncValues(paginator);
|
|
1288
|
+
_e.label = 2;
|
|
1289
|
+
case 2: return [4 /*yield*/, paginator_2.next()];
|
|
1290
|
+
case 3:
|
|
1291
|
+
if (!(paginator_2_1 = _e.sent(), _b = paginator_2_1.done, !_b)) return [3 /*break*/, 5];
|
|
1292
|
+
_d = paginator_2_1.value;
|
|
1293
|
+
_a = false;
|
|
1294
|
+
page = _d;
|
|
1295
|
+
if (page.ScheduleGroups)
|
|
1296
|
+
groups.push.apply(groups, page.ScheduleGroups);
|
|
1297
|
+
_e.label = 4;
|
|
1298
|
+
case 4:
|
|
1299
|
+
_a = true;
|
|
1300
|
+
return [3 /*break*/, 2];
|
|
1301
|
+
case 5: return [3 /*break*/, 12];
|
|
1302
|
+
case 6:
|
|
1303
|
+
e_2_1 = _e.sent();
|
|
1304
|
+
e_2 = { error: e_2_1 };
|
|
1305
|
+
return [3 /*break*/, 12];
|
|
1306
|
+
case 7:
|
|
1307
|
+
_e.trys.push([7, , 10, 11]);
|
|
1308
|
+
if (!(!_a && !_b && (_c = paginator_2.return))) return [3 /*break*/, 9];
|
|
1309
|
+
return [4 /*yield*/, _c.call(paginator_2)];
|
|
1310
|
+
case 8:
|
|
1311
|
+
_e.sent();
|
|
1312
|
+
_e.label = 9;
|
|
1313
|
+
case 9: return [3 /*break*/, 11];
|
|
1314
|
+
case 10:
|
|
1315
|
+
if (e_2) throw e_2.error;
|
|
1316
|
+
return [7 /*endfinally*/];
|
|
1317
|
+
case 11: return [7 /*endfinally*/];
|
|
1318
|
+
case 12: return [2 /*return*/, groups];
|
|
1319
|
+
}
|
|
1320
|
+
});
|
|
1321
|
+
});
|
|
1322
|
+
};
|
|
1323
|
+
return SchedulerService;
|
|
1324
|
+
}());
|
|
1325
|
+
|
|
1060
1326
|
/**
|
|
1061
1327
|
* Fields safe to log at INFO level. Omits `SecretString` and `SecretBinary` —
|
|
1062
1328
|
* the secret material itself. `POWERTOOLS_LOG_LEVEL=DEBUG` unlocks the full
|
|
@@ -1907,5 +2173,6 @@ exports.S3Service = S3Service;
|
|
|
1907
2173
|
exports.SNSService = SNSService;
|
|
1908
2174
|
exports.SQSService = SQSService;
|
|
1909
2175
|
exports.SSMService = SSMService;
|
|
2176
|
+
exports.SchedulerService = SchedulerService;
|
|
1910
2177
|
exports.SecretsManagerService = SecretsManagerService;
|
|
1911
2178
|
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.2.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",
|
package/cjs/src/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { DynamoDBService } from './dynamodb/dynamodb.js';
|
|
2
2
|
export { S3Service } from './s3/s3.js';
|
|
3
|
+
export { SchedulerService } from './scheduler/scheduler.js';
|
|
3
4
|
export { SecretsManagerService } from './secrets-manager/secrets-manager.js';
|
|
4
5
|
export { StepFunctionsService } from './sfn/sfn.js';
|
|
5
6
|
export { SNSService } from './sns/sns.js';
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { LoggerInterface } from '@aws-lambda-powertools/logger/types';
|
|
2
|
+
import { CreateScheduleCommandInput, CreateScheduleCommandOutput, CreateScheduleGroupCommandInput, CreateScheduleGroupCommandOutput, DeleteScheduleCommandInput, DeleteScheduleCommandOutput, DeleteScheduleGroupCommandInput, DeleteScheduleGroupCommandOutput, GetScheduleCommandInput, GetScheduleCommandOutput, GetScheduleGroupCommandInput, GetScheduleGroupCommandOutput, ListScheduleGroupsCommandInput, ListSchedulesCommandInput, ScheduleGroupSummary, SchedulerClient, ScheduleSummary, UpdateScheduleCommandInput, UpdateScheduleCommandOutput } from '@aws-sdk/client-scheduler';
|
|
3
|
+
/**
|
|
4
|
+
* Wrapper around the AWS EventBridge Scheduler client providing structured
|
|
5
|
+
* Powertools logging and X-Ray tracing by default.
|
|
6
|
+
*
|
|
7
|
+
* Covers CRUD on schedules and their groups. Named `SchedulerService` (not
|
|
8
|
+
* `EventBridgeSchedulerService`) so it doesn't collide with a future wrapper
|
|
9
|
+
* over the separate EventBridge bus/rules API (`@aws-sdk/client-eventbridge`).
|
|
10
|
+
*
|
|
11
|
+
* `FlexibleTimeWindow` is required by `CreateSchedule` and is passed through
|
|
12
|
+
* untouched — the wrapper bakes in no default, so the caller must state their
|
|
13
|
+
* intent (`{ Mode: 'OFF' }` for a fixed-time schedule).
|
|
14
|
+
*/
|
|
15
|
+
export declare class SchedulerService {
|
|
16
|
+
private readonly client;
|
|
17
|
+
private readonly logger;
|
|
18
|
+
/**
|
|
19
|
+
* @param opts.logger - Optional Powertools logger. Defaults to `new Logger()`,
|
|
20
|
+
* which picks up `POWERTOOLS_SERVICE_NAME` from the environment.
|
|
21
|
+
* @param opts.client - Optional pre-configured `SchedulerClient`. When
|
|
22
|
+
* supplied, the wrapper does not apply X-Ray instrumentation.
|
|
23
|
+
*/
|
|
24
|
+
constructor(opts?: {
|
|
25
|
+
logger?: LoggerInterface;
|
|
26
|
+
client?: SchedulerClient;
|
|
27
|
+
});
|
|
28
|
+
/**
|
|
29
|
+
* Create a new schedule. At INFO the log line omits `Target.Input` (the
|
|
30
|
+
* target payload, a PII carrier); `POWERTOOLS_LOG_LEVEL=DEBUG` unlocks the
|
|
31
|
+
* full input.
|
|
32
|
+
*/
|
|
33
|
+
createSchedule(input: CreateScheduleCommandInput): Promise<CreateScheduleCommandOutput>;
|
|
34
|
+
/**
|
|
35
|
+
* Fetch a schedule's full configuration.
|
|
36
|
+
*/
|
|
37
|
+
getSchedule(input: GetScheduleCommandInput): Promise<GetScheduleCommandOutput>;
|
|
38
|
+
/**
|
|
39
|
+
* Update an existing schedule.
|
|
40
|
+
*
|
|
41
|
+
* **`UpdateSchedule` has PUT (full-replacement) semantics.** Any field you
|
|
42
|
+
* omit is reset to its default — this is not a partial patch. To change one
|
|
43
|
+
* attribute, `getSchedule` first and resend the complete configuration with
|
|
44
|
+
* that attribute modified, or you will silently erase `ScheduleExpression`,
|
|
45
|
+
* `Target`, `Description`, `StartDate`, etc. The wrapper does not merge on
|
|
46
|
+
* your behalf: deep-merging a `Target` (with its mutually-exclusive
|
|
47
|
+
* target-type params) has no single correct semantics.
|
|
48
|
+
*
|
|
49
|
+
* At INFO the log line omits `Target.Input`; `POWERTOOLS_LOG_LEVEL=DEBUG`
|
|
50
|
+
* unlocks the full input.
|
|
51
|
+
*/
|
|
52
|
+
updateSchedule(input: UpdateScheduleCommandInput): Promise<UpdateScheduleCommandOutput>;
|
|
53
|
+
/**
|
|
54
|
+
* Delete a schedule.
|
|
55
|
+
*/
|
|
56
|
+
deleteSchedule(input: DeleteScheduleCommandInput): Promise<DeleteScheduleCommandOutput>;
|
|
57
|
+
/**
|
|
58
|
+
* List schedules, auto-paginating across all pages. Bounded in practice by
|
|
59
|
+
* the account's schedule count and the `GroupName` / `NamePrefix` / `State`
|
|
60
|
+
* filters, so the flat-array shape is safe.
|
|
61
|
+
*/
|
|
62
|
+
listSchedules(input?: ListSchedulesCommandInput): Promise<ScheduleSummary[]>;
|
|
63
|
+
/**
|
|
64
|
+
* Create a new schedule group. Groups are containers for schedules and are
|
|
65
|
+
* typically IaC-managed; use this for dynamically-provisioned groups only.
|
|
66
|
+
*/
|
|
67
|
+
createScheduleGroup(input: CreateScheduleGroupCommandInput): Promise<CreateScheduleGroupCommandOutput>;
|
|
68
|
+
/**
|
|
69
|
+
* Fetch a schedule group's configuration.
|
|
70
|
+
*/
|
|
71
|
+
getScheduleGroup(input: GetScheduleGroupCommandInput): Promise<GetScheduleGroupCommandOutput>;
|
|
72
|
+
/**
|
|
73
|
+
* Delete a schedule group. Deleting a group also deletes every schedule it
|
|
74
|
+
* contains, asynchronously — the API has no `UpdateScheduleGroup`, so this
|
|
75
|
+
* is the only mutating group operation besides create.
|
|
76
|
+
*/
|
|
77
|
+
deleteScheduleGroup(input: DeleteScheduleGroupCommandInput): Promise<DeleteScheduleGroupCommandOutput>;
|
|
78
|
+
/**
|
|
79
|
+
* List schedule groups, auto-paginating across all pages. Bounded in
|
|
80
|
+
* practice by the account's group count and the `NamePrefix` filter.
|
|
81
|
+
*/
|
|
82
|
+
listScheduleGroups(input?: ListScheduleGroupsCommandInput): Promise<ScheduleGroupSummary[]>;
|
|
83
|
+
}
|