Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[vrotsc, vrotsc-annotations] (#339) Add Workflow canvas Default Error Handler item #346

Merged
merged 7 commits into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ How to use Aria Orchestrator Workflows and available decorators.
- [`@WaitingTimerItem`](#waitingtimeritem)
- [`@DecisionItem`](#decisionitem)
- [`@RootItem`](#rootitem)
- [`@DefaultErrorHandler`](#defaulterrorhandler)
3. [Example Workflow](#example-workflow)

### Workflow Decorator
Expand All @@ -20,6 +21,17 @@ Not implemented yet.

### Available Method Decorators

#### `@DefaultErrorHandler`

The decorator is used to specify a default error handler within a workflow.

##### Supported Parameters

- `target` - **Not implemented yet**
- `exception` - Exception variable that will hold the exception data when triggered.

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`

This decorator is used to specify a scriptable task.
Expand Down Expand Up @@ -64,28 +76,38 @@ 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,
DefaultErrorHandler,
} from "vrotsc-annotations";

@Workflow({
name: "Example Waiting Timer",
path: "VMware/PSCoE",
attributes: {
waitingTimer: {
type: "Date"
type: "Date",
},
counter: {
type: "number"
type: "number",
},
first: {
type: "number"
type: "number",
},
second: {
type: "number"
type: "number",
},
result: {
type: "number"
}
}
type: "number",
},
},
})
export class HandleNetworkConfigurationBackup {
@DecisionItem({ target: "waitForEvent", else: "prepareItems" })
Expand All @@ -101,10 +123,13 @@ export class HandleNetworkConfigurationBackup {

@WorkflowItem({
target: "print",
linkedItem: "9e4503db-cbaa-435a-9fad-144409c08df0"
linkedItem: "9e4503db-cbaa-435a-9fad-144409c08df0",
})
public callOtherWf(@In first: number, @In second: number, @Out result: number) {
}
public callOtherWf(
@In first: number,
@In second: number,
@Out result: number
) {}

@Item({ target: "end" })
public print(@In result: number) {
Expand All @@ -118,7 +143,6 @@ export class HandleNetworkConfigurationBackup {
}

counter++;

if (counter < 2) {
const tt = Date.now() + 5 * 1000;
waitingTimer = new Date(tt);
Expand All @@ -138,6 +162,14 @@ export class HandleNetworkConfigurationBackup {

@WaitingTimerItem({ target: "execute" })
public waitForEvent(@In waitingTimer: Date) {
// NOOP
}

@DefaultErrorHandler({
exception: "errorMessage",
})
public defaultErrorHandler(@Out errorMessage: string) {
// NOOP
}
}
```
143 changes: 100 additions & 43 deletions docs/versions/latest/Release.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,78 @@
[//]: # (VERSION_PLACEHOLDER DO NOT DELETE)
[//]: # (Used when working on a new release. Placed together with the Version.md)
[//]: # (Nothing here is optional. If a step must not be performed, it must be said so)
[//]: # (Do not fill the version, it will be done automatically)
[//]: # (Quick Intro to what is the focus of this release)
[//]: # "VERSION_PLACEHOLDER DO NOT DELETE"
[//]: # "Used when working on a new release. Placed together with the Version.md"
[//]: # "Nothing here is optional. If a step must not be performed, it must be said so"
[//]: # "Do not fill the version, it will be done automatically"
[//]: # "Quick Intro to what is the focus of this release"

## Breaking Changes

[//]: # (### *Breaking Change*)
[//]: # (Describe the breaking change AND explain how to resolve it)
[//]: # (You can utilize internal links /e.g. link to the upgrade procedure, link to the improvement|deprecation that introduced this/)
[//]: # "### *Breaking Change*"
[//]: # "Describe the breaking change AND explain how to resolve it"
[//]: # "You can utilize internal links /e.g. link to the upgrade procedure, link to the improvement|deprecation that introduced this/"

## Deprecations

[//]: # (### *Deprecation*)
[//]: # (Explain what is deprecated and suggest alternatives)

[//]: # (Features -> New Functionality)
[//]: # "### *Deprecation*"
[//]: # "Explain what is deprecated and suggest alternatives"
[//]: # "Features -> New Functionality"

## Features

[//]: # (### *Feature Name*)
[//]: # (Describe the feature)
[//]: # (Optional But higlhy recommended Specify *NONE* if missing)
[//]: # (#### Relevant Documentation:)
[//]: # "### *Feature Name*"
[//]: # "Describe the feature"
[//]: # "Optional But highly recommended Specify *NONE* if missing"
[//]: # "#### Relevant Documentation:"
[//]: # "Improvements -> Bugfixes/hotfixes or general improvements"

### New `DefaultErrorHandler` decorator for Workflows

This decorator is used to specify a default error handler. Note that the default error handler will be generated
with its own end workflow item as it is required by the component.

#### Supported Parameters

- `target` - **Not implemented yet**
- `exception` - if set the variable will be bound to the error handler and its own end workflow component.
If set the end workflow component bound to the error handler will have exit code 1, otherwise the exit code will be 0.

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.

Example:

```typescript
import {
Workflow,
Out,
RootItem,
DefaultErrorHandler,
} from "vrotsc-annotations";

@Workflow({
name: "Default Error Handler Happy",
path: "VMware/PSCoE",
description: "Default error handler workflow",
attributes: {
errorMessage: {
type: "string",
},
},
})
export class HandleDefaultError {
@RootItem()
public initiateWorkflow() {
// NOOP
}

[//]: # (Improvements -> Bugfixes/hotfixes or general improvements)
@DefaultErrorHandler({
exception: "errorMessage",
})
public defaultErrorHandler(@Out errorMessage: string) {
// NOOP
}
}
```

### *New `WorkflowItem` decorator for Workflows
### New `WorkflowItem` decorator for Workflows

The new Decorator gives you the ability to specify a canvas item that calls a Workflow.

Expand All @@ -39,28 +85,37 @@ In order to bind inputs and outputs, you do it with the `@In` and `@Out` decorat
Example:

```typescript
import { Workflow, Out, In, Item, RootItem, DecisionItem, WaitingTimerItem, WorkflowItem } from "vrotsc-annotations";
import {
Workflow,
Out,
In,
Item,
RootItem,
DecisionItem,
WaitingTimerItem,
WorkflowItem,
} from "vrotsc-annotations";

@Workflow({
name: "Example Waiting Timer",
path: "VMware/PSCoE",
attributes: {
waitingTimer: {
type: "Date"
type: "Date",
},
counter: {
type: "number"
type: "number",
},
first: {
type: "number"
type: "number",
},
second: {
type: "number"
type: "number",
},
result: {
type: "number"
}
}
type: "number",
},
},
})
export class HandleNetworkConfigurationBackup {
@DecisionItem({ target: "waitForEvent", else: "prepareItems" })
Expand All @@ -76,10 +131,13 @@ export class HandleNetworkConfigurationBackup {

@WorkflowItem({
target: "print",
linkedItem: "9e4503db-cbaa-435a-9fad-144409c08df0"
linkedItem: "9e4503db-cbaa-435a-9fad-144409c08df0",
})
public callOtherWf(@In first: number, @In second: number, @Out result: number) {
}
public callOtherWf(
@In first: number,
@In second: number,
@Out result: number
) {}

@Item({ target: "end" })
public print(@In result: number) {
Expand Down Expand Up @@ -112,25 +170,24 @@ export class HandleNetworkConfigurationBackup {
}

@WaitingTimerItem({ target: "execute" })
public waitForEvent(@In waitingTimer: Date) {
}
public waitForEvent(@In waitingTimer: Date) {}
}
```

## Improvements

[//]: # (### *Improvement Name* )
[//]: # (Talk ONLY regarding the improvement)
[//]: # (Optional But higlhy recommended)
[//]: # (#### Previous Behavior)
[//]: # (Explain how it used to behave, regarding to the change)
[//]: # (Optional But higlhy recommended)
[//]: # (#### New Behavior)
[//]: # (Explain how it behaves now, regarding to the change)
[//]: # (Optional But higlhy recommended Specify *NONE* if missing)
[//]: # (#### Relevant Documentation:)
[//]: # "### *Improvement Name* "
[//]: # "Talk ONLY regarding the improvement"
[//]: # "Optional But highly recommended"
[//]: # "#### Previous Behavior"
[//]: # "Explain how it used to behave, regarding to the change"
[//]: # "Optional But highly recommended"
[//]: # "#### New Behavior"
[//]: # "Explain how it behaves now, regarding to the change"
[//]: # "Optional But highly recommended Specify *NONE* if missing"
[//]: # "#### Relevant Documentation:"

### *ABX archetype build issue, cannot compile*
### _ABX archetype build issue, cannot compile_

Fixed an issue where the ABX archetype could not compile due to an old version of the `xmlbuilder2` package.

Expand Down Expand Up @@ -174,4 +231,4 @@ The ABX archetype now compiles successfully.

## Upgrade procedure

[//]: # (Explain in details if something needs to be done)
[//]: # "Explain in details if something needs to be done"
2 changes: 2 additions & 0 deletions typescript/vrotsc/e2e/cases/canvas-items/complex.wf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { Workflow, Out, In, Item, RootItem, DecisionItem, WaitingTimerItem } fro
}
})
export class Complex {

@DecisionItem({
target: "waitForEvent",
else: null
Expand Down Expand Up @@ -59,5 +60,6 @@ export class Complex {
target: "execute"
})
public waitForEvent(@In waitingTimer: Date) {
// NOOP
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@ import { Workflow, DecisionItem } from "vrotsc-annotations";
}
})
export class HandleNetworkConfigurationBackup {

@DecisionItem({})
public decisionElement(waitingTimer: Date) {
return waitingTimer !== null;
}

public shouldGoHere() { }
public shouldGoHere() {
// NOOP
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@ import { Workflow, DecisionItem } from "vrotsc-annotations";
}
})
export class HandleNetworkConfigurationBackup {

@DecisionItem({
target: "waitForEvent",
})
public decisionElement(waitingTimer: Date) {
return waitingTimer !== null;
}

public shouldGoHere() { }
public shouldGoHere() {
// NOOP
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { Workflow, DecisionItem } from "vrotsc-annotations";
}
})
export class HandleNetworkConfigurationBackup {

@DecisionItem({
target: "shouldGoHere",
else: "end"
Expand All @@ -20,5 +21,7 @@ export class HandleNetworkConfigurationBackup {
}

// This will point to end too, but no incoming
public shouldGoHere() { }
public shouldGoHere() {
// NOOP
}
}
Loading
Loading