Skip to content

Commit 64655a6

Browse files
authored
Merge pull request #97 from antmendoza/fix-test_
fix example test
2 parents 41a4e8a + 4564ce0 commit 64655a6

36 files changed

+938
-1689
lines changed

examples/node/index.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
const { workflowBuilder, injectstateBuilder } = require('../../dist');
2-
const workflow = workflowBuilder()
3-
.id("helloworld")
4-
.version("1.0")
5-
.name("Hello World Workflow")
6-
.description("Inject Hello World")
7-
.start("Hello State")
8-
.states([
9-
injectstateBuilder()
10-
.name("Hello State")
11-
.data({
12-
"result": "Hello World!"
13-
})
14-
.end(true)
15-
.build()
16-
])
17-
.build();
1+
const { workflowBuilder, injectstateBuilder } = require('../../dist');
2+
const workflow = workflowBuilder()
3+
.id("helloworld")
4+
.version("1.0")
5+
.name("Hello World Workflow")
6+
.description("Inject Hello World")
7+
.start("Hello State")
8+
.states([
9+
injectstateBuilder()
10+
.name("Hello State")
11+
.data({
12+
"result": "Hello World!"
13+
})
14+
.end(true)
15+
.build()
16+
])
17+
.build();
1818
console.log(workflow.id);

