@fuzdev/fuz_app 0.63.0 → 0.65.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 (181) hide show
  1. package/dist/actions/CLAUDE.md +525 -827
  2. package/dist/actions/broadcast_api.d.ts +1 -1
  3. package/dist/actions/broadcast_api.js +1 -1
  4. package/dist/actions/cancel.d.ts +2 -2
  5. package/dist/actions/cancel.js +3 -3
  6. package/dist/actions/connection_closer.d.ts +65 -0
  7. package/dist/actions/connection_closer.d.ts.map +1 -0
  8. package/dist/actions/connection_closer.js +38 -0
  9. package/dist/actions/register_action_ws.d.ts +2 -2
  10. package/dist/actions/register_action_ws.d.ts.map +1 -1
  11. package/dist/actions/register_action_ws.js +23 -2
  12. package/dist/actions/register_ws_endpoint.d.ts +12 -10
  13. package/dist/actions/register_ws_endpoint.d.ts.map +1 -1
  14. package/dist/actions/register_ws_endpoint.js +5 -5
  15. package/dist/actions/transports_ws_auth_guard.d.ts +25 -10
  16. package/dist/actions/transports_ws_auth_guard.d.ts.map +1 -1
  17. package/dist/actions/transports_ws_auth_guard.js +24 -9
  18. package/dist/actions/ws_endpoint_spec.d.ts +119 -0
  19. package/dist/actions/ws_endpoint_spec.d.ts.map +1 -0
  20. package/dist/actions/ws_endpoint_spec.js +13 -0
  21. package/dist/auth/CLAUDE.md +592 -1808
  22. package/dist/auth/account_action_specs.d.ts +1 -1
  23. package/dist/auth/account_actions.d.ts +13 -0
  24. package/dist/auth/account_actions.d.ts.map +1 -1
  25. package/dist/auth/account_actions.js +31 -1
  26. package/dist/auth/account_routes.d.ts +12 -2
  27. package/dist/auth/account_routes.d.ts.map +1 -1
  28. package/dist/auth/account_routes.js +55 -8
  29. package/dist/auth/account_schema.d.ts +4 -4
  30. package/dist/auth/account_schema.d.ts.map +1 -1
  31. package/dist/auth/admin_action_specs.d.ts +8 -8
  32. package/dist/auth/admin_actions.d.ts +11 -0
  33. package/dist/auth/admin_actions.d.ts.map +1 -1
  34. package/dist/auth/admin_actions.js +25 -0
  35. package/dist/auth/api_token_queries.js +1 -1
  36. package/dist/auth/audit_emitter.d.ts +56 -12
  37. package/dist/auth/audit_emitter.d.ts.map +1 -1
  38. package/dist/auth/audit_emitter.js +38 -12
  39. package/dist/auth/audit_log_ddl.d.ts +1 -1
  40. package/dist/auth/audit_log_ddl.d.ts.map +1 -1
  41. package/dist/auth/audit_log_ddl.js +1 -1
  42. package/dist/auth/audit_log_schema.d.ts +5 -3
  43. package/dist/auth/audit_log_schema.d.ts.map +1 -1
  44. package/dist/auth/audit_log_schema.js +5 -3
  45. package/dist/auth/bootstrap_account.d.ts.map +1 -1
  46. package/dist/auth/bootstrap_account.js +1 -5
  47. package/dist/auth/bootstrap_routes.d.ts +8 -2
  48. package/dist/auth/bootstrap_routes.d.ts.map +1 -1
  49. package/dist/auth/bootstrap_routes.js +15 -11
  50. package/dist/auth/invite_schema.d.ts +2 -2
  51. package/dist/auth/keyring.d.ts +6 -6
  52. package/dist/auth/keyring.js +8 -8
  53. package/dist/auth/role_grant_offer_actions.d.ts.map +1 -1
  54. package/dist/auth/role_grant_offer_actions.js +4 -2
  55. package/dist/auth/signup_routes.d.ts +1 -1
  56. package/dist/auth/standard_rpc_actions.d.ts +1 -0
  57. package/dist/auth/standard_rpc_actions.d.ts.map +1 -1
  58. package/dist/auth/standard_rpc_actions.js +1 -0
  59. package/dist/db/create_db.d.ts.map +1 -1
  60. package/dist/db/create_db.js +13 -0
  61. package/dist/dev/setup.d.ts +2 -2
  62. package/dist/dev/setup.js +3 -3
  63. package/dist/http/CLAUDE.md +225 -483
  64. package/dist/http/error_schemas.d.ts +0 -4
  65. package/dist/http/error_schemas.d.ts.map +1 -1
  66. package/dist/http/error_schemas.js +0 -4
  67. package/dist/http/ip_canonical.d.ts +100 -0
  68. package/dist/http/ip_canonical.d.ts.map +1 -0
  69. package/dist/http/ip_canonical.js +195 -0
  70. package/dist/http/origin.d.ts +14 -6
  71. package/dist/http/origin.d.ts.map +1 -1
  72. package/dist/http/origin.js +14 -32
  73. package/dist/http/pending_effects.d.ts +1 -1
  74. package/dist/http/pending_effects.js +1 -1
  75. package/dist/http/proxy.d.ts +13 -5
  76. package/dist/http/proxy.d.ts.map +1 -1
  77. package/dist/http/proxy.js +15 -23
  78. package/dist/http/surface.d.ts +50 -0
  79. package/dist/http/surface.d.ts.map +1 -1
  80. package/dist/http/surface.js +27 -1
  81. package/dist/primitive_schemas.d.ts +20 -4
  82. package/dist/primitive_schemas.d.ts.map +1 -1
  83. package/dist/primitive_schemas.js +25 -4
  84. package/dist/realtime/sse_auth_guard.d.ts +16 -4
  85. package/dist/realtime/sse_auth_guard.d.ts.map +1 -1
  86. package/dist/realtime/sse_auth_guard.js +15 -3
  87. package/dist/runtime/mock.js +1 -1
  88. package/dist/server/app_backend.d.ts +66 -19
  89. package/dist/server/app_backend.d.ts.map +1 -1
  90. package/dist/server/app_backend.js +57 -34
  91. package/dist/server/app_server.d.ts +101 -10
  92. package/dist/server/app_server.d.ts.map +1 -1
  93. package/dist/server/app_server.js +105 -6
  94. package/dist/server/env.d.ts +7 -7
  95. package/dist/server/env.d.ts.map +1 -1
  96. package/dist/server/env.js +14 -14
  97. package/dist/server/startup.d.ts.map +1 -1
  98. package/dist/server/startup.js +12 -0
  99. package/dist/server/static.d.ts +4 -4
  100. package/dist/server/static.js +7 -7
  101. package/dist/testing/CLAUDE.md +269 -59
  102. package/dist/testing/admin_integration.d.ts +18 -23
  103. package/dist/testing/admin_integration.d.ts.map +1 -1
  104. package/dist/testing/admin_integration.js +159 -202
  105. package/dist/testing/adversarial_headers.d.ts +6 -0
  106. package/dist/testing/adversarial_headers.d.ts.map +1 -1
  107. package/dist/testing/adversarial_headers.js +13 -5
  108. package/dist/testing/app_server.d.ts +148 -60
  109. package/dist/testing/app_server.d.ts.map +1 -1
  110. package/dist/testing/app_server.js +143 -54
  111. package/dist/testing/attack_surface.d.ts +8 -7
  112. package/dist/testing/attack_surface.d.ts.map +1 -1
  113. package/dist/testing/attack_surface.js +12 -8
  114. package/dist/testing/audit_completeness.d.ts +23 -22
  115. package/dist/testing/audit_completeness.d.ts.map +1 -1
  116. package/dist/testing/audit_completeness.js +199 -158
  117. package/dist/testing/audit_drift_guard.d.ts +116 -0
  118. package/dist/testing/audit_drift_guard.d.ts.map +1 -0
  119. package/dist/testing/audit_drift_guard.js +134 -0
  120. package/dist/testing/bootstrap_success.d.ts +28 -0
  121. package/dist/testing/bootstrap_success.d.ts.map +1 -0
  122. package/dist/testing/bootstrap_success.js +144 -0
  123. package/dist/testing/connection_closer_helpers.d.ts +44 -0
  124. package/dist/testing/connection_closer_helpers.d.ts.map +1 -0
  125. package/dist/testing/connection_closer_helpers.js +48 -0
  126. package/dist/testing/cross_backend/capabilities.d.ts +64 -0
  127. package/dist/testing/cross_backend/capabilities.d.ts.map +1 -0
  128. package/dist/testing/cross_backend/capabilities.js +47 -0
  129. package/dist/testing/cross_backend/setup.d.ts +215 -0
  130. package/dist/testing/cross_backend/setup.d.ts.map +1 -0
  131. package/dist/testing/cross_backend/setup.js +101 -0
  132. package/dist/testing/data_exposure.d.ts +14 -15
  133. package/dist/testing/data_exposure.d.ts.map +1 -1
  134. package/dist/testing/data_exposure.js +127 -146
  135. package/dist/testing/db_entities.d.ts +11 -1
  136. package/dist/testing/db_entities.d.ts.map +1 -1
  137. package/dist/testing/db_entities.js +13 -1
  138. package/dist/testing/integration.d.ts +35 -21
  139. package/dist/testing/integration.d.ts.map +1 -1
  140. package/dist/testing/integration.js +231 -293
  141. package/dist/testing/integration_helpers.d.ts +16 -6
  142. package/dist/testing/integration_helpers.d.ts.map +1 -1
  143. package/dist/testing/integration_helpers.js +7 -7
  144. package/dist/testing/mock_fs.d.ts.map +1 -1
  145. package/dist/testing/mock_fs.js +0 -2
  146. package/dist/testing/rate_limiting.d.ts.map +1 -1
  147. package/dist/testing/rate_limiting.js +13 -4
  148. package/dist/testing/role_grant_helpers.d.ts +31 -0
  149. package/dist/testing/role_grant_helpers.d.ts.map +1 -0
  150. package/dist/testing/role_grant_helpers.js +46 -0
  151. package/dist/testing/round_trip.d.ts +21 -16
  152. package/dist/testing/round_trip.d.ts.map +1 -1
  153. package/dist/testing/round_trip.js +65 -86
  154. package/dist/testing/rpc_helpers.d.ts +2 -1
  155. package/dist/testing/rpc_helpers.d.ts.map +1 -1
  156. package/dist/testing/rpc_round_trip.d.ts +24 -21
  157. package/dist/testing/rpc_round_trip.d.ts.map +1 -1
  158. package/dist/testing/rpc_round_trip.js +91 -106
  159. package/dist/testing/schema_introspect.d.ts +106 -0
  160. package/dist/testing/schema_introspect.d.ts.map +1 -0
  161. package/dist/testing/schema_introspect.js +123 -0
  162. package/dist/testing/schema_parity.d.ts +144 -0
  163. package/dist/testing/schema_parity.d.ts.map +1 -0
  164. package/dist/testing/schema_parity.js +233 -0
  165. package/dist/testing/sse_round_trip.d.ts.map +1 -1
  166. package/dist/testing/sse_round_trip.js +12 -6
  167. package/dist/testing/standard.d.ts +57 -25
  168. package/dist/testing/standard.d.ts.map +1 -1
  169. package/dist/testing/standard.js +62 -5
  170. package/dist/testing/stubs.d.ts +22 -3
  171. package/dist/testing/stubs.d.ts.map +1 -1
  172. package/dist/testing/stubs.js +28 -21
  173. package/dist/testing/surface_invariants.d.ts +66 -1
  174. package/dist/testing/surface_invariants.d.ts.map +1 -1
  175. package/dist/testing/surface_invariants.js +103 -1
  176. package/dist/testing/transports/surface_source.d.ts +51 -0
  177. package/dist/testing/transports/surface_source.d.ts.map +1 -0
  178. package/dist/testing/transports/surface_source.js +19 -0
  179. package/dist/ui/SurfaceExplorer.svelte +161 -2
  180. package/dist/ui/SurfaceExplorer.svelte.d.ts.map +1 -1
  181. package/package.json +4 -4
