diff --git a/app/__test__/api/MediaApi.spec.ts b/app/__test__/api/MediaApi.spec.ts
index a479d19..95cac8e 100644
--- a/app/__test__/api/MediaApi.spec.ts
+++ b/app/__test__/api/MediaApi.spec.ts
@@ -1,8 +1,8 @@
///
import { describe, expect, it } from "bun:test";
import { Hono } from "hono";
-import { getFileFromContext, isFile, isReadableStream } from "../../src/core/utils";
-import { MediaApi } from "../../src/media/api/MediaApi";
+import { getFileFromContext, isFile, isReadableStream } from "core/utils";
+import { MediaApi } from "media/api/MediaApi";
import { assetsPath, assetsTmpPath } from "../helper";
const mockedBackend = new Hono()
@@ -39,10 +39,28 @@ describe("MediaApi", () => {
// @ts-ignore tests
const api = new MediaApi({
token: "token",
+ token_transport: "header",
});
expect(api.getUploadHeaders().get("Authorization")).toBe("Bearer token");
});
+ it("should return empty headers if not using `header` transport", () => {
+ expect(
+ new MediaApi({
+ token_transport: "cookie",
+ })
+ .getUploadHeaders()
+ .has("Authorization"),
+ ).toBe(false);
+ expect(
+ new MediaApi({
+ token_transport: "none",
+ })
+ .getUploadHeaders()
+ .has("Authorization"),
+ ).toBe(false);
+ });
+
it("should get file: native", async () => {
const name = "image.png";
const path = `${assetsTmpPath}/${name}`;
@@ -103,8 +121,12 @@ describe("MediaApi", () => {
});
it("should upload file in various ways", async () => {
- // @ts-ignore tests
- const api = new MediaApi({}, mockedBackend.request);
+ const api = new MediaApi(
+ {
+ upload_fetcher: mockedBackend.request,
+ },
+ mockedBackend.request,
+ );
const file = Bun.file(`${assetsPath}/image.png`);
async function matches(req: Promise, filename: string) {
diff --git a/app/__test__/core/Registry.spec.ts b/app/__test__/core/Registry.spec.ts
index 637a836..2a11250 100644
--- a/app/__test__/core/Registry.spec.ts
+++ b/app/__test__/core/Registry.spec.ts
@@ -1,7 +1,6 @@
import { describe, expect, test } from "bun:test";
-import type { TObject, TString } from "@sinclair/typebox";
-import { Registry } from "../../src/core/registry/Registry";
-import { type TSchema, Type } from "../../src/core/utils";
+import { type TObject, type TString, Type } from "@sinclair/typebox";
+import { Registry } from "core";
type Constructor = new (...args: any[]) => T;
diff --git a/app/__test__/core/object/SchemaObject.spec.ts b/app/__test__/core/object/SchemaObject.spec.ts
index 0c745e4..580ab57 100644
--- a/app/__test__/core/object/SchemaObject.spec.ts
+++ b/app/__test__/core/object/SchemaObject.spec.ts
@@ -1,6 +1,6 @@
import { describe, expect, test } from "bun:test";
import { SchemaObject } from "../../../src/core";
-import { Type } from "../../../src/core/utils";
+import { Type } from "@sinclair/typebox";
describe("SchemaObject", async () => {
test("basic", async () => {
diff --git a/app/__test__/data/specs/Entity.spec.ts b/app/__test__/data/specs/Entity.spec.ts
index 358c106..033d10b 100644
--- a/app/__test__/data/specs/Entity.spec.ts
+++ b/app/__test__/data/specs/Entity.spec.ts
@@ -1,5 +1,6 @@
import { describe, expect, test } from "bun:test";
-import { Entity, NumberField, TextField } from "../../../src/data";
+import { Entity, NumberField, TextField } from "data";
+import * as p from "data/prototype";
describe("[data] Entity", async () => {
const entity = new Entity("test", [
@@ -47,14 +48,7 @@ describe("[data] Entity", async () => {
expect(entity.getField("new_field")).toBe(field);
});
- // @todo: move this to ClientApp
- /*test("serialize and deserialize", async () => {
- const json = entity.toJSON();
- //sconsole.log("json", json.fields);
- const newEntity = Entity.deserialize(json);
- //console.log("newEntity", newEntity.toJSON().fields);
- expect(newEntity).toBeInstanceOf(Entity);
- expect(json).toEqual(newEntity.toJSON());
- expect(json.fields).toEqual(newEntity.toJSON().fields);
- });*/
+ test.only("types", async () => {
+ console.log(entity.toTypes());
+ });
});
diff --git a/app/__test__/data/specs/EntityManager.spec.ts b/app/__test__/data/specs/EntityManager.spec.ts
index c9b5dba..6401995 100644
--- a/app/__test__/data/specs/EntityManager.spec.ts
+++ b/app/__test__/data/specs/EntityManager.spec.ts
@@ -47,8 +47,8 @@ describe("[data] EntityManager", async () => {
em.addRelation(new ManyToOneRelation(posts, users));
expect(em.relations.all.length).toBe(1);
expect(em.relations.all[0]).toBeInstanceOf(ManyToOneRelation);
- expect(em.relationsOf("users")).toEqual([em.relations.all[0]]);
- expect(em.relationsOf("posts")).toEqual([em.relations.all[0]]);
+ expect(em.relationsOf("users")).toEqual([em.relations.all[0]!]);
+ expect(em.relationsOf("posts")).toEqual([em.relations.all[0]!]);
expect(em.hasRelations("users")).toBe(true);
expect(em.hasRelations("posts")).toBe(true);
expect(em.relatedEntitiesOf("users")).toEqual([posts]);
diff --git a/app/__test__/data/specs/Repository.spec.ts b/app/__test__/data/specs/Repository.spec.ts
index f50ca83..54254d4 100644
--- a/app/__test__/data/specs/Repository.spec.ts
+++ b/app/__test__/data/specs/Repository.spec.ts
@@ -266,5 +266,12 @@ describe("[data] Repository (Events)", async () => {
expect(events.has(RepositoryEvents.RepositoryFindManyBefore.slug)).toBeTrue();
expect(events.has(RepositoryEvents.RepositoryFindManyAfter.slug)).toBeTrue();
events.clear();
+
+ // check find one on findMany with limit 1
+ await repo.findMany({ where: { id: 1 }, limit: 1 });
+ await repo.emgr.executeAsyncs();
+ expect(events.has(RepositoryEvents.RepositoryFindOneBefore.slug)).toBeTrue();
+ expect(events.has(RepositoryEvents.RepositoryFindOneAfter.slug)).toBeTrue();
+ events.clear();
});
});
diff --git a/app/__test__/data/specs/fields/FieldIndex.spec.ts b/app/__test__/data/specs/fields/FieldIndex.spec.ts
index 0dd656c..1337f63 100644
--- a/app/__test__/data/specs/fields/FieldIndex.spec.ts
+++ b/app/__test__/data/specs/fields/FieldIndex.spec.ts
@@ -1,5 +1,5 @@
import { describe, expect, test } from "bun:test";
-import { Type } from "../../../../src/core/utils";
+import { Type } from "@sinclair/typebox";
import { Entity, EntityIndex, Field } from "../../../../src/data";
class TestField extends Field {
diff --git a/app/__test__/flows/SubWorkflowTask.spec.ts b/app/__test__/flows/SubWorkflowTask.spec.ts
index c52a0a2..e43473a 100644
--- a/app/__test__/flows/SubWorkflowTask.spec.ts
+++ b/app/__test__/flows/SubWorkflowTask.spec.ts
@@ -1,5 +1,23 @@
import { describe, expect, test } from "bun:test";
-import { Flow, LogTask, RenderTask, SubFlowTask } from "../../src/flows";
+import { Flow, LogTask, SubFlowTask, RenderTask, Task } from "../../src/flows";
+import { Type } from "@sinclair/typebox";
+
+export class StringifyTask