Skip to content

Commit b7e61dd

Browse files
committed
moved from types to classes
Signed-off-by: Antonio Mendoza Pérez <[email protected]>
1 parent 896a80e commit b7e61dd

File tree

127 files changed

+3707
-1675
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

127 files changed

+3707
-1675
lines changed

README.md

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ To build the project and run tests locally:
1919
```sh
2020
git clone https://github.com/serverlessworkflow/sdk-typescript.git
2121
cd sdk-typescript
22-
npm install && npm run update-code-base && npm run test
22+
npm install && npm run test
2323
```
2424

2525

@@ -66,7 +66,6 @@ const workflow: Specification.Workflow = workflowBuilder()
6666
.data({
6767
"result": "Hello World!"
6868
})
69-
.end(true)
7069
.build()
7170
])
7271
.build();
@@ -76,9 +75,9 @@ const workflow: Specification.Workflow = workflowBuilder()
7675
#### Load a file JSON/YAML to a Workflow instance
7776

7877
```typescript
79-
import { Specification, WorkflowConverter } from '@severlessworkflow/sdk-typescript';
78+
import { Specification, Workflow } from '@severlessworkflow/sdk-typescript';
8079

81-
const workflow: Specification.Workflow = WorkflowConverter.fromString(source);
80+
const workflow: Specification.Workflow = Workflow.fromSource(source);
8281
```
8382
Where `source` is a JSON or a YAML string.
8483

@@ -109,18 +108,18 @@ const workflow: Specification.Workflow = workflowBuilder()
109108
```
110109

111110
You can convert it to its string representation in JSON or YAML format
112-
by using the static methods `toJson` or `toYaml` respectively:
111+
by using the static methods `Workflow.toJson` or `Workflow.toYaml` respectively:
113112

114113
```typescript
115-
import { WorkflowConverter } from '@severlessworkflow/sdk-typescript';
114+
import { Workflow } from '../src/lib/definitions/workflow';
116115

117-
const workflowAsJson: string = WorkflowConverter.toJson(workflow);
116+
const workflowAsJson: string = Workflow.toJson(workflow);
118117
```
119118

120119
```typescript
121-
import { WorkflowConverter } from '@severlessworkflow/sdk-typescript';
120+
import { Workflow } from '../src/lib/definitions/workflow';
122121

123-
const workflowAsYaml: string = WorkflowConverter.toYaml(workflow);
122+
const workflowAsYaml: string = Workflow.toYaml(workflow);
124123
```
125124

126125

@@ -169,4 +168,4 @@ const injectionStateValidator: ValidateFunction<Specification.Injectstate> = val
169168
if (!injectionStateValidator(injectionState)) {
170169
injectionStateValidator.errors.forEach(error => console.error(error.message));
171170
}
172-
```
171+
```

src/lib/builders/action-builder.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,11 @@ import { validate } from '../utils';
2626
*/
2727
function actionBuildingFn(data: Specification.Action): () => Specification.Action {
2828
return () => {
29-
validate('Action', data);
30-
return data;
29+
const result = {} as Specification.Action;
30+
31+
Object.assign(result, data);
32+
validate('Action', result);
33+
return result;
3134
};
3235
}
3336

src/lib/builders/actiondatafilter-builder.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,11 @@ import { validate } from '../utils';
2626
*/
2727
function actiondatafilterBuildingFn(data: Specification.Actiondatafilter): () => Specification.Actiondatafilter {
2828
return () => {
29-
validate('Actiondatafilter', data);
30-
return data;
29+
const result = {} as Specification.Actiondatafilter;
30+
31+
Object.assign(result, data);
32+
validate('Actiondatafilter', result);
33+
return result;
3134
};
3235
}
3336

src/lib/builders/branch-builder.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,11 @@ import { validate } from '../utils';
2626
*/
2727
function branchBuildingFn(data: Specification.Branch): () => Specification.Branch {
2828
return () => {
29-
validate('Branch', data);
30-
return data;
29+
const result = {} as Specification.Branch;
30+
31+
Object.assign(result, data);
32+
validate('Branch', result);
33+
return result;
3134
};
3235
}
3336

src/lib/builders/callbackstate-builder.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,13 @@ import { validate } from '../utils';
2626
*/
2727
function callbackstateBuildingFn(data: Specification.Callbackstate): () => Specification.Callbackstate {
2828
return () => {
29-
data.type = 'callback';
30-
validate('Callbackstate', data);
31-
return data;
29+
const result = {
30+
type: 'callback',
31+
} as Specification.Callbackstate;
32+
33+
Object.assign(result, data);
34+
validate('Callbackstate', result);
35+
return result;
3236
};
3337
}
3438

src/lib/builders/correlation-def-builder.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,11 @@ import { validate } from '../utils';
2626
*/
2727
function correlationDefBuildingFn(data: Specification.CorrelationDef): () => Specification.CorrelationDef {
2828
return () => {
29-
validate('CorrelationDef', data);
30-
return data;
29+
const result = {} as Specification.CorrelationDef;
30+
31+
Object.assign(result, data);
32+
validate('CorrelationDef', result);
33+
return result;
3134
};
3235
}
3336

src/lib/builders/crondef-builder.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,11 @@ import { validate } from '../utils';
2626
*/
2727
function crondefBuildingFn(data: Specification.Crondef): () => Specification.Crondef {
2828
return () => {
29-
validate('Crondef', data);
30-
return data;
29+
const result = {} as Specification.Crondef;
30+
31+
Object.assign(result, data);
32+
validate('Crondef', result);
33+
return result;
3134
};
3235
}
3336

src/lib/builders/databasedswitch-builder.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,13 @@ import { validate } from '../utils';
2626
*/
2727
function databasedswitchBuildingFn(data: Specification.Databasedswitch): () => Specification.Databasedswitch {
2828
return () => {
29-
data.type = 'switch';
30-
validate('Databasedswitch', data);
31-
return data;
29+
const result = {
30+
type: 'switch',
31+
} as Specification.Databasedswitch;
32+
33+
Object.assign(result, data);
34+
validate('Databasedswitch', result);
35+
return result;
3236
};
3337
}
3438

src/lib/builders/datacondition-builder.ts

Lines changed: 0 additions & 40 deletions
This file was deleted.

src/lib/builders/defaultdef-builder.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,11 @@ import { validate } from '../utils';
2626
*/
2727
function defaultdefBuildingFn(data: Specification.Defaultdef): () => Specification.Defaultdef {
2828
return () => {
29-
validate('Defaultdef', data);
30-
return data;
29+
const result = {} as Specification.Defaultdef;
30+
31+
Object.assign(result, data);
32+
validate('Defaultdef', result);
33+
return result;
3134
};
3235
}
3336

0 commit comments

Comments
 (0)