mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-16 04:27:21 +00:00
chore: bump version to 0.18.0-rc.6 and fix EntityTypescript for system entities
This commit is contained in:
@@ -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": {
|
||||
|
||||
@@ -17,7 +17,7 @@ export async function serveStatic(server: Platform): Promise<MiddlewareHandler>
|
||||
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<MiddlewareHandler>
|
||||
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,
|
||||
|
||||
25
app/src/data/entities/EntityTypescript.spec.ts
Normal file
25
app/src/data/entities/EntityTypescript.spec.ts
Normal file
@@ -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"];');
|
||||
});
|
||||
});
|
||||
@@ -40,7 +40,7 @@ const systemEntities = {
|
||||
|
||||
export class EntityTypescript {
|
||||
constructor(
|
||||
protected em: EntityManager,
|
||||
protected em: EntityManager<any>,
|
||||
protected _options: EntityTypescriptOptions = {},
|
||||
) {}
|
||||
|
||||
|
||||
@@ -210,8 +210,8 @@ type SystemEntities = {
|
||||
export function systemEntity<
|
||||
E extends keyof SystemEntities,
|
||||
Fields extends Record<string, Field<any, any, any>>,
|
||||
>(name: E, fields: Fields) {
|
||||
return entity<E, SystemEntities[E] & Fields>(name, fields as any);
|
||||
>(name: E, fields: Fields, config?: EntityConfig) {
|
||||
return entity<E, SystemEntities[E] & Fields>(name, fields as any, config, "system");
|
||||
}
|
||||
|
||||
export function relation<Local extends Entity>(local: Local) {
|
||||
|
||||
Reference in New Issue
Block a user