@crvouga/mockingbird-service-workos 1.12.0 → 1.13.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/index.d.ts CHANGED
@@ -143,98 +143,6 @@ interface FetchAPI {
143
143
  /** A bare function form of {@link FetchAPI}, compatible with `Bun.serve`, workerd, and Deno. */
144
144
  type FetchHandler = (request: Request) => Promise<Response>;
145
145
 
146
- /** Bind values accepted by Mockingbird's SQLite port (matches sqlite-mem / better-sqlite3). */
147
- type SqliteValue = null | number | bigint | string | Uint8Array | boolean;
148
- /** Mutation counters returned by {@link SqliteStatement.run}. */
149
- type SqliteRunResult = {
150
- changes: number;
151
- lastInsertRowid: number | bigint;
152
- };
153
- /**
154
- * Prepared statement bound to a {@link SqliteClient}.
155
- *
156
- * Pass bind values as rest arguments on each call (no sticky `bind()`).
157
- */
158
- interface SqliteStatement {
159
- run(...params: SqliteValue[]): SqliteRunResult;
160
- all<T = Record<string, unknown>>(...params: SqliteValue[]): T[];
161
- get<T = Record<string, unknown>>(...params: SqliteValue[]): T | undefined;
162
- }
163
- /**
164
- * Sync SQLite client port owned by Mockingbird.
165
- *
166
- * Duck-typed so `@crvouga/mockingbird-service-sqlite` `Database`, better-sqlite3, and wrapped
167
- * `bun:sqlite` instances all work when they expose this surface.
168
- */
169
- interface SqliteClient {
170
- exec(sql: string): void;
171
- prepare(sql: string): SqliteStatement;
172
- transaction<T>(fn: () => T): T;
173
- }
174
-
175
- /** Every stored record carries a monotonically increasing sequence for stable ordering. */
176
- type Stored<T> = {
177
- seq: number;
178
- value: T;
179
- };
180
- type ListRecordsOptions<T> = {
181
- /** Keep only records passing the predicate. */
182
- where?: (value: T, seq: number) => boolean;
183
- /** Sort order; default newest first. */
184
- order?: "newest" | "oldest";
185
- };
186
- /**
187
- * A SQLite-backed table of JSON records addressed by id. Ordering is by insertion
188
- * sequence, never by id lexicographic order, so list semantics stay stable.
189
- */
190
- declare class Collection<T> {
191
- private readonly sqlite;
192
- /** Storage namespace. Admin introspection uses this to ignore another namespace's tables. */
193
- readonly namespace: string;
194
- /** Table name inside the namespace. Stable across resets of the rows themselves. */
195
- readonly collectionName: string;
196
- private readonly statements;
197
- private prepare;
198
- constructor(sqlite: SqliteClient,
199
- /** Storage namespace. Admin introspection uses this to ignore another namespace's tables. */
200
- namespace: string,
201
- /** Table name inside the namespace. Stable across resets of the rows themselves. */
202
- collectionName: string);
203
- private bumpCollectionSeq;
204
- nextSequence(): number;
205
- get(id: string): T | undefined;
206
- has(id: string): boolean;
207
- /** Insert a new record, assigning it the next sequence number. */
208
- insert(id: string, value: T): Stored<T>;
209
- /** Replace an existing record's value, keeping its position. */
210
- update(id: string, value: T): Stored<T> | undefined;
211
- delete(id: string): boolean;
212
- /** How many records the collection holds, without reading them. */
213
- count(): number;
214
- list(options?: ListRecordsOptions<T>): Array<Stored<T> & {
215
- id: string;
216
- }>;
217
- }
218
-
219
- /**
220
- * What names an id base: a non-negative safe integer (or its decimal string) or `"boot"`,
221
- * which derives the base from the wall clock when the runtime is created.
222
- */
223
- type IdBase = number | string;
224
-
225
- /** Options every provider constructor accepts. */
226
- type APIOptions = {
227
- /** Sync SQLite client. Defaults to `@crvouga/mockingbird-service-sqlite`. */
228
- sqlite?: SqliteClient;
229
- /** Clock used for `created`-style fields. Default `Date.now`. */
230
- now?: () => number;
231
- /**
232
- * Storage namespace for this instance's records. Instances sharing one SQLite
233
- * client stay isolated when their namespaces differ. Defaults to the service name.
234
- */
235
- namespace?: string;
236
- };
237
-
238
146
  /**
239
147
  * The single source of time for a service.
240
148
  *
@@ -265,6 +173,11 @@ type Clock = {
265
173
  state(): ClockState;
266
174
  };
267
175
 
176
+ type UpstreamState = {
177
+ mode: "emulated" | "forward";
178
+ baseUrl: string;
179
+ };
180
+
268
181
  /**
269
182
  * Seeded pseudo-random numbers, so anything a mock invents — ids, jitter, which
270
183
  * request a percentage fault hits — is reproducible from a seed.
@@ -541,6 +454,7 @@ declare const SNAPSHOT_FORMAT = "mockingbird.snapshot/v1";
541
454
  * `records` are required, so a hand-written seed file is a valid snapshot.
542
455
  */
543
456
  type SnapshotDocument = {
457
+ upstream?: UpstreamState;
544
458
  format: typeof SNAPSHOT_FORMAT;
545
459
  /** The service that wrote it. A snapshot is rejected by any other service. */
546
460
  service?: string;
@@ -614,6 +528,7 @@ type LatencyState = LatencyRule & {
614
528
  };
615
529
  /** What {@link controlHeaders} turns into request headers. */
616
530
  type ControlHeaderInput = {
531
+ upstream?: "emulated" | "forward";
617
532
  namespace?: string;
618
533
  adminKey?: string;
619
534
  branch?: string;
@@ -631,6 +546,48 @@ type ControlHeaderInput = {
631
546
  snapshot?: string;
632
547
  };
633
548
 
549
+ /** Bind values accepted by Mockingbird's SQLite port (matches sqlite-mem / better-sqlite3). */
550
+ type SqliteValue = null | number | bigint | string | Uint8Array | boolean;
551
+ /** Mutation counters returned by {@link SqliteStatement.run}. */
552
+ type SqliteRunResult = {
553
+ changes: number;
554
+ lastInsertRowid: number | bigint;
555
+ };
556
+ /**
557
+ * Prepared statement bound to a {@link SqliteClient}.
558
+ *
559
+ * Pass bind values as rest arguments on each call (no sticky `bind()`).
560
+ */
561
+ interface SqliteStatement {
562
+ run(...params: SqliteValue[]): SqliteRunResult;
563
+ all<T = Record<string, unknown>>(...params: SqliteValue[]): T[];
564
+ get<T = Record<string, unknown>>(...params: SqliteValue[]): T | undefined;
565
+ }
566
+ /**
567
+ * Sync SQLite client port owned by Mockingbird.
568
+ *
569
+ * Duck-typed so `@crvouga/mockingbird-service-sqlite` `Database`, better-sqlite3, and wrapped
570
+ * `bun:sqlite` instances all work when they expose this surface.
571
+ */
572
+ interface SqliteClient {
573
+ exec(sql: string): void;
574
+ prepare(sql: string): SqliteStatement;
575
+ transaction<T>(fn: () => T): T;
576
+ }
577
+
578
+ /** Options every provider constructor accepts. */
579
+ type APIOptions = {
580
+ /** Sync SQLite client. Defaults to `@crvouga/mockingbird-service-sqlite`. */
581
+ sqlite?: SqliteClient;
582
+ /** Clock used for `created`-style fields. Default `Date.now`. */
583
+ now?: () => number;
584
+ /**
585
+ * Storage namespace for this instance's records. Instances sharing one SQLite
586
+ * client stay isolated when their namespaces differ. Defaults to the service name.
587
+ */
588
+ namespace?: string;
589
+ };
590
+
634
591
  /**
635
592
  * One problem with a request body, at a dotted path (`patient.address.city`, `items.0.sku`).
636
593
  * `kind` is `media_type` when the body is present but its media type is not one the operation
@@ -657,6 +614,7 @@ type RejectedRequest = {
657
614
  };
658
615
  /** One handled request, as the structured log sees it. */
659
616
  type RequestLog = {
617
+ upstream?: boolean;
660
618
  service: string;
661
619
  namespace: string;
662
620
  operationId: string | undefined;
@@ -791,8 +749,6 @@ type CredentialRegistry = {
791
749
  }[];
792
750
  };
793
751
 
794
- type OwnedTransport = (request: Request, namespace: string, send: typeof fetch) => Promise<Response>;
795
-
796
752
  /**
797
753
  * A point-in-time copy of everything a service namespace holds.
798
754
  *
@@ -815,6 +771,50 @@ type NamespaceSnapshot = {
815
771
  }[];
816
772
  };
817
773
 
774
+ /** Every stored record carries a monotonically increasing sequence for stable ordering. */
775
+ type Stored<T> = {
776
+ seq: number;
777
+ value: T;
778
+ };
779
+ type ListRecordsOptions<T> = {
780
+ /** Keep only records passing the predicate. */
781
+ where?: (value: T, seq: number) => boolean;
782
+ /** Sort order; default newest first. */
783
+ order?: "newest" | "oldest";
784
+ };
785
+ /**
786
+ * A SQLite-backed table of JSON records addressed by id. Ordering is by insertion
787
+ * sequence, never by id lexicographic order, so list semantics stay stable.
788
+ */
789
+ declare class Collection<T> {
790
+ private readonly sqlite;
791
+ /** Storage namespace. Admin introspection uses this to ignore another namespace's tables. */
792
+ readonly namespace: string;
793
+ /** Table name inside the namespace. Stable across resets of the rows themselves. */
794
+ readonly collectionName: string;
795
+ private readonly statements;
796
+ private prepare;
797
+ constructor(sqlite: SqliteClient,
798
+ /** Storage namespace. Admin introspection uses this to ignore another namespace's tables. */
799
+ namespace: string,
800
+ /** Table name inside the namespace. Stable across resets of the rows themselves. */
801
+ collectionName: string);
802
+ private bumpCollectionSeq;
803
+ nextSequence(): number;
804
+ get(id: string): T | undefined;
805
+ has(id: string): boolean;
806
+ /** Insert a new record, assigning it the next sequence number. */
807
+ insert(id: string, value: T): Stored<T>;
808
+ /** Replace an existing record's value, keeping its position. */
809
+ update(id: string, value: T): Stored<T> | undefined;
810
+ delete(id: string): boolean;
811
+ /** How many records the collection holds, without reading them. */
812
+ count(): number;
813
+ list(options?: ListRecordsOptions<T>): Array<Stored<T> & {
814
+ id: string;
815
+ }>;
816
+ }
817
+
818
818
  declare const STATE_FIELD_KINDS: readonly ["string", "number", "boolean", "null", "object", "array", "unknown"];
819
819
  type StateFieldKind = (typeof STATE_FIELD_KINDS)[number];
820
820
  /** JSON-safe annotations a bespoke admin UI may read. The default UI shows them as text. */
@@ -845,6 +845,14 @@ type StateView = {
845
845
  collections: StateCollectionView[];
846
846
  };
847
847
 
848
+ /**
849
+ * What names an id base: a non-negative safe integer (or its decimal string) or `"boot"`,
850
+ * which derives the base from the wall clock when the runtime is created.
851
+ */
852
+ type IdBase = number | string;
853
+
854
+ type OwnedTransport = (request: Request, namespace: string, send: typeof fetch) => Promise<Response>;
855
+
848
856
  type WebhookEndpoint = {
849
857
  /** Stable id; generated when omitted. */
850
858
  id?: string;
package/dist/index.js CHANGED
@@ -8,8 +8,7 @@ import {
8
8
  document,
9
9
  operationIds,
10
10
  supportedOperationIds
11
- } from "./chunk-TSZTRJC6.js";
12
- import "./chunk-6WMXQP7I.js";
11
+ } from "./chunk-WKRHUOZR.js";
13
12
  export {
14
13
  DEFAULT_CLIENTS,
15
14
  DEFAULT_USERS,
package/dist/server.d.ts CHANGED
@@ -106,41 +106,6 @@ interface FetchAPI {
106
106
  /** A bare function form of {@link FetchAPI}, compatible with `Bun.serve`, workerd, and Deno. */
107
107
  type FetchHandler = (request: Request) => Promise<Response>;
108
108
 
109
- /** Bind values accepted by Mockingbird's SQLite port (matches sqlite-mem / better-sqlite3). */
110
- type SqliteValue = null | number | bigint | string | Uint8Array | boolean;
111
- /** Mutation counters returned by {@link SqliteStatement.run}. */
112
- type SqliteRunResult = {
113
- changes: number;
114
- lastInsertRowid: number | bigint;
115
- };
116
- /**
117
- * Prepared statement bound to a {@link SqliteClient}.
118
- *
119
- * Pass bind values as rest arguments on each call (no sticky `bind()`).
120
- */
121
- interface SqliteStatement {
122
- run(...params: SqliteValue[]): SqliteRunResult;
123
- all<T = Record<string, unknown>>(...params: SqliteValue[]): T[];
124
- get<T = Record<string, unknown>>(...params: SqliteValue[]): T | undefined;
125
- }
126
- /**
127
- * Sync SQLite client port owned by Mockingbird.
128
- *
129
- * Duck-typed so `@crvouga/mockingbird-service-sqlite` `Database`, better-sqlite3, and wrapped
130
- * `bun:sqlite` instances all work when they expose this surface.
131
- */
132
- interface SqliteClient {
133
- exec(sql: string): void;
134
- prepare(sql: string): SqliteStatement;
135
- transaction<T>(fn: () => T): T;
136
- }
137
-
138
- /**
139
- * What names an id base: a non-negative safe integer (or its decimal string) or `"boot"`,
140
- * which derives the base from the wall clock when the runtime is created.
141
- */
142
- type IdBase = number | string;
143
-
144
109
  /**
145
110
  * The single source of time for a service.
146
111
  *
@@ -171,6 +136,11 @@ type Clock = {
171
136
  state(): ClockState;
172
137
  };
173
138
 
139
+ type UpstreamState = {
140
+ mode: "emulated" | "forward";
141
+ baseUrl: string;
142
+ };
143
+
174
144
  /**
175
145
  * Seeded pseudo-random numbers, so anything a mock invents — ids, jitter, which
176
146
  * request a percentage fault hits — is reproducible from a seed.
@@ -434,6 +404,7 @@ declare const SNAPSHOT_FORMAT = "mockingbird.snapshot/v1";
434
404
  * `records` are required, so a hand-written seed file is a valid snapshot.
435
405
  */
436
406
  type SnapshotDocument = {
407
+ upstream?: UpstreamState;
437
408
  format: typeof SNAPSHOT_FORMAT;
438
409
  /** The service that wrote it. A snapshot is rejected by any other service. */
439
410
  service?: string;
@@ -507,6 +478,7 @@ type LatencyState = LatencyRule & {
507
478
  };
508
479
  /** What {@link controlHeaders} turns into request headers. */
509
480
  type ControlHeaderInput = {
481
+ upstream?: "emulated" | "forward";
510
482
  namespace?: string;
511
483
  adminKey?: string;
512
484
  branch?: string;
@@ -524,6 +496,35 @@ type ControlHeaderInput = {
524
496
  snapshot?: string;
525
497
  };
526
498
 
499
+ /** Bind values accepted by Mockingbird's SQLite port (matches sqlite-mem / better-sqlite3). */
500
+ type SqliteValue = null | number | bigint | string | Uint8Array | boolean;
501
+ /** Mutation counters returned by {@link SqliteStatement.run}. */
502
+ type SqliteRunResult = {
503
+ changes: number;
504
+ lastInsertRowid: number | bigint;
505
+ };
506
+ /**
507
+ * Prepared statement bound to a {@link SqliteClient}.
508
+ *
509
+ * Pass bind values as rest arguments on each call (no sticky `bind()`).
510
+ */
511
+ interface SqliteStatement {
512
+ run(...params: SqliteValue[]): SqliteRunResult;
513
+ all<T = Record<string, unknown>>(...params: SqliteValue[]): T[];
514
+ get<T = Record<string, unknown>>(...params: SqliteValue[]): T | undefined;
515
+ }
516
+ /**
517
+ * Sync SQLite client port owned by Mockingbird.
518
+ *
519
+ * Duck-typed so `@crvouga/mockingbird-service-sqlite` `Database`, better-sqlite3, and wrapped
520
+ * `bun:sqlite` instances all work when they expose this surface.
521
+ */
522
+ interface SqliteClient {
523
+ exec(sql: string): void;
524
+ prepare(sql: string): SqliteStatement;
525
+ transaction<T>(fn: () => T): T;
526
+ }
527
+
527
528
  /**
528
529
  * One problem with a request body, at a dotted path (`patient.address.city`, `items.0.sku`).
529
530
  * `kind` is `media_type` when the body is present but its media type is not one the operation
@@ -550,6 +551,7 @@ type RejectedRequest = {
550
551
  };
551
552
  /** One handled request, as the structured log sees it. */
552
553
  type RequestLog = {
554
+ upstream?: boolean;
553
555
  service: string;
554
556
  namespace: string;
555
557
  operationId: string | undefined;
@@ -684,8 +686,6 @@ type CredentialRegistry = {
684
686
  }[];
685
687
  };
686
688
 
687
- type OwnedTransport = (request: Request, namespace: string, send: typeof fetch) => Promise<Response>;
688
-
689
689
  /**
690
690
  * A point-in-time copy of everything a service namespace holds.
691
691
  *
@@ -738,6 +738,14 @@ type StateView = {
738
738
  collections: StateCollectionView[];
739
739
  };
740
740
 
741
+ /**
742
+ * What names an id base: a non-negative safe integer (or its decimal string) or `"boot"`,
743
+ * which derives the base from the wall clock when the runtime is created.
744
+ */
745
+ type IdBase = number | string;
746
+
747
+ type OwnedTransport = (request: Request, namespace: string, send: typeof fetch) => Promise<Response>;
748
+
741
749
  type WebhookEndpoint = {
742
750
  /** Stable id; generated when omitted. */
743
751
  id?: string;
package/dist/server.js CHANGED
@@ -2,9 +2,8 @@ import {
2
2
  DEFAULT_PORT,
3
3
  createServer,
4
4
  serveTarget
5
- } from "./chunk-4NHUXNPZ.js";
6
- import "./chunk-TSZTRJC6.js";
7
- import "./chunk-6WMXQP7I.js";
5
+ } from "./chunk-UVISFC5T.js";
6
+ import "./chunk-WKRHUOZR.js";
8
7
  export {
9
8
  DEFAULT_PORT,
10
9
  createServer,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crvouga/mockingbird-service-workos",
3
- "version": "1.12.0",
3
+ "version": "1.13.0",
4
4
  "description": "Stateful WorkOS AuthKit emulator with signed sessions, rotating refresh tokens and user pagination.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -103,7 +103,8 @@
103
103
  "pack:check": "bun ../../../scripts/pack-check.ts"
104
104
  },
105
105
  "dependencies": {
106
- "@crvouga/mockingbird-service-sqlite": "3.4.2",
106
+ "@crvouga/mockingbird-runtime": "0.0.1",
107
+ "@crvouga/mockingbird-service-sqlite": "3.5.0",
107
108
  "hono": "4.13.11"
108
109
  },
109
110
  "devDependencies": {