@crvouga/mockingbird-service-dynamodb 1.7.1 → 2.0.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/dist/cli.js CHANGED
@@ -3,8 +3,8 @@ import {
3
3
  runCli,
4
4
  serveCommand,
5
5
  serveTarget
6
- } from "./chunk-G5RO7ZQT.js";
7
- import "./chunk-72UG3JD2.js";
6
+ } from "./chunk-7EYNBJ7R.js";
7
+ import "./chunk-D6QJOV4D.js";
8
8
 
9
9
  // src/cli.ts
10
10
  var code = await runCli(
package/dist/index.d.ts CHANGED
@@ -207,6 +207,15 @@ type FaultCandidate = {
207
207
  namespace: string;
208
208
  };
209
209
  type FaultRegistry = {
210
+ isolateNamespaces(): void;
211
+ snapshot(namespace: string): {
212
+ rules: (FaultRule & {
213
+ remaining: number | null;
214
+ hits: number;
215
+ position: number;
216
+ })[];
217
+ rngState: number;
218
+ };
210
219
  add(rule: FaultRule): FaultRule;
211
220
  list(): (FaultRule & {
212
221
  remaining: number | null;
@@ -214,6 +223,14 @@ type FaultRegistry = {
214
223
  })[];
215
224
  remove(id: string): boolean;
216
225
  clear(): void;
226
+ restore(namespace: string, state: {
227
+ rules: (FaultRule & {
228
+ remaining: number | null;
229
+ hits: number;
230
+ position: number;
231
+ })[];
232
+ rngState: number;
233
+ }): void;
217
234
  /**
218
235
  * Every fault this request should get, in rule order, stopping at the first that answers
219
236
  * or drops (effect-only and delay-only rules let later rules match too). Consumes one of
@@ -391,8 +408,8 @@ type MetricsReport = {
391
408
  };
392
409
  type Metrics = {
393
410
  record(entry: RequestLog): void;
394
- report(): MetricsReport;
395
- reset(): void;
411
+ report(namespace?: string): MetricsReport;
412
+ reset(namespace?: string): void;
396
413
  };
397
414
 
398
415
  /** One journal entry: a request log stamped with when (on the mock clock) it was handled. */
@@ -558,6 +575,9 @@ type PublishInput = {
558
575
  id?: string;
559
576
  };
560
577
  type WebhookHub = {
578
+ pending(namespace: string): number;
579
+ snapshot(namespace: string): unknown;
580
+ restore(namespace: string, snapshot: unknown): void;
561
581
  publish(input: PublishInput): WebhookMessage;
562
582
  /** Replace a namespace's own endpoints (`PUT /__admin/webhook-endpoints`). */
563
583
  setEndpoints(namespace: string, endpoints: WebhookEndpoint[]): WebhookEndpoint[];
@@ -585,6 +605,8 @@ type ServiceTimelineState = Readonly<{
585
605
  }>;
586
606
  type ServiceCheckpoint = Checkpoint<ServiceTimelineState>;
587
607
  type ServiceRuntime<T extends ServiceInstance> = FetchAPI & {
608
+ /** Stop package-owned lifecycle timers when a supervisor closes the runtime. */
609
+ stop?(): void;
588
610
  readonly name: string;
589
611
  readonly sqlite: SqliteClient$1;
590
612
  readonly clock: Clock;
@@ -595,6 +617,13 @@ type ServiceRuntime<T extends ServiceInstance> = FetchAPI & {
595
617
  readonly credentials: CredentialRegistry;
596
618
  /** The webhook hub, when the service has outbound webhooks. */
597
619
  readonly webhooks: WebhookHub | undefined;
620
+ /** Enable independent namespace clocks and PRNGs before serving a fleet. */
621
+ isolateNamespaces(): void;
622
+ namespaceClock(namespace?: string): Clock;
623
+ namespaceOf(request: Request): string;
624
+ /** Opaque in-process checkpoint including records, controls and webhook history. */
625
+ fleetSnapshot(namespace: string): object;
626
+ fleetRestore(snapshot: unknown, namespace: string): void;
598
627
  /** Expand a named preset into fault rules (and webhook faults) for `namespace`. */
599
628
  applyPreset(name: string, namespace?: string, overrides?: Partial<FaultRule>): FaultRule[];
600
629
  /** The instance behind `namespace` (the default one when omitted), created on first use. */
@@ -884,6 +913,7 @@ type DynamoRuntimeOptions = {
884
913
  sqlite?: SqliteClient;
885
914
  clock?: Clock;
886
915
  seed?: number | string;
916
+ adminPrefix?: string;
887
917
  adminKey?: string;
888
918
  onLog?: (entry: RequestLog) => void;
889
919
  region?: string;
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  document,
8
8
  operationIds,
9
9
  supportedOperationIds
10
- } from "./chunk-72UG3JD2.js";
10
+ } from "./chunk-D6QJOV4D.js";
11
11
  export {
12
12
  DYNAMODB_NAMESPACE,
13
13
  DYNAMODB_PRESETS,
package/dist/server.d.ts CHANGED
@@ -154,6 +154,15 @@ type FaultCandidate$1 = {
154
154
  namespace: string;
155
155
  };
156
156
  type FaultRegistry$1 = {
157
+ isolateNamespaces(): void;
158
+ snapshot(namespace: string): {
159
+ rules: (FaultRule$1 & {
160
+ remaining: number | null;
161
+ hits: number;
162
+ position: number;
163
+ })[];
164
+ rngState: number;
165
+ };
157
166
  add(rule: FaultRule$1): FaultRule$1;
158
167
  list(): (FaultRule$1 & {
159
168
  remaining: number | null;
@@ -161,6 +170,14 @@ type FaultRegistry$1 = {
161
170
  })[];
162
171
  remove(id: string): boolean;
163
172
  clear(): void;
173
+ restore(namespace: string, state: {
174
+ rules: (FaultRule$1 & {
175
+ remaining: number | null;
176
+ hits: number;
177
+ position: number;
178
+ })[];
179
+ rngState: number;
180
+ }): void;
164
181
  /**
165
182
  * Every fault this request should get, in rule order, stopping at the first that answers
166
183
  * or drops (effect-only and delay-only rules let later rules match too). Consumes one of
@@ -325,8 +342,8 @@ type MetricsReport$1 = {
325
342
  };
326
343
  type Metrics$1 = {
327
344
  record(entry: RequestLog$1): void;
328
- report(): MetricsReport$1;
329
- reset(): void;
345
+ report(namespace?: string): MetricsReport$1;
346
+ reset(namespace?: string): void;
330
347
  };
331
348
 
332
349
  /** One journal entry: a request log stamped with when (on the mock clock) it was handled. */
@@ -480,6 +497,9 @@ type PublishInput$1 = {
480
497
  id?: string;
481
498
  };
482
499
  type WebhookHub$1 = {
500
+ pending(namespace: string): number;
501
+ snapshot(namespace: string): unknown;
502
+ restore(namespace: string, snapshot: unknown): void;
483
503
  publish(input: PublishInput$1): WebhookMessage$1;
484
504
  /** Replace a namespace's own endpoints (`PUT /__admin/webhook-endpoints`). */
485
505
  setEndpoints(namespace: string, endpoints: WebhookEndpoint$1[]): WebhookEndpoint$1[];
@@ -507,6 +527,8 @@ type ServiceTimelineState$1 = Readonly<{
507
527
  }>;
508
528
  type ServiceCheckpoint$1 = Checkpoint$1<ServiceTimelineState$1>;
509
529
  type ServiceRuntime$1<T extends ServiceInstance$1> = FetchAPI$1 & {
530
+ /** Stop package-owned lifecycle timers when a supervisor closes the runtime. */
531
+ stop?(): void;
510
532
  readonly name: string;
511
533
  readonly sqlite: SqliteClient$2;
512
534
  readonly clock: Clock$1;
@@ -517,6 +539,13 @@ type ServiceRuntime$1<T extends ServiceInstance$1> = FetchAPI$1 & {
517
539
  readonly credentials: CredentialRegistry$1;
518
540
  /** The webhook hub, when the service has outbound webhooks. */
519
541
  readonly webhooks: WebhookHub$1 | undefined;
542
+ /** Enable independent namespace clocks and PRNGs before serving a fleet. */
543
+ isolateNamespaces(): void;
544
+ namespaceClock(namespace?: string): Clock$1;
545
+ namespaceOf(request: Request): string;
546
+ /** Opaque in-process checkpoint including records, controls and webhook history. */
547
+ fleetSnapshot(namespace: string): object;
548
+ fleetRestore(snapshot: unknown, namespace: string): void;
520
549
  /** Expand a named preset into fault rules (and webhook faults) for `namespace`. */
521
550
  applyPreset(name: string, namespace?: string, overrides?: Partial<FaultRule$1>): FaultRule$1[];
522
551
  /** The instance behind `namespace` (the default one when omitted), created on first use. */
@@ -563,6 +592,7 @@ type CliOption = {
563
592
  };
564
593
  type CliValues = Record<string, string | boolean | undefined>;
565
594
  type CommonServeOptions = {
595
+ adminPrefix?: string;
566
596
  adminKey: string | undefined;
567
597
  seed: string | undefined;
568
598
  onLog: ((entry: RequestLog$1) => void) | undefined;
@@ -780,6 +810,15 @@ type FaultCandidate = {
780
810
  namespace: string;
781
811
  };
782
812
  type FaultRegistry = {
813
+ isolateNamespaces(): void;
814
+ snapshot(namespace: string): {
815
+ rules: (FaultRule & {
816
+ remaining: number | null;
817
+ hits: number;
818
+ position: number;
819
+ })[];
820
+ rngState: number;
821
+ };
783
822
  add(rule: FaultRule): FaultRule;
784
823
  list(): (FaultRule & {
785
824
  remaining: number | null;
@@ -787,6 +826,14 @@ type FaultRegistry = {
787
826
  })[];
788
827
  remove(id: string): boolean;
789
828
  clear(): void;
829
+ restore(namespace: string, state: {
830
+ rules: (FaultRule & {
831
+ remaining: number | null;
832
+ hits: number;
833
+ position: number;
834
+ })[];
835
+ rngState: number;
836
+ }): void;
790
837
  /**
791
838
  * Every fault this request should get, in rule order, stopping at the first that answers
792
839
  * or drops (effect-only and delay-only rules let later rules match too). Consumes one of
@@ -964,8 +1011,8 @@ type MetricsReport = {
964
1011
  };
965
1012
  type Metrics = {
966
1013
  record(entry: RequestLog): void;
967
- report(): MetricsReport;
968
- reset(): void;
1014
+ report(namespace?: string): MetricsReport;
1015
+ reset(namespace?: string): void;
969
1016
  };
970
1017
 
971
1018
  /** One journal entry: a request log stamped with when (on the mock clock) it was handled. */
@@ -1131,6 +1178,9 @@ type PublishInput = {
1131
1178
  id?: string;
1132
1179
  };
1133
1180
  type WebhookHub = {
1181
+ pending(namespace: string): number;
1182
+ snapshot(namespace: string): unknown;
1183
+ restore(namespace: string, snapshot: unknown): void;
1134
1184
  publish(input: PublishInput): WebhookMessage;
1135
1185
  /** Replace a namespace's own endpoints (`PUT /__admin/webhook-endpoints`). */
1136
1186
  setEndpoints(namespace: string, endpoints: WebhookEndpoint[]): WebhookEndpoint[];
@@ -1158,6 +1208,8 @@ type ServiceTimelineState = Readonly<{
1158
1208
  }>;
1159
1209
  type ServiceCheckpoint = Checkpoint<ServiceTimelineState>;
1160
1210
  type ServiceRuntime<T extends ServiceInstance> = FetchAPI & {
1211
+ /** Stop package-owned lifecycle timers when a supervisor closes the runtime. */
1212
+ stop?(): void;
1161
1213
  readonly name: string;
1162
1214
  readonly sqlite: SqliteClient$1;
1163
1215
  readonly clock: Clock;
@@ -1168,6 +1220,13 @@ type ServiceRuntime<T extends ServiceInstance> = FetchAPI & {
1168
1220
  readonly credentials: CredentialRegistry;
1169
1221
  /** The webhook hub, when the service has outbound webhooks. */
1170
1222
  readonly webhooks: WebhookHub | undefined;
1223
+ /** Enable independent namespace clocks and PRNGs before serving a fleet. */
1224
+ isolateNamespaces(): void;
1225
+ namespaceClock(namespace?: string): Clock;
1226
+ namespaceOf(request: Request): string;
1227
+ /** Opaque in-process checkpoint including records, controls and webhook history. */
1228
+ fleetSnapshot(namespace: string): object;
1229
+ fleetRestore(snapshot: unknown, namespace: string): void;
1171
1230
  /** Expand a named preset into fault rules (and webhook faults) for `namespace`. */
1172
1231
  applyPreset(name: string, namespace?: string, overrides?: Partial<FaultRule>): FaultRule[];
1173
1232
  /** The instance behind `namespace` (the default one when omitted), created on first use. */
@@ -1349,6 +1408,7 @@ type DynamoRuntimeOptions = {
1349
1408
  sqlite?: SqliteClient;
1350
1409
  clock?: Clock;
1351
1410
  seed?: number | string;
1411
+ adminPrefix?: string;
1352
1412
  adminKey?: string;
1353
1413
  onLog?: (entry: RequestLog) => void;
1354
1414
  region?: string;
package/dist/server.js CHANGED
@@ -2,8 +2,8 @@ import {
2
2
  DEFAULT_PORT,
3
3
  createServer,
4
4
  serveTarget
5
- } from "./chunk-G5RO7ZQT.js";
6
- import "./chunk-72UG3JD2.js";
5
+ } from "./chunk-7EYNBJ7R.js";
6
+ import "./chunk-D6QJOV4D.js";
7
7
  export {
8
8
  DEFAULT_PORT,
9
9
  createServer,
package/openapi.yaml ADDED
@@ -0,0 +1,22 @@
1
+ openapi: 3.1.0
2
+ info:
3
+ title: Amazon DynamoDB (Mockingbird subset)
4
+ version: "2012-08-10"
5
+ description: AWS JSON DynamoDB contract used by AWS SDK v3.
6
+ servers:
7
+ - url: https://dynamodb.us-east-1.amazonaws.com
8
+ paths:
9
+ /:
10
+ post:
11
+ operationId: DynamoDbRpc
12
+ x-mockingbird: { supported: true, parity: { enabled: true, safe: false } }
13
+ parameters:
14
+ - { name: X-Amz-Target, in: header, required: true, schema: { type: string, pattern: '^DynamoDB_20120810\\.[A-Za-z]+$' } }
15
+ requestBody:
16
+ required: true
17
+ content:
18
+ application/x-amz-json-1.0: { schema: { type: object, additionalProperties: true } }
19
+ application/json: { schema: { type: object, additionalProperties: true } }
20
+ responses:
21
+ "200": { description: Operation response, content: { application/x-amz-json-1.0: { schema: { type: object, additionalProperties: true } } } }
22
+ "400": { description: DynamoDB exception, content: { application/x-amz-json-1.0: { schema: { type: object, additionalProperties: true } } } }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crvouga/mockingbird-service-dynamodb",
3
- "version": "1.7.1",
3
+ "version": "2.0.0",
4
4
  "description": "Stateful Amazon DynamoDB mock with typed items, expressions, indexes, pagination, transactions, and streams.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -8,7 +8,10 @@
8
8
  "files": [
9
9
  "dist",
10
10
  "README.md",
11
- "CHANGELOG.md"
11
+ "CHANGELOG.md",
12
+ "DISCOVERY.md",
13
+ "SUPPORT.md",
14
+ "openapi.yaml"
12
15
  ],
13
16
  "main": "./dist/index.js",
14
17
  "types": "./dist/index.d.ts",
@@ -56,7 +59,29 @@
56
59
  "docs": "https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/"
57
60
  },
58
61
  "parity": "Items, indexes, and transactions",
59
- "parityTier": "cold"
62
+ "parityTier": "cold",
63
+ "discovery": {
64
+ "guide": "DISCOVERY.md",
65
+ "behavior": "README.md",
66
+ "capabilities": "SUPPORT.md",
67
+ "contract": "openapi.yaml",
68
+ "types": "dist/index.d.ts",
69
+ "oracle": {
70
+ "kind": "Live vendor API or sandbox",
71
+ "command": "bun run parity:service -- dynamodb",
72
+ "note": "Run from a Mockingbird checkout; credentials come only from .env.local or GitHub Actions secrets. Missing credentials exit 2."
73
+ },
74
+ "introspection": [
75
+ "GET /__admin/health",
76
+ "GET /__admin",
77
+ "GET /__admin/state",
78
+ "GET /__admin/requests",
79
+ "GET /__admin/metrics",
80
+ "GET /__admin/faults/presets",
81
+ "GET /__admin/ui"
82
+ ],
83
+ "reporting": "https://github.com/crvouga/mockingbird/blob/main/docs/REPORTING_ISSUES.md"
84
+ }
60
85
  },
61
86
  "scripts": {
62
87
  "generate": "bun ../../openapi/codegen/dist/cli.js",
@@ -71,7 +96,7 @@
71
96
  "pack:check": "bun ../../../scripts/pack-check.ts"
72
97
  },
73
98
  "dependencies": {
74
- "@crvouga/mockingbird-service-sqlite": "1.3.0"
99
+ "@crvouga/mockingbird-service-sqlite": "2.0.0"
75
100
  },
76
101
  "devDependencies": {
77
102
  "@aws-sdk/client-dynamodb": "3.1132.0",