@schemeless/event-store-types 3.2.1 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/EventStore.types.d.ts +27 -13
- package/package.json +2 -2
|
@@ -43,14 +43,14 @@ export interface CreatedEvent<Payload, META extends EventMeta = EventMeta> exten
|
|
|
43
43
|
export interface StoredEvent<Payload, META extends EventMeta = EventMeta> extends CreatedEvent<Payload, META> {
|
|
44
44
|
}
|
|
45
45
|
export type Event<Payload, META extends EventMeta = EventMeta> = StoredEvent<Payload, META>;
|
|
46
|
-
export interface EventFlow<PartialPayload = any, Payload extends PartialPayload = PartialPayload> {
|
|
46
|
+
export interface EventFlow<PartialPayload = any, Payload extends PartialPayload = PartialPayload, META extends EventMeta = EventMeta> {
|
|
47
47
|
readonly domain: string;
|
|
48
48
|
readonly type: string;
|
|
49
49
|
readonly description?: string;
|
|
50
50
|
readonly meta?: {
|
|
51
51
|
readonly sideEffectFailedRetryAllowed?: number;
|
|
52
52
|
};
|
|
53
|
-
readonly eventType?: CreatedEvent<Payload>;
|
|
53
|
+
readonly eventType?: CreatedEvent<Payload, META>;
|
|
54
54
|
readonly payloadType?: PartialPayload | Payload;
|
|
55
55
|
readonly samplePayload?: PartialPayload | Payload;
|
|
56
56
|
/**
|
|
@@ -67,7 +67,7 @@ export interface EventFlow<PartialPayload = any, Payload extends PartialPayload
|
|
|
67
67
|
* @param fromVersion - The version stored in event.meta.schemaVersion (defaults to 1)
|
|
68
68
|
* @returns Updated event with migrated payload, or void to use the original
|
|
69
69
|
*/
|
|
70
|
-
readonly upcast?: (event: CreatedEvent<any>, fromVersion: number) => CreatedEvent<Payload> | Promise<CreatedEvent<Payload>> | void;
|
|
70
|
+
readonly upcast?: (event: CreatedEvent<any, META>, fromVersion: number) => CreatedEvent<Payload, META> | Promise<CreatedEvent<Payload, META>> | void;
|
|
71
71
|
/**
|
|
72
72
|
* Extract the shard key for event routing.
|
|
73
73
|
* Events with the same shard key will be processed sequentially in the same partition.
|
|
@@ -78,16 +78,16 @@ export interface EventFlow<PartialPayload = any, Payload extends PartialPayload
|
|
|
78
78
|
* @example
|
|
79
79
|
* getShardKey: (event) => event.payload.userId
|
|
80
80
|
*/
|
|
81
|
-
readonly getShardKey?: (event: BaseEvent<Payload>) => string | undefined;
|
|
81
|
+
readonly getShardKey?: (event: BaseEvent<Payload, META>) => string | undefined;
|
|
82
82
|
readonly receive: (eventStore: {
|
|
83
|
-
receive: (eventFlow: EventFlow<PartialPayload, Payload>) => (eventInput: BaseEventInput<PartialPayload>) => Promise<[CreatedEvent<Payload>, ...Array<CreatedEvent<any>>]>;
|
|
84
|
-
}) => (eventInputArgs: BaseEventInput<PartialPayload>) => Promise<[CreatedEvent<Payload>, ...Array<CreatedEvent<any>>]>;
|
|
85
|
-
readonly validate?: (event: CreatedEvent<Payload>) => Promise<Error | void> | Error | void;
|
|
86
|
-
readonly preApply?: (event: CreatedEvent<PartialPayload>) => Promise<CreatedEvent<Payload> | void> | CreatedEvent<Payload> | void;
|
|
87
|
-
readonly apply?: (event: CreatedEvent<Payload>) => Promise<void> | void;
|
|
88
|
-
readonly sideEffect?: (event: CreatedEvent<Payload>) => Promise<void | BaseEvent<any>[]> | void | BaseEvent<any>[];
|
|
89
|
-
readonly cancelApply?: (event: CreatedEvent<Payload>) => Promise<void> | void;
|
|
90
|
-
readonly createConsequentEvents?: (causalEvent: CreatedEvent<Payload>) => Promise<BaseEvent<any>[]> | BaseEvent<any>[];
|
|
83
|
+
receive: (eventFlow: EventFlow<PartialPayload, Payload, META>) => (eventInput: BaseEventInput<PartialPayload, META>) => Promise<[CreatedEvent<Payload, META>, ...Array<CreatedEvent<any>>]>;
|
|
84
|
+
}) => (eventInputArgs: BaseEventInput<PartialPayload, META>) => Promise<[CreatedEvent<Payload, META>, ...Array<CreatedEvent<any>>]>;
|
|
85
|
+
readonly validate?: (event: CreatedEvent<Payload, META>) => Promise<Error | void> | Error | void;
|
|
86
|
+
readonly preApply?: (event: CreatedEvent<PartialPayload, META>) => Promise<CreatedEvent<Payload, META> | void> | CreatedEvent<Payload, META> | void;
|
|
87
|
+
readonly apply?: (event: CreatedEvent<Payload, META>) => Promise<void> | void;
|
|
88
|
+
readonly sideEffect?: (event: CreatedEvent<Payload, META>) => Promise<void | BaseEvent<any>[]> | void | BaseEvent<any>[];
|
|
89
|
+
readonly cancelApply?: (event: CreatedEvent<Payload, META>) => Promise<void> | void;
|
|
90
|
+
readonly createConsequentEvents?: (causalEvent: CreatedEvent<Payload, META>) => Promise<BaseEvent<any>[]> | BaseEvent<any>[];
|
|
91
91
|
/**
|
|
92
92
|
* Generates compensating event(s) to reverse this event's effects.
|
|
93
93
|
* Called by the framework during revert operations.
|
|
@@ -99,7 +99,21 @@ export interface EventFlow<PartialPayload = any, Payload extends PartialPayload
|
|
|
99
99
|
* @param originalEvent - The event being reverted
|
|
100
100
|
* @returns Compensating event(s) to persist
|
|
101
101
|
*/
|
|
102
|
-
readonly compensate?: (originalEvent: CreatedEvent<Payload>) => BaseEvent<any> | BaseEvent<any>[];
|
|
102
|
+
readonly compensate?: (originalEvent: CreatedEvent<Payload, META>) => BaseEvent<any> | BaseEvent<any>[];
|
|
103
|
+
}
|
|
104
|
+
export interface AggregateConfig<State> {
|
|
105
|
+
readonly reducer: (state: State, event: CreatedEvent<any>) => State;
|
|
106
|
+
readonly initialState: State;
|
|
107
|
+
readonly getIdentifier?: (event: BaseEvent<any>) => string | undefined;
|
|
108
|
+
}
|
|
109
|
+
export interface AggregateEventFlow<PartialPayload = any, Payload extends PartialPayload = PartialPayload, State = any, META extends EventMeta = EventMeta> extends Omit<EventFlow<PartialPayload, Payload, META>, 'validate' | 'apply'> {
|
|
110
|
+
readonly aggregate: AggregateConfig<State>;
|
|
111
|
+
readonly validate?: (event: CreatedEvent<Payload, META>, state: State) => Promise<Error | void> | Error | void;
|
|
112
|
+
readonly apply?: (event: CreatedEvent<Payload, META>, state: State) => State | Promise<State>;
|
|
113
|
+
}
|
|
114
|
+
export interface AggregateEventObserver<Payload = any, State = any> extends Omit<SuccessEventObserver<Payload>, 'apply'> {
|
|
115
|
+
readonly aggregate: true;
|
|
116
|
+
readonly apply?: (event: CreatedEvent<Payload>, state: State) => Promise<void> | void;
|
|
103
117
|
}
|
|
104
118
|
export type EventTaskAndError = {
|
|
105
119
|
task: CreatedEvent<any>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@schemeless/event-store-types",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.0",
|
|
4
4
|
"typescript:main": "src/index.ts",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -34,5 +34,5 @@
|
|
|
34
34
|
"publishConfig": {
|
|
35
35
|
"access": "public"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "92568fe932ab2dc550ba5795789b3fa602d3ce37"
|
|
38
38
|
}
|