@fuzdev/fuz_app 0.50.0 → 0.51.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 (77) hide show
  1. package/dist/actions/CLAUDE.md +2 -2
  2. package/dist/actions/action_codegen.d.ts +27 -6
  3. package/dist/actions/action_codegen.d.ts.map +1 -1
  4. package/dist/actions/action_codegen.js +41 -13
  5. package/dist/actions/action_registry.d.ts +1 -1
  6. package/dist/actions/action_registry.js +1 -1
  7. package/dist/actions/action_spec.d.ts +1 -1
  8. package/dist/actions/action_spec.js +1 -1
  9. package/dist/actions/action_types.d.ts +2 -2
  10. package/dist/actions/action_types.js +2 -2
  11. package/dist/actions/cancel.d.ts +2 -2
  12. package/dist/actions/cancel.js +2 -2
  13. package/dist/actions/heartbeat.d.ts +2 -2
  14. package/dist/actions/heartbeat.js +2 -2
  15. package/dist/actions/protocol.d.ts +1 -1
  16. package/dist/actions/protocol.js +1 -1
  17. package/dist/actions/register_action_ws.d.ts +1 -1
  18. package/dist/actions/register_action_ws.js +1 -1
  19. package/dist/auth/account_routes.d.ts +3 -3
  20. package/dist/auth/account_routes.js +3 -3
  21. package/dist/auth/account_schema.d.ts +1 -1
  22. package/dist/auth/account_schema.js +1 -1
  23. package/dist/auth/api_token.d.ts +1 -1
  24. package/dist/auth/api_token.js +1 -1
  25. package/dist/auth/audit_log_routes.d.ts +1 -1
  26. package/dist/auth/audit_log_routes.js +1 -1
  27. package/dist/auth/audit_log_schema.d.ts +1 -1
  28. package/dist/auth/daemon_token.d.ts +1 -1
  29. package/dist/auth/daemon_token.js +1 -1
  30. package/dist/auth/daemon_token_middleware.d.ts +1 -1
  31. package/dist/auth/daemon_token_middleware.js +1 -1
  32. package/dist/auth/ddl.d.ts +1 -1
  33. package/dist/auth/ddl.js +1 -1
  34. package/dist/auth/password.d.ts +1 -1
  35. package/dist/auth/password.js +1 -1
  36. package/dist/auth/route_guards.d.ts +1 -1
  37. package/dist/auth/route_guards.js +1 -1
  38. package/dist/auth/self_service_role_action_specs.d.ts +1 -1
  39. package/dist/auth/self_service_role_action_specs.js +1 -1
  40. package/dist/auth/self_service_role_actions.d.ts +1 -1
  41. package/dist/auth/self_service_role_actions.js +1 -1
  42. package/dist/auth/session_queries.d.ts +1 -1
  43. package/dist/auth/session_queries.js +1 -1
  44. package/dist/auth/signup_routes.d.ts +1 -1
  45. package/dist/auth/signup_routes.js +1 -1
  46. package/dist/cli/util.d.ts +1 -1
  47. package/dist/cli/util.js +1 -1
  48. package/dist/db/create_db.d.ts +2 -2
  49. package/dist/db/create_db.js +2 -2
  50. package/dist/db/db.d.ts +3 -3
  51. package/dist/db/db.js +3 -3
  52. package/dist/hono_context.d.ts +1 -1
  53. package/dist/hono_context.js +1 -1
  54. package/dist/http/jsonrpc_errors.d.ts +2 -2
  55. package/dist/http/jsonrpc_errors.js +2 -2
  56. package/dist/http/jsonrpc_helpers.d.ts +2 -2
  57. package/dist/http/jsonrpc_helpers.js +2 -2
  58. package/dist/http/middleware_spec.d.ts +1 -1
  59. package/dist/http/middleware_spec.js +1 -1
  60. package/dist/http/origin.d.ts +1 -1
  61. package/dist/http/origin.js +1 -1
  62. package/dist/http/schema_helpers.d.ts +1 -1
  63. package/dist/http/schema_helpers.js +1 -1
  64. package/dist/http/surface.d.ts +1 -1
  65. package/dist/http/surface.js +1 -1
  66. package/dist/runtime/deno.d.ts +1 -1
  67. package/dist/runtime/deno.js +1 -1
  68. package/dist/runtime/node.d.ts +1 -1
  69. package/dist/runtime/node.js +1 -1
  70. package/dist/testing/rpc_attack_surface.js +1 -1
  71. package/dist/testing/rpc_helpers.js +1 -1
  72. package/dist/testing/ws_round_trip.js +1 -1
  73. package/dist/ui/account_sessions_state.svelte.d.ts +2 -2
  74. package/dist/ui/account_sessions_state.svelte.js +1 -1
  75. package/dist/ui/admin_rpc_adapters.d.ts +1 -1
  76. package/dist/ui/admin_rpc_adapters.js +1 -1
  77. package/package.json +1 -1
@@ -116,8 +116,8 @@ not the runtime):
116
116
  - `ImportBuilder` — tracks value / type / namespace imports; emits `import type` when every entry on a module is a type (tree-shaking). Namespace (`* as specs`) entries are emitted verbatim. Public surface: `add`, `add_type`, `add_many`, `add_types`, `build`, `preview`, `has_imports`, `import_count`, `clear`.
117
117
  - `get_executor_phases(spec, executor)` — phases a given executor (`'frontend' | 'backend'`) participates in for the spec. Deduplicates via `Set` (handles `initiator: 'both'` overlap).
118
118
  - `get_handler_return_type(spec, phase, imports, collections_path?)` — the TS type a phase handler must return; triggers the `ActionOutputs` import (sourced from `collections_path`, default `'./action_collections.js'`) as a side effect.
119
- - `generate_phase_handlers(spec, executor, imports, {action_event_type?, collections_path?})` — emits the typed handler-map fragment for one action; consumers compose these into `ActionHandlers` types.
120
- - `generate_actions_api_method_signature(spec, {sync_returns_value?})` — single source of truth for the typed `FrontendActionsApi` method shape. Threads `options?: RpcClientCallOptions` (`{signal?, transport_name?, queue?}`) onto every async method — `request_response`, `remote_notification`, and async `local_call` — and wraps the return in `Promise<Result<...>>`. Notifications were previously emitted as `=> void`, mismatching the runtime (`create_remote_notification_method` returns a Promise that resolves to `Result<{value: void}>`); regenerate consumer typed clients to pick up the corrected shape.
119
+ - `generate_phase_handlers(spec, executor, imports, {action_event_type?, collections_path?})` — emits the typed handler-map fragment for one action; consumers compose these into `ActionHandlers` types. Returns `''` when the spec contributes no phases on the given executor (e.g. a backend-only `local_call` asked for `'frontend'`) so wrappers' `.filter(Boolean)` drops the row entirely instead of emitting a useless `${method}?: never` for a method that doesn't belong on this side.
120
+ - `generate_actions_api_method_signature(spec, imports, {sync_returns_value?, collections_path?})` — single source of truth for the typed `FrontendActionsApi` method shape. Threads `options?: RpcClientCallOptions` (`{signal?, transport_name?, queue?}`) onto every async method — `request_response`, `remote_notification`, and async `local_call` — and wraps the return in `Promise<Result<...>>`. Registers exactly the imports the emitted line references on `imports` — `ActionInputs` only when the spec has input, `RpcClientCallOptions` only when async, `Result` / `JsonrpcErrorObject` only when the return wraps in `Result`. Mirrors the leaf-level pattern `get_handler_return_type` already follows so wrappers no longer pre-register imports a per-spec emit might not actually use.
121
121
  - `create_banner(origin_path)` — gen banner comment.
122
122
  - `to_action_spec_identifier(method)` / `to_action_spec_input_identifier` / `to_action_spec_output_identifier` — naming convention helpers (emit `foo_action_spec` / `foo_action_spec.input` / `foo_action_spec.output`).
123
123
  - `PROTOCOL_ACTION_METHODS` (+ `ProtocolActionMethod` type) — readonly tuple `['heartbeat', 'cancel']`. Pairs with `protocol_actions` / `protocol_action_specs` in `actions/protocol.ts` (the runtime bundles). Consumers spread when filtering backend `request_response` methods so dispatcher-owned protocol actions don't leak into `BackendRequestResponseMethod` / handler maps.
