@aligent/aws-wrappers 0.5.7 → 0.5.8
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 +19 -3
- package/cjs/index.cjs +115 -61
- package/cjs/package.json +14 -14
- package/cjs/src/index.d.ts +1 -0
- package/cjs/src/index.d.ts.map +1 -1
- package/cjs/src/s3/s3.d.ts +26 -4
- package/cjs/src/s3/s3.d.ts.map +1 -1
- package/cjs/src/util/batch-operation-error.d.ts +25 -2
- package/cjs/src/util/batch-operation-error.d.ts.map +1 -1
- package/docs/index/classes/APIGatewayService.md +6 -6
- package/docs/index/classes/APIGatewayV2Service.md +5 -5
- package/docs/index/classes/BatchOperationError.md +9 -6
- package/docs/index/classes/DynamoDBService.md +34 -12
- package/docs/index/classes/S3Service.md +42 -19
- package/docs/index/classes/SNSService.md +4 -4
- package/docs/index/classes/SQSService.md +7 -7
- package/docs/index/classes/SSMService.md +9 -7
- package/docs/index/classes/SchedulerService.md +11 -11
- package/docs/index/classes/SecretsManagerService.md +10 -8
- package/docs/index/classes/StepFunctionsService.md +6 -6
- package/docs/index/interfaces/BatchFailedEntry.md +5 -5
- package/docs/index/interfaces/EmptyBucketPageResult.md +23 -0
- package/docs/index/modules.md +1 -0
- package/docs/testing/testing/functions/createMockService.md +5 -1
- package/esm/index.mjs +115 -61
- package/esm/package.json +14 -14
- package/esm/src/index.d.ts +1 -0
- package/esm/src/index.d.ts.map +1 -1
- package/esm/src/s3/s3.d.ts +26 -4
- package/esm/src/s3/s3.d.ts.map +1 -1
- package/esm/src/util/batch-operation-error.d.ts +25 -2
- package/esm/src/util/batch-operation-error.d.ts.map +1 -1
- package/package.json +14 -14
package/esm/src/s3/s3.d.ts
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import type { LoggerInterface } from '@aws-lambda-powertools/logger/types';
|
|
2
2
|
import { CopyObjectCommandInput, CopyObjectCommandOutput, DeleteObjectCommandInput, DeleteObjectCommandOutput, DeleteObjectsCommandOutput, GetObjectCommandInput, GetObjectCommandOutput, HeadObjectCommandInput, HeadObjectCommandOutput, PutObjectCommandInput, PutObjectCommandOutput, S3Client } from '@aws-sdk/client-s3';
|
|
3
|
+
/**
|
|
4
|
+
* One page of an `emptyBucket` run, as carried in `BatchOperationError.results`.
|
|
5
|
+
*/
|
|
6
|
+
export interface EmptyBucketPageResult {
|
|
7
|
+
/** The keys of this page that S3 deleted. */
|
|
8
|
+
deletedKeys: string[];
|
|
9
|
+
}
|
|
3
10
|
/** Tight wrapper input type for `putObject`. */
|
|
4
11
|
type PutObjectInput = Required<Pick<PutObjectCommandInput, 'Bucket' | 'Key' | 'Body'>>;
|
|
5
12
|
/** Tight wrapper input type for `putJsonObject`. */
|
|
@@ -122,13 +129,26 @@ export declare class S3Service {
|
|
|
122
129
|
* Delete multiple objects from S3, auto-chunking the request into batches
|
|
123
130
|
* of 1000 keys (the S3-enforced DeleteObjects limit). Returns one output
|
|
124
131
|
* per chunk.
|
|
132
|
+
*
|
|
133
|
+
* Every chunk is sent before the outcome is judged. If S3 reported a
|
|
134
|
+
* per-key delete error, a {@link BatchOperationError} is then thrown
|
|
135
|
+
* carrying the per-chunk results and the failed keys. Request-level SDK
|
|
136
|
+
* exceptions (throttling, access denied) propagate unchanged and
|
|
137
|
+
* immediately, so earlier chunks may already have been deleted.
|
|
125
138
|
*/
|
|
126
139
|
deleteObjects(bucket: string, keys: string[]): Promise<DeleteObjectsCommandOutput[]>;
|
|
127
140
|
/**
|
|
128
141
|
* Delete every object in an **unversioned** bucket. Streams the listing
|
|
129
|
-
* page-by-page and delegates each page's deletion to `deleteObjects`, so
|
|
130
|
-
*
|
|
131
|
-
*
|
|
142
|
+
* page-by-page and delegates each page's deletion to `deleteObjects`, so no
|
|
143
|
+
* more than one page (~1000 keys) of SDK responses is held at a time. The
|
|
144
|
+
* only thing that grows with the bucket is the list of deleted keys this
|
|
145
|
+
* method returns.
|
|
146
|
+
*
|
|
147
|
+
* A page with per-key delete errors does not stop the run: every page is
|
|
148
|
+
* attempted, then one {@link BatchOperationError} is thrown carrying every
|
|
149
|
+
* failed key in `failed` and, per page, the keys that were deleted in
|
|
150
|
+
* `results`. Request-level SDK exceptions propagate unchanged and
|
|
151
|
+
* immediately, so earlier pages may already have been deleted.
|
|
132
152
|
*
|
|
133
153
|
* **Versioned buckets are out of scope.** This paginates `ListObjectsV2`,
|
|
134
154
|
* which reports only current object versions — never noncurrent versions or
|
|
@@ -139,9 +159,11 @@ export declare class S3Service {
|
|
|
139
159
|
* versioned bucket requires `ListObjectVersions` and per-version deletes;
|
|
140
160
|
* use `S3Client` directly for that.
|
|
141
161
|
*
|
|
142
|
-
* @returns The keys
|
|
162
|
+
* @returns The keys that were deleted.
|
|
163
|
+
* @throws {BatchOperationError} If S3 could not delete one or more keys.
|
|
143
164
|
*/
|
|
144
165
|
emptyBucket(bucket: string): Promise<string[]>;
|
|
166
|
+
private deletePage;
|
|
145
167
|
}
|
|
146
168
|
export {};
|
|
147
169
|
//# sourceMappingURL=s3.d.ts.map
|
package/esm/src/s3/s3.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"s3.d.ts","sourceRoot":"","sources":["../../../../src/s3/s3.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAC3E,OAAO,EAEH,sBAAsB,EACtB,uBAAuB,EAEvB,wBAAwB,EACxB,yBAAyB,EAEzB,0BAA0B,EAE1B,qBAAqB,EACrB,sBAAsB,EAEtB,sBAAsB,EACtB,uBAAuB,EAGvB,qBAAqB,EACrB,sBAAsB,EACtB,QAAQ,EACX,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"s3.d.ts","sourceRoot":"","sources":["../../../../src/s3/s3.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAC3E,OAAO,EAEH,sBAAsB,EACtB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,CAAC,CAAC,GAClE,OAAO,CAAC,yBAAyB,CAAC;IAKrC;;;;;;;;;;OAUG;IACG,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,0BAA0B,EAAE,CAAC;IAqB1F;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACG,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;YAgBtC,UAAU;CAgB3B"}
|
|
@@ -2,7 +2,7 @@ import type { LoggerInterface } from '@aws-lambda-powertools/logger/types';
|
|
|
2
2
|
/**
|
|
3
3
|
* One entry a batch operation rejected. Deliberately limited to identifier,
|
|
4
4
|
* code and message so the error never carries message bodies, attributes or
|
|
5
|
-
* any other payload the caller sent.
|
|
5
|
+
* any other payload the caller sent. For S3 the identifier is the object key.
|
|
6
6
|
*/
|
|
7
7
|
export interface BatchFailedEntry {
|
|
8
8
|
id: string | undefined;
|
|
@@ -14,7 +14,8 @@ export interface BatchFailedEntry {
|
|
|
14
14
|
* entry was rejected.
|
|
15
15
|
*
|
|
16
16
|
* `results` holds the raw SDK output of every chunk, so the outputs of the
|
|
17
|
-
* entries that succeeded (message ids, sequence numbers) stay readable.
|
|
17
|
+
* entries that succeeded (message ids, sequence numbers) stay readable. The
|
|
18
|
+
* one exception is `S3.emptyBucket`, whose `results` are per-page deleted keys.
|
|
18
19
|
* `failed` is the normalised list of rejected entries across all chunks.
|
|
19
20
|
*
|
|
20
21
|
* Match on `name` rather than `instanceof` if both the CJS and ESM builds of
|
|
@@ -46,5 +47,27 @@ interface RejectedEntry {
|
|
|
46
47
|
export declare function throwIfAnyFailed<TResult extends {
|
|
47
48
|
Failed?: RejectedEntry[] | undefined;
|
|
48
49
|
}>(logger: LoggerInterface, operation: string, results: TResult[]): TResult[];
|
|
50
|
+
/**
|
|
51
|
+
* The shape S3 `DeleteObjects` uses for a key it could not delete.
|
|
52
|
+
*/
|
|
53
|
+
interface DeleteError {
|
|
54
|
+
Key?: string | undefined;
|
|
55
|
+
Code?: string | undefined;
|
|
56
|
+
Message?: string | undefined;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* S3 reports undeleted keys under `Errors` on an otherwise successful
|
|
60
|
+
* `DeleteObjects` response. Same contract as {@link throwIfAnyFailed}; the
|
|
61
|
+
* key is carried as the failed entry's `id`, and `VersionId` is dropped.
|
|
62
|
+
*/
|
|
63
|
+
export declare function throwIfAnyDeleteErrors<TResult extends {
|
|
64
|
+
Errors?: DeleteError[] | undefined;
|
|
65
|
+
}>(logger: LoggerInterface, operation: string, results: TResult[]): TResult[];
|
|
66
|
+
/**
|
|
67
|
+
* Throws a {@link BatchOperationError} for operations whose `results` aren't a
|
|
68
|
+
* plain list of SDK outputs, such as `S3.emptyBucket`. Returns `results`
|
|
69
|
+
* untouched when `failed` is empty.
|
|
70
|
+
*/
|
|
71
|
+
export declare function throwIfAny<TResult>(logger: LoggerInterface, operation: string, results: TResult[], failed: BatchFailedEntry[]): TResult[];
|
|
49
72
|
export {};
|
|
50
73
|
//# sourceMappingURL=batch-operation-error.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"batch-operation-error.d.ts","sourceRoot":"","sources":["../../../../src/util/batch-operation-error.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAE3E;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC7B,EAAE,EAAE,MAAM,GAAG,SAAS,CAAC;IACvB,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;CAC/B;AAED
|
|
1
|
+
{"version":3,"file":"batch-operation-error.d.ts","sourceRoot":"","sources":["../../../../src/util/batch-operation-error.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAE3E;;;;GAIG;AACH,M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ED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAC9B,MAAM,EAAE,eAAe,EACvB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,OAAO,EAAE,EAClB,MAAM,EAAE,gBAAgB,EAAE,GAC3B,OAAO,EAAE,CAQX"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aligent/aws-wrappers",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.8",
|
|
4
4
|
"description": "Opinionated AWS SDK wrappers with Powertools logging and X-Ray tracing",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=18"
|
|
@@ -43,19 +43,19 @@
|
|
|
43
43
|
"directory": "packages/aws-wrappers"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@aws-lambda-powertools/logger": "^2.
|
|
47
|
-
"@aws-sdk/client-api-gateway": "^3.
|
|
48
|
-
"@aws-sdk/client-apigatewayv2": "^3.
|
|
49
|
-
"@aws-sdk/client-dynamodb": "^3.
|
|
50
|
-
"@aws-sdk/client-s3": "^3.
|
|
51
|
-
"@aws-sdk/client-scheduler": "^3.
|
|
52
|
-
"@aws-sdk/client-secrets-manager": "^3.
|
|
53
|
-
"@aws-sdk/client-sfn": "^3.
|
|
54
|
-
"@aws-sdk/client-sns": "^3.
|
|
55
|
-
"@aws-sdk/client-sqs": "^3.
|
|
56
|
-
"@aws-sdk/client-ssm": "^3.
|
|
57
|
-
"@aws-sdk/lib-dynamodb": "^3.
|
|
58
|
-
"@aws-sdk/s3-request-presigner": "^3.
|
|
46
|
+
"@aws-lambda-powertools/logger": "^2.36.0",
|
|
47
|
+
"@aws-sdk/client-api-gateway": "^3.1160.0",
|
|
48
|
+
"@aws-sdk/client-apigatewayv2": "^3.1160.0",
|
|
49
|
+
"@aws-sdk/client-dynamodb": "^3.1160.0",
|
|
50
|
+
"@aws-sdk/client-s3": "^3.1160.0",
|
|
51
|
+
"@aws-sdk/client-scheduler": "^3.1160.0",
|
|
52
|
+
"@aws-sdk/client-secrets-manager": "^3.1160.0",
|
|
53
|
+
"@aws-sdk/client-sfn": "^3.1160.0",
|
|
54
|
+
"@aws-sdk/client-sns": "^3.1160.0",
|
|
55
|
+
"@aws-sdk/client-sqs": "^3.1160.0",
|
|
56
|
+
"@aws-sdk/client-ssm": "^3.1160.0",
|
|
57
|
+
"@aws-sdk/lib-dynamodb": "^3.1160.0",
|
|
58
|
+
"@aws-sdk/s3-request-presigner": "^3.1160.0",
|
|
59
59
|
"aws-xray-sdk-core": "^3.12.0"
|
|
60
60
|
},
|
|
61
61
|
"author": "Aligent",
|