@crvouga/mockingbird-service-postgres 1.4.0 → 1.5.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 +31 -1
- package/README.md +39 -8
- package/dist/admin.d.ts +13 -0
- package/dist/admin.js +26638 -0
- package/dist/admin.js.map +7 -0
- package/dist/api/database.d.ts +37 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +279 -22
- package/dist/index.js.map +3 -3
- package/dist/runtime/options.d.ts +5 -0
- package/dist/wire/cli.js +338 -29
- package/dist/wire/cli.js.map +4 -4
- package/dist/wire/connection.d.ts +5 -0
- package/dist/wire/index.d.ts +18 -2
- package/dist/wire/index.js +332 -26
- package/dist/wire/index.js.map +4 -4
- package/package.json +8 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
# Changelog — @crvouga/mockingbird-service-postgres
|
|
2
2
|
|
|
3
|
-
## 1.
|
|
3
|
+
## 1.5.0 (2026-10-01)
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
- record SQL timelines and serve the admin explorer ([8ced17a](https://github.com/crvouga/mockingbird/commit/8ced17ac398e386ef4e9d7e01fc7744c34b95d07))
|
|
8
|
+
|
|
9
|
+
### Fixes and improvements
|
|
10
|
+
|
|
11
|
+
- typecheck SQL admin timelines without a built sqlite port ([072daf4](https://github.com/crvouga/mockingbird/commit/072daf439f3967823149d7b0a8a9ce664d25097c))
|
|
12
|
+
- keep admin buttons pressed until the action finishes ([0aabfcb](https://github.com/crvouga/mockingbird/commit/0aabfcb5f392aa51e193f9c3f817d5877d92bc6a))
|
|
13
|
+
- size admin select fields like the text inputs beside them ([0fb3ef2](https://github.com/crvouga/mockingbird/commit/0fb3ef2ddbf43376c93a2ae6d87c6c9bf890dafc))
|
|
14
|
+
- keep admin section tabs wired when boot is renamed ([4eda25e](https://github.com/crvouga/mockingbird/commit/4eda25eacd59da048d196f7cc8369d7a02b47bfc))
|
|
15
|
+
|
|
16
|
+
## 1.4.0 (2026-09-29)
|
|
4
17
|
|
|
5
18
|
### Features
|
|
6
19
|
|
|
@@ -19,16 +32,23 @@
|
|
|
19
32
|
### Features
|
|
20
33
|
|
|
21
34
|
- state each mock's parity and share one CSS reset ([264b06e](https://github.com/crvouga/mockingbird/commit/264b06ef15efc1d5131bbf78c89f45e2ce86b557))
|
|
35
|
+
- share admin state and UI on every mock ([9194173](https://github.com/crvouga/mockingbird/commit/9194173ebeb4150a6e87e1187429a64bfc09b84c))
|
|
22
36
|
|
|
23
37
|
## 1.2.0 (2026-09-29)
|
|
24
38
|
|
|
25
39
|
### Features
|
|
26
40
|
|
|
27
41
|
- share one field-guide identity across the docs site and READMEs ([024f445](https://github.com/crvouga/mockingbird/commit/024f445c143e0d2d07a4dd0a3c063bca94c59623))
|
|
42
|
+
- let a scalar naming a later branch's enum value pick that branch ([30ade3a](https://github.com/crvouga/mockingbird/commit/30ade3a28a5b6b273ffbf261216b821acac8e961))
|
|
28
43
|
|
|
29
44
|
### Fixes and improvements
|
|
30
45
|
|
|
31
46
|
- typecheck the postgres and sqlite README signature blocks ([cd2080b](https://github.com/crvouga/mockingbird/commit/cd2080b1af98f2746de063f289382527e28acfb2))
|
|
47
|
+
- sign and retry webhooks on the injected clock ([1091bde](https://github.com/crvouga/mockingbird/commit/1091bde0df69d9cc3eba2062d8523755e6caca14))
|
|
48
|
+
- stop cleared webhook deliveries from rescheduling forever ([424b78f](https://github.com/crvouga/mockingbird/commit/424b78f29317b162e3bf7d0049cc19be5b977026))
|
|
49
|
+
- serialize immediate webhook attempts to fix reorder flake ([625c82b](https://github.com/crvouga/mockingbird/commit/625c82b5a8a7992c1cf93e9df68e77af08b353e3))
|
|
50
|
+
- flush drains webhook retries scheduled while it runs ([c58cede](https://github.com/crvouga/mockingbird/commit/c58cede1b6ba7ae5ed3f8721ad9b7cd7bc0b1ca7))
|
|
51
|
+
- treat enum [""] branches as unset markers in form coercion ([7177835](https://github.com/crvouga/mockingbird/commit/7177835cc510e14245d6648ad2821daa694bb80c))
|
|
32
52
|
|
|
33
53
|
## 1.1.0 (2026-09-25)
|
|
34
54
|
|
|
@@ -39,6 +59,8 @@
|
|
|
39
59
|
### Fixes and improvements
|
|
40
60
|
|
|
41
61
|
- expose the wire server under ./wire, not the reserved ./server export ([12734c7](https://github.com/crvouga/mockingbird/commit/12734c7ecb39585ac3c7565d6367b3611d8c38a6))
|
|
62
|
+
- take the rejected-request byte count from content-length, never by reading the body ([a0e5fb2](https://github.com/crvouga/mockingbird/commit/a0e5fb2fc80ab725c3552b612f3f091fd6c857fb))
|
|
63
|
+
- reject a present body by media type, and log what a rejected request sent ([12e351a](https://github.com/crvouga/mockingbird/commit/12e351aba53cfb7b41e31a7809419455fc2902eb))
|
|
42
64
|
|
|
43
65
|
## 1.0.0 (2026-09-24)
|
|
44
66
|
|
|
@@ -57,6 +79,8 @@
|
|
|
57
79
|
### Features
|
|
58
80
|
|
|
59
81
|
- agent issue reporting for parity, features and new services; in-process medplum mock ([fc3a53b](https://github.com/crvouga/mockingbird/commit/fc3a53be83e2840e55aef78970326c27982311a8))
|
|
82
|
+
- add vendor mocks for the full service catalog ([f870287](https://github.com/crvouga/mockingbird/commit/f8702874c807b1be4ce4ae2c5b46c8fd59a5e8eb))
|
|
83
|
+
- team identity, lab-account admin, sandbox limits, fixtures and request journal ([6cb1be3](https://github.com/crvouga/mockingbird/commit/6cb1be324a048ac9fe832061632c0ee9c9d01f8b))
|
|
60
84
|
|
|
61
85
|
### Fixes and improvements
|
|
62
86
|
|
|
@@ -64,8 +88,14 @@
|
|
|
64
88
|
|
|
65
89
|
## 0.1.3 (2026-09-20)
|
|
66
90
|
|
|
91
|
+
### Features
|
|
92
|
+
|
|
93
|
+
- one service contract — health, admin, namespaces, clock, faults, metrics ([fea7dd1](https://github.com/crvouga/mockingbird/commit/fea7dd169cc16d11baebba38dced7f630f725714))
|
|
94
|
+
|
|
67
95
|
### Fixes and improvements
|
|
68
96
|
|
|
97
|
+
- scope admin-injected faults to the calling namespace ([3c1d573](https://github.com/crvouga/mockingbird/commit/3c1d573ac0c404324bbd20855a5ac7a2cd50f738))
|
|
98
|
+
- take the admin namespace override only on admin routes ([37836a5](https://github.com/crvouga/mockingbird/commit/37836a5b0c51d17dd24e7b01c12dd6d8049646da))
|
|
69
99
|
- ship installable dependency pins and a changelog per package ([33264f2](https://github.com/crvouga/mockingbird/commit/33264f2c455c976303e07b72a3809e82ab70c803))
|
|
70
100
|
|
|
71
101
|
## 0.1.2 (2026-09-19)
|
package/README.md
CHANGED
|
@@ -164,19 +164,28 @@ in a local multi-service stack — start the frontend/backend v3 server instead
|
|
|
164
164
|
import { serve } from "@crvouga/mockingbird-service-postgres/wire"
|
|
165
165
|
|
|
166
166
|
const server = await serve({ port: 0 }) // 0 → a free port, reported as server.port
|
|
167
|
-
// postgres://postgres@127.0.0.1
|
|
167
|
+
// server.connectionString — postgres://postgres@127.0.0.1:<port>/postgres
|
|
168
168
|
await server.close()
|
|
169
|
+
|
|
170
|
+
const fromUri = await serve("postgres://postgres:secret@127.0.0.1:0/app")
|
|
171
|
+
// fromUri.connectionString uses the bound port. A client that asks for another
|
|
172
|
+
// database name is rejected with SQLSTATE 3D000.
|
|
173
|
+
await fromUri.close()
|
|
169
174
|
```
|
|
170
175
|
|
|
171
176
|
Or from the command line (installs a `mockingbird-postgres` bin):
|
|
172
177
|
|
|
173
178
|
```bash
|
|
174
179
|
mockingbird-postgres serve --port 55432 # trust auth
|
|
175
|
-
mockingbird-postgres serve
|
|
180
|
+
mockingbird-postgres serve postgres://postgres:secret@0.0.0.0:55432/app --log
|
|
176
181
|
```
|
|
177
182
|
|
|
178
183
|
`serve({ database })` shares an existing `Database`, and `serve({ database: snapshot })` boots every
|
|
179
184
|
server from one frozen template, so a seeded stack starts from the same bytes each time.
|
|
185
|
+
`createAdmin` from `@crvouga/mockingbird-service-postgres/admin` serves the same `/__admin`
|
|
186
|
+
surface as every other mock, including the table explorer (`GET /sql/tables`, `POST /sql/query`).
|
|
187
|
+
The wire server does not speak that HTTP API.
|
|
188
|
+
|
|
180
189
|
`server.snapshot()` freezes the live state; `server.fault({ dropConnection | delayStatementMs |
|
|
181
190
|
failCommit })` arms the next statement or connection for a drop, a delay, or a `40001` commit
|
|
182
191
|
failure.
|
|
@@ -207,12 +216,13 @@ another binary type gets `0A000`, and can switch that parameter to text).
|
|
|
207
216
|
| --- | --- |
|
|
208
217
|
| `exec(sql)` | Runs all semicolon-separated statements; **discards** row results (`void`). Does **not** accept bind parameters. Read `db.changes` afterwards if needed (reflects the **most recent** completed DML statement). Dump-only `DO` blocks and `ALTER TABLE ... SET (` storage parameters are no-ops. |
|
|
209
218
|
| `registerFunction(spec)` | Install a JavaScript scalar. Not stored in PGMM snapshots; `open()` of a live snapshot copies the implementation by reference. |
|
|
210
|
-
| `query(sql, params?, { at? }?)` | **Single statement only** (trailing `;` is fine). Returns all rows. `at`
|
|
219
|
+
| `query(sql, params?, { at? }?)` | **Single statement only** (trailing `;` is fine). Returns all rows. `at` is a `Snapshot` or a timeline checkpoint id and queries that checkpoint without changing live state. Multi-statement scripts throw `misuse`. |
|
|
211
220
|
| `prepare(sql)` | **Single statement only**. Parses immediately; the AST is reused. Pass binds as rest args to `run` / `all` / `get` / `result` / `textResult` on each call. |
|
|
212
221
|
| `transaction(fn)` | If idle: `BEGIN`, `fn()`, `COMMIT`, or `ROLLBACK` + rethrow. If already in a transaction: nested savepoint. A nested SQL `BEGIN` inside is a no-op warning like PostgreSQL. `close()` inside `fn` throws `misuse`. |
|
|
213
222
|
| `copyFrom(sql, data)` | Executes `COPY table [(cols)] FROM STDIN` with `data` as the copy-in payload (text or csv per the COPY options). Returns rows copied. `COPY ... TO STDOUT` output is returned as result rows by `query`. |
|
|
214
|
-
| `snapshot()` | Freeze a reusable `Snapshot` template (no encode). Illegal inside a transaction (`25P01`). |
|
|
215
|
-
| `checkpoint()` / `branch(at?)` |
|
|
223
|
+
| `snapshot()` | Freeze a reusable `Snapshot` template (no encode) and commit it on the followed timeline branch. Illegal inside a transaction (`25P01`). |
|
|
224
|
+
| `checkpoint()` / `branch(at?)` | `checkpoint` records the same timeline point as `snapshot`. `branch` opens an isolated database from a snapshot (or the current state). |
|
|
225
|
+
| `record(branch?)` / `fork(name, at?)` / `checkout(id, branch?)` / `reset()` | Timeline history on this database. `record` commits the live state. `fork` adds a branch pointer and does not switch live state. `checkout` installs a checkpoint. `reset` returns to the origin checkpoint on `main`. `history` lists heads and checkpoints. |
|
|
216
226
|
| `Snapshot.open()` | Copy-on-write fork from a template. The parent stays open. |
|
|
217
227
|
| `Snapshot.encode()` | Lazy PGMM blob for persistence / worker boot (computed once, cached). |
|
|
218
228
|
| `Snapshot.decode(bytes)` | Decode a blob once per `Uint8Array` (WeakMap); later `open()` calls are copy-on-write. |
|
|
@@ -349,8 +359,9 @@ Stable runtime exports of the main entry:
|
|
|
349
359
|
| `Statement` | Class returned by `db.prepare(sql)` (not constructed directly): `run`, `all`, `get`, `result`, `textResult`, and `sql`. |
|
|
350
360
|
| `PostgresError` | Error class thrown for SQL and API errors: `category` (`ErrorCategory`), `sqlState` / `code` (five-character SQLSTATE, e.g. `"42P01"`, `"23505"`). |
|
|
351
361
|
|
|
352
|
-
Signatures (types are exported too: `DatabaseOptions`, `
|
|
353
|
-
`RunResult`, `ErrorCategory`, `BindValue`, `JsValue`,
|
|
362
|
+
Signatures (types are exported too: `DatabaseOptions`, `HistoryCheckpoint`, `DatabaseHistory`,
|
|
363
|
+
`RegisterFunctionOptions`, `ResultSet`, `RunResult`, `ErrorCategory`, `BindValue`, `JsValue`,
|
|
364
|
+
`QueryRow`):
|
|
354
365
|
|
|
355
366
|
```ts
|
|
356
367
|
interface DatabaseOptions {
|
|
@@ -358,6 +369,21 @@ interface DatabaseOptions {
|
|
|
358
369
|
random?: "deterministic" | "os" // default "deterministic"; "os" is CSPRNG like PostgreSQL
|
|
359
370
|
now?: Date | (() => Date) | "system" // default 2000-01-01T00:00:00.000Z; "system" is wall clock
|
|
360
371
|
int8?: "bigint" | "number" | "string" // default "bigint"; "number" is unsafe beyond MAX_SAFE_INTEGER
|
|
372
|
+
maxCheckpoints?: number // timeline checkpoints to retain; default 1000
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
interface HistoryCheckpoint {
|
|
376
|
+
id: string
|
|
377
|
+
branch: string
|
|
378
|
+
parent: string | null
|
|
379
|
+
at: number
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
interface DatabaseHistory {
|
|
383
|
+
readonly size: number
|
|
384
|
+
head(branch?: string): HistoryCheckpoint | undefined
|
|
385
|
+
branches(): Readonly<Record<string, string>>
|
|
386
|
+
checkpoints(): readonly HistoryCheckpoint[]
|
|
361
387
|
}
|
|
362
388
|
|
|
363
389
|
declare class Database {
|
|
@@ -365,12 +391,17 @@ declare class Database {
|
|
|
365
391
|
exec(sql: string): void
|
|
366
392
|
registerFunction(spec: { name: string; args: string[]; returns: string; strict?: boolean;
|
|
367
393
|
fn: (...args: JsValue[]) => JsValue }): void
|
|
368
|
-
query<T = QueryRow>(sql: string, params?: readonly BindValue[], options?: { at?: Snapshot }): T[]
|
|
394
|
+
query<T = QueryRow>(sql: string, params?: readonly BindValue[], options?: { at?: Snapshot | string }): T[]
|
|
369
395
|
prepare(sql: string): Statement
|
|
370
396
|
transaction<T>(fn: () => T): T
|
|
371
397
|
copyFrom(sql: string, data: string): number // COPY t FROM STDIN payload (\copy analog)
|
|
372
398
|
snapshot(): Snapshot
|
|
373
399
|
checkpoint(): Snapshot
|
|
400
|
+
record(branch?: string): HistoryCheckpoint
|
|
401
|
+
fork(name: string, at?: string): HistoryCheckpoint
|
|
402
|
+
checkout(id: string, branch?: string): HistoryCheckpoint
|
|
403
|
+
reset(): HistoryCheckpoint
|
|
404
|
+
readonly history: DatabaseHistory
|
|
374
405
|
branch(at?: Snapshot): Database
|
|
375
406
|
close(): void // also [Symbol.dispose] when available
|
|
376
407
|
readonly changes: number // rows affected by the most recent INSERT/UPDATE/DELETE
|
package/dist/admin.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Database, DatabaseOptions } from "./api/database.js";
|
|
2
|
+
|
|
3
|
+
export interface AdminOptions {
|
|
4
|
+
database?: Database;
|
|
5
|
+
adminKey?: string;
|
|
6
|
+
databaseOptions?: DatabaseOptions;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface AdminServer {
|
|
10
|
+
fetch(request: Request): Promise<Response>;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export declare function createAdmin(options?: AdminOptions): AdminServer;
|