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",
|
"type": "module",
|
||||||
"sideEffects": false,
|
"sideEffects": false,
|
||||||
"bin": "./dist/cli/index.js",
|
"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.",
|
"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",
|
"homepage": "https://bknd.io",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ export async function serveStatic(server: Platform): Promise<MiddlewareHandler>
|
|||||||
case "node": {
|
case "node": {
|
||||||
const m = await import("@hono/node-server/serve-static");
|
const m = await import("@hono/node-server/serve-static");
|
||||||
const root = getRelativeDistPath() + "/static";
|
const root = getRelativeDistPath() + "/static";
|
||||||
$console.log("Serving static files from", root);
|
$console.debug("Serving static files from", root);
|
||||||
return m.serveStatic({
|
return m.serveStatic({
|
||||||
// somehow different for node
|
// somehow different for node
|
||||||
root,
|
root,
|
||||||
@@ -27,7 +27,7 @@ export async function serveStatic(server: Platform): Promise<MiddlewareHandler>
|
|||||||
case "bun": {
|
case "bun": {
|
||||||
const m = await import("hono/bun");
|
const m = await import("hono/bun");
|
||||||
const root = path.resolve(getRelativeDistPath(), "static");
|
const root = path.resolve(getRelativeDistPath(), "static");
|
||||||
$console.log("Serving static files from", root);
|
$console.debug("Serving static files from", root);
|
||||||
return m.serveStatic({
|
return m.serveStatic({
|
||||||
root,
|
root,
|
||||||
onNotFound,
|
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 {
|
export class EntityTypescript {
|
||||||
constructor(
|
constructor(
|
||||||
protected em: EntityManager,
|
protected em: EntityManager<any>,
|
||||||
protected _options: EntityTypescriptOptions = {},
|
protected _options: EntityTypescriptOptions = {},
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
|
|||||||
@@ -210,8 +210,8 @@ type SystemEntities = {
|
|||||||
export function systemEntity<
|
export function systemEntity<
|
||||||
E extends keyof SystemEntities,
|
E extends keyof SystemEntities,
|
||||||
Fields extends Record<string, Field<any, any, any>>,
|
Fields extends Record<string, Field<any, any, any>>,
|
||||||
>(name: E, fields: Fields) {
|
>(name: E, fields: Fields, config?: EntityConfig) {
|
||||||
return entity<E, SystemEntities[E] & Fields>(name, fields as any);
|
return entity<E, SystemEntities[E] & Fields>(name, fields as any, config, "system");
|
||||||
}
|
}
|
||||||
|
|
||||||
export function relation<Local extends Entity>(local: Local) {
|
export function relation<Local extends Entity>(local: Local) {
|
||||||
|
|||||||
Reference in New Issue
Block a user