@@ -118,6 +118,15 @@ export declare const get_handler_return_type: (spec: ActionSpecUnion, phase: Act
118
118
  * Generates the phase handlers for an action spec using the unified ActionEvent type
119
119
  * with the new phase/step type parameters.
120
120
  *
121
+ * Returns `''` when the spec contributes no phases on the given executor side
122
+ * (e.g. a backend-only `local_call` asked for `'frontend'`). Upstream wrappers
123
+ * compose blocks with `.filter(Boolean)` so empty entries are dropped from the
124
+ * generated handler map. The earlier shape was `${method}?: never`, which read
125
+ * as "calling this here is a type error" but in practice produced useless rows
126
+ * on `FrontendActionHandlers` for methods that don't belong on this side at
127
+ * all — drop the row instead so the typed surface only carries methods the
128
+ * executor actually handles.
129
+ *
121
130
  * @param options.action_event_type - custom type name to use instead of `ActionEvent`
122
131
  * (consumers can define a narrowed type that carries typed input/output via their codegen maps)
123
132
  * @param options.collections_path - import path the side-effect `ActionOutputs` import
@@ -151,19 +160,28 @@ export declare const to_action_spec_output_identifier: (method: string) => strin
151
160
  * failure). Earlier emit shapes declared notifications as `=> void` —
152
161
  * regenerate consumer typed clients to pick up the corrected return.
153
162
  *
154
- * Consumers must import `ActionInputs`, `ActionOutputs`, `Result`,
155
- * `JsonrpcErrorObject`, and (for async) `RpcClientCallOptions` into the
156
- * generated module — the helper only emits the type references.
163
+ * Registers exactly the imports the emitted line references on `imports`:
164
+ * `ActionInputs` (when the spec has input), `ActionOutputs` (always),
165
+ * `RpcClientCallOptions` (async only), and `Result` + `JsonrpcErrorObject`
166
+ * (any return shape that wraps the value in `Result<{value}, {error}>` —
167
+ * every async method, plus sync `local_call` when `sync_returns_value:
168
+ * false`). Mirrors the leaf-level pattern `get_handler_return_type` already
169
+ * follows so wrappers no longer pre-register imports a per-spec emit might
170
+ * not actually use.
157
171
  *
158
172
  * @param spec - the action spec to emit
173
+ * @param imports - import builder to register references on
159
174
  * @param options.sync_returns_value - when true (default), sync local_call
160
175
  * methods return the output value directly; when false they're wrapped in
161
176
  * `Result<{value, error}>` like async methods. Set to `false` if your
162
177
  * FrontendActionsApi treats every method uniformly.
178
+ * @param options.collections_path - import path that `ActionInputs` /
179
+ * `ActionOutputs` resolve to. Defaults to `'./action_collections.js'`.
163
180
  * @returns one line like `foo: (input: ActionInputs['foo'], options?: RpcClientCallOptions) => Promise<Result<...>>;`
164
181
  */
