@kaloma-ai/framework-api 0.0.0-stage → 0.6.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.
@@ -0,0 +1,1166 @@
1
+ import * as hono_types from 'hono/types';
2
+ import { MiddlewareHandler, Hono } from 'hono';
3
+ import { z } from 'zod';
4
+ import * as drizzle_orm_postgres_js from 'drizzle-orm/postgres-js';
5
+ import * as postgres from 'postgres';
6
+ import postgres__default from 'postgres';
7
+ import { Readable } from 'node:stream';
8
+ import { LanguageModel } from 'ai';
9
+ import * as drizzle_orm_pg_core from 'drizzle-orm/pg-core';
10
+
11
+ declare const schema: z.ZodObject<{
12
+ NODE_ENV: z.ZodDefault<z.ZodEnum<{
13
+ development: "development";
14
+ test: "test";
15
+ production: "production";
16
+ }>>;
17
+ PORT: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
18
+ DATABASE_URL: z.ZodString;
19
+ APP_NAME: z.ZodDefault<z.ZodString>;
20
+ PUBLIC_URL: z.ZodDefault<z.ZodString>;
21
+ AUTH_SECRET: z.ZodString;
22
+ SECRETS_KEY: z.ZodPreprocess<z.ZodOptional<z.ZodString>, unknown>;
23
+ INITIAL_ADMIN_EMAIL: z.ZodOptional<z.ZodString>;
24
+ EXTERNAL_ACCESS_DAYS: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
25
+ BRAND_DIR: z.ZodDefault<z.ZodString>;
26
+ BACKUP_ENABLED: z.ZodPipe<z.ZodDefault<z.ZodEnum<{
27
+ true: "true";
28
+ false: "false";
29
+ }>>, z.ZodTransform<boolean, "true" | "false">>;
30
+ BACKUP_DIR: z.ZodDefault<z.ZodString>;
31
+ BACKUP_TIME: z.ZodDefault<z.ZodString>;
32
+ BACKUP_KEEP: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
33
+ FILES_DIR: z.ZodDefault<z.ZodString>;
34
+ ALERT_EMAILS: z.ZodPipe<z.ZodPipe<z.ZodDefault<z.ZodString>, z.ZodTransform<string[], string>>, z.ZodArray<z.ZodEmail>>;
35
+ DISK_MIN_FREE_PERCENT: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
36
+ HEALTH_CHECK_SECONDS: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
37
+ EMAIL_TRANSPORT: z.ZodDefault<z.ZodEnum<{
38
+ console: "console";
39
+ smtp: "smtp";
40
+ }>>;
41
+ EMAIL_FROM: z.ZodDefault<z.ZodString>;
42
+ EMAIL_REPLY_TO: z.ZodOptional<z.ZodString>;
43
+ SMTP_HOST: z.ZodOptional<z.ZodString>;
44
+ SMTP_PORT: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
45
+ SMTP_USER: z.ZodOptional<z.ZodString>;
46
+ SMTP_PASSWORD: z.ZodOptional<z.ZodString>;
47
+ }, z.core.$strip>;
48
+ type Config = z.infer<typeof schema>;
49
+ /** Reads and validates environment variables. Fails fast with a readable message. */
50
+ declare function loadConfig(env?: Record<string, string | undefined>): Config;
51
+
52
+ /** Creates the database client. All data access goes through Drizzle. */
53
+ declare function createDb(databaseUrl: string): {
54
+ db: drizzle_orm_postgres_js.PostgresJsDatabase<Record<string, never>> & {
55
+ $client: postgres__default.Sql<{}>;
56
+ };
57
+ client: postgres__default.Sql<{}>;
58
+ close: () => Promise<void>;
59
+ };
60
+ type Db = ReturnType<typeof createDb>["db"];
61
+
62
+ interface StoredFile {
63
+ /** Path inside the storage, like the keys given to `put`. */
64
+ key: string;
65
+ size: number;
66
+ }
67
+ /**
68
+ * Provider-neutral file storage. Apps only ever use this (never `fs` or a cloud SDK directly), so the
69
+ * place where files live (this server, Dropbox, Google Drive, S3) is an Admin decision, not a code change.
70
+ */
71
+ interface FileStorage {
72
+ put(key: string, data: Uint8Array): Promise<void>;
73
+ /** For big files (backups): the stream is read once; `size` is the exact number of bytes it holds. */
74
+ putStream(key: string, data: Readable, size: number): Promise<void>;
75
+ /** The file's bytes, or null when there is no such file. */
76
+ get(key: string): Promise<Buffer | null>;
77
+ delete(key: string): Promise<void>;
78
+ /** Every file below `prefix` (all files when empty), at any depth. A missing folder is an empty list. */
79
+ list(prefix: string): Promise<StoredFile[]>;
80
+ /** Removes `prefix` with everything below it. */
81
+ deleteTree(prefix: string): Promise<void>;
82
+ }
83
+ /** Stores files in a folder on the server. The default storage uses FILES_DIR, which is included in every backup. */
84
+ declare function createLocalFileStorage(dir: string): FileStorage;
85
+
86
+ interface Email {
87
+ to: string;
88
+ subject: string;
89
+ text: string;
90
+ }
91
+ /** Provider-neutral email interface. Apps and framework code only ever use this. */
92
+ interface EmailSender {
93
+ send(email: Email): Promise<void>;
94
+ }
95
+ /** Prints emails to the log. Default for development: links can be copied from there. */
96
+ declare function consoleEmailSender(): EmailSender;
97
+ interface SmtpSettings {
98
+ host: string;
99
+ port: number;
100
+ user?: string;
101
+ password?: string;
102
+ /** The sender, for example `Customer Name <no-reply@customer.eu>`. */
103
+ from: string;
104
+ replyTo?: string;
105
+ }
106
+ /** Sends through any standard SMTP server (Google Workspace, HostGator, a transactional provider). */
107
+ declare function smtpSender({ host, port, user, password, from, replyTo }: SmtpSettings): EmailSender;
108
+ /**
109
+ * The app's email sender. When an Admin has set up and switched on the Email connection (Connections page),
110
+ * every message goes through it; otherwise the environment variables decide (`console` by default).
111
+ * The choice is made at every send, so an Admin's change applies without a restart.
112
+ */
113
+ declare function createEmailSender(config: Config, connections?: Pick<Connections, "emailSender">): EmailSender;
114
+
115
+ interface Actor {
116
+ userId: string | null;
117
+ email: string | null;
118
+ viaKeyId?: string | null;
119
+ }
120
+ /** Records an action. Apps get a ready-made version as `c.var.audit(action, target, details)`. */
121
+ type AuditFn = (action: string, target?: string | null, details?: Record<string, unknown>) => Promise<void>;
122
+
123
+ /**
124
+ * Permissions and built-in roles, defined in code. Permissions are named
125
+ * `resource:action`; apps add their own through `AppAuthz` (see docs/authorization.md).
126
+ */
127
+ interface PermissionDef {
128
+ name: string;
129
+ label: string;
130
+ /** Administrative permission: never usable through an API key. */
131
+ adminOnly?: boolean;
132
+ }
133
+ interface RoleDef {
134
+ key: string;
135
+ label: string;
136
+ permissions: string[];
137
+ /** Holders of this role get time-limited access (EXTERNAL_ACCESS_DAYS). */
138
+ external?: boolean;
139
+ }
140
+ /** What an app adds to the framework's permissions and roles. */
141
+ interface AppAuthz {
142
+ permissions?: PermissionDef[];
143
+ /** New built-in roles, for example the Privacy Coordinator. */
144
+ roles?: RoleDef[];
145
+ /** Extra permissions for existing roles, for example { owner: ["policy:read"] }. */
146
+ grants?: Record<string, string[]>;
147
+ }
148
+ interface Catalog {
149
+ permissions: Map<string, PermissionDef>;
150
+ roles: Map<string, RoleDef>;
151
+ }
152
+ declare const frameworkPermissions: PermissionDef[];
153
+ /** Merges the framework's and the app's definitions and rejects mistakes at startup. */
154
+ declare function buildCatalog(app?: AppAuthz): Catalog;
155
+
156
+ interface RoleView {
157
+ key: string;
158
+ label: string;
159
+ permissions: string[];
160
+ builtIn: boolean;
161
+ }
162
+ type AccessState = {
163
+ active: true;
164
+ expiresAt: Date | null;
165
+ } | {
166
+ active: false;
167
+ reason: "expired" | "deactivated";
168
+ };
169
+ declare class AuthzError extends Error {
170
+ readonly status: 400 | 403 | 404 | 409;
171
+ constructor(message: string, status?: 400 | 403 | 404 | 409);
172
+ }
173
+ interface AuthzDeps {
174
+ db: Db;
175
+ catalog: Catalog;
176
+ /** How long external users keep access after accepting an invitation. */
177
+ externalAccessDays: number;
178
+ }
179
+ /** Roles, permissions and access limits of the single company. */
180
+ declare function createAuthz({ db, catalog, externalAccessDays }: AuthzDeps): {
181
+ db: drizzle_orm_postgres_js.PostgresJsDatabase<Record<string, never>> & {
182
+ $client: postgres.Sql<{}>;
183
+ };
184
+ catalog: Catalog;
185
+ audit: {
186
+ record(actor: Actor, action: string, target?: string | null, details?: Record<string, unknown>): Promise<void>;
187
+ list(limit?: number, before?: Date): Promise<{
188
+ id: string;
189
+ at: Date;
190
+ actorUserId: string | null;
191
+ actorEmail: string | null;
192
+ viaKeyId: string | null;
193
+ action: string;
194
+ target: string | null;
195
+ details: Record<string, unknown> | null;
196
+ }[]>;
197
+ };
198
+ listRoles: () => Promise<RoleView[]>;
199
+ roleKeysOf: (userId: string) => Promise<string[]>;
200
+ permissionsOf: (userId: string) => Promise<Set<string>>;
201
+ accessOf: (userId: string) => Promise<AccessState>;
202
+ normaliseRoles: (keys: string[]) => Promise<string[]>;
203
+ onJoined: (userId: string, roles: string) => Promise<void>;
204
+ joinPendingInvitation: (userId: string) => Promise<string[] | null>;
205
+ setUserRoles: (actorId: string, userId: string, keys: string[]) => Promise<string[]>;
206
+ setDeactivated: (userId: string, deactivated: boolean) => Promise<void>;
207
+ renewAccess: (userId: string, days: number | null) => Promise<void>;
208
+ createRole: (label: string, permissions: string[]) => Promise<RoleView>;
209
+ updateRole: (key: string, label: string, permissions: string[]) => Promise<RoleView>;
210
+ deleteRole: (key: string) => Promise<void>;
211
+ };
212
+ type Authz = ReturnType<typeof createAuthz>;
213
+
214
+ type ConnectionKind = "llm" | "storage" | "email";
215
+ /** The storage that backups are copied to. The framework uses this id and no other. */
216
+ declare const BACKUP_STORAGE = "appai-backup";
217
+ /** The email connection: how the app sends invitations, password resets, reminders and alerts. The framework uses this id and no other. */
218
+ declare const EMAIL_CONNECTION = "appai-email";
219
+ /** The built-in storage: a folder on the server (FILES_DIR), included in every backup. */
220
+ declare const DEFAULT_STORAGE = "default";
221
+ interface FieldDef {
222
+ key: string;
223
+ label: string;
224
+ /** `secret` fields are encrypted, never shown again and kept when left empty on save. */
225
+ type: "text" | "secret" | "number" | "boolean" | "select";
226
+ required?: boolean;
227
+ help?: string;
228
+ placeholder?: string;
229
+ options?: {
230
+ value: string;
231
+ label: string;
232
+ }[];
233
+ default?: string | number | boolean;
234
+ min?: number;
235
+ max?: number;
236
+ }
237
+ /** What an app (or the framework) needs: shown to the Admin as a place to fill in. */
238
+ interface ConnectionSlot {
239
+ kind: ConnectionKind;
240
+ id: string;
241
+ /** What it is used for, in the Admin's words: "Summaries of long policies". */
242
+ purpose: string;
243
+ required?: boolean;
244
+ /** Extra fields for this slot only, for example the backup passphrase. */
245
+ extraFields?: FieldDef[];
246
+ }
247
+ interface ProviderContext {
248
+ id: string;
249
+ config: Record<string, unknown>;
250
+ secrets: Record<string, string>;
251
+ fetch: typeof fetch;
252
+ /** The address to register at the provider as the OAuth redirect. */
253
+ redirectUri: string;
254
+ /** Saves values the provider learned by itself, such as the id of the folder it created. */
255
+ saveConfig(patch: Record<string, unknown>): Promise<void>;
256
+ }
257
+ interface OAuthDef {
258
+ authorizeUrl(ctx: ProviderContext, state: string): string;
259
+ /** Trades the code for tokens; the result is stored with the connection's secrets. */
260
+ exchange(ctx: ProviderContext, code: string): Promise<Record<string, string>>;
261
+ }
262
+ interface ProviderBase {
263
+ key: string;
264
+ label: string;
265
+ description?: string;
266
+ fields: FieldDef[];
267
+ /** Extra check when the Admin saves (beyond the fields); returns a message for the Admin or null. */
268
+ check?(config: Record<string, unknown>): string | null;
269
+ }
270
+ interface StorageProvider extends ProviderBase {
271
+ kind: "storage";
272
+ oauth?: OAuthDef;
273
+ /** Whether our backups contain this storage's files (only the FILES_DIR folder does). */
274
+ inBackup?: (ctx: Pick<ProviderContext, "config">, filesDir: string) => boolean;
275
+ create(ctx: ProviderContext): FileStorage;
276
+ }
277
+ interface LlmProvider extends ProviderBase {
278
+ kind: "llm";
279
+ create(ctx: ProviderContext): LanguageModel;
280
+ }
281
+ interface EmailProvider extends ProviderBase {
282
+ kind: "email";
283
+ create(ctx: ProviderContext): EmailSender;
284
+ }
285
+ type Provider = StorageProvider | LlmProvider | EmailProvider;
286
+ /** Thrown when app code asks for a connection that is missing or not usable. The message is for the Admin. */
287
+ declare class ConnectionError extends AuthzError {
288
+ constructor(message: string);
289
+ }
290
+
291
+ interface ConnectionsDeps {
292
+ db: Db;
293
+ config: Pick<Config, "PUBLIC_URL" | "AUTH_SECRET" | "SECRETS_KEY" | "FILES_DIR">;
294
+ /** What the app needs, for example `{ kind: "llm", id: "default", purpose: "Summaries", required: true }`. */
295
+ slots?: ConnectionSlot[];
296
+ /** More providers than the framework's (the tests add a scripted LLM). */
297
+ providers?: Provider[];
298
+ fetch?: typeof fetch;
299
+ }
300
+ type ConnectionStatus = "missing" | "disabled" | "incomplete" | "untested" | "ok" | "failing";
301
+ interface ConnectionView {
302
+ kind: ConnectionKind;
303
+ id: string;
304
+ label: string;
305
+ /** What it is for; only for connections the app or the framework declared. */
306
+ purpose: string | null;
307
+ required: boolean;
308
+ declared: boolean;
309
+ /** The built-in storage cannot be changed or removed. */
310
+ builtIn: boolean;
311
+ provider: string | null;
312
+ providerLabel: string | null;
313
+ config: Record<string, unknown>;
314
+ /** Names of the secret fields that have a value. The values themselves are never sent. */
315
+ secretsSet: string[];
316
+ enabled: boolean;
317
+ status: ConnectionStatus;
318
+ /** What is wrong, when `status` is "incomplete". */
319
+ problem: string | null;
320
+ lastTest: {
321
+ at: string;
322
+ ok: boolean;
323
+ message: string;
324
+ } | null;
325
+ extraFields: FieldDef[];
326
+ /** Storages only: whether our backups contain the files kept here. */
327
+ inBackup: boolean | null;
328
+ }
329
+ interface ProviderView {
330
+ kind: ConnectionKind;
331
+ key: string;
332
+ label: string;
333
+ description: string | null;
334
+ fields: FieldDef[];
335
+ oauth: boolean;
336
+ }
337
+ interface SaveInput {
338
+ label?: string;
339
+ provider: string;
340
+ config?: Record<string, unknown>;
341
+ /** A field left out or empty keeps its stored value; `null` removes it. */
342
+ secrets?: Record<string, string | null>;
343
+ enabled?: boolean;
344
+ }
345
+ interface Usage {
346
+ inputTokens: number | null;
347
+ outputTokens: number | null;
348
+ }
349
+ interface LlmCallOptions {
350
+ system?: string;
351
+ prompt: string;
352
+ /** What the call is for ("policy-summary"); recorded in the usage log. */
353
+ feature?: string;
354
+ /** Who triggered it; recorded in the usage log. */
355
+ userId?: string;
356
+ maxOutputTokens?: number;
357
+ temperature?: number;
358
+ }
359
+ /** A connection to a language model. The prompt and the answer are never stored; only the counts are. */
360
+ interface Llm {
361
+ id: string;
362
+ text(options: LlmCallOptions): Promise<{
363
+ text: string;
364
+ usage: Usage;
365
+ }>;
366
+ /** The answer as an object that matches `schema`. */
367
+ object<T>(options: LlmCallOptions & {
368
+ schema: z.ZodType<T>;
369
+ }): Promise<{
370
+ object: T;
371
+ usage: Usage;
372
+ }>;
373
+ /** Streams the answer; `done` settles with the full text when the stream has ended. */
374
+ stream(options: LlmCallOptions): Promise<{
375
+ textStream: AsyncIterable<string>;
376
+ done: Promise<{
377
+ text: string;
378
+ usage: Usage;
379
+ }>;
380
+ }>;
381
+ }
382
+ interface LlmGetOptions {
383
+ /** Set when the prompt contains personal data: the call fails unless the Admin approved this connection for it. */
384
+ personalData?: boolean;
385
+ }
386
+ /**
387
+ * Named connections to LLMs and file storages, set up by an Admin and used by id from app code.
388
+ * One API process owns the database, so rows are cached in memory and every write refreshes the cache.
389
+ */
390
+ declare function createConnections({ db, config, slots, providers, fetch: fetchFn }: ConnectionsDeps): {
391
+ kinds: ConnectionKind[];
392
+ list: (kind: ConnectionKind) => Promise<ConnectionView[]>;
393
+ providers: (kind: ConnectionKind) => ProviderView[];
394
+ save: (kind: ConnectionKind, id: string, input: SaveInput, actor: string) => Promise<{
395
+ view: ConnectionView;
396
+ changedSecrets: string[];
397
+ }>;
398
+ remove: (kind: ConnectionKind, id: string) => Promise<void>;
399
+ test: (kind: ConnectionKind, id: string, recipient?: string) => Promise<{
400
+ ok: boolean;
401
+ message: string;
402
+ }>;
403
+ storage: (id: string) => FileStorage;
404
+ storageReady: (id: string) => Promise<boolean>;
405
+ emailSender: (fallback: EmailSender) => EmailSender;
406
+ llm: (id: string, options?: LlmGetOptions) => Llm;
407
+ oauthStart: (kind: ConnectionKind, id: string, userId: string) => Promise<string>;
408
+ oauthFinish: (kind: ConnectionKind, userId: string, code: string, state: string) => Promise<{
409
+ id: string;
410
+ test: {
411
+ ok: boolean;
412
+ message: string;
413
+ };
414
+ }>;
415
+ redirectUri: (kind: ConnectionKind) => string;
416
+ health: () => Promise<{
417
+ status: "ok" | "warn";
418
+ detail: string;
419
+ }>;
420
+ llmUsage: (days?: number) => Promise<{
421
+ connectionId: string;
422
+ day: string;
423
+ calls: number;
424
+ errors: number;
425
+ inputTokens: number;
426
+ outputTokens: number;
427
+ }[]>;
428
+ backupPassphrase: () => Promise<string | null>;
429
+ };
430
+ type Connections = ReturnType<typeof createConnections>;
431
+
432
+ interface AuthDeps {
433
+ db: Db;
434
+ config: Config;
435
+ email: EmailSender;
436
+ authz: Authz;
437
+ /** The current application name for emails; defaults to APP_NAME. An admin can change it while the app runs. */
438
+ appName?: () => string;
439
+ }
440
+ /**
441
+ * Creates the Better Auth instance. Everything auth-related goes through here,
442
+ * so the library can be replaced without touching apps.
443
+ *
444
+ * Rules enforced here:
445
+ * - Sign-up is invitation-only. While the app has no users, only INITIAL_ADMIN_EMAIL may sign up.
446
+ * - The first user becomes the owner ("Admin") of the single company.
447
+ * - Roles and permissions are our own (authz); the library only stores the role names.
448
+ * - API keys carry scopes; the guard intersects them with the owner's permissions.
449
+ */
450
+ declare function createAuth({ db, config, email, authz, appName }: AuthDeps): Auth;
451
+ /**
452
+ * What the framework uses of the auth provider (Better Auth today). Written out so the provider can be replaced
453
+ * without touching apps, and so the published type declarations stay small.
454
+ */
455
+ interface Auth {
456
+ /** Serves every /api/auth/* request: sign-in, sign-up, verification, password reset, invitations. */
457
+ handler(request: Request): Promise<Response>;
458
+ api: {
459
+ getSession(input: {
460
+ headers: Headers;
461
+ }): Promise<{
462
+ user: {
463
+ id: string;
464
+ email: string;
465
+ name: string;
466
+ emailVerified: boolean;
467
+ };
468
+ } | null>;
469
+ verifyApiKey(input: {
470
+ body: {
471
+ key: string;
472
+ };
473
+ }): Promise<{
474
+ valid: boolean;
475
+ key: {
476
+ id: string;
477
+ referenceId: string;
478
+ permissions: unknown;
479
+ } | null;
480
+ }>;
481
+ createApiKey(input: {
482
+ body: {
483
+ name: string;
484
+ userId: string;
485
+ prefix: string;
486
+ permissions: Record<string, string[]>;
487
+ expiresIn: number;
488
+ };
489
+ }): Promise<{
490
+ id: string;
491
+ key: string;
492
+ }>;
493
+ };
494
+ }
495
+
496
+ type SessionUser = {
497
+ id: string;
498
+ email: string;
499
+ name: string;
500
+ emailVerified: boolean;
501
+ };
502
+ /** Set when the request used an API key: the key's id and the permissions it was given. */
503
+ type ApiKeyInfo = {
504
+ id: string;
505
+ scopes: Set<string>;
506
+ };
507
+ type AuthEnv = {
508
+ Variables: {
509
+ user: SessionUser | null;
510
+ apiKey: ApiKeyInfo | null;
511
+ /** Why a known user was refused, so the API and UI can say so. */
512
+ accessProblem: "expired" | "deactivated" | null;
513
+ audit: AuditFn;
514
+ };
515
+ };
516
+ /**
517
+ * Identifies the caller from an API key (x-api-key header) or the session cookie, sets
518
+ * `c.var.user`, `c.var.apiKey` and `c.var.audit`, and treats deactivated or expired users as signed out.
519
+ */
520
+ declare function sessionMiddleware(auth: Auth, authz: Authz): MiddlewareHandler<AuthEnv>;
521
+ /** Declares an endpoint open to everyone (health check, sign-in pages). Use sparingly. */
522
+ declare function publicRoute(): MiddlewareHandler;
523
+ /** Declares an endpoint for any signed-in user, with no particular permission. 401 otherwise. */
524
+ declare function requireSession(): MiddlewareHandler<AuthEnv>;
525
+ /**
526
+ * Declares the permission an endpoint needs, for example "user:read". Several names mean any of them.
527
+ * 401 when not signed in, 403 when the user's roles (and, for API keys, the key's scopes) do not allow it.
528
+ * Administrative permissions are never available to API keys.
529
+ */
530
+ declare function requirePermission(authz: Authz, permission: string | string[]): MiddlewareHandler<AuthEnv>;
531
+ /** Any Hono app: only its route list is needed. */
532
+ type HasRoutes = {
533
+ routes: readonly {
534
+ method: string;
535
+ path: string;
536
+ handler: unknown;
537
+ }[];
538
+ };
539
+ /** Routes (method + path) that have no declaration: no requirePermission, requireSession or publicRoute. */
540
+ declare function findUndeclaredRoutes(app: HasRoutes): string[];
541
+ /** Default deny: refuses to start (and fails the tests) when an endpoint has no declared access. */
542
+ declare function assertDefaultDeny(app: HasRoutes): void;
543
+ /** The id of the single company (organization) of this deployment. */
544
+ declare function getCompanyId(db: Db): Promise<string | undefined>;
545
+
546
+ type BackupConfig = Pick<Config, "DATABASE_URL" | "BACKUP_DIR" | "BACKUP_KEEP" | "BACKUP_ENABLED" | "BACKUP_TIME"> & {
547
+ FILES_DIR?: string;
548
+ };
549
+ /** Writes a PostgreSQL dump (custom format) of `databaseUrl` to `file`. */
550
+ type DumpFn = (databaseUrl: string, file: string) => Promise<void>;
551
+ /** Writes a gzipped tar of `folder` to `file`. */
552
+ type ArchiveFn = (folder: string, file: string) => Promise<void>;
553
+
554
+ interface CheckResult {
555
+ name: string;
556
+ label: string;
557
+ /** ok = fine, warn = worth a look (no alert), fail = needs action (alert). */
558
+ status: "ok" | "warn" | "fail";
559
+ detail: string;
560
+ }
561
+ type Check = () => Promise<Pick<CheckResult, "status" | "detail">>;
562
+
563
+ /** What the browser needs to theme the app. Colors the profile does not set are left to theme.css. */
564
+ interface Brand {
565
+ appName: string;
566
+ logoUrl: string | null;
567
+ fontFamily: string | null;
568
+ fontUrl: string | null;
569
+ colors: {
570
+ primary?: string;
571
+ primaryContrast?: string;
572
+ secondary?: string;
573
+ primaryDark?: string;
574
+ primaryDarkContrast?: string;
575
+ secondaryDark?: string;
576
+ };
577
+ }
578
+ /** Black or white, whichever is easier to read on `color` (WCAG relative luminance). */
579
+ declare function contrastOn(color: string): "#000000" | "#ffffff";
580
+ interface LoadedBrand {
581
+ brand: Brand;
582
+ /** Absolute paths of the served files. */
583
+ logoPath: string | null;
584
+ fontPath: string | null;
585
+ }
586
+ /**
587
+ * Reads `brand.json` from the brand folder. A missing folder or file means the built-in look.
588
+ * A broken profile stops the app at startup with a readable message, never at the customer's first visit.
589
+ */
590
+ declare function loadBrand(dir: string, defaultAppName: string): LoadedBrand;
591
+ interface BrandService {
592
+ /** The brand as it is now: brand.json and the environment give the first-run values, the Settings page overrides them. */
593
+ brand(): Brand;
594
+ logo(): Promise<{
595
+ data: Buffer;
596
+ type: string;
597
+ } | null>;
598
+ font(): Buffer | null;
599
+ }
600
+ declare function createBrandService({ loaded, settings, storage, }: {
601
+ loaded: LoadedBrand;
602
+ settings: Pick<Settings, "get">;
603
+ storage: FileStorage;
604
+ }): BrandService;
605
+ /** GET /api/brand (+ logo and font files). Public: the sign-in page is themed too. */
606
+ declare function brandRoutes(service: BrandService): Hono<hono_types.BlankEnv, hono_types.BlankSchema, "/">;
607
+
608
+ type SettingType = "text" | "number" | "boolean" | "select" | "numbers" | "color";
609
+ /** One admin-editable setting. Declared in code, edited on the Settings page, stored in the database. */
610
+ interface SettingDef {
611
+ /** Unique, lower camel case with dots: `app.name`, `policy.reminderDays`. */
612
+ key: string;
613
+ label: string;
614
+ description?: string;
615
+ /** Settings with the same group are shown together on the Settings page. */
616
+ group: string;
617
+ type: SettingType;
618
+ /** Used until an admin changes the value. `null` means "not set" (colors fall back to the theme). */
619
+ default: unknown;
620
+ unit?: string;
621
+ /** number: smallest and largest value; numbers: smallest and largest entry; text: max length (min 1). */
622
+ min?: number;
623
+ max?: number;
624
+ options?: {
625
+ value: string;
626
+ label: string;
627
+ }[];
628
+ /** Readable by every signed-in user through GET /api/settings/values (e.g. a default shown in a form). */
629
+ expose?: boolean;
630
+ /** Set by code (e.g. the uploaded logo), never through the generic form. */
631
+ managed?: boolean;
632
+ }
633
+ /** The settings every app has. Defaults come from brand.json and the environment: they are the first-run values. */
634
+ declare function frameworkSettings({ brand }: Pick<LoadedBrand, "brand">): SettingDef[];
635
+
636
+ interface SettingView extends SettingDef {
637
+ value: unknown;
638
+ isDefault: boolean;
639
+ }
640
+ interface SettingChange {
641
+ key: string;
642
+ from: unknown;
643
+ to: unknown;
644
+ }
645
+ /**
646
+ * Admin-editable settings with in-memory reads. One API process owns the database,
647
+ * so a write refreshes the cache and every later read sees it without a restart.
648
+ */
649
+ declare function createSettings({ db, definitions }: {
650
+ db: Db;
651
+ definitions: SettingDef[];
652
+ }): {
653
+ /** Reads all saved values; call once at startup, after the migrations. */
654
+ load(): Promise<void>;
655
+ /** The current value (the default until an admin changes it). Cheap: no database access. */
656
+ get<T = unknown>(key: string): T;
657
+ /** For the Settings page: everything an admin can edit, with current values. */
658
+ describe(): SettingView[];
659
+ /** Values every signed-in user may read (settings marked `expose`). */
660
+ exposed(): Record<string, unknown>;
661
+ /** Saves values; `null` resets a setting to its default. Returns what actually changed. */
662
+ update(changes: Record<string, unknown>, actor: string): Promise<SettingChange[]>;
663
+ /** For code that owns a value (the uploaded logo). */
664
+ setManaged(key: string, value: unknown, actor: string): Promise<SettingChange[]>;
665
+ };
666
+ type Settings = ReturnType<typeof createSettings>;
667
+
668
+ interface OperationsDeps {
669
+ db: Db;
670
+ config: BackupConfig & Pick<Config, "ALERT_EMAILS" | "DISK_MIN_FREE_PERCENT" | "HEALTH_CHECK_SECONDS">;
671
+ email: EmailSender;
672
+ appName: () => string;
673
+ dump?: DumpFn;
674
+ archive?: ArchiveFn;
675
+ extraChecks?: Record<string, {
676
+ label: string;
677
+ run: Check;
678
+ }>;
679
+ /** With these, backups can be copied to the storage "appai-backup" and the Status page checks the connections. */
680
+ settings?: Settings;
681
+ connections?: Connections;
682
+ }
683
+ /**
684
+ * Backups, health checks and alerts. Nothing runs until `start()` is called (only the real server does that),
685
+ * so tests and tools can use the services without timers.
686
+ */
687
+ declare function createOperations({ db, config, email, appName, dump, archive, extraChecks, settings, connections }: OperationsDeps): {
688
+ backups: {
689
+ backupNow: (trigger: "scheduled" | "manual") => Promise<{
690
+ folder: string;
691
+ sizeBytes: number;
692
+ }>;
693
+ uploadBackup: (folder: string) => Promise<{
694
+ folder: string;
695
+ encrypted: boolean;
696
+ files: number;
697
+ }>;
698
+ recent: (limit?: number) => Omit<drizzle_orm_pg_core.PgSelectBase<"backup_run", {
699
+ id: drizzle_orm_pg_core.PgColumn<{
700
+ name: "id";
701
+ tableName: "backup_run";
702
+ dataType: "string";
703
+ columnType: "PgUUID";
704
+ data: string;
705
+ driverParam: string;
706
+ notNull: true;
707
+ hasDefault: true;
708
+ isPrimaryKey: true;
709
+ isAutoincrement: false;
710
+ hasRuntimeDefault: false;
711
+ enumValues: undefined;
712
+ baseColumn: never;
713
+ identity: undefined;
714
+ generated: undefined;
715
+ }, {}, {}>;
716
+ startedAt: drizzle_orm_pg_core.PgColumn<{
717
+ name: "started_at";
718
+ tableName: "backup_run";
719
+ dataType: "date";
720
+ columnType: "PgTimestamp";
721
+ data: Date;
722
+ driverParam: string;
723
+ notNull: true;
724
+ hasDefault: true;
725
+ isPrimaryKey: false;
726
+ isAutoincrement: false;
727
+ hasRuntimeDefault: false;
728
+ enumValues: undefined;
729
+ baseColumn: never;
730
+ identity: undefined;
731
+ generated: undefined;
732
+ }, {}, {}>;
733
+ finishedAt: drizzle_orm_pg_core.PgColumn<{
734
+ name: "finished_at";
735
+ tableName: "backup_run";
736
+ dataType: "date";
737
+ columnType: "PgTimestamp";
738
+ data: Date;
739
+ driverParam: string;
740
+ notNull: false;
741
+ hasDefault: false;
742
+ isPrimaryKey: false;
743
+ isAutoincrement: false;
744
+ hasRuntimeDefault: false;
745
+ enumValues: undefined;
746
+ baseColumn: never;
747
+ identity: undefined;
748
+ generated: undefined;
749
+ }, {}, {}>;
750
+ status: drizzle_orm_pg_core.PgColumn<{
751
+ name: "status";
752
+ tableName: "backup_run";
753
+ dataType: "string";
754
+ columnType: "PgText";
755
+ data: string;
756
+ driverParam: string;
757
+ notNull: true;
758
+ hasDefault: false;
759
+ isPrimaryKey: false;
760
+ isAutoincrement: false;
761
+ hasRuntimeDefault: false;
762
+ enumValues: [string, ...string[]];
763
+ baseColumn: never;
764
+ identity: undefined;
765
+ generated: undefined;
766
+ }, {}, {}>;
767
+ trigger: drizzle_orm_pg_core.PgColumn<{
768
+ name: "trigger";
769
+ tableName: "backup_run";
770
+ dataType: "string";
771
+ columnType: "PgText";
772
+ data: string;
773
+ driverParam: string;
774
+ notNull: true;
775
+ hasDefault: false;
776
+ isPrimaryKey: false;
777
+ isAutoincrement: false;
778
+ hasRuntimeDefault: false;
779
+ enumValues: [string, ...string[]];
780
+ baseColumn: never;
781
+ identity: undefined;
782
+ generated: undefined;
783
+ }, {}, {}>;
784
+ folder: drizzle_orm_pg_core.PgColumn<{
785
+ name: "folder";
786
+ tableName: "backup_run";
787
+ dataType: "string";
788
+ columnType: "PgText";
789
+ data: string;
790
+ driverParam: string;
791
+ notNull: false;
792
+ hasDefault: false;
793
+ isPrimaryKey: false;
794
+ isAutoincrement: false;
795
+ hasRuntimeDefault: false;
796
+ enumValues: [string, ...string[]];
797
+ baseColumn: never;
798
+ identity: undefined;
799
+ generated: undefined;
800
+ }, {}, {}>;
801
+ sizeBytes: drizzle_orm_pg_core.PgColumn<{
802
+ name: "size_bytes";
803
+ tableName: "backup_run";
804
+ dataType: "number";
805
+ columnType: "PgBigInt53";
806
+ data: number;
807
+ driverParam: string | number;
808
+ notNull: false;
809
+ hasDefault: false;
810
+ isPrimaryKey: false;
811
+ isAutoincrement: false;
812
+ hasRuntimeDefault: false;
813
+ enumValues: undefined;
814
+ baseColumn: never;
815
+ identity: undefined;
816
+ generated: undefined;
817
+ }, {}, {}>;
818
+ error: drizzle_orm_pg_core.PgColumn<{
819
+ name: "error";
820
+ tableName: "backup_run";
821
+ dataType: "string";
822
+ columnType: "PgText";
823
+ data: string;
824
+ driverParam: string;
825
+ notNull: false;
826
+ hasDefault: false;
827
+ isPrimaryKey: false;
828
+ isAutoincrement: false;
829
+ hasRuntimeDefault: false;
830
+ enumValues: [string, ...string[]];
831
+ baseColumn: never;
832
+ identity: undefined;
833
+ generated: undefined;
834
+ }, {}, {}>;
835
+ uploadedAt: drizzle_orm_pg_core.PgColumn<{
836
+ name: "uploaded_at";
837
+ tableName: "backup_run";
838
+ dataType: "date";
839
+ columnType: "PgTimestamp";
840
+ data: Date;
841
+ driverParam: string;
842
+ notNull: false;
843
+ hasDefault: false;
844
+ isPrimaryKey: false;
845
+ isAutoincrement: false;
846
+ hasRuntimeDefault: false;
847
+ enumValues: undefined;
848
+ baseColumn: never;
849
+ identity: undefined;
850
+ generated: undefined;
851
+ }, {}, {}>;
852
+ uploadEncrypted: drizzle_orm_pg_core.PgColumn<{
853
+ name: "upload_encrypted";
854
+ tableName: "backup_run";
855
+ dataType: "boolean";
856
+ columnType: "PgBoolean";
857
+ data: boolean;
858
+ driverParam: boolean;
859
+ notNull: false;
860
+ hasDefault: false;
861
+ isPrimaryKey: false;
862
+ isAutoincrement: false;
863
+ hasRuntimeDefault: false;
864
+ enumValues: undefined;
865
+ baseColumn: never;
866
+ identity: undefined;
867
+ generated: undefined;
868
+ }, {}, {}>;
869
+ uploadError: drizzle_orm_pg_core.PgColumn<{
870
+ name: "upload_error";
871
+ tableName: "backup_run";
872
+ dataType: "string";
873
+ columnType: "PgText";
874
+ data: string;
875
+ driverParam: string;
876
+ notNull: false;
877
+ hasDefault: false;
878
+ isPrimaryKey: false;
879
+ isAutoincrement: false;
880
+ hasRuntimeDefault: false;
881
+ enumValues: [string, ...string[]];
882
+ baseColumn: never;
883
+ identity: undefined;
884
+ generated: undefined;
885
+ }, {}, {}>;
886
+ }, "single", Record<"backup_run", "not-null">, false, "orderBy" | "limit", {
887
+ id: string;
888
+ startedAt: Date;
889
+ finishedAt: Date | null;
890
+ status: string;
891
+ trigger: string;
892
+ folder: string | null;
893
+ sizeBytes: number | null;
894
+ error: string | null;
895
+ uploadedAt: Date | null;
896
+ uploadEncrypted: boolean | null;
897
+ uploadError: string | null;
898
+ }[], {
899
+ id: drizzle_orm_pg_core.PgColumn<{
900
+ name: "id";
901
+ tableName: "backup_run";
902
+ dataType: "string";
903
+ columnType: "PgUUID";
904
+ data: string;
905
+ driverParam: string;
906
+ notNull: true;
907
+ hasDefault: true;
908
+ isPrimaryKey: true;
909
+ isAutoincrement: false;
910
+ hasRuntimeDefault: false;
911
+ enumValues: undefined;
912
+ baseColumn: never;
913
+ identity: undefined;
914
+ generated: undefined;
915
+ }, {}, {}>;
916
+ startedAt: drizzle_orm_pg_core.PgColumn<{
917
+ name: "started_at";
918
+ tableName: "backup_run";
919
+ dataType: "date";
920
+ columnType: "PgTimestamp";
921
+ data: Date;
922
+ driverParam: string;
923
+ notNull: true;
924
+ hasDefault: true;
925
+ isPrimaryKey: false;
926
+ isAutoincrement: false;
927
+ hasRuntimeDefault: false;
928
+ enumValues: undefined;
929
+ baseColumn: never;
930
+ identity: undefined;
931
+ generated: undefined;
932
+ }, {}, {}>;
933
+ finishedAt: drizzle_orm_pg_core.PgColumn<{
934
+ name: "finished_at";
935
+ tableName: "backup_run";
936
+ dataType: "date";
937
+ columnType: "PgTimestamp";
938
+ data: Date;
939
+ driverParam: string;
940
+ notNull: false;
941
+ hasDefault: false;
942
+ isPrimaryKey: false;
943
+ isAutoincrement: false;
944
+ hasRuntimeDefault: false;
945
+ enumValues: undefined;
946
+ baseColumn: never;
947
+ identity: undefined;
948
+ generated: undefined;
949
+ }, {}, {}>;
950
+ status: drizzle_orm_pg_core.PgColumn<{
951
+ name: "status";
952
+ tableName: "backup_run";
953
+ dataType: "string";
954
+ columnType: "PgText";
955
+ data: string;
956
+ driverParam: string;
957
+ notNull: true;
958
+ hasDefault: false;
959
+ isPrimaryKey: false;
960
+ isAutoincrement: false;
961
+ hasRuntimeDefault: false;
962
+ enumValues: [string, ...string[]];
963
+ baseColumn: never;
964
+ identity: undefined;
965
+ generated: undefined;
966
+ }, {}, {}>;
967
+ trigger: drizzle_orm_pg_core.PgColumn<{
968
+ name: "trigger";
969
+ tableName: "backup_run";
970
+ dataType: "string";
971
+ columnType: "PgText";
972
+ data: string;
973
+ driverParam: string;
974
+ notNull: true;
975
+ hasDefault: false;
976
+ isPrimaryKey: false;
977
+ isAutoincrement: false;
978
+ hasRuntimeDefault: false;
979
+ enumValues: [string, ...string[]];
980
+ baseColumn: never;
981
+ identity: undefined;
982
+ generated: undefined;
983
+ }, {}, {}>;
984
+ folder: drizzle_orm_pg_core.PgColumn<{
985
+ name: "folder";
986
+ tableName: "backup_run";
987
+ dataType: "string";
988
+ columnType: "PgText";
989
+ data: string;
990
+ driverParam: string;
991
+ notNull: false;
992
+ hasDefault: false;
993
+ isPrimaryKey: false;
994
+ isAutoincrement: false;
995
+ hasRuntimeDefault: false;
996
+ enumValues: [string, ...string[]];
997
+ baseColumn: never;
998
+ identity: undefined;
999
+ generated: undefined;
1000
+ }, {}, {}>;
1001
+ sizeBytes: drizzle_orm_pg_core.PgColumn<{
1002
+ name: "size_bytes";
1003
+ tableName: "backup_run";
1004
+ dataType: "number";
1005
+ columnType: "PgBigInt53";
1006
+ data: number;
1007
+ driverParam: string | number;
1008
+ notNull: false;
1009
+ hasDefault: false;
1010
+ isPrimaryKey: false;
1011
+ isAutoincrement: false;
1012
+ hasRuntimeDefault: false;
1013
+ enumValues: undefined;
1014
+ baseColumn: never;
1015
+ identity: undefined;
1016
+ generated: undefined;
1017
+ }, {}, {}>;
1018
+ error: drizzle_orm_pg_core.PgColumn<{
1019
+ name: "error";
1020
+ tableName: "backup_run";
1021
+ dataType: "string";
1022
+ columnType: "PgText";
1023
+ data: string;
1024
+ driverParam: string;
1025
+ notNull: false;
1026
+ hasDefault: false;
1027
+ isPrimaryKey: false;
1028
+ isAutoincrement: false;
1029
+ hasRuntimeDefault: false;
1030
+ enumValues: [string, ...string[]];
1031
+ baseColumn: never;
1032
+ identity: undefined;
1033
+ generated: undefined;
1034
+ }, {}, {}>;
1035
+ uploadedAt: drizzle_orm_pg_core.PgColumn<{
1036
+ name: "uploaded_at";
1037
+ tableName: "backup_run";
1038
+ dataType: "date";
1039
+ columnType: "PgTimestamp";
1040
+ data: Date;
1041
+ driverParam: string;
1042
+ notNull: false;
1043
+ hasDefault: false;
1044
+ isPrimaryKey: false;
1045
+ isAutoincrement: false;
1046
+ hasRuntimeDefault: false;
1047
+ enumValues: undefined;
1048
+ baseColumn: never;
1049
+ identity: undefined;
1050
+ generated: undefined;
1051
+ }, {}, {}>;
1052
+ uploadEncrypted: drizzle_orm_pg_core.PgColumn<{
1053
+ name: "upload_encrypted";
1054
+ tableName: "backup_run";
1055
+ dataType: "boolean";
1056
+ columnType: "PgBoolean";
1057
+ data: boolean;
1058
+ driverParam: boolean;
1059
+ notNull: false;
1060
+ hasDefault: false;
1061
+ isPrimaryKey: false;
1062
+ isAutoincrement: false;
1063
+ hasRuntimeDefault: false;
1064
+ enumValues: undefined;
1065
+ baseColumn: never;
1066
+ identity: undefined;
1067
+ generated: undefined;
1068
+ }, {}, {}>;
1069
+ uploadError: drizzle_orm_pg_core.PgColumn<{
1070
+ name: "upload_error";
1071
+ tableName: "backup_run";
1072
+ dataType: "string";
1073
+ columnType: "PgText";
1074
+ data: string;
1075
+ driverParam: string;
1076
+ notNull: false;
1077
+ hasDefault: false;
1078
+ isPrimaryKey: false;
1079
+ isAutoincrement: false;
1080
+ hasRuntimeDefault: false;
1081
+ enumValues: [string, ...string[]];
1082
+ baseColumn: never;
1083
+ identity: undefined;
1084
+ generated: undefined;
1085
+ }, {}, {}>;
1086
+ }>, "orderBy" | "limit">;
1087
+ lastSuccess: () => Promise<{
1088
+ id: string;
1089
+ startedAt: Date;
1090
+ finishedAt: Date | null;
1091
+ status: string;
1092
+ trigger: string;
1093
+ folder: string | null;
1094
+ sizeBytes: number | null;
1095
+ error: string | null;
1096
+ uploadedAt: Date | null;
1097
+ uploadEncrypted: boolean | null;
1098
+ uploadError: string | null;
1099
+ } | null>;
1100
+ recoverInterrupted: () => Promise<void>;
1101
+ isRunning: () => boolean;
1102
+ isCopying: () => boolean;
1103
+ };
1104
+ monitor: {
1105
+ tick: () => Promise<CheckResult[]>;
1106
+ current: () => CheckResult[];
1107
+ overall: (results?: CheckResult[]) => "ok" | "warn" | "fail";
1108
+ };
1109
+ start: () => Promise<void>;
1110
+ stop: () => void;
1111
+ nextBackupAt: () => Date | null;
1112
+ settings: {
1113
+ backupEnabled: boolean;
1114
+ backupTime: string;
1115
+ backupKeep: number;
1116
+ alertRecipients: number;
1117
+ includesFiles: boolean;
1118
+ };
1119
+ /** For the Status page: whether backups can be copied elsewhere, and how. */
1120
+ copy: () => Promise<{
1121
+ available: boolean;
1122
+ ready: boolean;
1123
+ auto: boolean;
1124
+ keep: number;
1125
+ encrypted: boolean;
1126
+ copying: boolean;
1127
+ }>;
1128
+ disk: () => Promise<{
1129
+ totalBytes: number;
1130
+ freeBytes: number;
1131
+ freePercent: number;
1132
+ }>;
1133
+ };
1134
+ type Operations = ReturnType<typeof createOperations>;
1135
+
1136
+ interface HealthDeps {
1137
+ /** The current application name (an admin can change it while the app runs). */
1138
+ appName: () => string;
1139
+ /** Resolves when the database answers; rejects otherwise. */
1140
+ checkDatabase: () => Promise<void>;
1141
+ }
1142
+ /** GET /api/health: used by uptime checks and the admin status page. */
1143
+ declare function healthRoutes({ appName, checkDatabase }: HealthDeps): Hono<hono_types.BlankEnv, hono_types.BlankSchema, "/">;
1144
+
1145
+ interface AppDeps extends HealthDeps {
1146
+ auth: Auth;
1147
+ db: Db;
1148
+ authz: Authz;
1149
+ email: EmailSender;
1150
+ publicUrl: string;
1151
+ brand: BrandService;
1152
+ settings: Settings;
1153
+ storage: FileStorage;
1154
+ connections: Connections;
1155
+ ops: Operations;
1156
+ /** Origins browsers may send state-changing requests from. Defaults to the public URL. */
1157
+ trustedOrigins?: string[];
1158
+ }
1159
+ /**
1160
+ * Creates the base HTTP app with the framework's standard routes.
1161
+ * Apps mount their own routes on the returned instance.
1162
+ */
1163
+ declare function createApp({ auth, db, authz, email, publicUrl, brand, settings, storage, connections, ops, trustedOrigins, ...health }: AppDeps): Hono<AuthEnv, hono_types.BlankSchema, "/">;
1164
+
1165
+ export { createLocalFileStorage as $, BACKUP_STORAGE as B, EMAIL_CONNECTION as E, assertDefaultDeny as J, brandRoutes as K, buildCatalog as M, consoleEmailSender as N, contrastOn as Q, createApp as T, createAuth as V, createAuthz as W, createBrandService as X, createConnections as Y, createDb as Z, createEmailSender as _, createOperations as a0, createSettings as a1, findUndeclaredRoutes as a2, frameworkPermissions as a3, frameworkSettings as a4, getCompanyId as a5, healthRoutes as a6, loadBrand as a7, loadConfig as a8, publicRoute as a9, requirePermission as aa, requireSession as ab, sessionMiddleware as ac, smtpSender as ad, AuthzError as f, ConnectionError as j, DEFAULT_STORAGE as p };
1166
+ export type { AppAuthz as A, Config as C, Db as D, FieldDef as F, SmtpSettings as G, HealthDeps as H, StoredFile as I, Llm as L, Operations as O, PermissionDef as P, RoleDef as R, SessionUser as S, Usage as U, AppDeps as a, AuditFn as b, Auth as c, AuthEnv as d, Authz as e, Brand as g, BrandService as h, Catalog as i, ConnectionKind as k, ConnectionSlot as l, ConnectionStatus as m, ConnectionView as n, Connections as o, Email as q, EmailSender as r, FileStorage as s, LlmCallOptions as t, LlmGetOptions as u, LoadedBrand as v, SettingDef as w, SettingType as x, SettingView as y, Settings as z };