@crvouga/mockingbird-service-ec2 1.1.0 → 1.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 +10 -0
- package/dist/{chunk-THUNALKH.js → chunk-DCLU5ICB.js} +5 -3
- package/dist/chunk-DCLU5ICB.js.map +7 -0
- package/dist/{chunk-W2IRXZDL.js → chunk-W6I7EHRT.js} +258 -170
- package/dist/chunk-W6I7EHRT.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-THUNALKH.js.map +0 -7
- package/dist/chunk-W2IRXZDL.js.map +0 -7
package/dist/cli.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,85 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
type MountedAPI = FetchAPI & {
|
|
2
|
+
readonly prefix: string;
|
|
3
|
+
GET: FetchHandler;
|
|
4
|
+
POST: FetchHandler;
|
|
5
|
+
PUT: FetchHandler;
|
|
6
|
+
PATCH: FetchHandler;
|
|
7
|
+
DELETE: FetchHandler;
|
|
8
|
+
HEAD: FetchHandler;
|
|
9
|
+
OPTIONS: FetchHandler;
|
|
7
10
|
};
|
|
8
|
-
/**
|
|
9
|
-
* Prepared statement bound to a {@link SqliteClient}.
|
|
10
|
-
*
|
|
11
|
-
* Pass bind values as rest arguments on each call (no sticky `bind()`).
|
|
12
|
-
*/
|
|
13
|
-
interface SqliteStatement$1 {
|
|
14
|
-
run(...params: SqliteValue$1[]): SqliteRunResult$1;
|
|
15
|
-
all<T = Record<string, unknown>>(...params: SqliteValue$1[]): T[];
|
|
16
|
-
get<T = Record<string, unknown>>(...params: SqliteValue$1[]): T | undefined;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Sync SQLite client port owned by Mockingbird.
|
|
20
|
-
*
|
|
21
|
-
* Duck-typed so `@crvouga/mockingbird-service-sqlite` `Database`, better-sqlite3, and wrapped
|
|
22
|
-
* `bun:sqlite` instances all work when they expose this surface.
|
|
23
|
-
*/
|
|
24
|
-
interface SqliteClient$1 {
|
|
25
|
-
exec(sql: string): void;
|
|
26
|
-
prepare(sql: string): SqliteStatement$1;
|
|
27
|
-
transaction<T>(fn: () => T): T;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/** Every stored record carries a monotonically increasing sequence for stable ordering. */
|
|
31
|
-
type Stored<T> = {
|
|
32
|
-
seq: number;
|
|
33
|
-
value: T;
|
|
34
|
-
};
|
|
35
|
-
type ListRecordsOptions<T> = {
|
|
36
|
-
/** Keep only records passing the predicate. */
|
|
37
|
-
where?: (value: T, seq: number) => boolean;
|
|
38
|
-
/** Sort order; default newest first. */
|
|
39
|
-
order?: "newest" | "oldest";
|
|
40
|
-
};
|
|
41
|
-
/**
|
|
42
|
-
* A SQLite-backed table of JSON records addressed by id. Ordering is by insertion
|
|
43
|
-
* sequence, never by id lexicographic order, so list semantics stay stable.
|
|
44
|
-
*/
|
|
45
|
-
declare class Collection<T> {
|
|
46
|
-
private readonly sqlite;
|
|
47
|
-
/** Storage namespace. Admin introspection uses this to ignore another namespace's tables. */
|
|
48
|
-
readonly namespace: string;
|
|
49
|
-
/** Table name inside the namespace. Stable across resets of the rows themselves. */
|
|
50
|
-
readonly collectionName: string;
|
|
51
|
-
constructor(sqlite: SqliteClient$1,
|
|
52
|
-
/** Storage namespace. Admin introspection uses this to ignore another namespace's tables. */
|
|
53
|
-
namespace: string,
|
|
54
|
-
/** Table name inside the namespace. Stable across resets of the rows themselves. */
|
|
55
|
-
collectionName: string);
|
|
56
|
-
private bumpCollectionSeq;
|
|
57
|
-
nextSequence(): number;
|
|
58
|
-
get(id: string): T | undefined;
|
|
59
|
-
has(id: string): boolean;
|
|
60
|
-
/** Insert a new record, assigning it the next sequence number. */
|
|
61
|
-
insert(id: string, value: T): Stored<T>;
|
|
62
|
-
/** Replace an existing record's value, keeping its position. */
|
|
63
|
-
update(id: string, value: T): Stored<T> | undefined;
|
|
64
|
-
delete(id: string): boolean;
|
|
65
|
-
/** How many records the collection holds, without reading them. */
|
|
66
|
-
count(): number;
|
|
67
|
-
list(options?: ListRecordsOptions<T>): Array<Stored<T> & {
|
|
68
|
-
id: string;
|
|
69
|
-
}>;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Sequential id source persisted in SQLite. Ids are deterministic for a given
|
|
74
|
-
* sequence history (`cus_` + 14 opaque chars), so reproductions stay stable.
|
|
75
|
-
*/
|
|
76
|
-
declare class IdSequence {
|
|
77
|
-
private readonly sqlite;
|
|
78
|
-
private readonly namespace;
|
|
79
|
-
private readonly salt;
|
|
80
|
-
constructor(sqlite: SqliteClient$1, namespace: string, salt?: string);
|
|
81
|
-
next(prefix: string, length?: number): string;
|
|
82
|
-
}
|
|
83
11
|
|
|
84
12
|
/** A stable identifier for a point in a {@link Timeline}. */
|
|
85
13
|
type CheckpointId = string;
|
|
@@ -170,6 +98,91 @@ declare class Timeline<T> {
|
|
|
170
98
|
interface FetchAPI {
|
|
171
99
|
fetch(request: Request): Promise<Response>;
|
|
172
100
|
}
|
|
101
|
+
/** A bare function form of {@link FetchAPI}, compatible with `Bun.serve`, workerd, and Deno. */
|
|
102
|
+
type FetchHandler = (request: Request) => Promise<Response>;
|
|
103
|
+
|
|
104
|
+
/** Bind values accepted by Mockingbird's SQLite port (matches sqlite-mem / better-sqlite3). */
|
|
105
|
+
type SqliteValue$1 = null | number | bigint | string | Uint8Array | boolean;
|
|
106
|
+
/** Mutation counters returned by {@link SqliteStatement.run}. */
|
|
107
|
+
type SqliteRunResult$1 = {
|
|
108
|
+
changes: number;
|
|
109
|
+
lastInsertRowid: number | bigint;
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* Prepared statement bound to a {@link SqliteClient}.
|
|
113
|
+
*
|
|
114
|
+
* Pass bind values as rest arguments on each call (no sticky `bind()`).
|
|
115
|
+
*/
|
|
116
|
+
interface SqliteStatement$1 {
|
|
117
|
+
run(...params: SqliteValue$1[]): SqliteRunResult$1;
|
|
118
|
+
all<T = Record<string, unknown>>(...params: SqliteValue$1[]): T[];
|
|
119
|
+
get<T = Record<string, unknown>>(...params: SqliteValue$1[]): T | undefined;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Sync SQLite client port owned by Mockingbird.
|
|
123
|
+
*
|
|
124
|
+
* Duck-typed so `@crvouga/mockingbird-service-sqlite` `Database`, better-sqlite3, and wrapped
|
|
125
|
+
* `bun:sqlite` instances all work when they expose this surface.
|
|
126
|
+
*/
|
|
127
|
+
interface SqliteClient$1 {
|
|
128
|
+
exec(sql: string): void;
|
|
129
|
+
prepare(sql: string): SqliteStatement$1;
|
|
130
|
+
transaction<T>(fn: () => T): T;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** Every stored record carries a monotonically increasing sequence for stable ordering. */
|
|
134
|
+
type Stored<T> = {
|
|
135
|
+
seq: number;
|
|
136
|
+
value: T;
|
|
137
|
+
};
|
|
138
|
+
type ListRecordsOptions<T> = {
|
|
139
|
+
/** Keep only records passing the predicate. */
|
|
140
|
+
where?: (value: T, seq: number) => boolean;
|
|
141
|
+
/** Sort order; default newest first. */
|
|
142
|
+
order?: "newest" | "oldest";
|
|
143
|
+
};
|
|
144
|
+
/**
|
|
145
|
+
* A SQLite-backed table of JSON records addressed by id. Ordering is by insertion
|
|
146
|
+
* sequence, never by id lexicographic order, so list semantics stay stable.
|
|
147
|
+
*/
|
|
148
|
+
declare class Collection<T> {
|
|
149
|
+
private readonly sqlite;
|
|
150
|
+
/** Storage namespace. Admin introspection uses this to ignore another namespace's tables. */
|
|
151
|
+
readonly namespace: string;
|
|
152
|
+
/** Table name inside the namespace. Stable across resets of the rows themselves. */
|
|
153
|
+
readonly collectionName: string;
|
|
154
|
+
constructor(sqlite: SqliteClient$1,
|
|
155
|
+
/** Storage namespace. Admin introspection uses this to ignore another namespace's tables. */
|
|
156
|
+
namespace: string,
|
|
157
|
+
/** Table name inside the namespace. Stable across resets of the rows themselves. */
|
|
158
|
+
collectionName: string);
|
|
159
|
+
private bumpCollectionSeq;
|
|
160
|
+
nextSequence(): number;
|
|
161
|
+
get(id: string): T | undefined;
|
|
162
|
+
has(id: string): boolean;
|
|
163
|
+
/** Insert a new record, assigning it the next sequence number. */
|
|
164
|
+
insert(id: string, value: T): Stored<T>;
|
|
165
|
+
/** Replace an existing record's value, keeping its position. */
|
|
166
|
+
update(id: string, value: T): Stored<T> | undefined;
|
|
167
|
+
delete(id: string): boolean;
|
|
168
|
+
/** How many records the collection holds, without reading them. */
|
|
169
|
+
count(): number;
|
|
170
|
+
list(options?: ListRecordsOptions<T>): Array<Stored<T> & {
|
|
171
|
+
id: string;
|
|
172
|
+
}>;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Sequential id source persisted in SQLite. Ids are deterministic for a given
|
|
177
|
+
* sequence history (`cus_` + 14 opaque chars), so reproductions stay stable.
|
|
178
|
+
*/
|
|
179
|
+
declare class IdSequence {
|
|
180
|
+
private readonly sqlite;
|
|
181
|
+
private readonly namespace;
|
|
182
|
+
private readonly salt;
|
|
183
|
+
constructor(sqlite: SqliteClient$1, namespace: string, salt?: string);
|
|
184
|
+
next(prefix: string, length?: number): string;
|
|
185
|
+
}
|
|
173
186
|
|
|
174
187
|
/** Options every provider constructor accepts. */
|
|
175
188
|
type APIOptions$1 = {
|
|
@@ -634,6 +647,8 @@ type ServiceRuntime<T extends ServiceInstance> = FetchAPI & {
|
|
|
634
647
|
/** Stop package-owned lifecycle timers when a supervisor closes the runtime. */
|
|
635
648
|
stop?(): void;
|
|
636
649
|
readonly name: string;
|
|
650
|
+
/** Same-origin Fetch handler and App Router method exports, sharing this runtime. */
|
|
651
|
+
mount(prefix: string): MountedAPI;
|
|
637
652
|
readonly sqlite: SqliteClient$1;
|
|
638
653
|
readonly clock: Clock;
|
|
639
654
|
readonly faults: FaultRegistry;
|
package/dist/index.js
CHANGED
package/dist/server.d.ts
CHANGED
|
@@ -1,33 +1,15 @@
|
|
|
1
1
|
import { Server } from 'node:http';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
type MountedAPI$1 = FetchAPI$1 & {
|
|
4
|
+
readonly prefix: string;
|
|
5
|
+
GET: FetchHandler$1;
|
|
6
|
+
POST: FetchHandler$1;
|
|
7
|
+
PUT: FetchHandler$1;
|
|
8
|
+
PATCH: FetchHandler$1;
|
|
9
|
+
DELETE: FetchHandler$1;
|
|
10
|
+
HEAD: FetchHandler$1;
|
|
11
|
+
OPTIONS: FetchHandler$1;
|
|
9
12
|
};
|
|
10
|
-
/**
|
|
11
|
-
* Prepared statement bound to a {@link SqliteClient}.
|
|
12
|
-
*
|
|
13
|
-
* Pass bind values as rest arguments on each call (no sticky `bind()`).
|
|
14
|
-
*/
|
|
15
|
-
interface SqliteStatement$2 {
|
|
16
|
-
run(...params: SqliteValue$2[]): SqliteRunResult$2;
|
|
17
|
-
all<T = Record<string, unknown>>(...params: SqliteValue$2[]): T[];
|
|
18
|
-
get<T = Record<string, unknown>>(...params: SqliteValue$2[]): T | undefined;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Sync SQLite client port owned by Mockingbird.
|
|
22
|
-
*
|
|
23
|
-
* Duck-typed so `@crvouga/mockingbird-service-sqlite` `Database`, better-sqlite3, and wrapped
|
|
24
|
-
* `bun:sqlite` instances all work when they expose this surface.
|
|
25
|
-
*/
|
|
26
|
-
interface SqliteClient$2 {
|
|
27
|
-
exec(sql: string): void;
|
|
28
|
-
prepare(sql: string): SqliteStatement$2;
|
|
29
|
-
transaction<T>(fn: () => T): T;
|
|
30
|
-
}
|
|
31
13
|
|
|
32
14
|
/** A stable identifier for a point in a {@link Timeline}. */
|
|
33
15
|
type CheckpointId$1 = string;
|
|
@@ -118,6 +100,37 @@ declare class Timeline$1<T> {
|
|
|
118
100
|
interface FetchAPI$1 {
|
|
119
101
|
fetch(request: Request): Promise<Response>;
|
|
120
102
|
}
|
|
103
|
+
/** A bare function form of {@link FetchAPI}, compatible with `Bun.serve`, workerd, and Deno. */
|
|
104
|
+
type FetchHandler$1 = (request: Request) => Promise<Response>;
|
|
105
|
+
|
|
106
|
+
/** Bind values accepted by Mockingbird's SQLite port (matches sqlite-mem / better-sqlite3). */
|
|
107
|
+
type SqliteValue$2 = null | number | bigint | string | Uint8Array | boolean;
|
|
108
|
+
/** Mutation counters returned by {@link SqliteStatement.run}. */
|
|
109
|
+
type SqliteRunResult$2 = {
|
|
110
|
+
changes: number;
|
|
111
|
+
lastInsertRowid: number | bigint;
|
|
112
|
+
};
|
|
113
|
+
/**
|
|
114
|
+
* Prepared statement bound to a {@link SqliteClient}.
|
|
115
|
+
*
|
|
116
|
+
* Pass bind values as rest arguments on each call (no sticky `bind()`).
|
|
117
|
+
*/
|
|
118
|
+
interface SqliteStatement$2 {
|
|
119
|
+
run(...params: SqliteValue$2[]): SqliteRunResult$2;
|
|
120
|
+
all<T = Record<string, unknown>>(...params: SqliteValue$2[]): T[];
|
|
121
|
+
get<T = Record<string, unknown>>(...params: SqliteValue$2[]): T | undefined;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Sync SQLite client port owned by Mockingbird.
|
|
125
|
+
*
|
|
126
|
+
* Duck-typed so `@crvouga/mockingbird-service-sqlite` `Database`, better-sqlite3, and wrapped
|
|
127
|
+
* `bun:sqlite` instances all work when they expose this surface.
|
|
128
|
+
*/
|
|
129
|
+
interface SqliteClient$2 {
|
|
130
|
+
exec(sql: string): void;
|
|
131
|
+
prepare(sql: string): SqliteStatement$2;
|
|
132
|
+
transaction<T>(fn: () => T): T;
|
|
133
|
+
}
|
|
121
134
|
|
|
122
135
|
/**
|
|
123
136
|
* The single source of time for a service.
|
|
@@ -534,6 +547,8 @@ type ServiceRuntime$1<T extends ServiceInstance$1> = FetchAPI$1 & {
|
|
|
534
547
|
/** Stop package-owned lifecycle timers when a supervisor closes the runtime. */
|
|
535
548
|
stop?(): void;
|
|
536
549
|
readonly name: string;
|
|
550
|
+
/** Same-origin Fetch handler and App Router method exports, sharing this runtime. */
|
|
551
|
+
mount(prefix: string): MountedAPI$1;
|
|
537
552
|
readonly sqlite: SqliteClient$2;
|
|
538
553
|
readonly clock: Clock$1;
|
|
539
554
|
readonly faults: FaultRegistry$1;
|
|
@@ -600,6 +615,9 @@ type CommonServeOptions = {
|
|
|
600
615
|
adminKey: string | undefined;
|
|
601
616
|
seed: string | undefined;
|
|
602
617
|
onLog: ((entry: RequestLog$1) => void) | undefined;
|
|
618
|
+
/** Synthetic provider fixture objects supplied by a fleet entry. */
|
|
619
|
+
fixtures?: Record<string, unknown>;
|
|
620
|
+
baseUrl?: string;
|
|
603
621
|
};
|
|
604
622
|
/**
|
|
605
623
|
* What a service contributes to `serve`: how to build its runtime from CLI flags,
|
|
@@ -618,88 +636,16 @@ type ServeTarget = {
|
|
|
618
636
|
listening?(server: Listening): void;
|
|
619
637
|
};
|
|
620
638
|
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
639
|
+
type MountedAPI = FetchAPI & {
|
|
640
|
+
readonly prefix: string;
|
|
641
|
+
GET: FetchHandler;
|
|
642
|
+
POST: FetchHandler;
|
|
643
|
+
PUT: FetchHandler;
|
|
644
|
+
PATCH: FetchHandler;
|
|
645
|
+
DELETE: FetchHandler;
|
|
646
|
+
HEAD: FetchHandler;
|
|
647
|
+
OPTIONS: FetchHandler;
|
|
627
648
|
};
|
|
628
|
-
/**
|
|
629
|
-
* Prepared statement bound to a {@link SqliteClient}.
|
|
630
|
-
*
|
|
631
|
-
* Pass bind values as rest arguments on each call (no sticky `bind()`).
|
|
632
|
-
*/
|
|
633
|
-
interface SqliteStatement$1 {
|
|
634
|
-
run(...params: SqliteValue$1[]): SqliteRunResult$1;
|
|
635
|
-
all<T = Record<string, unknown>>(...params: SqliteValue$1[]): T[];
|
|
636
|
-
get<T = Record<string, unknown>>(...params: SqliteValue$1[]): T | undefined;
|
|
637
|
-
}
|
|
638
|
-
/**
|
|
639
|
-
* Sync SQLite client port owned by Mockingbird.
|
|
640
|
-
*
|
|
641
|
-
* Duck-typed so `@crvouga/mockingbird-service-sqlite` `Database`, better-sqlite3, and wrapped
|
|
642
|
-
* `bun:sqlite` instances all work when they expose this surface.
|
|
643
|
-
*/
|
|
644
|
-
interface SqliteClient$1 {
|
|
645
|
-
exec(sql: string): void;
|
|
646
|
-
prepare(sql: string): SqliteStatement$1;
|
|
647
|
-
transaction<T>(fn: () => T): T;
|
|
648
|
-
}
|
|
649
|
-
|
|
650
|
-
/** Every stored record carries a monotonically increasing sequence for stable ordering. */
|
|
651
|
-
type Stored<T> = {
|
|
652
|
-
seq: number;
|
|
653
|
-
value: T;
|
|
654
|
-
};
|
|
655
|
-
type ListRecordsOptions<T> = {
|
|
656
|
-
/** Keep only records passing the predicate. */
|
|
657
|
-
where?: (value: T, seq: number) => boolean;
|
|
658
|
-
/** Sort order; default newest first. */
|
|
659
|
-
order?: "newest" | "oldest";
|
|
660
|
-
};
|
|
661
|
-
/**
|
|
662
|
-
* A SQLite-backed table of JSON records addressed by id. Ordering is by insertion
|
|
663
|
-
* sequence, never by id lexicographic order, so list semantics stay stable.
|
|
664
|
-
*/
|
|
665
|
-
declare class Collection<T> {
|
|
666
|
-
private readonly sqlite;
|
|
667
|
-
/** Storage namespace. Admin introspection uses this to ignore another namespace's tables. */
|
|
668
|
-
readonly namespace: string;
|
|
669
|
-
/** Table name inside the namespace. Stable across resets of the rows themselves. */
|
|
670
|
-
readonly collectionName: string;
|
|
671
|
-
constructor(sqlite: SqliteClient$1,
|
|
672
|
-
/** Storage namespace. Admin introspection uses this to ignore another namespace's tables. */
|
|
673
|
-
namespace: string,
|
|
674
|
-
/** Table name inside the namespace. Stable across resets of the rows themselves. */
|
|
675
|
-
collectionName: string);
|
|
676
|
-
private bumpCollectionSeq;
|
|
677
|
-
nextSequence(): number;
|
|
678
|
-
get(id: string): T | undefined;
|
|
679
|
-
has(id: string): boolean;
|
|
680
|
-
/** Insert a new record, assigning it the next sequence number. */
|
|
681
|
-
insert(id: string, value: T): Stored<T>;
|
|
682
|
-
/** Replace an existing record's value, keeping its position. */
|
|
683
|
-
update(id: string, value: T): Stored<T> | undefined;
|
|
684
|
-
delete(id: string): boolean;
|
|
685
|
-
/** How many records the collection holds, without reading them. */
|
|
686
|
-
count(): number;
|
|
687
|
-
list(options?: ListRecordsOptions<T>): Array<Stored<T> & {
|
|
688
|
-
id: string;
|
|
689
|
-
}>;
|
|
690
|
-
}
|
|
691
|
-
|
|
692
|
-
/**
|
|
693
|
-
* Sequential id source persisted in SQLite. Ids are deterministic for a given
|
|
694
|
-
* sequence history (`cus_` + 14 opaque chars), so reproductions stay stable.
|
|
695
|
-
*/
|
|
696
|
-
declare class IdSequence {
|
|
697
|
-
private readonly sqlite;
|
|
698
|
-
private readonly namespace;
|
|
699
|
-
private readonly salt;
|
|
700
|
-
constructor(sqlite: SqliteClient$1, namespace: string, salt?: string);
|
|
701
|
-
next(prefix: string, length?: number): string;
|
|
702
|
-
}
|
|
703
649
|
|
|
704
650
|
/** A stable identifier for a point in a {@link Timeline}. */
|
|
705
651
|
type CheckpointId = string;
|
|
@@ -790,6 +736,91 @@ declare class Timeline<T> {
|
|
|
790
736
|
interface FetchAPI {
|
|
791
737
|
fetch(request: Request): Promise<Response>;
|
|
792
738
|
}
|
|
739
|
+
/** A bare function form of {@link FetchAPI}, compatible with `Bun.serve`, workerd, and Deno. */
|
|
740
|
+
type FetchHandler = (request: Request) => Promise<Response>;
|
|
741
|
+
|
|
742
|
+
/** Bind values accepted by Mockingbird's SQLite port (matches sqlite-mem / better-sqlite3). */
|
|
743
|
+
type SqliteValue$1 = null | number | bigint | string | Uint8Array | boolean;
|
|
744
|
+
/** Mutation counters returned by {@link SqliteStatement.run}. */
|
|
745
|
+
type SqliteRunResult$1 = {
|
|
746
|
+
changes: number;
|
|
747
|
+
lastInsertRowid: number | bigint;
|
|
748
|
+
};
|
|
749
|
+
/**
|
|
750
|
+
* Prepared statement bound to a {@link SqliteClient}.
|
|
751
|
+
*
|
|
752
|
+
* Pass bind values as rest arguments on each call (no sticky `bind()`).
|
|
753
|
+
*/
|
|
754
|
+
interface SqliteStatement$1 {
|
|
755
|
+
run(...params: SqliteValue$1[]): SqliteRunResult$1;
|
|
756
|
+
all<T = Record<string, unknown>>(...params: SqliteValue$1[]): T[];
|
|
757
|
+
get<T = Record<string, unknown>>(...params: SqliteValue$1[]): T | undefined;
|
|
758
|
+
}
|
|
759
|
+
/**
|
|
760
|
+
* Sync SQLite client port owned by Mockingbird.
|
|
761
|
+
*
|
|
762
|
+
* Duck-typed so `@crvouga/mockingbird-service-sqlite` `Database`, better-sqlite3, and wrapped
|
|
763
|
+
* `bun:sqlite` instances all work when they expose this surface.
|
|
764
|
+
*/
|
|
765
|
+
interface SqliteClient$1 {
|
|
766
|
+
exec(sql: string): void;
|
|
767
|
+
prepare(sql: string): SqliteStatement$1;
|
|
768
|
+
transaction<T>(fn: () => T): T;
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
/** Every stored record carries a monotonically increasing sequence for stable ordering. */
|
|
772
|
+
type Stored<T> = {
|
|
773
|
+
seq: number;
|
|
774
|
+
value: T;
|
|
775
|
+
};
|
|
776
|
+
type ListRecordsOptions<T> = {
|
|
777
|
+
/** Keep only records passing the predicate. */
|
|
778
|
+
where?: (value: T, seq: number) => boolean;
|
|
779
|
+
/** Sort order; default newest first. */
|
|
780
|
+
order?: "newest" | "oldest";
|
|
781
|
+
};
|
|
782
|
+
/**
|
|
783
|
+
* A SQLite-backed table of JSON records addressed by id. Ordering is by insertion
|
|
784
|
+
* sequence, never by id lexicographic order, so list semantics stay stable.
|
|
785
|
+
*/
|
|
786
|
+
declare class Collection<T> {
|
|
787
|
+
private readonly sqlite;
|
|
788
|
+
/** Storage namespace. Admin introspection uses this to ignore another namespace's tables. */
|
|
789
|
+
readonly namespace: string;
|
|
790
|
+
/** Table name inside the namespace. Stable across resets of the rows themselves. */
|
|
791
|
+
readonly collectionName: string;
|
|
792
|
+
constructor(sqlite: SqliteClient$1,
|
|
793
|
+
/** Storage namespace. Admin introspection uses this to ignore another namespace's tables. */
|
|
794
|
+
namespace: string,
|
|
795
|
+
/** Table name inside the namespace. Stable across resets of the rows themselves. */
|
|
796
|
+
collectionName: string);
|
|
797
|
+
private bumpCollectionSeq;
|
|
798
|
+
nextSequence(): number;
|
|
799
|
+
get(id: string): T | undefined;
|
|
800
|
+
has(id: string): boolean;
|
|
801
|
+
/** Insert a new record, assigning it the next sequence number. */
|
|
802
|
+
insert(id: string, value: T): Stored<T>;
|
|
803
|
+
/** Replace an existing record's value, keeping its position. */
|
|
804
|
+
update(id: string, value: T): Stored<T> | undefined;
|
|
805
|
+
delete(id: string): boolean;
|
|
806
|
+
/** How many records the collection holds, without reading them. */
|
|
807
|
+
count(): number;
|
|
808
|
+
list(options?: ListRecordsOptions<T>): Array<Stored<T> & {
|
|
809
|
+
id: string;
|
|
810
|
+
}>;
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
/**
|
|
814
|
+
* Sequential id source persisted in SQLite. Ids are deterministic for a given
|
|
815
|
+
* sequence history (`cus_` + 14 opaque chars), so reproductions stay stable.
|
|
816
|
+
*/
|
|
817
|
+
declare class IdSequence {
|
|
818
|
+
private readonly sqlite;
|
|
819
|
+
private readonly namespace;
|
|
820
|
+
private readonly salt;
|
|
821
|
+
constructor(sqlite: SqliteClient$1, namespace: string, salt?: string);
|
|
822
|
+
next(prefix: string, length?: number): string;
|
|
823
|
+
}
|
|
793
824
|
|
|
794
825
|
/** Options every provider constructor accepts. */
|
|
795
826
|
type APIOptions$1 = {
|
|
@@ -1254,6 +1285,8 @@ type ServiceRuntime<T extends ServiceInstance> = FetchAPI & {
|
|
|
1254
1285
|
/** Stop package-owned lifecycle timers when a supervisor closes the runtime. */
|
|
1255
1286
|
stop?(): void;
|
|
1256
1287
|
readonly name: string;
|
|
1288
|
+
/** Same-origin Fetch handler and App Router method exports, sharing this runtime. */
|
|
1289
|
+
mount(prefix: string): MountedAPI;
|
|
1257
1290
|
readonly sqlite: SqliteClient$1;
|
|
1258
1291
|
readonly clock: Clock;
|
|
1259
1292
|
readonly faults: FaultRegistry;
|
package/dist/server.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crvouga/mockingbird-service-ec2",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Work-in-progress Amazon Elastic Compute Cloud transport scaffold; vendor operations are not implemented.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -146,7 +146,7 @@
|
|
|
146
146
|
"pack:check": "bun ../../../scripts/pack-check.ts"
|
|
147
147
|
},
|
|
148
148
|
"dependencies": {
|
|
149
|
-
"@crvouga/mockingbird-service-sqlite": "3.
|
|
149
|
+
"@crvouga/mockingbird-service-sqlite": "3.2.0"
|
|
150
150
|
},
|
|
151
151
|
"devDependencies": {
|
|
152
152
|
"@crvouga/mockingbird-adapter-node": "0.0.0-development",
|