fix schema import path

This commit is contained in:
dswbx
2025-07-07 16:09:29 +02:00
parent 43c8f14470
commit 88ec3432a0
97 changed files with 180 additions and 180 deletions
+1 -1
View File
@@ -6,7 +6,7 @@ import { dataConfigSchema } from "../../src/data/data-schema";
import * as proto from "../../src/data/prototype"; import * as proto from "../../src/data/prototype";
import { schemaToEm } from "../helper"; import { schemaToEm } from "../helper";
import { disableConsoleLog, enableConsoleLog } from "core/utils/test"; import { disableConsoleLog, enableConsoleLog } from "core/utils/test";
import { parse } from "core/object/schema"; import { parse } from "bknd/core";
beforeAll(disableConsoleLog); beforeAll(disableConsoleLog);
afterAll(enableConsoleLog); afterAll(enableConsoleLog);
+1 -1
View File
@@ -2,7 +2,7 @@ import { describe, expect, test } from "bun:test";
import { Authenticator, type User, type UserPool } from "../../src/auth"; import { Authenticator, type User, type UserPool } from "../../src/auth";
import { cookieConfig } from "../../src/auth/authenticate/Authenticator"; import { cookieConfig } from "../../src/auth/authenticate/Authenticator";
import { PasswordStrategy } from "../../src/auth/authenticate/strategies/PasswordStrategy"; import { PasswordStrategy } from "../../src/auth/authenticate/strategies/PasswordStrategy";
import { parse } from "core/object/schema"; import { parse } from "bknd/core";
/*class MemoryUserPool implements UserPool { /*class MemoryUserPool implements UserPool {
constructor(private users: User[] = []) {} constructor(private users: User[] = []) {}
+1 -1
View File
@@ -1,6 +1,6 @@
import { describe, expect, test } from "bun:test"; import { describe, expect, test } from "bun:test";
import { Registry } from "core"; import { Registry } from "core";
import { s } from "core/object/schema"; import { s } from "bknd/core";
type Constructor<T> = new (...args: any[]) => T; type Constructor<T> = new (...args: any[]) => T;
@@ -1,6 +1,6 @@
import { describe, expect, test } from "bun:test"; import { describe, expect, test } from "bun:test";
import { SchemaObject } from "../../../src/core"; import { SchemaObject } from "../../../src/core";
import { s } from "core/object/schema"; import { s } from "bknd/core";
describe("SchemaObject", async () => { describe("SchemaObject", async () => {
test("basic", async () => { test("basic", async () => {
+1 -1
View File
@@ -1,7 +1,7 @@
import { afterAll, beforeAll, describe, expect, test } from "bun:test"; import { afterAll, beforeAll, describe, expect, test } from "bun:test";
import { Guard } from "../../src/auth"; import { Guard } from "../../src/auth";
import { parse } from "core/object/schema"; import { parse } from "bknd/core";
import { import {
Entity, Entity,
type EntityData, type EntityData,
+1 -1
View File
@@ -1,5 +1,5 @@
import { afterAll, expect as bunExpect, describe, test } from "bun:test"; import { afterAll, expect as bunExpect, describe, test } from "bun:test";
import { stripMark } from "core/object/schema"; import { stripMark } from "bknd/core";
import { Entity, EntityManager, PolymorphicRelation, TextField } from "../../src/data"; import { Entity, EntityManager, PolymorphicRelation, TextField } from "../../src/data";
import { getDummyConnection } from "./helper"; import { getDummyConnection } from "./helper";
+1 -1
View File
@@ -2,7 +2,7 @@ import { describe, expect, test } from "bun:test";
import { baseFieldConfigSchema, Field } from "../../../../src/data/fields/Field"; import { baseFieldConfigSchema, Field } from "../../../../src/data/fields/Field";
import { fieldTestSuite } from "data/fields/field-test-suite"; import { fieldTestSuite } from "data/fields/field-test-suite";
import { bunTestRunner } from "adapter/bun/test"; import { bunTestRunner } from "adapter/bun/test";
import { stripMark } from "core/object/schema"; import { stripMark } from "bknd/core";
describe("[data] Field", async () => { describe("[data] Field", async () => {
class FieldSpec extends Field { class FieldSpec extends Field {
@@ -1,6 +1,6 @@
import { describe, expect, test } from "bun:test"; import { describe, expect, test } from "bun:test";
import { Entity, EntityIndex, Field } from "../../../../src/data"; import { Entity, EntityIndex, Field } from "../../../../src/data";
import { s } from "core/object/schema"; import { s } from "bknd/core";
class TestField extends Field { class TestField extends Field {
protected getSchema(): any { protected getSchema(): any {
+1 -1
View File
@@ -1,6 +1,6 @@
import { describe, expect, test } from "bun:test"; import { describe, expect, test } from "bun:test";
import { Flow, LogTask, SubFlowTask, RenderTask, Task } from "../../src/flows"; import { Flow, LogTask, SubFlowTask, RenderTask, Task } from "../../src/flows";
import { s } from "core/object/schema"; import { s } from "bknd/core";
export class StringifyTask<Output extends string> extends Task< export class StringifyTask<Output extends string> extends Task<
typeof StringifyTask.schema, typeof StringifyTask.schema,
+1 -1
View File
@@ -1,7 +1,7 @@
import { describe, expect, test } from "bun:test"; import { describe, expect, test } from "bun:test";
import { Task } from "../../src/flows"; import { Task } from "../../src/flows";
import { dynamic } from "../../src/flows/tasks/Task"; import { dynamic } from "../../src/flows/tasks/Task";
import { s } from "core/object/schema"; import { s } from "bknd/core";
describe.skip("Task", async () => { describe.skip("Task", async () => {
test("resolveParams: template with parse", async () => { test("resolveParams: template with parse", async () => {
+1 -1
View File
@@ -1,7 +1,7 @@
import { describe, expect, test } from "bun:test"; import { describe, expect, test } from "bun:test";
import { Hono } from "hono"; import { Hono } from "hono";
import { Event, EventManager } from "../../src/core/events"; import { Event, EventManager } from "../../src/core/events";
import { s, parse } from "core/object/schema"; import { s, parse } from "bknd/core";
import { EventTrigger, Flow, HttpTrigger, type InputsMap, Task } from "../../src/flows"; import { EventTrigger, Flow, HttpTrigger, type InputsMap, Task } from "../../src/flows";
import { dynamic } from "../../src/flows/tasks/Task"; import { dynamic } from "../../src/flows/tasks/Task";
+1 -1
View File
@@ -2,7 +2,7 @@
import { describe, expect, test } from "bun:test"; import { describe, expect, test } from "bun:test";
import { isEqual } from "lodash-es"; import { isEqual } from "lodash-es";
import { _jsonp, withDisabledConsole } from "../../src/core/utils"; import { _jsonp, withDisabledConsole } from "../../src/core/utils";
import { s } from "core/object/schema"; import { s } from "bknd/core";
import { Condition, ExecutionEvent, FetchTask, Flow, LogTask, Task } from "../../src/flows"; import { Condition, ExecutionEvent, FetchTask, Flow, LogTask, Task } from "../../src/flows";
/*beforeAll(disableConsoleLog); /*beforeAll(disableConsoleLog);
+1 -1
View File
@@ -1,5 +1,5 @@
import { beforeEach, describe, expect, test } from "bun:test"; import { beforeEach, describe, expect, test } from "bun:test";
import { parse } from "core/object/schema"; import { parse } from "bknd/core";
import { fieldsSchema } from "../../src/data/data-schema"; import { fieldsSchema } from "../../src/data/data-schema";
import { AppData, type ModuleBuildContext } from "../../src/modules"; import { AppData, type ModuleBuildContext } from "../../src/modules";
import { makeCtx, moduleTestSuite } from "./module-test-suite"; import { makeCtx, moduleTestSuite } from "./module-test-suite";
+1 -1
View File
@@ -1,5 +1,5 @@
import { describe, expect, test } from "bun:test"; import { describe, expect, test } from "bun:test";
import { s, stripMark } from "core/object/schema"; import { s, stripMark } from "bknd/core";
import { EntityManager, em, entity, index, text } from "../../src/data"; import { EntityManager, em, entity, index, text } from "../../src/data";
import { DummyConnection } from "../../src/data/connection/DummyConnection"; import { DummyConnection } from "../../src/data/connection/DummyConnection";
import { Module } from "../../src/modules/Module"; import { Module } from "../../src/modules/Module";
+1 -1
View File
@@ -5,7 +5,7 @@ import { Module } from "modules/Module";
import { type ConfigTable, getDefaultConfig, ModuleManager } from "modules/ModuleManager"; import { type ConfigTable, getDefaultConfig, ModuleManager } from "modules/ModuleManager";
import { CURRENT_VERSION, TABLE_NAME } from "modules/migrations"; import { CURRENT_VERSION, TABLE_NAME } from "modules/migrations";
import { getDummyConnection } from "../helper"; import { getDummyConnection } from "../helper";
import { s, stripMark } from "core/object/schema"; import { s, stripMark } from "bknd/core";
describe("ModuleManager", async () => { describe("ModuleManager", async () => {
test("s1: no config, no build", async () => { test("s1: no config, no build", async () => {
+4 -1
View File
@@ -12,7 +12,10 @@ export function getBindings<T extends GetBindingType>(env: any, type: T): Bindin
const bindings: BindingMap<T>[] = []; const bindings: BindingMap<T>[] = [];
for (const key in env) { for (const key in env) {
try { try {
if (env[key] && (env[key] as any).constructor.name === type) { if (
env[key] &&
((env[key] as any).constructor.name === type || String(env[key]) === `[object ${type}]`)
) {
bindings.push({ bindings.push({
key, key,
value: env[key] as BindingTypeMap[T], value: env[key] as BindingTypeMap[T],
+1 -1
View File
@@ -13,7 +13,7 @@ export {
type BindingMap, type BindingMap,
} from "./bindings"; } from "./bindings";
export { constants } from "./config"; export { constants } from "./config";
export { StorageR2Adapter } from "./storage/StorageR2Adapter"; export { StorageR2Adapter, registerMedia } from "./storage/StorageR2Adapter";
export { registries } from "bknd"; export { registries } from "bknd";
// for compatibility with old code // for compatibility with old code
@@ -2,7 +2,7 @@ import { registries } from "bknd";
import { isDebug } from "bknd/core"; import { isDebug } from "bknd/core";
import { guessMimeType as guess, StorageAdapter, type FileBody } from "bknd/media"; import { guessMimeType as guess, StorageAdapter, type FileBody } from "bknd/media";
import { getBindings } from "../bindings"; import { getBindings } from "../bindings";
import { s } from "core/object/schema"; import { s } from "bknd/core";
export function makeSchema(bindings: string[] = []) { export function makeSchema(bindings: string[] = []) {
return s.object( return s.object(
@@ -2,7 +2,7 @@ import { readFile, readdir, stat, unlink, writeFile } from "node:fs/promises";
import { isFile } from "bknd/utils"; import { isFile } from "bknd/utils";
import type { FileBody, FileListObject, FileMeta, FileUploadPayload } from "bknd/media"; import type { FileBody, FileListObject, FileMeta, FileUploadPayload } from "bknd/media";
import { StorageAdapter, guessMimeType as guess } from "bknd/media"; import { StorageAdapter, guessMimeType as guess } from "bknd/media";
import { parse, s } from "core/object/schema"; import { parse, s } from "bknd/core";
export const localAdapterConfig = s.object( export const localAdapterConfig = s.object(
{ {
+1 -1
View File
@@ -3,7 +3,7 @@ import { transformObject } from "core/utils";
import { DataPermissions } from "data"; import { DataPermissions } from "data";
import type { Hono } from "hono"; import type { Hono } from "hono";
import { Controller, type ServerEnv } from "modules/Controller"; import { Controller, type ServerEnv } from "modules/Controller";
import { describeRoute, jsc, s, parse, InvalidSchemaError } from "core/object/schema"; import { describeRoute, jsc, s, parse, InvalidSchemaError } from "bknd/core";
export type AuthActionResponse = { export type AuthActionResponse = {
success: boolean; success: boolean;
+1 -1
View File
@@ -1,7 +1,7 @@
import { cookieConfig, jwtConfig } from "auth/authenticate/Authenticator"; import { cookieConfig, jwtConfig } from "auth/authenticate/Authenticator";
import { CustomOAuthStrategy, OAuthStrategy, PasswordStrategy } from "auth/authenticate/strategies"; import { CustomOAuthStrategy, OAuthStrategy, PasswordStrategy } from "auth/authenticate/strategies";
import { objectTransform } from "core/utils"; import { objectTransform } from "core/utils";
import { s } from "core/object/schema"; import { s } from "bknd/core";
export const Strategies = { export const Strategies = {
password: { password: {
+1 -1
View File
@@ -8,7 +8,7 @@ import type { CookieOptions } from "hono/utils/cookie";
import type { ServerEnv } from "modules/Controller"; import type { ServerEnv } from "modules/Controller";
import { pick } from "lodash-es"; import { pick } from "lodash-es";
import { InvalidConditionsException } from "auth/errors"; import { InvalidConditionsException } from "auth/errors";
import { s, parse, secret } from "core/object/schema"; import { s, parse, secret } from "bknd/core";
type Input = any; // workaround type Input = any; // workaround
export type JWTPayload = Parameters<typeof sign>[0]; export type JWTPayload = Parameters<typeof sign>[0];
@@ -3,7 +3,7 @@ import { hash, $console } from "core/utils";
import { Hono } from "hono"; import { Hono } from "hono";
import { compare as bcryptCompare, genSalt as bcryptGenSalt, hash as bcryptHash } from "bcryptjs"; import { compare as bcryptCompare, genSalt as bcryptGenSalt, hash as bcryptHash } from "bcryptjs";
import { Strategy } from "./Strategy"; import { Strategy } from "./Strategy";
import { s, parse, jsc } from "core/object/schema"; import { s, parse, jsc } from "bknd/core";
const schema = s const schema = s
.object({ .object({
@@ -5,7 +5,7 @@ import type {
StrategyActions, StrategyActions,
} from "../Authenticator"; } from "../Authenticator";
import type { Hono } from "hono"; import type { Hono } from "hono";
import { type s, parse } from "core/object/schema"; import { type s, parse } from "bknd/core";
export type StrategyMode = "form" | "external"; export type StrategyMode = "form" | "external";
@@ -1,6 +1,6 @@
import type * as oauth from "oauth4webapi"; import type * as oauth from "oauth4webapi";
import { OAuthStrategy } from "./OAuthStrategy"; import { OAuthStrategy } from "./OAuthStrategy";
import { s } from "core/object/schema"; import { s } from "bknd/core";
type SupportedTypes = "oauth2" | "oidc"; type SupportedTypes = "oauth2" | "oidc";
@@ -6,7 +6,7 @@ import { getSignedCookie, setSignedCookie } from "hono/cookie";
import * as oauth from "oauth4webapi"; import * as oauth from "oauth4webapi";
import * as issuers from "./issuers"; import * as issuers from "./issuers";
import { Strategy } from "auth/authenticate/strategies/Strategy"; import { Strategy } from "auth/authenticate/strategies/Strategy";
import { s } from "core/object/schema"; import { s } from "bknd/core";
type ConfiguredIssuers = keyof typeof issuers; type ConfiguredIssuers = keyof typeof issuers;
type SupportedTypes = "oauth2" | "oidc"; type SupportedTypes = "oauth2" | "oidc";
+6 -2
View File
@@ -25,8 +25,12 @@ export {
} from "./object/query/query"; } from "./object/query/query";
export { Registry, type Constructor } from "./registry/Registry"; export { Registry, type Constructor } from "./registry/Registry";
export { getFlashMessage } from "./server/flash"; export { getFlashMessage } from "./server/flash";
/* export { export {
s, s,
stripMark,
mark,
stringIdentifier,
secret,
parse, parse,
jsc, jsc,
describeRoute, describeRoute,
@@ -34,7 +38,7 @@ export { getFlashMessage } from "./server/flash";
openAPISpecs, openAPISpecs,
type ParseOptions, type ParseOptions,
InvalidSchemaError, InvalidSchemaError,
} from "./object/schema"; */ } from "./object/schema";
export * from "./drivers"; export * from "./drivers";
export * from "./events"; export * from "./events";
+1 -1
View File
@@ -1,6 +1,6 @@
import { get, has, omit, set } from "lodash-es"; import { get, has, omit, set } from "lodash-es";
import { getFullPathKeys, mergeObjectWith } from "../utils"; import { getFullPathKeys, mergeObjectWith } from "../utils";
import { type s, parse, stripMark } from "core/object/schema"; import { type s, parse, stripMark } from "bknd/core";
export type SchemaObjectOptions<Schema extends s.Schema> = { export type SchemaObjectOptions<Schema extends s.Schema> = {
onUpdate?: (config: s.Static<Schema>) => void | Promise<void>; onUpdate?: (config: s.Static<Schema>) => void | Promise<void>;
+1 -1
View File
@@ -8,7 +8,7 @@ import {
import type { Handler } from "hono/types"; import type { Handler } from "hono/types";
import type { ModuleBuildContext } from "modules"; import type { ModuleBuildContext } from "modules";
import { Controller } from "modules/Controller"; import { Controller } from "modules/Controller";
import { jsc, s, describeRoute, schemaToSpec } from "core/object/schema"; import { jsc, s, describeRoute, schemaToSpec } from "bknd/core";
import * as SystemPermissions from "modules/permissions"; import * as SystemPermissions from "modules/permissions";
import type { AppDataConfig } from "../data-schema"; import type { AppDataConfig } from "../data-schema";
import { omitKeys } from "core/utils"; import { omitKeys } from "core/utils";
+6 -4
View File
@@ -4,7 +4,7 @@ import { FieldClassMap } from "data/fields";
import { RelationClassMap, RelationFieldClassMap } from "data/relations"; import { RelationClassMap, RelationFieldClassMap } from "data/relations";
import { entityConfigSchema, entityTypes } from "data/entities"; import { entityConfigSchema, entityTypes } from "data/entities";
import { primaryFieldTypes } from "./fields"; import { primaryFieldTypes } from "./fields";
import { s } from "core/object/schema"; import { s } from "bknd/core";
export const FIELDS = { export const FIELDS = {
...FieldClassMap, ...FieldClassMap,
@@ -18,6 +18,7 @@ export const RELATIONS = RelationClassMap;
export const fieldsSchemaObject = objectTransform(FIELDS, (field, name) => { export const fieldsSchemaObject = objectTransform(FIELDS, (field, name) => {
return s.strictObject( return s.strictObject(
{ {
name: s.string().optional(), // @todo: verify, old schema wasn't strict (req in UI)
type: s.literal(name), type: s.literal(name),
config: field.schema.optional(), config: field.schema.optional(),
}, },
@@ -32,9 +33,10 @@ export type TAppDataField = s.Static<typeof fieldsSchema>;
export type TAppDataEntityFields = s.Static<typeof entityFields>; export type TAppDataEntityFields = s.Static<typeof entityFields>;
export const entitiesSchema = s.strictObject({ export const entitiesSchema = s.strictObject({
type: s.string({ enum: entityTypes, default: "regular", readOnly: true }), name: s.string().optional(), // @todo: verify, old schema wasn't strict (req in UI)
config: entityConfigSchema.optional(), type: s.string({ enum: entityTypes, default: "regular" }),
fields: entityFields.optional(), config: entityConfigSchema,
fields: entityFields,
}); });
export type TAppDataEntity = s.Static<typeof entitiesSchema>; export type TAppDataEntity = s.Static<typeof entitiesSchema>;
+1 -1
View File
@@ -7,7 +7,7 @@ import {
type TActionContext, type TActionContext,
type TRenderContext, type TRenderContext,
} from "../fields"; } from "../fields";
import { s, parse } from "core/object/schema"; import { s, parse } from "bknd/core";
// @todo: entity must be migrated to typebox // @todo: entity must be migrated to typebox
export const entityConfigSchema = s export const entityConfigSchema = s
+1 -1
View File
@@ -1,6 +1,6 @@
import { Exception } from "core"; import { Exception } from "core";
import { HttpStatus } from "core/utils"; import { HttpStatus } from "core/utils";
import type { InvalidSchemaError } from "core/object/schema"; import type { InvalidSchemaError } from "bknd/core";
import type { Entity } from "./entities"; import type { Entity } from "./entities";
import type { Field } from "./fields"; import type { Field } from "./fields";
+1 -1
View File
@@ -2,7 +2,7 @@ import { omitKeys } from "core/utils";
import type { EntityManager } from "data"; import type { EntityManager } from "data";
import { TransformPersistFailedException } from "../errors"; import { TransformPersistFailedException } from "../errors";
import { Field, type TActionContext, type TRenderContext, baseFieldConfigSchema } from "./Field"; import { Field, type TActionContext, type TRenderContext, baseFieldConfigSchema } from "./Field";
import { s } from "core/object/schema"; import { s } from "bknd/core";
export const booleanFieldConfigSchema = s export const booleanFieldConfigSchema = s
.strictObject({ .strictObject({
+1 -1
View File
@@ -3,7 +3,7 @@ import type { EntityManager } from "../entities";
import { Field, type TActionContext, type TRenderContext, baseFieldConfigSchema } from "./Field"; import { Field, type TActionContext, type TRenderContext, baseFieldConfigSchema } from "./Field";
import { $console } from "core/utils"; import { $console } from "core/utils";
import type { TFieldTSType } from "data/entities/EntityTypescript"; import type { TFieldTSType } from "data/entities/EntityTypescript";
import { s } from "core/object/schema"; import { s } from "bknd/core";
export const dateFieldConfigSchema = s export const dateFieldConfigSchema = s
.strictObject({ .strictObject({
+1 -1
View File
@@ -3,7 +3,7 @@ import type { EntityManager } from "data";
import { TransformPersistFailedException } from "../errors"; import { TransformPersistFailedException } from "../errors";
import { baseFieldConfigSchema, Field, type TActionContext, type TRenderContext } from "./Field"; import { baseFieldConfigSchema, Field, type TActionContext, type TRenderContext } from "./Field";
import type { TFieldTSType } from "data/entities/EntityTypescript"; import type { TFieldTSType } from "data/entities/EntityTypescript";
import { s } from "core/object/schema"; import { s } from "bknd/core";
export const enumFieldConfigSchema = s export const enumFieldConfigSchema = s
.strictObject({ .strictObject({
+1 -1
View File
@@ -4,7 +4,7 @@ import type { EntityManager } from "../entities";
import { InvalidFieldConfigException, TransformPersistFailedException } from "../errors"; import { InvalidFieldConfigException, TransformPersistFailedException } from "../errors";
import type { FieldSpec } from "data/connection/Connection"; import type { FieldSpec } from "data/connection/Connection";
import type { TFieldTSType } from "data/entities/EntityTypescript"; import type { TFieldTSType } from "data/entities/EntityTypescript";
import { s, parse, InvalidSchemaError } from "core/object/schema"; import { s, parse, InvalidSchemaError } from "bknd/core";
// @todo: contexts need to be reworked // @todo: contexts need to be reworked
// e.g. "table" is irrelevant, because if read is not given, it fails // e.g. "table" is irrelevant, because if read is not given, it fails
+1 -1
View File
@@ -3,7 +3,7 @@ import type { EntityManager } from "data";
import { TransformPersistFailedException } from "../errors"; import { TransformPersistFailedException } from "../errors";
import { Field, type TActionContext, type TRenderContext, baseFieldConfigSchema } from "./Field"; import { Field, type TActionContext, type TRenderContext, baseFieldConfigSchema } from "./Field";
import type { TFieldTSType } from "data/entities/EntityTypescript"; import type { TFieldTSType } from "data/entities/EntityTypescript";
import { s } from "core/object/schema"; import { s } from "bknd/core";
export const jsonFieldConfigSchema = s export const jsonFieldConfigSchema = s
.strictObject({ .strictObject({
+1 -1
View File
@@ -4,7 +4,7 @@ import type { EntityManager } from "data";
import { TransformPersistFailedException } from "../errors"; import { TransformPersistFailedException } from "../errors";
import { Field, type TActionContext, type TRenderContext, baseFieldConfigSchema } from "./Field"; import { Field, type TActionContext, type TRenderContext, baseFieldConfigSchema } from "./Field";
import type { TFieldTSType } from "data/entities/EntityTypescript"; import type { TFieldTSType } from "data/entities/EntityTypescript";
import { s } from "core/object/schema"; import { s } from "bknd/core";
export const jsonSchemaFieldConfigSchema = s export const jsonSchemaFieldConfigSchema = s
.strictObject({ .strictObject({
+1 -1
View File
@@ -2,7 +2,7 @@ import type { EntityManager } from "data";
import { TransformPersistFailedException } from "../errors"; import { TransformPersistFailedException } from "../errors";
import { Field, type TActionContext, type TRenderContext, baseFieldConfigSchema } from "./Field"; import { Field, type TActionContext, type TRenderContext, baseFieldConfigSchema } from "./Field";
import type { TFieldTSType } from "data/entities/EntityTypescript"; import type { TFieldTSType } from "data/entities/EntityTypescript";
import { s } from "core/object/schema"; import { s } from "bknd/core";
import { omitKeys } from "core/utils"; import { omitKeys } from "core/utils";
export const numberFieldConfigSchema = s export const numberFieldConfigSchema = s
+1 -1
View File
@@ -2,7 +2,7 @@ import { config } from "core";
import { omitKeys, uuidv7 } from "core/utils"; import { omitKeys, uuidv7 } from "core/utils";
import { Field, baseFieldConfigSchema } from "./Field"; import { Field, baseFieldConfigSchema } from "./Field";
import type { TFieldTSType } from "data/entities/EntityTypescript"; import type { TFieldTSType } from "data/entities/EntityTypescript";
import { s } from "core/object/schema"; import { s } from "bknd/core";
export const primaryFieldTypes = ["integer", "uuid"] as const; export const primaryFieldTypes = ["integer", "uuid"] as const;
export type TPrimaryFieldFormat = (typeof primaryFieldTypes)[number]; export type TPrimaryFieldFormat = (typeof primaryFieldTypes)[number];
+1 -1
View File
@@ -2,7 +2,7 @@ import type { EntityManager } from "data";
import { omitKeys } from "core/utils"; import { omitKeys } from "core/utils";
import { TransformPersistFailedException } from "../errors"; import { TransformPersistFailedException } from "../errors";
import { Field, type TActionContext, baseFieldConfigSchema } from "./Field"; import { Field, type TActionContext, baseFieldConfigSchema } from "./Field";
import { s } from "core/object/schema"; import { s } from "bknd/core";
export const textFieldConfigSchema = s export const textFieldConfigSchema = s
.strictObject({ .strictObject({
+1 -1
View File
@@ -1,5 +1,5 @@
import { Field, baseFieldConfigSchema } from "./Field"; import { Field, baseFieldConfigSchema } from "./Field";
import { s } from "core/object/schema"; import { s } from "bknd/core";
export const virtualFieldConfigSchema = s export const virtualFieldConfigSchema = s
.strictObject({ .strictObject({
+2 -2
View File
@@ -1,4 +1,4 @@
import { parse } from "core/object/schema"; import { parse } from "bknd/core";
import type { ExpressionBuilder, SelectQueryBuilder } from "kysely"; import type { ExpressionBuilder, SelectQueryBuilder } from "kysely";
import type { Entity, EntityData, EntityManager } from "../entities"; import type { Entity, EntityData, EntityManager } from "../entities";
import { import {
@@ -9,7 +9,7 @@ import {
import type { RepoQuery } from "../server/query"; import type { RepoQuery } from "../server/query";
import type { RelationType } from "./relation-types"; import type { RelationType } from "./relation-types";
import type { PrimaryFieldType } from "core"; import type { PrimaryFieldType } from "core";
import { s } from "core/object/schema"; import { s } from "bknd/core";
const directions = ["source", "target"] as const; const directions = ["source", "target"] as const;
export type TDirection = (typeof directions)[number]; export type TDirection = (typeof directions)[number];
+1 -1
View File
@@ -6,7 +6,7 @@ import { EntityRelation, type KyselyQueryBuilder } from "./EntityRelation";
import { EntityRelationAnchor } from "./EntityRelationAnchor"; import { EntityRelationAnchor } from "./EntityRelationAnchor";
import { RelationField } from "./RelationField"; import { RelationField } from "./RelationField";
import { type RelationType, RelationTypes } from "./relation-types"; import { type RelationType, RelationTypes } from "./relation-types";
import { s } from "core/object/schema"; import { s } from "bknd/core";
export type ManyToManyRelationConfig = s.Static<typeof ManyToManyRelation.schema>; export type ManyToManyRelationConfig = s.Static<typeof ManyToManyRelation.schema>;
+1 -1
View File
@@ -8,7 +8,7 @@ import { EntityRelationAnchor } from "./EntityRelationAnchor";
import { RelationField, type RelationFieldBaseConfig } from "./RelationField"; import { RelationField, type RelationFieldBaseConfig } from "./RelationField";
import type { MutationInstructionResponse } from "./RelationMutator"; import type { MutationInstructionResponse } from "./RelationMutator";
import { type RelationType, RelationTypes } from "./relation-types"; import { type RelationType, RelationTypes } from "./relation-types";
import { s } from "core/object/schema"; import { s } from "bknd/core";
/** /**
* Source entity receives the mapping field * Source entity receives the mapping field
@@ -5,7 +5,7 @@ import type { RepoQuery } from "../server/query";
import { EntityRelation, type KyselyJsonFrom, type KyselyQueryBuilder } from "./EntityRelation"; import { EntityRelation, type KyselyJsonFrom, type KyselyQueryBuilder } from "./EntityRelation";
import { EntityRelationAnchor } from "./EntityRelationAnchor"; import { EntityRelationAnchor } from "./EntityRelationAnchor";
import { type RelationType, RelationTypes } from "./relation-types"; import { type RelationType, RelationTypes } from "./relation-types";
import { s } from "core/object/schema"; import { s } from "bknd/core";
export type PolymorphicRelationConfig = s.Static<typeof PolymorphicRelation.schema>; export type PolymorphicRelationConfig = s.Static<typeof PolymorphicRelation.schema>;
+1 -1
View File
@@ -3,7 +3,7 @@ import { Field, baseFieldConfigSchema } from "../fields";
import type { EntityRelation } from "./EntityRelation"; import type { EntityRelation } from "./EntityRelation";
import type { EntityRelationAnchor } from "./EntityRelationAnchor"; import type { EntityRelationAnchor } from "./EntityRelationAnchor";
import type { TFieldTSType } from "data/entities/EntityTypescript"; import type { TFieldTSType } from "data/entities/EntityTypescript";
import { s } from "core/object/schema"; import { s } from "bknd/core";
const CASCADES = ["cascade", "set null", "set default", "restrict", "no action"] as const; const CASCADES = ["cascade", "set null", "set default", "restrict", "no action"] as const;
+1 -1
View File
@@ -1,6 +1,6 @@
import { test, describe, expect } from "bun:test"; import { test, describe, expect } from "bun:test";
import * as q from "./query"; import * as q from "./query";
import { s as schema, parse as $parse, type ParseOptions } from "core/object/schema"; import { s as schema, parse as $parse, type ParseOptions } from "bknd/core";
const parse = (v: unknown, o: ParseOptions = {}) => const parse = (v: unknown, o: ParseOptions = {}) =>
$parse(q.repoQuery, v, { $parse(q.repoQuery, v, {
+1 -1
View File
@@ -1,4 +1,4 @@
import { s } from "core/object/schema"; import { s } from "bknd/core";
import { WhereBuilder, type WhereQuery } from "data/entities/query/WhereBuilder"; import { WhereBuilder, type WhereQuery } from "data/entities/query/WhereBuilder";
import { isObject, $console } from "core/utils"; import { isObject, $console } from "core/utils";
import type { anyOf, CoercionOptions, Schema } from "jsonv-ts"; import type { anyOf, CoercionOptions, Schema } from "jsonv-ts";
+1 -1
View File
@@ -3,7 +3,7 @@ import { Flow, HttpTrigger } from "flows";
import { Hono } from "hono"; import { Hono } from "hono";
import { Module } from "modules/Module"; import { Module } from "modules/Module";
import { TASKS, flowsConfigSchema } from "./flows-schema"; import { TASKS, flowsConfigSchema } from "./flows-schema";
import type { s } from "core/object/schema"; import type { s } from "bknd/core";
export type AppFlowsSchema = s.Static<typeof flowsConfigSchema>; export type AppFlowsSchema = s.Static<typeof flowsConfigSchema>;
export type TAppFlowSchema = AppFlowsSchema["flows"][number]; export type TAppFlowSchema = AppFlowsSchema["flows"][number];
+1 -1
View File
@@ -1,6 +1,6 @@
import { transformObject } from "core/utils"; import { transformObject } from "core/utils";
import { TaskMap, TriggerMap } from "flows"; import { TaskMap, TriggerMap } from "flows";
import { s } from "core/object/schema"; import { s } from "bknd/core";
export const TASKS = { export const TASKS = {
...TaskMap, ...TaskMap,
+1 -1
View File
@@ -2,7 +2,7 @@ import type { EventManager } from "core/events";
import type { Flow } from "../Flow"; import type { Flow } from "../Flow";
import { Trigger } from "./Trigger"; import { Trigger } from "./Trigger";
import { $console } from "core/utils"; import { $console } from "core/utils";
import { s } from "core/object/schema"; import { s } from "bknd/core";
export class EventTrigger extends Trigger<typeof EventTrigger.schema> { export class EventTrigger extends Trigger<typeof EventTrigger.schema> {
override type = "event"; override type = "event";
+1 -1
View File
@@ -1,7 +1,7 @@
import type { Context, Hono } from "hono"; import type { Context, Hono } from "hono";
import type { Flow } from "../Flow"; import type { Flow } from "../Flow";
import { Trigger } from "./Trigger"; import { Trigger } from "./Trigger";
import { s } from "core/object/schema"; import { s } from "bknd/core";
const httpMethods = ["GET", "POST", "PUT", "PATCH", "DELETE"] as const; const httpMethods = ["GET", "POST", "PUT", "PATCH", "DELETE"] as const;
+1 -1
View File
@@ -1,6 +1,6 @@
import type { Execution } from "../Execution"; import type { Execution } from "../Execution";
import type { Flow } from "../Flow"; import type { Flow } from "../Flow";
import { s, parse } from "core/object/schema"; import { s, parse } from "bknd/core";
export class Trigger<Schema extends typeof Trigger.schema = typeof Trigger.schema> { export class Trigger<Schema extends typeof Trigger.schema = typeof Trigger.schema> {
// @todo: remove this // @todo: remove this
+1 -1
View File
@@ -1,7 +1,7 @@
//import { BkndError, SimpleRenderer } from "core"; //import { BkndError, SimpleRenderer } from "core";
import { BkndError } from "core/errors"; import { BkndError } from "core/errors";
import { s, parse } from "core/object/schema"; import { s, parse } from "bknd/core";
import type { InputsMap } from "../flows/Execution"; import type { InputsMap } from "../flows/Execution";
import { SimpleRenderer } from "core/template/SimpleRenderer"; import { SimpleRenderer } from "core/template/SimpleRenderer";
+1 -1
View File
@@ -1,5 +1,5 @@
import { Task, dynamic } from "../Task"; import { Task, dynamic } from "../Task";
import { s } from "core/object/schema"; import { s } from "bknd/core";
const FetchMethods = ["GET", "POST", "PUT", "PATCH", "DELETE"]; const FetchMethods = ["GET", "POST", "PUT", "PATCH", "DELETE"];
+1 -1
View File
@@ -1,6 +1,6 @@
import { Task } from "../Task"; import { Task } from "../Task";
import { $console } from "core/utils"; import { $console } from "core/utils";
import { s } from "core/object/schema"; import { s } from "bknd/core";
export class LogTask extends Task<typeof LogTask.schema> { export class LogTask extends Task<typeof LogTask.schema> {
type = "log"; type = "log";
+1 -1
View File
@@ -1,5 +1,5 @@
import { Task } from "../Task"; import { Task } from "../Task";
import { s } from "core/object/schema"; import { s } from "bknd/core";
export class RenderTask<Output extends Record<string, any>> extends Task< export class RenderTask<Output extends Record<string, any>> extends Task<
typeof RenderTask.schema, typeof RenderTask.schema,
+1 -1
View File
@@ -1,6 +1,6 @@
import { Flow } from "../../flows/Flow"; import { Flow } from "../../flows/Flow";
import { Task, dynamic } from "../Task"; import { Task, dynamic } from "../Task";
import { s } from "core/object/schema"; import { s } from "bknd/core";
export class SubFlowTask<Output extends Record<string, any>> extends Task< export class SubFlowTask<Output extends Record<string, any>> extends Task<
typeof SubFlowTask.schema, typeof SubFlowTask.schema,
+1 -1
View File
@@ -1,5 +1,5 @@
import { Field, baseFieldConfigSchema } from "data/fields"; import { Field, baseFieldConfigSchema } from "data/fields";
import { s } from "core/object/schema"; import { s } from "bknd/core";
export const mediaFieldConfigSchema = s export const mediaFieldConfigSchema = s
.strictObject({ .strictObject({
+1 -1
View File
@@ -6,7 +6,7 @@ import { DataPermissions } from "data";
import { Controller } from "modules/Controller"; import { Controller } from "modules/Controller";
import type { AppMedia } from "../AppMedia"; import type { AppMedia } from "../AppMedia";
import { MediaField } from "../MediaField"; import { MediaField } from "../MediaField";
import { jsc, s, describeRoute } from "core/object/schema"; import { jsc, s, describeRoute } from "bknd/core";
export class MediaController extends Controller { export class MediaController extends Controller {
constructor(private readonly media: AppMedia) { constructor(private readonly media: AppMedia) {
+1 -1
View File
@@ -15,7 +15,7 @@ import {
StorageCloudinaryAdapter, StorageCloudinaryAdapter,
} from "./storage/adapters/cloudinary/StorageCloudinaryAdapter"; } from "./storage/adapters/cloudinary/StorageCloudinaryAdapter";
import { type S3AdapterConfig, StorageS3Adapter } from "./storage/adapters/s3/StorageS3Adapter"; import { type S3AdapterConfig, StorageS3Adapter } from "./storage/adapters/s3/StorageS3Adapter";
import type { s } from "core/object/schema"; import type { s } from "bknd/core";
export { StorageAdapter }; export { StorageAdapter };
export { StorageS3Adapter, type S3AdapterConfig, StorageCloudinaryAdapter, type CloudinaryConfig }; export { StorageS3Adapter, type S3AdapterConfig, StorageCloudinaryAdapter, type CloudinaryConfig };
+1 -1
View File
@@ -1,7 +1,7 @@
import { objectTransform } from "core/utils"; import { objectTransform } from "core/utils";
import { Adapters } from "media"; import { Adapters } from "media";
import { registries } from "modules/registries"; import { registries } from "modules/registries";
import { s } from "core/object/schema"; import { s } from "bknd/core";
export const ADAPTERS = { export const ADAPTERS = {
...Adapters, ...Adapters,
+1 -1
View File
@@ -1,6 +1,6 @@
import type { FileListObject, FileMeta } from "media"; import type { FileListObject, FileMeta } from "media";
import type { FileBody, FileUploadPayload } from "media/storage/Storage"; import type { FileBody, FileUploadPayload } from "media/storage/Storage";
import type { s } from "core/object/schema"; import type { s } from "bknd/core";
const SYMBOL = Symbol.for("bknd:storage"); const SYMBOL = Symbol.for("bknd:storage");
@@ -1,7 +1,7 @@
import { hash, pickHeaders } from "core/utils"; import { hash, pickHeaders } from "core/utils";
import type { FileBody, FileListObject, FileMeta } from "../../Storage"; import type { FileBody, FileListObject, FileMeta } from "../../Storage";
import { StorageAdapter } from "../../StorageAdapter"; import { StorageAdapter } from "../../StorageAdapter";
import { s, parse } from "core/object/schema"; import { s, parse } from "bknd/core";
export const cloudinaryAdapterConfig = s.object( export const cloudinaryAdapterConfig = s.object(
{ {
@@ -11,7 +11,7 @@ import { isFile, pickHeaders2 } from "core/utils";
import { transform } from "lodash-es"; import { transform } from "lodash-es";
import type { FileBody, FileListObject } from "../../Storage"; import type { FileBody, FileListObject } from "../../Storage";
import { StorageAdapter } from "../../StorageAdapter"; import { StorageAdapter } from "../../StorageAdapter";
import { parse, s } from "core/object/schema"; import { parse, s } from "bknd/core";
export const s3AdapterConfig = s.object( export const s3AdapterConfig = s.object(
{ {
+1 -1
View File
@@ -3,7 +3,7 @@ import { type Context, type Env, Hono } from "hono";
import * as middlewares from "modules/middlewares"; import * as middlewares from "modules/middlewares";
import type { SafeUser } from "auth"; import type { SafeUser } from "auth";
import type { EntityManager } from "data"; import type { EntityManager } from "data";
import { s } from "core/object/schema"; import { s } from "bknd/core";
export interface ServerEnv extends Env { export interface ServerEnv extends Env {
Variables: { Variables: {
+1 -1
View File
@@ -5,7 +5,7 @@ import type { Connection, EntityManager } from "data";
import type { Hono } from "hono"; import type { Hono } from "hono";
import type { ServerEnv } from "modules/Controller"; import type { ServerEnv } from "modules/Controller";
import type { ModuleHelper } from "./ModuleHelper"; import type { ModuleHelper } from "./ModuleHelper";
import type { s } from "core/object/schema"; import type { s } from "bknd/core";
type PartialRec<T> = { [P in keyof T]?: PartialRec<T[P]> }; type PartialRec<T> = { [P in keyof T]?: PartialRec<T[P]> };
+2 -1
View File
@@ -20,7 +20,8 @@ import { AppMedia } from "../media/AppMedia";
import type { ServerEnv } from "./Controller"; import type { ServerEnv } from "./Controller";
import { Module, type ModuleBuildContext } from "./Module"; import { Module, type ModuleBuildContext } from "./Module";
import { ModuleHelper } from "./ModuleHelper"; import { ModuleHelper } from "./ModuleHelper";
import { s, mark, stripMark } from "core/object/schema"; import { s } from "bknd/core";
import { mark, stripMark } from "bknd/core";
export type { ModuleBuildContext }; export type { ModuleBuildContext };
+1 -1
View File
@@ -3,7 +3,7 @@ import { $console } from "core/utils";
import { cors } from "hono/cors"; import { cors } from "hono/cors";
import { Module } from "modules/Module"; import { Module } from "modules/Module";
import { AuthException } from "auth/errors"; import { AuthException } from "auth/errors";
import { s } from "core/object/schema"; import { s } from "bknd/core";
const serverMethods = ["GET", "POST", "PATCH", "PUT", "DELETE"] as const; const serverMethods = ["GET", "POST", "PATCH", "PUT", "DELETE"] as const;
+1 -1
View File
@@ -14,7 +14,7 @@ import {
type ModuleKey, type ModuleKey,
} from "modules/ModuleManager"; } from "modules/ModuleManager";
import * as SystemPermissions from "modules/permissions"; import * as SystemPermissions from "modules/permissions";
import { jsc, s, describeRoute, InvalidSchemaError } from "core/object/schema"; import { jsc, s, describeRoute, InvalidSchemaError } from "bknd/core";
import { getVersion } from "core/env"; import { getVersion } from "core/env";
import { SecretSchema } from "core/object/schema/secret"; import { SecretSchema } from "core/object/schema/secret";
@@ -13,7 +13,7 @@ import {
import { useBknd } from "ui/client/bknd"; import { useBknd } from "ui/client/bknd";
import type { TSchemaActions } from "ui/client/schema/actions"; import type { TSchemaActions } from "ui/client/schema/actions";
import { bkndModals } from "ui/modals"; import { bkndModals } from "ui/modals";
import { s, parse, InvalidSchemaError } from "core/object/schema"; import { s, parse, InvalidSchemaError } from "bknd/core";
export function useBkndData() { export function useBkndData() {
const { config, app, schema, actions: bkndActions } = useBknd(); const { config, app, schema, actions: bkndActions } = useBknd();
+1 -1
View File
@@ -1,4 +1,4 @@
import { parse } from "core/object/schema"; import { parse } from "bknd/core";
import { type TAppFlowSchema, flowSchema } from "flows/flows-schema"; import { type TAppFlowSchema, flowSchema } from "flows/flows-schema";
import { useBknd } from "../../BkndProvider"; import { useBknd } from "../../BkndProvider";
+1 -1
View File
@@ -7,7 +7,7 @@ import { Button } from "ui/components/buttons/Button";
import { Group, Input, Password, Label } from "ui/components/form/Formy/components"; import { Group, Input, Password, Label } from "ui/components/form/Formy/components";
import { SocialLink } from "./SocialLink"; import { SocialLink } from "./SocialLink";
import type { Validator } from "json-schema-form-react"; import type { Validator } from "json-schema-form-react";
import { s } from "core/object/schema"; import { s } from "bknd/core";
import type { ErrorDetail } from "jsonv-ts"; import type { ErrorDetail } from "jsonv-ts";
class JsonvTsValidator implements Validator<ErrorDetail> { class JsonvTsValidator implements Validator<ErrorDetail> {
+1 -1
View File
@@ -1,7 +1,7 @@
import { decodeSearch, encodeSearch, mergeObject } from "core/utils"; import { decodeSearch, encodeSearch, mergeObject } from "core/utils";
import { isEqual, transform } from "lodash-es"; import { isEqual, transform } from "lodash-es";
import { useLocation, useSearch as useWouterSearch } from "wouter"; import { useLocation, useSearch as useWouterSearch } from "wouter";
import { type s, parse } from "core/object/schema"; import { type s, parse } from "bknd/core";
import { useEffect, useMemo, useState } from "react"; import { useEffect, useMemo, useState } from "react";
export type UseSearchOptions<Schema extends s.Schema = s.Schema> = { export type UseSearchOptions<Schema extends s.Schema = s.Schema> = {
@@ -1,6 +1,5 @@
import type { ModalProps } from "@mantine/core"; import type { ModalProps } from "@mantine/core";
import type { ContextModalProps } from "@mantine/modals"; import type { ContextModalProps } from "@mantine/modals";
import { entitiesSchema, fieldsSchema, relationsSchema } from "data/data-schema";
import { useState } from "react"; import { useState } from "react";
import { type Modal2Ref, ModalBody, ModalFooter, ModalTitle } from "ui/components/modal/Modal2"; import { type Modal2Ref, ModalBody, ModalFooter, ModalTitle } from "ui/components/modal/Modal2";
import { Step, Steps, useStepContext } from "ui/components/steps/Steps"; import { Step, Steps, useStepContext } from "ui/components/steps/Steps";
@@ -10,52 +9,10 @@ import { StepEntityFields } from "./step.entity.fields";
import { StepRelation } from "./step.relation"; import { StepRelation } from "./step.relation";
import { StepSelect } from "./step.select"; import { StepSelect } from "./step.select";
import Templates from "./templates/register"; import Templates from "./templates/register";
import { s } from "core/object/schema"; import type { TCreateModalSchema } from "./schema";
export type CreateModalRef = Modal2Ref; export type CreateModalRef = Modal2Ref;
export const ModalActions = ["entity", "relation", "media"] as const;
export const entitySchema = s.object({
name: s.string(),
...entitiesSchema.properties,
});
// @todo: this union is not fully working, just "string"
const schemaAction = s.anyOf([
s.string({ enum: ["entity", "relation", "media"] }),
s.string({ pattern: "^template-" }),
]);
export type TSchemaAction = s.Static<typeof schemaAction>;
const createFieldSchema = s.object({
entity: s.string(),
name: s.string(),
field: s.array(fieldsSchema),
});
export type TFieldCreate = s.Static<typeof createFieldSchema>;
const createModalSchema = s.strictObject({
action: schemaAction,
initial: s.any().optional(),
entities: s
.object({
create: s.array(entitySchema).optional(),
})
.optional(),
relations: s
.object({
create: s.array(s.anyOf(relationsSchema)).optional(),
})
.optional(),
fields: s
.object({
create: s.array(createFieldSchema).optional(),
})
.optional(),
});
export type TCreateModalSchema = s.Static<typeof createModalSchema>;
export function CreateModal({ export function CreateModal({
context, context,
id, id,
@@ -107,4 +64,4 @@ CreateModal.modalProps = {
padding: 0, padding: 0,
} satisfies Partial<ModalProps>; } satisfies Partial<ModalProps>;
export { ModalBody, ModalFooter, ModalTitle, useStepContext, relationsSchema }; export { ModalBody, ModalFooter, ModalTitle, useStepContext };
@@ -0,0 +1,44 @@
import { s } from "bknd/core";
import { entitiesSchema, fieldsSchema, relationsSchema } from "data/data-schema";
export const ModalActions = ["entity", "relation", "media"] as const;
export const entitySchema = s.object({
name: s.string(),
...entitiesSchema.properties,
});
// @todo: this union is not fully working, just "string"
const schemaAction = s.anyOf([
s.string({ enum: ["entity", "relation", "media"] }),
s.string({ pattern: "^template-" }),
]);
export type TSchemaAction = s.Static<typeof schemaAction>;
const createFieldSchema = s.object({
entity: s.string(),
name: s.string(),
field: s.array(fieldsSchema),
});
export type TFieldCreate = s.Static<typeof createFieldSchema>;
const createModalSchema = s.strictObject({
action: schemaAction,
initial: s.any().optional(),
entities: s
.object({
create: s.array(entitySchema).optional(),
})
.optional(),
relations: s
.object({
create: s.array(s.anyOf(relationsSchema)).optional(),
})
.optional(),
fields: s
.object({
create: s.array(createFieldSchema).optional(),
})
.optional(),
});
export type TCreateModalSchema = s.Static<typeof createModalSchema>;
@@ -1,7 +1,6 @@
import { useDisclosure } from "@mantine/hooks"; import { useDisclosure } from "@mantine/hooks";
import { import {
IconAlignJustified, IconAlignJustified,
IconAugmentedReality,
IconBox, IconBox,
IconCirclesRelation, IconCirclesRelation,
IconInfoCircle, IconInfoCircle,
@@ -15,7 +14,7 @@ import { IconButton, type IconType } from "ui/components/buttons/IconButton";
import { JsonViewer } from "ui/components/code/JsonViewer"; import { JsonViewer } from "ui/components/code/JsonViewer";
import { ModalBody, ModalFooter } from "ui/components/modal/Modal2"; import { ModalBody, ModalFooter } from "ui/components/modal/Modal2";
import { useStepContext } from "ui/components/steps/Steps"; import { useStepContext } from "ui/components/steps/Steps";
import type { TCreateModalSchema } from "ui/modules/data/components/schema/create-modal/CreateModal"; import type { TCreateModalSchema } from "ui/modules/data/components/schema/create-modal/schema";
type ActionItem = SummaryItemProps & { type ActionItem = SummaryItemProps & {
run: () => Promise<boolean>; run: () => Promise<boolean>;
@@ -35,9 +34,9 @@ export function StepCreate() {
action: "add", action: "add",
Icon: IconBox, Icon: IconBox,
type: "Entity", type: "Entity",
name: entity.name, name: entity.name!,
json: entity, json: entity,
run: async () => await $data.actions.entity.add(entity.name, entity), run: async () => await $data.actions.entity.add(entity.name!, entity),
})), })),
); );
} }
@@ -1,4 +1,3 @@
//import { typeboxResolver } from "@hookform/resolvers/typebox";
import { objectCleanEmpty } from "core/utils"; import { objectCleanEmpty } from "core/utils";
import { type TAppDataEntityFields, entitiesSchema } from "data/data-schema"; import { type TAppDataEntityFields, entitiesSchema } from "data/data-schema";
import { mergeWith } from "lodash-es"; import { mergeWith } from "lodash-es";
@@ -10,12 +9,13 @@ import {
EntityFieldsForm, EntityFieldsForm,
type EntityFieldsFormRef, type EntityFieldsFormRef,
} from "ui/routes/data/forms/entity.fields.form"; } from "ui/routes/data/forms/entity.fields.form";
import { ModalBody, ModalFooter, type TCreateModalSchema, useStepContext } from "./CreateModal"; import { ModalBody, ModalFooter, useStepContext } from "./CreateModal";
import { useBkndData } from "ui/client/schema/data/use-bknd-data"; import { useBkndData } from "ui/client/schema/data/use-bknd-data";
import type { s } from "core/object/schema"; import type { s } from "bknd/core";
import { standardSchemaResolver } from "@hookform/resolvers/standard-schema"; import { standardSchemaResolver } from "@hookform/resolvers/standard-schema";
import { entitySchema, type TCreateModalSchema } from "./schema";
const schema = entitiesSchema; const schema = entitySchema;
type Schema = s.Static<typeof schema>; type Schema = s.Static<typeof schema>;
export function StepEntityFields() { export function StepEntityFields() {
@@ -2,30 +2,29 @@ import { standardSchemaResolver } from "@hookform/resolvers/standard-schema";
import { TextInput, Textarea } from "@mantine/core"; import { TextInput, Textarea } from "@mantine/core";
import { useFocusTrap } from "@mantine/hooks"; import { useFocusTrap } from "@mantine/hooks";
import { useForm } from "react-hook-form"; import { useForm } from "react-hook-form";
import { import { ModalBody, ModalFooter, useStepContext } from "./CreateModal";
ModalBody, import { entitySchema, type TCreateModalSchema } from "./schema";
ModalFooter, import { s } from "bknd/core";
type TCreateModalSchema, import { cloneSchema } from "core/object/schema";
entitySchema,
useStepContext, const schema = s.object({
} from "./CreateModal"; name: entitySchema.properties.name,
config: entitySchema.properties.config.partial().optional(),
});
type Schema = s.Static<typeof schema>;
export function StepEntity() { export function StepEntity() {
const focusTrapRef = useFocusTrap(); const focusTrapRef = useFocusTrap();
const { nextStep, stepBack, state, setState } = useStepContext<TCreateModalSchema>(); const { nextStep, stepBack, state, setState } = useStepContext<TCreateModalSchema>();
const { register, handleSubmit, formState, watch, control } = useForm({ const { register, handleSubmit, formState, watch, control } = useForm({
mode: "onTouched", mode: "onChange",
resolver: standardSchemaResolver(entitySchema), resolver: standardSchemaResolver(cloneSchema(schema)),
defaultValues: state.entities?.create?.[0] ?? {}, defaultValues: (state.entities?.create?.[0] ?? {}) as Schema,
}); });
/*const data = watch();
console.log("state", { isValid });
console.log("schema", JSON.stringify(entitySchema));
console.log("data", JSON.stringify(data));*/
function onSubmit(data: any) { function onSubmit(data: any) {
console.log(data); console.log("onSubmit", data);
setState((prev) => { setState((prev) => {
const prevEntity = prev.entities?.create?.[0]; const prevEntity = prev.entities?.create?.[0];
if (prevEntity && prevEntity.name !== data.name) { if (prevEntity && prevEntity.name !== data.name) {
@@ -45,6 +44,7 @@ export function StepEntity() {
<> <>
<form onSubmit={handleSubmit(onSubmit)} ref={focusTrapRef}> <form onSubmit={handleSubmit(onSubmit)} ref={focusTrapRef}>
<ModalBody> <ModalBody>
<input type="hidden" {...register("type")} defaultValue="regular" />
<TextInput <TextInput
data-autofocus data-autofocus
required required
@@ -10,8 +10,9 @@ import { MantineNumberInput } from "ui/components/form/hook-form-mantine/Mantine
import { MantineSelect } from "ui/components/form/hook-form-mantine/MantineSelect"; import { MantineSelect } from "ui/components/form/hook-form-mantine/MantineSelect";
import { useStepContext } from "ui/components/steps/Steps"; import { useStepContext } from "ui/components/steps/Steps";
import { useEvent } from "ui/hooks/use-event"; import { useEvent } from "ui/hooks/use-event";
import { ModalBody, ModalFooter, type TCreateModalSchema } from "./CreateModal"; import { ModalBody, ModalFooter } from "./CreateModal";
import { s, stringIdentifier } from "core/object/schema"; import type { TCreateModalSchema } from "./schema";
import { s, stringIdentifier } from "bknd/core";
import { standardSchemaResolver } from "@hookform/resolvers/standard-schema"; import { standardSchemaResolver } from "@hookform/resolvers/standard-schema";
const Relations: { const Relations: {
@@ -1,15 +1,9 @@
import type { IconType } from "react-icons"; import type { IconType } from "react-icons";
import { TbBox, TbCirclesRelation, TbPhoto } from "react-icons/tb"; import { TbBox, TbCirclesRelation, TbPhoto } from "react-icons/tb";
import { twMerge } from "tailwind-merge"; import { twMerge } from "tailwind-merge";
import { import { ModalBody, ModalFooter, useStepContext } from "./CreateModal";
type ModalActions,
ModalBody,
ModalFooter,
type TCreateModalSchema,
type TSchemaAction,
useStepContext,
} from "./CreateModal";
import Templates from "./templates/register"; import Templates from "./templates/register";
import type { TCreateModalSchema, TSchemaAction } from "./schema";
export function StepSelect() { export function StepSelect() {
const { nextStep, stepBack, state, path, setState } = useStepContext<TCreateModalSchema>(); const { nextStep, stepBack, state, path, setState } = useStepContext<TCreateModalSchema>();
@@ -7,14 +7,9 @@ import { useBknd } from "ui/client/bknd";
import { MantineNumberInput } from "ui/components/form/hook-form-mantine/MantineNumberInput"; import { MantineNumberInput } from "ui/components/form/hook-form-mantine/MantineNumberInput";
import { MantineRadio } from "ui/components/form/hook-form-mantine/MantineRadio"; import { MantineRadio } from "ui/components/form/hook-form-mantine/MantineRadio";
import { MantineSelect } from "ui/components/form/hook-form-mantine/MantineSelect"; import { MantineSelect } from "ui/components/form/hook-form-mantine/MantineSelect";
import { import { ModalBody, ModalFooter, useStepContext } from "../../CreateModal";
ModalBody, import type { TCreateModalSchema, TFieldCreate } from "../../schema";
ModalFooter, import { s, stringIdentifier } from "bknd/core";
type TCreateModalSchema,
type TFieldCreate,
useStepContext,
} from "../../CreateModal";
import { s, stringIdentifier } from "core/object/schema";
import { standardSchemaResolver } from "@hookform/resolvers/standard-schema"; import { standardSchemaResolver } from "@hookform/resolvers/standard-schema";
const schema = s.object({ const schema = s.object({
@@ -4,7 +4,7 @@ import { type Trigger, TriggerMap } from "flows";
import type { IconType } from "react-icons"; import type { IconType } from "react-icons";
import { TbCircleLetterT } from "react-icons/tb"; import { TbCircleLetterT } from "react-icons/tb";
import { JsonSchemaForm } from "ui/components/form/json-schema"; import { JsonSchemaForm } from "ui/components/form/json-schema";
import { s } from "core/object/schema"; import { s } from "bknd/core";
export type TaskComponentProps = NodeProps<Node<{ trigger: Trigger }>> & { export type TaskComponentProps = NodeProps<Node<{ trigger: Trigger }>> & {
Icon?: IconType; Icon?: IconType;
@@ -2,7 +2,7 @@ import { Input, TextInput } from "@mantine/core";
import { useToggle } from "@mantine/hooks"; import { useToggle } from "@mantine/hooks";
import { IconMinus, IconPlus, IconWorld } from "@tabler/icons-react"; import { IconMinus, IconPlus, IconWorld } from "@tabler/icons-react";
import type { Node, NodeProps } from "@xyflow/react"; import type { Node, NodeProps } from "@xyflow/react";
import { s } from "core/object/schema"; import { s } from "bknd/core";
import { FetchTask } from "flows"; import { FetchTask } from "flows";
import { useState } from "react"; import { useState } from "react";
import { useForm } from "react-hook-form"; import { useForm } from "react-hook-form";
@@ -10,7 +10,7 @@ import { MantineSelect } from "ui/components/form/hook-form-mantine/MantineSelec
import { useFlowCanvas, useFlowSelector } from "../../../hooks/use-flow"; import { useFlowCanvas, useFlowSelector } from "../../../hooks/use-flow";
import { BaseNode } from "../BaseNode"; import { BaseNode } from "../BaseNode";
import { Handle } from "../Handle"; import { Handle } from "../Handle";
import { s } from "core/object/schema"; import { s } from "bknd/core";
import { standardSchemaResolver } from "@hookform/resolvers/standard-schema"; import { standardSchemaResolver } from "@hookform/resolvers/standard-schema";
const schema = s.object({ const schema = s.object({
+1 -1
View File
@@ -6,7 +6,7 @@ import { Button } from "../../components/buttons/Button";
import { CellValue, DataTable } from "../../components/table/DataTable"; import { CellValue, DataTable } from "../../components/table/DataTable";
import * as AppShell from "../../layouts/AppShell/AppShell"; import * as AppShell from "../../layouts/AppShell/AppShell";
import { routes, useNavigate } from "../../lib/routes"; import { routes, useNavigate } from "../../lib/routes";
import { stringIdentifier } from "core/object/schema"; import { stringIdentifier } from "bknd/core";
export function AuthRolesList() { export function AuthRolesList() {
const [navigate] = useNavigate(); const [navigate] = useNavigate();
+1 -1
View File
@@ -6,7 +6,7 @@ import { type UseControllerProps, useController, useForm } from "react-hook-form
import { useBknd } from "ui/client/bknd"; import { useBknd } from "ui/client/bknd";
import { Button } from "ui/components/buttons/Button"; import { Button } from "ui/components/buttons/Button";
import { MantineSwitch } from "ui/components/form/hook-form-mantine/MantineSwitch"; import { MantineSwitch } from "ui/components/form/hook-form-mantine/MantineSwitch";
import type { s } from "core/object/schema"; import type { s } from "bknd/core";
import { standardSchemaResolver } from "@hookform/resolvers/standard-schema"; import { standardSchemaResolver } from "@hookform/resolvers/standard-schema";
const schema = guardRoleSchema; const schema = guardRoleSchema;
@@ -11,7 +11,7 @@ import { Breadcrumbs2 } from "ui/layouts/AppShell/Breadcrumbs2";
import { routes, useNavigate } from "ui/lib/routes"; import { routes, useNavigate } from "ui/lib/routes";
import { EntityForm } from "ui/modules/data/components/EntityForm"; import { EntityForm } from "ui/modules/data/components/EntityForm";
import { useEntityForm } from "ui/modules/data/hooks/useEntityForm"; import { useEntityForm } from "ui/modules/data/hooks/useEntityForm";
import { s } from "core/object/schema"; import { s } from "bknd/core";
export function DataEntityCreate({ params }) { export function DataEntityCreate({ params }) {
const { $data } = useBkndData(); const { $data } = useBkndData();
@@ -14,7 +14,7 @@ import * as AppShell from "ui/layouts/AppShell/AppShell";
import { routes, useNavigate } from "ui/lib/routes"; import { routes, useNavigate } from "ui/lib/routes";
import { useCreateUserModal } from "ui/modules/auth/hooks/use-create-user-modal"; import { useCreateUserModal } from "ui/modules/auth/hooks/use-create-user-modal";
import { EntityTable2 } from "ui/modules/data/components/EntityTable2"; import { EntityTable2 } from "ui/modules/data/components/EntityTable2";
import { s } from "core/object/schema"; import { s } from "bknd/core";
import { pick } from "core/utils/objects"; import { pick } from "core/utils/objects";
const searchSchema = s.partialObject({ const searchSchema = s.partialObject({
@@ -21,7 +21,7 @@ import { dataFieldsUiSchema } from "../../settings/routes/data.settings";
import { useRoutePathState } from "ui/hooks/use-route-path-state"; import { useRoutePathState } from "ui/hooks/use-route-path-state";
import { MantineSelect } from "ui/components/form/hook-form-mantine/MantineSelect"; import { MantineSelect } from "ui/components/form/hook-form-mantine/MantineSelect";
import type { TPrimaryFieldFormat } from "data/fields/PrimaryField"; import type { TPrimaryFieldFormat } from "data/fields/PrimaryField";
import { s, stringIdentifier } from "core/object/schema"; import { s, stringIdentifier } from "bknd/core";
import { standardSchemaResolver } from "@hookform/resolvers/standard-schema"; import { standardSchemaResolver } from "@hookform/resolvers/standard-schema";
const fieldsSchemaObject = originalFieldsSchemaObject; const fieldsSchemaObject = originalFieldsSchemaObject;
@@ -13,7 +13,7 @@ import {
ModalTitle, ModalTitle,
} from "../../../components/modal/Modal2"; } from "../../../components/modal/Modal2";
import { Step, Steps, useStepContext } from "../../../components/steps/Steps"; import { Step, Steps, useStepContext } from "../../../components/steps/Steps";
import { s, stringIdentifier } from "core/object/schema"; import { s, stringIdentifier } from "bknd/core";
import { standardSchemaResolver } from "@hookform/resolvers/standard-schema"; import { standardSchemaResolver } from "@hookform/resolvers/standard-schema";
export type TCreateFlowModalSchema = any; export type TCreateFlowModalSchema = any;
@@ -18,7 +18,7 @@ import { Link, Route, useLocation } from "wouter";
import { extractSchema } from "../utils/schema"; import { extractSchema } from "../utils/schema";
import { SettingNewModal, type SettingsNewModalProps } from "./SettingNewModal"; import { SettingNewModal, type SettingsNewModalProps } from "./SettingNewModal";
import { SettingSchemaModal, type SettingsSchemaModalRef } from "./SettingSchemaModal"; import { SettingSchemaModal, type SettingsSchemaModalRef } from "./SettingSchemaModal";
import type { s } from "core/object/schema"; import type { s } from "bknd/core";
export type SettingProps< export type SettingProps<
Schema extends s.ObjectSchema = s.ObjectSchema, Schema extends s.ObjectSchema = s.ObjectSchema,
@@ -8,7 +8,7 @@ import { JsonSchemaForm, type JsonSchemaFormRef } from "ui/components/form/json-
import { Dropdown } from "ui/components/overlay/Dropdown"; import { Dropdown } from "ui/components/overlay/Dropdown";
import { Modal } from "ui/components/overlay/Modal"; import { Modal } from "ui/components/overlay/Modal";
import { useLocation } from "wouter"; import { useLocation } from "wouter";
import type { s } from "core/object/schema"; import type { s } from "bknd/core";
export type SettingsNewModalProps = { export type SettingsNewModalProps = {
schema: s.ObjectSchema; schema: s.ObjectSchema;
+1 -1
View File
@@ -1,5 +1,5 @@
import type { JSONSchema7 } from "json-schema"; import type { JSONSchema7 } from "json-schema";
import type { s } from "core/object/schema"; import type { s } from "bknd/core";
import { omitKeys } from "core/utils"; import { omitKeys } from "core/utils";
export function extractSchema< export function extractSchema<
@@ -3,7 +3,7 @@ import { useState } from "react";
import { JsonViewer } from "../../../components/code/JsonViewer"; import { JsonViewer } from "../../../components/code/JsonViewer";
import { JsonSchemaForm } from "../../../components/form/json-schema"; import { JsonSchemaForm } from "../../../components/form/json-schema";
import { Scrollable } from "../../../layouts/AppShell/AppShell"; import { Scrollable } from "../../../layouts/AppShell/AppShell";
import { parse } from "core/object/schema"; import { parse } from "bknd/core";
export default function FlowCreateSchemaTest() { export default function FlowCreateSchemaTest() {
//const schema = flowsConfigSchema; //const schema = flowsConfigSchema;
@@ -1,7 +1,7 @@
import { standardSchemaResolver } from "@hookform/resolvers/standard-schema"; import { standardSchemaResolver } from "@hookform/resolvers/standard-schema";
import { TextInput } from "@mantine/core"; import { TextInput } from "@mantine/core";
import { useForm } from "react-hook-form"; import { useForm } from "react-hook-form";
import { s } from "core/object/schema"; import { s } from "bknd/core";
const schema = s.object({ const schema = s.object({
example: s.string().optional(), example: s.string().optional(),