Merge pull request #44 from bknd-io/fix/flow-schema

fix advanced flow creation due to schema mismatches
This commit is contained in:
dswbx
2025-01-16 10:20:31 +01:00
committed by GitHub
5 changed files with 22 additions and 24 deletions

View File

@@ -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,

View File

@@ -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())
};
}
}

View File

@@ -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())
},

View File

@@ -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
};
}

View File

@@ -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()
}
};
});
}
}