mirror of
https://github.com/bknd-io/bknd/
synced 2026-08-02 16:16:02 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7e25d54847 |
@@ -20,7 +20,7 @@ jobs:
|
||||
- name: Setup Bun
|
||||
uses: oven-sh/setup-bun@v1
|
||||
with:
|
||||
bun-version: "1.2.19"
|
||||
bun-version: "1.2.14"
|
||||
|
||||
- name: Install dependencies
|
||||
working-directory: ./app
|
||||
|
||||
@@ -1,2 +1 @@
|
||||
tmp/*
|
||||
!tmp/.gitkeep
|
||||
tmp/*
|
||||
@@ -1,12 +1,12 @@
|
||||
import { afterAll, beforeAll, describe, expect, it } from "bun:test";
|
||||
import { Guard } from "../../src/auth/authorize/Guard";
|
||||
import { Guard } from "../../src/auth";
|
||||
import { DataApi } from "../../src/data/api/DataApi";
|
||||
import { DataController } from "../../src/data/api/DataController";
|
||||
import { dataConfigSchema } from "../../src/data/data-schema";
|
||||
import * as proto from "../../src/data/prototype";
|
||||
import { schemaToEm } from "../helper";
|
||||
import { disableConsoleLog, enableConsoleLog } from "core/utils/test";
|
||||
import { parse } from "core/utils/schema";
|
||||
import { parse } from "bknd/core";
|
||||
|
||||
beforeAll(disableConsoleLog);
|
||||
afterAll(enableConsoleLog);
|
||||
@@ -202,7 +202,7 @@ describe("DataApi", () => {
|
||||
{
|
||||
// create many
|
||||
const res = await api.createMany("posts", payload);
|
||||
expect(res.data?.length).toEqual(4);
|
||||
expect(res.data.length).toEqual(4);
|
||||
expect(res.ok).toBeTrue();
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ describe("AppServer", () => {
|
||||
expect(server).toBeDefined();
|
||||
expect(server.config).toEqual({
|
||||
cors: {
|
||||
allow_credentials: true,
|
||||
origin: "*",
|
||||
allow_methods: ["GET", "POST", "PATCH", "PUT", "DELETE"],
|
||||
allow_headers: ["Content-Type", "Content-Length", "Authorization", "Accept"],
|
||||
@@ -26,7 +25,6 @@ describe("AppServer", () => {
|
||||
expect(server).toBeDefined();
|
||||
expect(server.config).toEqual({
|
||||
cors: {
|
||||
allow_credentials: true,
|
||||
origin: "https",
|
||||
allow_methods: ["GET", "POST"],
|
||||
allow_headers: ["Content-Type", "Content-Length", "Authorization", "Accept"],
|
||||
|
||||
@@ -1,3 +1,45 @@
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { Authenticator, type User, type UserPool } from "../../src/auth";
|
||||
import { cookieConfig } from "../../src/auth/authenticate/Authenticator";
|
||||
import { PasswordStrategy } from "../../src/auth/authenticate/strategies/PasswordStrategy";
|
||||
import { parse } from "bknd/core";
|
||||
|
||||
describe("Authenticator", async () => {});
|
||||
/*class MemoryUserPool implements UserPool {
|
||||
constructor(private users: User[] = []) {}
|
||||
|
||||
async findBy(prop: "id" | "email" | "username", value: string | number) {
|
||||
return this.users.find((user) => user[prop] === value);
|
||||
}
|
||||
|
||||
async create(user: Pick<User, "email" | "password">) {
|
||||
const id = this.users.length + 1;
|
||||
const newUser = { ...user, id, username: user.email };
|
||||
this.users.push(newUser);
|
||||
return newUser;
|
||||
}
|
||||
}*/
|
||||
|
||||
describe("Authenticator", async () => {
|
||||
test("cookie options", async () => {
|
||||
console.log("parsed", parse(cookieConfig, undefined));
|
||||
console.log(cookieConfig.template({}));
|
||||
});
|
||||
/*const userpool = new MemoryUserPool([
|
||||
{ id: 1, email: "d", username: "test", password: await hash.sha256("test") },
|
||||
]);
|
||||
|
||||
test("sha256 login", async () => {
|
||||
const auth = new Authenticator(userpool, {
|
||||
password: new PasswordStrategy({
|
||||
hashing: "sha256",
|
||||
}),
|
||||
});
|
||||
|
||||
const { token } = await auth.login("password", { email: "d", password: "test" });
|
||||
expect(token).toBeDefined();
|
||||
|
||||
const { iat, ...decoded } = decodeJwt<any>(token);
|
||||
expect(decoded).toEqual({ id: 1, email: "d", username: "test" });
|
||||
expect(await auth.verify(token)).toBe(true);
|
||||
});*/
|
||||
});
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { Guard } from "../../../src/auth/authorize/Guard";
|
||||
import { Guard } from "../../../src/auth";
|
||||
|
||||
describe("authorize", () => {
|
||||
test("basic", async () => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { Registry } from "core/registry/Registry";
|
||||
import { s } from "core/utils/schema";
|
||||
import { Registry } from "core";
|
||||
import { s } from "bknd/core";
|
||||
|
||||
type Constructor<T> = new (...args: any[]) => T;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { s } from "core/utils/schema";
|
||||
import { SchemaObject } from "core/object/SchemaObject";
|
||||
import { SchemaObject } from "../../../src/core";
|
||||
import { s } from "bknd/core";
|
||||
|
||||
describe("SchemaObject", async () => {
|
||||
test("basic", async () => {
|
||||
|
||||
@@ -1,16 +1,19 @@
|
||||
import { afterAll, beforeAll, describe, expect, test } from "bun:test";
|
||||
|
||||
import { Guard } from "../../src/auth/authorize/Guard";
|
||||
import { parse } from "core/utils/schema";
|
||||
|
||||
import { Guard } from "../../src/auth";
|
||||
import { parse } from "bknd/core";
|
||||
import {
|
||||
Entity,
|
||||
type EntityData,
|
||||
EntityManager,
|
||||
ManyToOneRelation,
|
||||
TextField,
|
||||
} from "../../src/data";
|
||||
import { DataController } from "../../src/data/api/DataController";
|
||||
import { dataConfigSchema } from "../../src/data/data-schema";
|
||||
import { disableConsoleLog, enableConsoleLog, getDummyConnection } from "../helper";
|
||||
import type { RepositoryResultJSON } from "data/entities/query/RepositoryResult";
|
||||
import type { MutatorResultJSON } from "data/entities/mutation/MutatorResult";
|
||||
import { Entity, EntityManager, type EntityData } from "data/entities";
|
||||
import { TextField } from "data/fields";
|
||||
import { ManyToOneRelation } from "data/relations";
|
||||
|
||||
const { dummyConnection, afterAllCleanup } = getDummyConnection();
|
||||
beforeAll(() => disableConsoleLog(["log", "warn"]));
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
import { afterAll, describe, expect, test } from "bun:test";
|
||||
import { Entity, EntityManager } from "data/entities";
|
||||
import { TextField, PrimaryField, NumberField } from "data/fields";
|
||||
import {
|
||||
Entity,
|
||||
EntityManager,
|
||||
NumberField,
|
||||
PrimaryField,
|
||||
Repository,
|
||||
TextField,
|
||||
} from "../../src/data";
|
||||
import { getDummyConnection } from "./helper";
|
||||
|
||||
const { dummyConnection, afterAllCleanup } = getDummyConnection();
|
||||
|
||||
@@ -2,7 +2,7 @@ import { unlink } from "node:fs/promises";
|
||||
import type { SqliteDatabase } from "kysely";
|
||||
// @ts-ignore
|
||||
import Database from "libsql";
|
||||
import { SqliteLocalConnection } from "data/connection/sqlite/SqliteLocalConnection";
|
||||
import { SqliteLocalConnection } from "../../src/data";
|
||||
|
||||
export function getDummyDatabase(memory: boolean = true): {
|
||||
dummyDb: SqliteDatabase;
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
// eslint-disable-next-line import/no-unresolved
|
||||
import { afterAll, describe, expect, test } from "bun:test";
|
||||
import { Entity } from "data/entities";
|
||||
import { EntityManager } from "data/entities/EntityManager";
|
||||
import { ManyToOneRelation } from "data/relations";
|
||||
import { NumberField, TextField } from "data/fields";
|
||||
import { SchemaManager } from "data/schema/SchemaManager";
|
||||
import {
|
||||
Entity,
|
||||
EntityManager,
|
||||
ManyToOneRelation,
|
||||
NumberField,
|
||||
SchemaManager,
|
||||
TextField,
|
||||
} from "../../src/data";
|
||||
import { getDummyConnection } from "./helper";
|
||||
|
||||
const { dummyConnection, afterAllCleanup } = getDummyConnection();
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
// eslint-disable-next-line import/no-unresolved
|
||||
import { afterAll, describe, expect, test } from "bun:test";
|
||||
import { Entity, EntityManager } from "data/entities";
|
||||
import { NumberField, TextField } from "data/fields";
|
||||
import { TransformPersistFailedException } from "data/errors";
|
||||
import { Entity, EntityManager, Mutator, NumberField, TextField } from "../../src/data";
|
||||
import { TransformPersistFailedException } from "../../src/data/errors";
|
||||
import { getDummyConnection } from "./helper";
|
||||
|
||||
const { dummyConnection, afterAllCleanup } = getDummyConnection();
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import { afterAll, expect as bunExpect, describe, test } from "bun:test";
|
||||
import { stripMark } from "core/utils/schema";
|
||||
import { Entity, EntityManager } from "data/entities";
|
||||
import { TextField } from "data/fields";
|
||||
import { PolymorphicRelation } from "data/relations";
|
||||
import { stripMark } from "bknd/core";
|
||||
import { Entity, EntityManager, PolymorphicRelation, TextField } from "../../src/data";
|
||||
import { getDummyConnection } from "./helper";
|
||||
|
||||
const { dummyConnection, afterAllCleanup } = getDummyConnection();
|
||||
|
||||
@@ -2,20 +2,19 @@ import { describe, expect, test } from "bun:test";
|
||||
import {
|
||||
BooleanField,
|
||||
DateField,
|
||||
Entity,
|
||||
EntityIndex,
|
||||
EntityManager,
|
||||
EnumField,
|
||||
JsonField,
|
||||
NumberField,
|
||||
TextField,
|
||||
EntityIndex,
|
||||
} from "data/fields";
|
||||
import { Entity, EntityManager } from "data/entities";
|
||||
import {
|
||||
ManyToManyRelation,
|
||||
ManyToOneRelation,
|
||||
NumberField,
|
||||
OneToOneRelation,
|
||||
PolymorphicRelation,
|
||||
} from "data/relations";
|
||||
import { DummyConnection } from "data/connection/DummyConnection";
|
||||
TextField,
|
||||
} from "../../src/data";
|
||||
import { DummyConnection } from "../../src/data/connection/DummyConnection";
|
||||
import {
|
||||
FieldPrototype,
|
||||
type FieldSchema,
|
||||
@@ -33,8 +32,8 @@ import {
|
||||
number,
|
||||
relation,
|
||||
text,
|
||||
} from "data/prototype";
|
||||
import { MediaField } from "media/MediaField";
|
||||
} from "../../src/data/prototype";
|
||||
import { MediaField } from "../../src/media/MediaField";
|
||||
|
||||
describe("prototype", () => {
|
||||
test("...", () => {
|
||||
@@ -297,9 +296,9 @@ describe("prototype", () => {
|
||||
new Entity("posts", [new TextField("name"), new TextField("slug", { required: true })]),
|
||||
new Entity("comments", [new TextField("some")]),
|
||||
new Entity("users", [new TextField("email")]),
|
||||
] as const;
|
||||
];
|
||||
const _em2 = new EntityManager(
|
||||
[...es],
|
||||
es,
|
||||
new DummyConnection(),
|
||||
[new ManyToOneRelation(es[0], es[1]), new ManyToOneRelation(es[0], es[2])],
|
||||
[
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
// eslint-disable-next-line import/no-unresolved
|
||||
import { afterAll, describe, expect, test } from "bun:test";
|
||||
import { Entity, EntityManager } from "data/entities";
|
||||
import { TextField } from "data/fields";
|
||||
import { Entity, EntityManager, TextField } from "../../src/data";
|
||||
import {
|
||||
ManyToManyRelation,
|
||||
ManyToOneRelation,
|
||||
OneToOneRelation,
|
||||
PolymorphicRelation,
|
||||
RelationField,
|
||||
} from "data/relations";
|
||||
} from "../../src/data/relations";
|
||||
import { getDummyConnection } from "./helper";
|
||||
|
||||
const { dummyConnection, afterAllCleanup } = getDummyConnection();
|
||||
@@ -78,7 +77,7 @@ describe("Relations", async () => {
|
||||
const em = new EntityManager(entities, dummyConnection, relations);
|
||||
|
||||
// verify naming
|
||||
const rel = em.relations.all[0]!;
|
||||
const rel = em.relations.all[0];
|
||||
expect(rel.source.entity.name).toBe(posts.name);
|
||||
expect(rel.source.reference).toBe(posts.name);
|
||||
expect(rel.target.entity.name).toBe(users.name);
|
||||
@@ -90,11 +89,11 @@ describe("Relations", async () => {
|
||||
// verify low level relation
|
||||
expect(em.relationsOf(users.name).length).toBe(1);
|
||||
expect(em.relationsOf(users.name).length).toBe(1);
|
||||
expect(em.relationsOf(users.name)[0]!.source.entity).toBe(posts);
|
||||
expect(em.relationsOf(users.name)[0].source.entity).toBe(posts);
|
||||
expect(posts.field("author_id")).toBeInstanceOf(RelationField);
|
||||
expect(em.relationsOf(users.name).length).toBe(1);
|
||||
expect(em.relationsOf(users.name).length).toBe(1);
|
||||
expect(em.relationsOf(users.name)[0]!.source.entity).toBe(posts);
|
||||
expect(em.relationsOf(users.name)[0].source.entity).toBe(posts);
|
||||
|
||||
// verify high level relation (from users)
|
||||
const userPostsRel = em.relationOf(users.name, "posts");
|
||||
@@ -192,7 +191,7 @@ describe("Relations", async () => {
|
||||
const em = new EntityManager(entities, dummyConnection, relations);
|
||||
|
||||
// verify naming
|
||||
const rel = em.relations.all[0]!;
|
||||
const rel = em.relations.all[0];
|
||||
expect(rel.source.entity.name).toBe(users.name);
|
||||
expect(rel.source.reference).toBe(users.name);
|
||||
expect(rel.target.entity.name).toBe(settings.name);
|
||||
@@ -203,8 +202,8 @@ describe("Relations", async () => {
|
||||
|
||||
expect(em.relationsOf(users.name).length).toBe(1);
|
||||
expect(em.relationsOf(users.name).length).toBe(1);
|
||||
expect(em.relationsOf(users.name)[0]!.source.entity).toBe(users);
|
||||
expect(em.relationsOf(users.name)[0]!.target.entity).toBe(settings);
|
||||
expect(em.relationsOf(users.name)[0].source.entity).toBe(users);
|
||||
expect(em.relationsOf(users.name)[0].target.entity).toBe(settings);
|
||||
|
||||
// verify high level relation (from users)
|
||||
const userSettingRel = em.relationOf(users.name, settings.name);
|
||||
@@ -324,7 +323,7 @@ describe("Relations", async () => {
|
||||
);
|
||||
|
||||
// mutation info
|
||||
expect(relations[0]!.helper(posts.name)!.getMutationInfo()).toEqual({
|
||||
expect(relations[0].helper(posts.name)!.getMutationInfo()).toEqual({
|
||||
reference: "categories",
|
||||
local_field: undefined,
|
||||
$set: false,
|
||||
@@ -335,7 +334,7 @@ describe("Relations", async () => {
|
||||
cardinality: undefined,
|
||||
relation_type: "m:n",
|
||||
});
|
||||
expect(relations[0]!.helper(categories.name)!.getMutationInfo()).toEqual({
|
||||
expect(relations[0].helper(categories.name)!.getMutationInfo()).toEqual({
|
||||
reference: "posts",
|
||||
local_field: undefined,
|
||||
$set: false,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { Entity } from "data/entities";
|
||||
import { NumberField, TextField } from "data/fields";
|
||||
import { Entity, NumberField, TextField } from "data";
|
||||
import * as p from "data/prototype";
|
||||
|
||||
describe("[data] Entity", async () => {
|
||||
const entity = new Entity("test", [
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
import { afterAll, describe, expect, test } from "bun:test";
|
||||
import { Entity, EntityManager } from "data/entities";
|
||||
import { ManyToManyRelation, ManyToOneRelation } from "data/relations";
|
||||
import { SchemaManager } from "data/schema/SchemaManager";
|
||||
import { UnableToConnectException } from "data/errors";
|
||||
import {
|
||||
Entity,
|
||||
EntityManager,
|
||||
ManyToManyRelation,
|
||||
ManyToOneRelation,
|
||||
SchemaManager,
|
||||
} from "../../../src/data";
|
||||
import { UnableToConnectException } from "../../../src/data/errors";
|
||||
import { getDummyConnection } from "../helper";
|
||||
|
||||
const { dummyConnection, afterAllCleanup } = getDummyConnection();
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import { afterAll, describe, expect, test } from "bun:test";
|
||||
import { Entity, EntityManager } from "data/entities";
|
||||
import { ManyToOneRelation } from "data/relations";
|
||||
import { TextField } from "data/fields";
|
||||
import { JoinBuilder } from "data/entities/query/JoinBuilder";
|
||||
import { Entity, EntityManager, ManyToOneRelation, TextField } from "../../../src/data";
|
||||
import { JoinBuilder } from "../../../src/data/entities/query/JoinBuilder";
|
||||
import { getDummyConnection } from "../helper";
|
||||
|
||||
const { dummyConnection, afterAllCleanup } = getDummyConnection();
|
||||
|
||||
@@ -1,16 +1,18 @@
|
||||
import { afterAll, beforeAll, describe, expect, test } from "bun:test";
|
||||
import type { EventManager } from "../../../src/core/events";
|
||||
import { Entity, EntityManager } from "data/entities";
|
||||
import {
|
||||
Entity,
|
||||
EntityManager,
|
||||
ManyToOneRelation,
|
||||
MutatorEvents,
|
||||
NumberField,
|
||||
OneToOneRelation,
|
||||
RelationField,
|
||||
type RelationField,
|
||||
RelationMutator,
|
||||
} from "data/relations";
|
||||
import { NumberField, TextField } from "data/fields";
|
||||
import * as proto from "data/prototype";
|
||||
TextField,
|
||||
} from "../../../src/data";
|
||||
import * as proto from "../../../src/data/prototype";
|
||||
import { getDummyConnection, disableConsoleLog, enableConsoleLog } from "../../helper";
|
||||
import { MutatorEvents } from "data/events";
|
||||
|
||||
const { dummyConnection, afterAllCleanup } = getDummyConnection();
|
||||
afterAll(afterAllCleanup);
|
||||
|
||||
@@ -1,10 +1,17 @@
|
||||
import { afterAll, describe, expect, test } from "bun:test";
|
||||
import type { Kysely, Transaction } from "kysely";
|
||||
import { TextField } from "data/fields";
|
||||
import { em as $em, entity as $entity, text as $text } from "data/prototype";
|
||||
import { Entity, EntityManager } from "data/entities";
|
||||
import { ManyToOneRelation } from "data/relations";
|
||||
import { RepositoryEvents } from "data/events";
|
||||
import { Perf } from "core/utils";
|
||||
import {
|
||||
Entity,
|
||||
EntityManager,
|
||||
LibsqlConnection,
|
||||
ManyToOneRelation,
|
||||
RepositoryEvents,
|
||||
TextField,
|
||||
entity as $entity,
|
||||
text as $text,
|
||||
em as $em,
|
||||
} from "data";
|
||||
import { getDummyConnection } from "../helper";
|
||||
|
||||
type E = Kysely<any> | Transaction<any>;
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
// eslint-disable-next-line import/no-unresolved
|
||||
import { afterAll, describe, expect, test } from "bun:test";
|
||||
import { randomString } from "core/utils";
|
||||
import { Entity, EntityManager } from "data/entities";
|
||||
import { TextField, EntityIndex } from "data/fields";
|
||||
import { SchemaManager } from "data/schema/SchemaManager";
|
||||
import { randomString } from "../../../src/core/utils";
|
||||
import { Entity, EntityIndex, EntityManager, SchemaManager, TextField } from "../../../src/data";
|
||||
import { getDummyConnection } from "../helper";
|
||||
|
||||
const { dummyConnection, afterAllCleanup } = getDummyConnection();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { describe, test, expect } from "bun:test";
|
||||
import { getDummyConnection } from "../helper";
|
||||
import { WhereBuilder, type WhereQuery } from "data/entities/query/WhereBuilder";
|
||||
import { type WhereQuery, WhereBuilder } from "data";
|
||||
|
||||
function qb() {
|
||||
const c = getDummyConnection();
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { Entity, EntityManager } from "data/entities";
|
||||
import { ManyToManyRelation, ManyToOneRelation, PolymorphicRelation } from "data/relations";
|
||||
import { TextField } from "data/fields";
|
||||
import * as proto from "data/prototype";
|
||||
import { WithBuilder } from "data/entities/query/WithBuilder";
|
||||
import {
|
||||
Entity,
|
||||
EntityManager,
|
||||
ManyToManyRelation,
|
||||
ManyToOneRelation,
|
||||
PolymorphicRelation,
|
||||
TextField,
|
||||
WithBuilder,
|
||||
} from "../../../src/data";
|
||||
import * as proto from "../../../src/data/prototype";
|
||||
import { schemaToEm } from "../../helper";
|
||||
import { getDummyConnection } from "../helper";
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { afterAll, describe, expect, test } from "bun:test";
|
||||
import { EntityManager } from "data/entities/EntityManager";
|
||||
import { EntityManager } from "../../../../src/data";
|
||||
import { getDummyConnection } from "../../helper";
|
||||
|
||||
const { dummyConnection, afterAllCleanup } = getDummyConnection();
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import { bunTestRunner } from "adapter/bun/test";
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { BooleanField } from "data/fields";
|
||||
import { BooleanField } from "../../../../src/data";
|
||||
import { fieldTestSuite, transformPersist } from "data/fields/field-test-suite";
|
||||
|
||||
describe("[data] BooleanField", async () => {
|
||||
fieldTestSuite(bunTestRunner, BooleanField, { defaultValue: true, schemaType: "boolean" });
|
||||
fieldTestSuite({ expect, test }, BooleanField, { defaultValue: true, schemaType: "boolean" });
|
||||
|
||||
test("transformRetrieve", async () => {
|
||||
const field = new BooleanField("test");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { describe, test } from "bun:test";
|
||||
import { DateField } from "data/fields";
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { DateField, dateFieldConfigSchema } from "../../../../src/data";
|
||||
import { fieldTestSuite } from "data/fields/field-test-suite";
|
||||
import { bunTestRunner } from "adapter/bun/test";
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { bunTestRunner } from "adapter/bun/test";
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { EnumField } from "data/fields";
|
||||
import { EnumField } from "../../../../src/data";
|
||||
import { fieldTestSuite, transformPersist } from "data/fields/field-test-suite";
|
||||
|
||||
function options(strings: string[]) {
|
||||
@@ -9,7 +8,7 @@ function options(strings: string[]) {
|
||||
|
||||
describe("[data] EnumField", async () => {
|
||||
fieldTestSuite(
|
||||
bunTestRunner,
|
||||
{ expect, test },
|
||||
// @ts-ignore
|
||||
EnumField,
|
||||
{ defaultValue: "a", schemaType: "text" },
|
||||
|
||||
@@ -2,7 +2,7 @@ import { describe, expect, test } from "bun:test";
|
||||
import { baseFieldConfigSchema, Field } from "../../../../src/data/fields/Field";
|
||||
import { fieldTestSuite } from "data/fields/field-test-suite";
|
||||
import { bunTestRunner } from "adapter/bun/test";
|
||||
import { stripMark } from "core/utils/schema";
|
||||
import { stripMark } from "bknd/core";
|
||||
|
||||
describe("[data] Field", async () => {
|
||||
class FieldSpec extends Field {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { Entity } from "data/entities";
|
||||
import { Field, EntityIndex } from "data/fields";
|
||||
import { s } from "core/utils/schema";
|
||||
import { Entity, EntityIndex, Field } from "../../../../src/data";
|
||||
import { s } from "bknd/core";
|
||||
|
||||
class TestField extends Field {
|
||||
protected getSchema(): any {
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
import { bunTestRunner } from "adapter/bun/test";
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { JsonField } from "data/fields";
|
||||
import { JsonField } from "../../../../src/data";
|
||||
import { fieldTestSuite, transformPersist } from "data/fields/field-test-suite";
|
||||
|
||||
describe("[data] JsonField", async () => {
|
||||
const field = new JsonField("test");
|
||||
fieldTestSuite(bunTestRunner, JsonField, {
|
||||
fieldTestSuite({ expect, test }, JsonField, {
|
||||
defaultValue: { a: 1 },
|
||||
sampleValues: ["string", { test: 1 }, 1],
|
||||
schemaType: "text",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { JsonSchemaField } from "data/fields";
|
||||
import { JsonSchemaField } from "../../../../src/data";
|
||||
import { fieldTestSuite } from "data/fields/field-test-suite";
|
||||
|
||||
describe("[data] JsonSchemaField", async () => {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { bunTestRunner } from "adapter/bun/test";
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { NumberField } from "data/fields";
|
||||
import { NumberField } from "../../../../src/data";
|
||||
import { fieldTestSuite, transformPersist } from "data/fields/field-test-suite";
|
||||
|
||||
describe("[data] NumberField", async () => {
|
||||
@@ -16,5 +15,5 @@ describe("[data] NumberField", async () => {
|
||||
expect(transformPersist(field2, 10000)).resolves.toBe(10000);
|
||||
});
|
||||
|
||||
fieldTestSuite(bunTestRunner, NumberField, { defaultValue: 12, schemaType: "integer" });
|
||||
fieldTestSuite({ expect, test }, NumberField, { defaultValue: 12, schemaType: "integer" });
|
||||
});
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { PrimaryField } from "data/fields";
|
||||
import { PrimaryField } from "../../../../src/data";
|
||||
|
||||
describe("[data] PrimaryField", async () => {
|
||||
const field = new PrimaryField("primary");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { TextField } from "data/fields";
|
||||
import { TextField, textFieldConfigSchema } from "../../../../src/data";
|
||||
import { fieldTestSuite, transformPersist } from "data/fields/field-test-suite";
|
||||
import { bunTestRunner } from "adapter/bun/test";
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { describe, expect, it, test } from "bun:test";
|
||||
import { Entity, type EntityManager } from "data/entities";
|
||||
import { Entity, type EntityManager } from "../../../../src/data";
|
||||
import {
|
||||
type BaseRelationConfig,
|
||||
EntityRelation,
|
||||
EntityRelationAnchor,
|
||||
RelationTypes,
|
||||
} from "data/relations";
|
||||
} from "../../../../src/data/relations";
|
||||
|
||||
class TestEntityRelation extends EntityRelation {
|
||||
constructor(config?: BaseRelationConfig) {
|
||||
@@ -24,11 +24,11 @@ class TestEntityRelation extends EntityRelation {
|
||||
return this;
|
||||
}
|
||||
|
||||
buildWith(): any {
|
||||
buildWith(a: any, b: any, c: any): any {
|
||||
return;
|
||||
}
|
||||
|
||||
buildJoin(): any {
|
||||
buildJoin(a: any, b: any): any {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { Flow, LogTask, SubFlowTask, RenderTask, Task } from "../../src/flows";
|
||||
import { s } from "core/utils/schema";
|
||||
import { s } from "bknd/core";
|
||||
|
||||
export class StringifyTask<Output extends string> extends Task<
|
||||
typeof StringifyTask.schema,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { Task } from "../../src/flows";
|
||||
import { dynamic } from "../../src/flows/tasks/Task";
|
||||
import { s } from "core/utils/schema";
|
||||
import { s } from "bknd/core";
|
||||
|
||||
describe.skip("Task", async () => {
|
||||
test("resolveParams: template with parse", async () => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { Hono } from "hono";
|
||||
import { Event, EventManager } from "../../src/core/events";
|
||||
import { s, parse } from "core/utils/schema";
|
||||
import { s, parse } from "bknd/core";
|
||||
import { EventTrigger, Flow, HttpTrigger, type InputsMap, Task } from "../../src/flows";
|
||||
import { dynamic } from "../../src/flows/tasks/Task";
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { isEqual } from "lodash-es";
|
||||
import { _jsonp, withDisabledConsole } from "../../src/core/utils";
|
||||
import { s } from "core/utils/schema";
|
||||
import { s } from "bknd/core";
|
||||
import { Condition, ExecutionEvent, FetchTask, Flow, LogTask, Task } from "../../src/flows";
|
||||
|
||||
/*beforeAll(disableConsoleLog);
|
||||
|
||||
@@ -2,12 +2,11 @@ import { unlink } from "node:fs/promises";
|
||||
import type { SelectQueryBuilder, SqliteDatabase } from "kysely";
|
||||
import Database from "libsql";
|
||||
import { format as sqlFormat } from "sql-formatter";
|
||||
import { type Connection, EntityManager, SqliteLocalConnection } from "../src/data";
|
||||
import type { em as protoEm } from "../src/data/prototype";
|
||||
import { writeFile } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
import { slugify } from "core/utils/strings";
|
||||
import { type Connection, SqliteLocalConnection } from "data/connection";
|
||||
import { EntityManager } from "data/entities/EntityManager";
|
||||
|
||||
export function getDummyDatabase(memory: boolean = true): {
|
||||
dummyDb: SqliteDatabase;
|
||||
|
||||
@@ -54,6 +54,7 @@ describe("MediaController", () => {
|
||||
body: file,
|
||||
});
|
||||
const result = (await res.json()) as any;
|
||||
console.log(result);
|
||||
expect(result.name).toBe(name);
|
||||
|
||||
const destFile = Bun.file(assetsTmpPath + "/" + name);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { type FileBody, Storage } from "../../src/media/storage/Storage";
|
||||
import * as StorageEvents from "../../src/media/storage/events";
|
||||
import { StorageAdapter } from "media/storage/StorageAdapter";
|
||||
import { StorageAdapter } from "media";
|
||||
|
||||
class TestAdapter extends StorageAdapter {
|
||||
files: Record<string, FileBody> = {};
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { afterAll, beforeAll, beforeEach, describe, expect, spyOn, test } from "bun:test";
|
||||
import { createApp } from "core/test/utils";
|
||||
import { AuthController } from "../../src/auth/api/AuthController";
|
||||
import { em, entity, make, text } from "data/prototype";
|
||||
import { AppAuth, type ModuleBuildContext } from "modules";
|
||||
import { em, entity, make, text } from "../../src/data";
|
||||
import { AppAuth, type ModuleBuildContext } from "../../src/modules";
|
||||
import { disableConsoleLog, enableConsoleLog } from "../helper";
|
||||
// @ts-ignore
|
||||
import { makeCtx, moduleTestSuite } from "./module-test-suite";
|
||||
|
||||
describe("AppAuth", () => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { beforeEach, describe, expect, test } from "bun:test";
|
||||
import { parse } from "core/utils/schema";
|
||||
import { parse } from "bknd/core";
|
||||
import { fieldsSchema } from "../../src/data/data-schema";
|
||||
import { AppData, type ModuleBuildContext } from "../../src/modules";
|
||||
import { makeCtx, moduleTestSuite } from "./module-test-suite";
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { registries } from "../../src";
|
||||
import { createApp } from "core/test/utils";
|
||||
import { em, entity, text } from "data/prototype";
|
||||
import { registries } from "modules/registries";
|
||||
import { em, entity, text } from "../../src/data";
|
||||
import { StorageLocalAdapter } from "adapter/node/storage/StorageLocalAdapter";
|
||||
import { AppMedia } from "../../src/media/AppMedia";
|
||||
import { mediaConfigSchema } from "../../src/media/media-schema";
|
||||
import { moduleTestSuite } from "./module-test-suite";
|
||||
|
||||
describe("AppMedia", () => {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { s, stripMark } from "core/utils/schema";
|
||||
import { em, entity, index, text } from "data/prototype";
|
||||
import { EntityManager } from "data/entities/EntityManager";
|
||||
import { s, stripMark } from "bknd/core";
|
||||
import { EntityManager, em, entity, index, text } from "../../src/data";
|
||||
import { DummyConnection } from "../../src/data/connection/DummyConnection";
|
||||
import { Module } from "../../src/modules/Module";
|
||||
import { ModuleHelper } from "modules/ModuleHelper";
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
import { afterEach, beforeEach, describe, expect, mock, test } from "bun:test";
|
||||
import { disableConsoleLog, enableConsoleLog } from "core/utils";
|
||||
|
||||
import { Connection, entity, text } from "data";
|
||||
import { Module } from "modules/Module";
|
||||
import { type ConfigTable, getDefaultConfig, ModuleManager } from "modules/ModuleManager";
|
||||
import { CURRENT_VERSION, TABLE_NAME } from "modules/migrations";
|
||||
import { getDummyConnection } from "../helper";
|
||||
import { s, stripMark } from "core/utils/schema";
|
||||
import { Connection } from "data/connection/Connection";
|
||||
import { entity, text } from "data/prototype";
|
||||
import { s, stripMark } from "bknd/core";
|
||||
|
||||
describe("ModuleManager", async () => {
|
||||
test("s1: no config, no build", async () => {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { beforeEach, describe, expect, it } from "bun:test";
|
||||
|
||||
import { Hono } from "hono";
|
||||
import { Guard } from "auth/authorize/Guard";
|
||||
import { DebugLogger } from "core/utils/DebugLogger";
|
||||
import { EventManager } from "core/events";
|
||||
import { EntityManager } from "data/entities/EntityManager";
|
||||
import { Module, type ModuleBuildContext } from "modules/Module";
|
||||
import { Guard } from "../../src/auth";
|
||||
import { DebugLogger } from "../../src/core";
|
||||
import { EventManager } from "../../src/core/events";
|
||||
import { EntityManager } from "../../src/data";
|
||||
import { Module, type ModuleBuildContext } from "../../src/modules/Module";
|
||||
import { getDummyConnection } from "../helper";
|
||||
import { ModuleHelper } from "modules/ModuleHelper";
|
||||
|
||||
|
||||
+8
-1
@@ -79,7 +79,14 @@ async function buildApi() {
|
||||
sourcemap,
|
||||
watch,
|
||||
define,
|
||||
entry: ["src/index.ts", "src/core/utils/index.ts", "src/plugins/index.ts"],
|
||||
entry: [
|
||||
"src/index.ts",
|
||||
"src/core/index.ts",
|
||||
"src/core/utils/index.ts",
|
||||
"src/data/index.ts",
|
||||
"src/media/index.ts",
|
||||
"src/plugins/index.ts",
|
||||
],
|
||||
outDir: "dist",
|
||||
external: [...external],
|
||||
metafile: true,
|
||||
|
||||
+22
-5
@@ -13,7 +13,6 @@
|
||||
"bugs": {
|
||||
"url": "https://github.com/bknd-io/bknd/issues"
|
||||
},
|
||||
"packageManager": "bun@1.2.19",
|
||||
"engines": {
|
||||
"node": ">=22"
|
||||
},
|
||||
@@ -61,7 +60,8 @@
|
||||
"bcryptjs": "^3.0.2",
|
||||
"dayjs": "^1.11.13",
|
||||
"fast-xml-parser": "^5.0.8",
|
||||
"hono": "4.8.3",
|
||||
"hono": "^4.7.11",
|
||||
"json-schema-form-react": "^0.0.2",
|
||||
"json-schema-library": "10.0.0-rc7",
|
||||
"json-schema-to-ts": "^3.1.1",
|
||||
"kysely": "^0.27.6",
|
||||
@@ -100,7 +100,7 @@
|
||||
"dotenv": "^16.4.7",
|
||||
"jotai": "^2.12.2",
|
||||
"jsdom": "^26.0.0",
|
||||
"jsonv-ts": "^0.3.2",
|
||||
"jsonv-ts": "^0.2.2",
|
||||
"kysely-d1": "^0.3.0",
|
||||
"kysely-generic-sqlite": "^1.2.1",
|
||||
"libsql-stateless-easy": "^1.8.0",
|
||||
@@ -161,6 +161,16 @@
|
||||
"import": "./dist/ui/client/index.js",
|
||||
"require": "./dist/ui/client/index.js"
|
||||
},
|
||||
"./data": {
|
||||
"types": "./dist/types/data/index.d.ts",
|
||||
"import": "./dist/data/index.js",
|
||||
"require": "./dist/data/index.js"
|
||||
},
|
||||
"./core": {
|
||||
"types": "./dist/types/core/index.d.ts",
|
||||
"import": "./dist/core/index.js",
|
||||
"require": "./dist/core/index.js"
|
||||
},
|
||||
"./utils": {
|
||||
"types": "./dist/types/core/utils/index.d.ts",
|
||||
"import": "./dist/core/utils/index.js",
|
||||
@@ -171,6 +181,11 @@
|
||||
"import": "./dist/cli/index.js",
|
||||
"require": "./dist/cli/index.js"
|
||||
},
|
||||
"./media": {
|
||||
"types": "./dist/types/media/index.d.ts",
|
||||
"import": "./dist/media/index.js",
|
||||
"require": "./dist/media/index.js"
|
||||
},
|
||||
"./plugins": {
|
||||
"types": "./dist/types/plugins/index.d.ts",
|
||||
"import": "./dist/plugins/index.js",
|
||||
@@ -236,13 +251,15 @@
|
||||
},
|
||||
"./dist/main.css": "./dist/ui/main.css",
|
||||
"./dist/styles.css": "./dist/ui/styles.css",
|
||||
"./dist/manifest.json": "./dist/static/.vite/manifest.json",
|
||||
"./static/*": "./dist/static/*"
|
||||
"./dist/manifest.json": "./dist/static/.vite/manifest.json"
|
||||
},
|
||||
"typesVersions": {
|
||||
"*": {
|
||||
"data": ["./dist/types/data/index.d.ts"],
|
||||
"core": ["./dist/types/core/index.d.ts"],
|
||||
"utils": ["./dist/types/core/utils/index.d.ts"],
|
||||
"cli": ["./dist/types/cli/index.d.ts"],
|
||||
"media": ["./dist/types/media/index.d.ts"],
|
||||
"plugins": ["./dist/types/plugins/index.d.ts"],
|
||||
"adapter": ["./dist/types/adapter/index.d.ts"],
|
||||
"adapter/cloudflare": ["./dist/types/adapter/cloudflare/index.d.ts"],
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import type { SafeUser } from "bknd";
|
||||
import type { SafeUser } from "auth";
|
||||
import { AuthApi, type AuthApiOptions } from "auth/api/AuthApi";
|
||||
import { DataApi, type DataApiOptions } from "data/api/DataApi";
|
||||
import { decode } from "hono/jwt";
|
||||
|
||||
@@ -3,9 +3,10 @@
|
||||
import path from "node:path";
|
||||
import { type RuntimeBkndConfig, createRuntimeApp, type RuntimeOptions } from "bknd/adapter";
|
||||
import { registerLocalMediaAdapter } from ".";
|
||||
import { config, type App } from "bknd";
|
||||
import { config } from "bknd/core";
|
||||
import type { ServeOptions } from "bun";
|
||||
import { serveStatic } from "hono/bun";
|
||||
import type { App } from "App";
|
||||
|
||||
type BunEnv = Bun.Env;
|
||||
export type BunBkndConfig<Env = BunEnv> = RuntimeBkndConfig<Env> & Omit<ServeOptions, "fetch">;
|
||||
@@ -20,8 +21,8 @@ export async function createApp<Env = BunEnv>(
|
||||
|
||||
return await createRuntimeApp(
|
||||
{
|
||||
serveStatic: serveStatic({ root }),
|
||||
...config,
|
||||
serveStatic: serveStatic({ root }),
|
||||
},
|
||||
args ?? (process.env as Env),
|
||||
opts,
|
||||
@@ -52,7 +53,6 @@ export function serve<Env = BunEnv>(
|
||||
onBuilt,
|
||||
buildConfig,
|
||||
adminOptions,
|
||||
serveStatic,
|
||||
...serveOptions
|
||||
}: BunBkndConfig<Env> = {},
|
||||
args: Env = {} as Env,
|
||||
@@ -70,7 +70,6 @@ export function serve<Env = BunEnv>(
|
||||
buildConfig,
|
||||
adminOptions,
|
||||
distPath,
|
||||
serveStatic,
|
||||
},
|
||||
args,
|
||||
opts,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Database } from "bun:sqlite";
|
||||
import { genericSqlite, type GenericSqliteConnection } from "bknd";
|
||||
import { genericSqlite, type GenericSqliteConnection } from "bknd/data";
|
||||
|
||||
export type BunSqliteConnection = GenericSqliteConnection<Database>;
|
||||
export type BunSqliteConnectionConfig = {
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
/// <reference types="@cloudflare/workers-types" />
|
||||
|
||||
import { Connection } from "bknd";
|
||||
import { sqlite } from "bknd/adapter/sqlite";
|
||||
import { makeConfig as makeAdapterConfig } from "bknd/adapter";
|
||||
import { registerMedia } from "./storage/StorageR2Adapter";
|
||||
import { getBinding } from "./bindings";
|
||||
import { d1Sqlite } from "./connection/D1Connection";
|
||||
import { Connection } from "bknd/data";
|
||||
import type { CloudflareBkndConfig, CloudflareEnv } from ".";
|
||||
import { App } from "bknd";
|
||||
import { makeConfig as makeAdapterConfig } from "bknd/adapter";
|
||||
import type { Context, ExecutionContext } from "hono";
|
||||
import { $console } from "core/utils";
|
||||
import { setCookie } from "hono/cookie";
|
||||
import { sqlite } from "bknd/adapter/sqlite";
|
||||
|
||||
export const constants = {
|
||||
exec_async_event_id: "cf_register_waituntil",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/// <reference types="@cloudflare/workers-types" />
|
||||
|
||||
import { genericSqlite, type GenericSqliteConnection } from "bknd";
|
||||
import { genericSqlite, type GenericSqliteConnection } from "bknd/data";
|
||||
import type { QueryResult } from "kysely";
|
||||
|
||||
export type D1SqliteConnection = GenericSqliteConnection<D1Database>;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/// <reference types="@cloudflare/workers-types" />
|
||||
|
||||
import { genericSqlite, type GenericSqliteConnection } from "bknd";
|
||||
import { genericSqlite, type GenericSqliteConnection } from "bknd/data";
|
||||
import type { QueryResult } from "kysely";
|
||||
|
||||
export type D1SqliteConnection = GenericSqliteConnection<D1Database>;
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { registries, isDebug, guessMimeType } from "bknd";
|
||||
import { registries } from "bknd";
|
||||
import { isDebug } from "bknd/core";
|
||||
import { guessMimeType as guess, StorageAdapter, type FileBody } from "bknd/media";
|
||||
import { getBindings } from "../bindings";
|
||||
import { s } from "bknd/utils";
|
||||
import { StorageAdapter, type FileBody } from "bknd";
|
||||
import { s } from "bknd/core";
|
||||
|
||||
export function makeSchema(bindings: string[] = []) {
|
||||
return s.object(
|
||||
@@ -89,7 +90,7 @@ export class StorageR2Adapter extends StorageAdapter {
|
||||
|
||||
const responseHeaders = new Headers({
|
||||
"Accept-Ranges": "bytes",
|
||||
"Content-Type": guessMimeType(key),
|
||||
"Content-Type": guess(key),
|
||||
});
|
||||
|
||||
const range = headers.has("range");
|
||||
@@ -141,7 +142,7 @@ export class StorageR2Adapter extends StorageAdapter {
|
||||
if (!metadata || Object.keys(metadata).length === 0) {
|
||||
// guessing is especially required for dev environment (miniflare)
|
||||
metadata = {
|
||||
contentType: guessMimeType(object.key),
|
||||
contentType: guess(object.key),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -158,7 +159,7 @@ export class StorageR2Adapter extends StorageAdapter {
|
||||
}
|
||||
|
||||
return {
|
||||
type: String(head.httpMetadata?.contentType ?? guessMimeType(key)),
|
||||
type: String(head.httpMetadata?.contentType ?? guess(key)),
|
||||
size: head.size,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
import { config as $config, App, type CreateAppConfig, Connection, guessMimeType } from "bknd";
|
||||
import { App, type CreateAppConfig } from "bknd";
|
||||
import { config as $config } from "bknd/core";
|
||||
import { $console } from "bknd/utils";
|
||||
import type { Context, MiddlewareHandler, Next } from "hono";
|
||||
import type { MiddlewareHandler } from "hono";
|
||||
import type { AdminControllerOptions } from "modules/server/AdminController";
|
||||
import type { Manifest } from "vite";
|
||||
import { Connection } from "bknd/data";
|
||||
|
||||
export { Connection } from "bknd/data";
|
||||
|
||||
export type BkndConfig<Args = any> = CreateAppConfig & {
|
||||
app?: CreateAppConfig | ((args: Args) => CreateAppConfig);
|
||||
@@ -67,9 +70,9 @@ export async function createAdapterApp<Config extends BkndConfig = BkndConfig, A
|
||||
connection = config.connection;
|
||||
} else {
|
||||
const sqlite = (await import("bknd/adapter/sqlite")).sqlite;
|
||||
const conf = appConfig.connection ?? { url: ":memory:" };
|
||||
connection = sqlite(conf) as unknown as Connection;
|
||||
$console.info(`Using ${connection!.name} connection`, conf.url);
|
||||
const conf = config.connection ?? { url: ":memory:" };
|
||||
connection = sqlite(conf);
|
||||
$console.info(`Using ${connection.name} connection`, conf.url);
|
||||
}
|
||||
appConfig.connection = connection;
|
||||
}
|
||||
@@ -137,54 +140,3 @@ export async function createRuntimeApp<Args = DefaultArgs>(
|
||||
|
||||
return app;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a middleware handler to serve static assets via dynamic imports.
|
||||
* This is useful for environments where filesystem access is limited but bundled assets can be imported.
|
||||
*
|
||||
* @param manifest - Vite manifest object containing asset information
|
||||
* @returns Hono middleware handler for serving static assets
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { serveStaticViaImport } from "bknd/adapter";
|
||||
*
|
||||
* serve({
|
||||
* serveStatic: serveStaticViaImport(),
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
export function serveStaticViaImport(opts?: { manifest?: Manifest }) {
|
||||
let files: string[] | undefined;
|
||||
|
||||
// @ts-ignore
|
||||
return async (c: Context, next: Next) => {
|
||||
if (!files) {
|
||||
const manifest =
|
||||
opts?.manifest || ((await import("bknd/dist/manifest.json")).default as Manifest);
|
||||
files = Object.values(manifest).flatMap((asset) => [asset.file, ...(asset.css || [])]);
|
||||
}
|
||||
|
||||
const path = c.req.path.substring(1);
|
||||
if (files.includes(path)) {
|
||||
try {
|
||||
const content = await import(/* @vite-ignore */ `bknd/static/${path}?raw`, {
|
||||
assert: { type: "text" },
|
||||
}).then((m) => m.default);
|
||||
|
||||
if (content) {
|
||||
return c.body(content, {
|
||||
headers: {
|
||||
"Content-Type": guessMimeType(path),
|
||||
"Cache-Control": "public, max-age=31536000, immutable",
|
||||
},
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("Error serving static file:", e);
|
||||
return c.text("File not found", 404);
|
||||
}
|
||||
}
|
||||
await next();
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { genericSqlite } from "bknd";
|
||||
import { genericSqlite } from "bknd/data";
|
||||
import { DatabaseSync } from "node:sqlite";
|
||||
|
||||
export type NodeSqliteConnectionConfig = {
|
||||
|
||||
@@ -3,8 +3,9 @@ import { serve as honoServe } from "@hono/node-server";
|
||||
import { serveStatic } from "@hono/node-server/serve-static";
|
||||
import { registerLocalMediaAdapter } from "adapter/node/storage";
|
||||
import { type RuntimeBkndConfig, createRuntimeApp, type RuntimeOptions } from "bknd/adapter";
|
||||
import { config as $config, type App } from "bknd";
|
||||
import { $console } from "bknd/utils";
|
||||
import { config as $config } from "bknd/core";
|
||||
import { $console } from "core/utils";
|
||||
import type { App } from "App";
|
||||
|
||||
type NodeEnv = NodeJS.ProcessEnv;
|
||||
export type NodeBkndConfig<Env = NodeEnv> = RuntimeBkndConfig<Env> & {
|
||||
@@ -31,8 +32,8 @@ export async function createApp<Env = NodeEnv>(
|
||||
registerLocalMediaAdapter();
|
||||
return await createRuntimeApp(
|
||||
{
|
||||
serveStatic: serveStatic({ root }),
|
||||
...config,
|
||||
serveStatic: serveStatic({ root }),
|
||||
},
|
||||
// @ts-ignore
|
||||
args ?? { env: process.env },
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { readFile, readdir, stat, unlink, writeFile } from "node:fs/promises";
|
||||
import type { FileBody, FileListObject, FileMeta, FileUploadPayload } from "bknd";
|
||||
import { StorageAdapter, guessMimeType } from "bknd";
|
||||
import { parse, s, isFile } from "bknd/utils";
|
||||
import { isFile } from "bknd/utils";
|
||||
import type { FileBody, FileListObject, FileMeta, FileUploadPayload } from "bknd/media";
|
||||
import { StorageAdapter, guessMimeType as guess } from "bknd/media";
|
||||
import { parse, s } from "bknd/core";
|
||||
|
||||
export const localAdapterConfig = s.object(
|
||||
{
|
||||
@@ -83,7 +84,7 @@ export class StorageLocalAdapter extends StorageAdapter {
|
||||
async getObject(key: string, headers: Headers): Promise<Response> {
|
||||
try {
|
||||
const content = await readFile(`${this.config.path}/${key}`);
|
||||
const mimeType = guessMimeType(key);
|
||||
const mimeType = guess(key);
|
||||
|
||||
return new Response(content, {
|
||||
status: 200,
|
||||
@@ -105,7 +106,7 @@ export class StorageLocalAdapter extends StorageAdapter {
|
||||
async getObjectMeta(key: string): Promise<FileMeta> {
|
||||
const stats = await stat(`${this.config.path}/${key}`);
|
||||
return {
|
||||
type: guessMimeType(key) || "application/octet-stream",
|
||||
type: guess(key) || "application/octet-stream",
|
||||
size: stats.size,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { Connection } from "bknd";
|
||||
import type { Connection } from "bknd/data";
|
||||
import { bunSqlite } from "../bun/connection/BunSqliteConnection";
|
||||
|
||||
export function sqlite(config?: { url: string }): Connection {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { type Connection, libsql } from "bknd";
|
||||
import { type Connection, libsql } from "bknd/data";
|
||||
|
||||
export function sqlite(config: { url: string }): Connection {
|
||||
return libsql(config);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { Connection } from "bknd";
|
||||
import type { Connection } from "bknd/data";
|
||||
import { nodeSqlite } from "../node/connection/NodeSqliteConnection";
|
||||
|
||||
export function sqlite(config?: { url: string }): Connection {
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import type { DB } from "bknd";
|
||||
import * as AuthPermissions from "auth/auth-permissions";
|
||||
import type { AuthStrategy } from "auth/authenticate/strategies/Strategy";
|
||||
import type { PasswordStrategy } from "auth/authenticate/strategies/PasswordStrategy";
|
||||
import { Authenticator, AuthPermissions, Role, type Strategy } from "auth";
|
||||
import type { PasswordStrategy } from "auth/authenticate/strategies";
|
||||
import type { DB } from "core";
|
||||
import { $console, secureRandomString, transformObject } from "core/utils";
|
||||
import type { Entity, EntityManager } from "data/entities";
|
||||
import type { Entity, EntityManager } from "data";
|
||||
import { em, entity, enumm, type FieldSchema } from "data/prototype";
|
||||
import { Module } from "modules/Module";
|
||||
import { AuthController } from "./api/AuthController";
|
||||
@@ -11,11 +10,9 @@ import { type AppAuthSchema, authConfigSchema, STRATEGIES } from "./auth-schema"
|
||||
import { AppUserPool } from "auth/AppUserPool";
|
||||
import type { AppEntity } from "core/config";
|
||||
import { usersFields } from "./auth-entities";
|
||||
import { Authenticator } from "./authenticate/Authenticator";
|
||||
import { Role } from "./authorize/Role";
|
||||
|
||||
export type UserFieldSchema = FieldSchema<typeof AppAuth.usersFields>;
|
||||
declare module "bknd" {
|
||||
declare module "core" {
|
||||
interface Users extends AppEntity, UserFieldSchema {}
|
||||
interface DB {
|
||||
users: Users;
|
||||
@@ -91,7 +88,7 @@ export class AppAuth extends Module<AppAuthSchema> {
|
||||
this.ctx.guard.registerPermissions(AuthPermissions);
|
||||
}
|
||||
|
||||
isStrategyEnabled(strategy: AuthStrategy | string) {
|
||||
isStrategyEnabled(strategy: Strategy | string) {
|
||||
const name = typeof strategy === "string" ? strategy : strategy.getName();
|
||||
// for now, password is always active
|
||||
if (name === "password") return true;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { AuthActionResponse } from "auth/api/AuthController";
|
||||
import type { AppAuthSchema } from "auth/auth-schema";
|
||||
import type { AuthResponse, SafeUser, AuthStrategy } from "bknd";
|
||||
import type { AuthResponse, SafeUser, Strategy } from "auth/authenticate/Authenticator";
|
||||
import { type BaseModuleApiOptions, ModuleApi } from "modules/ModuleApi";
|
||||
|
||||
export type AuthApiOptions = BaseModuleApiOptions & {
|
||||
@@ -39,7 +39,7 @@ export class AuthApi extends ModuleApi<AuthApiOptions> {
|
||||
}
|
||||
|
||||
async actionSchema(strategy: string, action: string) {
|
||||
return this.get<AuthStrategy>([strategy, "actions", action, "schema.json"]);
|
||||
return this.get<Strategy>([strategy, "actions", action, "schema.json"]);
|
||||
}
|
||||
|
||||
async action(strategy: string, action: string, input: any) {
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
import type { SafeUser } from "bknd";
|
||||
import type { AuthStrategy } from "auth/authenticate/strategies/Strategy";
|
||||
import type { AppAuth } from "auth/AppAuth";
|
||||
import * as AuthPermissions from "auth/auth-permissions";
|
||||
import * as DataPermissions from "data/permissions";
|
||||
import { type AppAuth, AuthPermissions, type SafeUser, type Strategy } from "auth";
|
||||
import { transformObject } from "core/utils";
|
||||
import { DataPermissions } from "data";
|
||||
import type { Hono } from "hono";
|
||||
import { Controller, type ServerEnv } from "modules/Controller";
|
||||
import { describeRoute, jsc, s, parse, InvalidSchemaError, transformObject } from "bknd/utils";
|
||||
import { describeRoute, jsc, s, parse, InvalidSchemaError } from "bknd/core";
|
||||
|
||||
export type AuthActionResponse = {
|
||||
success: boolean;
|
||||
@@ -32,7 +30,7 @@ export class AuthController extends Controller {
|
||||
return this.em.repo(entity_name as "users");
|
||||
}
|
||||
|
||||
private registerStrategyActions(strategy: AuthStrategy, mainHono: Hono<ServerEnv>) {
|
||||
private registerStrategyActions(strategy: Strategy, mainHono: Hono<ServerEnv>) {
|
||||
if (!this.auth.isStrategyEnabled(strategy)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Permission } from "core/security/Permission";
|
||||
import { Permission } from "core";
|
||||
|
||||
export const createUser = new Permission("auth.user.create");
|
||||
//export const updateUser = new Permission("auth.user.update");
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { cookieConfig, jwtConfig } from "auth/authenticate/Authenticator";
|
||||
import { CustomOAuthStrategy, OAuthStrategy, PasswordStrategy } from "auth/authenticate/strategies";
|
||||
import { objectTransform, s } from "bknd/utils";
|
||||
import { objectTransform } from "core/utils";
|
||||
import { s } from "bknd/core";
|
||||
|
||||
export const Strategies = {
|
||||
password: {
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
import type { DB } from "bknd";
|
||||
import { Exception } from "core/errors";
|
||||
import { type DB, Exception } from "core";
|
||||
import { addFlashMessage } from "core/server/flash";
|
||||
import type { Context } from "hono";
|
||||
import { runtimeSupports, truncate, $console } from "core/utils";
|
||||
import type { Context, Hono } from "hono";
|
||||
import { deleteCookie, getSignedCookie, setSignedCookie } from "hono/cookie";
|
||||
import { sign, verify } from "hono/jwt";
|
||||
import { type CookieOptions, serializeSigned } from "hono/utils/cookie";
|
||||
import type { CookieOptions } from "hono/utils/cookie";
|
||||
import type { ServerEnv } from "modules/Controller";
|
||||
import { pick } from "lodash-es";
|
||||
import { InvalidConditionsException } from "auth/errors";
|
||||
import { s, parse, secret, runtimeSupports, truncate, $console } from "bknd/utils";
|
||||
import type { AuthStrategy } from "./strategies/Strategy";
|
||||
import { s, parse, secret } from "bknd/core";
|
||||
|
||||
type Input = any; // workaround
|
||||
export type JWTPayload = Parameters<typeof sign>[0];
|
||||
@@ -22,6 +21,17 @@ export type StrategyAction<S extends s.ObjectSchema = s.ObjectSchema> = {
|
||||
};
|
||||
export type StrategyActions = Partial<Record<StrategyActionName, StrategyAction>>;
|
||||
|
||||
// @todo: add schema to interface to ensure proper inference
|
||||
// @todo: add tests (e.g. invalid strategy_value)
|
||||
export interface Strategy {
|
||||
getController: (auth: Authenticator) => Hono<any>;
|
||||
getType: () => string;
|
||||
getMode: () => "form" | "external";
|
||||
getName: () => string;
|
||||
toJSON: (secrets?: boolean) => any;
|
||||
getActions?: () => StrategyActions;
|
||||
}
|
||||
|
||||
export type User = DB["users"];
|
||||
|
||||
export type ProfileExchange = {
|
||||
@@ -48,7 +58,6 @@ export const cookieConfig = s
|
||||
secure: s.boolean({ default: true }),
|
||||
httpOnly: s.boolean({ default: true }),
|
||||
expires: s.number({ default: defaultCookieExpires }), // seconds
|
||||
partitioned: s.boolean({ default: false }),
|
||||
renew: s.boolean({ default: true }),
|
||||
pathSuccess: s.string({ default: "/" }),
|
||||
pathLoggedOut: s.string({ default: "/" }),
|
||||
@@ -88,7 +97,7 @@ export type AuthResolveOptions = {
|
||||
};
|
||||
export type AuthUserResolver = (
|
||||
action: AuthAction,
|
||||
strategy: AuthStrategy,
|
||||
strategy: Strategy,
|
||||
profile: ProfileExchange,
|
||||
opts?: AuthResolveOptions,
|
||||
) => Promise<ProfileExchange | undefined>;
|
||||
@@ -98,9 +107,7 @@ type AuthClaims = SafeUser & {
|
||||
exp?: number;
|
||||
};
|
||||
|
||||
export class Authenticator<
|
||||
Strategies extends Record<string, AuthStrategy> = Record<string, AuthStrategy>,
|
||||
> {
|
||||
export class Authenticator<Strategies extends Record<string, Strategy> = Record<string, Strategy>> {
|
||||
private readonly config: AuthConfig;
|
||||
|
||||
constructor(
|
||||
@@ -113,7 +120,7 @@ export class Authenticator<
|
||||
|
||||
async resolveLogin(
|
||||
c: Context,
|
||||
strategy: AuthStrategy,
|
||||
strategy: Strategy,
|
||||
profile: Partial<SafeUser>,
|
||||
verify: (user: User) => Promise<void>,
|
||||
opts?: AuthResolveOptions,
|
||||
@@ -151,7 +158,7 @@ export class Authenticator<
|
||||
|
||||
async resolveRegister(
|
||||
c: Context,
|
||||
strategy: AuthStrategy,
|
||||
strategy: Strategy,
|
||||
profile: CreateUser,
|
||||
verify: (user: User) => Promise<void>,
|
||||
opts?: AuthResolveOptions,
|
||||
@@ -210,7 +217,7 @@ export class Authenticator<
|
||||
|
||||
await addFlashMessage(c, String(error), "error");
|
||||
|
||||
const referer = this.getSafeUrl(c, c.req.header("Referer") ?? "/");
|
||||
const referer = this.getSafeUrl(c, opts?.redirect ?? c.req.header("Referer") ?? "/");
|
||||
return c.redirect(referer);
|
||||
}
|
||||
|
||||
@@ -220,7 +227,7 @@ export class Authenticator<
|
||||
|
||||
strategy<
|
||||
StrategyName extends keyof Strategies,
|
||||
Strat extends AuthStrategy = Strategies[StrategyName],
|
||||
Strat extends Strategy = Strategies[StrategyName],
|
||||
>(strategy: StrategyName): Strat {
|
||||
try {
|
||||
return this.strategies[strategy] as unknown as Strat;
|
||||
@@ -327,11 +334,6 @@ export class Authenticator<
|
||||
await setSignedCookie(c, "auth", token, secret, this.cookieOptions);
|
||||
}
|
||||
|
||||
async unsafeGetAuthCookie(token: string): Promise<string | undefined> {
|
||||
// this works for as long as cookieOptions.prefix is not set
|
||||
return serializeSigned("auth", token, this.config.jwt.secret, this.cookieOptions);
|
||||
}
|
||||
|
||||
private deleteAuthCookie(c: Context) {
|
||||
$console.debug("deleting auth cookie");
|
||||
deleteCookie(c, "auth", this.cookieOptions);
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
import type { User } from "bknd";
|
||||
import type { Authenticator } from "auth/authenticate/Authenticator";
|
||||
import { InvalidCredentialsException } from "auth/errors";
|
||||
import { type Authenticator, InvalidCredentialsException, type User } from "auth";
|
||||
import { hash, $console } from "core/utils";
|
||||
import { Hono } from "hono";
|
||||
import { compare as bcryptCompare, genSalt as bcryptGenSalt, hash as bcryptHash } from "bcryptjs";
|
||||
import { AuthStrategy } from "./Strategy";
|
||||
import { s, parse, jsc } from "bknd/utils";
|
||||
import { Strategy } from "./Strategy";
|
||||
import { s, parse, jsc } from "bknd/core";
|
||||
|
||||
const schema = s
|
||||
.object({
|
||||
@@ -16,7 +14,7 @@ const schema = s
|
||||
|
||||
export type PasswordStrategyOptions = s.Static<typeof schema>;
|
||||
|
||||
export class PasswordStrategy extends AuthStrategy<typeof schema> {
|
||||
export class PasswordStrategy extends Strategy<typeof schema> {
|
||||
constructor(config: Partial<PasswordStrategyOptions> = {}) {
|
||||
super(config as any, "password", "password", "form");
|
||||
|
||||
|
||||
@@ -5,11 +5,11 @@ import type {
|
||||
StrategyActions,
|
||||
} from "../Authenticator";
|
||||
import type { Hono } from "hono";
|
||||
import { type s, parse } from "bknd/utils";
|
||||
import { type s, parse } from "bknd/core";
|
||||
|
||||
export type StrategyMode = "form" | "external";
|
||||
|
||||
export abstract class AuthStrategy<Schema extends s.Schema = s.Schema> {
|
||||
export abstract class Strategy<Schema extends s.Schema = s.Schema> {
|
||||
protected actions: StrategyActions = {};
|
||||
|
||||
constructor(
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type * as oauth from "oauth4webapi";
|
||||
import { OAuthStrategy } from "./OAuthStrategy";
|
||||
import { s } from "bknd/utils";
|
||||
import { s } from "bknd/core";
|
||||
|
||||
type SupportedTypes = "oauth2" | "oidc";
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import type { Authenticator, AuthAction } from "auth/authenticate/Authenticator";
|
||||
import type { AuthAction, Authenticator } from "auth";
|
||||
import { Exception, isDebug } from "core";
|
||||
import { filterKeys } from "core/utils";
|
||||
import { type Context, Hono } from "hono";
|
||||
import { getSignedCookie, setSignedCookie } from "hono/cookie";
|
||||
import * as oauth from "oauth4webapi";
|
||||
import * as issuers from "./issuers";
|
||||
import { s, filterKeys } from "bknd/utils";
|
||||
import { Exception } from "core/errors";
|
||||
import { isDebug } from "core/env";
|
||||
import { AuthStrategy } from "../Strategy";
|
||||
import { Strategy } from "auth/authenticate/strategies/Strategy";
|
||||
import { s } from "bknd/core";
|
||||
|
||||
type ConfiguredIssuers = keyof typeof issuers;
|
||||
type SupportedTypes = "oauth2" | "oidc";
|
||||
@@ -70,7 +70,7 @@ export class OAuthCallbackException extends Exception {
|
||||
}
|
||||
}
|
||||
|
||||
export class OAuthStrategy extends AuthStrategy<typeof schemaProvided> {
|
||||
export class OAuthStrategy extends Strategy<typeof schemaProvided> {
|
||||
constructor(config: ProvidedOAuthConfig) {
|
||||
super(config, "oauth", config.name, "external");
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { Exception } from "core/errors";
|
||||
import { Exception, Permission } from "core";
|
||||
import { $console, objectTransform } from "core/utils";
|
||||
import { Permission } from "core/security/Permission";
|
||||
import type { Context } from "hono";
|
||||
import type { ServerEnv } from "modules/Controller";
|
||||
import { Role } from "./Role";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Permission } from "core/security/Permission";
|
||||
import { Permission } from "core";
|
||||
|
||||
export class RolePermission {
|
||||
constructor(
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { Exception } from "core/errors";
|
||||
import { isDebug } from "core/env";
|
||||
import { HttpStatus } from "bknd/utils";
|
||||
import { Exception, isDebug } from "core";
|
||||
import { HttpStatus } from "core/utils";
|
||||
|
||||
export class AuthException extends Exception {
|
||||
getSafeErrorAndCode() {
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
export { UserExistsException, UserNotFoundException, InvalidCredentialsException } from "./errors";
|
||||
export {
|
||||
type ProfileExchange,
|
||||
type Strategy,
|
||||
type User,
|
||||
type SafeUser,
|
||||
type CreateUser,
|
||||
type AuthResponse,
|
||||
type UserPool,
|
||||
type AuthAction,
|
||||
type AuthUserResolver,
|
||||
Authenticator,
|
||||
authenticatorConfig,
|
||||
jwtConfig,
|
||||
} from "./authenticate/Authenticator";
|
||||
|
||||
export { AppAuth, type UserFieldSchema } from "./AppAuth";
|
||||
|
||||
export { Guard, type GuardUserContext, type GuardConfig } from "./authorize/Guard";
|
||||
export { Role } from "./authorize/Role";
|
||||
|
||||
export * as AuthPermissions from "./auth-permissions";
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { Permission } from "core/security/Permission";
|
||||
import { $console, patternMatch } from "bknd/utils";
|
||||
import type { Permission } from "core";
|
||||
import { $console, patternMatch } from "core/utils";
|
||||
import type { Context } from "hono";
|
||||
import { createMiddleware } from "hono/factory";
|
||||
import type { ServerEnv } from "modules/Controller";
|
||||
|
||||
@@ -5,7 +5,7 @@ import type { CliCommand } from "cli/types";
|
||||
import { typewriter, wait } from "cli/utils/cli";
|
||||
import { execAsync, getVersion } from "cli/utils/sys";
|
||||
import { Option } from "commander";
|
||||
import { env } from "bknd";
|
||||
import { env } from "core";
|
||||
import color from "picocolors";
|
||||
import { overridePackageJson, updateBkndPackages } from "./npm";
|
||||
import { type Template, templates, type TemplateSetupCtx } from "./templates";
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import type { Config } from "@libsql/client/node";
|
||||
import type { App, CreateAppConfig } from "App";
|
||||
import { StorageLocalAdapter } from "adapter/node/storage";
|
||||
import type { CliBkndConfig, CliCommand } from "cli/types";
|
||||
import { Option } from "commander";
|
||||
import { config, type App, type CreateAppConfig } from "bknd";
|
||||
import { config } from "core";
|
||||
import dotenv from "dotenv";
|
||||
import { registries } from "modules/registries";
|
||||
import c from "picocolors";
|
||||
@@ -15,8 +16,8 @@ import {
|
||||
serveStatic,
|
||||
startServer,
|
||||
} from "./platform";
|
||||
import { createRuntimeApp, makeConfig } from "bknd/adapter";
|
||||
import { colorizeConsole, isBun } from "bknd/utils";
|
||||
import { createRuntimeApp, makeConfig } from "adapter";
|
||||
import { colorizeConsole, isBun } from "core/utils";
|
||||
|
||||
const env_files = [".env", ".dev.vars"];
|
||||
dotenv.config({
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { PostHog } from "posthog-js-lite";
|
||||
import { getVersion } from "cli/utils/sys";
|
||||
import { env, isDebug } from "bknd";
|
||||
import { $console } from "bknd/utils";
|
||||
import { env, isDebug } from "core";
|
||||
import { $console } from "core/utils";
|
||||
|
||||
type Properties = { [p: string]: any };
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* These are package global defaults.
|
||||
*/
|
||||
import type { Generated } from "./types";
|
||||
import type { Generated } from "kysely";
|
||||
|
||||
export type PrimaryFieldType<IdType = number | string> = IdType | Generated<IdType>;
|
||||
|
||||
|
||||
@@ -6,3 +6,23 @@ export interface IEmailDriver<Data = unknown, Options = object> {
|
||||
options?: Options,
|
||||
): Promise<Data>;
|
||||
}
|
||||
|
||||
import type { BkndConfig } from "bknd";
|
||||
import { resendEmail, memoryCache } from "bknd/core";
|
||||
|
||||
export default {
|
||||
onBuilt: async (app) => {
|
||||
app.server.get("/send-email", async (c) => {
|
||||
if (await app.drivers?.email?.send("test@test.com", "Test", "Test")) {
|
||||
return c.text("success");
|
||||
}
|
||||
return c.text("failed");
|
||||
});
|
||||
},
|
||||
options: {
|
||||
drivers: {
|
||||
email: resendEmail({ apiKey: "..." }),
|
||||
cache: memoryCache(),
|
||||
},
|
||||
},
|
||||
} as const satisfies BkndConfig;
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
import type { Hono, MiddlewareHandler } from "hono";
|
||||
|
||||
export { Exception, BkndError } from "./errors";
|
||||
export { isDebug, env } from "./env";
|
||||
export { type PrimaryFieldType, config, type DB, type AppEntity } from "./config";
|
||||
export { AwsClient } from "./clients/aws/AwsClient";
|
||||
export {
|
||||
SimpleRenderer,
|
||||
type TemplateObject,
|
||||
type TemplateTypes,
|
||||
type SimpleRendererOptions,
|
||||
} from "./template/SimpleRenderer";
|
||||
export { SchemaObject } from "./object/SchemaObject";
|
||||
export { DebugLogger } from "./utils/DebugLogger";
|
||||
export { Permission } from "./security/Permission";
|
||||
export {
|
||||
exp,
|
||||
makeValidator,
|
||||
type FilterQuery,
|
||||
type Primitive,
|
||||
isPrimitive,
|
||||
type TExpression,
|
||||
type BooleanLike,
|
||||
isBooleanLike,
|
||||
} from "./object/query/query";
|
||||
export { Registry, type Constructor } from "./registry/Registry";
|
||||
export { getFlashMessage } from "./server/flash";
|
||||
export {
|
||||
s,
|
||||
stripMark,
|
||||
mark,
|
||||
stringIdentifier,
|
||||
secret,
|
||||
parse,
|
||||
jsc,
|
||||
describeRoute,
|
||||
schemaToSpec,
|
||||
openAPISpecs,
|
||||
type ParseOptions,
|
||||
InvalidSchemaError,
|
||||
} from "./object/schema";
|
||||
export * as $diff from "./object/diff";
|
||||
|
||||
export * from "./drivers";
|
||||
export * from "./events";
|
||||
|
||||
// compatibility
|
||||
export type Middleware = MiddlewareHandler<any, any, any>;
|
||||
export interface ClassController {
|
||||
getController: () => Hono<any, any, any>;
|
||||
getMiddleware?: MiddlewareHandler<any, any, any>;
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
import { get, has, omit, set } from "lodash-es";
|
||||
import { type s, parse, stripMark, getFullPathKeys, mergeObjectWith, deepFreeze } from "bknd/utils";
|
||||
import { getFullPathKeys, mergeObjectWith } from "../utils";
|
||||
import { type s, parse, stripMark } from "bknd/core";
|
||||
|
||||
export type SchemaObjectOptions<Schema extends s.Schema> = {
|
||||
onUpdate?: (config: s.Static<Schema>) => void | Promise<void>;
|
||||
@@ -25,16 +26,14 @@ export class SchemaObject<Schema extends TSchema = TSchema> {
|
||||
initial?: Partial<s.Static<Schema>>,
|
||||
private options?: SchemaObjectOptions<Schema>,
|
||||
) {
|
||||
this._default = deepFreeze(_schema.template({}, { withOptional: true }) as any);
|
||||
this._value = deepFreeze(
|
||||
parse(_schema, structuredClone(initial ?? {}), {
|
||||
withDefaults: true,
|
||||
withExtendedDefaults: true,
|
||||
forceParse: this.isForceParse(),
|
||||
skipMark: this.isForceParse(),
|
||||
}),
|
||||
);
|
||||
this._config = deepFreeze(this._value);
|
||||
this._default = _schema.template({}, { withOptional: true }) as any;
|
||||
this._value = parse(_schema, structuredClone(initial ?? {}), {
|
||||
withDefaults: true,
|
||||
withExtendedDefaults: true,
|
||||
forceParse: this.isForceParse(),
|
||||
skipMark: this.isForceParse(),
|
||||
});
|
||||
this._config = Object.freeze(this._value);
|
||||
}
|
||||
|
||||
protected isForceParse(): boolean {
|
||||
@@ -77,8 +76,8 @@ export class SchemaObject<Schema extends TSchema = TSchema> {
|
||||
// regardless of "noEmit" – this should always be triggered
|
||||
const updatedConfig = await this.onBeforeUpdate(this._config, valid);
|
||||
|
||||
this._value = deepFreeze(updatedConfig);
|
||||
this._config = deepFreeze(updatedConfig);
|
||||
this._value = updatedConfig;
|
||||
this._config = Object.freeze(updatedConfig);
|
||||
|
||||
if (noEmit !== true) {
|
||||
await this.options?.onUpdate?.(this._config);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { PrimaryFieldType } from "core/config";
|
||||
import type { PrimaryFieldType } from "core";
|
||||
|
||||
export type Primitive = PrimaryFieldType | string | number | boolean;
|
||||
export function isPrimitive(value: any): value is Primitive {
|
||||
|
||||
@@ -3,7 +3,7 @@ import * as s from "jsonv-ts";
|
||||
export { validator as jsc, type Options } from "jsonv-ts/hono";
|
||||
export { describeRoute, schemaToSpec, openAPISpecs } from "jsonv-ts/hono";
|
||||
|
||||
export { secret, SecretSchema } from "./secret";
|
||||
export { secret } from "./secret";
|
||||
|
||||
export { s };
|
||||
|
||||
@@ -42,7 +42,6 @@ export type ParseOptions = {
|
||||
withDefaults?: boolean;
|
||||
withExtendedDefaults?: boolean;
|
||||
coerce?: boolean;
|
||||
coerceDropUnknown?: boolean;
|
||||
clone?: boolean;
|
||||
skipMark?: boolean; // @todo: do something with this
|
||||
forceParse?: boolean; // @todo: do something with this
|
||||
@@ -60,10 +59,7 @@ export function parse<S extends s.Schema, Options extends ParseOptions = ParseOp
|
||||
opts?: Options,
|
||||
): Options extends { coerce: true } ? s.StaticCoerced<S> : s.Static<S> {
|
||||
const schema = (opts?.clone ? cloneSchema(_schema as any) : _schema) as s.Schema;
|
||||
let value =
|
||||
opts?.coerce !== false
|
||||
? schema.coerce(v, { dropUnknown: opts?.coerceDropUnknown ?? false })
|
||||
: v;
|
||||
let value = opts?.coerce !== false ? schema.coerce(v) : v;
|
||||
if (opts?.withDefaults !== false) {
|
||||
value = schema.template(value, {
|
||||
withOptional: true,
|
||||
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { SimpleRenderer } from "./SimpleRenderer";
|
||||
import { SimpleRenderer } from "core";
|
||||
|
||||
describe(SimpleRenderer, () => {
|
||||
const renderer = new SimpleRenderer(
|
||||
|
||||
@@ -4,194 +4,3 @@ export interface Serializable<Class, Json extends object = object> {
|
||||
}
|
||||
|
||||
export type MaybePromise<T> = T | Promise<T>;
|
||||
|
||||
/**
|
||||
* Types below are copied from kysely.
|
||||
*/
|
||||
|
||||
export type DrainOuterGeneric<T> = [T] extends [unknown] ? T : never;
|
||||
/**
|
||||
* This type can be used to specify a different type for
|
||||
* select, insert and update operations.
|
||||
*
|
||||
* Also see the {@link Generated} type.
|
||||
*
|
||||
* ### Examples
|
||||
*
|
||||
* The next example defines a number column that is optional
|
||||
* in inserts and updates. All columns are always optional
|
||||
* in updates so therefore we don't need to specify `undefined`
|
||||
* for the update type. The type below is useful for all kinds of
|
||||
* database generated columns like identifiers. The `Generated`
|
||||
* type is actually just a shortcut for the type in this example:
|
||||
*
|
||||
* ```ts
|
||||
* type GeneratedNumber = ColumnType<number, number | undefined, number>
|
||||
* ```
|
||||
*
|
||||
* The above example makes the column optional in inserts
|
||||
* and updates, but you can still choose to provide the
|
||||
* column. If you want to prevent insertion/update you
|
||||
* can se the type as `never`:
|
||||
*
|
||||
* ```ts
|
||||
* type ReadonlyNumber = ColumnType<number, never, never>
|
||||
* ```
|
||||
*
|
||||
* Here's one more example where the type is different
|
||||
* for each different operation:
|
||||
*
|
||||
* ```ts
|
||||
* type UnupdateableDate = ColumnType<Date, string, never>
|
||||
* ```
|
||||
*/
|
||||
export type ColumnType<SelectType, InsertType = SelectType, UpdateType = SelectType> = {
|
||||
readonly __select__: SelectType;
|
||||
readonly __insert__: InsertType;
|
||||
readonly __update__: UpdateType;
|
||||
};
|
||||
/**
|
||||
* A shortcut for defining database-generated columns. The type
|
||||
* is the same for all selects, inserts and updates but the
|
||||
* column is optional for inserts and updates.
|
||||
*
|
||||
* The update type is `S` instead of `S | undefined` because updates are always
|
||||
* optional --> no need to specify optionality.
|
||||
* ```
|
||||
*/
|
||||
export type Generated<S> = ColumnType<S, S | undefined, S>;
|
||||
/**
|
||||
* A shortcut for defining columns that are only database-generated
|
||||
* (like postgres GENERATED ALWAYS AS IDENTITY). No insert/update
|
||||
* is allowed.
|
||||
*/
|
||||
export type GeneratedAlways<S> = ColumnType<S, never, never>;
|
||||
/**
|
||||
* A shortcut for defining JSON columns, which are by default inserted/updated
|
||||
* as stringified JSON strings.
|
||||
*/
|
||||
export type JSONColumnType<
|
||||
SelectType extends object | null,
|
||||
InsertType = string,
|
||||
UpdateType = string,
|
||||
> = ColumnType<SelectType, InsertType, UpdateType>;
|
||||
/**
|
||||
* Evaluates to `K` if `T` can be `null` or `undefined`.
|
||||
*/
|
||||
type IfNullable<T, K> = undefined extends T ? K : null extends T ? K : never;
|
||||
/**
|
||||
* Evaluates to `K` if `T` can't be `null` or `undefined`.
|
||||
*/
|
||||
type IfNotNullable<T, K> = undefined extends T
|
||||
? never
|
||||
: null extends T
|
||||
? never
|
||||
: T extends never
|
||||
? never
|
||||
: K;
|
||||
/**
|
||||
* Evaluates to `K` if `T` isn't `never`.
|
||||
*/
|
||||
type IfNotNever<T, K> = T extends never ? never : K;
|
||||
export type SelectType<T> = T extends ColumnType<infer S, any, any> ? S : T;
|
||||
export type InsertType<T> = T extends ColumnType<any, infer I, any> ? I : T;
|
||||
export type UpdateType<T> = T extends ColumnType<any, any, infer U> ? U : T;
|
||||
/**
|
||||
* Keys of `R` whose `InsertType` values can be `null` or `undefined`.
|
||||
*/
|
||||
export type NullableInsertKeys<R> = {
|
||||
[K in keyof R]: IfNullable<InsertType<R[K]>, K>;
|
||||
}[keyof R];
|
||||
/**
|
||||
* Keys of `R` whose `InsertType` values can't be `null` or `undefined`.
|
||||
*/
|
||||
export type NonNullableInsertKeys<R> = {
|
||||
[K in keyof R]: IfNotNullable<InsertType<R[K]>, K>;
|
||||
}[keyof R];
|
||||
/**
|
||||
* Keys of `R` whose `SelectType` values are not `never`
|
||||
*/
|
||||
type NonNeverSelectKeys<R> = {
|
||||
[K in keyof R]: IfNotNever<SelectType<R[K]>, K>;
|
||||
}[keyof R];
|
||||
/**
|
||||
* Keys of `R` whose `UpdateType` values are not `never`
|
||||
*/
|
||||
export type UpdateKeys<R> = {
|
||||
[K in keyof R]: IfNotNever<UpdateType<R[K]>, K>;
|
||||
}[keyof R];
|
||||
/**
|
||||
* Given a table interface, extracts the select type from all
|
||||
* {@link ColumnType} types.
|
||||
*
|
||||
* ### Examples
|
||||
*
|
||||
* ```ts
|
||||
* interface PersonTable {
|
||||
* id: Generated<number>
|
||||
* first_name: string
|
||||
* modified_at: ColumnType<Date, string, never>
|
||||
* }
|
||||
*
|
||||
* type Person = Selectable<PersonTable>
|
||||
* // {
|
||||
* // id: number,
|
||||
* // first_name: string
|
||||
* // modified_at: Date
|
||||
* // }
|
||||
* ```
|
||||
*/
|
||||
export type Selectable<R> = DrainOuterGeneric<{
|
||||
[K in NonNeverSelectKeys<R>]: SelectType<R[K]>;
|
||||
}>;
|
||||
/**
|
||||
* Given a table interface, extracts the insert type from all
|
||||
* {@link ColumnType} types.
|
||||
*
|
||||
* ### Examples
|
||||
*
|
||||
* ```ts
|
||||
* interface PersonTable {
|
||||
* id: Generated<number>
|
||||
* first_name: string
|
||||
* modified_at: ColumnType<Date, string, never>
|
||||
* }
|
||||
*
|
||||
* type InsertablePerson = Insertable<PersonTable>
|
||||
* // {
|
||||
* // id?: number,
|
||||
* // first_name: string
|
||||
* // modified_at: string
|
||||
* // }
|
||||
* ```
|
||||
*/
|
||||
export type Insertable<R> = DrainOuterGeneric<
|
||||
{
|
||||
[K in NonNullableInsertKeys<R>]: InsertType<R[K]>;
|
||||
} & {
|
||||
[K in NullableInsertKeys<R>]?: InsertType<R[K]>;
|
||||
}
|
||||
>;
|
||||
/**
|
||||
* Given a table interface, extracts the update type from all
|
||||
* {@link ColumnType} types.
|
||||
*
|
||||
* ### Examples
|
||||
*
|
||||
* ```ts
|
||||
* interface PersonTable {
|
||||
* id: Generated<number>
|
||||
* first_name: string
|
||||
* modified_at: ColumnType<Date, string, never>
|
||||
* }
|
||||
*
|
||||
* type UpdateablePerson = Updateable<PersonTable>
|
||||
* // {
|
||||
* // id?: number,
|
||||
* // first_name?: string
|
||||
* // }
|
||||
* ```
|
||||
*/
|
||||
export type Updateable<R> = DrainOuterGeneric<{
|
||||
[K in UpdateKeys<R>]?: UpdateType<R[K]>;
|
||||
}>;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { datetimeStringLocal } from "./dates";
|
||||
import { datetimeStringLocal } from "core/utils";
|
||||
import colors from "picocolors";
|
||||
import { env } from "core/env";
|
||||
import { env } from "core";
|
||||
|
||||
function hasColors() {
|
||||
try {
|
||||
|
||||
@@ -13,18 +13,3 @@ export * from "./uuid";
|
||||
export * from "./test";
|
||||
export * from "./runtime";
|
||||
export * from "./numbers";
|
||||
export {
|
||||
s,
|
||||
stripMark,
|
||||
mark,
|
||||
stringIdentifier,
|
||||
SecretSchema,
|
||||
secret,
|
||||
parse,
|
||||
jsc,
|
||||
describeRoute,
|
||||
schemaToSpec,
|
||||
openAPISpecs,
|
||||
type ParseOptions,
|
||||
InvalidSchemaError,
|
||||
} from "./schema";
|
||||
|
||||
@@ -94,14 +94,16 @@ export function transformObject<T extends Record<string, any>, U>(
|
||||
object: T,
|
||||
transform: (value: T[keyof T], key: keyof T) => U | undefined,
|
||||
): { [K in keyof T]: U } {
|
||||
const result = {} as { [K in keyof T]: U };
|
||||
for (const [key, value] of Object.entries(object) as [keyof T, T[keyof T]][]) {
|
||||
const t = transform(value, key);
|
||||
if (typeof t !== "undefined") {
|
||||
result[key] = t;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
return Object.entries(object).reduce(
|
||||
(acc, [key, value]) => {
|
||||
const t = transform(value, key as keyof T);
|
||||
if (typeof t !== "undefined") {
|
||||
acc[key as keyof T] = t;
|
||||
}
|
||||
return acc;
|
||||
},
|
||||
{} as { [K in keyof T]: U },
|
||||
);
|
||||
}
|
||||
export const objectTransform = transformObject;
|
||||
|
||||
@@ -417,21 +419,3 @@ export function pick<T extends object, K extends keyof T>(obj: T, keys: K[]): Pi
|
||||
{} as Pick<T, K>,
|
||||
);
|
||||
}
|
||||
|
||||
export function deepFreeze<T extends object>(object: T): T {
|
||||
if (Object.isFrozen(object)) return object;
|
||||
|
||||
// Retrieve the property names defined on object
|
||||
const propNames = Reflect.ownKeys(object);
|
||||
|
||||
// Freeze properties before freezing self
|
||||
for (const name of propNames) {
|
||||
const value = object[name];
|
||||
|
||||
if ((value && typeof value === "object") || typeof value === "function") {
|
||||
deepFreeze(value);
|
||||
}
|
||||
}
|
||||
|
||||
return Object.freeze(object);
|
||||
}
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
import { transformObject } from "core/utils";
|
||||
|
||||
import {
|
||||
DataPermissions,
|
||||
type Entity,
|
||||
EntityIndex,
|
||||
type EntityManager,
|
||||
constructEntity,
|
||||
constructRelation,
|
||||
} from "data";
|
||||
import { Module } from "modules/Module";
|
||||
import { DataController } from "./api/DataController";
|
||||
import { type AppDataConfig, dataConfigSchema } from "./data-schema";
|
||||
import { constructEntity, constructRelation } from "./schema/constructor";
|
||||
import type { Entity, EntityManager } from "data/entities";
|
||||
import { EntityIndex } from "data/fields";
|
||||
import * as DataPermissions from "data/permissions";
|
||||
|
||||
export class AppData extends Module<AppDataConfig> {
|
||||
override async build() {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import type { DB, EntityData, RepoQueryIn, Insertable, Selectable, Updateable } from "bknd";
|
||||
|
||||
import type { DB } from "core";
|
||||
import type { EntityData, RepoQueryIn, RepositoryResultJSON } from "data";
|
||||
import type { Insertable, Selectable, Updateable } from "kysely";
|
||||
import { type BaseModuleApiOptions, ModuleApi, type PrimaryFieldType } from "modules";
|
||||
import type { FetchPromise, ResponseObject } from "modules/ModuleApi";
|
||||
import type { RepositoryResultJSON } from "data/entities/query/RepositoryResult";
|
||||
|
||||
export type DataApiOptions = BaseModuleApiOptions & {
|
||||
queryLengthLimit: number;
|
||||
|
||||
@@ -1,12 +1,17 @@
|
||||
import {
|
||||
DataPermissions,
|
||||
type EntityData,
|
||||
type EntityManager,
|
||||
type RepoQuery,
|
||||
repoQuery,
|
||||
} from "data";
|
||||
import type { Handler } from "hono/types";
|
||||
import type { ModuleBuildContext } from "modules";
|
||||
import { Controller } from "modules/Controller";
|
||||
import { jsc, s, describeRoute, schemaToSpec, omitKeys } from "bknd/utils";
|
||||
import { jsc, s, describeRoute, schemaToSpec } from "bknd/core";
|
||||
import * as SystemPermissions from "modules/permissions";
|
||||
import type { AppDataConfig } from "../data-schema";
|
||||
import type { EntityManager, EntityData } from "data/entities";
|
||||
import * as DataPermissions from "data/permissions";
|
||||
import { repoQuery, type RepoQuery } from "data/server/query";
|
||||
import { omitKeys } from "core/utils";
|
||||
|
||||
export class DataController extends Controller {
|
||||
constructor(
|
||||
@@ -201,7 +206,7 @@ export class DataController extends Controller {
|
||||
|
||||
const entitiesEnum = this.getEntitiesEnum(this.em);
|
||||
// @todo: make dynamic based on entity
|
||||
const idType = s.anyOf([s.number(), s.string()], { coerce: (v) => v as number | string });
|
||||
const idType = s.anyOf([s.number(), s.string()], { coerce: (v) => v as any });
|
||||
|
||||
/**
|
||||
* Function endpoints
|
||||
@@ -382,7 +387,7 @@ export class DataController extends Controller {
|
||||
if (!this.entityExists(entity)) {
|
||||
return this.notFound(c);
|
||||
}
|
||||
const options = c.req.valid("json") as RepoQuery;
|
||||
const options = (await c.req.json()) as RepoQuery;
|
||||
const result = await this.em.repository(entity).findMany(options);
|
||||
|
||||
return c.json(result, { status: result.data ? 200 : 404 });
|
||||
@@ -392,7 +397,7 @@ export class DataController extends Controller {
|
||||
/**
|
||||
* Mutation endpoints
|
||||
*/
|
||||
// insert one or many
|
||||
// insert one
|
||||
hono.post(
|
||||
"/:entity",
|
||||
describeRoute({
|
||||
|
||||
@@ -18,8 +18,7 @@ import {
|
||||
sql,
|
||||
} from "kysely";
|
||||
import type { BaseIntrospector, BaseIntrospectorConfig } from "./BaseIntrospector";
|
||||
import type { DB } from "bknd";
|
||||
import type { Constructor } from "core/registry/Registry";
|
||||
import type { Constructor, DB } from "core";
|
||||
import { KyselyPluginRunner } from "data/plugins/KyselyPluginRunner";
|
||||
import type { Field } from "data/fields/Field";
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user