@fuzdev/fuz_app 0.38.1 → 0.39.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 (39) hide show
  1. package/dist/auth/CLAUDE.md +48 -32
  2. package/dist/auth/audit_log_queries.d.ts +19 -17
  3. package/dist/auth/audit_log_queries.d.ts.map +1 -1
  4. package/dist/auth/audit_log_queries.js +49 -36
  5. package/dist/auth/audit_log_schema.d.ts +81 -10
  6. package/dist/auth/audit_log_schema.d.ts.map +1 -1
  7. package/dist/auth/audit_log_schema.js +67 -10
  8. package/dist/auth/role_schema.d.ts +10 -1
  9. package/dist/auth/role_schema.d.ts.map +1 -1
  10. package/dist/auth/role_schema.js +10 -1
  11. package/dist/http/jsonrpc_errors.d.ts +27 -75
  12. package/dist/http/jsonrpc_errors.d.ts.map +1 -1
  13. package/dist/http/jsonrpc_errors.js +16 -9
  14. package/dist/server/app_backend.d.ts +17 -6
  15. package/dist/server/app_backend.d.ts.map +1 -1
  16. package/dist/server/app_backend.js +17 -6
  17. package/dist/server/app_server.d.ts +6 -7
  18. package/dist/server/app_server.d.ts.map +1 -1
  19. package/dist/server/app_server.js +16 -29
  20. package/dist/ui/AdminAccounts.svelte +19 -0
  21. package/dist/ui/AdminAccounts.svelte.d.ts +2 -17
  22. package/dist/ui/AdminAccounts.svelte.d.ts.map +1 -1
  23. package/dist/ui/AdminPermitHistory.svelte +23 -2
  24. package/dist/ui/AdminPermitHistory.svelte.d.ts +2 -17
  25. package/dist/ui/AdminPermitHistory.svelte.d.ts.map +1 -1
  26. package/dist/ui/CLAUDE.md +11 -0
  27. package/dist/ui/PermitOfferHistory.svelte +11 -5
  28. package/dist/ui/PermitOfferHistory.svelte.d.ts +7 -1
  29. package/dist/ui/PermitOfferHistory.svelte.d.ts.map +1 -1
  30. package/dist/ui/PermitOfferInbox.svelte +12 -7
  31. package/dist/ui/PermitOfferInbox.svelte.d.ts +8 -3
  32. package/dist/ui/PermitOfferInbox.svelte.d.ts.map +1 -1
  33. package/dist/ui/admin_rpc_adapters.d.ts +16 -1
  34. package/dist/ui/admin_rpc_adapters.d.ts.map +1 -1
  35. package/dist/ui/admin_rpc_adapters.js +12 -1
  36. package/dist/ui/format_scope.d.ts +45 -0
  37. package/dist/ui/format_scope.d.ts.map +1 -0
  38. package/dist/ui/format_scope.js +34 -0
  39. package/package.json +1 -1
@@ -27,71 +27,22 @@ export type JsonrpcErrorName = 'parse_error' | 'invalid_request' | 'method_not_f
27
27
  * Extensible — consumers add domain-specific codes to their own objects
28
28
  * by casting `as JsonrpcErrorCode`. Application codes use the -32000 to
29
29
  * -32099 range reserved by the JSON-RPC spec.
30
+ *
31
+ * Frozen with `Object.freeze` to convert accidental mutation (test
32
+ * cross-contamination, cast escapes) into loud TypeErrors. Spread into
33
+ * a fresh object to extend.
30
34
  */
31
- export declare const JSONRPC_ERROR_CODES: {
32
- readonly parse_error: JsonrpcErrorCode;
33
- readonly invalid_request: JsonrpcErrorCode;
34
- readonly method_not_found: JsonrpcErrorCode;
35
- readonly invalid_params: JsonrpcErrorCode;
36
- readonly internal_error: JsonrpcErrorCode;
37
- /**
38
- * Same as HTTP 401 "unauthorized", but correctly named.
39
- *
40
- * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status#client_error_responses
41
- */
42
- readonly unauthenticated: JsonrpcErrorCode;
43
- /**
44
- * Named to match HTTP 403 — avoids confusion with 401 which
45
- * is incorrectly named "unauthorized" in HTTP.
46
- */
47
- readonly forbidden: JsonrpcErrorCode;
48
- readonly not_found: JsonrpcErrorCode;
49
- readonly conflict: JsonrpcErrorCode;
50
- /**
51
- * Application-level validation failures (business logic).
52
- * Use `invalid_params` (-32602) for schema/parsing failures.
53
- */
54
- readonly validation_error: JsonrpcErrorCode;
55
- readonly rate_limited: JsonrpcErrorCode;
56
- readonly service_unavailable: JsonrpcErrorCode;
57
- readonly timeout: JsonrpcErrorCode;
58
- /**
59
- * Client-side backpressure — an outbound buffer (e.g. `FrontendWebsocketClient`'s
60
- * disconnected request queue) refused a new request because it was full.
61
- * Distinct from `rate_limited`, which signals a server-side policy.
62
- */
63
- readonly queue_overflow: JsonrpcErrorCode;
64
- /**
65
- * Caller-initiated cancellation (e.g. `AbortSignal` fired). Cooperative,
66
- * not a failure — the request did not complete because the caller asked
67
- * for it to stop.
68
- */
69
- readonly request_cancelled: JsonrpcErrorCode;
70
- };
35
+ export declare const JSONRPC_ERROR_CODES: Readonly<Record<JsonrpcErrorName, JsonrpcErrorCode>>;
71
36
  /**
72
37
  * Named constructors for `JsonrpcErrorObject` values.
73
38
  *
74
39
  * Each function creates a JSON-RPC error object with the correct
75
40
  * code and a sensible default message. Used by the catch layer in
76
41
  * `apply_route_specs` to build response bodies.
42
+ *
43
+ * Frozen so tests must compose new objects rather than monkey-patch.
77
44
  */