src/lib/builders/foreachstate-builder.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ import { validators } from '../validators';
2828
function foreachstateBuildingFn(data: Specification.Foreachstate): () => Specification.Foreachstate {
2929
return () => {
3030
data.type = 'foreach';
31+
32+
//FIXME https://github.com/serverlessworkflow/sdk-typescript/issues/95
33+
34+
data.usedForCompensation = data.usedForCompensation || false;
3135
const validate = validators.get('Foreachstate');
3236
// TODO: ignore validation if no validator or throw ?
3337
if (!validate) return data;

src/lib/definitions/workflow.ts

Lines changed: 81 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ export interface Actiondatafilter {
151151
/**
152152
* Branch Definition
153153
*/
154-
export type Branch = /* Branch Definition */
154+
export type Branch /* Branch Definition */ =
155155
| {
156156
/**
157157
* Branch name
@@ -305,13 +305,13 @@ export interface Databasedswitch {
305305
usedForCompensation?: boolean;
306306
metadata?: /* Metadata information */ Metadata;
307307
}
308-
export type Datacondition = /* Switch state data based condition */
308+
export type Datacondition /* Switch state data based condition */ =
309309
| Transitiondatacondition
310310
| /* Switch state data based condition */ Enddatacondition;
311311
/**
312312
* Default definition. Can be either a transition or end definition
313313
*/
314-
export type Defaultdef = /* Default definition. Can be either a transition or end definition */
314+
export type Defaultdef /* Default definition. Can be either a transition or end definition */ =
315315
| {
316316
transition: Transition;
317317
end?: End;
@@ -501,7 +501,7 @@ export interface Eventbasedswitch {
501501
usedForCompensation?: boolean;
502502
metadata?: /* Metadata information */ Metadata;
503503
}
504-
export type Eventcondition = /* Switch state data event condition */
504+
export type Eventcondition /* Switch state data event condition */ =
505505
| Transitioneventcondition
506506
| /* Switch state data event condition */ Enddeventcondition;
507507
export interface Eventdatafilter {
@@ -576,120 +576,82 @@ export type Events = string /* uri */ | [Eventdef, ...Eventdef[]];
576576
*/
577577
export type Eventstate =
578578
/* This state is used to wait for events from event sources, then consumes them and invoke one or more actions to run in sequence or parallel */
579-
| {
580-
/**
581-
* Unique State id
582-
*/
583-
id?: string;
584-
/**
585-
* State name
586-
*/
587-
name: string;
588-
/**
589-
* State type
590-
*/
591-
type: 'event';
592-
/**
593-
* If true consuming one of the defined events causes its associated actions to be performed. If false all of the defined events must be consumed in order for actions to be performed
594-
*/
595-
exclusive?: boolean;
596-
/**
597-
* Define the events to be consumed and optional actions to be performed
598-
*/
599-
onEvents: Onevents[];
600-
/**
601-
* Time period to wait for incoming events (ISO 8601 format)
602-
*/
603-
timeout?: string;
604-
stateDataFilter?: Statedatafilter;
605-
/**
606-
* States error handling and retries definitions
607-
*/
608-
onErrors?: Error[];
609-
transition?: Transition;
610-
end: End;
611-
/**
612-
* Unique Name of a workflow state which is responsible for compensation of this state
613-
*/
614-
compensatedBy?: string;
615-
metadata?: /* Metadata information */ Metadata;
616-
}
617-
| {
618-
/**
619-
* Unique State id
620-
*/
621-
id?: string;
622-
/**
623-
* State name
624-
*/
625-
name: string;
626-
/**
627-
* State type
628-
*/
629-
type: 'event';
630-
/**
631-
* If true consuming one of the defined events causes its associated actions to be performed. If false all of the defined events must be consumed in order for actions to be performed
632-
*/
633-
exclusive?: boolean;
634-
/**
635-
* Define the events to be consumed and optional actions to be performed
636-
*/
637-
onEvents: Onevents[];
638-
/**
639-
* Time period to wait for incoming events (ISO 8601 format)
640-
*/
641-
timeout?: string;
642-
stateDataFilter?: Statedatafilter;
643-
/**
644-
* States error handling and retries definitions
645-
*/
646-
onErrors?: Error[];
647-
transition: Transition;
648-
end?: End;
649-
/**
650-
* Unique Name of a workflow state which is responsible for compensation of this state
651-
*/
652-
compensatedBy?: string;
653-
metadata?: /* Metadata information */ Metadata;
654-
}
655-
| {
656-
/**
657-
* Unique State id
658-
*/
659-
id?: string;
660-
/**
661-
* State name
662-
*/
663-
name: string;
664-
/**
665-
* State type
666-
*/
667-
type: 'event';
668-
/**
669-
* If true consuming one of the defined events causes its associated actions to be performed. If false all of the defined events must be consumed in order for actions to be performed
670-
*/
671-
exclusive?: boolean;
672-
/**
673-
* Define the events to be consumed and optional actions to be performed
674-
*/
675-
onEvents: Onevents[];
676-
/**
677-
* Time period to wait for incoming events (ISO 8601 format)
678-
*/
679-
timeout?: string;
680-
stateDataFilter?: Statedatafilter;
681-
/**
682-
* States error handling and retries definitions
683-
*/
684-
onErrors?: Error[];
685-
transition?: Transition;
686-
end: End;
687-
/**
688-
* Unique Name of a workflow state which is responsible for compensation of this state
689-
*/
690-
compensatedBy?: string;
691-
metadata?: /* Metadata information */ Metadata;
692-
};
579+
| {
580+
/**
581+
* Unique State id
582+
*/
583+
id?: string;
584+
/**
585+
* State name
586+
*/
587+
name: string;
588+
/**
589+
* State type
590+
*/
591+
type: 'event';
592+
/**
593+
* If true consuming one of the defined events causes its associated actions to be performed. If false all of the defined events must be consumed in order for actions to be performed
594+
*/
595+
exclusive?: boolean;
596+
/**
597+
* Define the events to be consumed and optional actions to be performed
598+
*/
599+
onEvents: Onevents[];
600+
/**
601+
* Time period to wait for incoming events (ISO 8601 format)
602+
*/
603+
timeout?: string;
604+
stateDataFilter?: Statedatafilter;
605+
/**
606+
* States error handling and retries definitions
607+
*/
608+
onErrors?: Error[];
609+
transition?: Transition;
610+
end: End;
611+
/**
612+
* Unique Name of a workflow state which is responsible for compensation of this state
613+
*/
614+
compensatedBy?: string;
615+
metadata?: /* Metadata information */ Metadata;
616+
}
617+
| {
618+
/**
619+
* Unique State id
620+
*/
621+
id?: string;
622+
/**
623+
* State name
624+
*/
625+
name: string;
626+
/**
627+
* State type
628+
*/
629+
type: 'event';
630+
/**
631+
* If true consuming one of the defined events causes its associated actions to be performed. If false all of the defined events must be consumed in order for actions to be performed
632+
*/
633+
exclusive?: boolean;
634+
/**
635+
* Define the events to be consumed and optional actions to be performed
636+
*/
637+
onEvents: Onevents[];
638+
/**
639+
* Time period to wait for incoming events (ISO 8601 format)
640+
*/
641+
timeout?: string;
642+
stateDataFilter?: Statedatafilter;
643+
/**
644+
* States error handling and retries definitions
645+
*/
646+
onErrors?: Error[];
647+
transition: Transition;
648+
end?: End;
649+
/**
650+
* Unique Name of a workflow state which is responsible for compensation of this state
651+
*/
652+
compensatedBy?: string;
653+
metadata?: /* Metadata information */ Metadata;
654+
};
693655
export interface Exectimeout {
694656
/**
695657
* Timeout duration (ISO 8601 duration format)
@@ -1135,7 +1097,7 @@ export interface Subflowstate {
11351097
usedForCompensation?: boolean;
11361098
metadata?: /* Metadata information */ Metadata;
11371099
}
1138-
export type Switchstate = /* Permits transitions to other states based on data conditions */
1100+
export type Switchstate /* Permits transitions to other states based on data conditions */ =
11391101
| Databasedswitch
11401102
| /* Permits transitions to other states based on events */ Eventbasedswitch;
11411103
export type Transition =

src/lib/schema/workflow.json

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -590,14 +590,6 @@
590590
"onEvents",
591591
"transition"
592592
]
593-
},
594-
{
595-
"required": [
596-
"name",
597-
"type",
598-
"onEvents",
599-
"end"
600-
]
601593
}
602594
]
603595
},
@@ -703,14 +695,6 @@
703695
"actions",
704696
"transition"
705697
]
706-
},
707-
{
708-
"required": [
709-
"name",
710-
"type",
711-
"actions",
712-
"end"
713-
]
714698
}
715699
]
716700
}
@@ -828,14 +812,6 @@
828812
"branches",
829813
"transition"
830814
]
831-
},
832-
{
833-
"required": [
834-
"name",
835-
"type",
836-
"branches",
837-
"end"
838-
]
839815
}
840816
]
841817
}

0 commit comments

Comments
 (0)