@@ -0,0 +1,215 @@
1
+ import '../assert_dev_env.js';
2
+ /**
3
+ * Per-test fixture protocol shared by in-process and cross-process
4
+ * transports.
5
+ *
6
+ * Each standard suite body takes a required
7
+ * `setup_test: () => Promise<TestFixture>` callback and invokes it once
8
+ * per test. The fixture carries everything a test needs to fire requests
9
+ * and assert on a single bootstrapped keeper account — transport,
10
+ * account / actor identity, three header builders, a multi-account mint
11
+ * factory, and (in-process only) the in-memory keyring + raw backend.
12
+ *
13
+ * `default_in_process_setup(options)` wraps `create_test_app` into the
14
+ * `SetupTest` contract. The cross-process sibling
15
+ * (`default_cross_process_setup`) lands alongside the spawn-a-backend
16
+ * transport plumbing — it implements the same contract by spawning a
17
+ * binary and bootstrapping over real HTTP.
18
+ *
19
+ * @module
20
+ */
21
+ import type { Uuid } from '@fuzdev/fuz_util/id.js';
22
+ import type { Keyring } from '../../auth/keyring.js';
23
+ import type { RouteSpec } from '../../http/route_spec.js';
24
+ import type { AppServerContext, BootstrapServerOptions } from '../../server/app_server.js';
25
+ import type { SessionOptions } from '../../auth/session_cookie.js';
26
+ import { type CreateTestAppOptions, type SuiteAppOptions, type TestAccount, type TestAppServer } from '../app_server.js';
27
+ import { type RpcTestTransport, type RpcEndpointsSuiteOption } from '../rpc_helpers.js';
28
+ import { type BackendCapabilities } from './capabilities.js';
29
+ import type { SurfaceSource } from '../transports/surface_source.js';
30
+ /**
31
+ * Options for `TestFixture.create_account` — mints an additional
32
+ * bootstrapped account alongside the keeper. Matches the existing
33
+ * `TestApp.create_account` signature so the migration to fixture-style
34
+ * reads is a one-site call rewrite per use.
35
+ */
36
+ export interface CreateTestAccountOptions {
37
+ readonly username?: string;
38
+ readonly password_value?: string;
39
+ readonly roles?: Array<string>;
40
+ }
41
+ /**
42
+ * Shape returned by `TestFixture.create_account`. Aliased to the
43
+ * existing `TestAccount` interface from `app_server.ts` — same shape,
44
+ * stable name on the cross-backend testing surface so call sites read
45
+ * `fixture.create_account(...)` returning `TestAccountFixture` without
46
+ * crossing module boundaries.
47
+ */
48
+ export type TestAccountFixture = TestAccount;
49
+ /**
50
+ * Fields shared by every `TestFixture` regardless of transport. The
51
+ * discriminated union below adds in-process-only fields conditionally.
52
+ */
53
+ export interface TestFixtureBase {
54
+ /** Transport for this test's HTTP requests (cookie-threaded cross-process). */
55
+ readonly transport: RpcTestTransport;
56
+ /** The freshly-bootstrapped keeper account. */
57
+ readonly account: {
58
+ readonly id: Uuid;
59
+ readonly username: string;
60
+ };
61
+ /** The actor linked to the keeper account. */
62
+ readonly actor: {
63
+ readonly id: Uuid;
64
+ };
65
+ /** Build request headers with the keeper's session cookie. */
66
+ readonly create_session_headers: (extra?: Record<string, string>) => Record<string, string>;
67
+ /** Build request headers with the keeper's bearer token. */
68
+ readonly create_bearer_headers: (extra?: Record<string, string>) => Record<string, string>;
69
+ /** Build request headers with the daemon token (keeper auth). */
70
+ readonly create_daemon_token_headers: (extra?: Record<string, string>) => Record<string, string>;
71
+ /**
72
+ * Mint an additional bootstrapped account for cross-account / multi-user
73
+ * tests. In-process: re-uses `create_test_account_with_credentials` against the same DB;
74
+ * cross-process: goes through the consumer-supplied DB-admin
75
+ * channel.
76
+ */
77
+ readonly create_account: (options?: CreateTestAccountOptions) => Promise<TestAccountFixture>;
78
+ }
79
+ /**
80
+ * The per-test bundle returned by `SetupTest`. Every Tier 1 suite body
81
+ * reads exclusively from this shape — no `test_app.backend.*` reads
82
+ * remain in the suite bodies.
83
+ *
84
+ * Discriminated by `in_process`: when `true`, `keyring` and
85
+ * `backend_internals` are present (compile-time narrowed); when `false`,
86
+ * they're absent and the suite body must either run via the public wire
87
+ * (cross-process) or gate the test with
88
+ * `test_if(capabilities.in_process_only, ...)`. The discriminant value
89
+ * mirrors `BackendCapabilities.in_process_only` — both source from the
90
+ * same producer (`default_in_process_setup` vs. cross-process variant).
91
+ *
92
+ * Suite bodies narrow with `assert(fixture.in_process)` after
93
+ * `setup_test()`; sites that reach for `keyring` or `backend_internals`
94
+ * are in-process-only by structure and the assertion surfaces a clear
95
+ * failure if a future cross-process consumer reaches them without a
96
+ * `test_if` gate.
97
+ */
98
+ export type TestFixture = (TestFixtureBase & {
99
+ readonly in_process: true;
100
+ /**
101
+ * Test-only keyring access — in-process only. Used for
102
+ * expired-cookie generation in `describe_standard_integration_tests`.
103
+ */
104
+ readonly keyring: Keyring;
105
+ /**
106
+ * Raw backend access (`deps.db`, etc.) — in-process only. Used by
107
+ * `create_test_role_grant_direct` seed sites in
108
+ * `describe_standard_admin_integration_tests` and the
109
+ * origin-verification cookie-composition sites in
110
+ * `describe_standard_integration_tests`.
111
+ */
112
+ readonly backend_internals: TestAppServer;
113
+ }) | (TestFixtureBase & {
114
+ readonly in_process: false;
115
+ });
116
+ /**
117
+ * Per-test fixture-producing function. Invoked once inside every
118
+ * `test()` body. The implementation captures factory inputs (in-process)
119
+ * or a long-running backend handle (cross-process) and creates
120
+ * a fresh per-test bundle on each call.
121
+ */
122
+ export type SetupTest = () => Promise<TestFixture>;
123
+ /**
124
+ * Build a `SetupTest` that creates a fresh `TestApp` per call via
125
+ * `create_test_app` and projects it into the `TestFixture` shape.
126
+ *
127
+ * Same factory inputs `create_test_app` already takes — this helper
128
+ * is a projection layer, not a new lifecycle. fuz_app's own `src/test/`
129
+ * and consumer suites pass `default_in_process_setup({...factory_inputs})`
130
+ * in place of the old per-suite factory-input bundle.
131
+ *
132
+ * The describe-level `auth_integration_truncate_tables` / pglite WASM
133
+ * cache lifecycle stays in `create_pglite_factory` / `create_describe_db`
134
+ * (`testing/db.js`) — `default_in_process_setup` doesn't manage db state
135
+ * beyond what `create_test_app` already does.
136
+ */
137
+ export declare const default_in_process_setup: (options: CreateTestAppOptions) => SetupTest;
138
+ /**
139
+ * Consumer-facing options for `default_in_process_suite_options` — the
140
+ * minimal factory inputs both `default_in_process_setup` and
141
+ * `create_test_app_surface_spec` consume to produce the
142
+ * `{setup_test, surface_source, capabilities}` bundle.
143
+ */
144
+ export interface DefaultInProcessSuiteOptions {
145
+ session_options: SessionOptions<string>;
146
+ create_route_specs: (ctx: AppServerContext) => Array<RouteSpec>;
147
+ rpc_endpoints?: RpcEndpointsSuiteOption;
148
+ /**
149
+ * Bootstrap config — top-level slot, single source of truth for both
150
+ * surface generation and live dispatch. Same precedent as
151
+ * `rpc_endpoints`. Discriminated by `mode`; omit for the default (no
152
+ * bootstrap route mounted).
153
+ */
154
+ bootstrap?: BootstrapServerOptions;
155
+ app_options?: SuiteAppOptions;
156
+ /**
157
+ * Additional roles to grant the bootstrapped keeper alongside
158
+ * `ROLE_KEEPER` — additive, never replaces. The keeper account
159
+ * always holds `ROLE_KEEPER` (otherwise daemon-token auth breaks);
160
+ * pass extras here for suites that need additional role coverage.
161
+ *
162
+ * Admin-suite consumers pass `[ROLE_ADMIN]` so the default keeper
163
+ * can hit admin-gated RPC methods.
164
+ * `describe_standard_admin_integration_tests` and
165
+ * `describe_audit_completeness_tests` need this.
166
+ */
167
+ extra_keeper_roles?: Array<string>;
168
+ /**
169
+ * Pre-built `SurfaceSource` — overrides the default which calls
170
+ * `create_test_app_surface_spec` against the same factory inputs.
171
+ * Pass when surface assembly needs fields outside the shared subset
172
+ * (e.g. `env_schema`, `event_specs`, `ws_endpoints`, `transform_middleware`).
173
+ */
174
+ surface_source?: SurfaceSource;
175
+ }
176
+ /**
177
+ * Build the full in-process suite bundle in a single helper invocation.
178
+ * Output covers `{setup_test, surface_source, capabilities}` plus every
179
+ * factory input the Tier 1 suites read at their top level
180
+ * (`session_options`, `create_route_specs`, `rpc_endpoints`) — so the
181
+ * call site spreads once and adds only suite-specific extras
182
+ * (`roles`, `skip_routes`, `input_overrides`, `db_factories`, ...).
183
+ *
184
+ * ```ts
185
+ * // Suite-extras-free call: helper output is the entire options bag.
186
+ * describe_round_trip_validation(default_in_process_suite_options({
187
+ * session_options,
188
+ * create_route_specs,
189
+ * rpc_endpoints: [rpc_endpoint_spec],
190
+ * }));
191
+ *
192
+ * // With suite-specific extras: spread and add.
193
+ * describe_standard_admin_integration_tests({
194
+ * ...default_in_process_suite_options({
195
+ * session_options, create_route_specs, rpc_endpoints,
196
+ * extra_keeper_roles: [ROLE_ADMIN],
197
+ * }),
198
+ * roles,
199
+ * });
200
+ * ```
201
+ *
202
+ * Suites that don't read `session_options` / `rpc_endpoints` at their
203
+ * top level (`round_trip`, `data_exposure`) accept the spread anyway —
204
+ * excess properties on spread sources aren't checked by TS, and the
205
+ * uniform shape keeps consumer call sites mechanical.
206
+ */
207
+ export declare const default_in_process_suite_options: <const O extends DefaultInProcessSuiteOptions>(options: O) => {
208
+ setup_test: SetupTest;
209
+ surface_source: SurfaceSource;
210
+ capabilities: BackendCapabilities;
211
+ session_options: O["session_options"];
212
+ create_route_specs: O["create_route_specs"];
213
+ rpc_endpoints: O["rpc_endpoints"];
214
+ };
215
+ //# sourceMappingURL=setup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setup.d.ts","sourceRoot":"../src/lib/","sources":["../../../src/lib/testing/cross_backend/setup.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAE9B;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,wBAAwB,CAAC;AAEjD,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,uBAAuB,CAAC;AACnD,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,0BAA0B,CAAC;AACxD,OAAO,KAAK,EAAC,gBAAgB,EAAE,sBAAsB,EAAC,MAAM,4BAA4B,CAAC;AACzF,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,8BAA8B,CAAC;AAEjE,OAAO,EAEN,KAAK,oBAAoB,EACzB,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAEN,KAAK,gBAAgB,EACrB,KAAK,uBAAuB,EAC5B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAA0B,KAAK,mBAAmB,EAAC,MAAM,mBAAmB,CAAC;AACpF,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,iCAAiC,CAAC;AAEnE;;;;;GAKG;AACH,MAAM,WAAW,wBAAwB;IACxC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IA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CAAC;CA4BjC,CAAC"}
@@ -0,0 +1,101 @@
1
+ import '../assert_dev_env.js';
2
+ import { ROLE_KEEPER } from '../../auth/role_schema.js';
3
+ import { create_test_app, } from '../app_server.js';
4
+ import { create_test_app_surface_spec } from '../stubs.js';
5
+ import { http_transport, } from '../rpc_helpers.js';
6
+ import { in_process_capabilities } from './capabilities.js';
7
+ /**
8
+ * Build a `SetupTest` that creates a fresh `TestApp` per call via
9
+ * `create_test_app` and projects it into the `TestFixture` shape.
10
+ *
11
+ * Same factory inputs `create_test_app` already takes — this helper
12
+ * is a projection layer, not a new lifecycle. fuz_app's own `src/test/`
13
+ * and consumer suites pass `default_in_process_setup({...factory_inputs})`
14
+ * in place of the old per-suite factory-input bundle.
15
+ *
16
+ * The describe-level `auth_integration_truncate_tables` / pglite WASM
17
+ * cache lifecycle stays in `create_pglite_factory` / `create_describe_db`
18
+ * (`testing/db.js`) — `default_in_process_setup` doesn't manage db state
19
+ * beyond what `create_test_app` already does.
20
+ */
21
+ export const default_in_process_setup = (options) => async () => {
22
+ const test_app = await create_test_app(options);
23
+ return {
24
+ in_process: true,
25
+ transport: http_transport(test_app.app),
26
+ account: test_app.backend.account,
27
+ actor: test_app.backend.actor,
28
+ create_session_headers: test_app.create_session_headers,
29
+ create_bearer_headers: test_app.create_bearer_headers,
30
+ create_daemon_token_headers: test_app.create_daemon_token_headers,
31
+ create_account: test_app.create_account,
32
+ keyring: test_app.backend.keyring,
33
+ backend_internals: test_app.backend,
34
+ };
35
+ };
36
+ // NOTE: bootstrap config is read from `options.bootstrap` — top-level slot,
37
+ // single source of truth for both the surface spec (so the route appears in
38
+ // `expected_public_routes` / attack-surface iteration) AND the live
39
+ // `create_test_app` (so the route exists at dispatch time and returns 403
40
+ // `ERROR_ALREADY_BOOTSTRAPPED` matching its declared 403 schema). Same
41
+ // precedent as `rpc_endpoints`. Discriminated union shape (`mode: 'disabled'`
42
+ // | `'surface_only'` | `'live'`) replaces the old `token_path: string | null`
43
+ // overload that conflated three deployment intents on one channel.
44
+ /**
45
+ * Build the full in-process suite bundle in a single helper invocation.
46
+ * Output covers `{setup_test, surface_source, capabilities}` plus every
47
+ * factory input the Tier 1 suites read at their top level
48
+ * (`session_options`, `create_route_specs`, `rpc_endpoints`) — so the
49
+ * call site spreads once and adds only suite-specific extras
50
+ * (`roles`, `skip_routes`, `input_overrides`, `db_factories`, ...).
51
+ *
52
+ * ```ts
53
+ * // Suite-extras-free call: helper output is the entire options bag.
54
+ * describe_round_trip_validation(default_in_process_suite_options({
55
+ * session_options,
56
+ * create_route_specs,
57
+ * rpc_endpoints: [rpc_endpoint_spec],
58
+ * }));
59
+ *
60
+ * // With suite-specific extras: spread and add.
61
+ * describe_standard_admin_integration_tests({
62
+ * ...default_in_process_suite_options({
63
+ * session_options, create_route_specs, rpc_endpoints,
64
+ * extra_keeper_roles: [ROLE_ADMIN],
65
+ * }),
66
+ * roles,
67
+ * });
68
+ * ```
69
+ *
70
+ * Suites that don't read `session_options` / `rpc_endpoints` at their
71
+ * top level (`round_trip`, `data_exposure`) accept the spread anyway —
72
+ * excess properties on spread sources aren't checked by TS, and the
73
+ * uniform shape keeps consumer call sites mechanical.
74
+ */
75
+ export const default_in_process_suite_options = (options) => ({
76
+ setup_test: default_in_process_setup({
77
+ session_options: options.session_options,
78
+ create_route_specs: options.create_route_specs,
79
+ rpc_endpoints: options.rpc_endpoints,
80
+ bootstrap: options.bootstrap,
81
+ app_options: options.app_options,
82
+ roles: [ROLE_KEEPER, ...(options.extra_keeper_roles ?? [])],
83
+ }),
84
+ surface_source: options.surface_source ??
85
+ {
86
+ kind: 'inline',
87
+ spec: create_test_app_surface_spec({
88
+ session_options: options.session_options,
89
+ create_route_specs: options.create_route_specs,
90
+ rpc_endpoints: options.rpc_endpoints,
91
+ // Mirror what `create_test_app` → `create_app_server` will mount.
92
+ // Both helpers read from the top-level `bootstrap` slot so surface
93
+ // and live app stay in sync by construction.
94
+ bootstrap: options.bootstrap,
95
+ }),
96
+ },
97
+ capabilities: in_process_capabilities,
98
+ session_options: options.session_options,
99
+ create_route_specs: options.create_route_specs,
100
+ rpc_endpoints: options.rpc_endpoints,
101
+ });
@@ -1,9 +1,8 @@
1
1
  import './assert_dev_env.js';
