Skip to content

Commit cfe1cea

Browse files
antmendozatsurdilo
authored andcommitted
added builder to produceEventDef
Signed-off-by: Antonio Mendoza Pérez <[email protected]>
1 parent 2f033b3 commit cfe1cea

File tree

4 files changed

+9
-152
lines changed

4 files changed

+9
-152
lines changed

spec/produce-event-def-builder.spec.ts

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -14,39 +14,8 @@
1414
* limitations under the License.
1515
*
1616
*/
17+
import {ProduceEventDefBuilder} from '../src/model/produce-event-def.builder';
1718

18-
import {EventName, ProduceEventDef} from '../src';
19-
20-
21-
export class ProduceEventDefBuilder {
22-
// @ts-ignore
23-
private readonly model: ProduceEventDef = {};
24-
25-
26-
withEventRef(value: EventName): ProduceEventDefBuilder {
27-
this.model.eventRef = value;
28-
return this;
29-
}
30-
31-
withData(value: object): ProduceEventDefBuilder {
32-
this.model.data = value;
33-
return this;
34-
35-
}
36-
37-
withContextAttributes(value: object): any {
38-
this.model.contextAttributes = value;
39-
return this;
40-
}
41-
42-
build(): ProduceEventDef {
43-
if (!this.model.eventRef) {
44-
throw new Error("Field eventRef can not be undefined");
45-
}
46-
return this.model;
47-
}
48-
49-
}
5019

5120
describe("ProduceEventDefBuilder", () => {
5221

src/model/produce-event-def.builder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*
1616
*/
17-
import {EventName, ProduceEventDef} from '../src';
17+
import {EventName, ProduceEventDef} from '../index';
1818

1919
export class ProduceEventDefBuilder {
2020
// @ts-ignore

src/model/types.ts

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -175,24 +175,7 @@ export type EndType = | boolean
175175
/**
176176
* Defines events that should be produced
177177
*/
178-
produceEvents?: {
179-
/**
180-
* References a name of a defined event
181-
*/
182-
eventRef: string;
183-
/**
184-
* If String, expression which selects parts of the states data output to become the data of the produced event. If object a custom object to become the data of produced event.
185-
*/
186-
data?:
187-
| string
188-
| object;
189-
/**
190-
* Add additional event extension context attributes
191-
*/
192-
contextAttributes?: {
193-
[k: string]: string;
194-
};
195-
}[];
178+
produceEvents?: ProduceEventsDef;
196179
/**
197180
* If set to true, triggers workflow compensation. Default is false
198181
*/

src/model/workflow.ts

Lines changed: 6 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ export interface ParallelState {
384384
/**
385385
* Array of events to be produced before the transition happens
386386
*/
387-
produceEvents?:ProduceEventsDef;
387+
produceEvents?: ProduceEventsDef;
388388
/**
389389
* If set to true, triggers workflow compensation when before this transition is taken. Default is false
390390
*/
@@ -483,26 +483,7 @@ export interface Transitiondatacondition {
483483
/**
484484
* Array of events to be produced before the transition happens
485485
*/
486-
produceEvents?: {
487-
/**
488-
* References a name of a defined event
489-
*/
490-
eventRef: string;
491-
/**
492-
* If String, expression which selects parts of the states data output to become the data of the produced event. If object a custom object to become the data of produced event.
493-
*/
494-
data?:
495-
| string
496-
| {
497-
[k: string]: unknown;
498-
};
499-
/**
500-
* Add additional event extension context attributes
501-
*/
502-
contextAttributes?: {
503-
[k: string]: string;
504-
};
505-
}[];
486+
produceEvents?: ProduceEventsDef;
506487
/**
507488
* If set to true, triggers workflow compensation when before this transition is taken. Default is false
508489
*/
@@ -741,26 +722,7 @@ export interface SubFlowState {
741722
/**
742723
* Array of events to be produced before the transition happens
743724
*/
744-
produceEvents?: {
745-
/**
746-
* References a name of a defined event
747-
*/
748-
eventRef: string;
749-
/**
750-
* If String, expression which selects parts of the states data output to become the data of the produced event. If object a custom object to become the data of produced event.
751-
*/
752-
data?:
753-
| string
754-
| {
755-
[k: string]: unknown;
756-
};
757-
/**
758-
* Add additional event extension context attributes
759-
*/
760-
contextAttributes?: {
761-
[k: string]: string;
762-
};
763-
}[];
725+
produceEvents?: ProduceEventsDef;
764726
/**
765727
* If set to true, triggers workflow compensation when before this transition is taken. Default is false
766728
*/
@@ -824,26 +786,7 @@ export interface InjectState {
824786
/**
825787
* Array of events to be produced before the transition happens
826788
*/
827-
produceEvents?: {
828-
/**
829-
* References a name of a defined event
830-
*/
831-
eventRef: string;
832-
/**
833-
* If String, expression which selects parts of the states data output to become the data of the produced event. If object a custom object to become the data of produced event.
834-
*/
835-
data?:
836-
| string
837-
| {
838-
[k: string]: unknown;
839-
};
840-
/**
841-
* Add additional event extension context attributes
842-
*/
843-
contextAttributes?: {
844-
[k: string]: string;
845-
};
846-
}[];
789+
produceEvents?: ProduceEventsDef;
847790
/**
848791
* If set to true, triggers workflow compensation when before this transition is taken. Default is false
849792
*/
@@ -943,26 +886,7 @@ export interface ForEachState {
943886
/**
944887
* Array of events to be produced before the transition happens
945888
*/
946-
produceEvents?: {
947-
/**
948-
* References a name of a defined event
949-
*/
950-
eventRef: string;
951-
/**
952-
* If String, expression which selects parts of the states data output to become the data of the produced event. If object a custom object to become the data of produced event.
953-
*/
954-
data?:
955-
| string
956-
| {
957-
[k: string]: unknown;
958-
};
959-
/**
960-
* Add additional event extension context attributes
961-
*/
962-
contextAttributes?: {
963-
[k: string]: string;
964-
};
965-
}[];
889+
produceEvents?: ProduceEventsDef;
966890
/**
967891
* If set to true, triggers workflow compensation when before this transition is taken. Default is false
968892
*/
@@ -1057,26 +981,7 @@ export interface CallbackState {
1057981
/**
1058982
* Array of events to be produced before the transition happens
1059983
*/
1060-
produceEvents?: {
1061-
/**
1062-
* References a name of a defined event
1063-
*/
1064-
eventRef: string;
1065-
/**
1066-
* If String, expression which selects parts of the states data output to become the data of the produced event. If object a custom object to become the data of produced event.
1067-
*/
1068-
data?:
1069-
| string
1070-
| {
1071-
[k: string]: unknown;
1072-
};
1073-
/**
1074-
* Add additional event extension context attributes
1075-
*/
1076-
contextAttributes?: {
1077-
[k: string]: string;
1078-
};
1079-
}[];
984+
produceEvents?: ProduceEventsDef;
1080985
/**
1081986
* If set to true, triggers workflow compensation when before this transition is taken. Default is false
1082987
*/

0 commit comments

Comments
 (0)