@aligent/aws-wrappers 0.3.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 CHANGED
@@ -8,6 +8,8 @@ Opinionated AWS SDK wrappers with Powertools logging and X-Ray tracing baked in.
8
8
  npm install @aligent/aws-wrappers
9
9
  ```
10
10
 
11
+ Requires **Node 18 or later**. The package is compiled to ES2022 and ships native `class` declarations, so older runtimes fail at import time with a syntax error rather than degrading gracefully.
12
+
11
13
  ## Conventions
12
14
 
13
15
  Every wrapper takes the same optional constructor options:
@@ -71,11 +73,13 @@ const uploadUrl = await s3.getPresignedUrl({
71
73
 
72
74
  await s3.deleteObject({ Bucket: 'my-bucket', Key: 'file.txt' });
73
75
  await s3.deleteObjects('my-bucket', ['key1', 'key2']); // auto-chunked to 1000 keys per request
74
- await s3.emptyBucket('my-bucket'); // streams the listing + delegates each page to deleteObjects
76
+ await s3.emptyBucket('my-bucket'); // unversioned buckets only — see below
75
77
  ```
76
78
 
77
79
  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.
78
80
 
81
+ `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.
82
+
79
83
  ## DynamoDB
80
84
 
81
85
  ```ts
@@ -138,8 +142,23 @@ for await (const item of ddb.paginateItems<{ pk: string }>({
138
142
  for await (const item of ddb.paginateScan<{ pk: string }>({ TableName: 'my-table' })) {
139
143
  console.log(item.pk);
140
144
  }
145
+
146
+ // `Limit` is a PAGE SIZE, not a total cap — this walks the whole result set
147
+ // in pages of 10, it does not stop after 10 items. `break` to bound the read.
148
+ const firstTen: Array<{ pk: string }> = [];
149
+ for await (const item of ddb.paginateItems<{ pk: string }>({
150
+ TableName: 'my-table',
151
+ KeyConditionExpression: 'pk = :pk',
152
+ ExpressionAttributeValues: { ':pk': 'abc' },
153
+ Limit: 10,
154
+ })) {
155
+ firstTen.push(item);
156
+ if (firstTen.length === 10) break; // stops immediately — no further requests
157
+ }
141
158
  ```
142
159
 
160
+ `Limit` on `paginateItems` / `paginateScan` is applied by DynamoDB per request, and both methods walk every page until `LastEvaluatedKey` is exhausted. Passing `Limit: 10` therefore yields *every* matching item in pages of 10, not the first 10. Because both return an `AsyncGenerator`, `break` calls its `return()`, which unwinds the pagination and issues no further requests — that is how you bound the number of items. `Limit` is still the right knob for tuning per-request consumed capacity and page memory; it just doesn't stop the walk.
161
+
143
162
  `batchGet` is **not** generic — its `Responses` field is a multi-table record whose item shapes can differ per table, so no single generic can soundly describe it. Callers should narrow the result type at the call site.
144
163
 
145
164
  ## Secrets Manager