78
- export declare const jsonrpc_error_messages: {
79
- readonly parse_error: (data?: unknown) => JsonrpcErrorObject;
80
- readonly invalid_request: (data?: unknown) => JsonrpcErrorObject;
81
- readonly method_not_found: (method?: string, data?: unknown) => JsonrpcErrorObject;
82
- readonly invalid_params: (message?: string, data?: unknown) => JsonrpcErrorObject;
83
- readonly internal_error: (message?: string, data?: unknown) => JsonrpcErrorObject;
84
- readonly unauthenticated: (message?: string, data?: unknown) => JsonrpcErrorObject;
85
- readonly forbidden: (message?: string, data?: unknown) => JsonrpcErrorObject;
86
- readonly not_found: (resource?: string, data?: unknown) => JsonrpcErrorObject;
87
- readonly conflict: (message?: string, data?: unknown) => JsonrpcErrorObject;
88
- readonly validation_error: (message?: string, data?: unknown) => JsonrpcErrorObject;
89
- readonly rate_limited: (message?: string, data?: unknown) => JsonrpcErrorObject;
90
- readonly service_unavailable: (message?: string, data?: unknown) => JsonrpcErrorObject;
91
- readonly timeout: (message?: string, data?: unknown) => JsonrpcErrorObject;
92
- readonly queue_overflow: (message?: string, data?: unknown) => JsonrpcErrorObject;
93
- readonly request_cancelled: (message?: string, data?: unknown) => JsonrpcErrorObject;
94
- };
45
+ export declare const jsonrpc_error_messages: Readonly<Record<JsonrpcErrorName, (...args: Array<any>) => JsonrpcErrorObject>>;
95
46
  /**
96
47
  * Error class carrying a JSON-RPC error code — thrown by handlers,
97
48
  * caught by `apply_route_specs` and mapped to HTTP status + JSON-RPC error response.
@@ -109,29 +60,30 @@ export declare class ThrownJsonrpcError extends Error {
109
60
  * Usage: `throw jsonrpc_errors.not_found('user')` or `throw jsonrpc_errors.forbidden()`.
110
61
  */
111
62
  export declare const jsonrpc_errors: {
112
- readonly parse_error: (data?: unknown) => ThrownJsonrpcError;
113
- readonly invalid_request: (data?: unknown) => ThrownJsonrpcError;
114
- readonly method_not_found: (method?: string | undefined, data?: unknown) => ThrownJsonrpcError;
115
- readonly invalid_params: (message?: string | undefined, data?: unknown) => ThrownJsonrpcError;
116
- readonly internal_error: (message?: string | undefined, data?: unknown) => ThrownJsonrpcError;
117
- readonly unauthenticated: (message?: string | undefined, data?: unknown) => ThrownJsonrpcError;
118
- readonly forbidden: (message?: string | undefined, data?: unknown) => ThrownJsonrpcError;
119
- readonly not_found: (resource?: string | undefined, data?: unknown) => ThrownJsonrpcError;
120
- readonly conflict: (message?: string | undefined, data?: unknown) => ThrownJsonrpcError;
121
- readonly validation_error: (message?: string | undefined, data?: unknown) => ThrownJsonrpcError;
122
- readonly rate_limited: (message?: string | undefined, data?: unknown) => ThrownJsonrpcError;
123
- readonly service_unavailable: (message?: string | undefined, data?: unknown) => ThrownJsonrpcError;
124
- readonly timeout: (message?: string | undefined, data?: unknown) => ThrownJsonrpcError;
125
- readonly queue_overflow: (message?: string | undefined, data?: unknown) => ThrownJsonrpcError;
126
- readonly request_cancelled: (message?: string | undefined, data?: unknown) => ThrownJsonrpcError;
63
+ readonly parse_error: (...args: any[]) => ThrownJsonrpcError;
64
+ readonly invalid_request: (...args: any[]) => ThrownJsonrpcError;
65
+ readonly method_not_found: (...args: any[]) => ThrownJsonrpcError;
66
+ readonly invalid_params: (...args: any[]) => ThrownJsonrpcError;
67
+ readonly internal_error: (...args: any[]) => ThrownJsonrpcError;
68
+ readonly unauthenticated: (...args: any[]) => ThrownJsonrpcError;
69
+ readonly forbidden: (...args: any[]) => ThrownJsonrpcError;
70
+ readonly not_found: (...args: any[]) => ThrownJsonrpcError;
71
+ readonly conflict: (...args: any[]) => ThrownJsonrpcError;
72
+ readonly validation_error: (...args: any[]) => ThrownJsonrpcError;
73
+ readonly rate_limited: (...args: any[]) => ThrownJsonrpcError;
74
+ readonly service_unavailable: (...args: any[]) => ThrownJsonrpcError;
75
+ readonly timeout: (...args: any[]) => ThrownJsonrpcError;
76
+ readonly queue_overflow: (...args: any[]) => ThrownJsonrpcError;
77
+ readonly request_cancelled: (...args: any[]) => ThrownJsonrpcError;
127
78
  };
