diff --git a/client/src/components/MailIngest/MailInboxDialog.tsx b/client/src/components/MailIngest/MailInboxDialog.tsx index 91ef3f20d..fe4f5884b 100644 --- a/client/src/components/MailIngest/MailInboxDialog.tsx +++ b/client/src/components/MailIngest/MailInboxDialog.tsx @@ -198,19 +198,13 @@ export default function MailInboxDialog(): ReactElement | null { labelId={titleId} onClose={inbox.close} title={t('mailInbox.title')} - sub={inbox.pending > 0 ? t('mailInbox.pendingCount', { count: inbox.pending }) : t('mailInbox.empty')} + // The empty state below says it already; the head only counts what waits. + sub={inbox.pending > 0 ? t('mailInbox.pendingCount', { count: inbox.pending }) : undefined} /> ); return ( - + {inbox.picking ? ( ) : inbox.preview ? ( diff --git a/server/scripts/size-baseline.json b/server/scripts/size-baseline.json index 474b77dcd..1a7259048 100644 --- a/server/scripts/size-baseline.json +++ b/server/scripts/size-baseline.json @@ -2,7 +2,7 @@ "scripts/db-call-graph.mjs": 1036, "scripts/generate-entities.ts": 2259, "src/db/repositories/Places.repository.ts": 1437, - "src/db/repositories/Reservations.repository.ts": 1559, + "src/db/repositories/Reservations.repository.ts": 1558, "src/db/repositories/Trips.repository.ts": 1120, "src/db/repositories/Users.repository.ts": 1445, "src/nest/atlas/atlas.service.ts": 1174, @@ -15,6 +15,6 @@ "src/nest/places/places.service.ts": 1549, "src/nest/plugins/plugin-runtime.service.ts": 1460, "src/nest/plugins/runtime/plugin-sdk.ts": 1093, - "src/nest/reservations/reservations.service.ts": 1228, + "src/nest/reservations/reservations.service.ts": 1168, "src/nest/vacay/vacay.service.ts": 1393 } diff --git a/server/src/db/repositories/Reservations.repository.ts b/server/src/db/repositories/Reservations.repository.ts index 41167c0e5..0bb1e57ca 100644 --- a/server/src/db/repositories/Reservations.repository.ts +++ b/server/src/db/repositories/Reservations.repository.ts @@ -7,6 +7,8 @@ import { publicReservationExpr, publicStayExists, type ReservationVisibilityKyse import type { DayAssignmentRow } from './day-assignment-rows'; import { TrekRepository } from './_shared/trek-repository'; import { passContextQuery, type PassContextDB } from './_shared/reservation-pass-context'; +import { originColumnValues, type ReservationOriginColumns } from './_shared/reservation-origin-columns'; +import { idByExternalQuery, joinedReservationQuery, type ReservationJoinDB } from './_shared/reservation-joined-query'; import type { DB } from '../kysely/db'; import { ROADTRIP_RESERVATION_TYPES } from '@trek/shared'; import type { @@ -41,7 +43,6 @@ export type { * 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. */ -type ReservationJoinKyselyDB = Pick; /** * `reservations` as the two aliases below bind it: `accommodation_id` is a @@ -363,24 +364,7 @@ export class ReservationsRepository extends TrekRepository { findPassContext(id: number, tripId: number) { return passContextQuery(this.kysely(), id, tripId); } private joinedQuery() { - return this.kysely() - .selectFrom('reservations as r') - .leftJoin('days as d', 'd.id', 'r.day_id') - .leftJoin('places as p', 'p.id', 'r.place_id') - .leftJoin('day_accommodations as ap', 'ap.id', 'r.accommodation_id') - .leftJoin('places as acc_p', 'acc_p.id', 'ap.place_id') - .selectAll('r') - .select([ - 'd.day_number as day_number', - 'p.name as place_name', - 'ap.place_id as accommodation_place_id', - 'acc_p.name as accommodation_name', - 'ap.start_day_id as accommodation_start_day_id', - 'ap.end_day_id as accommodation_end_day_id', - 'ap.check_in as accommodation_check_in', - 'ap.check_in_end as accommodation_check_in_end', - 'ap.check_out as accommodation_check_out', - ]); + return joinedReservationQuery(this.kysely()); } /** @@ -493,10 +477,7 @@ export class ReservationsRepository extends TrekRepository { accommodation_id: string | null; metadata: string | null; needs_review: number; - external_source?: string; - external_id?: string; - sync_enabled?: number; - }): Promise { + } & ReservationOriginColumns): Promise { return await this.insert({ trip: input.trip_id, day: input.day_id, @@ -515,27 +496,13 @@ export class ReservationsRepository extends TrekRepository { accommodation_id: input.accommodation_id, metadata: input.metadata, needs_review: input.needs_review, - ...(input.external_source !== undefined && { external_source: input.external_source }), - ...(input.external_id !== undefined && { external_id: input.external_id }), - ...(input.sync_enabled !== undefined && { sync_enabled: input.sync_enabled }), + ...originColumnValues(input), }); } - /** - * The booking an import already wrote into this trip under the same origin, - * or undefined: what `idx_reservations_external (external_source, - * external_id, trip_id)` would refuse, read before the write so a repeat - * import is reported instead of failing on the unique index. - */ - async findIdByExternal(trip_id: number, external_source: string, external_id: string): Promise { - const row = await this.kysely() - .selectFrom('reservations') - .select(['id']) - .where('trip_id', '=', trip_id) - .where('external_source', '=', external_source) - .where('external_id', '=', external_id) - .executeTakeFirst(); - return row?.id; + /** The booking an import already wrote into this trip under the same origin (_shared/reservation-joined-query.ts). */ + findIdByExternal(trip_id: number, external_source: string, external_id: string): Promise { + return idByExternalQuery(this.kysely(), trip_id, external_source, external_id); } /** diff --git a/server/src/db/repositories/_shared/reservation-joined-query.ts b/server/src/db/repositories/_shared/reservation-joined-query.ts new file mode 100644 index 000000000..09826c819 --- /dev/null +++ b/server/src/db/repositories/_shared/reservation-joined-query.ts @@ -0,0 +1,56 @@ +import type { DB } from '../../kysely/db'; + +import type { Kysely } from 'kysely'; + +/** The tables the joined booking projection reads. */ +export type ReservationJoinDB = Pick; + +/** + * A booking with its day number, its place's name and its stay's place and + * times: the projection `ReservationsRepository.listForTrip` and + * `findWithJoins` narrow with their own `WHERE`. Kept out of the repository + * file, which is at its size baseline. + */ +export function joinedReservationQuery(kysely: Kysely) { + return kysely + .selectFrom('reservations as r') + .leftJoin('days as d', 'd.id', 'r.day_id') + .leftJoin('places as p', 'p.id', 'r.place_id') + .leftJoin('day_accommodations as ap', 'ap.id', 'r.accommodation_id') + .leftJoin('places as acc_p', 'acc_p.id', 'ap.place_id') + .selectAll('r') + .select([ + 'd.day_number as day_number', + 'p.name as place_name', + 'ap.place_id as accommodation_place_id', + 'acc_p.name as accommodation_name', + 'ap.start_day_id as accommodation_start_day_id', + 'ap.end_day_id as accommodation_end_day_id', + 'ap.check_in as accommodation_check_in', + 'ap.check_in_end as accommodation_check_in_end', + 'ap.check_out as accommodation_check_out', + ]); +} + +/** + * The booking an import already wrote into this trip under the same origin, + * or undefined: what `idx_reservations_external (external_source, + * external_id, trip_id)` would refuse, read before the write so a repeat + * import is reported instead of failing on the unique index + * (`ReservationsRepository.findIdByExternal`). + */ +export async function idByExternalQuery( + kysely: Kysely>, + trip_id: number, + external_source: string, + external_id: string, +): Promise { + const row = await kysely + .selectFrom('reservations') + .select(['id']) + .where('trip_id', '=', trip_id) + .where('external_source', '=', external_source) + .where('external_id', '=', external_id) + .executeTakeFirst(); + return row?.id; +} diff --git a/server/src/db/repositories/_shared/reservation-origin-columns.ts b/server/src/db/repositories/_shared/reservation-origin-columns.ts new file mode 100644 index 000000000..e95d5204a --- /dev/null +++ b/server/src/db/repositories/_shared/reservation-origin-columns.ts @@ -0,0 +1,21 @@ +/** + * Where an imported booking came from and its key there, as the reservations + * table stores them. Named on an insert only when the caller passes them: an + * imported booking records its origin, every other write leaves the columns to + * their defaults (`sync_enabled INTEGER DEFAULT 1`). Kept out of + * Reservations.repository.ts, which is at its size baseline. + */ +export interface ReservationOriginColumns { + external_source?: string; + external_id?: string; + sync_enabled?: number; +} + +/** The origin columns an insert names: only those the caller set. */ +export function originColumnValues(input: ReservationOriginColumns): ReservationOriginColumns { + return { + ...(input.external_source !== undefined && { external_source: input.external_source }), + ...(input.external_id !== undefined && { external_id: input.external_id }), + ...(input.sync_enabled !== undefined && { sync_enabled: input.sync_enabled }), + }; +} diff --git a/server/src/nest/auth/auth.service.ts b/server/src/nest/auth/auth.service.ts index fa001dbc4..b639bb7b3 100644 --- a/server/src/nest/auth/auth.service.ts +++ b/server/src/nest/auth/auth.service.ts @@ -15,7 +15,7 @@ import { UnitOfWork } from '../database/unit-of-work'; import { PermissionsService } from '../permissions/permissions.service'; import { validatePassword } from '../common/passwordPolicy'; import { encryptMfaSecret, decryptMfaSecret } from '../common/crypto/mfaCrypto'; -import { decrypt_api_key, maybe_encrypt_api_key, encrypt_api_key } from '../common/crypto/apiKeyCrypto'; +import { decrypt_api_key } from '../common/crypto/apiKeyCrypto'; import { resolveApiKey } from '../settings/instance-api-keys'; import { InjectRepository } from '@mikro-orm/nestjs'; import { AppSettings } from '../../db/entities/AppSettings.entity'; @@ -71,13 +71,14 @@ import { } from './auth.helpers'; import { ADMIN_FORM_SETTING_KEYS, - APP_SETTINGS, MASKED_ADMIN_SETTING_KEYS, + ADMIN_SETTING_MASK, + isMaskEcho, + storedAdminValue, PUBLIC_CONFIG_SETTING_KEYS, isOidcConfigured, isOidcConfiguredIn, readAppSetting, - type AppSettingDef, type AppSettingKey, } from '../common/app-settings.registry'; @@ -709,7 +710,7 @@ export class AuthService { const result: Record = {}; for (const key of ADMIN_FORM_SETTING_KEYS) { const value = await readAppSetting(this.appSettings, key); - if (value !== null) result[key] = MASKED_ADMIN_SETTING_KEYS.has(key) ? '••••••••' : value; + if (value !== null) result[key] = MASKED_ADMIN_SETTING_KEYS.has(key) ? ADMIN_SETTING_MASK : value; } return { data: withEnvLocks(result) }; } @@ -769,22 +770,14 @@ export class AuthService { // admin a saved setting that quietly does nothing. if (key === 'places_provider' && !isPlacesProviderChoice(val)) continue; // A masked key sent back unchanged keeps its stored value. - if (MASKED_ADMIN_SETTING_KEYS.has(key) && val === '••••••••') continue; - const def = APP_SETTINGS[key] as AppSettingDef; - if (def.validated) { - const checked = def.schema.safeParse(val); - if (!checked.success) throw new DomainError(400, checked.error.issues[0]?.message ?? `${key} is not valid`); - } - const encrypted: AppSettingDef['encrypted'] = def.encrypted; - if (encrypted === 'always') val = encrypt_api_key(val); - else if (encrypted === 'if-plain' && val) val = maybe_encrypt_api_key(val) ?? val; - await this.appSettings.setValue(key, val); + if (isMaskEcho(key, val)) continue; + await this.appSettings.setValue(key, storedAdminValue(key, val)); } } }); // A masked key sent back as its mask was not changed, and a secret's value never reaches the audit row. - const changedKeys = ADMIN_FORM_SETTING_KEYS.filter(k => !blocked.includes(k) && body[k] !== undefined && !(MASKED_ADMIN_SETTING_KEYS.has(k) && String(body[k]) === '••••••••')); + const changedKeys = ADMIN_FORM_SETTING_KEYS.filter(k => !blocked.includes(k) && body[k] !== undefined && !isMaskEcho(k, body[k])); const summary: Record = {}; const smtpChanged = changedKeys.some(k => k.startsWith('smtp_')); diff --git a/server/src/nest/booking-import/booking-import.service.ts b/server/src/nest/booking-import/booking-import.service.ts index 79c5f7d24..f8205563f 100644 --- a/server/src/nest/booking-import/booking-import.service.ts +++ b/server/src/nest/booking-import/booking-import.service.ts @@ -14,7 +14,8 @@ import { McpToolGuardsService } from '../mcp-shared/mcp-tool-guards.service'; import { PlaceOriginsService } from '../places/place-origins.service'; import { PlacesService } from '../places/places.service'; import { RealtimeService } from '../realtime/realtime.service'; -import { ReservationsService, withoutOrigin, type CreateAccommodation } from '../reservations/reservations.service'; +import { withoutOrigin } from '../reservations/reservation-origin'; +import { ReservationsService, type CreateAccommodation } from '../reservations/reservations.service'; import { IMPORT_SOURCE, importExternalId } from './booking-origin'; import { KitineraryExtractorService } from './kitinerary-extractor.service'; import { mapReservations } from './kitinerary-mapper'; diff --git a/server/src/nest/common/app-settings.registry.ts b/server/src/nest/common/app-settings.registry.ts index 5660562a0..769fb001c 100644 --- a/server/src/nest/common/app-settings.registry.ts +++ b/server/src/nest/common/app-settings.registry.ts @@ -1,5 +1,7 @@ import { readEnv } from '../../app-config'; import type { AppSettingsRepository } from '../../db/repositories/AppSettings.repository'; +import { encrypt_api_key, maybe_encrypt_api_key } from './crypto/apiKeyCrypto'; +import { DomainError } from './domain-error'; import { aiPolicySchema, mailIngestImapTlsSchema, mailIngestTransportSettingSchema } from '@trek/shared'; import { z } from 'zod'; @@ -217,6 +219,30 @@ const keysWhere = (pick: (def: AppSettingDef) => unknown): AppSettingKey[] => export const ADMIN_FORM_SETTING_KEYS: readonly AppSettingKey[] = keysWhere((d) => d.adminForm); /** The form's keys answered as `••••••••` rather than their value. */ export const MASKED_ADMIN_SETTING_KEYS: ReadonlySet = new Set(keysWhere((d) => d.masked)); + +/** What the admin form shows for a stored secret, and takes back as "unchanged". */ +export const ADMIN_SETTING_MASK = '••••••••'; + +/** True when the admin form sent a masked key back as its mask: the stored value stays. */ +export function isMaskEcho(key: AppSettingKey, value: unknown): boolean { + return MASKED_ADMIN_SETTING_KEYS.has(key) && String(value) === ADMIN_SETTING_MASK; +} + +/** + * The value an admin form key is stored as: checked against its schema where + * the registry asks for it (`validated`, a 400 naming what is wrong), and + * encrypted where it says so. + */ +export function storedAdminValue(key: AppSettingKey, value: string): string { + const def = APP_SETTINGS[key] as AppSettingDef; + if (def.validated) { + const checked = def.schema.safeParse(value); + if (!checked.success) throw new DomainError(400, checked.error.issues[0]?.message ?? `${key} is not valid`); + } + if (def.encrypted === 'always') return encrypt_api_key(value); + if (def.encrypted === 'if-plain' && value) return maybe_encrypt_api_key(value) ?? value; + return value; +} /** The keys stored encrypted. */ export const ENCRYPTED_APP_SETTING_KEYS: ReadonlySet = new Set(keysWhere((d) => d.encrypted)); /** The registered keys a managed install withholds from its admin (the rest of that list is user settings and profile columns). */ diff --git a/server/src/nest/reservations/reservation-inputs.ts b/server/src/nest/reservations/reservation-inputs.ts new file mode 100644 index 000000000..3244ebf23 --- /dev/null +++ b/server/src/nest/reservations/reservation-inputs.ts @@ -0,0 +1,75 @@ +import type { ReservationOrigin } from './reservation-origin'; + +/* + * The shapes the reservations service takes in: a booking's endpoints, the + * stay a booking can create, and the create and update bodies. Kept apart + * from reservations.service.ts, which is at its size baseline; the service + * exports them on, so their importers did not change. + */ + +export interface ReservationEndpoint { + id?: number; + reservation_id?: number; + role: 'from' | 'to' | 'stop'; + sequence: number; + name: string; + code: string | null; + lat: number; + lng: number; + timezone: string | null; + local_time: string | null; + local_date: string | null; +} + +export type EndpointInput = Omit & { sequence?: number }; + +export interface CreateAccommodation { + place_id?: number; + start_day_id?: number; + end_day_id?: number; + check_in?: string; + check_out?: string; + confirmation?: string; +} + +export interface CreateReservationData extends ReservationOrigin { + title: string; + reservation_time?: string; + reservation_end_time?: string; + location?: string; + confirmation_number?: string; + notes?: string; + url?: string; + day_id?: number; + end_day_id?: number; + place_id?: number; + assignment_id?: number; + status?: string; + type?: string; + accommodation_id?: number; + metadata?: unknown; + create_accommodation?: CreateAccommodation; + endpoints?: EndpointInput[]; + needs_review?: boolean; +} + +export interface UpdateReservationData { + title?: string; + reservation_time?: string; + reservation_end_time?: string; + location?: string; + confirmation_number?: string; + notes?: string; + url?: string; + day_id?: number | null; + end_day_id?: number | null; + place_id?: number; + assignment_id?: number; + status?: string; + type?: string; + accommodation_id?: number; + metadata?: unknown; + create_accommodation?: CreateAccommodation; + endpoints?: EndpointInput[]; + needs_review?: boolean; +} diff --git a/server/src/nest/reservations/reservation-origin.ts b/server/src/nest/reservations/reservation-origin.ts new file mode 100644 index 000000000..7c198c29c --- /dev/null +++ b/server/src/nest/reservations/reservation-origin.ts @@ -0,0 +1,35 @@ +/** + * Where an imported booking came from (`import`, `mail`) and its key there, + * unique per trip. Both or neither; without them the row is a hand-made + * booking, as every write was before imports recorded their origin. + */ +export interface ReservationOrigin { + external_source?: string; + external_id?: string; + /** False keeps an imported booking out of any sync back to its source; the column defaults to on. */ + sync_enabled?: boolean; +} + +/** + * A create body from a client without the origin fields. The REST and plugin + * bodies are open objects, and an origin a caller could name would let it pose + * as an AirTrail link or an import, so only the importers set one. + */ +export function withoutOrigin(body: Record): Record { + const { external_source: _source, external_id: _id, sync_enabled: _sync, ...rest } = body; + return rest; +} + +/** The origin columns an insert names, none for a booking without an origin. */ +export function originColumns(data: ReservationOrigin): { + external_source?: string; + external_id?: string; + sync_enabled?: number; +} { + if (!data.external_source || !data.external_id) return {}; + return { + external_source: data.external_source, + external_id: data.external_id, + ...(data.sync_enabled !== undefined && { sync_enabled: data.sync_enabled ? 1 : 0 }), + }; +} diff --git a/server/src/nest/reservations/reservations.controller.ts b/server/src/nest/reservations/reservations.controller.ts index 4b5f18bf1..3ff8c240e 100644 --- a/server/src/nest/reservations/reservations.controller.ts +++ b/server/src/nest/reservations/reservations.controller.ts @@ -2,6 +2,7 @@ import type { User } from '../../types'; import { CurrentUser } from '../auth-core/current-user.decorator'; import { JwtAuthGuard } from '../auth-core/jwt-auth.guard'; import { RequirePermission, TripAccessGuard } from '../permissions/trip-access.guard'; +import { withoutOrigin } from './reservation-origin'; import { ReservationWritesService } from './reservation-writes.service'; import { ReservationCreateDto, @@ -9,7 +10,7 @@ import { ReservationPositionsDto, ReservationTravelersDto, } from './reservations.dto'; -import { ReservationsService, withoutOrigin } from './reservations.service'; +import { ReservationsService } from './reservations.service'; import { Body, Controller, Delete, Get, Headers, HttpException, Param, Post, Put, UseGuards } from '@nestjs/common'; type ReservationBody = Record & { diff --git a/server/src/nest/reservations/reservations.rpc.ts b/server/src/nest/reservations/reservations.rpc.ts index cc2d5e2a4..fcec9cb3b 100644 --- a/server/src/nest/reservations/reservations.rpc.ts +++ b/server/src/nest/reservations/reservations.rpc.ts @@ -4,7 +4,8 @@ import { PluginController, PluginMethod } from '../../nest-rpc/rpc-kit/decorator import type { PluginRpcContext } from '../../nest-rpc/rpc-kit/types'; import { num, schemaMessage } from '../../nest-rpc/rpc-params'; import { RealtimeService } from '../realtime/realtime.service'; -import { ReservationsService, withoutOrigin } from './reservations.service'; +import { withoutOrigin } from './reservation-origin'; +import { ReservationsService } from './reservations.service'; import { reservationCreateRequestSchema, reservationEndpointsInputSchema, diff --git a/server/src/nest/reservations/reservations.service.ts b/server/src/nest/reservations/reservations.service.ts index 8f0f1bc0d..e6ed8f2a7 100644 --- a/server/src/nest/reservations/reservations.service.ts +++ b/server/src/nest/reservations/reservations.service.ts @@ -1,3 +1,6 @@ +import { originColumns } from './reservation-origin'; +import type { CreateAccommodation, CreateReservationData, EndpointInput, ReservationEndpoint, UpdateReservationData } from './reservation-inputs'; +export type { CreateAccommodation, CreateReservationData, EndpointInput, ReservationEndpoint, UpdateReservationData } from './reservation-inputs'; import { BadRequestException, Injectable } from '@nestjs/common'; import { InjectRepository } from '@mikro-orm/nestjs'; import type { TripAccess, TripsRepository } from '../../db/repositories/Trips.repository'; @@ -52,22 +55,6 @@ export type CostEvent = | { event: 'budget:updated'; payload: TrekWsPayload<'budget:updated'> } | { event: 'budget:deleted'; payload: TrekWsPayload<'budget:deleted'> }; -export interface ReservationEndpoint { - id?: number; - reservation_id?: number; - role: 'from' | 'to' | 'stop'; - sequence: number; - name: string; - code: string | null; - lat: number; - lng: number; - timezone: string | null; - local_time: string | null; - local_date: string | null; -} - -export type EndpointInput = Omit & { sequence?: number }; - // --- Travelers (#1517): trip members / named guests assigned to a booking ----- export interface ReservationTraveler { @@ -94,89 +81,6 @@ export type ReservationRow = Record & { travelers?: ReservationTraveler[]; }; -export interface CreateAccommodation { - place_id?: number; - start_day_id?: number; - end_day_id?: number; - check_in?: string; - check_out?: string; - confirmation?: string; -} - -export interface CreateReservationData { - title: string; - reservation_time?: string; - reservation_end_time?: string; - location?: string; - confirmation_number?: string; - notes?: string; - url?: string; - day_id?: number; - end_day_id?: number; - place_id?: number; - assignment_id?: number; - status?: string; - type?: string; - accommodation_id?: number; - metadata?: unknown; - create_accommodation?: CreateAccommodation; - endpoints?: EndpointInput[]; - needs_review?: boolean; - /** - * Where an imported booking came from (`import`, `mail`) and its key there, - * unique per trip. Both or neither; without them the row is a hand-made - * booking, as every write was before imports recorded their origin. - */ - external_source?: string; - external_id?: string; - /** False keeps an imported booking out of any sync back to its source; the column defaults to on. */ - sync_enabled?: boolean; -} - -/** The origin fields of {@link CreateReservationData}, which only a server-side import may set. */ -type ReservationOrigin = Pick; - -/** - * A create body from a client without the origin fields. The REST and plugin - * bodies are open objects, and an origin a caller could name would let it pose - * as an AirTrail link or an import, so only the importers set one. - */ -export function withoutOrigin(body: Record): Record { - const { external_source: _source, external_id: _id, sync_enabled: _sync, ...rest } = body; - return rest; -} - -/** The origin columns an insert names, none for a booking without an origin. */ -function originColumns(data: ReservationOrigin): { external_source?: string; external_id?: string; sync_enabled?: number } { - if (!data.external_source || !data.external_id) return {}; - return { - external_source: data.external_source, - external_id: data.external_id, - ...(data.sync_enabled !== undefined && { sync_enabled: data.sync_enabled ? 1 : 0 }), - }; -} - -export interface UpdateReservationData { - title?: string; - reservation_time?: string; - reservation_end_time?: string; - location?: string; - confirmation_number?: string; - notes?: string; - url?: string; - day_id?: number | null; - end_day_id?: number | null; - place_id?: number; - assignment_id?: number; - status?: string; - type?: string; - accommodation_id?: number; - metadata?: unknown; - create_accommodation?: CreateAccommodation; - endpoints?: EndpointInput[]; - needs_review?: boolean; -} - type AccommodationTimesMeta = { check_in_time?: string | null; check_in_end_time?: string | null; diff --git a/server/tests/integration/broadcast-parity/bookings.cases.ts b/server/tests/integration/broadcast-parity/bookings.cases.ts index b024360ce..189a0eaa7 100644 --- a/server/tests/integration/broadcast-parity/bookings.cases.ts +++ b/server/tests/integration/broadcast-parity/bookings.cases.ts @@ -243,6 +243,7 @@ async function mailEntryFor(s: Scene, app: INestApplication, added: boolean): Pr const trip = person ? await trips.editableTrip(person, s.trip.id) : null; if (!trip) throw new Error(`the owner of scene ${s.n} cannot add bookings to its trip`); const apply = app.get(MailIngestApplyService); + // test-sql-allow: MailIngestApplyService.prepare builds the booking to write, it is no SQL statement. const prepared = await apply.prepare(item, trip, s.owner.id, []); const written = await app.get(UnitOfWork).transactional(() => apply.writeInTx(prepared)); return em.getRepository(MailIngestCandidates).insertCandidate({ diff --git a/server/tests/unit/nest/reservations.service.test.ts b/server/tests/unit/nest/reservations.service.test.ts index d49c8f561..af6c62379 100644 --- a/server/tests/unit/nest/reservations.service.test.ts +++ b/server/tests/unit/nest/reservations.service.test.ts @@ -33,7 +33,8 @@ import { HttpException } from '@nestjs/common'; import { resetTestDb } from '../../helpers/test-db'; import { createUser, createTrip, createReservation, createBudgetItem, createPlace, createDay, createDayAccommodation, createDayAssignment, addTripMember } from '../../helpers/factories'; import type { PermissionsService } from '../../../src/nest/permissions/permissions.service'; -import { ReservationsService, withoutOrigin, type UpdateReservationData } from '../../../src/nest/reservations/reservations.service'; +import { withoutOrigin } from '../../../src/nest/reservations/reservation-origin'; +import { ReservationsService, type UpdateReservationData } from '../../../src/nest/reservations/reservations.service'; import { ReservationsReadService } from '../../../src/nest/reservations/reservations-read.service'; import type { BudgetService } from '../../../src/nest/budget/budget.service'; // Was reservations.bridge, deleted along with the other three that had no