@aligent/aws-wrappers 0.4.0 → 0.5.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 +62 -0
- package/cjs/package.json +11 -1
- package/cjs/src/testing/testing.d.ts +44 -0
- package/cjs/testing.cjs +95 -0
- package/cjs/testing.d.ts +1 -0
- package/docs/{classes → index/classes}/DynamoDBService.md +14 -14
- package/docs/{classes → index/classes}/S3Service.md +17 -17
- package/docs/{classes → index/classes}/SNSService.md +6 -6
- package/docs/{classes → index/classes}/SQSService.md +9 -9
- package/docs/{classes → index/classes}/SSMService.md +9 -9
- package/docs/{classes → index/classes}/SchedulerService.md +13 -13
- package/docs/{classes → index/classes}/SecretsManagerService.md +10 -10
- package/docs/{classes → index/classes}/StepFunctionsService.md +8 -8
- package/docs/index/modules.md +18 -0
- package/docs/modules.md +3 -9
- package/docs/testing/testing/functions/createMockService.md +79 -0
- package/docs/testing/testing/modules.md +11 -0
- package/esm/package.json +11 -1
- package/esm/src/testing/testing.d.ts +44 -0
- package/esm/testing.d.ts +1 -0
- package/esm/testing.mjs +93 -0
- package/package.json +11 -1
package/README.md
CHANGED
|
@@ -352,6 +352,68 @@ await truncSns.publish({ TopicArn, Message: huge, Subject: long });
|
|
|
352
352
|
await truncSns.publish({ TopicArn, Message: huge }, { truncate: false });
|
|
353
353
|
```
|
|
354
354
|
|
|
355
|
+
## Testing
|
|
356
|
+
|
|
357
|
+
When you unit-test code that takes a wrapper as a dependency, you usually want to assert that *your* code called the right method with the right arguments — not to exercise the wrapper's chunking, pagination or JSON round-tripping, which this package already covers with its own tests against a mocked SDK client.
|
|
358
|
+
|
|
359
|
+
`createMockService` builds a stand-in for a service class from an object of method overrides. It ships from the `@aligent/aws-wrappers/testing` subpath — it is deliberately not exported from the package root, so test scaffolding can never be reached from the module your Lambda bundles.
|
|
360
|
+
|
|
361
|
+
```ts
|
|
362
|
+
// report-handler.ts
|
|
363
|
+
import type { S3Service } from '@aligent/aws-wrappers';
|
|
364
|
+
|
|
365
|
+
export async function reportHandler({ s3 }: { s3: S3Service }) {
|
|
366
|
+
const report = await s3.getJsonObject<{ total: number }>({
|
|
367
|
+
Bucket: 'reports',
|
|
368
|
+
Key: 'daily.json',
|
|
369
|
+
});
|
|
370
|
+
|
|
371
|
+
return { statusCode: 200, body: `Total: ${report?.total ?? 0}` };
|
|
372
|
+
}
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
```ts
|
|
376
|
+
// report-handler.test.ts
|
|
377
|
+
import { S3Service } from '@aligent/aws-wrappers';
|
|
378
|
+
import { createMockService } from '@aligent/aws-wrappers/testing';
|
|
379
|
+
import { expect, it, vi } from 'vitest';
|
|
380
|
+
import { reportHandler } from './report-handler.js';
|
|
381
|
+
|
|
382
|
+
it('reads the daily report from S3', async () => {
|
|
383
|
+
const getJsonObject = vi.fn().mockResolvedValue({ total: 42 });
|
|
384
|
+
const s3 = createMockService(S3Service, { getJsonObject });
|
|
385
|
+
|
|
386
|
+
const result = await reportHandler({ s3 });
|
|
387
|
+
|
|
388
|
+
expect(getJsonObject).toHaveBeenCalledWith({ Bucket: 'reports', Key: 'daily.json' });
|
|
389
|
+
expect(result.body).toBe('Total: 42');
|
|
390
|
+
});
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
- **No cast at the call site.** The returned value is accepted wherever the real class is expected.
|
|
394
|
+
- **Override keys are type-checked** against the class's public surface, so a misspelled key is a compile error rather than a green test that exercised nothing. For a non-generic method you can type the spy — `vi.fn<SQSService['sendMessage']>()` — to have its shape checked against the real method too.
|
|
395
|
+
- **Only mock what the code under test calls.** Accessing any other method of the class throws `S3Service.headObject was accessed but not mocked`, naming both the service and the method, instead of failing later as `is not a function`.
|
|
396
|
+
- **Bring your own spies.** The helper imports no test framework — `vi.fn()`, `jest.fn()` or a hand-rolled closure all work, and overridden keys keep your spy's type, so `s3.getJsonObject.mock.calls` typechecks through the returned object.
|
|
397
|
+
|
|
398
|
+
### Overriding a generic method
|
|
399
|
+
|
|
400
|
+
Several methods are generic in their return type — `S3Service.getJsonObject` / `putJsonObject` / `getAllObjects`, `DynamoDBService.putItem` / `query` / `scan`, `SecretsManagerService.getJsonSecret` and `SSMService.getParameters`. An override has to satisfy the generic signature, so a plain non-generic function is rejected:
|
|
401
|
+
|
|
402
|
+
```ts
|
|
403
|
+
// Error: '{ total: number }' is not assignable to 'T'
|
|
404
|
+
const getJsonObject = async () => ({ total: 42 });
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
An untyped `vi.fn()` is the easy path and is what the example above uses — `Mock`'s call signature is loose enough to satisfy the constraint. Otherwise make the override generic:
|
|
408
|
+
|
|
409
|
+
```ts
|
|
410
|
+
const getJsonObject = async <T>() => ({ total: 42 }) as T;
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
Note that the typed-spy form does **not** work here: `vi.fn<S3Service['getJsonObject']>()` produces a `Mock` that erases the type parameter and is no longer assignable to the generic signature. Reach for a typed spy on non-generic methods only.
|
|
414
|
+
|
|
415
|
+
The helper is generic over any class, so it works for all eight wrappers and for your own service classes too.
|
|
416
|
+
|
|
355
417
|
## Build / test
|
|
356
418
|
|
|
357
419
|
```sh
|
package/cjs/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aligent/aws-wrappers",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Opinionated AWS SDK wrappers with Powertools logging and X-Ray tracing",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=18"
|
|
@@ -19,6 +19,16 @@
|
|
|
19
19
|
"default": "./cjs/index.cjs"
|
|
20
20
|
}
|
|
21
21
|
},
|
|
22
|
+
"./testing": {
|
|
23
|
+
"import": {
|
|
24
|
+
"types": "./esm/src/testing/testing.d.ts",
|
|
25
|
+
"default": "./esm/testing.mjs"
|
|
26
|
+
},
|
|
27
|
+
"require": {
|
|
28
|
+
"types": "./cjs/src/testing/testing.d.ts",
|
|
29
|
+
"default": "./cjs/testing.cjs"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
22
32
|
"./package.json": "./package.json"
|
|
23
33
|
},
|
|
24
34
|
"files": [
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build a stand-in for a service class from an object of method overrides, for
|
|
3
|
+
* use in unit tests of code that depends on the service.
|
|
4
|
+
*
|
|
5
|
+
* Accessing a method of the class that was not overridden throws immediately,
|
|
6
|
+
* naming the service and the method, rather than failing later as
|
|
7
|
+
* `is not a function`. Any key that is neither an override nor a method of the
|
|
8
|
+
* class falls through to the overrides object — so `toString`, `valueOf` and
|
|
9
|
+
* `constructor` resolve from `Object.prototype` as usual, and anything else is
|
|
10
|
+
* `undefined`. That fallback is what keeps probe properties safe: `then` (so
|
|
11
|
+
* awaiting the mock does not throw), `Symbol.toStringTag`, inspection symbols,
|
|
12
|
+
* and whatever a test framework's error serialiser reaches for.
|
|
13
|
+
*
|
|
14
|
+
* Only the overrides are enumerable, so spreading, serialising or deep-equalling
|
|
15
|
+
* an object that holds the mock does not trip the throw.
|
|
16
|
+
*
|
|
17
|
+
* The helper imports no test framework: callers supply their own spies, and
|
|
18
|
+
* overridden keys keep the caller's spy type so `.mock` resolves through the
|
|
19
|
+
* returned object.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* const getJsonObject = vi.fn().mockResolvedValue({ id: 1 });
|
|
24
|
+
* const s3 = createMockService(S3Service, { getJsonObject });
|
|
25
|
+
*
|
|
26
|
+
* await handler({ s3 });
|
|
27
|
+
*
|
|
28
|
+
* expect(s3.getJsonObject.mock.calls).toHaveLength(1);
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @param service - The service class itself. It is never constructed — only
|
|
32
|
+
* its prototype is read — so the parameter is typed as just that capability,
|
|
33
|
+
* which also accepts abstract classes and classes with required constructor
|
|
34
|
+
* arguments. Passing the class as a value (rather than as an explicit type
|
|
35
|
+
* argument) is load-bearing for the types: TypeScript has no partial
|
|
36
|
+
* type-argument inference, so an explicit `T` would suppress inference of the
|
|
37
|
+
* overrides type and lose the caller's spy typing on overridden keys.
|
|
38
|
+
* @param overrides - The methods the code under test actually calls. Keys are
|
|
39
|
+
* checked against the class's public surface, so a typo or a wrong-shaped
|
|
40
|
+
* override is a compile error.
|
|
41
|
+
*/
|
|
42
|
+
export declare function createMockService<T extends object, O extends Partial<T>>(service: {
|
|
43
|
+
prototype: T;
|
|
44
|
+
}, overrides: O): T & O;
|
package/cjs/testing.cjs
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Collect the method names of a class, walking the prototype chain up to but
|
|
5
|
+
* excluding `Object.prototype` so inherited methods are found.
|
|
6
|
+
*
|
|
7
|
+
* Property *descriptors* are inspected rather than properties read: reading a
|
|
8
|
+
* prototype getter here would execute consumer code with `this` bound to the
|
|
9
|
+
* mock. Accessor properties are therefore neither mockable nor throwable.
|
|
10
|
+
*/
|
|
11
|
+
function collectMethodNames(prototype) {
|
|
12
|
+
const names = new Set();
|
|
13
|
+
let current = prototype;
|
|
14
|
+
while (current !== null && current !== Object.prototype) {
|
|
15
|
+
for (const key of Object.getOwnPropertyNames(current)) {
|
|
16
|
+
if (key === 'constructor')
|
|
17
|
+
continue;
|
|
18
|
+
const descriptor = Object.getOwnPropertyDescriptor(current, key);
|
|
19
|
+
if (typeof descriptor?.value === 'function')
|
|
20
|
+
names.add(key);
|
|
21
|
+
}
|
|
22
|
+
current = Object.getPrototypeOf(current);
|
|
23
|
+
}
|
|
24
|
+
return names;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Build a stand-in for a service class from an object of method overrides, for
|
|
28
|
+
* use in unit tests of code that depends on the service.
|
|
29
|
+
*
|
|
30
|
+
* Accessing a method of the class that was not overridden throws immediately,
|
|
31
|
+
* naming the service and the method, rather than failing later as
|
|
32
|
+
* `is not a function`. Any key that is neither an override nor a method of the
|
|
33
|
+
* class falls through to the overrides object — so `toString`, `valueOf` and
|
|
34
|
+
* `constructor` resolve from `Object.prototype` as usual, and anything else is
|
|
35
|
+
* `undefined`. That fallback is what keeps probe properties safe: `then` (so
|
|
36
|
+
* awaiting the mock does not throw), `Symbol.toStringTag`, inspection symbols,
|
|
37
|
+
* and whatever a test framework's error serialiser reaches for.
|
|
38
|
+
*
|
|
39
|
+
* Only the overrides are enumerable, so spreading, serialising or deep-equalling
|
|
40
|
+
* an object that holds the mock does not trip the throw.
|
|
41
|
+
*
|
|
42
|
+
* The helper imports no test framework: callers supply their own spies, and
|
|
43
|
+
* overridden keys keep the caller's spy type so `.mock` resolves through the
|
|
44
|
+
* returned object.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```typescript
|
|
48
|
+
* const getJsonObject = vi.fn().mockResolvedValue({ id: 1 });
|
|
49
|
+
* const s3 = createMockService(S3Service, { getJsonObject });
|
|
50
|
+
*
|
|
51
|
+
* await handler({ s3 });
|
|
52
|
+
*
|
|
53
|
+
* expect(s3.getJsonObject.mock.calls).toHaveLength(1);
|
|
54
|
+
* ```
|
|
55
|
+
*
|
|
56
|
+
* @param service - The service class itself. It is never constructed — only
|
|
57
|
+
* its prototype is read — so the parameter is typed as just that capability,
|
|
58
|
+
* which also accepts abstract classes and classes with required constructor
|
|
59
|
+
* arguments. Passing the class as a value (rather than as an explicit type
|
|
60
|
+
* argument) is load-bearing for the types: TypeScript has no partial
|
|
61
|
+
* type-argument inference, so an explicit `T` would suppress inference of the
|
|
62
|
+
* overrides type and lose the caller's spy typing on overridden keys.
|
|
63
|
+
* @param overrides - The methods the code under test actually calls. Keys are
|
|
64
|
+
* checked against the class's public surface, so a typo or a wrong-shaped
|
|
65
|
+
* override is a compile error.
|
|
66
|
+
*/
|
|
67
|
+
function createMockService(service, overrides) {
|
|
68
|
+
const { prototype } = service;
|
|
69
|
+
const methodNames = collectMethodNames(prototype);
|
|
70
|
+
const className = prototype.constructor?.name;
|
|
71
|
+
const isUnmockedMethod = (key) => typeof key === 'string' && methodNames.has(key);
|
|
72
|
+
const mock = new Proxy(overrides, {
|
|
73
|
+
get(target, key, receiver) {
|
|
74
|
+
// `hasOwn`, not `has`: a class method that shadows one of
|
|
75
|
+
// `Object.prototype`'s (`toString`, `valueOf`, …) must still throw
|
|
76
|
+
// rather than be served silently from the prototype chain.
|
|
77
|
+
if (Object.hasOwn(target, key))
|
|
78
|
+
return Reflect.get(target, key, receiver);
|
|
79
|
+
if (isUnmockedMethod(key)) {
|
|
80
|
+
throw new Error(`${className ?? 'Service'}.${key} was accessed but not mocked`);
|
|
81
|
+
}
|
|
82
|
+
return Reflect.get(target, key, receiver);
|
|
83
|
+
},
|
|
84
|
+
has(target, key) {
|
|
85
|
+
return Reflect.has(target, key) || isUnmockedMethod(key);
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
// The services declare `private readonly client` / `private readonly logger`.
|
|
89
|
+
// Those fields are nominal, so no structurally-constructed value is
|
|
90
|
+
// assignable to the class type — this cast is unavoidable. Concentrating
|
|
91
|
+
// it here is the point of the helper: consumer test suites contain none.
|
|
92
|
+
return mock;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
exports.createMockService = createMockService;
|
package/cjs/testing.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./src/testing/testing";
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
[**@aligent/aws-wrappers**](
|
|
1
|
+
[**@aligent/aws-wrappers**](../../modules.md)
|
|
2
2
|
|
|
3
3
|
***
|
|
4
4
|
|
|
5
|
-
[@aligent/aws-wrappers](../modules.md) / DynamoDBService
|
|
5
|
+
[@aligent/aws-wrappers](../../modules.md) / [index](../modules.md) / DynamoDBService
|
|
6
6
|
|
|
7
7
|
# Class: DynamoDBService
|
|
8
8
|
|
|
9
|
-
Defined in: [dynamodb/dynamodb.ts:153](https://github.com/aligent/microservice-development-utilities/blob/
|
|
9
|
+
Defined in: [dynamodb/dynamodb.ts:153](https://github.com/aligent/microservice-development-utilities/blob/12392981323381975cdaffeb0a828cecd4846ce0/packages/aws-wrappers/src/dynamodb/dynamodb.ts#L153)
|
|
10
10
|
|
|
11
11
|
Wrapper around the AWS DynamoDB Document client providing structured
|
|
12
12
|
Powertools logging and X-Ray tracing by default.
|
|
@@ -26,7 +26,7 @@ callers work with plain TypeScript objects in both directions.
|
|
|
26
26
|
|
|
27
27
|
> **new DynamoDBService**(`opts?`): `DynamoDBService`
|
|
28
28
|
|
|
29
|
-
Defined in: [dynamodb/dynamodb.ts:166](https://github.com/aligent/microservice-development-utilities/blob/
|
|
29
|
+
Defined in: [dynamodb/dynamodb.ts:166](https://github.com/aligent/microservice-development-utilities/blob/12392981323381975cdaffeb0a828cecd4846ce0/packages/aws-wrappers/src/dynamodb/dynamodb.ts#L166)
|
|
30
30
|
|
|
31
31
|
#### Parameters
|
|
32
32
|
|
|
@@ -61,7 +61,7 @@ which picks up `POWERTOOLS_SERVICE_NAME` from the environment.
|
|
|
61
61
|
|
|
62
62
|
> **batchGet**(`input`): `Promise`\<`BatchGetCommandOutput`\>
|
|
63
63
|
|
|
64
|
-
Defined in: [dynamodb/dynamodb.ts:317](https://github.com/aligent/microservice-development-utilities/blob/
|
|
64
|
+
Defined in: [dynamodb/dynamodb.ts:317](https://github.com/aligent/microservice-development-utilities/blob/12392981323381975cdaffeb0a828cecd4846ce0/packages/aws-wrappers/src/dynamodb/dynamodb.ts#L317)
|
|
65
65
|
|
|
66
66
|
Batch-get items from one or more DynamoDB tables.
|
|
67
67
|
|
|
@@ -88,7 +88,7 @@ Callers should narrow the result type at the call site.
|
|
|
88
88
|
|
|
89
89
|
> **batchWrite**(`input`): `Promise`\<`BatchWriteCommandOutput`\>
|
|
90
90
|
|
|
91
|
-
Defined in: [dynamodb/dynamodb.ts:334](https://github.com/aligent/microservice-development-utilities/blob/
|
|
91
|
+
Defined in: [dynamodb/dynamodb.ts:334](https://github.com/aligent/microservice-development-utilities/blob/12392981323381975cdaffeb0a828cecd4846ce0/packages/aws-wrappers/src/dynamodb/dynamodb.ts#L334)
|
|
92
92
|
|
|
93
93
|
Batch-write items to DynamoDB, retrying `UnprocessedItems` with jittered
|
|
94
94
|
exponential backoff. Up to 5 attempts (200ms base delay). Throws when
|
|
@@ -112,7 +112,7 @@ items remain unprocessed after the final attempt.
|
|
|
112
112
|
|
|
113
113
|
> **deleteItem**\<`K`, `R`\>(`input`): `Promise`\<`Omit`\<`DeleteCommandOutput`, `"Attributes"`\> & `object`\>
|
|
114
114
|
|
|
115
|
-
Defined in: [dynamodb/dynamodb.ts:247](https://github.com/aligent/microservice-development-utilities/blob/
|
|
115
|
+
Defined in: [dynamodb/dynamodb.ts:247](https://github.com/aligent/microservice-development-utilities/blob/12392981323381975cdaffeb0a828cecd4846ce0/packages/aws-wrappers/src/dynamodb/dynamodb.ts#L247)
|
|
116
116
|
|
|
117
117
|
Delete an item from DynamoDB. The `Attributes` field on the response is
|
|
118
118
|
typed as `R` — relevant when `ReturnValues: 'ALL_OLD'` is set.
|
|
@@ -149,7 +149,7 @@ Expected shape of the returned `Attributes`.
|
|
|
149
149
|
|
|
150
150
|
> **getItem**\<`K`, `R`\>(`input`): `Promise`\<`R` \| `undefined`\>
|
|
151
151
|
|
|
152
|
-
Defined in: [dynamodb/dynamodb.ts:181](https://github.com/aligent/microservice-development-utilities/blob/
|
|
152
|
+
Defined in: [dynamodb/dynamodb.ts:181](https://github.com/aligent/microservice-development-utilities/blob/12392981323381975cdaffeb0a828cecd4846ce0/packages/aws-wrappers/src/dynamodb/dynamodb.ts#L181)
|
|
153
153
|
|
|
154
154
|
Get an item from DynamoDB.
|
|
155
155
|
|
|
@@ -187,7 +187,7 @@ The item, or `undefined` if not found.
|
|
|
187
187
|
|
|
188
188
|
> **paginateItems**\<`T`\>(`input`): `AsyncGenerator`\<`T`\>
|
|
189
189
|
|
|
190
|
-
Defined in: [dynamodb/dynamodb.ts:384](https://github.com/aligent/microservice-development-utilities/blob/
|
|
190
|
+
Defined in: [dynamodb/dynamodb.ts:384](https://github.com/aligent/microservice-development-utilities/blob/12392981323381975cdaffeb0a828cecd4846ce0/packages/aws-wrappers/src/dynamodb/dynamodb.ts#L384)
|
|
191
191
|
|
|
192
192
|
Paginate over Query results, yielding one unmarshalled item at a time.
|
|
193
193
|
|
|
@@ -238,7 +238,7 @@ Expected shape of each yielded item.
|
|
|
238
238
|
|
|
239
239
|
> **paginateScan**\<`T`\>(`input`): `AsyncGenerator`\<`T`\>
|
|
240
240
|
|
|
241
|
-
Defined in: [dynamodb/dynamodb.ts:406](https://github.com/aligent/microservice-development-utilities/blob/
|
|
241
|
+
Defined in: [dynamodb/dynamodb.ts:406](https://github.com/aligent/microservice-development-utilities/blob/12392981323381975cdaffeb0a828cecd4846ce0/packages/aws-wrappers/src/dynamodb/dynamodb.ts#L406)
|
|
242
242
|
|
|
243
243
|
Paginate over Scan results, yielding one unmarshalled item at a time.
|
|
244
244
|
|
|
@@ -272,7 +272,7 @@ Expected shape of each yielded item.
|
|
|
272
272
|
|
|
273
273
|
> **putItem**\<`T`\>(`input`): `Promise`\<`PutCommandOutput`\>
|
|
274
274
|
|
|
275
|
-
Defined in: [dynamodb/dynamodb.ts:201](https://github.com/aligent/microservice-development-utilities/blob/
|
|
275
|
+
Defined in: [dynamodb/dynamodb.ts:201](https://github.com/aligent/microservice-development-utilities/blob/12392981323381975cdaffeb0a828cecd4846ce0/packages/aws-wrappers/src/dynamodb/dynamodb.ts#L201)
|
|
276
276
|
|
|
277
277
|
Put an item into DynamoDB. The caller's `Item` is typed as `T`, which
|
|
278
278
|
the document client marshalls automatically.
|
|
@@ -303,7 +303,7 @@ Type of the item being stored.
|
|
|
303
303
|
|
|
304
304
|
> **query**\<`T`\>(`input`): `Promise`\<`Omit`\<`QueryCommandOutput`, `"Items"`\> & `object`\>
|
|
305
305
|
|
|
306
|
-
Defined in: [dynamodb/dynamodb.ts:270](https://github.com/aligent/microservice-development-utilities/blob/
|
|
306
|
+
Defined in: [dynamodb/dynamodb.ts:270](https://github.com/aligent/microservice-development-utilities/blob/12392981323381975cdaffeb0a828cecd4846ce0/packages/aws-wrappers/src/dynamodb/dynamodb.ts#L270)
|
|
307
307
|
|
|
308
308
|
Execute a DynamoDB Query. The full `QueryCommandOutput` is returned with
|
|
309
309
|
`Items` typed as `T[]` so callers retain pagination metadata
|
|
@@ -335,7 +335,7 @@ Expected shape of each unmarshalled item.
|
|
|
335
335
|
|
|
336
336
|
> **scan**\<`T`\>(`input`): `Promise`\<`Omit`\<`ScanCommandOutput`, `"Items"`\> & `object`\>
|
|
337
337
|
|
|
338
|
-
Defined in: [dynamodb/dynamodb.ts:299](https://github.com/aligent/microservice-development-utilities/blob/
|
|
338
|
+
Defined in: [dynamodb/dynamodb.ts:299](https://github.com/aligent/microservice-development-utilities/blob/12392981323381975cdaffeb0a828cecd4846ce0/packages/aws-wrappers/src/dynamodb/dynamodb.ts#L299)
|
|
339
339
|
|
|
340
340
|
Scan a DynamoDB table. The full `ScanCommandOutput` is returned with
|
|
341
341
|
`Items` typed as `T[]` so callers retain pagination metadata.
|
|
@@ -379,7 +379,7 @@ Expected shape of each unmarshalled item.
|
|
|
379
379
|
|
|
380
380
|
> **updateItem**\<`K`, `R`\>(`input`): `Promise`\<`Omit`\<`UpdateCommandOutput`, `"Attributes"`\> & `object`\>
|
|
381
381
|
|
|
382
|
-
Defined in: [dynamodb/dynamodb.ts:224](https://github.com/aligent/microservice-development-utilities/blob/
|
|
382
|
+
Defined in: [dynamodb/dynamodb.ts:224](https://github.com/aligent/microservice-development-utilities/blob/12392981323381975cdaffeb0a828cecd4846ce0/packages/aws-wrappers/src/dynamodb/dynamodb.ts#L224)
|
|
383
383
|
|
|
384
384
|
Update an item in DynamoDB. The `Attributes` field on the response is
|
|
385
385
|
typed as `R` — the caller should choose `R` to match their
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
[**@aligent/aws-wrappers**](
|
|
1
|
+
[**@aligent/aws-wrappers**](../../modules.md)
|
|
2
2
|
|
|
3
3
|
***
|
|
4
4
|
|
|
5
|
-
[@aligent/aws-wrappers](../modules.md) / S3Service
|
|
5
|
+
[@aligent/aws-wrappers](../../modules.md) / [index](../modules.md) / S3Service
|
|
6
6
|
|
|
7
7
|
# Class: S3Service
|
|
8
8
|
|
|
9
|
-
Defined in: [s3/s3.ts:70](https://github.com/aligent/microservice-development-utilities/blob/
|
|
9
|
+
Defined in: [s3/s3.ts:70](https://github.com/aligent/microservice-development-utilities/blob/12392981323381975cdaffeb0a828cecd4846ce0/packages/aws-wrappers/src/s3/s3.ts#L70)
|
|
10
10
|
|
|
11
11
|
Wrapper around the AWS S3 client providing structured Powertools logging
|
|
12
12
|
and X-Ray tracing by default.
|
|
@@ -27,7 +27,7 @@ tagging, version IDs) should use `S3Client` directly.
|
|
|
27
27
|
|
|
28
28
|
> **new S3Service**(`opts?`): `S3Service`
|
|
29
29
|
|
|
30
|
-
Defined in: [s3/s3.ts:80](https://github.com/aligent/microservice-development-utilities/blob/
|
|
30
|
+
Defined in: [s3/s3.ts:80](https://github.com/aligent/microservice-development-utilities/blob/12392981323381975cdaffeb0a828cecd4846ce0/packages/aws-wrappers/src/s3/s3.ts#L80)
|
|
31
31
|
|
|
32
32
|
#### Parameters
|
|
33
33
|
|
|
@@ -59,7 +59,7 @@ which picks up `POWERTOOLS_SERVICE_NAME` from the environment.
|
|
|
59
59
|
|
|
60
60
|
> **copyObject**(`input`): `Promise`\<`CopyObjectCommandOutput`\>
|
|
61
61
|
|
|
62
|
-
Defined in: [s3/s3.ts:175](https://github.com/aligent/microservice-development-utilities/blob/
|
|
62
|
+
Defined in: [s3/s3.ts:175](https://github.com/aligent/microservice-development-utilities/blob/12392981323381975cdaffeb0a828cecd4846ce0/packages/aws-wrappers/src/s3/s3.ts#L175)
|
|
63
63
|
|
|
64
64
|
Copy an object within S3.
|
|
65
65
|
|
|
@@ -81,7 +81,7 @@ Copy an object within S3.
|
|
|
81
81
|
|
|
82
82
|
> **deleteObject**(`input`): `Promise`\<`DeleteObjectCommandOutput`\>
|
|
83
83
|
|
|
84
|
-
Defined in: [s3/s3.ts:268](https://github.com/aligent/microservice-development-utilities/blob/
|
|
84
|
+
Defined in: [s3/s3.ts:268](https://github.com/aligent/microservice-development-utilities/blob/12392981323381975cdaffeb0a828cecd4846ce0/packages/aws-wrappers/src/s3/s3.ts#L268)
|
|
85
85
|
|
|
86
86
|
Delete a single object from S3.
|
|
87
87
|
|
|
@@ -103,7 +103,7 @@ Delete a single object from S3.
|
|
|
103
103
|
|
|
104
104
|
> **deleteObjects**(`bucket`, `keys`): `Promise`\<`DeleteObjectsCommandOutput`[]\>
|
|
105
105
|
|
|
106
|
-
Defined in: [s3/s3.ts:280](https://github.com/aligent/microservice-development-utilities/blob/
|
|
106
|
+
Defined in: [s3/s3.ts:280](https://github.com/aligent/microservice-development-utilities/blob/12392981323381975cdaffeb0a828cecd4846ce0/packages/aws-wrappers/src/s3/s3.ts#L280)
|
|
107
107
|
|
|
108
108
|
Delete multiple objects from S3, auto-chunking the request into batches
|
|
109
109
|
of 1000 keys (the S3-enforced DeleteObjects limit). Returns one output
|
|
@@ -131,7 +131,7 @@ per chunk.
|
|
|
131
131
|
|
|
132
132
|
> **emptyBucket**(`bucket`): `Promise`\<`string`[]\>
|
|
133
133
|
|
|
134
|
-
Defined in: [s3/s3.ts:320](https://github.com/aligent/microservice-development-utilities/blob/
|
|
134
|
+
Defined in: [s3/s3.ts:320](https://github.com/aligent/microservice-development-utilities/blob/12392981323381975cdaffeb0a828cecd4846ce0/packages/aws-wrappers/src/s3/s3.ts#L320)
|
|
135
135
|
|
|
136
136
|
Delete every object in an **unversioned** bucket. Streams the listing
|
|
137
137
|
page-by-page and delegates each page's deletion to `deleteObjects`, so
|
|
@@ -167,7 +167,7 @@ The keys this call issued deletes for.
|
|
|
167
167
|
|
|
168
168
|
> **getAllObjects**\<`T`\>(`bucket`, `prefix?`): `Promise`\<`T`[]\>
|
|
169
169
|
|
|
170
|
-
Defined in: [s3/s3.ts:206](https://github.com/aligent/microservice-development-utilities/blob/
|
|
170
|
+
Defined in: [s3/s3.ts:206](https://github.com/aligent/microservice-development-utilities/blob/12392981323381975cdaffeb0a828cecd4846ce0/packages/aws-wrappers/src/s3/s3.ts#L206)
|
|
171
171
|
|
|
172
172
|
List and JSON-parse every object under a bucket and optional prefix.
|
|
173
173
|
Auto-paginated. Objects without a body are skipped.
|
|
@@ -202,7 +202,7 @@ Expected type of each parsed object.
|
|
|
202
202
|
|
|
203
203
|
> **getJsonObject**\<`T`\>(`input`): `Promise`\<`T` \| `undefined`\>
|
|
204
204
|
|
|
205
|
-
Defined in: [s3/s3.ts:153](https://github.com/aligent/microservice-development-utilities/blob/
|
|
205
|
+
Defined in: [s3/s3.ts:153](https://github.com/aligent/microservice-development-utilities/blob/12392981323381975cdaffeb0a828cecd4846ce0/packages/aws-wrappers/src/s3/s3.ts#L153)
|
|
206
206
|
|
|
207
207
|
Get an object from S3 and parse it as JSON.
|
|
208
208
|
|
|
@@ -238,7 +238,7 @@ If the body is non-empty and not valid JSON.
|
|
|
238
238
|
|
|
239
239
|
> **getObject**(`input`): `Promise`\<`GetObjectCommandOutput`\>
|
|
240
240
|
|
|
241
|
-
Defined in: [s3/s3.ts:127](https://github.com/aligent/microservice-development-utilities/blob/
|
|
241
|
+
Defined in: [s3/s3.ts:127](https://github.com/aligent/microservice-development-utilities/blob/12392981323381975cdaffeb0a828cecd4846ce0/packages/aws-wrappers/src/s3/s3.ts#L127)
|
|
242
242
|
|
|
243
243
|
Get an object from S3.
|
|
244
244
|
|
|
@@ -260,7 +260,7 @@ Get an object from S3.
|
|
|
260
260
|
|
|
261
261
|
> **getObjectBody**(`input`): `Promise`\<`string` \| `undefined`\>
|
|
262
262
|
|
|
263
|
-
Defined in: [s3/s3.ts:139](https://github.com/aligent/microservice-development-utilities/blob/
|
|
263
|
+
Defined in: [s3/s3.ts:139](https://github.com/aligent/microservice-development-utilities/blob/12392981323381975cdaffeb0a828cecd4846ce0/packages/aws-wrappers/src/s3/s3.ts#L139)
|
|
264
264
|
|
|
265
265
|
Get an object from S3 and return its body as a string.
|
|
266
266
|
|
|
@@ -285,7 +285,7 @@ has no body.
|
|
|
285
285
|
|
|
286
286
|
> **getPresignedUrl**(`input`): `Promise`\<`string`\>
|
|
287
287
|
|
|
288
|
-
Defined in: [s3/s3.ts:244](https://github.com/aligent/microservice-development-utilities/blob/
|
|
288
|
+
Defined in: [s3/s3.ts:244](https://github.com/aligent/microservice-development-utilities/blob/12392981323381975cdaffeb0a828cecd4846ce0/packages/aws-wrappers/src/s3/s3.ts#L244)
|
|
289
289
|
|
|
290
290
|
Generate a presigned URL that callers can use to GET or PUT an S3 object
|
|
291
291
|
directly, without going through the wrapper. The signing happens against
|
|
@@ -339,7 +339,7 @@ The S3 object key.
|
|
|
339
339
|
|
|
340
340
|
> **headObject**(`input`): `Promise`\<`HeadObjectCommandOutput`\>
|
|
341
341
|
|
|
342
|
-
Defined in: [s3/s3.ts:165](https://github.com/aligent/microservice-development-utilities/blob/
|
|
342
|
+
Defined in: [s3/s3.ts:165](https://github.com/aligent/microservice-development-utilities/blob/12392981323381975cdaffeb0a828cecd4846ce0/packages/aws-wrappers/src/s3/s3.ts#L165)
|
|
343
343
|
|
|
344
344
|
Fetch the metadata for an S3 object without downloading its body.
|
|
345
345
|
|
|
@@ -361,7 +361,7 @@ Fetch the metadata for an S3 object without downloading its body.
|
|
|
361
361
|
|
|
362
362
|
> **listObjects**(`bucket`, `prefix?`): `Promise`\<`string`[]\>
|
|
363
363
|
|
|
364
|
-
Defined in: [s3/s3.ts:186](https://github.com/aligent/microservice-development-utilities/blob/
|
|
364
|
+
Defined in: [s3/s3.ts:186](https://github.com/aligent/microservice-development-utilities/blob/12392981323381975cdaffeb0a828cecd4846ce0/packages/aws-wrappers/src/s3/s3.ts#L186)
|
|
365
365
|
|
|
366
366
|
List object keys under a bucket and optional prefix, auto-paginating
|
|
367
367
|
across all pages.
|
|
@@ -388,7 +388,7 @@ across all pages.
|
|
|
388
388
|
|
|
389
389
|
> **putJsonObject**\<`T`\>(`input`): `Promise`\<`PutObjectCommandOutput`\>
|
|
390
390
|
|
|
391
|
-
Defined in: [s3/s3.ts:110](https://github.com/aligent/microservice-development-utilities/blob/
|
|
391
|
+
Defined in: [s3/s3.ts:110](https://github.com/aligent/microservice-development-utilities/blob/12392981323381975cdaffeb0a828cecd4846ce0/packages/aws-wrappers/src/s3/s3.ts#L110)
|
|
392
392
|
|
|
393
393
|
Serialise a value to JSON and store it as an S3 object.
|
|
394
394
|
|
|
@@ -422,7 +422,7 @@ Type of the value being stored.
|
|
|
422
422
|
|
|
423
423
|
> **putObject**(`input`): `Promise`\<`PutObjectCommandOutput`\>
|
|
424
424
|
|
|
425
|
-
Defined in: [s3/s3.ts:94](https://github.com/aligent/microservice-development-utilities/blob/
|
|
425
|
+
Defined in: [s3/s3.ts:94](https://github.com/aligent/microservice-development-utilities/blob/12392981323381975cdaffeb0a828cecd4846ce0/packages/aws-wrappers/src/s3/s3.ts#L94)
|
|
426
426
|
|
|
427
427
|
Put an object into S3.
|
|
428
428
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
[**@aligent/aws-wrappers**](
|
|
1
|
+
[**@aligent/aws-wrappers**](../../modules.md)
|
|
2
2
|
|
|
3
3
|
***
|
|
4
4
|
|
|
5
|
-
[@aligent/aws-wrappers](../modules.md) / SNSService
|
|
5
|
+
[@aligent/aws-wrappers](../../modules.md) / [index](../modules.md) / SNSService
|
|
6
6
|
|
|
7
7
|
# Class: SNSService
|
|
8
8
|
|
|
9
|
-
Defined in: [sns/sns.ts:43](https://github.com/aligent/microservice-development-utilities/blob/
|
|
9
|
+
Defined in: [sns/sns.ts:43](https://github.com/aligent/microservice-development-utilities/blob/12392981323381975cdaffeb0a828cecd4846ce0/packages/aws-wrappers/src/sns/sns.ts#L43)
|
|
10
10
|
|
|
11
11
|
Wrapper around the AWS SNS client providing structured Powertools logging
|
|
12
12
|
and X-Ray tracing by default.
|
|
@@ -23,7 +23,7 @@ log line omits them; the verbose levels (`POWERTOOLS_LOG_LEVEL=DEBUG` or
|
|
|
23
23
|
|
|
24
24
|
> **new SNSService**(`opts?`): `SNSService`
|
|
25
25
|
|
|
26
|
-
Defined in: [sns/sns.ts:59](https://github.com/aligent/microservice-development-utilities/blob/
|
|
26
|
+
Defined in: [sns/sns.ts:59](https://github.com/aligent/microservice-development-utilities/blob/12392981323381975cdaffeb0a828cecd4846ce0/packages/aws-wrappers/src/sns/sns.ts#L59)
|
|
27
27
|
|
|
28
28
|
#### Parameters
|
|
29
29
|
|
|
@@ -65,7 +65,7 @@ its own `truncate` option.
|
|
|
65
65
|
|
|
66
66
|
> **publish**(`input`, `opts?`): `Promise`\<`PublishCommandOutput`\>
|
|
67
67
|
|
|
68
|
-
Defined in: [sns/sns.ts:73](https://github.com/aligent/microservice-development-utilities/blob/
|
|
68
|
+
Defined in: [sns/sns.ts:73](https://github.com/aligent/microservice-development-utilities/blob/12392981323381975cdaffeb0a828cecd4846ce0/packages/aws-wrappers/src/sns/sns.ts#L73)
|
|
69
69
|
|
|
70
70
|
Publish a single message to an SNS topic.
|
|
71
71
|
|
|
@@ -98,7 +98,7 @@ PublishCommandInput including TopicArn and Message.
|
|
|
98
98
|
|
|
99
99
|
> **publishBatch**(`input`): `Promise`\<`PublishBatchCommandOutput`[]\>
|
|
100
100
|
|
|
101
|
-
Defined in: [sns/sns.ts:125](https://github.com/aligent/microservice-development-utilities/blob/
|
|
101
|
+
Defined in: [sns/sns.ts:125](https://github.com/aligent/microservice-development-utilities/blob/12392981323381975cdaffeb0a828cecd4846ce0/packages/aws-wrappers/src/sns/sns.ts#L125)
|
|
102
102
|
|
|
103
103
|
Publish a batch of messages to an SNS topic. The SNS API caps
|
|
104
104
|
PublishBatch at 10 entries per request, so this method auto-chunks
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
[**@aligent/aws-wrappers**](
|
|
1
|
+
[**@aligent/aws-wrappers**](../../modules.md)
|
|
2
2
|
|
|
3
3
|
***
|
|
4
4
|
|
|
5
|
-
[@aligent/aws-wrappers](../modules.md) / SQSService
|
|
5
|
+
[@aligent/aws-wrappers](../../modules.md) / [index](../modules.md) / SQSService
|
|
6
6
|
|
|
7
7
|
# Class: SQSService
|
|
8
8
|
|
|
9
|
-
Defined in: [sqs/sqs.ts:49](https://github.com/aligent/microservice-development-utilities/blob/
|
|
9
|
+
Defined in: [sqs/sqs.ts:49](https://github.com/aligent/microservice-development-utilities/blob/12392981323381975cdaffeb0a828cecd4846ce0/packages/aws-wrappers/src/sqs/sqs.ts#L49)
|
|
10
10
|
|
|
11
11
|
Wrapper around the AWS SQS client providing structured Powertools logging
|
|
12
12
|
and X-Ray tracing by default.
|
|
@@ -23,7 +23,7 @@ log line omits them; the verbose levels (`POWERTOOLS_LOG_LEVEL=DEBUG` or
|
|
|
23
23
|
|
|
24
24
|
> **new SQSService**(`opts?`): `SQSService`
|
|
25
25
|
|
|
26
|
-
Defined in: [sqs/sqs.ts:64](https://github.com/aligent/microservice-development-utilities/blob/
|
|
26
|
+
Defined in: [sqs/sqs.ts:64](https://github.com/aligent/microservice-development-utilities/blob/12392981323381975cdaffeb0a828cecd4846ce0/packages/aws-wrappers/src/sqs/sqs.ts#L64)
|
|
27
27
|
|
|
28
28
|
#### Parameters
|
|
29
29
|
|
|
@@ -64,7 +64,7 @@ option.
|
|
|
64
64
|
|
|
65
65
|
> **deleteMessage**(`input`): `Promise`\<`DeleteMessageCommandOutput`\>
|
|
66
66
|
|
|
67
|
-
Defined in: [sqs/sqs.ts:128](https://github.com/aligent/microservice-development-utilities/blob/
|
|
67
|
+
Defined in: [sqs/sqs.ts:128](https://github.com/aligent/microservice-development-utilities/blob/12392981323381975cdaffeb0a828cecd4846ce0/packages/aws-wrappers/src/sqs/sqs.ts#L128)
|
|
68
68
|
|
|
69
69
|
Delete a single message from an SQS queue.
|
|
70
70
|
|
|
@@ -86,7 +86,7 @@ Delete a single message from an SQS queue.
|
|
|
86
86
|
|
|
87
87
|
> **deleteMessageBatch**(`input`): `Promise`\<`DeleteMessageBatchCommandOutput`[]\>
|
|
88
88
|
|
|
89
|
-
Defined in: [sqs/sqs.ts:164](https://github.com/aligent/microservice-development-utilities/blob/
|
|
89
|
+
Defined in: [sqs/sqs.ts:164](https://github.com/aligent/microservice-development-utilities/blob/12392981323381975cdaffeb0a828cecd4846ce0/packages/aws-wrappers/src/sqs/sqs.ts#L164)
|
|
90
90
|
|
|
91
91
|
Delete a batch of messages from an SQS queue. The SQS API caps
|
|
92
92
|
DeleteMessageBatch at 10 entries per request, so this method auto-chunks
|
|
@@ -110,7 +110,7 @@ the caller's entries and sends one request per chunk.
|
|
|
110
110
|
|
|
111
111
|
> **receiveMessages**(`input`): `Promise`\<`Message`[]\>
|
|
112
112
|
|
|
113
|
-
Defined in: [sqs/sqs.ts:119](https://github.com/aligent/microservice-development-utilities/blob/
|
|
113
|
+
Defined in: [sqs/sqs.ts:119](https://github.com/aligent/microservice-development-utilities/blob/12392981323381975cdaffeb0a828cecd4846ce0/packages/aws-wrappers/src/sqs/sqs.ts#L119)
|
|
114
114
|
|
|
115
115
|
Receive messages from an SQS queue. Returns an empty array when no
|
|
116
116
|
messages are available. No automatic deletion is performed — visibility
|
|
@@ -136,7 +136,7 @@ The `Messages` array from the response, or `[]` if absent.
|
|
|
136
136
|
|
|
137
137
|
> **sendMessage**(`input`, `opts?`): `Promise`\<`SendMessageCommandOutput`\>
|
|
138
138
|
|
|
139
|
-
Defined in: [sqs/sqs.ts:76](https://github.com/aligent/microservice-development-utilities/blob/
|
|
139
|
+
Defined in: [sqs/sqs.ts:76](https://github.com/aligent/microservice-development-utilities/blob/12392981323381975cdaffeb0a828cecd4846ce0/packages/aws-wrappers/src/sqs/sqs.ts#L76)
|
|
140
140
|
|
|
141
141
|
Send a single message to an SQS queue.
|
|
142
142
|
|
|
@@ -167,7 +167,7 @@ see `SEND_MESSAGE_SAFE_FIELDS`.
|
|
|
167
167
|
|
|
168
168
|
> **sendMessageBatch**(`input`): `Promise`\<`SendMessageBatchCommandOutput`[]\>
|
|
169
169
|
|
|
170
|
-
Defined in: [sqs/sqs.ts:138](https://github.com/aligent/microservice-development-utilities/blob/
|
|
170
|
+
Defined in: [sqs/sqs.ts:138](https://github.com/aligent/microservice-development-utilities/blob/12392981323381975cdaffeb0a828cecd4846ce0/packages/aws-wrappers/src/sqs/sqs.ts#L138)
|
|
171
171
|
|
|
172
172
|
Send a batch of messages to an SQS queue. The SQS API caps
|
|
173
173
|
SendMessageBatch at 10 entries per request, so this method auto-chunks
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
[**@aligent/aws-wrappers**](
|
|
1
|
+
[**@aligent/aws-wrappers**](../../modules.md)
|
|
2
2
|
|
|
3
3
|
***
|
|
4
4
|
|
|
5
|
-
[@aligent/aws-wrappers](../modules.md) / SSMService
|
|
5
|
+
[@aligent/aws-wrappers](../../modules.md) / [index](../modules.md) / SSMService
|
|
6
6
|
|
|
7
7
|
# Class: SSMService
|
|
8
8
|
|
|
9
|
-
Defined in: [ssm/ssm.ts:50](https://github.com/aligent/microservice-development-utilities/blob/
|
|
9
|
+
Defined in: [ssm/ssm.ts:50](https://github.com/aligent/microservice-development-utilities/blob/12392981323381975cdaffeb0a828cecd4846ce0/packages/aws-wrappers/src/ssm/ssm.ts#L50)
|
|
10
10
|
|
|
11
11
|
Wrapper around the AWS SSM Parameter Store client providing structured
|
|
12
12
|
Powertools logging and X-Ray tracing by default. All read operations enable
|
|
@@ -31,7 +31,7 @@ mutate within the application.
|
|
|
31
31
|
|
|
32
32
|
> **new SSMService**(`opts?`): `SSMService`
|
|
33
33
|
|
|
34
|
-
Defined in: [ssm/ssm.ts:60](https://github.com/aligent/microservice-development-utilities/blob/
|
|
34
|
+
Defined in: [ssm/ssm.ts:60](https://github.com/aligent/microservice-development-utilities/blob/12392981323381975cdaffeb0a828cecd4846ce0/packages/aws-wrappers/src/ssm/ssm.ts#L60)
|
|
35
35
|
|
|
36
36
|
#### Parameters
|
|
37
37
|
|
|
@@ -63,7 +63,7 @@ which picks up `POWERTOOLS_SERVICE_NAME` from the environment.
|
|
|
63
63
|
|
|
64
64
|
> **deleteParameter**(`name`): `Promise`\<`void`\>
|
|
65
65
|
|
|
66
|
-
Defined in: [ssm/ssm.ts:139](https://github.com/aligent/microservice-development-utilities/blob/
|
|
66
|
+
Defined in: [ssm/ssm.ts:139](https://github.com/aligent/microservice-development-utilities/blob/12392981323381975cdaffeb0a828cecd4846ce0/packages/aws-wrappers/src/ssm/ssm.ts#L139)
|
|
67
67
|
|
|
68
68
|
Delete an SSM parameter by name.
|
|
69
69
|
|
|
@@ -88,7 +88,7 @@ runtime cleanup only.
|
|
|
88
88
|
|
|
89
89
|
> **getParameter**(`name`): `Promise`\<`string` \| `undefined`\>
|
|
90
90
|
|
|
91
|
-
Defined in: [ssm/ssm.ts:71](https://github.com/aligent/microservice-development-utilities/blob/
|
|
91
|
+
Defined in: [ssm/ssm.ts:71](https://github.com/aligent/microservice-development-utilities/blob/12392981323381975cdaffeb0a828cecd4846ce0/packages/aws-wrappers/src/ssm/ssm.ts#L71)
|
|
92
92
|
|
|
93
93
|
Fetch a single SSM parameter's value.
|
|
94
94
|
|
|
@@ -115,7 +115,7 @@ value set.
|
|
|
115
115
|
|
|
116
116
|
> **getParameters**\<`K`\>(`aliases`): `Promise`\<`Record`\<`K`, `string` \| `undefined`\>\>
|
|
117
117
|
|
|
118
|
-
Defined in: [ssm/ssm.ts:98](https://github.com/aligent/microservice-development-utilities/blob/
|
|
118
|
+
Defined in: [ssm/ssm.ts:98](https://github.com/aligent/microservice-development-utilities/blob/12392981323381975cdaffeb0a828cecd4846ce0/packages/aws-wrappers/src/ssm/ssm.ts#L98)
|
|
119
119
|
|
|
120
120
|
Fetch multiple SSM parameters in a single request. Callers supply an
|
|
121
121
|
alias-to-path record, and the returned record is keyed by the same
|
|
@@ -160,7 +160,7 @@ no value.
|
|
|
160
160
|
|
|
161
161
|
> **getParametersByPath**(`path`, `opts?`): `Promise`\<`Parameter`[]\>
|
|
162
162
|
|
|
163
|
-
Defined in: [ssm/ssm.ts:155](https://github.com/aligent/microservice-development-utilities/blob/
|
|
163
|
+
Defined in: [ssm/ssm.ts:155](https://github.com/aligent/microservice-development-utilities/blob/12392981323381975cdaffeb0a828cecd4846ce0/packages/aws-wrappers/src/ssm/ssm.ts#L155)
|
|
164
164
|
|
|
165
165
|
Fetch all parameters under an SSM hierarchy path, auto-paginating across
|
|
166
166
|
all pages. `Recursive` defaults to `true` (overriding the AWS SDK
|
|
@@ -199,7 +199,7 @@ The full `Parameter` objects (including `Version`,
|
|
|
199
199
|
|
|
200
200
|
> **putParameter**(`input`): `Promise`\<`PutParameterCommandOutput`\>
|
|
201
201
|
|
|
202
|
-
Defined in: [ssm/ssm.ts:126](https://github.com/aligent/microservice-development-utilities/blob/
|
|
202
|
+
Defined in: [ssm/ssm.ts:126](https://github.com/aligent/microservice-development-utilities/blob/12392981323381975cdaffeb0a828cecd4846ce0/packages/aws-wrappers/src/ssm/ssm.ts#L126)
|
|
203
203
|
|
|
204
204
|
Create or update an SSM parameter. The log line omits `Value` to avoid
|
|
205
205
|
leaking secret material.
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
[**@aligent/aws-wrappers**](
|
|
1
|
+
[**@aligent/aws-wrappers**](../../modules.md)
|
|
2
2
|
|
|
3
3
|
***
|
|
4
4
|
|
|
5
|
-
[@aligent/aws-wrappers](../modules.md) / SchedulerService
|
|
5
|
+
[@aligent/aws-wrappers](../../modules.md) / [index](../modules.md) / SchedulerService
|
|
6
6
|
|
|
7
7
|
# Class: SchedulerService
|
|
8
8
|
|
|
9
|
-
Defined in: [scheduler/scheduler.ts:81](https://github.com/aligent/microservice-development-utilities/blob/
|
|
9
|
+
Defined in: [scheduler/scheduler.ts:81](https://github.com/aligent/microservice-development-utilities/blob/12392981323381975cdaffeb0a828cecd4846ce0/packages/aws-wrappers/src/scheduler/scheduler.ts#L81)
|
|
10
10
|
|
|
11
11
|
Wrapper around the AWS EventBridge Scheduler client providing structured
|
|
12
12
|
Powertools logging and X-Ray tracing by default.
|
|
@@ -31,7 +31,7 @@ intent (`{ Mode: 'OFF' }` for a fixed-time schedule).
|
|
|
31
31
|
|
|
32
32
|
> **new SchedulerService**(`opts?`): `SchedulerService`
|
|
33
33
|
|
|
34
|
-
Defined in: [scheduler/scheduler.ts:91](https://github.com/aligent/microservice-development-utilities/blob/
|
|
34
|
+
Defined in: [scheduler/scheduler.ts:91](https://github.com/aligent/microservice-development-utilities/blob/12392981323381975cdaffeb0a828cecd4846ce0/packages/aws-wrappers/src/scheduler/scheduler.ts#L91)
|
|
35
35
|
|
|
36
36
|
#### Parameters
|
|
37
37
|
|
|
@@ -63,7 +63,7 @@ which picks up `POWERTOOLS_SERVICE_NAME` from the environment.
|
|
|
63
63
|
|
|
64
64
|
> **createSchedule**(`input`): `Promise`\<`CreateScheduleCommandOutput`\>
|
|
65
65
|
|
|
66
|
-
Defined in: [scheduler/scheduler.ts:100](https://github.com/aligent/microservice-development-utilities/blob/
|
|
66
|
+
Defined in: [scheduler/scheduler.ts:100](https://github.com/aligent/microservice-development-utilities/blob/12392981323381975cdaffeb0a828cecd4846ce0/packages/aws-wrappers/src/scheduler/scheduler.ts#L100)
|
|
67
67
|
|
|
68
68
|
Create a new schedule. At INFO the log line omits `Target.Input` (the
|
|
69
69
|
target payload, a PII carrier).
|
|
@@ -86,7 +86,7 @@ target payload, a PII carrier).
|
|
|
86
86
|
|
|
87
87
|
> **createScheduleGroup**(`input`): `Promise`\<`CreateScheduleGroupCommandOutput`\>
|
|
88
88
|
|
|
89
|
-
Defined in: [scheduler/scheduler.ts:158](https://github.com/aligent/microservice-development-utilities/blob/
|
|
89
|
+
Defined in: [scheduler/scheduler.ts:158](https://github.com/aligent/microservice-development-utilities/blob/12392981323381975cdaffeb0a828cecd4846ce0/packages/aws-wrappers/src/scheduler/scheduler.ts#L158)
|
|
90
90
|
|
|
91
91
|
Create a new schedule group. Groups are containers for schedules and are
|
|
92
92
|
typically IaC-managed; use this for dynamically-provisioned groups only.
|
|
@@ -109,7 +109,7 @@ typically IaC-managed; use this for dynamically-provisioned groups only.
|
|
|
109
109
|
|
|
110
110
|
> **deleteSchedule**(`input`): `Promise`\<`DeleteScheduleCommandOutput`\>
|
|
111
111
|
|
|
112
|
-
Defined in: [scheduler/scheduler.ts:134](https://github.com/aligent/microservice-development-utilities/blob/
|
|
112
|
+
Defined in: [scheduler/scheduler.ts:134](https://github.com/aligent/microservice-development-utilities/blob/12392981323381975cdaffeb0a828cecd4846ce0/packages/aws-wrappers/src/scheduler/scheduler.ts#L134)
|
|
113
113
|
|
|
114
114
|
Delete a schedule.
|
|
115
115
|
|
|
@@ -131,7 +131,7 @@ Delete a schedule.
|
|
|
131
131
|
|
|
132
132
|
> **deleteScheduleGroup**(`input`): `Promise`\<`DeleteScheduleGroupCommandOutput`\>
|
|
133
133
|
|
|
134
|
-
Defined in: [scheduler/scheduler.ts:180](https://github.com/aligent/microservice-development-utilities/blob/
|
|
134
|
+
Defined in: [scheduler/scheduler.ts:180](https://github.com/aligent/microservice-development-utilities/blob/12392981323381975cdaffeb0a828cecd4846ce0/packages/aws-wrappers/src/scheduler/scheduler.ts#L180)
|
|
135
135
|
|
|
136
136
|
Delete a schedule group. Deleting a group also deletes every schedule it
|
|
137
137
|
contains, asynchronously — the API has no `UpdateScheduleGroup`, so this
|
|
@@ -155,7 +155,7 @@ is the only mutating group operation besides create.
|
|
|
155
155
|
|
|
156
156
|
> **getSchedule**(`input`): `Promise`\<`GetScheduleCommandOutput`\>
|
|
157
157
|
|
|
158
|
-
Defined in: [scheduler/scheduler.ts:108](https://github.com/aligent/microservice-development-utilities/blob/
|
|
158
|
+
Defined in: [scheduler/scheduler.ts:108](https://github.com/aligent/microservice-development-utilities/blob/12392981323381975cdaffeb0a828cecd4846ce0/packages/aws-wrappers/src/scheduler/scheduler.ts#L108)
|
|
159
159
|
|
|
160
160
|
Fetch a schedule's full configuration.
|
|
161
161
|
|
|
@@ -177,7 +177,7 @@ Fetch a schedule's full configuration.
|
|
|
177
177
|
|
|
178
178
|
> **getScheduleGroup**(`input`): `Promise`\<`GetScheduleGroupCommandOutput`\>
|
|
179
179
|
|
|
180
|
-
Defined in: [scheduler/scheduler.ts:168](https://github.com/aligent/microservice-development-utilities/blob/
|
|
180
|
+
Defined in: [scheduler/scheduler.ts:168](https://github.com/aligent/microservice-development-utilities/blob/12392981323381975cdaffeb0a828cecd4846ce0/packages/aws-wrappers/src/scheduler/scheduler.ts#L168)
|
|
181
181
|
|
|
182
182
|
Fetch a schedule group's configuration.
|
|
183
183
|
|
|
@@ -199,7 +199,7 @@ Fetch a schedule group's configuration.
|
|
|
199
199
|
|
|
200
200
|
> **listScheduleGroups**(`input?`): `Promise`\<`ScheduleGroupSummary`[]\>
|
|
201
201
|
|
|
202
|
-
Defined in: [scheduler/scheduler.ts:191](https://github.com/aligent/microservice-development-utilities/blob/
|
|
202
|
+
Defined in: [scheduler/scheduler.ts:191](https://github.com/aligent/microservice-development-utilities/blob/12392981323381975cdaffeb0a828cecd4846ce0/packages/aws-wrappers/src/scheduler/scheduler.ts#L191)
|
|
203
203
|
|
|
204
204
|
List schedule groups, auto-paginating across all pages. Bounded in
|
|
205
205
|
practice by the account's group count and the `NamePrefix` filter.
|
|
@@ -222,7 +222,7 @@ practice by the account's group count and the `NamePrefix` filter.
|
|
|
222
222
|
|
|
223
223
|
> **listSchedules**(`input?`): `Promise`\<`ScheduleSummary`[]\>
|
|
224
224
|
|
|
225
|
-
Defined in: [scheduler/scheduler.ts:144](https://github.com/aligent/microservice-development-utilities/blob/
|
|
225
|
+
Defined in: [scheduler/scheduler.ts:144](https://github.com/aligent/microservice-development-utilities/blob/12392981323381975cdaffeb0a828cecd4846ce0/packages/aws-wrappers/src/scheduler/scheduler.ts#L144)
|
|
226
226
|
|
|
227
227
|
List schedules, auto-paginating across all pages. Bounded in practice by
|
|
228
228
|
the account's schedule count and the `GroupName` / `NamePrefix` / `State`
|
|
@@ -246,7 +246,7 @@ filters, so the flat-array shape is safe.
|
|
|
246
246
|
|
|
247
247
|
> **updateSchedule**(`input`): `Promise`\<`UpdateScheduleCommandOutput`\>
|
|
248
248
|
|
|
249
|
-
Defined in: [scheduler/scheduler.ts:126](https://github.com/aligent/microservice-development-utilities/blob/
|
|
249
|
+
Defined in: [scheduler/scheduler.ts:126](https://github.com/aligent/microservice-development-utilities/blob/12392981323381975cdaffeb0a828cecd4846ce0/packages/aws-wrappers/src/scheduler/scheduler.ts#L126)
|
|
250
250
|
|
|
251
251
|
Update an existing schedule.
|
|
252
252
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
[**@aligent/aws-wrappers**](
|
|
1
|
+
[**@aligent/aws-wrappers**](../../modules.md)
|
|
2
2
|
|
|
3
3
|
***
|
|
4
4
|
|
|
5
|
-
[@aligent/aws-wrappers](../modules.md) / SecretsManagerService
|
|
5
|
+
[@aligent/aws-wrappers](../../modules.md) / [index](../modules.md) / SecretsManagerService
|
|
6
6
|
|
|
7
7
|
# Class: SecretsManagerService
|
|
8
8
|
|
|
9
|
-
Defined in: [secrets-manager/secrets-manager.ts:75](https://github.com/aligent/microservice-development-utilities/blob/
|
|
9
|
+
Defined in: [secrets-manager/secrets-manager.ts:75](https://github.com/aligent/microservice-development-utilities/blob/12392981323381975cdaffeb0a828cecd4846ce0/packages/aws-wrappers/src/secrets-manager/secrets-manager.ts#L75)
|
|
10
10
|
|
|
11
11
|
Wrapper around the AWS Secrets Manager client providing structured
|
|
12
12
|
Powertools logging and X-Ray tracing by default.
|
|
@@ -30,7 +30,7 @@ mutable values.
|
|
|
30
30
|
|
|
31
31
|
> **new SecretsManagerService**(`opts?`): `SecretsManagerService`
|
|
32
32
|
|
|
33
|
-
Defined in: [secrets-manager/secrets-manager.ts:86](https://github.com/aligent/microservice-development-utilities/blob/
|
|
33
|
+
Defined in: [secrets-manager/secrets-manager.ts:86](https://github.com/aligent/microservice-development-utilities/blob/12392981323381975cdaffeb0a828cecd4846ce0/packages/aws-wrappers/src/secrets-manager/secrets-manager.ts#L86)
|
|
34
34
|
|
|
35
35
|
#### Parameters
|
|
36
36
|
|
|
@@ -63,7 +63,7 @@ which picks up `POWERTOOLS_SERVICE_NAME` from the environment.
|
|
|
63
63
|
|
|
64
64
|
> **createSecret**(`input`): `Promise`\<`CreateSecretCommandOutput`\>
|
|
65
65
|
|
|
66
|
-
Defined in: [secrets-manager/secrets-manager.ts:123](https://github.com/aligent/microservice-development-utilities/blob/
|
|
66
|
+
Defined in: [secrets-manager/secrets-manager.ts:123](https://github.com/aligent/microservice-development-utilities/blob/12392981323381975cdaffeb0a828cecd4846ce0/packages/aws-wrappers/src/secrets-manager/secrets-manager.ts#L123)
|
|
67
67
|
|
|
68
68
|
Create a new secret. At INFO level the log line includes only identity
|
|
69
69
|
and non-secret metadata.
|
|
@@ -89,7 +89,7 @@ dynamically-issued credentials only.
|
|
|
89
89
|
|
|
90
90
|
> **deleteSecret**(`input`): `Promise`\<`DeleteSecretCommandOutput`\>
|
|
91
91
|
|
|
92
|
-
Defined in: [secrets-manager/secrets-manager.ts:163](https://github.com/aligent/microservice-development-utilities/blob/
|
|
92
|
+
Defined in: [secrets-manager/secrets-manager.ts:163](https://github.com/aligent/microservice-development-utilities/blob/12392981323381975cdaffeb0a828cecd4846ce0/packages/aws-wrappers/src/secrets-manager/secrets-manager.ts#L163)
|
|
93
93
|
|
|
94
94
|
Delete a secret. Pass `ForceDeleteWithoutRecovery: true` to bypass the
|
|
95
95
|
default 7-30 day recovery window (irreversible).
|
|
@@ -114,7 +114,7 @@ Prefer IaC (CDK / Terraform) for secret lifecycle.
|
|
|
114
114
|
|
|
115
115
|
> **getJsonSecret**\<`T`\>(`secretId`): `Promise`\<`T`\>
|
|
116
116
|
|
|
117
|
-
Defined in: [secrets-manager/secrets-manager.ts:110](https://github.com/aligent/microservice-development-utilities/blob/
|
|
117
|
+
Defined in: [secrets-manager/secrets-manager.ts:110](https://github.com/aligent/microservice-development-utilities/blob/12392981323381975cdaffeb0a828cecd4846ce0/packages/aws-wrappers/src/secrets-manager/secrets-manager.ts#L110)
|
|
118
118
|
|
|
119
119
|
Fetch a secret and parse it as JSON.
|
|
120
120
|
|
|
@@ -152,7 +152,7 @@ If the secret has no `SecretString` or the value is not valid JSON.
|
|
|
152
152
|
|
|
153
153
|
> **getSecret**(`secretId`): `Promise`\<`string`\>
|
|
154
154
|
|
|
155
|
-
Defined in: [secrets-manager/secrets-manager.ts:98](https://github.com/aligent/microservice-development-utilities/blob/
|
|
155
|
+
Defined in: [secrets-manager/secrets-manager.ts:98](https://github.com/aligent/microservice-development-utilities/blob/12392981323381975cdaffeb0a828cecd4846ce0/packages/aws-wrappers/src/secrets-manager/secrets-manager.ts#L98)
|
|
156
156
|
|
|
157
157
|
Fetch a secret's string value from Secrets Manager.
|
|
158
158
|
|
|
@@ -183,7 +183,7 @@ stores binary data).
|
|
|
183
183
|
|
|
184
184
|
> **putSecretValue**(`input`): `Promise`\<`PutSecretValueCommandOutput`\>
|
|
185
185
|
|
|
186
|
-
Defined in: [secrets-manager/secrets-manager.ts:150](https://github.com/aligent/microservice-development-utilities/blob/
|
|
186
|
+
Defined in: [secrets-manager/secrets-manager.ts:150](https://github.com/aligent/microservice-development-utilities/blob/12392981323381975cdaffeb0a828cecd4846ce0/packages/aws-wrappers/src/secrets-manager/secrets-manager.ts#L150)
|
|
187
187
|
|
|
188
188
|
Store a new version of a secret's value. At INFO level the log line
|
|
189
189
|
omits `SecretString` / `SecretBinary`.
|
|
@@ -208,7 +208,7 @@ Typically used by rotation flows.
|
|
|
208
208
|
|
|
209
209
|
> **updateSecret**(`input`): `Promise`\<`UpdateSecretCommandOutput`\>
|
|
210
210
|
|
|
211
|
-
Defined in: [secrets-manager/secrets-manager.ts:137](https://github.com/aligent/microservice-development-utilities/blob/
|
|
211
|
+
Defined in: [secrets-manager/secrets-manager.ts:137](https://github.com/aligent/microservice-development-utilities/blob/12392981323381975cdaffeb0a828cecd4846ce0/packages/aws-wrappers/src/secrets-manager/secrets-manager.ts#L137)
|
|
212
212
|
|
|
213
213
|
Update an existing secret's metadata or value. At INFO level the log
|
|
214
214
|
line omits `SecretString` / `SecretBinary`.
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
[**@aligent/aws-wrappers**](
|
|
1
|
+
[**@aligent/aws-wrappers**](../../modules.md)
|
|
2
2
|
|
|
3
3
|
***
|
|
4
4
|
|
|
5
|
-
[@aligent/aws-wrappers](../modules.md) / StepFunctionsService
|
|
5
|
+
[@aligent/aws-wrappers](../../modules.md) / [index](../modules.md) / StepFunctionsService
|
|
6
6
|
|
|
7
7
|
# Class: StepFunctionsService
|
|
8
8
|
|
|
9
|
-
Defined in: [sfn/sfn.ts:40](https://github.com/aligent/microservice-development-utilities/blob/
|
|
9
|
+
Defined in: [sfn/sfn.ts:40](https://github.com/aligent/microservice-development-utilities/blob/12392981323381975cdaffeb0a828cecd4846ce0/packages/aws-wrappers/src/sfn/sfn.ts#L40)
|
|
10
10
|
|
|
11
11
|
Wrapper around the AWS Step Functions client providing structured
|
|
12
12
|
Powertools logging and X-Ray tracing by default.
|
|
@@ -23,7 +23,7 @@ log line omits them; the verbose levels (`POWERTOOLS_LOG_LEVEL=DEBUG` or
|
|
|
23
23
|
|
|
24
24
|
> **new StepFunctionsService**(`opts?`): `StepFunctionsService`
|
|
25
25
|
|
|
26
|
-
Defined in: [sfn/sfn.ts:50](https://github.com/aligent/microservice-development-utilities/blob/
|
|
26
|
+
Defined in: [sfn/sfn.ts:50](https://github.com/aligent/microservice-development-utilities/blob/12392981323381975cdaffeb0a828cecd4846ce0/packages/aws-wrappers/src/sfn/sfn.ts#L50)
|
|
27
27
|
|
|
28
28
|
#### Parameters
|
|
29
29
|
|
|
@@ -55,7 +55,7 @@ which picks up `POWERTOOLS_SERVICE_NAME` from the environment.
|
|
|
55
55
|
|
|
56
56
|
> **describeExecution**(`input`): `Promise`\<`DescribeExecutionCommandOutput`\>
|
|
57
57
|
|
|
58
|
-
Defined in: [sfn/sfn.ts:83](https://github.com/aligent/microservice-development-utilities/blob/
|
|
58
|
+
Defined in: [sfn/sfn.ts:83](https://github.com/aligent/microservice-development-utilities/blob/12392981323381975cdaffeb0a828cecd4846ce0/packages/aws-wrappers/src/sfn/sfn.ts#L83)
|
|
59
59
|
|
|
60
60
|
Describe an existing Step Functions execution.
|
|
61
61
|
|
|
@@ -77,7 +77,7 @@ Describe an existing Step Functions execution.
|
|
|
77
77
|
|
|
78
78
|
> **listExecutions**(`input`): `Promise`\<`ExecutionListItem`[]\>
|
|
79
79
|
|
|
80
|
-
Defined in: [sfn/sfn.ts:60](https://github.com/aligent/microservice-development-utilities/blob/
|
|
80
|
+
Defined in: [sfn/sfn.ts:60](https://github.com/aligent/microservice-development-utilities/blob/12392981323381975cdaffeb0a828cecd4846ce0/packages/aws-wrappers/src/sfn/sfn.ts#L60)
|
|
81
81
|
|
|
82
82
|
List all executions for a state machine, auto-paginating across all
|
|
83
83
|
pages. Typically bounded by `statusFilter` and state-machine retention,
|
|
@@ -101,7 +101,7 @@ so the flat-array shape is safe in practice.
|
|
|
101
101
|
|
|
102
102
|
> **startExecution**(`input`): `Promise`\<`StartExecutionCommandOutput`\>
|
|
103
103
|
|
|
104
|
-
Defined in: [sfn/sfn.ts:73](https://github.com/aligent/microservice-development-utilities/blob/
|
|
104
|
+
Defined in: [sfn/sfn.ts:73](https://github.com/aligent/microservice-development-utilities/blob/12392981323381975cdaffeb0a828cecd4846ce0/packages/aws-wrappers/src/sfn/sfn.ts#L73)
|
|
105
105
|
|
|
106
106
|
Start a new Step Functions execution.
|
|
107
107
|
|
|
@@ -123,7 +123,7 @@ Start a new Step Functions execution.
|
|
|
123
123
|
|
|
124
124
|
> **stopExecution**(`input`): `Promise`\<`StopExecutionCommandOutput`\>
|
|
125
125
|
|
|
126
|
-
Defined in: [sfn/sfn.ts:93](https://github.com/aligent/microservice-development-utilities/blob/
|
|
126
|
+
Defined in: [sfn/sfn.ts:93](https://github.com/aligent/microservice-development-utilities/blob/12392981323381975cdaffeb0a828cecd4846ce0/packages/aws-wrappers/src/sfn/sfn.ts#L93)
|
|
127
127
|
|
|
128
128
|
Stop an in-progress Step Functions execution.
|
|
129
129
|
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
[**@aligent/aws-wrappers**](../modules.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@aligent/aws-wrappers](../modules.md) / index
|
|
6
|
+
|
|
7
|
+
# index
|
|
8
|
+
|
|
9
|
+
## Classes
|
|
10
|
+
|
|
11
|
+
- [DynamoDBService](classes/DynamoDBService.md)
|
|
12
|
+
- [S3Service](classes/S3Service.md)
|
|
13
|
+
- [SchedulerService](classes/SchedulerService.md)
|
|
14
|
+
- [SecretsManagerService](classes/SecretsManagerService.md)
|
|
15
|
+
- [SNSService](classes/SNSService.md)
|
|
16
|
+
- [SQSService](classes/SQSService.md)
|
|
17
|
+
- [SSMService](classes/SSMService.md)
|
|
18
|
+
- [StepFunctionsService](classes/StepFunctionsService.md)
|
package/docs/modules.md
CHANGED
|
@@ -4,13 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
# @aligent/aws-wrappers
|
|
6
6
|
|
|
7
|
-
##
|
|
7
|
+
## Modules
|
|
8
8
|
|
|
9
|
-
- [
|
|
10
|
-
- [
|
|
11
|
-
- [SchedulerService](classes/SchedulerService.md)
|
|
12
|
-
- [SecretsManagerService](classes/SecretsManagerService.md)
|
|
13
|
-
- [SNSService](classes/SNSService.md)
|
|
14
|
-
- [SQSService](classes/SQSService.md)
|
|
15
|
-
- [SSMService](classes/SSMService.md)
|
|
16
|
-
- [StepFunctionsService](classes/StepFunctionsService.md)
|
|
9
|
+
- [index](index/modules.md)
|
|
10
|
+
- [testing/testing](testing/testing/modules.md)
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
[**@aligent/aws-wrappers**](../../../modules.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@aligent/aws-wrappers](../../../modules.md) / [testing/testing](../modules.md) / createMockService
|
|
6
|
+
|
|
7
|
+
# Function: createMockService()
|
|
8
|
+
|
|
9
|
+
> **createMockService**\<`T`, `O`\>(`service`, `overrides`): `T` & `O`
|
|
10
|
+
|
|
11
|
+
Defined in: [testing/testing.ts:66](https://github.com/aligent/microservice-development-utilities/blob/12392981323381975cdaffeb0a828cecd4846ce0/packages/aws-wrappers/src/testing/testing.ts#L66)
|
|
12
|
+
|
|
13
|
+
Build a stand-in for a service class from an object of method overrides, for
|
|
14
|
+
use in unit tests of code that depends on the service.
|
|
15
|
+
|
|
16
|
+
Accessing a method of the class that was not overridden throws immediately,
|
|
17
|
+
naming the service and the method, rather than failing later as
|
|
18
|
+
`is not a function`. Any key that is neither an override nor a method of the
|
|
19
|
+
class falls through to the overrides object — so `toString`, `valueOf` and
|
|
20
|
+
`constructor` resolve from `Object.prototype` as usual, and anything else is
|
|
21
|
+
`undefined`. That fallback is what keeps probe properties safe: `then` (so
|
|
22
|
+
awaiting the mock does not throw), `Symbol.toStringTag`, inspection symbols,
|
|
23
|
+
and whatever a test framework's error serialiser reaches for.
|
|
24
|
+
|
|
25
|
+
Only the overrides are enumerable, so spreading, serialising or deep-equalling
|
|
26
|
+
an object that holds the mock does not trip the throw.
|
|
27
|
+
|
|
28
|
+
The helper imports no test framework: callers supply their own spies, and
|
|
29
|
+
overridden keys keep the caller's spy type so `.mock` resolves through the
|
|
30
|
+
returned object.
|
|
31
|
+
|
|
32
|
+
## Type Parameters
|
|
33
|
+
|
|
34
|
+
### T
|
|
35
|
+
|
|
36
|
+
`T` *extends* `object`
|
|
37
|
+
|
|
38
|
+
### O
|
|
39
|
+
|
|
40
|
+
`O` *extends* `Partial`\<`T`\>
|
|
41
|
+
|
|
42
|
+
## Parameters
|
|
43
|
+
|
|
44
|
+
### service
|
|
45
|
+
|
|
46
|
+
The service class itself. It is never constructed — only
|
|
47
|
+
its prototype is read — so the parameter is typed as just that capability,
|
|
48
|
+
which also accepts abstract classes and classes with required constructor
|
|
49
|
+
arguments. Passing the class as a value (rather than as an explicit type
|
|
50
|
+
argument) is load-bearing for the types: TypeScript has no partial
|
|
51
|
+
type-argument inference, so an explicit `T` would suppress inference of the
|
|
52
|
+
overrides type and lose the caller's spy typing on overridden keys.
|
|
53
|
+
|
|
54
|
+
#### prototype
|
|
55
|
+
|
|
56
|
+
`T`
|
|
57
|
+
|
|
58
|
+
### overrides
|
|
59
|
+
|
|
60
|
+
`O`
|
|
61
|
+
|
|
62
|
+
The methods the code under test actually calls. Keys are
|
|
63
|
+
checked against the class's public surface, so a typo or a wrong-shaped
|
|
64
|
+
override is a compile error.
|
|
65
|
+
|
|
66
|
+
## Returns
|
|
67
|
+
|
|
68
|
+
`T` & `O`
|
|
69
|
+
|
|
70
|
+
## Example
|
|
71
|
+
|
|
72
|
+
```typescript
|
|
73
|
+
const getJsonObject = vi.fn().mockResolvedValue({ id: 1 });
|
|
74
|
+
const s3 = createMockService(S3Service, { getJsonObject });
|
|
75
|
+
|
|
76
|
+
await handler({ s3 });
|
|
77
|
+
|
|
78
|
+
expect(s3.getJsonObject.mock.calls).toHaveLength(1);
|
|
79
|
+
```
|
package/esm/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aligent/aws-wrappers",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Opinionated AWS SDK wrappers with Powertools logging and X-Ray tracing",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=18"
|
|
@@ -19,6 +19,16 @@
|
|
|
19
19
|
"default": "./cjs/index.cjs"
|
|
20
20
|
}
|
|
21
21
|
},
|
|
22
|
+
"./testing": {
|
|
23
|
+
"import": {
|
|
24
|
+
"types": "./esm/src/testing/testing.d.ts",
|
|
25
|
+
"default": "./esm/testing.mjs"
|
|
26
|
+
},
|
|
27
|
+
"require": {
|
|
28
|
+
"types": "./cjs/src/testing/testing.d.ts",
|
|
29
|
+
"default": "./cjs/testing.cjs"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
22
32
|
"./package.json": "./package.json"
|
|
23
33
|
},
|
|
24
34
|
"files": [
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build a stand-in for a service class from an object of method overrides, for
|
|
3
|
+
* use in unit tests of code that depends on the service.
|
|
4
|
+
*
|
|
5
|
+
* Accessing a method of the class that was not overridden throws immediately,
|
|
6
|
+
* naming the service and the method, rather than failing later as
|
|
7
|
+
* `is not a function`. Any key that is neither an override nor a method of the
|
|
8
|
+
* class falls through to the overrides object — so `toString`, `valueOf` and
|
|
9
|
+
* `constructor` resolve from `Object.prototype` as usual, and anything else is
|
|
10
|
+
* `undefined`. That fallback is what keeps probe properties safe: `then` (so
|
|
11
|
+
* awaiting the mock does not throw), `Symbol.toStringTag`, inspection symbols,
|
|
12
|
+
* and whatever a test framework's error serialiser reaches for.
|
|
13
|
+
*
|
|
14
|
+
* Only the overrides are enumerable, so spreading, serialising or deep-equalling
|
|
15
|
+
* an object that holds the mock does not trip the throw.
|
|
16
|
+
*
|
|
17
|
+
* The helper imports no test framework: callers supply their own spies, and
|
|
18
|
+
* overridden keys keep the caller's spy type so `.mock` resolves through the
|
|
19
|
+
* returned object.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* const getJsonObject = vi.fn().mockResolvedValue({ id: 1 });
|
|
24
|
+
* const s3 = createMockService(S3Service, { getJsonObject });
|
|
25
|
+
*
|
|
26
|
+
* await handler({ s3 });
|
|
27
|
+
*
|
|
28
|
+
* expect(s3.getJsonObject.mock.calls).toHaveLength(1);
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @param service - The service class itself. It is never constructed — only
|
|
32
|
+
* its prototype is read — so the parameter is typed as just that capability,
|
|
33
|
+
* which also accepts abstract classes and classes with required constructor
|
|
34
|
+
* arguments. Passing the class as a value (rather than as an explicit type
|
|
35
|
+
* argument) is load-bearing for the types: TypeScript has no partial
|
|
36
|
+
* type-argument inference, so an explicit `T` would suppress inference of the
|
|
37
|
+
* overrides type and lose the caller's spy typing on overridden keys.
|
|
38
|
+
* @param overrides - The methods the code under test actually calls. Keys are
|
|
39
|
+
* checked against the class's public surface, so a typo or a wrong-shaped
|
|
40
|
+
* override is a compile error.
|
|
41
|
+
*/
|
|
42
|
+
export declare function createMockService<T extends object, O extends Partial<T>>(service: {
|
|
43
|
+
prototype: T;
|
|
44
|
+
}, overrides: O): T & O;
|
package/esm/testing.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./src/testing/testing";
|
package/esm/testing.mjs
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Collect the method names of a class, walking the prototype chain up to but
|
|
3
|
+
* excluding `Object.prototype` so inherited methods are found.
|
|
4
|
+
*
|
|
5
|
+
* Property *descriptors* are inspected rather than properties read: reading a
|
|
6
|
+
* prototype getter here would execute consumer code with `this` bound to the
|
|
7
|
+
* mock. Accessor properties are therefore neither mockable nor throwable.
|
|
8
|
+
*/
|
|
9
|
+
function collectMethodNames(prototype) {
|
|
10
|
+
const names = new Set();
|
|
11
|
+
let current = prototype;
|
|
12
|
+
while (current !== null && current !== Object.prototype) {
|
|
13
|
+
for (const key of Object.getOwnPropertyNames(current)) {
|
|
14
|
+
if (key === 'constructor')
|
|
15
|
+
continue;
|
|
16
|
+
const descriptor = Object.getOwnPropertyDescriptor(current, key);
|
|
17
|
+
if (typeof descriptor?.value === 'function')
|
|
18
|
+
names.add(key);
|
|
19
|
+
}
|
|
20
|
+
current = Object.getPrototypeOf(current);
|
|
21
|
+
}
|
|
22
|
+
return names;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Build a stand-in for a service class from an object of method overrides, for
|
|
26
|
+
* use in unit tests of code that depends on the service.
|
|
27
|
+
*
|
|
28
|
+
* Accessing a method of the class that was not overridden throws immediately,
|
|
29
|
+
* naming the service and the method, rather than failing later as
|
|
30
|
+
* `is not a function`. Any key that is neither an override nor a method of the
|
|
31
|
+
* class falls through to the overrides object — so `toString`, `valueOf` and
|
|
32
|
+
* `constructor` resolve from `Object.prototype` as usual, and anything else is
|
|
33
|
+
* `undefined`. That fallback is what keeps probe properties safe: `then` (so
|
|
34
|
+
* awaiting the mock does not throw), `Symbol.toStringTag`, inspection symbols,
|
|
35
|
+
* and whatever a test framework's error serialiser reaches for.
|
|
36
|
+
*
|
|
37
|
+
* Only the overrides are enumerable, so spreading, serialising or deep-equalling
|
|
38
|
+
* an object that holds the mock does not trip the throw.
|
|
39
|
+
*
|
|
40
|
+
* The helper imports no test framework: callers supply their own spies, and
|
|
41
|
+
* overridden keys keep the caller's spy type so `.mock` resolves through the
|
|
42
|
+
* returned object.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* const getJsonObject = vi.fn().mockResolvedValue({ id: 1 });
|
|
47
|
+
* const s3 = createMockService(S3Service, { getJsonObject });
|
|
48
|
+
*
|
|
49
|
+
* await handler({ s3 });
|
|
50
|
+
*
|
|
51
|
+
* expect(s3.getJsonObject.mock.calls).toHaveLength(1);
|
|
52
|
+
* ```
|
|
53
|
+
*
|
|
54
|
+
* @param service - The service class itself. It is never constructed — only
|
|
55
|
+
* its prototype is read — so the parameter is typed as just that capability,
|
|
56
|
+
* which also accepts abstract classes and classes with required constructor
|
|
57
|
+
* arguments. Passing the class as a value (rather than as an explicit type
|
|
58
|
+
* argument) is load-bearing for the types: TypeScript has no partial
|
|
59
|
+
* type-argument inference, so an explicit `T` would suppress inference of the
|
|
60
|
+
* overrides type and lose the caller's spy typing on overridden keys.
|
|
61
|
+
* @param overrides - The methods the code under test actually calls. Keys are
|
|
62
|
+
* checked against the class's public surface, so a typo or a wrong-shaped
|
|
63
|
+
* override is a compile error.
|
|
64
|
+
*/
|
|
65
|
+
function createMockService(service, overrides) {
|
|
66
|
+
const { prototype } = service;
|
|
67
|
+
const methodNames = collectMethodNames(prototype);
|
|
68
|
+
const className = prototype.constructor?.name;
|
|
69
|
+
const isUnmockedMethod = (key) => typeof key === 'string' && methodNames.has(key);
|
|
70
|
+
const mock = new Proxy(overrides, {
|
|
71
|
+
get(target, key, receiver) {
|
|
72
|
+
// `hasOwn`, not `has`: a class method that shadows one of
|
|
73
|
+
// `Object.prototype`'s (`toString`, `valueOf`, …) must still throw
|
|
74
|
+
// rather than be served silently from the prototype chain.
|
|
75
|
+
if (Object.hasOwn(target, key))
|
|
76
|
+
return Reflect.get(target, key, receiver);
|
|
77
|
+
if (isUnmockedMethod(key)) {
|
|
78
|
+
throw new Error(`${className ?? 'Service'}.${key} was accessed but not mocked`);
|
|
79
|
+
}
|
|
80
|
+
return Reflect.get(target, key, receiver);
|
|
81
|
+
},
|
|
82
|
+
has(target, key) {
|
|
83
|
+
return Reflect.has(target, key) || isUnmockedMethod(key);
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
// The services declare `private readonly client` / `private readonly logger`.
|
|
87
|
+
// Those fields are nominal, so no structurally-constructed value is
|
|
88
|
+
// assignable to the class type — this cast is unavoidable. Concentrating
|
|
89
|
+
// it here is the point of the helper: consumer test suites contain none.
|
|
90
|
+
return mock;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export { createMockService };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aligent/aws-wrappers",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Opinionated AWS SDK wrappers with Powertools logging and X-Ray tracing",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=18"
|
|
@@ -19,6 +19,16 @@
|
|
|
19
19
|
"default": "./cjs/index.cjs"
|
|
20
20
|
}
|
|
21
21
|
},
|
|
22
|
+
"./testing": {
|
|
23
|
+
"import": {
|
|
24
|
+
"types": "./esm/src/testing/testing.d.ts",
|
|
25
|
+
"default": "./esm/testing.mjs"
|
|
26
|
+
},
|
|
27
|
+
"require": {
|
|
28
|
+
"types": "./cjs/src/testing/testing.d.ts",
|
|
29
|
+
"default": "./cjs/testing.cjs"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
22
32
|
"./package.json": "./package.json"
|
|
23
33
|
},
|
|
24
34
|
"files": [
|