The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.
TypeScript budget-trackercollaborativedockeritinerarymcp-serveroffline-firstopen-sourceopenstreetmappacking-listpwareal-timeself-hostedselfhostedtraveltravel-apptravel-journaltravel-plannertripitwanderlog
refactor(db): generate the Kysely table types from the migrated schema
Maurice5f17a5df5011
diff --git a/CLAUDE.md b/CLAUDE.mdindex a15100de3..22ca3ef42 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -101,7 +101,7 @@ These principles come out of a full-repo audit and shape all new code:- **Protect the crown jewels.** The client's offline-first data core (repos + mutation queue + Dexie), the out-of-process plugin sandbox, the Zod contract layer, and the auth primitives are production-grade. Extend them; never route around them or rewrite them in anger.- **No "modern shell over legacy core."** The debt pattern is a modern frame delegating to the old approach underneath (on the client: feature components calling the raw API past the offline core). New code goes all-in on the target architecture; when touching a legacy seam, migrate it rather than adding another wrapper.-- **Single source of truth over manual synchronization.** Never add a hand-mirrored copy of state, schema, or contract (server↔Dexie↔Zustand, schema↔SQL, the plugin contract). Derive from one source, or guard the copy with a parity test that cannot silently skip — the server entities are the precedent: `npm run gen:entities`/`check:entities --workspace=server` (`server/scripts/generate-entities.ts`) regenerate them from the live migrated schema instead of hand-editing, and a parity test (PARITY-009) pins entity-vs-DB drift (delete rules, index names) at zero skips.+- **Single source of truth over manual synchronization.** Never add a hand-mirrored copy of state, schema, or contract (server↔Dexie↔Zustand, schema↔SQL, the plugin contract). Derive from one source, or guard the copy with a parity test that cannot silently skip — the server entities are the precedent: `npm run gen:entities`/`check:entities --workspace=server` (`server/scripts/generate-entities.ts`) regenerate them from the live migrated schema instead of hand-editing, and a parity test (PARITY-009) pins entity-vs-DB drift (delete rules, index names) at zero skips. The Kysely table types the repositories query through are generated the same way (`gen:db-types`/`check:db-types`, `server/scripts/generate-db-types.ts`).- **DI over global mutable module state.** New server code injects its dependencies; new client code avoids `window`-global buses and mutable module state.- **Use the runtime's native idioms.** Prefer React 19 features (`useOptimistic`, Actions, `use()`/Suspense) and Nest subsystems (providers, pipes, guards, `@nestjs/schedule`) over hand-rolled equivalents.- **Fail closed, gates stay on.** Security switches default to safe; misconfiguration must refuse, not degrade. Never lower a quality gate to land a change — no new `any`, no new `eslint-disable`, no downgrading rules to `warn`, no lowered coverage thresholds.diff --git a/server/CLAUDE.md b/server/CLAUDE.mdindex b342b42f0..b313668dd 100644--- a/server/CLAUDE.md+++ b/server/CLAUDE.md@@ -15,6 +15,8 @@ npm run test # vitest run; also test:unit / test:integration / testnpm run test:coverage # istanbul coverage; per-domain ratchet over src/nest/**npm run gen:plugin-facts # regenerate the plugin-protocol tables into plugin-sdk/ + shared/npm run check:plugin-facts # CI gate — fails if the generated copies drifted+npm run gen:db-types # regenerate the Kysely table types in src/db/kysely/ from the migrated schema+npm run check:db-types # CI gate: fails when src/db/kysely/ no longer matches the migrationsnode scripts/coverage-thresholds.mjs # after test:coverage — prints the ratchet block for vitest.config.tsnpm run db:call-graph -- --sync --tx [--domains nest/days,…] # sync DB-touching methods + transaction sites (exit 1 if any)npm run lint:size # no file in src/ or scripts/ past 1000 lines, longer ones only shrink (CI gate)@@ -42,7 +44,7 @@ Nest owns everything. Every domain is a DI module under `src/nest/<domain>/` (`c- **Scheduling**: `src/nest/scheduling/` (`CronRegistrarService`) is the one way to schedule a cron. Jobs are `*.job.ts` providers in their owning domain. The registrar refuses to schedule under `NODE_ENV=test` (an integration test pins it). **Never use a `@Cron` decorator** — it bypasses that gate.- **Plugins** (`src/nest/plugins/`): the child-process runtime (`supervisor/`, `runtime/plugin-host-entry.ts`, `protocol/envelope.ts`) is **intentionally not Nest** — it is the security boundary. `host/rpc-host.ts` registers an RPC method at spawn only if the plugin holds the unlocking permission (registration = authorization). Install-time gates live in `install/`; the manifest's `trek` version range fails closed, and `TREK_PLUGINS_IGNORE_TREK_RANGE` downgrades that to a warning. The protocol tables in `protocol/envelope.ts` (+ `src/plugin-event-sink.ts`) are **generated** into `plugin-sdk/` and `shared/` — run `gen:plugin-facts` after touching them and commit the output. `runtime/egress-policy.ts` is a hand-kept mirror guarded by a parity test in `plugin-sdk/`; change both sides together.- **Storage**: `src/nest/storage/` is the upload driver abstraction (local / S3 / mirror behind one interface, with an admin surface and a usage job). Domain services never touch the filesystem or the S3 SDK directly.-- **DB** (`src/db/`): `better-sqlite3`, WAL, FK on. `database.ts` only holds the connection and applies pragmas. It does not build a schema, and importing it opens nothing (the first reader does). The connection's lifecycle belongs to the `DatabaseLifecycle` provider (`nest/database/database-lifecycle.service.ts`): `buildApp()` opens it through `open()` (which binds the ORM to later swaps and runs the schema bootstrap below), the shutdown closes it through `close()`, and a restore or the demo reset swaps the file only through the database backup port, `DATABASE_BACKUP` (`nest/database/database-backup.interface.ts`; the SQLite implementation is `nest/backup/sqlite-database-backup.ts`: `VACUUM INTO` snapshot, close, atomic file swap, `reopen()`). The port works on `DatabaseLifecycle.file`, the one resolved path (`TREK_DB_FILE` or `data/travel.db`), and a snapshot that fails fails the backup rather than archiving the live file. `MaintenanceRepository` is provided only by `MaintenanceModule`'s factory and injected everywhere else; no consumer constructs it. A provider that has to follow every reopen (the demo reset job saves the first demo baseline after a restore's re-bootstrap seeded the example trips) registers with `DatabaseLifecycle.onReopened()`, which runs after the reopen's schema bootstrap; a listener contains its own failures, since one that throws fails the reopen. MikroORM's migrations (`db/migrations/`) are the only schema source, **including for tests**: the hand-kept `schema.ts`/`migrations.ts`/`seeds.ts` builders and the parity test that guarded them are gone. Seeding is the MikroORM seeders in `db/seeders/`, applied by `db/orm.ts` from `buildApp()` before anything reads. An install the retired positional runner migrated (a `schema_version` row, no `mikro_orm_migrations` rows) is baselined by `db/legacy-baseline.ts`: the migrations whose `Legacy migration step N` docstring is ≤ its version are recorded as executed (never replayed) in the same transaction as the migrator run, while the baseline migration itself still runs first, as the legacy runner's `createTables()` did on every boot; anything it cannot map refuses the boot. Before a boot applies pending migrations to a file database that holds anything, `db/pre-migrate-snapshot.ts` writes a `VACUUM INTO` copy next to it (`pre-migrate-<schema>-<time>.db`, `<schema>` being `legacy-<schema_version>` or the last recorded migration's timestamp; the newest `TREK_DB_PRE_MIGRATE_SNAPSHOT_KEEP` stay) and the newer-database refusal names the matching copy; a copy that cannot be written refuses the boot unless `TREK_DB_PRE_MIGRATE_SNAPSHOT=false`. It is off under `NODE_ENV=test` unless a suite sets that variable to true, and a restore's re-bootstrap skips it (the archive is the copy). After the migrator, `db/email-case-index.ts` creates the case-insensitive unique index on `users.email` that its migration had to defer on an install holding two accounts whose emails differ only in case (flag `email_case_index_pending`). `db/orm-driver.ts` binds the ORM to that same connection instead of opening a second one — with `:memory:` under test, a second connection is a second, empty database. Every read and write goes through a repository in `db/repositories/` (each extends the shared `TrekRepository` base in `db/repositories/_shared/`, which validates the request context before delegating to MikroORM) and, for multi-statement writes, `UnitOfWork.transactional(...)` (`nest/database/unit-of-work.ts`, provided by the global `OrmModule`) — there is no `DatabaseService`/`DatabaseModule` to inject any more. Entrypoints outside an HTTP request — an MCP tool call, a plugin RPC dispatch, a WebSocket message, a cron job, boot-time seeding, a backup restore — open one explicitly with `withRequestContext()` (`nest/database/request-context.ts`), since only the pathless `mikroOrmRequestContext` middleware `buildApp()` mounts (with `@mikro-orm/nestjs`'s own `registerRequestContext` turned off in `app.module.ts`, UPLOADS-P16) forks an `EntityManager` per HTTP request. `NODE_ENV=test` ⇒ isolated `:memory:` DB per vitest worker, opened from a snapshot `tests/global-setup.ts` migrates once per run; `TREK_DB_FILE` ⇒ explicit file DB (Playwright harness).+- **DB** (`src/db/`): `better-sqlite3`, WAL, FK on. `database.ts` only holds the connection and applies pragmas. It does not build a schema, and importing it opens nothing (the first reader does). The connection's lifecycle belongs to the `DatabaseLifecycle` provider (`nest/database/database-lifecycle.service.ts`): `buildApp()` opens it through `open()` (which binds the ORM to later swaps and runs the schema bootstrap below), the shutdown closes it through `close()`, and a restore or the demo reset swaps the file only through the database backup port, `DATABASE_BACKUP` (`nest/database/database-backup.interface.ts`; the SQLite implementation is `nest/backup/sqlite-database-backup.ts`: `VACUUM INTO` snapshot, close, atomic file swap, `reopen()`). The port works on `DatabaseLifecycle.file`, the one resolved path (`TREK_DB_FILE` or `data/travel.db`), and a snapshot that fails fails the backup rather than archiving the live file. `MaintenanceRepository` is provided only by `MaintenanceModule`'s factory and injected everywhere else; no consumer constructs it. A provider that has to follow every reopen (the demo reset job saves the first demo baseline after a restore's re-bootstrap seeded the example trips) registers with `DatabaseLifecycle.onReopened()`, which runs after the reopen's schema bootstrap; a listener contains its own failures, since one that throws fails the reopen. MikroORM's migrations (`db/migrations/`) are the only schema source, **including for tests**: the hand-kept `schema.ts`/`migrations.ts`/`seeds.ts` builders and the parity test that guarded them are gone. Seeding is the MikroORM seeders in `db/seeders/`, applied by `db/orm.ts` from `buildApp()` before anything reads. An install the retired positional runner migrated (a `schema_version` row, no `mikro_orm_migrations` rows) is baselined by `db/legacy-baseline.ts`: the migrations whose `Legacy migration step N` docstring is ≤ its version are recorded as executed (never replayed) in the same transaction as the migrator run, while the baseline migration itself still runs first, as the legacy runner's `createTables()` did on every boot; anything it cannot map refuses the boot. Before a boot applies pending migrations to a file database that holds anything, `db/pre-migrate-snapshot.ts` writes a `VACUUM INTO` copy next to it (`pre-migrate-<schema>-<time>.db`, `<schema>` being `legacy-<schema_version>` or the last recorded migration's timestamp; the newest `TREK_DB_PRE_MIGRATE_SNAPSHOT_KEEP` stay) and the newer-database refusal names the matching copy; a copy that cannot be written refuses the boot unless `TREK_DB_PRE_MIGRATE_SNAPSHOT=false`. It is off under `NODE_ENV=test` unless a suite sets that variable to true, and a restore's re-bootstrap skips it (the archive is the copy). After the migrator, `db/email-case-index.ts` creates the case-insensitive unique index on `users.email` that its migration had to defer on an install holding two accounts whose emails differ only in case (flag `email_case_index_pending`). `db/orm-driver.ts` binds the ORM to that same connection instead of opening a second one — with `:memory:` under test, a second connection is a second, empty database. Kysely statements (`this.kysely<...>()`) type against `DB` from `db/kysely/db.ts`, narrowed with `Pick<DB, 'trips' | 'days'>`; those files are generated from the migrated schema by `scripts/generate-db-types.ts`, so a migration that adds or changes a column is followed by `npm run gen:db-types`, never by a hand-written table interface. Every read and write goes through a repository in `db/repositories/` (each extends the shared `TrekRepository` base in `db/repositories/_shared/`, which validates the request context before delegating to MikroORM) and, for multi-statement writes, `UnitOfWork.transactional(...)` (`nest/database/unit-of-work.ts`, provided by the global `OrmModule`) — there is no `DatabaseService`/`DatabaseModule` to inject any more. Entrypoints outside an HTTP request — an MCP tool call, a plugin RPC dispatch, a WebSocket message, a cron job, boot-time seeding, a backup restore — open one explicitly with `withRequestContext()` (`nest/database/request-context.ts`), since only the pathless `mikroOrmRequestContext` middleware `buildApp()` mounts (with `@mikro-orm/nestjs`'s own `registerRequestContext` turned off in `app.module.ts`, UPLOADS-P16) forks an `EntityManager` per HTTP request. `NODE_ENV=test` ⇒ isolated `:memory:` DB per vitest worker, opened from a snapshot `tests/global-setup.ts` migrates once per run; `TREK_DB_FILE` ⇒ explicit file DB (Playwright harness).## Rules for new codediff --git a/server/package.json b/server/package.jsonindex 9745b8b41..76eda56cd 100644--- a/server/package.json+++ b/server/package.json@@ -22,6 +22,8 @@"check:plugin-facts": "node --import tsx scripts/gen-plugin-facts.ts --check","gen:entities": "node --import tsx scripts/generate-entities.ts","check:entities": "node --import tsx scripts/generate-entities.ts --check",+ "gen:db-types": "node --import tsx scripts/generate-db-types.ts",+ "check:db-types": "node --import tsx scripts/generate-db-types.ts --check","format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"","format:check": "prettier --check \"src/**/*.ts\" \"test/**/*.ts\"","lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",diff --git a/server/scripts/generate-db-types.ts b/server/scripts/generate-db-types.tsnew file mode 100644index 000000000..71a8c2a3b--- /dev/null+++ b/server/scripts/generate-db-types.ts@@ -0,0 +1,259 @@+/**+ * Generates the Kysely database type from the migrated schema.+ *+ * Repositories that need a statement the MikroORM QueryBuilder cannot express+ * go through `this.kysely<...>()`, and Kysely types every table and column it+ * touches from the type parameter. Those parameters used to be interfaces+ * written by hand in each repository, so a migration that renamed a column or+ * made it nullable left them stale while `tsc` stayed green. This script+ * derives them instead, the same way `generate-entities.ts` derives the+ * entities: it migrates a throwaway SQLite file with the real migrations,+ * reads every table's columns back and writes+ *+ * src/db/kysely/<Table>.table.ts one interface per table+ * src/db/kysely/db.ts `DB`, the map from table name to interface+ *+ * A repository narrows it with `Pick<DB, 'trips' | 'days'>`.+ *+ * The column types describe what the driver hands back, which is the storage+ * model, not the domain one: an INTEGER flag is `number`, a timestamp is the+ * `string` it is stored as. A column an insert may leave out (an integer+ * primary key, anything with a DEFAULT, anything nullable) is+ * `InsertOptional<T>`, declared in the generated `columns.ts`.+ *+ * Usage:+ * node --import tsx scripts/generate-db-types.ts # rewrite src/db/kysely/+ * node --import tsx scripts/generate-db-types.ts --check # exit 1 when src/db/kysely/ drifted (CI)+ */++import fs from 'node:fs';+import path from 'node:path';++import Database from 'better-sqlite3';++import { migrateTempDb, tempDbPath } from './generate-entities';++const SERVER_ROOT = path.join(__dirname, '..');+export const KYSELY_DIR = path.join(SERVER_ROOT, 'src/db/kysely');++/** Tables the application never queries: the migrator's own bookkeeping. */+const SKIPPED_TABLES: ReadonlySet<string> = new Set(['mikro_orm_migrations']);++const HEADER = '// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:\n' ++ '// change the migration, then run `npm run gen:db-types`.\n';++export interface ColumnInfo {+ name: string;+ /** The declared type as `PRAGMA table_xinfo` reports it (may be empty). */+ type: string;+ notnull: boolean;+ hasDefault: boolean;+ /** Position in the primary key, 0 when the column is not part of it. */+ pk: number;+ /** 0 for an ordinary column, 2 or 3 for a generated (computed) one. */+ hidden: number;+}++export interface TableInfo {+ name: string;+ columns: ColumnInfo[];+}++/**+ * The TypeScript type a value of this declared type comes back as from+ * better-sqlite3, following SQLite's affinity rules (sqlite.org/datatype3.html+ * section 3.1). Date-like declarations have NUMERIC affinity on paper, but+ * every one of them in this schema holds ISO text, so they read as strings.+ */+export function tsTypeFor(declared: string): string {+ const t = declared.toUpperCase();+ if (t.includes('INT')) return 'number';+ if (t.includes('CHAR') || t.includes('CLOB') || t.includes('TEXT')) return 'string';+ if (t.includes('BLOB')) return 'Buffer';+ if (t.includes('REAL') || t.includes('FLOA') || t.includes('DOUB')) return 'number';+ if (t.includes('DATE') || t.includes('TIME')) return 'string';+ if (t.includes('BOOL') || t.includes('NUMERIC') || t.includes('DECIMAL')) return 'number';+ if (t === '') return 'unknown';+ throw new Error(`generate-db-types: no TypeScript mapping for the declared column type "${declared}"`);+}++/** `budget_items` -> `BudgetItems`. */+export function pascalCase(table: string): string {+ return table+ .split('_')+ .filter((part) => part !== '')+ .map((part) => part[0].toUpperCase() + part.slice(1))+ .join('');+}++/** The interface name for a table: `BudgetItemsTable`. */+export function interfaceName(table: string): string {+ return `${pascalCase(table)}Table`;+}++function columnType(table: TableInfo, column: ColumnInfo): string {+ // A lone INTEGER primary key aliases the rowid: it is never null and the+ // database assigns it when the insert leaves it out.+ const pkColumns = table.columns.filter((c) => c.pk > 0);+ const isRowid = column.pk > 0 && pkColumns.length === 1 && column.type.toUpperCase() === 'INTEGER';+ const base = tsTypeFor(column.type);+ const nullable = !column.notnull && column.pk === 0;+ const value = nullable ? `${base} | null` : base;+ if (column.hidden === 2 || column.hidden === 3) return `GeneratedAlways<${value}>`;+ if (isRowid || column.hasDefault || nullable) return `InsertOptional<${value}>`;+ return value;+}++const IDENTIFIER = /^[A-Za-z_$][A-Za-z0-9_$]*$/;++function propertyKey(name: string): string {+ return IDENTIFIER.test(name) ? name : `'${name.replace(/'/g, "\\'")}'`;+}++/** The source of `<Table>.table.ts`. */+export function renderTable(table: TableInfo): string {+ const types = table.columns.map((c) => columnType(table, c));+ const has = (marker: string) => types.some((t) => t.startsWith(`${marker}<`));+ const imports =+ (has('GeneratedAlways') ? "import type { GeneratedAlways } from 'kysely';\n" : '') ++ (has('InsertOptional') ? "import type { InsertOptional } from './columns';\n" : '');+ const importBlock = imports === '' ? '' : `${imports}\n`;+ const body = table.columns.map((c, i) => ` ${propertyKey(c.name)}: ${types[i]};`).join('\n');+ return `${HEADER}\n${importBlock}export interface ${interfaceName(table.name)} {\n${body}\n}\n`;+}++/**+ * The source of `columns.ts`. Kysely makes a column optional on insert when its+ * insert type can be null or undefined, which it tests with `NonNullable`. The+ * server compiles without `strictNullChecks`, where `T | undefined` and+ * `T | null` collapse to `T`, so Kysely's own `Generated<T>` would still demand+ * the column. `void` survives that collapse and still refuses any other value,+ * so the insert stays typed.+ */+export function renderColumns(): string {+ return (+ `${HEADER}\nimport type { ColumnType } from 'kysely';\n\n` ++ '/** A column an insert may leave out: the database assigns it (rowid, DEFAULT) or stores NULL. */\n' ++ 'export type InsertOptional<T> = ColumnType<T, T | void, T>;\n'+ );+}++/** The source of `db.ts`. */+export function renderDb(tables: readonly TableInfo[]): string {+ const imports = tables+ .map((t) => `import type { ${interfaceName(t.name)} } from './${pascalCase(t.name)}.table';`)+ .join('\n');+ const body = tables.map((t) => ` ${propertyKey(t.name)}: ${interfaceName(t.name)};`).join('\n');+ return (+ `${HEADER}\n${imports}\n\n` ++ '/** Every table of the migrated schema. A repository narrows it: `this.kysely<Pick<DB, \'trips\'>>()`. */\n' ++ `export interface DB {\n${body}\n}\n`+ );+}++/** Reads every application table of a migrated database, sorted by name, columns in declaration order. */+export function readSchema(dbPath: string): TableInfo[] {+ const conn = new Database(dbPath, { readonly: true });+ try {+ const names = conn+ .prepare("SELECT name FROM sqlite_master WHERE type = 'table' AND name NOT LIKE 'sqlite_%' ORDER BY name")+ .all() as { name: string }[];+ return names+ .filter(({ name }) => !SKIPPED_TABLES.has(name))+ .map(({ name }) => {+ const rows = conn.prepare(`PRAGMA table_xinfo("${name.replace(/"/g, '""')}")`).all() as {+ name: string;+ type: string;+ notnull: number;+ dflt_value: string | null;+ pk: number;+ hidden: number;+ }[];+ return {+ name,+ columns: rows+ .filter((r) => r.hidden !== 1)+ .map((r) => ({+ name: r.name,+ type: r.type,+ notnull: r.notnull === 1,+ hasDefault: r.dflt_value !== null,+ pk: r.pk,+ hidden: r.hidden,+ })),+ };+ });+ } finally {+ conn.close();+ }+}++/** File name -> content for everything under src/db/kysely/. */+export function renderAll(tables: readonly TableInfo[]): Map<string, string> {+ if (tables.length === 0) {+ throw new Error('generate-db-types: the migrated schema has no tables; check the migrations path');+ }+ const files = new Map<string, string>();+ for (const table of tables) files.set(`${pascalCase(table.name)}.table.ts`, renderTable(table));+ files.set('columns.ts', renderColumns());+ files.set('db.ts', renderDb(tables));+ return files;+}++export async function generateDbTypes(): Promise<Map<string, string>> {+ const dbPath = tempDbPath();+ try {+ await migrateTempDb(dbPath);+ return renderAll(readSchema(dbPath));+ } finally {+ fs.rmSync(dbPath, { force: true });+ }+}++/** Every file that differs from, is missing from or is extra in `dir`. Read-only. */+export function checkDbTypes(dir: string, files: ReadonlyMap<string, string>): string[] {+ const drift: string[] = [];+ for (const [fileName, content] of files) {+ const onDisk = path.join(dir, fileName);+ const current = fs.existsSync(onDisk) ? fs.readFileSync(onDisk, 'utf8').replace(/\r\n/g, '\n') : undefined;+ if (current !== content) drift.push(fileName);+ }+ const onDiskFiles = fs.existsSync(dir) ? fs.readdirSync(dir).filter((f) => f.endsWith('.ts')) : [];+ for (const fileName of onDiskFiles) {+ if (!files.has(fileName)) drift.push(`${fileName} (not produced by the generator)`);+ }+ return drift.sort();+}++/** Replaces the contents of `dir` with `files`, removing any .ts file the generator no longer produces. */+export function writeDbTypes(dir: string, files: ReadonlyMap<string, string>): void {+ fs.mkdirSync(dir, { recursive: true });+ for (const fileName of fs.readdirSync(dir)) {+ if (fileName.endsWith('.ts') && !files.has(fileName)) fs.rmSync(path.join(dir, fileName));+ }+ for (const [fileName, content] of files) fs.writeFileSync(path.join(dir, fileName), content);+}++async function main(): Promise<void> {+ const check = process.argv.slice(2).includes('--check');+ const files = await generateDbTypes();+ if (check) {+ const drift = checkDbTypes(KYSELY_DIR, files);+ for (const fileName of drift) console.error(`[generate-db-types] DRIFT: src/db/kysely/${fileName}`);+ if (drift.length > 0) {+ console.error('[generate-db-types] --check failed. Run: npm run gen:db-types');+ process.exit(1);+ }+ console.log(`[generate-db-types] --check: ${files.size} files match the migrated schema`);+ return;+ }+ writeDbTypes(KYSELY_DIR, files);+ console.log(`[generate-db-types] wrote ${files.size} files to src/db/kysely/`);+}++if (require.main === module) {+ main().catch((err: unknown) => {+ console.error('[generate-db-types] failed:', err);+ process.exit(1);+ });+}diff --git a/server/scripts/generate-entities.ts b/server/scripts/generate-entities.tsindex 3528501e9..5341eb8b8 100644--- a/server/scripts/generate-entities.ts+++ b/server/scripts/generate-entities.ts@@ -1921,11 +1921,11 @@ export function applyTextPasses(source: string, fixups: RuleFixups): string {// side effect and needs nothing from those modules.// ----------------------------------------------------------------------------function tempDbPath(): string {+export function tempDbPath(): string {return path.join(os.tmpdir(), `trek-gen-entities-${crypto.randomUUID()}.db`);}-async function migrateTempDb(dbPath: string): Promise<void> {+export async function migrateTempDb(dbPath: string): Promise<void> {const orm = await SqliteMikroORM.init({entities: [],discovery: { warnWhenNoEntities: false },diff --git a/server/scripts/size-baseline.json b/server/scripts/size-baseline.jsonindex 14cf0dcd4..a4899be30 100644--- a/server/scripts/size-baseline.json+++ b/server/scripts/size-baseline.json@@ -2,10 +2,9 @@"scripts/db-call-graph.mjs": 1036,"scripts/generate-entities.ts": 2259,"src/db/dialect/sql-functions.ts": 1007,- "src/db/repositories/DayAssignments.repository.ts": 1030,- "src/db/repositories/Places.repository.ts": 1483,- "src/db/repositories/Reservations.repository.ts": 1806,- "src/db/repositories/Trips.repository.ts": 1164,+ "src/db/repositories/Places.repository.ts": 1440,+ "src/db/repositories/Reservations.repository.ts": 1676,+ "src/db/repositories/Trips.repository.ts": 1121,"src/db/repositories/Users.repository.ts": 1710,"src/nest/atlas/atlas-geo.ts": 1005,"src/nest/atlas/atlas.service.ts": 1182,diff --git a/server/src/db/kysely/Addons.table.ts b/server/src/db/kysely/Addons.table.tsnew file mode 100644index 000000000..df4438cb2--- /dev/null+++ b/server/src/db/kysely/Addons.table.ts@@ -0,0 +1,15 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface AddonsTable {+ id: string;+ name: string;+ description: InsertOptional<string | null>;+ type: InsertOptional<string>;+ icon: InsertOptional<string | null>;+ enabled: InsertOptional<number | null>;+ config: InsertOptional<string | null>;+ sort_order: InsertOptional<number | null>;+}diff --git a/server/src/db/kysely/AppSettings.table.ts b/server/src/db/kysely/AppSettings.table.tsnew file mode 100644index 000000000..d56f040fa--- /dev/null+++ b/server/src/db/kysely/AppSettings.table.ts@@ -0,0 +1,9 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface AppSettingsTable {+ key: string;+ value: InsertOptional<string | null>;+}diff --git a/server/src/db/kysely/AssignmentParticipants.table.ts b/server/src/db/kysely/AssignmentParticipants.table.tsnew file mode 100644index 000000000..7e10f9466--- /dev/null+++ b/server/src/db/kysely/AssignmentParticipants.table.ts@@ -0,0 +1,10 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface AssignmentParticipantsTable {+ id: InsertOptional<number>;+ assignment_id: number;+ user_id: number;+}diff --git a/server/src/db/kysely/AuditLog.table.ts b/server/src/db/kysely/AuditLog.table.tsnew file mode 100644index 000000000..65d7b3525--- /dev/null+++ b/server/src/db/kysely/AuditLog.table.ts@@ -0,0 +1,14 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface AuditLogTable {+ id: InsertOptional<number>;+ created_at: InsertOptional<string | null>;+ user_id: InsertOptional<number | null>;+ action: string;+ resource: InsertOptional<string | null>;+ details: InsertOptional<string | null>;+ ip: InsertOptional<string | null>;+}diff --git a/server/src/db/kysely/BucketList.table.ts b/server/src/db/kysely/BucketList.table.tsnew file mode 100644index 000000000..a03e07f05--- /dev/null+++ b/server/src/db/kysely/BucketList.table.ts@@ -0,0 +1,19 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface BucketListTable {+ id: InsertOptional<number>;+ user_id: number;+ name: string;+ lat: InsertOptional<number | null>;+ lng: InsertOptional<number | null>;+ country_code: InsertOptional<string | null>;+ notes: InsertOptional<string | null>;+ created_at: InsertOptional<string | null>;+ target_date: InsertOptional<string | null>;+ visited_at: InsertOptional<string | null>;+ visited_source: InsertOptional<string | null>;+ region_code: InsertOptional<string | null>;+}diff --git a/server/src/db/kysely/BudgetCategoryOrder.table.ts b/server/src/db/kysely/BudgetCategoryOrder.table.tsnew file mode 100644index 000000000..1bb0f4000--- /dev/null+++ b/server/src/db/kysely/BudgetCategoryOrder.table.ts@@ -0,0 +1,10 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface BudgetCategoryOrderTable {+ trip_id: number;+ category: string;+ sort_order: InsertOptional<number>;+}diff --git a/server/src/db/kysely/BudgetItemMembers.table.ts b/server/src/db/kysely/BudgetItemMembers.table.tsnew file mode 100644index 000000000..d50b77f0e--- /dev/null+++ b/server/src/db/kysely/BudgetItemMembers.table.ts@@ -0,0 +1,12 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface BudgetItemMembersTable {+ id: InsertOptional<number>;+ budget_item_id: number;+ user_id: number;+ paid: InsertOptional<number>;+ amount: InsertOptional<number | null>;+}diff --git a/server/src/db/kysely/BudgetItemPayers.table.ts b/server/src/db/kysely/BudgetItemPayers.table.tsnew file mode 100644index 000000000..ce0128708--- /dev/null+++ b/server/src/db/kysely/BudgetItemPayers.table.ts@@ -0,0 +1,11 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface BudgetItemPayersTable {+ id: InsertOptional<number>;+ budget_item_id: number;+ user_id: number;+ amount: InsertOptional<number>;+}diff --git a/server/src/db/kysely/BudgetItems.table.ts b/server/src/db/kysely/BudgetItems.table.tsnew file mode 100644index 000000000..34d595e3c--- /dev/null+++ b/server/src/db/kysely/BudgetItems.table.ts@@ -0,0 +1,24 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface BudgetItemsTable {+ id: InsertOptional<number>;+ trip_id: number;+ category: InsertOptional<string>;+ name: string;+ total_price: InsertOptional<number>;+ persons: InsertOptional<number | null>;+ days: InsertOptional<number | null>;+ note: InsertOptional<string | null>;+ sort_order: InsertOptional<number | null>;+ created_at: InsertOptional<string | null>;+ paid_by_user_id: InsertOptional<number | null>;+ expense_date: InsertOptional<string | null>;+ reservation_id: InsertOptional<number | null>;+ currency: InsertOptional<string | null>;+ exchange_rate: InsertOptional<number>;+ ticket_json: InsertOptional<string | null>;+ place_id: InsertOptional<number | null>;+}diff --git a/server/src/db/kysely/BudgetSettlements.table.ts b/server/src/db/kysely/BudgetSettlements.table.tsnew file mode 100644index 000000000..15cc0c32b--- /dev/null+++ b/server/src/db/kysely/BudgetSettlements.table.ts@@ -0,0 +1,18 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface BudgetSettlementsTable {+ id: InsertOptional<number>;+ trip_id: number;+ from_user_id: number;+ to_user_id: number;+ amount: InsertOptional<number>;+ created_at: InsertOptional<string | null>;+ created_by_user_id: InsertOptional<number | null>;+ currency: InsertOptional<string | null>;+ exchange_rate: InsertOptional<number>;+ settled_at: InsertOptional<string | null>;+ note: InsertOptional<string | null>;+}diff --git a/server/src/db/kysely/Categories.table.ts b/server/src/db/kysely/Categories.table.tsnew file mode 100644index 000000000..eb6fd89b4--- /dev/null+++ b/server/src/db/kysely/Categories.table.ts@@ -0,0 +1,13 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface CategoriesTable {+ id: InsertOptional<number>;+ name: string;+ color: InsertOptional<string | null>;+ icon: InsertOptional<string | null>;+ user_id: InsertOptional<number | null>;+ created_at: InsertOptional<string | null>;+}diff --git a/server/src/db/kysely/CollabLinks.table.ts b/server/src/db/kysely/CollabLinks.table.tsnew file mode 100644index 000000000..23cfd6c92--- /dev/null+++ b/server/src/db/kysely/CollabLinks.table.ts@@ -0,0 +1,15 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface CollabLinksTable {+ id: InsertOptional<number>;+ trip_id: number;+ user_id: number;+ title: string;+ url: string;+ pinned: InsertOptional<number | null>;+ created_at: InsertOptional<string | null>;+ updated_at: InsertOptional<string | null>;+}diff --git a/server/src/db/kysely/CollabMessageReactions.table.ts b/server/src/db/kysely/CollabMessageReactions.table.tsnew file mode 100644index 000000000..fc3f89cbb--- /dev/null+++ b/server/src/db/kysely/CollabMessageReactions.table.ts@@ -0,0 +1,12 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface CollabMessageReactionsTable {+ id: InsertOptional<number>;+ message_id: number;+ user_id: number;+ emoji: string;+ created_at: InsertOptional<string | null>;+}diff --git a/server/src/db/kysely/CollabMessages.table.ts b/server/src/db/kysely/CollabMessages.table.tsnew file mode 100644index 000000000..65625bd93--- /dev/null+++ b/server/src/db/kysely/CollabMessages.table.ts@@ -0,0 +1,14 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface CollabMessagesTable {+ id: InsertOptional<number>;+ trip_id: number;+ user_id: number;+ text: string;+ reply_to: InsertOptional<number | null>;+ created_at: InsertOptional<string | null>;+ deleted: InsertOptional<number | null>;+}diff --git a/server/src/db/kysely/CollabNotes.table.ts b/server/src/db/kysely/CollabNotes.table.tsnew file mode 100644index 000000000..e460e182b--- /dev/null+++ b/server/src/db/kysely/CollabNotes.table.ts@@ -0,0 +1,18 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface CollabNotesTable {+ id: InsertOptional<number>;+ trip_id: number;+ user_id: number;+ category: InsertOptional<string | null>;+ title: string;+ content: InsertOptional<string | null>;+ color: InsertOptional<string | null>;+ pinned: InsertOptional<number | null>;+ created_at: InsertOptional<string | null>;+ updated_at: InsertOptional<string | null>;+ website: InsertOptional<string | null>;+}diff --git a/server/src/db/kysely/CollabPollVotes.table.ts b/server/src/db/kysely/CollabPollVotes.table.tsnew file mode 100644index 000000000..42dc6c2a0--- /dev/null+++ b/server/src/db/kysely/CollabPollVotes.table.ts@@ -0,0 +1,12 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface CollabPollVotesTable {+ id: InsertOptional<number>;+ poll_id: number;+ user_id: number;+ option_index: number;+ created_at: InsertOptional<string | null>;+}diff --git a/server/src/db/kysely/CollabPolls.table.ts b/server/src/db/kysely/CollabPolls.table.tsnew file mode 100644index 000000000..03f43bdd2--- /dev/null+++ b/server/src/db/kysely/CollabPolls.table.ts@@ -0,0 +1,16 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface CollabPollsTable {+ id: InsertOptional<number>;+ trip_id: number;+ user_id: number;+ question: string;+ options: string;+ multiple: InsertOptional<number | null>;+ closed: InsertOptional<number | null>;+ deadline: InsertOptional<string | null>;+ created_at: InsertOptional<string | null>;+}diff --git a/server/src/db/kysely/CollectionLabels.table.ts b/server/src/db/kysely/CollectionLabels.table.tsnew file mode 100644index 000000000..14af8f7cf--- /dev/null+++ b/server/src/db/kysely/CollectionLabels.table.ts@@ -0,0 +1,13 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface CollectionLabelsTable {+ id: InsertOptional<number>;+ collection_id: number;+ name: string;+ color: InsertOptional<string | null>;+ sort_order: InsertOptional<number | null>;+ created_at: InsertOptional<string | null>;+}diff --git a/server/src/db/kysely/CollectionMembers.table.ts b/server/src/db/kysely/CollectionMembers.table.tsnew file mode 100644index 000000000..0ff59e68c--- /dev/null+++ b/server/src/db/kysely/CollectionMembers.table.ts@@ -0,0 +1,13 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface CollectionMembersTable {+ id: InsertOptional<number>;+ collection_id: number;+ user_id: number;+ status: InsertOptional<string>;+ role: InsertOptional<string>;+ created_at: InsertOptional<string | null>;+}diff --git a/server/src/db/kysely/CollectionPlaceLabels.table.ts b/server/src/db/kysely/CollectionPlaceLabels.table.tsnew file mode 100644index 000000000..b8451b3f9--- /dev/null+++ b/server/src/db/kysely/CollectionPlaceLabels.table.ts@@ -0,0 +1,7 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++export interface CollectionPlaceLabelsTable {+ collection_place_id: number;+ label_id: number;+}diff --git a/server/src/db/kysely/CollectionPlaceRatings.table.ts b/server/src/db/kysely/CollectionPlaceRatings.table.tsnew file mode 100644index 000000000..1ba572197--- /dev/null+++ b/server/src/db/kysely/CollectionPlaceRatings.table.ts@@ -0,0 +1,12 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface CollectionPlaceRatingsTable {+ id: InsertOptional<number>;+ collection_place_id: number;+ user_id: number;+ rating: number;+ created_at: InsertOptional<string | null>;+}diff --git a/server/src/db/kysely/CollectionPlaceTags.table.ts b/server/src/db/kysely/CollectionPlaceTags.table.tsnew file mode 100644index 000000000..24ea0cdf9--- /dev/null+++ b/server/src/db/kysely/CollectionPlaceTags.table.ts@@ -0,0 +1,7 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++export interface CollectionPlaceTagsTable {+ collection_place_id: number;+ tag_id: number;+}diff --git a/server/src/db/kysely/CollectionPlaces.table.ts b/server/src/db/kysely/CollectionPlaces.table.tsnew file mode 100644index 000000000..c5bf24028--- /dev/null+++ b/server/src/db/kysely/CollectionPlaces.table.ts@@ -0,0 +1,33 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface CollectionPlacesTable {+ id: InsertOptional<number>;+ collection_id: number;+ owner_id: number;+ saved_by: InsertOptional<number | null>;+ name: string;+ description: InsertOptional<string | null>;+ lat: InsertOptional<number | null>;+ lng: InsertOptional<number | null>;+ address: InsertOptional<string | null>;+ category_id: InsertOptional<number | null>;+ price: InsertOptional<number | null>;+ currency: InsertOptional<string | null>;+ notes: InsertOptional<string | null>;+ image_url: InsertOptional<string | null>;+ google_place_id: InsertOptional<string | null>;+ google_ftid: InsertOptional<string | null>;+ osm_id: InsertOptional<string | null>;+ website: InsertOptional<string | null>;+ phone: InsertOptional<string | null>;+ status: InsertOptional<string>;+ source_trip_id: InsertOptional<number | null>;+ source_place_id: InsertOptional<number | null>;+ links: InsertOptional<string | null>;+ sort_order: InsertOptional<number | null>;+ created_at: InsertOptional<string | null>;+ updated_at: InsertOptional<string | null>;+}diff --git a/server/src/db/kysely/Collections.table.ts b/server/src/db/kysely/Collections.table.tsnew file mode 100644index 000000000..5fa248efd--- /dev/null+++ b/server/src/db/kysely/Collections.table.ts@@ -0,0 +1,18 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface CollectionsTable {+ id: InsertOptional<number>;+ owner_id: number;+ name: string;+ description: InsertOptional<string | null>;+ color: InsertOptional<string | null>;+ icon: InsertOptional<string | null>;+ cover_image: InsertOptional<string | null>;+ links: InsertOptional<string | null>;+ sort_order: InsertOptional<number | null>;+ created_at: InsertOptional<string | null>;+ updated_at: InsertOptional<string | null>;+}diff --git a/server/src/db/kysely/DawarichConnections.table.ts b/server/src/db/kysely/DawarichConnections.table.tsnew file mode 100644index 000000000..25918b623--- /dev/null+++ b/server/src/db/kysely/DawarichConnections.table.ts@@ -0,0 +1,18 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface DawarichConnectionsTable {+ user_id: InsertOptional<number>;+ url: InsertOptional<string | null>;+ api_key: InsertOptional<string | null>;+ allow_insecure_tls: InsertOptional<number>;+ sync_enabled: InsertOptional<number>;+ last_sync_at: InsertOptional<string | null>;+ last_sync_state: InsertOptional<string>;+ last_sync_error: InsertOptional<string | null>;+ capabilities: InsertOptional<string | null>;+ created_at: InsertOptional<string | null>;+ updated_at: InsertOptional<string | null>;+}diff --git a/server/src/db/kysely/DawarichVisitSuggestions.table.ts b/server/src/db/kysely/DawarichVisitSuggestions.table.tsnew file mode 100644index 000000000..dea3506f0--- /dev/null+++ b/server/src/db/kysely/DawarichVisitSuggestions.table.ts@@ -0,0 +1,33 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface DawarichVisitSuggestionsTable {+ id: InsertOptional<number>;+ user_id: number;+ source_visit_id: string;+ trip_id: InsertOptional<number | null>;+ name: string;+ lat: InsertOptional<number | null>;+ lng: InsertOptional<number | null>;+ started_at: string;+ ended_at: string;+ duration_minutes: InsertOptional<number>;+ local_date: string;+ source_status: InsertOptional<string>;+ confidence: InsertOptional<number | null>;+ confidence_band: InsertOptional<string | null>;+ country_code: InsertOptional<string | null>;+ state: InsertOptional<string>;+ target: InsertOptional<string | null>;+ accepted_place_id: InsertOptional<number | null>;+ accepted_journal_entry_id: InsertOptional<number | null>;+ accepted_bucket_list_item_id: InsertOptional<number | null>;+ matched_bucket_list_item_id: InsertOptional<number | null>;+ source_hash: string;+ accepted_hash: InsertOptional<string | null>;+ source_missing_at: InsertOptional<string | null>;+ first_seen_at: InsertOptional<string>;+ last_seen_at: InsertOptional<string>;+}diff --git a/server/src/db/kysely/DayAccommodations.table.ts b/server/src/db/kysely/DayAccommodations.table.tsnew file mode 100644index 000000000..4e1de741a--- /dev/null+++ b/server/src/db/kysely/DayAccommodations.table.ts@@ -0,0 +1,18 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface DayAccommodationsTable {+ id: InsertOptional<number>;+ trip_id: number;+ place_id: InsertOptional<number | null>;+ start_day_id: number;+ end_day_id: number;+ check_in: InsertOptional<string | null>;+ check_in_end: InsertOptional<string | null>;+ check_out: InsertOptional<string | null>;+ confirmation: InsertOptional<string | null>;+ notes: InsertOptional<string | null>;+ created_at: InsertOptional<string | null>;+}diff --git a/server/src/db/kysely/DayAssignments.table.ts b/server/src/db/kysely/DayAssignments.table.tsnew file mode 100644index 000000000..c94e1c30a--- /dev/null+++ b/server/src/db/kysely/DayAssignments.table.ts@@ -0,0 +1,23 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface DayAssignmentsTable {+ id: InsertOptional<number>;+ day_id: number;+ place_id: number;+ order_index: InsertOptional<number | null>;+ notes: InsertOptional<string | null>;+ reservation_status: InsertOptional<string | null>;+ reservation_notes: InsertOptional<string | null>;+ reservation_datetime: InsertOptional<string | null>;+ created_at: InsertOptional<string | null>;+ assignment_time: InsertOptional<string | null>;+ assignment_end_time: InsertOptional<string | null>;+ leg_transport_mode: InsertOptional<string | null>;+ incoming_leg_transport_mode: InsertOptional<string | null>;+ end_day: InsertOptional<number>;+ accommodation_id: InsertOptional<number | null>;+ route_excluded: InsertOptional<number>;+}diff --git a/server/src/db/kysely/DayNotes.table.ts b/server/src/db/kysely/DayNotes.table.tsnew file mode 100644index 000000000..b21dd6562--- /dev/null+++ b/server/src/db/kysely/DayNotes.table.ts@@ -0,0 +1,16 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface DayNotesTable {+ id: InsertOptional<number>;+ day_id: number;+ trip_id: number;+ text: string;+ time: InsertOptional<string | null>;+ icon: InsertOptional<string | null>;+ sort_order: InsertOptional<number | null>;+ created_at: InsertOptional<string | null>;+ color: InsertOptional<string | null>;+}diff --git a/server/src/db/kysely/Days.table.ts b/server/src/db/kysely/Days.table.tsnew file mode 100644index 000000000..63463d3e8--- /dev/null+++ b/server/src/db/kysely/Days.table.ts@@ -0,0 +1,14 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface DaysTable {+ id: InsertOptional<number>;+ trip_id: number;+ day_number: number;+ date: InsertOptional<string | null>;+ notes: InsertOptional<string | null>;+ title: InsertOptional<string | null>;+ default_transport_mode: InsertOptional<string | null>;+}diff --git a/server/src/db/kysely/DocumentConnections.table.ts b/server/src/db/kysely/DocumentConnections.table.tsnew file mode 100644index 000000000..4e59a03be--- /dev/null+++ b/server/src/db/kysely/DocumentConnections.table.ts@@ -0,0 +1,21 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface DocumentConnectionsTable {+ id: InsertOptional<number>;+ trip_id: number;+ provider_id: string;+ owner_user_id: number;+ base_url: string;+ secrets: InsertOptional<string | null>;+ settings: InsertOptional<string>;+ allow_insecure_tls: InsertOptional<number>;+ capabilities: InsertOptional<string | null>;+ last_probe_at: InsertOptional<string | null>;+ last_probe_state: InsertOptional<string>;+ last_probe_error: InsertOptional<string | null>;+ created_at: InsertOptional<string | null>;+ updated_at: InsertOptional<string | null>;+}diff --git a/server/src/db/kysely/DocumentProviderFields.table.ts b/server/src/db/kysely/DocumentProviderFields.table.tsnew file mode 100644index 000000000..36e2b1f21--- /dev/null+++ b/server/src/db/kysely/DocumentProviderFields.table.ts@@ -0,0 +1,17 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface DocumentProviderFieldsTable {+ id: InsertOptional<number>;+ provider_id: string;+ field_key: string;+ label: string;+ input_type: InsertOptional<string>;+ placeholder: InsertOptional<string | null>;+ hint: InsertOptional<string | null>;+ required: InsertOptional<number | null>;+ secret: InsertOptional<number | null>;+ sort_order: InsertOptional<number | null>;+}diff --git a/server/src/db/kysely/DocumentProviders.table.ts b/server/src/db/kysely/DocumentProviders.table.tsnew file mode 100644index 000000000..881118192--- /dev/null+++ b/server/src/db/kysely/DocumentProviders.table.ts@@ -0,0 +1,13 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface DocumentProvidersTable {+ id: string;+ name: string;+ description: InsertOptional<string | null>;+ icon: InsertOptional<string | null>;+ enabled: InsertOptional<number | null>;+ sort_order: InsertOptional<number | null>;+}diff --git a/server/src/db/kysely/DocumentSyncItems.table.ts b/server/src/db/kysely/DocumentSyncItems.table.tsnew file mode 100644index 000000000..c225686d4--- /dev/null+++ b/server/src/db/kysely/DocumentSyncItems.table.ts@@ -0,0 +1,28 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface DocumentSyncItemsTable {+ id: InsertOptional<number>;+ link_id: number;+ trip_id: number;+ file_id: InsertOptional<number | null>;+ trek_doc_uid: string;+ remote_id: InsertOptional<string | null>;+ remote_name: InsertOptional<string | null>;+ remote_version: InsertOptional<string | null>;+ remote_size: InsertOptional<number | null>;+ remote_modified_at: InsertOptional<string | null>;+ content_sha256: InsertOptional<string | null>;+ pushed_sha256: InsertOptional<string | null>;+ state: InsertOptional<string>;+ error_code: InsertOptional<string | null>;+ attempts: InsertOptional<number>;+ next_attempt_at: InsertOptional<string | null>;+ remote_missing_at: InsertOptional<string | null>;+ first_seen_at: InsertOptional<string>;+ last_seen_at: InsertOptional<string>;+ synced_at: InsertOptional<string | null>;+ remote_trashed_at: InsertOptional<string | null>;+}diff --git a/server/src/db/kysely/FileLinks.table.ts b/server/src/db/kysely/FileLinks.table.tsnew file mode 100644index 000000000..e3ccefc58--- /dev/null+++ b/server/src/db/kysely/FileLinks.table.ts@@ -0,0 +1,14 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface FileLinksTable {+ id: InsertOptional<number>;+ file_id: number;+ reservation_id: InsertOptional<number | null>;+ assignment_id: InsertOptional<number | null>;+ place_id: InsertOptional<number | null>;+ created_at: InsertOptional<string | null>;+ budget_item_id: InsertOptional<number | null>;+}diff --git a/server/src/db/kysely/GoogleApiUsage.table.ts b/server/src/db/kysely/GoogleApiUsage.table.tsnew file mode 100644index 000000000..5ead69264--- /dev/null+++ b/server/src/db/kysely/GoogleApiUsage.table.ts@@ -0,0 +1,9 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface GoogleApiUsageTable {+ day: string;+ calls: InsertOptional<number>;+}diff --git a/server/src/db/kysely/GooglePlacePhotoMeta.table.ts b/server/src/db/kysely/GooglePlacePhotoMeta.table.tsnew file mode 100644index 000000000..64ed515e2--- /dev/null+++ b/server/src/db/kysely/GooglePlacePhotoMeta.table.ts@@ -0,0 +1,11 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface GooglePlacePhotoMetaTable {+ place_id: string;+ attribution: InsertOptional<string | null>;+ fetched_at: number;+ error_at: InsertOptional<number | null>;+}diff --git a/server/src/db/kysely/HiddenCountries.table.ts b/server/src/db/kysely/HiddenCountries.table.tsnew file mode 100644index 000000000..554ed4a08--- /dev/null+++ b/server/src/db/kysely/HiddenCountries.table.ts@@ -0,0 +1,11 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface HiddenCountriesTable {+ id: InsertOptional<number>;+ user_id: number;+ country_code: string;+ created_at: InsertOptional<string | null>;+}diff --git a/server/src/db/kysely/HiddenRegions.table.ts b/server/src/db/kysely/HiddenRegions.table.tsnew file mode 100644index 000000000..fa3756261--- /dev/null+++ b/server/src/db/kysely/HiddenRegions.table.ts@@ -0,0 +1,12 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface HiddenRegionsTable {+ id: InsertOptional<number>;+ user_id: number;+ region_code: string;+ country_code: string;+ created_at: InsertOptional<string | null>;+}diff --git a/server/src/db/kysely/IdempotencyKeys.table.ts b/server/src/db/kysely/IdempotencyKeys.table.tsnew file mode 100644index 000000000..2d037491a--- /dev/null+++ b/server/src/db/kysely/IdempotencyKeys.table.ts@@ -0,0 +1,14 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface IdempotencyKeysTable {+ key: string;+ user_id: number;+ method: string;+ path: string;+ status_code: number;+ response_body: string;+ created_at: InsertOptional<number>;+}diff --git a/server/src/db/kysely/InviteTokens.table.ts b/server/src/db/kysely/InviteTokens.table.tsnew file mode 100644index 000000000..81a86d9f3--- /dev/null+++ b/server/src/db/kysely/InviteTokens.table.ts@@ -0,0 +1,15 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface InviteTokensTable {+ id: InsertOptional<number>;+ token: string;+ max_uses: InsertOptional<number>;+ used_count: InsertOptional<number>;+ expires_at: InsertOptional<string | null>;+ created_by: number;+ created_at: InsertOptional<string | null>;+ trip_id: InsertOptional<number | null>;+}diff --git a/server/src/db/kysely/JourneyBooks.table.ts b/server/src/db/kysely/JourneyBooks.table.tsnew file mode 100644index 000000000..f4fb66857--- /dev/null+++ b/server/src/db/kysely/JourneyBooks.table.ts@@ -0,0 +1,16 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface JourneyBooksTable {+ id: InsertOptional<number>;+ journey_id: number;+ title: InsertOptional<string>;+ document: string;+ version: InsertOptional<number>;+ created_by: InsertOptional<number | null>;+ updated_by: InsertOptional<number | null>;+ created_at: InsertOptional<string | null>;+ updated_at: InsertOptional<string | null>;+}diff --git a/server/src/db/kysely/JourneyContributors.table.ts b/server/src/db/kysely/JourneyContributors.table.tsnew file mode 100644index 000000000..085a1d184--- /dev/null+++ b/server/src/db/kysely/JourneyContributors.table.ts@@ -0,0 +1,12 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface JourneyContributorsTable {+ journey_id: number;+ user_id: number;+ role: string;+ added_at: number;+ hide_skeletons: InsertOptional<number>;+}diff --git a/server/src/db/kysely/JourneyEntries.table.ts b/server/src/db/kysely/JourneyEntries.table.tsnew file mode 100644index 000000000..e7fac7cb7--- /dev/null+++ b/server/src/db/kysely/JourneyEntries.table.ts@@ -0,0 +1,33 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface JourneyEntriesTable {+ id: InsertOptional<number>;+ journey_id: number;+ source_trip_id: InsertOptional<number | null>;+ source_place_id: InsertOptional<number | null>;+ author_id: number;+ type: string;+ title: InsertOptional<string | null>;+ story: InsertOptional<string | null>;+ entry_date: string;+ entry_time: InsertOptional<string | null>;+ location_name: InsertOptional<string | null>;+ location_lat: InsertOptional<number | null>;+ location_lng: InsertOptional<number | null>;+ mood: InsertOptional<string | null>;+ weather: InsertOptional<string | null>;+ tags: InsertOptional<string | null>;+ visibility: InsertOptional<string | null>;+ sort_order: InsertOptional<number | null>;+ created_at: number;+ updated_at: number;+ pros_cons: InsertOptional<string | null>;+ stats_excluded: InsertOptional<number>;+ dismissed: InsertOptional<number>;+ country_code: InsertOptional<string | null>;+ source_assignment_id: InsertOptional<number | null>;+ is_draft: InsertOptional<number>;+}diff --git a/server/src/db/kysely/JourneyEntryPhotos.table.ts b/server/src/db/kysely/JourneyEntryPhotos.table.tsnew file mode 100644index 000000000..e3674d6fd--- /dev/null+++ b/server/src/db/kysely/JourneyEntryPhotos.table.ts@@ -0,0 +1,11 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface JourneyEntryPhotosTable {+ entry_id: number;+ journey_photo_id: number;+ sort_order: InsertOptional<number | null>;+ created_at: number;+}diff --git a/server/src/db/kysely/JourneyPhotos.table.ts b/server/src/db/kysely/JourneyPhotos.table.tsnew file mode 100644index 000000000..a1a79ed27--- /dev/null+++ b/server/src/db/kysely/JourneyPhotos.table.ts@@ -0,0 +1,17 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface JourneyPhotosTable {+ id: InsertOptional<number>;+ journey_id: number;+ photo_id: number;+ caption: InsertOptional<string | null>;+ shared: InsertOptional<number | null>;+ sort_order: InsertOptional<number | null>;+ provider: InsertOptional<string | null>;+ asset_id: InsertOptional<string | null>;+ owner_id: InsertOptional<number | null>;+ created_at: number;+}diff --git a/server/src/db/kysely/JourneyShareTokens.table.ts b/server/src/db/kysely/JourneyShareTokens.table.tsnew file mode 100644index 000000000..45f7cca01--- /dev/null+++ b/server/src/db/kysely/JourneyShareTokens.table.ts@@ -0,0 +1,16 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface JourneyShareTokensTable {+ id: InsertOptional<number>;+ journey_id: number;+ token: string;+ created_by: number;+ share_timeline: InsertOptional<number | null>;+ share_gallery: InsertOptional<number | null>;+ share_map: InsertOptional<number | null>;+ created_at: InsertOptional<string | null>;+ newest_first: InsertOptional<number>;+}diff --git a/server/src/db/kysely/JourneyTrips.table.ts b/server/src/db/kysely/JourneyTrips.table.tsnew file mode 100644index 000000000..a4be28476--- /dev/null+++ b/server/src/db/kysely/JourneyTrips.table.ts@@ -0,0 +1,8 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++export interface JourneyTripsTable {+ journey_id: number;+ trip_id: number;+ added_at: number;+}diff --git a/server/src/db/kysely/Journeys.table.ts b/server/src/db/kysely/Journeys.table.tsnew file mode 100644index 000000000..d1572982e--- /dev/null+++ b/server/src/db/kysely/Journeys.table.ts@@ -0,0 +1,22 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface JourneysTable {+ id: InsertOptional<number>;+ user_id: number;+ title: string;+ subtitle: InsertOptional<string | null>;+ cover_gradient: InsertOptional<string | null>;+ status: InsertOptional<string | null>;+ created_at: number;+ updated_at: number;+ cover_image: InsertOptional<string | null>;+ show_trip_tracks: InsertOptional<number>;+ show_verdict: InsertOptional<number>;+ show_mood: InsertOptional<number>;+ show_weather: InsertOptional<number>;+ status_override: InsertOptional<string | null>;+ photo_location: InsertOptional<number>;+}diff --git a/server/src/db/kysely/McpTokens.table.ts b/server/src/db/kysely/McpTokens.table.tsnew file mode 100644index 000000000..73668e7a9--- /dev/null+++ b/server/src/db/kysely/McpTokens.table.ts@@ -0,0 +1,17 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface McpTokensTable {+ id: InsertOptional<number>;+ user_id: number;+ name: string;+ token_hash: string;+ token_prefix: string;+ created_at: InsertOptional<string | null>;+ last_used_at: InsertOptional<string | null>;+ kind: InsertOptional<string>;+ scope_mode: InsertOptional<string>;+ api_scopes: InsertOptional<string | null>;+}diff --git a/server/src/db/kysely/Migrations.table.ts b/server/src/db/kysely/Migrations.table.tsnew file mode 100644index 000000000..270f8ed78--- /dev/null+++ b/server/src/db/kysely/Migrations.table.ts@@ -0,0 +1,10 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface MigrationsTable {+ id: InsertOptional<number>;+ timestamp: number;+ name: string;+}diff --git a/server/src/db/kysely/NotificationChannelPreferences.table.ts b/server/src/db/kysely/NotificationChannelPreferences.table.tsnew file mode 100644index 000000000..c0f3397e2--- /dev/null+++ b/server/src/db/kysely/NotificationChannelPreferences.table.ts@@ -0,0 +1,11 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface NotificationChannelPreferencesTable {+ user_id: number;+ event_type: string;+ channel: string;+ enabled: InsertOptional<number>;+}diff --git a/server/src/db/kysely/Notifications.table.ts b/server/src/db/kysely/Notifications.table.tsnew file mode 100644index 000000000..33577e740--- /dev/null+++ b/server/src/db/kysely/Notifications.table.ts@@ -0,0 +1,26 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface NotificationsTable {+ id: InsertOptional<number>;+ type: string;+ scope: string;+ target: number;+ sender_id: InsertOptional<number | null>;+ recipient_id: number;+ title_key: string;+ title_params: InsertOptional<string | null>;+ text_key: string;+ text_params: InsertOptional<string | null>;+ positive_text_key: InsertOptional<string | null>;+ negative_text_key: InsertOptional<string | null>;+ positive_callback: InsertOptional<string | null>;+ negative_callback: InsertOptional<string | null>;+ response: InsertOptional<string | null>;+ navigate_text_key: InsertOptional<string | null>;+ navigate_target: InsertOptional<string | null>;+ is_read: InsertOptional<number | null>;+ created_at: InsertOptional<string | null>;+}diff --git a/server/src/db/kysely/OauthClients.table.ts b/server/src/db/kysely/OauthClients.table.tsnew file mode 100644index 000000000..c9d054fe6--- /dev/null+++ b/server/src/db/kysely/OauthClients.table.ts@@ -0,0 +1,18 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface OauthClientsTable {+ id: string;+ user_id: InsertOptional<number | null>;+ name: string;+ client_id: string;+ client_secret_hash: string;+ redirect_uris: InsertOptional<string>;+ allowed_scopes: InsertOptional<string>;+ created_at: InsertOptional<string | null>;+ is_public: InsertOptional<number>;+ created_via: InsertOptional<string>;+ allows_client_credentials: InsertOptional<number>;+}diff --git a/server/src/db/kysely/OauthConsents.table.ts b/server/src/db/kysely/OauthConsents.table.tsnew file mode 100644index 000000000..89487e2a4--- /dev/null+++ b/server/src/db/kysely/OauthConsents.table.ts@@ -0,0 +1,12 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface OauthConsentsTable {+ id: InsertOptional<number>;+ client_id: string;+ user_id: number;+ scopes: InsertOptional<string>;+ updated_at: InsertOptional<string | null>;+}diff --git a/server/src/db/kysely/OauthTokens.table.ts b/server/src/db/kysely/OauthTokens.table.tsnew file mode 100644index 000000000..0e0f2bd68--- /dev/null+++ b/server/src/db/kysely/OauthTokens.table.ts@@ -0,0 +1,19 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface OauthTokensTable {+ id: InsertOptional<number>;+ client_id: string;+ user_id: number;+ access_token_hash: string;+ refresh_token_hash: string;+ scopes: InsertOptional<string>;+ access_token_expires_at: string;+ refresh_token_expires_at: string;+ revoked_at: InsertOptional<string | null>;+ created_at: InsertOptional<string | null>;+ parent_token_id: InsertOptional<number | null>;+ audience: InsertOptional<string | null>;+}diff --git a/server/src/db/kysely/PackingBagMembers.table.ts b/server/src/db/kysely/PackingBagMembers.table.tsnew file mode 100644index 000000000..94a7e2b12--- /dev/null+++ b/server/src/db/kysely/PackingBagMembers.table.ts@@ -0,0 +1,7 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++export interface PackingBagMembersTable {+ bag_id: number;+ user_id: number;+}diff --git a/server/src/db/kysely/PackingBags.table.ts b/server/src/db/kysely/PackingBags.table.tsnew file mode 100644index 000000000..a241838a7--- /dev/null+++ b/server/src/db/kysely/PackingBags.table.ts@@ -0,0 +1,15 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface PackingBagsTable {+ id: InsertOptional<number>;+ trip_id: number;+ name: string;+ color: InsertOptional<string>;+ weight_limit_grams: InsertOptional<number | null>;+ sort_order: InsertOptional<number | null>;+ created_at: InsertOptional<string | null>;+ user_id: InsertOptional<number | null>;+}diff --git a/server/src/db/kysely/PackingCategoryAssignees.table.ts b/server/src/db/kysely/PackingCategoryAssignees.table.tsnew file mode 100644index 000000000..9b153a8df--- /dev/null+++ b/server/src/db/kysely/PackingCategoryAssignees.table.ts@@ -0,0 +1,11 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface PackingCategoryAssigneesTable {+ id: InsertOptional<number>;+ trip_id: number;+ category_name: string;+ user_id: number;+}diff --git a/server/src/db/kysely/PackingItemContributors.table.ts b/server/src/db/kysely/PackingItemContributors.table.tsnew file mode 100644index 000000000..a2b08c4c0--- /dev/null+++ b/server/src/db/kysely/PackingItemContributors.table.ts@@ -0,0 +1,11 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface PackingItemContributorsTable {+ item_id: number;+ user_id: number;+ status: InsertOptional<string>;+ created_at: InsertOptional<string | null>;+}diff --git a/server/src/db/kysely/PackingItemRecipients.table.ts b/server/src/db/kysely/PackingItemRecipients.table.tsnew file mode 100644index 000000000..b637c2ffe--- /dev/null+++ b/server/src/db/kysely/PackingItemRecipients.table.ts@@ -0,0 +1,7 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++export interface PackingItemRecipientsTable {+ item_id: number;+ user_id: number;+}diff --git a/server/src/db/kysely/PackingItems.table.ts b/server/src/db/kysely/PackingItems.table.tsnew file mode 100644index 000000000..95068f6d2--- /dev/null+++ b/server/src/db/kysely/PackingItems.table.ts@@ -0,0 +1,21 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface PackingItemsTable {+ id: InsertOptional<number>;+ trip_id: number;+ name: string;+ checked: InsertOptional<number | null>;+ category: InsertOptional<string | null>;+ sort_order: InsertOptional<number | null>;+ created_at: InsertOptional<string | null>;+ weight_grams: InsertOptional<number | null>;+ bag_id: InsertOptional<number | null>;+ quantity: InsertOptional<number>;+ updated_at: InsertOptional<string | null>;+ is_private: InsertOptional<number>;+ owner_id: InsertOptional<number | null>;+ packed_quantity: InsertOptional<number | null>;+}diff --git a/server/src/db/kysely/PackingTemplateCategories.table.ts b/server/src/db/kysely/PackingTemplateCategories.table.tsnew file mode 100644index 000000000..8b782be7d--- /dev/null+++ b/server/src/db/kysely/PackingTemplateCategories.table.ts@@ -0,0 +1,11 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface PackingTemplateCategoriesTable {+ id: InsertOptional<number>;+ template_id: number;+ name: string;+ sort_order: InsertOptional<number>;+}diff --git a/server/src/db/kysely/PackingTemplateItems.table.ts b/server/src/db/kysely/PackingTemplateItems.table.tsnew file mode 100644index 000000000..2af2b5a1d--- /dev/null+++ b/server/src/db/kysely/PackingTemplateItems.table.ts@@ -0,0 +1,14 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface PackingTemplateItemsTable {+ id: InsertOptional<number>;+ category_id: number;+ name: string;+ sort_order: InsertOptional<number>;+ weight_grams: InsertOptional<number | null>;+ quantity: InsertOptional<number>;+ bag_name: InsertOptional<string | null>;+}diff --git a/server/src/db/kysely/PackingTemplates.table.ts b/server/src/db/kysely/PackingTemplates.table.tsnew file mode 100644index 000000000..a1fac5c23--- /dev/null+++ b/server/src/db/kysely/PackingTemplates.table.ts@@ -0,0 +1,11 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface PackingTemplatesTable {+ id: InsertOptional<number>;+ name: string;+ created_by: number;+ created_at: InsertOptional<string | null>;+}diff --git a/server/src/db/kysely/PasswordResetTokens.table.ts b/server/src/db/kysely/PasswordResetTokens.table.tsnew file mode 100644index 000000000..759d77345--- /dev/null+++ b/server/src/db/kysely/PasswordResetTokens.table.ts@@ -0,0 +1,14 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface PasswordResetTokensTable {+ id: InsertOptional<number>;+ user_id: number;+ token_hash: string;+ expires_at: string;+ consumed_at: InsertOptional<string | null>;+ created_at: InsertOptional<string | null>;+ created_ip: InsertOptional<string | null>;+}diff --git a/server/src/db/kysely/PhotoProviderFields.table.ts b/server/src/db/kysely/PhotoProviderFields.table.tsnew file mode 100644index 000000000..a02a97a1d--- /dev/null+++ b/server/src/db/kysely/PhotoProviderFields.table.ts@@ -0,0 +1,19 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface PhotoProviderFieldsTable {+ id: InsertOptional<number>;+ provider_id: string;+ field_key: string;+ label: string;+ input_type: InsertOptional<string>;+ placeholder: InsertOptional<string | null>;+ hint: InsertOptional<string | null>;+ required: InsertOptional<number | null>;+ secret: InsertOptional<number | null>;+ settings_key: InsertOptional<string | null>;+ payload_key: InsertOptional<string | null>;+ sort_order: InsertOptional<number | null>;+}diff --git a/server/src/db/kysely/PhotoProviders.table.ts b/server/src/db/kysely/PhotoProviders.table.tsnew file mode 100644index 000000000..42199a140--- /dev/null+++ b/server/src/db/kysely/PhotoProviders.table.ts@@ -0,0 +1,13 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface PhotoProvidersTable {+ id: string;+ name: string;+ description: InsertOptional<string | null>;+ icon: InsertOptional<string | null>;+ enabled: InsertOptional<number | null>;+ sort_order: InsertOptional<number | null>;+}diff --git a/server/src/db/kysely/Photos.table.ts b/server/src/db/kysely/Photos.table.tsnew file mode 100644index 000000000..5813c30df--- /dev/null+++ b/server/src/db/kysely/Photos.table.ts@@ -0,0 +1,18 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface PhotosTable {+ id: InsertOptional<number>;+ trip_id: number;+ day_id: InsertOptional<number | null>;+ place_id: InsertOptional<number | null>;+ filename: string;+ original_name: string;+ file_size: InsertOptional<number | null>;+ mime_type: InsertOptional<string | null>;+ caption: InsertOptional<string | null>;+ taken_at: InsertOptional<string | null>;+ created_at: InsertOptional<string | null>;+}diff --git a/server/src/db/kysely/PlaceDetailsCache.table.ts b/server/src/db/kysely/PlaceDetailsCache.table.tsnew file mode 100644index 000000000..58993833d--- /dev/null+++ b/server/src/db/kysely/PlaceDetailsCache.table.ts@@ -0,0 +1,12 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface PlaceDetailsCacheTable {+ place_id: string;+ lang: InsertOptional<string>;+ expanded: InsertOptional<number>;+ payload_json: string;+ fetched_at: number;+}diff --git a/server/src/db/kysely/PlaceRatings.table.ts b/server/src/db/kysely/PlaceRatings.table.tsnew file mode 100644index 000000000..aa62ad2fd--- /dev/null+++ b/server/src/db/kysely/PlaceRatings.table.ts@@ -0,0 +1,12 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface PlaceRatingsTable {+ id: InsertOptional<number>;+ place_id: number;+ user_id: number;+ rating: number;+ created_at: InsertOptional<string | null>;+}diff --git a/server/src/db/kysely/PlaceRegions.table.ts b/server/src/db/kysely/PlaceRegions.table.tsnew file mode 100644index 000000000..f1186a10b--- /dev/null+++ b/server/src/db/kysely/PlaceRegions.table.ts@@ -0,0 +1,11 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface PlaceRegionsTable {+ place_id: InsertOptional<number>;+ country_code: string;+ region_code: string;+ region_name: string;+}diff --git a/server/src/db/kysely/PlaceShadowPicks.table.ts b/server/src/db/kysely/PlaceShadowPicks.table.tsnew file mode 100644index 000000000..58c0d9cc5--- /dev/null+++ b/server/src/db/kysely/PlaceShadowPicks.table.ts@@ -0,0 +1,20 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface PlaceShadowPicksTable {+ id: InsertOptional<number>;+ created_at: InsertOptional<string>;+ query: string;+ lang: InsertOptional<string | null>;+ bias_lat: InsertOptional<number | null>;+ bias_lng: InsertOptional<number | null>;+ source: string;+ live_rank: number;+ live_count: number;+ picked_name: string;+ picked_lat: number;+ picked_lng: number;+ picked_place_id: InsertOptional<string | null>;+}diff --git a/server/src/db/kysely/PlaceTags.table.ts b/server/src/db/kysely/PlaceTags.table.tsnew file mode 100644index 000000000..9e3e407b7--- /dev/null+++ b/server/src/db/kysely/PlaceTags.table.ts@@ -0,0 +1,7 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++export interface PlaceTagsTable {+ place_id: number;+ tag_id: number;+}diff --git a/server/src/db/kysely/Places.table.ts b/server/src/db/kysely/Places.table.tsnew file mode 100644index 000000000..acb01e2dc--- /dev/null+++ b/server/src/db/kysely/Places.table.ts@@ -0,0 +1,41 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface PlacesTable {+ id: InsertOptional<number>;+ trip_id: number;+ name: string;+ description: InsertOptional<string | null>;+ lat: InsertOptional<number | null>;+ lng: InsertOptional<number | null>;+ address: InsertOptional<string | null>;+ category_id: InsertOptional<number | null>;+ price: InsertOptional<number | null>;+ currency: InsertOptional<string | null>;+ reservation_status: InsertOptional<string | null>;+ reservation_notes: InsertOptional<string | null>;+ reservation_datetime: InsertOptional<string | null>;+ place_time: InsertOptional<string | null>;+ end_time: InsertOptional<string | null>;+ duration_minutes: InsertOptional<number | null>;+ notes: InsertOptional<string | null>;+ image_url: InsertOptional<string | null>;+ google_place_id: InsertOptional<string | null>;+ google_ftid: InsertOptional<string | null>;+ website: InsertOptional<string | null>;+ phone: InsertOptional<string | null>;+ transport_mode: InsertOptional<string | null>;+ created_at: InsertOptional<string | null>;+ updated_at: InsertOptional<string | null>;+ osm_id: InsertOptional<string | null>;+ route_geometry: InsertOptional<string | null>;+ route_color: InsertOptional<string | null>;+ stop_type: InsertOptional<string | null>;+ fill_percent: InsertOptional<number | null>;+ amap_poi_id: InsertOptional<string | null>;+ source: InsertOptional<string | null>;+ email: InsertOptional<string | null>;+ opening_hours: InsertOptional<string | null>;+}diff --git a/server/src/db/kysely/PluginActions.table.ts b/server/src/db/kysely/PluginActions.table.tsnew file mode 100644index 000000000..19742962f--- /dev/null+++ b/server/src/db/kysely/PluginActions.table.ts@@ -0,0 +1,14 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface PluginActionsTable {+ plugin_id: string;+ action_key: string;+ label: string;+ hint: InsertOptional<string | null>;+ danger: InsertOptional<number>;+ sort_order: InsertOptional<number>;+ scope: InsertOptional<string>;+}diff --git a/server/src/db/kysely/PluginCapabilityAudit.table.ts b/server/src/db/kysely/PluginCapabilityAudit.table.tsnew file mode 100644index 000000000..cd171d0e3--- /dev/null+++ b/server/src/db/kysely/PluginCapabilityAudit.table.ts@@ -0,0 +1,16 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface PluginCapabilityAuditTable {+ id: InsertOptional<number>;+ plugin_id: string;+ acting_user_id: InsertOptional<number | null>;+ method: string;+ resource: InsertOptional<string | null>;+ code: string;+ ts: InsertOptional<string>;+ prev_hash: InsertOptional<string | null>;+ hash: string;+}diff --git a/server/src/db/kysely/PluginEgressHosts.table.ts b/server/src/db/kysely/PluginEgressHosts.table.tsnew file mode 100644index 000000000..29714554b--- /dev/null+++ b/server/src/db/kysely/PluginEgressHosts.table.ts@@ -0,0 +1,11 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface PluginEgressHostsTable {+ id: InsertOptional<number>;+ plugin_id: string;+ host: string;+ created_at: InsertOptional<string>;+}diff --git a/server/src/db/kysely/PluginEntityMetadata.table.ts b/server/src/db/kysely/PluginEntityMetadata.table.tsnew file mode 100644index 000000000..3d6583cf4--- /dev/null+++ b/server/src/db/kysely/PluginEntityMetadata.table.ts@@ -0,0 +1,14 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface PluginEntityMetadataTable {+ id: InsertOptional<number>;+ plugin_id: string;+ entity_type: string;+ entity_id: number;+ key: string;+ value: InsertOptional<string | null>;+ updated_at: InsertOptional<string>;+}diff --git a/server/src/db/kysely/PluginErrorLog.table.ts b/server/src/db/kysely/PluginErrorLog.table.tsnew file mode 100644index 000000000..8b250c609--- /dev/null+++ b/server/src/db/kysely/PluginErrorLog.table.ts@@ -0,0 +1,13 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface PluginErrorLogTable {+ id: InsertOptional<number>;+ plugin_id: string;+ ts: InsertOptional<string | null>;+ level: InsertOptional<string>;+ message: InsertOptional<string | null>;+ stack: InsertOptional<string | null>;+}diff --git a/server/src/db/kysely/PluginMetaMigrations.table.ts b/server/src/db/kysely/PluginMetaMigrations.table.tsnew file mode 100644index 000000000..fe88d4778--- /dev/null+++ b/server/src/db/kysely/PluginMetaMigrations.table.ts@@ -0,0 +1,10 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface PluginMetaMigrationsTable {+ plugin_id: string;+ migration_id: string;+ applied_at: InsertOptional<string | null>;+}diff --git a/server/src/db/kysely/PluginOauthState.table.ts b/server/src/db/kysely/PluginOauthState.table.tsnew file mode 100644index 000000000..727af107b--- /dev/null+++ b/server/src/db/kysely/PluginOauthState.table.ts@@ -0,0 +1,10 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++export interface PluginOauthStateTable {+ state: string;+ plugin_id: string;+ user_id: number;+ verifier: string;+ created_at: number;+}diff --git a/server/src/db/kysely/PluginOauthTokens.table.ts b/server/src/db/kysely/PluginOauthTokens.table.tsnew file mode 100644index 000000000..fc0ee4876--- /dev/null+++ b/server/src/db/kysely/PluginOauthTokens.table.ts@@ -0,0 +1,14 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface PluginOauthTokensTable {+ plugin_id: string;+ user_id: number;+ access_token: InsertOptional<string | null>;+ refresh_token: InsertOptional<string | null>;+ expires_at: InsertOptional<number | null>;+ scope: InsertOptional<string | null>;+ updated_at: InsertOptional<string>;+}diff --git a/server/src/db/kysely/PluginScheduledTasks.table.ts b/server/src/db/kysely/PluginScheduledTasks.table.tsnew file mode 100644index 000000000..a78f22a75--- /dev/null+++ b/server/src/db/kysely/PluginScheduledTasks.table.ts@@ -0,0 +1,14 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface PluginScheduledTasksTable {+ id: InsertOptional<number>;+ plugin_id: string;+ name: string;+ due_at: number;+ payload: InsertOptional<string>;+ every_ms: InsertOptional<number | null>;+ created_at: InsertOptional<string>;+}diff --git a/server/src/db/kysely/PluginSettingsFields.table.ts b/server/src/db/kysely/PluginSettingsFields.table.tsnew file mode 100644index 000000000..b542c73f5--- /dev/null+++ b/server/src/db/kysely/PluginSettingsFields.table.ts@@ -0,0 +1,21 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface PluginSettingsFieldsTable {+ id: InsertOptional<number>;+ plugin_id: string;+ field_key: string;+ label: InsertOptional<string | null>;+ input_type: InsertOptional<string>;+ placeholder: InsertOptional<string | null>;+ hint: InsertOptional<string | null>;+ required: InsertOptional<number>;+ secret: InsertOptional<number>;+ scope: InsertOptional<string>;+ options: InsertOptional<string | null>;+ oauth_config: InsertOptional<string | null>;+ sort_order: InsertOptional<number>;+ default_value: InsertOptional<string | null>;+}diff --git a/server/src/db/kysely/PluginUserConfig.table.ts b/server/src/db/kysely/PluginUserConfig.table.tsnew file mode 100644index 000000000..6457dbf6e--- /dev/null+++ b/server/src/db/kysely/PluginUserConfig.table.ts@@ -0,0 +1,11 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface PluginUserConfigTable {+ plugin_id: string;+ user_id: number;+ config: InsertOptional<string>;+ updated_at: InsertOptional<string>;+}diff --git a/server/src/db/kysely/PluginUserErasureQueue.table.ts b/server/src/db/kysely/PluginUserErasureQueue.table.tsnew file mode 100644index 000000000..40cf56890--- /dev/null+++ b/server/src/db/kysely/PluginUserErasureQueue.table.ts@@ -0,0 +1,11 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface PluginUserErasureQueueTable {+ id: InsertOptional<number>;+ plugin_id: string;+ user_id: number;+ created_at: InsertOptional<string>;+}diff --git a/server/src/db/kysely/Plugins.table.ts b/server/src/db/kysely/Plugins.table.tsnew file mode 100644index 000000000..12350c6b8--- /dev/null+++ b/server/src/db/kysely/Plugins.table.ts@@ -0,0 +1,38 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface PluginsTable {+ id: string;+ name: string;+ description: InsertOptional<string | null>;+ type: InsertOptional<string>;+ icon: InsertOptional<string | null>;+ version: InsertOptional<string | null>;+ api_version: InsertOptional<number | null>;+ min_trek_version: InsertOptional<string | null>;+ permissions: InsertOptional<string | null>;+ granted_permissions: InsertOptional<string | null>;+ status: InsertOptional<string>;+ config: InsertOptional<string | null>;+ source_repo: InsertOptional<string | null>;+ source_commit: InsertOptional<string | null>;+ sha256: InsertOptional<string | null>;+ crash_count: InsertOptional<number>;+ last_error: InsertOptional<string | null>;+ reviewed_at: InsertOptional<string | null>;+ sort_order: InsertOptional<number>;+ installed_at: InsertOptional<string | null>;+ updated_at: InsertOptional<string | null>;+ enabled: InsertOptional<number>;+ capabilities: InsertOptional<string>;+ author_pubkey: InsertOptional<string | null>;+ dependencies: InsertOptional<string>;+ operator_egress: InsertOptional<number>;+ update_block_code: InsertOptional<string | null>;+ update_block_detail: InsertOptional<string | null>;+ update_block_version: InsertOptional<string | null>;+ trek_range: InsertOptional<string | null>;+ update_hold: InsertOptional<number>;+}diff --git a/server/src/db/kysely/PushSubscriptions.table.ts b/server/src/db/kysely/PushSubscriptions.table.tsnew file mode 100644index 000000000..dc6261c22--- /dev/null+++ b/server/src/db/kysely/PushSubscriptions.table.ts@@ -0,0 +1,17 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface PushSubscriptionsTable {+ id: InsertOptional<number>;+ user_id: number;+ endpoint: string;+ p256dh: string;+ auth: string;+ vapid_public_key: string;+ user_agent: InsertOptional<string | null>;+ created_at: InsertOptional<string>;+ last_success_at: InsertOptional<string | null>;+ failure_count: InsertOptional<number>;+}diff --git a/server/src/db/kysely/ReservationDayPositions.table.ts b/server/src/db/kysely/ReservationDayPositions.table.tsnew file mode 100644index 000000000..312780776--- /dev/null+++ b/server/src/db/kysely/ReservationDayPositions.table.ts@@ -0,0 +1,8 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++export interface ReservationDayPositionsTable {+ reservation_id: number;+ day_id: number;+ position: number;+}diff --git a/server/src/db/kysely/ReservationEndpoints.table.ts b/server/src/db/kysely/ReservationEndpoints.table.tsnew file mode 100644index 000000000..d3b5aa6fe--- /dev/null+++ b/server/src/db/kysely/ReservationEndpoints.table.ts@@ -0,0 +1,19 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface ReservationEndpointsTable {+ id: InsertOptional<number>;+ reservation_id: number;+ role: string;+ sequence: InsertOptional<number>;+ name: string;+ code: InsertOptional<string | null>;+ lat: number;+ lng: number;+ timezone: InsertOptional<string | null>;+ local_time: InsertOptional<string | null>;+ local_date: InsertOptional<string | null>;+ created_at: InsertOptional<string | null>;+}diff --git a/server/src/db/kysely/ReservationTravelers.table.ts b/server/src/db/kysely/ReservationTravelers.table.tsnew file mode 100644index 000000000..b72e4da6a--- /dev/null+++ b/server/src/db/kysely/ReservationTravelers.table.ts@@ -0,0 +1,10 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface ReservationTravelersTable {+ id: InsertOptional<number>;+ reservation_id: number;+ user_id: number;+}diff --git a/server/src/db/kysely/Reservations.table.ts b/server/src/db/kysely/Reservations.table.tsnew file mode 100644index 000000000..8253ebe7a--- /dev/null+++ b/server/src/db/kysely/Reservations.table.ts@@ -0,0 +1,34 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface ReservationsTable {+ id: InsertOptional<number>;+ trip_id: number;+ day_id: InsertOptional<number | null>;+ end_day_id: InsertOptional<number | null>;+ place_id: InsertOptional<number | null>;+ assignment_id: InsertOptional<number | null>;+ title: string;+ accommodation_id: InsertOptional<string | null>;+ reservation_time: InsertOptional<string | null>;+ reservation_end_time: InsertOptional<string | null>;+ location: InsertOptional<string | null>;+ confirmation_number: InsertOptional<string | null>;+ notes: InsertOptional<string | null>;+ status: InsertOptional<string | null>;+ type: InsertOptional<string | null>;+ created_at: InsertOptional<string | null>;+ metadata: InsertOptional<string | null>;+ day_plan_position: InsertOptional<number | null>;+ needs_review: InsertOptional<number>;+ external_source: InsertOptional<string | null>;+ external_id: InsertOptional<string | null>;+ external_owner_user_id: InsertOptional<number | null>;+ external_synced_at: InsertOptional<string | null>;+ sync_enabled: InsertOptional<number | null>;+ external_hash: InsertOptional<string | null>;+ url: InsertOptional<string | null>;+ ingest_state: InsertOptional<string>;+}diff --git a/server/src/db/kysely/RoadtripDayBoundaries.table.ts b/server/src/db/kysely/RoadtripDayBoundaries.table.tsnew file mode 100644index 000000000..10116f955--- /dev/null+++ b/server/src/db/kysely/RoadtripDayBoundaries.table.ts@@ -0,0 +1,12 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface RoadtripDayBoundariesTable {+ trip_id: number;+ day_number: number;+ from_assignment_id: number;+ to_assignment_id: InsertOptional<number | null>;+ fraction: number;+}diff --git a/server/src/db/kysely/RoadtripDayTracks.table.ts b/server/src/db/kysely/RoadtripDayTracks.table.tsnew file mode 100644index 000000000..c228e6710--- /dev/null+++ b/server/src/db/kysely/RoadtripDayTracks.table.ts@@ -0,0 +1,11 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface RoadtripDayTracksTable {+ day_id: InsertOptional<number>;+ place_id: number;+ stray_km: InsertOptional<number | null>;+ created_at: InsertOptional<string | null>;+}diff --git a/server/src/db/kysely/RoadtripPreferences.table.ts b/server/src/db/kysely/RoadtripPreferences.table.tsnew file mode 100644index 000000000..4c70fbd01--- /dev/null+++ b/server/src/db/kysely/RoadtripPreferences.table.ts@@ -0,0 +1,8 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++export interface RoadtripPreferencesTable {+ trip_id: number;+ key: string;+ value: string;+}diff --git a/server/src/db/kysely/RoadtripVias.table.ts b/server/src/db/kysely/RoadtripVias.table.tsnew file mode 100644index 000000000..f201a565c--- /dev/null+++ b/server/src/db/kysely/RoadtripVias.table.ts@@ -0,0 +1,14 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface RoadtripViasTable {+ id: InsertOptional<number>;+ day_id: number;+ after_order_index: number;+ sequence: InsertOptional<number>;+ lat: number;+ lng: number;+ created_at: InsertOptional<string | null>;+}diff --git a/server/src/db/kysely/RouteUsageDaily.table.ts b/server/src/db/kysely/RouteUsageDaily.table.tsnew file mode 100644index 000000000..683a09aec--- /dev/null+++ b/server/src/db/kysely/RouteUsageDaily.table.ts@@ -0,0 +1,15 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface RouteUsageDailyTable {+ day: string;+ profile: string;+ surface: string;+ self_hosted: number;+ requests: InsertOptional<number>;+ waypoints: InsertOptional<number>;+ km: InsertOptional<number>;+ failed: InsertOptional<number>;+}diff --git a/server/src/db/kysely/SchemaVersion.table.ts b/server/src/db/kysely/SchemaVersion.table.tsnew file mode 100644index 000000000..3aab6fe89--- /dev/null+++ b/server/src/db/kysely/SchemaVersion.table.ts@@ -0,0 +1,9 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface SchemaVersionTable {+ id: InsertOptional<number>;+ version: number;+}diff --git a/server/src/db/kysely/SchoolHolidayCountries.table.ts b/server/src/db/kysely/SchoolHolidayCountries.table.tsnew file mode 100644index 000000000..84ad2a41a--- /dev/null+++ b/server/src/db/kysely/SchoolHolidayCountries.table.ts@@ -0,0 +1,7 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++export interface SchoolHolidayCountriesTable {+ code: string;+ name: string;+}diff --git a/server/src/db/kysely/SchoolHolidayPeriods.table.ts b/server/src/db/kysely/SchoolHolidayPeriods.table.tsnew file mode 100644index 000000000..562ddbf72--- /dev/null+++ b/server/src/db/kysely/SchoolHolidayPeriods.table.ts@@ -0,0 +1,12 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface SchoolHolidayPeriodsTable {+ id: InsertOptional<number>;+ region_id: number;+ name: string;+ start_date: string;+ end_date: string;+}diff --git a/server/src/db/kysely/SchoolHolidayRegions.table.ts b/server/src/db/kysely/SchoolHolidayRegions.table.tsnew file mode 100644index 000000000..de737c16a--- /dev/null+++ b/server/src/db/kysely/SchoolHolidayRegions.table.ts@@ -0,0 +1,11 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface SchoolHolidayRegionsTable {+ id: InsertOptional<number>;+ country: string;+ name: string;+ revision: InsertOptional<number>;+}diff --git a/server/src/db/kysely/Settings.table.ts b/server/src/db/kysely/Settings.table.tsnew file mode 100644index 000000000..4d509ba11--- /dev/null+++ b/server/src/db/kysely/Settings.table.ts@@ -0,0 +1,11 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface SettingsTable {+ id: InsertOptional<number>;+ user_id: number;+ key: string;+ value: InsertOptional<string | null>;+}diff --git a/server/src/db/kysely/ShareTokens.table.ts b/server/src/db/kysely/ShareTokens.table.tsnew file mode 100644index 000000000..899677e2c--- /dev/null+++ b/server/src/db/kysely/ShareTokens.table.ts@@ -0,0 +1,20 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface ShareTokensTable {+ id: InsertOptional<number>;+ trip_id: number;+ token: string;+ created_by: number;+ share_map: InsertOptional<number | null>;+ share_bookings: InsertOptional<number | null>;+ share_packing: InsertOptional<number | null>;+ share_budget: InsertOptional<number | null>;+ share_collab: InsertOptional<number | null>;+ created_at: InsertOptional<string | null>;+ expires_at: InsertOptional<string | null>;+ share_travel_only: InsertOptional<number>;+ share_hide_images: InsertOptional<number>;+}diff --git a/server/src/db/kysely/Tags.table.ts b/server/src/db/kysely/Tags.table.tsnew file mode 100644index 000000000..2b20f2889--- /dev/null+++ b/server/src/db/kysely/Tags.table.ts@@ -0,0 +1,12 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface TagsTable {+ id: InsertOptional<number>;+ user_id: number;+ name: string;+ color: InsertOptional<string | null>;+ created_at: InsertOptional<string | null>;+}diff --git a/server/src/db/kysely/TodoCategoryAssignees.table.ts b/server/src/db/kysely/TodoCategoryAssignees.table.tsnew file mode 100644index 000000000..ee7e28ea9--- /dev/null+++ b/server/src/db/kysely/TodoCategoryAssignees.table.ts@@ -0,0 +1,11 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface TodoCategoryAssigneesTable {+ id: InsertOptional<number>;+ trip_id: number;+ category_name: string;+ user_id: number;+}diff --git a/server/src/db/kysely/TodoItems.table.ts b/server/src/db/kysely/TodoItems.table.tsnew file mode 100644index 000000000..026ffbcd5--- /dev/null+++ b/server/src/db/kysely/TodoItems.table.ts@@ -0,0 +1,19 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface TodoItemsTable {+ id: InsertOptional<number>;+ trip_id: number;+ name: string;+ checked: InsertOptional<number | null>;+ category: InsertOptional<string | null>;+ sort_order: InsertOptional<number | null>;+ due_date: InsertOptional<string | null>;+ description: InsertOptional<string | null>;+ assigned_user_id: InsertOptional<number | null>;+ priority: InsertOptional<number | null>;+ created_at: InsertOptional<string | null>;+ reminded_at: InsertOptional<string | null>;+}diff --git a/server/src/db/kysely/TourTypes.table.ts b/server/src/db/kysely/TourTypes.table.tsnew file mode 100644index 000000000..fda759c8a--- /dev/null+++ b/server/src/db/kysely/TourTypes.table.ts@@ -0,0 +1,15 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface TourTypesTable {+ key: string;+ label_key: string;+ icon: string;+ color: string;+ routing_profile: InsertOptional<string | null>;+ is_sport: InsertOptional<number>;+ enabled: InsertOptional<number>;+ sort_order: InsertOptional<number>;+}diff --git a/server/src/db/kysely/TourWaypoints.table.ts b/server/src/db/kysely/TourWaypoints.table.tsnew file mode 100644index 000000000..955f458bd--- /dev/null+++ b/server/src/db/kysely/TourWaypoints.table.ts@@ -0,0 +1,13 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface TourWaypointsTable {+ id: InsertOptional<number>;+ place_id: number;+ lat: number;+ lng: number;+ role: string;+ sequence: number;+}diff --git a/server/src/db/kysely/Tours.table.ts b/server/src/db/kysely/Tours.table.tsnew file mode 100644index 000000000..46186ec99--- /dev/null+++ b/server/src/db/kysely/Tours.table.ts@@ -0,0 +1,18 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface ToursTable {+ place_id: InsertOptional<number>;+ tour_type: string;+ distance: InsertOptional<number | null>;+ elevation_gain: InsertOptional<number | null>;+ elevation_loss: InsertOptional<number | null>;+ duration: InsertOptional<number | null>;+ difficulty: InsertOptional<string | null>;+ wanderer_ref: InsertOptional<string | null>;+ match_confidence: InsertOptional<number | null>;+ created_at: InsertOptional<string | null>;+ max_hiking_difficulty: InsertOptional<number>;+}diff --git a/server/src/db/kysely/TrekPhotoCacheMeta.table.ts b/server/src/db/kysely/TrekPhotoCacheMeta.table.tsnew file mode 100644index 000000000..1ad3d001a--- /dev/null+++ b/server/src/db/kysely/TrekPhotoCacheMeta.table.ts@@ -0,0 +1,10 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface TrekPhotoCacheMetaTable {+ cache_key: string;+ content_type: InsertOptional<string>;+ fetched_at: number;+}diff --git a/server/src/db/kysely/TrekPhotos.table.ts b/server/src/db/kysely/TrekPhotos.table.tsnew file mode 100644index 000000000..87344be4a--- /dev/null+++ b/server/src/db/kysely/TrekPhotos.table.ts@@ -0,0 +1,22 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface TrekPhotosTable {+ id: InsertOptional<number>;+ provider: string;+ asset_id: InsertOptional<string | null>;+ owner_id: InsertOptional<number | null>;+ file_path: InsertOptional<string | null>;+ thumbnail_path: InsertOptional<string | null>;+ width: InsertOptional<number | null>;+ height: InsertOptional<number | null>;+ created_at: InsertOptional<string | null>;+ passphrase: InsertOptional<string | null>;+ media_type: InsertOptional<string>;+ duration_ms: InsertOptional<number | null>;+ taken_at: InsertOptional<string | null>;+ lat: InsertOptional<number | null>;+ lng: InsertOptional<number | null>;+}diff --git a/server/src/db/kysely/TripAlbumLinks.table.ts b/server/src/db/kysely/TripAlbumLinks.table.tsnew file mode 100644index 000000000..6fd804554--- /dev/null+++ b/server/src/db/kysely/TripAlbumLinks.table.ts@@ -0,0 +1,17 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface TripAlbumLinksTable {+ id: InsertOptional<number>;+ trip_id: number;+ user_id: number;+ provider: string;+ album_id: string;+ album_name: InsertOptional<string>;+ sync_enabled: InsertOptional<number>;+ last_synced_at: InsertOptional<string | null>;+ created_at: InsertOptional<string | null>;+ passphrase: InsertOptional<string | null>;+}diff --git a/server/src/db/kysely/TripDocumentLinks.table.ts b/server/src/db/kysely/TripDocumentLinks.table.tsnew file mode 100644index 000000000..fc038a6c8--- /dev/null+++ b/server/src/db/kysely/TripDocumentLinks.table.ts@@ -0,0 +1,31 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface TripDocumentLinksTable {+ id: InsertOptional<number>;+ trip_id: number;+ connection_id: number;+ provider_id: string;+ remote_scope_key: string;+ remote_root_id: InsertOptional<string | null>;+ remote_root_path: InsertOptional<string | null>;+ remote_label: InsertOptional<string>;+ direction: InsertOptional<string>;+ delete_policy: InsertOptional<string>;+ conflict_policy: InsertOptional<string>;+ sync_enabled: InsertOptional<number>;+ webhook_token: InsertOptional<string | null>;+ webhook_secret: InsertOptional<string | null>;+ webhook_subscription_id: InsertOptional<string | null>;+ remote_cursor: InsertOptional<string | null>;+ last_sync_at: InsertOptional<string | null>;+ last_sync_state: InsertOptional<string>;+ last_sync_error: InsertOptional<string | null>;+ failure_count: InsertOptional<number>;+ next_attempt_at: InsertOptional<string | null>;+ created_by: InsertOptional<number | null>;+ created_at: InsertOptional<string | null>;+ updated_at: InsertOptional<string | null>;+}diff --git a/server/src/db/kysely/TripFiles.table.ts b/server/src/db/kysely/TripFiles.table.tsnew file mode 100644index 000000000..be164484e--- /dev/null+++ b/server/src/db/kysely/TripFiles.table.ts@@ -0,0 +1,22 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface TripFilesTable {+ id: InsertOptional<number>;+ trip_id: number;+ place_id: InsertOptional<number | null>;+ reservation_id: InsertOptional<number | null>;+ filename: string;+ original_name: string;+ file_size: InsertOptional<number | null>;+ mime_type: InsertOptional<string | null>;+ description: InsertOptional<string | null>;+ created_at: InsertOptional<string | null>;+ note_id: InsertOptional<number | null>;+ uploaded_by: InsertOptional<number | null>;+ starred: InsertOptional<number | null>;+ deleted_at: InsertOptional<string | null>;+ message_id: InsertOptional<number | null>;+}diff --git a/server/src/db/kysely/TripInviteTokens.table.ts b/server/src/db/kysely/TripInviteTokens.table.tsnew file mode 100644index 000000000..9645987dd--- /dev/null+++ b/server/src/db/kysely/TripInviteTokens.table.ts@@ -0,0 +1,13 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface TripInviteTokensTable {+ id: InsertOptional<number>;+ trip_id: number;+ token: string;+ created_by: InsertOptional<number | null>;+ expires_at: InsertOptional<string | null>;+ created_at: InsertOptional<string | null>;+}diff --git a/server/src/db/kysely/TripMembers.table.ts b/server/src/db/kysely/TripMembers.table.tsnew file mode 100644index 000000000..d5df374cc--- /dev/null+++ b/server/src/db/kysely/TripMembers.table.ts@@ -0,0 +1,12 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface TripMembersTable {+ id: InsertOptional<number>;+ trip_id: number;+ user_id: number;+ invited_by: InsertOptional<number | null>;+ added_at: InsertOptional<string | null>;+}diff --git a/server/src/db/kysely/TripPhotos.table.ts b/server/src/db/kysely/TripPhotos.table.tsnew file mode 100644index 000000000..f08623ba3--- /dev/null+++ b/server/src/db/kysely/TripPhotos.table.ts@@ -0,0 +1,14 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface TripPhotosTable {+ id: InsertOptional<number>;+ trip_id: number;+ user_id: number;+ photo_id: number;+ shared: InsertOptional<number>;+ album_link_id: InsertOptional<number | null>;+ added_at: InsertOptional<string | null>;+}diff --git a/server/src/db/kysely/Trips.table.ts b/server/src/db/kysely/Trips.table.tsnew file mode 100644index 000000000..6fce64e69--- /dev/null+++ b/server/src/db/kysely/Trips.table.ts@@ -0,0 +1,21 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface TripsTable {+ id: InsertOptional<number>;+ user_id: number;+ title: string;+ description: InsertOptional<string | null>;+ start_date: InsertOptional<string | null>;+ end_date: InsertOptional<string | null>;+ currency: InsertOptional<string | null>;+ cover_image: InsertOptional<string | null>;+ is_archived: InsertOptional<number | null>;+ reminder_days: InsertOptional<number | null>;+ feed_token: InsertOptional<string | null>;+ created_at: InsertOptional<string | null>;+ updated_at: InsertOptional<string | null>;+ reminder_sent_for: InsertOptional<string | null>;+}diff --git a/server/src/db/kysely/UserNoticeDismissals.table.ts b/server/src/db/kysely/UserNoticeDismissals.table.tsnew file mode 100644index 000000000..791d17f01--- /dev/null+++ b/server/src/db/kysely/UserNoticeDismissals.table.ts@@ -0,0 +1,11 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface UserNoticeDismissalsTable {+ user_id: number;+ notice_id: string;+ dismissed_at: number;+ dismissed_app_version: InsertOptional<string | null>;+}diff --git a/server/src/db/kysely/Users.table.ts b/server/src/db/kysely/Users.table.tsnew file mode 100644index 000000000..08a021c5b--- /dev/null+++ b/server/src/db/kysely/Users.table.ts@@ -0,0 +1,47 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface UsersTable {+ id: InsertOptional<number>;+ username: string;+ email: string;+ password_hash: string;+ role: InsertOptional<string>;+ maps_api_key: InsertOptional<string | null>;+ unsplash_api_key: InsertOptional<string | null>;+ amap_api_key: InsertOptional<string | null>;+ openweather_api_key: InsertOptional<string | null>;+ avatar: InsertOptional<string | null>;+ oidc_sub: InsertOptional<string | null>;+ oidc_issuer: InsertOptional<string | null>;+ last_login: InsertOptional<string | null>;+ mfa_enabled: InsertOptional<number | null>;+ mfa_secret: InsertOptional<string | null>;+ mfa_backup_codes: InsertOptional<string | null>;+ immich_url: InsertOptional<string | null>;+ immich_access_token: InsertOptional<string | null>;+ synology_url: InsertOptional<string | null>;+ synology_username: InsertOptional<string | null>;+ synology_password: InsertOptional<string | null>;+ synology_sid: InsertOptional<string | null>;+ must_change_password: InsertOptional<number | null>;+ password_version: InsertOptional<number>;+ feed_token: InsertOptional<string | null>;+ is_guest: InsertOptional<number>;+ created_at: InsertOptional<string | null>;+ updated_at: InsertOptional<string | null>;+ immich_api_key: InsertOptional<string | null>;+ synology_skip_ssl: InsertOptional<number>;+ synology_did: InsertOptional<string | null>;+ first_seen_version: InsertOptional<string>;+ login_count: InsertOptional<number>;+ immich_auto_upload: InsertOptional<number>;+ airtrail_url: InsertOptional<string | null>;+ airtrail_api_key: InsertOptional<string | null>;+ airtrail_allow_insecure_tls: InsertOptional<number | null>;+ airtrail_write_enabled: InsertOptional<number | null>;+ display_name: InsertOptional<string | null>;+ immich_allow_insecure_tls: InsertOptional<number>;+}diff --git a/server/src/db/kysely/VacayCompanyHolidays.table.ts b/server/src/db/kysely/VacayCompanyHolidays.table.tsnew file mode 100644index 000000000..882982949--- /dev/null+++ b/server/src/db/kysely/VacayCompanyHolidays.table.ts@@ -0,0 +1,12 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface VacayCompanyHolidaysTable {+ id: InsertOptional<number>;+ plan_id: number;+ date: string;+ note: InsertOptional<string | null>;+ fraction: InsertOptional<number>;+}diff --git a/server/src/db/kysely/VacayEntries.table.ts b/server/src/db/kysely/VacayEntries.table.tsnew file mode 100644index 000000000..4171e21c2--- /dev/null+++ b/server/src/db/kysely/VacayEntries.table.ts@@ -0,0 +1,14 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface VacayEntriesTable {+ id: InsertOptional<number>;+ plan_id: number;+ user_id: number;+ date: string;+ note: InsertOptional<string | null>;+ fraction: InsertOptional<number>;+ kind: InsertOptional<string>;+}diff --git a/server/src/db/kysely/VacayHolidayCalendars.table.ts b/server/src/db/kysely/VacayHolidayCalendars.table.tsnew file mode 100644index 000000000..4d1fdd35f--- /dev/null+++ b/server/src/db/kysely/VacayHolidayCalendars.table.ts@@ -0,0 +1,14 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface VacayHolidayCalendarsTable {+ id: InsertOptional<number>;+ plan_id: number;+ type: InsertOptional<string>;+ region: string;+ label: InsertOptional<string | null>;+ color: InsertOptional<string>;+ sort_order: InsertOptional<number>;+}diff --git a/server/src/db/kysely/VacayPlanMembers.table.ts b/server/src/db/kysely/VacayPlanMembers.table.tsnew file mode 100644index 000000000..8d296cddd--- /dev/null+++ b/server/src/db/kysely/VacayPlanMembers.table.ts@@ -0,0 +1,12 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface VacayPlanMembersTable {+ id: InsertOptional<number>;+ plan_id: number;+ user_id: number;+ status: InsertOptional<string | null>;+ created_at: InsertOptional<string | null>;+}diff --git a/server/src/db/kysely/VacayPlans.table.ts b/server/src/db/kysely/VacayPlans.table.tsnew file mode 100644index 000000000..1dabaff5d--- /dev/null+++ b/server/src/db/kysely/VacayPlans.table.ts@@ -0,0 +1,18 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface VacayPlansTable {+ id: InsertOptional<number>;+ owner_id: number;+ block_weekends: InsertOptional<number | null>;+ holidays_enabled: InsertOptional<number | null>;+ holidays_region: InsertOptional<string | null>;+ school_holidays_enabled: InsertOptional<number | null>;+ company_holidays_enabled: InsertOptional<number | null>;+ carry_over_enabled: InsertOptional<number | null>;+ created_at: InsertOptional<string | null>;+ weekend_days: InsertOptional<string | null>;+ week_start: InsertOptional<number>;+}diff --git a/server/src/db/kysely/VacayShares.table.ts b/server/src/db/kysely/VacayShares.table.tsnew file mode 100644index 000000000..0f2061297--- /dev/null+++ b/server/src/db/kysely/VacayShares.table.ts@@ -0,0 +1,12 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface VacaySharesTable {+ id: InsertOptional<number>;+ owner_id: number;+ user_id: number;+ hidden: InsertOptional<number>;+ created_at: InsertOptional<string | null>;+}diff --git a/server/src/db/kysely/VacayUserColors.table.ts b/server/src/db/kysely/VacayUserColors.table.tsnew file mode 100644index 000000000..df9b68f0b--- /dev/null+++ b/server/src/db/kysely/VacayUserColors.table.ts@@ -0,0 +1,11 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface VacayUserColorsTable {+ id: InsertOptional<number>;+ user_id: number;+ plan_id: number;+ color: InsertOptional<string | null>;+}diff --git a/server/src/db/kysely/VacayUserSettings.table.ts b/server/src/db/kysely/VacayUserSettings.table.tsnew file mode 100644index 000000000..48b505f0d--- /dev/null+++ b/server/src/db/kysely/VacayUserSettings.table.ts@@ -0,0 +1,12 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface VacayUserSettingsTable {+ user_id: InsertOptional<number>;+ year_type: InsertOptional<string>;+ year_start_month: InsertOptional<number>;+ year_start_day: InsertOptional<number>;+ hire_date: InsertOptional<string | null>;+}diff --git a/server/src/db/kysely/VacayUserYears.table.ts b/server/src/db/kysely/VacayUserYears.table.tsnew file mode 100644index 000000000..e1f1dab3a--- /dev/null+++ b/server/src/db/kysely/VacayUserYears.table.ts@@ -0,0 +1,13 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface VacayUserYearsTable {+ id: InsertOptional<number>;+ user_id: number;+ plan_id: number;+ year: number;+ vacation_days: InsertOptional<number | null>;+ carried_over: InsertOptional<number | null>;+}diff --git a/server/src/db/kysely/VacayYears.table.ts b/server/src/db/kysely/VacayYears.table.tsnew file mode 100644index 000000000..68d960655--- /dev/null+++ b/server/src/db/kysely/VacayYears.table.ts@@ -0,0 +1,10 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface VacayYearsTable {+ id: InsertOptional<number>;+ plan_id: number;+ year: number;+}diff --git a/server/src/db/kysely/VisitedCountries.table.ts b/server/src/db/kysely/VisitedCountries.table.tsnew file mode 100644index 000000000..925288fe6--- /dev/null+++ b/server/src/db/kysely/VisitedCountries.table.ts@@ -0,0 +1,12 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface VisitedCountriesTable {+ id: InsertOptional<number>;+ user_id: number;+ country_code: string;+ created_at: InsertOptional<string | null>;+ source: InsertOptional<string>;+}diff --git a/server/src/db/kysely/VisitedRegions.table.ts b/server/src/db/kysely/VisitedRegions.table.tsnew file mode 100644index 000000000..77314c178--- /dev/null+++ b/server/src/db/kysely/VisitedRegions.table.ts@@ -0,0 +1,13 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface VisitedRegionsTable {+ id: InsertOptional<number>;+ user_id: number;+ region_code: string;+ region_name: string;+ country_code: string;+ created_at: InsertOptional<string | null>;+}diff --git a/server/src/db/kysely/WebauthnChallenges.table.ts b/server/src/db/kysely/WebauthnChallenges.table.tsnew file mode 100644index 000000000..371d810f6--- /dev/null+++ b/server/src/db/kysely/WebauthnChallenges.table.ts@@ -0,0 +1,13 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface WebauthnChallengesTable {+ id: InsertOptional<number>;+ challenge: string;+ user_id: InsertOptional<number | null>;+ type: string;+ expires_at: number;+ created_at: InsertOptional<string | null>;+}diff --git a/server/src/db/kysely/WebauthnCredentials.table.ts b/server/src/db/kysely/WebauthnCredentials.table.tsnew file mode 100644index 000000000..24bf4d3c5--- /dev/null+++ b/server/src/db/kysely/WebauthnCredentials.table.ts@@ -0,0 +1,19 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { InsertOptional } from './columns';++export interface WebauthnCredentialsTable {+ id: InsertOptional<number>;+ user_id: number;+ credential_id: string;+ public_key: Buffer;+ counter: InsertOptional<number>;+ transports: InsertOptional<string | null>;+ device_type: InsertOptional<string | null>;+ backed_up: InsertOptional<number>;+ name: InsertOptional<string | null>;+ aaguid: InsertOptional<string | null>;+ created_at: InsertOptional<string | null>;+ last_used_at: InsertOptional<string | null>;+}diff --git a/server/src/db/kysely/columns.ts b/server/src/db/kysely/columns.tsnew file mode 100644index 000000000..ba50fa677--- /dev/null+++ b/server/src/db/kysely/columns.ts@@ -0,0 +1,7 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { ColumnType } from 'kysely';++/** A column an insert may leave out: the database assigns it (rowid, DEFAULT) or stores NULL. */+export type InsertOptional<T> = ColumnType<T, T | void, T>;diff --git a/server/src/db/kysely/db.ts b/server/src/db/kysely/db.tsnew file mode 100644index 000000000..a18a7f591--- /dev/null+++ b/server/src/db/kysely/db.ts@@ -0,0 +1,277 @@+// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:+// change the migration, then run `npm run gen:db-types`.++import type { AddonsTable } from './Addons.table';+import type { AppSettingsTable } from './AppSettings.table';+import type { AssignmentParticipantsTable } from './AssignmentParticipants.table';+import type { AuditLogTable } from './AuditLog.table';+import type { BucketListTable } from './BucketList.table';+import type { BudgetCategoryOrderTable } from './BudgetCategoryOrder.table';+import type { BudgetItemMembersTable } from './BudgetItemMembers.table';+import type { BudgetItemPayersTable } from './BudgetItemPayers.table';+import type { BudgetItemsTable } from './BudgetItems.table';+import type { BudgetSettlementsTable } from './BudgetSettlements.table';+import type { CategoriesTable } from './Categories.table';+import type { CollabLinksTable } from './CollabLinks.table';+import type { CollabMessageReactionsTable } from './CollabMessageReactions.table';+import type { CollabMessagesTable } from './CollabMessages.table';+import type { CollabNotesTable } from './CollabNotes.table';+import type { CollabPollVotesTable } from './CollabPollVotes.table';+import type { CollabPollsTable } from './CollabPolls.table';+import type { CollectionLabelsTable } from './CollectionLabels.table';+import type { CollectionMembersTable } from './CollectionMembers.table';+import type { CollectionPlaceLabelsTable } from './CollectionPlaceLabels.table';+import type { CollectionPlaceRatingsTable } from './CollectionPlaceRatings.table';+import type { CollectionPlaceTagsTable } from './CollectionPlaceTags.table';+import type { CollectionPlacesTable } from './CollectionPlaces.table';+import type { CollectionsTable } from './Collections.table';+import type { DawarichConnectionsTable } from './DawarichConnections.table';+import type { DawarichVisitSuggestionsTable } from './DawarichVisitSuggestions.table';+import type { DayAccommodationsTable } from './DayAccommodations.table';+import type { DayAssignmentsTable } from './DayAssignments.table';+import type { DayNotesTable } from './DayNotes.table';+import type { DaysTable } from './Days.table';+import type { DocumentConnectionsTable } from './DocumentConnections.table';+import type { DocumentProviderFieldsTable } from './DocumentProviderFields.table';+import type { DocumentProvidersTable } from './DocumentProviders.table';+import type { DocumentSyncItemsTable } from './DocumentSyncItems.table';+import type { FileLinksTable } from './FileLinks.table';+import type { GoogleApiUsageTable } from './GoogleApiUsage.table';+import type { GooglePlacePhotoMetaTable } from './GooglePlacePhotoMeta.table';+import type { HiddenCountriesTable } from './HiddenCountries.table';+import type { HiddenRegionsTable } from './HiddenRegions.table';+import type { IdempotencyKeysTable } from './IdempotencyKeys.table';+import type { InviteTokensTable } from './InviteTokens.table';+import type { JourneyBooksTable } from './JourneyBooks.table';+import type { JourneyContributorsTable } from './JourneyContributors.table';+import type { JourneyEntriesTable } from './JourneyEntries.table';+import type { JourneyEntryPhotosTable } from './JourneyEntryPhotos.table';+import type { JourneyPhotosTable } from './JourneyPhotos.table';+import type { JourneyShareTokensTable } from './JourneyShareTokens.table';+import type { JourneyTripsTable } from './JourneyTrips.table';+import type { JourneysTable } from './Journeys.table';+import type { McpTokensTable } from './McpTokens.table';+import type { MigrationsTable } from './Migrations.table';+import type { NotificationChannelPreferencesTable } from './NotificationChannelPreferences.table';+import type { NotificationsTable } from './Notifications.table';+import type { OauthClientsTable } from './OauthClients.table';+import type { OauthConsentsTable } from './OauthConsents.table';+import type { OauthTokensTable } from './OauthTokens.table';+import type { PackingBagMembersTable } from './PackingBagMembers.table';+import type { PackingBagsTable } from './PackingBags.table';+import type { PackingCategoryAssigneesTable } from './PackingCategoryAssignees.table';+import type { PackingItemContributorsTable } from './PackingItemContributors.table';+import type { PackingItemRecipientsTable } from './PackingItemRecipients.table';+import type { PackingItemsTable } from './PackingItems.table';+import type { PackingTemplateCategoriesTable } from './PackingTemplateCategories.table';+import type { PackingTemplateItemsTable } from './PackingTemplateItems.table';+import type { PackingTemplatesTable } from './PackingTemplates.table';+import type { PasswordResetTokensTable } from './PasswordResetTokens.table';+import type { PhotoProviderFieldsTable } from './PhotoProviderFields.table';+import type { PhotoProvidersTable } from './PhotoProviders.table';+import type { PhotosTable } from './Photos.table';+import type { PlaceDetailsCacheTable } from './PlaceDetailsCache.table';+import type { PlaceRatingsTable } from './PlaceRatings.table';+import type { PlaceRegionsTable } from './PlaceRegions.table';+import type { PlaceShadowPicksTable } from './PlaceShadowPicks.table';+import type { PlaceTagsTable } from './PlaceTags.table';+import type { PlacesTable } from './Places.table';+import type { PluginActionsTable } from './PluginActions.table';+import type { PluginCapabilityAuditTable } from './PluginCapabilityAudit.table';+import type { PluginEgressHostsTable } from './PluginEgressHosts.table';+import type { PluginEntityMetadataTable } from './PluginEntityMetadata.table';+import type { PluginErrorLogTable } from './PluginErrorLog.table';+import type { PluginMetaMigrationsTable } from './PluginMetaMigrations.table';+import type { PluginOauthStateTable } from './PluginOauthState.table';+import type { PluginOauthTokensTable } from './PluginOauthTokens.table';+import type { PluginScheduledTasksTable } from './PluginScheduledTasks.table';+import type { PluginSettingsFieldsTable } from './PluginSettingsFields.table';+import type { PluginUserConfigTable } from './PluginUserConfig.table';+import type { PluginUserErasureQueueTable } from './PluginUserErasureQueue.table';+import type { PluginsTable } from './Plugins.table';+import type { PushSubscriptionsTable } from './PushSubscriptions.table';+import type { ReservationDayPositionsTable } from './ReservationDayPositions.table';+import type { ReservationEndpointsTable } from './ReservationEndpoints.table';+import type { ReservationTravelersTable } from './ReservationTravelers.table';+import type { ReservationsTable } from './Reservations.table';+import type { RoadtripDayBoundariesTable } from './RoadtripDayBoundaries.table';+import type { RoadtripDayTracksTable } from './RoadtripDayTracks.table';+import type { RoadtripPreferencesTable } from './RoadtripPreferences.table';+import type { RoadtripViasTable } from './RoadtripVias.table';+import type { RouteUsageDailyTable } from './RouteUsageDaily.table';+import type { SchemaVersionTable } from './SchemaVersion.table';+import type { SchoolHolidayCountriesTable } from './SchoolHolidayCountries.table';+import type { SchoolHolidayPeriodsTable } from './SchoolHolidayPeriods.table';+import type { SchoolHolidayRegionsTable } from './SchoolHolidayRegions.table';+import type { SettingsTable } from './Settings.table';+import type { ShareTokensTable } from './ShareTokens.table';+import type { TagsTable } from './Tags.table';+import type { TodoCategoryAssigneesTable } from './TodoCategoryAssignees.table';+import type { TodoItemsTable } from './TodoItems.table';+import type { TourTypesTable } from './TourTypes.table';+import type { TourWaypointsTable } from './TourWaypoints.table';+import type { ToursTable } from './Tours.table';+import type { TrekPhotoCacheMetaTable } from './TrekPhotoCacheMeta.table';+import type { TrekPhotosTable } from './TrekPhotos.table';+import type { TripAlbumLinksTable } from './TripAlbumLinks.table';+import type { TripDocumentLinksTable } from './TripDocumentLinks.table';+import type { TripFilesTable } from './TripFiles.table';+import type { TripInviteTokensTable } from './TripInviteTokens.table';+import type { TripMembersTable } from './TripMembers.table';+import type { TripPhotosTable } from './TripPhotos.table';+import type { TripsTable } from './Trips.table';+import type { UserNoticeDismissalsTable } from './UserNoticeDismissals.table';+import type { UsersTable } from './Users.table';+import type { VacayCompanyHolidaysTable } from './VacayCompanyHolidays.table';+import type { VacayEntriesTable } from './VacayEntries.table';+import type { VacayHolidayCalendarsTable } from './VacayHolidayCalendars.table';+import type { VacayPlanMembersTable } from './VacayPlanMembers.table';+import type { VacayPlansTable } from './VacayPlans.table';+import type { VacaySharesTable } from './VacayShares.table';+import type { VacayUserColorsTable } from './VacayUserColors.table';+import type { VacayUserSettingsTable } from './VacayUserSettings.table';+import type { VacayUserYearsTable } from './VacayUserYears.table';+import type { VacayYearsTable } from './VacayYears.table';+import type { VisitedCountriesTable } from './VisitedCountries.table';+import type { VisitedRegionsTable } from './VisitedRegions.table';+import type { WebauthnChallengesTable } from './WebauthnChallenges.table';+import type { WebauthnCredentialsTable } from './WebauthnCredentials.table';++/** Every table of the migrated schema. A repository narrows it: `this.kysely<Pick<DB, 'trips'>>()`. */+export interface DB {+ addons: AddonsTable;+ app_settings: AppSettingsTable;+ assignment_participants: AssignmentParticipantsTable;+ audit_log: AuditLogTable;+ bucket_list: BucketListTable;+ budget_category_order: BudgetCategoryOrderTable;+ budget_item_members: BudgetItemMembersTable;+ budget_item_payers: BudgetItemPayersTable;+ budget_items: BudgetItemsTable;+ budget_settlements: BudgetSettlementsTable;+ categories: CategoriesTable;+ collab_links: CollabLinksTable;+ collab_message_reactions: CollabMessageReactionsTable;+ collab_messages: CollabMessagesTable;+ collab_notes: CollabNotesTable;+ collab_poll_votes: CollabPollVotesTable;+ collab_polls: CollabPollsTable;+ collection_labels: CollectionLabelsTable;+ collection_members: CollectionMembersTable;+ collection_place_labels: CollectionPlaceLabelsTable;+ collection_place_ratings: CollectionPlaceRatingsTable;+ collection_place_tags: CollectionPlaceTagsTable;+ collection_places: CollectionPlacesTable;+ collections: CollectionsTable;+ dawarich_connections: DawarichConnectionsTable;+ dawarich_visit_suggestions: DawarichVisitSuggestionsTable;+ day_accommodations: DayAccommodationsTable;+ day_assignments: DayAssignmentsTable;+ day_notes: DayNotesTable;+ days: DaysTable;+ document_connections: DocumentConnectionsTable;+ document_provider_fields: DocumentProviderFieldsTable;+ document_providers: DocumentProvidersTable;+ document_sync_items: DocumentSyncItemsTable;+ file_links: FileLinksTable;+ google_api_usage: GoogleApiUsageTable;+ google_place_photo_meta: GooglePlacePhotoMetaTable;+ hidden_countries: HiddenCountriesTable;+ hidden_regions: HiddenRegionsTable;+ idempotency_keys: IdempotencyKeysTable;+ invite_tokens: InviteTokensTable;+ journey_books: JourneyBooksTable;+ journey_contributors: JourneyContributorsTable;+ journey_entries: JourneyEntriesTable;+ journey_entry_photos: JourneyEntryPhotosTable;+ journey_photos: JourneyPhotosTable;+ journey_share_tokens: JourneyShareTokensTable;+ journey_trips: JourneyTripsTable;+ journeys: JourneysTable;+ mcp_tokens: McpTokensTable;+ migrations: MigrationsTable;+ notification_channel_preferences: NotificationChannelPreferencesTable;+ notifications: NotificationsTable;+ oauth_clients: OauthClientsTable;+ oauth_consents: OauthConsentsTable;+ oauth_tokens: OauthTokensTable;+ packing_bag_members: PackingBagMembersTable;+ packing_bags: PackingBagsTable;+ packing_category_assignees: PackingCategoryAssigneesTable;+ packing_item_contributors: PackingItemContributorsTable;+ packing_item_recipients: PackingItemRecipientsTable;+ packing_items: PackingItemsTable;+ packing_template_categories: PackingTemplateCategoriesTable;+ packing_template_items: PackingTemplateItemsTable;+ packing_templates: PackingTemplatesTable;+ password_reset_tokens: PasswordResetTokensTable;+ photo_provider_fields: PhotoProviderFieldsTable;+ photo_providers: PhotoProvidersTable;+ photos: PhotosTable;+ place_details_cache: PlaceDetailsCacheTable;+ place_ratings: PlaceRatingsTable;+ place_regions: PlaceRegionsTable;+ place_shadow_picks: PlaceShadowPicksTable;+ place_tags: PlaceTagsTable;+ places: PlacesTable;+ plugin_actions: PluginActionsTable;+ plugin_capability_audit: PluginCapabilityAuditTable;+ plugin_egress_hosts: PluginEgressHostsTable;+ plugin_entity_metadata: PluginEntityMetadataTable;+ plugin_error_log: PluginErrorLogTable;+ plugin_meta_migrations: PluginMetaMigrationsTable;+ plugin_oauth_state: PluginOauthStateTable;+ plugin_oauth_tokens: PluginOauthTokensTable;+ plugin_scheduled_tasks: PluginScheduledTasksTable;+ plugin_settings_fields: PluginSettingsFieldsTable;+ plugin_user_config: PluginUserConfigTable;+ plugin_user_erasure_queue: PluginUserErasureQueueTable;+ plugins: PluginsTable;+ push_subscriptions: PushSubscriptionsTable;+ reservation_day_positions: ReservationDayPositionsTable;+ reservation_endpoints: ReservationEndpointsTable;+ reservation_travelers: ReservationTravelersTable;+ reservations: ReservationsTable;+ roadtrip_day_boundaries: RoadtripDayBoundariesTable;+ roadtrip_day_tracks: RoadtripDayTracksTable;+ roadtrip_preferences: RoadtripPreferencesTable;+ roadtrip_vias: RoadtripViasTable;+ route_usage_daily: RouteUsageDailyTable;+ schema_version: SchemaVersionTable;+ school_holiday_countries: SchoolHolidayCountriesTable;+ school_holiday_periods: SchoolHolidayPeriodsTable;+ school_holiday_regions: SchoolHolidayRegionsTable;+ settings: SettingsTable;+ share_tokens: ShareTokensTable;+ tags: TagsTable;+ todo_category_assignees: TodoCategoryAssigneesTable;+ todo_items: TodoItemsTable;+ tour_types: TourTypesTable;+ tour_waypoints: TourWaypointsTable;+ tours: ToursTable;+ trek_photo_cache_meta: TrekPhotoCacheMetaTable;+ trek_photos: TrekPhotosTable;+ trip_album_links: TripAlbumLinksTable;+ trip_document_links: TripDocumentLinksTable;+ trip_files: TripFilesTable;+ trip_invite_tokens: TripInviteTokensTable;+ trip_members: TripMembersTable;+ trip_photos: TripPhotosTable;+ trips: TripsTable;+ user_notice_dismissals: UserNoticeDismissalsTable;+ users: UsersTable;+ vacay_company_holidays: VacayCompanyHolidaysTable;+ vacay_entries: VacayEntriesTable;+ vacay_holiday_calendars: VacayHolidayCalendarsTable;+ vacay_plan_members: VacayPlanMembersTable;+ vacay_plans: VacayPlansTable;+ vacay_shares: VacaySharesTable;+ vacay_user_colors: VacayUserColorsTable;+ vacay_user_settings: VacayUserSettingsTable;+ vacay_user_years: VacayUserYearsTable;+ vacay_years: VacayYearsTable;+ visited_countries: VisitedCountriesTable;+ visited_regions: VisitedRegionsTable;+ webauthn_challenges: WebauthnChallengesTable;+ webauthn_credentials: WebauthnCredentialsTable;+}diff --git a/server/src/db/repositories/AuditLog.repository.ts b/server/src/db/repositories/AuditLog.repository.tsindex 2ed85642c..66fe1180f 100644--- a/server/src/db/repositories/AuditLog.repository.ts+++ b/server/src/db/repositories/AuditLog.repository.ts@@ -1,6 +1,7 @@import { AuditLog } from '../entities/AuditLog.entity';import { type AssertRowKeys } from './_shared/rows';import { TrekRepository } from './_shared/trek-repository';+import type { DB } from '../kysely/db';/*** An `audit_log` row as the API emits it (Plan 3i's `admin.service.ts`@@ -47,11 +48,8 @@ export interface AuditLogPageRow {ip: string | null;}-/** Kysely shape for the `listPage` join — only the columns it actually selects. */-interface AuditLogKyselyDB {- audit_log: AuditLogRow;- users: { id: number; username: string; email: string };-}+/** The tables the `listPage` join reads. */+type AuditLogKyselyDB = Pick<DB, 'audit_log' | 'users'>;export class AuditLogRepository extends TrekRepository<AuditLog> {/**diff --git a/server/src/db/repositories/BucketList.repository.ts b/server/src/db/repositories/BucketList.repository.tsindex d560ce5e0..9cd602888 100644--- a/server/src/db/repositories/BucketList.repository.ts+++ b/server/src/db/repositories/BucketList.repository.ts@@ -2,6 +2,7 @@ import { lowerTrim, lowerTrimParam } from '../dialect/sql-functions';import type { BucketList } from '../entities/BucketList.entity';import { presenceSet } from './_shared/presence-set';import { TrekRepository } from './_shared/trek-repository';+import type { DB } from '../kysely/db';/** `bucket_list` — every scalar column, `AT30`/`AT33`/`AT34`'s `SELECT *` shape. */export interface BucketListRow {@@ -20,31 +21,17 @@ export interface BucketListRow {}/**- * Three separate table shapes for the SAME `bucket_list` table (the- * `VisitedCountriesRepository`'s own docstring explains why one shared- * shape doesn't work for both reads and writes): the full row for- * {@link listForUser}/{@link findById}/{@link findForUser}'s `SELECT *`;- * the exact 8-column legacy `INSERT` list for {@link insertItem} (`id`,- * `created_at`, `visited_at`, `visited_source` are never bound —- * `created_at` via the schema's `DEFAULT CURRENT_TIMESTAMP`, the rest via- * SQLite's ordinary "omitted nullable column ⇒ NULL"); `id`/`user_id` plus- * the six settable columns for {@link update}/{@link deleteForUser}, which- * only ever `.set()`/`.where()` — never `.values()` — so no insert-only- * column needs excluding there.+ * The generated `bucket_list` table, under one alias per statement family:+ * the `SELECT *` reads ({@link listForUser}/{@link findById}/{@link findForUser}),+ * the 8-column legacy `INSERT` of {@link insertItem} (`id`, `created_at`,+ * `visited_at` and `visited_source` stay unbound: the columns the statement leaves out (the rowid, defaulted and nullable ones) are `InsertOptional` in the generated type, so `.values()` may omit them) and the+ * `.set()`/`.where()` writes of {@link update}/{@link deleteForUser}.*/-interface BucketListReadKyselyDB {- bucket_list: BucketListRow;-}-interface BucketListInsertKyselyDB {- bucket_list: { user_id: number; name: string; lat: number | null; lng: number | null; country_code: string | null; notes: string | null; target_date: string | null; region_code: string | null };-}-interface BucketListWriteKyselyDB {- bucket_list: { id: number; user_id: number; name: string; notes: string | null; lat: number | null; lng: number | null; country_code: string | null; target_date: string | null };-}-/** The narrow `bucket_list` shape Plan 3h Task 3's visited-tick writes (DWS9/13/15) need. */-interface BucketListVisitKyselyDB {- bucket_list: { id: number; user_id: number; visited_at: string | null; visited_source: string | null };-}+type BucketListReadKyselyDB = Pick<DB, 'bucket_list'>;+type BucketListInsertKyselyDB = Pick<DB, 'bucket_list'>;+type BucketListWriteKyselyDB = Pick<DB, 'bucket_list'>;+/** The `bucket_list` table Plan 3h Task 3's visited-tick writes (DWS9/13/15) touch. */+type BucketListVisitKyselyDB = Pick<DB, 'bucket_list'>;/** The six columns `findDuplicate`'s #1898 dedup identity compares (`AT31`). */export interface BucketListIdentity {diff --git a/server/src/db/repositories/BudgetCategoryOrder.repository.ts b/server/src/db/repositories/BudgetCategoryOrder.repository.tsindex da79c722a..859e6b240 100644--- a/server/src/db/repositories/BudgetCategoryOrder.repository.ts+++ b/server/src/db/repositories/BudgetCategoryOrder.repository.ts@@ -1,9 +1,8 @@import type { BudgetCategoryOrder } from '../entities/BudgetCategoryOrder.entity';import { TrekRepository } from './_shared/trek-repository';+import type { DB } from '../kysely/db';-interface BudgetCategoryOrderKyselyDB {- budget_category_order: { trip_id: number; category: string; sort_order: number };-}+type BudgetCategoryOrderKyselyDB = Pick<DB, 'budget_category_order'>;/*** `budget_category_order` — a composite-PK `(trip_id, category)` table (nodiff --git a/server/src/db/repositories/BudgetItemMembers.repository.ts b/server/src/db/repositories/BudgetItemMembers.repository.tsindex aaef58bd5..7047d6fc0 100644--- a/server/src/db/repositories/BudgetItemMembers.repository.ts+++ b/server/src/db/repositories/BudgetItemMembers.repository.ts@@ -1,6 +1,7 @@import type { BudgetItemMembers } from '../entities/BudgetItemMembers.entity';import { type AssertRowKeys } from './_shared/rows';import { TrekRepository } from './_shared/trek-repository';+import type { DB } from '../kysely/db';/** A bare `budget_item_members` row — every scalar column, incl. the two `persist(false)` relation mirrors. */export interface BudgetItemMemberRow {@@ -22,15 +23,10 @@ export interface BudgetItemMemberWithUserRow {avatar: string | null;}-interface BudgetItemMembersKyselyDB {- budget_item_members: BudgetItemMemberRow;- users: { id: number; username: string; display_name: string | null; avatar: string | null };-}+type BudgetItemMembersKyselyDB = Pick<DB, 'budget_item_members' | 'users'>;-/** The insert-only shape — `id` is autoincrement and omitted from `.values()` below, matching `FileLinksWriteKyselyDB`'s precedent. */-interface BudgetItemMembersWriteKyselyDB {- budget_item_members: { budget_item_id: number; user_id: number; paid: number; amount: number | null };-}+/** The insert's table: `id` is the rowid and `InsertOptional` in the generated type, so `.values()` below omits it. */+type BudgetItemMembersWriteKyselyDB = Pick<DB, 'budget_item_members'>;/*** `budget_item_members` — who splits a budget item, and whether they've@@ -74,7 +70,7 @@ export class BudgetItemMembersRepository extends TrekRepository<BudgetItemMember/** TP62 (`TripsService.copy`'s bare member read) — `SELECT bm.* FROM budget_item_members bm JOIN budget_items b ON b.id = bm.budget_item_id WHERE b.trip_id = ?`. */async listRawForTrip(trip_id: number | string): Promise<BudgetItemMemberRow[]> {- return await this.kysely<BudgetItemMembersKyselyDB & { budget_items: { id: number; trip_id: number } }>()+ return await this.kysely<BudgetItemMembersKyselyDB & Pick<DB, 'budget_items'>>().selectFrom('budget_item_members as bm').innerJoin('budget_items as b', 'b.id', 'bm.budget_item_id').select(['bm.id', 'bm.budget_item_id', 'bm.user_id', 'bm.paid', 'bm.amount'])@@ -84,7 +80,7 @@ export class BudgetItemMembersRepository extends TrekRepository<BudgetItemMember/** BG73 (`calculateSettlement`'s member read) — the `budget_item_id IN (SELECT id FROM budget_items WHERE trip_id = ?)` subquery, re-expressed as a join (rule 23) — same result set. No `paid` column — unlike {@link listForItem}, this legacy statement never selected it. */async listForTripWithUsers(trip_id: number | string): Promise<{ budget_item_id: number; user_id: number; amount: number | null; username: string; avatar: string | null }[]> {- return await this.kysely<BudgetItemMembersKyselyDB & { budget_items: { id: number; trip_id: number } }>()+ return await this.kysely<BudgetItemMembersKyselyDB & Pick<DB, 'budget_items'>>().selectFrom('budget_item_members as bm').innerJoin('budget_items as b', 'b.id', 'bm.budget_item_id').innerJoin('users as u', 'u.id', 'bm.user_id')@@ -101,7 +97,7 @@ export class BudgetItemMembersRepository extends TrekRepository<BudgetItemMember* bi.trip_id = ?`. Like {@link listForTripWithUsers}, plus `paid`.*/async listForTripWithUsersAndPaid(trip_id: number | string): Promise<(BudgetItemMemberWithUserRow & { budget_item_id: number })[]> {- return await this.kysely<BudgetItemMembersKyselyDB & { budget_items: { id: number; trip_id: number } }>()+ return await this.kysely<BudgetItemMembersKyselyDB & Pick<DB, 'budget_items'>>().selectFrom('budget_item_members as bm').innerJoin('budget_items as bi', 'bi.id', 'bm.budget_item_id').innerJoin('users as u', 'u.id', 'bm.user_id')diff --git a/server/src/db/repositories/BudgetItemPayers.repository.ts b/server/src/db/repositories/BudgetItemPayers.repository.tsindex 19d3ad0d9..b6c322f6a 100644--- a/server/src/db/repositories/BudgetItemPayers.repository.ts+++ b/server/src/db/repositories/BudgetItemPayers.repository.ts@@ -1,6 +1,7 @@import type { BudgetItemPayers } from '../entities/BudgetItemPayers.entity';import { type AssertRowKeys } from './_shared/rows';import { TrekRepository } from './_shared/trek-repository';+import type { DB } from '../kysely/db';/** A bare `budget_item_payers` row — every scalar column, incl. the two `persist(false)` relation mirrors. */export interface BudgetItemPayerRow {@@ -20,15 +21,10 @@ export interface BudgetItemPayerWithUserRow {avatar: string | null;}-interface BudgetItemPayersKyselyDB {- budget_item_payers: BudgetItemPayerRow;- users: { id: number; username: string; display_name: string | null; avatar: string | null };-}+type BudgetItemPayersKyselyDB = Pick<DB, 'budget_item_payers' | 'users'>;-/** The insert-only shape — `id` is autoincrement and omitted from `.values()` below, matching `FileLinksWriteKyselyDB`'s precedent. */-interface BudgetItemPayersWriteKyselyDB {- budget_item_payers: { budget_item_id: number; user_id: number; amount: number };-}+/** The insert's table: `id` is the rowid and `InsertOptional` in the generated type, so `.values()` below omits it. */+type BudgetItemPayersWriteKyselyDB = Pick<DB, 'budget_item_payers'>;/*** `budget_item_payers` — who actually paid a budget item, and how much.@@ -60,7 +56,7 @@ export class BudgetItemPayersRepository extends TrekRepository<BudgetItemPayers>/** TP64 (`TripsService.copy`'s bare payer read) — `SELECT bp.* FROM budget_item_payers bp JOIN budget_items b ON b.id = bp.budget_item_id WHERE b.trip_id = ?`. */async listRawForTrip(trip_id: number | string): Promise<BudgetItemPayerRow[]> {- return await this.kysely<BudgetItemPayersKyselyDB & { budget_items: { id: number; trip_id: number } }>()+ return await this.kysely<BudgetItemPayersKyselyDB & Pick<DB, 'budget_items'>>().selectFrom('budget_item_payers as bp').innerJoin('budget_items as b', 'b.id', 'bp.budget_item_id').select(['bp.id', 'bp.budget_item_id', 'bp.user_id', 'bp.amount'])@@ -70,7 +66,7 @@ export class BudgetItemPayersRepository extends TrekRepository<BudgetItemPayers>/** BG74 (`calculateSettlement`'s payer read) — the `budget_item_id IN (SELECT id FROM budget_items WHERE trip_id = ?)` subquery, re-expressed as a join (rule 23) — same result set. */async listForTripWithUsers(trip_id: number | string): Promise<(BudgetItemPayerWithUserRow & { budget_item_id: number })[]> {- return await this.kysely<BudgetItemPayersKyselyDB & { budget_items: { id: number; trip_id: number } }>()+ return await this.kysely<BudgetItemPayersKyselyDB & Pick<DB, 'budget_items'>>().selectFrom('budget_item_payers as bp').innerJoin('budget_items as b', 'b.id', 'bp.budget_item_id').innerJoin('users as u', 'u.id', 'bp.user_id')diff --git a/server/src/db/repositories/BudgetItems.repository.ts b/server/src/db/repositories/BudgetItems.repository.tsindex 0d7f1decf..b3ac9b135 100644--- a/server/src/db/repositories/BudgetItems.repository.ts+++ b/server/src/db/repositories/BudgetItems.repository.ts@@ -3,6 +3,7 @@ import { columnRef } from '../dialect/sql-functions';import { type AssertRowKeys } from './_shared/rows';import { TrekRepository } from './_shared/trek-repository';import { presenceSet } from './_shared/presence-set';+import type { DB } from '../kysely/db';/** A bare `budget_items` row — every scalar column, incl. the four `persist(false)` relation mirrors (the program-wide trap this class goes through Kysely to avoid). */export interface BudgetItemRow {@@ -55,37 +56,18 @@ export interface BudgetItemMoneyRow {exchange_rate: number;}-interface BudgetKyselyDB {- budget_items: BudgetItemRow;- budget_item_members: { id: number; budget_item_id: number; user_id: number; paid: number; amount: number | null };- budget_category_order: { trip_id: number; category: string; sort_order: number };- users: { id: number; username: string; display_name: string | null; avatar: string | null };- trip_files: { id: number; filename: string; original_name: string; file_size: number | null; mime_type: string | null; trip_id: number; deleted_at: string | null; created_at: string | null };- file_links: { id: number; file_id: number; reservation_id: number | null; assignment_id: number | null; place_id: number | null; budget_item_id: number | null; created_at: string | null };-}+type BudgetKyselyDB = Pick<DB, 'budget_items' | 'budget_item_members' | 'budget_category_order' | 'users' | 'trip_files' | 'file_links'>;/**- * The insert-only shape for `create` (BG25) — omits `id`/`created_at`- * (autoincrement/`DEFAULT CURRENT_TIMESTAMP`, matching the legacy column- * list) and `paid_by_user_id` (never written by `BudgetService` — R11/§17- * surprise 7, only `UserCleanupService`'s UC5 touches it).+ * The table `create` (BG25) inserts into. It binds the legacy column list:+ * `id`/`created_at` are filled by the schema and `paid_by_user_id` is never+ * written by `BudgetService` (R11/§17 surprise 7, only `UserCleanupService`'s+ * UC5 touches it); the columns the statement leaves out (the rowid, defaulted and nullable ones) are `InsertOptional` in the generated type, so `.values()` may omit them.*/-interface BudgetItemsInsertKyselyDB {- budget_items: {- trip_id: number | string; category: string; name: string; total_price: number; currency: string | null;- exchange_rate: number; persons: number | null; days: number | null; note: string | null; ticket_json: string | null;- sort_order: number; expense_date: string | null; reservation_id: number | null; place_id: number | null;- };-}+type BudgetItemsInsertKyselyDB = Pick<DB, 'budget_items'>;-/** The insert-only shape for `insertCopy` (TP61) — a distinct column set/order from `create`'s, carrying `paid_by_user_id` verbatim (§17). */-interface BudgetItemsCopyInsertKyselyDB {- budget_items: {- trip_id: number | string; category: string; name: string; total_price: number; persons: number | null; days: number | null;- note: string | null; sort_order: number | null; reservation_id: number | null; currency: string | null;- exchange_rate: number; expense_date: string | null; ticket_json: string | null; paid_by_user_id: number | null;- };-}+/** The table `insertCopy` (TP61) inserts into, with a distinct column set/order from `create`'s, carrying `paid_by_user_id` verbatim (§17). */+type BudgetItemsCopyInsertKyselyDB = Pick<DB, 'budget_items'>;/*** `budget_items` — the expense rows themselves, plus this domain's own view@@ -171,7 +153,7 @@ export class BudgetItemsRepository extends TrekRepository<BudgetItems> {exchange_rate: number; persons: number | null; days: number | null; note: string | null; ticket_json: string | null;sort_order: number; expense_date: string | null; reservation_id: number | null; place_id: number | null;}): Promise<number> {- const result = await this.kysely<BudgetItemsInsertKyselyDB>().insertInto('budget_items').values(row).executeTakeFirstOrThrow();+ const result = await this.kysely<BudgetItemsInsertKyselyDB>().insertInto('budget_items').values({ ...row, trip_id: row.trip_id as number }).executeTakeFirstOrThrow();return Number(result.insertId);}@@ -188,7 +170,7 @@ export class BudgetItemsRepository extends TrekRepository<BudgetItems> {note: string | null; sort_order: number | null; reservation_id: number | null; currency: string | null;exchange_rate: number; expense_date: string | null; ticket_json: string | null; paid_by_user_id: number | null;}): Promise<number> {- const result = await this.kysely<BudgetItemsCopyInsertKyselyDB>().insertInto('budget_items').values(row).executeTakeFirstOrThrow();+ const result = await this.kysely<BudgetItemsCopyInsertKyselyDB>().insertInto('budget_items').values({ ...row, trip_id: row.trip_id as number }).executeTakeFirstOrThrow();return Number(result.insertId);}@@ -447,7 +429,7 @@ export class BudgetItemsRepository extends TrekRepository<BudgetItems> {/** BG28/BG45 — `INSERT OR IGNORE INTO file_links (file_id, budget_item_id) VALUES (?, ?)`. */async insertReceiptLink(file_id: number, budget_item_id: number | string): Promise<void> {- await this.kysely<{ file_links: { file_id: number; budget_item_id: number } }>()+ await this.kysely<Pick<DB, 'file_links'>>().insertInto('file_links').values({ file_id, budget_item_id: budget_item_id as number }).onConflict((oc) => oc.doNothing())diff --git a/server/src/db/repositories/BudgetSettlements.repository.ts b/server/src/db/repositories/BudgetSettlements.repository.tsindex 5d92403ea..5e1a53bd0 100644--- a/server/src/db/repositories/BudgetSettlements.repository.ts+++ b/server/src/db/repositories/BudgetSettlements.repository.ts@@ -2,6 +2,7 @@ import type { BudgetSettlements } from '../entities/BudgetSettlements.entity';import { type AssertRowKeys } from './_shared/rows';import { TrekRepository } from './_shared/trek-repository';import { presenceSet } from './_shared/presence-set';+import type { DB } from '../kysely/db';/** A bare `budget_settlements` row — every scalar column, incl. the `persist(false)` relation mirrors. */export interface BudgetSettlementRow {@@ -28,26 +29,15 @@ export interface BudgetSettlementWithUsersRow extends BudgetSettlementRow {to_avatar: string | null;}-interface BudgetSettlementsKyselyDB {- budget_settlements: BudgetSettlementRow;- users: { id: number; username: string; display_name: string | null; avatar: string | null };-}+type BudgetSettlementsKyselyDB = Pick<DB, 'budget_settlements' | 'users'>;/**- * The insert-only shape — `id`/`created_at` are autoincrement/`DEFAULT+ * The insert's table. `id`/`created_at` are autoincrement/`DEFAULT* CURRENT_TIMESTAMP` and omitted from `.values()` below (the legacy- * statement's own column list omits them too), matching the- * `FileLinksWriteKyselyDB`/`FileLinksRepository` precedent: a separate- * interface rather than making those two columns optional on- * {@link BudgetSettlementRow}, which would also loosen every SELECT- * method's inferred type.+ * statement's own column list omits them too); both are `InsertOptional`+ * in the generated type, so every SELECT still reads them as present.*/-interface BudgetSettlementsWriteKyselyDB {- budget_settlements: {- trip_id: number; from_user_id: number; to_user_id: number; amount: number;- currency: string | null; exchange_rate: number; settled_at: string | null; note: string | null; created_by_user_id: number | null;- };-}+type BudgetSettlementsWriteKyselyDB = Pick<DB, 'budget_settlements'>;/*** `budget_settlements` — recorded settle-up transfers. Kysely throughout,diff --git a/server/src/db/repositories/CollabLinks.repository.ts b/server/src/db/repositories/CollabLinks.repository.tsindex bc32f05a4..b7a4f640b 100644--- a/server/src/db/repositories/CollabLinks.repository.ts+++ b/server/src/db/repositories/CollabLinks.repository.ts@@ -2,6 +2,7 @@ import type { CollabLinks } from '../entities/CollabLinks.entity';import { currentTimestamp } from '../dialect/sql-functions';import { type AssertRowKeys } from './_shared/rows';import { TrekRepository } from './_shared/trek-repository';+import type { DB } from '../kysely/db';/** A bare `collab_links` row — every scalar column of the entity, incl. the two `persist(false)` relation mirrors (`trip_id`, `user_id`). */export interface CollabLinkRow {@@ -22,10 +23,7 @@ export interface CollabLinkJoinRow extends CollabLinkRow {username: string;}-interface CollabLinksKyselyDB {- collab_links: CollabLinkRow;- users: { id: number; username: string };-}+type CollabLinksKyselyDB = Pick<DB, 'collab_links' | 'users'>;/*** `collab_links` — pinned/shared trip links. Kysely throughout: `trip_id`/diff --git a/server/src/db/repositories/CollabMessages.repository.ts b/server/src/db/repositories/CollabMessages.repository.tsindex fc74dc207..b26eabf06 100644--- a/server/src/db/repositories/CollabMessages.repository.ts+++ b/server/src/db/repositories/CollabMessages.repository.ts@@ -2,6 +2,7 @@ import type { CollabMessages } from '../entities/CollabMessages.entity';import type { TripFileRow } from './TripFiles.repository';import { type AssertRowKeys } from './_shared/rows';import { TrekRepository } from './_shared/trek-repository';+import type { DB } from '../kysely/db';/** A bare `collab_messages` row — every scalar column of the entity, incl. the three `persist(false)` mirrors (`trip_id`, `user_id`, `reply_to`). */export interface CollabMessageRow {@@ -30,15 +31,10 @@ export interface SharePublicCollabMessageRow extends CollabMessageRow {avatar: string | null;}-interface CollabMessagesKyselyDB {- collab_messages: CollabMessageRow;- users: { id: number; username: string; avatar: string | null };-}+type CollabMessagesKyselyDB = Pick<DB, 'collab_messages' | 'users'>;-/** Only the `trip_files` columns the message-attachment methods below touch — the `CollabNotesRepository` class docstring explains why they live on the OWNING collab entity's repository rather than on `TripFilesRepository`. */-interface MessageAttachmentsKyselyDB {- trip_files: TripFileRow;-}+/** The `trip_files` table the message-attachment methods below touch (the `CollabNotesRepository` class docstring explains why they live on the OWNING collab entity's repository rather than on `TripFilesRepository`). */+type MessageAttachmentsKyselyDB = Pick<DB, 'trip_files'>;/** CB43's narrow attachment projection (`formatMessage`'s hydration read). `message_id` keeps `TripFileRow`'s own nullable typing even though the WHERE clause below always matches a non-null value — no narrowing cast. */export interface MessageAttachmentRow {@@ -51,18 +47,8 @@ export interface MessageAttachmentRow {mime_type: string | null;}-/** CB49's insert-only shape — every OTHER `trip_files` column is autoincrement/nullable-defaulted and omitted, matching the legacy statement's own seven-column list (the `NoteAttachmentInsertKyselyDB` precedent, `CollabNotes.repository.ts`). */-interface MessageAttachmentInsertKyselyDB {- trip_files: {- trip_id: number | string;- message_id: number | string;- filename: string;- original_name: string;- file_size: number;- mime_type: string;- uploaded_by: number;- };-}+/** CB49's insert table: it binds the legacy statement's own seven-column list, and every other `trip_files` column is `InsertOptional` in the generated type. */+type MessageAttachmentInsertKyselyDB = Pick<DB, 'trip_files'>;/*** `collab_messages` — trip chat, plus (second half of this class) the@@ -206,8 +192,8 @@ export class CollabMessagesRepository extends TrekRepository<CollabMessages> {await this.kysely<MessageAttachmentInsertKyselyDB>().insertInto('trip_files').values({- trip_id: row.trip_id,- message_id: row.message_id,+ trip_id: row.trip_id as number,+ message_id: row.message_id as number,filename: row.filename,original_name: row.original_name,file_size: row.file_size,diff --git a/server/src/db/repositories/CollabNotes.repository.ts b/server/src/db/repositories/CollabNotes.repository.tsindex b9926aa7a..b099394f7 100644--- a/server/src/db/repositories/CollabNotes.repository.ts+++ b/server/src/db/repositories/CollabNotes.repository.ts@@ -3,6 +3,7 @@ import { currentTimestamp } from '../dialect/sql-functions';import type { TripFileRow } from './TripFiles.repository';import { type AssertRowKeys } from './_shared/rows';import { TrekRepository } from './_shared/trek-repository';+import type { DB } from '../kysely/db';/** A bare `collab_notes` row — every scalar column of the entity, incl. the two `persist(false)` relation mirrors (`trip_id`, `user_id`). */export interface CollabNoteRow {@@ -36,36 +37,17 @@ export interface NoteAttachmentRow {mime_type: string | null;}-interface CollabNotesKyselyDB {- collab_notes: CollabNoteRow;- users: { id: number; username: string; avatar: string | null };-}+type CollabNotesKyselyDB = Pick<DB, 'collab_notes' | 'users'>;-/** Only the `trip_files` columns the note-attachment methods below touch — see the class docstring's second half. */-interface NoteAttachmentsKyselyDB {- trip_files: TripFileRow;-}+/** The `trip_files` table the note-attachment methods below touch (see the class docstring's second half). */+type NoteAttachmentsKyselyDB = Pick<DB, 'trip_files'>;/**- * CB18's insert-only shape — `id`/`place_id`/`reservation_id`/`description`/- * `created_at`/`uploaded_by`/`starred`/`deleted_at`/`message_id` are- * autoincrement/nullable-defaulted and omitted from `.values()` below (the- * legacy statement's own six-column list omits them too), so a SEPARATE- * interface from {@link NoteAttachmentsKyselyDB} rather than widening that- * one's required columns (the `TripAlbumLinksInsertKyselyDB` /- * `FileLinksWriteKyselyDB` precedent: one purpose-shaped Kysely interface per- * statement).+ * CB18's insert table. It binds the legacy statement's own six-column list;+ * `id`/`place_id`/`reservation_id`/`description`/`created_at`/`uploaded_by`/+ * `starred`/`deleted_at`/`message_id` stay unbound, and the columns the statement leaves out (the rowid, defaulted and nullable ones) are `InsertOptional` in the generated type, so `.values()` may omit them.*/-interface NoteAttachmentInsertKyselyDB {- trip_files: {- trip_id: number | string;- note_id: number | string;- filename: string;- original_name: string;- file_size: number;- mime_type: string;- };-}+type NoteAttachmentInsertKyselyDB = Pick<DB, 'trip_files'>;/*** `collab_notes` — shared trip notes, plus (second half of this class) the@@ -226,7 +208,7 @@ export class CollabNotesRepository extends TrekRepository<CollabNotes> {async insertAttachmentForNote(row: { trip_id: number | string; note_id: number | string; filename: string; original_name: string; file_size: number; mime_type: string }): Promise<number> {const result = await this.kysely<NoteAttachmentInsertKyselyDB>().insertInto('trip_files')- .values({ trip_id: row.trip_id, note_id: row.note_id, filename: row.filename, original_name: row.original_name, file_size: row.file_size, mime_type: row.mime_type })+ .values({ trip_id: row.trip_id as number, note_id: row.note_id as number, filename: row.filename, original_name: row.original_name, file_size: row.file_size, mime_type: row.mime_type }).executeTakeFirstOrThrow();return Number(result.insertId);}diff --git a/server/src/db/repositories/CollabPolls.repository.ts b/server/src/db/repositories/CollabPolls.repository.tsindex dfa1434d2..2046e87b1 100644--- a/server/src/db/repositories/CollabPolls.repository.ts+++ b/server/src/db/repositories/CollabPolls.repository.ts@@ -1,6 +1,7 @@import type { CollabPolls } from '../entities/CollabPolls.entity';import { type AssertRowKeys } from './_shared/rows';import { TrekRepository } from './_shared/trek-repository';+import type { DB } from '../kysely/db';/** A bare `collab_polls` row — every scalar column of the entity, incl. the two `persist(false)` relation mirrors (`trip_id`, `user_id`). */export interface CollabPollRow {@@ -23,10 +24,7 @@ export interface CollabPollJoinRow extends CollabPollRow {avatar: string | null;}-interface CollabPollsKyselyDB {- collab_polls: CollabPollRow;- users: { id: number; username: string; avatar: string | null };-}+type CollabPollsKyselyDB = Pick<DB, 'collab_polls' | 'users'>;/*** `collab_polls` — decision polls. Kysely throughout: `trip_id`/`user_id`diff --git a/server/src/db/repositories/CollectionLabels.repository.ts b/server/src/db/repositories/CollectionLabels.repository.tsindex 37e58b272..216661c22 100644--- a/server/src/db/repositories/CollectionLabels.repository.ts+++ b/server/src/db/repositories/CollectionLabels.repository.ts@@ -1,6 +1,7 @@import type { CollectionLabels } from '../entities/CollectionLabels.entity';import { lower, lowerParam } from '../dialect/sql-functions';import { TrekRepository } from './_shared/trek-repository';+import type { DB } from '../kysely/db';/** `collection_labels` — `loadLabelsByCollection`'s (CL7) shape. */export interface CollectionLabelRow {@@ -11,21 +12,10 @@ export interface CollectionLabelRow {sort_order: number | null;}-interface CollectionLabelsKyselyDB {- collection_labels: {- id: number;- collection_id: number;- name: string;- color: string | null;- sort_order: number | null;- created_at: string | null;- };-}+type CollectionLabelsKyselyDB = Pick<DB, 'collection_labels'>;-/** CL20's own `INSERT INTO collection_labels (collection_id, name, color, sort_order)` column list, exactly — no `id`/`created_at`, the `BucketListInsertKyselyDB` narrower-insert-interface precedent. */-interface CollectionLabelsInsertKyselyDB {- collection_labels: { collection_id: number; name: string; color: string; sort_order: number };-}+/** CL20's insert table: it binds `INSERT INTO collection_labels (collection_id, name, color, sort_order)` exactly, and `id`/`created_at` are `InsertOptional` in the generated type. */+type CollectionLabelsInsertKyselyDB = Pick<DB, 'collection_labels'>;/*** `collection_labels` — Plan 3h Task 1's first cut. Owns Part A's owndiff --git a/server/src/db/repositories/CollectionMembers.repository.ts b/server/src/db/repositories/CollectionMembers.repository.tsindex 0bf6ebb1b..6de24c255 100644--- a/server/src/db/repositories/CollectionMembers.repository.ts+++ b/server/src/db/repositories/CollectionMembers.repository.ts@@ -1,5 +1,6 @@import type { CollectionMembers } from '../entities/CollectionMembers.entity';import { TrekRepository } from './_shared/trek-repository';+import type { DB } from '../kysely/db';/** `buildMembers`'s owner row — `collections` joined to `users` (CL12). */export interface CollectionOwnerMemberRow {@@ -15,19 +16,11 @@ export interface CollectionMemberRow extends CollectionOwnerMemberRow {role: string;}-interface CollectionOwnerKyselyDB {- collections: { id: number; owner_id: number };- users: { id: number; username: string; email: string; avatar: string | null };-}+type CollectionOwnerKyselyDB = Pick<DB, 'collections' | 'users'>;-interface CollectionMembersKyselyDB {- collection_members: { collection_id: number; user_id: number; status: string; role: string };- users: { id: number; username: string; email: string; avatar: string | null };-}+type CollectionMembersKyselyDB = Pick<DB, 'collection_members' | 'users'>;-interface CollectionMemberUserIdsKyselyDB {- collection_members: { collection_id: number; user_id: number; status: string };-}+type CollectionMemberUserIdsKyselyDB = Pick<DB, 'collection_members'>;/** `listCollections`'s incoming-invites read — a genuine statement missing* its own CL number in the plan's inventory gather (jumped CL15 → CL16@@ -42,11 +35,7 @@ export interface CollectionIncomingInviteRow {from_username: string;}-interface CollectionIncomingInvitesKyselyDB {- collection_members: { collection_id: number; user_id: number; status: string };- collections: { id: number; name: string; owner_id: number };- users: { id: number; username: string };-}+type CollectionIncomingInvitesKyselyDB = Pick<DB, 'collection_members' | 'collections' | 'users'>;/*** `collection_members` — Plan 3h Task 1's first cut (`roleOf`'s own member@@ -190,8 +179,5 @@ export class CollectionMembersRepository extends TrekRepository<CollectionMember}}-/** {@link CollectionMembersRepository.availableUsers}'s narrow `users`/`collection_members` shape. */-interface CollectionAvailableUsersKyselyDB {- users: { id: number; username: string; is_guest: number };- collection_members: { collection_id: number; user_id: number };-}+/** The `users`/`collection_members` tables {@link CollectionMembersRepository.availableUsers} reads. */+type CollectionAvailableUsersKyselyDB = Pick<DB, 'users' | 'collection_members'>;diff --git a/server/src/db/repositories/CollectionPlaceRatings.repository.ts b/server/src/db/repositories/CollectionPlaceRatings.repository.tsindex f30808f1c..2850563a0 100644--- a/server/src/db/repositories/CollectionPlaceRatings.repository.ts+++ b/server/src/db/repositories/CollectionPlaceRatings.repository.ts@@ -1,5 +1,6 @@import type { CollectionPlaceRatings } from '../entities/CollectionPlaceRatings.entity';import { TrekRepository } from './_shared/trek-repository';+import type { DB } from '../kysely/db';/*** `collection_place_ratings` (Plan 3h Task 2, part B — #1435's per-voter@@ -63,7 +64,7 @@ export class CollectionPlaceRatingsRepository extends TrekRepository<CollectionP* mirror column silently dropped" trap (3d/3e ledgers).*/async listForPlace(collectionPlaceId: number): Promise<{ user_id: number; rating: number }[]> {- return await this.kysely<{ collection_place_ratings: { collection_place_id: number; user_id: number; rating: number } }>()+ return await this.kysely<Pick<DB, 'collection_place_ratings'>>().selectFrom('collection_place_ratings').select(['user_id', 'rating']).where('collection_place_id', '=', collectionPlaceId)diff --git a/server/src/db/repositories/CollectionPlaces.repository.ts b/server/src/db/repositories/CollectionPlaces.repository.tsindex 23d0b762b..e4380ef33 100644--- a/server/src/db/repositories/CollectionPlaces.repository.ts+++ b/server/src/db/repositories/CollectionPlaces.repository.ts@@ -2,6 +2,7 @@ import type { CollectionPlaces } from '../entities/CollectionPlaces.entity';import { currentTimestamp } from '../dialect/sql-functions';import type { CollectionPlaceRow } from './Collections.repository';import { TrekRepository } from './_shared/trek-repository';+import type { DB } from '../kysely/db';/*** `collection_places` (Plan 3h Task 2, part B — saved places CRUD, dedup,@@ -474,13 +475,6 @@ export interface CollectionPlaceCopyRow {phone: string | null;}-interface CollectionPlacesKyselyDB {- collection_places: Omit<CollectionPlaceRow, 'category_name' | 'category_color' | 'category_icon'>;- collection_place_tags: { collection_place_id: number; tag_id: number };- collection_place_labels: { collection_place_id: number; label_id: number };-}+type CollectionPlacesKyselyDB = Pick<DB, 'collection_places' | 'collection_place_tags' | 'collection_place_labels'>;-interface CollectionPlacesMembershipKyselyDB {- collection_places: Pick<CollectionPlaceRow, 'id' | 'collection_id' | 'google_place_id' | 'google_ftid' | 'lat' | 'lng' | 'status'>;- collections: { id: number; name: string };-}+type CollectionPlacesMembershipKyselyDB = Pick<DB, 'collection_places' | 'collections'>;diff --git a/server/src/db/repositories/Collections.repository.ts b/server/src/db/repositories/Collections.repository.tsindex 97f956986..ecaeca42c 100644--- a/server/src/db/repositories/Collections.repository.ts+++ b/server/src/db/repositories/Collections.repository.ts@@ -1,5 +1,6 @@import type { Collections } from '../entities/Collections.entity';import { TrekRepository } from './_shared/trek-repository';+import type { DB } from '../kysely/db';/** `collections` — every scalar column, `getCollectionRow`'s (CL14) `SELECT *` shape. */export interface CollectionRow {@@ -58,75 +59,29 @@ export interface CollectionPlaceRow {category_icon: string | null;}-interface CollectionsKyselyDB {- collections: CollectionRow;-}+type CollectionsKyselyDB = Pick<DB, 'collections'>;/**- * CL29's own `INSERT INTO collections (owner_id, name, description, color,- * icon, cover_image, links, sort_order)` column list, exactly — no `id`/- * `created_at`/`updated_at` (never bound; the schema's own- * `DEFAULT CURRENT_TIMESTAMP`/autoincrement fill them), the- * `BucketListRepository`/`BucketListInsertKyselyDB` precedent for a- * narrower insert-only Kysely interface instead of `Generated<>` markers.+ * CL29's insert table: it binds `INSERT INTO collections (owner_id, name,+ * description, color, icon, cover_image, links, sort_order)` exactly, and+ * `id`/`created_at`/`updated_at` (filled by the schema's own+ * `DEFAULT CURRENT_TIMESTAMP`/autoincrement) are `InsertOptional` in the+ * generated type.*/-interface CollectionsInsertKyselyDB {- collections: {- owner_id: number;- name: string;- description: string | null;- color: string | null;- icon: string | null;- cover_image: string | null;- links: string | null;- sort_order: number;- };-}+type CollectionsInsertKyselyDB = Pick<DB, 'collections'>;-interface CollectionIdsKyselyDB {- collections: { id: number; owner_id: number };- collection_members: { collection_id: number; user_id: number; status: string };-}+type CollectionIdsKyselyDB = Pick<DB, 'collections' | 'collection_members'>;-interface CollectionPlacesReadKyselyDB {- collection_places: Omit<CollectionPlaceRow, 'category_name' | 'category_color' | 'category_icon'>;- categories: { id: number; name: string; color: string | null; icon: string | null };-}+type CollectionPlacesReadKyselyDB = Pick<DB, 'collection_places' | 'categories'>;/**- * CL23's own `INSERT INTO collection_places (21 cols)` list, exactly — no- * `id`/`created_at`/`updated_at`, the same narrower-insert-interface shape- * as {@link CollectionsInsertKyselyDB} above.+ * CL23's insert table: it binds `INSERT INTO collection_places (21 cols)`+ * exactly, and `id`/`created_at`/`updated_at` are `InsertOptional` in the+ * generated type, as for {@link CollectionsInsertKyselyDB} above.*/-interface CollectionPlacesWriteKyselyDB {- collection_places: {- collection_id: number;- owner_id: number;- saved_by: number | null;- name: string;- description: string | null;- lat: number | null;- lng: number | null;- address: string | null;- category_id: number | null;- price: number | null;- currency: string | null;- notes: string | null;- image_url: string | null;- google_place_id: string | null;- google_ftid: string | null;- osm_id: string | null;- website: string | null;- phone: string | null;- status: string;- links: string | null;- sort_order: number | null;- };-}+type CollectionPlacesWriteKyselyDB = Pick<DB, 'collection_places'>;-interface CollectionPlaceLabelsKyselyDB {- collection_place_labels: { collection_place_id: number; label_id: number };-}+type CollectionPlaceLabelsKyselyDB = Pick<DB, 'collection_place_labels'>;/*** `collections` — the root of the collections cluster (Plan 3h Task 1, part@@ -361,7 +316,7 @@ export class CollectionsRepository extends TrekRepository<Collections> {*/async loadTagsByPlaceIds(placeIds: number[]): Promise<{ pid: number; id: number; name: string; color: string }[]> {if (placeIds.length === 0) return [];- return await this.kysely<{ collection_place_tags: { collection_place_id: number; tag_id: number }; tags: { id: number; name: string; color: string } }>()+ return await this.kysely<Pick<DB, 'collection_place_tags' | 'tags'>>().selectFrom('collection_place_tags as cpt').innerJoin('tags as t', 't.id', 'cpt.tag_id').select(['cpt.collection_place_id as pid', 't.id', 't.name', 't.color'])@@ -391,10 +346,7 @@ export class CollectionsRepository extends TrekRepository<Collections> {placeIds: number[],): Promise<{ pid: number; user_id: number; username: string; avatar: string | null; rating: number }[]> {if (placeIds.length === 0) return [];- return await this.kysely<{- collection_place_ratings: { collection_place_id: number; user_id: number; rating: number; created_at: string | null };- users: { id: number; username: string; avatar: string | null };- }>()+ return await this.kysely<Pick<DB, 'collection_place_ratings' | 'users'>>().selectFrom('collection_place_ratings as cpr').innerJoin('users as u', 'u.id', 'cpr.user_id').select(['cpr.collection_place_id as pid', 'cpr.user_id', 'u.username', 'u.avatar', 'cpr.rating'])diff --git a/server/src/db/repositories/DawarichVisitSuggestions.repository.ts b/server/src/db/repositories/DawarichVisitSuggestions.repository.tsindex 84ed763ce..b5ea286fa 100644--- a/server/src/db/repositories/DawarichVisitSuggestions.repository.ts+++ b/server/src/db/repositories/DawarichVisitSuggestions.repository.ts@@ -2,6 +2,7 @@ import { coalesceParam, columnRef } from '../dialect/sql-functions';import type { DawarichVisitSuggestions } from '../entities/DawarichVisitSuggestions.entity';import { type AssertRowKeys } from './_shared/rows';import { TrekRepository } from './_shared/trek-repository';+import type { DB } from '../kysely/db';/** `dawarich_visit_suggestions` — every scalar column, DWS6/DSY3's `SELECT *` shape. */export interface SuggestionRow {@@ -40,21 +41,15 @@ export interface SuggestionJoinRow extends SuggestionRow {matched_bucket_name: string | null;}-/** The narrow `dawarich_visit_suggestions`/`trips`/`bucket_list` shape DWS1/DWS3's join needs. */-interface SuggestionJoinKyselyDB {- dawarich_visit_suggestions: SuggestionRow;- trips: { id: number; title: string | null };- bucket_list: { id: number; name: string };-}+/** The `dawarich_visit_suggestions`/`trips`/`bucket_list` tables DWS1/DWS3's join reads. */+type SuggestionJoinKyselyDB = Pick<DB, 'dawarich_visit_suggestions' | 'trips' | 'bucket_list'>;-/** The narrow `dawarich_visit_suggestions` shape a bare `SELECT *` read needs (DWS6/DSY3). */-interface SuggestionAllKyselyDB {- dawarich_visit_suggestions: SuggestionRow;-}+/** The `dawarich_visit_suggestions` table a bare `SELECT *` read (DWS6/DSY3) needs. */+type SuggestionAllKyselyDB = Pick<DB, 'dawarich_visit_suggestions'>;/**- * The narrow `dawarich_visit_suggestions`/`journey_entries` shape DWS2's- * `reopenOrphaned` needs. `journey_entries` is 3g's table, read cross-domain+ * The `dawarich_visit_suggestions`/`journey_entries` tables DWS2's+ * `reopenOrphaned` reads. `journey_entries` is 3g's table, read cross-domain* over `this.kysely()` — the same "a repository may query any table"* convention `JourneyEntriesRepository`'s own cross-domain reads* (`listStatsTrips`/`listSuggestedTrips`) already establish — rather than a@@ -66,10 +61,7 @@ interface SuggestionAllKyselyDB {* statement's one-round-trip shape more faithfully than a JS-side* per-row `existsById` loop would have.*/-interface ReopenOrphanedKyselyDB {- dawarich_visit_suggestions: SuggestionRow;- journey_entries: { id: number };-}+type ReopenOrphanedKyselyDB = Pick<DB, 'dawarich_visit_suggestions' | 'journey_entries'>;/** The narrow shape DSY7's window-candidates read needs. */interface CandidateRow {diff --git a/server/src/db/repositories/DayAccommodations.repository.ts b/server/src/db/repositories/DayAccommodations.repository.tsindex 039dd224a..df8c38226 100644--- a/server/src/db/repositories/DayAccommodations.repository.ts+++ b/server/src/db/repositories/DayAccommodations.repository.ts@@ -2,6 +2,7 @@ import type { DayAccommodations } from '../entities/DayAccommodations.entity';import { coalesceOverride, columnRef } from '../dialect/sql-functions';import { type AssertRowKeys } from './_shared/rows';import { TrekRepository } from './_shared/trek-repository';+import type { DB } from '../kysely/db';/*** A `day_accommodations` row exactly as AC34 (`AccommodationsService@@ -47,38 +48,7 @@ export interface DayAccommodationListRow extends DayAccommodationWithPlaceRow {* the QueryBuilder's relation-path `.join()` cannot express `LEFT JOIN* reservations r ON r.accommodation_id = a.id` at all.*/-interface DayAccommodationListKyselyDB {- day_accommodations: {- id: number;- // `number | string` — `ReservationsRepository.listForTrip`'s own- // `trip_id` widening: the raw-bind flexibility a `.where(col, '=',- // value)` call keeps regardless of how loosely its value is typed- // (program rule 23 bans a raw SQL-text condition, not a loosely-typed- // bound value).- trip_id: number | string;- place_id: number | null;- start_day_id: number;- end_day_id: number;- check_in: string | null;- check_in_end: string | null;- check_out: string | null;- confirmation: string | null;- notes: string | null;- created_at: string | null;- };- places: {- id: number;- name: string;- address: string | null;- image_url: string | null;- lat: number | null;- lng: number | null;- };- reservations: {- accommodation_id: string | null;- title: string;- };-}+type DayAccommodationListKyselyDB = Pick<DB, 'day_accommodations' | 'places' | 'reservations'>;/*** Plan 3d Task 2 (`ReservationsService`'s `day_accommodations` writes — RS27,@@ -274,7 +244,7 @@ export class DayAccommodationsRepository extends TrekRepository<DayAccommodation'p.lng as place_lng','r.title as reservation_title',])- .where('a.trip_id', '=', trip_id)+ .where('a.trip_id', '=', trip_id as number).orderBy('a.created_at', 'asc').execute();return rows as DayAccommodationListRow[];@@ -517,24 +487,4 @@ export interface RoadtripStayRow {}/** Kysely typing for RPL3 (`listRoadtripStays`). */-interface RoadtripStaysKyselyDB {- day_accommodations: {- id: number;- trip_id: number;- place_id: number | null;- start_day_id: number;- end_day_id: number;- check_in: string | null;- check_out: string | null;- };- places: {- id: number;- name: string;- lat: number | null;- lng: number | null;- };- reservations: {- id: number;- accommodation_id: string | null;- };-}+type RoadtripStaysKyselyDB = Pick<DB, 'day_accommodations' | 'places' | 'reservations'>;diff --git a/server/src/db/repositories/DayAssignments.repository.ts b/server/src/db/repositories/DayAssignments.repository.tsindex c34afb833..83208d5a4 100644--- a/server/src/db/repositories/DayAssignments.repository.ts+++ b/server/src/db/repositories/DayAssignments.repository.ts@@ -3,6 +3,7 @@ import type { DayAssignments } from '../entities/DayAssignments.entity';import { caseWhenNotNull, coalesce, columnIncrementedBy, columnRef } from '../dialect/sql-functions';import { type AssertRowKeys } from './_shared/rows';import { TrekRepository } from './_shared/trek-repository';+import type { DB } from '../kysely/db';/*** The DY1/DY3/AS1/AS3 assignment-with-place projection row (Plan 3c Task 2's@@ -140,27 +141,7 @@ export interface DaySeatRow {* next step down D3's escape-hatch order (`find/findOne → nativeUpdate →* qb() → em.getKysely()`).*/-interface AssignmentTimeSortKyselyDB {- day_assignments: {- id: number;- day_id: number;- place_id: number;- order_index: number | null;- assignment_time: string | null;- accommodation_id: number | null;- created_at: string | null;- };- places: {- id: number;- place_time: string | null;- lat: number | null;- lng: number | null;- };- day_accommodations: {- id: number;- check_in: string | null;- };-}+type AssignmentTimeSortKyselyDB = Pick<DB, 'day_assignments' | 'places' | 'day_accommodations'>;/*** RPL2's row, exactly as `RoadtripPlanService.context`'s old local `VisitRow`@@ -200,45 +181,7 @@ export interface RoadtripVisitRow {* `AssignmentTimeSortKyselyDB` above uses. `days` is joined twice under two* aliases (`d`, `checkout`) — both resolve against this one `days` entry.*/-interface RoadtripVisitsKyselyDB {- day_assignments: {- id: number;- day_id: number;- place_id: number;- order_index: number | null;- accommodation_id: number | null;- created_at: string | null;- assignment_time: string | null;- assignment_end_time: string | null;- end_day: number;- leg_transport_mode: string | null;- incoming_leg_transport_mode: string | null;- };- days: {- id: number;- trip_id: number;- day_number: number;- };- places: {- id: number;- name: string;- lat: number | null;- lng: number | null;- place_time: string | null;- end_time: string | null;- duration_minutes: number | null;- stop_type: string | null;- fill_percent: number | null;- };- day_accommodations: {- id: number;- place_id: number;- start_day_id: number;- end_day_id: number | null;- check_in: string | null;- check_out: string | null;- };-}+type RoadtripVisitsKyselyDB = Pick<DB, 'day_assignments' | 'days' | 'places' | 'day_accommodations'>;export class DayAssignmentsRepository extends TrekRepository<DayAssignments> {/** The DY1/DY3/AS1/AS3 projection's SELECT list, shared by all three query shapes below. */diff --git a/server/src/db/repositories/DayNotes.repository.ts b/server/src/db/repositories/DayNotes.repository.tsindex 2a97cf429..eeaa5560a 100644--- a/server/src/db/repositories/DayNotes.repository.ts+++ b/server/src/db/repositories/DayNotes.repository.ts@@ -1,6 +1,7 @@import type { DayNotes } from '../entities/DayNotes.entity';import { toRow, type AssertRowKeys } from './_shared/rows';import { TrekRepository } from './_shared/trek-repository';+import type { DB } from '../kysely/db';export interface DayNoteRow {id: number;@@ -203,7 +204,5 @@ export class DayNotesRepository extends TrekRepository<DayNotes> {}}-/** {@link DayNotesRepository.listForPublicApi}'s narrow `day_notes` shape. */-interface DayNotesPublicApiKyselyDB {- day_notes: { day_id: number; trip_id: number; text: string; time: string | null; sort_order: number | null };-}+/** The `day_notes` table {@link DayNotesRepository.listForPublicApi} reads. */+type DayNotesPublicApiKyselyDB = Pick<DB, 'day_notes'>;diff --git a/server/src/db/repositories/Days.repository.ts b/server/src/db/repositories/Days.repository.tsindex 9245d7eb6..b8c840dd4 100644--- a/server/src/db/repositories/Days.repository.ts+++ b/server/src/db/repositories/Days.repository.ts@@ -2,6 +2,7 @@ import type { Days } from '../entities/Days.entity';import { columnRef } from '../dialect/sql-functions';import { toRow, type AssertRowKeys } from './_shared/rows';import { TrekRepository } from './_shared/trek-repository';+import type { DB } from '../kysely/db';/** A `days` row as the API emits it. */export interface DayRow {@@ -46,13 +47,8 @@ export interface DayGridReadRow {has_plan_items: number;}-/** The narrow table shape TP77/TP78 read (`this.kysely()`'s typed `DB` argument). */-interface DayGridKyselyDB {- days: { id: number; trip_id: number; day_number: number; date: string | null };- day_assignments: { id: number; day_id: number };- day_notes: { id: number; day_id: number };- day_accommodations: { id: number; start_day_id: number; end_day_id: number };-}+/** The tables TP77/TP78 read (`this.kysely()`'s typed `DB` argument). */+type DayGridKyselyDB = Pick<DB, 'days' | 'day_assignments' | 'day_notes' | 'day_accommodations'>;export class DaysRepository extends TrekRepository<Days> {/** `SELECT * FROM days WHERE trip_id = ? ORDER BY day_number ASC` */diff --git a/server/src/db/repositories/DocumentConnections.repository.ts b/server/src/db/repositories/DocumentConnections.repository.tsindex 1df1b8333..dd8566b82 100644--- a/server/src/db/repositories/DocumentConnections.repository.ts+++ b/server/src/db/repositories/DocumentConnections.repository.ts@@ -2,6 +2,7 @@ import { currentTimestamp, coalesceOverride } from '../dialect/sql-functions';import type { DocumentConnections } from '../entities/DocumentConnections.entity';import { type AssertRowKeys } from './_shared/rows';import { TrekRepository } from './_shared/trek-repository';+import type { DB } from '../kysely/db';/*** A bare `document_connections` row. `secrets` is opaque encrypted TEXT here@@ -29,11 +30,7 @@ export interface DocumentConnectionRow {const _connectionRowKeys: AssertRowKeys<DocumentConnectionRow, DocumentConnections> = true;-interface OwnerLeftKyselyDB {- document_connections: { id: number; trip_id: number; owner_user_id: number };- trip_members: { trip_id: number; user_id: number };- trips: { id: number; user_id: number };-}+type OwnerLeftKyselyDB = Pick<DB, 'document_connections' | 'trip_members' | 'trips'>;/*** `document_connections` — one provider credential per trip (R7's encrypteddiff --git a/server/src/db/repositories/DocumentSyncItems.repository.ts b/server/src/db/repositories/DocumentSyncItems.repository.tsindex 1f09ec504..c599c838c 100644--- a/server/src/db/repositories/DocumentSyncItems.repository.ts+++ b/server/src/db/repositories/DocumentSyncItems.repository.ts@@ -3,6 +3,7 @@ import { coalesceOverride, currentTimestamp, currentTimestampKysely, foundAgainSimport type { DocumentSyncItems } from '../entities/DocumentSyncItems.entity';import { type AssertRowKeys } from './_shared/rows';import { TrekRepository } from './_shared/trek-repository';+import type { DB } from '../kysely/db';/** A bare `document_sync_items` row (every scalar column). */export interface DocumentSyncItemRow {@@ -73,53 +74,15 @@ export interface DocumentSyncHoldingsRow {missing: number;}-interface DocumentSyncItemsKyselyDB {- document_sync_items: DocumentSyncItemRow;- trip_files: { id: number; original_name: string };-}+type DocumentSyncItemsKyselyDB = Pick<DB, 'document_sync_items' | 'trip_files'>;/**- * DS24's insert-only shape — `id`/`first_seen_at`/`last_seen_at` are- * autoincrement/`DEFAULT CURRENT_TIMESTAMP` and `remote_missing_at`/- * `remote_trashed_at` are always NULL on a brand-new row (matching the- * legacy statement's own 16-column list, which omits all five) — a- * SEPARATE interface from {@link DocumentSyncItemsKyselyDB} rather than- * making those columns optional there, the same one-purpose-shaped-interface- * reasoning `FileLinksRepository`'s own `FileLinksWriteKyselyDB` docstring- * gives.+ * DS24's insert table. It binds the legacy statement's own 16-column list:+ * `id`/`first_seen_at`/`last_seen_at` are autoincrement/`DEFAULT+ * CURRENT_TIMESTAMP` and `remote_missing_at`/`remote_trashed_at` are always+ * NULL on a brand-new row; the columns the statement leaves out (the rowid, defaulted and nullable ones) are `InsertOptional` in the generated type, so `.values()` may omit them.*/-interface DocumentSyncItemsWriteKyselyDB {- document_sync_items: {- link_id: number;- trip_id: number;- file_id: number | null;- trek_doc_uid: string;- remote_id: string | null;- remote_name: string | null;- remote_version: string | null;- remote_size: number | null;- remote_modified_at: string | null;- content_sha256: string | null;- pushed_sha256: string | null;- state: string;- error_code: string | null;- attempts: number;- next_attempt_at: string | null;- synced_at: string | null;- /**- * Not part of DS24's legacy `VALUES` column list (the row is brand new,- * so SQLite's own `DEFAULT CURRENT_TIMESTAMP` would fire identically) —- * set explicitly here anyway, to the SAME `CURRENT_TIMESTAMP` value,- * because Kysely's typed insert-expression callback form requires every- * declared column of an `ON CONFLICT ... DO UPDATE` target table to be- * present in `.values()` (a plain `?:` optional marker on this- * interface is not honoured by that callback form, verified directly —- * `tsc` still demanded it). Behaviourally identical either way: both- * paths evaluate to the DB clock at insert time.- */- last_seen_at: string;- };-}+type DocumentSyncItemsWriteKyselyDB = Pick<DB, 'document_sync_items'>;const ISSUE_STATES = ['conflict', 'rejected_type', 'too_large', 'remote_missing', 'error'] as const;diff --git a/server/src/db/repositories/FileLinks.repository.ts b/server/src/db/repositories/FileLinks.repository.tsindex 4409ffd50..93fe5f5dd 100644--- a/server/src/db/repositories/FileLinks.repository.ts+++ b/server/src/db/repositories/FileLinks.repository.ts@@ -1,6 +1,7 @@import type { FileLinks } from '../entities/FileLinks.entity';import { type AssertRowKeys } from './_shared/rows';import { TrekRepository } from './_shared/trek-repository';+import type { DB } from '../kysely/db';/** A bare `file_links` row — every scalar column of the entity, incl. its five `persist(false)` relation mirrors. */export interface FileLinkRow {@@ -28,32 +29,16 @@ export interface FileLinkTargetRow {budget_item_id: number | null;}-interface FileLinksKyselyDB {- file_links: FileLinkRow;- reservations: { id: number; title: string };-}+type FileLinksKyselyDB = Pick<DB, 'file_links' | 'reservations'>;/**- * The insert-only shape — `id`/`created_at` are autoincrement/`DEFAULT+ * The insert's table. `id`/`created_at` are autoincrement/`DEFAULT* CURRENT_TIMESTAMP` and omitted from `.values()` below (the legacy- * statement's own column list omits them too, matching this exactly), so a- * SEPARATE interface from {@link FileLinksKyselyDB} rather than making those- * two columns optional there — that would also loosen every SELECT method's- * inferred `id`/`created_at` to `T | undefined`, which is wrong for a row- * that unquestionably has both once read back (the `ReservationJoinKyselyDB`- * / `ReservationRestampKyselyDB` precedent, `Reservations.repository.ts`:- * one purpose-shaped Kysely interface per statement, not one reused- * everywhere).+ * statement's own column list omits them too). Both are `InsertOptional` in+ * the generated type, which keeps them optional for the insert while every+ * SELECT still reads them as present.*/-interface FileLinksWriteKyselyDB {- file_links: {- file_id: number;- reservation_id: number | null;- assignment_id: number | null;- place_id: number | null;- budget_item_id: number | null;- };-}+type FileLinksWriteKyselyDB = Pick<DB, 'file_links'>;/*** `file_links` — the many-to-many between a `trip_files` row and thediff --git a/server/src/db/repositories/GoogleApiUsage.repository.ts b/server/src/db/repositories/GoogleApiUsage.repository.tsindex 4e2e81a87..fe96ddf49 100644--- a/server/src/db/repositories/GoogleApiUsage.repository.ts+++ b/server/src/db/repositories/GoogleApiUsage.repository.ts@@ -2,6 +2,7 @@ import type { GoogleApiUsage } from '../entities/GoogleApiUsage.entity';import { nowDateOffset } from '../dialect/sql-functions';import type { AssertRowKeys } from './_shared/rows';import { TrekRepository } from './_shared/trek-repository';+import type { DB } from '../kysely/db';/** A `google_api_usage` row: Google API calls counted per UTC day (#1582). */export interface GoogleApiUsageRow {@@ -11,9 +12,7 @@ export interface GoogleApiUsageRow {const _googleApiUsageRowKeys: AssertRowKeys<GoogleApiUsageRow, GoogleApiUsage> = true;-interface GoogleApiUsageKyselyDB {- google_api_usage: GoogleApiUsageRow;-}+type GoogleApiUsageKyselyDB = Pick<DB, 'google_api_usage'>;/*** `google_api_usage` — one row a day, nothing about who searched. Kyselydiff --git a/server/src/db/repositories/HiddenCountries.repository.ts b/server/src/db/repositories/HiddenCountries.repository.tsindex ebbe9ccc0..97e35cfc3 100644--- a/server/src/db/repositories/HiddenCountries.repository.ts+++ b/server/src/db/repositories/HiddenCountries.repository.ts@@ -1,9 +1,8 @@import type { HiddenCountries } from '../entities/HiddenCountries.entity';import { TrekRepository } from './_shared/trek-repository';+import type { DB } from '../kysely/db';-interface HiddenCountriesKyselyDB {- hidden_countries: { user_id: number; country_code: string };-}+type HiddenCountriesKyselyDB = Pick<DB, 'hidden_countries'>;/*** `hidden_countries` — the #1490 tombstone table: a country derived from adiff --git a/server/src/db/repositories/HiddenRegions.repository.ts b/server/src/db/repositories/HiddenRegions.repository.tsindex f91d49c13..4c0535779 100644--- a/server/src/db/repositories/HiddenRegions.repository.ts+++ b/server/src/db/repositories/HiddenRegions.repository.ts@@ -1,9 +1,8 @@import type { HiddenRegions } from '../entities/HiddenRegions.entity';import { TrekRepository } from './_shared/trek-repository';+import type { DB } from '../kysely/db';-interface HiddenRegionsKyselyDB {- hidden_regions: { user_id: number; region_code: string; country_code: string };-}+type HiddenRegionsKyselyDB = Pick<DB, 'hidden_regions'>;/*** `hidden_regions` — the region-level sibling of `hidden_countries`'sdiff --git a/server/src/db/repositories/JourneyContributors.repository.ts b/server/src/db/repositories/JourneyContributors.repository.tsindex f276f0c0c..f3fb859ad 100644--- a/server/src/db/repositories/JourneyContributors.repository.ts+++ b/server/src/db/repositories/JourneyContributors.repository.ts@@ -1,5 +1,6 @@import type { JourneyContributors } from '../entities/JourneyContributors.entity';import { TrekRepository } from './_shared/trek-repository';+import type { DB } from '../kysely/db';/** JG18's contributor-list row (`getJourneyFull`) — the junction plus the joined username/avatar. */export interface JourneyContributorListRow {@@ -11,11 +12,8 @@ export interface JourneyContributorListRow {avatar: string | null;}-/** The narrow `journey_contributors`/`users` shape {@link JourneyContributorsRepository.listForJourney} needs. */-interface JourneyContributorListKyselyDB {- journey_contributors: { journey_id: number; user_id: number; role: string; added_at: number };- users: { id: number; username: string; avatar: string | null };-}+/** The `journey_contributors`/`users` tables {@link JourneyContributorsRepository.listForJourney} reads. */+type JourneyContributorListKyselyDB = Pick<DB, 'journey_contributors' | 'users'>;/*** `journey_contributors` — a genuine TWO-column composite primary keydiff --git a/server/src/db/repositories/JourneyEntries.repository.ts b/server/src/db/repositories/JourneyEntries.repository.tsindex 145d7fca6..b99f27934 100644--- a/server/src/db/repositories/JourneyEntries.repository.ts+++ b/server/src/db/repositories/JourneyEntries.repository.ts@@ -1,6 +1,7 @@import type { JourneyEntry } from '../../types';import type { JourneyEntries } from '../entities/JourneyEntries.entity';import { TrekRepository } from './_shared/trek-repository';+import type { DB } from '../kysely/db';/** JG55's wider reconciliation projection (`reconcileTripSkeletons`) — a distinct column set from JG35's dedup-key-only read. */export interface ReconcileEntryRow {@@ -26,16 +27,11 @@ export interface JourneyTrackSourceRow {route_geometry: string;}-/** The narrow `journey_entries`/`places` shape {@link JourneyEntriesRepository.listTracksSource} needs. */-interface JourneyTracksKyselyDB {- journey_entries: { journey_id: number; source_trip_id: number | null };- places: { id: number; trip_id: number; name: string | null; route_color: string | null; route_geometry: string | null };-}+/** The `journey_entries`/`places` tables {@link JourneyEntriesRepository.listTracksSource} reads. */+type JourneyTracksKyselyDB = Pick<DB, 'journey_entries' | 'places'>;-/** The narrow `journey_entries` shape a bare `entry_date`/`sort_order` MAX-per-date read needs. */-interface JourneyEntriesDateSortKyselyDB {- journey_entries: { journey_id: number; entry_date: string; sort_order: number | null };-}+/** The `journey_entries` tables a bare `entry_date`/`sort_order` MAX-per-date read reads. */+type JourneyEntriesDateSortKyselyDB = Pick<DB, 'journey_entries'>;/** An entry waiting for a place and the geotagged photo that can give it one (#1003), {@link JourneyEntriesRepository.listPhotoPlacementCandidates}. */export interface PhotoPlacementRow {@@ -45,19 +41,11 @@ export interface PhotoPlacementRow {lng: number;}-/** The narrow `trek_photos`/`journey_photos`/`journey_entry_photos`/`journey_entries`/`journeys` shape {@link JourneyEntriesRepository.listPhotoPlacementCandidates} needs. */-interface PhotoPlacementKyselyDB {- trek_photos: { id: number; lat: number | null; lng: number | null };- journey_photos: { id: number; photo_id: number };- journey_entry_photos: { entry_id: number; journey_photo_id: number; sort_order: number | null };- journey_entries: { id: number; journey_id: number; location_lat: number | null; location_lng: number | null; type: string };- journeys: { id: number; photo_location: number };-}+/** The `trek_photos`/`journey_photos`/`journey_entry_photos`/`journey_entries`/`journeys` tables {@link JourneyEntriesRepository.listPhotoPlacementCandidates} reads. */+type PhotoPlacementKyselyDB = Pick<DB, 'trek_photos' | 'journey_photos' | 'journey_entry_photos' | 'journey_entries' | 'journeys'>;/** `journey_entry_photos`, read cross-table (no `JourneyEntryPhotosRepository` yet — Task 2's own; the two `hasPhotos` guards in Part A only ever check existence). */-interface JourneyEntryPhotosExistsKyselyDB {- journey_entry_photos: { entry_id: number };-}+type JourneyEntryPhotosExistsKyselyDB = Pick<DB, 'journey_entry_photos'>;/** JG64's narrow `journeyStats` projection — NOT the same text as JG14/JG71 (a wider `SELECT *`); a distinct, narrower column list read directly off the current source, not the inventory's (stale) "same text as JG14" annotation. */export interface StatsEntryRow {@@ -101,28 +89,14 @@ export interface TripPickerRow {place_count: number;}-/** The narrow `journey_entries`/`journey_trips`/`trips`/`places`/`day_assignments`/`days` shape `journeyStats`'s cross-domain reads (JG65-67) need. */-interface StatsKyselyDB {- journey_trips: { journey_id: number; trip_id: number };- trips: { id: number; title: string | null; start_date: string | null; end_date: string | null };- places: { id: number; trip_id: number; name: string | null; lat: number | null; lng: number | null };- day_assignments: { id: number; place_id: number; day_id: number; order_index: number | null };- days: { id: number; date: string | null };-}+/** The `journey_entries`/`journey_trips`/`trips`/`places`/`day_assignments`/`days` tables `journeyStats`'s cross-domain reads (JG65-67) read. */+type StatsKyselyDB = Pick<DB, 'journey_trips' | 'trips' | 'places' | 'day_assignments' | 'days'>;/** JG70's chunked cached-country probe (`journeyStats`, `place_regions` — atlas-owned, 3f-DONE, read-only here). */-interface PlaceRegionsKyselyDB {- place_regions: { place_id: number; country_code: string | null };-}+type PlaceRegionsKyselyDB = Pick<DB, 'place_regions'>;-/** The narrow `trips`/`trip_members`/`places`/`day_assignments`/`journey_trips` shape JG120/JG121's trip-picker reads need. */-interface TripPickerKyselyDB {- trips: { id: number; title: string; start_date: string | null; end_date: string | null; cover_image: string | null; user_id: number };- trip_members: { trip_id: number; user_id: number };- places: { id: number; trip_id: number };- day_assignments: { id: number; place_id: number };- journey_trips: { trip_id: number };-}+/** The `trips`/`trip_members`/`places`/`day_assignments`/`journey_trips` tables JG120/JG121's trip-picker reads read. */+type TripPickerKyselyDB = Pick<DB, 'trips' | 'trip_members' | 'places' | 'day_assignments' | 'journey_trips'>;/*** `journey_entries` — first cut (Plan 3g Task 1, R9's Part A): everydiff --git a/server/src/db/repositories/JourneyEntryPhotos.repository.ts b/server/src/db/repositories/JourneyEntryPhotos.repository.tsindex ab06db28c..c45ac11e5 100644--- a/server/src/db/repositories/JourneyEntryPhotos.repository.ts+++ b/server/src/db/repositories/JourneyEntryPhotos.repository.ts@@ -2,28 +2,10 @@ import type { JourneyPhoto } from '../../types';import type { JourneyEntryPhotos } from '../entities/JourneyEntryPhotos.entity';import type { JourneyPublicGalleryRow } from './JourneyShareTokens.repository';import { TrekRepository } from './_shared/trek-repository';+import type { DB } from '../kysely/db';-/** The narrow `journey_entry_photos`/`journey_photos`/`trek_photos`/`journey_entries` shape the `JP_SELECT`/`JP_JOIN`-shaped reads need. */-interface JourneyPhotoJoinKyselyDB {- journey_entry_photos: { entry_id: number; journey_photo_id: number; sort_order: number | null; created_at: number };- journey_photos: { id: number; journey_id: number; photo_id: number; caption: string | null; shared: number | null; sort_order: number | null; created_at: number };- trek_photos: {- id: number;- provider: string;- asset_id: string | null;- owner_id: number | null;- file_path: string | null;- thumbnail_path: string | null;- width: number | null;- height: number | null;- media_type: string | null;- duration_ms: number | null;- taken_at: string | null;- lat: number | null;- lng: number | null;- };- journey_entries: { id: number; journey_id: number };-}+/** The `journey_entry_photos`/`journey_photos`/`trek_photos`/`journey_entries` tables the `JP_SELECT`/`JP_JOIN`-shaped reads read. */+type JourneyPhotoJoinKyselyDB = Pick<DB, 'journey_entry_photos' | 'journey_photos' | 'trek_photos' | 'journey_entries'>;/** `JP_SELECT`'s exact column list (`journey-domain.service.ts`'s module const), aliased `jep`/`gp`/`tp` — shared by every `JP_SELECT`/`JP_JOIN`-shaped read below. */const JP_COLUMNS = [diff --git a/server/src/db/repositories/JourneyPhotos.repository.ts b/server/src/db/repositories/JourneyPhotos.repository.tsindex f64d583bc..090935a29 100644--- a/server/src/db/repositories/JourneyPhotos.repository.ts+++ b/server/src/db/repositories/JourneyPhotos.repository.ts@@ -5,6 +5,7 @@ import type { JourneyPhotos } from '../entities/JourneyPhotos.entity';import { concatKysely, unixEpochToIsoKysely } from '../dialect/sql-functions';import { type AssertRowKeys } from './_shared/rows';import { TrekRepository } from './_shared/trek-repository';+import type { DB } from '../kysely/db';/** `SELECT * FROM journey_photos WHERE id = ?`'s row (JG105) — every scalar column of the entity. */export interface JourneyPhotoFullRow {@@ -22,36 +23,8 @@ export interface JourneyPhotoFullRow {const _journeyPhotoFullRowKeys: AssertRowKeys<JourneyPhotoFullRow, JourneyPhotos> = true;-/** The narrow `journey_photos`/`trek_photos`/`journey_entry_photos`/`journey_entries` shape the gallery reads (JG19/JG101/JG102, `galleryChronologicalOrderExpr`) need. */-interface GalleryKyselyDB {- journey_photos: {- id: number;- journey_id: number;- photo_id: number;- caption: string | null;- shared: number | null;- sort_order: number | null;- created_at: number;- };- trek_photos: {- id: number;- provider: string;- asset_id: string | null;- owner_id: number | null;- file_path: string | null;- thumbnail_path: string | null;- width: number | null;- height: number | null;- media_type: string | null;- duration_ms: number | null;- taken_at: string | null;- lat: number | null;- lng: number | null;- };- journey_entry_photos: { entry_id: number; journey_photo_id: number };- journey_entries: { id: number; entry_date: string; entry_time: string | null; is_draft: number };- journeys: { id: number; user_id: number };-}+/** The `journey_photos`/`trek_photos`/`journey_entry_photos`/`journey_entries` tables the gallery reads (JG19/JG101/JG102, `galleryChronologicalOrderExpr`) read. */+type GalleryKyselyDB = Pick<DB, 'journey_photos' | 'trek_photos' | 'journey_entry_photos' | 'journey_entries' | 'journeys'>;/** JS7 (Plan 4 Task 8b relocation) — the public photo-validation join's row (`journey_photos` + `trek_photos`). */export interface JourneyPublicPhotoValidationRow {diff --git a/server/src/db/repositories/JourneyTrips.repository.ts b/server/src/db/repositories/JourneyTrips.repository.tsindex ffd0c21d0..5240d3940 100644--- a/server/src/db/repositories/JourneyTrips.repository.ts+++ b/server/src/db/repositories/JourneyTrips.repository.ts@@ -1,5 +1,6 @@import type { JourneyTrips } from '../entities/JourneyTrips.entity';import { TrekRepository } from './_shared/trek-repository';+import type { DB } from '../kysely/db';/** JG17's trip-link row (`getJourneyFull`) — the junction plus the joined trip summary and its place count. */export interface JourneyTripLinkRow {@@ -13,12 +14,8 @@ export interface JourneyTripLinkRow {place_count: number;}-/** The narrow `journey_trips`/`trips`/`places` shape {@link JourneyTripsRepository.listForJourney} needs. */-interface JourneyTripLinkKyselyDB {- journey_trips: { journey_id: number; trip_id: number; added_at: number };- trips: { id: number; title: string; start_date: string | null; end_date: string | null; cover_image: string | null; currency: string | null };- places: { id: number; trip_id: number };-}+/** The `journey_trips`/`trips`/`places` tables {@link JourneyTripsRepository.listForJourney} reads. */+type JourneyTripLinkKyselyDB = Pick<DB, 'journey_trips' | 'trips' | 'places'>;/*** The sync engine's per-assignment place row (JG34/onPlaceCreated's JG39,@@ -48,12 +45,8 @@ export interface AssignmentTimeRow {assignment_time: string | null;}-/** The narrow `places`/`day_assignments`/`days` shape the sync-engine reads need. */-interface SyncPlacesKyselyDB {- places: { id: number; trip_id: number; name: string; address: string | null; lat: number | null; lng: number | null; place_time: string | null };- day_assignments: { id: number; place_id: number; day_id: number; assignment_time: string | null; order_index: number | null };- days: { id: number; date: string | null; day_number: number };-}+/** The `places`/`day_assignments`/`days` tables the sync-engine reads read. */+type SyncPlacesKyselyDB = Pick<DB, 'places' | 'day_assignments' | 'days'>;/*** `journey_trips` — a genuine TWO-column composite primary key (`journey` +diff --git a/server/src/db/repositories/Journeys.repository.ts b/server/src/db/repositories/Journeys.repository.tsindex 8896d917b..7edf725cb 100644--- a/server/src/db/repositories/Journeys.repository.ts+++ b/server/src/db/repositories/Journeys.repository.ts@@ -1,5 +1,6 @@import type { Journeys } from '../entities/Journeys.entity';import { TrekRepository } from './_shared/trek-repository';+import type { DB } from '../kysely/db';/*** `SELECT * FROM journeys WHERE id = ?`'s row — every scalar column the@@ -39,37 +40,11 @@ export interface JourneyListRow extends JourneyRow {trip_date_max: string | null;}-/** The narrow `journeys`/`journey_contributors`/`journey_entries`/`journey_photos`/`journey_trips`/`trips` shape {@link JourneysRepository.listForUser} needs. */-interface JourneyListKyselyDB {- journeys: {- id: number;- user_id: number;- title: string;- subtitle: string | null;- cover_gradient: string | null;- status: string | null;- created_at: number;- updated_at: number;- cover_image: string | null;- show_trip_tracks: number;- show_verdict: number;- show_mood: number;- show_weather: number;- status_override: string | null;- photo_location: number;- };- journey_contributors: { journey_id: number; user_id: number };- journey_entries: { journey_id: number; type: string; location_name: string | null };- journey_photos: { journey_id: number };- journey_trips: { journey_id: number; trip_id: number };- trips: { id: number; start_date: string | null; end_date: string | null };-}+/** The `journeys`/`journey_contributors`/`journey_entries`/`journey_photos`/`journey_trips`/`trips` tables {@link JourneysRepository.listForUser} reads. */+type JourneyListKyselyDB = Pick<DB, 'journeys' | 'journey_contributors' | 'journey_entries' | 'journey_photos' | 'journey_trips' | 'trips'>;-/** The narrow `journeys`/`journey_contributors` shape {@link JourneysRepository.listRecipientUserIds} needs. */-interface JourneyRecipientsKyselyDB {- journeys: { id: number; user_id: number };- journey_contributors: { journey_id: number; user_id: number };-}+/** The `journeys`/`journey_contributors` tables {@link JourneysRepository.listRecipientUserIds} reads. */+type JourneyRecipientsKyselyDB = Pick<DB, 'journeys' | 'journey_contributors'>;/*** `journeys` — the root of the journey cluster (Plan 3g Task 1, R9's Part A).diff --git a/server/src/db/repositories/Notifications.repository.ts b/server/src/db/repositories/Notifications.repository.tsindex 11daeacc2..6ebfceae2 100644--- a/server/src/db/repositories/Notifications.repository.ts+++ b/server/src/db/repositories/Notifications.repository.ts@@ -1,6 +1,7 @@import type { Notifications } from '../entities/Notifications.entity';import { type AssertRowKeys } from './_shared/rows';import { TrekRepository } from './_shared/trek-repository';+import type { DB } from '../kysely/db';/*** A bare `notifications` row — every scalar column of the entity, incl. the@@ -69,12 +70,7 @@ export interface NotificationInsertRow {* constructs `NotificationsService`, per the BOOT GATE note) for reads that* are each a single, narrow, already-indexed lookup.*/-interface NotificationsKyselyDB {- notifications: NotificationRow;- users: { id: number; username: string; avatar: string | null; is_guest: number; role: string };- trips: { id: number; user_id: number };- trip_members: { trip_id: number; user_id: number };-}+type NotificationsKyselyDB = Pick<DB, 'notifications' | 'users' | 'trips' | 'trip_members'>;/*** `notifications` — the in-app notification store. Kysely throughout fordiff --git a/server/src/db/repositories/OauthTokens.repository.ts b/server/src/db/repositories/OauthTokens.repository.tsindex b185c56bd..3b22fb48f 100644--- a/server/src/db/repositories/OauthTokens.repository.ts+++ b/server/src/db/repositories/OauthTokens.repository.ts@@ -2,6 +2,7 @@ import { OauthTokens } from '../entities/OauthTokens.entity';import { type AssertRowKeys } from './_shared/rows';import { columnRef, currentTimestamp } from '../dialect/sql-functions';import { TrekRepository } from './_shared/trek-repository';+import type { DB } from '../kysely/db';/*** The Kysely-side table shape `em.getKysely()` needs for `collectChainIds`'s@@ -13,19 +14,7 @@ import { TrekRepository } from './_shared/trek-repository';* `.referencedColumnNames('client_id')` for `OauthTokens.client` (Plan 3b* interlude A) — see those methods' docstrings.*/-interface OauthTokensKyselyDB {- oauth_tokens: {- id: number;- client_id: string;- user_id: number;- scopes: string;- access_token_expires_at: string;- refresh_token_expires_at: string;- revoked_at: string | null;- created_at: string | null;- parent_token_id: number | null;- };-}+type OauthTokensKyselyDB = Pick<DB, 'oauth_tokens'>;/** `OauthService.issueTokens`/`issueClientCredentialsToken`'s write (OA13/OA14) — same column set, one method. */export interface NewOauthTokenRow {diff --git a/server/src/db/repositories/PackingBags.repository.ts b/server/src/db/repositories/PackingBags.repository.tsindex f6a5f1ea3..8d169c6ee 100644--- a/server/src/db/repositories/PackingBags.repository.ts+++ b/server/src/db/repositories/PackingBags.repository.ts@@ -2,6 +2,7 @@ import type { PackingBags } from '../entities/PackingBags.entity';import { type AssertRowKeys } from './_shared/rows';import { TrekRepository } from './_shared/trek-repository';import { presenceSet } from './_shared/presence-set';+import type { DB } from '../kysely/db';/** A bare `packing_bags` row — every scalar column, incl. the two `persist(false)` relation mirrors (`trip_id`, `user_id`). */export interface PackingBagRow {@@ -37,21 +38,13 @@ export interface PackingBagMemberForTripRow {avatar: string | null;}-interface PackingBagsKyselyDB {- packing_bags: PackingBagRow;- packing_bag_members: { bag_id: number; user_id: number };- users: { id: number; username: string; display_name: string | null; avatar: string | null };-}+type PackingBagsKyselyDB = Pick<DB, 'packing_bags' | 'packing_bag_members' | 'users'>;-/** The insert-only shape for `insertMinimal` (PK32) — `id`/`created_at` are autoincrement/`DEFAULT CURRENT_TIMESTAMP` and omitted, matching the legacy 3-column list. */-interface PackingBagsMinimalInsertKyselyDB {- packing_bags: { trip_id: number | string; name: string; color: string };-}+/** The table `insertMinimal` (PK32) inserts into, binding the legacy 3-column list; `id`/`created_at` are `InsertOptional` in the generated type. */+type PackingBagsMinimalInsertKyselyDB = Pick<DB, 'packing_bags'>;-/** The insert-only shape for `insertBag` (PK42/TP67) — a distinct, wider column set from {@link PackingBagsMinimalInsertKyselyDB}'s. */-interface PackingBagsInsertKyselyDB {- packing_bags: { trip_id: number | string; name: string; color: string; sort_order: number | null; weight_limit_grams: number | null };-}+/** The table `insertBag` (PK42/TP67) inserts into, with a wider column set than {@link PackingBagsMinimalInsertKyselyDB}'s. */+type PackingBagsInsertKyselyDB = Pick<DB, 'packing_bags'>;/*** `packing_bags` — bags themselves, plus (this class's own relation, no@@ -119,7 +112,7 @@ export class PackingBagsRepository extends TrekRepository<PackingBags> {* the new row's id.*/async insertMinimal(trip_id: number | string, name: string, color: string): Promise<number> {- const result = await this.kysely<PackingBagsMinimalInsertKyselyDB>().insertInto('packing_bags').values({ trip_id, name, color }).executeTakeFirstOrThrow();+ const result = await this.kysely<PackingBagsMinimalInsertKyselyDB>().insertInto('packing_bags').values({ trip_id: trip_id as number, name, color }).executeTakeFirstOrThrow();return Number(result.insertId);}@@ -129,7 +122,7 @@ export class PackingBagsRepository extends TrekRepository<PackingBags> {* set from {@link insertMinimal}'s. Returns the new row's id.*/async insertBag(row: { trip_id: number | string; name: string; color: string; sort_order: number | null; weight_limit_grams: number | null }): Promise<number> {- const result = await this.kysely<PackingBagsInsertKyselyDB>().insertInto('packing_bags').values(row).executeTakeFirstOrThrow();+ const result = await this.kysely<PackingBagsInsertKyselyDB>().insertInto('packing_bags').values({ ...row, trip_id: row.trip_id as number }).executeTakeFirstOrThrow();return Number(result.insertId);}diff --git a/server/src/db/repositories/PackingCategoryAssignees.repository.ts b/server/src/db/repositories/PackingCategoryAssignees.repository.tsindex 0d83c652e..5ae1b28a5 100644--- a/server/src/db/repositories/PackingCategoryAssignees.repository.ts+++ b/server/src/db/repositories/PackingCategoryAssignees.repository.ts@@ -1,5 +1,6 @@import type { PackingCategoryAssignees } from '../entities/PackingCategoryAssignees.entity';import { TrekRepository } from './_shared/trek-repository';+import type { DB } from '../kysely/db';/** PK58/PK61's joined projection. */export interface PackingCategoryAssigneeRow {@@ -9,14 +10,9 @@ export interface PackingCategoryAssigneeRow {avatar: string | null;}-interface PackingCategoryAssigneesKyselyDB {- packing_category_assignees: { id: number; trip_id: number; category_name: string; user_id: number };- users: { id: number; username: string; display_name: string | null; avatar: string | null };-}+type PackingCategoryAssigneesKyselyDB = Pick<DB, 'packing_category_assignees' | 'users'>;-interface PackingCategoryAssigneesInsertKyselyDB {- packing_category_assignees: { trip_id: number | string; category_name: string; user_id: number };-}+type PackingCategoryAssigneesInsertKyselyDB = Pick<DB, 'packing_category_assignees'>;/*** `packing_category_assignees` — who is "on the hook" for a packing@@ -75,7 +71,7 @@ export class PackingCategoryAssigneesRepository extends TrekRepository<PackingCafor (const user_id of user_ids) {await this.kysely<PackingCategoryAssigneesInsertKyselyDB>().insertInto('packing_category_assignees')- .values({ trip_id, category_name, user_id })+ .values({ trip_id: trip_id as number, category_name, user_id }).onConflict((oc) => oc.doNothing()).execute();}diff --git a/server/src/db/repositories/PackingItemContributors.repository.ts b/server/src/db/repositories/PackingItemContributors.repository.tsindex bc3e60aed..ced603af2 100644--- a/server/src/db/repositories/PackingItemContributors.repository.ts+++ b/server/src/db/repositories/PackingItemContributors.repository.ts@@ -1,5 +1,6 @@import type { PackingItemContributors } from '../entities/PackingItemContributors.entity';import { TrekRepository } from './_shared/trek-repository';+import type { DB } from '../kysely/db';/** PK3's contributor projection (`enrichItems`). */export interface PackingItemContributorRow {@@ -9,10 +10,7 @@ export interface PackingItemContributorRow {username: string;}-interface PackingItemContributorsKyselyDB {- packing_item_contributors: { item_id: number; user_id: number; status: string; created_at: string | null };- users: { id: number; username: string; display_name: string | null };-}+type PackingItemContributorsKyselyDB = Pick<DB, 'packing_item_contributors' | 'users'>;/*** `packing_item_contributors` — "I can bring that too" co-contributors on adiff --git a/server/src/db/repositories/PackingItems.repository.ts b/server/src/db/repositories/PackingItems.repository.tsindex fcc739afd..e8ffd73d9 100644--- a/server/src/db/repositories/PackingItems.repository.ts+++ b/server/src/db/repositories/PackingItems.repository.ts@@ -4,6 +4,7 @@ import { type AssertRowKeys } from './_shared/rows';import { TrekRepository } from './_shared/trek-repository';import { presenceSet } from './_shared/presence-set';import { packingVisibleToActorExpr, type PackingVisibilityKyselyDB } from './_shared/packing-visibility';+import type { DB } from '../kysely/db';/** A bare `packing_items` row — every scalar column, incl. the three `persist(false)` relation mirrors (`trip_id`, `bag_id`, `owner_id`) — the program-wide trap this class goes through Kysely throughout to avoid. */export interface PackingItemRow {@@ -42,19 +43,13 @@ export interface PackingItemExportRow {}/**- * `packing_items`'s own Kysely shape, extended from `_shared/packing-visibility.ts`'s- * `PackingVisibilityKyselyDB` (Task 0, R1) — `PackingItemRow` is a structural- * superset of that file's narrower `{id, is_private, owner_id}` requirement,- * so `packingVisibleToActorExpr` type-checks directly against a query built- * from this interface (the `CalendarStayKyselyDB extends- * ReservationVisibilityKyselyDB` precedent, `Reservations.repository.ts`).+ * `packing_items`'s own tables, joined with `_shared/packing-visibility.ts`'s+ * `PackingVisibilityKyselyDB` (Task 0, R1), so `packingVisibleToActorExpr`+ * type-checks directly against a query built from this alias (the+ * `CalendarStayKyselyDB`/`ReservationVisibilityKyselyDB` precedent,+ * `Reservations.repository.ts`).*/-interface PackingItemsKyselyDB extends PackingVisibilityKyselyDB {- packing_items: PackingItemRow;- packing_item_recipients: { item_id: number; user_id: number };- users: { id: number; username: string; display_name: string | null };- packing_bags: { id: number; name: string };-}+type PackingItemsKyselyDB = PackingVisibilityKyselyDB & Pick<DB, 'packing_items' | 'packing_item_recipients' | 'users' | 'packing_bags'>;/*** `packing_items` — the checklist rows themselves, plus (this class's owndiff --git a/server/src/db/repositories/PackingTemplateCategories.repository.ts b/server/src/db/repositories/PackingTemplateCategories.repository.tsindex 3d56a07bb..c059bba5c 100644--- a/server/src/db/repositories/PackingTemplateCategories.repository.ts+++ b/server/src/db/repositories/PackingTemplateCategories.repository.ts@@ -1,6 +1,7 @@import type { PackingTemplateCategories } from '../entities/PackingTemplateCategories.entity';import { type AssertRowKeys } from './_shared/rows';import { TrekRepository } from './_shared/trek-repository';+import type { DB } from '../kysely/db';/** A bare `packing_template_categories` row — every scalar column, incl. the `persist(false)` `template_id` relation mirror. */export interface PackingTemplateCategoryRow {@@ -12,14 +13,10 @@ export interface PackingTemplateCategoryRow {const _packingTemplateCategoryRowKeys: AssertRowKeys<PackingTemplateCategoryRow, PackingTemplateCategories> = true;-interface PackingTemplateCategoriesKyselyDB {- packing_template_categories: PackingTemplateCategoryRow;-}+type PackingTemplateCategoriesKyselyDB = Pick<DB, 'packing_template_categories'>;-/** The insert-only shape for `insertCategory` (PK56/PK77) — `id` is autoincrement and omitted. */-interface PackingTemplateCategoriesInsertKyselyDB {- packing_template_categories: { template_id: number | string; name: string; sort_order: number };-}+/** The table `insertCategory` (PK56/PK77) inserts into; `id` is the rowid and `InsertOptional` in the generated type. */+type PackingTemplateCategoriesInsertKyselyDB = Pick<DB, 'packing_template_categories'>;/** `packing_template_categories` — the middle tier of the packing template tree. Kysely throughout: `template_id` is `persist(false)`. */export class PackingTemplateCategoriesRepository extends TrekRepository<PackingTemplateCategories> {@@ -40,7 +37,7 @@ export class PackingTemplateCategoriesRepository extends TrekRepository<PackingT* with `TrekRepository`/`EntityRepository`'s own same-named method.*/async insertCategory(template_id: number | string, name: string, sort_order: number): Promise<number> {- const result = await this.kysely<PackingTemplateCategoriesInsertKyselyDB>().insertInto('packing_template_categories').values({ template_id, name, sort_order }).executeTakeFirstOrThrow();+ const result = await this.kysely<PackingTemplateCategoriesInsertKyselyDB>().insertInto('packing_template_categories').values({ template_id: template_id as number, name, sort_order }).executeTakeFirstOrThrow();return Number(result.insertId);}diff --git a/server/src/db/repositories/PackingTemplateItems.repository.ts b/server/src/db/repositories/PackingTemplateItems.repository.tsindex 01171ec9a..2fae4b4a3 100644--- a/server/src/db/repositories/PackingTemplateItems.repository.ts+++ b/server/src/db/repositories/PackingTemplateItems.repository.ts@@ -1,6 +1,7 @@import type { PackingTemplateItems } from '../entities/PackingTemplateItems.entity';import { type AssertRowKeys } from './_shared/rows';import { TrekRepository } from './_shared/trek-repository';+import type { DB } from '../kysely/db';/** A bare `packing_template_items` row — every scalar column, incl. the `persist(false)` `category_id` relation mirror. */export interface PackingTemplateItemRow {@@ -24,15 +25,10 @@ export interface PackingTemplateApplyRow {bag_name: string | null;}-interface PackingTemplateItemsKyselyDB {- packing_template_items: PackingTemplateItemRow;- packing_template_categories: { id: number; template_id: number; name: string; sort_order: number };-}+type PackingTemplateItemsKyselyDB = Pick<DB, 'packing_template_items' | 'packing_template_categories'>;-/** The insert-only shape for `insertTemplateItem` (PK57/PK86) — `id` is autoincrement and omitted. */-interface PackingTemplateItemsInsertKyselyDB {- packing_template_items: { category_id: number | string; name: string; sort_order: number; weight_grams?: number | null; quantity?: number; bag_name?: string | null };-}+/** The table `insertTemplateItem` (PK57/PK86) inserts into; `id` is the rowid and `InsertOptional` in the generated type. */+type PackingTemplateItemsInsertKyselyDB = Pick<DB, 'packing_template_items'>;/** `packing_template_items` — the leaf tier of the packing template tree. Kysely throughout: `category_id` is `persist(false)`. */export class PackingTemplateItemsRepository extends TrekRepository<PackingTemplateItems> {@@ -99,7 +95,7 @@ export class PackingTemplateItemsRepository extends TrekRepository<PackingTemplaconst result = await this.kysely<PackingTemplateItemsInsertKyselyDB>().insertInto('packing_template_items').values({- category_id: row.category_id,+ category_id: row.category_id as number,name: row.name,sort_order: row.sort_order,weight_grams: row.weight_grams,diff --git a/server/src/db/repositories/PackingTemplates.repository.ts b/server/src/db/repositories/PackingTemplates.repository.tsindex b70b7b58f..be3425457 100644--- a/server/src/db/repositories/PackingTemplates.repository.ts+++ b/server/src/db/repositories/PackingTemplates.repository.ts@@ -1,6 +1,7 @@import type { PackingTemplates } from '../entities/PackingTemplates.entity';import { type AssertRowKeys } from './_shared/rows';import { TrekRepository } from './_shared/trek-repository';+import type { DB } from '../kysely/db';/** A bare `packing_templates` row — every scalar column, incl. the `persist(false)` `created_by` relation mirror. */export interface PackingTemplateRow {@@ -26,17 +27,10 @@ export interface PackingTemplateAdminRow extends PackingTemplateRow {category_count: number;}-interface PackingTemplatesKyselyDB {- packing_templates: PackingTemplateRow;- packing_template_categories: { id: number; template_id: number; name: string; sort_order: number };- packing_template_items: { id: number; category_id: number; name: string; sort_order: number };- users: { id: number; username: string };-}+type PackingTemplatesKyselyDB = Pick<DB, 'packing_templates' | 'packing_template_categories' | 'packing_template_items' | 'users'>;-/** The insert-only shape for `insertTemplate` (PK55/PK68) — `id`/`created_at` are autoincrement/`DEFAULT CURRENT_TIMESTAMP` and omitted. */-interface PackingTemplatesInsertKyselyDB {- packing_templates: { name: string; created_by: number };-}+/** The table `insertTemplate` (PK55/PK68) inserts into; `id`/`created_at` are `InsertOptional` in the generated type. */+type PackingTemplatesInsertKyselyDB = Pick<DB, 'packing_templates'>;/*** `packing_templates` — the top level of the (admin-managed) packingdiff --git a/server/src/db/repositories/Photos.repository.ts b/server/src/db/repositories/Photos.repository.tsindex f3e0efaf0..e71344025 100644--- a/server/src/db/repositories/Photos.repository.ts+++ b/server/src/db/repositories/Photos.repository.ts@@ -1,10 +1,9 @@import type { Photos } from '../entities/Photos.entity';import { TrekRepository } from './_shared/trek-repository';+import type { DB } from '../kysely/db';-/** The narrow `photos` shape {@link PhotosRepository.findTripIdByFilename} needs. */-interface PhotosKyselyDB {- photos: { filename: string; trip_id: number };-}+/** The `photos` tables {@link PhotosRepository.findTripIdByFilename} reads. */+type PhotosKyselyDB = Pick<DB, 'photos'>;/*** `photos` (Plan 4 Task 1's platform.routes.ts pickup — the last table with nodiff --git a/server/src/db/repositories/PlaceRatings.repository.ts b/server/src/db/repositories/PlaceRatings.repository.tsindex f92fd6147..0be147462 100644--- a/server/src/db/repositories/PlaceRatings.repository.ts+++ b/server/src/db/repositories/PlaceRatings.repository.ts@@ -1,5 +1,6 @@import type { PlaceRatings } from '../entities/PlaceRatings.entity';import { TrekRepository } from './_shared/trek-repository';+import type { DB } from '../kysely/db';/** One rated place, from `QueryHelpersService.loadRatingsByPlaceIds` (QH2). */export interface PlaceRatingForPlaceRow {@@ -89,7 +90,7 @@ export class PlaceRatingsRepository extends TrekRepository<PlaceRatings> {* variant of the same finding).*/async listVotesForPlace(place_id: number): Promise<{ user_id: number; rating: number }[]> {- return await this.kysely<{ place_ratings: { place_id: number; user_id: number; rating: number } }>()+ return await this.kysely<Pick<DB, 'place_ratings'>>().selectFrom('place_ratings').select(['user_id', 'rating']).where('place_id', '=', place_id)diff --git a/server/src/db/repositories/PlaceRegions.repository.ts b/server/src/db/repositories/PlaceRegions.repository.tsindex c0028b59b..ab201a465 100644--- a/server/src/db/repositories/PlaceRegions.repository.ts+++ b/server/src/db/repositories/PlaceRegions.repository.ts@@ -1,5 +1,6 @@import type { PlaceRegions } from '../entities/PlaceRegions.entity';import { TrekRepository } from './_shared/trek-repository';+import type { DB } from '../kysely/db';/** `place_regions` — the columns `AT28`'s `SELECT *` needs. */export interface PlaceRegionRow {@@ -9,12 +10,7 @@ export interface PlaceRegionRow {region_name: string;}-interface PlaceRegionsKyselyDB {- place_regions: { place_id: number; country_code: string; region_code: string; region_name: string };- places: { id: number; trip_id: number; lat: number | null; lng: number | null; address: string | null };- trips: { id: number; user_id: number; start_date: string | null; end_date: string | null };- trip_members: { trip_id: number; user_id: number };-}+type PlaceRegionsKyselyDB = Pick<DB, 'place_regions' | 'places' | 'trips' | 'trip_members'>;/*** `place_regions` — the geocoded-country/region cache for a place (Plan 3fdiff --git a/server/src/db/repositories/Places.repository.ts b/server/src/db/repositories/Places.repository.tsindex 62f9733c4..1496c4669 100644--- a/server/src/db/repositories/Places.repository.ts+++ b/server/src/db/repositories/Places.repository.ts@@ -7,6 +7,7 @@ import { TrekRepository } from './_shared/trek-repository';// declaration of the same shape is exactly the duplication Sonar flags and// the program's "single source of truth" rule (root CLAUDE.md) forbids.import type { TagRow } from './Tags.repository';+import type { DB } from '../kysely/db';/** A `places` row as the API emits it — every scalar column of the entity. */export interface PlaceRow {@@ -63,10 +64,8 @@ export interface PlaceListRow extends PlaceWithCategoryRow {region_name: string | null;}-/** {@link PlacesRepository.findActiveTripFile}'s narrow `trip_files` shape. */-interface PlacesTripFileKyselyDB {- trip_files: { id: number; trip_id: number; filename: string; original_name: string; mime_type: string | null; file_size: number | null; deleted_at: string | null };-}+/** {@link PlacesRepository.findActiveTripFile}'s `trip_files` tables. */+type PlacesTripFileKyselyDB = Pick<DB, 'trip_files'>;/*** {@link PlacesRepository.listPublicForShare}'s projection (SH12) — the@@ -81,14 +80,7 @@ export type SharePublicPlaceRow = Pick<| 'created_at' | 'updated_at' | 'category_name' | 'category_color' | 'category_icon'>;-interface SharePublicPlaceKyselyDB {- places: Pick<PlaceRow,- | 'id' | 'trip_id' | 'name' | 'description' | 'lat' | 'lng' | 'address' | 'category_id' | 'price' | 'currency'- | 'place_time' | 'end_time' | 'duration_minutes' | 'notes' | 'image_url' | 'website' | 'phone' | 'transport_mode'- | 'created_at' | 'updated_at'- >;- categories: { id: number; name: string; color: string | null; icon: string | null };-}+type SharePublicPlaceKyselyDB = Pick<DB, 'places' | 'categories'>;interface PlaceRatingRow {user_id: number;@@ -896,7 +888,7 @@ export class PlacesRepository extends TrekRepository<Places> {* `image_url`.*/async existsByTripAndImageUrl(trip_id: number | string, imageUrl: string): Promise<boolean> {- const row = await this.kysely<{ places: { id: number; trip_id: number; image_url: string | null } }>()+ const row = await this.kysely<Pick<DB, 'places'>>().selectFrom('places').select('id').where('trip_id', '=', trip_id as number)@@ -1392,12 +1384,8 @@ export interface PublicApiAssignedPlaceRow extends PublicApiPlaceColumns {category: string | null;}-/** {@link PlacesRepository.listAssignedForPublicApi}'s narrow `day_assignments`/`places`/`categories` shape. */-interface PublicApiAssignedPlacesKyselyDB {- day_assignments: { day_id: number; place_id: number; accommodation_id: number | null; order_index: number | null };- places: PublicApiPlaceColumns & Pick<PlaceRow, 'id' | 'trip_id' | 'category_id'>;- categories: { id: number; name: string };-}+/** {@link PlacesRepository.listAssignedForPublicApi}'s `day_assignments`/`places`/`categories` tables. */+type PublicApiAssignedPlacesKyselyDB = Pick<DB, 'day_assignments' | 'places' | 'categories'>;/** {@link PlacesRepository.listImportable}'s row shape (CL45). */export interface ImportablePlaceRow {@@ -1426,39 +1414,11 @@ export interface PlaceMatchRow {osm_id: string | null;}-/** {@link PlacesRepository.listImportable}'s narrow `places`/`day_assignments`/`days` shape (CL45). */-interface ImportablePlacesKyselyDB {- places: { id: number; trip_id: number; name: string; address: string | null; lat: number | null; lng: number | null; category_id: number | null; image_url: string | null; google_place_id: string | null; google_ftid: string | null; osm_id: string | null };- day_assignments: { place_id: number; day_id: number };- days: { id: number; trip_id: number; day_number: number; date: string };-}+/** {@link PlacesRepository.listImportable}'s `places`/`day_assignments`/`days` tables (CL45). */+type ImportablePlacesKyselyDB = Pick<DB, 'places' | 'day_assignments' | 'days'>;-/** {@link PlacesRepository.insertFromCollectionPlace}'s narrow insert-only shape (CL64). */-interface PlacesNarrowInsertKyselyDB {- places: {- trip_id: number;- name: string;- description: string | null;- lat: number | null;- lng: number | null;- address: string | null;- category_id: number | null;- price: number | null;- currency: string | null;- notes: string | null;- image_url: string | null;- google_place_id: string | null;- google_ftid: string | null;- website: string | null;- phone: string | null;- osm_id: string | null;- };-}+/** The table {@link PlacesRepository.insertFromCollectionPlace} (CL64) inserts into. */+type PlacesNarrowInsertKyselyDB = Pick<DB, 'places'>;-/** {@link PlacesRepository.listAddressesForUser}'s narrow `places`/`trips`/`trip_members`/`place_regions` shape. */-interface PlacesAddressesForUserKyselyDB {- places: { id: number; trip_id: number; address: string | null; lat: number | null; lng: number | null };- trips: { id: number; user_id: number };- trip_members: { trip_id: number; user_id: number };- place_regions: { place_id: number; region_name: string | null };-}+/** {@link PlacesRepository.listAddressesForUser}'s `places`/`trips`/`trip_members`/`place_regions` tables. */+type PlacesAddressesForUserKyselyDB = Pick<DB, 'places' | 'trips' | 'trip_members' | 'place_regions'>;diff --git a/server/src/db/repositories/PluginCapabilityAudit.repository.ts b/server/src/db/repositories/PluginCapabilityAudit.repository.tsindex fe3a5030d..33b0203c4 100644--- a/server/src/db/repositories/PluginCapabilityAudit.repository.ts+++ b/server/src/db/repositories/PluginCapabilityAudit.repository.ts@@ -1,5 +1,6 @@import type { PluginCapabilityAudit } from '../entities/PluginCapabilityAudit.entity';import { TrekRepository } from './_shared/trek-repository';+import type { DB } from '../kysely/db';/*** Plan 3j Task 2 note: this repository's ONLY method today is the uninstall@@ -164,18 +165,5 @@ export interface AuditForPluginRow {code: string;}-/** Kysely shape for `pruneKeepingNewest`/`forUser`/`budgetSeed`'s escape-hatch queries — only the columns/tables they actually touch. */-interface PluginCapabilityAuditKyselyDB {- plugin_capability_audit: {- id: number;- plugin_id: string;- acting_user_id: number | null;- method: string;- resource: string | null;- code: string;- ts: string;- prev_hash: string | null;- hash: string;- };- plugins: { id: string; name: string };-}+/** The tables `pruneKeepingNewest`/`forUser`/`budgetSeed`'s escape-hatch queries touch. */+type PluginCapabilityAuditKyselyDB = Pick<DB, 'plugin_capability_audit' | 'plugins'>;diff --git a/server/src/db/repositories/PluginErrorLog.repository.ts b/server/src/db/repositories/PluginErrorLog.repository.tsindex 164210bd1..46dee0959 100644--- a/server/src/db/repositories/PluginErrorLog.repository.ts+++ b/server/src/db/repositories/PluginErrorLog.repository.ts@@ -1,5 +1,6 @@import type { PluginErrorLog } from '../entities/PluginErrorLog.entity';import { TrekRepository } from './_shared/trek-repository';+import type { DB } from '../kysely/db';/** PR2 delivery row / plugins.service.ts `errors()`'s own projection. */export interface PluginErrorLogRow {@@ -8,10 +9,8 @@ export interface PluginErrorLogRow {message: string;}-/** `pruneKeepingRecent`'s own `this.kysely()` escape hatch (`_shared/trek-repository.ts`) — the `id`/`plugin_id` columns its correlated subquery needs. */-interface PluginErrorLogKyselyDB {- plugin_error_log: { id: number; plugin_id: string };-}+/** The tables `pruneKeepingRecent`'s own `this.kysely()` escape hatch (`_shared/trek-repository.ts`) reads, for its correlated subquery on `id`/`plugin_id`. */+type PluginErrorLogKyselyDB = Pick<DB, 'plugin_error_log'>;export class PluginErrorLogRepository extends TrekRepository<PluginErrorLog> {/** PR2 — `INSERT INTO plugin_error_log (plugin_id, level, message) VALUES (?, ?, ?)` (the supervisor's `onLog` callback — §4a, lazily resolved, own try/catch swallow unchanged in the caller). */diff --git a/server/src/db/repositories/PluginOauthState.repository.ts b/server/src/db/repositories/PluginOauthState.repository.tsindex 39731adf4..a9c0d083e 100644--- a/server/src/db/repositories/PluginOauthState.repository.ts+++ b/server/src/db/repositories/PluginOauthState.repository.ts@@ -1,5 +1,6 @@import type { PluginOauthState } from '../entities/PluginOauthState.entity';import { TrekRepository } from './_shared/trek-repository';+import type { DB } from '../kysely/db';/*** Plan 3j Task 2 note: this repository's ONLY method today is the uninstall@@ -18,15 +19,7 @@ export interface PluginOauthStateRow {}/** `consumeByState`'s own Kysely DB shape. */-interface PluginOauthStateKyselyDB {- plugin_oauth_state: {- state: string;- plugin_id: string;- user_id: number;- verifier: string;- created_at: number;- };-}+type PluginOauthStateKyselyDB = Pick<DB, 'plugin_oauth_state'>;export class PluginOauthStateRepository extends TrekRepository<PluginOauthState> {/** PR43 (uninstall cascade, `deleteData` branch) — `DELETE FROM plugin_oauth_state WHERE plugin_id = ?`. */diff --git a/server/src/db/repositories/PluginOauthTokens.repository.ts b/server/src/db/repositories/PluginOauthTokens.repository.tsindex 3f87a0d62..a8ae9e662 100644--- a/server/src/db/repositories/PluginOauthTokens.repository.ts+++ b/server/src/db/repositories/PluginOauthTokens.repository.ts@@ -1,6 +1,7 @@import type { PluginOauthTokens } from '../entities/PluginOauthTokens.entity';import { currentTimestampKysely } from '../dialect/sql-functions';import { TrekRepository } from './_shared/trek-repository';+import type { DB } from '../kysely/db';/*** Plan 3j Task 2 note: this repository's ONLY method today is the uninstall@@ -20,23 +21,8 @@ export interface PluginOauthTokenRow {expires_at: number | null;}-/**- * PO11's insert-only shape (`storeToken`'s VALUES list — `updated_at` is always- * `datetime('now')`/`CURRENT_TIMESTAMP`, never caller-supplied, same reasoning- * `DocumentSyncItemsRepository`'s own write-only Kysely interface docstring gives- * for a SEPARATE interface rather than widening the read-shaped row above).- */-interface PluginOauthTokensWriteKyselyDB {- plugin_oauth_tokens: {- plugin_id: string;- user_id: number;- access_token: string | null;- refresh_token: string | null;- expires_at: number | null;- scope: string | null;- updated_at: string;- };-}+/** PO11's insert table (`storeToken`'s VALUES list): `updated_at` is always `CURRENT_TIMESTAMP`, never caller-supplied. */+type PluginOauthTokensWriteKyselyDB = Pick<DB, 'plugin_oauth_tokens'>;export class PluginOauthTokensRepository extends TrekRepository<PluginOauthTokens> {/** PR42 (uninstall cascade, `deleteData` branch) — `DELETE FROM plugin_oauth_tokens WHERE plugin_id = ?`. */diff --git a/server/src/db/repositories/PluginUserErasureQueue.repository.ts b/server/src/db/repositories/PluginUserErasureQueue.repository.tsindex 772a452b2..a32eb3ce9 100644--- a/server/src/db/repositories/PluginUserErasureQueue.repository.ts+++ b/server/src/db/repositories/PluginUserErasureQueue.repository.ts@@ -1,5 +1,6 @@import type { PluginUserErasureQueue } from '../entities/PluginUserErasureQueue.entity';import { TrekRepository } from './_shared/trek-repository';+import type { DB } from '../kysely/db';/** The drain's own pending-row projection. */export interface PendingErasureRow {@@ -8,11 +9,8 @@ export interface PendingErasureRow {user_id: number;}-/** `plugin_id`/`id` — the columns the orphan-scan's correlated `NOT IN (SELECT id FROM plugins)` subquery needs. */-interface PluginUserErasureQueueKyselyDB {- plugin_user_erasure_queue: { id: number; plugin_id: string; user_id: number };- plugins: { id: string };-}+/** The tables the orphan-scan's correlated `NOT IN (SELECT id FROM plugins)` subquery reads. */+type PluginUserErasureQueueKyselyDB = Pick<DB, 'plugin_user_erasure_queue' | 'plugins'>;export class PluginUserErasureQueueRepository extends TrekRepository<PluginUserErasureQueue> {/** PR8 — `INSERT OR IGNORE INTO plugin_user_erasure_queue (plugin_id, user_id) VALUES (?, ?)` (idempotent — a duplicate enqueue for the same pair is a no-op). */diff --git a/server/src/db/repositories/PushSubscriptions.repository.ts b/server/src/db/repositories/PushSubscriptions.repository.tsindex 662d80ad2..1a5d6c493 100644--- a/server/src/db/repositories/PushSubscriptions.repository.ts+++ b/server/src/db/repositories/PushSubscriptions.repository.ts@@ -2,6 +2,7 @@ import type { PushSubscriptions } from '../entities/PushSubscriptions.entity';import { columnIncrementedBy, currentTimestamp, currentTimestampKysely } from '../dialect/sql-functions';import type { AssertRowKeys } from './_shared/rows';import { TrekRepository } from './_shared/trek-repository';+import type { DB } from '../kysely/db';/** A `push_subscriptions` row exactly as `SELECT *` reads it (Web Push, #894). */export interface PushSubscriptionRow {@@ -19,23 +20,10 @@ export interface PushSubscriptionRow {const _pushSubscriptionRowKeys: AssertRowKeys<PushSubscriptionRow, PushSubscriptions> = true;-interface PushSubscriptionsKyselyDB {- push_subscriptions: PushSubscriptionRow;-}+type PushSubscriptionsKyselyDB = Pick<DB, 'push_subscriptions'>;-/** The columns PS1's INSERT binds; the rest come from their defaults. */-interface PushSubscriptionsInsertKyselyDB {- push_subscriptions: {- user_id: number;- endpoint: string;- p256dh: string;- auth: string;- vapid_public_key: string;- user_agent: string | null;- created_at: string;- failure_count: number;- };-}+/** The table PS1's INSERT binds; the columns it leaves out come from their defaults. */+type PushSubscriptionsInsertKyselyDB = Pick<DB, 'push_subscriptions'>;/** `push_subscriptions` — one row per browser a user switched Web Push on in. */export class PushSubscriptionsRepository extends TrekRepository<PushSubscriptions> {diff --git a/server/src/db/repositories/ReservationDayPositions.repository.ts b/server/src/db/repositories/ReservationDayPositions.repository.tsindex 0ac75b16d..b27c487dd 100644--- a/server/src/db/repositories/ReservationDayPositions.repository.ts+++ b/server/src/db/repositories/ReservationDayPositions.repository.ts@@ -1,28 +1,10 @@import type { ReservationDayPositions } from '../entities/ReservationDayPositions.entity';import { columnRef } from '../dialect/sql-functions';import { TrekRepository } from './_shared/trek-repository';+import type { DB } from '../kysely/db';/** `reservation_day_positions`/`reservations`/`days`'s shape for RS31's Kysely upsert. */-interface ReservationDayPositionsKyselyDB {- reservation_day_positions: {- reservation_id: number;- day_id: number;- position: number;- };- reservations: {- id: number;- // `number | string`: the legacy statement raw-binds `tripId` exactly as- // the caller received it (D4's T5 escape hatch) — the Kysely column type- // here is widened to accept both without narrowing which non-canonical- // ids match, never actually persisted (this table has no `trip_id`- // column of its own).- trip_id: number | string;- };- days: {- id: number;- trip_id: number | string;- };-}+type ReservationDayPositionsKyselyDB = Pick<DB, 'reservation_day_positions' | 'reservations' | 'days'>;export class ReservationDayPositionsRepository extends TrekRepository<ReservationDayPositions> {/**@@ -72,7 +54,7 @@ export class ReservationDayPositionsRepository extends TrekRepository<Reservatio.select(['r.id as reservation_id', 'd.id as day_id', eb.val(position).as('position')]).where('r.id', '=', reservation_id).where('d.id', '=', day_id)- .where('r.trip_id', '=', trip_id),+ .where('r.trip_id', '=', trip_id as number),).execute();}diff --git a/server/src/db/repositories/ReservationEndpoints.repository.ts b/server/src/db/repositories/ReservationEndpoints.repository.tsindex 9907e5cad..2481bc450 100644--- a/server/src/db/repositories/ReservationEndpoints.repository.ts+++ b/server/src/db/repositories/ReservationEndpoints.repository.ts@@ -3,6 +3,7 @@ import { type AssertRowKeys } from './_shared/rows';import { columnRef } from '../dialect/sql-functions';import { travelerOwnsExpr, type ReservationTravelersOwnsKyselyDB } from './_shared/reservation-travelers-owns';import { TrekRepository } from './_shared/trek-repository';+import type { DB } from '../kysely/db';/** A `reservation_endpoints` row exactly as `r.*`/`SELECT *` read it (every scalar column). */export interface ReservationEndpointRow {@@ -273,14 +274,8 @@ export interface TravelerOwnedEndpointRow {fallback_time: string | null;}-/** {@link ReservationEndpointsRepository.listOwnedEndpointsForTrips}'s narrow `reservation_endpoints`/`reservations`/`reservation_travelers` shape (`r` aliased for `travelerOwnsExpr`, R7). */-interface TravelerOwnedEndpointsKyselyDB extends ReservationTravelersOwnsKyselyDB {- reservation_endpoints: { id: number; reservation_id: number; role: string; sequence: number; code: string | null; lat: number; lng: number; local_date: string | null; local_time: string | null };- reservations: ReservationTravelersOwnsKyselyDB['reservations'] & { trip_id: number; type: string | null; status: string | null; reservation_time: string | null; reservation_end_time: string | null };-}+/** {@link ReservationEndpointsRepository.listOwnedEndpointsForTrips}'s `reservation_endpoints`/`reservations`/`reservation_travelers` tables (`r` aliased for `travelerOwnsExpr`, R7). */+type TravelerOwnedEndpointsKyselyDB = ReservationTravelersOwnsKyselyDB & Pick<DB, 'reservation_endpoints' | 'reservations'>;-/** {@link ReservationEndpointsRepository.listOwnedEndpointsForUser}/{@link ReservationEndpointsRepository.listOwnedFlightLegsForUser}'s narrow shape, adding `trips`/`trip_members` to {@link TravelerOwnedEndpointsKyselyDB}. */-interface TravelerOwnedEndpointsWithTripsKyselyDB extends TravelerOwnedEndpointsKyselyDB {- trips: { id: number; user_id: number; start_date: string | null; end_date: string | null };- trip_members: { trip_id: number; user_id: number };-}+/** {@link ReservationEndpointsRepository.listOwnedEndpointsForUser}/{@link ReservationEndpointsRepository.listOwnedFlightLegsForUser}'s tables, adding `trips`/`trip_members` to {@link TravelerOwnedEndpointsKyselyDB}. */+type TravelerOwnedEndpointsWithTripsKyselyDB = TravelerOwnedEndpointsKyselyDB & Pick<DB, 'trips' | 'trip_members'>;diff --git a/server/src/db/repositories/Reservations.repository.ts b/server/src/db/repositories/Reservations.repository.tsindex 96c8781fd..5f6e3e980 100644--- a/server/src/db/repositories/Reservations.repository.ts+++ b/server/src/db/repositories/Reservations.repository.ts@@ -5,6 +5,7 @@ import { castIntegerKysely, coalesceOverride, columnRef, concatKysely, dayDistanimport { publicReservationExpr, publicStayExists, type ReservationVisibilityKyselyDB } from './_shared/reservation-visibility';import type { DayAssignmentRow } from './DayAssignments.repository';import { TrekRepository } from './_shared/trek-repository';+import type { DB } from '../kysely/db';/*** RS18/RR1's shared joined projection — `SELECT r.*, d.day_number, p.name as@@ -60,46 +61,18 @@ export interface ReservationJoinRow {* relation-path `.join()` cannot express `LEFT JOIN day_accommodations ap ON* r.accommodation_id = ap.id` at all — the same escape hatch* `DayAssignmentsRepository.effectiveStart`/`TripsRepository.tripSelectQuery`- * use. `id`/`trip_id` stay `number | string` (raw-bind, D4's T5 seam): a- * Kysely `.where(col, '=', value)` call is a TYPED condition regardless of- * how loosely its value is typed (program rule 23 bans a raw SQL-text- * condition string, not a loosely-typed bound value), so this join keeps the- * legacy statement's exact raw-bind flexibility.+ * use. The `id`/`trip_id` the callers pass stay `number | string` (raw-bind,+ * D4's T5 seam) and are cast to the column type only at the bind, so this+ * join keeps the legacy statement's exact raw-bind flexibility.*/-interface ReservationJoinKyselyDB {- reservations: {- id: number | string;- trip_id: number | string;- day_id: number | null;- end_day_id: number | null;- place_id: number | null;- assignment_id: number | null;- title: string;- accommodation_id: string | null;- reservation_time: string | null;- reservation_end_time: string | null;- location: string | null;- confirmation_number: string | null;- notes: string | null;- status: string | null;- type: string | null;- created_at: string | null;- metadata: string | null;- day_plan_position: number | null;- needs_review: number;- external_source: string | null;- external_id: string | null;- external_owner_user_id: number | null;- external_synced_at: string | null;- sync_enabled: number | null;- external_hash: string | null;- url: string | null;- ingest_state: string;- };- days: { id: number; day_number: number };- places: { id: number; name: string };- day_accommodations: { id: number; place_id: number | null; start_day_id: number; end_day_id: number };-}+type ReservationJoinKyselyDB = Pick<DB, 'reservations' | 'days' | 'places' | 'day_accommodations'>;++/**+ * `reservations` as the two aliases below bind it: `accommodation_id` is a+ * TEXT column, widened to `string | number | null` so the plain `number`+ * their statements bind against it type-checks (R2's ruling).+ */+type ReservationsNumericAccommodationBind = Omit<DB['reservations'], 'accommodation_id'> & { accommodation_id: string | number | null };/*** Kysely typing for `restampLinkedReservation` (DY23). `accommodation_id:@@ -111,15 +84,7 @@ interface ReservationJoinKyselyDB {* time regardless of which JS type bound the value — see the method's own* docstring).*/-interface ReservationRestampKyselyDB {- reservations: {- id: number;- accommodation_id: string | number | null;- type: string | null;- day_id: number | null;- reservation_time: string | null;- };-}+type ReservationRestampKyselyDB = { reservations: ReservationsNumericAccommodationBind };/*** Kysely typing for AC37/AC40 (`listIdMetadataByStay`/`listIdsByStay`).@@ -151,18 +116,7 @@ interface ReservationRestampKyselyDB {* comparison used a `CAST`, not a bound number — this interface's two* consumers are not that case.*/-interface ReservationsByAccommodationKyselyDB {- reservations: {- id: number;- // `string | number | null`, not just `string` (R2's ruling, the same- // widening {@link ReservationRestampKyselyDB} documents for DY23): the- // column is TEXT, but the bind below is a plain `number`, matching the- // legacy's own `Number(id)` bind — the interface only needs to- // type-check that bind, not describe the column's storage type.- accommodation_id: string | number | null;- metadata: string | null;- };-}+type ReservationsByAccommodationKyselyDB = { reservations: ReservationsNumericAccommodationBind };// ---------------------------------------------------------------------------// Plan 3d Task 4 (calendar, `listUpcoming`, the visibility-predicate@@ -213,12 +167,7 @@ export interface CalendarReservationRow extends ReservationAllColumnsRow {end_day_date: string | null;}-interface CalendarReservationKyselyDB {- reservations: ReservationJoinKyselyDB['reservations'];- places: { id: number; lat: number | null; lng: number | null };- day_accommodations: { id: number; start_day_id: number | null; end_day_id: number | null; check_in: string | null; check_out: string | null };- days: { id: number; date: string | null };-}+type CalendarReservationKyselyDB = Pick<DB, 'reservations' | 'places' | 'day_accommodations' | 'days'>;/*** CL4 (`CalendarService.buildTripCalendar`'s per-day assignment read,@@ -244,15 +193,7 @@ export interface CalendarStopRow extends DayAssignmentRow {effective_end_time: string | null;}-interface CalendarStopsKyselyDB {- day_assignments: {- id: number; day_id: number; place_id: number; order_index: number | null; notes: string | null;- reservation_status: string | null; reservation_notes: string | null; reservation_datetime: string | null;- created_at: string | null; assignment_time: string | null; assignment_end_time: string | null;- leg_transport_mode: string | null; incoming_leg_transport_mode: string | null; end_day: number; accommodation_id: number | null;- };- places: { id: number; name: string; address: string | null; lat: number | null; lng: number | null; place_time: string | null; end_time: string | null };-}+type CalendarStopsKyselyDB = Pick<DB, 'day_assignments' | 'places'>;/*** CL7 (`CalendarService.buildTripCalendar`'s check-in/check-out stay read)@@ -286,15 +227,7 @@ export interface CalendarStayRow {reservation_title: string | null;}-interface CalendarStayKyselyDB extends ReservationVisibilityKyselyDB {- day_accommodations: {- id: number; trip_id: number | string; place_id: number | null; start_day_id: number | null; end_day_id: number | null;- check_in: string | null; check_in_end: string | null; check_out: string | null;- };- reservations: ReservationVisibilityKyselyDB['reservations'] & { title: string };- days: { id: number; date: string | null };- places: { id: number; name: string | null; address: string | null; lat: number | null; lng: number | null };-}+type CalendarStayKyselyDB = ReservationVisibilityKyselyDB & Pick<DB, 'day_accommodations' | 'reservations' | 'days' | 'places'>;/*** RS20 (`ReservationsService.listUpcoming`) — the CTE + `UNION ALL`@@ -344,21 +277,7 @@ interface EntriesRow extends UpcomingReservationRow {at_time: string | null;}-interface UpcomingReservationsKyselyDB {- trips: { id: number; user_id: number; title: string; cover_image: string | null; is_archived: number };- trip_members: { trip_id: number; user_id: number };- reservations: {- id: number; trip_id: number; title: string; type: string | null; status: string | null;- location: string | null; reservation_time: string | null; confirmation_number: string | null;- day_id: number | null; place_id: number | null; accommodation_id: string | null;- };- days: { id: number; date: string | null };- places: { id: number; name: string | null; image_url: string | null };- day_accommodations: {- id: number; trip_id: number; place_id: number | null; start_day_id: number; end_day_id: number;- check_in: string | null; check_out: string | null; confirmation: string | null;- };-}+type UpcomingReservationsKyselyDB = Pick<DB, 'trips' | 'trip_members' | 'reservations' | 'days' | 'places' | 'day_accommodations'>;/*** `share.service.ts:251` (`publicEndpointsByReservation`) — `SELECT@@ -384,13 +303,7 @@ export interface ShareEndpointRow {local_time: string | null;}-interface ShareEndpointsKyselyDB {- reservation_endpoints: {- reservation_id: number; role: string; sequence: number; name: string; code: string | null;- lat: number; lng: number; timezone: string | null; local_date: string | null; local_time: string | null;- };- reservations: { id: number; trip_id: number | string };-}+type ShareEndpointsKyselyDB = Pick<DB, 'reservation_endpoints' | 'reservations'>;/*** `share.service.ts:368` (`getSharedTripData`'s day-position read) —@@ -406,10 +319,7 @@ export interface ShareDayPositionRow {position: number;}-interface ShareDayPositionsKyselyDB {- reservation_day_positions: { reservation_id: number; day_id: number; position: number };- reservations: { id: number; trip_id: number | string };-}+type ShareDayPositionsKyselyDB = Pick<DB, 'reservation_day_positions' | 'reservations'>;/*** `share.service.ts:387` (`getSharedTripData`'s public booking read) —@@ -440,15 +350,7 @@ export interface SharePublicReservationRow {created_at: string | null;}-interface SharePublicReservationKyselyDB {- reservations: ReservationVisibilityKyselyDB['reservations'] & {- trip_id: number | string;- day_id: number | null; end_day_id: number | null; place_id: number | null; title: string;- type: string | null; status: string | null; location: string | null;- reservation_time: string | null; reservation_end_time: string | null;- notes: string | null; url: string | null; metadata: string | null; created_at: string | null;- };-}+type SharePublicReservationKyselyDB = Pick<DB, 'reservations'>;/*** `share.service.ts:401` (`getSharedTripData`'s public stay read) —@@ -476,13 +378,7 @@ export interface SharePublicAccommodationRow {place_lng: number | null;}-interface SharePublicAccommodationKyselyDB extends ReservationVisibilityKyselyDB {- day_accommodations: {- id: number; trip_id: number | string; place_id: number | null; start_day_id: number | null; end_day_id: number | null;- check_in: string | null; check_in_end: string | null; check_out: string | null; notes: string | null;- };- places: { id: number; name: string | null; address: string | null; lat: number | null; lng: number | null };-}+type SharePublicAccommodationKyselyDB = ReservationVisibilityKyselyDB & Pick<DB, 'day_accommodations' | 'places'>;/*** `public-api.service.ts::reservationsByDay` (Task 5's `// Task 2` pickup)@@ -508,13 +404,7 @@ export interface PublicApiScheduledReservationRow {*/export type PublicApiUnscheduledReservationRow = Omit<PublicApiScheduledReservationRow, 'day_id'>;-interface PublicApiReservationKyselyDB {- reservations: {- id: number; trip_id: number; day_id: number | null; type: string | null; title: string | null;- location: string | null; reservation_time: string | null; reservation_end_time: string | null;- status: string | null; notes: string | null;- };-}+type PublicApiReservationKyselyDB = Pick<DB, 'reservations'>;/*** `public-api.service.ts::buildAccommodations` (Task 5's `// Task 3`@@ -536,11 +426,7 @@ export interface PublicApiAccommodationRow {notes: string | null;}-interface PublicApiAccommodationKyselyDB {- day_accommodations: { id: number; trip_id: number; place_id: number | null; start_day_id: number | null; end_day_id: number | null; check_in: string | null; check_out: string | null; notes: string | null };- places: { id: number; name: string | null; address: string | null; lat: number | null; lng: number | null };- days: { id: number; date: string | null };-}+type PublicApiAccommodationKyselyDB = Pick<DB, 'day_accommodations' | 'places' | 'days'>;/*** `public-api.service.ts::buildUnplannedPlaces` (Task 5's `// Task 3`@@ -567,26 +453,14 @@ export interface PublicApiUnplannedPlaceRow {category: string | null;}-interface PublicApiUnplannedPlaceKyselyDB {- places: {- id: number; trip_id: number; name: string; address: string | null; lat: number | null; lng: number | null;- place_time: string | null; end_time: string | null; duration_minutes: number | null; notes: string | null;- transport_mode: string | null; category_id: number | null; created_at: string | null;- };- categories: { id: number; name: string };- day_assignments: { id: number; place_id: number };- day_accommodations: { id: number; place_id: number | null };-}+type PublicApiUnplannedPlaceKyselyDB = Pick<DB, 'places' | 'categories' | 'day_assignments' | 'day_accommodations'>;/*** Plan 3h Task 4 (`AirportsService.backfillFlightEndpoints`, AIR1) —- * additive. The narrow `reservations`/`reservation_endpoints` shape the- * `NOT EXISTS` guard needs.+ * additive. The `reservations`/`reservation_endpoints` tables the+ * `NOT EXISTS` guard reads.*/-interface FlightsMissingEndpointsKyselyDB {- reservations: { id: number; metadata: string | null; reservation_time: string | null; reservation_end_time: string | null; type: string | null };- reservation_endpoints: { id: number; reservation_id: number };-}+type FlightsMissingEndpointsKyselyDB = Pick<DB, 'reservations' | 'reservation_endpoints'>;export class ReservationsRepository extends TrekRepository<Reservations> {private joinedQuery() {@@ -613,7 +487,7 @@ export class ReservationsRepository extends TrekRepository<Reservations> {*/async listForTrip(trip_id: number | string): Promise<ReservationJoinRow[]> {const rows = await this.joinedQuery()- .where('r.trip_id', '=', trip_id)+ .where('r.trip_id', '=', trip_id as number).orderBy('r.reservation_time', 'asc').orderBy('r.created_at', 'asc').execute();@@ -625,7 +499,7 @@ export class ReservationsRepository extends TrekRepository<Reservations> {* projection for one reservation, no `ORDER BY` (a single row).*/async findWithJoins(id: number | string): Promise<ReservationJoinRow | undefined> {- const row = await this.joinedQuery().where('r.id', '=', id).executeTakeFirst();+ const row = await this.joinedQuery().where('r.id', '=', id as number).executeTakeFirst();return row as ReservationJoinRow | undefined;}@@ -1009,7 +883,7 @@ export class ReservationsRepository extends TrekRepository<Reservations> {* second, differently-named copy of the same fields.*/async listAllForTrip(trip_id: number): Promise<ReservationAllColumnsRow[]> {- return await this.kysely<{ reservations: ReservationAllColumnsRow }>()+ return await this.kysely<Pick<DB, 'reservations'>>().selectFrom('reservations').selectAll().where('trip_id', '=', trip_id)@@ -1113,7 +987,7 @@ export class ReservationsRepository extends TrekRepository<Reservations> {'rd.date as day_date','red.date as end_day_date',])- .where('r.trip_id', '=', trip_id)+ .where('r.trip_id', '=', trip_id as number).where((eb) => publicReservationExpr(eb, 'r.ingest_state')).execute();return rows as CalendarReservationRow[];@@ -1145,7 +1019,7 @@ export class ReservationsRepository extends TrekRepository<Reservations> {async listPublicStaysForCalendar(trip_id: number | string): Promise<CalendarStayRow[]> {const rows = await this.kysely<CalendarStayKyselyDB>().selectFrom('day_accommodations as a')- .where('a.trip_id', '=', trip_id)+ .where('a.trip_id', '=', trip_id as number).where((eb) => publicStayExists(eb)).leftJoin('days as sd', 'sd.id', 'a.start_day_id').leftJoin('days as ed', 'ed.id', 'a.end_day_id')@@ -1343,7 +1217,7 @@ export class ReservationsRepository extends TrekRepository<Reservations> {.selectFrom('reservation_endpoints as e').innerJoin('reservations as r', 'r.id', 'e.reservation_id').select(['e.reservation_id', 'e.role', 'e.sequence', 'e.name', 'e.code', 'e.lat', 'e.lng', 'e.timezone', 'e.local_date', 'e.local_time'])- .where('r.trip_id', '=', trip_id)+ .where('r.trip_id', '=', trip_id as number).orderBy('e.reservation_id', 'asc').orderBy('e.sequence', 'asc').execute();@@ -1356,7 +1230,7 @@ export class ReservationsRepository extends TrekRepository<Reservations> {.selectFrom('reservation_day_positions as rdp').innerJoin('reservations as r', 'r.id', 'rdp.reservation_id').select(['rdp.reservation_id', 'rdp.day_id', 'rdp.position'])- .where('r.trip_id', '=', trip_id)+ .where('r.trip_id', '=', trip_id as number).execute();return rows as ShareDayPositionRow[];}@@ -1370,7 +1244,7 @@ export class ReservationsRepository extends TrekRepository<Reservations> {'r.title', 'r.type', 'r.status', 'r.location', 'r.reservation_time', 'r.reservation_end_time','r.notes', 'r.url', 'r.metadata', 'r.created_at',])- .where('r.trip_id', '=', trip_id)+ .where('r.trip_id', '=', trip_id as number).where((eb) => publicReservationExpr(eb, 'r.ingest_state')).orderBy('r.reservation_time', 'asc').execute();@@ -1381,7 +1255,7 @@ export class ReservationsRepository extends TrekRepository<Reservations> {async listPublicAccommodationsForShare(trip_id: number | string): Promise<SharePublicAccommodationRow[]> {const rows = await this.kysely<SharePublicAccommodationKyselyDB>().selectFrom('day_accommodations as a')- .where('a.trip_id', '=', trip_id)+ .where('a.trip_id', '=', trip_id as number).where((eb) => publicStayExists(eb)).innerJoin('places as p', 'p.id', 'a.place_id').select([@@ -1402,7 +1276,7 @@ export class ReservationsRepository extends TrekRepository<Reservations> {async listPublicStayPlaceIdsForShare(trip_id: number | string): Promise<number[]> {const rows = await this.kysely<SharePublicAccommodationKyselyDB>().selectFrom('day_accommodations as a')- .where('a.trip_id', '=', trip_id)+ .where('a.trip_id', '=', trip_id as number).where((eb) => publicStayExists(eb)).select('a.place_id').distinct()@@ -1502,7 +1376,7 @@ export class ReservationsRepository extends TrekRepository<Reservations> {/** BG54/BG85 — `SELECT id, metadata FROM reservations WHERE id = ? AND trip_id = ?`. */async getIdAndMetadata(id: number | string, trip_id: number | string): Promise<{ id: number; metadata: string | null } | undefined> {- return await this.kysely<{ reservations: { id: number; trip_id: number; metadata: string | null } }>()+ return await this.kysely<Pick<DB, 'reservations'>>().selectFrom('reservations').select(['id', 'metadata']).where('id', '=', id as number)@@ -1512,7 +1386,7 @@ export class ReservationsRepository extends TrekRepository<Reservations> {/** BG55/BG86 — `UPDATE reservations SET metadata = ? WHERE id = ?`. */async setMetadata(id: number | string, metadata: string): Promise<void> {- await this.kysely<{ reservations: { id: number; metadata: string } }>()+ await this.kysely<Pick<DB, 'reservations'>>().updateTable('reservations').set({ metadata }).where('id', '=', id as number)@@ -1521,7 +1395,7 @@ export class ReservationsRepository extends TrekRepository<Reservations> {/** BG56/BG87 — `SELECT * FROM reservations WHERE id = ?`, the mirrored-price re-select for the `reservation:updated` broadcast. */async getFull(id: number | string): Promise<ReservationAllColumnsRow | undefined> {- return await this.kysely<{ reservations: ReservationAllColumnsRow }>()+ return await this.kysely<Pick<DB, 'reservations'>>().selectFrom('reservations').selectAll().where('id', '=', id as number)diff --git a/server/src/db/repositories/RouteUsageDaily.repository.ts b/server/src/db/repositories/RouteUsageDaily.repository.tsindex bd9c92537..2b41a8cc0 100644--- a/server/src/db/repositories/RouteUsageDaily.repository.ts+++ b/server/src/db/repositories/RouteUsageDaily.repository.ts@@ -1,6 +1,7 @@import type { RouteUsageDaily } from '../entities/RouteUsageDaily.entity';import { nowDateOffset } from '../dialect/sql-functions';import { TrekRepository } from './_shared/trek-repository';+import type { DB } from '../kysely/db';/*** A `route_usage_daily` row exactly as `SELECT *` reads it (RU3's shape,@@ -20,18 +21,7 @@ export interface RouteUsageDailyRow {failed: number;}-interface RouteUsageDailyKyselyDB {- route_usage_daily: {- day: string;- profile: string;- surface: string;- self_hosted: number;- requests: number;- waypoints: number;- km: number;- failed: number;- };-}+type RouteUsageDailyKyselyDB = Pick<DB, 'route_usage_daily'>;/*** `route_usage_daily` — a composite-PK `(day, profile, surface, self_hosted)`diff --git a/server/src/db/repositories/SchoolHolidayCountries.repository.ts b/server/src/db/repositories/SchoolHolidayCountries.repository.tsindex 3aec11875..7ffdf69c0 100644--- a/server/src/db/repositories/SchoolHolidayCountries.repository.ts+++ b/server/src/db/repositories/SchoolHolidayCountries.repository.ts@@ -1,6 +1,7 @@import type { SchoolHolidayCountries } from '../entities/SchoolHolidayCountries.entity';import { toRow, type AssertRowKeys } from './_shared/rows';import { TrekRepository } from './_shared/trek-repository';+import type { DB } from '../kysely/db';/** A `school_holiday_countries` row as the API emits it (SH1/SH3 — `SchoolHolidayCountryRequest`'s exact shape, `@trek/shared`). */export interface SchoolHolidayCountryRow {@@ -64,6 +65,4 @@ export class SchoolHolidayCountriesRepository extends TrekRepository<SchoolHolid}}-interface SchoolHolidayCountriesKyselyDB {- school_holiday_countries: { code: string; name: string };-}+type SchoolHolidayCountriesKyselyDB = Pick<DB, 'school_holiday_countries'>;diff --git a/server/src/db/repositories/ShareTokens.repository.ts b/server/src/db/repositories/ShareTokens.repository.tsindex e2134a388..5f248c8ba 100644--- a/server/src/db/repositories/ShareTokens.repository.ts+++ b/server/src/db/repositories/ShareTokens.repository.ts@@ -1,6 +1,7 @@import type { ShareTokens } from '../entities/ShareTokens.entity';import { currentTimestampKysely } from '../dialect/sql-functions';import { TrekRepository } from './_shared/trek-repository';+import type { DB } from '../kysely/db';/*** `share_tokens` — public trip-share links (Plan 3h Task 6). `trip_id` and@@ -29,9 +30,7 @@ export interface ShareTokenRow {share_hide_images: number;}-interface ShareTokensKyselyDB {- share_tokens: ShareTokenRow;-}+type ShareTokensKyselyDB = Pick<DB, 'share_tokens'>;export class ShareTokensRepository extends TrekRepository<ShareTokens> {private db_() {diff --git a/server/src/db/repositories/Tags.repository.ts b/server/src/db/repositories/Tags.repository.tsindex 8b6f5094e..9281f0bb2 100644--- a/server/src/db/repositories/Tags.repository.ts+++ b/server/src/db/repositories/Tags.repository.ts@@ -2,6 +2,7 @@ import type { Tags } from '../entities/Tags.entity';import { findOwnedByUser, listForOwner } from './_shared/owned-lookup';import { toRow, type AssertRowKeys } from './_shared/rows';import { TrekRepository } from './_shared/trek-repository';+import type { DB } from '../kysely/db';/** A `tags` row as the API emits it. */export interface TagRow {@@ -42,21 +43,16 @@ export interface TagForPlaceRow {* `TrekRepository.kysely()` (D3's sanctioned next escape hatch) is the only* API that reaches it.*/-interface PlaceTagsKyselyDB {- place_tags: { place_id: number; tag_id: number };-}+type PlaceTagsKyselyDB = Pick<DB, 'place_tags'>;/*** `place_tags` joined to `places` for TP46 (`trips.service.ts::copy`'s- * place-tags read) — `trip_id` widened to `number | string` (D4's T5 escape- * hatch, `TripsRepository.findAccessible`'s precedent) so the raw-bind seam- * matches `TripsService.copy`'s own `sourceTripId: string | number`- * parameter.+ * place-tags read). The `trip_id` the caller passes stays `number | string`+ * (D4's T5 escape hatch, `TripsRepository.findAccessible`'s precedent, to+ * match `TripsService.copy`'s own `sourceTripId: string | number`) and is+ * cast to the column type only at the bind.*/-interface PlaceTagsForTripKyselyDB {- place_tags: { place_id: number; tag_id: number };- places: { id: number; trip_id: number | string };-}+type PlaceTagsForTripKyselyDB = Pick<DB, 'place_tags' | 'places'>;export class TagsRepository extends TrekRepository<Tags> {/**@@ -269,7 +265,7 @@ export class TagsRepository extends TrekRepository<Tags> {.selectFrom('place_tags as pt').innerJoin('places as p', 'p.id', 'pt.place_id').select(['pt.place_id', 'pt.tag_id'])- .where('p.trip_id', '=', trip_id)+ .where('p.trip_id', '=', trip_id as number).execute();}}diff --git a/server/src/db/repositories/TodoCategoryAssignees.repository.ts b/server/src/db/repositories/TodoCategoryAssignees.repository.tsindex 3dd941076..5fa17d1cb 100644--- a/server/src/db/repositories/TodoCategoryAssignees.repository.ts+++ b/server/src/db/repositories/TodoCategoryAssignees.repository.ts@@ -1,5 +1,6 @@import type { TodoCategoryAssignees } from '../entities/TodoCategoryAssignees.entity';import { TrekRepository } from './_shared/trek-repository';+import type { DB } from '../kysely/db';/** TD11/TD14's joined projection — the assignee row plus the display fields the picker needs. */export interface TodoCategoryAssigneeRow {@@ -8,14 +9,9 @@ export interface TodoCategoryAssigneeRow {avatar: string | null;}-interface TodoCategoryAssigneesKyselyDB {- todo_category_assignees: { id: number; trip_id: number; category_name: string; user_id: number };- users: { id: number; username: string; avatar: string | null };-}+type TodoCategoryAssigneesKyselyDB = Pick<DB, 'todo_category_assignees' | 'users'>;-interface TodoCategoryAssigneesInsertKyselyDB {- todo_category_assignees: { trip_id: number | string; category_name: string; user_id: number };-}+type TodoCategoryAssigneesInsertKyselyDB = Pick<DB, 'todo_category_assignees'>;/*** `todo_category_assignees` — which trip members are pinned to a to-dodiff --git a/server/src/db/repositories/TodoItems.repository.ts b/server/src/db/repositories/TodoItems.repository.tsindex 7ad2b5368..871ee2d3f 100644--- a/server/src/db/repositories/TodoItems.repository.ts+++ b/server/src/db/repositories/TodoItems.repository.ts@@ -3,6 +3,7 @@ import { type AssertRowKeys } from './_shared/rows';import { TrekRepository } from './_shared/trek-repository';import { presenceSet } from './_shared/presence-set';import { columnRef, currentTimestamp, nowMinusHours } from '../dialect/sql-functions';+import type { DB } from '../kysely/db';/** A bare `todo_items` row — every scalar column, incl. the two `persist(false)` relation mirrors (`trip_id`, `assigned_user_id`). */export interface TodoItemRow {@@ -22,25 +23,13 @@ export interface TodoItemRow {const _todoItemRowKeys: AssertRowKeys<TodoItemRow, TodoItems> = true;-interface TodoItemsKyselyDB {- todo_items: TodoItemRow;-}+type TodoItemsKyselyDB = Pick<DB, 'todo_items'>;-/** The insert-only shape for `insertItem` (TD3) — omits `id`/`created_at`/`reminded_at` (autoincrement / `DEFAULT CURRENT_TIMESTAMP` / never written here). */-interface TodoItemsInsertKyselyDB {- todo_items: {- trip_id: number | string; name: string; checked: number; category: string | null; sort_order: number;- due_date: string | null; description: string | null; assigned_user_id: number | null; priority: number;- };-}+/** The table `insertItem` (TD3) inserts into; it leaves `id`/`created_at`/`reminded_at` unbound (autoincrement / `DEFAULT CURRENT_TIMESTAMP` / never written here). */+type TodoItemsInsertKyselyDB = Pick<DB, 'todo_items'>;-/** The insert-only shape for `insertCopy` (TP73) — a distinct column set from {@link TodoItemsRepository.insertItem}'s: no `assigned_user_id` parameter at all (always written `NULL`, never taken from the caller). */-interface TodoItemsCopyInsertKyselyDB {- todo_items: {- trip_id: number | string; name: string; checked: number; category: string | null; sort_order: number | null;- due_date: string | null; description: string | null; assigned_user_id: null; priority: number | null;- };-}+/** The table `insertCopy` (TP73) inserts into, with a distinct column set from {@link TodoItemsRepository.insertItem}'s: no `assigned_user_id` parameter at all (always written `NULL`, never taken from the caller). */+type TodoItemsCopyInsertKyselyDB = Pick<DB, 'todo_items'>;/** `isoDate` + 1 calendar day, in UTC — turns {@link TodoItemsRepository.listDueForReminder}'s inclusive cutoff into an exclusive `$lt` bound (L2, task-7-review.md). */function dayAfter(isoDate: string): string {@@ -88,7 +77,7 @@ export class TodoItemsRepository extends TrekRepository<TodoItems> {}): Promise<number> {const result = await this.kysely<TodoItemsInsertKyselyDB>().insertInto('todo_items')- .values({ ...row, checked: 0 })+ .values({ ...row, trip_id: row.trip_id as number, checked: 0 }).executeTakeFirstOrThrow();return Number(result.insertId);}@@ -170,7 +159,7 @@ export class TodoItemsRepository extends TrekRepository<TodoItems> {}): Promise<number> {const result = await this.kysely<TodoItemsCopyInsertKyselyDB>().insertInto('todo_items')- .values({ ...row, checked: 0, assigned_user_id: null })+ .values({ ...row, trip_id: row.trip_id as number, checked: 0, assigned_user_id: null }).executeTakeFirstOrThrow();return Number(result.insertId);}diff --git a/server/src/db/repositories/TourWaypoints.repository.ts b/server/src/db/repositories/TourWaypoints.repository.tsindex b5112ab44..fbc3be0d2 100644--- a/server/src/db/repositories/TourWaypoints.repository.ts+++ b/server/src/db/repositories/TourWaypoints.repository.ts@@ -1,5 +1,6 @@import type { TourWaypoints } from '../entities/TourWaypoints.entity';import { TrekRepository } from './_shared/trek-repository';+import type { DB } from '../kysely/db';/** One saved routing control point of a tour, in route order. */export interface TourWaypointRow {@@ -14,10 +15,10 @@ export interface TourWaypointWithPlaceRow extends TourWaypointRow {place_id: number;}-interface TourWaypointsKyselyDB {- tour_waypoints: { id: number; place_id: number; lat: number; lng: number; role: TourWaypointRow['role']; sequence: number };- places: { id: number; trip_id: number };-}+/** `role` narrowed to the three values the column's CHECK constraint allows. */+type TourWaypointsKyselyDB = Pick<DB, 'places'> & {+ tour_waypoints: Omit<DB['tour_waypoints'], 'role'> & { role: TourWaypointRow['role'] };+};/*** `tour_waypoints` — the start, via and end points the route editor saveddiff --git a/server/src/db/repositories/Tours.repository.ts b/server/src/db/repositories/Tours.repository.tsindex 8e04686a5..dd147376c 100644--- a/server/src/db/repositories/Tours.repository.ts+++ b/server/src/db/repositories/Tours.repository.ts@@ -1,6 +1,7 @@import type { AssertRowKeys } from './_shared/rows';import type { Tours } from '../entities/Tours.entity';import { TrekRepository } from './_shared/trek-repository';+import type { DB } from '../kysely/db';/*** A tour as the Tours list and detail read it: the `tours` facet joined with@@ -55,12 +56,7 @@ export interface TourInsert {/** What a route edit replaces on an existing tour. */export type TourUpdate = Omit<TourInsert, 'place_id'>;-interface ToursKyselyDB {- tours: TourRow;- places: { id: number; trip_id: number; name: string };- day_assignments: { id: number; day_id: number; place_id: number };- tour_waypoints: { id: number; place_id: number };-}+type ToursKyselyDB = Pick<DB, 'tours' | 'places' | 'day_assignments' | 'tour_waypoints'>;/*** `tours` — the facet that makes a place a tour (#2586). Keyed on the owningdiff --git a/server/src/db/repositories/TripAlbumLinks.repository.ts b/server/src/db/repositories/TripAlbumLinks.repository.tsindex 1bb9d71b2..7691feb8d 100644--- a/server/src/db/repositories/TripAlbumLinks.repository.ts+++ b/server/src/db/repositories/TripAlbumLinks.repository.ts@@ -1,6 +1,7 @@import type { TripAlbumLinks } from '../entities/TripAlbumLinks.entity';import { currentTimestamp } from '../dialect/sql-functions';import { TrekRepository } from './_shared/trek-repository';+import type { DB } from '../kysely/db';/** MA7/MA8's shared row shape — album_id always needed, passphrase only by the sync path (MA8). */export interface TripAlbumLinkSyncRow {@@ -9,57 +10,24 @@ export interface TripAlbumLinkSyncRow {}/**- * `trip_album_links`'s single-table write shape (Plan 3e Task 7,- * UM7/UM10). `trip_id`/`id` are typed `number | string` — the legacy- * statements bound `tripId`/`linkId` raw (T5's raw-bind seam), including the- * primary-key `id` column in UM10's `DELETE ... WHERE id = ?`.+ * `trip_album_links`'s single-table writes (Plan 3e Task 7, UM7/UM10). The+ * `tripId`/`linkId` the callers pass stay `number | string` (the legacy+ * statements bound them raw, T5's raw-bind seam, including the primary-key+ * `id` column in UM10's `DELETE ... WHERE id = ?`) and are cast to the+ * column type only at the bind.*/-interface TripAlbumLinksWriteKyselyDB {- trip_album_links: {- id: number | string;- trip_id: number | string;- user_id: number;- provider: string;- album_id: string;- album_name: string;- passphrase: string | null;- };-}+type TripAlbumLinksWriteKyselyDB = Pick<DB, 'trip_album_links'>;/**- * UM7's insert-only shape — `id`/`sync_enabled`/`last_synced_at`/`created_at`- * are autoincrement/defaulted and omitted from `.values()` (the legacy- * statement's own column list omits them too), so a SEPARATE interface from- * {@link TripAlbumLinksWriteKyselyDB} (the `FileLinksWriteKyselyDB` /- * `TripPhotosInsertKyselyDB` precedent) — that one declares `id` as- * required, which `.insertInto()` would then also require in `.values()`.+ * UM7's insert table. `id`/`sync_enabled`/`last_synced_at`/`created_at` are+ * autoincrement/defaulted and omitted from `.values()` (the legacy+ * statement's own column list omits them too); the generated type marks+ * them `InsertOptional`.*/-interface TripAlbumLinksInsertKyselyDB {- trip_album_links: {- trip_id: number | string;- user_id: number;- provider: string;- album_id: string;- album_name: string;- passphrase: string | null;- };-}+type TripAlbumLinksInsertKyselyDB = Pick<DB, 'trip_album_links'>;-/** UM3's joined projection (`UnifiedMemoriesService.listTripAlbumLinks`) — own Kysely shape, one purpose-shaped interface per statement. */-interface TripAlbumLinksListKyselyDB {- trip_album_links: {- id: number;- trip_id: number | string;- user_id: number;- provider: string;- album_id: string;- album_name: string;- sync_enabled: number;- last_synced_at: string | null;- created_at: string | null;- };- users: { id: number; username: string | null };-}+/** UM3's joined projection (`UnifiedMemoriesService.listTripAlbumLinks`). */+type TripAlbumLinksListKyselyDB = Pick<DB, 'trip_album_links' | 'users'>;/** UM3's row shape — `tal.*, u.username`. */export interface TripAlbumLinkListRow {@@ -116,7 +84,7 @@ export class TripAlbumLinksRepository extends TrekRepository<TripAlbumLinks> {async insertIgnore(row: { trip_id: number | string; user_id: number; provider: string; album_id: string; album_name: string; passphrase: string | null }): Promise<boolean> {const result = await this.kysely<TripAlbumLinksInsertKyselyDB>().insertInto('trip_album_links')- .values({ trip_id: row.trip_id, user_id: row.user_id, provider: row.provider, album_id: row.album_id, album_name: row.album_name, passphrase: row.passphrase })+ .values({ trip_id: row.trip_id as number, user_id: row.user_id, provider: row.provider, album_id: row.album_id, album_name: row.album_name, passphrase: row.passphrase }).onConflict((oc) => oc.columns(['trip_id', 'user_id', 'provider', 'album_id']).doNothing()).executeTakeFirst();return (result?.numInsertedOrUpdatedRows ?? 0n) > 0n;@@ -126,8 +94,8 @@ export class TripAlbumLinksRepository extends TrekRepository<TripAlbumLinks> {async deleteScoped(id: number | string, trip_id: number | string, user_id: number): Promise<void> {await this.kysely<TripAlbumLinksWriteKyselyDB>().deleteFrom('trip_album_links')- .where('id', '=', id)- .where('trip_id', '=', trip_id)+ .where('id', '=', id as number)+ .where('trip_id', '=', trip_id as number).where('user_id', '=', user_id).execute();}@@ -156,7 +124,7 @@ export class TripAlbumLinksRepository extends TrekRepository<TripAlbumLinks> {'tal.created_at as created_at','u.username as username',])- .where('tal.trip_id', '=', trip_id)+ .where('tal.trip_id', '=', trip_id as number).where('tal.provider', 'in', enabled_providers).orderBy('tal.created_at', 'asc').execute();diff --git a/server/src/db/repositories/TripFiles.repository.ts b/server/src/db/repositories/TripFiles.repository.tsindex 11c8850b1..4d5d90772 100644--- a/server/src/db/repositories/TripFiles.repository.ts+++ b/server/src/db/repositories/TripFiles.repository.ts@@ -2,6 +2,7 @@ import { currentTimestamp } from '../dialect/sql-functions';import type { TripFiles } from '../entities/TripFiles.entity';import { type AssertRowKeys } from './_shared/rows';import { TrekRepository } from './_shared/trek-repository';+import type { DB } from '../kysely/db';/*** A bare `trip_files` row — every scalar column of the entity, incl. the SIX@@ -38,11 +39,7 @@ export interface TripFileJoinRow extends TripFileRow {uploaded_by_avatar: string | null;}-interface TripFilesKyselyDB {- trip_files: TripFileRow;- reservations: { id: number; title: string };- users: { id: number; username: string; avatar: string | null };-}+type TripFilesKyselyDB = Pick<DB, 'trip_files' | 'reservations' | 'users'>;/*** `trip_files` — trip attachments (uploads, expense receipts). Every readdiff --git a/server/src/db/repositories/TripInviteTokens.repository.ts b/server/src/db/repositories/TripInviteTokens.repository.tsindex 450721b63..b304907b3 100644--- a/server/src/db/repositories/TripInviteTokens.repository.ts+++ b/server/src/db/repositories/TripInviteTokens.repository.ts@@ -1,6 +1,7 @@import type { TripInviteTokens } from '../entities/TripInviteTokens.entity';import { currentTimestamp } from '../dialect/sql-functions';import { TrekRepository } from './_shared/trek-repository';+import type { DB } from '../kysely/db';/** `trip-invite.service.ts::get`'s projection. */export interface TripInviteInfoRow {@@ -16,10 +17,7 @@ export interface TripInviteResolvedRow {expires_at: string | null;}-interface TripInviteResolveKyselyDB {- trip_invite_tokens: { token: string; trip_id: number; expires_at: string | null };- trips: { id: number; title: string };-}+type TripInviteResolveKyselyDB = Pick<DB, 'trip_invite_tokens' | 'trips'>;/*** `trip_invite_tokens` (Plan 4 Task 1). One row per trip (`uniques: [{diff --git a/server/src/db/repositories/TripPhotos.repository.ts b/server/src/db/repositories/TripPhotos.repository.tsindex 1392275b7..3ee3e7d22 100644--- a/server/src/db/repositories/TripPhotos.repository.ts+++ b/server/src/db/repositories/TripPhotos.repository.ts@@ -1,55 +1,27 @@import type { TripPhotos } from '../entities/TripPhotos.entity';import { TrekRepository } from './_shared/trek-repository';+import type { DB } from '../kysely/db';/**- * `trip_photos`'s single-table write/lookup shape (Plan 3e Task 7,- * UM4/UM5/UM6/UM8/UM9). `trip_id`/`album_link_id` are typed `number |- * string` — the legacy statements bound `tripId`/`albumLinkId` raw, straight- * from the route param, with no `Number()`/`toRowId` conversion (the same- * T5 raw-bind seam `TripsRepository.findForViewer`'s docstring documents),- * so this Kysely shape has to accept both to bind the identical value.+ * `trip_photos`'s single-table writes and lookups (Plan 3e Task 7,+ * UM4/UM5/UM6/UM8/UM9). The `tripId`/`albumLinkId` the callers pass stay+ * `number | string` (the legacy statements bound them raw, straight from the+ * route param, with no `Number()`/`toRowId` conversion: the same T5 raw-bind+ * seam `TripsRepository.findForViewer`'s docstring documents) and are cast to+ * the column type only at the bind, so the identical value is bound.*/-interface TripPhotosKyselyDB {- trip_photos: {- id: number;- trip_id: number | string;- user_id: number;- photo_id: number;- shared: number;- album_link_id: number | string | null;- added_at: string | null;- };-}+type TripPhotosKyselyDB = Pick<DB, 'trip_photos'>;/**- * UM4's insert-only shape — `id`/`added_at` are autoincrement/`DEFAULT+ * UM4's insert table. `id`/`added_at` are autoincrement/`DEFAULT* CURRENT_TIMESTAMP` and omitted from `.values()` (the legacy statement's- * own column list omits them too), so Kysely's `InsertObject` needs a- * SEPARATE interface that doesn't declare them (the `FileLinksWriteKyselyDB`- * precedent) — {@link TripPhotosKyselyDB} declares every column, so passing- * it to `.insertInto()` would require `id`/`added_at` in every `.values()`.+ * own column list omits them too); the generated type marks them+ * `InsertOptional`.*/-interface TripPhotosInsertKyselyDB {- trip_photos: {- trip_id: number | string;- user_id: number;- photo_id: number;- shared: number;- album_link_id: number | string | null;- };-}+type TripPhotosInsertKyselyDB = Pick<DB, 'trip_photos'>;-/**- * UM2's joined projection (`UnifiedMemoriesService.listTripPhotos`) — three- * tables, so its own Kysely shape rather than folding onto- * {@link TripPhotosKyselyDB} (one purpose-shaped interface per statement,- * the `FileLinksRepository` precedent).- */-interface TripPhotosListKyselyDB {- trip_photos: { trip_id: number | string; user_id: number; photo_id: number; shared: number; added_at: string | null };- trek_photos: { id: number; asset_id: string | null; provider: string };- users: { id: number; username: string | null; avatar: string | null };-}+/** UM2's joined projection (`UnifiedMemoriesService.listTripPhotos`) over three tables. */+type TripPhotosListKyselyDB = Pick<DB, 'trip_photos' | 'trek_photos' | 'users'>;/** UM2's row shape — `tp.photo_id, tkp.asset_id, tkp.provider, tp.user_id, tp.shared, tp.added_at, u.username, u.avatar`. */export interface TripPhotoListRow {@@ -129,7 +101,7 @@ export class TripPhotosRepository extends TrekRepository<TripPhotos> {async insertIgnore(row: { trip_id: number | string; user_id: number; photo_id: number; shared: number; album_link_id: number | string | null }): Promise<boolean> {const result = await this.kysely<TripPhotosInsertKyselyDB>().insertInto('trip_photos')- .values({ trip_id: row.trip_id, user_id: row.user_id, photo_id: row.photo_id, shared: row.shared, album_link_id: row.album_link_id })+ .values({ trip_id: row.trip_id as number, user_id: row.user_id, photo_id: row.photo_id, shared: row.shared, album_link_id: row.album_link_id as number }).onConflict((oc) => oc.columns(['trip_id', 'user_id', 'photo_id']).doNothing()).executeTakeFirst();return (result?.numInsertedOrUpdatedRows ?? 0n) > 0n;@@ -140,7 +112,7 @@ export class TripPhotosRepository extends TrekRepository<TripPhotos> {await this.kysely<TripPhotosKyselyDB>().updateTable('trip_photos').set({ shared })- .where('trip_id', '=', trip_id)+ .where('trip_id', '=', trip_id as number).where('user_id', '=', user_id).where('photo_id', '=', photo_id).execute();@@ -150,7 +122,7 @@ export class TripPhotosRepository extends TrekRepository<TripPhotos> {async deleteForUserPhoto(trip_id: number | string, user_id: number, photo_id: number): Promise<void> {await this.kysely<TripPhotosKyselyDB>().deleteFrom('trip_photos')- .where('trip_id', '=', trip_id)+ .where('trip_id', '=', trip_id as number).where('user_id', '=', user_id).where('photo_id', '=', photo_id).execute();@@ -161,8 +133,8 @@ export class TripPhotosRepository extends TrekRepository<TripPhotos> {const rows = await this.kysely<TripPhotosKyselyDB>().selectFrom('trip_photos').select(['photo_id'])- .where('trip_id', '=', trip_id)- .where('album_link_id', '=', album_link_id)+ .where('trip_id', '=', trip_id as number)+ .where('album_link_id', '=', album_link_id as number).execute();return rows.map((r) => r.photo_id);}@@ -171,8 +143,8 @@ export class TripPhotosRepository extends TrekRepository<TripPhotos> {async deleteForAlbumLink(trip_id: number | string, album_link_id: number | string): Promise<void> {await this.kysely<TripPhotosKyselyDB>().deleteFrom('trip_photos')- .where('trip_id', '=', trip_id)- .where('album_link_id', '=', album_link_id)+ .where('trip_id', '=', trip_id as number)+ .where('album_link_id', '=', album_link_id as number).execute();}@@ -202,7 +174,7 @@ export class TripPhotosRepository extends TrekRepository<TripPhotos> {'u.username as username','u.avatar as avatar',])- .where('tp.trip_id', '=', trip_id)+ .where('tp.trip_id', '=', trip_id as number).where((eb) => eb.or([eb('tp.user_id', '=', user_id), eb('tp.shared', '=', 1)])).where('tkp.provider', 'in', enabled_providers).orderBy('tp.added_at', 'asc')diff --git a/server/src/db/repositories/Trips.repository.ts b/server/src/db/repositories/Trips.repository.tsindex 344c60712..cba9187ec 100644--- a/server/src/db/repositories/Trips.repository.ts+++ b/server/src/db/repositories/Trips.repository.ts@@ -4,6 +4,7 @@ import { coalesceParam, currentTimestamp, nowDateOffset } from '../dialect/sql-fimport type { AssertRowKeys } from './_shared/rows';import { TrekRepository } from './_shared/trek-repository';import { tripAccessExpr } from './_shared/trip-access';+import type { DB } from '../kysely/db';/** What a trip-scoped request learns about the trip once access is verified. */export interface TripAccess {@@ -55,35 +56,8 @@ export interface TripSelectRow extends Omit<TripRawRow, 'feed_token'> {shared_count: number;}-/** The narrow `trips`/`users`/`days`/`places`/`trip_members` shape `tripSelectQuery` needs (`this.kysely()`'s typed `DB` argument). */-interface TripSelectKyselyDB {- trips: {- // `number | string`, not a bare `number`: the raw-bind seam (D4's T5- // escape hatch) — `findForViewer`'s `WHERE t.id = ?` accepts the route's- // unconverted id with no coercion, the same seam every QB-based method- // in this file documents. Widening the TYPE (not spelling `sql\`...\``,- // which `no-restricted-syntax` bans in `src/db/repositories/**`) is what- // lets `.where('t.id', '=', trip_id)` accept a `string` here.- id: number | string;- user_id: number;- title: string;- description: string | null;- start_date: string | null;- end_date: string | null;- currency: string | null;- cover_image: string | null;- is_archived: number | null;- reminder_days: number | null;- feed_token: string | null;- created_at: string | null;- updated_at: string | null;- reminder_sent_for: string | null;- };- users: { id: number; username: string };- trip_members: { id: number; trip_id: number; user_id: number };- days: { id: number; trip_id: number };- places: { id: number; trip_id: number };-}+/** The `trips`/`users`/`days`/`places`/`trip_members` tables `tripSelectQuery` reads (`this.kysely()`'s typed `DB` argument). */+type TripSelectKyselyDB = Pick<DB, 'trips' | 'users' | 'trip_members' | 'days' | 'places'>;// Task 7 review L4, absorbed here (Task 8 touches the same file): the 13// hand-listed columns of `TripSelectKyselyDB['trips']` above are a second,@@ -104,11 +78,8 @@ export interface ActiveTripRow {relevance: number;}-/** The narrow `trips`/`trip_members` shape `activeTrip` needs. */-interface ActiveTripKyselyDB {- trips: { id: number; title: string; start_date: string | null; end_date: string | null; user_id: number; is_archived: number | null };- trip_members: { id: number; trip_id: number; user_id: number };-}+/** The `trips`/`trip_members` tables `activeTrip` reads. */+type ActiveTripKyselyDB = Pick<DB, 'trips' | 'trip_members'>;export class TripsRepository extends TrekRepository<Trips> {/**@@ -428,7 +399,7 @@ export class TripsRepository extends TrekRepository<Trips> {* same apart from `is_owner`.*/async findListShapeById(trip_id: number | string, user_id: number): Promise<TripSelectRow | undefined> {- const row = await this.tripSelectQuery(user_id).where('t.id', '=', trip_id).executeTakeFirst();+ const row = await this.tripSelectQuery(user_id).where('t.id', '=', trip_id as number).executeTakeFirst();return row as TripSelectRow | undefined;}@@ -454,7 +425,7 @@ export class TripsRepository extends TrekRepository<Trips> {async findForViewer(trip_id: number | string, user_id: number): Promise<TripSelectRow | undefined> {const row = await this.tripSelectQuery(user_id).leftJoin('trip_members as m', (join) => join.onRef('m.trip_id', '=', 't.id').on('m.user_id', '=', user_id))- .where('t.id', '=', trip_id)+ .where('t.id', '=', trip_id as number).where((eb) => tripAccessExpr(eb, 't.user_id', 'm.user_id', user_id)).executeTakeFirst();return row as TripSelectRow | undefined;@@ -849,7 +820,7 @@ export class TripsRepository extends TrekRepository<Trips> {/** BG15/BG16/BGM2/BGM3 — `SELECT currency FROM trips WHERE id = ?`, four legacy call sites, one statement. */async getCurrency(id: number | string): Promise<string | null | undefined> {- const row = await this.kysely<{ trips: { id: number; currency: string | null } }>()+ const row = await this.kysely<Pick<DB, 'trips'>>().selectFrom('trips').select('currency').where('id', '=', id as number)@@ -1077,23 +1048,14 @@ export class TripsRepository extends TrekRepository<Trips> {}}-/** {@link TripsRepository.listIdTitleOrderedByTitle}'s narrow `trips` shape. */-interface TripIdTitleKyselyDB {- trips: { id: number; title: string };-}+/** {@link TripsRepository.listIdTitleOrderedByTitle}'s `trips` tables. */+type TripIdTitleKyselyDB = Pick<DB, 'trips'>;-/** {@link TripsRepository.lastStartedTrip}'s and {@link TripsRepository.nextUpcomingTrip}'s narrow `trips`/`trip_members` shape. */-interface LastStartedTripKyselyDB {- trips: { id: number; title: string; start_date: string | null; end_date: string | null; user_id: number };- trip_members: { trip_id: number; user_id: number };-}+/** {@link TripsRepository.lastStartedTrip}'s and {@link TripsRepository.nextUpcomingTrip}'s `trips`/`trip_members` tables. */+type LastStartedTripKyselyDB = Pick<DB, 'trips' | 'trip_members'>;-/** {@link TripsRepository.countTripsAndDaysForUser}'s narrow `trips`/`days`/`trip_members` shape. */-interface CountTripsAndDaysKyselyDB {- trips: { id: number; user_id: number };- days: { id: number; trip_id: number };- trip_members: { trip_id: number; user_id: number };-}+/** {@link TripsRepository.countTripsAndDaysForUser}'s `trips`/`days`/`trip_members` tables. */+type CountTripsAndDaysKyselyDB = Pick<DB, 'trips' | 'days' | 'trip_members'>;/** {@link TripsRepository.listReminderCandidates}'s row — `t.user` selected bare (not joined here), so it aliases to the physical `user_id` column per `findAccessible`'s documented precedent. */export interface TripReminderCandidateRow {@@ -1134,9 +1096,5 @@ export interface TravellerUsernameRow {is_owner: number;}-/** The narrow `trips`/`users`/`trip_members` shape `listTravellerUsernames` needs. */-interface TravellerUsernameKyselyDB {- trips: { id: number; user_id: number };- users: { id: number; username: string };- trip_members: { id: number; trip_id: number; user_id: number };-}+/** The `trips`/`users`/`trip_members` tables `listTravellerUsernames` reads. */+type TravellerUsernameKyselyDB = Pick<DB, 'trips' | 'users' | 'trip_members'>;diff --git a/server/src/db/repositories/VacayEntries.repository.ts b/server/src/db/repositories/VacayEntries.repository.tsindex 8476dcc0b..7ba83e121 100644--- a/server/src/db/repositories/VacayEntries.repository.ts+++ b/server/src/db/repositories/VacayEntries.repository.ts@@ -1,10 +1,9 @@import { dateAdd } from '../dialect/sql-functions';import type { VacayEntries } from '../entities/VacayEntries.entity';import { TrekRepository } from './_shared/trek-repository';+import type { DB } from '../kysely/db';-interface VacayEntriesKyselyDB {- vacay_entries: { id: number; plan_id: number; user_id: number; date: string; note: string | null; fraction: number; kind: string };-}+type VacayEntriesKyselyDB = Pick<DB, 'vacay_entries'>;/** VC111's joined grid projection (`getEntries`) — the full entry row plus the author's username and color. */export interface VacayEntryWithPersonRow {@@ -156,11 +155,7 @@ export class VacayEntriesRepository extends TrekRepository<VacayEntries> {* `.onRef(...).onRef(...)` shape).*/async listForRangeWithPerson(planId: number, start: string, end: string): Promise<VacayEntryWithPersonRow[]> {- interface EntriesWithPersonKyselyDB {- vacay_entries: { id: number; plan_id: number; user_id: number; date: string; note: string | null; fraction: number; kind: string };- users: { id: number; username: string };- vacay_user_colors: { id: number; user_id: number; plan_id: number; color: string | null };- }+ type EntriesWithPersonKyselyDB = Pick<DB, 'vacay_entries' | 'users' | 'vacay_user_colors'>;return this.kysely<EntriesWithPersonKyselyDB>().selectFrom('vacay_entries as e').innerJoin('users as u', 'u.id', 'e.user_id')diff --git a/server/src/db/repositories/VacayPlanMembers.repository.ts b/server/src/db/repositories/VacayPlanMembers.repository.tsindex c85fbdb37..d787b3ae0 100644--- a/server/src/db/repositories/VacayPlanMembers.repository.ts+++ b/server/src/db/repositories/VacayPlanMembers.repository.ts@@ -1,6 +1,7 @@import type { VacayPlanMembers } from '../entities/VacayPlanMembers.entity';import { toRow, type AssertRowKeys } from './_shared/rows';import { TrekRepository } from './_shared/trek-repository';+import type { DB } from '../kysely/db';/** A `vacay_plan_members` row as the legacy `SELECT *` returned it (VC51). */export interface VacayPlanMemberRow {@@ -98,9 +99,7 @@ export class VacayPlanMembersRepository extends TrekRepository<VacayPlanMembers>* instead.*/async findInvitableUser(id: number): Promise<{ id: number; username: string } | null> {- interface UsersKyselyDB {- users: { id: number; username: string; is_guest: number | null };- }+ type UsersKyselyDB = Pick<DB, 'users'>;const row = await this.kysely<UsersKyselyDB>().selectFrom('users').select(['id', 'username'])@@ -166,11 +165,7 @@ export class VacayPlanMembersRepository extends TrekRepository<VacayPlanMembers>* subqueries (§13) — Kysely, no `sql` tag, every operand builder-expressed.*/async listAvailableForFusion(userId: number, planId: number): Promise<VacayMemberUserRow[]> {- interface FusionCandidateKyselyDB {- users: { id: number; username: string; email: string; is_guest: number | null };- vacay_plan_members: { id: number; plan_id: number; user_id: number; status: string | null };- vacay_plans: { id: number; owner_id: number };- }+ type FusionCandidateKyselyDB = Pick<DB, 'users' | 'vacay_plan_members' | 'vacay_plans'>;return this.kysely<FusionCandidateKyselyDB>().selectFrom('users as u').select(['u.id', 'u.username', 'u.email'])diff --git a/server/src/db/repositories/VacayPlans.repository.ts b/server/src/db/repositories/VacayPlans.repository.tsindex 7471c0a99..b0830f384 100644--- a/server/src/db/repositories/VacayPlans.repository.ts+++ b/server/src/db/repositories/VacayPlans.repository.ts@@ -1,6 +1,7 @@import type { VacayPlans } from '../entities/VacayPlans.entity';import { toRow, type AssertRowKeys } from './_shared/rows';import { TrekRepository } from './_shared/trek-repository';+import type { DB } from '../kysely/db';/*** A `vacay_plans` row as the legacy `SELECT *` returned it (Plan 3f Task 5,@@ -114,9 +115,7 @@ export class VacayPlansRepository extends TrekRepository<VacayPlans> {* than risk a conflicting concurrent edit to a file this task does not own.*/async findVacayUser(id: number): Promise<{ id: number; username: string; email: string } | null> {- interface UsersKyselyDB {- users: { id: number; username: string; email: string };- }+ type UsersKyselyDB = Pick<DB, 'users'>;const row = await this.kysely<UsersKyselyDB>().selectFrom('users').select(['id', 'username', 'email']).where('id', '=', id).executeTakeFirst();return row ?? null;}diff --git a/server/src/db/repositories/VacayShares.repository.ts b/server/src/db/repositories/VacayShares.repository.tsindex 77fa1d5b2..d34d960c9 100644--- a/server/src/db/repositories/VacayShares.repository.ts+++ b/server/src/db/repositories/VacayShares.repository.ts@@ -1,6 +1,7 @@import type { VacayShares } from '../entities/VacayShares.entity';import { toRow, type AssertRowKeys } from './_shared/rows';import { TrekRepository } from './_shared/trek-repository';+import type { DB } from '../kysely/db';/** A `vacay_shares` row as the legacy `SELECT *` returned it. */export interface VacayShareRow {@@ -45,9 +46,7 @@ export class VacaySharesRepository extends TrekRepository<VacayShares> {* docstring) — a direct `users`-table Kysely read here instead.*/async existsInvitableUser(id: number): Promise<boolean> {- interface UsersKyselyDB {- users: { id: number; is_guest: number | null };- }+ type UsersKyselyDB = Pick<DB, 'users'>;const row = await this.kysely<UsersKyselyDB>().selectFrom('users').select('id')@@ -133,9 +132,7 @@ export class VacaySharesRepository extends TrekRepository<VacayShares> {/** VC20 — `SELECT DISTINCT user_id FROM vacay_shares WHERE owner_id IN (${dynamic})` (`notifyShareViewers`'s fan-out list). Empty `ownerIds` short-circuits before any query, matching the caller's own guard. */async listDistinctViewerIdsForOwners(ownerIds: number[]): Promise<number[]> {if (ownerIds.length === 0) return [];- interface VacaySharesKyselyDB {- vacay_shares: { id: number; owner_id: number; user_id: number; hidden: number; created_at: string | null };- }+ type VacaySharesKyselyDB = Pick<DB, 'vacay_shares'>;const rows = await this.kysely<VacaySharesKyselyDB>().selectFrom('vacay_shares').select('user_id')@@ -155,12 +152,7 @@ export class VacaySharesRepository extends TrekRepository<VacayShares> {* subquery (§13) — Kysely, no `sql` tag.*/async listAvailableForShare(userId: number, planId: number): Promise<{ id: number; username: string }[]> {- interface ShareCandidateKyselyDB {- users: { id: number; username: string; is_guest: number | null };- vacay_shares: { id: number; owner_id: number; user_id: number };- vacay_plans: { id: number; owner_id: number };- vacay_plan_members: { id: number; plan_id: number; user_id: number; status: string | null };- }+ type ShareCandidateKyselyDB = Pick<DB, 'users' | 'vacay_shares' | 'vacay_plans' | 'vacay_plan_members'>;return this.kysely<ShareCandidateKyselyDB>().selectFrom('users as u').select(['u.id', 'u.username'])diff --git a/server/src/db/repositories/VisitedCountries.repository.ts b/server/src/db/repositories/VisitedCountries.repository.tsindex 2f2b35f9b..a23c7c3bc 100644--- a/server/src/db/repositories/VisitedCountries.repository.ts+++ b/server/src/db/repositories/VisitedCountries.repository.ts@@ -1,5 +1,6 @@import type { VisitedCountries } from '../entities/VisitedCountries.entity';import { TrekRepository } from './_shared/trek-repository';+import type { DB } from '../kysely/db';/** `visited_countries` — every scalar column, `AT10`'s own read shape. */export interface VisitedCountryRow {@@ -9,25 +10,15 @@ export interface VisitedCountryRow {}/**- * Two separate table shapes for the SAME `visited_countries` table, not one- * shared interface: {@link listForUser} SELECTs `created_at`, while- * {@link markVisited}/{@link markFromRegion} INSERT it never — the legacy+ * The generated `visited_countries` table, under one alias for the reads+ * ({@link listForUser} SELECTs `created_at`) and one for the writes+ * ({@link markVisited}/{@link markFromRegion} never bind it: the legacy* statements' own column lists omit it, leaving the schema's `DEFAULT- * CURRENT_TIMESTAMP` to fill it in. Kysely validates `.values()` against- * exactly the columns its `DB` type parameter declares (it has no notion of- * "this column exists in the real table but is optional here" short of the- * `Generated<>` wrapper, which — unlike every other column type in this- * program — did not resolve `created_at` out of `InsertObject`'s required- * set when tried here); declaring a NARROWER write-only shape that never- * mentions `created_at` at all reproduces the legacy statement's own column- * list exactly, with no wrapper needed.+ * CURRENT_TIMESTAMP` to fill it in, and the generated type marks it+ * `InsertOptional`).*/-interface VisitedCountriesReadKyselyDB {- visited_countries: { user_id: number; country_code: string; source: string; created_at: string | null };-}-interface VisitedCountriesWriteKyselyDB {- visited_countries: { user_id: number; country_code: string; source: string };-}+type VisitedCountriesReadKyselyDB = Pick<DB, 'visited_countries'>;+type VisitedCountriesWriteKyselyDB = Pick<DB, 'visited_countries'>;/*** `visited_countries` — the user's own explicit "I've been here" marksdiff --git a/server/src/db/repositories/VisitedRegions.repository.ts b/server/src/db/repositories/VisitedRegions.repository.tsindex 3163b6b0e..e79f08f6d 100644--- a/server/src/db/repositories/VisitedRegions.repository.ts+++ b/server/src/db/repositories/VisitedRegions.repository.ts@@ -1,5 +1,6 @@import type { VisitedRegions } from '../entities/VisitedRegions.entity';import { TrekRepository } from './_shared/trek-repository';+import type { DB } from '../kysely/db';/** `visited_regions` — the columns `AT21`'s read needs. */export interface VisitedRegionRow {@@ -9,18 +10,12 @@ export interface VisitedRegionRow {}/**- * Two separate table shapes for the SAME `visited_regions` table (the- * `VisitedCountriesRepository`'s own docstring explains why: {@link- * listForUser} SELECTs `created_at`, `markVisited` INSERTs it never — the- * legacy statement's own column list omits it, leaving the schema's- * `DEFAULT CURRENT_TIMESTAMP` to fill it).+ * The generated `visited_regions` table, under one alias for the reads+ * ({@link listForUser} SELECTs `created_at`) and one for `markVisited`,+ * which never binds it (see {@link VisitedCountriesRepository}).*/-interface VisitedRegionsReadKyselyDB {- visited_regions: { user_id: number; region_code: string; region_name: string; country_code: string; created_at: string | null };-}-interface VisitedRegionsWriteKyselyDB {- visited_regions: { user_id: number; region_code: string; region_name: string; country_code: string };-}+type VisitedRegionsReadKyselyDB = Pick<DB, 'visited_regions'>;+type VisitedRegionsWriteKyselyDB = Pick<DB, 'visited_regions'>;/*** `visited_regions` — the user's own explicit region-level marks, plus thediff --git a/server/src/db/repositories/WebauthnChallenges.repository.ts b/server/src/db/repositories/WebauthnChallenges.repository.tsindex ce52f860b..e9ae29b06 100644--- a/server/src/db/repositories/WebauthnChallenges.repository.ts+++ b/server/src/db/repositories/WebauthnChallenges.repository.ts@@ -1,5 +1,6 @@import type { WebauthnChallenges } from '../entities/WebauthnChallenges.entity';import { TrekRepository } from './_shared/trek-repository';+import type { DB } from '../kysely/db';/** `PasskeyService.storeChallenge` (PK2). */export interface NewChallengeRow {@@ -10,19 +11,11 @@ export interface NewChallengeRow {}/**- * The `webauthn_challenges` table shape as `claimChallenge`'s- * `em.getKysely()` call needs it — an explicit type argument rather than- * relying on `getKysely()`'s automatic entity-metadata inference (kept- * narrow to the one column this repository ever reads back).+ * The `webauthn_challenges` table as `claimChallenge`'s `em.getKysely()`+ * call needs it: an explicit type argument rather than relying on+ * `getKysely()`'s automatic entity-metadata inference.*/-interface WebauthnChallengesKyselyDB {- webauthn_challenges: {- challenge: string;- user_id: number | null;- type: string;- expires_at: number;- };-}+type WebauthnChallengesKyselyDB = Pick<DB, 'webauthn_challenges'>;/** The single-use, TTL'd WebAuthn ceremony challenge store — PK1–PK3. */export class WebauthnChallengesRepository extends TrekRepository<WebauthnChallenges> {diff --git a/server/src/db/repositories/_shared/packing-visibility.ts b/server/src/db/repositories/_shared/packing-visibility.tsindex 6bcf9ac98..eb3589cea 100644--- a/server/src/db/repositories/_shared/packing-visibility.ts+++ b/server/src/db/repositories/_shared/packing-visibility.ts@@ -1,4 +1,5 @@import type { Expression, ExpressionBuilder, ExpressionWrapper, SqlBool } from 'kysely';+import type { DB } from '../../kysely/db';/*** The per-actor visibility predicate packing's three-tier sharing model@@ -118,15 +119,11 @@ export function packingVisibleToActorCondition(actorId: number | undefined) {}/**- * `packing_items`/`packing_item_recipients`'s REAL table names — the shape- * `packingVisibleToActorExpr` needs. A consumer's own local Kysely `DB`- * interface satisfies this by structural extension, the same- * `ReservationVisibilityKyselyDB` precedent.+ * `packing_items`/`packing_item_recipients`'s REAL table names, the tables+ * `packingVisibleToActorExpr` needs. A consumer's own alias satisfies this by+ * intersecting it, the same `ReservationVisibilityKyselyDB` precedent.*/-export interface PackingVisibilityKyselyDB {- packing_items: { id: number; is_private: number; owner_id: number | null };- packing_item_recipients: { item_id: number; user_id: number };-}+export type PackingVisibilityKyselyDB = Pick<DB, 'packing_items' | 'packing_item_recipients'>;export function packingVisibleToActorExpr(eb: ExpressionBuilder<PackingVisibilityKyselyDB, 'packing_items'>,diff --git a/server/src/db/repositories/_shared/reservation-travelers-owns.ts b/server/src/db/repositories/_shared/reservation-travelers-owns.tsindex 06d85ec1b..ebbb7dca2 100644--- a/server/src/db/repositories/_shared/reservation-travelers-owns.ts+++ b/server/src/db/repositories/_shared/reservation-travelers-owns.ts@@ -1,4 +1,5 @@import type { ExpressionBuilder, ExpressionWrapper, SqlBool } from 'kysely';+import type { DB } from '../../kysely/db';/*** The `TRAVELER_OWNS` predicate atlas's `AtlasService` inlines as a@@ -95,17 +96,13 @@ export function travelerOwnsCondition(userId: number) {}/**- * `reservation_travelers`/`reservations`' REAL table names, the shape- * `travelerOwnsExpr` needs (fixed alias `r` for `reservations` — see this+ * `reservation_travelers`/`reservations`' REAL table names, the tables+ * `travelerOwnsExpr` needs (fixed alias `r` for `reservations`: see this* file's module docstring for why, unlike RV1's genuinely-multi-alias- * shape). A consumer's own local Kysely `DB` interface satisfies this by- * structural extension, the same `ReservationVisibilityKyselyDB`/- * `PackingVisibilityKyselyDB` precedent.+ * shape). A consumer's own alias satisfies this by intersecting it, the same+ * `ReservationVisibilityKyselyDB`/`PackingVisibilityKyselyDB` precedent.*/-export interface ReservationTravelersOwnsKyselyDB {- reservation_travelers: { reservation_id: number; user_id: number };- reservations: { id: number };-}+export type ReservationTravelersOwnsKyselyDB = Pick<DB, 'reservation_travelers' | 'reservations'>;/*** `TRAVELER_OWNS` as a Kysely predicate: `(NOT EXISTS (…) OR EXISTS (… ANDdiff --git a/server/src/db/repositories/_shared/reservation-visibility.ts b/server/src/db/repositories/_shared/reservation-visibility.tsindex b2428de03..fa79e7abe 100644--- a/server/src/db/repositories/_shared/reservation-visibility.ts+++ b/server/src/db/repositories/_shared/reservation-visibility.ts@@ -1,6 +1,7 @@import type { Platform } from '@mikro-orm/core';import type { ExpressionBuilder, ExpressionWrapper, ReferenceExpression, SqlBool } from 'kysely';import { coalesceParam } from '../../dialect/sql-functions';+import type { DB } from '../../kysely/db';/*** The visibility predicate an anonymous viewer's reads are filtered@@ -119,23 +120,19 @@ export function publicReservationExpr<DB, TB extends keyof DB>(}/**- * `reservations`/`day_accommodations`'s REAL table names, the shape- * `publicStayExists` needs. A consumer's own local Kysely `DB` interface- * (the `AssignmentTimeSortKyselyDB`/`RoadtripVisitsKyselyDB`/- * `TripSelectKyselyDB` per-query-interface precedent) satisfies this by- * structural extension — declaring `day_accommodations`/`reservations`- * with at least these columns is enough; `Kysely<DB>` typed against it and- * queried via `.selectFrom('day_accommodations as a')` (the fixed alias- * every known legacy caller uses — see this file's module docstring) is- * what actually produces the aliased `a` member `publicStayExists`- * requires; Kysely computes that from THIS interface's `day_accommodations`- * entry, not from a hand-declared `a` key (a table's alias is a property of- * the QUERY, never of the `DB` interface itself).+ * `reservations`/`day_accommodations`'s REAL table names, the tables+ * `publicStayExists` needs. A consumer's own alias (the+ * `AssignmentTimeSortKyselyDB`/`RoadtripVisitsKyselyDB`/`TripSelectKyselyDB`+ * per-query precedent) satisfies this by picking the same generated tables.+ * `Kysely<DB>` typed against it and queried via+ * `.selectFrom('day_accommodations as a')` (the fixed alias every known+ * legacy caller uses, see this file's module docstring) is what actually+ * produces the aliased `a` member `publicStayExists` requires; Kysely+ * computes that from THIS alias's `day_accommodations` entry, not from a+ * hand-declared `a` key (a table's alias is a property of the QUERY, never+ * of the `DB` type itself).*/-export interface ReservationVisibilityKyselyDB {- day_accommodations: { id: number };- reservations: { id: number; accommodation_id: number | string | null; ingest_state: string | null };-}+export type ReservationVisibilityKyselyDB = Pick<DB, 'day_accommodations' | 'reservations'>;/*** RV2 as a Kysely predicate: `(NOT EXISTS (…) OR EXISTS (… AND <RV1>))`,diff --git a/server/tests/unit/db/generate-db-types.test.ts b/server/tests/unit/db/generate-db-types.test.tsnew file mode 100644index 000000000..c8c3512a1--- /dev/null+++ b/server/tests/unit/db/generate-db-types.test.ts@@ -0,0 +1,166 @@+import fs from 'node:fs';+import os from 'node:os';+import path from 'node:path';+import { describe, expect, it } from 'vitest';+import {+ checkDbTypes,+ generateDbTypes,+ interfaceName,+ KYSELY_DIR,+ pascalCase,+ renderAll,+ renderColumns,+ renderDb,+ renderTable,+ tsTypeFor,+ writeDbTypes,+ type ColumnInfo,+ type TableInfo,+} from '../../../scripts/generate-db-types';++function column(overrides: Partial<ColumnInfo> & { name: string }): ColumnInfo {+ return { type: 'TEXT', notnull: true, hasDefault: false, pk: 0, hidden: 0, ...overrides };+}++const ITEMS: TableInfo = {+ name: 'budget_items',+ columns: [+ column({ name: 'id', type: 'INTEGER', notnull: false, pk: 1 }),+ column({ name: 'trip_id', type: 'INTEGER' }),+ column({ name: 'name' }),+ column({ name: 'note', notnull: false }),+ column({ name: 'created_at', type: 'DATETIME', notnull: false, hasDefault: true }),+ column({ name: 'exchange_rate', type: 'REAL', hasDefault: true }),+ ],+};++function tempDir(prefix: string): string {+ return fs.mkdtempSync(path.join(os.tmpdir(), prefix));+}++describe('tsTypeFor', () => {+ it('DBTYPES-001: maps the declared types the schema uses by SQLite affinity', () => {+ expect(tsTypeFor('INTEGER')).toBe('number');+ expect(tsTypeFor('bigint')).toBe('number');+ expect(tsTypeFor('TEXT')).toBe('string');+ expect(tsTypeFor('varchar(255)')).toBe('string');+ expect(tsTypeFor('REAL')).toBe('number');+ expect(tsTypeFor('DATETIME')).toBe('string');+ expect(tsTypeFor('BLOB')).toBe('Buffer');+ expect(tsTypeFor('BOOLEAN')).toBe('number');+ expect(tsTypeFor('')).toBe('unknown');+ });++ it('DBTYPES-002: refuses a declared type it has no mapping for, naming it', () => {+ expect(() => tsTypeFor('GEOMETRY')).toThrow(/"GEOMETRY"/);+ });+});++describe('names', () => {+ it('DBTYPES-003: snake_case tables become PascalCase files and <Name>Table interfaces', () => {+ expect(pascalCase('budget_items')).toBe('BudgetItems');+ expect(pascalCase('users')).toBe('Users');+ expect(interfaceName('trip_files')).toBe('TripFilesTable');+ });+});++describe('renderTable', () => {+ it('DBTYPES-004: a rowid, a defaulted and a nullable column are InsertOptional, the rest required', () => {+ const source = renderTable(ITEMS);+ expect(source).toContain("import type { InsertOptional } from './columns';");+ expect(source).toContain('export interface BudgetItemsTable {');+ expect(source).toContain(' id: InsertOptional<number>;');+ expect(source).toContain(' trip_id: number;');+ expect(source).toContain(' name: string;');+ expect(source).toContain(' note: InsertOptional<string | null>;');+ expect(source).toContain(' created_at: InsertOptional<string | null>;');+ expect(source).toContain(' exchange_rate: InsertOptional<number>;');+ });++ it('DBTYPES-005: a composite primary key is required on insert, not a rowid', () => {+ const source = renderTable({+ name: 'place_tags',+ columns: [column({ name: 'place_id', type: 'INTEGER', pk: 1 }), column({ name: 'tag_id', type: 'INTEGER', pk: 2 })],+ });+ expect(source).toContain(' place_id: number;');+ expect(source).toContain(' tag_id: number;');+ expect(source).not.toContain('import type');+ });++ it('DBTYPES-006: a generated (computed) column is GeneratedAlways, so no insert or update can name it', () => {+ const source = renderTable({ name: 't', columns: [column({ name: 'total', type: 'INTEGER', hidden: 2 })] });+ expect(source).toContain("import type { GeneratedAlways } from 'kysely';");+ expect(source).toContain(' total: GeneratedAlways<number>;');+ });++ it('DBTYPES-007: a column name that is not an identifier is quoted', () => {+ const source = renderTable({ name: 't', columns: [column({ name: 'group-name' })] });+ expect(source).toContain(" 'group-name': string;");+ });+});++describe('renderDb / renderColumns / renderAll', () => {+ it('DBTYPES-008: db.ts imports every table interface and maps the table name to it', () => {+ const source = renderDb([ITEMS, { name: 'users', columns: [column({ name: 'id', type: 'INTEGER', pk: 1 })] }]);+ expect(source).toContain("import type { BudgetItemsTable } from './BudgetItems.table';");+ expect(source).toContain("import type { UsersTable } from './Users.table';");+ expect(source).toContain('export interface DB {\n budget_items: BudgetItemsTable;\n users: UsersTable;\n}');+ });++ it('DBTYPES-009: InsertOptional widens the insert type with void, which survives a non-strict compile', () => {+ expect(renderColumns()).toContain('export type InsertOptional<T> = ColumnType<T, T | void, T>;');+ });++ it('DBTYPES-010: renderAll emits one file per table plus columns.ts and db.ts, and refuses an empty schema', () => {+ const files = renderAll([ITEMS]);+ expect([...files.keys()].sort()).toEqual(['BudgetItems.table.ts', 'columns.ts', 'db.ts']);+ expect(() => renderAll([])).toThrow(/no tables/);+ });+});++describe('checkDbTypes / writeDbTypes', () => {+ it('DBTYPES-011: reports a changed, a missing and an extra file, and nothing once written', () => {+ const files = renderAll([ITEMS]);+ const dir = tempDir('gen-db-types-');+ try {+ expect(checkDbTypes(dir, files)).toEqual(['BudgetItems.table.ts', 'columns.ts', 'db.ts']);+ writeDbTypes(dir, files);+ expect(checkDbTypes(dir, files)).toEqual([]);++ fs.writeFileSync(path.join(dir, 'db.ts'), 'export interface DB {}\n');+ fs.writeFileSync(path.join(dir, 'Stale.table.ts'), 'export interface StaleTable {}\n');+ expect(checkDbTypes(dir, files)).toEqual(['Stale.table.ts (not produced by the generator)', 'db.ts']);++ writeDbTypes(dir, files);+ expect(fs.existsSync(path.join(dir, 'Stale.table.ts'))).toBe(false);+ expect(checkDbTypes(dir, files)).toEqual([]);+ } finally {+ fs.rmSync(dir, { recursive: true, force: true });+ }+ });++ it('DBTYPES-012: a CRLF checkout of an unchanged file is not drift', () => {+ const files = renderAll([ITEMS]);+ const dir = tempDir('gen-db-types-crlf-');+ try {+ writeDbTypes(dir, files);+ const target = path.join(dir, 'db.ts');+ fs.writeFileSync(target, fs.readFileSync(target, 'utf8').replace(/\n/g, '\r\n'));+ expect(checkDbTypes(dir, files)).toEqual([]);+ } finally {+ fs.rmSync(dir, { recursive: true, force: true });+ }+ });+});++describe('the committed src/db/kysely/', () => {+ it(+ 'DBTYPES-013: matches what the migrated schema generates (the check:db-types gate)',+ async () => {+ const files = await generateDbTypes();+ expect(files.get('db.ts')).toContain(' budget_items: BudgetItemsTable;');+ expect(checkDbTypes(KYSELY_DIR, files)).toEqual([]);+ },+ 60_000,+ );+});diff --git a/server/tests/unit/db/repositories/_shared/reservation-travelers-owns.parity.test.ts b/server/tests/unit/db/repositories/_shared/reservation-travelers-owns.parity.test.tsindex 60f165c0f..a5ebf5a23 100644--- a/server/tests/unit/db/repositories/_shared/reservation-travelers-owns.parity.test.ts+++ b/server/tests/unit/db/repositories/_shared/reservation-travelers-owns.parity.test.ts@@ -53,9 +53,8 @@ async function typedQbOwnedIds(tripId: number, userId: number): Promise<number[]return rows.map((row) => row.id);}-interface TestDB extends ReservationTravelersOwnsKyselyDB {- reservations: { id: number; trip_id: number };-}+// The generated tables carry every column, `reservations.trip_id` included.+type TestDB = ReservationTravelersOwnsKyselyDB;async function typedKyselyOwnedIds(tripId: number, userId: number): Promise<number[]> {const rows = await t.emdiff --git a/server/tests/unit/db/repositories/_shared/reservation-visibility.test.ts b/server/tests/unit/db/repositories/_shared/reservation-visibility.test.tsindex bb7bd2c44..fd3179bd7 100644--- a/server/tests/unit/db/repositories/_shared/reservation-visibility.test.ts+++ b/server/tests/unit/db/repositories/_shared/reservation-visibility.test.ts@@ -185,16 +185,14 @@ describe('reservation-visibility parity (RV1 Kysely form: publicReservationExpr* types every other repository's Kysely escape hatch — here obtained* directly off the test ORM's EntityManager (this module has no repository* of its own; it is a shared predicate builder, not a `TrekRepository`- * subclass). Extends `ReservationVisibilityKyselyDB`'s real-table-name- * shape with the one extra column this test's own WHERE clause needs- * (`day_accommodations.trip_id`) — `.selectFrom('day_accommodations as a')`+ * subclass). `ReservationVisibilityKyselyDB` picks the generated tables,+ * which already carry the column this test's own WHERE clause needs+ * (`day_accommodations.trip_id`); `.selectFrom('day_accommodations as a')`* below derives the aliased `a` member FROM `day_accommodations` (see* `ReservationVisibilityKyselyDB`'s own docstring), so the resulting `eb` is* exactly the shape `publicStayExists` requires.*/-interface StayVisibilityTestDB extends ReservationVisibilityKyselyDB {- day_accommodations: { id: number; trip_id: number };-}+type StayVisibilityTestDB = ReservationVisibilityKyselyDB;describe('reservation-visibility parity (RV2: publicStayExists vs publicStaySql)', () => {it('RESVIS-004: no reservation points at the stay — public (the NOT EXISTS branch)', async () => {diff --git a/server/tsconfig.scripts.json b/server/tsconfig.scripts.jsonindex 699b1d7c6..ee5fb10b2 100644--- a/server/tsconfig.scripts.json+++ b/server/tsconfig.scripts.json@@ -4,5 +4,5 @@"rootDir": ".","noEmit": true},- "include": ["scripts/generate-entities.ts", "scripts/migrate-encryption.ts"]+ "include": ["scripts/generate-entities.ts", "scripts/generate-db-types.ts", "scripts/migrate-encryption.ts"]}diff --git a/sonar-project.properties b/sonar-project.propertiesindex d3bc20bcd..25c218307 100644--- a/sonar-project.properties+++ b/sonar-project.properties@@ -57,7 +57,10 @@ sonar.coverage.exclusions=\plugin-sdk/src/lucide-icon-names.ts# Locale files are large near-identical literal objects — keep them out of duplication metrics-sonar.cpd.exclusions=shared/src/i18n/**+# server/src/db/kysely/ is generated from the migrated schema by+# server/scripts/generate-db-types.ts (one interface per table, CI checks it with+# check:db-types), so a column list two tables share is not copied code.+sonar.cpd.exclusions=shared/src/i18n/**,server/src/db/kysely/**# The full analysis of a push to dev outgrows the JS/TS analyser's default heap# of about 4 GB since the ORM migration and stops with "Analysis of JS/TS filesdiff --git a/wiki/Development-environment.md b/wiki/Development-environment.mdindex 7f009d0ef..ba721d80f 100644--- a/wiki/Development-environment.md+++ b/wiki/Development-environment.md@@ -235,7 +235,7 @@ Then open a Pull Request from your fork to `liketrek/TREK` targeting the `dev` b- Always branch off from an up-to-date `dev` — run `git fetch upstream && git rebase upstream/dev` before starting new work.- Run tests before pushing: `npm test` at the repo root runs all workspaces. That alone is not the full CI gate. With `shared` built, these are the checks CI runs before any test (`.github/workflows/test.yml` is the source of truth):- in `shared/`: `npm run typecheck && npm run contracts:open`- - in `server/`: `npm run build && npm run typecheck && npm run typecheck:tests && npm run typecheck:scripts && npm run check:entities && npm run lint:check && npm run db:call-graph -- --sync --tx && npm run lint:size && npm run lint:boundaries && npm run check:plugin-facts`+ - in `server/`: `npm run build && npm run typecheck && npm run typecheck:tests && npm run typecheck:scripts && npm run check:entities && npm run check:db-types && npm run lint:check && npm run db:call-graph -- --sync --tx && npm run lint:size && npm run lint:boundaries && npm run check:plugin-facts`- in `client/`: `npm run typecheck && npm run lint:warnings && npm run lint:pages && npm run lint:rtl && npm run lint:size && npm run lint:format && npm run lint:layers && npm run lint:offline && npm run lint:skips && npm run lint:i18n-keys`- at the root, if you touched translations: `npm run i18n:parity:strict --workspace=shared`- Follow the commit message conventions described in the [[Contributing]] guidelines.