2
- import type { AppSurface, AppSurfaceSpec } from '../http/surface.js';
3
- import type { RouteSpec } from '../http/route_spec.js';
4
- import type { AppServerContext, AppServerOptions } from '../server/app_server.js';
5
- import type { SessionOptions } from '../auth/session_cookie.js';
6
- import { type DbFactory } from './db.js';
2
+ import type { AppSurface } from '../http/surface.js';
3
+ import type { BackendCapabilities } from './cross_backend/capabilities.js';
4
+ import type { SetupTest } from './cross_backend/setup.js';
5
+ import type { SurfaceSource } from './transports/surface_source.js';
7
6
  /**
8
7
  * Recursively collect all property names from a JSON Schema.
9
8
  *
@@ -21,20 +20,20 @@ export declare const assert_output_schemas_no_sensitive_fields: (surface: AppSur
21
20
  export declare const assert_non_admin_schemas_no_admin_fields: (surface: AppSurface, admin_only_fields?: ReadonlyArray<string>) => void;
22
21
  /** Options for `describe_data_exposure_tests`. */
23
22
  export interface DataExposureTestOptions {
24
- /** Build the app surface spec (for schema-level checks). */
25
- build: () => AppSurfaceSpec;
26
- /** Session config for runtime tests. */
27
- session_options: SessionOptions<string>;
28
- /** Route spec factory for runtime tests. */
29
- create_route_specs: (ctx: AppServerContext) => Array<RouteSpec>;
23
+ /** Per-test fixture-producing function (per-describe cadence). */
24
+ setup_test: SetupTest;
25
+ /**
26
+ * Source of the app surface for schema-level + route-iteration checks.
27
+ * Currently requires `kind: 'inline'` the cross-process snapshot
28
+ * variant lands alongside the spawned-backend transport plumbing.
29
+ */
30
+ surface_source: SurfaceSource;
31
+ /** Backend capability declarations. */
32
+ capabilities: BackendCapabilities;
30
33
  /** Fields that must never appear in any response. Default: `sensitive_field_blocklist`. */
31
34
  sensitive_fields?: ReadonlyArray<string>;
32
35
  /** Fields that must not appear in non-admin responses. Default: `admin_only_field_blocklist`. */
33
36
  admin_only_fields?: ReadonlyArray<string>;
34
- /** Optional overrides for `AppServerOptions`. */
35
- app_options?: Partial<Omit<AppServerOptions, 'backend' | 'session_options' | 'create_route_specs'>>;
36
- /** Database factories to run tests against. Default: pglite only. */
37
- db_factories?: Array<DbFactory>;
38
37
  /** Routes to skip, in `'METHOD /path'` format. */
39
38
  skip_routes?: Array<string>;
40
39
  }
