Skip to content

Commit f6dbeb4

Browse files
committed
Created legacy branch for spec v0.9
Signed-off-by: Jean-Baptiste Bianchi <[email protected]>
1 parent af7a343 commit f6dbeb4

39 files changed

+75
-72
lines changed

.eslintrc.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ module.exports = {
1212
],
1313
rules: {
1414
'@typescript-eslint/no-explicit-any': 0,
15-
'@typescript-eslint/no-inferrable-types': 0
15+
'@typescript-eslint/no-inferrable-types': 0,
16+
'@typescript-eslint/ban-types': 0
1617
}
1718
};

README.md

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
> [!CAUTION]
2+
> This is a legacy branch. It is not officially supported by the ServerlessWorkflow organisation anymore but still accepts community contributions.
3+
14
![Node CI](https://github.com/serverlessworkflow/sdk-typescript/workflows/Node%20CI/badge.svg) [![Gitpod ready-to-code](https://img.shields.io/badge/Gitpod-ready--to--code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/serverlessworkflow/sdk-typescript)
25

36
# Serverless Workflow Specification - Typescript SDK
@@ -17,6 +20,7 @@ With the SDK you can:
1720
| [v1.0.0](https://github.com/serverlessworkflow/sdk-typescript/releases/) | [v0.6](https://github.com/serverlessworkflow/specification/tree/0.6.x) |
1821
| [v2.0.0](https://github.com/serverlessworkflow/sdk-typescript/releases/) | [v0.7](https://github.com/serverlessworkflow/specification/tree/0.7.x) |
1922
| [v3.0.0](https://github.com/serverlessworkflow/sdk-typescript/releases/) | [v0.8](https://github.com/serverlessworkflow/specification/tree/0.8.x) |
23+
| [v4.0.0](https://github.com/serverlessworkflow/sdk-typescript/releases/) | [v0.9](https://github.com/serverlessworkflow/specification/tree/0.9.x) |
2024

2125

2226

@@ -39,7 +43,6 @@ npm install && npm run build && npm run test
3943

4044

4145
##### Version >= 4.0.0
42-
Note: Version 4.0.0 has not been released yet.
4346
```sh
4447
npm i @serverlessworkflow/sdk-typescript
4548
```
@@ -59,7 +62,7 @@ import { workflowBuilder, injectstateBuilder, Specification } from '@serverlessw
5962

6063
const workflow: Specification.Workflow = workflowBuilder()
6164
.id("helloworld")
62-
.specVersion("0.8")
65+
.specVersion("0.9")
6366
.version("1.0")
6467
.name("Hello World Workflow")
6568
.description("Inject Hello World")
@@ -107,7 +110,7 @@ import { workflowBuilder, injectstateBuilder, Specification } from '@serverlessw
107110
const workflow: Specification.Workflow = workflowBuilder()
108111
.id("helloworld")
109112
.version("1.0")
110-
.specVersion("0.8")
113+
.specVersion("0.9")
111114
.name("Hello World Workflow")
112115
.description("Inject Hello World")
113116
.start("Hello State")
@@ -162,7 +165,7 @@ import {Workflow} from "./workflow";
162165
const workflow = {
163166
id: 'helloworld',
164167
version: '1.0',
165-
specVersion: '0.3',
168+
specVersion: '0.9',
166169
name: 'Hello World Workflow',
167170
description: 'Inject Hello World',
168171
start: 'Hello State',

examples/browser/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
const workflow = workflowBuilder()
2020
.id("helloworld")
2121
.version("1.0")
22-
.specVersion("0.8")
22+
.specVersion("0.9")
2323
.name("Hello World Workflow")
2424
.description("Inject Hello World")
2525
.start("Hello State")

examples/browser/mermaid.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
const workflow = workflowBuilder()
2222
.id("helloworld")
2323
.version("1.0")
24-
.specVersion("0.8")
24+
.specVersion("0.9")
2525
.name("Hello World Workflow")
2626
.description("Inject Hello World")
2727
.start("Hello State")

package.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"name": "@serverlessworkflow/sdk-typescript",
3-
"version": "4.0.0",
4-
"schemaVersion": "0.8",
2+
"name": "@severlessworkflow/sdk-typescript",
3+
"version": "4.0.0-rc1",
4+
"schemaVersion": "0.9",
55
"description": "Typescript SDK for Serverless Workflow Specification",
66
"main": "umd/index.umd.min.js",
77
"browser": "umd/index.umd.min.js",
@@ -28,7 +28,7 @@
2828
"prebuild": "npx rimraf dist",
2929
"build": "npx rollup -c rollup.config.ts && npx shx mv ./dist/src/lib ./dist/lib && npx shx mv ./dist/src/*d.ts.map ./dist/src/*d.ts ./dist && npx rimraf ./dist/src",
3030
"postbuild": "npx shx cp ./package.json ./README.md ./LICENSE ./dist/",
31-
"verify-publish-directory": "node -e 'if (!process.cwd().endsWith(\"dist\")) { console.error(\"Packaging/Publishing should be done from ./dist/\"); process.exitCode = 1; } process.exit();'",
31+
"verify-publish-directory": "node -e \"if (!process.cwd().endsWith('dist')) { console.error('Packaging/Publishing should be done from ./dist/'); process.exitCode = 1; } process.exit();\"",
3232
"prepack": "npm run verify-publish-directory",
3333
"prepublishOnly": "npm run verify-publish-directory",
3434
"prepublish": "husky install"
@@ -72,7 +72,7 @@
7272
},
7373
"repository": {
7474
"type": "git",
75-
"url": "https://github.com/serverlessworkflow/sdk-typescript.git"
75+
"url": "git+https://github.com/serverlessworkflow/sdk-typescript.git"
7676
},
7777
"author": {
7878
"name": "Serverless Workflow Contributors",

src/lib/diagram/mermaidDiagram.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { MermaidState } from './mermaidState';
1919
export class MermaidDiagram {
2020
constructor(private workflow: Specification.Workflow) {}
2121

22-
sourceCode() {
22+
sourceCode(): string {
2323
const mermaidStateDiagramVersion = 'stateDiagram-v2';
2424
return (
2525
mermaidStateDiagramVersion +

src/lib/diagram/mermaidState.ts

+7-5
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export class MermaidState {
3030
private isFirstState: boolean = false
3131
) {}
3232

33-
sourceCode() {
33+
sourceCode(): string {
3434
const stateDefinition = this.definitions();
3535
const stateTransitions = this.transitions();
3636

@@ -145,7 +145,7 @@ export class MermaidState {
145145
const end = this.state.end as Specification.End;
146146

147147
if (end.produceEvents) {
148-
transitionLabel = 'Produced event = [' + end.produceEvents!.map((pe) => pe.eventRef).join(',') + ']';
148+
transitionLabel = 'Produced event = [' + end.produceEvents.map((pe) => pe.eventRef).join(',') + ']';
149149
}
150150
}
151151

@@ -211,7 +211,7 @@ export class MermaidState {
211211
case 'parallel':
212212
definition = this.parallelStateDetails();
213213
break;
214-
case 'switch':
214+
case 'switch': {
215215
const switchState: any = this.state;
216216
if (switchState.dataConditions) {
217217
definition = this.dataBasedSwitchStateDetails();
@@ -222,6 +222,7 @@ export class MermaidState {
222222
break;
223223
}
224224
throw new Error(`Unexpected switch type; \n state value= ${JSON.stringify(this.state, null, 4)}`);
225+
}
225226
case 'inject':
226227
// NOTHING
227228
break;
@@ -243,12 +244,13 @@ export class MermaidState {
243244
return definition ? definition : undefined;
244245
}
245246

246-
private definitionType() {
247+
private definitionType(): string {
247248
const type = this.state.type;
249+
if (!type) return '';
248250
return this.stateDescription(
249251
this.stateKeyDiagram(this.state.name),
250252
'type',
251-
type!.charAt(0).toUpperCase() + type!.slice(1) + ' State'
253+
type.charAt(0).toUpperCase() + type.slice(1) + ' State'
252254
);
253255
}
254256

src/lib/utils.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { validators } from './validators';
2222
* @param data {object} The data to validate
2323
* @returns {boolean} True if valid, throws if invalid
2424
*/
25-
export const validate = (typeName: string, data: any): boolean => {
25+
export const validate = (typeName: string, data: unknown): boolean => {
2626
const validateFn: ValidateFunction | undefined = validators.get(typeName);
2727

2828
if (!validateFn) {
@@ -44,7 +44,7 @@ export const validate = (typeName: string, data: any): boolean => {
4444
* @param value The data
4545
* @returns {boolean} True if the provided value is an object
4646
*/
47-
export const isObject = (value: any): boolean => {
47+
export const isObject = (value: unknown): boolean => {
4848
if (!value) return false;
4949
const type = typeof value;
5050
return type === 'object';

src/lib/validators.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ const schemas: any[] = [
4343
];
4444
const strict: boolean = false;
4545
const ajv = new Ajv({ schemas, strict });
46-
ajv.addFormat('uri', (uri: string): boolean => true);
46+
ajv.addFormat('uri', (): boolean => true);
4747
/**
4848
* A Map of validation functions, where the key is the name of the schema to validate with
4949
*/

tests/examples/applicantrequest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"name": "Applicant Request Decision Workflow",
44
"version": "1.0.0",
55
"description": "Determine if applicant request is valid",
6-
"specVersion": "0.8",
6+
"specVersion": "0.9",
77
"start": "CheckApplication",
88
"states": [
99
{

tests/examples/applicantrequest.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ describe('applicationrequest workflow example', () => {
3131
const workflow = workflowBuilder()
3232
.id('applicantrequest')
3333
.version('1.0.0')
34-
.specVersion('0.8')
34+
.specVersion('0.9')
3535
.name('Applicant Request Decision Workflow')
3636
.description('Determine if applicant request is valid')
3737
.start('CheckApplication')

tests/examples/booklending.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"id": "booklending",
33
"name": "Book Lending Workflow",
44
"version": "1.0.0",
5-
"specVersion": "0.8",
5+
"specVersion": "0.9",
66
"start": "Book Lending Request",
77
"states": [
88
{

tests/examples/booklending.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ describe('booklending workflow example', () => {
3636
.id('booklending')
3737
.name('Book Lending Workflow')
3838
.version('1.0.0')
39-
.specVersion('0.8')
39+
.specVersion('0.9')
4040
.start('Book Lending Request')
4141
.states([
4242
eventstateBuilder()

tests/examples/carauctionbids.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"name": "Car Auction Bidding Workflow",
44
"version": "1.0.0",
55
"description": "Store a single bid whole the car auction is active",
6-
"specVersion": "0.8",
6+
"specVersion": "0.9",
77
"start": {
88
"stateName": "StoreCarAuctionBid",
99
"schedule": "R/PT2H"

tests/examples/carauctionbids.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ describe('carauctionbids workflow example', () => {
3030
const workflow = workflowBuilder()
3131
.id('handleCarAuctionBid')
3232
.version('1.0.0')
33-
.specVersion('0.8')
33+
.specVersion('0.9')
3434
.name('Car Auction Bidding Workflow')
3535
.description('Store a single bid whole the car auction is active')
3636
.start(startdefBuilder().stateName('StoreCarAuctionBid').schedule('R/PT2H').build())

tests/examples/checkcarvitals.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"id": "checkcarvitals",
33
"name": "Check Car Vitals Workflow",
44
"version": "1.0.0",
5-
"specVersion": "0.8",
5+
"specVersion": "0.9",
66
"start": "WhenCarIsOn",
77
"states": [
88
{

tests/examples/checkcarvitals.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ describe('checkcarvitals workflow example', () => {
3434
.id('checkcarvitals')
3535
.name('Check Car Vitals Workflow')
3636
.version('1.0.0')
37-
.specVersion('0.8')
37+
.specVersion('0.9')
3838
.start('WhenCarIsOn')
3939
.states([
4040
eventstateBuilder()

tests/examples/jobmonitoring.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"name": "Job Monitoring",
44
"version": "1.0.0",
55
"description": "Monitor finished execution of a submitted job",
6-
"specVersion": "0.8",
6+
"specVersion": "0.9",
77
"start": "SubmitJob",
88
"states": [
99
{

tests/examples/jobmonitoring.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ describe('jobmonitoring workflow example', () => {
3434
const workflow = workflowBuilder()
3535
.id('jobmonitoring')
3636
.version('1.0.0')
37-
.specVersion('0.8')
37+
.specVersion('0.9')
3838
.name('Job Monitoring')
3939
.description('Monitor finished execution of a submitted job')
4040
.start('SubmitJob')

tests/examples/parallel.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"name": "Parallel Execution Workflow",
44
"version": "1.0.0",
55
"description": "Executes two branches in parallel",
6-
"specVersion": "0.8",
6+
"specVersion": "0.9",
77
"start": "ParallelExec",
88
"states": [
99
{

tests/examples/parallel.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ describe('parallel workflow example', () => {
2222
const workflow = workflowBuilder()
2323
.id('parallelexec')
2424
.version('1.0.0')
25-
.specVersion('0.8')
25+
.specVersion('0.9')
2626
.name('Parallel Execution Workflow')
2727
.description('Executes two branches in parallel')
2828
.start('ParallelExec')

tests/examples/provisionorder.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"name": "Provision Orders",
44
"version": "1.0.0",
55
"description": "Provision Orders and handle errors thrown",
6-
"specVersion": "0.8",
6+
"specVersion": "0.9",
77
"start": "ProvisionOrder",
88
"states": [
99
{

tests/examples/provisionorder.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ describe('provisionorder workflow example', () => {
3131
const workflow = workflowBuilder()
3232
.id('provisionorders')
3333
.version('1.0.0')
34-
.specVersion('0.8')
34+
.specVersion('0.9')
3535
.name('Provision Orders')
3636
.description('Provision Orders and handle errors thrown')
3737
.start('ProvisionOrder')

tests/examples/sendcloudevent.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"id": "sendcloudeventonprovision",
33
"name": "Send CloudEvent on provision completion",
44
"version": "1.0.0",
5-
"specVersion": "0.8",
5+
"specVersion": "0.9",
66
"start": "ProvisionOrdersState",
77
"states": [
88
{

tests/examples/sendcloudevent.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ describe('sendcloudevent workflow example', () => {
3030
const workflow = workflowBuilder()
3131
.id('sendcloudeventonprovision')
3232
.version('1.0.0')
33-
.specVersion('0.8')
33+
.specVersion('0.9')
3434
.name('Send CloudEvent on provision completion')
3535
.start('ProvisionOrdersState')
3636
.events([

tests/examples/solvemathproblems.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"name": "Solve Math Problems Workflow",
44
"version": "1.0.0",
55
"description": "Solve math problems",
6-
"specVersion": "0.8",
6+
"specVersion": "0.9",
77
"start": "Solve",
88
"states": [
99
{

tests/examples/solvemathproblems.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ describe('solvemathproblems workflow example', () => {
2828
const workflow = workflowBuilder()
2929
.id('solvemathproblems')
3030
.version('1.0.0')
31-
.specVersion('0.8')
31+
.specVersion('0.9')
3232
.name('Solve Math Problems Workflow')
3333
.description('Solve math problems')
3434
.start('Solve')

tests/lib/definitions/action.spec.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ describe('Action ', () => {
2727

2828
const model = new Action(data);
2929

30-
expect(model.functionRef!.constructor.name).toBe('Functionref');
31-
expect(model.eventRef!.constructor.name).toBe('Eventref');
32-
expect(model.actionDataFilter!.constructor.name).toBe('Actiondatafilter');
30+
expect(model.functionRef?.constructor.name).toBe('Functionref');
31+
expect(model.eventRef?.constructor.name).toBe('Eventref');
32+
expect(model.actionDataFilter?.constructor.name).toBe('Actiondatafilter');
3333
});
3434
});

tests/lib/definitions/branch.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ describe('Branch ', () => {
2525

2626
const model = new Branch(data);
2727

28-
expect(model.actions![0].constructor.name).toBe('Action');
28+
expect(model.actions?.[0].constructor.name).toBe('Action');
2929
});
3030
});

tests/lib/definitions/eventdef.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ describe('Eventdef ', () => {
2626

2727
const model = new Eventdef(data);
2828

29-
expect(model.correlation![0].constructor.name).toBe('CorrelationDef');
30-
expect(model.metadata!.constructor.name).toBe('Metadata');
29+
expect(model.correlation?.[0].constructor.name).toBe('CorrelationDef');
30+
expect(model.metadata?.constructor.name).toBe('Metadata');
3131
});
3232
});

tests/lib/definitions/schedule.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe('schedule ', () => {
2424
};
2525

2626
const model = new Schedule(data);
27-
expect(model.cron!.constructor.name).toBe('Crondef');
27+
expect(model.cron?.constructor.name).toBe('Crondef');
2828
});
2929

3030
it('should not convert primitive properties', () => {

0 commit comments

Comments
 (0)