diff --git a/app/package.json b/app/package.json index 6aa8dfd..f087b57 100644 --- a/app/package.json +++ b/app/package.json @@ -3,7 +3,7 @@ "type": "module", "sideEffects": false, "bin": "./dist/cli/index.js", - "version": "0.18.0-rc.5", + "version": "0.18.0-rc.6", "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": { diff --git a/app/src/cli/commands/run/platform.ts b/app/src/cli/commands/run/platform.ts index 479d6cd..c4c2d69 100644 --- a/app/src/cli/commands/run/platform.ts +++ b/app/src/cli/commands/run/platform.ts @@ -17,7 +17,7 @@ export async function serveStatic(server: Platform): Promise case "node": { const m = await import("@hono/node-server/serve-static"); const root = getRelativeDistPath() + "/static"; - $console.log("Serving static files from", root); + $console.debug("Serving static files from", root); return m.serveStatic({ // somehow different for node root, @@ -27,7 +27,7 @@ export async function serveStatic(server: Platform): Promise case "bun": { const m = await import("hono/bun"); const root = path.resolve(getRelativeDistPath(), "static"); - $console.log("Serving static files from", root); + $console.debug("Serving static files from", root); return m.serveStatic({ root, onNotFound, diff --git a/app/src/data/entities/EntityTypescript.spec.ts b/app/src/data/entities/EntityTypescript.spec.ts new file mode 100644 index 0000000..561e950 --- /dev/null +++ b/app/src/data/entities/EntityTypescript.spec.ts @@ -0,0 +1,25 @@ +import { describe, it, expect } from "bun:test"; +import { EntityTypescript } from "./EntityTypescript"; +import * as proto from "../prototype"; +import { getDummyConnection } from "../../../__test__/data/helper"; + +describe("EntityTypescript", () => { + it("should generate correct typescript for system entities", () => { + const schema = proto.em( + { + test: proto.entity("test", { + name: proto.text(), + }), + users: proto.systemEntity("users", { + name: proto.text(), + }), + }, + ({ relation }, { test, users }) => { + relation(test).manyToOne(users); + }, + ); + const { dummyConnection } = getDummyConnection(); + const et = new EntityTypescript(schema.proto.withConnection(dummyConnection)); + expect(et.toString()).toContain('users?: DB["users"];'); + }); +}); diff --git a/app/src/data/entities/EntityTypescript.ts b/app/src/data/entities/EntityTypescript.ts index 6278a83..36d571b 100644 --- a/app/src/data/entities/EntityTypescript.ts +++ b/app/src/data/entities/EntityTypescript.ts @@ -40,7 +40,7 @@ const systemEntities = { export class EntityTypescript { constructor( - protected em: EntityManager, + protected em: EntityManager, protected _options: EntityTypescriptOptions = {}, ) {} diff --git a/app/src/data/prototype/index.ts b/app/src/data/prototype/index.ts index 06483f5..43df6a1 100644 --- a/app/src/data/prototype/index.ts +++ b/app/src/data/prototype/index.ts @@ -210,8 +210,8 @@ type SystemEntities = { export function systemEntity< E extends keyof SystemEntities, Fields extends Record>, ->(name: E, fields: Fields) { - return entity(name, fields as any); +>(name: E, fields: Fields, config?: EntityConfig) { + return entity(name, fields as any, config, "system"); } export function relation(local: Local) {