Skip to content

Commit e58c2ab

Browse files
committed
start.
0 parents  commit e58c2ab

File tree

8 files changed

+224
-0
lines changed

8 files changed

+224
-0
lines changed

.editorconfig

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
indent_style = tab
6+
tab_width = 4
7+
insert_final_newline = true
8+
trim_trailing_whitespace = true
9+
10+
[*.ts]
11+
quote_type = single
12+
13+
[*.md]
14+
indent_style = space
15+
max_line_length = off
16+
trim_trailing_whitespace = false

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules/
2+
lib/

LICENSE

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2023 N4NO.com
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6+
7+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8+
9+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Sequential Workflow Model
2+
3+
[![License: MIT](https://img.shields.io/github/license/mashape/apistatus.svg?style=flat-square)](/LICENSE) [![View this project on NPM](https://img.shields.io/npm/v/sequential-workflow-model.svg?style=flat-square)](https://npmjs.org/package/sequential-workflow-model)
4+
5+
This package contains a extendable data model of a sequential workflow.
6+
7+
The package is used by the following packages:
8+
* [Sequential Workflow Designer](https://github.com/nocode-js/sequential-workflow-designer)
9+
* [Sequential Workflow Machine](https://github.com/nocode-js/sequential-workflow-machine)
10+
11+
## 🔨 How to Extend Model
12+
13+
To extend the model, you need to extend base interfaces.
14+
15+
```ts
16+
interface MyDefinition extends Definition {
17+
properties: {
18+
baseUrl: string;
19+
};
20+
}
21+
22+
interface SendEmailStep extends Step {
23+
componentType: 'task';
24+
type: 'sendEmail';
25+
properties: {
26+
to: string;
27+
subject: string;
28+
body: string;
29+
};
30+
}
31+
32+
interface IfStep extends BranchedStep {
33+
componentType: 'switch';
34+
type: 'if';
35+
properties: {
36+
condition: string;
37+
};
38+
}
39+
```
40+
41+
## 💡 License
42+
43+
This project is released under the MIT license.

package.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"name": "sequential-workflow-model",
3+
"description": "Extendable data model of sequential workflow.",
4+
"version": "0.1.0",
5+
"homepage": "https://nocode-js.com/",
6+
"author": {
7+
"name": "NoCode JS",
8+
"url": "https://nocode-js.com/"
9+
},
10+
"license": "MIT",
11+
"main": "./lib/index.js",
12+
"types": "./lib/index.d.ts",
13+
"files": [
14+
"lib/"
15+
],
16+
"publishConfig": {
17+
"registry": "https://registry.npmjs.org/"
18+
},
19+
"repository": {
20+
"type": "git",
21+
"url": "https://github.com/nocode-js/sequential-workflow-model.git"
22+
},
23+
"scripts": {
24+
"clean": "rm -rf lib",
25+
"build": "yarn clean && tsc"
26+
},
27+
"devDependencies": {
28+
"typescript": "^4.9.5"
29+
},
30+
"keywords": [
31+
"workflow",
32+
"nocode",
33+
"state machine",
34+
"data model"
35+
]
36+
}

src/index.ts

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
/**
2+
* @description Represents a definition of a sequential workflow.
3+
*/
4+
export interface Definition {
5+
/**
6+
* @description The root sequence of the sequential workflow.
7+
*/
8+
sequence: Sequence;
9+
10+
/**
11+
* @description The global properties of the sequential workflow.
12+
*/
13+
properties: Properties;
14+
}
15+
16+
/**
17+
* @description Represents a sequence of steps.
18+
*/
19+
export type Sequence = Step[];
20+
21+
/**
22+
* @description Represents a step in a sequence.
23+
*/
24+
export interface Step {
25+
/**
26+
* @description The unique identifier for the step.
27+
*/
28+
id: string;
29+
30+
/**
31+
* @description The component type rendered by the designer.
32+
*/
33+
componentType: ComponentType;
34+
35+
/**
36+
* @description The type of the step.
37+
*/
38+
type: string;
39+
40+
/**
41+
* @description The name of the step.
42+
*/
43+
name: string;
44+
45+
/**
46+
* @description The properties of the step.
47+
*/
48+
properties: Properties;
49+
}
50+
51+
/**
52+
* @description Represents a component type.
53+
*/
54+
export type ComponentType = string;
55+
56+
/**
57+
* @description Represents a set of branches.
58+
*/
59+
export interface Branches {
60+
[branchName: string]: Sequence;
61+
}
62+
63+
/**
64+
* @description Represents a set of properties.
65+
*/
66+
export interface Properties {
67+
[propertyName: string]: PropertyValue;
68+
};
69+
70+
/**
71+
* @description Represents a property value. The value must be serializable.
72+
*/
73+
export type PropertyValue = string | string[] | number | number[] | boolean | boolean[] | null | object;
74+
75+
// Extended types
76+
77+
/**
78+
* @description Represents a step that contains branches.
79+
*/
80+
export interface BranchedStep extends Step {
81+
/**
82+
* @description The branches of the step.
83+
*/
84+
branches: Branches;
85+
}
86+
87+
/**
88+
* @description Represents a step that contains a subsequence.
89+
*/
90+
export interface SequentialStep extends Step {
91+
/**
92+
* @description The subsequence of the step.
93+
*/
94+
sequence: Sequence;
95+
}

tsconfig.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"compilerOptions": {
3+
"outDir": "./lib",
4+
"noImplicitAny": true,
5+
"target": "es6",
6+
"module": "es2015",
7+
"sourceMap": false,
8+
"strict": true,
9+
"allowJs": false,
10+
"declaration": true,
11+
"moduleResolution": "node",
12+
"esModuleInterop": true,
13+
"lib": ["es2015", "dom"]
14+
}
15+
}

yarn.lock

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2+
# yarn lockfile v1
3+
4+
5+
typescript@^4.9.5:
6+
version "4.9.5"
7+
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.9.5.tgz#095979f9bcc0d09da324d58d03ce8f8374cbe65a"
8+
integrity sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==

0 commit comments

Comments
 (0)