Skip to content

Commit 53a059b

Browse files
antmendozatsurdilo
authored andcommitted
refactored EventData
Signed-off-by: Antonio Mendoza Pérez <[email protected]>
1 parent cfe1cea commit 53a059b

File tree

3 files changed

+21
-14
lines changed

3 files changed

+21
-14
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ describe("ProduceEventDefBuilder", () => {
3232
it("should build a valid ProduceEventDef object ", () => {
3333

3434
expect(new ProduceEventDefBuilder()
35-
.withEventRef("eventName")
36-
.withData({kData: "kdValue"})
35+
.withEventRef("ConfirmationCompletedEvent")
36+
.withData("${ .payment }")
3737
.withContextAttributes({
3838
kContext: "kcValue",
3939
})
4040
.build())
4141
.toEqual({
42-
eventRef: "eventName",
43-
data: {kData: "kdValue"},
42+
eventRef: "ConfirmationCompletedEvent",
43+
data: "${ .payment }",
4444
contextAttributes: {
4545
kContext: "kcValue",
4646
},

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

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

1919
export class ProduceEventDefBuilder {
2020
// @ts-ignore
@@ -26,7 +26,7 @@ export class ProduceEventDefBuilder {
2626
return this;
2727
}
2828

29-
withData(value: object): ProduceEventDefBuilder {
29+
withData(value: EventData): ProduceEventDefBuilder {
3030
this.model.data = value;
3131
return this;
3232

src/model/types.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,11 @@ export type EventRefType = {
6060
/**
6161
* If string type, an expression which selects parts of the states data output to become the data (payload) of the event referenced by 'triggerEventRef'. If object type, a custom object to become the data (payload) of the event referenced by 'triggerEventRef'.
6262
*/
63-
data?:
64-
| string
65-
| object;
63+
data?: EventData;
6664
/**
6765
* Add additional extension context attributes to the produced event
6866
*/
69-
contextAttributes?: object;
67+
contextAttributes?: ContextAttributes;
7068
};
7169

7270
export type ActionDataFilterType = {
@@ -340,6 +338,17 @@ export type CronDef =
340338
validUntil?: string;
341339
};
342340
export type Interval = string;
341+
342+
export type ExpressionExtractData = string;
343+
344+
export type DataObject = object;
345+
346+
export type EventData =
347+
| ExpressionExtractData
348+
| DataObject;
349+
350+
export type ContextAttributes = object;
351+
343352
export type ProduceEventDef = {
344353
/**
345354
* References a name of a defined event
@@ -348,12 +357,10 @@ export type ProduceEventDef = {
348357
/**
349358
* 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.
350359
*/
351-
data?:
352-
| string
353-
| object;
360+
data?: EventData;
354361
/**
355362
* Add additional event extension context attributes
356363
*/
357-
contextAttributes?: object;
364+
contextAttributes?: ContextAttributes;
358365
};
359366
export type ProduceEventsDef = ProduceEventDef[];

0 commit comments

Comments
 (0)