@crvouga/mockingbird-service-dynamodb 0.1.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/CHANGELOG.md +5 -0
- package/README.md +56 -0
- package/dist/chunk-CR54OR5S.js +2709 -0
- package/dist/chunk-CR54OR5S.js.map +7 -0
- package/dist/chunk-TCM6WKQB.js +330 -0
- package/dist/chunk-TCM6WKQB.js.map +7 -0
- package/dist/cli.js +19 -0
- package/dist/cli.js.map +7 -0
- package/dist/index.d.ts +895 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +7 -0
- package/dist/server.d.ts +1243 -0
- package/dist/server.js +12 -0
- package/dist/server.js.map +7 -0
- package/package.json +85 -0
package/CHANGELOG.md
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# @crvouga/mockingbird-service-dynamodb
|
|
2
|
+
|
|
3
|
+
Stateful, portable Amazon DynamoDB mock for the AWS SDK v3 low-level client and `DynamoDBDocumentClient`. It preserves DynamoDB attribute types while modelling CRUD, expressions, indexes, pagination, batches, transactions, TTL, streams, and conditional writes without contacting AWS.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -D @crvouga/mockingbird-service-dynamodb
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
ESM only. Node 22+ or Bun 1.2+.
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
Point the SDK's `endpoint` option at the mock. Fixture SigV4 credentials are accepted.
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import { createServer } from "@crvouga/mockingbird-service-dynamodb/server"
|
|
19
|
+
|
|
20
|
+
const mock = await createServer({
|
|
21
|
+
tables: [
|
|
22
|
+
{
|
|
23
|
+
name: "records",
|
|
24
|
+
keySchema: [{ AttributeName: "pk", KeyType: "HASH" }],
|
|
25
|
+
items: [{ pk: { S: "fixture" }, status: { S: "ready" } }],
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
})
|
|
29
|
+
const health = await fetch(`${mock.url}/health`)
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Supported operations are CreateTable, DescribeTable, GetItem, PutItem, UpdateItem, DeleteItem, Query, Scan, BatchGetItem, BatchWriteItem, TransactGetItems, and TransactWriteItems. The expression subset includes expression name/value aliases, SET/ADD/REMOVE/DELETE, `if_not_exists`, `attribute_exists`, `attribute_not_exists`, `begins_with`, comparisons, BETWEEN, AND/OR, projection, conditions, limits, cursors, index ordering, and return values.
|
|
33
|
+
|
|
34
|
+
### Admin and deterministic controls
|
|
35
|
+
|
|
36
|
+
- Constructor fixtures define tables, indexes, typed items, and TTL attributes.
|
|
37
|
+
- `GET /__admin/tables`, `/__admin/items?table=…`, and `/__admin/streams?table=…` inspect local state and ordered INSERT/MODIFY/REMOVE records.
|
|
38
|
+
- Advance the shared mock clock to expire TTL items without sleeps.
|
|
39
|
+
- Fault presets are `throttled` and one-shot `unavailable`; generic fault rules can model unprocessed batch responses or eventual-read failures.
|
|
40
|
+
|
|
41
|
+
The shared runtime also provides reset, timeline, request journal, metrics, faults, and namespace isolation through `x-mockingbird-namespace`, `/ns/<name>`, or SigV4 access-key mappings.
|
|
42
|
+
|
|
43
|
+
### Deliberately not modelled
|
|
44
|
+
|
|
45
|
+
PartiQL, control-plane operations outside Create/Describe, local/global table replication, IAM policy evaluation, encryption, backups, production capacity accounting, all DynamoDB expression grammar, real asynchronous streams, dashboards, and billing are not modelled.
|
|
46
|
+
|
|
47
|
+
## API
|
|
48
|
+
|
|
49
|
+
- `DynamoAPI`, `DynamoAPIOptions`, `DynamoSeedTable`: portable AWS JSON handler and fixtures.
|
|
50
|
+
- `AttributeValue`, `Item`, `KeySchemaElement`, `DynamoIndex`, `DynamoItem`, `DynamoTable`, `StreamRecord`: typed state.
|
|
51
|
+
- `createRuntime`, `DynamoRuntime`, `DynamoRuntimeOptions`: full Mockingbird runtime.
|
|
52
|
+
- `DYNAMODB_NAMESPACE`, `DYNAMODB_PRESETS`, `accessKeyCredential`: constants and controls.
|
|
53
|
+
- `document`, `operationIds`, `supportedOperationIds`: generated OpenAPI metadata.
|
|
54
|
+
- `createServer`, `DynamoServerOptions`, `DEFAULT_PORT`, `serveTarget` from `./server`: Node HTTP adapter and CLI integration.
|
|
55
|
+
|
|
56
|
+
Official oracle: [Amazon DynamoDB API Reference](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/Welcome.html).
|