mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-16 04:27:21 +00:00
fix advanced flow creation due to schema mismatches
This commit is contained in:
@@ -69,18 +69,9 @@ export class AppData extends Module<typeof dataConfigSchema> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override getOverwritePaths() {
|
override getOverwritePaths() {
|
||||||
return [
|
return [/^entities\..*\.config$/, /^entities\..*\.fields\..*\.config$/];
|
||||||
/^entities\..*\.config$/,
|
|
||||||
/^entities\..*\.fields\..*\.config$/
|
|
||||||
///^entities\..*\.fields\..*\.config\.schema$/
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*registerController(server: AppServer) {
|
|
||||||
console.log("adding data controller to", this.basepath);
|
|
||||||
server.add(this.basepath, new DataController(this.em));
|
|
||||||
}*/
|
|
||||||
|
|
||||||
override toJSON(secrets?: boolean): AppDataConfig {
|
override toJSON(secrets?: boolean): AppDataConfig {
|
||||||
return {
|
return {
|
||||||
...this.config,
|
...this.config,
|
||||||
|
|||||||
@@ -12,6 +12,18 @@ export type { TAppFlowTaskSchema } from "./flows-schema";
|
|||||||
export class AppFlows extends Module<typeof flowsConfigSchema> {
|
export class AppFlows extends Module<typeof flowsConfigSchema> {
|
||||||
private flows: Record<string, Flow> = {};
|
private flows: Record<string, Flow> = {};
|
||||||
|
|
||||||
|
getSchema() {
|
||||||
|
return flowsConfigSchema;
|
||||||
|
}
|
||||||
|
|
||||||
|
private getFlowInfo(flow: Flow) {
|
||||||
|
return {
|
||||||
|
...flow.toJSON(),
|
||||||
|
tasks: flow.tasks.length,
|
||||||
|
connections: flow.connections
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
override async build() {
|
override async build() {
|
||||||
//console.log("building flows", this.config);
|
//console.log("building flows", this.config);
|
||||||
const flows = transformObject(this.config.flows, (flowConfig, name) => {
|
const flows = transformObject(this.config.flows, (flowConfig, name) => {
|
||||||
@@ -67,15 +79,10 @@ export class AppFlows extends Module<typeof flowsConfigSchema> {
|
|||||||
this.setBuilt();
|
this.setBuilt();
|
||||||
}
|
}
|
||||||
|
|
||||||
getSchema() {
|
override toJSON() {
|
||||||
return flowsConfigSchema;
|
|
||||||
}
|
|
||||||
|
|
||||||
private getFlowInfo(flow: Flow) {
|
|
||||||
return {
|
return {
|
||||||
...flow.toJSON(),
|
...this.config,
|
||||||
tasks: flow.tasks.length,
|
flows: transformObject(this.flows, (flow) => flow.toJSON())
|
||||||
connections: flow.connections
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ export const flowSchema = Type.Object(
|
|||||||
{
|
{
|
||||||
trigger: Type.Union(Object.values(triggerSchemaObject)),
|
trigger: Type.Union(Object.values(triggerSchemaObject)),
|
||||||
tasks: Type.Optional(StringRecord(Type.Union(Object.values(taskSchemaObject)))),
|
tasks: Type.Optional(StringRecord(Type.Union(Object.values(taskSchemaObject)))),
|
||||||
connections: Type.Optional(StringRecord(connectionSchema, { default: {} })),
|
connections: Type.Optional(StringRecord(connectionSchema)),
|
||||||
start_task: Type.Optional(Type.String()),
|
start_task: Type.Optional(Type.String()),
|
||||||
responding_task: Type.Optional(Type.String())
|
responding_task: Type.Optional(Type.String())
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -162,8 +162,8 @@ export class Flow {
|
|||||||
trigger: this.trigger.toJSON(),
|
trigger: this.trigger.toJSON(),
|
||||||
tasks: Object.fromEntries(this.tasks.map((t) => [t.name, t.toJSON()])),
|
tasks: Object.fromEntries(this.tasks.map((t) => [t.name, t.toJSON()])),
|
||||||
connections: Object.fromEntries(this.connections.map((c) => [c.id, c.toJSON()])),
|
connections: Object.fromEntries(this.connections.map((c) => [c.id, c.toJSON()])),
|
||||||
start_task: this.startTask.name,
|
start_task: this.startTask?.name,
|
||||||
responding_task: this.respondingTask ? this.respondingTask.name : null
|
responding_task: this.respondingTask?.name
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { uuid } from "core/utils";
|
import { objectCleanEmpty, uuid } from "core/utils";
|
||||||
import { get } from "lodash-es";
|
import { get } from "lodash-es";
|
||||||
import type { Task, TaskResult } from "./Task";
|
import type { Task, TaskResult } from "./Task";
|
||||||
|
|
||||||
@@ -34,14 +34,14 @@ export class TaskConnection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
toJSON() {
|
toJSON() {
|
||||||
return {
|
return objectCleanEmpty({
|
||||||
source: this.source.name,
|
source: this.source.name,
|
||||||
target: this.target.name,
|
target: this.target.name,
|
||||||
config: {
|
config: {
|
||||||
...this.config,
|
...this.config,
|
||||||
condition: this.config.condition?.toJSON()
|
condition: this.config.condition?.toJSON()
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user