@@ -37,16 +37,25 @@ npm install && npm run build && npm run test
37
37
38
38
#### Install
39
39
40
- For the latest stable version:
41
40
41
+ ##### Version >= 4.0.0
42
+ Note: Version 4.0.0 has not been released yet.
43
+ ``` sh
44
+ npm i @serverlessworkflow/sdk-typescript
45
+ ```
46
+
47
+
48
+ ##### Version < 4.0.0
42
49
``` sh
43
50
npm i @severlessworkflow/sdk-typescript
44
51
```
45
52
53
+
54
+
46
55
#### Create Workflow using builder API
47
56
48
57
``` typescript
49
- import { workflowBuilder , injectstateBuilder , Specification } from ' @severlessworkflow /sdk-typescript' ;
58
+ import { workflowBuilder , injectstateBuilder , Specification } from ' @serverlessworkflow /sdk-typescript' ;
50
59
51
60
const workflow: Specification .Workflow = workflowBuilder ()
52
61
.id (" helloworld" )
@@ -69,7 +78,7 @@ const workflow: Specification.Workflow = workflowBuilder()
69
78
#### Create Workflow from JSON/YAML source
70
79
71
80
``` typescript
72
- import { Specification , Workflow } from ' @severlessworkflow /sdk-typescript' ;
81
+ import { Specification , Workflow } from ' @serverlessworkflow /sdk-typescript' ;
73
82
74
83
const source = ` id: helloworld
75
84
version: '1.0'
@@ -93,7 +102,7 @@ Where `source` can be in both JSON or YAML format.
93
102
Having the following workflow instance:
94
103
95
104
``` typescript
96
- import { workflowBuilder , injectstateBuilder , Specification } from ' @severlessworkflow /sdk-typescript' ;
105
+ import { workflowBuilder , injectstateBuilder , Specification } from ' @serverlessworkflow /sdk-typescript' ;
97
106
98
107
const workflow: Specification .Workflow = workflowBuilder ()
99
108
.id (" helloworld" )
@@ -118,15 +127,23 @@ You can convert it to its string representation in JSON or YAML format
118
127
by using the static methods ` Workflow.toJson ` or ` Workflow.toYaml ` respectively:
119
128
120
129
``` typescript
121
- import { Workflow } from ' ../src/lib/definitions/workflow' ;
130
+ import {Specification , workflowBuilder } from " @severlessworkflow/sdk-typescript" ;
131
+
132
+ const workflow: Specification .Workflow = workflowBuilder ()
133
+ // ...
134
+ .build ()
122
135
123
- const workflowAsJson: string = Workflow .toJson (workflow );
136
+ const workflowAsJson: string = Specification . Workflow .toJson (workflow );
124
137
```
125
138
126
139
``` typescript
127
- import { Workflow } from ' ../src/lib/definitions/workflow' ;
140
+ import {Specification , workflowBuilder } from " @severlessworkflow/sdk-typescript" ;
141
+
142
+ const workflow: Specification .Workflow = workflowBuilder ()
143
+ // ...
144
+ .build ()
128
145
129
- const workflowAsYaml: string = Workflow .toYaml (workflow );
146
+ const workflowAsYaml: string = Specification . Workflow .toYaml (workflow );
130
147
```
131
148
132
149
@@ -139,7 +156,7 @@ The sdk provides a way to validate if a workflow object is compliant with the se
139
156
- ` validate(): boolean `
140
157
141
158
``` typescript
142
- import {WorkflowValidator , Specification } from ' @severlessworkflow /sdk-typescript' ;
159
+ import {WorkflowValidator , Specification } from ' @serverlessworkflow /sdk-typescript' ;
143
160
import {Workflow } from " ./workflow" ;
144
161
145
162
const workflow = {
@@ -171,7 +188,7 @@ You can also validate parts of a workflow using `validators`:
171
188
172
189
``` typescript
173
190
import { ValidateFunction } from ' ajv' ;
174
- import { validators , Specification } from ' @severlessworkflow /sdk-typescript' ;
191
+ import { validators , Specification } from ' @serverlessworkflow /sdk-typescript' ;
175
192
176
193
const injectionState: Specification .Injectstate = workflow .states [0 ];
177
194
const injectionStateValidator: ValidateFunction <Specification .Injectstate > = validators .get (' Injectstate' );
0 commit comments