@aligent/aws-wrappers 0.5.6 → 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.
Files changed (49) hide show
  1. package/README.md +21 -4
  2. package/cjs/index.cjs +192 -152
  3. package/cjs/package.json +14 -14
  4. package/cjs/src/dynamodb/dynamodb.d.ts.map +1 -1
  5. package/cjs/src/index.d.ts +1 -0
  6. package/cjs/src/index.d.ts.map +1 -1
  7. package/cjs/src/s3/s3.d.ts +26 -4
  8. package/cjs/src/s3/s3.d.ts.map +1 -1
  9. package/cjs/src/scheduler/scheduler.d.ts.map +1 -1
  10. package/cjs/src/sns/sns.d.ts +7 -0
  11. package/cjs/src/sns/sns.d.ts.map +1 -1
  12. package/cjs/src/sqs/sqs.d.ts +0 -7
  13. package/cjs/src/sqs/sqs.d.ts.map +1 -1
  14. package/cjs/src/util/batch-operation-error.d.ts +45 -5
  15. package/cjs/src/util/batch-operation-error.d.ts.map +1 -1
  16. package/cjs/src/util/redact.d.ts +17 -18
  17. package/cjs/src/util/redact.d.ts.map +1 -1
  18. package/docs/index/classes/APIGatewayService.md +6 -6
  19. package/docs/index/classes/APIGatewayV2Service.md +5 -5
  20. package/docs/index/classes/BatchOperationError.md +9 -6
  21. package/docs/index/classes/DynamoDBService.md +34 -12
  22. package/docs/index/classes/S3Service.md +42 -19
  23. package/docs/index/classes/SNSService.md +10 -4
  24. package/docs/index/classes/SQSService.md +7 -7
  25. package/docs/index/classes/SSMService.md +9 -7
  26. package/docs/index/classes/SchedulerService.md +11 -11
  27. package/docs/index/classes/SecretsManagerService.md +10 -8
  28. package/docs/index/classes/StepFunctionsService.md +6 -6
  29. package/docs/index/interfaces/BatchFailedEntry.md +5 -5
  30. package/docs/index/interfaces/EmptyBucketPageResult.md +23 -0
  31. package/docs/index/modules.md +1 -0
  32. package/docs/testing/testing/functions/createMockService.md +5 -1
  33. package/esm/index.mjs +192 -152
  34. package/esm/package.json +14 -14
  35. package/esm/src/dynamodb/dynamodb.d.ts.map +1 -1
  36. package/esm/src/index.d.ts +1 -0
  37. package/esm/src/index.d.ts.map +1 -1
  38. package/esm/src/s3/s3.d.ts +26 -4
  39. package/esm/src/s3/s3.d.ts.map +1 -1
  40. package/esm/src/scheduler/scheduler.d.ts.map +1 -1
  41. package/esm/src/sns/sns.d.ts +7 -0
  42. package/esm/src/sns/sns.d.ts.map +1 -1
  43. package/esm/src/sqs/sqs.d.ts +0 -7
  44. package/esm/src/sqs/sqs.d.ts.map +1 -1
  45. package/esm/src/util/batch-operation-error.d.ts +45 -5
  46. package/esm/src/util/batch-operation-error.d.ts.map +1 -1
  47. package/esm/src/util/redact.d.ts +17 -18
  48. package/esm/src/util/redact.d.ts.map +1 -1
  49. package/package.json +14 -14
package/README.md CHANGED
@@ -27,7 +27,7 @@ Every wrapper emits one `logger.info` line per SDK call with a per-method safe-f
27
27
 
28
28
  ### Batch semantics
29
29
 
30
- Batch methods split your entries into chunks of the size the AWS API allows and send one request per chunk. AWS reports rejected entries inside an otherwise successful response, so a resolved request does not mean every entry was accepted. Currently covered: `SQSService.sendMessageBatch` and `SQSService.deleteMessageBatch`.
30
+ Batch methods split your entries into chunks of the size the AWS API allows and send one request per chunk. AWS reports rejected entries inside an otherwise successful response, so a resolved request does not mean every entry was accepted. Currently covered: `SQSService.sendMessageBatch`, `SQSService.deleteMessageBatch`, `SNSService.publishBatch`, `S3Service.deleteObjects` and `S3Service.emptyBucket`.
31
31
 
32
32
  Every chunk is sent first. If any entry was rejected, the method then throws a single `BatchOperationError`. A call where nothing was rejected returns the per-chunk SDK outputs exactly as before.
