From 7bdb504ebac3c6036e078e539cff8b6b8901f893 Mon Sep 17 00:00:00 2001 From: Stefan Genov Date: Fri, 19 Jul 2024 16:33:52 +0300 Subject: [PATCH 01/13] feat: Added the new decorator for scheduled workflows Signed-off-by: Stefan Genov --- typescript/vrotsc/src/compiler/decorators.ts | 8 ++++++++ .../decorators/itemDecoratorStrategy.ts | 1 + .../waitingTimerItemDecoratorStrategy.ts | 2 -- vro-types/vrotsc-annotations/index.d.ts | 19 +++++++++++++++++++ 4 files changed, 28 insertions(+), 2 deletions(-) diff --git a/typescript/vrotsc/src/compiler/decorators.ts b/typescript/vrotsc/src/compiler/decorators.ts index 997d84e6..f4e9be55 100644 --- a/typescript/vrotsc/src/compiler/decorators.ts +++ b/typescript/vrotsc/src/compiler/decorators.ts @@ -127,6 +127,14 @@ export enum WorkflowItemType { * It can target a specific item and accepts input and output bindings */ Workflow = "WorkflowItem", + + /** + * This item type represents a scheduled workflow item + * + * It can target a specific item and accepts input bindings + * There is only one outputBinding if you want to get the scheduledTask information + */ + ScheduledWorkflow = "ScheduledWorkflowItem" } /////////////////////////////////// Polyglot Decorator /////////////////////////////////// diff --git a/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/itemDecoratorStrategy.ts b/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/itemDecoratorStrategy.ts index ef3a4384..1b14ccc9 100644 --- a/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/itemDecoratorStrategy.ts +++ b/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/itemDecoratorStrategy.ts @@ -77,6 +77,7 @@ export default class ItemDecoratorStrategy implements CanvasItemDecoratorStrateg + ` out-name="${targetItem}"` + ` type="${this.getCanvasType()}"` + ">").appendLine(); + stringBuilder.indent(); stringBuilder.append(``).appendLine(); diff --git a/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/waitingTimerItemDecoratorStrategy.ts b/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/waitingTimerItemDecoratorStrategy.ts index 6ab322b0..1b5c333b 100644 --- a/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/waitingTimerItemDecoratorStrategy.ts +++ b/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/waitingTimerItemDecoratorStrategy.ts @@ -38,8 +38,6 @@ import { InputOutputBindings, buildItemParameterBindings } from "./helpers/prese * ``` */ export default class WaitingTimerItemDecoratorStrategy implements CanvasItemDecoratorStrategy { - constructor(private readonly sourceFilePrinter: SourceFilePrinter = new DefaultSourceFilePrinter()) { } - getCanvasType(): string { return "waiting-timer"; } diff --git a/vro-types/vrotsc-annotations/index.d.ts b/vro-types/vrotsc-annotations/index.d.ts index 8ed98331..fccf2c46 100644 --- a/vro-types/vrotsc-annotations/index.d.ts +++ b/vro-types/vrotsc-annotations/index.d.ts @@ -245,6 +245,25 @@ interface VroWorkflowItemMethodDecorator { } +// ---------------------------------------------- Scheduled Workflow Canvas Item ------------------------------------------------ + +export declare const ScheduledWorkflowItem: VroScheduledWorkflowItemDecorator; + +interface VroScheduledWorkflowItemDecorator { + (obj?: VroScheduledWorkflowItemConfiguration): VroScheduledWorkflowItemMethodDecorator; + new(obj?: VroScheduledWorkflowItemConfiguration): VroScheduledWorkflowItemConfiguration; +} + +interface VroScheduledWorkflowItemConfiguration { + target?: string; + linkedItem: string; +} + +interface VroScheduledWorkflowItemMethodDecorator { + >(type: T): T; + (target: Object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor): void; +} + //--------------------------------------------- POLYGLOT ------------------------------------------------------------------------------- export declare const Polyglot: VroPolyglotDecorator; From b37156fa18c9468c4802e63c5be10520204533ac Mon Sep 17 00:00:00 2001 From: Stefan Genov Date: Fri, 19 Jul 2024 16:34:08 +0300 Subject: [PATCH 02/13] feat: Add the ScheduledWorkflowItemDecoratorStrategy source file pending Signed-off-by: Stefan Genov --- .../workflow/decorators/helpers/sourceFile.ts | 8 + .../scheduledWorkflowItemDecoratorStrategy.ts | 162 ++++++++++++++++++ 2 files changed, 170 insertions(+) create mode 100644 typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/scheduledWorkflowItemDecoratorStrategy.ts diff --git a/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/helpers/sourceFile.ts b/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/helpers/sourceFile.ts index e4ece20b..88664105 100644 --- a/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/helpers/sourceFile.ts +++ b/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/helpers/sourceFile.ts @@ -68,3 +68,11 @@ export class WrapperSourceFilePrinter implements SourceFilePrinter { ); } } + +export class ScheduledWorkflowItemSourceFilePrinter extends DefaultSourceFilePrinter { + public printSourceFile(methodNode: MethodDeclaration, sourceFile: SourceFile): string { + // return printSourceFile( + // ); + return ""; + } +} diff --git a/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/scheduledWorkflowItemDecoratorStrategy.ts b/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/scheduledWorkflowItemDecoratorStrategy.ts new file mode 100644 index 00000000..cb823767 --- /dev/null +++ b/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/scheduledWorkflowItemDecoratorStrategy.ts @@ -0,0 +1,162 @@ +/*- + * #%L + * vrotsc + * %% + * Copyright (C) 2023 - 2024 VMware + * %% + * Build Tools for VMware Aria + * Copyright 2023 VMware, Inc. + * + * This product is licensed to you under the BSD-2 license (the "License"). You may not use this product except in compliance with the BSD-2 License. + * + * This product may include a number of subcomponents with separate copyright notices and license terms. Your use of these subcomponents is subject to the terms and conditions of the subcomponent's license, as noted in the LICENSE file. + * #L% + */ +import { Decorator, MethodDeclaration, SourceFile } from "typescript"; +import { WorkflowItemDescriptor, WorkflowItemType } from "../../../../decorators"; +import { getDecoratorProps } from "../../../helpers/node"; +import CanvasItemDecoratorStrategy from "./canvasItemDecoratorStrategy"; +import { InputOutputBindings, buildItemParameterBindings } from "./helpers/presentation"; +import { findTargetItem } from "../helpers/findTargetItem"; +import { StringBuilderClass } from "../../../../../utilities/stringBuilder"; +import { ScheduledWorkflowItemSourceFilePrinter, SourceFilePrinter } from "./helpers/sourceFile"; + +/** + * + * Responsible for printing out the workflow item: + * @example + * ```xml + + + + + + + + + + + + + + + * ``` + */ +export default class ScheduledWorkflowItemDecoratorStrategy implements CanvasItemDecoratorStrategy { + constructor(private readonly sourceFilePrinter: SourceFilePrinter = new ScheduledWorkflowItemSourceFilePrinter()) { } + + getCanvasType(): string { + return "task"; + } + + getDecoratorType(): WorkflowItemType { + return WorkflowItemType.ScheduledWorkflow; + } + + registerItemArguments(itemInfo: WorkflowItemDescriptor, decoratorNode: Decorator): void { + getDecoratorProps(decoratorNode).forEach((propTuple) => { + const [propName, propValue] = propTuple; + switch (propName) { + case "target": + itemInfo.target = propValue; + break; + + case "exception": + itemInfo.canvasItemPolymorphicBag.exception = propValue; + break; + + case "linkedItem": + itemInfo.canvasItemPolymorphicBag.linkedItem = propValue; + break; + + default: + throw new Error(`Item attribute '${propName}' is not supported for ${this.getDecoratorType()} item`); + } + }); + } + + /** + * There is no need to print the source file for the workflow item + */ + printSourceFile(methodNode: MethodDeclaration, sourceFile: SourceFile): string { return ""; } + + /** + * Prints out the item + * + * - `out-name` is the target canvas item to be called after the item is executed + * + * @param itemInfo The item to print + * @param pos The position of the item in the workflow + * + * @returns The string representation of the item + */ + printItem(itemInfo: WorkflowItemDescriptor, pos: number): string { + const stringBuilder = new StringBuilderClass("", ""); + + this.validateNeededParameters(itemInfo); + + const targetItem = findTargetItem(itemInfo.target, pos, itemInfo); + if (targetItem === null) { + throw new Error(`Unable to find target item for ${this.getDecoratorType()} item`); + } + + stringBuilder.append(`").appendLine(); + + stringBuilder.indent(); + stringBuilder.append(``).appendLine(); + + stringBuilder.append(``).appendLine(); + stringBuilder.appendContent(buildItemParameterBindings(itemInfo, InputOutputBindings.IN_BINDINGS)); + stringBuilder.appendContent(buildItemParameterBindings(itemInfo, InputOutputBindings.OUT_BINDINGS)); + stringBuilder.append(``).appendLine(); + stringBuilder.unindent(); + stringBuilder.append(``).appendLine(); + + return stringBuilder.toString(); + } + + /** + * Validates that the item has all the required parameters + * + * Inputs: + * - workflowScheduleDate + * + * Outputs: + * - scheduledTask (optional) but if present, it should be the only output + * + * @param itemInfo The item to validate + * @throws Error if the item is missing required parameters + * @returns void + */ + private validateNeededParameters(itemInfo: WorkflowItemDescriptor): void { + const inputs = itemInfo.input; + + ["workflowScheduleDate"].forEach((input) => { + if (!inputs.includes(input)) { + throw new Error(`Decorator ${this.getDecoratorType()} is missing required input: ${input}`); + } + }); + + const outputs = itemInfo.output; + + if (outputs.length && outputs.length !== 1 && !outputs.includes("scheduledTask")) { + throw new Error(`Decorator ${this.getDecoratorType()} has an invalid output: ${outputs}, expected: scheduledTask`); + } + } +} + From 68a86cc54b4e6a19d4e3c314f6dfb986c9785e89 Mon Sep 17 00:00:00 2001 From: Stefan Genov Date: Fri, 19 Jul 2024 17:04:30 +0300 Subject: [PATCH 03/13] fix: Add the missing strategy to the list of possible decorators Signed-off-by: Stefan Genov --- .../transformer/fileTransformers/workflow/decorators.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators.ts b/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators.ts index 8f79f74d..2cf30f3a 100644 --- a/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators.ts +++ b/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators.ts @@ -23,6 +23,7 @@ import RootItemDecoratorStrategy from "./decorators/rootItemDecoratorStrategy"; import WaitingTimerItemDecoratorStrategy from "./decorators/waitingTimerItemDecoratorStrategy"; import DecisionItemDecoratorStrategy from "./decorators/decisionItemDecoratorStrategy"; import WorkflowItemDecoratorStrategy from "./decorators/workflowItemDecoratorStrategy"; +import ScheduledWorkflowItemDecoratorStrategy from "./decorators/scheduledWorkflowItemDecoratorStrategy"; /** * Fetches details from the decorators for the methods and adds the information to the Descriptors @@ -84,6 +85,8 @@ function getItemStrategy(decoratorNode: ts.Decorator): CanvasItemDecoratorStrate return new WorkflowItemDecoratorStrategy(); case WorkflowItemType.RootItem: return new RootItemDecoratorStrategy(); + case WorkflowItemType.ScheduledWorkflow: + return new ScheduledWorkflowItemDecoratorStrategy(); default: throw new Error(`Invalid decorator type: ${identifierText}`); } From c2fee0b0c2a602690f07db0faab815c07672616d Mon Sep 17 00:00:00 2001 From: Stefan Genov Date: Fri, 19 Jul 2024 17:07:08 +0300 Subject: [PATCH 04/13] fix: Added `itemInfo` to be passed in the `printSourceFile` Signed-off-by: Stefan Genov --- .../decorators/canvasItemDecoratorStrategy.ts | 2 +- .../decisionItemDecoratorStrategy.ts | 4 +- .../workflow/decorators/helpers/sourceFile.ts | 85 +++++++++++++++++-- .../decorators/itemDecoratorStrategy.ts | 4 +- .../decorators/rootItemDecoratorStrategy.ts | 2 +- .../scheduledWorkflowItemDecoratorStrategy.ts | 8 +- .../waitingTimerItemDecoratorStrategy.ts | 2 +- .../workflowItemDecoratorStrategy.ts | 2 +- .../fileTransformers/workflow/workflow.ts | 2 +- 9 files changed, 91 insertions(+), 20 deletions(-) diff --git a/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/canvasItemDecoratorStrategy.ts b/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/canvasItemDecoratorStrategy.ts index 7f06f856..86dde707 100644 --- a/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/canvasItemDecoratorStrategy.ts +++ b/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/canvasItemDecoratorStrategy.ts @@ -36,7 +36,7 @@ export default interface CanvasItemDecoratorStrategy { * * The rest can return an empty string. */ - printSourceFile(methodNode: ts.MethodDeclaration, sourceFile: ts.SourceFile): string; + printSourceFile(methodNode: ts.MethodDeclaration, sourceFile: ts.SourceFile, itemInfo: WorkflowItemDescriptor): string; printItem(itemInfo: WorkflowItemDescriptor, pos: number): string; } diff --git a/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/decisionItemDecoratorStrategy.ts b/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/decisionItemDecoratorStrategy.ts index ae80fb69..0dd9beb8 100644 --- a/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/decisionItemDecoratorStrategy.ts +++ b/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/decisionItemDecoratorStrategy.ts @@ -66,8 +66,8 @@ export default class DecisionItemDecoratorStrategy implements CanvasItemDecorato }); } - printSourceFile(methodNode: MethodDeclaration, sourceFile: SourceFile): string { - return this.sourceFilePrinter.printSourceFile(methodNode, sourceFile); + printSourceFile(methodNode: MethodDeclaration, sourceFile: SourceFile, itemInfo: WorkflowItemDescriptor): string { + return this.sourceFilePrinter.printSourceFile(methodNode, sourceFile, itemInfo); } /** diff --git a/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/helpers/sourceFile.ts b/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/helpers/sourceFile.ts index 88664105..cda4ad76 100644 --- a/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/helpers/sourceFile.ts +++ b/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/helpers/sourceFile.ts @@ -15,16 +15,17 @@ import { MethodDeclaration, SourceFile, SyntaxKind, factory } from "typescript"; import { printSourceFile } from "../../../../helpers/source"; import { createWorkflowItemPrologueStatements } from "../../../../codeTransformers/prologueStatements"; +import { WorkflowItemDescriptor } from "../../../../../decorators"; export interface SourceFilePrinter { - printSourceFile(methodNode: MethodDeclaration, sourceFile: SourceFile): string; + printSourceFile(methodNode: MethodDeclaration, sourceFile: SourceFile, itemInfo?: WorkflowItemDescriptor): string; } /** * Default source file printer will directly print the source file with the method node body statements. */ export class DefaultSourceFilePrinter implements SourceFilePrinter { - public printSourceFile(methodNode: MethodDeclaration, sourceFile: SourceFile): string { + public printSourceFile(methodNode: MethodDeclaration, sourceFile: SourceFile, itemInfo: WorkflowItemDescriptor): string { return printSourceFile( factory.updateSourceFile( sourceFile, @@ -46,7 +47,7 @@ export class DefaultSourceFilePrinter implements SourceFilePrinter { * @NOTE: This is 100% due to a typescript limitation, and not a vRO limitation. */ export class WrapperSourceFilePrinter implements SourceFilePrinter { - public printSourceFile(methodNode: MethodDeclaration, sourceFile: SourceFile): string { + public printSourceFile(methodNode: MethodDeclaration, sourceFile: SourceFile, itemInfo: WorkflowItemDescriptor): string { const wrapperFunction = factory.createFunctionDeclaration( undefined, undefined, @@ -69,10 +70,78 @@ export class WrapperSourceFilePrinter implements SourceFilePrinter { } } -export class ScheduledWorkflowItemSourceFilePrinter extends DefaultSourceFilePrinter { - public printSourceFile(methodNode: MethodDeclaration, sourceFile: SourceFile): string { - // return printSourceFile( - // ); - return ""; + +// +// +// +// +// +// +// +// +// +// +// +// +// +// +export class ScheduledWorkflowItemSourceFilePrinter implements SourceFilePrinter { + public printSourceFile(methodNode: MethodDeclaration, sourceFile: SourceFile, itemInfo: WorkflowItemDescriptor): string { + const segments = []; + + segments.push( + factory.createVariableDeclaration( + "workflowToLaunch", + undefined, + undefined, + factory.createCallExpression( + factory.createPropertyAccessExpression( + factory.createIdentifier("Server"), + factory.createIdentifier("getWorkflowWithId") + ), + undefined, + [factory.createStringLiteral(itemInfo.canvasItemPolymorphicBag.linkedItem)] + ) + ) + ); + + segments.push( + factory.createIfStatement( + factory.createBinaryExpression( + factory.createIdentifier("workflowToLaunch"), + factory.createToken(SyntaxKind.ExclamationEqualsToken), + factory.createNull() + ), + factory.createBlock( + [ + factory.createThrowStatement( + factory.createStringLiteral("Workflow not found") + ) + ], + true + ) + ) + ); + + return printSourceFile( + factory.updateSourceFile( + sourceFile, + [ + ...sourceFile.statements.filter(n => n.kind !== SyntaxKind.ClassDeclaration), + ...createWorkflowItemPrologueStatements(methodNode), + ...segments, + ] + ) + ); } } diff --git a/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/itemDecoratorStrategy.ts b/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/itemDecoratorStrategy.ts index 1b14ccc9..032083df 100644 --- a/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/itemDecoratorStrategy.ts +++ b/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/itemDecoratorStrategy.ts @@ -50,8 +50,8 @@ export default class ItemDecoratorStrategy implements CanvasItemDecoratorStrateg }); } - printSourceFile(methodNode: MethodDeclaration, sourceFile: SourceFile): string { - return this.sourceFilePrinter.printSourceFile(methodNode, sourceFile); + printSourceFile(methodNode: MethodDeclaration, sourceFile: SourceFile, itemInfo: WorkflowItemDescriptor): string { + return this.sourceFilePrinter.printSourceFile(methodNode, sourceFile, itemInfo); } /** diff --git a/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/rootItemDecoratorStrategy.ts b/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/rootItemDecoratorStrategy.ts index cb64ddb6..0e0de2a9 100644 --- a/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/rootItemDecoratorStrategy.ts +++ b/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/rootItemDecoratorStrategy.ts @@ -34,7 +34,7 @@ export default class RootItemDecoratorStrategy implements CanvasItemDecoratorStr itemInfo.parent.rootItem = methodNode.name.escapedText as string; } - printSourceFile(methodNode: MethodDeclaration, sourceFile: SourceFile): string { return this.throwDoNotCallError(); } + printSourceFile(methodNode: MethodDeclaration, sourceFile: SourceFile, itemInfo: WorkflowItemDescriptor): string { return this.throwDoNotCallError(); } getCanvasType(): string { return this.throwDoNotCallError(); } printItem(itemInfo: WorkflowItemDescriptor, pos: number): string { return this.throwDoNotCallError(); } diff --git a/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/scheduledWorkflowItemDecoratorStrategy.ts b/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/scheduledWorkflowItemDecoratorStrategy.ts index cb823767..19e62c26 100644 --- a/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/scheduledWorkflowItemDecoratorStrategy.ts +++ b/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/scheduledWorkflowItemDecoratorStrategy.ts @@ -88,7 +88,9 @@ export default class ScheduledWorkflowItemDecoratorStrategy implements CanvasIte /** * There is no need to print the source file for the workflow item */ - printSourceFile(methodNode: MethodDeclaration, sourceFile: SourceFile): string { return ""; } + printSourceFile(methodNode: MethodDeclaration, sourceFile: SourceFile, itemInfo: WorkflowItemDescriptor): string { + return this.sourceFilePrinter.printSourceFile(methodNode, sourceFile, itemInfo); + } /** * Prints out the item @@ -134,10 +136,10 @@ export default class ScheduledWorkflowItemDecoratorStrategy implements CanvasIte * Validates that the item has all the required parameters * * Inputs: - * - workflowScheduleDate + * - {Date} workflowScheduleDate * * Outputs: - * - scheduledTask (optional) but if present, it should be the only output + * - {Task} scheduledTask (optional) but if present, it should be the only output * * @param itemInfo The item to validate * @throws Error if the item is missing required parameters diff --git a/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/waitingTimerItemDecoratorStrategy.ts b/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/waitingTimerItemDecoratorStrategy.ts index 1b5c333b..69eb9d6e 100644 --- a/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/waitingTimerItemDecoratorStrategy.ts +++ b/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/waitingTimerItemDecoratorStrategy.ts @@ -64,7 +64,7 @@ export default class WaitingTimerItemDecoratorStrategy implements CanvasItemDeco /** * There is no need to print the source file for a waiting timer item */ - printSourceFile(methodNode: MethodDeclaration, sourceFile: SourceFile): string { return ""; } + printSourceFile(methodNode: MethodDeclaration, sourceFile: SourceFile, itemInfo: WorkflowItemDescriptor): string { return ""; } /** * Prints the waiting timer to the workflow file diff --git a/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/workflowItemDecoratorStrategy.ts b/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/workflowItemDecoratorStrategy.ts index 53b62812..de8f936d 100644 --- a/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/workflowItemDecoratorStrategy.ts +++ b/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/workflowItemDecoratorStrategy.ts @@ -74,7 +74,7 @@ export default class WorkflowItemDecoratorStrategy implements CanvasItemDecorato /** * There is no need to print the source file for the workflow item */ - printSourceFile(methodNode: MethodDeclaration, sourceFile: SourceFile): string { return ""; } + printSourceFile(methodNode: MethodDeclaration, sourceFile: SourceFile, itemInfo: WorkflowItemDescriptor): string { return ""; } /** * Prints out the item diff --git a/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/workflow.ts b/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/workflow.ts index d1c66380..86cdf859 100644 --- a/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/workflow.ts +++ b/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/workflow.ts @@ -97,7 +97,7 @@ export function getWorkflowTransformer(file: FileDescriptor, context: FileTransf registerWorkflowItem(itemInfo, methodNode); const actionSourceFilePath = system.changeFileExt(sourceFile.fileName, `.${itemInfo.name}.wf.ts`, [".wf.ts"]); - let actionSourceText = itemInfo.strategy.printSourceFile(methodNode, sourceFile); + let actionSourceText = itemInfo.strategy.printSourceFile(methodNode, sourceFile, itemInfo); // @TODO: "Unstupify" me if (itemInfo.polyglot) { actionSourceText = decorateSourceFileTextWithPolyglot(actionSourceText, itemInfo.polyglot, itemInfo); From 2dde4a145a4a06c23ed118fca7c99ec996da08a4 Mon Sep 17 00:00:00 2001 From: Stefan Genov Date: Fri, 19 Jul 2024 17:48:48 +0300 Subject: [PATCH 05/13] fix: Wrong format for the linked workflow xml prop Signed-off-by: Stefan Genov --- .../decorators/scheduledWorkflowItemDecoratorStrategy.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/scheduledWorkflowItemDecoratorStrategy.ts b/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/scheduledWorkflowItemDecoratorStrategy.ts index 19e62c26..1ce28b9d 100644 --- a/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/scheduledWorkflowItemDecoratorStrategy.ts +++ b/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/scheduledWorkflowItemDecoratorStrategy.ts @@ -116,7 +116,7 @@ export default class ScheduledWorkflowItemDecoratorStrategy implements CanvasIte + ` name="item${pos}"` + ` out-name="${targetItem}"` + ` type="${this.getCanvasType()}"` - + ` linked-workflow-id="${itemInfo.canvasItemPolymorphicBag.linkedItem}"` + + ` launched-workflow-id="${itemInfo.canvasItemPolymorphicBag.linkedItem}"` + ">").appendLine(); stringBuilder.indent(); From e9a8a2076cb704bc579c34bdf0b616f83fc8af94 Mon Sep 17 00:00:00 2001 From: Stefan Genov Date: Fri, 19 Jul 2024 17:49:07 +0300 Subject: [PATCH 06/13] refactor: Moved the printing away from a block and into the print file Signed-off-by: Stefan Genov --- .../workflow/decorators/helpers/sourceFile.ts | 154 ++++++++++++------ 1 file changed, 100 insertions(+), 54 deletions(-) diff --git a/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/helpers/sourceFile.ts b/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/helpers/sourceFile.ts index cda4ad76..d3c8d2c6 100644 --- a/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/helpers/sourceFile.ts +++ b/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/helpers/sourceFile.ts @@ -12,7 +12,7 @@ * This product may include a number of subcomponents with separate copyright notices and license terms. Your use of these subcomponents is subject to the terms and conditions of the subcomponent's license, as noted in the LICENSE file. * #L% */ -import { MethodDeclaration, SourceFile, SyntaxKind, factory } from "typescript"; +import { MethodDeclaration, SourceFile, SyntaxKind, addSyntheticLeadingComment, factory } from "typescript"; import { printSourceFile } from "../../../../helpers/source"; import { createWorkflowItemPrologueStatements } from "../../../../codeTransformers/prologueStatements"; import { WorkflowItemDescriptor } from "../../../../../decorators"; @@ -70,10 +70,12 @@ export class WrapperSourceFilePrinter implements SourceFilePrinter { } } - -// -// -// -// -// -// -// -// -// -// -// -// -// -// + * + */ export class ScheduledWorkflowItemSourceFilePrinter implements SourceFilePrinter { public printSourceFile(methodNode: MethodDeclaration, sourceFile: SourceFile, itemInfo: WorkflowItemDescriptor): string { - const segments = []; - - segments.push( - factory.createVariableDeclaration( - "workflowToLaunch", - undefined, - undefined, - factory.createCallExpression( - factory.createPropertyAccessExpression( - factory.createIdentifier("Server"), - factory.createIdentifier("getWorkflowWithId") - ), - undefined, - [factory.createStringLiteral(itemInfo.canvasItemPolymorphicBag.linkedItem)] - ) - ) - ); - - segments.push( - factory.createIfStatement( - factory.createBinaryExpression( - factory.createIdentifier("workflowToLaunch"), - factory.createToken(SyntaxKind.ExclamationEqualsToken), - factory.createNull() - ), - factory.createBlock( - [ - factory.createThrowStatement( - factory.createStringLiteral("Workflow not found") - ) - ], - true - ) - ) - ); - return printSourceFile( factory.updateSourceFile( sourceFile, [ ...sourceFile.statements.filter(n => n.kind !== SyntaxKind.ClassDeclaration), ...createWorkflowItemPrologueStatements(methodNode), - ...segments, + // Variable declarations are on top + factory.createVariableStatement( + undefined, + // A list of declarations + factory.createVariableDeclarationList( + [ + // `var workflowParameters = new Properties();` + factory.createVariableDeclaration( + "workflowParameters", + undefined, + undefined, + factory.createNewExpression( + factory.createIdentifier("Properties"), + undefined, + [] + ) + ), + // `, workflowToLaunch = Server.getWorkflowWithId("some id here");` + factory.createVariableDeclaration( + "workflowToLaunch", + undefined, + undefined, + factory.createCallExpression( + factory.createPropertyAccessExpression( + factory.createIdentifier("Server"), + factory.createIdentifier("getWorkflowWithId") + ), + undefined, + [factory.createStringLiteral(itemInfo.canvasItemPolymorphicBag.linkedItem)] + ) + ) + ], + undefined + ) + ), + + // `if (workflowToLaunch == null) { throw "Workflow not found"; }` + factory.createIfStatement( + factory.createBinaryExpression( + factory.createIdentifier("workflowToLaunch"), + factory.createToken(SyntaxKind.EqualsEqualsToken), + factory.createNull() + ), + factory.createBlock( + [ + factory.createThrowStatement( + factory.createStringLiteral("Workflow not found") + ) + ], + true + ) + ), + + // `workflowParameters.put("first",first);` + // `workflowParameters.put("second",second);` + // ...... etc + ...itemInfo.input.filter(i => i !== "workflowScheduleDate").map((input) => { + return factory.createExpressionStatement( + factory.createCallExpression( + factory.createPropertyAccessExpression( + factory.createIdentifier("workflowParameters"), + factory.createIdentifier("put") + ), + undefined, + [ + factory.createStringLiteral(input), + factory.createIdentifier(input) + ] + ) + ); + }), + + // `scheduledTask = workflowToLaunch.schedule(workflowParameters, workflowScheduleDate);` + factory.createExpressionStatement( + factory.createAssignment( + factory.createIdentifier("scheduledTask"), + factory.createCallExpression( + factory.createPropertyAccessExpression( + factory.createIdentifier("workflowToLaunch"), + factory.createIdentifier("schedule") + ), + undefined, + [ + factory.createIdentifier("workflowParameters"), + factory.createIdentifier("workflowScheduleDate"), + factory.createIdentifier("undefined"), + factory.createIdentifier("undefined") + ] + ) + ) + ) ] ) ); From b687935e2e3d770633d9bf369142c4c07ff6c0e8 Mon Sep 17 00:00:00 2001 From: Stefan Genov Date: Fri, 19 Jul 2024 18:10:11 +0300 Subject: [PATCH 07/13] test: Add e2e tests for scheduled workflow Signed-off-by: Stefan Genov --- .../canvas-items/scheduled-workflow.wf.ts | 54 ++++++++++++++++ .../@types/vrotsc-annotations/index.d.ts | 61 ++++++------------- .../Scheduled Workflow Test.element_info.xml | 9 +++ .../VMware/PSCoE/Scheduled Workflow Test.xml | 13 ++++ 4 files changed, 95 insertions(+), 42 deletions(-) create mode 100644 typescript/vrotsc/e2e/cases/canvas-items/scheduled-workflow.wf.ts create mode 100644 typescript/vrotsc/e2e/expect/canvas-items/workflows/VMware/PSCoE/Scheduled Workflow Test.element_info.xml create mode 100644 typescript/vrotsc/e2e/expect/canvas-items/workflows/VMware/PSCoE/Scheduled Workflow Test.xml diff --git a/typescript/vrotsc/e2e/cases/canvas-items/scheduled-workflow.wf.ts b/typescript/vrotsc/e2e/cases/canvas-items/scheduled-workflow.wf.ts new file mode 100644 index 00000000..d5792ed8 --- /dev/null +++ b/typescript/vrotsc/e2e/cases/canvas-items/scheduled-workflow.wf.ts @@ -0,0 +1,54 @@ +import { Workflow, Out, In, Item, RootItem, ScheduledWorkflowItem } from "vrotsc-annotations"; + +@Workflow({ + name: "Scheduled Workflow Test", + path: "VMware/PSCoE", + description: "Scheduling another workflow and binding values correctly", + attributes: { + waitingTimer: { + type: "Date" + }, + counter: { + type: "number" + }, + first: { + type: "number" + }, + second: { + type: "number" + }, + workflowScheduleDate: { + type: "Date" + }, + scheduledTask: { + type: "Task" + } + } +}) +export class HandleNetworkConfigurationBackup { + @ScheduledWorkflowItem({ + target: "printScheduledDetails", + linkedItem: "9e4503db-cbaa-435a-9fad-144409c08df0" + }) + public scheduleOtherWf(@In first: number, @In second: number, @In workflowScheduleDate: Date, @Out scheduledTask: Task) { + } + + @Item({ target: "scheduleOtherWf" }) + public prepareItems(@In @Out first: number, @In @Out second: number, @In @Out workflowScheduleDate: Date) { + first = 1; + second = 2; + workflowScheduleDate = System.getDate("1 minute from now", undefined); + } + + @Item({ target: "end" }) + public printScheduledDetails(@In scheduledTask: Task) { + System.log(`Scheduled task: ${scheduledTask.id}, [${scheduledTask.state}]`); + } + + + @Item({ target: "prepareItems", exception: "" }) + @RootItem() + public start() { + System.log("Starting workflow"); + } +} diff --git a/typescript/vrotsc/e2e/cases/node_modules/@types/vrotsc-annotations/index.d.ts b/typescript/vrotsc/e2e/cases/node_modules/@types/vrotsc-annotations/index.d.ts index e284c071..fccf2c46 100644 --- a/typescript/vrotsc/e2e/cases/node_modules/@types/vrotsc-annotations/index.d.ts +++ b/typescript/vrotsc/e2e/cases/node_modules/@types/vrotsc-annotations/index.d.ts @@ -186,15 +186,6 @@ interface VroWaitingTimerItemMethodDecorator { >(type: T): T; (target: Object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor): void; } -// -// -// -// -// -// -// -// -// // ---------------------------------------------- Workflow Canvas Decision Item ------------------------------------------------ @@ -215,16 +206,6 @@ interface VroDecisionItemMethodDecorator { (target: Object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor): void; } -// -// -// -// -// -// -// -// -// -// // ---------------------------------------------- Workflow Canvas Root Item ------------------------------------------------ @@ -243,16 +224,6 @@ interface VroRootItemMethodDecorator { (target: Object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor): void; } -// -// -// -// -// -// -// -// -// -// // ---------------------------------------------- Workflow Canvas Item ------------------------------------------------ @@ -273,19 +244,25 @@ interface VroWorkflowItemMethodDecorator { (target: Object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor): void; } -// -// -// -// -// -// -// -// -// -// -// -// -// + +// ---------------------------------------------- Scheduled Workflow Canvas Item ------------------------------------------------ + +export declare const ScheduledWorkflowItem: VroScheduledWorkflowItemDecorator; + +interface VroScheduledWorkflowItemDecorator { + (obj?: VroScheduledWorkflowItemConfiguration): VroScheduledWorkflowItemMethodDecorator; + new(obj?: VroScheduledWorkflowItemConfiguration): VroScheduledWorkflowItemConfiguration; +} + +interface VroScheduledWorkflowItemConfiguration { + target?: string; + linkedItem: string; +} + +interface VroScheduledWorkflowItemMethodDecorator { + >(type: T): T; + (target: Object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor): void; +} //--------------------------------------------- POLYGLOT ------------------------------------------------------------------------------- export declare const Polyglot: VroPolyglotDecorator; diff --git a/typescript/vrotsc/e2e/expect/canvas-items/workflows/VMware/PSCoE/Scheduled Workflow Test.element_info.xml b/typescript/vrotsc/e2e/expect/canvas-items/workflows/VMware/PSCoE/Scheduled Workflow Test.element_info.xml new file mode 100644 index 00000000..b742e43c --- /dev/null +++ b/typescript/vrotsc/e2e/expect/canvas-items/workflows/VMware/PSCoE/Scheduled Workflow Test.element_info.xml @@ -0,0 +1,9 @@ + + + +Generated by vrotsc +VMware.PSCoE +Scheduled Workflow Test +Workflow +18b56581-f9ac-30cb-8df2-8c1c7e5dba37 + diff --git a/typescript/vrotsc/e2e/expect/canvas-items/workflows/VMware/PSCoE/Scheduled Workflow Test.xml b/typescript/vrotsc/e2e/expect/canvas-items/workflows/VMware/PSCoE/Scheduled Workflow Test.xml new file mode 100644 index 00000000..594b0523 --- /dev/null +++ b/typescript/vrotsc/e2e/expect/canvas-items/workflows/VMware/PSCoE/Scheduled Workflow Test.xml @@ -0,0 +1,13 @@ + \ No newline at end of file From 28eb00c2aa4b9773991ca6868f97b67de2282124 Mon Sep 17 00:00:00 2001 From: Stefan Genov Date: Fri, 19 Jul 2024 18:18:51 +0300 Subject: [PATCH 08/13] docs: Added docs for scheduled Workflows Signed-off-by: Stefan Genov --- .../typescript/Components/Workflows.md | 185 +++++++++++------- docs/versions/latest/Release.md | 83 +++++++- 2 files changed, 196 insertions(+), 72 deletions(-) diff --git a/docs/versions/latest/Components/Archetypes/typescript/Components/Workflows.md b/docs/versions/latest/Components/Archetypes/typescript/Components/Workflows.md index a9fc558f..fa70a044 100644 --- a/docs/versions/latest/Components/Archetypes/typescript/Components/Workflows.md +++ b/docs/versions/latest/Components/Archetypes/typescript/Components/Workflows.md @@ -57,6 +57,29 @@ The decorator is used to specify a workflow item that will be called. In order to bind inputs and outputs, you do it with the `@In` and `@Out` decorators. This is the same way we do it for other items. +#### `@ScheduledWorkflowItem` + +The decorator is used to specify a scheduled workflow item that will be called. + +##### Supported Parameters + +- `target` - The name of the next in line item. Same as `@Item`. +- `linkedItem` - The ID of the workflow to schedule. + +In order to bind inputs and outputs, you do it with the `@In` and `@Out` decorators. This is the same way we do it for other items. + +##### Inputs + +Special input is needed for the ScheduledWorkflowItem. + +- `workflowScheduleDate` - {Date} is required. The name **must** be `workflowScheduleDate`. If this is missing an error is thrown. We don't check if the type is `Date` but Aria Orchestrator will complain. + +##### Outputs + +Special output is needed for the ScheduledWorkflowItem. + +- `scheduledTask` - {Task} is optional. If it's missing nothing will happen, if it's added, then the name **must** be `scheduledTask`. This is the task that is scheduled. + #### `@RootItem` This is a meta decorator. Add this to whichever function you want to be the entry point of the workflow. @@ -64,80 +87,100 @@ This is a meta decorator. Add this to whichever function you want to be the entr ### Example Workflow ```ts -import { Workflow, Out, In, Item, RootItem, DecisionItem, WaitingTimerItem, WorkflowItem } from "vrotsc-annotations"; +import { Workflow, Out, In, Item, RootItem, DecisionItem, WaitingTimerItem, WorkflowItem, ScheduledWorkflowItem } from "vrotsc-annotations"; @Workflow({ - name: "Example Waiting Timer", - path: "VMware/PSCoE", - attributes: { - waitingTimer: { - type: "Date" - }, - counter: { - type: "number" - }, - first: { - type: "number" - }, - second: { - type: "number" - }, - result: { - type: "number" - } - } + name: "Example Waiting Timer", + path: "VMware/PSCoE", + attributes: { + waitingTimer: { + type: "Date" + }, + counter: { + type: "number" + }, + first: { + type: "number" + }, + second: { + type: "number" + }, + result: { + type: "number" + }, + workflowScheduleDate: { + type: "Date" + }, + scheduledTask: { + type: "Task" + } + } }) export class HandleNetworkConfigurationBackup { - @DecisionItem({ target: "waitForEvent", else: "prepareItems" }) - public decisionElement(waitingTimer: Date) { - return waitingTimer !== null; - } - - @Item({ target: "callOtherWf" }) - public prepareItems(@In @Out first: number, @In @Out second: number) { - first = 1; - second = 2; - } - - @WorkflowItem({ - target: "print", - linkedItem: "9e4503db-cbaa-435a-9fad-144409c08df0" - }) - public callOtherWf(@In first: number, @In second: number, @Out result: number) { - } - - @Item({ target: "end" }) - public print(@In result: number) { - System.log("Result: " + result); - } - - @Item({ target: "decisionElement", exception: "" }) - public execute(@Out @In waitingTimer: Date, @Out @In counter: number): void { - if (!counter) { - counter = 0; - } - - counter++; - - if (counter < 2) { - const tt = Date.now() + 5 * 1000; - waitingTimer = new Date(tt); - } else { - waitingTimer = null; - } - - System.log("Counter: " + counter); - System.log("Waiting Timer: " + waitingTimer); - } - - @Item({ target: "execute", exception: "" }) - @RootItem() - public start() { - System.log("Starting workflow"); - } - - @WaitingTimerItem({ target: "execute" }) - public waitForEvent(@In waitingTimer: Date) { - } + @DecisionItem({ target: "waitForEvent", else: "prepareItems" }) + public decisionElement(waitingTimer: Date) { + return waitingTimer !== null; + } + + @Item({ target: "callOtherWf" }) + public prepareItems(@In @Out first: number, @In @Out second: number, @In @Out workflowScheduleDate: Date) { + first = 1; + second = 2; + workflowScheduleDate = System.getDate("1 minute from now", undefined); + } + + @WorkflowItem({ + target: "print", + linkedItem: "9e4503db-cbaa-435a-9fad-144409c08df0" + }) + public callOtherWf(@In first: number, @In second: number, @Out result: number) { + } + + + @Item({ target: "scheduleOtherWf" }) + public print(@In result: number) { + System.log("Result: " + result); + } + + @ScheduledWorkflowItem({ + target: "printScheduledDetails", + linkedItem: "9e4503db-cbaa-435a-9fad-144409c08df0" + }) + public scheduleOtherWf(@In first: number, @In second: number, @In workflowScheduleDate: Date, @Out scheduledTask: Task) { + } + + @Item({ target: "end" }) + public printScheduledDetails(@In scheduledTask: Task) { + System.log(`Scheduled task: ${scheduledTask.id}, [${scheduledTask.state}]`); + } + + @Item({ target: "decisionElement", exception: "" }) + public execute(@Out @In waitingTimer: Date, @Out @In counter: number): void { + if (!counter) { + counter = 0; + } + + counter++; + + if (counter < 2) { + const tt = Date.now() + 5 * 1000; + waitingTimer = new Date(tt); + } else { + waitingTimer = null; + } + + System.log("Counter: " + counter); + System.log("Waiting Timer: " + waitingTimer); + } + + @Item({ target: "execute", exception: "" }) + @RootItem() + public start() { + System.log("Starting workflow"); + } + + @WaitingTimerItem({ target: "execute" }) + public waitForEvent(@In waitingTimer: Date) { + } } ``` diff --git a/docs/versions/latest/Release.md b/docs/versions/latest/Release.md index bc2f9cb5..feba88e0 100644 --- a/docs/versions/latest/Release.md +++ b/docs/versions/latest/Release.md @@ -26,7 +26,88 @@ [//]: # (Improvements -> Bugfixes/hotfixes or general improvements) -### *New `WorkflowItem` decorator for Workflows +### *New `ScheduledWorkflowItem` decorator for Workflows* + +The new decorator gives you the ability to specify a canvas item that schedules a Workflow. + +- `@ScheduledWorkflowItem({target: "", linkedItem: "" })` + - `target` - The name of the next in line item. + - `linkedItem` - The ID of the workflow to schedule + +In order to bind inputs and outputs, you do it with the `@In` and `@Out` decorators. This is the same way we do it for other items. + +#### Inputs + +Special input is needed for the ScheduledWorkflowItem. + +- `workflowScheduleDate` - {Date} is required. The name **must** be `workflowScheduleDate`. If this is missing an error is thrown. We don't check if the type is `Date` but Aria Orchestrator will complain. + +#### Outputs + +Special output is needed for the ScheduledWorkflowItem. + +- `scheduledTask` - {Task} is optional. If it's missing nothing will happen, if it's added, then the name **must** be `scheduledTask`. This is the task that is scheduled. + +#### Example + +```ts +import { Workflow, Out, In, Item, RootItem, ScheduledWorkflowItem } from "vrotsc-annotations"; + +@Workflow({ + name: "Scheduled Workflow Test", + path: "VMware/PSCoE", + description: "Scheduling another workflow and binding values correctly", + attributes: { + waitingTimer: { + type: "Date" + }, + counter: { + type: "number" + }, + first: { + type: "number" + }, + second: { + type: "number" + }, + workflowScheduleDate: { + type: "Date" + }, + scheduledTask: { + type: "Task" + } + } +}) +export class HandleNetworkConfigurationBackup { + @ScheduledWorkflowItem({ + target: "printScheduledDetails", + linkedItem: "9e4503db-cbaa-435a-9fad-144409c08df0" + }) + public scheduleOtherWf(@In first: number, @In second: number, @In workflowScheduleDate: Date, @Out scheduledTask: Task) { + } + + @Item({ target: "scheduleOtherWf" }) + public prepareItems(@In @Out first: number, @In @Out second: number, @In @Out workflowScheduleDate: Date) { + first = 1; + second = 2; + workflowScheduleDate = System.getDate("1 minute from now", undefined); + } + + @Item({ target: "end" }) + public printScheduledDetails(@In scheduledTask: Task) { + System.log(`Scheduled task: ${scheduledTask.id}, [${scheduledTask.state}]`); + } + + + @Item({ target: "prepareItems", exception: "" }) + @RootItem() + public start() { + System.log("Starting workflow"); + } +} +``` + +### *New `WorkflowItem` decorator for Workflows* The new Decorator gives you the ability to specify a canvas item that calls a Workflow. From f1465102f70fc1ac7a5a83d6a513a76f7749ad90 Mon Sep 17 00:00:00 2001 From: Stefan Genov Date: Fri, 19 Jul 2024 18:23:39 +0300 Subject: [PATCH 09/13] style: linting errors Signed-off-by: Stefan Genov --- .../typescript/Components/Workflows.md | 180 +++++++++--------- docs/versions/latest/Release.md | 96 +++++----- 2 files changed, 138 insertions(+), 138 deletions(-) diff --git a/docs/versions/latest/Components/Archetypes/typescript/Components/Workflows.md b/docs/versions/latest/Components/Archetypes/typescript/Components/Workflows.md index fa70a044..5868b86b 100644 --- a/docs/versions/latest/Components/Archetypes/typescript/Components/Workflows.md +++ b/docs/versions/latest/Components/Archetypes/typescript/Components/Workflows.md @@ -90,97 +90,97 @@ This is a meta decorator. Add this to whichever function you want to be the entr import { Workflow, Out, In, Item, RootItem, DecisionItem, WaitingTimerItem, WorkflowItem, ScheduledWorkflowItem } from "vrotsc-annotations"; @Workflow({ - name: "Example Waiting Timer", - path: "VMware/PSCoE", - attributes: { - waitingTimer: { - type: "Date" - }, - counter: { - type: "number" - }, - first: { - type: "number" - }, - second: { - type: "number" - }, - result: { - type: "number" - }, - workflowScheduleDate: { - type: "Date" - }, - scheduledTask: { - type: "Task" - } - } + name: "Example Waiting Timer", + path: "VMware/PSCoE", + attributes: { + waitingTimer: { + type: "Date" + }, + counter: { + type: "number" + }, + first: { + type: "number" + }, + second: { + type: "number" + }, + result: { + type: "number" + }, + workflowScheduleDate: { + type: "Date" + }, + scheduledTask: { + type: "Task" + } + } }) export class HandleNetworkConfigurationBackup { - @DecisionItem({ target: "waitForEvent", else: "prepareItems" }) - public decisionElement(waitingTimer: Date) { - return waitingTimer !== null; - } - - @Item({ target: "callOtherWf" }) - public prepareItems(@In @Out first: number, @In @Out second: number, @In @Out workflowScheduleDate: Date) { - first = 1; - second = 2; - workflowScheduleDate = System.getDate("1 minute from now", undefined); - } - - @WorkflowItem({ - target: "print", - linkedItem: "9e4503db-cbaa-435a-9fad-144409c08df0" - }) - public callOtherWf(@In first: number, @In second: number, @Out result: number) { - } - - - @Item({ target: "scheduleOtherWf" }) - public print(@In result: number) { - System.log("Result: " + result); - } - - @ScheduledWorkflowItem({ - target: "printScheduledDetails", - linkedItem: "9e4503db-cbaa-435a-9fad-144409c08df0" - }) - public scheduleOtherWf(@In first: number, @In second: number, @In workflowScheduleDate: Date, @Out scheduledTask: Task) { - } - - @Item({ target: "end" }) - public printScheduledDetails(@In scheduledTask: Task) { - System.log(`Scheduled task: ${scheduledTask.id}, [${scheduledTask.state}]`); - } - - @Item({ target: "decisionElement", exception: "" }) - public execute(@Out @In waitingTimer: Date, @Out @In counter: number): void { - if (!counter) { - counter = 0; - } - - counter++; - - if (counter < 2) { - const tt = Date.now() + 5 * 1000; - waitingTimer = new Date(tt); - } else { - waitingTimer = null; - } - - System.log("Counter: " + counter); - System.log("Waiting Timer: " + waitingTimer); - } - - @Item({ target: "execute", exception: "" }) - @RootItem() - public start() { - System.log("Starting workflow"); - } - - @WaitingTimerItem({ target: "execute" }) - public waitForEvent(@In waitingTimer: Date) { - } + @DecisionItem({ target: "waitForEvent", else: "prepareItems" }) + public decisionElement(waitingTimer: Date) { + return waitingTimer !== null; + } + + @Item({ target: "callOtherWf" }) + public prepareItems(@In @Out first: number, @In @Out second: number, @In @Out workflowScheduleDate: Date) { + first = 1; + second = 2; + workflowScheduleDate = System.getDate("1 minute from now", undefined); + } + + @WorkflowItem({ + target: "print", + linkedItem: "9e4503db-cbaa-435a-9fad-144409c08df0" + }) + public callOtherWf(@In first: number, @In second: number, @Out result: number) { + } + + + @Item({ target: "scheduleOtherWf" }) + public print(@In result: number) { + System.log("Result: " + result); + } + + @ScheduledWorkflowItem({ + target: "printScheduledDetails", + linkedItem: "9e4503db-cbaa-435a-9fad-144409c08df0" + }) + public scheduleOtherWf(@In first: number, @In second: number, @In workflowScheduleDate: Date, @Out scheduledTask: Task) { + } + + @Item({ target: "end" }) + public printScheduledDetails(@In scheduledTask: Task) { + System.log(`Scheduled task: ${scheduledTask.id}, [${scheduledTask.state}]`); + } + + @Item({ target: "decisionElement", exception: "" }) + public execute(@Out @In waitingTimer: Date, @Out @In counter: number): void { + if (!counter) { + counter = 0; + } + + counter++; + + if (counter < 2) { + const tt = Date.now() + 5 * 1000; + waitingTimer = new Date(tt); + } else { + waitingTimer = null; + } + + System.log("Counter: " + counter); + System.log("Waiting Timer: " + waitingTimer); + } + + @Item({ target: "execute", exception: "" }) + @RootItem() + public start() { + System.log("Starting workflow"); + } + + @WaitingTimerItem({ target: "execute" }) + public waitForEvent(@In waitingTimer: Date) { + } } ``` diff --git a/docs/versions/latest/Release.md b/docs/versions/latest/Release.md index feba88e0..340fcfd2 100644 --- a/docs/versions/latest/Release.md +++ b/docs/versions/latest/Release.md @@ -54,56 +54,56 @@ Special output is needed for the ScheduledWorkflowItem. import { Workflow, Out, In, Item, RootItem, ScheduledWorkflowItem } from "vrotsc-annotations"; @Workflow({ - name: "Scheduled Workflow Test", - path: "VMware/PSCoE", - description: "Scheduling another workflow and binding values correctly", - attributes: { - waitingTimer: { - type: "Date" - }, - counter: { - type: "number" - }, - first: { - type: "number" - }, - second: { - type: "number" - }, - workflowScheduleDate: { - type: "Date" - }, - scheduledTask: { - type: "Task" - } - } + name: "Scheduled Workflow Test", + path: "VMware/PSCoE", + description: "Scheduling another workflow and binding values correctly", + attributes: { + waitingTimer: { + type: "Date" + }, + counter: { + type: "number" + }, + first: { + type: "number" + }, + second: { + type: "number" + }, + workflowScheduleDate: { + type: "Date" + }, + scheduledTask: { + type: "Task" + } + } }) export class HandleNetworkConfigurationBackup { - @ScheduledWorkflowItem({ - target: "printScheduledDetails", - linkedItem: "9e4503db-cbaa-435a-9fad-144409c08df0" - }) - public scheduleOtherWf(@In first: number, @In second: number, @In workflowScheduleDate: Date, @Out scheduledTask: Task) { - } - - @Item({ target: "scheduleOtherWf" }) - public prepareItems(@In @Out first: number, @In @Out second: number, @In @Out workflowScheduleDate: Date) { - first = 1; - second = 2; - workflowScheduleDate = System.getDate("1 minute from now", undefined); - } - - @Item({ target: "end" }) - public printScheduledDetails(@In scheduledTask: Task) { - System.log(`Scheduled task: ${scheduledTask.id}, [${scheduledTask.state}]`); - } - - - @Item({ target: "prepareItems", exception: "" }) - @RootItem() - public start() { - System.log("Starting workflow"); - } + @ScheduledWorkflowItem({ + target: "printScheduledDetails", + linkedItem: "9e4503db-cbaa-435a-9fad-144409c08df0" + }) + public scheduleOtherWf(@In first: number, @In second: number, @In workflowScheduleDate: Date, @Out scheduledTask: Task) { + } + + @Item({ target: "scheduleOtherWf" }) + public prepareItems(@In @Out first: number, @In @Out second: number, @In @Out workflowScheduleDate: Date) { + first = 1; + second = 2; + workflowScheduleDate = System.getDate("1 minute from now", undefined); + } + + @Item({ target: "end" }) + public printScheduledDetails(@In scheduledTask: Task) { + System.log(`Scheduled task: ${scheduledTask.id}, [${scheduledTask.state}]`); + } + + + @Item({ target: "prepareItems", exception: "" }) + @RootItem() + public start() { + System.log("Starting workflow"); + } } ``` From 236cb2e3b9a099590c70fc58dcc74cc4e0b2c39a Mon Sep 17 00:00:00 2001 From: Stefan Genov Date: Mon, 22 Jul 2024 17:24:48 +0300 Subject: [PATCH 10/13] fix: Pr fixes Signed-off-by: Stefan Genov --- docs/versions/latest/Release.md | 117 +++++++----------- typescript/vrotsc/src/compiler/decorators.ts | 1 - .../workflow/decorators/helpers/sourceFile.ts | 2 +- .../scheduledWorkflowItemDecoratorStrategy.ts | 18 +++ 4 files changed, 67 insertions(+), 71 deletions(-) diff --git a/docs/versions/latest/Release.md b/docs/versions/latest/Release.md index 9f222c12..40a0c240 100644 --- a/docs/versions/latest/Release.md +++ b/docs/versions/latest/Release.md @@ -165,12 +165,11 @@ Special output is needed for the ScheduledWorkflowItem. #### Example ```ts -import { Workflow, Out, In, Item, RootItem, ScheduledWorkflowItem } from "vrotsc-annotations"; +import { Workflow, Out, In, Item, RootItem, DecisionItem, WaitingTimerItem, WorkflowItem, ScheduledWorkflowItem } from "vrotsc-annotations"; @Workflow({ - name: "Scheduled Workflow Test", + name: "Example Waiting Timer", path: "VMware/PSCoE", - description: "Scheduling another workflow and binding values correctly", attributes: { waitingTimer: { type: "Date" @@ -184,6 +183,9 @@ import { Workflow, Out, In, Item, RootItem, ScheduledWorkflowItem } from "vrotsc second: { type: "number" }, + result: { + type: "number" + }, workflowScheduleDate: { type: "Date" }, @@ -193,93 +195,70 @@ import { Workflow, Out, In, Item, RootItem, ScheduledWorkflowItem } from "vrotsc } }) export class HandleNetworkConfigurationBackup { - @ScheduledWorkflowItem({ - target: "printScheduledDetails", - linkedItem: "9e4503db-cbaa-435a-9fad-144409c08df0" - }) - public scheduleOtherWf(@In first: number, @In second: number, @In workflowScheduleDate: Date, @Out scheduledTask: Task) { + @DecisionItem({ target: "waitForEvent", else: "prepareItems" }) + public decisionElement(waitingTimer: Date) { + return waitingTimer !== null; } - @Item({ target: "scheduleOtherWf" }) + @Item({ target: "callOtherWf" }) public prepareItems(@In @Out first: number, @In @Out second: number, @In @Out workflowScheduleDate: Date) { first = 1; second = 2; workflowScheduleDate = System.getDate("1 minute from now", undefined); } - @Item({ target: "end" }) - public printScheduledDetails(@In scheduledTask: Task) { - System.log(`Scheduled task: ${scheduledTask.id}, [${scheduledTask.state}]`); + @WorkflowItem({ + target: "print", + linkedItem: "9e4503db-cbaa-435a-9fad-144409c08df0" + }) + public callOtherWf(@In first: number, @In second: number, @Out result: number) { } - @Item({ target: "prepareItems", exception: "" }) - @RootItem() - public start() { - System.log("Starting workflow"); -======= -This decorator is used to specify a default error handler. It can be bound either to a workflow item component or workflow end. - -#### Supported Parameters + @Item({ target: "scheduleOtherWf" }) + public print(@In result: number) { + System.log("Result: " + result); + } -- `target` - target item to be attached to the default error handler, could be one of workflow item or workflow end. -- `exceptionVariable` - Exception variable that will hold the exception data when triggered. + @ScheduledWorkflowItem({ + target: "printScheduledDetails", + linkedItem: "9e4503db-cbaa-435a-9fad-144409c08df0" + }) + public scheduleOtherWf(@In first: number, @In second: number, @In workflowScheduleDate: Date, @Out scheduledTask: Task) { + } -In order to bind inputs and outputs, you do it with the `@In` and `@Out` decorators. This is the same way we do it for other items. + @Item({ target: "end" }) + public printScheduledDetails(@In scheduledTask: Task) { + System.log(`Scheduled task: ${scheduledTask.id}, [${scheduledTask.state}]`); + } -Example: + @Item({ target: "decisionElement", exception: "" }) + public execute(@Out @In waitingTimer: Date, @Out @In counter: number): void { + if (!counter) { + counter = 0; + } -```typescript -import { - Workflow, - RootItem, - In, - Out, - Item, - DefaultErrorHandler, - WorkflowEndItem, -} from "vrotsc-annotations"; + counter++; -@Workflow({ - name: "Default Error Handler Custom Item", - path: "VMware/PSCoE", - description: - "Default error handler workflow with error handler redirecting to a workflow item", - attributes: { - errorMessage: { - type: "string", - }, - }, -}) -export class HandleDefaultError { - @RootItem() - public initiateWorkflow() { - System.log("Initiating workflow execution"); - } + if (counter < 2) { + const tt = Date.now() + 5 * 1000; + waitingTimer = new Date(tt); + } else { + waitingTimer = null; + } - @Item({ - target: "workflowEnd", - }) - public processError(@In errorMessage: string) { - System.log( - `Processing error using custom task with message '${errorMessage}'` - ); + System.log("Counter: " + counter); + System.log("Waiting Timer: " + waitingTimer); } - @DefaultErrorHandler({ - exceptionVariable: "errorMessage", - target: "processError", - }) - public defaultErrorHandler(@Out errorMessage: string) { - // NOOP + @Item({ target: "execute", exception: "" }) + @RootItem() + public start() { + System.log("Starting workflow"); } - @WorkflowEndItem({ - endMode: 0, - exceptionVariable: "errorMessage", - }) - public workflowEnd(@Out errorMessage: string) { - System.log(`Terminating workflow with error ${errorMessage}`); + @WaitingTimerItem({ target: "execute" }) + public waitForEvent(@In waitingTimer: Date) { } } ``` diff --git a/typescript/vrotsc/src/compiler/decorators.ts b/typescript/vrotsc/src/compiler/decorators.ts index 362f5678..9597051c 100644 --- a/typescript/vrotsc/src/compiler/decorators.ts +++ b/typescript/vrotsc/src/compiler/decorators.ts @@ -148,7 +148,6 @@ export enum WorkflowItemType { * It can target a workflow item or workflow end and accepts input and output bindings. */ DefaultErrorHandler = "DefaultErrorHandler", - } /////////////////////////////////// Polyglot Decorator /////////////////////////////////// diff --git a/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/helpers/sourceFile.ts b/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/helpers/sourceFile.ts index d3c8d2c6..3acd5c69 100644 --- a/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/helpers/sourceFile.ts +++ b/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/helpers/sourceFile.ts @@ -18,7 +18,7 @@ import { createWorkflowItemPrologueStatements } from "../../../../codeTransforme import { WorkflowItemDescriptor } from "../../../../../decorators"; export interface SourceFilePrinter { - printSourceFile(methodNode: MethodDeclaration, sourceFile: SourceFile, itemInfo?: WorkflowItemDescriptor): string; + printSourceFile(methodNode: MethodDeclaration, sourceFile: SourceFile, itemInfo: WorkflowItemDescriptor): string; } /** diff --git a/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/scheduledWorkflowItemDecoratorStrategy.ts b/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/scheduledWorkflowItemDecoratorStrategy.ts index 1ce28b9d..3e3002b3 100644 --- a/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/scheduledWorkflowItemDecoratorStrategy.ts +++ b/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/scheduledWorkflowItemDecoratorStrategy.ts @@ -55,14 +55,32 @@ scheduledTask = workflowToLaunch.schedule(workflowParameters, workflowScheduleDa export default class ScheduledWorkflowItemDecoratorStrategy implements CanvasItemDecoratorStrategy { constructor(private readonly sourceFilePrinter: SourceFilePrinter = new ScheduledWorkflowItemSourceFilePrinter()) { } + /** + * @returns The type of canvas item + */ getCanvasType(): string { return "task"; } + /** + * @returns The type of decorator + */ getDecoratorType(): WorkflowItemType { return WorkflowItemType.ScheduledWorkflow; } + /** + * Registers the item arguments + * + * - `target` is the name of the item to call after the item is executed + * - `exception` is the exception to throw if the item fails + * - `linkedItem` is the id of the workflow to schedule + * + * @param itemInfo The item to register + * @param decoratorNode The decorator node + * @returns void + * @throws Error if an unsupported attribute is found + */ registerItemArguments(itemInfo: WorkflowItemDescriptor, decoratorNode: Decorator): void { getDecoratorProps(decoratorNode).forEach((propTuple) => { const [propName, propValue] = propTuple; From 50cc0ac982731830391b3f251abb171a1a80078b Mon Sep 17 00:00:00 2001 From: Stefan Genov Date: Mon, 22 Jul 2024 17:25:19 +0300 Subject: [PATCH 11/13] fix: Remove unused case for `exception` Signed-off-by: Stefan Genov --- .../decorators/scheduledWorkflowItemDecoratorStrategy.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/scheduledWorkflowItemDecoratorStrategy.ts b/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/scheduledWorkflowItemDecoratorStrategy.ts index 3e3002b3..f8babf6c 100644 --- a/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/scheduledWorkflowItemDecoratorStrategy.ts +++ b/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/scheduledWorkflowItemDecoratorStrategy.ts @@ -89,10 +89,6 @@ export default class ScheduledWorkflowItemDecoratorStrategy implements CanvasIte itemInfo.target = propValue; break; - case "exception": - itemInfo.canvasItemPolymorphicBag.exception = propValue; - break; - case "linkedItem": itemInfo.canvasItemPolymorphicBag.linkedItem = propValue; break; From 8fc1d4f2a264c9caf92659a54dd9a40f3a1bae19 Mon Sep 17 00:00:00 2001 From: Alexander Kantchev Date: Tue, 23 Jul 2024 10:42:09 +0300 Subject: [PATCH 12/13] [Task 337] fix: Add itemInfo parameter to decorators. Signed-off-by: Alexander Kantchev --- .../workflow/decorators/defaultErrorHandlerDecoratorStrategy.ts | 2 +- .../workflow/decorators/endItemDecoratorStrategy.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/defaultErrorHandlerDecoratorStrategy.ts b/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/defaultErrorHandlerDecoratorStrategy.ts index 1115b2cb..81a36845 100644 --- a/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/defaultErrorHandlerDecoratorStrategy.ts +++ b/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/defaultErrorHandlerDecoratorStrategy.ts @@ -90,7 +90,7 @@ export default class DefaultErrorHandlerDecoratorStrategy implements CanvasItemD /** * There is no need to print the source file for the default error handler. */ - public printSourceFile(methodNode: MethodDeclaration, sourceFile: SourceFile): string { + public printSourceFile(methodNode: MethodDeclaration, sourceFile: SourceFile, itemInfo: WorkflowItemDescriptor): string { return ""; } diff --git a/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/endItemDecoratorStrategy.ts b/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/endItemDecoratorStrategy.ts index 040de72f..f01124c6 100644 --- a/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/endItemDecoratorStrategy.ts +++ b/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/endItemDecoratorStrategy.ts @@ -93,7 +93,7 @@ export default class EndItemDecoratorStrategy implements CanvasItemDecoratorStra /** * There is no need to print the source file for the workflow item. */ - printSourceFile(methodNode: MethodDeclaration, sourceFile: SourceFile): string { + printSourceFile(methodNode: MethodDeclaration, sourceFile: SourceFile, itemInfo: WorkflowItemDescriptor): string { return ""; } From 0b383c4ee99e80e2c721ca5467aad3b3aab39085 Mon Sep 17 00:00:00 2001 From: Alexander Kantchev Date: Tue, 23 Jul 2024 10:48:32 +0300 Subject: [PATCH 13/13] [Task 337] fix: Remove unused imports. Signed-off-by: Alexander Kantchev --- .../workflow/decorators/decisionItemDecoratorStrategy.ts | 6 +++--- .../decorators/defaultErrorHandlerDecoratorStrategy.ts | 1 - .../workflow/decorators/itemDecoratorStrategy.ts | 6 +++--- .../decorators/scheduledWorkflowItemDecoratorStrategy.ts | 4 ++-- .../decorators/waitingTimerItemDecoratorStrategy.ts | 5 ++--- .../workflow/decorators/workflowItemDecoratorStrategy.ts | 4 ++-- 6 files changed, 12 insertions(+), 14 deletions(-) diff --git a/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/decisionItemDecoratorStrategy.ts b/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/decisionItemDecoratorStrategy.ts index 0dd9beb8..2dd3a5e5 100644 --- a/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/decisionItemDecoratorStrategy.ts +++ b/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/decisionItemDecoratorStrategy.ts @@ -13,13 +13,13 @@ * #L% */ import { Decorator, MethodDeclaration, SourceFile } from "typescript"; +import { StringBuilderClass } from "../../../../../utilities/stringBuilder"; import { CanvasItemPolymorphicBagForDecision, WorkflowItemDescriptor, WorkflowItemType } from "../../../../decorators"; import { getDecoratorProps } from "../../../helpers/node"; -import CanvasItemDecoratorStrategy from "./canvasItemDecoratorStrategy"; -import { SourceFilePrinter, WrapperSourceFilePrinter } from "./helpers/sourceFile"; -import { StringBuilderClass } from "../../../../../utilities/stringBuilder"; import { findTargetItem } from "../helpers/findTargetItem"; +import CanvasItemDecoratorStrategy from "./canvasItemDecoratorStrategy"; import { InputOutputBindings, buildItemParameterBindings } from "./helpers/presentation"; +import { SourceFilePrinter, WrapperSourceFilePrinter } from "./helpers/sourceFile"; /** * Responsible for printing out decision items diff --git a/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/defaultErrorHandlerDecoratorStrategy.ts b/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/defaultErrorHandlerDecoratorStrategy.ts index 81a36845..215762bd 100644 --- a/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/defaultErrorHandlerDecoratorStrategy.ts +++ b/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/defaultErrorHandlerDecoratorStrategy.ts @@ -18,7 +18,6 @@ import { WorkflowItemDescriptor, WorkflowItemType } from "../../../../decorators import { getDecoratorProps } from "../../../helpers/node"; import { findTargetItem } from "../helpers/findTargetItem"; import CanvasItemDecoratorStrategy from "./canvasItemDecoratorStrategy"; -import { buildItemParameterBindings, InputOutputBindings } from "./helpers/presentation"; // UI positioning constants in the output XML file. const xBasePosition = 180; diff --git a/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/itemDecoratorStrategy.ts b/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/itemDecoratorStrategy.ts index 032083df..74794a5f 100644 --- a/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/itemDecoratorStrategy.ts +++ b/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/itemDecoratorStrategy.ts @@ -13,13 +13,13 @@ * #L% */ import { Decorator, MethodDeclaration, SourceFile } from "typescript"; +import { StringBuilderClass } from "../../../../../utilities/stringBuilder"; import { WorkflowItemDescriptor, WorkflowItemType } from "../../../../decorators"; import { getDecoratorProps } from "../../../helpers/node"; +import { findTargetItem } from "../helpers/findTargetItem"; import CanvasItemDecoratorStrategy from "./canvasItemDecoratorStrategy"; -import { DefaultSourceFilePrinter, SourceFilePrinter } from "./helpers/sourceFile"; import { InputOutputBindings, buildItemParameterBindings } from "./helpers/presentation"; -import { findTargetItem } from "../helpers/findTargetItem"; -import { StringBuilderClass } from "../../../../../utilities/stringBuilder"; +import { DefaultSourceFilePrinter, SourceFilePrinter } from "./helpers/sourceFile"; export default class ItemDecoratorStrategy implements CanvasItemDecoratorStrategy { constructor(private readonly sourceFilePrinter: SourceFilePrinter = new DefaultSourceFilePrinter()) { } diff --git a/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/scheduledWorkflowItemDecoratorStrategy.ts b/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/scheduledWorkflowItemDecoratorStrategy.ts index f8babf6c..4afe08bf 100644 --- a/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/scheduledWorkflowItemDecoratorStrategy.ts +++ b/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/scheduledWorkflowItemDecoratorStrategy.ts @@ -13,12 +13,12 @@ * #L% */ import { Decorator, MethodDeclaration, SourceFile } from "typescript"; +import { StringBuilderClass } from "../../../../../utilities/stringBuilder"; import { WorkflowItemDescriptor, WorkflowItemType } from "../../../../decorators"; import { getDecoratorProps } from "../../../helpers/node"; +import { findTargetItem } from "../helpers/findTargetItem"; import CanvasItemDecoratorStrategy from "./canvasItemDecoratorStrategy"; import { InputOutputBindings, buildItemParameterBindings } from "./helpers/presentation"; -import { findTargetItem } from "../helpers/findTargetItem"; -import { StringBuilderClass } from "../../../../../utilities/stringBuilder"; import { ScheduledWorkflowItemSourceFilePrinter, SourceFilePrinter } from "./helpers/sourceFile"; /** diff --git a/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/waitingTimerItemDecoratorStrategy.ts b/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/waitingTimerItemDecoratorStrategy.ts index 69eb9d6e..b9d75c5c 100644 --- a/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/waitingTimerItemDecoratorStrategy.ts +++ b/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/waitingTimerItemDecoratorStrategy.ts @@ -13,12 +13,11 @@ * #L% */ import { Decorator, MethodDeclaration, SourceFile } from "typescript"; +import { StringBuilderClass } from "../../../../../utilities/stringBuilder"; import { WorkflowItemDescriptor, WorkflowItemType } from "../../../../decorators"; import { getDecoratorProps } from "../../../helpers/node"; -import CanvasItemDecoratorStrategy from "./canvasItemDecoratorStrategy"; -import { DefaultSourceFilePrinter, SourceFilePrinter } from "./helpers/sourceFile"; -import { StringBuilderClass } from "../../../../../utilities/stringBuilder"; import { findTargetItem } from "../helpers/findTargetItem"; +import CanvasItemDecoratorStrategy from "./canvasItemDecoratorStrategy"; import { InputOutputBindings, buildItemParameterBindings } from "./helpers/presentation"; /** diff --git a/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/workflowItemDecoratorStrategy.ts b/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/workflowItemDecoratorStrategy.ts index de8f936d..f0ec1db8 100644 --- a/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/workflowItemDecoratorStrategy.ts +++ b/typescript/vrotsc/src/compiler/transformer/fileTransformers/workflow/decorators/workflowItemDecoratorStrategy.ts @@ -13,12 +13,12 @@ * #L% */ import { Decorator, MethodDeclaration, SourceFile } from "typescript"; +import { StringBuilderClass } from "../../../../../utilities/stringBuilder"; import { WorkflowItemDescriptor, WorkflowItemType } from "../../../../decorators"; import { getDecoratorProps } from "../../../helpers/node"; +import { findTargetItem } from "../helpers/findTargetItem"; import CanvasItemDecoratorStrategy from "./canvasItemDecoratorStrategy"; import { InputOutputBindings, buildItemParameterBindings } from "./helpers/presentation"; -import { findTargetItem } from "../helpers/findTargetItem"; -import { StringBuilderClass } from "../../../../../utilities/stringBuilder"; /** *