From d58792524d89f53491540811b2886d3d547a24bc Mon Sep 17 00:00:00 2001 From: Mitchell R Date: Wed, 27 May 2026 03:57:42 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20auto-create=20setup=5Fstate=20if=20missi?= =?UTF-8?q?ng=20+=20map=20ablesign=E2=86=92web=20in=20bundle?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - getSetupState: INSERT if row missing instead of throwing. Handles manual DELETE or fresh tenant schema. - Bundle generation: ablesign entities map to content_type='web' with web_url from entity. Kiosk renders as WebView — no kiosk update needed. Co-Authored-By: Claude Opus 4.6 (1M context) --- server/src/shared/bundle.ts | 3 ++- server/src/shared/db/repository.ts | 10 ++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/server/src/shared/bundle.ts b/server/src/shared/bundle.ts index cb6bd7c..0b9c3d9 100644 --- a/server/src/shared/bundle.ts +++ b/server/src/shared/bundle.ts @@ -229,10 +229,11 @@ export async function generateBundle( // Dashboard entities are surfaced to the kiosk as `web` cells // pointing at /dash/ — kiosk WebKit handles them // identically to user-supplied web cells. - contentType = ent.type === "dashboard" ? "web" : ent.type; + contentType = (ent.type === "dashboard" || ent.type === "ablesign") ? "web" : ent.type; cameraId = ent.type === "camera" ? ent.camera_id : null; webUrl = ent.type === "web" ? ent.web_url : + ent.type === "ablesign" ? ent.web_url : ent.type === "dashboard" && ent.dashboard_id ? `/dash/${ent.dashboard_id}` : null; htmlContent = ent.type === "html" ? ent.html_content : null; diff --git a/server/src/shared/db/repository.ts b/server/src/shared/db/repository.ts index 97436b9..8f377c7 100644 --- a/server/src/shared/db/repository.ts +++ b/server/src/shared/db/repository.ts @@ -254,8 +254,14 @@ export class Repository { // =========================================================================== async getSetupState(): Promise { - const r = await this._get("SELECT * FROM setup_state WHERE id = 1"); - if (!r) throw new Error("setup_state row missing"); + let r = await this._get("SELECT * FROM setup_state WHERE id = 1"); + if (!r) { + await this._run( + "INSERT INTO setup_state (id, is_complete, extras) VALUES (1, false, '{}') ON CONFLICT (id) DO NOTHING", + ); + r = await this._get("SELECT * FROM setup_state WHERE id = 1"); + if (!r) throw new Error("setup_state row could not be created"); + } return rowToSetupState(r as Record); }