Skip to content

update spec main branch #147

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

Merged
merged 2 commits into from
Nov 28, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ import { workflowBuilder, injectstateBuilder, Specification } from '@severlesswo

const workflow: Specification.Workflow = workflowBuilder()
.id("helloworld")
.specVersion("0.7")
.specVersion("0.8")
.version("1.0")
.name("Hello World Workflow")
.description("Inject Hello World")
Expand All @@ -72,7 +72,7 @@ import { Specification, Workflow } from '@severlessworkflow/sdk-typescript';

const source = `id: helloworld
version: '1.0'
specVerion: '0.7'
specVerion: '0.8'
name: Hello World Workflow
description: Inject Hello World
start: Hello State
Expand All @@ -97,7 +97,7 @@ import { workflowBuilder, injectstateBuilder, Specification } from '@severlesswo
const workflow: Specification.Workflow = workflowBuilder()
.id("helloworld")
.version("1.0")
.specVersion("0.7")
.specVersion("0.8")
.name("Hello World Workflow")
.description("Inject Hello World")
.start("Hello State")
Expand Down Expand Up @@ -143,6 +143,7 @@ import { WorkflowValidator, Specification } from '@severlessworkflow/sdk-typescr
const workflow: Specification.Workflow = {
id: 'helloworld',
version: '1.0',
specVersion: '0.8',
name: 'Hello World Workflow',
description: 'Inject Hello World',
start: 'Hello State',
Expand Down
4 changes: 2 additions & 2 deletions examples/browser/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</head>
<body>
<!--
Run http-server from the project root then navigate to http://localhost:8080/examples/browser/index.html
Run http-server from the project root then navigate to http://localhost:8080/examples/browser/mermaid.html
-->
<div id="output"></div>
<script src="../../dist/umd/index.umd.js"></script>
Expand All @@ -19,7 +19,7 @@
const workflow = workflowBuilder()
.id("helloworld")
.version("1.0")
.specVersion("0.7")
.specVersion("0.8")
.name("Hello World Workflow")
.description("Inject Hello World")
.start("Hello State")
Expand Down
2 changes: 1 addition & 1 deletion examples/browser/mermaid.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
const workflow = workflowBuilder()
.id("helloworld")
.version("1.0")
.specVersion("0.7")
.specVersion("0.8")
.name("Hello World Workflow")
.description("Inject Hello World")
.start("Hello State")
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@severlessworkflow/sdk-typescript",
"version": "3.0.0",
"schemaVersion": "0.7",
"schemaVersion": "0.8",
"description": "Typescript SDK for Serverless Workflow Specification",
"main": "umd/index.umd.min.js",
"browser": "umd/index.umd.min.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,24 @@ import { validate } from '../utils';

/**
* The internal function used by the builder proxy to validate and return its underlying object
* @param {Specification.Databasedswitch} data The underlying object
* @returns {Specification.Databasedswitch} The validated underlying object
* @param {Specification.Databasedswitchstate} data The underlying object
* @returns {Specification.Databasedswitchstate} The validated underlying object
*/
function databasedswitchBuildingFn(data: Specification.Databasedswitch): () => Specification.Databasedswitch {
function databasedswitchstateBuildingFn(
data: Specification.Databasedswitchstate
): () => Specification.Databasedswitchstate {
return () => {
const model = new Specification.Databasedswitch(data);
const model = new Specification.Databasedswitchstate(data);

validate('Databasedswitch', model);
validate('Databasedswitchstate', model);
return model;
};
}

/**
* A factory to create a builder proxy for the type `Specification.Databasedswitch`
* @returns {Specification.Databasedswitch} A builder for `Specification.Databasedswitch`
* A factory to create a builder proxy for the type `Specification.Databasedswitchstate`
* @returns {Specification.Databasedswitchstate} A builder for `Specification.Databasedswitchstate`
*/
export function databasedswitchBuilder(): Builder<Specification.Databasedswitch> {
return builder<Specification.Databasedswitch>(databasedswitchBuildingFn);
export function databasedswitchstateBuilder(): Builder<Specification.Databasedswitchstate> {
return builder<Specification.Databasedswitchstate>(databasedswitchstateBuildingFn);
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,24 @@ import { validate } from '../utils';

/**
* The internal function used by the builder proxy to validate and return its underlying object
* @param {Specification.Eventbasedswitch} data The underlying object
* @returns {Specification.Eventbasedswitch} The validated underlying object
* @param {Specification.Eventbasedswitchstate} data The underlying object
* @returns {Specification.Eventbasedswitchstate} The validated underlying object
*/
function eventbasedswitchBuildingFn(data: Specification.Eventbasedswitch): () => Specification.Eventbasedswitch {
function eventbasedswitchstateBuildingFn(
data: Specification.Eventbasedswitchstate
): () => Specification.Eventbasedswitchstate {
return () => {
const model = new Specification.Eventbasedswitch(data);
const model = new Specification.Eventbasedswitchstate(data);

validate('Eventbasedswitch', model);
validate('Eventbasedswitchstate', model);
return model;
};
}

/**
* A factory to create a builder proxy for the type `Specification.Eventbasedswitch`
* @returns {Specification.Eventbasedswitch} A builder for `Specification.Eventbasedswitch`
* A factory to create a builder proxy for the type `Specification.Eventbasedswitchstate`
* @returns {Specification.Eventbasedswitchstate} A builder for `Specification.Eventbasedswitchstate`
*/
export function eventbasedswitchBuilder(): Builder<Specification.Eventbasedswitch> {
return builder<Specification.Eventbasedswitch>(eventbasedswitchBuildingFn);
export function eventbasedswitchstateBuilder(): Builder<Specification.Eventbasedswitchstate> {
return builder<Specification.Eventbasedswitchstate>(eventbasedswitchstateBuildingFn);
}
4 changes: 2 additions & 2 deletions src/lib/builders/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ export * from './callbackstate-builder';
export * from './continueasdef-builder';
export * from './correlation-def-builder';
export * from './crondef-builder';
export * from './databasedswitch-builder';
export * from './databasedswitchstate-builder';
export * from './defaultconditiondef-builder';
export * from './end-builder';
export * from './enddatacondition-builder';
export * from './enddeventcondition-builder';
export * from './error-builder';
export * from './errordef-builder';
export * from './eventbasedswitch-builder';
export * from './eventbasedswitchstate-builder';
export * from './eventdatafilter-builder';
export * from './eventdef-builder';
export * from './eventref-builder';
Expand Down
13 changes: 13 additions & 0 deletions src/lib/definitions/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import { Actiondatafilter } from './actiondatafilter';
import { Eventref } from './eventref';
import { Functionref } from './functionref';
import {
normalizeEventRef,
normalizeFunctionRef,
normalizeSubFlowRefIfObject,
overwriteActionDataFilter,
overwriteEventRef,
Expand All @@ -38,6 +40,10 @@ export class Action {
overwriteActionDataFilter(this);
}

/**
* Unique action identifier
*/
id?: string;
/**
* Unique action definition name
*/
Expand All @@ -59,14 +65,21 @@ export class Action {
*/
retryableErrors?: [string, ...string[]];
actionDataFilter?: Actiondatafilter;
/**
* Expression, if defined, must evaluate to true for this action to be performed. If false, action is disregarded
*/
condition?: string;

/**
* Normalize the value of each property by recursively deleting properties whose value is equal to its default value. Does not modify the object state.
* @returns {Specification.Action} without deleted properties.
*/
normalize = (): Action => {
const clone = new Action(this);

normalizeSubFlowRefIfObject(clone);
normalizeEventRef(clone);
normalizeFunctionRef(clone);

return clone;
};
Expand Down
4 changes: 4 additions & 0 deletions src/lib/definitions/actiondatafilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ export class Actiondatafilter {
* Workflow expression that selects state data that the state action can use
*/
fromStateData?: string;
/**
* If set to false, action data results are not added/merged to state data. In this case 'results' and 'toStateData' should be ignored. Default is true.
*/
useResults?: boolean;
/**
* Workflow expression that filters the actions data results
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import {
import { Datacondition } from './types';
import { StateExecTimeout } from './stateExecTimeout';

export class Databasedswitch {
export class Databasedswitchstate {
constructor(model: any) {
const defaultModel = { type: 'switch', usedForCompensation: false };
Object.assign(this, defaultModel, model);
Expand Down Expand Up @@ -79,7 +79,7 @@ export class Databasedswitch {
/**
* Default transition of the workflow if there is no matching data conditions. Can include a transition or end definition
*/
defaultCondition?: /* DefaultCondition definition. Can be either a transition or end definition */ Defaultconditiondef;
defaultCondition: /* DefaultCondition definition. Can be either a transition or end definition */ Defaultconditiondef;
/**
* Unique Name of a workflow state which is responsible for compensation of this state
*/
Expand All @@ -94,8 +94,8 @@ export class Databasedswitch {
* Normalize the value of each property by recursively deleting properties whose value is equal to its default value. Does not modify the object state.
* @returns {Specification.Databasedswitch} without deleted properties.
*/
normalize = (): Databasedswitch => {
const clone = new Databasedswitch(this);
normalize = (): Databasedswitchstate => {
const clone = new Databasedswitchstate(this);

normalizeDataConditions(clone);
normalizeOnErrors(clone);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import {
import { Eventcondition, EventTimeout } from './types';
import { StateExecTimeout } from './stateExecTimeout';

export class Eventbasedswitch {
export class Eventbasedswitchstate {
constructor(model: any) {
const defaultModel = {
type: 'switch',
Expand Down Expand Up @@ -83,7 +83,7 @@ export class Eventbasedswitch {
/**
* Default transition of the workflow if there is no matching data conditions. Can include a transition or end definition
*/
defaultCondition?: /* DefaultCondition definition. Can be either a transition or end definition */ Defaultconditiondef;
defaultCondition: /* DefaultCondition definition. Can be either a transition or end definition */ Defaultconditiondef;
/**
* Unique Name of a workflow state which is responsible for compensation of this state
*/
Expand All @@ -98,8 +98,8 @@ export class Eventbasedswitch {
* Normalize the value of each property by recursively deleting properties whose value is equal to its default value. Does not modify the object state.
* @returns {Specification.Eventbasedswitch} without deleted properties.
*/
normalize = (): Eventbasedswitch => {
const clone = new Eventbasedswitch(this);
normalize = (): Eventbasedswitchstate => {
const clone = new Eventbasedswitchstate(this);

normalizeEventConditions(clone);
normalizeOnErrors(clone);
Expand Down
6 changes: 5 additions & 1 deletion src/lib/definitions/eventdatafilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ export class Eventdatafilter {
}

/**
* Workflow expression that filters the received event/payload (default: '${ . }')
* If set to false, event payload is not added/merged to state data. In this case 'data' and 'toStateData' should be ignored. Default is true.
*/
useData?: boolean;
/**
* Workflow expression that filters the received event payload (default: '${ . }')
*/
data?: string;
/**
Expand Down
22 changes: 21 additions & 1 deletion src/lib/definitions/eventref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import { overwritePropertyAsPlainType } from './utils';
import { normalizeInvoke, overwritePropertyAsPlainType } from './utils';

export class Eventref {
constructor(model: any) {
Expand All @@ -31,6 +31,10 @@ export class Eventref {
* Reference to the unique name of a 'consumed' event definition
*/
resultEventRef: string;
/**
* Maximum amount of time (ISO 8601 format) to wait for the result event. If not defined it should default to the actionExecutionTimeout
*/
resultEventTimeout?: string;
/**
* If string type, an expression which selects parts of the states data output to become the data (payload) of the event referenced by 'triggerEventRef'. If object type, a custom object to become the data (payload) of the event referenced by 'triggerEventRef'.
*/
Expand All @@ -45,4 +49,20 @@ export class Eventref {
contextAttributes?: {
[name: string]: string;
};
/**
* Specifies if the function should be invoked sync or async. Default is sync.
*/
invoke?: 'sync' | 'async';

/**
* Normalize the value of each property by recursively deleting properties whose value is equal to its default value. Does not modify the object state.
* @returns {Specification.Eventref} without deleted properties.
*/
normalize = (): Eventref => {
const clone = new Eventref(this);

normalizeInvoke(clone);

return clone;
};
}
18 changes: 17 additions & 1 deletion src/lib/definitions/functionref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import { overwritePropertyAsPlainType } from './utils';
import { normalizeInvoke, overwritePropertyAsPlainType } from './utils';

export class Functionref {
constructor(model: any) {
Expand All @@ -36,4 +36,20 @@ export class Functionref {
* Only used if function type is 'graphql'. A string containing a valid GraphQL selection set
*/
selectionSet?: string;
/**
* Specifies if the function should be invoked sync or async
*/
invoke?: 'sync' | 'async';

/**
* Normalize the value of each property by recursively deleting properties whose value is equal to its default value. Does not modify the object state.
* @returns {Specification.Functionref} without deleted properties.
*/
normalize = (): Functionref => {
const clone = new Functionref(this);

normalizeInvoke(clone);

return clone;
};
}
4 changes: 2 additions & 2 deletions src/lib/definitions/specification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ export * from './callbackstate';
export * from './continueasdef';
export * from './correlationDef';
export * from './crondef';
export * from './databasedswitch';
export * from './databasedswitchstate';
export * from './defaultconditiondef';
export * from './end';
export * from './enddatacondition';
export * from './enddeventcondition';
export * from './error';
export * from './errordef';
export * from './eventbasedswitch';
export * from './eventbasedswitchstate';
export * from './eventdatafilter';
export * from './eventdef';
export * from './eventref';
Expand Down
Loading