128
79
  /**
129
80
  * Maps JSON-RPC error codes to HTTP status codes.
130
81
  *
131
82
  * Extensible — consumers with domain-specific error codes can spread
132
- * this into their own mapping object.
83
+ * this into their own mapping object. Frozen so the source can't be
84
+ * accidentally mutated; spread copies are mutable.
133
85
  */
134
- export declare const JSONRPC_ERROR_CODE_TO_HTTP_STATUS: Record<number, number>;
86
+ export declare const JSONRPC_ERROR_CODE_TO_HTTP_STATUS: Readonly<Record<number, number>>;
135
87
  /**
136
88
  * Maps HTTP status codes to JSON-RPC error codes (reverse mapping).
137
89
  *
@@ -139,7 +91,7 @@ export declare const JSONRPC_ERROR_CODE_TO_HTTP_STATUS: Record<number, number>;
139
91
  * and invalid_request both map to 400), the last one wins. Use for
140
92
  * best-effort HTTP → JSON-RPC translation.
141
93
  */
142
- export declare const HTTP_STATUS_TO_JSONRPC_ERROR_CODE: Record<number, JsonrpcErrorCode>;
94
+ export declare const HTTP_STATUS_TO_JSONRPC_ERROR_CODE: Readonly<Record<number, JsonrpcErrorCode>>;
143
95
  /**
144
96
  * Map a JSON-RPC error code to an HTTP status code.
145
97
  *
@@ -1 +1 @@
1
- {"version":3,"file":"jsonrpc_errors.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/http/j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kB;CA2BqC,CAAC;AAI3F;;;;;;GAMG;AACH,eAAO,MAAM,iCAAiC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAkB7E,CAAC;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,iCAAiC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAQvF,CAAC;AAEH;;;;;;;;GAQG;AACH,eAAO,MAAM,iCAAiC,GAAI,MAAM,gBAAgB,KAAG,MAClB,CAAC;AAE1D;;;;;;;GAOG;AACH,eAAO,MAAM,iCAAiC,GAAI,QAAQ,MAAM,KAAG,gBACa,CAAC"}
@@ -25,8 +25,12 @@ export const UNKNOWN_ERROR_MESSAGE = 'unknown error';
25
25
  * Extensible — consumers add domain-specific codes to their own objects
26
26
  * by casting `as JsonrpcErrorCode`. Application codes use the -32000 to
27
27
  * -32099 range reserved by the JSON-RPC spec.
28
+ *
29
+ * Frozen with `Object.freeze` to convert accidental mutation (test
30
+ * cross-contamination, cast escapes) into loud TypeErrors. Spread into
31
+ * a fresh object to extend.
28
32
  */