33
33
 
@@ -48,7 +48,7 @@ try {
48
48
  }
49
49
  ```
50
50
 
51
- - `failed` carries only the entry identifier, error code and message — never message bodies, attributes or any other payload.
51
+ - `failed` carries only the entry identifier, error code and message — never message bodies, attributes or any other payload. For S3 the identifier is the object key.
52
52
  - The error has a stable `name` of `'BatchOperationError'`. If both the CJS and ESM builds of this package can be loaded in one process, check `error.name` instead of `instanceof`.
53
53
  - A warning is logged with the failure count and error codes, and no payload, at every log level.
54
54
  - Request-level SDK exceptions (throttling, access denied, network errors) are **not** wrapped. They propagate unchanged and immediately, so earlier chunks may already have been sent and the caller cannot tell which. Treat those as "outcome unknown" and make the operation safe to repeat.
@@ -104,9 +104,25 @@ await s3.deleteObjects('my-bucket', ['key1', 'key2']); // auto-chunked to 1000 k
104
104
  await s3.emptyBucket('my-bucket'); // unversioned buckets only — see below
105
105
  ```
106
106
 
107
+ `deleteObjects` and `emptyBucket` throw a `BatchOperationError` when S3 reports that it could not delete one or more keys — see "Batch semantics". `failed[].id` is the object key.
108
+
109
+ `emptyBucket` returns only the keys that were actually deleted. A page with failures does not stop the run: every page is attempted, then one aggregated `BatchOperationError` is thrown. Its `results` hold one `{ deletedKeys }` per page, so the caller can tell which keys were deleted and which failed:
110
+
111
+ ```ts
112
+ try {
113
+ const deleted = await s3.emptyBucket('my-bucket');
114
+ } catch (error) {
115
+ if (error instanceof BatchOperationError) {
116
+ const deleted = error.results.flatMap(page => page.deletedKeys);
117
+ const stuck = error.failed.map(entry => entry.id); // [{ id: key, code, message }]
118
+ }
119
+ throw error;
120
+ }
121
+ ```
122
+
107
123
  Input shapes are intentionally tight (`Bucket`, `Key`, `Body` and similar). Callers needing SDK-specific options like server-side encryption or tagging should use `S3Client` directly.
108
124
 
109
- `emptyBucket` streams the listing page-by-page and delegates each page to `deleteObjects`, so peak memory stays bounded by one page regardless of bucket size. It empties **unversioned buckets only**: it paginates `ListObjectsV2`, which reports current object versions and never noncurrent versions or delete markers. Against a versioned bucket the call succeeds and the bucket then *looks* empty to `ListObjectsV2` — but the deletes only added delete markers, so every object version is still stored. You will still be billed for that storage, and `DeleteBucket` will fail with `BucketNotEmpty`. Emptying a versioned bucket needs `ListObjectVersions` plus per-version deletes — use `S3Client` directly.
125
+ `emptyBucket` streams the listing page-by-page and delegates each page to `deleteObjects`, so only one page of SDK responses is held at a time; the list of deleted keys it returns is the one thing that grows with the bucket. It empties **unversioned buckets only**: it paginates `ListObjectsV2`, which reports current object versions and never noncurrent versions or delete markers. Against a versioned bucket the call succeeds and the bucket then *looks* empty to `ListObjectsV2` — but the deletes only added delete markers, so every object version is still stored. You will still be billed for that storage, and `DeleteBucket` will fail with `BucketNotEmpty`. Emptying a versioned bucket needs `ListObjectVersions` plus per-version deletes — use `S3Client` directly.
110
126
 
111
127
  ## DynamoDB
112
128
 
@@ -372,7 +388,8 @@ const sns = new SNSService();
372
388
 
373
389
  await sns.publish({ TopicArn, Message: 'hello' });
374
390
 
375
- // publishBatch auto-chunks PublishBatchRequestEntries to the SNS-enforced 10-entry limit.
391
+ // publishBatch auto-chunks PublishBatchRequestEntries to the SNS-enforced 10-entry limit
392
+ // and throws a BatchOperationError if SNS rejects any entry — see "Batch semantics".
376
393
  await sns.publishBatch({ TopicArn, PublishBatchRequestEntries: bigEntryList });
377
394
 
378
395
  // Opt-in truncation — same shape as SQS. Truncates Message (256 KB byte-safe)