From a0b2dde0342e537790808f095231e9bbe866a7ef Mon Sep 17 00:00:00 2001 From: dswbx Date: Tue, 16 Sep 2025 16:04:09 +0200 Subject: [PATCH] fix: improve asset handling, logging, and ui conditions Refactored asset handling to support multiple CSS entries and fixed context handling in authenticator when executed through mcp. Adjusted UI readonly conditions. --- app/build.ts | 2 ++ app/src/App.ts | 3 --- app/src/auth/authenticate/Authenticator.ts | 9 ++++++--- app/src/modules/server/AdminController.tsx | 15 ++++++++++----- app/src/ui/routes/auth/auth.roles.edit.$role.tsx | 10 +++++----- app/src/ui/routes/data/data.$entity.index.tsx | 2 -- 6 files changed, 23 insertions(+), 18 deletions(-) diff --git a/app/build.ts b/app/build.ts index 66db700..e60e0e3 100644 --- a/app/build.ts +++ b/app/build.ts @@ -252,6 +252,8 @@ async function buildAdapters() { platform: "neutral", entry: ["src/adapter/index.ts"], outDir: "dist/adapter", + // only way to keep @vite-ignore comments + minify: false, }), // specific adatpers diff --git a/app/src/App.ts b/app/src/App.ts index 4712c55..ea88f42 100644 --- a/app/src/App.ts +++ b/app/src/App.ts @@ -98,9 +98,6 @@ export type AppOptions = { readonly?: boolean; }; export type CreateAppConfig = { - /** - * bla - */ connection?: Connection | { url: string }; config?: InitialModuleConfigs; options?: AppOptions; diff --git a/app/src/auth/authenticate/Authenticator.ts b/app/src/auth/authenticate/Authenticator.ts index 0350aba..52a2e42 100644 --- a/app/src/auth/authenticate/Authenticator.ts +++ b/app/src/auth/authenticate/Authenticator.ts @@ -278,7 +278,9 @@ export class Authenticator< } return payload as any; - } catch (e) {} + } catch (e) { + $console.debug("Authenticator jwt verify error", String(e)); + } return; } @@ -396,8 +398,9 @@ export class Authenticator< if (headers.has("Authorization")) { const bearerHeader = String(headers.get("Authorization")); token = bearerHeader.replace("Bearer ", ""); - } else if (is_context) { - token = await this.getAuthCookie(c as Context); + } else { + const context = is_context ? (c as Context) : ({ req: { raw: { headers } } } as Context); + token = await this.getAuthCookie(context); } if (token) { diff --git a/app/src/modules/server/AdminController.tsx b/app/src/modules/server/AdminController.tsx index a68519d..2800781 100644 --- a/app/src/modules/server/AdminController.tsx +++ b/app/src/modules/server/AdminController.tsx @@ -192,7 +192,7 @@ export class AdminController extends Controller { const assets = { js: "main.js", - css: "styles.css", + css: ["styles.css"], }; if (isProd) { @@ -213,9 +213,12 @@ export class AdminController extends Controller { } try { - // @todo: load all marked as entry (incl. css) - assets.js = manifest["src/ui/main.tsx"]?.file!; - assets.css = manifest["src/ui/main.tsx"]?.css?.[0] as any; + const entry = Object.values(manifest).find((m) => m.isEntry); + if (!entry) { + throw new Error("No entry found in manifest"); + } + assets.js = entry?.file; + assets.css = entry?.css ?? []; } catch (e) { $console.warn("Couldn't find assets in manifest", e); } @@ -245,7 +248,9 @@ export class AdminController extends Controller { {isProd ? (