@crvouga/mockingbird-service-workos 1.0.0 → 1.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/dist/cli.js CHANGED
@@ -3,8 +3,8 @@ import {
3
3
  runCli,
4
4
  serveCommand,
5
5
  serveTarget
6
- } from "./chunk-XR6BP2AR.js";
7
- import "./chunk-BXGLSAOT.js";
6
+ } from "./chunk-BIGV6FI5.js";
7
+ import "./chunk-JITNKKHL.js";
8
8
 
9
9
  // src/cli.ts
10
10
  var code = await runCli(
package/dist/index.d.ts CHANGED
@@ -40,76 +40,16 @@ interface FetchAPI$1 {
40
40
  fetch(request: Request): Promise<Response>;
41
41
  }
42
42
 
43
- /** Bind values accepted by Mockingbird's SQLite port (matches sqlite-mem / better-sqlite3). */
44
- type SqliteValue = null | number | bigint | string | Uint8Array | boolean;
45
- /** Mutation counters returned by {@link SqliteStatement.run}. */
46
- type SqliteRunResult = {
47
- changes: number;
48
- lastInsertRowid: number | bigint;
49
- };
50
- /**
51
- * Prepared statement bound to a {@link SqliteClient}.
52
- *
53
- * Pass bind values as rest arguments on each call (no sticky `bind()`).
54
- */
55
- interface SqliteStatement {
56
- run(...params: SqliteValue[]): SqliteRunResult;
57
- all<T = Record<string, unknown>>(...params: SqliteValue[]): T[];
58
- get<T = Record<string, unknown>>(...params: SqliteValue[]): T | undefined;
59
- }
60
- /**
61
- * Sync SQLite client port owned by Mockingbird.
62
- *
63
- * Duck-typed so `@crvouga/mockingbird-service-sqlite` `Database`, better-sqlite3, and wrapped
64
- * `bun:sqlite` instances all work when they expose this surface.
65
- */
66
- interface SqliteClient {
67
- exec(sql: string): void;
68
- prepare(sql: string): SqliteStatement;
69
- transaction<T>(fn: () => T): T;
70
- }
71
-
72
- /** Every stored record carries a monotonically increasing sequence for stable ordering. */
73
- type Stored<T> = {
74
- seq: number;
75
- value: T;
76
- };
77
- type ListRecordsOptions<T> = {
78
- /** Keep only records passing the predicate. */
79
- where?: (value: T, seq: number) => boolean;
80
- /** Sort order; default newest first. */
81
- order?: "newest" | "oldest";
43
+ type MountedAPI = FetchAPI & {
44
+ readonly prefix: string;
45
+ GET: FetchHandler;
46
+ POST: FetchHandler;
47
+ PUT: FetchHandler;
48
+ PATCH: FetchHandler;
49
+ DELETE: FetchHandler;
50
+ HEAD: FetchHandler;
51
+ OPTIONS: FetchHandler;
82
52
  };
83
- /**
84
- * A SQLite-backed table of JSON records addressed by id. Ordering is by insertion
85
- * sequence, never by id lexicographic order, so list semantics stay stable.
86
- */
87
- declare class Collection<T> {
88
- private readonly sqlite;
89
- /** Storage namespace. Admin introspection uses this to ignore another namespace's tables. */
90
- readonly namespace: string;
91
- /** Table name inside the namespace. Stable across resets of the rows themselves. */
92
- readonly collectionName: string;
93
- constructor(sqlite: SqliteClient,
94
- /** Storage namespace. Admin introspection uses this to ignore another namespace's tables. */
95
- namespace: string,
96
- /** Table name inside the namespace. Stable across resets of the rows themselves. */
97
- collectionName: string);
98
- private bumpCollectionSeq;
99
- nextSequence(): number;
100
- get(id: string): T | undefined;
101
- has(id: string): boolean;
102
- /** Insert a new record, assigning it the next sequence number. */
103
- insert(id: string, value: T): Stored<T>;
104
- /** Replace an existing record's value, keeping its position. */
105
- update(id: string, value: T): Stored<T> | undefined;
106
- delete(id: string): boolean;
107
- /** How many records the collection holds, without reading them. */
108
- count(): number;
109
- list(options?: ListRecordsOptions<T>): Array<Stored<T> & {
110
- id: string;
111
- }>;
112
- }
113
53
 
114
54
  /** A stable identifier for a point in a {@link Timeline}. */
115
55
  type CheckpointId = string;
@@ -200,6 +140,79 @@ declare class Timeline<T> {
200
140
  interface FetchAPI {
201
141
  fetch(request: Request): Promise<Response>;
202
142
  }
143
+ /** A bare function form of {@link FetchAPI}, compatible with `Bun.serve`, workerd, and Deno. */
144
+ type FetchHandler = (request: Request) => Promise<Response>;
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
+ constructor(sqlite: SqliteClient,
197
+ /** Storage namespace. Admin introspection uses this to ignore another namespace's tables. */
198
+ namespace: string,
199
+ /** Table name inside the namespace. Stable across resets of the rows themselves. */
200
+ collectionName: string);
201
+ private bumpCollectionSeq;
202
+ nextSequence(): number;
203
+ get(id: string): T | undefined;
204
+ has(id: string): boolean;
205
+ /** Insert a new record, assigning it the next sequence number. */
206
+ insert(id: string, value: T): Stored<T>;
207
+ /** Replace an existing record's value, keeping its position. */
208
+ update(id: string, value: T): Stored<T> | undefined;
209
+ delete(id: string): boolean;
210
+ /** How many records the collection holds, without reading them. */
211
+ count(): number;
212
+ list(options?: ListRecordsOptions<T>): Array<Stored<T> & {
213
+ id: string;
214
+ }>;
215
+ }
203
216
 
204
217
  /** Options every provider constructor accepts. */
205
218
  type APIOptions = {
@@ -642,6 +655,8 @@ type ServiceRuntime<T extends ServiceInstance> = FetchAPI & {
642
655
  /** Stop package-owned lifecycle timers when a supervisor closes the runtime. */
643
656
  stop?(): void;
644
657
  readonly name: string;
658
+ /** Same-origin Fetch handler and App Router method exports, sharing this runtime. */
659
+ mount(prefix: string): MountedAPI;
645
660
  readonly sqlite: SqliteClient;
646
661
  readonly clock: Clock;
647
662
  readonly faults: FaultRegistry;
package/dist/index.js CHANGED
@@ -8,7 +8,7 @@ import {
8
8
  document,
9
9
  operationIds,
10
10
  supportedOperationIds
11
- } from "./chunk-BXGLSAOT.js";
11
+ } from "./chunk-JITNKKHL.js";
12
12
  export {
13
13
  DEFAULT_CLIENTS,
14
14
  DEFAULT_USERS,
package/dist/server.d.ts CHANGED
@@ -2,34 +2,16 @@ import { Server } from 'node:http';
2
2
  import * as hono from 'hono';
3
3
  import * as hono_types from 'hono/types';
4
4
 
5
- /** Bind values accepted by Mockingbird's SQLite port (matches sqlite-mem / better-sqlite3). */
6
- type SqliteValue$2 = null | number | bigint | string | Uint8Array | boolean;
7
- /** Mutation counters returned by {@link SqliteStatement.run}. */
8
- type SqliteRunResult$2 = {
9
- changes: number;
10
- lastInsertRowid: number | bigint;
5
+ type MountedAPI$1 = FetchAPI$2 & {
6
+ readonly prefix: string;
7
+ GET: FetchHandler$1;
8
+ POST: FetchHandler$1;
9
+ PUT: FetchHandler$1;
10
+ PATCH: FetchHandler$1;
11
+ DELETE: FetchHandler$1;
12
+ HEAD: FetchHandler$1;
13
+ OPTIONS: FetchHandler$1;
11
14
  };
12
- /**
13
- * Prepared statement bound to a {@link SqliteClient}.
14
- *
15
- * Pass bind values as rest arguments on each call (no sticky `bind()`).
16
- */
17
- interface SqliteStatement$2 {
18
- run(...params: SqliteValue$2[]): SqliteRunResult$2;
19
- all<T = Record<string, unknown>>(...params: SqliteValue$2[]): T[];
20
- get<T = Record<string, unknown>>(...params: SqliteValue$2[]): T | undefined;
21
- }
22
- /**
23
- * Sync SQLite client port owned by Mockingbird.
24
- *
25
- * Duck-typed so `@crvouga/mockingbird-service-sqlite` `Database`, better-sqlite3, and wrapped
26
- * `bun:sqlite` instances all work when they expose this surface.
27
- */
28
- interface SqliteClient$2 {
29
- exec(sql: string): void;
30
- prepare(sql: string): SqliteStatement$2;
31
- transaction<T>(fn: () => T): T;
32
- }
33
15
 
34
16
  /** A stable identifier for a point in a {@link Timeline}. */
35
17
  type CheckpointId$1 = string;
@@ -120,6 +102,37 @@ declare class Timeline$1<T> {
120
102
  interface FetchAPI$2 {
121
103
  fetch(request: Request): Promise<Response>;
122
104
  }
105
+ /** A bare function form of {@link FetchAPI}, compatible with `Bun.serve`, workerd, and Deno. */
106
+ type FetchHandler$1 = (request: Request) => Promise<Response>;
107
+
108
+ /** Bind values accepted by Mockingbird's SQLite port (matches sqlite-mem / better-sqlite3). */
109
+ type SqliteValue$2 = null | number | bigint | string | Uint8Array | boolean;
110
+ /** Mutation counters returned by {@link SqliteStatement.run}. */
111
+ type SqliteRunResult$2 = {
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$2 {
121
+ run(...params: SqliteValue$2[]): SqliteRunResult$2;
122
+ all<T = Record<string, unknown>>(...params: SqliteValue$2[]): T[];
123
+ get<T = Record<string, unknown>>(...params: SqliteValue$2[]): 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$2 {
132
+ exec(sql: string): void;
133
+ prepare(sql: string): SqliteStatement$2;
134
+ transaction<T>(fn: () => T): T;
135
+ }
123
136
 
124
137
  /**
125
138
  * The single source of time for a service.
@@ -536,6 +549,8 @@ type ServiceRuntime$1<T extends ServiceInstance$1> = FetchAPI$2 & {
536
549
  /** Stop package-owned lifecycle timers when a supervisor closes the runtime. */
537
550
  stop?(): void;
538
551
  readonly name: string;
552
+ /** Same-origin Fetch handler and App Router method exports, sharing this runtime. */
553
+ mount(prefix: string): MountedAPI$1;
539
554
  readonly sqlite: SqliteClient$2;
540
555
  readonly clock: Clock$1;
541
556
  readonly faults: FaultRegistry$1;
@@ -602,6 +617,9 @@ type CommonServeOptions = {
602
617
  adminKey: string | undefined;
603
618
  seed: string | undefined;
604
619
  onLog: ((entry: RequestLog$1) => void) | undefined;
620
+ /** Synthetic provider fixture objects supplied by a fleet entry. */
621
+ fixtures?: Record<string, unknown>;
622
+ baseUrl?: string;
605
623
  };
606
624
  /**
607
625
  * What a service contributes to `serve`: how to build its runtime from CLI flags,
@@ -620,76 +638,16 @@ type ServeTarget = {
620
638
  listening?(server: Listening): void;
621
639
  };
622
640
 
623
- /** Bind values accepted by Mockingbird's SQLite port (matches sqlite-mem / better-sqlite3). */
624
- type SqliteValue$1 = null | number | bigint | string | Uint8Array | boolean;
625
- /** Mutation counters returned by {@link SqliteStatement.run}. */
626
- type SqliteRunResult$1 = {
627
- changes: number;
628
- lastInsertRowid: number | bigint;
641
+ type MountedAPI = FetchAPI$1 & {
642
+ readonly prefix: string;
643
+ GET: FetchHandler;
644
+ POST: FetchHandler;
645
+ PUT: FetchHandler;
646
+ PATCH: FetchHandler;
647
+ DELETE: FetchHandler;
648
+ HEAD: FetchHandler;
649
+ OPTIONS: FetchHandler;
629
650
  };
630
- /**
631
- * Prepared statement bound to a {@link SqliteClient}.
632
- *
633
- * Pass bind values as rest arguments on each call (no sticky `bind()`).
634
- */
635
- interface SqliteStatement$1 {
636
- run(...params: SqliteValue$1[]): SqliteRunResult$1;
637
- all<T = Record<string, unknown>>(...params: SqliteValue$1[]): T[];
638
- get<T = Record<string, unknown>>(...params: SqliteValue$1[]): T | undefined;
639
- }
640
- /**
641
- * Sync SQLite client port owned by Mockingbird.
642
- *
643
- * Duck-typed so `@crvouga/mockingbird-service-sqlite` `Database`, better-sqlite3, and wrapped
644
- * `bun:sqlite` instances all work when they expose this surface.
645
- */
646
- interface SqliteClient$1 {
647
- exec(sql: string): void;
648
- prepare(sql: string): SqliteStatement$1;
649
- transaction<T>(fn: () => T): T;
650
- }
651
-
652
- /** Every stored record carries a monotonically increasing sequence for stable ordering. */
653
- type Stored<T> = {
654
- seq: number;
655
- value: T;
656
- };
657
- type ListRecordsOptions<T> = {
658
- /** Keep only records passing the predicate. */
659
- where?: (value: T, seq: number) => boolean;
660
- /** Sort order; default newest first. */
661
- order?: "newest" | "oldest";
662
- };
663
- /**
664
- * A SQLite-backed table of JSON records addressed by id. Ordering is by insertion
665
- * sequence, never by id lexicographic order, so list semantics stay stable.
666
- */
667
- declare class Collection<T> {
668
- private readonly sqlite;
669
- /** Storage namespace. Admin introspection uses this to ignore another namespace's tables. */
670
- readonly namespace: string;
671
- /** Table name inside the namespace. Stable across resets of the rows themselves. */
672
- readonly collectionName: string;
673
- constructor(sqlite: SqliteClient$1,
674
- /** Storage namespace. Admin introspection uses this to ignore another namespace's tables. */
675
- namespace: string,
676
- /** Table name inside the namespace. Stable across resets of the rows themselves. */
677
- collectionName: string);
678
- private bumpCollectionSeq;
679
- nextSequence(): number;
680
- get(id: string): T | undefined;
681
- has(id: string): boolean;
682
- /** Insert a new record, assigning it the next sequence number. */
683
- insert(id: string, value: T): Stored<T>;
684
- /** Replace an existing record's value, keeping its position. */
685
- update(id: string, value: T): Stored<T> | undefined;
686
- delete(id: string): boolean;
687
- /** How many records the collection holds, without reading them. */
688
- count(): number;
689
- list(options?: ListRecordsOptions<T>): Array<Stored<T> & {
690
- id: string;
691
- }>;
692
- }
693
651
 
694
652
  /** A stable identifier for a point in a {@link Timeline}. */
695
653
  type CheckpointId = string;
@@ -780,6 +738,79 @@ declare class Timeline<T> {
780
738
  interface FetchAPI$1 {
781
739
  fetch(request: Request): Promise<Response>;
782
740
  }
741
+ /** A bare function form of {@link FetchAPI}, compatible with `Bun.serve`, workerd, and Deno. */
742
+ type FetchHandler = (request: Request) => Promise<Response>;
743
+
744
+ /** Bind values accepted by Mockingbird's SQLite port (matches sqlite-mem / better-sqlite3). */
745
+ type SqliteValue$1 = null | number | bigint | string | Uint8Array | boolean;
746
+ /** Mutation counters returned by {@link SqliteStatement.run}. */
747
+ type SqliteRunResult$1 = {
748
+ changes: number;
749
+ lastInsertRowid: number | bigint;
750
+ };
751
+ /**
752
+ * Prepared statement bound to a {@link SqliteClient}.
753
+ *
754
+ * Pass bind values as rest arguments on each call (no sticky `bind()`).
755
+ */
756
+ interface SqliteStatement$1 {
757
+ run(...params: SqliteValue$1[]): SqliteRunResult$1;
758
+ all<T = Record<string, unknown>>(...params: SqliteValue$1[]): T[];
759
+ get<T = Record<string, unknown>>(...params: SqliteValue$1[]): T | undefined;
760
+ }
761
+ /**
762
+ * Sync SQLite client port owned by Mockingbird.
763
+ *
764
+ * Duck-typed so `@crvouga/mockingbird-service-sqlite` `Database`, better-sqlite3, and wrapped
765
+ * `bun:sqlite` instances all work when they expose this surface.
766
+ */
767
+ interface SqliteClient$1 {
768
+ exec(sql: string): void;
769
+ prepare(sql: string): SqliteStatement$1;
770
+ transaction<T>(fn: () => T): T;
771
+ }
772
+
773
+ /** Every stored record carries a monotonically increasing sequence for stable ordering. */
774
+ type Stored<T> = {
775
+ seq: number;
776
+ value: T;
777
+ };
778
+ type ListRecordsOptions<T> = {
779
+ /** Keep only records passing the predicate. */
780
+ where?: (value: T, seq: number) => boolean;
781
+ /** Sort order; default newest first. */
782
+ order?: "newest" | "oldest";
783
+ };
784
+ /**
785
+ * A SQLite-backed table of JSON records addressed by id. Ordering is by insertion
786
+ * sequence, never by id lexicographic order, so list semantics stay stable.
787
+ */
788
+ declare class Collection<T> {
789
+ private readonly sqlite;
790
+ /** Storage namespace. Admin introspection uses this to ignore another namespace's tables. */
791
+ readonly namespace: string;
792
+ /** Table name inside the namespace. Stable across resets of the rows themselves. */
793
+ readonly collectionName: string;
794
+ constructor(sqlite: SqliteClient$1,
795
+ /** Storage namespace. Admin introspection uses this to ignore another namespace's tables. */
796
+ namespace: string,
797
+ /** Table name inside the namespace. Stable across resets of the rows themselves. */
798
+ collectionName: string);
799
+ private bumpCollectionSeq;
800
+ nextSequence(): number;
801
+ get(id: string): T | undefined;
802
+ has(id: string): boolean;
803
+ /** Insert a new record, assigning it the next sequence number. */
804
+ insert(id: string, value: T): Stored<T>;
805
+ /** Replace an existing record's value, keeping its position. */
806
+ update(id: string, value: T): Stored<T> | undefined;
807
+ delete(id: string): boolean;
808
+ /** How many records the collection holds, without reading them. */
809
+ count(): number;
810
+ list(options?: ListRecordsOptions<T>): Array<Stored<T> & {
811
+ id: string;
812
+ }>;
813
+ }
783
814
 
784
815
  /** Options every provider constructor accepts. */
785
816
  type APIOptions = {
@@ -1209,6 +1240,8 @@ type ServiceRuntime<T extends ServiceInstance> = FetchAPI$1 & {
1209
1240
  /** Stop package-owned lifecycle timers when a supervisor closes the runtime. */
1210
1241
  stop?(): void;
1211
1242
  readonly name: string;
1243
+ /** Same-origin Fetch handler and App Router method exports, sharing this runtime. */
1244
+ mount(prefix: string): MountedAPI;
1212
1245
  readonly sqlite: SqliteClient$1;
1213
1246
  readonly clock: Clock;
1214
1247
  readonly faults: FaultRegistry;
package/dist/server.js CHANGED
@@ -2,8 +2,8 @@ import {
2
2
  DEFAULT_PORT,
3
3
  createServer,
4
4
  serveTarget
5
- } from "./chunk-XR6BP2AR.js";
6
- import "./chunk-BXGLSAOT.js";
5
+ } from "./chunk-BIGV6FI5.js";
6
+ import "./chunk-JITNKKHL.js";
7
7
  export {
8
8
  DEFAULT_PORT,
9
9
  createServer,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crvouga/mockingbird-service-workos",
3
- "version": "1.0.0",
3
+ "version": "1.1.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",
@@ -102,7 +102,7 @@
102
102
  "pack:check": "bun ../../../scripts/pack-check.ts"
103
103
  },
104
104
  "dependencies": {
105
- "@crvouga/mockingbird-service-sqlite": "3.1.0",
105
+ "@crvouga/mockingbird-service-sqlite": "3.2.0",
106
106
  "hono": "4.11.9"
107
107
  },
108
108
  "devDependencies": {