From d5bb6ffa61db5f7edafb741e187a34a18169b38a Mon Sep 17 00:00:00 2001 From: dswbx Date: Thu, 12 Jun 2025 10:24:50 +0200 Subject: [PATCH] fix adapters, handle entity enum more gracefully --- app/e2e/adapters.ts | 6 +++++- app/package.json | 6 +++--- app/playwright.config.ts | 3 ++- app/src/adapter/cloudflare/config.ts | 2 +- app/src/modules/Controller.ts | 3 ++- 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/app/e2e/adapters.ts b/app/e2e/adapters.ts index fd64442..9ca8154 100644 --- a/app/e2e/adapters.ts +++ b/app/e2e/adapters.ts @@ -142,6 +142,7 @@ const adapters = { }, nextjs: { dir: path.join(basePath, "examples/nextjs"), + env: "TEST_TIMEOUT=20000", clean: async function () { const cwd = path.relative(process.cwd(), this.dir); await $`cd ${cwd} && rm -rf .nextjs data.db`; @@ -195,7 +196,8 @@ async function testAdapter(name: keyof typeof adapters) { console.log("proc:", proc.pid, "data:", c.cyan(data)); //proc.kill();process.exit(0); - await $`TEST_URL=${data} TEST_ADAPTER=${name} bun run test:e2e`; + const add_env = "env" in config && config.env ? config.env : ""; + await $`TEST_URL=${data} TEST_ADAPTER=${name} ${add_env} bun run test:e2e`; console.log("DONE!"); while (!proc.killed) { @@ -205,6 +207,8 @@ async function testAdapter(name: keyof typeof adapters) { } } +// run with: TEST_ADAPTER=astro bun run e2e/adapters.ts +// (modify `test:e2e` to `test:e2e:ui` to see the UI) if (process.env.TEST_ADAPTER) { await testAdapter(process.env.TEST_ADAPTER as any); } else { diff --git a/app/package.json b/app/package.json index fc458c8..9ca0d89 100644 --- a/app/package.json +++ b/app/package.json @@ -3,7 +3,7 @@ "type": "module", "sideEffects": false, "bin": "./dist/cli/index.js", - "version": "0.14.0-rc.2", + "version": "0.14.0", "description": "Lightweight Firebase/Supabase alternative built to run anywhere — incl. Next.js, React Router, Astro, Cloudflare, Bun, Node, AWS Lambda & more.", "homepage": "https://bknd.io", "repository": { @@ -70,8 +70,7 @@ "oauth4webapi": "^2.11.1", "object-path-immutable": "^4.1.2", "radix-ui": "^1.1.3", - "swr": "^2.3.3", - "uuid": "^11.1.0" + "swr": "^2.3.3" }, "devDependencies": { "@aws-sdk/client-s3": "^3.758.0", @@ -121,6 +120,7 @@ "tsc-alias": "^1.8.11", "tsup": "^8.4.0", "tsx": "^4.19.3", + "uuid": "^11.1.0", "vite": "^6.3.5", "vite-tsconfig-paths": "^5.1.4", "vitest": "^3.0.9", diff --git a/app/playwright.config.ts b/app/playwright.config.ts index 7f4f9d1..9a53d62 100644 --- a/app/playwright.config.ts +++ b/app/playwright.config.ts @@ -3,6 +3,7 @@ import { defineConfig, devices } from "@playwright/test"; const baseUrl = process.env.TEST_URL || "http://localhost:28623"; const startCommand = process.env.TEST_START_COMMAND || "bun run dev"; const autoStart = ["1", "true", undefined].includes(process.env.TEST_AUTO_START); +const timeout = process.env.TEST_TIMEOUT ? Number.parseInt(process.env.TEST_TIMEOUT) : 5000; export default defineConfig({ testMatch: "**/*.e2e-spec.ts", @@ -12,7 +13,7 @@ export default defineConfig({ retries: process.env.CI ? 2 : 0, workers: process.env.CI ? 1 : undefined, reporter: "html", - timeout: 20000, + timeout, use: { baseURL: baseUrl, trace: "on-first-retry", diff --git a/app/src/adapter/cloudflare/config.ts b/app/src/adapter/cloudflare/config.ts index d6e75b1..a37cfa3 100644 --- a/app/src/adapter/cloudflare/config.ts +++ b/app/src/adapter/cloudflare/config.ts @@ -92,7 +92,7 @@ export function makeConfig( args?: CfMakeConfigArgs, ) { if (!media_registered) { - registerMedia(args as any); + registerMedia(args?.env as any); media_registered = true; } diff --git a/app/src/modules/Controller.ts b/app/src/modules/Controller.ts index 610337d..ee54fed 100644 --- a/app/src/modules/Controller.ts +++ b/app/src/modules/Controller.ts @@ -51,6 +51,7 @@ export class Controller { protected getEntitiesEnum(em: EntityManager) { const entities = em.entities.map((e) => e.name); - return entities.length > 0 ? s.string({ enum: entities }) : s.string(); + // @todo: current workaround to allow strings (sometimes building is not fast enough to get the entities) + return entities.length > 0 ? s.anyOf([s.string({ enum: entities }), s.string()]) : s.string(); } }