a9ccf9e20c
Car Wash — the pilot venue module (wiki/decisions/venue-modules.md): - Master data (categories × services price matrix) at /setup/carwash; the desk at /wash (ticket lookup → order; open queue oldest-first: Done / Paid cash / Paid card / Void; Finished list). Orders freeze names + price; their life is signed (carwash_order, carwash_payment). Migration 0027. - Where money is taken is a SITE setting (carwash_config.pay_at, migration 0028, signed config_change on a flip) — no per-order radio; a stale client is refused (409). - Core seams: PayStation charge providers (a booth-paid wash rides the parking payment as chargeLines) + applyValidation() shared with the merchant route. A bay-paid, done wash signs the $0 parking payment so the exit reader releases the car. - "Parking discount" modes for the wash: free while the wash runs (+ tolerance) and wash price off the fee (floored at 0), resolved at done and anchored at the order's intake (the entry-anchored version comped a 74-day stay); typed-amount and percent hidden for the wash. Long durations render y/d/h/m. Tills — a shift belongs to a till, not the site (wiki/concepts/shift.md §Tills): - TillId booth|carwash; every money event names its till (absent = booth, so the chain re-folds identically). ShiftService is per till: single-open, folds, X/Z-reports, vouchers, carry-forward. A bay payment needs the carwash shift. - Working a till needs that till's module permission (manifest tillPermission; 403 till_forbidden); /api/shift/tills lists only the role's tills. - Web: ShiftButton per till (header = booth, wash desk = carwash); shift hub lists every open shift with till badges + filter; drawer hub switches tills. Modules: landing per module (index route resolves booth → module landing → shifts → profile); guards bounce to "/", /booth needs session:read. Tests: carwash e2e suite (settings, intake, booth/bay paths, modes, void, gate, pay-at policy, till permissions), 6 per-till shift tests; suite green (1 pre-existing flaky backup test under the parallel run). Claude-Session: https://claude.ai/code/session_01FWncR69HgGPuei1dLrW3cU
62 lines
2.7 KiB
TypeScript
62 lines
2.7 KiB
TypeScript
import type { FastifyInstance } from "fastify";
|
|
import type { Db } from "@parking/db";
|
|
import { MODULES, parseEntitledModules, type ModuleId } from "@parking/shared";
|
|
import type { EventLog } from "../event-log.js";
|
|
import type { PayStation } from "../pay-station.js";
|
|
import type { ShiftService } from "../shift-service.js";
|
|
import { effectiveModulesFor } from "../modules.js";
|
|
import { carwashModule } from "./carwash/index.js";
|
|
import { validationModule } from "./validation/index.js";
|
|
|
|
// The server-side module registry. A module's routes live in its own folder
|
|
// (apps/server/src/modules/<id>/index.ts) and are registered by iterating
|
|
// @parking/shared's MODULES — so adding a module is one manifest entry + one folder +
|
|
// one line in SERVER_MODULES below, with nothing else in the core touched
|
|
// (wiki/decisions/venue-modules.md, "A module = a manifest + three folders").
|
|
//
|
|
// `parking` is registered in the manifest but has NO folder yet: its routes are still
|
|
// the flat list in server.ts. That is deliberate — the seam is drawn, the code moves
|
|
// across it subsystem by subsystem as each is touched, not in one big move.
|
|
|
|
/** What the core hands a module at registration. Modules reach the core ONLY through
|
|
* these (never by importing another module): the DB, the signed ledger, the booth
|
|
* settlement (to fold charges in / settle a session — PayStation.registerChargeProvider,
|
|
* quote, pay) and the shift service (money needs an open shift). */
|
|
export interface ServerModuleDeps {
|
|
db: Db;
|
|
eventLog: EventLog;
|
|
payStation: PayStation;
|
|
shiftService: ShiftService;
|
|
}
|
|
|
|
export interface ServerModule {
|
|
id: ModuleId;
|
|
register(app: FastifyInstance, deps: ServerModuleDeps): Promise<void>;
|
|
}
|
|
|
|
const SERVER_MODULES: Partial<Record<ModuleId, ServerModule>> = {
|
|
validation: validationModule,
|
|
carwash: carwashModule,
|
|
};
|
|
|
|
/** Register every folder-based module in registry order, then log what this site
|
|
* is entitled to / has effective, so a "why is X missing" question is answerable
|
|
* from the container log alone. */
|
|
export async function registerModules(app: FastifyInstance, deps: ServerModuleDeps): Promise<void> {
|
|
for (const manifest of MODULES) {
|
|
const impl = SERVER_MODULES[manifest.id];
|
|
if (impl) {
|
|
if (impl.id !== manifest.id) throw new Error(`module registry mismatch: ${impl.id} registered under ${manifest.id}`);
|
|
await impl.register(app, deps);
|
|
}
|
|
}
|
|
const { entitled, unknown } = parseEntitledModules(process.env.MODULES_ENTITLED);
|
|
if (unknown.length > 0) {
|
|
app.log.warn({ unknown }, "MODULES_ENTITLED names unknown module ids — ignored");
|
|
}
|
|
app.log.info(
|
|
{ entitled, effective: effectiveModulesFor(deps.db) },
|
|
"venue modules (entitled = MODULES_ENTITLED env; effective = entitled ∩ site activation)",
|
|
);
|
|
}
|