@@ -1 +1 @@
1
- {"version":3,"file":"data_exposure.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/data_exposure.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAgB7B,OAAO,KAAK,EAAC,UAAU,EAAE,cAAc,EAAC,MAAM,oBAAoB,CAAC;AACnE,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,uBAAuB,CAAC;AACrD,OAAO,KAAK,EAAC,gBAAgB,EAAE,gBAAgB,EAAC,MAAM,yBAAyB,CAAC;AAChF,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,2BAA2B,CAAC;AAG9D,OAAO,EAAwB,KAAK,SAAS,EAAC,MAAM,SAAS,CAAC;AAgB9D;;;;;GAKG;AACH,eAAO,MAAM,kCAAkC,GAAI,QAAQ,OAAO,KAAG,GAAG,CAAC,MAAM,CAuB9E,CAAC;AAIF;;GAEG;AACH,eAAO,MAAM,yCAAyC,GACrD,SAAS,UAAU,EACnB,mBAAkB,aAAa,CAAC,MAAM,CAA6B,KACjE,IAWF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,wCAAwC,GACpD,SAAS,UAAU,EACnB,oBAAmB,aAAa,CAAC,MAAM,CAA8B,KACnE,IAcF,CAAC;AAIF,kDAAkD;AAClD,MAAM,WAAW,uBAAuB;IACvC,4DAA4D;IAC5D,KAAK,EAAE,MAAM,cAAc,CAAC;IAC5B,wCAAwC;IACxC,eAAe,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC;IACxC,4CAA4C;IAC5C,kBAAkB,EAAE,CAAC,GAAG,EAAE,gBAAgB,KAAK,KAAK,CAAC,SAAS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