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
fix(db): refuse a fraction for an integer column at the request boundary
Maurice2d7392c4c0ea
diff --git a/server/src/nest/packing/packing.mcp.ts b/server/src/nest/packing/packing.mcp.tsindex be4498560..125153fa5 100644--- a/server/src/nest/packing/packing.mcp.ts+++ b/server/src/nest/packing/packing.mcp.ts@@ -664,7 +664,7 @@ export class PackingMcp {.max(100).optional().describe('Bag name to assign the item to; created if it does not exist'),- weight_grams: z.number().nonnegative().optional(),+ weight_grams: z.number().int().nonnegative().optional(),checked: z.boolean().optional(),}),)diff --git a/server/tests/unit/contracts/integer-columns.test.ts b/server/tests/unit/contracts/integer-columns.test.tsnew file mode 100644index 000000000..e6606dad4--- /dev/null+++ b/server/tests/unit/contracts/integer-columns.test.ts@@ -0,0 +1,258 @@+/**+ * INTCOL: a request number bound for an integer column is a+ * whole number at the request boundary.+ *+ * Every integer column is `bigint` on Postgres. SQLite stores a fraction sent+ * to one as a REAL without a word, while Postgres rounds it (a statement+ * MikroORM renders) or refuses it with a 500 (a Kysely statement, whose+ * values travel as text), so the two engines end up holding different data+ * for the same request. The fix is to refuse the fraction before it reaches+ * the database, with `.int()` on the field in the `@trek/shared` schema, the+ * way `idSchema` already does for ids.+ *+ * This walks every `class X extends createZodDto(...)` under src/ (the schemas+ * the global ZodValidationPipe enforces, found as contracts:dto-open finds+ * them), and reads the fields an MCP tool declares inline in a `*.mcp.ts`, and+ * fails on a number field without `.int()` whose name is a column+ * that is an integer in some entity and fractional in none. The names come+ * from the entity files (`<name>: p.integer()`), so a new integer column is+ * checked as soon as it exists. A field that shares a column's name but does+ * not end up in it goes into NOT_A_COLUMN with the reason; a name that is+ * an integer in one table and a double in another (`sort_order`, `position`)+ * cannot be judged by its name and is left out.+ */+import { isZodDto } from 'nestjs-zod/dto';+import { readdirSync, readFileSync, statSync } from 'node:fs';+import path from 'node:path';+import { pathToFileURL } from 'node:url';+import { beforeAll, describe, expect, it } from 'vitest';+import { z } from 'zod';++const SERVER_ROOT = path.resolve(__dirname, '../../..');+const SRC = path.join(SERVER_ROOT, 'src');+const ENTITIES = path.join(SRC, 'db/entities');++/**+ * Fields named like an integer column that never reach one, each with its+ * reason, keyed `DtoClass.path`, or `DtoClass` alone for every field of a DTO+ * that is stored as one document or not stored at all. Only add one when the+ * value never lands in an integer column.+ */+const NOT_A_COLUMN: Record<string, string> = {+ BookSaveDto: 'the photo book is stored whole as one JSON document; its sizes and widths are layout measures',+ ImmichSearchDto: 'a search sent on to Immich: size is its page size and the offset a time zone, neither is stored',+ SynologySearchDto:+ 'a search sent on to Synology Photos: size is its page size and the offset a time zone, neither is stored',+};++/** Whether `key` (`DtoClass.path`) is excused by NOT_A_COLUMN. */+function excused(key: string): boolean {+ return key in NOT_A_COLUMN || key.split('.')[0] in NOT_A_COLUMN;+}++/** An inline MCP tool field: `name: z.number()` or `name: z.coerce.number()`, with the rest of its line. */+const INLINE_NUMBER = /\b(\w+): z\.(?:coerce\.)?number\(\)(.*)$/gm;+const DTO_CLASS = /\bexport\s+class\s+(\w+)\s+extends\s+createZodDto\s*\(/g;+const COLUMN = /^\s+(\w+): (?:\(\) => )?p\.(\w+)\(/gm;+const INTEGER_TYPES = new Set(['integer', 'smallint', 'bigint', 'tinyint', 'mediumint']);+const FRACTIONAL_TYPES = new Set(['double', 'float', 'decimal', 'real']);++function sourceFiles(dir: string, files: string[] = []): string[] {+ for (const name of readdirSync(dir)) {+ const full = path.join(dir, name);+ if (statSync(full).isDirectory()) sourceFiles(full, files);+ else if (name.endsWith('.ts') && !name.endsWith('.d.ts')) files.push(full);+ }+ return files;+}++/** The column names that are an integer in some entity and fractional in none. */+function integerColumnNames(entitySources: readonly string[]): Set<string> {+ const integer = new Set<string>();+ const fractional = new Set<string>();+ for (const source of entitySources) {+ for (const [, name, type] of source.matchAll(COLUMN)) {+ if (INTEGER_TYPES.has(type)) integer.add(name);+ if (FRACTIONAL_TYPES.has(type)) fractional.add(name);+ }+ }+ return new Set([...integer].filter((name) => !fractional.has(name)));+}++/** What a zod schema holds once its wrappers (optional, nullable, default, both ends of a pipe, ...) are taken off. */+function children(schema: z.ZodType): Array<[string | null, z.ZodType]> {+ const def = schema._zod.def as unknown as Record<string, unknown> & { type: string };+ switch (def.type) {+ case 'object':+ return Object.entries(def.shape as Record<string, z.ZodType>);+ case 'optional':+ case 'nullable':+ case 'default':+ case 'prefault':+ case 'readonly':+ case 'catch':+ case 'nonoptional':+ case 'success':+ return [[null, def.innerType as z.ZodType]];+ case 'pipe':+ return [+ [null, def.in as z.ZodType],+ [null, def.out as z.ZodType],+ ];+ case 'array':+ return [[null, def.element as z.ZodType]];+ case 'union':+ return (def.options as z.ZodType[]).map((option) => [null, option]);+ case 'intersection':+ return [+ [null, def.left as z.ZodType],+ [null, def.right as z.ZodType],+ ];+ case 'record':+ return [[null, def.valueType as z.ZodType]];+ case 'tuple':+ return (def.items as z.ZodType[]).map((item) => [null, item]);+ case 'lazy':+ return [[null, (def.getter as () => z.ZodType)()]];+ default:+ return [];+ }+}++/**+ * The paths in `schema` whose field is named like an integer column but takes+ * any number. A path names the object keys from the root, so a nested field+ * reads `items.quantity`.+ */+function fractionalIntegerFields(schema: z.ZodType, integerNames: ReadonlySet<string>): string[] {+ const found = new Set<string>();+ const seen = new Set<z.ZodType>();+ const walk = (node: z.ZodType, trail: string[], field: string | null): void => {+ if (seen.has(node)) return;+ seen.add(node);+ if (node instanceof z.ZodNumber && field !== null && integerNames.has(field) && !node.isInt) {+ found.add(trail.join('.'));+ }+ for (const [key, child] of children(node)) {+ if (key === null) walk(child, trail, field);+ else walk(child, [...trail, key], key);+ }+ seen.delete(node);+ };+ walk(schema, [], null);+ return [...found].sort();+}++/** `file:line field` for every inline number field in `source` named like an integer column without `.int()`. */+function fractionalInlineFields(file: string, source: string, integerNames: ReadonlySet<string>): string[] {+ const found: string[] = [];+ for (const match of source.matchAll(INLINE_NUMBER)) {+ const [, field, rest] = match;+ if (!integerNames.has(field) || rest.startsWith('.int()')) continue;+ const line = source.slice(0, match.index).split('\n').length;+ found.push(`${file}:${line} ${field}`);+ }+ return found;+}++describe('request numbers bound for integer columns', () => {+ let integerNames: Set<string>;+ let found: string[];+ let inline: string[];+ let dtoCount: number;++ beforeAll(async () => {+ integerNames = integerColumnNames(+ readdirSync(ENTITIES)+ .filter((name) => name.endsWith('.entity.ts'))+ .map((name) => readFileSync(path.join(ENTITIES, name), 'utf8')),+ );+ found = [];+ dtoCount = 0;+ inline = sourceFiles(SRC)+ .filter((file) => file.endsWith('.mcp.ts'))+ .flatMap((file) =>+ fractionalInlineFields(+ path.relative(SERVER_ROOT, file).split(path.sep).join('/'),+ readFileSync(file, 'utf8'),+ integerNames,+ ),+ );+ const files = sourceFiles(SRC).filter((file) => readFileSync(file, 'utf8').includes('createZodDto'));+ const modules = await Promise.all(+ files.map(async (file) => ({+ names: [...readFileSync(file, 'utf8').matchAll(DTO_CLASS)].map(([, name]) => name),+ namespace: (await import(pathToFileURL(file).href)) as Record<string, unknown>,+ })),+ );+ for (const { names, namespace } of modules) {+ for (const name of names) {+ const dto = namespace[name];+ if (typeof dto !== 'function' || !isZodDto(dto)) continue;+ dtoCount++;+ for (const field of fractionalIntegerFields(dto.schema as z.ZodType, integerNames))+ found.push(`${name}.${field}`);+ }+ }+ }, 120_000);++ it('INTCOL-001: the walk saw DTOs and integer columns', () => {+ expect(dtoCount, 'no DTO class found under src/: the check would look at nothing').toBeGreaterThan(0);+ expect(integerNames.has('quantity')).toBe(true);+ });++ it('INTCOL-002: every such field is a whole number', () => {+ expect(+ found.filter((key) => !excused(key)),+ 'add .int() to these fields in the @trek/shared schema: the column is bigint on Postgres, ' ++ 'which cannot hold the fraction SQLite would store. If the field never reaches that column, ' ++ 'list it in NOT_A_COLUMN in this file with the reason.',+ ).toEqual([]);+ });++ it('INTCOL-006: no MCP tool declares such a field inline without .int()', () => {+ expect(inline, 'add .int() to these inline MCP fields, or take the field from the @trek/shared schema').toEqual([]);+ });++ it('INTCOL-003: NOT_A_COLUMN names only fields that would be reported', () => {+ const stale = Object.keys(NOT_A_COLUMN).filter(+ (entry) => !found.some((key) => key === entry || key.startsWith(`${entry}.`)),+ );+ expect(stale, 'drop these NOT_A_COLUMN entries: nothing they excuse is reported any more').toEqual([]);+ });+});++describe('the walk itself', () => {+ const names = integerColumnNames([+ ' quantity: p.integer(),\n plan: () => p.manyToOne(Plans),\n plan_id: p.integer().persist(false),\n',+ ' lat: p.double().nullable(),\n sort_order: p.integer(),\n',+ ' sort_order: p.double(),\n',+ ]);++ it('INTCOL-004: reads integer columns from the entities and drops the names a table keeps fractional', () => {+ expect([...names].sort()).toEqual(['plan_id', 'quantity']);+ });++ it('INTCOL-005: finds a bare number through wrappers, arrays and nesting, and accepts .int()', () => {+ const schema = z.object({+ quantity: z.number().optional(),+ plan_id: z.number().int(),+ lat: z.number(),+ items: z.array(z.object({ quantity: z.number().nullable().default(null) })),+ nested: z.object({ plan_id: z.coerce.number() }).optional(),+ sort_order: z.number(),+ });+ expect(fractionalIntegerFields(schema, names)).toEqual(['items.quantity', 'nested.plan_id', 'quantity']);+ expect(fractionalIntegerFields(z.object({ quantity: z.int() }), names)).toEqual([]);+ });++ it('INTCOL-007: finds an inline MCP number field without .int() and its line', () => {+ const source = [+ ' quantity: z.number().optional(),',+ ' plan_id: z.number().int(),',+ ' lat: z.number(),',+ ' quantity: z.coerce.number().min(1),',+ ].join('\n');+ expect(fractionalInlineFields('a.mcp.ts', source, names)).toEqual(['a.mcp.ts:1 quantity', 'a.mcp.ts:4 quantity']);+ });+});diff --git a/shared/src/admin/admin.schema.ts b/shared/src/admin/admin.schema.tsindex 4c2cb430c..7c74fe9c9 100644--- a/shared/src/admin/admin.schema.ts+++ b/shared/src/admin/admin.schema.ts@@ -40,12 +40,12 @@ export type AdminPermissionsRequest = z.infer<typeof adminPermissionsRequestScheexport const adminInviteCreateRequestSchema = z.object({// string | number: the service parses with parseInt(String(x)), and the// admin UI sends numbers while older clients sent strings.- max_uses: z.union([z.number(), z.string()]).optional(),+ max_uses: z.union([z.number().int(), z.string()]).optional(),expires_in_days: z.union([z.number(), z.string()]).optional(),role: z.enum(['user', 'admin']).optional(),// Optional trip binding (#1402): a user who registers via the link is// auto-added to this trip. Nullable/absent = a plain registration invite.- trip_id: z.union([z.number(), z.string()]).nullable().optional(),+ trip_id: z.union([z.number().int(), z.string()]).nullable().optional(),});export type AdminInviteCreateRequest = z.infer<typeof adminInviteCreateRequestSchema>;diff --git a/shared/src/assignment/assignment.schema.ts b/shared/src/assignment/assignment.schema.tsindex 5be28cc6f..525643703 100644--- a/shared/src/assignment/assignment.schema.ts+++ b/shared/src/assignment/assignment.schema.ts@@ -74,7 +74,7 @@ export const assignmentSchema = z.object({export type Assignment = z.infer<typeof assignmentSchema>;export const assignmentCreateRequestSchema = z.object({- place_id: z.union([z.number(), z.string()]),+ place_id: z.union([z.number().int(), z.string()]),notes: z.string().nullable().optional(),/*** MDT-02: puts one stage of a multi-day tour on the day instead of the whole@@ -94,7 +94,7 @@ export const assignmentMoveRequestSchema = z.object({new_day_id: z.union([z.number(), z.string()]),// The client api types this `number | null` (assignmentsApi.move) and the// legacy route accepted null (`orderIndex || 0`) — keep null on the wire.- order_index: z.number().nullable().optional(),+ order_index: z.number().int().nullable().optional(),});export type AssignmentMoveRequest = z.infer<typeof assignmentMoveRequestSchema>;diff --git a/shared/src/budget/budget.schema.ts b/shared/src/budget/budget.schema.tsindex 5febac67a..5ce81b0b4 100644--- a/shared/src/budget/budget.schema.ts+++ b/shared/src/budget/budget.schema.ts@@ -117,12 +117,12 @@ export const budgetItemSchema = z.object({export type BudgetItem = z.infer<typeof budgetItemSchema>;const payerInputSchema = z.object({- user_id: z.number(),+ user_id: z.number().int(),amount: z.number(),});const memberInputSchema = z.object({- user_id: z.number(),+ user_id: z.number().int(),amount: z.number().nullable().optional(),});@@ -161,17 +161,17 @@ export const budgetCreateItemRequestSchema = z.object({// Equal-split participants. When omitted, the item has no split (planning-only).member_ids: z.array(z.number()).optional(),members: z.array(memberInputSchema).optional(),- persons: z.number().nullable().optional(),- days: z.number().nullable().optional(),+ persons: z.number().int().nullable().optional(),+ days: z.number().int().nullable().optional(),note: z.string().nullable().optional(),ticket_json: z.string().nullable().optional(),expense_date: z.string().nullable().optional(),// Link this expense to a reservation (e.g. created from a booking's// "add expense" flow). The server stores it on budget_items.reservation_id.- reservation_id: z.number().optional(),+ reservation_id: z.number().int().optional(),// The same for a place: the place form's "add expense" flow saves the place// first, then creates the expense against it (#1298).- place_id: z.number().optional(),+ place_id: z.number().int().optional(),// Receipt files to link to this expensereceipt_file_ids: z.array(z.number()).optional(),// Rates to freeze a foreign currency with when the server has none of its own.@@ -189,8 +189,8 @@ export const budgetUpdateItemRequestSchema = z.object({payers: z.array(payerInputSchema).optional(),member_ids: z.array(z.number()).optional(),members: z.array(memberInputSchema).optional(),- persons: z.number().nullable().optional(),- days: z.number().nullable().optional(),+ persons: z.number().int().nullable().optional(),+ days: z.number().int().nullable().optional(),note: z.string().nullable().optional(),ticket_json: z.string().nullable().optional(),expense_date: z.string().nullable().optional(),@@ -244,8 +244,8 @@ export const budgetSettlementSchema = z.object({export type BudgetSettlement = z.infer<typeof budgetSettlementSchema>;export const budgetCreateSettlementRequestSchema = z.object({- from_user_id: z.number(),- to_user_id: z.number(),+ from_user_id: z.number().int(),+ to_user_id: z.number().int(),amount: z.number(),// The display currency the amount was entered in; the server freezes its FX rate.currency: z.string().nullable().optional(),@@ -261,8 +261,8 @@ export type BudgetCreateSettlementRequest = z.infer<typeof budgetCreateSettlemen/** Edit a persisted settle-up transfer (same fields as create; full replace). */export const budgetUpdateSettlementRequestSchema = z.object({- from_user_id: z.number(),- to_user_id: z.number(),+ from_user_id: z.number().int(),+ to_user_id: z.number().int(),amount: z.number(),currency: z.string().nullable().optional(),settled_at: z.string().nullable().optional(),diff --git a/shared/src/collab/collab.schema.ts b/shared/src/collab/collab.schema.tsindex 08a162e43..31bc8abc8 100644--- a/shared/src/collab/collab.schema.ts+++ b/shared/src/collab/collab.schema.ts@@ -29,7 +29,7 @@ export const collabNoteUpdateRequestSchema = z.object({content: z.string().nullable().optional(),category: z.string().nullable().optional(),color: z.string().nullable().optional(),- pinned: z.union([z.boolean(), z.number()]).optional(),+ pinned: z.union([z.boolean(), z.number().int()]).optional(),website: z.string().nullable().optional(),});export type CollabNoteUpdateRequest = z.infer<typeof collabNoteUpdateRequestSchema>;@@ -44,7 +44,7 @@ export const collabPollCreateRequestSchema = z.object({export type CollabPollCreateRequest = z.infer<typeof collabPollCreateRequestSchema>;export const collabPollVoteRequestSchema = z.object({- option_index: z.number(),+ option_index: z.number().int(),});export type CollabPollVoteRequest = z.infer<typeof collabPollVoteRequestSchema>;@@ -57,14 +57,14 @@ const httpUrl = z.url().refine((value) => /^https?:\/\//i.test(value.trim()), 'Aexport const collabLinkCreateRequestSchema = z.object({title: z.string().trim().min(1),url: httpUrl,- pinned: z.union([z.boolean(), z.number()]).optional(),+ pinned: z.union([z.boolean(), z.number().int()]).optional(),});export type CollabLinkCreateRequest = z.infer<typeof collabLinkCreateRequestSchema>;export const collabLinkUpdateRequestSchema = z.object({title: z.string().trim().min(1).optional(),url: httpUrl.optional(),- pinned: z.union([z.boolean(), z.number()]).optional(),+ pinned: z.union([z.boolean(), z.number().int()]).optional(),});export type CollabLinkUpdateRequest = z.infer<typeof collabLinkUpdateRequestSchema>;@@ -73,7 +73,7 @@ export type CollabLinkUpdateRequest = z.infer<typeof collabLinkUpdateRequestScheexport const collabMessageCreateRequestSchema = z.object({text: z.string().max(5000).optional(),// Multipart fields arrive as strings; JSON chat still sends a number/null.- reply_to: z.union([z.number(), z.string(), z.null()]).optional(),+ reply_to: z.union([z.number().int(), z.string(), z.null()]).optional(),});export type CollabMessageCreateRequest = z.infer<typeof collabMessageCreateRequestSchema>;diff --git a/shared/src/collection/collection.schema.ts b/shared/src/collection/collection.schema.tsindex ac945511f..41547717b 100644--- a/shared/src/collection/collection.schema.ts+++ b/shared/src/collection/collection.schema.ts@@ -157,15 +157,15 @@ export type CollectionReorderRequest = z.infer<typeof collectionReorderRequestSc/** Save a place into a list from a raw maps/manual payload (or carrying provenance). */export const collectionSavePlaceRequestSchema = z.object({- collection_id: z.number(),- source_place_id: z.number().nullable().optional(),- source_trip_id: z.number().nullable().optional(),+ collection_id: z.number().int(),+ source_place_id: z.number().int().nullable().optional(),+ source_trip_id: z.number().int().nullable().optional(),name: z.string().min(1),description: z.string().nullable().optional(),lat: z.number().nullable().optional(),lng: z.number().nullable().optional(),address: z.string().nullable().optional(),- category_id: z.number().nullable().optional(),+ category_id: z.number().int().nullable().optional(),price: z.number().nullable().optional(),currency: z.string().nullable().optional(),notes: z.string().nullable().optional(),@@ -184,17 +184,17 @@ export type CollectionSavePlaceRequest = z.infer<typeof collectionSavePlaceReque/** DEDICATED DTO for POST /places/from-trip — the server reads the place, so no place payload. */export const collectionSaveFromTripRequestSchema = z.object({- collection_id: z.number(),- source_trip_id: z.number(),- source_place_id: z.number(),+ collection_id: z.number().int(),+ source_trip_id: z.number().int(),+ source_place_id: z.number().int(),force: z.boolean().optional(),});export type CollectionSaveFromTripRequest = z.infer<typeof collectionSaveFromTripRequestSchema>;/** Bulk: copy several selected trip places into a list at once. */export const collectionSaveFromTripManyRequestSchema = z.object({- collection_id: z.number(),- source_trip_id: z.number(),+ collection_id: z.number().int(),+ source_trip_id: z.number().int(),source_place_ids: z.array(z.number()).min(1).max(1000),force: z.boolean().optional(),});@@ -215,8 +215,8 @@ export const collectionPlaceUpdateRequestSchema = z.object({// undefined (left unchanged) instead of being injected as 'idea' (see #1437). The// .catch('idea') guard against invalid values is preserved.status: collectionStatusSchema.removeDefault().optional(),- category_id: z.number().nullable().optional(),- collection_id: z.number().optional(), // move to another list+ category_id: z.number().int().nullable().optional(),+ collection_id: z.number().int().optional(), // move to another listlinks: collectionLinksSchema.optional(),tag_ids: z.array(z.number()).optional(),// Replace the place's per-collection label assignments (omit to leave unchanged).@@ -250,7 +250,7 @@ export type CollectionSetStatusManyRequest = z.infer<typeof collectionSetStatusM/** Same, but naming the places by their TRIP ids: the server resolves each one to* the lists it is saved in. Drives the planner's bulk "mark as visited" (#1469). */export const collectionSetStatusFromTripRequestSchema = z.object({- trip_id: z.number(),+ trip_id: z.number().int(),place_ids: z.array(z.number()).min(1).max(1000),status: collectionStatusSchema,});@@ -273,7 +273,7 @@ export type CollectionDeleteManyRequest = z.infer<typeof collectionDeleteManyReq/** Copy one or many saved places INTO a trip (dedup precheck on server). */export const collectionCopyToTripRequestSchema = z.object({- trip_id: z.number(),+ trip_id: z.number().int(),place_ids: z.array(z.number()).min(1),force: z.boolean().optional(),});@@ -328,32 +328,32 @@ export type CollectionPlacesPageRequest = z.infer<typeof collectionPlacesPageReq// Fusion invitations. user_id is NUMERIC ONLY — the UI always sends an id from availableUsers.export const collectionInviteRequestSchema = z.object({- collection_id: z.number(),- user_id: z.number(),+ collection_id: z.number().int(),+ user_id: z.number().int(),role: collectionRoleSchema.optional(),});export type CollectionInviteRequest = z.infer<typeof collectionInviteRequestSchema>;-export const collectionInviteActionRequestSchema = z.object({ collection_id: z.number() });+export const collectionInviteActionRequestSchema = z.object({ collection_id: z.number().int() });export type CollectionInviteActionRequest = z.infer<typeof collectionInviteActionRequestSchema>;export const collectionInviteCancelRequestSchema = z.object({- collection_id: z.number(),- user_id: z.number(),+ collection_id: z.number().int(),+ user_id: z.number().int(),});export type CollectionInviteCancelRequest = z.infer<typeof collectionInviteCancelRequestSchema>;/** Owner removes an ALREADY-ACCEPTED member (kick). */export const collectionRemoveMemberRequestSchema = z.object({- collection_id: z.number(),- user_id: z.number(),+ collection_id: z.number().int(),+ user_id: z.number().int(),});export type CollectionRemoveMemberRequest = z.infer<typeof collectionRemoveMemberRequestSchema>;/** Owner changes an accepted member's permission role. */export const collectionSetMemberRoleRequestSchema = z.object({- collection_id: z.number(),- user_id: z.number(),+ collection_id: z.number().int(),+ user_id: z.number().int(),role: collectionRoleSchema,});export type CollectionSetMemberRoleRequest = z.infer<typeof collectionSetMemberRoleRequestSchema>;@@ -363,7 +363,7 @@ const labelColorSchema = z.string().regex(/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/);/** Create a custom label in a list. */export const collectionLabelCreateRequestSchema = z.object({- collection_id: z.number(),+ collection_id: z.number().int(),name: z.string().trim().min(1).max(60),color: labelColorSchema.optional(),});diff --git a/shared/src/file/file.schema.ts b/shared/src/file/file.schema.tsindex e219336e0..eec6de4f2 100644--- a/shared/src/file/file.schema.ts+++ b/shared/src/file/file.schema.ts@@ -12,7 +12,7 @@ import { z } from 'zod';* bodies. The bespoke 400/403/404 controller messages pin the rest.*/-const nullableIdField = z.union([z.string(), z.number()]).nullable().optional();+const nullableIdField = z.union([z.string(), z.number().int()]).nullable().optional();/*** Multipart text fields riding along with the upload — always strings on thediff --git a/shared/src/memories/memories.schema.ts b/shared/src/memories/memories.schema.tsindex b6c87cc1d..0045a86ff 100644--- a/shared/src/memories/memories.schema.ts+++ b/shared/src/memories/memories.schema.ts@@ -25,6 +25,8 @@ const looseBoolean = z.union([z.boolean(), z.literal('true'), z.literal('false')/** `Number(x) || fallback` — the client sends these as strings from query-ish forms. */const looseNumber = z.union([z.number(), z.string()]).optional();+/** A row id the same loose way: a whole number, or a string the service converts. */+const looseId = z.union([z.number().int(), z.string()]).optional();/*** The UTC offset the caller means its calendar days in, in minutes east of UTC@@ -119,7 +121,7 @@ export const synologySearchSchema = z.looseObject({export const photoSelectionSchema = z.looseObject({provider: z.string(),asset_ids: z.array(z.string()),- owner_id: z.number().optional(),+ owner_id: z.number().int().optional(),passphrase: z.string().optional(),});@@ -131,13 +133,13 @@ export const addTripPhotosSchema = z.looseObject({});export const setTripPhotoSharingSchema = z.looseObject({- photo_id: looseNumber,+ photo_id: looseId,shared: z.unknown().optional(),});/** The photo to unlink from the trip. Same shape the sharing toggle takes. */export const removeTripPhotoSchema = z.looseObject({- photo_id: looseNumber,+ photo_id: looseId,});export const createAlbumLinkSchema = z.looseObject({diff --git a/shared/src/packing/packing.schema.ts b/shared/src/packing/packing.schema.tsindex 2d5586180..be43edbc9 100644--- a/shared/src/packing/packing.schema.ts+++ b/shared/src/packing/packing.schema.ts@@ -102,9 +102,9 @@ export const packingCreateItemRequestSchema = z.object({checked: z.union([z.boolean(), z.number().int().min(0).max(1)]).optional(),// Same shapes as the update schema below (#2154) — the create route used to// strip these three silently, forcing a second write to set them.- weight_grams: z.number().nullable().optional(),- bag_id: z.number().nullable().optional(),- quantity: z.number().optional(),+ weight_grams: z.number().int().nullable().optional(),+ bag_id: z.number().int().nullable().optional(),+ quantity: z.number().int().optional(),// Mark the new item private to its creator (#858, legacy flag).is_private: z.boolean().optional(),// Three-tier sharing (#858): which list the item belongs to, and — for 'shared' —@@ -133,9 +133,9 @@ export const packingUpdateItemRequestSchema = z.object({// The legacy route accepted both boolean and 0/1 for checked — both stay valid.checked: z.union([z.boolean(), z.number().int().min(0).max(1)]).optional(),category: z.string().optional(),- weight_grams: z.number().nullable().optional(),- bag_id: z.number().nullable().optional(),- quantity: z.number().optional(),+ weight_grams: z.number().int().nullable().optional(),+ bag_id: z.number().int().nullable().optional(),+ quantity: z.number().int().optional(),// Count packed pieces of a multi-piece item (#2296). Reaching the quantity// checks the item; null or 0 clears the count. Ticking `checked` resets it.packed_quantity: z.number().int().min(0).max(999).nullable().optional(),@@ -158,15 +158,15 @@ export const packingCreateBagRequestSchema = z.object({name: z.string().min(1),color: z.string().optional(),// Same shape as the update schema below (#2154) — POST used to strip it.- weight_limit_grams: z.number().nullable().optional(),+ weight_limit_grams: z.number().int().nullable().optional(),});export type PackingCreateBagRequest = z.infer<typeof packingCreateBagRequestSchema>;export const packingUpdateBagRequestSchema = z.object({name: z.string().optional(),color: z.string().optional(),- weight_limit_grams: z.number().nullable().optional(),- user_id: z.number().nullable().optional(),+ weight_limit_grams: z.number().int().nullable().optional(),+ user_id: z.number().int().nullable().optional(),});export type PackingUpdateBagRequest = z.infer<typeof packingUpdateBagRequestSchema>;diff --git a/shared/src/place/place.schema.ts b/shared/src/place/place.schema.tsindex b2447dae3..97d755ac3 100644--- a/shared/src/place/place.schema.ts+++ b/shared/src/place/place.schema.ts@@ -298,7 +298,7 @@ export const placeBulkUpdateRequestSchema = z.object({ids: z.array(z.number()),// null clears the category ("No category"); a number sets it. Optional so the// field can be omitted, but the endpoint requires it to be present to act.- category_id: z.number().nullable().optional(),+ category_id: z.number().int().nullable().optional(),});export type PlaceBulkUpdateRequest = z.infer<typeof placeBulkUpdateRequestSchema>;diff --git a/shared/src/reservation/reservation.schema.ts b/shared/src/reservation/reservation.schema.tsindex a17dac7ce..330f17291 100644--- a/shared/src/reservation/reservation.schema.ts+++ b/shared/src/reservation/reservation.schema.ts@@ -283,15 +283,15 @@ export const reservationPositionsRequestSchema = z.object({// day_plan_position is optional on the wire: the legacy route never// validated position items, and an absent value binds NULL (clears the// stored position) — pinned by the server integration suite (RESV-006).- positions: z.array(z.object({ id: z.number(), day_plan_position: z.number().optional() })),- day_id: z.union([z.number(), z.string()]).nullable().optional(),+ positions: z.array(z.object({ id: z.number().int(), day_plan_position: z.number().optional() })),+ day_id: z.union([z.number().int(), z.string()]).nullable().optional(),});export type ReservationPositionsRequest = z.infer<typeof reservationPositionsRequestSchema>;export const accommodationCreateRequestSchema = z.object({- place_id: z.union([z.number(), z.string()]),- start_day_id: z.union([z.number(), z.string()]),- end_day_id: z.union([z.number(), z.string()]),+ place_id: z.union([z.number().int(), z.string()]),+ start_day_id: z.union([z.number().int(), z.string()]),+ end_day_id: z.union([z.number().int(), z.string()]),check_in: z.string().nullable().optional(),check_in_end: z.string().nullable().optional(),check_out: z.string().nullable().optional(),diff --git a/shared/src/todo/todo.schema.ts b/shared/src/todo/todo.schema.tsindex ede39d89d..8efb1c1b4 100644--- a/shared/src/todo/todo.schema.ts+++ b/shared/src/todo/todo.schema.ts@@ -17,8 +17,8 @@ export const todoCreateItemRequestSchema = z.object({category: z.string().nullable().optional(),due_date: z.string().nullable().optional(),description: z.string().nullable().optional(),- assigned_user_id: z.number().nullable().optional(),- priority: z.number().optional(),+ assigned_user_id: z.number().int().nullable().optional(),+ priority: z.number().int().optional(),});export type TodoCreateItemRequest = z.infer<typeof todoCreateItemRequestSchema>;@@ -31,8 +31,8 @@ export const todoUpdateItemRequestSchema = z.object({category: z.string().nullable().optional(),due_date: z.string().nullable().optional(),description: z.string().nullable().optional(),- assigned_user_id: z.number().nullable().optional(),- priority: z.number().nullable().optional(),+ assigned_user_id: z.number().int().nullable().optional(),+ priority: z.number().int().nullable().optional(),});export type TodoUpdateItemRequest = z.infer<typeof todoUpdateItemRequestSchema>;diff --git a/shared/src/trip/trip.schema.ts b/shared/src/trip/trip.schema.tsindex 6b805e1b9..c4d8b374c 100644--- a/shared/src/trip/trip.schema.ts+++ b/shared/src/trip/trip.schema.ts@@ -108,7 +108,7 @@ export const tripCreateRequestSchema = z.object({start_date: z.string().nullable().optional(),end_date: z.string().nullable().optional(),currency: z.string().optional(),- reminder_days: z.number().optional(),+ reminder_days: z.number().int().optional(),day_count: z.number().optional(),});export type TripCreateRequest = z.infer<typeof tripCreateRequestSchema>;@@ -127,9 +127,9 @@ export const tripUpdateRequestSchema = z.object({*/date_shift_mode: z.enum(['keep_bookings', 'shift_all']).optional(),currency: z.string().optional(),- reminder_days: z.number().optional(),+ reminder_days: z.number().int().optional(),day_count: z.number().optional(),- is_archived: z.union([z.boolean(), z.number()]).optional(),+ is_archived: z.union([z.boolean(), z.number().int()]).optional(),// Bounded like a place's image url: a replaced cover is queued for release,// and every upload path the old value spells out is one queued object.cover_image: z.string().max(2048).nullable().optional(),diff --git a/shared/src/vacay/vacay.schema.ts b/shared/src/vacay/vacay.schema.tsindex 184e208f1..3e67a8830 100644--- a/shared/src/vacay/vacay.schema.ts+++ b/shared/src/vacay/vacay.schema.ts@@ -29,7 +29,7 @@ export const vacayUpdatePlanRequestSchema = z.object({company_holidays_enabled: z.boolean().optional(),carry_over_enabled: z.boolean().optional(),weekend_days: z.string().optional(),- week_start: z.number().optional(),+ week_start: z.number().int().optional(),});export type VacayUpdatePlanRequest = z.infer<typeof vacayUpdatePlanRequestSchema>;@@ -60,17 +60,17 @@ export const vacaySetColorRequestSchema = z.object({export type VacaySetColorRequest = z.infer<typeof vacaySetColorRequestSchema>;export const vacayInviteRequestSchema = z.object({- user_id: z.union([z.number(), z.string()]),+ user_id: z.union([z.number().int(), z.string()]),});export type VacayInviteRequest = z.infer<typeof vacayInviteRequestSchema>;export const vacayInviteActionRequestSchema = z.object({- plan_id: z.number().optional(),+ plan_id: z.number().int().optional(),});export type VacayInviteActionRequest = z.infer<typeof vacayInviteActionRequestSchema>;export const vacayAddYearRequestSchema = z.object({- year: z.union([z.number(), z.string()]),+ year: z.union([z.number().int(), z.string()]),});export type VacayAddYearRequest = z.infer<typeof vacayAddYearRequestSchema>;@@ -110,7 +110,7 @@ export const vacayCompanyHolidayRequestSchema = z.object({export type VacayCompanyHolidayRequest = z.infer<typeof vacayCompanyHolidayRequestSchema>;export const vacayUpdateStatsRequestSchema = z.object({- vacation_days: z.number().optional(),+ vacation_days: z.number().int().optional(),target_user_id: z.union([z.number(), z.string()]).optional(),});export type VacayUpdateStatsRequest = z.infer<typeof vacayUpdateStatsRequestSchema>;@@ -118,7 +118,7 @@ export type VacayUpdateStatsRequest = z.infer<typeof vacayUpdateStatsRequestSche// Read-only calendar sharing (#444/#667): grant another user view access to// your vacation calendar without fusing plans.export const vacayShareRequestSchema = z.object({- user_id: z.union([z.number(), z.string()]),+ user_id: z.union([z.number().int(), z.string()]),});export type VacayShareRequest = z.infer<typeof vacayShareRequestSchema>;