@crvouga/mockingbird-service-prism 3.1.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 +8 -2
- package/dist/{chunk-BXFWX7GE.js → chunk-CFRVKHYC.js} +5 -3
- package/dist/chunk-CFRVKHYC.js.map +7 -0
- package/dist/{chunk-SF36BO5M.js → chunk-HLKYLL64.js} +258 -170
- package/dist/chunk-HLKYLL64.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/package.json +2 -2
- package/dist/chunk-BXFWX7GE.js.map +0 -7
- package/dist/chunk-SF36BO5M.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,
|
|
@@ -619,88 +637,16 @@ type ServeTarget = {
|
|
|
619
637
|
listening?(server: Listening): void;
|
|
620
638
|
};
|
|
621
639
|
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
640
|
+
type MountedAPI = FetchAPI$1 & {
|
|
641
|
+
readonly prefix: string;
|
|
642
|
+
GET: FetchHandler;
|
|
643
|
+
POST: FetchHandler;
|
|
644
|
+
PUT: FetchHandler;
|
|
645
|
+
PATCH: FetchHandler;
|
|
646
|
+
DELETE: FetchHandler;
|
|
647
|
+
HEAD: FetchHandler;
|
|
648
|
+
OPTIONS: FetchHandler;
|
|
628
649
|
};
|
|
629
|
-
/**
|
|
630
|
-
* Prepared statement bound to a {@link SqliteClient}.
|
|
631
|
-
*
|
|
632
|
-
* Pass bind values as rest arguments on each call (no sticky `bind()`).
|
|
633
|
-
*/
|
|
634
|
-
interface SqliteStatement$1 {
|
|
635
|
-
run(...params: SqliteValue$1[]): SqliteRunResult$1;
|
|
636
|
-
all<T = Record<string, unknown>>(...params: SqliteValue$1[]): T[];
|
|
637
|
-
get<T = Record<string, unknown>>(...params: SqliteValue$1[]): T | undefined;
|
|
638
|
-
}
|
|
639
|
-
/**
|
|
640
|
-
* Sync SQLite client port owned by Mockingbird.
|
|
641
|
-
*
|
|
642
|
-
* Duck-typed so `@crvouga/mockingbird-service-sqlite` `Database`, better-sqlite3, and wrapped
|
|
643
|
-
* `bun:sqlite` instances all work when they expose this surface.
|
|
644
|
-
*/
|
|
645
|
-
interface SqliteClient$1 {
|
|
646
|
-
exec(sql: string): void;
|
|
647
|
-
prepare(sql: string): SqliteStatement$1;
|
|
648
|
-
transaction<T>(fn: () => T): T;
|
|
649
|
-
}
|
|
650
|
-
|
|
651
|
-
/** Every stored record carries a monotonically increasing sequence for stable ordering. */
|
|
652
|
-
type Stored<T> = {
|
|
653
|
-
seq: number;
|
|
654
|
-
value: T;
|
|
655
|
-
};
|
|
656
|
-
type ListRecordsOptions<T> = {
|
|
657
|
-
/** Keep only records passing the predicate. */
|
|
658
|
-
where?: (value: T, seq: number) => boolean;
|
|
659
|
-
/** Sort order; default newest first. */
|
|
660
|
-
order?: "newest" | "oldest";
|
|
661
|
-
};
|
|
662
|
-
/**
|
|
663
|
-
* A SQLite-backed table of JSON records addressed by id. Ordering is by insertion
|
|
664
|
-
* sequence, never by id lexicographic order, so list semantics stay stable.
|
|
665
|
-
*/
|
|
666
|
-
declare class Collection<T> {
|
|
667
|
-
private readonly sqlite;
|
|
668
|
-
/** Storage namespace. Admin introspection uses this to ignore another namespace's tables. */
|
|
669
|
-
readonly namespace: string;
|
|
670
|
-
/** Table name inside the namespace. Stable across resets of the rows themselves. */
|
|
671
|
-
readonly collectionName: string;
|
|
672
|
-
constructor(sqlite: SqliteClient$1,
|
|
673
|
-
/** Storage namespace. Admin introspection uses this to ignore another namespace's tables. */
|
|
674
|
-
namespace: string,
|
|
675
|
-
/** Table name inside the namespace. Stable across resets of the rows themselves. */
|
|
676
|
-
collectionName: string);
|
|
677
|
-
private bumpCollectionSeq;
|
|
678
|
-
nextSequence(): number;
|
|
679
|
-
get(id: string): T | undefined;
|
|
680
|
-
has(id: string): boolean;
|
|
681
|
-
/** Insert a new record, assigning it the next sequence number. */
|
|
682
|
-
insert(id: string, value: T): Stored<T>;
|
|
683
|
-
/** Replace an existing record's value, keeping its position. */
|
|
684
|
-
update(id: string, value: T): Stored<T> | undefined;
|
|
685
|
-
delete(id: string): boolean;
|
|
686
|
-
/** How many records the collection holds, without reading them. */
|
|
687
|
-
count(): number;
|
|
688
|
-
list(options?: ListRecordsOptions<T>): Array<Stored<T> & {
|
|
689
|
-
id: string;
|
|
690
|
-
}>;
|
|
691
|
-
}
|
|
692
|
-
|
|
693
|
-
/**
|
|
694
|
-
* Sequential id source persisted in SQLite. Ids are deterministic for a given
|
|
695
|
-
* sequence history (`cus_` + 14 opaque chars), so reproductions stay stable.
|
|
696
|
-
*/
|
|
697
|
-
declare class IdSequence {
|
|
698
|
-
private readonly sqlite;
|
|
699
|
-
private readonly namespace;
|
|
700
|
-
private readonly salt;
|
|
701
|
-
constructor(sqlite: SqliteClient$1, namespace: string, salt?: string);
|
|
702
|
-
next(prefix: string, length?: number): string;
|
|
703
|
-
}
|
|
704
650
|
|
|
705
651
|
/** A stable identifier for a point in a {@link Timeline}. */
|
|
706
652
|
type CheckpointId = string;
|
|
@@ -791,6 +737,91 @@ declare class Timeline<T> {
|
|
|
791
737
|
interface FetchAPI$1 {
|
|
792
738
|
fetch(request: Request): Promise<Response>;
|
|
793
739
|
}
|
|
740
|
+
/** A bare function form of {@link FetchAPI}, compatible with `Bun.serve`, workerd, and Deno. */
|
|
741
|
+
type FetchHandler = (request: Request) => Promise<Response>;
|
|
742
|
+
|
|
743
|
+
/** Bind values accepted by Mockingbird's SQLite port (matches sqlite-mem / better-sqlite3). */
|
|
744
|
+
type SqliteValue$1 = null | number | bigint | string | Uint8Array | boolean;
|
|
745
|
+
/** Mutation counters returned by {@link SqliteStatement.run}. */
|
|
746
|
+
type SqliteRunResult$1 = {
|
|
747
|
+
changes: number;
|
|
748
|
+
lastInsertRowid: number | bigint;
|
|
749
|
+
};
|
|
750
|
+
/**
|
|
751
|
+
* Prepared statement bound to a {@link SqliteClient}.
|
|
752
|
+
*
|
|
753
|
+
* Pass bind values as rest arguments on each call (no sticky `bind()`).
|
|
754
|
+
*/
|
|
755
|
+
interface SqliteStatement$1 {
|
|
756
|
+
run(...params: SqliteValue$1[]): SqliteRunResult$1;
|
|
757
|
+
all<T = Record<string, unknown>>(...params: SqliteValue$1[]): T[];
|
|
758
|
+
get<T = Record<string, unknown>>(...params: SqliteValue$1[]): T | undefined;
|
|
759
|
+
}
|
|
760
|
+
/**
|
|
761
|
+
* Sync SQLite client port owned by Mockingbird.
|
|
762
|
+
*
|
|
763
|
+
* Duck-typed so `@crvouga/mockingbird-service-sqlite` `Database`, better-sqlite3, and wrapped
|
|
764
|
+
* `bun:sqlite` instances all work when they expose this surface.
|
|
765
|
+
*/
|
|
766
|
+
interface SqliteClient$1 {
|
|
767
|
+
exec(sql: string): void;
|
|
768
|
+
prepare(sql: string): SqliteStatement$1;
|
|
769
|
+
transaction<T>(fn: () => T): T;
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
/** Every stored record carries a monotonically increasing sequence for stable ordering. */
|
|
773
|
+
type Stored<T> = {
|
|
774
|
+
seq: number;
|
|
775
|
+
value: T;
|
|
776
|
+
};
|
|
777
|
+
type ListRecordsOptions<T> = {
|
|
778
|
+
/** Keep only records passing the predicate. */
|
|
779
|
+
where?: (value: T, seq: number) => boolean;
|
|
780
|
+
/** Sort order; default newest first. */
|
|
781
|
+
order?: "newest" | "oldest";
|
|
782
|
+
};
|
|
783
|
+
/**
|
|
784
|
+
* A SQLite-backed table of JSON records addressed by id. Ordering is by insertion
|
|
785
|
+
* sequence, never by id lexicographic order, so list semantics stay stable.
|
|
786
|
+
*/
|
|
787
|
+
declare class Collection<T> {
|
|
788
|
+
private readonly sqlite;
|
|
789
|
+
/** Storage namespace. Admin introspection uses this to ignore another namespace's tables. */
|
|
790
|
+
readonly namespace: string;
|
|
791
|
+
/** Table name inside the namespace. Stable across resets of the rows themselves. */
|
|
792
|
+
readonly collectionName: string;
|
|
793
|
+
constructor(sqlite: SqliteClient$1,
|
|
794
|
+
/** Storage namespace. Admin introspection uses this to ignore another namespace's tables. */
|
|
795
|
+
namespace: string,
|
|
796
|
+
/** Table name inside the namespace. Stable across resets of the rows themselves. */
|
|
797
|
+
collectionName: string);
|
|
798
|
+
private bumpCollectionSeq;
|
|
799
|
+
nextSequence(): number;
|
|
800
|
+
get(id: string): T | undefined;
|
|
801
|
+
has(id: string): boolean;
|
|
802
|
+
/** Insert a new record, assigning it the next sequence number. */
|
|
803
|
+
insert(id: string, value: T): Stored<T>;
|
|
804
|
+
/** Replace an existing record's value, keeping its position. */
|
|
805
|
+
update(id: string, value: T): Stored<T> | undefined;
|
|
806
|
+
delete(id: string): boolean;
|
|
807
|
+
/** How many records the collection holds, without reading them. */
|
|
808
|
+
count(): number;
|
|
809
|
+
list(options?: ListRecordsOptions<T>): Array<Stored<T> & {
|
|
810
|
+
id: string;
|
|
811
|
+
}>;
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
/**
|
|
815
|
+
* Sequential id source persisted in SQLite. Ids are deterministic for a given
|
|
816
|
+
* sequence history (`cus_` + 14 opaque chars), so reproductions stay stable.
|
|
817
|
+
*/
|
|
818
|
+
declare class IdSequence {
|
|
819
|
+
private readonly sqlite;
|
|
820
|
+
private readonly namespace;
|
|
821
|
+
private readonly salt;
|
|
822
|
+
constructor(sqlite: SqliteClient$1, namespace: string, salt?: string);
|
|
823
|
+
next(prefix: string, length?: number): string;
|
|
824
|
+
}
|
|
794
825
|
|
|
795
826
|
/** Options every provider constructor accepts. */
|
|
796
827
|
type APIOptions = {
|
|
@@ -1220,6 +1251,8 @@ type ServiceRuntime<T extends ServiceInstance> = FetchAPI$1 & {
|
|
|
1220
1251
|
/** Stop package-owned lifecycle timers when a supervisor closes the runtime. */
|
|
1221
1252
|
stop?(): void;
|
|
1222
1253
|
readonly name: string;
|
|
1254
|
+
/** Same-origin Fetch handler and App Router method exports, sharing this runtime. */
|
|
1255
|
+
mount(prefix: string): MountedAPI;
|
|
1223
1256
|
readonly sqlite: SqliteClient$1;
|
|
1224
1257
|
readonly clock: Clock;
|
|
1225
1258
|
readonly faults: FaultRegistry;
|
package/dist/server.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crvouga/mockingbird-service-prism",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"description": "Stateful emulator of the Prism Labs body-scan API: subjects, scans, presigned capture upload, processing stages to READY, and deterministic body-composition, measurement, health-report and asset results.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
"pack:check": "bun ../../../scripts/pack-check.ts"
|
|
96
96
|
},
|
|
97
97
|
"dependencies": {
|
|
98
|
-
"@crvouga/mockingbird-service-sqlite": "3.
|
|
98
|
+
"@crvouga/mockingbird-service-sqlite": "3.2.0",
|
|
99
99
|
"hono": "4.11.9"
|
|
100
100
|
},
|
|
101
101
|
"devDependencies": {
|