@zeeshan60/event-processor 1.0.11 → 1.0.13
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/ActivityEventHandler.d.ts +4 -4
- package/dist/ActivityEventHandler.d.ts.map +1 -1
- package/dist/ActivityLogEvents.d.ts +4 -2
- package/dist/ActivityLogEvents.d.ts.map +1 -1
- package/dist/ActivityLogEvents.js +1 -0
- package/dist/EventProcessorSDK.d.ts +22 -18
- package/dist/EventProcessorSDK.d.ts.map +1 -1
- package/dist/EventProcessorSDK.js +15 -4
- package/dist/FriendEventHandler.d.ts +4 -12
- package/dist/FriendEventHandler.d.ts.map +1 -1
- package/dist/FriendEventHandler.js +22 -54
- package/dist/FriendEvents.d.ts +13 -3
- package/dist/FriendEvents.d.ts.map +1 -1
- package/dist/FriendEvents.js +16 -7
- package/dist/GroupEventHandler.d.ts +7 -7
- package/dist/GroupEventHandler.d.ts.map +1 -1
- package/dist/GroupEventHandler.js +21 -12
- package/dist/GroupEvents.d.ts +15 -3
- package/dist/GroupEvents.d.ts.map +1 -1
- package/dist/GroupEvents.js +25 -13
- package/dist/GroupTransactionEventHandler.d.ts +7 -7
- package/dist/GroupTransactionEventHandler.d.ts.map +1 -1
- package/dist/GroupTransactionEventHandler.js +23 -16
- package/dist/GroupTransactionEvents.d.ts +22 -4
- package/dist/GroupTransactionEvents.d.ts.map +1 -1
- package/dist/GroupTransactionEvents.js +39 -21
- package/dist/TransactionEventHandler.d.ts +2 -5
- package/dist/TransactionEventHandler.d.ts.map +1 -1
- package/dist/TransactionEventHandler.js +29 -13
- package/dist/TransactionEvents.d.ts +24 -8
- package/dist/TransactionEvents.d.ts.map +1 -1
- package/dist/TransactionEvents.js +38 -22
- package/dist/UserEventHandler.d.ts +3 -11
- package/dist/UserEventHandler.d.ts.map +1 -1
- package/dist/UserEventHandler.js +64 -62
- package/dist/UserEvents.d.ts +20 -3
- package/dist/UserEvents.d.ts.map +1 -1
- package/dist/UserEvents.js +53 -18
- package/dist/__tests__/e2e/setup/firebaseEmulator.d.ts +3 -0
- package/dist/__tests__/e2e/setup/firebaseEmulator.d.ts.map +1 -0
- package/dist/__tests__/e2e/setup/firebaseEmulator.js +87 -0
- package/dist/__tests__/e2e/setup/firestoreStores.d.ts +28 -0
- package/dist/__tests__/e2e/setup/firestoreStores.d.ts.map +1 -0
- package/dist/__tests__/e2e/setup/firestoreStores.js +276 -0
- package/dist/__tests__/e2e/setup/firestoreTestHelpers.d.ts +15 -0
- package/dist/__tests__/e2e/setup/firestoreTestHelpers.d.ts.map +1 -0
- package/dist/__tests__/e2e/setup/firestoreTestHelpers.js +167 -0
- package/dist/__tests__/test-helpers/IMActivityLogEventStore.d.ts +2 -2
- package/dist/__tests__/test-helpers/IMActivityLogEventStore.d.ts.map +1 -1
- package/dist/__tests__/test-helpers/IMActivityLogModelStore.d.ts +2 -2
- package/dist/__tests__/test-helpers/IMActivityLogModelStore.d.ts.map +1 -1
- package/dist/__tests__/test-helpers/IMFriendEventStore.d.ts +2 -2
- package/dist/__tests__/test-helpers/IMFriendEventStore.d.ts.map +1 -1
- package/dist/__tests__/test-helpers/IMFriendModelStore.d.ts +3 -2
- package/dist/__tests__/test-helpers/IMFriendModelStore.d.ts.map +1 -1
- package/dist/__tests__/test-helpers/IMFriendModelStore.js +9 -0
- package/dist/__tests__/test-helpers/IMGroupEventStore.d.ts +2 -2
- package/dist/__tests__/test-helpers/IMGroupEventStore.d.ts.map +1 -1
- package/dist/__tests__/test-helpers/IMGroupModelStore.d.ts +2 -2
- package/dist/__tests__/test-helpers/IMGroupModelStore.d.ts.map +1 -1
- package/dist/__tests__/test-helpers/IMGroupTransactionEventStore.d.ts +2 -2
- package/dist/__tests__/test-helpers/IMGroupTransactionEventStore.d.ts.map +1 -1
- package/dist/__tests__/test-helpers/IMGroupTransactionModelStore.d.ts +2 -2
- package/dist/__tests__/test-helpers/IMGroupTransactionModelStore.d.ts.map +1 -1
- package/dist/__tests__/test-helpers/IMTransactionEventStore.d.ts +2 -2
- package/dist/__tests__/test-helpers/IMTransactionEventStore.d.ts.map +1 -1
- package/dist/__tests__/test-helpers/IMTransactionModelStore.d.ts +2 -2
- package/dist/__tests__/test-helpers/IMTransactionModelStore.d.ts.map +1 -1
- package/dist/__tests__/test-helpers/IMUserEventStore.d.ts +2 -2
- package/dist/__tests__/test-helpers/IMUserEventStore.d.ts.map +1 -1
- package/dist/__tests__/test-helpers/IMUserModelStore.d.ts +2 -2
- package/dist/__tests__/test-helpers/IMUserModelStore.d.ts.map +1 -1
- package/dist/__tests__/test-helpers/MockFirebaseAdapter.d.ts +2 -1
- package/dist/__tests__/test-helpers/MockFirebaseAdapter.d.ts.map +1 -1
- package/dist/__tests__/test-helpers/MockFirebaseAdapter.js +5 -1
- package/dist/client/controllers/FriendController.d.ts +12 -0
- package/dist/client/controllers/FriendController.d.ts.map +1 -0
- package/dist/client/controllers/FriendController.js +122 -0
- package/dist/client/controllers/UserController.d.ts +6 -5
- package/dist/client/controllers/UserController.d.ts.map +1 -1
- package/dist/client/controllers/UserController.js +94 -7
- package/dist/client/handlers/UIEventHandler.d.ts +1 -1
- package/dist/client/handlers/UIEventHandler.d.ts.map +1 -1
- package/dist/client/handlers/UIEventHandler.js +4 -2
- package/dist/client/handlers/UIFriendEventHandler.d.ts +6 -6
- package/dist/client/handlers/UIFriendEventHandler.d.ts.map +1 -1
- package/dist/client/handlers/UIGroupEventHandler.d.ts +7 -7
- package/dist/client/handlers/UIGroupEventHandler.d.ts.map +1 -1
- package/dist/client/handlers/UIGroupTransactionEventHandler.d.ts +7 -7
- package/dist/client/handlers/UIGroupTransactionEventHandler.d.ts.map +1 -1
- package/dist/client/handlers/UITransactionEventHandler.d.ts +5 -5
- package/dist/client/handlers/UITransactionEventHandler.d.ts.map +1 -1
- package/dist/client/handlers/UIUserEventHandler.d.ts +4 -4
- package/dist/client/handlers/UIUserEventHandler.d.ts.map +1 -1
- package/dist/common/DomainEvents.d.ts +1 -1
- package/dist/common/DomainEvents.d.ts.map +1 -1
- package/dist/common/DomainEvents.js +37 -37
- package/dist/common/Event.d.ts +3 -2
- package/dist/common/Event.d.ts.map +1 -1
- package/dist/common/EventBus.d.ts +2 -2
- package/dist/common/EventBus.d.ts.map +1 -1
- package/dist/common/EventBusSingleton.d.ts +1 -1
- package/dist/common/Model.d.ts.map +1 -1
- package/dist/common/index.d.ts +2 -2
- package/dist/contracts/common/index.d.ts.map +1 -1
- package/dist/contracts/expenses/index.d.ts.map +1 -1
- package/dist/contracts/friends/index.d.ts.map +1 -1
- package/dist/contracts/groups/index.d.ts.map +1 -1
- package/dist/contracts/index.d.ts +1 -0
- package/dist/contracts/index.d.ts.map +1 -1
- package/dist/contracts/index.js +1 -0
- package/dist/contracts/shared/index.d.ts.map +1 -1
- package/dist/contracts/transactions/index.d.ts.map +1 -1
- package/dist/contracts/users/index.d.ts +15 -0
- package/dist/contracts/users/index.d.ts.map +1 -0
- package/dist/contracts/users/index.js +2 -0
- package/dist/converters/eventConverter.d.ts +3 -3
- package/dist/converters/eventConverter.d.ts.map +1 -1
- package/dist/converters/eventConverter.js +67 -50
- package/dist/events.d.ts +29 -29
- package/dist/events.d.ts.map +1 -1
- package/dist/index.d.ts +18 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -2
- package/dist/store/ActivityLogEventStore.d.ts +1 -1
- package/dist/store/ActivityLogEventStore.d.ts.map +1 -1
- package/dist/store/ActivityLogModelStore.d.ts +2 -2
- package/dist/store/ActivityLogModelStore.d.ts.map +1 -1
- package/dist/store/FriendEventStore.d.ts +1 -1
- package/dist/store/FriendEventStore.d.ts.map +1 -1
- package/dist/store/FriendModelStore.d.ts +3 -2
- package/dist/store/FriendModelStore.d.ts.map +1 -1
- package/dist/store/GroupEventStore.d.ts +1 -1
- package/dist/store/GroupEventStore.d.ts.map +1 -1
- package/dist/store/GroupModelStore.d.ts +2 -2
- package/dist/store/GroupModelStore.d.ts.map +1 -1
- package/dist/store/GroupTransactionEventStore.d.ts +1 -1
- package/dist/store/GroupTransactionEventStore.d.ts.map +1 -1
- package/dist/store/GroupTransactionModelStore.d.ts +2 -2
- package/dist/store/GroupTransactionModelStore.d.ts.map +1 -1
- package/dist/store/ModelStore.d.ts +1 -1
- package/dist/store/ModelStore.d.ts.map +1 -1
- package/dist/store/TransactionEventStore.d.ts +1 -1
- package/dist/store/TransactionEventStore.d.ts.map +1 -1
- package/dist/store/TransactionModelStore.d.ts +2 -2
- package/dist/store/TransactionModelStore.d.ts.map +1 -1
- package/dist/store/UserEventStore.d.ts +1 -1
- package/dist/store/UserEventStore.d.ts.map +1 -1
- package/dist/store/UserModelStore.d.ts +2 -2
- package/dist/store/UserModelStore.d.ts.map +1 -1
- package/dist/utils/splitTypeUtils.d.ts +1 -1
- package/dist/utils/splitTypeUtils.d.ts.map +1 -1
- package/dist/utils/userPathUtils.d.ts +1 -1
- package/dist/utils/userPathUtils.d.ts.map +1 -1
- package/dist/utils/userPathUtils.js +3 -3
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { TransactionEvent } from
|
|
2
|
-
import { Model } from
|
|
3
|
-
import { ActivityLogCreatedProps } from
|
|
1
|
+
import { TransactionEvent } from "./common/DomainEvents";
|
|
2
|
+
import { Model } from "./common/Model";
|
|
3
|
+
import { ActivityLogCreatedProps } from "./ActivityLogEvents";
|
|
4
4
|
export declare enum SplitType {
|
|
5
5
|
YouPaidSplitEqually = "YouPaidSplitEqually",
|
|
6
6
|
TheyPaidSplitEqually = "TheyPaidSplitEqually",
|
|
@@ -21,27 +21,27 @@ export interface ChangeHistoryBase {
|
|
|
21
21
|
changedBy: string;
|
|
22
22
|
}
|
|
23
23
|
export interface DescriptionUpdated extends ChangeHistoryBase {
|
|
24
|
-
type:
|
|
24
|
+
type: "DESCRIPTION_UPDATED";
|
|
25
25
|
oldValue: string;
|
|
26
26
|
newValue: string;
|
|
27
27
|
}
|
|
28
28
|
export interface AmountUpdated extends ChangeHistoryBase {
|
|
29
|
-
type:
|
|
29
|
+
type: "AMOUNT_UPDATED";
|
|
30
30
|
oldValue: number;
|
|
31
31
|
newValue: number;
|
|
32
32
|
}
|
|
33
33
|
export interface CurrencyUpdated extends ChangeHistoryBase {
|
|
34
|
-
type:
|
|
34
|
+
type: "CURRENCY_UPDATED";
|
|
35
35
|
oldValue: string;
|
|
36
36
|
newValue: string;
|
|
37
37
|
}
|
|
38
38
|
export interface SplitTypeUpdated extends ChangeHistoryBase {
|
|
39
|
-
type:
|
|
39
|
+
type: "SPLIT_TYPE_UPDATED";
|
|
40
40
|
oldValue: SplitType;
|
|
41
41
|
newValue: SplitType;
|
|
42
42
|
}
|
|
43
43
|
export interface TransactionDateUpdated extends ChangeHistoryBase {
|
|
44
|
-
type:
|
|
44
|
+
type: "TRANSACTION_DATE_UPDATED";
|
|
45
45
|
oldValue: Date;
|
|
46
46
|
newValue: Date;
|
|
47
47
|
}
|
|
@@ -71,6 +71,7 @@ export interface TransactionModel extends Model {
|
|
|
71
71
|
history: ChangeHistory;
|
|
72
72
|
}
|
|
73
73
|
export interface TransactionCreatedProps {
|
|
74
|
+
eventId: string;
|
|
74
75
|
userId: string;
|
|
75
76
|
recipientUserId: string;
|
|
76
77
|
logicalTransactionId: string;
|
|
@@ -90,6 +91,7 @@ export interface TransactionCreatedProps {
|
|
|
90
91
|
systemGenerated: boolean;
|
|
91
92
|
}
|
|
92
93
|
export declare class TransactionCreated implements TransactionEvent {
|
|
94
|
+
eventId: string;
|
|
93
95
|
userId: string;
|
|
94
96
|
recipientUserId: string;
|
|
95
97
|
logicalTransactionId: string;
|
|
@@ -112,6 +114,7 @@ export declare class TransactionCreated implements TransactionEvent {
|
|
|
112
114
|
activityLog(_existing?: Model, actorName?: string): ActivityLogCreatedProps | undefined;
|
|
113
115
|
}
|
|
114
116
|
export interface TransactionDeletedProps {
|
|
117
|
+
eventId: string;
|
|
115
118
|
userId: string;
|
|
116
119
|
streamId: string;
|
|
117
120
|
version: number;
|
|
@@ -120,6 +123,7 @@ export interface TransactionDeletedProps {
|
|
|
120
123
|
systemGenerated: boolean;
|
|
121
124
|
}
|
|
122
125
|
export declare class TransactionDeleted implements TransactionEvent {
|
|
126
|
+
eventId: string;
|
|
123
127
|
userId: string;
|
|
124
128
|
streamId: string;
|
|
125
129
|
version: number;
|
|
@@ -131,6 +135,7 @@ export declare class TransactionDeleted implements TransactionEvent {
|
|
|
131
135
|
activityLog(existing?: Model, actorName?: string): ActivityLogCreatedProps | undefined;
|
|
132
136
|
}
|
|
133
137
|
export interface DescriptionChangedProps {
|
|
138
|
+
eventId: string;
|
|
134
139
|
userId: string;
|
|
135
140
|
description: string;
|
|
136
141
|
streamId: string;
|
|
@@ -140,6 +145,7 @@ export interface DescriptionChangedProps {
|
|
|
140
145
|
systemGenerated: boolean;
|
|
141
146
|
}
|
|
142
147
|
export declare class DescriptionChanged implements TransactionEvent {
|
|
148
|
+
eventId: string;
|
|
143
149
|
userId: string;
|
|
144
150
|
description: string;
|
|
145
151
|
streamId: string;
|
|
@@ -152,6 +158,7 @@ export declare class DescriptionChanged implements TransactionEvent {
|
|
|
152
158
|
activityLog(existing?: Model, actorName?: string): ActivityLogCreatedProps | undefined;
|
|
153
159
|
}
|
|
154
160
|
export interface TotalAmountChangedProps {
|
|
161
|
+
eventId: string;
|
|
155
162
|
userId: string;
|
|
156
163
|
totalAmount: number;
|
|
157
164
|
streamId: string;
|
|
@@ -161,6 +168,7 @@ export interface TotalAmountChangedProps {
|
|
|
161
168
|
systemGenerated: boolean;
|
|
162
169
|
}
|
|
163
170
|
export declare class TotalAmountChanged implements TransactionEvent {
|
|
171
|
+
eventId: string;
|
|
164
172
|
userId: string;
|
|
165
173
|
totalAmount: number;
|
|
166
174
|
streamId: string;
|
|
@@ -173,6 +181,7 @@ export declare class TotalAmountChanged implements TransactionEvent {
|
|
|
173
181
|
activityLog(existing?: Model, actorName?: string): ActivityLogCreatedProps | undefined;
|
|
174
182
|
}
|
|
175
183
|
export interface SplitTypeChangedProps {
|
|
184
|
+
eventId: string;
|
|
176
185
|
userId: string;
|
|
177
186
|
splitType: SplitType;
|
|
178
187
|
totalAmount: number;
|
|
@@ -185,6 +194,7 @@ export interface SplitTypeChangedProps {
|
|
|
185
194
|
systemGenerated: boolean;
|
|
186
195
|
}
|
|
187
196
|
export declare class SplitTypeChanged implements TransactionEvent {
|
|
197
|
+
eventId: string;
|
|
188
198
|
userId: string;
|
|
189
199
|
splitType: SplitType;
|
|
190
200
|
totalAmount: number;
|
|
@@ -200,6 +210,7 @@ export declare class SplitTypeChanged implements TransactionEvent {
|
|
|
200
210
|
activityLog(existing?: Model, actorName?: string): ActivityLogCreatedProps | undefined;
|
|
201
211
|
}
|
|
202
212
|
export interface CurrencyChangedProps {
|
|
213
|
+
eventId: string;
|
|
203
214
|
userId: string;
|
|
204
215
|
currency: string;
|
|
205
216
|
streamId: string;
|
|
@@ -209,6 +220,7 @@ export interface CurrencyChangedProps {
|
|
|
209
220
|
systemGenerated: boolean;
|
|
210
221
|
}
|
|
211
222
|
export declare class CurrencyChanged implements TransactionEvent {
|
|
223
|
+
eventId: string;
|
|
212
224
|
userId: string;
|
|
213
225
|
currency: string;
|
|
214
226
|
streamId: string;
|
|
@@ -221,6 +233,7 @@ export declare class CurrencyChanged implements TransactionEvent {
|
|
|
221
233
|
activityLog(existing?: Model, actorName?: string): ActivityLogCreatedProps | undefined;
|
|
222
234
|
}
|
|
223
235
|
export interface TransactionDateChangedProps {
|
|
236
|
+
eventId: string;
|
|
224
237
|
userId: string;
|
|
225
238
|
transactionDate: Date;
|
|
226
239
|
streamId: string;
|
|
@@ -230,6 +243,7 @@ export interface TransactionDateChangedProps {
|
|
|
230
243
|
systemGenerated: boolean;
|
|
231
244
|
}
|
|
232
245
|
export declare class TransactionDateChanged implements TransactionEvent {
|
|
246
|
+
eventId: string;
|
|
233
247
|
userId: string;
|
|
234
248
|
transactionDate: Date;
|
|
235
249
|
streamId: string;
|
|
@@ -242,6 +256,7 @@ export declare class TransactionDateChanged implements TransactionEvent {
|
|
|
242
256
|
activityLog(existing?: Model, actorName?: string): ActivityLogCreatedProps | undefined;
|
|
243
257
|
}
|
|
244
258
|
export interface TransactionDetailsChangedProps {
|
|
259
|
+
eventId: string;
|
|
245
260
|
userId: string;
|
|
246
261
|
totalAmount: number;
|
|
247
262
|
amount: number;
|
|
@@ -253,6 +268,7 @@ export interface TransactionDetailsChangedProps {
|
|
|
253
268
|
systemGenerated: boolean;
|
|
254
269
|
}
|
|
255
270
|
export declare class TransactionDetailsChanged implements TransactionEvent {
|
|
271
|
+
eventId: string;
|
|
256
272
|
userId: string;
|
|
257
273
|
totalAmount: number;
|
|
258
274
|
amount: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TransactionEvents.d.ts","sourceRoot":"","sources":["../src/TransactionEvents.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAyB,MAAM,uBAAuB,CAAC;AAChF,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,uBAAuB,EAAc,MAAM,qBAAqB,CAAC;AAI1E,oBAAY,SAAS;
|
|
1
|
+
{"version":3,"file":"TransactionEvents.d.ts","sourceRoot":"","sources":["../src/TransactionEvents.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAyB,MAAM,uBAAuB,CAAC;AAChF,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,uBAAuB,EAAc,MAAM,qBAAqB,CAAC;AAI1E,oBAAY,SAAS;IACjB,mBAAmB,wBAAwB;IAC3C,oBAAoB,yBAAyB;IAC7C,aAAa,kBAAkB;IAC/B,aAAa,kBAAkB;IAC/B,gBAAgB,qBAAqB;IACrC,eAAe,oBAAoB;IACnC,eAAe,oBAAoB;CACtC;AAGD,MAAM,WAAW,SAAS;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,MAA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ventId = props.eventId;
|
|
27
28
|
this.userId = props.userId;
|
|
28
29
|
this.recipientUserId = props.recipientUserId;
|
|
29
30
|
this.logicalTransactionId = props.logicalTransactionId;
|
|
@@ -67,9 +68,10 @@ class TransactionCreated {
|
|
|
67
68
|
};
|
|
68
69
|
}
|
|
69
70
|
activityLog(_existing, actorName) {
|
|
70
|
-
const actor = actorName ??
|
|
71
|
+
const actor = actorName ?? "You";
|
|
71
72
|
const logMessage = `${actor} created transaction "${this.description}" for ${this.totalAmount} ${this.currency}`;
|
|
72
73
|
return {
|
|
74
|
+
eventId: (0, uuid_1.v4)(),
|
|
73
75
|
userId: this.userId,
|
|
74
76
|
activityByUid: this.createdBy,
|
|
75
77
|
sourceStreamId: this.streamId,
|
|
@@ -87,6 +89,7 @@ class TransactionCreated {
|
|
|
87
89
|
exports.TransactionCreated = TransactionCreated;
|
|
88
90
|
class TransactionDeleted {
|
|
89
91
|
constructor(props) {
|
|
92
|
+
this.eventId = props.eventId;
|
|
90
93
|
this.userId = props.userId;
|
|
91
94
|
this.streamId = props.streamId;
|
|
92
95
|
this.version = props.version;
|
|
@@ -96,7 +99,7 @@ class TransactionDeleted {
|
|
|
96
99
|
}
|
|
97
100
|
apply(existing) {
|
|
98
101
|
if (!existing) {
|
|
99
|
-
throw new Error(
|
|
102
|
+
throw new Error("TransactionModel is required for deletion");
|
|
100
103
|
}
|
|
101
104
|
const existingTx = existing;
|
|
102
105
|
return {
|
|
@@ -112,9 +115,10 @@ class TransactionDeleted {
|
|
|
112
115
|
return undefined;
|
|
113
116
|
}
|
|
114
117
|
const existingTx = existing;
|
|
115
|
-
const actor = actorName ??
|
|
118
|
+
const actor = actorName ?? "You";
|
|
116
119
|
const logMessage = `${actor} deleted transaction "${existingTx.description}"`;
|
|
117
120
|
return {
|
|
121
|
+
eventId: (0, uuid_1.v4)(),
|
|
118
122
|
userId: existingTx.userId,
|
|
119
123
|
activityByUid: this.createdBy,
|
|
120
124
|
sourceStreamId: this.streamId,
|
|
@@ -132,6 +136,7 @@ class TransactionDeleted {
|
|
|
132
136
|
exports.TransactionDeleted = TransactionDeleted;
|
|
133
137
|
class DescriptionChanged {
|
|
134
138
|
constructor(props) {
|
|
139
|
+
this.eventId = props.eventId;
|
|
135
140
|
this.userId = props.userId;
|
|
136
141
|
this.description = props.description;
|
|
137
142
|
this.streamId = props.streamId;
|
|
@@ -142,11 +147,11 @@ class DescriptionChanged {
|
|
|
142
147
|
}
|
|
143
148
|
apply(existing) {
|
|
144
149
|
if (!existing) {
|
|
145
|
-
throw new Error(
|
|
150
|
+
throw new Error("TransactionModel is required");
|
|
146
151
|
}
|
|
147
152
|
const existingTx = existing;
|
|
148
153
|
const descriptionChange = {
|
|
149
|
-
type:
|
|
154
|
+
type: "DESCRIPTION_UPDATED",
|
|
150
155
|
changedAt: this.createdAt,
|
|
151
156
|
changedBy: this.createdBy,
|
|
152
157
|
oldValue: existingTx.description,
|
|
@@ -168,9 +173,10 @@ class DescriptionChanged {
|
|
|
168
173
|
return undefined;
|
|
169
174
|
}
|
|
170
175
|
const existingTx = existing;
|
|
171
|
-
const actor = actorName ??
|
|
176
|
+
const actor = actorName ?? "You";
|
|
172
177
|
const logMessage = `${actor} changed description from "${existingTx.description}" to "${this.description}"`;
|
|
173
178
|
return {
|
|
179
|
+
eventId: (0, uuid_1.v4)(),
|
|
174
180
|
userId: existingTx.userId,
|
|
175
181
|
activityByUid: this.createdBy,
|
|
176
182
|
sourceStreamId: this.streamId,
|
|
@@ -188,6 +194,7 @@ class DescriptionChanged {
|
|
|
188
194
|
exports.DescriptionChanged = DescriptionChanged;
|
|
189
195
|
class TotalAmountChanged {
|
|
190
196
|
constructor(props) {
|
|
197
|
+
this.eventId = props.eventId;
|
|
191
198
|
this.userId = props.userId;
|
|
192
199
|
this.totalAmount = props.totalAmount;
|
|
193
200
|
this.streamId = props.streamId;
|
|
@@ -198,11 +205,11 @@ class TotalAmountChanged {
|
|
|
198
205
|
}
|
|
199
206
|
apply(existing) {
|
|
200
207
|
if (!existing) {
|
|
201
|
-
throw new Error(
|
|
208
|
+
throw new Error("TransactionModel is required");
|
|
202
209
|
}
|
|
203
210
|
const existingTx = existing;
|
|
204
211
|
const amountChange = {
|
|
205
|
-
type:
|
|
212
|
+
type: "AMOUNT_UPDATED",
|
|
206
213
|
changedAt: this.createdAt,
|
|
207
214
|
changedBy: this.createdBy,
|
|
208
215
|
oldValue: existingTx.totalAmount,
|
|
@@ -224,9 +231,10 @@ class TotalAmountChanged {
|
|
|
224
231
|
return undefined;
|
|
225
232
|
}
|
|
226
233
|
const existingTx = existing;
|
|
227
|
-
const actor = actorName ??
|
|
234
|
+
const actor = actorName ?? "You";
|
|
228
235
|
const logMessage = `${actor} changed amount from ${existingTx.totalAmount} ${existingTx.currency} to ${this.totalAmount} ${existingTx.currency}`;
|
|
229
236
|
return {
|
|
237
|
+
eventId: (0, uuid_1.v4)(),
|
|
230
238
|
userId: existingTx.userId,
|
|
231
239
|
activityByUid: this.createdBy,
|
|
232
240
|
sourceStreamId: this.streamId,
|
|
@@ -244,6 +252,7 @@ class TotalAmountChanged {
|
|
|
244
252
|
exports.TotalAmountChanged = TotalAmountChanged;
|
|
245
253
|
class SplitTypeChanged {
|
|
246
254
|
constructor(props) {
|
|
255
|
+
this.eventId = props.eventId;
|
|
247
256
|
this.userId = props.userId;
|
|
248
257
|
this.splitType = props.splitType;
|
|
249
258
|
this.totalAmount = props.totalAmount;
|
|
@@ -257,11 +266,11 @@ class SplitTypeChanged {
|
|
|
257
266
|
}
|
|
258
267
|
apply(existing) {
|
|
259
268
|
if (!existing) {
|
|
260
|
-
throw new Error(
|
|
269
|
+
throw new Error("TransactionModel is required");
|
|
261
270
|
}
|
|
262
271
|
const existingTx = existing;
|
|
263
272
|
const splitTypeChange = {
|
|
264
|
-
type:
|
|
273
|
+
type: "SPLIT_TYPE_UPDATED",
|
|
265
274
|
changedAt: this.createdAt,
|
|
266
275
|
changedBy: this.createdBy,
|
|
267
276
|
oldValue: existingTx.splitType,
|
|
@@ -285,9 +294,10 @@ class SplitTypeChanged {
|
|
|
285
294
|
return undefined;
|
|
286
295
|
}
|
|
287
296
|
const existingTx = existing;
|
|
288
|
-
const actor = actorName ??
|
|
297
|
+
const actor = actorName ?? "You";
|
|
289
298
|
const logMessage = `${actor} changed split type from ${existingTx.splitType} to ${this.splitType}`;
|
|
290
299
|
return {
|
|
300
|
+
eventId: (0, uuid_1.v4)(),
|
|
291
301
|
userId: existingTx.userId,
|
|
292
302
|
activityByUid: this.createdBy,
|
|
293
303
|
sourceStreamId: this.streamId,
|
|
@@ -305,6 +315,7 @@ class SplitTypeChanged {
|
|
|
305
315
|
exports.SplitTypeChanged = SplitTypeChanged;
|
|
306
316
|
class CurrencyChanged {
|
|
307
317
|
constructor(props) {
|
|
318
|
+
this.eventId = props.eventId;
|
|
308
319
|
this.userId = props.userId;
|
|
309
320
|
this.currency = props.currency;
|
|
310
321
|
this.streamId = props.streamId;
|
|
@@ -315,11 +326,11 @@ class CurrencyChanged {
|
|
|
315
326
|
}
|
|
316
327
|
apply(existing) {
|
|
317
328
|
if (!existing) {
|
|
318
|
-
throw new Error(
|
|
329
|
+
throw new Error("TransactionModel is required");
|
|
319
330
|
}
|
|
320
331
|
const existingTx = existing;
|
|
321
332
|
const currencyChange = {
|
|
322
|
-
type:
|
|
333
|
+
type: "CURRENCY_UPDATED",
|
|
323
334
|
changedAt: this.createdAt,
|
|
324
335
|
changedBy: this.createdBy,
|
|
325
336
|
oldValue: existingTx.currency,
|
|
@@ -341,9 +352,10 @@ class CurrencyChanged {
|
|
|
341
352
|
return undefined;
|
|
342
353
|
}
|
|
343
354
|
const existingTx = existing;
|
|
344
|
-
const actor = actorName ??
|
|
355
|
+
const actor = actorName ?? "You";
|
|
345
356
|
const logMessage = `${actor} changed currency from ${existingTx.currency} to ${this.currency}`;
|
|
346
357
|
return {
|
|
358
|
+
eventId: (0, uuid_1.v4)(),
|
|
347
359
|
userId: existingTx.userId,
|
|
348
360
|
activityByUid: this.createdBy,
|
|
349
361
|
sourceStreamId: this.streamId,
|
|
@@ -361,6 +373,7 @@ class CurrencyChanged {
|
|
|
361
373
|
exports.CurrencyChanged = CurrencyChanged;
|
|
362
374
|
class TransactionDateChanged {
|
|
363
375
|
constructor(props) {
|
|
376
|
+
this.eventId = props.eventId;
|
|
364
377
|
this.userId = props.userId;
|
|
365
378
|
this.transactionDate = props.transactionDate;
|
|
366
379
|
this.streamId = props.streamId;
|
|
@@ -371,11 +384,11 @@ class TransactionDateChanged {
|
|
|
371
384
|
}
|
|
372
385
|
apply(existing) {
|
|
373
386
|
if (!existing) {
|
|
374
|
-
throw new Error(
|
|
387
|
+
throw new Error("TransactionModel is required");
|
|
375
388
|
}
|
|
376
389
|
const existingTx = existing;
|
|
377
390
|
const dateChange = {
|
|
378
|
-
type:
|
|
391
|
+
type: "TRANSACTION_DATE_UPDATED",
|
|
379
392
|
changedAt: this.createdAt,
|
|
380
393
|
changedBy: this.createdBy,
|
|
381
394
|
oldValue: existingTx.transactionDate,
|
|
@@ -397,9 +410,10 @@ class TransactionDateChanged {
|
|
|
397
410
|
return undefined;
|
|
398
411
|
}
|
|
399
412
|
const existingTx = existing;
|
|
400
|
-
const actor = actorName ??
|
|
413
|
+
const actor = actorName ?? "You";
|
|
401
414
|
const logMessage = `${actor} changed transaction date from ${existingTx.transactionDate.toLocaleDateString()} to ${this.transactionDate.toLocaleDateString()}`;
|
|
402
415
|
return {
|
|
416
|
+
eventId: (0, uuid_1.v4)(),
|
|
403
417
|
userId: existingTx.userId,
|
|
404
418
|
activityByUid: this.createdBy,
|
|
405
419
|
sourceStreamId: this.streamId,
|
|
@@ -417,6 +431,7 @@ class TransactionDateChanged {
|
|
|
417
431
|
exports.TransactionDateChanged = TransactionDateChanged;
|
|
418
432
|
class TransactionDetailsChanged {
|
|
419
433
|
constructor(props) {
|
|
434
|
+
this.eventId = props.eventId;
|
|
420
435
|
this.userId = props.userId;
|
|
421
436
|
this.totalAmount = props.totalAmount;
|
|
422
437
|
this.amount = props.amount;
|
|
@@ -429,13 +444,13 @@ class TransactionDetailsChanged {
|
|
|
429
444
|
}
|
|
430
445
|
apply(existing) {
|
|
431
446
|
if (!existing) {
|
|
432
|
-
throw new Error(
|
|
447
|
+
throw new Error("TransactionModel is required");
|
|
433
448
|
}
|
|
434
449
|
const existingTx = existing;
|
|
435
450
|
const changes = [];
|
|
436
451
|
if (existingTx.totalAmount !== this.totalAmount) {
|
|
437
452
|
const totalAmountChange = {
|
|
438
|
-
type:
|
|
453
|
+
type: "AMOUNT_UPDATED",
|
|
439
454
|
changedAt: this.createdAt,
|
|
440
455
|
changedBy: this.createdBy,
|
|
441
456
|
oldValue: existingTx.totalAmount,
|
|
@@ -445,7 +460,7 @@ class TransactionDetailsChanged {
|
|
|
445
460
|
}
|
|
446
461
|
if (existingTx.amount !== this.amount) {
|
|
447
462
|
const amountChange = {
|
|
448
|
-
type:
|
|
463
|
+
type: "AMOUNT_UPDATED",
|
|
449
464
|
changedAt: this.createdAt,
|
|
450
465
|
changedBy: this.createdBy,
|
|
451
466
|
oldValue: existingTx.amount,
|
|
@@ -471,9 +486,10 @@ class TransactionDetailsChanged {
|
|
|
471
486
|
return undefined;
|
|
472
487
|
}
|
|
473
488
|
const existingTx = existing;
|
|
474
|
-
const actor = actorName ??
|
|
489
|
+
const actor = actorName ?? "You";
|
|
475
490
|
const logMessage = `${actor} updated transaction details`;
|
|
476
491
|
return {
|
|
492
|
+
eventId: (0, uuid_1.v4)(),
|
|
477
493
|
userId: existingTx.userId,
|
|
478
494
|
activityByUid: this.createdBy,
|
|
479
495
|
sourceStreamId: this.streamId,
|
|
@@ -1,19 +1,11 @@
|
|
|
1
|
-
import { UserCreated,
|
|
2
|
-
import {
|
|
3
|
-
import { UserEventStore } from '.';
|
|
4
|
-
import { ActivityEventHandler } from './ActivityEventHandler';
|
|
1
|
+
import { UserCreated, UserEvent, UserEventStore, UserModel, UserModelStore } from ".";
|
|
2
|
+
import { ActivityEventHandler } from "./ActivityEventHandler";
|
|
5
3
|
export declare class UserEventHandler {
|
|
6
4
|
private modelStore;
|
|
7
5
|
private eventStore;
|
|
8
6
|
private activityEventHandler?;
|
|
9
7
|
constructor(modelStore: UserModelStore, eventStore: UserEventStore, activityEventHandler?: ActivityEventHandler | undefined);
|
|
8
|
+
handleEvent(event: UserEvent): Promise<UserModel>;
|
|
10
9
|
handleUserCreated(event: UserCreated): Promise<UserModel>;
|
|
11
|
-
handlePlaceholderUserCreated(event: PlaceholderUserCreated): Promise<UserModel>;
|
|
12
|
-
handleUserCurrencyChanged(event: UserCurrencyChanged): Promise<UserModel>;
|
|
13
|
-
handleUserPhoneNumberChanged(event: UserPhoneNumberChanged): Promise<UserModel>;
|
|
14
|
-
handleUserDisplayNameChanged(event: UserDisplayNameChanged): Promise<UserModel>;
|
|
15
|
-
handleUserDeleted(event: UserDeleted): Promise<UserModel>;
|
|
16
|
-
handlePlaceholderUserMerged(event: PlaceholderUserMerged): Promise<UserModel>;
|
|
17
|
-
handleUserConvertedToPlaceholder(event: UserConvertedToPlaceholder): Promise<UserModel>;
|
|
18
10
|
}
|
|
19
11
|
//# sourceMappingURL=UserEventHandler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserEventHandler.d.ts","sourceRoot":"","sources":["../src/UserEventHandler.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"UserEventHandler.d.ts","sourceRoot":"","sources":["../src/UserEventHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAGH,WAAW,EACX,SAAS,EACT,cAAc,EACd,SAAS,EACT,cAAc,EACjB,MAAM,GAAG,CAAC;AACX,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAK9D,qBAAa,gBAAgB;IAErB,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,oBAAoB,CAAC;gBAFrB,UAAU,EAAE,cAAc,EAC1B,UAAU,EAAE,cAAc,EAC1B,oBAAoB,CAAC,EAAE,oBAAoB,YAAA;IAGjD,WAAW,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;IAgDjD,iBAAiB,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,SAAS,CAAC;CAmDlE"}
|
package/dist/UserEventHandler.js
CHANGED
|
@@ -1,85 +1,87 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.UserEventHandler = void 0;
|
|
4
|
-
const
|
|
4
|
+
const _1 = require(".");
|
|
5
|
+
const DomainEvents_1 = require("./common/DomainEvents");
|
|
6
|
+
const uuid_1 = require("uuid");
|
|
5
7
|
class UserEventHandler {
|
|
6
8
|
constructor(modelStore, eventStore, activityEventHandler) {
|
|
7
9
|
this.modelStore = modelStore;
|
|
8
10
|
this.eventStore = eventStore;
|
|
9
11
|
this.activityEventHandler = activityEventHandler;
|
|
10
12
|
}
|
|
11
|
-
async
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
await this.modelStore.save(updatedModel);
|
|
16
|
-
if (this.activityEventHandler) {
|
|
17
|
-
await this.activityEventHandler.createActivityLog(event, existingModel, updatedModel);
|
|
13
|
+
async handleEvent(event) {
|
|
14
|
+
const eventType = event.constructor.name;
|
|
15
|
+
if (!(0, DomainEvents_1.isValidUserEventType)(eventType)) {
|
|
16
|
+
throw new Error(`Unknown user event type: ${eventType}`);
|
|
18
17
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
18
|
+
const serverOnlyEvents = [
|
|
19
|
+
"UserCreated",
|
|
20
|
+
"PlaceholderUserCreated",
|
|
21
|
+
"PlaceholderUserMerged",
|
|
22
|
+
];
|
|
23
|
+
const clientOnlyEvents = [
|
|
24
|
+
"UserCurrencyChanged",
|
|
25
|
+
"UserPhoneNumberChanged",
|
|
26
|
+
"UserDisplayNameChanged",
|
|
27
|
+
"UserDeleted",
|
|
28
|
+
"UserConvertedToPlaceholder",
|
|
29
|
+
];
|
|
30
|
+
if (!_1.residence.isClient && clientOnlyEvents.includes(eventType)) {
|
|
31
|
+
throw new Error(`${eventType} can only be handled on client side. Server only handles: ${serverOnlyEvents.join(", ")}`);
|
|
28
32
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
async handleUserCurrencyChanged(event) {
|
|
32
|
-
const existingModel = await this.modelStore.getByStreamIdWhereDeletedIsFalse(event.streamId);
|
|
33
|
-
const updatedModel = event.apply(existingModel);
|
|
34
|
-
await this.modelStore.save(updatedModel);
|
|
35
|
-
if (this.activityEventHandler) {
|
|
36
|
-
await this.activityEventHandler.createActivityLog(event, existingModel, updatedModel);
|
|
33
|
+
if (eventType === "UserCreated") {
|
|
34
|
+
return await this.handleUserCreated(event);
|
|
37
35
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
36
|
+
else {
|
|
37
|
+
const existingModel = await this.modelStore.getByStreamIdWhereDeletedIsFalse(event.streamId);
|
|
38
|
+
const updatedModel = event.apply(existingModel);
|
|
39
|
+
await this.modelStore.save(updatedModel);
|
|
40
|
+
if (_1.residence.isClient) {
|
|
41
|
+
await this.eventStore.addEvent(event);
|
|
42
|
+
if (this.activityEventHandler) {
|
|
43
|
+
await this.activityEventHandler.createActivityLog(event, existingModel, updatedModel);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return updatedModel;
|
|
46
47
|
}
|
|
47
|
-
return updatedModel;
|
|
48
48
|
}
|
|
49
|
-
async
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
await this.modelStore.save(updatedModel);
|
|
53
|
-
if (this.activityEventHandler) {
|
|
54
|
-
await this.activityEventHandler.createActivityLog(event, existingModel, updatedModel);
|
|
49
|
+
async handleUserCreated(event) {
|
|
50
|
+
if (_1.residence.isClient) {
|
|
51
|
+
throw new Error("handleUserCreated should not be called on client side");
|
|
55
52
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const existingModel = await this.modelStore.getByStreamIdWhereDeletedIsFalse(event.streamId);
|
|
60
|
-
const updatedModel = event.apply(existingModel);
|
|
61
|
-
await this.modelStore.save(updatedModel);
|
|
62
|
-
if (this.activityEventHandler) {
|
|
63
|
-
await this.activityEventHandler.createActivityLog(event, existingModel, updatedModel);
|
|
53
|
+
let placeholderUser;
|
|
54
|
+
if (event.phoneNumber) {
|
|
55
|
+
placeholderUser = await this.modelStore.findByPhone(event.phoneNumber);
|
|
64
56
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
async handlePlaceholderUserMerged(event) {
|
|
68
|
-
const existingModel = await this.modelStore.getByStreamIdWhereDeletedIsFalse(event.streamId);
|
|
69
|
-
const updatedModel = event.apply(existingModel);
|
|
70
|
-
await this.modelStore.save(updatedModel);
|
|
71
|
-
if (this.activityEventHandler) {
|
|
72
|
-
await this.activityEventHandler.createActivityLog(event, existingModel, updatedModel);
|
|
57
|
+
if (!placeholderUser && event.email) {
|
|
58
|
+
placeholderUser = await this.modelStore.findByEmail(event.email);
|
|
73
59
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
60
|
+
if (placeholderUser && placeholderUser.isPlaceholder) {
|
|
61
|
+
const mergeEvent = new _1.PlaceholderUserMerged({
|
|
62
|
+
eventId: (0, uuid_1.v4)(),
|
|
63
|
+
userId: placeholderUser.userId,
|
|
64
|
+
firebaseUid: event.firebaseUid,
|
|
65
|
+
displayName: event.displayName,
|
|
66
|
+
email: event.email,
|
|
67
|
+
phoneNumber: event.phoneNumber,
|
|
68
|
+
photoUrl: event.photoUrl,
|
|
69
|
+
emailVerified: event.emailVerified,
|
|
70
|
+
createdAt: event.createdAt,
|
|
71
|
+
createdBy: event.createdBy,
|
|
72
|
+
streamId: placeholderUser.streamId,
|
|
73
|
+
version: placeholderUser.version + 1,
|
|
74
|
+
systemGenerated: event.systemGenerated,
|
|
75
|
+
});
|
|
76
|
+
await this.eventStore.addEvent(mergeEvent);
|
|
77
|
+
const updatedModel = mergeEvent.apply(placeholderUser);
|
|
78
|
+
await this.modelStore.save(updatedModel);
|
|
79
|
+
return updatedModel;
|
|
80
|
+
}
|
|
81
|
+
await this.eventStore.addEvent(event);
|
|
77
82
|
const existingModel = await this.modelStore.getByStreamIdWhereDeletedIsFalse(event.streamId);
|
|
78
83
|
const updatedModel = event.apply(existingModel);
|
|
79
84
|
await this.modelStore.save(updatedModel);
|
|
80
|
-
if (this.activityEventHandler) {
|
|
81
|
-
await this.activityEventHandler.createActivityLog(event, existingModel, updatedModel);
|
|
82
|
-
}
|
|
83
85
|
return updatedModel;
|
|
84
86
|
}
|
|
85
87
|
}
|