feat(F-163): completed feature

This commit is contained in:
chattie
2026-08-22 18:33:24 +02:00
parent 08af6caf50
commit 5d90dd32de
19 changed files with 403 additions and 37 deletions

View File

@@ -23,6 +23,9 @@ export interface PosRouteDeps {
}
const idParamSchema = z.object({ id: z.string().uuid() });
// Zod's strict UUID parser rejects the RFC nil UUID used by the seeded default
// store. Store references accept the canonical UUID shape, including nil.
const storeIdSchema = z.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i);
export async function registerPosRoutes(app: FastifyInstance, deps: PosRouteDeps) {
const { pool, authenticate } = deps;
@@ -174,7 +177,7 @@ export async function registerPosRoutes(app: FastifyInstance, deps: PosRouteDeps
const user = await authenticate(request);
requireRole(user, 'admin');
const body = parseJson(
z.object({ storeId: z.string().uuid(), name: z.string().min(1).max(100) }),
z.object({ storeId: storeIdSchema, name: z.string().min(1).max(100) }),
request.body ?? {},
);
// Generate a short binding code (8 hex chars)

View File

@@ -3,12 +3,14 @@ import type { PosPaymentMethodRepository } from '../infrastructure/pg-payment-me
import type { PosStore } from '../domain/store.js';
import type { PosTerminal } from '../domain/terminal.js';
import type { PosPaymentMethod } from '../infrastructure/pg-payment-method-repository.js';
import type { PosCashSession } from '../domain/cash-session.js';
export interface PosConfig {
store: PosStore;
terminal: PosTerminal;
paymentMethods: PosPaymentMethod[];
sessionOpen: boolean;
session: PosCashSession | null;
}
export class GetPosConfigUseCase {
@@ -29,6 +31,6 @@ export class GetPosConfigUseCase {
this.sessionRepo.findOpenByTerminal(terminalId),
]);
await this.terminalRepo.updateLastSeen(terminalId);
return { store, terminal, paymentMethods, sessionOpen: !!openSession };
return { store, terminal, paymentMethods, sessionOpen: !!openSession, session: openSession ?? null };
}
}