@crvouga/mockingbird-service-rxvortex 3.0.0 → 3.2.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 +16 -4
- package/DISCOVERY.md +2 -2
- package/README.md +8 -8
- package/SUPPORT.md +2 -2
- package/dist/{chunk-MDYMFXBM.js → chunk-7HMXBWW2.js} +8 -6
- package/dist/chunk-7HMXBWW2.js.map +7 -0
- package/dist/{chunk-GSV6JLPE.js → chunk-V2QVAS5F.js} +260 -172
- package/dist/chunk-V2QVAS5F.js.map +7 -0
- package/dist/cli.js +2 -2
- package/dist/index.d.ts +96 -81
- package/dist/index.js +1 -1
- package/dist/server.d.ts +141 -108
- package/dist/server.js +2 -2
- package/openapi.yaml +1 -1
- package/package.json +3 -3
- package/dist/chunk-GSV6JLPE.js.map +0 -7
- package/dist/chunk-MDYMFXBM.js.map +0 -7
package/dist/cli.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -10,88 +10,16 @@ interface FetchAPI$1 {
|
|
|
10
10
|
fetch(request: Request): Promise<Response>;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
type MountedAPI = FetchAPI & {
|
|
14
|
+
readonly prefix: string;
|
|
15
|
+
GET: FetchHandler;
|
|
16
|
+
POST: FetchHandler;
|
|
17
|
+
PUT: FetchHandler;
|
|
18
|
+
PATCH: FetchHandler;
|
|
19
|
+
DELETE: FetchHandler;
|
|
20
|
+
HEAD: FetchHandler;
|
|
21
|
+
OPTIONS: FetchHandler;
|
|
19
22
|
};
|
|
20
|
-
/**
|
|
21
|
-
* Prepared statement bound to a {@link SqliteClient}.
|
|
22
|
-
*
|
|
23
|
-
* Pass bind values as rest arguments on each call (no sticky `bind()`).
|
|
24
|
-
*/
|
|
25
|
-
interface SqliteStatement$1 {
|
|
26
|
-
run(...params: SqliteValue$1[]): SqliteRunResult$1;
|
|
27
|
-
all<T = Record<string, unknown>>(...params: SqliteValue$1[]): T[];
|
|
28
|
-
get<T = Record<string, unknown>>(...params: SqliteValue$1[]): T | undefined;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Sync SQLite client port owned by Mockingbird.
|
|
32
|
-
*
|
|
33
|
-
* Duck-typed so `@crvouga/mockingbird-service-sqlite` `Database`, better-sqlite3, and wrapped
|
|
34
|
-
* `bun:sqlite` instances all work when they expose this surface.
|
|
35
|
-
*/
|
|
36
|
-
interface SqliteClient$1 {
|
|
37
|
-
exec(sql: string): void;
|
|
38
|
-
prepare(sql: string): SqliteStatement$1;
|
|
39
|
-
transaction<T>(fn: () => T): T;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/** Every stored record carries a monotonically increasing sequence for stable ordering. */
|
|
43
|
-
type Stored<T> = {
|
|
44
|
-
seq: number;
|
|
45
|
-
value: T;
|
|
46
|
-
};
|
|
47
|
-
type ListRecordsOptions<T> = {
|
|
48
|
-
/** Keep only records passing the predicate. */
|
|
49
|
-
where?: (value: T, seq: number) => boolean;
|
|
50
|
-
/** Sort order; default newest first. */
|
|
51
|
-
order?: "newest" | "oldest";
|
|
52
|
-
};
|
|
53
|
-
/**
|
|
54
|
-
* A SQLite-backed table of JSON records addressed by id. Ordering is by insertion
|
|
55
|
-
* sequence, never by id lexicographic order, so list semantics stay stable.
|
|
56
|
-
*/
|
|
57
|
-
declare class Collection<T> {
|
|
58
|
-
private readonly sqlite;
|
|
59
|
-
/** Storage namespace. Admin introspection uses this to ignore another namespace's tables. */
|
|
60
|
-
readonly namespace: string;
|
|
61
|
-
/** Table name inside the namespace. Stable across resets of the rows themselves. */
|
|
62
|
-
readonly collectionName: string;
|
|
63
|
-
constructor(sqlite: SqliteClient$1,
|
|
64
|
-
/** Storage namespace. Admin introspection uses this to ignore another namespace's tables. */
|
|
65
|
-
namespace: string,
|
|
66
|
-
/** Table name inside the namespace. Stable across resets of the rows themselves. */
|
|
67
|
-
collectionName: string);
|
|
68
|
-
private bumpCollectionSeq;
|
|
69
|
-
nextSequence(): number;
|
|
70
|
-
get(id: string): T | undefined;
|
|
71
|
-
has(id: string): boolean;
|
|
72
|
-
/** Insert a new record, assigning it the next sequence number. */
|
|
73
|
-
insert(id: string, value: T): Stored<T>;
|
|
74
|
-
/** Replace an existing record's value, keeping its position. */
|
|
75
|
-
update(id: string, value: T): Stored<T> | undefined;
|
|
76
|
-
delete(id: string): boolean;
|
|
77
|
-
/** How many records the collection holds, without reading them. */
|
|
78
|
-
count(): number;
|
|
79
|
-
list(options?: ListRecordsOptions<T>): Array<Stored<T> & {
|
|
80
|
-
id: string;
|
|
81
|
-
}>;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Sequential id source persisted in SQLite. Ids are deterministic for a given
|
|
86
|
-
* sequence history (`cus_` + 14 opaque chars), so reproductions stay stable.
|
|
87
|
-
*/
|
|
88
|
-
declare class IdSequence {
|
|
89
|
-
private readonly sqlite;
|
|
90
|
-
private readonly namespace;
|
|
91
|
-
private readonly salt;
|
|
92
|
-
constructor(sqlite: SqliteClient$1, namespace: string, salt?: string);
|
|
93
|
-
next(prefix: string, length?: number): string;
|
|
94
|
-
}
|
|
95
23
|
|
|
96
24
|
/** A stable identifier for a point in a {@link Timeline}. */
|
|
97
25
|
type CheckpointId = string;
|
|
@@ -182,6 +110,91 @@ declare class Timeline<T> {
|
|
|
182
110
|
interface FetchAPI {
|
|
183
111
|
fetch(request: Request): Promise<Response>;
|
|
184
112
|
}
|
|
113
|
+
/** A bare function form of {@link FetchAPI}, compatible with `Bun.serve`, workerd, and Deno. */
|
|
114
|
+
type FetchHandler = (request: Request) => Promise<Response>;
|
|
115
|
+
|
|
116
|
+
/** Bind values accepted by Mockingbird's SQLite port (matches sqlite-mem / better-sqlite3). */
|
|
117
|
+
type SqliteValue$1 = null | number | bigint | string | Uint8Array | boolean;
|
|
118
|
+
/** Mutation counters returned by {@link SqliteStatement.run}. */
|
|
119
|
+
type SqliteRunResult$1 = {
|
|
120
|
+
changes: number;
|
|
121
|
+
lastInsertRowid: number | bigint;
|
|
122
|
+
};
|
|
123
|
+
/**
|
|
124
|
+
* Prepared statement bound to a {@link SqliteClient}.
|
|
125
|
+
*
|
|
126
|
+
* Pass bind values as rest arguments on each call (no sticky `bind()`).
|
|
127
|
+
*/
|
|
128
|
+
interface SqliteStatement$1 {
|
|
129
|
+
run(...params: SqliteValue$1[]): SqliteRunResult$1;
|
|
130
|
+
all<T = Record<string, unknown>>(...params: SqliteValue$1[]): T[];
|
|
131
|
+
get<T = Record<string, unknown>>(...params: SqliteValue$1[]): T | undefined;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Sync SQLite client port owned by Mockingbird.
|
|
135
|
+
*
|
|
136
|
+
* Duck-typed so `@crvouga/mockingbird-service-sqlite` `Database`, better-sqlite3, and wrapped
|
|
137
|
+
* `bun:sqlite` instances all work when they expose this surface.
|
|
138
|
+
*/
|
|
139
|
+
interface SqliteClient$1 {
|
|
140
|
+
exec(sql: string): void;
|
|
141
|
+
prepare(sql: string): SqliteStatement$1;
|
|
142
|
+
transaction<T>(fn: () => T): T;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** Every stored record carries a monotonically increasing sequence for stable ordering. */
|
|
146
|
+
type Stored<T> = {
|
|
147
|
+
seq: number;
|
|
148
|
+
value: T;
|
|
149
|
+
};
|
|
150
|
+
type ListRecordsOptions<T> = {
|
|
151
|
+
/** Keep only records passing the predicate. */
|
|
152
|
+
where?: (value: T, seq: number) => boolean;
|
|
153
|
+
/** Sort order; default newest first. */
|
|
154
|
+
order?: "newest" | "oldest";
|
|
155
|
+
};
|
|
156
|
+
/**
|
|
157
|
+
* A SQLite-backed table of JSON records addressed by id. Ordering is by insertion
|
|
158
|
+
* sequence, never by id lexicographic order, so list semantics stay stable.
|
|
159
|
+
*/
|
|
160
|
+
declare class Collection<T> {
|
|
161
|
+
private readonly sqlite;
|
|
162
|
+
/** Storage namespace. Admin introspection uses this to ignore another namespace's tables. */
|
|
163
|
+
readonly namespace: string;
|
|
164
|
+
/** Table name inside the namespace. Stable across resets of the rows themselves. */
|
|
165
|
+
readonly collectionName: string;
|
|
166
|
+
constructor(sqlite: SqliteClient$1,
|
|
167
|
+
/** Storage namespace. Admin introspection uses this to ignore another namespace's tables. */
|
|
168
|
+
namespace: string,
|
|
169
|
+
/** Table name inside the namespace. Stable across resets of the rows themselves. */
|
|
170
|
+
collectionName: string);
|
|
171
|
+
private bumpCollectionSeq;
|
|
172
|
+
nextSequence(): number;
|
|
173
|
+
get(id: string): T | undefined;
|
|
174
|
+
has(id: string): boolean;
|
|
175
|
+
/** Insert a new record, assigning it the next sequence number. */
|
|
176
|
+
insert(id: string, value: T): Stored<T>;
|
|
177
|
+
/** Replace an existing record's value, keeping its position. */
|
|
178
|
+
update(id: string, value: T): Stored<T> | undefined;
|
|
179
|
+
delete(id: string): boolean;
|
|
180
|
+
/** How many records the collection holds, without reading them. */
|
|
181
|
+
count(): number;
|
|
182
|
+
list(options?: ListRecordsOptions<T>): Array<Stored<T> & {
|
|
183
|
+
id: string;
|
|
184
|
+
}>;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Sequential id source persisted in SQLite. Ids are deterministic for a given
|
|
189
|
+
* sequence history (`cus_` + 14 opaque chars), so reproductions stay stable.
|
|
190
|
+
*/
|
|
191
|
+
declare class IdSequence {
|
|
192
|
+
private readonly sqlite;
|
|
193
|
+
private readonly namespace;
|
|
194
|
+
private readonly salt;
|
|
195
|
+
constructor(sqlite: SqliteClient$1, namespace: string, salt?: string);
|
|
196
|
+
next(prefix: string, length?: number): string;
|
|
197
|
+
}
|
|
185
198
|
|
|
186
199
|
/** Options every provider constructor accepts. */
|
|
187
200
|
type APIOptions = {
|
|
@@ -624,6 +637,8 @@ type ServiceRuntime<T extends ServiceInstance> = FetchAPI & {
|
|
|
624
637
|
/** Stop package-owned lifecycle timers when a supervisor closes the runtime. */
|
|
625
638
|
stop?(): void;
|
|
626
639
|
readonly name: string;
|
|
640
|
+
/** Same-origin Fetch handler and App Router method exports, sharing this runtime. */
|
|
641
|
+
mount(prefix: string): MountedAPI;
|
|
627
642
|
readonly sqlite: SqliteClient$1;
|
|
628
643
|
readonly clock: Clock;
|
|
629
644
|
readonly faults: FaultRegistry;
|
package/dist/index.js
CHANGED
package/dist/server.d.ts
CHANGED
|
@@ -1,34 +1,16 @@
|
|
|
1
1
|
import { Server } from 'node:http';
|
|
2
2
|
import { Hono } from 'hono';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
type MountedAPI$1 = FetchAPI$2 & {
|
|
5
|
+
readonly prefix: string;
|
|
6
|
+
GET: FetchHandler$1;
|
|
7
|
+
POST: FetchHandler$1;
|
|
8
|
+
PUT: FetchHandler$1;
|
|
9
|
+
PATCH: FetchHandler$1;
|
|
10
|
+
DELETE: FetchHandler$1;
|
|
11
|
+
HEAD: FetchHandler$1;
|
|
12
|
+
OPTIONS: FetchHandler$1;
|
|
10
13
|
};
|
|
11
|
-
/**
|
|
12
|
-
* Prepared statement bound to a {@link SqliteClient}.
|
|
13
|
-
*
|
|
14
|
-
* Pass bind values as rest arguments on each call (no sticky `bind()`).
|
|
15
|
-
*/
|
|
16
|
-
interface SqliteStatement$2 {
|
|
17
|
-
run(...params: SqliteValue$2[]): SqliteRunResult$2;
|
|
18
|
-
all<T = Record<string, unknown>>(...params: SqliteValue$2[]): T[];
|
|
19
|
-
get<T = Record<string, unknown>>(...params: SqliteValue$2[]): T | undefined;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Sync SQLite client port owned by Mockingbird.
|
|
23
|
-
*
|
|
24
|
-
* Duck-typed so `@crvouga/mockingbird-service-sqlite` `Database`, better-sqlite3, and wrapped
|
|
25
|
-
* `bun:sqlite` instances all work when they expose this surface.
|
|
26
|
-
*/
|
|
27
|
-
interface SqliteClient$2 {
|
|
28
|
-
exec(sql: string): void;
|
|
29
|
-
prepare(sql: string): SqliteStatement$2;
|
|
30
|
-
transaction<T>(fn: () => T): T;
|
|
31
|
-
}
|
|
32
14
|
|
|
33
15
|
/** A stable identifier for a point in a {@link Timeline}. */
|
|
34
16
|
type CheckpointId$1 = string;
|
|
@@ -119,6 +101,37 @@ declare class Timeline$1<T> {
|
|
|
119
101
|
interface FetchAPI$2 {
|
|
120
102
|
fetch(request: Request): Promise<Response>;
|
|
121
103
|
}
|
|
104
|
+
/** A bare function form of {@link FetchAPI}, compatible with `Bun.serve`, workerd, and Deno. */
|
|
105
|
+
type FetchHandler$1 = (request: Request) => Promise<Response>;
|
|
106
|
+
|
|
107
|
+
/** Bind values accepted by Mockingbird's SQLite port (matches sqlite-mem / better-sqlite3). */
|
|
108
|
+
type SqliteValue$2 = null | number | bigint | string | Uint8Array | boolean;
|
|
109
|
+
/** Mutation counters returned by {@link SqliteStatement.run}. */
|
|
110
|
+
type SqliteRunResult$2 = {
|
|
111
|
+
changes: number;
|
|
112
|
+
lastInsertRowid: number | bigint;
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* Prepared statement bound to a {@link SqliteClient}.
|
|
116
|
+
*
|
|
117
|
+
* Pass bind values as rest arguments on each call (no sticky `bind()`).
|
|
118
|
+
*/
|
|
119
|
+
interface SqliteStatement$2 {
|
|
120
|
+
run(...params: SqliteValue$2[]): SqliteRunResult$2;
|
|
121
|
+
all<T = Record<string, unknown>>(...params: SqliteValue$2[]): T[];
|
|
122
|
+
get<T = Record<string, unknown>>(...params: SqliteValue$2[]): T | undefined;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Sync SQLite client port owned by Mockingbird.
|
|
126
|
+
*
|
|
127
|
+
* Duck-typed so `@crvouga/mockingbird-service-sqlite` `Database`, better-sqlite3, and wrapped
|
|
128
|
+
* `bun:sqlite` instances all work when they expose this surface.
|
|
129
|
+
*/
|
|
130
|
+
interface SqliteClient$2 {
|
|
131
|
+
exec(sql: string): void;
|
|
132
|
+
prepare(sql: string): SqliteStatement$2;
|
|
133
|
+
transaction<T>(fn: () => T): T;
|
|
134
|
+
}
|
|
122
135
|
|
|
123
136
|
/**
|
|
124
137
|
* The single source of time for a service.
|
|
@@ -535,6 +548,8 @@ type ServiceRuntime$1<T extends ServiceInstance$1> = FetchAPI$2 & {
|
|
|
535
548
|
/** Stop package-owned lifecycle timers when a supervisor closes the runtime. */
|
|
536
549
|
stop?(): void;
|
|
537
550
|
readonly name: string;
|
|
551
|
+
/** Same-origin Fetch handler and App Router method exports, sharing this runtime. */
|
|
552
|
+
mount(prefix: string): MountedAPI$1;
|
|
538
553
|
readonly sqlite: SqliteClient$2;
|
|
539
554
|
readonly clock: Clock$1;
|
|
540
555
|
readonly faults: FaultRegistry$1;
|
|
@@ -601,6 +616,9 @@ type CommonServeOptions = {
|
|
|
601
616
|
adminKey: string | undefined;
|
|
602
617
|
seed: string | undefined;
|
|
603
618
|
onLog: ((entry: RequestLog$1) => void) | undefined;
|
|
619
|
+
/** Synthetic provider fixture objects supplied by a fleet entry. */
|
|
620
|
+
fixtures?: Record<string, unknown>;
|
|
621
|
+
baseUrl?: string;
|
|
604
622
|
};
|
|
605
623
|
/**
|
|
606
624
|
* What a service contributes to `serve`: how to build its runtime from CLI flags,
|
|
@@ -633,88 +651,16 @@ type CatalogItem = {
|
|
|
633
651
|
status: "active" | "inactive";
|
|
634
652
|
};
|
|
635
653
|
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
654
|
+
type MountedAPI = FetchAPI$1 & {
|
|
655
|
+
readonly prefix: string;
|
|
656
|
+
GET: FetchHandler;
|
|
657
|
+
POST: FetchHandler;
|
|
658
|
+
PUT: FetchHandler;
|
|
659
|
+
PATCH: FetchHandler;
|
|
660
|
+
DELETE: FetchHandler;
|
|
661
|
+
HEAD: FetchHandler;
|
|
662
|
+
OPTIONS: FetchHandler;
|
|
642
663
|
};
|
|
643
|
-
/**
|
|
644
|
-
* Prepared statement bound to a {@link SqliteClient}.
|
|
645
|
-
*
|
|
646
|
-
* Pass bind values as rest arguments on each call (no sticky `bind()`).
|
|
647
|
-
*/
|
|
648
|
-
interface SqliteStatement$1 {
|
|
649
|
-
run(...params: SqliteValue$1[]): SqliteRunResult$1;
|
|
650
|
-
all<T = Record<string, unknown>>(...params: SqliteValue$1[]): T[];
|
|
651
|
-
get<T = Record<string, unknown>>(...params: SqliteValue$1[]): T | undefined;
|
|
652
|
-
}
|
|
653
|
-
/**
|
|
654
|
-
* Sync SQLite client port owned by Mockingbird.
|
|
655
|
-
*
|
|
656
|
-
* Duck-typed so `@crvouga/mockingbird-service-sqlite` `Database`, better-sqlite3, and wrapped
|
|
657
|
-
* `bun:sqlite` instances all work when they expose this surface.
|
|
658
|
-
*/
|
|
659
|
-
interface SqliteClient$1 {
|
|
660
|
-
exec(sql: string): void;
|
|
661
|
-
prepare(sql: string): SqliteStatement$1;
|
|
662
|
-
transaction<T>(fn: () => T): T;
|
|
663
|
-
}
|
|
664
|
-
|
|
665
|
-
/** Every stored record carries a monotonically increasing sequence for stable ordering. */
|
|
666
|
-
type Stored<T> = {
|
|
667
|
-
seq: number;
|
|
668
|
-
value: T;
|
|
669
|
-
};
|
|
670
|
-
type ListRecordsOptions<T> = {
|
|
671
|
-
/** Keep only records passing the predicate. */
|
|
672
|
-
where?: (value: T, seq: number) => boolean;
|
|
673
|
-
/** Sort order; default newest first. */
|
|
674
|
-
order?: "newest" | "oldest";
|
|
675
|
-
};
|
|
676
|
-
/**
|
|
677
|
-
* A SQLite-backed table of JSON records addressed by id. Ordering is by insertion
|
|
678
|
-
* sequence, never by id lexicographic order, so list semantics stay stable.
|
|
679
|
-
*/
|
|
680
|
-
declare class Collection<T> {
|
|
681
|
-
private readonly sqlite;
|
|
682
|
-
/** Storage namespace. Admin introspection uses this to ignore another namespace's tables. */
|
|
683
|
-
readonly namespace: string;
|
|
684
|
-
/** Table name inside the namespace. Stable across resets of the rows themselves. */
|
|
685
|
-
readonly collectionName: string;
|
|
686
|
-
constructor(sqlite: SqliteClient$1,
|
|
687
|
-
/** Storage namespace. Admin introspection uses this to ignore another namespace's tables. */
|
|
688
|
-
namespace: string,
|
|
689
|
-
/** Table name inside the namespace. Stable across resets of the rows themselves. */
|
|
690
|
-
collectionName: string);
|
|
691
|
-
private bumpCollectionSeq;
|
|
692
|
-
nextSequence(): number;
|
|
693
|
-
get(id: string): T | undefined;
|
|
694
|
-
has(id: string): boolean;
|
|
695
|
-
/** Insert a new record, assigning it the next sequence number. */
|
|
696
|
-
insert(id: string, value: T): Stored<T>;
|
|
697
|
-
/** Replace an existing record's value, keeping its position. */
|
|
698
|
-
update(id: string, value: T): Stored<T> | undefined;
|
|
699
|
-
delete(id: string): boolean;
|
|
700
|
-
/** How many records the collection holds, without reading them. */
|
|
701
|
-
count(): number;
|
|
702
|
-
list(options?: ListRecordsOptions<T>): Array<Stored<T> & {
|
|
703
|
-
id: string;
|
|
704
|
-
}>;
|
|
705
|
-
}
|
|
706
|
-
|
|
707
|
-
/**
|
|
708
|
-
* Sequential id source persisted in SQLite. Ids are deterministic for a given
|
|
709
|
-
* sequence history (`cus_` + 14 opaque chars), so reproductions stay stable.
|
|
710
|
-
*/
|
|
711
|
-
declare class IdSequence {
|
|
712
|
-
private readonly sqlite;
|
|
713
|
-
private readonly namespace;
|
|
714
|
-
private readonly salt;
|
|
715
|
-
constructor(sqlite: SqliteClient$1, namespace: string, salt?: string);
|
|
716
|
-
next(prefix: string, length?: number): string;
|
|
717
|
-
}
|
|
718
664
|
|
|
719
665
|
/** A stable identifier for a point in a {@link Timeline}. */
|
|
720
666
|
type CheckpointId = string;
|
|
@@ -805,6 +751,91 @@ declare class Timeline<T> {
|
|
|
805
751
|
interface FetchAPI$1 {
|
|
806
752
|
fetch(request: Request): Promise<Response>;
|
|
807
753
|
}
|
|
754
|
+
/** A bare function form of {@link FetchAPI}, compatible with `Bun.serve`, workerd, and Deno. */
|
|
755
|
+
type FetchHandler = (request: Request) => Promise<Response>;
|
|
756
|
+
|
|
757
|
+
/** Bind values accepted by Mockingbird's SQLite port (matches sqlite-mem / better-sqlite3). */
|
|
758
|
+
type SqliteValue$1 = null | number | bigint | string | Uint8Array | boolean;
|
|
759
|
+
/** Mutation counters returned by {@link SqliteStatement.run}. */
|
|
760
|
+
type SqliteRunResult$1 = {
|
|
761
|
+
changes: number;
|
|
762
|
+
lastInsertRowid: number | bigint;
|
|
763
|
+
};
|
|
764
|
+
/**
|
|
765
|
+
* Prepared statement bound to a {@link SqliteClient}.
|
|
766
|
+
*
|
|
767
|
+
* Pass bind values as rest arguments on each call (no sticky `bind()`).
|
|
768
|
+
*/
|
|
769
|
+
interface SqliteStatement$1 {
|
|
770
|
+
run(...params: SqliteValue$1[]): SqliteRunResult$1;
|
|
771
|
+
all<T = Record<string, unknown>>(...params: SqliteValue$1[]): T[];
|
|
772
|
+
get<T = Record<string, unknown>>(...params: SqliteValue$1[]): T | undefined;
|
|
773
|
+
}
|
|
774
|
+
/**
|
|
775
|
+
* Sync SQLite client port owned by Mockingbird.
|
|
776
|
+
*
|
|
777
|
+
* Duck-typed so `@crvouga/mockingbird-service-sqlite` `Database`, better-sqlite3, and wrapped
|
|
778
|
+
* `bun:sqlite` instances all work when they expose this surface.
|
|
779
|
+
*/
|
|
780
|
+
interface SqliteClient$1 {
|
|
781
|
+
exec(sql: string): void;
|
|
782
|
+
prepare(sql: string): SqliteStatement$1;
|
|
783
|
+
transaction<T>(fn: () => T): T;
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
/** Every stored record carries a monotonically increasing sequence for stable ordering. */
|
|
787
|
+
type Stored<T> = {
|
|
788
|
+
seq: number;
|
|
789
|
+
value: T;
|
|
790
|
+
};
|
|
791
|
+
type ListRecordsOptions<T> = {
|
|
792
|
+
/** Keep only records passing the predicate. */
|
|
793
|
+
where?: (value: T, seq: number) => boolean;
|
|
794
|
+
/** Sort order; default newest first. */
|
|
795
|
+
order?: "newest" | "oldest";
|
|
796
|
+
};
|
|
797
|
+
/**
|
|
798
|
+
* A SQLite-backed table of JSON records addressed by id. Ordering is by insertion
|
|
799
|
+
* sequence, never by id lexicographic order, so list semantics stay stable.
|
|
800
|
+
*/
|
|
801
|
+
declare class Collection<T> {
|
|
802
|
+
private readonly sqlite;
|
|
803
|
+
/** Storage namespace. Admin introspection uses this to ignore another namespace's tables. */
|
|
804
|
+
readonly namespace: string;
|
|
805
|
+
/** Table name inside the namespace. Stable across resets of the rows themselves. */
|
|
806
|
+
readonly collectionName: string;
|
|
807
|
+
constructor(sqlite: SqliteClient$1,
|
|
808
|
+
/** Storage namespace. Admin introspection uses this to ignore another namespace's tables. */
|
|
809
|
+
namespace: string,
|
|
810
|
+
/** Table name inside the namespace. Stable across resets of the rows themselves. */
|
|
811
|
+
collectionName: string);
|
|
812
|
+
private bumpCollectionSeq;
|
|
813
|
+
nextSequence(): number;
|
|
814
|
+
get(id: string): T | undefined;
|
|
815
|
+
has(id: string): boolean;
|
|
816
|
+
/** Insert a new record, assigning it the next sequence number. */
|
|
817
|
+
insert(id: string, value: T): Stored<T>;
|
|
818
|
+
/** Replace an existing record's value, keeping its position. */
|
|
819
|
+
update(id: string, value: T): Stored<T> | undefined;
|
|
820
|
+
delete(id: string): boolean;
|
|
821
|
+
/** How many records the collection holds, without reading them. */
|
|
822
|
+
count(): number;
|
|
823
|
+
list(options?: ListRecordsOptions<T>): Array<Stored<T> & {
|
|
824
|
+
id: string;
|
|
825
|
+
}>;
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
/**
|
|
829
|
+
* Sequential id source persisted in SQLite. Ids are deterministic for a given
|
|
830
|
+
* sequence history (`cus_` + 14 opaque chars), so reproductions stay stable.
|
|
831
|
+
*/
|
|
832
|
+
declare class IdSequence {
|
|
833
|
+
private readonly sqlite;
|
|
834
|
+
private readonly namespace;
|
|
835
|
+
private readonly salt;
|
|
836
|
+
constructor(sqlite: SqliteClient$1, namespace: string, salt?: string);
|
|
837
|
+
next(prefix: string, length?: number): string;
|
|
838
|
+
}
|
|
808
839
|
|
|
809
840
|
/** Options every provider constructor accepts. */
|
|
810
841
|
type APIOptions = {
|
|
@@ -1234,6 +1265,8 @@ type ServiceRuntime<T extends ServiceInstance> = FetchAPI$1 & {
|
|
|
1234
1265
|
/** Stop package-owned lifecycle timers when a supervisor closes the runtime. */
|
|
1235
1266
|
stop?(): void;
|
|
1236
1267
|
readonly name: string;
|
|
1268
|
+
/** Same-origin Fetch handler and App Router method exports, sharing this runtime. */
|
|
1269
|
+
mount(prefix: string): MountedAPI;
|
|
1237
1270
|
readonly sqlite: SqliteClient$1;
|
|
1238
1271
|
readonly clock: Clock;
|
|
1239
1272
|
readonly faults: FaultRegistry;
|
package/dist/server.js
CHANGED
package/openapi.yaml
CHANGED
|
@@ -2,7 +2,7 @@ openapi: 3.1.0
|
|
|
2
2
|
info:
|
|
3
3
|
title: RxVortex (Strive) pharmacy API (Mockingbird subset)
|
|
4
4
|
description: |
|
|
5
|
-
Stateful
|
|
5
|
+
Stateful emulator subset of the RxVortex / Strive compounding-pharmacy API: client-credentials
|
|
6
6
|
token, order submit, status, cancel, lookup by sender order id (recovery), and the preset
|
|
7
7
|
catalog. Hand-authored from the consumer's adapters (the vendor publishes no spec).
|
|
8
8
|
version: "1"
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crvouga/mockingbird-service-rxvortex",
|
|
3
|
-
"version": "3.
|
|
4
|
-
"description": "Stateful
|
|
3
|
+
"version": "3.2.0",
|
|
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",
|
|
7
7
|
"sideEffects": false,
|
|
@@ -97,7 +97,7 @@
|
|
|
97
97
|
"pack:check": "bun ../../../scripts/pack-check.ts"
|
|
98
98
|
},
|
|
99
99
|
"dependencies": {
|
|
100
|
-
"@crvouga/mockingbird-service-sqlite": "3.
|
|
100
|
+
"@crvouga/mockingbird-service-sqlite": "3.2.0",
|
|
101
101
|
"hono": "4.11.9"
|
|
102
102
|
},
|
|
103
103
|
"devDependencies": {
|