mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-15 20:17:22 +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() {
|
||||
return [
|
||||
/^entities\..*\.config$/,
|
||||
/^entities\..*\.fields\..*\.config$/
|
||||
///^entities\..*\.fields\..*\.config\.schema$/
|
||||
];
|
||||
return [/^entities\..*\.config$/, /^entities\..*\.fields\..*\.config$/];
|
||||
}
|
||||
|
||||
/*registerController(server: AppServer) {
|
||||
console.log("adding data controller to", this.basepath);
|
||||
server.add(this.basepath, new DataController(this.em));
|
||||
}*/
|
||||
|
||||
override toJSON(secrets?: boolean): AppDataConfig {
|
||||
return {
|
||||
...this.config,
|
||||
|
||||
@@ -12,6 +12,18 @@ export type { TAppFlowTaskSchema } from "./flows-schema";
|
||||
export class AppFlows extends Module<typeof flowsConfigSchema> {
|
||||
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() {
|
||||
//console.log("building flows", this.config);
|
||||
const flows = transformObject(this.config.flows, (flowConfig, name) => {
|
||||
@@ -67,15 +79,10 @@ export class AppFlows extends Module<typeof flowsConfigSchema> {
|
||||
this.setBuilt();
|
||||
}
|
||||
|
||||
getSchema() {
|
||||
return flowsConfigSchema;
|
||||
}
|
||||
|
||||
private getFlowInfo(flow: Flow) {
|
||||
override toJSON() {
|
||||
return {
|
||||
...flow.toJSON(),
|
||||
tasks: flow.tasks.length,
|
||||
connections: flow.connections
|
||||
...this.config,
|
||||
flows: transformObject(this.flows, (flow) => flow.toJSON())
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ export const flowSchema = Type.Object(
|
||||
{
|
||||
trigger: Type.Union(Object.values(triggerSchemaObject)),
|
||||
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()),
|
||||
responding_task: Type.Optional(Type.String())
|
||||
},
|
||||
|
||||
@@ -162,8 +162,8 @@ export class Flow {
|
||||
trigger: this.trigger.toJSON(),
|
||||
tasks: Object.fromEntries(this.tasks.map((t) => [t.name, t.toJSON()])),
|
||||
connections: Object.fromEntries(this.connections.map((c) => [c.id, c.toJSON()])),
|
||||
start_task: this.startTask.name,
|
||||
responding_task: this.respondingTask ? this.respondingTask.name : null
|
||||
start_task: this.startTask?.name,
|
||||
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 type { Task, TaskResult } from "./Task";
|
||||
|
||||
@@ -34,14 +34,14 @@ export class TaskConnection {
|
||||
}
|
||||
|
||||
toJSON() {
|
||||
return {
|
||||
return objectCleanEmpty({
|
||||
source: this.source.name,
|
||||
target: this.target.name,
|
||||
config: {
|
||||
...this.config,
|
||||
condition: this.config.condition?.toJSON()
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user