From 0574ceddb0c005a471c3be9c8a58b851fdcba2c5 Mon Sep 17 00:00:00 2001 From: jtricerolph Date: Tue, 1 Sep 2026 17:37:01 +0000 Subject: [PATCH] Seed tablet-checkin app + push/admin/settings capabilities Co-Authored-By: Claude Sonnet 5 --- src/db.js | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/db.js b/src/db.js index 00a679b..f0aa241 100644 --- a/src/db.js +++ b/src/db.js @@ -575,6 +575,43 @@ export async function initDb() { sort_order = EXCLUDED.sort_order `) + // Seed tablet-checkin app + capabilities. LXC 132 — staff-push guest + // check-in tablet (contact details, car reg, marketing opt-in, T&Cs + + // signature). No default Staff grants — writes guest PII to NewBook and + // holds signed regcards, access is admin-assigned per role via the portal + // (same convention as hvac/plant/wages/utilities). 'push' also covers the + // standalone Chrome extension's manual-test surface inside this app's own + // Devices page — the extension's real push call authenticates via a + // terminal API key, not this capability (see project_checkin memory). + await pool.query(` + INSERT INTO apps (slug, name, description, base_path, icon, theme_color, category, internal_host, internal_port) + VALUES ('tablet-checkin', 'Tablet Check-In', 'Staff-push guest check-in tablet — contact details, car reg, marketing opt-in, T&Cs and signature capture', '/tablet-checkin', 'UserCheck', '#be123c', 'Hotel', '10.10.10.132', 3080) + ON CONFLICT (slug) DO UPDATE SET + name = EXCLUDED.name, + description = EXCLUDED.description, + base_path = EXCLUDED.base_path, + icon = EXCLUDED.icon, + theme_color = EXCLUDED.theme_color, + category = EXCLUDED.category, + internal_host = EXCLUDED.internal_host, + internal_port = EXCLUDED.internal_port + `) + + await pool.query(` + INSERT INTO app_capabilities (app_id, slug, name, description, sort_order) + SELECT a.id, c.slug, c.name, c.description, c.sort_order + FROM apps a, (VALUES + ('push', 'Push to Tablet', 'Push a booking to a check-in tablet (staff push trigger + manual test-push)', 1), + ('admin', 'Admin', 'View check-in audit history, manage devices, terminals and marketing config', 2), + ('settings', 'Settings', 'Configure tablet-checkin app settings', 3) + ) AS c(slug, name, description, sort_order) + WHERE a.slug = 'tablet-checkin' + ON CONFLICT (app_id, slug) DO UPDATE SET + name = EXCLUDED.name, + description = EXCLUDED.description, + sort_order = EXCLUDED.sort_order + `) + // Seed first admin user if table is empty const { rows } = await pool.query('SELECT COUNT(*) FROM users') if (parseInt(rows[0].count) === 0) {