diff --git a/app/src/data/AppData.ts b/app/src/data/AppData.ts index df90b57..210c834 100644 --- a/app/src/data/AppData.ts +++ b/app/src/data/AppData.ts @@ -69,18 +69,9 @@ export class AppData extends Module { } 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, diff --git a/app/src/flows/AppFlows.ts b/app/src/flows/AppFlows.ts index 34026e8..4f75cbf 100644 --- a/app/src/flows/AppFlows.ts +++ b/app/src/flows/AppFlows.ts @@ -12,6 +12,18 @@ export type { TAppFlowTaskSchema } from "./flows-schema"; export class AppFlows extends Module { private flows: Record = {}; + 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 { 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()) }; } } diff --git a/app/src/flows/flows-schema.ts b/app/src/flows/flows-schema.ts index 4fc2c2a..d073d15 100644 --- a/app/src/flows/flows-schema.ts +++ b/app/src/flows/flows-schema.ts @@ -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()) }, diff --git a/app/src/flows/flows/Flow.ts b/app/src/flows/flows/Flow.ts index 2890b7f..43356b6 100644 --- a/app/src/flows/flows/Flow.ts +++ b/app/src/flows/flows/Flow.ts @@ -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 }; } diff --git a/app/src/flows/tasks/TaskConnection.ts b/app/src/flows/tasks/TaskConnection.ts index 1a4e579..fb9e102 100644 --- a/app/src/flows/tasks/TaskConnection.ts +++ b/app/src/flows/tasks/TaskConnection.ts @@ -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() } - }; + }); } }