import { Process as SBDraft2Process } from "../../mappings/d2sb/Process"; import { CWLVersion } from "../../mappings/v1.0/CWLVersion"; import { NamespaceBag } from "../elements/namespace-bag"; import { EventHub } from "../helpers/EventHub"; import { Edge, Graph } from "../helpers/Graph"; import { ValidationBase } from "../helpers/validation/ValidationBase"; import { Customizable } from '../interfaces/Customizable'; import { Serializable } from "../interfaces/Serializable"; import { Process } from "./Process"; import { ProcessRequirement } from "./ProcessRequirement"; import { ProcessRequirementModel } from "./ProcessRequirementModel"; import { RequirementBaseModel } from "./RequirementBaseModel"; import { StepModel } from "./StepModel"; import { WorkflowInputParameterModel } from "./WorkflowInputParameterModel"; import { WorkflowOutputParameterModel } from "./WorkflowOutputParameterModel"; import { WorkflowStepInputModel } from "./WorkflowStepInputModel"; import { WorkflowStepOutputModel } from "./WorkflowStepOutputModel"; import { ExpressionModel } from "./ExpressionModel"; export declare abstract class WorkflowModel extends ValidationBase implements Serializable { id: string; cwlVersion: string | CWLVersion; class: string; sbgId: string; hasBatch: boolean; batchInput: string; batchByValue: string | string[]; namespaces: NamespaceBag; steps: StepModel[]; inputs: WorkflowInputParameterModel[]; outputs: WorkflowOutputParameterModel[]; hints: Array; /** Flag to indicate that the tool has finished deserializing */ protected constructed: boolean; /** Set of all expressions the tool contains */ private expressions; /** Array of all validation processes that are currently occurring */ private validationPromises; protected readonly eventHub: EventHub; label?: string; description?: string; customProps: any; readonly connections: Edge[]; readonly nodes: [string, any][]; private addVertex(connectionId, node, graph?); protected graph: Graph; constructor(loc: string); private initializeGraphWatchers(); abstract getContext(step: StepModel): any; protected initializeExprWatchers(): void; protected validateExpression(expression: ExpressionModel): Promise; protected validateAllExpressions(): void; /** * Emitted after a step is created * @param {"step.create"} event * @param {(step: StepModel) => void} handler */ on(event: "step.create", handler: (step: StepModel) => void): any; /** * Emitted after a step is removed * @param {"step.remove"} event * @param {(step: StepModel) => void} handler */ on(event: "step.remove", handler: (step: StepModel) => void): any; /** * Emitted after a step's label has changed * @param {"step.change"} event * @param {(step: StepModel) => void} handler */ on(event: "step.change", handler: (step: StepModel) => void): any; /** * Emitted when step's run is updated * @param {"step.update"} event * @param {(step: StepModel) => void} handler */ on(event: "step.update", handler: (step: StepModel) => void): any; /** * Emitted after a step's ID has changed * @param {"step.change.id"} event * @param {(step: StepModel) => void} handler */ on(event: "step.change.id", handler: (step: StepModel) => void): any; /** * Emitted after a step.run port is included in ports * @param {"step.inPort.show"} event * @param {(inPort: WorkflowStepInputModel) => void} handler */ on(event: "step.inPort.show", handler: (inPort: WorkflowStepInputModel) => void): any; /** * Emitted after a step's in port is hidden from the graph * @param {"step.inPort.hide"} event * @param {(inPort: WorkflowStepInputModel) => void} handler */ on(event: "step.inPort.hide", handler: (inPort: WorkflowStepInputModel) => void): any; /** * Emitted when a step's in ports are removed, such as after an update of the step's run * @param {"step.inPort.remove"} event * @param {(inPort: WorkflowStepInputModel) => void} handler */ on(event: "step.inPort.remove", handler: (inPort: WorkflowStepInputModel) => void): any; /** * Emitted when an in port is added to the step, such as after an update of the step's run * @param {"step.inPort.create"} event * @param {(inPort: WorkflowStepInputModel) => void} handler */ on(event: "step.inPort.create", handler: (inPort: WorkflowStepInputModel) => void): any; /** * Emitted when an out port is removed from the step, such as after an update of the step's run * @param {"step.outPort.remove"} event * @param {(outPort: WorkflowStepOutputModel) => void} handler */ on(event: "step.outPort.remove", handler: (outPort: WorkflowStepOutputModel) => void): any; /** * Emitted when an in port is added to the step, such as after an update of the step's run * @param {"step.outPort.create"} event * @param {(outPort: WorkflowStepOutputModel) => void} handler */ on(event: "step.outPort.create", handler: (outPort: WorkflowStepOutputModel) => void): any; /** * Emitted when a step in/out port is changed during an update of the step's run * @param {"step.port.change"} event * @param {(port: (WorkflowStepOutputModel | WorkflowStepInputModel)) => void} handler */ on(event: "step.port.change", handler: (port: WorkflowStepOutputModel | WorkflowStepInputModel) => void): any; /** * Emitted when an input is removed from the workflow * @param {"input.remove"} event * @param {(input: WorkflowInputParameterModel) => void} handler */ on(event: "input.remove", handler: (input: WorkflowInputParameterModel) => void): any; /** * Emitted when an input is created on the workflow * @param {"input.create"} event * @param {(input: WorkflowInputParameterModel) => void} handler */ on(event: "input.create", handler: (input: WorkflowInputParameterModel) => void): any; /** * Emitted when an output is removed from the workflow * @param {"output.remove"} event * @param {(output: WorkflowOutputParameterModel) => void} handler */ on(event: "output.remove", handler: (output: WorkflowOutputParameterModel) => void): any; /** * Emitted when an output is created on the workflow * @param {"output.create"} event * @param {(output: WorkflowOutputParameterModel) => void} handler */ on(event: "output.create", handler: (output: WorkflowOutputParameterModel) => void): any; /** * Emitted when some property of the workflow input/output changes that affects the rendering of the graph. * @example label * @param {"io.change"} event * @param {(io: (WorkflowOutputParameterModel | WorkflowInputParameterModel)) => void} handler */ on(event: "io.change", handler: (io: WorkflowOutputParameterModel | WorkflowInputParameterModel) => void): any; /** * Emitted when id of workflow input/output changes * @param {"io.change.id"} event * @param {(io: (WorkflowOutputParameterModel | WorkflowInputParameterModel)) => void} handler */ on(event: "io.change.id", handler: (io: WorkflowOutputParameterModel | WorkflowInputParameterModel) => void): any; /** * Emitted when id of workflow input/output changes * @param {"io.change.type"} event * @param {(loc: string) => void} handler */ on(event: "io.change.type", handler: (loc: string) => void): any; /** * Emitted when validation of workflow connections finishes * @param {"connections.updated"} event * @param {() => void} handler */ on(event: "connections.updated", handler: () => void): any; /** * Emitted when a connection is removed * @param {"connection.remove"} event * @param {(source: (WorkflowInputParameterModel | WorkflowStepOutputModel), destination: (WorkflowOutputParameterModel | WorkflowStepInputModel)) => void} handler */ on(event: "connection.remove", handler: (source: WorkflowInputParameterModel | WorkflowStepOutputModel, destination: WorkflowOutputParameterModel | WorkflowStepInputModel) => void): any; /** * Emitted when a connection is created * @param {"connection.create"} event * @param {(source: (WorkflowInputParameterModel | WorkflowStepOutputModel), destination: (WorkflowOutputParameterModel | WorkflowStepInputModel)) => void} handler */ on(event: "connection.create", handler: (source: WorkflowInputParameterModel | WorkflowStepOutputModel, destination: WorkflowOutputParameterModel | WorkflowStepInputModel) => void): any; off(event: string, handler: any): void; serializeEmbedded(retainSource?: boolean): any; serialize(): any; deserialize(attr: any): void; addHint(hint?: ProcessRequirement | any): RequirementBaseModel; protected createReq(req: ProcessRequirement, constructor: any, loc?: string, hint?: boolean): RequirementBaseModel; setBatch(input: any, type: any): void; findById(connectionId: string): any; protected _exposePort(inPort: WorkflowStepInputModel, inputConstructor: any): WorkflowInputParameterModel; /** * Expose creates an input on the workflow level and connects it with the exposed port * Sets inPort.isVisible to false * Sets input.isVisible to false */ exposePort(inPort: WorkflowStepInputModel): void; /** * Adds inPort to graph and makes a connection between it and its step * sets inPort.isVisible to true * * @name step.inPort.show */ includePort(inPort: WorkflowStepInputModel): void; /** * Removes connections to port to out/inputs, removes dangling inputs, sets port to invisible * * @name step.inPort.hide */ clearPort(inPort: WorkflowStepInputModel): void; clearOutPort(outPort: WorkflowStepOutputModel): void; /** * Checks if a workflow input has been leftover after removing */ private removeDanglingInput(connectionId); private removeDanglingOutput(connectionId); /** * Removes step from workflow and from graph * removes all connections to step and cleans up dangling inputs * @param step */ removeStep(step: StepModel | string): void; private removeStepFromGraph(step); /** * Removes input from workflow and from graph * removes all connections * @param input */ removeInput(input: WorkflowInputParameterModel | string): void; /** * Removes output from workflow and from graph * removes all connections * @param output */ removeOutput(output: WorkflowOutputParameterModel | string): void; /** * Checks if source contains stepId. * If it does, returns id of step.out, else null; * @param source * @param stepId */ protected isSourceFromStep(source: string, stepId: string): string; /** * Checks if ID is valid and if it already exists on the graph * @param id * @param connectionId */ private checkIdValidity(id, connectionId); /** * Changes ID of step, updates connections and nodes in graph */ changeStepId(step: StepModel, id: string): void; private removeIONodeFromGraph(node); changeIONodeId(node: WorkflowInputParameterModel | WorkflowOutputParameterModel, id: string): void; /** * Connects two vertices which have already been added to the graph */ private addEdge(source, destination, isVisible?, isValid?); private checkSrcAndDest(source, destination); disconnect(source: WorkflowInputParameterModel | WorkflowStepOutputModel | string, destination: WorkflowOutputParameterModel | WorkflowStepInputModel | string): void; connect(source: WorkflowInputParameterModel | WorkflowStepOutputModel | string, destination: WorkflowOutputParameterModel | WorkflowStepInputModel | string, show?: boolean): boolean; addStepFromProcess(proc: Process | SBDraft2Process): StepModel; /** * Checks for naming collisions in vertex ids, in case of collisions, * it will increment the provided id, otherwise it returns the original id */ protected getNextAvailableId(connectionId: string, isIO?: boolean, graph?: Graph): string; isConnected(): boolean; hasCycles(): boolean; /** * Finds matching ports to which pointA can connect within the workflow. * Looks at port type and fileTypes if they are specified. */ private gatherValidPorts(pointA, points, ltr); /** * Finds valid destination ports (workflow.outputs and step.in) * for a given source port (workflow.inputs and step.out); * @param port * @returns {any[]} */ gatherValidConnectionPoints(port: WorkflowInputParameterModel | WorkflowStepOutputModel | WorkflowOutputParameterModel | WorkflowStepInputModel | string): any[]; /** * Returns all possible sources on the graph */ gatherSources(): Array; /** * Returns all possible destinations on the graph */ gatherDestinations(): Array; protected addStepToGraph(step: StepModel, graph?: Graph): void; abstract createInputFromPort(inPort: WorkflowStepInputModel | string, data?: Customizable): WorkflowInputParameterModel; /** * @param inPort * @param inputConstructor * @param show * @param create * * @param data * @private */ protected _createInputFromPort(inPort: WorkflowStepInputModel | string, inputConstructor: { new (...args: any[]): WorkflowInputParameterModel; }, show?: boolean, create?: boolean, data?: Customizable): WorkflowInputParameterModel; /** * Creates a workflow output from a given step.out * @param port * @param data */ abstract createOutputFromPort(port: WorkflowStepOutputModel | string, data?: Customizable): WorkflowOutputParameterModel; protected _createOutputFromPort(outPort: WorkflowStepOutputModel | string, outputConstructor: { new (...args: any[]): WorkflowOutputParameterModel; }, show?: boolean, create?: boolean, opts?: Customizable): WorkflowOutputParameterModel; protected addInputToGraph(input: WorkflowInputParameterModel, graph?: Graph): void; protected addOutputToGraph(output: WorkflowOutputParameterModel, graph?: Graph): void; /** * Helper function to connect source to destination */ private connectSource(sourceId, dest, destNode, graph?); constructGraph(): Graph; /** * Returns type of node to be added to graph, for canvas rendering */ private getNodeType(node); protected getSourceConnectionId(source: string): string; /** * Validate all visible connections and sets correct validity state on destinations */ protected validateConnections(): void; /** * Validate connection between source and destination and sets correct validity state on destination */ private validateConnection(destination, source, graph?); /** * Validate all connections made with given destination */ private validateDestination(destination); /** * Validate all connections made with given IO port */ validateConnectionsForIOPort(port: WorkflowOutputParameterModel | WorkflowInputParameterModel): void; protected validateGraph(): void; validate(): Promise; }