29
- export const JSONRPC_ERROR_CODES = {
33
+ export const JSONRPC_ERROR_CODES = Object.freeze({
30
34
  // Standard JSON-RPC errors — values from jsonrpc.ts
31
35
  parse_error: JSONRPC_PARSE_ERROR,
32
36
  invalid_request: JSONRPC_INVALID_REQUEST,
@@ -67,15 +71,17 @@ export const JSONRPC_ERROR_CODES = {
67
71
  * for it to stop.
68
72
  */
69
73
  request_cancelled: -32010,
70
- };
74
+ });
71
75
  /**
72
76
  * Named constructors for `JsonrpcErrorObject` values.
73
77
  *
74
78
  * Each function creates a JSON-RPC error object with the correct
75
79
  * code and a sensible default message. Used by the catch layer in
76
80
  * `apply_route_specs` to build response bodies.
81
+ *
82
+ * Frozen so tests must compose new objects rather than monkey-patch.
77
83
  */
78
- export const jsonrpc_error_messages = {
84
+ export const jsonrpc_error_messages = Object.freeze({
79
85
  parse_error: (data) => ({
80
86
  code: JSONRPC_ERROR_CODES.parse_error,
81
87
  message: 'parse error',
@@ -151,7 +157,7 @@ export const jsonrpc_error_messages = {
151
157
  message,
152
158
  data,
153
159
  }),
154
- };
160
+ });
155
161
  /**
156
162
  * Error class carrying a JSON-RPC error code — thrown by handlers,
157
163
  * caught by `apply_route_specs` and mapped to HTTP status + JSON-RPC error response.
@@ -198,9 +204,10 @@ export const jsonrpc_errors = {
198
204
  * Maps JSON-RPC error codes to HTTP status codes.
199
205
  *
200
206
  * Extensible — consumers with domain-specific error codes can spread
201
- * this into their own mapping object.
207
+ * this into their own mapping object. Frozen so the source can't be
208
+ * accidentally mutated; spread copies are mutable.
202
209
  */
203
- export const JSONRPC_ERROR_CODE_TO_HTTP_STATUS = {
210
+ export const JSONRPC_ERROR_CODE_TO_HTTP_STATUS = Object.freeze({
204
211
  [-32700]: 400, // parse_error
205
212
  [-32600]: 400, // invalid_request
206
213
  [-32601]: 404, // method_not_found
@@ -218,7 +225,7 @@ export const JSONRPC_ERROR_CODE_TO_HTTP_STATUS = {
218
225
  [-32007]: 503, // service_unavailable
219
226
  [-32008]: 504, // timeout
220
227
  [-32010]: 499, // request_cancelled (nginx "client closed request")
221
- };
228
+ });
222
229
  /**
223
230
  * Maps HTTP status codes to JSON-RPC error codes (reverse mapping).
224
231
  *
@@ -226,10 +233,10 @@ export const JSONRPC_ERROR_CODE_TO_HTTP_STATUS = {
226
233
  * and invalid_request both map to 400), the last one wins. Use for
227
234
  * best-effort HTTP → JSON-RPC translation.
228
235
  */
229
- export const HTTP_STATUS_TO_JSONRPC_ERROR_CODE = Object.fromEntries(Object.entries(JSONRPC_ERROR_CODE_TO_HTTP_STATUS).map(([code, status]) => [
236
+ export const HTTP_STATUS_TO_JSONRPC_ERROR_CODE = Object.freeze(Object.fromEntries(Object.entries(JSONRPC_ERROR_CODE_TO_HTTP_STATUS).map(([code, status]) => [
230
237
  status,
231
238
  Number(code),
232
- ]));
239
+ ])));
233
240
  /**
234
241
  * Map a JSON-RPC error code to an HTTP status code.
235
242
  *
@@ -17,7 +17,7 @@ import type { DbType } from '../db/db.js';
17
17
  import type { Keyring } from '../auth/keyring.js';
18
18
  import type { PasswordHashDeps } from '../auth/password.js';
19
19
  import type { StatResult } from '../runtime/deps.js';
20
- import { type MigrationResult } from '../db/migrate.js';
20
+ import { type MigrationNamespace, type MigrationResult } from '../db/migrate.js';
21
21
  /**
22
22
  * Result of `create_app_backend()` — database metadata + deps bundle.
23
23
  *
@@ -28,7 +28,7 @@ export interface AppBackend {
28
28
  deps: AppDeps;
29
29
  db_type: DbType;
30
30
  db_name: string;
31
- /** Migration results from `create_app_backend` (auth migrations only). */
31
+ /** Migration results from `create_app_backend` auth migrations plus any consumer namespaces passed via `migration_namespaces`. */
32
32
  readonly migration_results: ReadonlyArray<MigrationResult>;
33
33
  /** Close the database connection. Bound to the actual driver. */
34
34
  close: () => Promise<void>;
@@ -60,15 +60,26 @@ export interface CreateAppBackendOptions {
60
60
  * to all route factories automatically. Defaults to a noop.
61
61
  */
62
62
  on_audit_event?: (event: AuditLogEvent) => void;
63
+ /**
64
+ * Additional migration namespaces to run after the builtin auth namespace.
65
+ * Each namespace's own `schema_version` row tracks progress; order is
66
+ * append-only so forward-only guarantees hold per-namespace.
67
+ *
68
+ * The reserved `'fuz_auth'` namespace is rejected at startup. Omit for no
69
+ * extra namespaces. This is the only place to splice consumer migrations
70
+ * — DB init belongs to the backend lifecycle, not server assembly.
71
+ */
72
+ migration_namespaces?: ReadonlyArray<MigrationNamespace>;
63
73
  }
64
74
  /**
65
75
  * Initialize the backend: database + auth migrations + deps.
66
76
  *
67
- * Calls `create_db` → `run_migrations` (auth namespace) and bundles
68
- * the result with the provided keyring and password deps.
77
+ * Calls `create_db` → `run_migrations` (auth namespace, then any
78
+ * `migration_namespaces` from options in order) and bundles the result
79
+ * with the provided keyring and password deps.
69
80
  *
70
- * @param options - keyring, password deps, and optional database URL
71
- * @returns app backend with deps, database metadata, and migration results
81
+ * @param options - keyring, password deps, optional database URL, and optional `migration_namespaces`
82
+ * @returns app backend with deps, database metadata, and combined migration results
72
83
  */
73
84
  export declare const create_app_backend: (options: CreateAppBackendOptions) => Promise<AppBackend>;
74
85
  //# sourceMappingURL=app_backend.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"app_backend.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/server/app_backend.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAC,MAAM,EAAC,MAAM,yBAAyB,CAAC;AAE/C,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,iBAAiB,CAAC;AAC7C,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,6BAA6B,CAAC;AAC/D,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AACxC,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,oBAAoB,CAAC;AAChD,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAiB,KAAK,eAAe,EAAC,MAAM,kBAAkB,CAAC;AAItE;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IAC1B,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,0EAA0E;IAC1E,QAAQ,CAAC,iBAAiB,EAAE,aAAa,CAAC,eAAe,CAAC,CAAC;IAC3D,iEAAiE;IACjE,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3B;AAED;;;;;GAKG;AACH,MAAM,WAAW,uBAAuB;IACvC,+DAA+D;IAC/D,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC;IACnD,2BAA2B;IAC3B,cAAc,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,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I,QAAQ,CAAC,iBAAiB,EAAE,aAAa,CAAC,eAAe,CAAC,CAAC;IAC3D,iEAAiE;IACjE,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3B;AAED;;;;;GAKG;AACH,MAAM,WAAW,uBAAuB;IACvC,+DAA+D;IAC/D,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC;IACnD,2BAA2B;IAC3B,cAAc,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IAClD,qBAAqB;IACrB,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7C,0EAA0E;IAC1E,YAAY,EAAE,MAAM,CAAC;IACrB,wCAAwC;IACxC,OAAO,EAAE,OAAO,CAAC;IACjB,iFAAiF;IACjF,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,6EAA6E;IAC7E,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IAChD;;;;;;;;OAQG;IACH,oBAAoB,CAAC,EAAE,aAAa,CAAC,kBAAkB,CAAC,CAAC;CACzD;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB,GAAU,SAAS,uBAAuB,KAAG,OAAO,CAAC,UAAU,CAyB7F,CAAC"}
@@ -12,23 +12,34 @@
12
12
  */
13
13
  import { Logger } from '@fuzdev/fuz_util/log.js';
14
14
  import { run_migrations } from '../db/migrate.js';
15
- import { AUTH_MIGRATION_NS } from '../auth/migrations.js';
15
+ import { AUTH_MIGRATION_NS, AUTH_MIGRATION_NAMESPACE } from '../auth/migrations.js';
16
16
  import { create_db } from '../db/create_db.js';
17
17
  /**
18
18
  * Initialize the backend: database + auth migrations + deps.
19
19
  *
20
- * Calls `create_db` → `run_migrations` (auth namespace) and bundles
21
- * the result with the provided keyring and password deps.
20
+ * Calls `create_db` → `run_migrations` (auth namespace, then any
21
+ * `migration_namespaces` from options in order) and bundles the result
22
+ * with the provided keyring and password deps.
22
23
  *
23
- * @param options - keyring, password deps, and optional database URL
24
- * @returns app backend with deps, database metadata, and migration results
24
+ * @param options - keyring, password deps, optional database URL, and optional `migration_namespaces`
25
+ * @returns app backend with deps, database metadata, and combined migration results
25
26
  */
26
27
  export const create_app_backend = async (options) => {
27
28
  const { database_url, keyring, password, stat, read_text_file, delete_file } = options;
28
29
  const log = options.log ?? new Logger('server');
29
30
  const on_audit_event = options.on_audit_event ?? (() => { }); // eslint-disable-line @typescript-eslint/no-empty-function
30
31
  const { db, close, db_type, db_name } = await create_db(database_url);
31
- const migration_results = await run_migrations(db, [AUTH_MIGRATION_NS]);
32
+ if (options.migration_namespaces?.length) {
33
+ for (const ns of options.migration_namespaces) {
34
+ if (ns.namespace === AUTH_MIGRATION_NAMESPACE) {
35
+ throw new Error(`Migration namespace "${AUTH_MIGRATION_NAMESPACE}" is reserved by fuz_app — choose a different namespace`);
36
+ }
37
+ }
38
+ }
39
+ const migration_results = await run_migrations(db, [
40
+ AUTH_MIGRATION_NS,
41
+ ...(options.migration_namespaces ?? []),
42
+ ]);
32
43
  return {
33
44
  db_type,
34
45
  db_name,
@@ -17,7 +17,7 @@ import { type AuditLogSse } from '../realtime/sse_auth_guard.js';
17
17
  import type { AppSettings } from '../auth/app_settings_schema.js';
18
18
  import { type RateLimiter } from '../rate_limiter.js';
19
19
  import type { DaemonTokenState } from '../auth/daemon_token.js';
20
- import { type MigrationNamespace, type MigrationResult } from '../db/migrate.js';
20
+ import type { MigrationResult } from '../db/migrate.js';
21
21
  import type { AppDeps } from '../auth/deps.js';
22
22
  import type { AppBackend } from './app_backend.js';
23
23
  import '../hono_context.js';
@@ -104,8 +104,6 @@ export interface AppServerOptions {
104
104
  * Default: auto-created (authenticated).
105
105
  */
106
106
  surface_route?: false;
107
- /** Consumer migration namespaces — run after auth migrations during init. */
108
- migration_namespaces?: Array<MigrationNamespace>;
109
107
  /**
110
108
  * Build route specs from the initialized backend.
111
109
  * Called after all middleware is ready.
@@ -191,7 +189,7 @@ export interface AppServer {
191
189
  bootstrap_status: BootstrapStatus;
192
190
  /** Global app settings (mutable ref — mutated by settings admin route). */
193
191
  app_settings: AppSettings;
194
- /** Combined migration results auth migrations from `create_app_backend` plus consumer migrations. */
192
+ /** Migration results from `create_app_backend` (auth + any `migration_namespaces` passed there). */
195
193
  migration_results: ReadonlyArray<MigrationResult>;
196
194
  /** Factory-managed audit log SSE. `null` when `audit_log_sse` option is not set. */
197
195
  audit_sse: AuditLogSse | null;
@@ -203,9 +201,10 @@ export declare const DEFAULT_MAX_BODY_SIZE: number;
203
201
  /**
204
202
  * Create a fully assembled Hono app with auth, middleware, and routes.
205
203
  *
206
- * Handles the full lifecycle: consumer migrationsproxy middleware →
207
- * auth middleware → bootstrap status → route specs → surface generation →
208
- * Hono app assembly static serving.
204
+ * Handles the assembly lifecycle: proxy middlewareauth middleware →
205
+ * bootstrap status → route specs → surface generation → Hono app assembly →
206
+ * static serving. Database migrations belong to the backend lifecycle —
207
+ * pass `migration_namespaces` to `create_app_backend`.
209
208
  *
210
209
  * @param options - server configuration
211
210
  * @returns assembled Hono app, backend, surface build, and bootstrap status
@@ -1 +1 @@
1
- {"version":3,"file":"app_server.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/server/app_server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAC,IAAI,EAAE,KAAK,OAAO,EAAC,MAAM,MAAM,CAAC;AAGxC,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAEtB,OAAO,EAEN,KAAK,cAAc,EAEnB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAC,uBAAuB,EAAC,MAAM,8BAA8B,CAAC;AAC1E,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,oBAAoB,C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se, AUDIT_LOG_EVENT_SPECS, } from '../realtime/sse_auth_guard.js';
17
17
  import { query_app_settings_load } from '../auth/app_settings_queries.js';
18
18
  import { create_rate_limiter, DEFAULT_LOGIN_ACCOUNT_RATE_LIMIT, } from '../rate_limiter.js';
19
- import { run_migrations } from '../db/migrate.js';
20
- import { AUTH_MIGRATION_NAMESPACE } from '../auth/migrations.js';
21
19
  // Side-effect import: augments Hono's ContextVariableMap so consumers
22
20
  // that import app_server get type-safe c.get('auth_session_id') etc.
23
21
  import '../hono_context.js';
@@ -37,9 +35,10 @@ export const DEFAULT_MAX_BODY_SIZE = 1024 * 1024;
37
35
  /**
38
36
  * Create a fully assembled Hono app with auth, middleware, and routes.
39
37
  *
40
- * Handles the full lifecycle: consumer migrationsproxy middleware →
41
- * auth middleware → bootstrap status → route specs → surface generation →
42
- * Hono app assembly static serving.
38
+ * Handles the assembly lifecycle: proxy middlewareauth middleware →
39
+ * bootstrap status → route specs → surface generation → Hono app assembly →
40
+ * static serving. Database migrations belong to the backend lifecycle —
41
+ * pass `migration_namespaces` to `create_app_backend`.
43
42
  *
44
43
  * @param options - server configuration
45
44
  * @returns assembled Hono app, backend, surface build, and bootstrap status
@@ -47,19 +46,7 @@ export const DEFAULT_MAX_BODY_SIZE = 1024 * 1024;
47
46
  export const create_app_server = async (options) => {
48
47
  const { backend } = options;
49
48
  const { log } = backend.deps;
50
- // 1. Consumer migrations
51
- let all_migration_results = backend.migration_results;
52
- if (options.migration_namespaces?.length) {
53
- // guard against namespace collision with fuz_app's internal migrations
54
- for (const ns of options.migration_namespaces) {
55
- if (ns.namespace === AUTH_MIGRATION_NAMESPACE) {
56
- throw new Error(`Migration namespace "${AUTH_MIGRATION_NAMESPACE}" is reserved by fuz_app — choose a different namespace`);
57
- }
58
- }
59
- const consumer_results = await run_migrations(backend.deps.db, options.migration_namespaces);
60
- all_migration_results = [...backend.migration_results, ...consumer_results];
61
- }
62
- // 2. Rate limiter defaults (undefined = default, null = disable)
49
+ // Rate limiter defaults (undefined = default, null = disable)
63
50
  const ip_rate_limiter = options.ip_rate_limiter === undefined ? create_rate_limiter() : options.ip_rate_limiter;
64
51
  const login_account_rate_limiter = options.login_account_rate_limiter === undefined
65
52
  ? create_rate_limiter(DEFAULT_LOGIN_ACCOUNT_RATE_LIMIT)
@@ -70,7 +57,7 @@ export const create_app_server = async (options) => {
70
57
  const bearer_ip_rate_limiter = options.bearer_ip_rate_limiter === undefined
71
58
  ? create_rate_limiter()
72
59
  : options.bearer_ip_rate_limiter;
73
- // 3. Factory-managed audit SSE (shallow copy deps, no mutation of backend.deps)
60
+ // Factory-managed audit SSE (shallow copy deps, no mutation of backend.deps)
74
61
  const audit_sse = options.audit_log_sse
75
62
  ? create_audit_log_sse({
76
63
  log,
@@ -86,9 +73,9 @@ export const create_app_server = async (options) => {
86
73
  },
87
74
  }
88
75
  : backend.deps;
89
- // 4. Proxy middleware
76
+ // Proxy middleware
90
77
  const proxy_spec = create_proxy_middleware_spec({ ...options.proxy, log });
91
- // 5. Auth middleware
78
+ // Auth middleware
92
79
  const auth_middleware = await create_auth_middleware_specs(deps, {
93
80
  allowed_origins: options.allowed_origins,
94
81
  session_options: options.session_options,
@@ -99,16 +86,16 @@ export const create_app_server = async (options) => {
99
86
  if (options.transform_middleware) {
100
87
  middleware_specs = options.transform_middleware(middleware_specs);
101
88
  }
102
- // 6. Bootstrap status + app settings
89
+ // Bootstrap status + app settings
103
90
  const bootstrap_status = options.bootstrap
104
91
  ? await check_bootstrap_status(deps, { token_path: options.bootstrap.token_path })
105
92
  : { available: false, token_path: null };
106
93
  const app_settings = await query_app_settings_load({ db: deps.db });
107
- // 7. Surface route ref — factory manages the circular ref
94
+ // Surface route ref — factory manages the circular ref
108
95
  const surface_ref = {
109
96
  surface: { middleware: [], routes: [], rpc_endpoints: [], env: [], events: [], diagnostics: [] },
110
97
  };
111
- // 8. Route specs (consumer routes + factory-managed routes)
98
+ // Route specs (consumer routes + factory-managed routes)
112
99
  const context = {
113
100
  deps,
114
101
  backend,
@@ -149,7 +136,7 @@ export const create_app_server = async (options) => {
149
136
  factory_routes.push(create_surface_route_spec(surface_ref));
150
137
  }
151
138
  const route_specs = [...consumer_routes, ...factory_routes];
152
- // 9. Surface + logging
139
+ // Surface + logging
153
140
  const surface_middleware = options.post_route_middleware
154
141
  ? [...middleware_specs, ...options.post_route_middleware]
155
142
  : middleware_specs;
@@ -210,7 +197,7 @@ export const create_app_server = async (options) => {
210
197
  // Backfill the surface ref — factory owns this lifecycle
211
198
  surface_ref.surface = surface_spec.surface;
212
199
  log_startup_summary(surface_spec.surface, log, options.env_values);
213
- // 10. Hono app assembly
200
+ // Hono app assembly
214
201
  const app = new Hono();
215
202
  // Pending effects — collects fire-and-forget promises (audit logs, usage tracking).
216
203
  // In test mode, effects are awaited before the response returns.
@@ -255,11 +242,11 @@ export const create_app_server = async (options) => {
255
242
  }
256
243
  apply_middleware_specs(app, middleware_specs);
257
244
  apply_route_specs(app, route_specs, fuz_auth_guard_resolver, log, deps.db);
258
- // 11. Post-route middleware (before static serving)
245
+ // Post-route middleware (before static serving)
259
246
  if (options.post_route_middleware) {
260
247
  apply_middleware_specs(app, options.post_route_middleware);
261
248
  }
262
- // 12. Static file serving
249
+ // Static file serving
263
250
  if (options.static_serving) {
264
251
  const { serve_static, spa_fallback } = options.static_serving;
265
252
  for (const mw of create_static_middleware(serve_static, { spa_fallback })) {
@@ -271,7 +258,7 @@ export const create_app_server = async (options) => {
271
258
  surface_spec,
272
259
  bootstrap_status,
273
260
  app_settings,
274
- migration_results: all_migration_results,
261
+ migration_results: backend.migration_results,
275
262
  audit_sse,
276
263
  close: backend.close,
277
264
  };
@@ -5,9 +5,16 @@
5
5
  import type {DatatableColumn} from './datatable.js';
6
6
  import type {AdminAccountEntryJson} from '../auth/account_schema.js';
7
7
  import {format_relative_time, format_datetime_local} from './ui_format.js';
8
+ import {format_scope_context, resolve_scope_label} from './format_scope.js';
8
9
 
9
10
  const get_rpc = admin_accounts_rpc_context.get();
10
11
  const admin_accounts = new AdminAccountsState({get_rpc});
12
+ const get_format_scope = format_scope_context.get();
13
+ const format_scope = $derived(get_format_scope());
14
+
15
+ // `null` global label: global permits render no scope chip — the implicit default in admin tables.
16
+ const scope_label = (scope_id: string | null, role: string): string | null =>
17
+ resolve_scope_label(scope_id, role, format_scope, null);
11
18
 
12
19
  void admin_accounts.fetch();
13
20
 
@@ -57,8 +64,14 @@
57
64
  {/if}
58
65
  {:else if column.key === 'permits'}
59
66
  {#each row.permits as permit (permit.id)}
67
+ {@const scope = scope_label(permit.scope_id, permit.role)}
60
68
  <div class="row">
61
69
  <span class="chip color_b">{permit.role}</span>
70
+ {#if scope !== null}
71
+ <span class="text_50 font_size_sm" title={permit.scope_id ?? undefined}>
72
+ {scope}
73
+ </span>
74
+ {/if}
62
75
  {#if permit.expires_at}
63
76
  <span class="text_50 font_size_sm" title={format_datetime_local(permit.expires_at)}>
64
77
  expires {format_relative_time(permit.expires_at)}
@@ -80,6 +93,7 @@
80
93
  </div>
81
94
  {/each}
82
95
  {#each row.pending_offers as offer (offer.id)}
96
+ {@const offer_scope = scope_label(offer.scope_id, offer.role)}
83
97
  <div class="row">
84
98
  <span
85
99
  class="chip"
@@ -87,6 +101,11 @@
87
101
  >
88
102
  {offer.role} (pending from @{offer.from_username})
89
103
  </span>
104
+ {#if offer_scope !== null}
105
+ <span class="text_50 font_size_sm" title={offer.scope_id ?? undefined}>
106
+ {offer_scope}
107
+ </span>
108
+ {/if}
90
109
  {#if admin_accounts.has_rpc}
91
110
  <ConfirmButton
92
111
  onconfirm={() => admin_accounts.retract_offer(offer.id)}
@@ -1,19 +1,4 @@
1
- interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
2
- new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
3
- $$bindings?: Bindings;
4
- } & Exports;
5
- (internal: unknown, props: {
6
- $$events?: Events;
7
- $$slots?: Slots;
8
- }): Exports & {
9
- $set?: any;
10
- $on?: any;
11
- };
12
- z_$$bindings?: Bindings;
13
- }
14
- declare const AdminAccounts: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
15
- [evt: string]: CustomEvent<any>;
16
- }, {}, {}, string>;
17
- type AdminAccounts = InstanceType<typeof AdminAccounts>;
1
+ declare const AdminAccounts: import("svelte").Component<Record<string, never>, {}, "">;
2
+ type AdminAccounts = ReturnType<typeof AdminAccounts>;
18
3
  export default AdminAccounts;
19
4
  //# sourceMappingURL=AdminAccounts.svelte.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"AdminAccounts.svelte.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/ui/AdminAccounts.svelte"],"names":[],"mappings":"AAgIA,UAAU,kCAAkC,CAAC,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,EAAE,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,EAAE,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,EAAE,OAAO,GAAG,EAAE,EAAE,QAAQ,GAAG,MAAM;IACpM,KAAK,OAAO,EAAE,OAAO,QAAQ,EAAE,2BAA2B,CAAC,KAAK,CAAC,GAAG,OAAO,QAAQ,EAAE,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,GAAG;QAAE,UAAU,CAAC,EAAE,QAAQ,CAAA;KAAE,GAAG,OAAO,CAAC;IACjK,CAAC,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,KAAK,CAAA;KAAC,GAAG,OAAO,GAAG;QAAE,IAAI,CAAC,EAAE,GAAG,CAAC;QAAC,GAAG,CAAC,EAAE,GAAG,CAAA;KAAE,CAAC;IACtG,YAAY,CAAC,EAAE,QAAQ,CAAC;CAC3B;AAKD,QAAA,MAAM,aAAa;;kBAA+E,CAAC;AACjF,KAAK,aAAa,GAAG,YAAY,CAAC,OAAO,aAAa,CAAC,CAAC;AAC1D,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"AdminAccounts.svelte.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/ui/AdminAccounts.svelte"],"names":[],"mappings":"AAoJA,QAAA,MAAM,aAAa,2DAAwC,CAAC;AAC5D,KAAK,aAAa,GAAG,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC;AACtD,eAAe,aAAa,CAAC"}