165
- export declare const generate_actions_api_method_signature: (spec: ActionSpecUnion, options?: {
182
+ export declare const generate_actions_api_method_signature: (spec: ActionSpecUnion, imports: ImportBuilder, options?: {
166
183
  sync_returns_value?: boolean;
184
+ collections_path?: string;
167
185
  }) => string;
168
186
  /** Discriminator for `generate_action_method_enums` — which method-set enums to emit. */
169
187
  export type ActionMethodEnumKind = 'all' | 'request_response' | 'remote_notification' | 'local_call' | 'frontend' | 'backend' | 'frontend_handled' | 'backend_handled' | 'broadcast';
@@ -300,8 +318,11 @@ export declare const generate_action_event_datas: (specs: ReadonlyArray<ActionSp
300
318
  * (e.g. omit additional methods alongside the default protocol-action
301
319
  * filter) via `method_filter`.
302
320
  *
303
- * Adds the `Result`, `JsonrpcErrorObject`, and `RpcClientCallOptions` type
304
- * imports plus `ActionInputs` / `ActionOutputs` (sourced from `collections_path`).
321
+ * Imports are registered by the leaf `generate_actions_api_method_signature`
322
+ * per emitted line only what the spec set actually references shows up on
323
+ * `imports`. A spec set with no async methods skips `RpcClientCallOptions`;
324
+ * one with no inputs skips `ActionInputs`; sync `local_call` methods with
325
+ * `sync_returns_value: true` (the default) skip `Result` / `JsonrpcErrorObject`.
305
326
  *
306
327
  * The interface name is fixed at `FrontendActionsApi` — the symmetric counterpart
307
328
  * of `BackendActionsApi`. Earlier consumer-named variants (`MyActionsApi`,
@@ -1 +1 @@
1
- {"version":3,"file":"action_codegen.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/actions/action_codegen.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,eAAe,EAAE,gBAAgB,EAAC,MAAM,kBAAkB,CAAC;AAGxE;;;;;;;GAOG;AACH,eAAO,MAAM,uBAAuB,kCAAmC,CAAC;AAExE,8FAA8F;AAC9F,MAAM,MAAM,oBAAoB,GAAG,CAAC,OAAO,uBAAuB,CAAC,CAAC,MAAM,CAAC,CAAC;AAI5E;;;;;;;;;;GAUG;AACH,eAAO,MAAM,yBAAyB,GAAI,QAAQ,MAAM,KAAG,MAAM,IAAI,oBACrC,CAAC;AAEjC;;GAEG;AACH,UAAU,UAAU;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,WAAW,CAAC;CACrC;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,qBAAa,aAAa;;IACzB,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAa;IAE1D;;;;OAIG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;IAQrC;;;;OAIG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;IAI1C;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,IAAI;IAOrD;;OAEG;IACH,SAAS,CAAC,IAAI,EAAE,MAAM,EA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AAC"}
@@ -278,6 +278,15 @@ export const get_handler_return_type = (spec, phase, imports, collections_path =
278
278
  * Generates the phase handlers for an action spec using the unified ActionEvent type
279
279
  * with the new phase/step type parameters.
280
280
  *
281
+ * Returns `''` when the spec contributes no phases on the given executor side
282
+ * (e.g. a backend-only `local_call` asked for `'frontend'`). Upstream wrappers
283
+ * compose blocks with `.filter(Boolean)` so empty entries are dropped from the
284
+ * generated handler map. The earlier shape was `${method}?: never`, which read
285
+ * as "calling this here is a type error" but in practice produced useless rows
286
+ * on `FrontendActionHandlers` for methods that don't belong on this side at
287
+ * all — drop the row instead so the typed surface only carries methods the
288
+ * executor actually handles.
289
+ *
281
290
  * @param options.action_event_type - custom type name to use instead of `ActionEvent`
282
291
  * (consumers can define a narrowed type that carries typed input/output via their codegen maps)
283
292
  * @param options.collections_path - import path the side-effect `ActionOutputs` import
@@ -287,7 +296,7 @@ export const generate_phase_handlers = (spec, executor, imports, options) => {
287
296
  const { method } = spec;
288
297
  const phases = get_executor_phases(spec, executor);
289
298
  if (phases.length === 0) {
290
- return `${method}?: never`;
299
+ return '';
291
300
  }
292
301
  const action_event_type = options?.action_event_type ?? 'ActionEvent';
293
302
  const collections_path = options?.collections_path ?? DEFAULT_COLLECTIONS_PATH;
@@ -331,32 +340,52 @@ export const to_action_spec_output_identifier = (method) => `${to_action_spec_id
331
340
  * failure). Earlier emit shapes declared notifications as `=> void` —
332
341
  * regenerate consumer typed clients to pick up the corrected return.
333
342
  *
334
- * Consumers must import `ActionInputs`, `ActionOutputs`, `Result`,
335
- * `JsonrpcErrorObject`, and (for async) `RpcClientCallOptions` into the
336
- * generated module — the helper only emits the type references.
343
+ * Registers exactly the imports the emitted line references on `imports`:
344
+ * `ActionInputs` (when the spec has input), `ActionOutputs` (always),
345
+ * `RpcClientCallOptions` (async only), and `Result` + `JsonrpcErrorObject`
346
+ * (any return shape that wraps the value in `Result<{value}, {error}>` —
347
+ * every async method, plus sync `local_call` when `sync_returns_value:
348
+ * false`). Mirrors the leaf-level pattern `get_handler_return_type` already
349
+ * follows so wrappers no longer pre-register imports a per-spec emit might
350
+ * not actually use.
337
351
  *
338
352
  * @param spec - the action spec to emit
353
+ * @param imports - import builder to register references on
339
354
  * @param options.sync_returns_value - when true (default), sync local_call
340
355
  * methods return the output value directly; when false they're wrapped in
341
356
  * `Result<{value, error}>` like async methods. Set to `false` if your
342
357
  * FrontendActionsApi treats every method uniformly.
358
+ * @param options.collections_path - import path that `ActionInputs` /
359
+ * `ActionOutputs` resolve to. Defaults to `'./action_collections.js'`.
343
360
  * @returns one line like `foo: (input: ActionInputs['foo'], options?: RpcClientCallOptions) => Promise<Result<...>>;`
344
361
  */
345
- export const generate_actions_api_method_signature = (spec, options) => {
362
+ export const generate_actions_api_method_signature = (spec, imports, options) => {
346
363
  const sync_returns_value = options?.sync_returns_value ?? true;
364
+ const collections_path = options?.collections_path ?? DEFAULT_COLLECTIONS_PATH;
347
365
  const innermost_type_name = zod_get_base_type(spec.input);
348
366
  const has_input = innermost_type_name !== 'null' && innermost_type_name !== 'void';
349
367
  const input_param = has_input
350
368
  ? `input${spec.input.safeParse(undefined).success ? '?' : ''}: ActionInputs['${spec.method}']`
351
369
  : 'input?: void';
370
+ if (has_input)
371
+ imports.add_type(collections_path, 'ActionInputs');
372
+ imports.add_type(collections_path, 'ActionOutputs');
352
373
  const is_async = spec.kind === 'request_response' || spec.kind === 'remote_notification' || spec.async;
353
374
  const options_param = is_async ? ', options?: RpcClientCallOptions' : '';
375
+ if (is_async) {
376
+ imports.add_type('@fuzdev/fuz_app/actions/rpc_client.js', 'RpcClientCallOptions');
377
+ }
354
378
  const result_return = `Result<{value: ActionOutputs['${spec.method}']}, {error: JsonrpcErrorObject}>`;
355
379
  const return_type = is_async
356
380
  ? `Promise<${result_return}>`
357
381
  : sync_returns_value
358
382
  ? `ActionOutputs['${spec.method}']`
359
383
  : result_return;
384
+ const wraps_in_result = is_async || !sync_returns_value;
385
+ if (wraps_in_result) {
386
+ imports.add_type('@fuzdev/fuz_util/result.js', 'Result');
387
+ imports.add_type('@fuzdev/fuz_app/http/jsonrpc.js', 'JsonrpcErrorObject');
388
+ }
360
389
  return `${spec.method}: (${input_param}${options_param}) => ${return_type};`;
361
390
  };
362
391
  // --------------------------------------------------------------------------
@@ -711,8 +740,11 @@ ${lines.join('\n')}
711
740
  * (e.g. omit additional methods alongside the default protocol-action
712
741
  * filter) via `method_filter`.
713
742
  *
714
- * Adds the `Result`, `JsonrpcErrorObject`, and `RpcClientCallOptions` type
715
- * imports plus `ActionInputs` / `ActionOutputs` (sourced from `collections_path`).
743
+ * Imports are registered by the leaf `generate_actions_api_method_signature`
744
+ * per emitted line only what the spec set actually references shows up on
745
+ * `imports`. A spec set with no async methods skips `RpcClientCallOptions`;
746
+ * one with no inputs skips `ActionInputs`; sync `local_call` methods with
747
+ * `sync_returns_value: true` (the default) skip `Result` / `JsonrpcErrorObject`.
716
748
  *
717
749
  * The interface name is fixed at `FrontendActionsApi` — the symmetric counterpart
718
750
  * of `BackendActionsApi`. Earlier consumer-named variants (`MyActionsApi`,
@@ -738,14 +770,10 @@ export const generate_frontend_actions_api = (specs, imports, options) => {
738
770
  return `${interface_doc}
739
771
  export interface FrontendActionsApi {}`;
740
772
  }
741
- const collections_path = options?.collections_path ?? DEFAULT_COLLECTIONS_PATH;
742
- imports.add_type('@fuzdev/fuz_util/result.js', 'Result');
743
- imports.add_type('@fuzdev/fuz_app/http/jsonrpc.js', 'JsonrpcErrorObject');
744
- imports.add_type('@fuzdev/fuz_app/actions/rpc_client.js', 'RpcClientCallOptions');
745
- imports.add_types(collections_path, 'ActionInputs', 'ActionOutputs');
746
773
  const lines = filtered
747
- .map((spec) => generate_actions_api_method_signature(spec, {
774
+ .map((spec) => generate_actions_api_method_signature(spec, imports, {
748
775
  sync_returns_value: options?.sync_returns_value,
776
+ collections_path: options?.collections_path,
749
777
  }))
750
778
  .map((line) => `\t${line}`)
751
779
  .join('\n');
@@ -17,7 +17,7 @@
17
17
  *
18
18
  * Cache discipline: `spec_by_method` (Map) and the internal streams-target
19
19
  * set lazy-memoize because the Map is consulted per-RPC dispatch
20
- * (`frontend_rpc_client.ts` wires it into `lookup_action_spec`) and the
20
+ * (`actions/frontend_rpc_client.ts` wires it into `lookup_action_spec`) and the
21
21
  * streams set is rebuilt by two public getters. Array-returning getters
22
22
  * recompute on each call so callers can mutate the result freely
23
23
  * (`.sort()`, `.push(injected)` on a copy, etc.) without affecting the
@@ -17,7 +17,7 @@
17
17
  *
18
18
  * Cache discipline: `spec_by_method` (Map) and the internal streams-target
19
19
  * set lazy-memoize because the Map is consulted per-RPC dispatch
20
- * (`frontend_rpc_client.ts` wires it into `lookup_action_spec`) and the
20
+ * (`actions/frontend_rpc_client.ts` wires it into `lookup_action_spec`) and the
21
21
  * streams set is rebuilt by two public getters. Array-returning getters
22
22
  * recompute on each call so callers can mutate the result freely
23
23
  * (`.sort()`, `.push(injected)` on a copy, etc.) without affecting the
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * Extracted from zzz's action system. Action specs define method, kind,
5
5
  * auth, side effects, and input/output schemas. Bridge functions in
6
- * `action_bridge.ts` derive `RouteSpec` and `EventSpec` from them.
6
+ * `actions/action_bridge.ts` derive `RouteSpec` and `EventSpec` from them.
7
7
  *
8
8
  * TODO @action-system-review The action system (action_spec, action_registry,
9
9
  * action_codegen, action_bridge) will evolve significantly as RPC patterns settle.
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * Extracted from zzz's action system. Action specs define method, kind,
5
5
  * auth, side effects, and input/output schemas. Bridge functions in
6
- * `action_bridge.ts` derive `RouteSpec` and `EventSpec` from them.
6
+ * `actions/action_bridge.ts` derive `RouteSpec` and `EventSpec` from them.
7
7
  *
8
8
  * TODO @action-system-review The action system (action_spec, action_registry,
9
9
  * action_codegen, action_bridge) will evolve significantly as RPC patterns settle.
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * Shared type surface for the action system — context, handler, composable Action tuple.
3
3
  *
4
- * These types sit above `action_spec.ts` (pure Zod schemas) and below the
5
- * dispatchers (`register_action_ws.ts`, `action_rpc.ts`). Extracted so the
4
+ * These types sit above `actions/action_spec.ts` (pure Zod schemas) and below the
5
+ * dispatchers (`actions/register_action_ws.ts`, `actions/action_rpc.ts`). Extracted so the
6
6
  * shared protocol actions (e.g. `heartbeat_action`) can name them without
7
7
  * pulling in server-only modules.
8
8
  *
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * Shared type surface for the action system — context, handler, composable Action tuple.
3
3
  *
4
- * These types sit above `action_spec.ts` (pure Zod schemas) and below the
5
- * dispatchers (`register_action_ws.ts`, `action_rpc.ts`). Extracted so the
4
+ * These types sit above `actions/action_spec.ts` (pure Zod schemas) and below the
5
+ * dispatchers (`actions/register_action_ws.ts`, `actions/action_rpc.ts`). Extracted so the
6
6
  * shared protocol actions (e.g. `heartbeat_action`) can name them without
7
7
  * pulling in server-only modules.
8
8
  *
@@ -14,7 +14,7 @@
14
14
  * handler). The handler exists for symmetry with other protocol actions
15
15
  * like `heartbeat_action`; the dispatcher never calls it. Consumers
16
16
  * spread `cancel_action` (or the `protocol_actions` bundle from
17
- * `./protocol.js`) into their server's `actions` array so `spec_by_method`
17
+ * `actions/protocol.ts`) into their server's `actions` array so `spec_by_method`
18
18
  * knows about it (enabling input validation on incoming cancels) and so
19
19
  * `create_rpc_client` codegen produces `app.api.cancel()` when desired —
20
20
  * though `FrontendWebsocketClient.request({signal})` sends the cancel on
@@ -69,7 +69,7 @@ export declare const cancel_action_spec: {
69
69
  export declare const cancel_handler: () => void;
70
70
  /**
71
71
  * Protocol-action tuple — spread into the server's `actions` array (or via
72
- * `protocol_actions` from `./protocol.js`) so the dispatcher registers the
72
+ * `protocol_actions` from `actions/protocol.ts`) so the dispatcher registers the
73
73
  * spec for input validation and so `create_rpc_client` codegen sees the
74
74
  * method. The client doesn't need to call it directly;
75
75
  * `FrontendWebsocketClient.request({signal})` sends the cancel notification
@@ -14,7 +14,7 @@
14
14
  * handler). The handler exists for symmetry with other protocol actions
15
15
  * like `heartbeat_action`; the dispatcher never calls it. Consumers
16
16
  * spread `cancel_action` (or the `protocol_actions` bundle from
17
- * `./protocol.js`) into their server's `actions` array so `spec_by_method`
17
+ * `actions/protocol.ts`) into their server's `actions` array so `spec_by_method`
18
18
  * knows about it (enabling input validation on incoming cancels) and so
19
19
  * `create_rpc_client` codegen produces `app.api.cancel()` when desired —
20
20
  * though `FrontendWebsocketClient.request({signal})` sends the cancel on
@@ -66,7 +66,7 @@ export const cancel_action_spec = {
66
66
  export const cancel_handler = () => { }; // eslint-disable-line @typescript-eslint/no-empty-function
67
67
  /**
68
68
  * Protocol-action tuple — spread into the server's `actions` array (or via
69
- * `protocol_actions` from `./protocol.js`) so the dispatcher registers the
69
+ * `protocol_actions` from `actions/protocol.ts`) so the dispatcher registers the
70
70
  * spec for input validation and so `create_rpc_client` codegen sees the
71
71
  * method. The client doesn't need to call it directly;
72
72
  * `FrontendWebsocketClient.request({signal})` sends the cancel notification
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Shared heartbeat action — a fuz_app protocol action carrying both a spec
3
3
  * and a handler in one tuple. Consumers spread `heartbeat_action` (or the
4
- * `protocol_actions` bundle from `./protocol.js`) into the server's
4
+ * `protocol_actions` bundle from `actions/protocol.ts`) into the server's
5
5
  * `actions` array so disconnect detection works identically across every
6
6
  * repo without per-consumer ping plumbing.
7
7
  *
@@ -39,7 +39,7 @@ export declare const heartbeat_action_spec: {
39
39
  export declare const heartbeat_handler: () => Record<string, never>;
40
40
  /**
41
41
  * Protocol-action tuple — spread into the server's `actions` array for
42
- * dispatch (or via `protocol_actions` from `./protocol.js`) so the
42
+ * dispatch (or via `protocol_actions` from `actions/protocol.ts`) so the
43
43
  * dispatcher resolves the heartbeat handler. The frontend-side spread
44
44
  * happens via `protocol_action_specs` — the client doesn't run the echo
45
45
  * handler, but the spec must be in `ActionRegistry` so `create_rpc_client`
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Shared heartbeat action — a fuz_app protocol action carrying both a spec
3
3
  * and a handler in one tuple. Consumers spread `heartbeat_action` (or the
4
- * `protocol_actions` bundle from `./protocol.js`) into the server's
4
+ * `protocol_actions` bundle from `actions/protocol.ts`) into the server's
5
5
  * `actions` array so disconnect detection works identically across every
6
6
  * repo without per-consumer ping plumbing.
7
7
  *
@@ -38,7 +38,7 @@ export const heartbeat_action_spec = {
38
38
  export const heartbeat_handler = () => ({});
39
39
  /**
40
40
  * Protocol-action tuple — spread into the server's `actions` array for
41
- * dispatch (or via `protocol_actions` from `./protocol.js`) so the
41
+ * dispatch (or via `protocol_actions` from `actions/protocol.ts`) so the
42
42
  * dispatcher resolves the heartbeat handler. The frontend-side spread
43
43
  * happens via `protocol_action_specs` — the client doesn't run the echo
44
44
  * handler, but the spec must be in `ActionRegistry` so `create_rpc_client`
@@ -7,7 +7,7 @@
7
7
  * fuz_app, not consumer domain logic. The split is intentional: the server
8
8
  * needs `{spec, handler}` tuples to drive dispatch; the frontend
9
9
  * `ActionRegistry` only stores specs. The codegen
10
- * `include_protocol_actions: false` default (in `action_codegen.ts`) is the
10
+ * `include_protocol_actions: false` default (in `actions/action_codegen.ts`) is the
11
11
  * third leg of this contract — protocol actions are excluded from
12
12
  * generated typed surfaces because consumers spread them in at
13
13
  * registration time.
@@ -7,7 +7,7 @@
7
7
  * fuz_app, not consumer domain logic. The split is intentional: the server
8
8
  * needs `{spec, handler}` tuples to drive dispatch; the frontend
9
9
  * `ActionRegistry` only stores specs. The codegen
10
- * `include_protocol_actions: false` default (in `action_codegen.ts`) is the
10
+ * `include_protocol_actions: false` default (in `actions/action_codegen.ts`) is the
11
11
  * third leg of this contract — protocol actions are excluded from
12
12
  * generated typed surfaces because consumers spread them in at
13
13
  * registration time.
@@ -157,7 +157,7 @@ export interface RegisterActionWsResult {
157
157
  * - Per-action auth: `public` / `authenticated` pass through (upgrade auth
158
158
  * already verified identity); `keeper` requires `daemon_token` credential
159
159
  * type *and* the keeper role; role-based `{role}` requires the named role
160
- * via `has_role`, matching the HTTP path in `action_rpc.ts`.
160
+ * via `has_role`, matching the HTTP path in `actions/action_rpc.ts`.
161
161
  * - DEV mode validates handler output against the spec's `output` schema and
162
162
  * warns on mismatches.
163
163
  *
@@ -55,7 +55,7 @@ export const DEFAULT_SERVER_HEARTBEAT_TIMEOUT = 60_000;
55
55
  * - Per-action auth: `public` / `authenticated` pass through (upgrade auth
56
56
  * already verified identity); `keeper` requires `daemon_token` credential
57
57
  * type *and* the keeper role; role-based `{role}` requires the named role
58
- * via `has_role`, matching the HTTP path in `action_rpc.ts`.
58
+ * via `has_role`, matching the HTTP path in `actions/action_rpc.ts`.
59
59
  * - DEV mode validates handler output against the spec's `output` schema and
60
60
  * warns on mismatches.
61
61
  *
@@ -4,7 +4,7 @@
4
4
  * Returns `RouteSpec[]` — caller applies them to Hono via `apply_route_specs`.
5
5
  *
6
6
  * Four REST flows remain here; each has a concrete reason to stay REST
7
- * rather than moving to `account_actions.ts`:
7
+ * rather than moving to `auth/account_actions.ts`:
8
8
  *
9
9
  * - `POST /login` — issues a signed `Set-Cookie` and pre-handler rate-limits
10
10
  * by IP + per-canonical-account before password hashing.
@@ -15,7 +15,7 @@
15
15
  * callers should use the `account_verify` RPC action for the typed payload.
16
16
  *
17
17
  * Session listing/revocation and API token CRUD are on the RPC endpoint —
18
- * see `account_actions.ts`. Signup is in `signup_routes.ts`. Defaults are
18
+ * see `auth/account_actions.ts`. Signup is in `auth/signup_routes.ts`. Defaults are
19
19
  * closed/safe: accounts are created through bootstrap, admin action, or
20
20
  * invite.
21
21
  *
@@ -184,7 +184,7 @@ export type PasswordChangeOutput = z.infer<typeof PasswordChangeOutput>;
184
184
  *
185
185
  * The returned specs cover the three flows that stay REST after the RPC
186
186
  * migration (login, logout, password change). Self-service session/token
187
- * management and verify are on `account_actions.ts`.
187
+ * management and verify are on `auth/account_actions.ts`.
188
188
  *
189
189
  * @param deps - stateless capabilities (keyring, password, log)
190
190
  * @param options - per-factory configuration (session_options, ip_rate_limiter, login_account_rate_limiter)
@@ -4,7 +4,7 @@
4
4
  * Returns `RouteSpec[]` — caller applies them to Hono via `apply_route_specs`.
5
5
  *
6
6
  * Four REST flows remain here; each has a concrete reason to stay REST
7
- * rather than moving to `account_actions.ts`:
7
+ * rather than moving to `auth/account_actions.ts`:
8
8
  *
9
9
  * - `POST /login` — issues a signed `Set-Cookie` and pre-handler rate-limits
10
10
  * by IP + per-canonical-account before password hashing.
@@ -15,7 +15,7 @@
15
15
  * callers should use the `account_verify` RPC action for the typed payload.
16
16
  *
17
17
  * Session listing/revocation and API token CRUD are on the RPC endpoint —
18
- * see `account_actions.ts`. Signup is in `signup_routes.ts`. Defaults are
18
+ * see `auth/account_actions.ts`. Signup is in `auth/signup_routes.ts`. Defaults are
19
19
  * closed/safe: accounts are created through bootstrap, admin action, or
20
20
  * invite.
21
21
  *
@@ -167,7 +167,7 @@ export const PasswordChangeOutput = z.strictObject({
167
167
  *
168
168
  * The returned specs cover the three flows that stay REST after the RPC
169
169
  * migration (login, logout, password change). Self-service session/token
170
- * management and verify are on `account_actions.ts`.
170
+ * management and verify are on `auth/account_actions.ts`.
171
171
  *
172
172
  * @param deps - stateless capabilities (keyring, password, log)
173
173
  * @param options - per-factory configuration (session_options, ip_rate_limiter, login_account_rate_limiter)
@@ -4,7 +4,7 @@
4
4
  * Defines the runtime types for the fuz identity system:
5
5
  * `Account`, `Actor`, `Permit`, `AuthSession`, and `ApiToken`.
6
6
  *
7
- * DDL lives in `ddl.ts`; role system in `role_schema.ts`.
7
+ * DDL lives in `auth/ddl.ts`; role system in `auth/role_schema.ts`.
8
8
  * See docs/identity.md for design rationale.
9
9
  *
10
10
  * @module
@@ -4,7 +4,7 @@
4
4
  * Defines the runtime types for the fuz identity system:
5
5
  * `Account`, `Actor`, `Permit`, `AuthSession`, and `ApiToken`.
6
6
  *
7
- * DDL lives in `ddl.ts`; role system in `role_schema.ts`.
7
+ * DDL lives in `auth/ddl.ts`; role system in `auth/role_schema.ts`.
8
8
  * See docs/identity.md for design rationale.
9
9
  *
10
10
  * @module
@@ -4,7 +4,7 @@
4
4
  * Tokens use the format `secret_fuz_token_<base64url>` and are stored
5
5
  * as blake3 hashes. These are pure cryptographic operations with no
6
6
  * framework dependency — the bearer auth middleware that validates
7
- * tokens lives in `bearer_auth.ts`.
7
+ * tokens lives in `auth/bearer_auth.ts`.
8
8
  *
9
9
  * @module
10
10
  */
@@ -4,7 +4,7 @@
4
4
  * Tokens use the format `secret_fuz_token_<base64url>` and are stored
5
5
  * as blake3 hashes. These are pure cryptographic operations with no
6
6
  * framework dependency — the bearer auth middleware that validates
7
- * tokens lives in `bearer_auth.ts`.
7
+ * tokens lives in `auth/bearer_auth.ts`.
8
8
  *
9
9
  * @module
10
10
  */
@@ -2,7 +2,7 @@
2
2
  * Audit log SSE stream route.
3
3
  *
4
4
  * The two list-reads (`audit_log_list`, `audit_log_permit_history`) moved to
5
- * RPC in `admin_actions.ts`, and the admin session listing moved to
5
+ * RPC in `auth/admin_actions.ts`, and the admin session listing moved to
6
6
  * `admin_session_list` on the same file. What remains here is the optional
7
7
  * `GET /audit-log/stream` SSE route — streams aren't an action-kind, so they
8
8
  * stay on REST. The event payload broadcast on the stream surfaces via
@@ -2,7 +2,7 @@
2
2
  * Audit log SSE stream route.
3
3
  *
4
4
  * The two list-reads (`audit_log_list`, `audit_log_permit_history`) moved to
5
- * RPC in `admin_actions.ts`, and the admin session listing moved to
5
+ * RPC in `auth/admin_actions.ts`, and the admin session listing moved to
6
6
  * `admin_session_list` on the same file. What remains here is the optional
7
7
  * `GET /audit-log/stream` SSE route — streams aren't an action-kind, so they
8
8
  * stay on REST. The event payload broadcast on the stream surfaces via
@@ -242,7 +242,7 @@ export interface CreateAuditLogConfigOptions {
242
242
  *
243
243
  * Collisions with builtin event-type strings throw at construction.
244
244
  * Schemas are run via `safeParse` at insert time; mismatches log + count
245
- * but never throw (fail-open — see the drift counters in `audit_log_queries.ts`).
245
+ * but never throw (fail-open — see the drift counters in `auth/audit_log_queries.ts`).
246
246
  */
247
247
  extra_events?: Readonly<Record<string, z.ZodType | null>>;
248
248
  }
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * Pure auth operations with no I/O or state management.
5
5
  * The middleware, rotation, and persistence logic lives in
6
- * `daemon_token_middleware.ts`.
6
+ * `auth/daemon_token_middleware.ts`.
7
7
  *
8
8
  * @module
9
9
  */
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * Pure auth operations with no I/O or state management.
5
5
  * The middleware, rotation, and persistence logic lives in
6
- * `daemon_token_middleware.ts`.
6
+ * `auth/daemon_token_middleware.ts`.
7
7
  *
8
8
  * @module
9
9
  */
@@ -4,7 +4,7 @@
4
4
  * Manages the lifecycle of filesystem-resident daemon tokens: writing to disk,
5
5
  * rotation on an interval, and HTTP middleware for authentication.
6
6
  *
7
- * Pure token primitives (schema, generation, validation) live in `daemon_token.ts`.
7
+ * Pure token primitives (schema, generation, validation) live in `auth/daemon_token.ts`.
8
8
  * See docs/identity.md for design rationale.
9
9
  *
10
10
  * @module
@@ -4,7 +4,7 @@
4
4
  * Manages the lifecycle of filesystem-resident daemon tokens: writing to disk,
5
5
  * rotation on an interval, and HTTP middleware for authentication.
6
6
  *
7
- * Pure token primitives (schema, generation, validation) live in `daemon_token.ts`.
7
+ * Pure token primitives (schema, generation, validation) live in `auth/daemon_token.ts`.
8
8
  * See docs/identity.md for design rationale.
9
9
  *
10
10
  * @module
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Auth table DDL — CREATE TABLE, index, and seed statements.
3
3
  *
4
- * Consumed by `migrations.ts`. Separated from `account_schema.ts`
4
+ * Consumed by `auth/migrations.ts`. Separated from `auth/account_schema.ts`
5
5
  * to isolate DDL concerns from runtime types.
6
6
  *
7
7
  * @module
package/dist/auth/ddl.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Auth table DDL — CREATE TABLE, index, and seed statements.
3
3
  *
4
- * Consumed by `migrations.ts`. Separated from `account_schema.ts`
4
+ * Consumed by `auth/migrations.ts`. Separated from `auth/account_schema.ts`
5
5
  * to isolate DDL concerns from runtime types.
6
6
  *
7
7
  * @module
@@ -2,7 +2,7 @@
2
2
  * Password hashing type definitions.
3
3
  *
4
4
  * Defines the `PasswordHashDeps` injectable interface and `PASSWORD_LENGTH_MIN`.
5
- * Concrete Argon2id implementation lives in `password_argon2.ts`.
5
+ * Concrete Argon2id implementation lives in `auth/password_argon2.ts`.
6
6
  *
7
7
  * @module
8
8
  */
@@ -2,7 +2,7 @@
2
2
  * Password hashing type definitions.
3
3
  *
4
4
  * Defines the `PasswordHashDeps` injectable interface and `PASSWORD_LENGTH_MIN`.
5
- * Concrete Argon2id implementation lives in `password_argon2.ts`.
5
+ * Concrete Argon2id implementation lives in `auth/password_argon2.ts`.
6
6
  *
7
7
  * @module
8
8
  */
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * Maps `RouteAuth` discriminants to auth middleware handlers.
5
5
  * Injected into `apply_route_specs` to decouple the generic HTTP
6
- * framework (`route_spec.ts`) from auth-specific middleware.
6
+ * framework (`http/route_spec.ts`) from auth-specific middleware.
7
7
  *
8
8
  * @module
9
9
  */
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * Maps `RouteAuth` discriminants to auth middleware handlers.
5
5
  * Injected into `apply_route_specs` to decouple the generic HTTP
6
- * framework (`route_spec.ts`) from auth-specific middleware.
6
+ * framework (`http/route_spec.ts`) from auth-specific middleware.
7
7
  *
8
8
  * @module
9
9
  */
@@ -3,7 +3,7 @@
3
3
  * and the codegen-ready registry.
4
4
  *
5
5
  * Client-safe: no query-layer or audit-write imports. Handler factory
6
- * lives in `self_service_role_actions.ts`.
6
+ * lives in `auth/self_service_role_actions.ts`.
7
7
  *
8
8
  * @module
9
9
  */
@@ -3,7 +3,7 @@
3
3
  * and the codegen-ready registry.
4
4
  *
5
5
  * Client-safe: no query-layer or audit-write imports. Handler factory
6
- * lives in `self_service_role_actions.ts`.
6
+ * lives in `auth/self_service_role_actions.ts`.
7
7
  *
8
8
  * @module
9
9
  */
@@ -25,7 +25,7 @@
25
25
  * the existing `permit_offer_create({role})` precedent rather than
26
26
  * generating per-role methods.
27
27
  *
28
- * Specs and schemas live in `self_service_role_action_specs.ts` so
28
+ * Specs and schemas live in `auth/self_service_role_action_specs.ts` so
29
29
  * client-side codegen can import the surface without dragging in the
30
30
  * query layer.
31
31
  *
@@ -25,7 +25,7 @@
25
25
  * the existing `permit_offer_create({role})` precedent rather than
26
26
  * generating per-role methods.
27
27
  *
28
- * Specs and schemas live in `self_service_role_action_specs.ts` so
28
+ * Specs and schemas live in `auth/self_service_role_action_specs.ts` so
29
29
  * client-side codegen can import the surface without dragging in the
30
30
  * query layer.
31
31
  *
@@ -57,7 +57,7 @@ export declare const query_session_touch: (deps: QueryDeps, token_hash: string)
57
57
  * The `_unscoped` suffix is the safety signal — there is no `account_id`
58
58
  * constraint, so callers must guarantee the hash came from a trusted
59
59
  * source (the authenticated session cookie path is the only safe production
60
- * caller — see `account_routes.ts` `/logout`). For user-facing revocation
60
+ * caller — see `auth/account_routes.ts` `/logout`). For user-facing revocation
61
61
  * of a specific session by ID, use `query_session_revoke_for_account`
62
62
  * (IDOR-guarded).
63
63
  */
@@ -77,7 +77,7 @@ export const query_session_touch = async (deps, token_hash) => {
77
77
  * The `_unscoped` suffix is the safety signal — there is no `account_id`
78
78
  * constraint, so callers must guarantee the hash came from a trusted
79
79
  * source (the authenticated session cookie path is the only safe production
80
- * caller — see `account_routes.ts` `/logout`). For user-facing revocation
80
+ * caller — see `auth/account_routes.ts` `/logout`). For user-facing revocation
81
81
  * of a specific session by ID, use `query_session_revoke_for_account`
82
82
  * (IDOR-guarded).
83
83
  */
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * Public endpoint that creates an account. When `open_signup` is disabled
5
5
  * (default), a matching unclaimed invite is required. When enabled, anyone
6
- * can sign up without an invite. Follows the `bootstrap_routes.ts` pattern.
6
+ * can sign up without an invite. Follows the `auth/bootstrap_routes.ts` pattern.
7
7
  *
8
8
  * @module
9
9
  */
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * Public endpoint that creates an account. When `open_signup` is disabled
5
5
  * (default), a matching unclaimed invite is required. When enabled, anyone
6
- * can sign up without an invite. Follows the `bootstrap_routes.ts` pattern.
6
+ * can sign up without an invite. Follows the `auth/bootstrap_routes.ts` pattern.
7
7
  *
8
8
  * @module
9
9
  */
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * CLI utilities for colors, confirmation, and command delegation.
3
3
  *
4
- * For structured CLI logging, see `create_cli_logger` in `logger.ts`.
4
+ * For structured CLI logging, see `create_cli_logger` in `cli/logger.ts`.
5
5
  *
6
6
  * @module
7
7
  */
package/dist/cli/util.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * CLI utilities for colors, confirmation, and command delegation.
3
3
  *
4
- * For structured CLI logging, see `create_cli_logger` in `logger.ts`.
4
+ * For structured CLI logging, see `create_cli_logger` in `cli/logger.ts`.
5
5
  *
6
6
  * @module
7
7
  */
@@ -8,7 +8,7 @@
8
8
  *
9
9
  * Both `pg` and `@electric-sql/pglite` are optional peer dependencies,
10
10
  * dynamically imported only when needed. For direct driver construction
11
- * without auto-detection, use `db_pg.ts` or `db_pglite.ts`.
11
+ * without auto-detection, use `db/db_pg.ts` or `db/db_pglite.ts`.
12
12
  *
13
13
  * @module
14
14
  */
@@ -29,7 +29,7 @@ export interface CreateDbResult {
29
29
  * know which driver is in use.
30
30
  *
31
31
  * For direct driver construction without URL routing, import
32
- * `create_pg_db` from `db_pg.ts` or `create_pglite_db` from `db_pglite.ts`.
32
+ * `create_pg_db` from `db/db_pg.ts` or `create_pglite_db` from `db/db_pglite.ts`.
33
33
  *
34
34
  * @param database_url - connection URL (`postgres://`, `postgresql://`, `file://`, or `memory://`)
35
35
  * @returns database instance, close callback, type, and display name
@@ -8,7 +8,7 @@
8
8
  *
9
9
  * Both `pg` and `@electric-sql/pglite` are optional peer dependencies,
10
10
  * dynamically imported only when needed. For direct driver construction
11
- * without auto-detection, use `db_pg.ts` or `db_pglite.ts`.
11
+ * without auto-detection, use `db/db_pg.ts` or `db/db_pglite.ts`.
12
12
  *
13
13
  * @module
14
14
  */
@@ -22,7 +22,7 @@ import { create_pglite_db } from './db_pglite.js';
22
22
  * know which driver is in use.
23
23
  *
24
24
  * For direct driver construction without URL routing, import
25
- * `create_pg_db` from `db_pg.ts` or `create_pglite_db` from `db_pglite.ts`.
25
+ * `create_pg_db` from `db/db_pg.ts` or `create_pglite_db` from `db/db_pglite.ts`.
26
26
  *
27
27
  * @param database_url - connection URL (`postgres://`, `postgresql://`, `file://`, or `memory://`)
28
28
  * @returns database instance, close callback, type, and display name
package/dist/db/db.d.ts CHANGED
@@ -5,7 +5,7 @@
5
5
  * Both `pg.Pool` and `@electric-sql/pglite` satisfy this interface.
6
6
  *
7
7
  * Transaction safety is provided by an injected `transaction` callback —
8
- * the driver adapters (`db_pg.ts`, `db_pglite.ts`) supply the driver-appropriate
8
+ * the driver adapters (`db/db_pg.ts`, `db/db_pglite.ts`) supply the driver-appropriate
9
9
  * implementation. Close is handled externally (returned alongside the Db
10
10
  * as `DbDriverResult`), not as a method on this class.
11
11
  *
@@ -55,8 +55,8 @@ export declare const no_nested_transaction: DbDeps['transaction'];
55
55
  /**
56
56
  * Database wrapper providing a consistent query and transaction interface.
57
57
  *
58
- * Construct via `create_pg_db()` from `db_pg.ts` or `create_pglite_db()` from
59
- * `db_pglite.ts` for proper transaction support, or via `create_db()` for
58
+ * Construct via `create_pg_db()` from `db/db_pg.ts` or `create_pglite_db()` from
59
+ * `db/db_pglite.ts` for proper transaction support, or via `create_db()` for
60
60
  * URL-based auto-detection.
61
61
  *
62
62
  * @example
package/dist/db/db.js CHANGED
@@ -5,7 +5,7 @@
5
5
  * Both `pg.Pool` and `@electric-sql/pglite` satisfy this interface.
6
6
  *
7
7
  * Transaction safety is provided by an injected `transaction` callback —
8
- * the driver adapters (`db_pg.ts`, `db_pglite.ts`) supply the driver-appropriate
8
+ * the driver adapters (`db/db_pg.ts`, `db/db_pglite.ts`) supply the driver-appropriate
9
9
  * implementation. Close is handled externally (returned alongside the Db
10
10
  * as `DbDriverResult`), not as a method on this class.
11
11
  *
@@ -24,8 +24,8 @@ export const no_nested_transaction = () => {
24
24
  /**
25
25
  * Database wrapper providing a consistent query and transaction interface.
26
26
  *
27
- * Construct via `create_pg_db()` from `db_pg.ts` or `create_pglite_db()` from
28
- * `db_pglite.ts` for proper transaction support, or via `create_db()` for
27
+ * Construct via `create_pg_db()` from `db/db_pg.ts` or `create_pglite_db()` from
28
+ * `db/db_pglite.ts` for proper transaction support, or via `create_db()` for
29
29
  * URL-based auto-detection.
30
30
  *
31
31
  * @example
@@ -7,7 +7,7 @@
7
7
  * Import this module once in your app to get type-safe access to
8
8
  * `auth_session_id`, `request_context`, and `credential_type` on the Hono context.
9
9
  *
10
- * In practice, this is auto-loaded by `app_server.ts` (side-effect import)
10
+ * In practice, this is auto-loaded by `server/app_server.ts` (side-effect import)
11
11
  * and transitively by auth middleware modules that import `CREDENTIAL_TYPE_KEY`.
12
12
  * Consumers don't need a manual import unless bypassing the standard server assembly.
13
13
  *
@@ -7,7 +7,7 @@
7
7
  * Import this module once in your app to get type-safe access to
8
8
  * `auth_session_id`, `request_context`, and `credential_type` on the Hono context.
9
9
  *
10
- * In practice, this is auto-loaded by `app_server.ts` (side-effect import)
10
+ * In practice, this is auto-loaded by `server/app_server.ts` (side-effect import)
11
11
  * and transitively by auth middleware modules that import `CREDENTIAL_TYPE_KEY`.
12
12
  * Consumers don't need a manual import unless bypassing the standard server assembly.
13
13
  *
@@ -7,10 +7,10 @@
7
7
  * codes stay in consumers — add by casting `as JsonrpcErrorCode`.
8
8
  *
9
9
  * `JsonrpcErrorCode` and `JsonrpcErrorObject` types are Zod-inferred
10
- * from `jsonrpc.ts` — this module re-uses those as the single source
10
+ * from `http/jsonrpc.ts` — this module re-uses those as the single source
11
11
  * of truth.
12
12
  *
13
- * Complementary to `error_schemas.ts`: that module is declarative
13
+ * Complementary to `http/error_schemas.ts`: that module is declarative
14
14
  * (Zod schemas for surface introspection), this one is runtime
15
15
  * (throw + catch + map).
16
16
  *
@@ -7,10 +7,10 @@
7
7
  * codes stay in consumers — add by casting `as JsonrpcErrorCode`.
8
8
  *
9
9
  * `JsonrpcErrorCode` and `JsonrpcErrorObject` types are Zod-inferred
10
- * from `jsonrpc.ts` — this module re-uses those as the single source
10
+ * from `http/jsonrpc.ts` — this module re-uses those as the single source
11
11
  * of truth.
12
12
  *
13
- * Complementary to `error_schemas.ts`: that module is declarative
13
+ * Complementary to `http/error_schemas.ts`: that module is declarative
14
14
  * (Zod schemas for surface introspection), this one is runtime
15
15
  * (throw + catch + map).
16
16
  *
@@ -2,8 +2,8 @@
2
2
  * JSON-RPC message builders, type guards, and converters.
3
3
  *
4
4
  * Used by the SAES runtime (ActionEvent, ActionPeer, transports) and
5
- * the RPC endpoint dispatcher. Complements `jsonrpc.ts` (schemas) and
6
- * `jsonrpc_errors.ts` (error infrastructure).
5
+ * the RPC endpoint dispatcher. Complements `http/jsonrpc.ts` (schemas) and
6
+ * `http/jsonrpc_errors.ts` (error infrastructure).
7
7
  *
8
8
  * @module
9
9
  */
@@ -2,8 +2,8 @@
2
2
  * JSON-RPC message builders, type guards, and converters.
3
3
  *
4
4
  * Used by the SAES runtime (ActionEvent, ActionPeer, transports) and
5
- * the RPC endpoint dispatcher. Complements `jsonrpc.ts` (schemas) and
6
- * `jsonrpc_errors.ts` (error infrastructure).
5
+ * the RPC endpoint dispatcher. Complements `http/jsonrpc.ts` (schemas) and
6
+ * `http/jsonrpc_errors.ts` (error infrastructure).
7
7
  *
8
8
  * @module
9
9
  */
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Middleware spec type — named middleware layer definition.
3
3
  *
4
- * Separated from `route_spec.ts` so middleware modules can import this
4
+ * Separated from `http/route_spec.ts` so middleware modules can import this
5
5
  * type without creating an upward dependency on routes.
6
6
  *
7
7
  * @module
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Middleware spec type — named middleware layer definition.
3
3
  *
4
- * Separated from `route_spec.ts` so middleware modules can import this
4
+ * Separated from `http/route_spec.ts` so middleware modules can import this
5
5
  * type without creating an upward dependency on routes.
6
6
  *
7
7
  * @module
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * Verifies requests are coming from expected origins/referers.
5
5
  * CSRF protection is provided by `SameSite: strict` on session cookies
6
- * (see `session_middleware.ts`). This module provides origin allowlisting
6
+ * (see `auth/session_middleware.ts`). This module provides origin allowlisting
7
7
  * for locally-running services — preventing untrusted websites from
8
8
  * making requests as the user browses the web.
9
9
  *
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * Verifies requests are coming from expected origins/referers.
5
5
  * CSRF protection is provided by `SameSite: strict` on session cookies
6
- * (see `session_middleware.ts`). This module provides origin allowlisting
6
+ * (see `auth/session_middleware.ts`). This module provides origin allowlisting
7
7
  * for locally-running services — preventing untrusted websites from
8
8
  * making requests as the user browses the web.
9
9
  *
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Shared pure helpers for schema introspection and middleware matching.
3
3
  *
4
- * Used by both `route_spec.ts` (input validation) and `surface.ts`
4
+ * Used by both `http/route_spec.ts` (input validation) and `http/surface.ts`
5
5
  * (attack surface generation). Extracted to avoid circular dependencies
6
6
  * between routes and middleware.
7
7
  *
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Shared pure helpers for schema introspection and middleware matching.
3
3
  *
4
- * Used by both `route_spec.ts` (input validation) and `surface.ts`
4
+ * Used by both `http/route_spec.ts` (input validation) and `http/surface.ts`
5
5
  * (attack surface generation). Extracted to avoid circular dependencies
6
6
  * between routes and middleware.
7
7
  *
@@ -2,7 +2,7 @@
2
2
  * App surface generation — JSON-serializable attack surface from route and middleware specs.
3
3
  *
4
4
  * Pure schema helpers (`is_null_schema`, `schema_to_surface`, `middleware_applies`,
5
- * `merge_error_schemas`) live in `schema_helpers.ts`.
5
+ * `merge_error_schemas`) live in `http/schema_helpers.ts`.
6
6
  *
7
7
  * @module
8
8
  */
@@ -2,7 +2,7 @@
2
2
  * App surface generation — JSON-serializable attack surface from route and middleware specs.
3
3
  *
4
4
  * Pure schema helpers (`is_null_schema`, `schema_to_surface`, `middleware_applies`,
5
- * `merge_error_schemas`) live in `schema_helpers.ts`.
5
+ * `merge_error_schemas`) live in `http/schema_helpers.ts`.
6
6
  *
7
7
  * @module
8
8
  */
@@ -11,7 +11,7 @@ import type { RuntimeDeps } from './deps.js';
11
11
  /**
12
12
  * Create a runtime backed by Deno APIs.
13
13
  *
14
- * Returns an object satisfying all `*Deps` interfaces from `deps.ts`.
14
+ * Returns an object satisfying all `*Deps` interfaces from `runtime/deps.ts`.
15
15
  * Pass to shared functions that accept `EnvDeps`, `FsReadDeps`, etc.
16
16
  *
17
17
  * @param args - CLI arguments (typically `Deno.args`)
@@ -10,7 +10,7 @@
10
10
  /**
11
11
  * Create a runtime backed by Deno APIs.
12
12
  *
13
- * Returns an object satisfying all `*Deps` interfaces from `deps.ts`.
13
+ * Returns an object satisfying all `*Deps` interfaces from `runtime/deps.ts`.
14
14
  * Pass to shared functions that accept `EnvDeps`, `FsReadDeps`, etc.
15
15
  *
16
16
  * @param args - CLI arguments (typically `Deno.args`)
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Node.js implementation of `RuntimeDeps`.
3
3
  *
4
- * Provides the same interface as `deno.ts` but backed by Node.js APIs.
4
+ * Provides the same interface as `runtime/deno.ts` but backed by Node.js APIs.
5
5
  * Used for running servers in Node.js and for tests (vitest runs in Node).
6
6
  *
7
7
  * @module
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Node.js implementation of `RuntimeDeps`.
3
3
  *
4
- * Provides the same interface as `deno.ts` but backed by Node.js APIs.
4
+ * Provides the same interface as `runtime/deno.ts` but backed by Node.js APIs.
5
5
  * Used for running servers in Node.js and for tests (vitest runs in Node).
6
6
  *
7
7
  * @module
@@ -306,7 +306,7 @@ const describe_rpc_adversarial_envelopes = (options) => {
306
306
  * For each method with a non-null input schema, generates test cases
307
307
  * from the schema (wrong types, missing fields, format violations)
308
308
  * and wraps them in valid JSON-RPC envelopes. Reuses
309
- * `generate_input_test_cases` from `adversarial_input.ts`.
309
+ * `generate_input_test_cases` from `testing/adversarial_input.ts`.
310
310
  */
311
311
  const describe_rpc_adversarial_params = (options) => {
312
312
  const { build, roles } = options;
@@ -3,7 +3,7 @@ import './assert_dev_env.js';
3
3
  * JSON-RPC test helpers — request construction, response assertion, and
4
4
  * one-shot call ergonomics.
5
5
  *
6
- * Shared by `rpc_attack_surface.ts`, `rpc_round_trip.ts`, and
6
+ * Shared by `testing/rpc_attack_surface.ts`, `testing/rpc_round_trip.ts`, and
7
7
  * consumer-facing admin/audit suites that exercise RPC methods directly.
8
8
  *
9
9
  * @module
@@ -203,7 +203,7 @@ const build_multi_role_request_context = (account_id, roles) => {
203
203
  /**
204
204
  * Stub `RequestContext` for single-role or public fakes. Hardcoded
205
205
  * ids (`acc_1` / `act_1`) mirror `create_test_request_context` in
206
- * `auth_apps.ts`.
206
+ * `testing/auth_apps.ts`.
207
207
  */
208
208
  const build_simple_request_context = (role) => ({
209
209
  account: create_test_account({ id: 'acc_1', username: 'testuser' }),
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Reactive state for managing the authenticated account's auth sessions on a
3
3
  * settings page. Reads and mutations flow through a narrow RPC adapter; the
4
- * REST routes that backed this class moved to `account_actions.ts` in the
4
+ * REST routes that backed this class moved to `auth/account_actions.ts` in the
5
5
  * 2026-04-23 RPC migration.
6
6
  *
7
7
  * @module
@@ -14,7 +14,7 @@ import type { AuthSessionJson } from '../auth/account_schema.js';
14
14
  * interfaces (`AdminAccountsRpc`, `AuditLogRpc`, `AdminInvitesRpc`).
15
15
  *
16
16
  * The three methods wrap the corresponding action specs on
17
- * `account_actions.ts`:
17
+ * `auth/account_actions.ts`:
18
18
  *
19
19
  * - `list` → `account_session_list`
20
20
  * - `revoke` → `account_session_revoke` (IDOR-guarded by `account_id` server-side)
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Reactive state for managing the authenticated account's auth sessions on a
3
3
  * settings page. Reads and mutations flow through a narrow RPC adapter; the
4
- * REST routes that backed this class moved to `account_actions.ts` in the
4
+ * REST routes that backed this class moved to `auth/account_actions.ts` in the
5
5
  * 2026-04-23 RPC migration.
6
6
  *
7
7
  * @module
@@ -21,7 +21,7 @@
21
21
  * ```
22
22
  *
23
23
  * The throwing Proxy spreads the JSON-RPC `{code, message, data?}` onto
24
- * the thrown `Error` so form components (e.g. `PermitOfferForm.svelte`)
24
+ * the thrown `Error` so form components (e.g. `ui/PermitOfferForm.svelte`)
25
25
  * can match on `error.data?.reason` via `ERROR_OFFER_*` constants —
26
26
  * optional chaining is required because JSON-RPC `data` is spec-level
27
27
  * optional. Consumers that need a custom unwrap strategy can construct
@@ -21,7 +21,7 @@
21
21
  * ```
22
22
  *
23
23
  * The throwing Proxy spreads the JSON-RPC `{code, message, data?}` onto
24
- * the thrown `Error` so form components (e.g. `PermitOfferForm.svelte`)
24
+ * the thrown `Error` so form components (e.g. `ui/PermitOfferForm.svelte`)
25
25
  * can match on `error.data?.reason` via `ERROR_OFFER_*` constants —
26
26
  * optional chaining is required because JSON-RPC `data` is spec-level
27
27
  * optional. Consumers that need a custom unwrap strategy can construct
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fuzdev/fuz_app",
3
- "version": "0.50.0",
3
+ "version": "0.51.0",
4
4
  "description": "fullstack app library",
5
5
  "glyph": "🗝",
6
6
  "logo": "logo.svg",