@zeeshan60/event-processor 1.0.4 → 1.0.6
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 +12 -0
- package/dist/ActivityEventHandler.d.ts.map +1 -0
- package/dist/ActivityEventHandler.js +35 -0
- package/dist/ActivityLogEvents.d.ts +2 -0
- package/dist/ActivityLogEvents.d.ts.map +1 -1
- package/dist/ActivityLogEvents.js +1 -0
- package/dist/FriendEventHandler.d.ts +21 -0
- package/dist/FriendEventHandler.d.ts.map +1 -0
- package/dist/FriendEventHandler.js +180 -0
- package/dist/FriendEvents.d.ts +10 -0
- package/dist/FriendEvents.d.ts.map +1 -1
- package/dist/FriendEvents.js +9 -0
- package/dist/GroupEventHandler.d.ts +25 -0
- package/dist/GroupEventHandler.d.ts.map +1 -0
- package/dist/GroupEventHandler.js +278 -0
- package/dist/GroupEvents.d.ts +12 -0
- package/dist/GroupEvents.d.ts.map +1 -1
- package/dist/GroupEvents.js +12 -0
- package/dist/GroupTransactionEventHandler.d.ts +25 -0
- package/dist/GroupTransactionEventHandler.d.ts.map +1 -0
- package/dist/GroupTransactionEventHandler.js +303 -0
- package/dist/GroupTransactionEvents.d.ts +18 -0
- package/dist/GroupTransactionEvents.d.ts.map +1 -1
- package/dist/GroupTransactionEvents.js +18 -0
- package/dist/TransactionEventHandler.d.ts +11 -7
- package/dist/TransactionEventHandler.d.ts.map +1 -1
- package/dist/TransactionEventHandler.js +146 -10
- package/dist/TransactionEvents.d.ts +16 -0
- package/dist/TransactionEvents.d.ts.map +1 -1
- package/dist/TransactionEvents.js +16 -0
- package/dist/UserEventHandler.d.ts +17 -0
- package/dist/UserEventHandler.d.ts.map +1 -0
- package/dist/UserEventHandler.js +82 -0
- package/dist/UserEvents.d.ts +16 -0
- package/dist/UserEvents.d.ts.map +1 -1
- package/dist/UserEvents.js +12 -0
- package/dist/__tests__/test-helpers/IMActivityLogEventStore.d.ts +9 -0
- package/dist/__tests__/test-helpers/IMActivityLogEventStore.d.ts.map +1 -0
- package/dist/__tests__/test-helpers/IMActivityLogEventStore.js +21 -0
- package/dist/__tests__/test-helpers/IMActivityLogModelStore.d.ts +11 -0
- package/dist/__tests__/test-helpers/IMActivityLogModelStore.d.ts.map +1 -0
- package/dist/{store/InMemoryModelStore.js → __tests__/test-helpers/IMActivityLogModelStore.js} +14 -13
- package/dist/__tests__/test-helpers/IMFriendEventStore.d.ts +9 -0
- package/dist/__tests__/test-helpers/IMFriendEventStore.d.ts.map +1 -0
- package/dist/__tests__/test-helpers/IMFriendEventStore.js +20 -0
- package/dist/__tests__/test-helpers/IMFriendModelStore.d.ts +16 -0
- package/dist/__tests__/test-helpers/IMFriendModelStore.d.ts.map +1 -0
- package/dist/__tests__/test-helpers/IMFriendModelStore.js +74 -0
- package/dist/__tests__/test-helpers/IMGroupEventStore.d.ts +9 -0
- package/dist/__tests__/test-helpers/IMGroupEventStore.d.ts.map +1 -0
- package/dist/__tests__/test-helpers/IMGroupEventStore.js +20 -0
- package/dist/__tests__/test-helpers/IMGroupModelStore.d.ts +14 -0
- package/dist/__tests__/test-helpers/IMGroupModelStore.d.ts.map +1 -0
- package/dist/__tests__/test-helpers/IMGroupModelStore.js +53 -0
- package/dist/__tests__/test-helpers/IMGroupTransactionEventStore.d.ts +9 -0
- package/dist/__tests__/test-helpers/IMGroupTransactionEventStore.d.ts.map +1 -0
- package/dist/__tests__/test-helpers/IMGroupTransactionEventStore.js +22 -0
- package/dist/__tests__/test-helpers/IMGroupTransactionModelStore.d.ts +14 -0
- package/dist/__tests__/test-helpers/IMGroupTransactionModelStore.d.ts.map +1 -0
- package/dist/__tests__/test-helpers/IMGroupTransactionModelStore.js +55 -0
- package/dist/__tests__/test-helpers/IMTransactionEventStore.d.ts +10 -0
- package/dist/__tests__/test-helpers/IMTransactionEventStore.d.ts.map +1 -0
- package/dist/__tests__/test-helpers/IMTransactionEventStore.js +23 -0
- package/dist/__tests__/test-helpers/IMTransactionModelStore.d.ts +14 -0
- package/dist/__tests__/test-helpers/IMTransactionModelStore.d.ts.map +1 -0
- package/dist/__tests__/test-helpers/IMTransactionModelStore.js +56 -0
- package/dist/__tests__/test-helpers/IMUserEventStore.d.ts +10 -0
- package/dist/__tests__/test-helpers/IMUserEventStore.d.ts.map +1 -0
- package/dist/{store/InMemoryEventStore.js → __tests__/test-helpers/IMUserEventStore.js} +5 -5
- package/dist/__tests__/test-helpers/IMUserModelStore.d.ts +15 -0
- package/dist/__tests__/test-helpers/IMUserModelStore.d.ts.map +1 -0
- package/dist/__tests__/test-helpers/IMUserModelStore.js +58 -0
- package/dist/common/Event.d.ts +1 -0
- package/dist/common/Event.d.ts.map +1 -1
- package/dist/events.d.ts +30 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +60 -0
- package/dist/index.d.ts +1 -21
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -86
- package/dist/utils/splitTypeUtils.d.ts +7 -0
- package/dist/utils/splitTypeUtils.d.ts.map +1 -0
- package/dist/utils/splitTypeUtils.js +45 -0
- package/dist/utils/userPathUtils.d.ts +6 -0
- package/dist/utils/userPathUtils.d.ts.map +1 -0
- package/dist/utils/userPathUtils.js +16 -0
- package/package.json +1 -1
- package/dist/common/EventStore.d.ts +0 -5
- package/dist/common/EventStore.d.ts.map +0 -1
- package/dist/common/EventStore.js +0 -6
- package/dist/common/ModelStore.d.ts +0 -6
- package/dist/common/ModelStore.d.ts.map +0 -1
- package/dist/common/ModelStore.js +0 -6
- package/dist/store/InMemoryEventStore.d.ts +0 -10
- package/dist/store/InMemoryEventStore.d.ts.map +0 -1
- package/dist/store/InMemoryModelStore.d.ts +0 -11
- package/dist/store/InMemoryModelStore.d.ts.map +0 -1
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GroupTransactionEventHandler = void 0;
|
|
4
|
+
const _1 = require(".");
|
|
5
|
+
const splitTypeUtils_1 = require("./utils/splitTypeUtils");
|
|
6
|
+
const uuid_1 = require("uuid");
|
|
7
|
+
class GroupTransactionEventHandler {
|
|
8
|
+
constructor(modelStore, eventStore, groupModelStore, transactionEventStore, transactionModelStore, activityEventHandler) {
|
|
9
|
+
this.modelStore = modelStore;
|
|
10
|
+
this.eventStore = eventStore;
|
|
11
|
+
this.groupModelStore = groupModelStore;
|
|
12
|
+
this.transactionEventStore = transactionEventStore;
|
|
13
|
+
this.transactionModelStore = transactionModelStore;
|
|
14
|
+
this.activityEventHandler = activityEventHandler;
|
|
15
|
+
}
|
|
16
|
+
async handleEvent(event) {
|
|
17
|
+
const validEventTypes = [
|
|
18
|
+
'GroupTransactionCreated',
|
|
19
|
+
'GroupTransactionSplitDetailsChanged',
|
|
20
|
+
];
|
|
21
|
+
const eventType = event.constructor.name;
|
|
22
|
+
if (!validEventTypes.includes(eventType)) {
|
|
23
|
+
throw new Error(`Unknown group transaction event type: ${eventType}`);
|
|
24
|
+
}
|
|
25
|
+
switch (eventType) {
|
|
26
|
+
case 'GroupTransactionCreated':
|
|
27
|
+
return await this.handleGroupTransactionCreated(event);
|
|
28
|
+
case 'GroupTransactionSplitDetailsChanged':
|
|
29
|
+
return await this.handleGroupTransactionSplitDetailsChanged(event);
|
|
30
|
+
default:
|
|
31
|
+
throw new Error(`Unknown group transaction event type: ${eventType}`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
calculateNetBalances(members) {
|
|
35
|
+
const netBalances = new Map();
|
|
36
|
+
for (const member of members) {
|
|
37
|
+
const net = member.paid - member.owed;
|
|
38
|
+
netBalances.set(member.memberId, net);
|
|
39
|
+
}
|
|
40
|
+
return netBalances;
|
|
41
|
+
}
|
|
42
|
+
async createFriendTransactions(groupTransactionEvent) {
|
|
43
|
+
const netBalances = this.calculateNetBalances(groupTransactionEvent.originalTransaction.members);
|
|
44
|
+
const creditors = [];
|
|
45
|
+
const debtors = [];
|
|
46
|
+
for (const [memberId, net] of netBalances.entries()) {
|
|
47
|
+
if (net > 0) {
|
|
48
|
+
creditors.push({ memberId, amount: net });
|
|
49
|
+
}
|
|
50
|
+
else if (net < 0) {
|
|
51
|
+
debtors.push({ memberId, amount: Math.abs(net) });
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
for (const creditor of creditors) {
|
|
55
|
+
for (const debtor of debtors) {
|
|
56
|
+
if (creditor.amount > 0 && debtor.amount > 0) {
|
|
57
|
+
const transactionAmount = Math.min(creditor.amount, debtor.amount);
|
|
58
|
+
const creditorStreamId = `stream-${(0, uuid_1.v4)()}`;
|
|
59
|
+
const creditorTransactionEvent = new _1.TransactionCreated({
|
|
60
|
+
userId: creditor.memberId,
|
|
61
|
+
recipientUserId: debtor.memberId,
|
|
62
|
+
logicalTransactionId: groupTransactionEvent.transactionId,
|
|
63
|
+
description: groupTransactionEvent.description ?? '',
|
|
64
|
+
currency: groupTransactionEvent.currency,
|
|
65
|
+
splitType: _1.SplitType.SpecificAmounts,
|
|
66
|
+
totalAmount: transactionAmount,
|
|
67
|
+
amount: transactionAmount,
|
|
68
|
+
isOwed: false,
|
|
69
|
+
transactionDate: groupTransactionEvent.transactionDate,
|
|
70
|
+
groupId: groupTransactionEvent.groupId,
|
|
71
|
+
groupTransactionId: groupTransactionEvent.transactionId,
|
|
72
|
+
createdAt: new Date(),
|
|
73
|
+
createdBy: groupTransactionEvent.createdBy,
|
|
74
|
+
streamId: creditorStreamId,
|
|
75
|
+
version: 1,
|
|
76
|
+
systemGenerated: true,
|
|
77
|
+
});
|
|
78
|
+
await this.transactionEventStore.addEvent(creditor.memberId, creditorTransactionEvent);
|
|
79
|
+
const creditorModel = creditorTransactionEvent.apply(undefined);
|
|
80
|
+
await this.transactionModelStore.save(creditorModel);
|
|
81
|
+
const debtorStreamId = `stream-${(0, uuid_1.v4)()}`;
|
|
82
|
+
const debtorTransactionEvent = new _1.TransactionCreated({
|
|
83
|
+
userId: debtor.memberId,
|
|
84
|
+
recipientUserId: creditor.memberId,
|
|
85
|
+
logicalTransactionId: groupTransactionEvent.transactionId,
|
|
86
|
+
description: groupTransactionEvent.description ?? '',
|
|
87
|
+
currency: groupTransactionEvent.currency,
|
|
88
|
+
splitType: _1.SplitType.SpecificAmounts,
|
|
89
|
+
totalAmount: transactionAmount,
|
|
90
|
+
amount: transactionAmount,
|
|
91
|
+
isOwed: true,
|
|
92
|
+
transactionDate: groupTransactionEvent.transactionDate,
|
|
93
|
+
groupId: groupTransactionEvent.groupId,
|
|
94
|
+
groupTransactionId: groupTransactionEvent.transactionId,
|
|
95
|
+
createdAt: new Date(),
|
|
96
|
+
createdBy: groupTransactionEvent.createdBy,
|
|
97
|
+
streamId: debtorStreamId,
|
|
98
|
+
version: 1,
|
|
99
|
+
systemGenerated: true,
|
|
100
|
+
});
|
|
101
|
+
await this.transactionEventStore.addEvent(debtor.memberId, debtorTransactionEvent);
|
|
102
|
+
const debtorModel = debtorTransactionEvent.apply(undefined);
|
|
103
|
+
await this.transactionModelStore.save(debtorModel);
|
|
104
|
+
creditor.amount -= transactionAmount;
|
|
105
|
+
debtor.amount -= transactionAmount;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
async updateFriendTransactions(event, existingModel, _oldMembers, newMembers) {
|
|
111
|
+
await this.updateExistingFriendTransactions(event, existingModel, newMembers);
|
|
112
|
+
}
|
|
113
|
+
calculateRequiredTransactions(newMembers) {
|
|
114
|
+
const newNetBalances = this.calculateNetBalances(newMembers);
|
|
115
|
+
const requiredTransactions = new Map();
|
|
116
|
+
const creditors = [];
|
|
117
|
+
const debtors = [];
|
|
118
|
+
for (const [memberId, net] of newNetBalances.entries()) {
|
|
119
|
+
if (net > 0) {
|
|
120
|
+
creditors.push({ memberId, amount: net });
|
|
121
|
+
}
|
|
122
|
+
else if (net < 0) {
|
|
123
|
+
debtors.push({ memberId, amount: Math.abs(net) });
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
for (const creditor of creditors) {
|
|
127
|
+
for (const debtor of debtors) {
|
|
128
|
+
if (creditor.amount > 0 && debtor.amount > 0) {
|
|
129
|
+
const transactionAmount = Math.min(creditor.amount, debtor.amount);
|
|
130
|
+
const creditorKey = `${creditor.memberId}-${debtor.memberId}`;
|
|
131
|
+
requiredTransactions.set(creditorKey, {
|
|
132
|
+
recipientUserId: debtor.memberId,
|
|
133
|
+
amount: transactionAmount,
|
|
134
|
+
isOwed: false
|
|
135
|
+
});
|
|
136
|
+
const debtorKey = `${debtor.memberId}-${creditor.memberId}`;
|
|
137
|
+
requiredTransactions.set(debtorKey, {
|
|
138
|
+
recipientUserId: creditor.memberId,
|
|
139
|
+
amount: transactionAmount,
|
|
140
|
+
isOwed: true
|
|
141
|
+
});
|
|
142
|
+
creditor.amount -= transactionAmount;
|
|
143
|
+
debtor.amount -= transactionAmount;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return requiredTransactions;
|
|
148
|
+
}
|
|
149
|
+
async updateExistingFriendTransactions(event, existingModel, newMembers) {
|
|
150
|
+
const requiredTransactions = this.calculateRequiredTransactions(newMembers);
|
|
151
|
+
const oldMemberIds = new Set(existingModel.originalTransaction.members.map(m => m.memberId));
|
|
152
|
+
const newMemberIds = new Set(newMembers.map(m => m.memberId));
|
|
153
|
+
const allMemberIds = new Set([...oldMemberIds, ...newMemberIds]);
|
|
154
|
+
for (const memberId of allMemberIds) {
|
|
155
|
+
const existingTransactions = await this.transactionModelStore.findByGroupTransactionId(memberId, existingModel.transactionId);
|
|
156
|
+
for (const existingTx of existingTransactions) {
|
|
157
|
+
const key = `${existingTx.userId}-${existingTx.recipientUserId}`;
|
|
158
|
+
const requiredTx = requiredTransactions.get(key);
|
|
159
|
+
if (requiredTx) {
|
|
160
|
+
if (existingTx.amount !== requiredTx.amount ||
|
|
161
|
+
existingTx.totalAmount !== requiredTx.amount ||
|
|
162
|
+
existingTx.isOwed !== requiredTx.isOwed) {
|
|
163
|
+
const updateEvent = new _1.TransactionDetailsChanged({
|
|
164
|
+
totalAmount: requiredTx.amount,
|
|
165
|
+
amount: requiredTx.amount,
|
|
166
|
+
isOwed: requiredTx.isOwed,
|
|
167
|
+
streamId: existingTx.streamId,
|
|
168
|
+
version: existingTx.version + 1,
|
|
169
|
+
createdAt: new Date(),
|
|
170
|
+
createdBy: event.createdBy,
|
|
171
|
+
systemGenerated: true,
|
|
172
|
+
});
|
|
173
|
+
await this.transactionEventStore.addEvent(memberId, updateEvent);
|
|
174
|
+
const updatedModel = updateEvent.apply(existingTx);
|
|
175
|
+
await this.transactionModelStore.save(updatedModel);
|
|
176
|
+
}
|
|
177
|
+
requiredTransactions.delete(key);
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
const deleteEvent = new _1.TransactionDeleted({
|
|
181
|
+
createdAt: new Date(),
|
|
182
|
+
createdBy: event.createdBy,
|
|
183
|
+
streamId: existingTx.streamId,
|
|
184
|
+
version: existingTx.version + 1,
|
|
185
|
+
systemGenerated: true,
|
|
186
|
+
});
|
|
187
|
+
await this.transactionEventStore.addEvent(memberId, deleteEvent);
|
|
188
|
+
const deletedModel = deleteEvent.apply(existingTx);
|
|
189
|
+
await this.transactionModelStore.save(deletedModel);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
for (const [key, txDetails] of requiredTransactions.entries()) {
|
|
194
|
+
const [userId, recipientUserId] = key.split('-');
|
|
195
|
+
const streamId = `stream-${(0, uuid_1.v4)()}`;
|
|
196
|
+
const createEvent = new _1.TransactionCreated({
|
|
197
|
+
userId: userId,
|
|
198
|
+
recipientUserId: recipientUserId,
|
|
199
|
+
logicalTransactionId: existingModel.transactionId,
|
|
200
|
+
description: existingModel.description ?? '',
|
|
201
|
+
currency: existingModel.currency,
|
|
202
|
+
splitType: _1.SplitType.SpecificAmounts,
|
|
203
|
+
totalAmount: txDetails.amount,
|
|
204
|
+
amount: txDetails.amount,
|
|
205
|
+
isOwed: txDetails.isOwed,
|
|
206
|
+
transactionDate: existingModel.transactionDate,
|
|
207
|
+
groupId: existingModel.groupId,
|
|
208
|
+
groupTransactionId: existingModel.transactionId,
|
|
209
|
+
createdAt: new Date(),
|
|
210
|
+
createdBy: event.createdBy,
|
|
211
|
+
streamId: streamId,
|
|
212
|
+
version: 1,
|
|
213
|
+
systemGenerated: true,
|
|
214
|
+
});
|
|
215
|
+
await this.transactionEventStore.addEvent(userId, createEvent);
|
|
216
|
+
const model = createEvent.apply(undefined);
|
|
217
|
+
await this.transactionModelStore.save(model);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
async handleGroupTransactionCreated(event) {
|
|
221
|
+
const existingModel = await this.modelStore.getByStreamIdWhereDeletedIsFalse(event.streamId);
|
|
222
|
+
const updatedModel = event.apply(existingModel);
|
|
223
|
+
await this.modelStore.save(updatedModel);
|
|
224
|
+
if (this.activityEventHandler) {
|
|
225
|
+
await this.activityEventHandler.createActivityLog(event, existingModel, updatedModel);
|
|
226
|
+
}
|
|
227
|
+
const allGroupPerspectives = await this.groupModelStore.findAllByGroupIdAndDeletedIsFalse(event.groupId);
|
|
228
|
+
for (const groupPerspective of allGroupPerspectives) {
|
|
229
|
+
if (groupPerspective.userId !== event.userId) {
|
|
230
|
+
const perspectiveStreamId = `stream-${(0, uuid_1.v4)()}`;
|
|
231
|
+
const perspectiveSplitType = (0, splitTypeUtils_1.reverseSplitType)(event.splitType);
|
|
232
|
+
const perspectiveEvent = new _1.GroupTransactionCreated({
|
|
233
|
+
userId: groupPerspective.userId,
|
|
234
|
+
groupId: event.groupId,
|
|
235
|
+
transactionId: event.transactionId,
|
|
236
|
+
description: event.description,
|
|
237
|
+
notes: event.notes,
|
|
238
|
+
totalAmount: event.totalAmount,
|
|
239
|
+
currency: event.currency,
|
|
240
|
+
splitType: perspectiveSplitType,
|
|
241
|
+
transactionDate: event.transactionDate,
|
|
242
|
+
originalTransaction: event.originalTransaction,
|
|
243
|
+
createdAt: new Date(),
|
|
244
|
+
createdBy: event.createdBy,
|
|
245
|
+
streamId: perspectiveStreamId,
|
|
246
|
+
version: 1,
|
|
247
|
+
systemGenerated: true,
|
|
248
|
+
});
|
|
249
|
+
await this.eventStore.addEvent(groupPerspective.userId, perspectiveEvent);
|
|
250
|
+
const perspectiveModel = perspectiveEvent.apply(undefined);
|
|
251
|
+
await this.modelStore.save(perspectiveModel);
|
|
252
|
+
if (this.activityEventHandler) {
|
|
253
|
+
await this.activityEventHandler.createActivityLog(perspectiveEvent, undefined, perspectiveModel);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
await this.createFriendTransactions(event);
|
|
258
|
+
return updatedModel;
|
|
259
|
+
}
|
|
260
|
+
async handleGroupTransactionSplitDetailsChanged(event) {
|
|
261
|
+
const existingModel = await this.modelStore.getByStreamIdWhereDeletedIsFalse(event.streamId);
|
|
262
|
+
if (!existingModel) {
|
|
263
|
+
throw new Error('GroupTransaction must exist to change split details');
|
|
264
|
+
}
|
|
265
|
+
const oldMembers = existingModel.originalTransaction.members;
|
|
266
|
+
const newMembers = event.originalTransaction.members;
|
|
267
|
+
const updatedModel = event.apply(existingModel);
|
|
268
|
+
await this.modelStore.save(updatedModel);
|
|
269
|
+
if (this.activityEventHandler) {
|
|
270
|
+
await this.activityEventHandler.createActivityLog(event, existingModel, updatedModel);
|
|
271
|
+
}
|
|
272
|
+
const allGroupPerspectives = await this.groupModelStore.findAllByGroupIdAndDeletedIsFalse(updatedModel.groupId);
|
|
273
|
+
for (const groupPerspective of allGroupPerspectives) {
|
|
274
|
+
if (groupPerspective.userId !== event.userId) {
|
|
275
|
+
const perspectiveStreamId = updatedModel.streamId;
|
|
276
|
+
const perspectiveSplitType = (0, splitTypeUtils_1.reverseSplitType)(event.splitType);
|
|
277
|
+
const perspectiveEvent = new _1.GroupTransactionSplitDetailsChanged({
|
|
278
|
+
userId: groupPerspective.userId,
|
|
279
|
+
totalAmount: event.totalAmount,
|
|
280
|
+
splitType: perspectiveSplitType,
|
|
281
|
+
originalTransaction: event.originalTransaction,
|
|
282
|
+
createdAt: new Date(),
|
|
283
|
+
createdBy: event.createdBy,
|
|
284
|
+
streamId: perspectiveStreamId,
|
|
285
|
+
version: updatedModel.version,
|
|
286
|
+
systemGenerated: true,
|
|
287
|
+
});
|
|
288
|
+
await this.eventStore.addEvent(groupPerspective.userId, perspectiveEvent);
|
|
289
|
+
const existingPerspectiveModel = await this.modelStore.findByUserIdAndTransactionId(groupPerspective.userId, updatedModel.transactionId);
|
|
290
|
+
if (existingPerspectiveModel) {
|
|
291
|
+
const perspectiveModel = perspectiveEvent.apply(existingPerspectiveModel);
|
|
292
|
+
await this.modelStore.save(perspectiveModel);
|
|
293
|
+
if (this.activityEventHandler) {
|
|
294
|
+
await this.activityEventHandler.createActivityLog(perspectiveEvent, existingPerspectiveModel, perspectiveModel);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
await this.updateFriendTransactions(event, existingModel, oldMembers, newMembers);
|
|
300
|
+
return updatedModel;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
exports.GroupTransactionEventHandler = GroupTransactionEventHandler;
|
|
@@ -51,6 +51,7 @@ export interface GroupTransactionCreatedProps {
|
|
|
51
51
|
createdBy: string;
|
|
52
52
|
streamId: string;
|
|
53
53
|
version: number;
|
|
54
|
+
systemGenerated: boolean;
|
|
54
55
|
}
|
|
55
56
|
export declare class GroupTransactionCreated implements Event {
|
|
56
57
|
userId?: string;
|
|
@@ -67,6 +68,7 @@ export declare class GroupTransactionCreated implements Event {
|
|
|
67
68
|
createdBy: string;
|
|
68
69
|
streamId: string;
|
|
69
70
|
version: number;
|
|
71
|
+
systemGenerated: boolean;
|
|
70
72
|
constructor(props: GroupTransactionCreatedProps);
|
|
71
73
|
apply(_existing?: Model): GroupTransactionModel;
|
|
72
74
|
activityLog(_existing?: Model, actorName?: string): ActivityLogCreatedProps | undefined;
|
|
@@ -78,6 +80,7 @@ export interface GroupTransactionDescriptionChangedProps {
|
|
|
78
80
|
createdBy: string;
|
|
79
81
|
streamId: string;
|
|
80
82
|
version: number;
|
|
83
|
+
systemGenerated: boolean;
|
|
81
84
|
}
|
|
82
85
|
export declare class GroupTransactionDescriptionChanged implements Event {
|
|
83
86
|
userId?: string;
|
|
@@ -86,6 +89,7 @@ export declare class GroupTransactionDescriptionChanged implements Event {
|
|
|
86
89
|
createdBy: string;
|
|
87
90
|
streamId: string;
|
|
88
91
|
version: number;
|
|
92
|
+
systemGenerated: boolean;
|
|
89
93
|
constructor(props: GroupTransactionDescriptionChangedProps);
|
|
90
94
|
apply(existing?: Model): GroupTransactionModel;
|
|
91
95
|
activityLog(existing?: Model, actorName?: string): ActivityLogCreatedProps | undefined;
|
|
@@ -97,6 +101,7 @@ export interface GroupTransactionNotesChangedProps {
|
|
|
97
101
|
createdBy: string;
|
|
98
102
|
streamId: string;
|
|
99
103
|
version: number;
|
|
104
|
+
systemGenerated: boolean;
|
|
100
105
|
}
|
|
101
106
|
export declare class GroupTransactionNotesChanged implements Event {
|
|
102
107
|
userId?: string;
|
|
@@ -105,6 +110,7 @@ export declare class GroupTransactionNotesChanged implements Event {
|
|
|
105
110
|
createdBy: string;
|
|
106
111
|
streamId: string;
|
|
107
112
|
version: number;
|
|
113
|
+
systemGenerated: boolean;
|
|
108
114
|
constructor(props: GroupTransactionNotesChangedProps);
|
|
109
115
|
apply(existing?: Model): GroupTransactionModel;
|
|
110
116
|
activityLog(existing?: Model, actorName?: string): ActivityLogCreatedProps | undefined;
|
|
@@ -116,6 +122,7 @@ export interface GroupTransactionTotalAmountChangedProps {
|
|
|
116
122
|
createdBy: string;
|
|
117
123
|
streamId: string;
|
|
118
124
|
version: number;
|
|
125
|
+
systemGenerated: boolean;
|
|
119
126
|
}
|
|
120
127
|
export declare class GroupTransactionTotalAmountChanged implements Event {
|
|
121
128
|
userId?: string;
|
|
@@ -124,6 +131,7 @@ export declare class GroupTransactionTotalAmountChanged implements Event {
|
|
|
124
131
|
createdBy: string;
|
|
125
132
|
streamId: string;
|
|
126
133
|
version: number;
|
|
134
|
+
systemGenerated: boolean;
|
|
127
135
|
constructor(props: GroupTransactionTotalAmountChangedProps);
|
|
128
136
|
apply(existing?: Model): GroupTransactionModel;
|
|
129
137
|
activityLog(existing?: Model, actorName?: string): ActivityLogCreatedProps | undefined;
|
|
@@ -135,6 +143,7 @@ export interface GroupTransactionCurrencyChangedProps {
|
|
|
135
143
|
createdBy: string;
|
|
136
144
|
streamId: string;
|
|
137
145
|
version: number;
|
|
146
|
+
systemGenerated: boolean;
|
|
138
147
|
}
|
|
139
148
|
export declare class GroupTransactionCurrencyChanged implements Event {
|
|
140
149
|
userId?: string;
|
|
@@ -143,6 +152,7 @@ export declare class GroupTransactionCurrencyChanged implements Event {
|
|
|
143
152
|
createdBy: string;
|
|
144
153
|
streamId: string;
|
|
145
154
|
version: number;
|
|
155
|
+
systemGenerated: boolean;
|
|
146
156
|
constructor(props: GroupTransactionCurrencyChangedProps);
|
|
147
157
|
apply(existing?: Model): GroupTransactionModel;
|
|
148
158
|
activityLog(existing?: Model, actorName?: string): ActivityLogCreatedProps | undefined;
|
|
@@ -154,6 +164,7 @@ export interface GroupTransactionSplitTypeChangedProps {
|
|
|
154
164
|
createdBy: string;
|
|
155
165
|
streamId: string;
|
|
156
166
|
version: number;
|
|
167
|
+
systemGenerated: boolean;
|
|
157
168
|
}
|
|
158
169
|
export declare class GroupTransactionSplitTypeChanged implements Event {
|
|
159
170
|
userId?: string;
|
|
@@ -162,6 +173,7 @@ export declare class GroupTransactionSplitTypeChanged implements Event {
|
|
|
162
173
|
createdBy: string;
|
|
163
174
|
streamId: string;
|
|
164
175
|
version: number;
|
|
176
|
+
systemGenerated: boolean;
|
|
165
177
|
constructor(props: GroupTransactionSplitTypeChangedProps);
|
|
166
178
|
apply(existing?: Model): GroupTransactionModel;
|
|
167
179
|
activityLog(existing?: Model, actorName?: string): ActivityLogCreatedProps | undefined;
|
|
@@ -173,6 +185,7 @@ export interface GroupTransactionDateChangedProps {
|
|
|
173
185
|
createdBy: string;
|
|
174
186
|
streamId: string;
|
|
175
187
|
version: number;
|
|
188
|
+
systemGenerated: boolean;
|
|
176
189
|
}
|
|
177
190
|
export declare class GroupTransactionDateChanged implements Event {
|
|
178
191
|
userId?: string;
|
|
@@ -181,6 +194,7 @@ export declare class GroupTransactionDateChanged implements Event {
|
|
|
181
194
|
createdBy: string;
|
|
182
195
|
streamId: string;
|
|
183
196
|
version: number;
|
|
197
|
+
systemGenerated: boolean;
|
|
184
198
|
constructor(props: GroupTransactionDateChangedProps);
|
|
185
199
|
apply(existing?: Model): GroupTransactionModel;
|
|
186
200
|
activityLog(existing?: Model, actorName?: string): ActivityLogCreatedProps | undefined;
|
|
@@ -194,6 +208,7 @@ export interface GroupTransactionSplitDetailsChangedProps {
|
|
|
194
208
|
createdBy: string;
|
|
195
209
|
streamId: string;
|
|
196
210
|
version: number;
|
|
211
|
+
systemGenerated: boolean;
|
|
197
212
|
}
|
|
198
213
|
export declare class GroupTransactionSplitDetailsChanged implements Event {
|
|
199
214
|
userId?: string;
|
|
@@ -204,6 +219,7 @@ export declare class GroupTransactionSplitDetailsChanged implements Event {
|
|
|
204
219
|
createdBy: string;
|
|
205
220
|
streamId: string;
|
|
206
221
|
version: number;
|
|
222
|
+
systemGenerated: boolean;
|
|
207
223
|
constructor(props: GroupTransactionSplitDetailsChangedProps);
|
|
208
224
|
apply(existing?: Model): GroupTransactionModel;
|
|
209
225
|
activityLog(existing?: Model, actorName?: string): ActivityLogCreatedProps | undefined;
|
|
@@ -214,6 +230,7 @@ export interface GroupTransactionDeletedProps {
|
|
|
214
230
|
createdBy: string;
|
|
215
231
|
streamId: string;
|
|
216
232
|
version: number;
|
|
233
|
+
systemGenerated: boolean;
|
|
217
234
|
}
|
|
218
235
|
export declare class GroupTransactionDeleted implements Event {
|
|
219
236
|
userId?: string;
|
|
@@ -221,6 +238,7 @@ export declare class GroupTransactionDeleted implements Event {
|
|
|
221
238
|
createdBy: string;
|
|
222
239
|
streamId: string;
|
|
223
240
|
version: number;
|
|
241
|
+
systemGenerated: boolean;
|
|
224
242
|
constructor(props: GroupTransactionDeletedProps);
|
|
225
243
|
apply(existing?: Model): GroupTransactionModel;
|
|
226
244
|
activityLog(existing?: Model, actorName?: string): ActivityLogCreatedProps | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GroupTransactionEvents.d.ts","sourceRoot":"","sources":["../src/GroupTransactionEvents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,uBAAuB,EAAc,MAAM,qBAAqB,CAAC;AAC1E,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAGhD,oBAAY,yBAAyB;IACnC,yBAAyB,8BAA8B;IACvD,qCAAqC,0CAA0C;IAC/E,+BAA+B,oCAAoC;IACnE,sCAAsC,2CAA2C;IACjF,kCAAkC,uCAAuC;IACzE,oCAAoC,yCAAyC;IAC7E,8BAA8B,mCAAmC;IACjE,uCAAuC,4CAA4C;IACnF,yBAAyB,8BAA8B;CACxD;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,wBAAwB;IACvC,OAAO,EAAE,aAAa,EAAE,CAAC;CAC1B;AAED,MAAM,WAAW,qBAAsB,SAAQ,KAAK;IAClD,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,E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C,EAAE,KAAK,GAAG,qBAAqB;IAc9C,WAAW,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,uBAAuB,GAAG,SAAS;CAwBvF"}
|
|
@@ -31,6 +31,7 @@ class GroupTransactionCreated {
|
|
|
31
31
|
this.createdBy = props.createdBy;
|
|
32
32
|
this.streamId = props.streamId;
|
|
33
33
|
this.version = props.version;
|
|
34
|
+
this.systemGenerated = props.systemGenerated;
|
|
34
35
|
}
|
|
35
36
|
apply(_existing) {
|
|
36
37
|
if (!this.userId) {
|
|
@@ -73,6 +74,7 @@ class GroupTransactionCreated {
|
|
|
73
74
|
createdAt: this.createdAt,
|
|
74
75
|
createdBy: this.createdBy,
|
|
75
76
|
streamId: (0, uuid_1.v4)(),
|
|
77
|
+
systemGenerated: true,
|
|
76
78
|
version: 1,
|
|
77
79
|
};
|
|
78
80
|
}
|
|
@@ -86,6 +88,7 @@ class GroupTransactionDescriptionChanged {
|
|
|
86
88
|
this.createdBy = props.createdBy;
|
|
87
89
|
this.streamId = props.streamId;
|
|
88
90
|
this.version = props.version;
|
|
91
|
+
this.systemGenerated = props.systemGenerated;
|
|
89
92
|
}
|
|
90
93
|
apply(existing) {
|
|
91
94
|
if (!existing) {
|
|
@@ -119,6 +122,7 @@ class GroupTransactionDescriptionChanged {
|
|
|
119
122
|
createdAt: this.createdAt,
|
|
120
123
|
createdBy: this.createdBy,
|
|
121
124
|
streamId: (0, uuid_1.v4)(),
|
|
125
|
+
systemGenerated: true,
|
|
122
126
|
version: 1,
|
|
123
127
|
};
|
|
124
128
|
}
|
|
@@ -132,6 +136,7 @@ class GroupTransactionNotesChanged {
|
|
|
132
136
|
this.createdBy = props.createdBy;
|
|
133
137
|
this.streamId = props.streamId;
|
|
134
138
|
this.version = props.version;
|
|
139
|
+
this.systemGenerated = props.systemGenerated;
|
|
135
140
|
}
|
|
136
141
|
apply(existing) {
|
|
137
142
|
if (!existing) {
|
|
@@ -163,6 +168,7 @@ class GroupTransactionNotesChanged {
|
|
|
163
168
|
createdAt: this.createdAt,
|
|
164
169
|
createdBy: this.createdBy,
|
|
165
170
|
streamId: (0, uuid_1.v4)(),
|
|
171
|
+
systemGenerated: true,
|
|
166
172
|
version: 1,
|
|
167
173
|
};
|
|
168
174
|
}
|
|
@@ -176,6 +182,7 @@ class GroupTransactionTotalAmountChanged {
|
|
|
176
182
|
this.createdBy = props.createdBy;
|
|
177
183
|
this.streamId = props.streamId;
|
|
178
184
|
this.version = props.version;
|
|
185
|
+
this.systemGenerated = props.systemGenerated;
|
|
179
186
|
}
|
|
180
187
|
apply(existing) {
|
|
181
188
|
if (!existing) {
|
|
@@ -207,6 +214,7 @@ class GroupTransactionTotalAmountChanged {
|
|
|
207
214
|
createdAt: this.createdAt,
|
|
208
215
|
createdBy: this.createdBy,
|
|
209
216
|
streamId: (0, uuid_1.v4)(),
|
|
217
|
+
systemGenerated: true,
|
|
210
218
|
version: 1,
|
|
211
219
|
};
|
|
212
220
|
}
|
|
@@ -220,6 +228,7 @@ class GroupTransactionCurrencyChanged {
|
|
|
220
228
|
this.createdBy = props.createdBy;
|
|
221
229
|
this.streamId = props.streamId;
|
|
222
230
|
this.version = props.version;
|
|
231
|
+
this.systemGenerated = props.systemGenerated;
|
|
223
232
|
}
|
|
224
233
|
apply(existing) {
|
|
225
234
|
if (!existing) {
|
|
@@ -251,6 +260,7 @@ class GroupTransactionCurrencyChanged {
|
|
|
251
260
|
createdAt: this.createdAt,
|
|
252
261
|
createdBy: this.createdBy,
|
|
253
262
|
streamId: (0, uuid_1.v4)(),
|
|
263
|
+
systemGenerated: true,
|
|
254
264
|
version: 1,
|
|
255
265
|
};
|
|
256
266
|
}
|
|
@@ -264,6 +274,7 @@ class GroupTransactionSplitTypeChanged {
|
|
|
264
274
|
this.createdBy = props.createdBy;
|
|
265
275
|
this.streamId = props.streamId;
|
|
266
276
|
this.version = props.version;
|
|
277
|
+
this.systemGenerated = props.systemGenerated;
|
|
267
278
|
}
|
|
268
279
|
apply(existing) {
|
|
269
280
|
if (!existing) {
|
|
@@ -295,6 +306,7 @@ class GroupTransactionSplitTypeChanged {
|
|
|
295
306
|
createdAt: this.createdAt,
|
|
296
307
|
createdBy: this.createdBy,
|
|
297
308
|
streamId: (0, uuid_1.v4)(),
|
|
309
|
+
systemGenerated: true,
|
|
298
310
|
version: 1,
|
|
299
311
|
};
|
|
300
312
|
}
|
|
@@ -308,6 +320,7 @@ class GroupTransactionDateChanged {
|
|
|
308
320
|
this.createdBy = props.createdBy;
|
|
309
321
|
this.streamId = props.streamId;
|
|
310
322
|
this.version = props.version;
|
|
323
|
+
this.systemGenerated = props.systemGenerated;
|
|
311
324
|
}
|
|
312
325
|
apply(existing) {
|
|
313
326
|
if (!existing) {
|
|
@@ -339,6 +352,7 @@ class GroupTransactionDateChanged {
|
|
|
339
352
|
createdAt: this.createdAt,
|
|
340
353
|
createdBy: this.createdBy,
|
|
341
354
|
streamId: (0, uuid_1.v4)(),
|
|
355
|
+
systemGenerated: true,
|
|
342
356
|
version: 1,
|
|
343
357
|
};
|
|
344
358
|
}
|
|
@@ -354,6 +368,7 @@ class GroupTransactionSplitDetailsChanged {
|
|
|
354
368
|
this.createdBy = props.createdBy;
|
|
355
369
|
this.streamId = props.streamId;
|
|
356
370
|
this.version = props.version;
|
|
371
|
+
this.systemGenerated = props.systemGenerated;
|
|
357
372
|
}
|
|
358
373
|
apply(existing) {
|
|
359
374
|
if (!existing) {
|
|
@@ -387,6 +402,7 @@ class GroupTransactionSplitDetailsChanged {
|
|
|
387
402
|
createdAt: this.createdAt,
|
|
388
403
|
createdBy: this.createdBy,
|
|
389
404
|
streamId: (0, uuid_1.v4)(),
|
|
405
|
+
systemGenerated: true,
|
|
390
406
|
version: 1,
|
|
391
407
|
};
|
|
392
408
|
}
|
|
@@ -399,6 +415,7 @@ class GroupTransactionDeleted {
|
|
|
399
415
|
this.createdBy = props.createdBy;
|
|
400
416
|
this.streamId = props.streamId;
|
|
401
417
|
this.version = props.version;
|
|
418
|
+
this.systemGenerated = props.systemGenerated;
|
|
402
419
|
}
|
|
403
420
|
apply(existing) {
|
|
404
421
|
if (!existing) {
|
|
@@ -431,6 +448,7 @@ class GroupTransactionDeleted {
|
|
|
431
448
|
createdAt: this.createdAt,
|
|
432
449
|
createdBy: this.createdBy,
|
|
433
450
|
streamId: (0, uuid_1.v4)(),
|
|
451
|
+
systemGenerated: true,
|
|
434
452
|
version: 1,
|
|
435
453
|
};
|
|
436
454
|
}
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import { Event } from '
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { TransactionModel, Event } from '.';
|
|
2
|
+
import { TransactionModelStore } from '.';
|
|
3
|
+
import { TransactionEventStore } from '.';
|
|
4
|
+
import { UserModelStore } from '.';
|
|
5
|
+
import { ActivityEventHandler } from './ActivityEventHandler';
|
|
5
6
|
export declare class TransactionEventHandler {
|
|
6
|
-
private eventStore;
|
|
7
7
|
private modelStore;
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
private eventStore;
|
|
9
|
+
private txUserModelStore;
|
|
10
|
+
private activityEventHandler?;
|
|
11
|
+
constructor(modelStore: TransactionModelStore, eventStore: TransactionEventStore, txUserModelStore: UserModelStore, activityEventHandler?: ActivityEventHandler | undefined);
|
|
12
|
+
handleEvent(event: Event): Promise<TransactionModel>;
|
|
13
|
+
private createMirrorEvent;
|
|
10
14
|
}
|
|
11
15
|
//# sourceMappingURL=TransactionEventHandler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TransactionEventHandler.d.ts","sourceRoot":"","sources":["../src/TransactionEventHandler.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"TransactionEventHandler.d.ts","sourceRoot":"","sources":["../src/TransactionEventHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAQH,gBAAgB,EAChB,KAAK,EACR,MAAM,GAAG,CAAC;AACX,OAAO,EAAC,qBAAqB,EAAC,MAAM,GAAG,CAAC;AACxC,OAAO,EAAC,qBAAqB,EAAC,MAAM,GAAG,CAAC;AACxC,OAAO,EAAC,cAAc,EAAC,MAAM,GAAG,CAAC;AACjC,OAAO,EAAC,oBAAoB,EAAC,MAAM,wBAAwB,CAAC;AAK5D,qBAAa,uBAAuB;IAE5B,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,gBAAgB;IACxB,OAAO,CAAC,oBAAoB,CAAC;gBAHrB,UAAU,EAAE,qBAAqB,EACjC,UAAU,EAAE,qBAAqB,EACjC,gBAAgB,EAAE,cAAc,EAChC,oBAAoB,CAAC,EAAE,oBAAoB,YAAA;IAGjD,WAAW,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,gBAAgB,CAAC;YA2B5C,iBAAiB;CAmJlC"}
|