Skip to content

Commit 6e6dc9d

Browse files
authored
Merge pull request #114 from antmendoza/from-types-to-classes
moved from types to classes
2 parents 896a80e + 01424a8 commit 6e6dc9d

File tree

134 files changed

+5341
-1859
lines changed

Some content is hidden

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

134 files changed

+5341
-1859
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: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@ import { validate } from '../utils';
2626
*/
2727
function actionBuildingFn(data: Specification.Action): () => Specification.Action {
2828
return () => {
29-
validate('Action', data);
30-
return data;
29+
const model = new Specification.Action(data);
30+
31+
validate('Action', model);
32+
return model;
3133
};
3234
}
3335

src/lib/builders/actiondatafilter-builder.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@ import { validate } from '../utils';
2626
*/
2727
function actiondatafilterBuildingFn(data: Specification.Actiondatafilter): () => Specification.Actiondatafilter {
2828
return () => {
29-
validate('Actiondatafilter', data);
30-
return data;
29+
const model = new Specification.Actiondatafilter(data);
30+
31+
validate('Actiondatafilter', model);
32+
return model;
3133
};
3234
}
3335

src/lib/builders/branch-builder.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@ import { validate } from '../utils';
2626
*/
2727
function branchBuildingFn(data: Specification.Branch): () => Specification.Branch {
2828
return () => {
29-
validate('Branch', data);
30-
return data;
29+
const model = new Specification.Branch(data);
30+
31+
validate('Branch', model);
32+
return model;
3133
};
3234
}
3335

src/lib/builders/callbackstate-builder.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import { Builder, builder } from '../builder';
1919
import { Specification } from '../definitions';
2020
import { validate } from '../utils';
21+
import { setEndValueIfNoTransition } from '../definitions/utils';
2122

2223
/**
2324
* The internal function used by the builder proxy to validate and return its underlying object
@@ -26,9 +27,12 @@ import { validate } from '../utils';
2627
*/
2728
function callbackstateBuildingFn(data: Specification.Callbackstate): () => Specification.Callbackstate {
2829
return () => {
29-
data.type = 'callback';
30-
validate('Callbackstate', data);
31-
return data;
30+
const model = new Specification.Callbackstate(data);
31+
32+
setEndValueIfNoTransition(model);
33+
34+
validate('Callbackstate', model);
35+
return model;
3236
};
3337
}
3438

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@ import { validate } from '../utils';
2626
*/
2727
function correlationDefBuildingFn(data: Specification.CorrelationDef): () => Specification.CorrelationDef {
2828
return () => {
29-
validate('CorrelationDef', data);
30-
return data;
29+
const model = new Specification.CorrelationDef(data);
30+
31+
validate('CorrelationDef', model);
32+
return model;
3133
};
3234
}
3335

src/lib/builders/crondef-builder.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@ import { validate } from '../utils';
2626
*/
2727
function crondefBuildingFn(data: Specification.Crondef): () => Specification.Crondef {
2828
return () => {
29-
validate('Crondef', data);
30-
return data;
29+
const model = new Specification.Crondef(data);
30+
31+
validate('Crondef', model);
32+
return model;
3133
};
3234
}
3335

src/lib/builders/databasedswitch-builder.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@ 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 model = new Specification.Databasedswitch(data);
30+
31+
validate('Databasedswitch', model);
32+
return model;
3233
};
3334
}
3435

src/lib/builders/datacondition-builder.ts

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

src/lib/builders/defaultdef-builder.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import { Builder, builder } from '../builder';
1919
import { Specification } from '../definitions';
2020
import { validate } from '../utils';
21+
import { setEndValueIfNoTransition } from '../definitions/utils';
2122

2223
/**
2324
* The internal function used by the builder proxy to validate and return its underlying object
@@ -26,8 +27,12 @@ import { validate } from '../utils';
2627
*/
2728
function defaultdefBuildingFn(data: Specification.Defaultdef): () => Specification.Defaultdef {
2829
return () => {
29-
validate('Defaultdef', data);
30-
return data;
30+
const model = new Specification.Defaultdef(data);
31+
32+
setEndValueIfNoTransition(model);
33+
34+
validate('Defaultdef', model);
35+
return model;
3136
};
3237
}
3338

0 commit comments

Comments
 (0)