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

Lines changed: 2 additions & 1 deletion
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

Lines changed: 7 additions & 4 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 5 additions & 5 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 7 additions & 5 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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
{

0 commit comments

Comments
 (0)