@crvouga/mockingbird-service-rxvortex 3.12.1 → 3.14.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/server.d.ts CHANGED
@@ -105,41 +105,6 @@ interface FetchAPI {
105
105
  /** A bare function form of {@link FetchAPI}, compatible with `Bun.serve`, workerd, and Deno. */
106
106
  type FetchHandler = (request: Request) => Promise<Response>;
107
107
 
108
- /** Bind values accepted by Mockingbird's SQLite port (matches sqlite-mem / better-sqlite3). */
109
- type SqliteValue = null | number | bigint | string | Uint8Array | boolean;
110
- /** Mutation counters returned by {@link SqliteStatement.run}. */
111
- type SqliteRunResult = {
112
- changes: number;
113
- lastInsertRowid: number | bigint;
114
- };
115
- /**
116
- * Prepared statement bound to a {@link SqliteClient}.
117
- *
118
- * Pass bind values as rest arguments on each call (no sticky `bind()`).
119
- */
120
- interface SqliteStatement {
121
- run(...params: SqliteValue[]): SqliteRunResult;
122
- all<T = Record<string, unknown>>(...params: SqliteValue[]): T[];
123
- get<T = Record<string, unknown>>(...params: SqliteValue[]): T | undefined;
124
- }
125
- /**
126
- * Sync SQLite client port owned by Mockingbird.
127
- *
128
- * Duck-typed so `@crvouga/mockingbird-service-sqlite` `Database`, better-sqlite3, and wrapped
129
- * `bun:sqlite` instances all work when they expose this surface.
130
- */
131
- interface SqliteClient {
132
- exec(sql: string): void;
133
- prepare(sql: string): SqliteStatement;
134
- transaction<T>(fn: () => T): T;
135
- }
136
-
137
- /**
138
- * What names an id base: a non-negative safe integer (or its decimal string) or `"boot"`,
139
- * which derives the base from the wall clock when the runtime is created.
140
- */
141
- type IdBase = number | string;
142
-
143
108
  /**
144
109
  * The single source of time for a service.
145
110
  *
@@ -170,6 +135,11 @@ type Clock = {
170
135
  state(): ClockState;
171
136
  };
172
137
 
138
+ type UpstreamState = {
139
+ mode: "emulated" | "forward";
140
+ baseUrl: string;
141
+ };
142
+
173
143
  /**
174
144
  * Seeded pseudo-random numbers, so anything a mock invents — ids, jitter, which
175
145
  * request a percentage fault hits — is reproducible from a seed.
@@ -433,6 +403,7 @@ declare const SNAPSHOT_FORMAT = "mockingbird.snapshot/v1";
433
403
  * `records` are required, so a hand-written seed file is a valid snapshot.
434
404
  */
435
405
  type SnapshotDocument = {
406
+ upstream?: UpstreamState;
436
407
  format: typeof SNAPSHOT_FORMAT;
437
408
  /** The service that wrote it. A snapshot is rejected by any other service. */
438
409
  service?: string;
@@ -506,6 +477,7 @@ type LatencyState = LatencyRule & {
506
477
  };
507
478
  /** What {@link controlHeaders} turns into request headers. */
508
479
  type ControlHeaderInput = {
480
+ upstream?: "emulated" | "forward";
509
481
  namespace?: string;
510
482
  adminKey?: string;
511
483
  branch?: string;
@@ -523,6 +495,35 @@ type ControlHeaderInput = {
523
495
  snapshot?: string;
524
496
  };
525
497
 
498
+ /** Bind values accepted by Mockingbird's SQLite port (matches sqlite-mem / better-sqlite3). */
499
+ type SqliteValue = null | number | bigint | string | Uint8Array | boolean;
500
+ /** Mutation counters returned by {@link SqliteStatement.run}. */
501
+ type SqliteRunResult = {
502
+ changes: number;
503
+ lastInsertRowid: number | bigint;
504
+ };
505
+ /**
506
+ * Prepared statement bound to a {@link SqliteClient}.
507
+ *
508
+ * Pass bind values as rest arguments on each call (no sticky `bind()`).
509
+ */
510
+ interface SqliteStatement {
511
+ run(...params: SqliteValue[]): SqliteRunResult;
512
+ all<T = Record<string, unknown>>(...params: SqliteValue[]): T[];
513
+ get<T = Record<string, unknown>>(...params: SqliteValue[]): T | undefined;
514
+ }
515
+ /**
516
+ * Sync SQLite client port owned by Mockingbird.
517
+ *
518
+ * Duck-typed so `@crvouga/mockingbird-service-sqlite` `Database`, better-sqlite3, and wrapped
519
+ * `bun:sqlite` instances all work when they expose this surface.
520
+ */
521
+ interface SqliteClient {
522
+ exec(sql: string): void;
523
+ prepare(sql: string): SqliteStatement;
524
+ transaction<T>(fn: () => T): T;
525
+ }
526
+
526
527
  /**
527
528
  * One problem with a request body, at a dotted path (`patient.address.city`, `items.0.sku`).
528
529
  * `kind` is `media_type` when the body is present but its media type is not one the operation
@@ -549,6 +550,7 @@ type RejectedRequest = {
549
550
  };
550
551
  /** One handled request, as the structured log sees it. */
551
552
  type RequestLog = {
553
+ upstream?: boolean;
552
554
  service: string;
553
555
  namespace: string;
554
556
  operationId: string | undefined;
@@ -683,8 +685,6 @@ type CredentialRegistry = {
683
685
  }[];
684
686
  };
685
687
 
686
- type OwnedTransport = (request: Request, namespace: string, send: typeof fetch) => Promise<Response>;
687
-
688
688
  /**
689
689
  * A point-in-time copy of everything a service namespace holds.
690
690
  *
@@ -737,6 +737,14 @@ type StateView = {
737
737
  collections: StateCollectionView[];
738
738
  };
739
739
 
740
+ /**
741
+ * What names an id base: a non-negative safe integer (or its decimal string) or `"boot"`,
742
+ * which derives the base from the wall clock when the runtime is created.
743
+ */
744
+ type IdBase = number | string;
745
+
746
+ type OwnedTransport = (request: Request, namespace: string, send: typeof fetch) => Promise<Response>;
747
+
740
748
  type WebhookEndpoint = {
741
749
  /** Stable id; generated when omitted. */
742
750
  id?: string;
package/dist/server.js CHANGED
@@ -3,8 +3,8 @@ import {
3
3
  createServer,
4
4
  loadCatalogFile,
5
5
  serveTarget
6
- } from "./chunk-BCKBQQOM.js";
7
- import "./chunk-KVEXOK7V.js";
6
+ } from "./chunk-4PYIJTMH.js";
7
+ import "./chunk-GTPGV2ML.js";
8
8
  export {
9
9
  DEFAULT_PORT,
10
10
  createServer,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crvouga/mockingbird-service-rxvortex",
3
- "version": "3.12.1",
3
+ "version": "3.14.0",
4
4
  "description": "Stateful emulator of the RxVortex (Strive) pharmacy API: OAuth token, order submit, status, cancel, recovery by sender order id, preset catalog, and signed status webhooks.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -98,7 +98,8 @@
98
98
  "pack:check": "bun ../../../scripts/pack-check.ts"
99
99
  },
100
100
  "dependencies": {
101
- "@crvouga/mockingbird-service-sqlite": "3.4.2",
101
+ "@crvouga/mockingbird-runtime": "0.0.1",
102
+ "@crvouga/mockingbird-service-sqlite": "3.5.0",
102
103
  "hono": "4.13.11"
103
104
  },
104
105
  "devDependencies": {