@fuzdev/fuz_app 0.83.0 → 0.84.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.
Files changed (38) hide show
  1. package/dist/auth/migrations.d.ts +21 -18
  2. package/dist/auth/migrations.d.ts.map +1 -1
  3. package/dist/auth/migrations.js +22 -19
  4. package/dist/db/CLAUDE.md +6 -0
  5. package/dist/db/schema_ready.d.ts +83 -0
  6. package/dist/db/schema_ready.d.ts.map +1 -0
  7. package/dist/db/schema_ready.js +103 -0
  8. package/dist/http/CLAUDE.md +3 -2
  9. package/dist/http/common_routes.d.ts +49 -0
  10. package/dist/http/common_routes.d.ts.map +1 -1
  11. package/dist/http/common_routes.js +92 -0
  12. package/dist/testing/CLAUDE.md +35 -6
  13. package/dist/testing/cross_backend/backend_config.d.ts +2 -2
  14. package/dist/testing/cross_backend/capabilities.d.ts +10 -0
  15. package/dist/testing/cross_backend/capabilities.d.ts.map +1 -1
  16. package/dist/testing/cross_backend/capabilities.js +1 -0
  17. package/dist/testing/cross_backend/default_backend_configs.d.ts.map +1 -1
  18. package/dist/testing/cross_backend/default_backend_configs.js +6 -0
  19. package/dist/testing/cross_backend/default_spine_surface.d.ts +48 -0
  20. package/dist/testing/cross_backend/default_spine_surface.d.ts.map +1 -1
  21. package/dist/testing/cross_backend/default_spine_surface.js +24 -24
  22. package/dist/testing/cross_backend/expected_schema.json +113 -0
  23. package/dist/testing/cross_backend/ready.d.ts +14 -0
  24. package/dist/testing/cross_backend/ready.d.ts.map +1 -0
  25. package/dist/testing/cross_backend/ready.js +50 -0
  26. package/dist/testing/cross_backend/rust_spine_stub_backend_config.d.ts +39 -0
  27. package/dist/testing/cross_backend/rust_spine_stub_backend_config.d.ts.map +1 -0
  28. package/dist/testing/cross_backend/rust_spine_stub_backend_config.js +103 -0
  29. package/dist/testing/cross_backend/ts_spine_backend_config.d.ts +1 -1
  30. package/dist/testing/cross_backend/ts_spine_backend_config.d.ts.map +1 -1
  31. package/dist/testing/cross_backend/ts_spine_backend_config.js +6 -2
  32. package/dist/testing/schema_ready_fixture.d.ts +46 -0
  33. package/dist/testing/schema_ready_fixture.d.ts.map +1 -0
  34. package/dist/testing/schema_ready_fixture.js +48 -0
  35. package/package.json +7 -3
  36. package/dist/testing/cross_backend/spine_stub_backend_config.d.ts +0 -66
  37. package/dist/testing/cross_backend/spine_stub_backend_config.d.ts.map +0 -1
  38. package/dist/testing/cross_backend/spine_stub_backend_config.js +0 -53
@@ -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
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fuzdev/fuz_app",
3
- "version": "0.83.0",
3
+ "version": "0.84.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 cross_backend_spine_stub",
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",
@@ -146,6 +146,10 @@
146
146
  "types": "./dist/*.svelte.d.ts",
147
147
  "svelte": "./dist/*.svelte",
148
148
  "default": "./dist/*.svelte"
149
+ },
150
+ "./*.json": {
151
+ "types": "./dist/*.json.d.ts",
152
+ "default": "./dist/*.json"
149
153
  }
150
154
  }
151
155
  }
@@ -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
- };