@fuzdev/fuz_app 0.83.0 → 0.85.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/auth/migrations.d.ts +21 -18
- package/dist/auth/migrations.d.ts.map +1 -1
- package/dist/auth/migrations.js +22 -19
- package/dist/db/CLAUDE.md +6 -0
- package/dist/db/schema_ready.d.ts +83 -0
- package/dist/db/schema_ready.d.ts.map +1 -0
- package/dist/db/schema_ready.js +103 -0
- package/dist/http/CLAUDE.md +3 -2
- package/dist/http/common_routes.d.ts +49 -0
- package/dist/http/common_routes.d.ts.map +1 -1
- package/dist/http/common_routes.js +92 -0
- package/dist/testing/CLAUDE.md +36 -8
- package/dist/testing/cross_backend/backend_config.d.ts +2 -2
- package/dist/testing/cross_backend/capabilities.d.ts +10 -0
- package/dist/testing/cross_backend/capabilities.d.ts.map +1 -1
- package/dist/testing/cross_backend/capabilities.js +1 -0
- package/dist/testing/cross_backend/default_backend_configs.d.ts.map +1 -1
- package/dist/testing/cross_backend/default_backend_configs.js +6 -0
- package/dist/testing/cross_backend/default_spine_surface.d.ts +48 -0
- package/dist/testing/cross_backend/default_spine_surface.d.ts.map +1 -1
- package/dist/testing/cross_backend/default_spine_surface.js +24 -24
- package/dist/testing/cross_backend/expected_schema.json +113 -0
- package/dist/testing/cross_backend/ready.d.ts +14 -0
- package/dist/testing/cross_backend/ready.d.ts.map +1 -0
- package/dist/testing/cross_backend/ready.js +50 -0
- package/dist/testing/cross_backend/rust_spine_stub_backend_config.d.ts +39 -0
- package/dist/testing/cross_backend/rust_spine_stub_backend_config.d.ts.map +1 -0
- package/dist/testing/cross_backend/rust_spine_stub_backend_config.js +103 -0
- package/dist/testing/cross_backend/ts_spine_backend_config.d.ts +1 -1
- package/dist/testing/cross_backend/ts_spine_backend_config.d.ts.map +1 -1
- package/dist/testing/cross_backend/ts_spine_backend_config.js +6 -2
- package/dist/testing/db.d.ts +9 -16
- package/dist/testing/db.d.ts.map +1 -1
- package/dist/testing/db.js +12 -32
- package/dist/testing/schema_ready_fixture.d.ts +46 -0
- package/dist/testing/schema_ready_fixture.d.ts.map +1 -0
- package/dist/testing/schema_ready_fixture.js +48 -0
- package/dist/ui/ConfirmButton.svelte +4 -5
- package/dist/ui/ConfirmButton.svelte.d.ts.map +1 -1
- package/package.json +11 -6
- package/dist/testing/cross_backend/spine_stub_backend_config.d.ts +0 -66
- package/dist/testing/cross_backend/spine_stub_backend_config.d.ts.map +0 -1
- package/dist/testing/cross_backend/spine_stub_backend_config.js +0 -53
package/dist/testing/db.js
CHANGED
|
@@ -178,42 +178,22 @@ export const auth_truncate_tables = [
|
|
|
178
178
|
*/
|
|
179
179
|
export const auth_integration_truncate_tables = [...auth_truncate_tables, 'audit_log'];
|
|
180
180
|
/**
|
|
181
|
-
*
|
|
182
|
-
*
|
|
183
|
-
* The full set created by `auth_migrations` — use for clean-slate
|
|
184
|
-
* test DB initialization. `auth_truncate_tables` is the subset for
|
|
185
|
-
* between-test data cleanup (excludes `audit_log`).
|
|
186
|
-
*
|
|
187
|
-
* When adding tables to `auth_migrations`, add them here too.
|
|
188
|
-
*/
|
|
189
|
-
export const auth_drop_tables = [
|
|
190
|
-
'app_settings',
|
|
191
|
-
'invite',
|
|
192
|
-
'audit_log',
|
|
193
|
-
'api_token',
|
|
194
|
-
'auth_session',
|
|
195
|
-
'role_grant',
|
|
196
|
-
'role_grant_offer',
|
|
197
|
-
'actor',
|
|
198
|
-
'account',
|
|
199
|
-
'bootstrap_lock',
|
|
200
|
-
];
|
|
201
|
-
/**
|
|
202
|
-
* Drop all auth tables and schema version tracking for a clean slate.
|
|
181
|
+
* Reset the entire `public` schema for a clean slate before re-migration.
|
|
203
182
|
*
|
|
204
183
|
* Recommended at the start of `init_schema` callbacks for `create_pg_factory`.
|
|
205
|
-
* Persistent test databases
|
|
206
|
-
*
|
|
207
|
-
*
|
|
208
|
-
*
|
|
209
|
-
*
|
|
210
|
-
*
|
|
184
|
+
* Persistent test databases accumulate stale DDL across fuz_app versions;
|
|
185
|
+
* `DROP SCHEMA public CASCADE; CREATE SCHEMA public` wipes every table, type,
|
|
186
|
+
* and sequence regardless of namespace, so migrations always run against a
|
|
187
|
+
* truly empty database. Drift-proof — unlike a hand-maintained drop list it
|
|
188
|
+
* needs no upkeep when the schema gains a table. Despite the historical name,
|
|
189
|
+
* this resets the whole schema, not just auth tables (the only documented use
|
|
190
|
+
* is clean-slate re-migration, which always wanted a full reset).
|
|
191
|
+
*
|
|
192
|
+
* @mutates db - drops and recreates the `public` schema; all tables gone.
|
|
211
193
|
*/
|
|
212
194
|
export const drop_auth_schema = async (db) => {
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
}
|
|
216
|
-
await db.query('DROP TABLE IF EXISTS schema_version CASCADE');
|
|
195
|
+
await db.query('DROP SCHEMA public CASCADE');
|
|
196
|
+
await db.query('CREATE SCHEMA public');
|
|
217
197
|
};
|
|
218
198
|
/**
|
|
219
199
|
* Create a `describe_db` function bound to specific factories and truncate tables.
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import './assert_dev_env.js';
|
|
2
|
+
import type { Db } from '../db/db.js';
|
|
3
|
+
import { type ExpectedSchema } from '../db/schema_ready.js';
|
|
4
|
+
/** Options for `sync_expected_schema_fixture`. */
|
|
5
|
+
export interface SyncExpectedSchemaFixtureOptions {
|
|
6
|
+
/** A bootstrapped DB — the consumer has run its full migration chain on it. */
|
|
7
|
+
db: Db;
|
|
8
|
+
/** Committed fixture location — an `import.meta.url`-relative URL or a path. */
|
|
9
|
+
fixture_url: URL | string;
|
|
10
|
+
/**
|
|
11
|
+
* When true, overwrite the fixture with the live column map instead of just
|
|
12
|
+
* reading it. Drive from an env flag (e.g. `UPDATE_SCHEMA_READY === '1'`).
|
|
13
|
+
*/
|
|
14
|
+
update?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/** The live column map and the committed fixture, for a `deepEqual` assertion. */
|
|
17
|
+
export interface SyncExpectedSchemaFixtureResult {
|
|
18
|
+
/** Columns introspected from the live, freshly-bootstrapped DB. */
|
|
19
|
+
live: Record<string, Array<string>>;
|
|
20
|
+
/** The committed fixture (re-read after writing when `update`). */
|
|
21
|
+
committed: ExpectedSchema;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Introspect the live (bootstrapped) DB's columns, write them to the committed
|
|
25
|
+
* fixture when `update`, then read the committed fixture back. The caller
|
|
26
|
+
* asserts `deepEqual(live, committed)`:
|
|
27
|
+
*
|
|
28
|
+
* ```ts
|
|
29
|
+
* const {live, committed} = await sync_expected_schema_fixture({
|
|
30
|
+
* db,
|
|
31
|
+
* fixture_url: new URL('../../lib/server/expected_schema.json', import.meta.url),
|
|
32
|
+
* update: process.env.UPDATE_SCHEMA_READY === '1',
|
|
33
|
+
* });
|
|
34
|
+
* assert.deepEqual(live, committed);
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* When `update` writes the fixture it emits raw `JSON.stringify` (one array
|
|
38
|
+
* element per line); Prettier collapses short arrays inline, so run `gro format`
|
|
39
|
+
* after `UPDATE_SCHEMA_READY=1` before committing or the format check will flag
|
|
40
|
+
* the regenerated file. (The content is identical either way — the regen test
|
|
41
|
+
* compares values, not formatting.)
|
|
42
|
+
*
|
|
43
|
+
* @returns the live column map and the committed map (post-write when `update`)
|
|
44
|
+
*/
|
|
45
|
+
export declare const sync_expected_schema_fixture: (options: SyncExpectedSchemaFixtureOptions) => Promise<SyncExpectedSchemaFixtureResult>;
|
|
46
|
+
//# sourceMappingURL=schema_ready_fixture.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema_ready_fixture.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/schema_ready_fixture.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAmB7B,OAAO,KAAK,EAAC,EAAE,EAAC,MAAM,aAAa,CAAC;AACpC,OAAO,EAAuB,KAAK,cAAc,EAAC,MAAM,uBAAuB,CAAC;AAEhF,kDAAkD;AAClD,MAAM,WAAW,gCAAgC;IAChD,+EAA+E;IAC/E,EAAE,EAAE,EAAE,CAAC;IACP,gFAAgF;IAChF,WAAW,EAAE,GAAG,GAAG,MAAM,CAAC;IAC1B;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,kFAAkF;AAClF,MAAM,WAAW,+BAA+B;IAC/C,mEAAmE;IACnE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;IACpC,mEAAmE;IACnE,SAAS,EAAE,cAAc,CAAC;CAC1B;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,4BAA4B,GACxC,SAAS,gCAAgC,KACvC,OAAO,CAAC,+BAA+B,CAQzC,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import './assert_dev_env.js';
|
|
2
|
+
/**
|
|
3
|
+
* Gen-time helper for the `/ready` schema-drift probe's committed fixture.
|
|
4
|
+
*
|
|
5
|
+
* A consumer commits an `expected_schema.json` (the column map a fresh full
|
|
6
|
+
* migration-chain bootstrap produces) and serves it through
|
|
7
|
+
* `create_ready_route_spec`. This helper keeps the regenerate-and-verify test
|
|
8
|
+
* that guards that fixture to ~10 lines: it introspects a freshly-bootstrapped
|
|
9
|
+
* DB, writes the fixture when an update flag is set, and reads it back so the
|
|
10
|
+
* caller can assert the committed copy equals a fresh bootstrap — the assertion
|
|
11
|
+
* that fails when the fixture drifts from the DDLs, so the runtime expectation
|
|
12
|
+
* can't silently fall behind.
|
|
13
|
+
*
|
|
14
|
+
* @module
|
|
15
|
+
*/
|
|
16
|
+
import { readFileSync, writeFileSync } from 'node:fs';
|
|
17
|
+
import { query_public_columns } from '../db/schema_ready.js';
|
|
18
|
+
/**
|
|
19
|
+
* Introspect the live (bootstrapped) DB's columns, write them to the committed
|
|
20
|
+
* fixture when `update`, then read the committed fixture back. The caller
|
|
21
|
+
* asserts `deepEqual(live, committed)`:
|
|
22
|
+
*
|
|
23
|
+
* ```ts
|
|
24
|
+
* const {live, committed} = await sync_expected_schema_fixture({
|
|
25
|
+
* db,
|
|
26
|
+
* fixture_url: new URL('../../lib/server/expected_schema.json', import.meta.url),
|
|
27
|
+
* update: process.env.UPDATE_SCHEMA_READY === '1',
|
|
28
|
+
* });
|
|
29
|
+
* assert.deepEqual(live, committed);
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* When `update` writes the fixture it emits raw `JSON.stringify` (one array
|
|
33
|
+
* element per line); Prettier collapses short arrays inline, so run `gro format`
|
|
34
|
+
* after `UPDATE_SCHEMA_READY=1` before committing or the format check will flag
|
|
35
|
+
* the regenerated file. (The content is identical either way — the regen test
|
|
36
|
+
* compares values, not formatting.)
|
|
37
|
+
*
|
|
38
|
+
* @returns the live column map and the committed map (post-write when `update`)
|
|
39
|
+
*/
|
|
40
|
+
export const sync_expected_schema_fixture = async (options) => {
|
|
41
|
+
const { db, fixture_url, update } = options;
|
|
42
|
+
const live = await query_public_columns(db);
|
|
43
|
+
if (update) {
|
|
44
|
+
writeFileSync(fixture_url, JSON.stringify(live, null, '\t') + '\n');
|
|
45
|
+
}
|
|
46
|
+
const committed = JSON.parse(readFileSync(fixture_url, 'utf8'));
|
|
47
|
+
return { live, committed };
|
|
48
|
+
};
|
|
@@ -50,14 +50,13 @@
|
|
|
50
50
|
import type {SvelteHTMLElements} from 'svelte/elements';
|
|
51
51
|
import type {ComponentProps, Snippet} from 'svelte';
|
|
52
52
|
import type {OmitStrict} from '@fuzdev/fuz_util/types.js';
|
|
53
|
-
import
|
|
53
|
+
import {icon_remove} from '@fuzdev/fuz_ui/icons.js';
|
|
54
54
|
import PendingAnimation from '@fuzdev/fuz_ui/PendingAnimation.svelte';
|
|
55
|
+
import Svg from '@fuzdev/fuz_ui/Svg.svelte';
|
|
55
56
|
|
|
56
57
|
import PopoverButton from './PopoverButton.svelte';
|
|
57
58
|
import type {Popover} from './popover.svelte.js';
|
|
58
59
|
|
|
59
|
-
const GLYPH_REMOVE = '🗙';
|
|
60
|
-
|
|
61
60
|
const {
|
|
62
61
|
onconfirm,
|
|
63
62
|
popover_button_attrs,
|
|
@@ -140,7 +139,7 @@
|
|
|
140
139
|
{#if popover_button_content}
|
|
141
140
|
{@render popover_button_content(popover, () => confirm(popover))}
|
|
142
141
|
{:else}
|
|
143
|
-
<
|
|
142
|
+
<Svg data={icon_remove} />
|
|
144
143
|
{/if}
|
|
145
144
|
</button>
|
|
146
145
|
{/if}
|
|
@@ -155,7 +154,7 @@
|
|
|
155
154
|
{:else if label !== undefined}
|
|
156
155
|
{label}
|
|
157
156
|
{:else}
|
|
158
|
-
<
|
|
157
|
+
<Svg data={icon_remove} />
|
|
159
158
|
{/if}
|
|
160
159
|
</span>
|
|
161
160
|
{#if pending}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfirmButton.svelte.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/ui/ConfirmButton.svelte"],"names":[],"mappings":"AAkDA,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,iBAAiB,CAAC;AACxD,OAAO,KAAK,EAAC,cAAc,EAAE,OAAO,EAAC,MAAM,QAAQ,CAAC;AACpD,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"ConfirmButton.svelte.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/ui/ConfirmButton.svelte"],"names":[],"mappings":"AAkDA,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,iBAAiB,CAAC;AACxD,OAAO,KAAK,EAAC,cAAc,EAAE,OAAO,EAAC,MAAM,QAAQ,CAAC;AACpD,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,2BAA2B,CAAC;AAK1D,OAAO,aAAa,MAAM,wBAAwB,CAAC;AACnD,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,qBAAqB,CAAC;AAEhD,KAAK,gBAAgB,GAAI,UAAU,CAAC,cAAc,CAAC,OAAO,aAAa,CAAC,EAAE,iBAAiB,GAAG,UAAU,CAAC,GACxG,UAAU,CAAC,kBAAkB,CAAC,QAAQ,CAAC,EAAE,UAAU,CAAC,GAAG;IACtD,SAAS,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACtC,oBAAoB,CAAC,EAAE,kBAAkB,CAAC,QAAQ,CAAC,GAAG,SAAS,CAAC;IAChE,eAAe,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACtC,yEAAyE;IACzE,eAAe,CAAC,EAAE,OAAO,CAAC,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC,CAAC,GAAG,SAAS,CAAC;IAC/E,qCAAqC;IACrC,sBAAsB,CAAC,EAAE,OAAO,CAAC,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC,CAAC,GAAG,SAAS,CAAC;IACtF,yDAAyD;IACzD,QAAQ,CAAC,EAAE,OAAO,CAAC,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC,CAAC,GAAG,SAAS,CAAC;IACxE,iFAAiF;IACjF,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CAC9B,CAAC;AA+FJ,QAAA,MAAM,aAAa,sDAAwC,CAAC;AAC5D,KAAK,aAAa,GAAG,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC;AACtD,eAAe,aAAa,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fuzdev/fuz_app",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.85.0",
|
|
4
4
|
"description": "fullstack app library",
|
|
5
5
|
"glyph": "🗝",
|
|
6
6
|
"logo": "logo.svg",
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
"build": "gro build",
|
|
15
15
|
"check": "gro check",
|
|
16
16
|
"test": "gro test",
|
|
17
|
-
"test:cross": "FUZ_TEST_CROSS_BACKEND=1 vitest run --project cross_backend_ts_node --project cross_backend_ts_deno --project cross_backend_ts_bun",
|
|
18
|
-
"test:cross:spine-stub": "FUZ_TEST_CROSS_BACKEND=1 vitest run --project
|
|
17
|
+
"test:cross:ts": "FUZ_TEST_CROSS_BACKEND=1 vitest run --project cross_backend_ts_node --project cross_backend_ts_deno --project cross_backend_ts_bun",
|
|
18
|
+
"test:cross:rust-spine-stub": "FUZ_TEST_CROSS_BACKEND=1 vitest run --project cross_backend_rust_spine_stub",
|
|
19
19
|
"test:cross:schema-parity": "FUZ_TEST_CROSS_BACKEND=1 vitest run --project cross_backend_schema_parity",
|
|
20
20
|
"benchmark:cross-impl": "gro run src/benchmarks/cross_impl.bench.ts",
|
|
21
21
|
"preview": "vite preview",
|
|
@@ -70,10 +70,11 @@
|
|
|
70
70
|
"@electric-sql/pglite": "^0.4.5",
|
|
71
71
|
"@fuzdev/blake3_wasm": "^0.1.1",
|
|
72
72
|
"@fuzdev/fuz_code": "^0.46.0",
|
|
73
|
-
"@fuzdev/fuz_css": "^0.
|
|
74
|
-
"@fuzdev/fuz_ui": "^0.
|
|
73
|
+
"@fuzdev/fuz_css": "^0.63.0",
|
|
74
|
+
"@fuzdev/fuz_ui": "^0.205.0",
|
|
75
75
|
"@fuzdev/fuz_util": "^0.65.1",
|
|
76
76
|
"@fuzdev/gro": "^0.204.0",
|
|
77
|
+
"@fuzdev/mdz": "^0.1.0",
|
|
77
78
|
"@hono/node-server": "^1.19.14",
|
|
78
79
|
"@hono/node-ws": "^1.3.1",
|
|
79
80
|
"@node-rs/argon2": "^2.0.2",
|
|
@@ -98,7 +99,7 @@
|
|
|
98
99
|
"prettier-plugin-svelte": "^3.5.1",
|
|
99
100
|
"svelte": "^5.56.2",
|
|
100
101
|
"svelte-check": "^4.6.0",
|
|
101
|
-
"svelte-docinfo": "^0.
|
|
102
|
+
"svelte-docinfo": "^0.5.1",
|
|
102
103
|
"svelte2tsx": "^0.7.52",
|
|
103
104
|
"tslib": "^2.8.1",
|
|
104
105
|
"typescript": "^5.9.3",
|
|
@@ -146,6 +147,10 @@
|
|
|
146
147
|
"types": "./dist/*.svelte.d.ts",
|
|
147
148
|
"svelte": "./dist/*.svelte",
|
|
148
149
|
"default": "./dist/*.svelte"
|
|
150
|
+
},
|
|
151
|
+
"./*.json": {
|
|
152
|
+
"types": "./dist/*.json.d.ts",
|
|
153
|
+
"default": "./dist/*.json"
|
|
149
154
|
}
|
|
150
155
|
}
|
|
151
156
|
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import '../assert_dev_env.js';
|
|
2
|
-
/**
|
|
3
|
-
* Cross-process `BackendConfig` preset for the non-domain spine consumer,
|
|
4
|
-
* `testing_spine_stub` — a Rust binary that mounts only the spine surface
|
|
5
|
-
* (auth / account / admin / audit / role-grant offers) with no domain
|
|
6
|
-
* layer. fuz_app drives it from `src/test/cross_backend/*.cross.test.ts`
|
|
7
|
-
* to verify its TS spec against the Rust spine end-to-end with no domain
|
|
8
|
-
* implementation in the loop — drift becomes a fuz_app failure rather than
|
|
9
|
-
* a downstream consumer's failure with mixed signals.
|
|
10
|
-
*
|
|
11
|
-
* **Binary discovery — env-supplied, never hardcoded.** The binary lives
|
|
12
|
-
* in a sibling Rust workspace, not in fuz_app, so the preset never bakes a
|
|
13
|
-
* path in. `FUZ_TESTING_SPINE_STUB_BIN` (or the `binary_path` option) must
|
|
14
|
-
* point at a prebuilt binary; the preset throws a clear error when neither
|
|
15
|
-
* is set rather than guessing. Build once with
|
|
16
|
-
* `cargo build -p testing_spine_stub --release` and point the env var at
|
|
17
|
-
* the resulting `target/release/testing_spine_stub`; operators / CI cache
|
|
18
|
-
* the binary across runs for fast spawns.
|
|
19
|
-
*
|
|
20
|
-
* **Operator setup** — the target Postgres database must exist before the
|
|
21
|
-
* harness runs (the harness never issues `CREATE DATABASE`, to avoid
|
|
22
|
-
* forcing a `CREATEDB` grant on the test role):
|
|
23
|
-
*
|
|
24
|
-
* ```bash
|
|
25
|
-
* createdb fuz_app_test_spine_stub 2>/dev/null || true
|
|
26
|
-
* ```
|
|
27
|
-
*
|
|
28
|
-
* The binary self-wipes the auth-namespace schema on every boot
|
|
29
|
-
* (`FUZ_TESTING_RESET_DB_ON_STARTUP=true`, set by the Rust-family builder),
|
|
30
|
-
* so no manual `DROP TABLE` between sessions is needed; per-test reset is
|
|
31
|
-
* the orthogonal `_testing_reset` RPC action `default_cross_process_setup`
|
|
32
|
-
* fires.
|
|
33
|
-
*
|
|
34
|
-
* @module
|
|
35
|
-
*/
|
|
36
|
-
import type { BackendConfig } from './backend_config.js';
|
|
37
|
-
/** Env var naming the prebuilt `testing_spine_stub` binary. Required when `binary_path` is omitted. */
|
|
38
|
-
export declare const SPINE_STUB_BIN_ENV = "FUZ_TESTING_SPINE_STUB_BIN";
|
|
39
|
-
/** Default listening port — slots beside zzz's 1175/1176; matches the binary's `DEFAULT_PORT`. */
|
|
40
|
-
export declare const SPINE_STUB_DEFAULT_PORT = 1177;
|
|
41
|
-
/** Default Postgres database — real PG (PGlite isn't reachable from `tokio-postgres`). */
|
|
42
|
-
export declare const SPINE_STUB_DEFAULT_DATABASE_URL = "postgres://localhost/fuz_app_test_spine_stub";
|
|
43
|
-
export interface SpineStubBackendConfigOptions {
|
|
44
|
-
/** Listening port. Default `SPINE_STUB_DEFAULT_PORT`. */
|
|
45
|
-
readonly port?: number;
|
|
46
|
-
/** Postgres connection URL. Default `SPINE_STUB_DEFAULT_DATABASE_URL`. */
|
|
47
|
-
readonly database_url?: string;
|
|
48
|
-
/**
|
|
49
|
-
* Prebuilt binary path. Overrides the `FUZ_TESTING_SPINE_STUB_BIN` env
|
|
50
|
-
* var. When neither is set the preset throws.
|
|
51
|
-
*/
|
|
52
|
-
readonly binary_path?: string;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Build the `BackendConfig` for `testing_spine_stub`. Resolves the binary
|
|
56
|
-
* from `options.binary_path` or `FUZ_TESTING_SPINE_STUB_BIN`; throws when
|
|
57
|
-
* neither is set so a missing build surfaces as a clear error rather than
|
|
58
|
-
* a confusing spawn failure. Reconciles the binary's env contract: port
|
|
59
|
-
* via `--port` (and `FUZ_SPINE_STUB_PORT`), daemon-token dir via
|
|
60
|
-
* `FUZ_SPINE_STUB_DIR` (anchored to `paths.root` so the written
|
|
61
|
-
* `{dir}/run/daemon_token` matches the path `spawn_backend` reads).
|
|
62
|
-
*
|
|
63
|
-
* @throws Error when no binary path is available.
|
|
64
|
-
*/
|
|
65
|
-
export declare const spine_stub_backend_config: (options?: SpineStubBackendConfigOptions) => BackendConfig;
|
|
66
|
-
//# sourceMappingURL=spine_stub_backend_config.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"spine_stub_backend_config.d.ts","sourceRoot":"../src/lib/","sources":["../../../src/lib/testing/cross_backend/spine_stub_backend_config.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAE9B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,qBAAqB,CAAC;AAOvD,uGAAuG;AACvG,eAAO,MAAM,kBAAkB,+BAA+B,CAAC;AAE/D,kGAAkG;AAClG,eAAO,MAAM,uBAAuB,OAAO,CAAC;AAE5C,0FAA0F;AAC1F,eAAO,MAAM,+BAA+B,iDAAiD,CAAC;AAE9F,MAAM,WAAW,6BAA6B;IAC7C,yDAAyD;IACzD,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,0EAA0E;IAC1E,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B;;;OAGG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,yBAAyB,GACrC,UAAS,6BAAkC,KACzC,aAsCF,CAAC"}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import '../assert_dev_env.js';
|
|
2
|
-
import { build_test_backend_paths } from './build_test_backend_paths.js';
|
|
3
|
-
import { make_default_rust_backend_config, rust_default_capabilities, } from './default_backend_configs.js';
|
|
4
|
-
/** Env var naming the prebuilt `testing_spine_stub` binary. Required when `binary_path` is omitted. */
|
|
5
|
-
export const SPINE_STUB_BIN_ENV = 'FUZ_TESTING_SPINE_STUB_BIN';
|
|
6
|
-
/** Default listening port — slots beside zzz's 1175/1176; matches the binary's `DEFAULT_PORT`. */
|
|
7
|
-
export const SPINE_STUB_DEFAULT_PORT = 1177;
|
|
8
|
-
/** Default Postgres database — real PG (PGlite isn't reachable from `tokio-postgres`). */
|
|
9
|
-
export const SPINE_STUB_DEFAULT_DATABASE_URL = 'postgres://localhost/fuz_app_test_spine_stub';
|
|
10
|
-
/**
|
|
11
|
-
* Build the `BackendConfig` for `testing_spine_stub`. Resolves the binary
|
|
12
|
-
* from `options.binary_path` or `FUZ_TESTING_SPINE_STUB_BIN`; throws when
|
|
13
|
-
* neither is set so a missing build surfaces as a clear error rather than
|
|
14
|
-
* a confusing spawn failure. Reconciles the binary's env contract: port
|
|
15
|
-
* via `--port` (and `FUZ_SPINE_STUB_PORT`), daemon-token dir via
|
|
16
|
-
* `FUZ_SPINE_STUB_DIR` (anchored to `paths.root` so the written
|
|
17
|
-
* `{dir}/run/daemon_token` matches the path `spawn_backend` reads).
|
|
18
|
-
*
|
|
19
|
-
* @throws Error when no binary path is available.
|
|
20
|
-
*/
|
|
21
|
-
export const spine_stub_backend_config = (options = {}) => {
|
|
22
|
-
const { port = SPINE_STUB_DEFAULT_PORT, database_url = SPINE_STUB_DEFAULT_DATABASE_URL, binary_path = process.env[SPINE_STUB_BIN_ENV], } = options;
|
|
23
|
-
if (!binary_path) {
|
|
24
|
-
throw new Error(`spine_stub_backend_config: no binary path — set ${SPINE_STUB_BIN_ENV} to a prebuilt ` +
|
|
25
|
-
'`testing_spine_stub` binary (build it with `cargo build -p testing_spine_stub --release`) ' +
|
|
26
|
-
'or pass `binary_path`.');
|
|
27
|
-
}
|
|
28
|
-
const name = 'spine_stub';
|
|
29
|
-
const paths = build_test_backend_paths(name);
|
|
30
|
-
return make_default_rust_backend_config({
|
|
31
|
-
name,
|
|
32
|
-
port,
|
|
33
|
-
// `--port` is the binary's authoritative port input; the
|
|
34
|
-
// `FUZ_SPINE_STUB_PORT` env the builder also sets (via `port_env_var`)
|
|
35
|
-
// is the lower-precedence fallback — both carry the same value.
|
|
36
|
-
start_command: [binary_path, '--port', String(port)],
|
|
37
|
-
database_url,
|
|
38
|
-
// The stub now serves `GET /api/admin/audit/stream` (the spine
|
|
39
|
-
// `fuz_realtime::SseRegistry` + audit listener), so it advertises `sse`
|
|
40
|
-
// like the TS spines — the cross-process SSE suite's three cases run.
|
|
41
|
-
capabilities: { ...rust_default_capabilities, sse: true },
|
|
42
|
-
port_env_var: 'FUZ_SPINE_STUB_PORT',
|
|
43
|
-
rust_log: 'info,testing_spine_stub=info',
|
|
44
|
-
paths,
|
|
45
|
-
extra_env: {
|
|
46
|
-
// The binary writes its daemon-token JSON to
|
|
47
|
-
// `{FUZ_SPINE_STUB_DIR}/run/daemon_token`; anchoring the dir to
|
|
48
|
-
// `paths.root` makes that equal `paths.daemon_token_path`, which
|
|
49
|
-
// `spawn_backend` reads after the health probe.
|
|
50
|
-
FUZ_SPINE_STUB_DIR: paths.root,
|
|
51
|
-
},
|
|
52
|
-
});
|
|
53
|
-
};
|