@jzhuo3/dynamodb-lib 0.1.0 → 0.1.1
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/PUBLISHING.md +9 -1
- package/dist/cjs/index.js +58 -102
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +58 -102
- package/dist/esm/index.js.map +1 -1
- package/doc/service.md +36 -0
- package/package.json +4 -3
package/doc/service.md
CHANGED
|
@@ -192,3 +192,39 @@ db.destroy();
|
|
|
192
192
|
```
|
|
193
193
|
|
|
194
194
|
In Lambda, keep the service outside the handler and reuse it across invocations. Calling `destroy` at the end of every handler invocation prevents connection reuse.
|
|
195
|
+
|
|
196
|
+
## Logging
|
|
197
|
+
|
|
198
|
+
Pass a logger implementing `debug(message, ...meta)`, `warn(message, ...meta)`, and `error(message, ...meta)`. Logging is silent when no logger is supplied. Messages use a readable string followed by a structured metadata object; Winston does not need interpolation formatting to display them.
|
|
199
|
+
|
|
200
|
+
- **Debug:** individual requests and their outcomes, batch sizes and completion counts, query pages and whether more pages exist, transaction start/completion, and expected conditional write skips. Batch read completion counts exclude missing and expired items; query page counts describe the DynamoDB response before local TTL filtering.
|
|
201
|
+
- **Warn:** retrying unprocessed batch items or transaction conflicts, including attempt and delay in milliseconds; LSI projections that may incur additional reads.
|
|
202
|
+
- **Error:** failed requests, invalid GSI projections, and exhausted batch or transaction retries. SDK errors retain their original cause for the caller; logs include the error name instead of the raw error message.
|
|
203
|
+
|
|
204
|
+
Logs omit primary key values, item contents, expression text and bindings, cursors, credentials, and raw request options. Metadata can include your configured table alias (`tableKey`) and index names, so choose aliases appropriate for your logging environment. Expected missing/expired records and unmet write conditions are not warnings.
|
|
205
|
+
|
|
206
|
+
For example, an unprocessed batch produces:
|
|
207
|
+
|
|
208
|
+
```ts
|
|
209
|
+
logger.warn('DynamoDB retrying unprocessed batch items', {
|
|
210
|
+
operation: 'getMany',
|
|
211
|
+
tableKey: 'items',
|
|
212
|
+
itemCount: 2,
|
|
213
|
+
attempt: 1,
|
|
214
|
+
delayMs: 50, // Actual delay includes backoff jitter.
|
|
215
|
+
});
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
Retry warnings describe retries performed by this library, not retries internal to the AWS SDK. Debug messages are diagnostic output, not a stable audit-event API.
|
|
219
|
+
|
|
220
|
+
### Testing with Winston
|
|
221
|
+
|
|
222
|
+
The integration suite injects a real Winston logger with a JSON console transport. Winston is a development dependency only; consumers still choose their own logger. Debug output is enabled by default so you can see requests, pagination, and outcomes while testing:
|
|
223
|
+
|
|
224
|
+
```sh
|
|
225
|
+
npm run test:integration
|
|
226
|
+
npm run test:integration -- --log-level warn
|
|
227
|
+
DYNAMODB_TEST_LOG_LEVEL=error npm run test:integration
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
`--log-level` overrides `DYNAMODB_TEST_LOG_LEVEL`. Supported levels are Winston's standard npm levels: `error`, `warn`, `info`, `http`, `verbose`, `debug`, and `silly`. The unit suite also sends library events through a real Winston JSON stream transport and checks debug/warn/error metadata and payload omission; other unit tests retain spies for precise assertions.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jzhuo3/dynamodb-lib",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Framework-independent DynamoDB document service and expression builders",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "jzhuo3",
|
|
@@ -55,7 +55,8 @@
|
|
|
55
55
|
"@types/node": "^22.19.0",
|
|
56
56
|
"@vitest/coverage-v8": "4.1.11",
|
|
57
57
|
"typescript": "~5.9.3",
|
|
58
|
-
"vitest": "4.1.11"
|
|
58
|
+
"vitest": "4.1.11",
|
|
59
|
+
"winston": "3.19.0"
|
|
59
60
|
},
|
|
60
61
|
"overrides": {
|
|
61
62
|
"fast-xml-parser": "5.7.1",
|
|
@@ -73,4 +74,4 @@
|
|
|
73
74
|
"bugs": {
|
|
74
75
|
"url": "https://github.com/maczhuo/dynamodb-lib/issues"
|
|
75
76
|
}
|
|
76
|
-
}
|
|
77
|
+
}
|