@aligent/aws-wrappers 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -3
- package/cjs/index.cjs +678 -1428
- package/cjs/package.json +4 -1
- package/cjs/src/dynamodb/dynamodb.d.ts +31 -0
- package/cjs/src/s3/s3.d.ts +19 -4
- package/cjs/src/scheduler/scheduler.d.ts +6 -4
- package/cjs/src/secrets-manager/secrets-manager.d.ts +7 -6
- package/cjs/src/sfn/sfn.d.ts +4 -0
- package/cjs/src/sns/sns.d.ts +12 -2
- package/cjs/src/sqs/sqs.d.ts +12 -2
- package/cjs/src/ssm/ssm.d.ts +4 -0
- package/cjs/src/util/redact.d.ts +14 -4
- package/docs/classes/DynamoDBService.md +41 -12
- package/docs/classes/S3Service.md +33 -19
- package/docs/classes/SNSService.md +9 -6
- package/docs/classes/SQSService.md +12 -9
- package/docs/classes/SSMService.md +11 -7
- package/docs/classes/SchedulerService.md +17 -15
- package/docs/classes/SecretsManagerService.md +15 -14
- package/docs/classes/StepFunctionsService.md +10 -6
- package/esm/index.mjs +680 -1430
- package/esm/package.json +4 -1
- package/esm/src/dynamodb/dynamodb.d.ts +31 -0
- package/esm/src/s3/s3.d.ts +19 -4
- package/esm/src/scheduler/scheduler.d.ts +6 -4
- package/esm/src/secrets-manager/secrets-manager.d.ts +7 -6
- package/esm/src/sfn/sfn.d.ts +4 -0
- package/esm/src/sns/sns.d.ts +12 -2
- package/esm/src/sqs/sqs.d.ts +12 -2
- package/esm/src/ssm/ssm.d.ts +4 -0
- package/esm/src/util/redact.d.ts +14 -4
- package/package.json +4 -1
package/cjs/package.json
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aligent/aws-wrappers",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Opinionated AWS SDK wrappers with Powertools logging and X-Ray tracing",
|
|
5
|
+
"engines": {
|
|
6
|
+
"node": ">=18"
|
|
7
|
+
},
|
|
5
8
|
"main": "./index.cjs.js",
|
|
6
9
|
"module": "./esm/index.mjs",
|
|
7
10
|
"types": "./cjs/src/index.d.ts",
|
|
@@ -11,6 +11,10 @@ type WithTypedKey<TInput, K extends Record<string, unknown>> = Omit<TInput, 'Key
|
|
|
11
11
|
* Wrapper around the AWS DynamoDB Document client providing structured
|
|
12
12
|
* Powertools logging and X-Ray tracing by default.
|
|
13
13
|
*
|
|
14
|
+
* Where a method's input carries payloads, secret material or PII, the INFO
|
|
15
|
+
* log line omits them; the verbose levels (`POWERTOOLS_LOG_LEVEL=DEBUG` or
|
|
16
|
+
* `TRACE`) log full SDK inputs.
|
|
17
|
+
*
|
|
14
18
|
* Items are automatically marshalled / unmarshalled via the document client —
|
|
15
19
|
* callers work with plain TypeScript objects in both directions.
|
|
16
20
|
*/
|
|
@@ -115,11 +119,38 @@ export declare class DynamoDBService {
|
|
|
115
119
|
batchWrite(input: BatchWriteCommandInput): Promise<BatchWriteCommandOutput>;
|
|
116
120
|
/**
|
|
117
121
|
* Paginate over Query results, yielding one unmarshalled item at a time.
|
|
122
|
+
*
|
|
123
|
+
* **`Limit` is a page size, not a total cap.** DynamoDB applies it per
|
|
124
|
+
* request, and this method walks every page until `LastEvaluatedKey` is
|
|
125
|
+
* exhausted — so `paginateItems({ Limit: 10 })` yields *every* matching
|
|
126
|
+
* item, in pages of 10, not the first 10 items.
|
|
127
|
+
*
|
|
128
|
+
* To bound the number of items, `break` out of the loop. This is an
|
|
129
|
+
* `AsyncGenerator`, so `break` calls its `return()`, which unwinds the
|
|
130
|
+
* pagination and issues no further requests:
|
|
131
|
+
*
|
|
132
|
+
* ```ts
|
|
133
|
+
* const firstTen: Item[] = [];
|
|
134
|
+
* for await (const item of ddb.paginateItems<Item>(input)) {
|
|
135
|
+
* firstTen.push(item);
|
|
136
|
+
* if (firstTen.length === 10) break;
|
|
137
|
+
* }
|
|
138
|
+
* ```
|
|
139
|
+
*
|
|
140
|
+
* `Limit` remains the right knob for tuning per-request consumed capacity
|
|
141
|
+
* and page memory — set it deliberately, just don't expect it to stop the
|
|
142
|
+
* walk.
|
|
143
|
+
*
|
|
118
144
|
* @template T - Expected shape of each yielded item.
|
|
119
145
|
*/
|
|
120
146
|
paginateItems<T extends Record<string, unknown> = Record<string, unknown>>(input: QueryCommandInput): AsyncGenerator<T>;
|
|
121
147
|
/**
|
|
122
148
|
* Paginate over Scan results, yielding one unmarshalled item at a time.
|
|
149
|
+
*
|
|
150
|
+
* **`Limit` is a page size, not a total cap** — see `paginateItems` for the
|
|
151
|
+
* detail. `break` out of the loop to bound the number of items; `Limit`
|
|
152
|
+
* stays the right knob for per-request consumed capacity and page memory.
|
|
153
|
+
*
|
|
123
154
|
* @template T - Expected shape of each yielded item.
|
|
124
155
|
*/
|
|
125
156
|
paginateScan<T extends Record<string, unknown> = Record<string, unknown>>(input: ScanCommandInput): AsyncGenerator<T>;
|
package/cjs/src/s3/s3.d.ts
CHANGED
|
@@ -13,6 +13,10 @@ type PutJsonObjectInput<T> = {
|
|
|
13
13
|
* Wrapper around the AWS S3 client providing structured Powertools logging
|
|
14
14
|
* and X-Ray tracing by default.
|
|
15
15
|
*
|
|
16
|
+
* Where a method's input carries payloads, secret material or PII, the INFO
|
|
17
|
+
* log line omits them; the verbose levels (`POWERTOOLS_LOG_LEVEL=DEBUG` or
|
|
18
|
+
* `TRACE`) log full SDK inputs.
|
|
19
|
+
*
|
|
16
20
|
* Input shapes are intentionally tight (Bucket/Key/Body only). Callers
|
|
17
21
|
* needing SDK-level options not exposed here (server-side encryption,
|
|
18
22
|
* tagging, version IDs) should use `S3Client` directly.
|
|
@@ -121,10 +125,21 @@ export declare class S3Service {
|
|
|
121
125
|
*/
|
|
122
126
|
deleteObjects(bucket: string, keys: string[]): Promise<DeleteObjectsCommandOutput[]>;
|
|
123
127
|
/**
|
|
124
|
-
* Delete every object in
|
|
125
|
-
* delegates each page's deletion to `deleteObjects`, so
|
|
126
|
-
* bounded by one page (~1000 keys) regardless of bucket
|
|
127
|
-
*
|
|
128
|
+
* Delete every object in an **unversioned** bucket. Streams the listing
|
|
129
|
+
* page-by-page and delegates each page's deletion to `deleteObjects`, so
|
|
130
|
+
* peak memory stays bounded by one page (~1000 keys) regardless of bucket
|
|
131
|
+
* size.
|
|
132
|
+
*
|
|
133
|
+
* **Versioned buckets are out of scope.** This paginates `ListObjectsV2`,
|
|
134
|
+
* which reports only current object versions — never noncurrent versions or
|
|
135
|
+
* delete markers. Against a versioned bucket the call therefore succeeds and
|
|
136
|
+
* the bucket then *looks* empty to `ListObjectsV2`, but the deletes only
|
|
137
|
+
* added delete markers: every object version is still stored, still billed,
|
|
138
|
+
* and `DeleteBucket` will still fail with `BucketNotEmpty`. Emptying a
|
|
139
|
+
* versioned bucket requires `ListObjectVersions` and per-version deletes;
|
|
140
|
+
* use `S3Client` directly for that.
|
|
141
|
+
*
|
|
142
|
+
* @returns The keys this call issued deletes for.
|
|
128
143
|
*/
|
|
129
144
|
emptyBucket(bucket: string): Promise<string[]>;
|
|
130
145
|
}
|
|
@@ -4,6 +4,10 @@ import { CreateScheduleCommandInput, CreateScheduleCommandOutput, CreateSchedule
|
|
|
4
4
|
* Wrapper around the AWS EventBridge Scheduler client providing structured
|
|
5
5
|
* Powertools logging and X-Ray tracing by default.
|
|
6
6
|
*
|
|
7
|
+
* Where a method's input carries payloads, secret material or PII, the INFO
|
|
8
|
+
* log line omits them; the verbose levels (`POWERTOOLS_LOG_LEVEL=DEBUG` or
|
|
9
|
+
* `TRACE`) log full SDK inputs.
|
|
10
|
+
*
|
|
7
11
|
* Covers CRUD on schedules and their groups. Named `SchedulerService` (not
|
|
8
12
|
* `EventBridgeSchedulerService`) so it doesn't collide with a future wrapper
|
|
9
13
|
* over the separate EventBridge bus/rules API (`@aws-sdk/client-eventbridge`).
|
|
@@ -27,8 +31,7 @@ export declare class SchedulerService {
|
|
|
27
31
|
});
|
|
28
32
|
/**
|
|
29
33
|
* Create a new schedule. At INFO the log line omits `Target.Input` (the
|
|
30
|
-
* target payload, a PII carrier)
|
|
31
|
-
* full input.
|
|
34
|
+
* target payload, a PII carrier).
|
|
32
35
|
*/
|
|
33
36
|
createSchedule(input: CreateScheduleCommandInput): Promise<CreateScheduleCommandOutput>;
|
|
34
37
|
/**
|
|
@@ -46,8 +49,7 @@ export declare class SchedulerService {
|
|
|
46
49
|
* your behalf: deep-merging a `Target` (with its mutually-exclusive
|
|
47
50
|
* target-type params) has no single correct semantics.
|
|
48
51
|
*
|
|
49
|
-
* At INFO the log line omits `Target.Input
|
|
50
|
-
* unlocks the full input.
|
|
52
|
+
* At INFO the log line omits `Target.Input`.
|
|
51
53
|
*/
|
|
52
54
|
updateSchedule(input: UpdateScheduleCommandInput): Promise<UpdateScheduleCommandOutput>;
|
|
53
55
|
/**
|
|
@@ -4,6 +4,10 @@ import { CreateSecretCommandInput, CreateSecretCommandOutput, DeleteSecretComman
|
|
|
4
4
|
* Wrapper around the AWS Secrets Manager client providing structured
|
|
5
5
|
* Powertools logging and X-Ray tracing by default.
|
|
6
6
|
*
|
|
7
|
+
* Where a method's input carries payloads, secret material or PII, the INFO
|
|
8
|
+
* log line omits them; the verbose levels (`POWERTOOLS_LOG_LEVEL=DEBUG` or
|
|
9
|
+
* `TRACE`) log full SDK inputs.
|
|
10
|
+
*
|
|
7
11
|
* Write operations (`createSecret`, `updateSecret`, `putSecretValue`,
|
|
8
12
|
* `deleteSecret`) are exposed for convenience but should be used with care:
|
|
9
13
|
* secret lifecycle is usually managed by IaC (CDK / Terraform). Prefer IaC
|
|
@@ -43,8 +47,7 @@ export declare class SecretsManagerService {
|
|
|
43
47
|
getJsonSecret<T>(secretId: string): Promise<T>;
|
|
44
48
|
/**
|
|
45
49
|
* Create a new secret. At INFO level the log line includes only identity
|
|
46
|
-
* and non-secret metadata
|
|
47
|
-
* input (including `SecretString` / `SecretBinary`).
|
|
50
|
+
* and non-secret metadata.
|
|
48
51
|
*
|
|
49
52
|
* Prefer IaC (CDK / Terraform) for secret lifecycle — use this for
|
|
50
53
|
* dynamically-issued credentials only.
|
|
@@ -52,8 +55,7 @@ export declare class SecretsManagerService {
|
|
|
52
55
|
createSecret(input: CreateSecretCommandInput): Promise<CreateSecretCommandOutput>;
|
|
53
56
|
/**
|
|
54
57
|
* Update an existing secret's metadata or value. At INFO level the log
|
|
55
|
-
* line omits `SecretString` / `SecretBinary
|
|
56
|
-
* unlocks the full input.
|
|
58
|
+
* line omits `SecretString` / `SecretBinary`.
|
|
57
59
|
*
|
|
58
60
|
* Prefer IaC (CDK / Terraform) for secret lifecycle — use this for
|
|
59
61
|
* runtime metadata updates only.
|
|
@@ -61,8 +63,7 @@ export declare class SecretsManagerService {
|
|
|
61
63
|
updateSecret(input: UpdateSecretCommandInput): Promise<UpdateSecretCommandOutput>;
|
|
62
64
|
/**
|
|
63
65
|
* Store a new version of a secret's value. At INFO level the log line
|
|
64
|
-
* omits `SecretString` / `SecretBinary
|
|
65
|
-
* unlocks the full input.
|
|
66
|
+
* omits `SecretString` / `SecretBinary`.
|
|
66
67
|
*
|
|
67
68
|
* Typically used by rotation flows.
|
|
68
69
|
*/
|
package/cjs/src/sfn/sfn.d.ts
CHANGED
|
@@ -3,6 +3,10 @@ import { DescribeExecutionCommandInput, DescribeExecutionCommandOutput, Executio
|
|
|
3
3
|
/**
|
|
4
4
|
* Wrapper around the AWS Step Functions client providing structured
|
|
5
5
|
* Powertools logging and X-Ray tracing by default.
|
|
6
|
+
*
|
|
7
|
+
* Where a method's input carries payloads, secret material or PII, the INFO
|
|
8
|
+
* log line omits them; the verbose levels (`POWERTOOLS_LOG_LEVEL=DEBUG` or
|
|
9
|
+
* `TRACE`) log full SDK inputs.
|
|
6
10
|
*/
|
|
7
11
|
export declare class StepFunctionsService {
|
|
8
12
|
private readonly client;
|
package/cjs/src/sns/sns.d.ts
CHANGED
|
@@ -3,6 +3,10 @@ import { PublishBatchCommandInput, PublishBatchCommandOutput, PublishCommandInpu
|
|
|
3
3
|
/**
|
|
4
4
|
* Wrapper around the AWS SNS client providing structured Powertools logging
|
|
5
5
|
* and X-Ray tracing by default.
|
|
6
|
+
*
|
|
7
|
+
* Where a method's input carries payloads, secret material or PII, the INFO
|
|
8
|
+
* log line omits them; the verbose levels (`POWERTOOLS_LOG_LEVEL=DEBUG` or
|
|
9
|
+
* `TRACE`) log full SDK inputs.
|
|
6
10
|
*/
|
|
7
11
|
export declare class SNSService {
|
|
8
12
|
private readonly client;
|
|
@@ -28,14 +32,20 @@ export declare class SNSService {
|
|
|
28
32
|
* Publish a single message to an SNS topic.
|
|
29
33
|
*
|
|
30
34
|
* At INFO level the log line includes only routing / dedup metadata; see
|
|
31
|
-
* `PUBLISH_SAFE_FIELDS` for the list.
|
|
32
|
-
* unlocks the full input.
|
|
35
|
+
* `PUBLISH_SAFE_FIELDS` for the list.
|
|
33
36
|
*
|
|
34
37
|
* @param input - PublishCommandInput including TopicArn and Message.
|
|
35
38
|
*/
|
|
36
39
|
publish(input: PublishCommandInput, opts?: {
|
|
37
40
|
truncate?: boolean;
|
|
38
41
|
}): Promise<PublishCommandOutput>;
|
|
42
|
+
/**
|
|
43
|
+
* The truncation helpers return the input unchanged when it already fits, so
|
|
44
|
+
* a `!==` comparison against their result is what decides whether a field
|
|
45
|
+
* was modified. Don't reintroduce a size guard here: that would state each
|
|
46
|
+
* limit twice, encode the string to a `Buffer` twice, and let the two
|
|
47
|
+
* expressions drift into warning without truncating (or the reverse).
|
|
48
|
+
*/
|
|
39
49
|
private applyTruncation;
|
|
40
50
|
/**
|
|
41
51
|
* Publish a batch of messages to an SNS topic. The SNS API caps
|
package/cjs/src/sqs/sqs.d.ts
CHANGED
|
@@ -3,6 +3,10 @@ import { DeleteMessageBatchCommandInput, DeleteMessageBatchCommandOutput, Delete
|
|
|
3
3
|
/**
|
|
4
4
|
* Wrapper around the AWS SQS client providing structured Powertools logging
|
|
5
5
|
* and X-Ray tracing by default.
|
|
6
|
+
*
|
|
7
|
+
* Where a method's input carries payloads, secret material or PII, the INFO
|
|
8
|
+
* log line omits them; the verbose levels (`POWERTOOLS_LOG_LEVEL=DEBUG` or
|
|
9
|
+
* `TRACE`) log full SDK inputs.
|
|
6
10
|
*/
|
|
7
11
|
export declare class SQSService {
|
|
8
12
|
private readonly client;
|
|
@@ -27,12 +31,18 @@ export declare class SQSService {
|
|
|
27
31
|
* Send a single message to an SQS queue.
|
|
28
32
|
*
|
|
29
33
|
* At INFO level the log line includes only queue routing / FIFO metadata;
|
|
30
|
-
* see `SEND_MESSAGE_SAFE_FIELDS`.
|
|
31
|
-
* full input.
|
|
34
|
+
* see `SEND_MESSAGE_SAFE_FIELDS`.
|
|
32
35
|
*/
|
|
33
36
|
sendMessage(input: SendMessageCommandInput, opts?: {
|
|
34
37
|
truncate?: boolean;
|
|
35
38
|
}): Promise<SendMessageCommandOutput>;
|
|
39
|
+
/**
|
|
40
|
+
* `truncateUtf8` returns the input unchanged when it already fits, so a
|
|
41
|
+
* `!==` comparison against its result is what decides whether the body was
|
|
42
|
+
* modified. Don't reintroduce a size guard here: that would state the limit
|
|
43
|
+
* twice, encode the string to a `Buffer` twice, and let the two expressions
|
|
44
|
+
* drift into warning without truncating (or the reverse).
|
|
45
|
+
*/
|
|
36
46
|
private applyTruncation;
|
|
37
47
|
/**
|
|
38
48
|
* Receive messages from an SQS queue. Returns an empty array when no
|
package/cjs/src/ssm/ssm.d.ts
CHANGED
|
@@ -6,6 +6,10 @@ import { Parameter, PutParameterCommandInput, PutParameterCommandOutput, SSMClie
|
|
|
6
6
|
* `WithDecryption` — callers needing plaintext should use `SSMClient`
|
|
7
7
|
* directly.
|
|
8
8
|
*
|
|
9
|
+
* Where a method's input carries payloads, secret material or PII, the INFO
|
|
10
|
+
* log line omits them; the verbose levels (`POWERTOOLS_LOG_LEVEL=DEBUG` or
|
|
11
|
+
* `TRACE`) log full SDK inputs.
|
|
12
|
+
*
|
|
9
13
|
* Write operations (`putParameter`, `deleteParameter`) are exposed for
|
|
10
14
|
* convenience but should be used with care: parameter lifecycle is usually
|
|
11
15
|
* managed by IaC (CDK / Terraform). Prefer IaC for anything that exists at
|
package/cjs/src/util/redact.d.ts
CHANGED
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
import type { LoggerInterface } from '@aws-lambda-powertools/logger/types';
|
|
2
|
+
/**
|
|
3
|
+
* Whether the logger is verbose enough that full SDK inputs — payloads, secret
|
|
4
|
+
* material and PII — may be written to the log.
|
|
5
|
+
*
|
|
6
|
+
* **This is the only place in the package that reads the log level.** Never
|
|
7
|
+
* compare `logger.getLevelName()` yourself: Powertools orders `TRACE` as *more*
|
|
8
|
+
* verbose than `DEBUG` (thresholds 6 and 8), so the obvious
|
|
9
|
+
* `getLevelName() === 'DEBUG'` check silently redacts at the most verbose level
|
|
10
|
+
* available. Route every disclosure decision through this predicate instead.
|
|
11
|
+
*/
|
|
12
|
+
export declare function shouldLogFullInput(logger: LoggerInterface): boolean;
|
|
2
13
|
/**
|
|
3
14
|
* Return a log-safe projection of `input` based on the logger's configured level.
|
|
4
15
|
*
|
|
5
|
-
* At
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* and PII.
|
|
16
|
+
* At the verbose levels — see {@link shouldLogFullInput} — the full input is
|
|
17
|
+
* returned unchanged: operators who asked for that verbosity have explicitly
|
|
18
|
+
* opted into seeing everything, including payloads, secret material and PII.
|
|
9
19
|
*
|
|
10
20
|
* At any other level, only the fields listed in `safeFields` are included.
|
|
11
21
|
* Missing fields are silently skipped — the result type narrows to
|
|
@@ -6,11 +6,15 @@
|
|
|
6
6
|
|
|
7
7
|
# Class: DynamoDBService
|
|
8
8
|
|
|
9
|
-
Defined in: [dynamodb/dynamodb.ts:
|
|
9
|
+
Defined in: [dynamodb/dynamodb.ts:153](https://github.com/aligent/microservice-development-utilities/blob/fd6cf9d0c7112a3e2feb0c83a6bedebeddcf46ed/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.
|
|
13
13
|
|
|
14
|
+
Where a method's input carries payloads, secret material or PII, the INFO
|
|
15
|
+
log line omits them; the verbose levels (`POWERTOOLS_LOG_LEVEL=DEBUG` or
|
|
16
|
+
`TRACE`) log full SDK inputs.
|
|
17
|
+
|
|
14
18
|
Items are automatically marshalled / unmarshalled via the document client —
|
|
15
19
|
callers work with plain TypeScript objects in both directions.
|
|
16
20
|
|
|
@@ -22,7 +26,7 @@ callers work with plain TypeScript objects in both directions.
|
|
|
22
26
|
|
|
23
27
|
> **new DynamoDBService**(`opts?`): `DynamoDBService`
|
|
24
28
|
|
|
25
|
-
Defined in: [dynamodb/dynamodb.ts:
|
|
29
|
+
Defined in: [dynamodb/dynamodb.ts:166](https://github.com/aligent/microservice-development-utilities/blob/fd6cf9d0c7112a3e2feb0c83a6bedebeddcf46ed/packages/aws-wrappers/src/dynamodb/dynamodb.ts#L166)
|
|
26
30
|
|
|
27
31
|
#### Parameters
|
|
28
32
|
|
|
@@ -57,7 +61,7 @@ which picks up `POWERTOOLS_SERVICE_NAME` from the environment.
|
|
|
57
61
|
|
|
58
62
|
> **batchGet**(`input`): `Promise`\<`BatchGetCommandOutput`\>
|
|
59
63
|
|
|
60
|
-
Defined in: [dynamodb/dynamodb.ts:
|
|
64
|
+
Defined in: [dynamodb/dynamodb.ts:317](https://github.com/aligent/microservice-development-utilities/blob/fd6cf9d0c7112a3e2feb0c83a6bedebeddcf46ed/packages/aws-wrappers/src/dynamodb/dynamodb.ts#L317)
|
|
61
65
|
|
|
62
66
|
Batch-get items from one or more DynamoDB tables.
|
|
63
67
|
|
|
@@ -84,7 +88,7 @@ Callers should narrow the result type at the call site.
|
|
|
84
88
|
|
|
85
89
|
> **batchWrite**(`input`): `Promise`\<`BatchWriteCommandOutput`\>
|
|
86
90
|
|
|
87
|
-
Defined in: [dynamodb/dynamodb.ts:
|
|
91
|
+
Defined in: [dynamodb/dynamodb.ts:334](https://github.com/aligent/microservice-development-utilities/blob/fd6cf9d0c7112a3e2feb0c83a6bedebeddcf46ed/packages/aws-wrappers/src/dynamodb/dynamodb.ts#L334)
|
|
88
92
|
|
|
89
93
|
Batch-write items to DynamoDB, retrying `UnprocessedItems` with jittered
|
|
90
94
|
exponential backoff. Up to 5 attempts (200ms base delay). Throws when
|
|
@@ -108,7 +112,7 @@ items remain unprocessed after the final attempt.
|
|
|
108
112
|
|
|
109
113
|
> **deleteItem**\<`K`, `R`\>(`input`): `Promise`\<`Omit`\<`DeleteCommandOutput`, `"Attributes"`\> & `object`\>
|
|
110
114
|
|
|
111
|
-
Defined in: [dynamodb/dynamodb.ts:
|
|
115
|
+
Defined in: [dynamodb/dynamodb.ts:247](https://github.com/aligent/microservice-development-utilities/blob/fd6cf9d0c7112a3e2feb0c83a6bedebeddcf46ed/packages/aws-wrappers/src/dynamodb/dynamodb.ts#L247)
|
|
112
116
|
|
|
113
117
|
Delete an item from DynamoDB. The `Attributes` field on the response is
|
|
114
118
|
typed as `R` — relevant when `ReturnValues: 'ALL_OLD'` is set.
|
|
@@ -145,7 +149,7 @@ Expected shape of the returned `Attributes`.
|
|
|
145
149
|
|
|
146
150
|
> **getItem**\<`K`, `R`\>(`input`): `Promise`\<`R` \| `undefined`\>
|
|
147
151
|
|
|
148
|
-
Defined in: [dynamodb/dynamodb.ts:
|
|
152
|
+
Defined in: [dynamodb/dynamodb.ts:181](https://github.com/aligent/microservice-development-utilities/blob/fd6cf9d0c7112a3e2feb0c83a6bedebeddcf46ed/packages/aws-wrappers/src/dynamodb/dynamodb.ts#L181)
|
|
149
153
|
|
|
150
154
|
Get an item from DynamoDB.
|
|
151
155
|
|
|
@@ -183,10 +187,31 @@ The item, or `undefined` if not found.
|
|
|
183
187
|
|
|
184
188
|
> **paginateItems**\<`T`\>(`input`): `AsyncGenerator`\<`T`\>
|
|
185
189
|
|
|
186
|
-
Defined in: [dynamodb/dynamodb.ts:
|
|
190
|
+
Defined in: [dynamodb/dynamodb.ts:384](https://github.com/aligent/microservice-development-utilities/blob/fd6cf9d0c7112a3e2feb0c83a6bedebeddcf46ed/packages/aws-wrappers/src/dynamodb/dynamodb.ts#L384)
|
|
187
191
|
|
|
188
192
|
Paginate over Query results, yielding one unmarshalled item at a time.
|
|
189
193
|
|
|
194
|
+
**`Limit` is a page size, not a total cap.** DynamoDB applies it per
|
|
195
|
+
request, and this method walks every page until `LastEvaluatedKey` is
|
|
196
|
+
exhausted — so `paginateItems({ Limit: 10 })` yields *every* matching
|
|
197
|
+
item, in pages of 10, not the first 10 items.
|
|
198
|
+
|
|
199
|
+
To bound the number of items, `break` out of the loop. This is an
|
|
200
|
+
`AsyncGenerator`, so `break` calls its `return()`, which unwinds the
|
|
201
|
+
pagination and issues no further requests:
|
|
202
|
+
|
|
203
|
+
```ts
|
|
204
|
+
const firstTen: Item[] = [];
|
|
205
|
+
for await (const item of ddb.paginateItems<Item>(input)) {
|
|
206
|
+
firstTen.push(item);
|
|
207
|
+
if (firstTen.length === 10) break;
|
|
208
|
+
}
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
`Limit` remains the right knob for tuning per-request consumed capacity
|
|
212
|
+
and page memory — set it deliberately, just don't expect it to stop the
|
|
213
|
+
walk.
|
|
214
|
+
|
|
190
215
|
#### Type Parameters
|
|
191
216
|
|
|
192
217
|
##### T
|
|
@@ -213,10 +238,14 @@ Expected shape of each yielded item.
|
|
|
213
238
|
|
|
214
239
|
> **paginateScan**\<`T`\>(`input`): `AsyncGenerator`\<`T`\>
|
|
215
240
|
|
|
216
|
-
Defined in: [dynamodb/dynamodb.ts:
|
|
241
|
+
Defined in: [dynamodb/dynamodb.ts:406](https://github.com/aligent/microservice-development-utilities/blob/fd6cf9d0c7112a3e2feb0c83a6bedebeddcf46ed/packages/aws-wrappers/src/dynamodb/dynamodb.ts#L406)
|
|
217
242
|
|
|
218
243
|
Paginate over Scan results, yielding one unmarshalled item at a time.
|
|
219
244
|
|
|
245
|
+
**`Limit` is a page size, not a total cap** — see `paginateItems` for the
|
|
246
|
+
detail. `break` out of the loop to bound the number of items; `Limit`
|
|
247
|
+
stays the right knob for per-request consumed capacity and page memory.
|
|
248
|
+
|
|
220
249
|
#### Type Parameters
|
|
221
250
|
|
|
222
251
|
##### T
|
|
@@ -243,7 +272,7 @@ Expected shape of each yielded item.
|
|
|
243
272
|
|
|
244
273
|
> **putItem**\<`T`\>(`input`): `Promise`\<`PutCommandOutput`\>
|
|
245
274
|
|
|
246
|
-
Defined in: [dynamodb/dynamodb.ts:
|
|
275
|
+
Defined in: [dynamodb/dynamodb.ts:201](https://github.com/aligent/microservice-development-utilities/blob/fd6cf9d0c7112a3e2feb0c83a6bedebeddcf46ed/packages/aws-wrappers/src/dynamodb/dynamodb.ts#L201)
|
|
247
276
|
|
|
248
277
|
Put an item into DynamoDB. The caller's `Item` is typed as `T`, which
|
|
249
278
|
the document client marshalls automatically.
|
|
@@ -274,7 +303,7 @@ Type of the item being stored.
|
|
|
274
303
|
|
|
275
304
|
> **query**\<`T`\>(`input`): `Promise`\<`Omit`\<`QueryCommandOutput`, `"Items"`\> & `object`\>
|
|
276
305
|
|
|
277
|
-
Defined in: [dynamodb/dynamodb.ts:
|
|
306
|
+
Defined in: [dynamodb/dynamodb.ts:270](https://github.com/aligent/microservice-development-utilities/blob/fd6cf9d0c7112a3e2feb0c83a6bedebeddcf46ed/packages/aws-wrappers/src/dynamodb/dynamodb.ts#L270)
|
|
278
307
|
|
|
279
308
|
Execute a DynamoDB Query. The full `QueryCommandOutput` is returned with
|
|
280
309
|
`Items` typed as `T[]` so callers retain pagination metadata
|
|
@@ -306,7 +335,7 @@ Expected shape of each unmarshalled item.
|
|
|
306
335
|
|
|
307
336
|
> **scan**\<`T`\>(`input`): `Promise`\<`Omit`\<`ScanCommandOutput`, `"Items"`\> & `object`\>
|
|
308
337
|
|
|
309
|
-
Defined in: [dynamodb/dynamodb.ts:
|
|
338
|
+
Defined in: [dynamodb/dynamodb.ts:299](https://github.com/aligent/microservice-development-utilities/blob/fd6cf9d0c7112a3e2feb0c83a6bedebeddcf46ed/packages/aws-wrappers/src/dynamodb/dynamodb.ts#L299)
|
|
310
339
|
|
|
311
340
|
Scan a DynamoDB table. The full `ScanCommandOutput` is returned with
|
|
312
341
|
`Items` typed as `T[]` so callers retain pagination metadata.
|
|
@@ -350,7 +379,7 @@ Expected shape of each unmarshalled item.
|
|
|
350
379
|
|
|
351
380
|
> **updateItem**\<`K`, `R`\>(`input`): `Promise`\<`Omit`\<`UpdateCommandOutput`, `"Attributes"`\> & `object`\>
|
|
352
381
|
|
|
353
|
-
Defined in: [dynamodb/dynamodb.ts:
|
|
382
|
+
Defined in: [dynamodb/dynamodb.ts:224](https://github.com/aligent/microservice-development-utilities/blob/fd6cf9d0c7112a3e2feb0c83a6bedebeddcf46ed/packages/aws-wrappers/src/dynamodb/dynamodb.ts#L224)
|
|
354
383
|
|
|
355
384
|
Update an item in DynamoDB. The `Attributes` field on the response is
|
|
356
385
|
typed as `R` — the caller should choose `R` to match their
|
|
@@ -6,11 +6,15 @@
|
|
|
6
6
|
|
|
7
7
|
# Class: S3Service
|
|
8
8
|
|
|
9
|
-
Defined in: [s3/s3.ts:
|
|
9
|
+
Defined in: [s3/s3.ts:70](https://github.com/aligent/microservice-development-utilities/blob/fd6cf9d0c7112a3e2feb0c83a6bedebeddcf46ed/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.
|
|
13
13
|
|
|
14
|
+
Where a method's input carries payloads, secret material or PII, the INFO
|
|
15
|
+
log line omits them; the verbose levels (`POWERTOOLS_LOG_LEVEL=DEBUG` or
|
|
16
|
+
`TRACE`) log full SDK inputs.
|
|
17
|
+
|
|
14
18
|
Input shapes are intentionally tight (Bucket/Key/Body only). Callers
|
|
15
19
|
needing SDK-level options not exposed here (server-side encryption,
|
|
16
20
|
tagging, version IDs) should use `S3Client` directly.
|
|
@@ -23,7 +27,7 @@ tagging, version IDs) should use `S3Client` directly.
|
|
|
23
27
|
|
|
24
28
|
> **new S3Service**(`opts?`): `S3Service`
|
|
25
29
|
|
|
26
|
-
Defined in: [s3/s3.ts:
|
|
30
|
+
Defined in: [s3/s3.ts:80](https://github.com/aligent/microservice-development-utilities/blob/fd6cf9d0c7112a3e2feb0c83a6bedebeddcf46ed/packages/aws-wrappers/src/s3/s3.ts#L80)
|
|
27
31
|
|
|
28
32
|
#### Parameters
|
|
29
33
|
|
|
@@ -55,7 +59,7 @@ which picks up `POWERTOOLS_SERVICE_NAME` from the environment.
|
|
|
55
59
|
|
|
56
60
|
> **copyObject**(`input`): `Promise`\<`CopyObjectCommandOutput`\>
|
|
57
61
|
|
|
58
|
-
Defined in: [s3/s3.ts:
|
|
62
|
+
Defined in: [s3/s3.ts:175](https://github.com/aligent/microservice-development-utilities/blob/fd6cf9d0c7112a3e2feb0c83a6bedebeddcf46ed/packages/aws-wrappers/src/s3/s3.ts#L175)
|
|
59
63
|
|
|
60
64
|
Copy an object within S3.
|
|
61
65
|
|
|
@@ -77,7 +81,7 @@ Copy an object within S3.
|
|
|
77
81
|
|
|
78
82
|
> **deleteObject**(`input`): `Promise`\<`DeleteObjectCommandOutput`\>
|
|
79
83
|
|
|
80
|
-
Defined in: [s3/s3.ts:
|
|
84
|
+
Defined in: [s3/s3.ts:268](https://github.com/aligent/microservice-development-utilities/blob/fd6cf9d0c7112a3e2feb0c83a6bedebeddcf46ed/packages/aws-wrappers/src/s3/s3.ts#L268)
|
|
81
85
|
|
|
82
86
|
Delete a single object from S3.
|
|
83
87
|
|
|
@@ -99,7 +103,7 @@ Delete a single object from S3.
|
|
|
99
103
|
|
|
100
104
|
> **deleteObjects**(`bucket`, `keys`): `Promise`\<`DeleteObjectsCommandOutput`[]\>
|
|
101
105
|
|
|
102
|
-
Defined in: [s3/s3.ts:
|
|
106
|
+
Defined in: [s3/s3.ts:280](https://github.com/aligent/microservice-development-utilities/blob/fd6cf9d0c7112a3e2feb0c83a6bedebeddcf46ed/packages/aws-wrappers/src/s3/s3.ts#L280)
|
|
103
107
|
|
|
104
108
|
Delete multiple objects from S3, auto-chunking the request into batches
|
|
105
109
|
of 1000 keys (the S3-enforced DeleteObjects limit). Returns one output
|
|
@@ -127,11 +131,21 @@ per chunk.
|
|
|
127
131
|
|
|
128
132
|
> **emptyBucket**(`bucket`): `Promise`\<`string`[]\>
|
|
129
133
|
|
|
130
|
-
Defined in: [s3/s3.ts:
|
|
134
|
+
Defined in: [s3/s3.ts:320](https://github.com/aligent/microservice-development-utilities/blob/fd6cf9d0c7112a3e2feb0c83a6bedebeddcf46ed/packages/aws-wrappers/src/s3/s3.ts#L320)
|
|
135
|
+
|
|
136
|
+
Delete every object in an **unversioned** bucket. Streams the listing
|
|
137
|
+
page-by-page and delegates each page's deletion to `deleteObjects`, so
|
|
138
|
+
peak memory stays bounded by one page (~1000 keys) regardless of bucket
|
|
139
|
+
size.
|
|
131
140
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
141
|
+
**Versioned buckets are out of scope.** This paginates `ListObjectsV2`,
|
|
142
|
+
which reports only current object versions — never noncurrent versions or
|
|
143
|
+
delete markers. Against a versioned bucket the call therefore succeeds and
|
|
144
|
+
the bucket then *looks* empty to `ListObjectsV2`, but the deletes only
|
|
145
|
+
added delete markers: every object version is still stored, still billed,
|
|
146
|
+
and `DeleteBucket` will still fail with `BucketNotEmpty`. Emptying a
|
|
147
|
+
versioned bucket requires `ListObjectVersions` and per-version deletes;
|
|
148
|
+
use `S3Client` directly for that.
|
|
135
149
|
|
|
136
150
|
#### Parameters
|
|
137
151
|
|
|
@@ -143,7 +157,7 @@ bounded by one page (~1000 keys) regardless of bucket size.
|
|
|
143
157
|
|
|
144
158
|
`Promise`\<`string`[]\>
|
|
145
159
|
|
|
146
|
-
The keys
|
|
160
|
+
The keys this call issued deletes for.
|
|
147
161
|
|
|
148
162
|
***
|
|
149
163
|
|
|
@@ -153,7 +167,7 @@ The keys of every deleted object.
|
|
|
153
167
|
|
|
154
168
|
> **getAllObjects**\<`T`\>(`bucket`, `prefix?`): `Promise`\<`T`[]\>
|
|
155
169
|
|
|
156
|
-
Defined in: [s3/s3.ts:
|
|
170
|
+
Defined in: [s3/s3.ts:206](https://github.com/aligent/microservice-development-utilities/blob/fd6cf9d0c7112a3e2feb0c83a6bedebeddcf46ed/packages/aws-wrappers/src/s3/s3.ts#L206)
|
|
157
171
|
|
|
158
172
|
List and JSON-parse every object under a bucket and optional prefix.
|
|
159
173
|
Auto-paginated. Objects without a body are skipped.
|
|
@@ -188,7 +202,7 @@ Expected type of each parsed object.
|
|
|
188
202
|
|
|
189
203
|
> **getJsonObject**\<`T`\>(`input`): `Promise`\<`T` \| `undefined`\>
|
|
190
204
|
|
|
191
|
-
Defined in: [s3/s3.ts:
|
|
205
|
+
Defined in: [s3/s3.ts:153](https://github.com/aligent/microservice-development-utilities/blob/fd6cf9d0c7112a3e2feb0c83a6bedebeddcf46ed/packages/aws-wrappers/src/s3/s3.ts#L153)
|
|
192
206
|
|
|
193
207
|
Get an object from S3 and parse it as JSON.
|
|
194
208
|
|
|
@@ -224,7 +238,7 @@ If the body is non-empty and not valid JSON.
|
|
|
224
238
|
|
|
225
239
|
> **getObject**(`input`): `Promise`\<`GetObjectCommandOutput`\>
|
|
226
240
|
|
|
227
|
-
Defined in: [s3/s3.ts:
|
|
241
|
+
Defined in: [s3/s3.ts:127](https://github.com/aligent/microservice-development-utilities/blob/fd6cf9d0c7112a3e2feb0c83a6bedebeddcf46ed/packages/aws-wrappers/src/s3/s3.ts#L127)
|
|
228
242
|
|
|
229
243
|
Get an object from S3.
|
|
230
244
|
|
|
@@ -246,7 +260,7 @@ Get an object from S3.
|
|
|
246
260
|
|
|
247
261
|
> **getObjectBody**(`input`): `Promise`\<`string` \| `undefined`\>
|
|
248
262
|
|
|
249
|
-
Defined in: [s3/s3.ts:
|
|
263
|
+
Defined in: [s3/s3.ts:139](https://github.com/aligent/microservice-development-utilities/blob/fd6cf9d0c7112a3e2feb0c83a6bedebeddcf46ed/packages/aws-wrappers/src/s3/s3.ts#L139)
|
|
250
264
|
|
|
251
265
|
Get an object from S3 and return its body as a string.
|
|
252
266
|
|
|
@@ -271,7 +285,7 @@ has no body.
|
|
|
271
285
|
|
|
272
286
|
> **getPresignedUrl**(`input`): `Promise`\<`string`\>
|
|
273
287
|
|
|
274
|
-
Defined in: [s3/s3.ts:
|
|
288
|
+
Defined in: [s3/s3.ts:244](https://github.com/aligent/microservice-development-utilities/blob/fd6cf9d0c7112a3e2feb0c83a6bedebeddcf46ed/packages/aws-wrappers/src/s3/s3.ts#L244)
|
|
275
289
|
|
|
276
290
|
Generate a presigned URL that callers can use to GET or PUT an S3 object
|
|
277
291
|
directly, without going through the wrapper. The signing happens against
|
|
@@ -325,7 +339,7 @@ The S3 object key.
|
|
|
325
339
|
|
|
326
340
|
> **headObject**(`input`): `Promise`\<`HeadObjectCommandOutput`\>
|
|
327
341
|
|
|
328
|
-
Defined in: [s3/s3.ts:
|
|
342
|
+
Defined in: [s3/s3.ts:165](https://github.com/aligent/microservice-development-utilities/blob/fd6cf9d0c7112a3e2feb0c83a6bedebeddcf46ed/packages/aws-wrappers/src/s3/s3.ts#L165)
|
|
329
343
|
|
|
330
344
|
Fetch the metadata for an S3 object without downloading its body.
|
|
331
345
|
|
|
@@ -347,7 +361,7 @@ Fetch the metadata for an S3 object without downloading its body.
|
|
|
347
361
|
|
|
348
362
|
> **listObjects**(`bucket`, `prefix?`): `Promise`\<`string`[]\>
|
|
349
363
|
|
|
350
|
-
Defined in: [s3/s3.ts:
|
|
364
|
+
Defined in: [s3/s3.ts:186](https://github.com/aligent/microservice-development-utilities/blob/fd6cf9d0c7112a3e2feb0c83a6bedebeddcf46ed/packages/aws-wrappers/src/s3/s3.ts#L186)
|
|
351
365
|
|
|
352
366
|
List object keys under a bucket and optional prefix, auto-paginating
|
|
353
367
|
across all pages.
|
|
@@ -374,7 +388,7 @@ across all pages.
|
|
|
374
388
|
|
|
375
389
|
> **putJsonObject**\<`T`\>(`input`): `Promise`\<`PutObjectCommandOutput`\>
|
|
376
390
|
|
|
377
|
-
Defined in: [s3/s3.ts:
|
|
391
|
+
Defined in: [s3/s3.ts:110](https://github.com/aligent/microservice-development-utilities/blob/fd6cf9d0c7112a3e2feb0c83a6bedebeddcf46ed/packages/aws-wrappers/src/s3/s3.ts#L110)
|
|
378
392
|
|
|
379
393
|
Serialise a value to JSON and store it as an S3 object.
|
|
380
394
|
|
|
@@ -408,7 +422,7 @@ Type of the value being stored.
|
|
|
408
422
|
|
|
409
423
|
> **putObject**(`input`): `Promise`\<`PutObjectCommandOutput`\>
|
|
410
424
|
|
|
411
|
-
Defined in: [s3/s3.ts:
|
|
425
|
+
Defined in: [s3/s3.ts:94](https://github.com/aligent/microservice-development-utilities/blob/fd6cf9d0c7112a3e2feb0c83a6bedebeddcf46ed/packages/aws-wrappers/src/s3/s3.ts#L94)
|
|
412
426
|
|
|
413
427
|
Put an object into S3.
|
|
414
428
|
|