@zeeshan60/event-processor 1.0.1 → 1.0.3
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/ActivityLogEvents.d.ts +43 -0
- package/dist/ActivityLogEvents.d.ts.map +1 -0
- package/dist/ActivityLogEvents.js +39 -0
- package/dist/FriendEvents.d.ts +122 -0
- package/dist/FriendEvents.d.ts.map +1 -0
- package/dist/FriendEvents.js +213 -0
- package/dist/GroupEvents.d.ts +140 -0
- package/dist/GroupEvents.d.ts.map +1 -0
- package/dist/GroupEvents.js +289 -0
- package/dist/GroupTransactionEvents.d.ts +228 -0
- package/dist/GroupTransactionEvents.d.ts.map +1 -0
- package/dist/GroupTransactionEvents.js +438 -0
- package/dist/TransactionEvents.d.ts +98 -56
- package/dist/TransactionEvents.d.ts.map +1 -1
- package/dist/TransactionEvents.js +345 -26
- package/dist/UserEvents.d.ts +54 -49
- package/dist/UserEvents.d.ts.map +1 -1
- package/dist/UserEvents.js +108 -8
- package/dist/common/Event.d.ts +3 -2
- package/dist/common/Event.d.ts.map +1 -1
- package/dist/common/Model.d.ts +0 -1
- package/dist/common/Model.d.ts.map +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +38 -3
- package/package.json +5 -1
|
@@ -0,0 +1,438 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GroupTransactionDeleted = exports.GroupTransactionSplitDetailsChanged = exports.GroupTransactionDateChanged = exports.GroupTransactionSplitTypeChanged = exports.GroupTransactionCurrencyChanged = exports.GroupTransactionTotalAmountChanged = exports.GroupTransactionNotesChanged = exports.GroupTransactionDescriptionChanged = exports.GroupTransactionCreated = exports.GroupTransactionEventType = void 0;
|
|
4
|
+
const ActivityLogEvents_1 = require("./ActivityLogEvents");
|
|
5
|
+
const uuid_1 = require("uuid");
|
|
6
|
+
var GroupTransactionEventType;
|
|
7
|
+
(function (GroupTransactionEventType) {
|
|
8
|
+
GroupTransactionEventType["GROUP_TRANSACTION_CREATED"] = "GROUP_TRANSACTION_CREATED";
|
|
9
|
+
GroupTransactionEventType["GROUP_TRANSACTION_DESCRIPTION_CHANGED"] = "GROUP_TRANSACTION_DESCRIPTION_CHANGED";
|
|
10
|
+
GroupTransactionEventType["GROUP_TRANSACTION_NOTES_CHANGED"] = "GROUP_TRANSACTION_NOTES_CHANGED";
|
|
11
|
+
GroupTransactionEventType["GROUP_TRANSACTION_TOTAL_AMOUNT_CHANGED"] = "GROUP_TRANSACTION_TOTAL_AMOUNT_CHANGED";
|
|
12
|
+
GroupTransactionEventType["GROUP_TRANSACTION_CURRENCY_CHANGED"] = "GROUP_TRANSACTION_CURRENCY_CHANGED";
|
|
13
|
+
GroupTransactionEventType["GROUP_TRANSACTION_SPLIT_TYPE_CHANGED"] = "GROUP_TRANSACTION_SPLIT_TYPE_CHANGED";
|
|
14
|
+
GroupTransactionEventType["GROUP_TRANSACTION_DATE_CHANGED"] = "GROUP_TRANSACTION_DATE_CHANGED";
|
|
15
|
+
GroupTransactionEventType["GROUP_TRANSACTION_SPLIT_DETAILS_CHANGED"] = "GROUP_TRANSACTION_SPLIT_DETAILS_CHANGED";
|
|
16
|
+
GroupTransactionEventType["GROUP_TRANSACTION_DELETED"] = "GROUP_TRANSACTION_DELETED";
|
|
17
|
+
})(GroupTransactionEventType || (exports.GroupTransactionEventType = GroupTransactionEventType = {}));
|
|
18
|
+
class GroupTransactionCreated {
|
|
19
|
+
constructor(props) {
|
|
20
|
+
this.userId = props.userId;
|
|
21
|
+
this.groupId = props.groupId;
|
|
22
|
+
this.transactionId = props.transactionId;
|
|
23
|
+
this.description = props.description;
|
|
24
|
+
this.notes = props.notes;
|
|
25
|
+
this.totalAmount = props.totalAmount;
|
|
26
|
+
this.currency = props.currency;
|
|
27
|
+
this.splitType = props.splitType;
|
|
28
|
+
this.transactionDate = props.transactionDate;
|
|
29
|
+
this.originalTransaction = props.originalTransaction;
|
|
30
|
+
this.createdAt = props.createdAt;
|
|
31
|
+
this.createdBy = props.createdBy;
|
|
32
|
+
this.streamId = props.streamId;
|
|
33
|
+
this.version = props.version;
|
|
34
|
+
}
|
|
35
|
+
apply(_existing) {
|
|
36
|
+
if (!this.userId) {
|
|
37
|
+
throw new Error('userId is required for GroupTransactionModel');
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
streamId: this.streamId,
|
|
41
|
+
userId: this.userId,
|
|
42
|
+
groupId: this.groupId,
|
|
43
|
+
transactionId: this.transactionId,
|
|
44
|
+
description: this.description,
|
|
45
|
+
notes: this.notes,
|
|
46
|
+
totalAmount: this.totalAmount,
|
|
47
|
+
currency: this.currency,
|
|
48
|
+
splitType: this.splitType,
|
|
49
|
+
transactionDate: this.transactionDate,
|
|
50
|
+
originalTransaction: this.originalTransaction,
|
|
51
|
+
createdAt: this.createdAt,
|
|
52
|
+
updatedAt: this.createdAt,
|
|
53
|
+
createdBy: this.createdBy,
|
|
54
|
+
updatedBy: this.createdBy,
|
|
55
|
+
version: this.version,
|
|
56
|
+
deleted: false,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
activityLog(_existing, actorName) {
|
|
60
|
+
if (!this.userId) {
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
63
|
+
const actor = actorName ?? 'You';
|
|
64
|
+
const desc = this.description ?? 'transaction';
|
|
65
|
+
const logMessage = `${actor} created transaction "${desc}" for ${this.totalAmount} ${this.currency}`;
|
|
66
|
+
return {
|
|
67
|
+
userId: this.userId,
|
|
68
|
+
activityByUid: this.createdBy,
|
|
69
|
+
sourceStreamId: this.streamId,
|
|
70
|
+
sourceType: ActivityLogEvents_1.SourceType.GroupTransaction,
|
|
71
|
+
logMessage,
|
|
72
|
+
date: this.transactionDate,
|
|
73
|
+
createdAt: this.createdAt,
|
|
74
|
+
createdBy: this.createdBy,
|
|
75
|
+
streamId: (0, uuid_1.v4)(),
|
|
76
|
+
version: 1,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
exports.GroupTransactionCreated = GroupTransactionCreated;
|
|
81
|
+
class GroupTransactionDescriptionChanged {
|
|
82
|
+
constructor(props) {
|
|
83
|
+
this.userId = props.userId;
|
|
84
|
+
this.description = props.description;
|
|
85
|
+
this.createdAt = props.createdAt;
|
|
86
|
+
this.createdBy = props.createdBy;
|
|
87
|
+
this.streamId = props.streamId;
|
|
88
|
+
this.version = props.version;
|
|
89
|
+
}
|
|
90
|
+
apply(existing) {
|
|
91
|
+
if (!existing) {
|
|
92
|
+
throw new Error('GroupTransaction must exist to change description');
|
|
93
|
+
}
|
|
94
|
+
const existingTx = existing;
|
|
95
|
+
return {
|
|
96
|
+
...existingTx,
|
|
97
|
+
description: this.description,
|
|
98
|
+
updatedAt: this.createdAt,
|
|
99
|
+
updatedBy: this.createdBy,
|
|
100
|
+
version: this.version,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
activityLog(existing, actorName) {
|
|
104
|
+
if (!existing) {
|
|
105
|
+
return undefined;
|
|
106
|
+
}
|
|
107
|
+
const existingTx = existing;
|
|
108
|
+
const actor = actorName ?? 'You';
|
|
109
|
+
const oldDesc = existingTx.description ?? 'transaction';
|
|
110
|
+
const newDesc = this.description ?? 'transaction';
|
|
111
|
+
const logMessage = `${actor} changed transaction description from "${oldDesc}" to "${newDesc}"`;
|
|
112
|
+
return {
|
|
113
|
+
userId: existingTx.userId,
|
|
114
|
+
activityByUid: this.createdBy,
|
|
115
|
+
sourceStreamId: this.streamId,
|
|
116
|
+
sourceType: ActivityLogEvents_1.SourceType.GroupTransaction,
|
|
117
|
+
logMessage,
|
|
118
|
+
date: this.createdAt,
|
|
119
|
+
createdAt: this.createdAt,
|
|
120
|
+
createdBy: this.createdBy,
|
|
121
|
+
streamId: (0, uuid_1.v4)(),
|
|
122
|
+
version: 1,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
exports.GroupTransactionDescriptionChanged = GroupTransactionDescriptionChanged;
|
|
127
|
+
class GroupTransactionNotesChanged {
|
|
128
|
+
constructor(props) {
|
|
129
|
+
this.userId = props.userId;
|
|
130
|
+
this.notes = props.notes;
|
|
131
|
+
this.createdAt = props.createdAt;
|
|
132
|
+
this.createdBy = props.createdBy;
|
|
133
|
+
this.streamId = props.streamId;
|
|
134
|
+
this.version = props.version;
|
|
135
|
+
}
|
|
136
|
+
apply(existing) {
|
|
137
|
+
if (!existing) {
|
|
138
|
+
throw new Error('GroupTransaction must exist to change notes');
|
|
139
|
+
}
|
|
140
|
+
const existingTx = existing;
|
|
141
|
+
return {
|
|
142
|
+
...existingTx,
|
|
143
|
+
notes: this.notes,
|
|
144
|
+
updatedAt: this.createdAt,
|
|
145
|
+
updatedBy: this.createdBy,
|
|
146
|
+
version: this.version,
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
activityLog(existing, actorName) {
|
|
150
|
+
if (!existing) {
|
|
151
|
+
return undefined;
|
|
152
|
+
}
|
|
153
|
+
const existingTx = existing;
|
|
154
|
+
const actor = actorName ?? 'You';
|
|
155
|
+
const logMessage = `${actor} updated transaction notes`;
|
|
156
|
+
return {
|
|
157
|
+
userId: existingTx.userId,
|
|
158
|
+
activityByUid: this.createdBy,
|
|
159
|
+
sourceStreamId: this.streamId,
|
|
160
|
+
sourceType: ActivityLogEvents_1.SourceType.GroupTransaction,
|
|
161
|
+
logMessage,
|
|
162
|
+
date: this.createdAt,
|
|
163
|
+
createdAt: this.createdAt,
|
|
164
|
+
createdBy: this.createdBy,
|
|
165
|
+
streamId: (0, uuid_1.v4)(),
|
|
166
|
+
version: 1,
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
exports.GroupTransactionNotesChanged = GroupTransactionNotesChanged;
|
|
171
|
+
class GroupTransactionTotalAmountChanged {
|
|
172
|
+
constructor(props) {
|
|
173
|
+
this.userId = props.userId;
|
|
174
|
+
this.totalAmount = props.totalAmount;
|
|
175
|
+
this.createdAt = props.createdAt;
|
|
176
|
+
this.createdBy = props.createdBy;
|
|
177
|
+
this.streamId = props.streamId;
|
|
178
|
+
this.version = props.version;
|
|
179
|
+
}
|
|
180
|
+
apply(existing) {
|
|
181
|
+
if (!existing) {
|
|
182
|
+
throw new Error('GroupTransaction must exist to change total amount');
|
|
183
|
+
}
|
|
184
|
+
const existingTx = existing;
|
|
185
|
+
return {
|
|
186
|
+
...existingTx,
|
|
187
|
+
totalAmount: this.totalAmount,
|
|
188
|
+
updatedAt: this.createdAt,
|
|
189
|
+
updatedBy: this.createdBy,
|
|
190
|
+
version: this.version,
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
activityLog(existing, actorName) {
|
|
194
|
+
if (!existing) {
|
|
195
|
+
return undefined;
|
|
196
|
+
}
|
|
197
|
+
const existingTx = existing;
|
|
198
|
+
const actor = actorName ?? 'You';
|
|
199
|
+
const logMessage = `${actor} changed amount from ${existingTx.totalAmount} ${existingTx.currency} to ${this.totalAmount} ${existingTx.currency}`;
|
|
200
|
+
return {
|
|
201
|
+
userId: existingTx.userId,
|
|
202
|
+
activityByUid: this.createdBy,
|
|
203
|
+
sourceStreamId: this.streamId,
|
|
204
|
+
sourceType: ActivityLogEvents_1.SourceType.GroupTransaction,
|
|
205
|
+
logMessage,
|
|
206
|
+
date: this.createdAt,
|
|
207
|
+
createdAt: this.createdAt,
|
|
208
|
+
createdBy: this.createdBy,
|
|
209
|
+
streamId: (0, uuid_1.v4)(),
|
|
210
|
+
version: 1,
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
exports.GroupTransactionTotalAmountChanged = GroupTransactionTotalAmountChanged;
|
|
215
|
+
class GroupTransactionCurrencyChanged {
|
|
216
|
+
constructor(props) {
|
|
217
|
+
this.userId = props.userId;
|
|
218
|
+
this.currency = props.currency;
|
|
219
|
+
this.createdAt = props.createdAt;
|
|
220
|
+
this.createdBy = props.createdBy;
|
|
221
|
+
this.streamId = props.streamId;
|
|
222
|
+
this.version = props.version;
|
|
223
|
+
}
|
|
224
|
+
apply(existing) {
|
|
225
|
+
if (!existing) {
|
|
226
|
+
throw new Error('GroupTransaction must exist to change currency');
|
|
227
|
+
}
|
|
228
|
+
const existingTx = existing;
|
|
229
|
+
return {
|
|
230
|
+
...existingTx,
|
|
231
|
+
currency: this.currency,
|
|
232
|
+
updatedAt: this.createdAt,
|
|
233
|
+
updatedBy: this.createdBy,
|
|
234
|
+
version: this.version,
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
activityLog(existing, actorName) {
|
|
238
|
+
if (!existing) {
|
|
239
|
+
return undefined;
|
|
240
|
+
}
|
|
241
|
+
const existingTx = existing;
|
|
242
|
+
const actor = actorName ?? 'You';
|
|
243
|
+
const logMessage = `${actor} changed currency from ${existingTx.currency} to ${this.currency}`;
|
|
244
|
+
return {
|
|
245
|
+
userId: existingTx.userId,
|
|
246
|
+
activityByUid: this.createdBy,
|
|
247
|
+
sourceStreamId: this.streamId,
|
|
248
|
+
sourceType: ActivityLogEvents_1.SourceType.GroupTransaction,
|
|
249
|
+
logMessage,
|
|
250
|
+
date: this.createdAt,
|
|
251
|
+
createdAt: this.createdAt,
|
|
252
|
+
createdBy: this.createdBy,
|
|
253
|
+
streamId: (0, uuid_1.v4)(),
|
|
254
|
+
version: 1,
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
exports.GroupTransactionCurrencyChanged = GroupTransactionCurrencyChanged;
|
|
259
|
+
class GroupTransactionSplitTypeChanged {
|
|
260
|
+
constructor(props) {
|
|
261
|
+
this.userId = props.userId;
|
|
262
|
+
this.splitType = props.splitType;
|
|
263
|
+
this.createdAt = props.createdAt;
|
|
264
|
+
this.createdBy = props.createdBy;
|
|
265
|
+
this.streamId = props.streamId;
|
|
266
|
+
this.version = props.version;
|
|
267
|
+
}
|
|
268
|
+
apply(existing) {
|
|
269
|
+
if (!existing) {
|
|
270
|
+
throw new Error('GroupTransaction must exist to change split type');
|
|
271
|
+
}
|
|
272
|
+
const existingTx = existing;
|
|
273
|
+
return {
|
|
274
|
+
...existingTx,
|
|
275
|
+
splitType: this.splitType,
|
|
276
|
+
updatedAt: this.createdAt,
|
|
277
|
+
updatedBy: this.createdBy,
|
|
278
|
+
version: this.version,
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
activityLog(existing, actorName) {
|
|
282
|
+
if (!existing) {
|
|
283
|
+
return undefined;
|
|
284
|
+
}
|
|
285
|
+
const existingTx = existing;
|
|
286
|
+
const actor = actorName ?? 'You';
|
|
287
|
+
const logMessage = `${actor} changed split type from ${existingTx.splitType} to ${this.splitType}`;
|
|
288
|
+
return {
|
|
289
|
+
userId: existingTx.userId,
|
|
290
|
+
activityByUid: this.createdBy,
|
|
291
|
+
sourceStreamId: this.streamId,
|
|
292
|
+
sourceType: ActivityLogEvents_1.SourceType.GroupTransaction,
|
|
293
|
+
logMessage,
|
|
294
|
+
date: this.createdAt,
|
|
295
|
+
createdAt: this.createdAt,
|
|
296
|
+
createdBy: this.createdBy,
|
|
297
|
+
streamId: (0, uuid_1.v4)(),
|
|
298
|
+
version: 1,
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
exports.GroupTransactionSplitTypeChanged = GroupTransactionSplitTypeChanged;
|
|
303
|
+
class GroupTransactionDateChanged {
|
|
304
|
+
constructor(props) {
|
|
305
|
+
this.userId = props.userId;
|
|
306
|
+
this.transactionDate = props.transactionDate;
|
|
307
|
+
this.createdAt = props.createdAt;
|
|
308
|
+
this.createdBy = props.createdBy;
|
|
309
|
+
this.streamId = props.streamId;
|
|
310
|
+
this.version = props.version;
|
|
311
|
+
}
|
|
312
|
+
apply(existing) {
|
|
313
|
+
if (!existing) {
|
|
314
|
+
throw new Error('GroupTransaction must exist to change transaction date');
|
|
315
|
+
}
|
|
316
|
+
const existingTx = existing;
|
|
317
|
+
return {
|
|
318
|
+
...existingTx,
|
|
319
|
+
transactionDate: this.transactionDate,
|
|
320
|
+
updatedAt: this.createdAt,
|
|
321
|
+
updatedBy: this.createdBy,
|
|
322
|
+
version: this.version,
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
activityLog(existing, actorName) {
|
|
326
|
+
if (!existing) {
|
|
327
|
+
return undefined;
|
|
328
|
+
}
|
|
329
|
+
const existingTx = existing;
|
|
330
|
+
const actor = actorName ?? 'You';
|
|
331
|
+
const logMessage = `${actor} changed transaction date from ${existingTx.transactionDate.toLocaleDateString()} to ${this.transactionDate.toLocaleDateString()}`;
|
|
332
|
+
return {
|
|
333
|
+
userId: existingTx.userId,
|
|
334
|
+
activityByUid: this.createdBy,
|
|
335
|
+
sourceStreamId: this.streamId,
|
|
336
|
+
sourceType: ActivityLogEvents_1.SourceType.GroupTransaction,
|
|
337
|
+
logMessage,
|
|
338
|
+
date: this.createdAt,
|
|
339
|
+
createdAt: this.createdAt,
|
|
340
|
+
createdBy: this.createdBy,
|
|
341
|
+
streamId: (0, uuid_1.v4)(),
|
|
342
|
+
version: 1,
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
exports.GroupTransactionDateChanged = GroupTransactionDateChanged;
|
|
347
|
+
class GroupTransactionSplitDetailsChanged {
|
|
348
|
+
constructor(props) {
|
|
349
|
+
this.userId = props.userId;
|
|
350
|
+
this.totalAmount = props.totalAmount;
|
|
351
|
+
this.splitType = props.splitType;
|
|
352
|
+
this.originalTransaction = props.originalTransaction;
|
|
353
|
+
this.createdAt = props.createdAt;
|
|
354
|
+
this.createdBy = props.createdBy;
|
|
355
|
+
this.streamId = props.streamId;
|
|
356
|
+
this.version = props.version;
|
|
357
|
+
}
|
|
358
|
+
apply(existing) {
|
|
359
|
+
if (!existing) {
|
|
360
|
+
throw new Error('GroupTransaction must exist to change split details');
|
|
361
|
+
}
|
|
362
|
+
const existingTx = existing;
|
|
363
|
+
return {
|
|
364
|
+
...existingTx,
|
|
365
|
+
totalAmount: this.totalAmount,
|
|
366
|
+
splitType: this.splitType,
|
|
367
|
+
originalTransaction: this.originalTransaction,
|
|
368
|
+
updatedAt: this.createdAt,
|
|
369
|
+
updatedBy: this.createdBy,
|
|
370
|
+
version: this.version,
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
activityLog(existing, actorName) {
|
|
374
|
+
if (!existing) {
|
|
375
|
+
return undefined;
|
|
376
|
+
}
|
|
377
|
+
const existingTx = existing;
|
|
378
|
+
const actor = actorName ?? 'You';
|
|
379
|
+
const logMessage = `${actor} updated transaction split details`;
|
|
380
|
+
return {
|
|
381
|
+
userId: existingTx.userId,
|
|
382
|
+
activityByUid: this.createdBy,
|
|
383
|
+
sourceStreamId: this.streamId,
|
|
384
|
+
sourceType: ActivityLogEvents_1.SourceType.GroupTransaction,
|
|
385
|
+
logMessage,
|
|
386
|
+
date: this.createdAt,
|
|
387
|
+
createdAt: this.createdAt,
|
|
388
|
+
createdBy: this.createdBy,
|
|
389
|
+
streamId: (0, uuid_1.v4)(),
|
|
390
|
+
version: 1,
|
|
391
|
+
};
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
exports.GroupTransactionSplitDetailsChanged = GroupTransactionSplitDetailsChanged;
|
|
395
|
+
class GroupTransactionDeleted {
|
|
396
|
+
constructor(props) {
|
|
397
|
+
this.userId = props.userId;
|
|
398
|
+
this.createdAt = props.createdAt;
|
|
399
|
+
this.createdBy = props.createdBy;
|
|
400
|
+
this.streamId = props.streamId;
|
|
401
|
+
this.version = props.version;
|
|
402
|
+
}
|
|
403
|
+
apply(existing) {
|
|
404
|
+
if (!existing) {
|
|
405
|
+
throw new Error('GroupTransaction must exist to delete');
|
|
406
|
+
}
|
|
407
|
+
const existingTx = existing;
|
|
408
|
+
return {
|
|
409
|
+
...existingTx,
|
|
410
|
+
updatedAt: this.createdAt,
|
|
411
|
+
updatedBy: this.createdBy,
|
|
412
|
+
version: this.version,
|
|
413
|
+
deleted: true,
|
|
414
|
+
};
|
|
415
|
+
}
|
|
416
|
+
activityLog(existing, actorName) {
|
|
417
|
+
if (!existing) {
|
|
418
|
+
return undefined;
|
|
419
|
+
}
|
|
420
|
+
const existingTx = existing;
|
|
421
|
+
const actor = actorName ?? 'You';
|
|
422
|
+
const desc = existingTx.description ?? 'transaction';
|
|
423
|
+
const logMessage = `${actor} deleted transaction "${desc}"`;
|
|
424
|
+
return {
|
|
425
|
+
userId: existingTx.userId,
|
|
426
|
+
activityByUid: this.createdBy,
|
|
427
|
+
sourceStreamId: this.streamId,
|
|
428
|
+
sourceType: ActivityLogEvents_1.SourceType.GroupTransaction,
|
|
429
|
+
logMessage,
|
|
430
|
+
date: this.createdAt,
|
|
431
|
+
createdAt: this.createdAt,
|
|
432
|
+
createdBy: this.createdBy,
|
|
433
|
+
streamId: (0, uuid_1.v4)(),
|
|
434
|
+
version: 1,
|
|
435
|
+
};
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
exports.GroupTransactionDeleted = GroupTransactionDeleted;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Event } from './common/Event';
|
|
2
2
|
import { Model } from './common/Model';
|
|
3
|
+
import { ActivityLogCreatedProps } from './ActivityLogEvents';
|
|
3
4
|
export declare enum SplitType {
|
|
4
5
|
YouPaidSplitEqually = "YouPaidSplitEqually",
|
|
5
6
|
TheyPaidSplitEqually = "TheyPaidSplitEqually",
|
|
@@ -64,17 +65,18 @@ export interface TransactionModel extends Model {
|
|
|
64
65
|
splitType: SplitType;
|
|
65
66
|
totalAmount: number;
|
|
66
67
|
amount: number;
|
|
68
|
+
isOwed: boolean;
|
|
67
69
|
transactionDate: Date;
|
|
68
70
|
createdAt: Date;
|
|
69
71
|
updatedAt: Date;
|
|
70
72
|
createdBy: string;
|
|
71
73
|
updatedBy: string;
|
|
72
|
-
groupId
|
|
73
|
-
groupTransactionId
|
|
74
|
+
groupId?: string;
|
|
75
|
+
groupTransactionId?: string;
|
|
74
76
|
history: ChangeHistory;
|
|
75
77
|
}
|
|
76
78
|
export interface TransactionCreatedProps {
|
|
77
|
-
userId
|
|
79
|
+
userId?: string;
|
|
78
80
|
recipientUserId: string;
|
|
79
81
|
logicalTransactionId: string;
|
|
80
82
|
description: string;
|
|
@@ -82,16 +84,17 @@ export interface TransactionCreatedProps {
|
|
|
82
84
|
splitType: SplitType;
|
|
83
85
|
totalAmount: number;
|
|
84
86
|
amount: number;
|
|
87
|
+
isOwed: boolean;
|
|
85
88
|
transactionDate: Date;
|
|
86
|
-
groupId
|
|
87
|
-
groupTransactionId
|
|
89
|
+
groupId?: string;
|
|
90
|
+
groupTransactionId?: string;
|
|
88
91
|
createdAt: Date;
|
|
89
92
|
createdBy: string;
|
|
90
93
|
streamId: string;
|
|
91
94
|
version: number;
|
|
92
95
|
}
|
|
93
96
|
export declare class TransactionCreated implements Event {
|
|
94
|
-
userId
|
|
97
|
+
userId?: string;
|
|
95
98
|
recipientUserId: string;
|
|
96
99
|
logicalTransactionId: string;
|
|
97
100
|
description: string;
|
|
@@ -99,69 +102,34 @@ export declare class TransactionCreated implements Event {
|
|
|
99
102
|
splitType: SplitType;
|
|
100
103
|
totalAmount: number;
|
|
101
104
|
amount: number;
|
|
105
|
+
isOwed: boolean;
|
|
102
106
|
transactionDate: Date;
|
|
103
|
-
groupId
|
|
104
|
-
groupTransactionId
|
|
107
|
+
groupId?: string;
|
|
108
|
+
groupTransactionId?: string;
|
|
105
109
|
createdAt: Date;
|
|
106
110
|
createdBy: string;
|
|
107
111
|
streamId: string;
|
|
108
112
|
version: number;
|
|
109
113
|
constructor(props: TransactionCreatedProps);
|
|
110
|
-
apply(_existing
|
|
111
|
-
|
|
112
|
-
export interface ChangeSummary {
|
|
113
|
-
date: Date;
|
|
114
|
-
changedBy: string;
|
|
115
|
-
oldValue: string;
|
|
116
|
-
newValue: string;
|
|
117
|
-
type: TransactionChangeType;
|
|
118
|
-
}
|
|
119
|
-
export declare enum TransactionChangeType {
|
|
120
|
-
TRANSACTION_DATE = "TRANSACTION_DATE",
|
|
121
|
-
DESCRIPTION = "DESCRIPTION",
|
|
122
|
-
TOTAL_AMOUNT = "TOTAL_AMOUNT",
|
|
123
|
-
CURRENCY = "CURRENCY",
|
|
124
|
-
SPLIT_TYPE = "SPLIT_TYPE",
|
|
125
|
-
DELETED = "DELETED"
|
|
126
|
-
}
|
|
127
|
-
export declare enum ActivityType {
|
|
128
|
-
CREATED = "CREATED",
|
|
129
|
-
UPDATED = "UPDATED",
|
|
130
|
-
DELETED = "DELETED"
|
|
131
|
-
}
|
|
132
|
-
export interface ActivityLog {
|
|
133
|
-
id: string;
|
|
134
|
-
userId: string;
|
|
135
|
-
activityByUid: string;
|
|
136
|
-
description: string;
|
|
137
|
-
activityType: ActivityType;
|
|
138
|
-
amount: number;
|
|
139
|
-
currency: string;
|
|
140
|
-
isOwed: boolean;
|
|
141
|
-
date: Date;
|
|
142
|
-
transactionModel: TransactionModel;
|
|
114
|
+
apply(_existing?: Model): TransactionModel;
|
|
115
|
+
activityLog(_existing?: Model, actorName?: string): ActivityLogCreatedProps | undefined;
|
|
143
116
|
}
|
|
144
117
|
export interface TransactionDeletedProps {
|
|
145
|
-
userId: string;
|
|
146
|
-
recipientUserId: string;
|
|
147
118
|
streamId: string;
|
|
148
119
|
version: number;
|
|
149
120
|
createdAt: Date;
|
|
150
121
|
createdBy: string;
|
|
151
122
|
}
|
|
152
123
|
export declare class TransactionDeleted implements Event {
|
|
153
|
-
userId: string;
|
|
154
|
-
recipientUserId: string;
|
|
155
124
|
streamId: string;
|
|
156
125
|
version: number;
|
|
157
126
|
createdAt: Date;
|
|
158
127
|
createdBy: string;
|
|
159
128
|
constructor(props: TransactionDeletedProps);
|
|
160
|
-
apply(existing
|
|
129
|
+
apply(existing?: Model): TransactionModel;
|
|
130
|
+
activityLog(existing?: Model, actorName?: string): ActivityLogCreatedProps | undefined;
|
|
161
131
|
}
|
|
162
132
|
export interface DescriptionChangedProps {
|
|
163
|
-
userId: string;
|
|
164
|
-
recipientUserId: string;
|
|
165
133
|
description: string;
|
|
166
134
|
streamId: string;
|
|
167
135
|
version: number;
|
|
@@ -169,19 +137,16 @@ export interface DescriptionChangedProps {
|
|
|
169
137
|
createdBy: string;
|
|
170
138
|
}
|
|
171
139
|
export declare class DescriptionChanged implements Event {
|
|
172
|
-
userId: string;
|
|
173
|
-
recipientUserId: string;
|
|
174
140
|
description: string;
|
|
175
141
|
streamId: string;
|
|
176
142
|
version: number;
|
|
177
143
|
createdAt: Date;
|
|
178
144
|
createdBy: string;
|
|
179
145
|
constructor(props: DescriptionChangedProps);
|
|
180
|
-
apply(existing
|
|
146
|
+
apply(existing?: Model): TransactionModel;
|
|
147
|
+
activityLog(existing?: Model, actorName?: string): ActivityLogCreatedProps | undefined;
|
|
181
148
|
}
|
|
182
149
|
export interface TotalAmountChangedProps {
|
|
183
|
-
userId: string;
|
|
184
|
-
recipientUserId: string;
|
|
185
150
|
totalAmount: number;
|
|
186
151
|
streamId: string;
|
|
187
152
|
version: number;
|
|
@@ -189,14 +154,91 @@ export interface TotalAmountChangedProps {
|
|
|
189
154
|
createdBy: string;
|
|
190
155
|
}
|
|
191
156
|
export declare class TotalAmountChanged implements Event {
|
|
192
|
-
userId: string;
|
|
193
|
-
recipientUserId: string;
|
|
194
157
|
totalAmount: number;
|
|
195
158
|
streamId: string;
|
|
196
159
|
version: number;
|
|
197
160
|
createdAt: Date;
|
|
198
161
|
createdBy: string;
|
|
199
162
|
constructor(props: TotalAmountChangedProps);
|
|
200
|
-
apply(existing
|
|
163
|
+
apply(existing?: Model): TransactionModel;
|
|
164
|
+
activityLog(existing?: Model, actorName?: string): ActivityLogCreatedProps | undefined;
|
|
165
|
+
}
|
|
166
|
+
export interface SplitTypeChangedProps {
|
|
167
|
+
splitType: SplitType;
|
|
168
|
+
totalAmount: number;
|
|
169
|
+
amount: number;
|
|
170
|
+
isOwed: boolean;
|
|
171
|
+
streamId: string;
|
|
172
|
+
version: number;
|
|
173
|
+
createdAt: Date;
|
|
174
|
+
createdBy: string;
|
|
175
|
+
}
|
|
176
|
+
export declare class SplitTypeChanged implements Event {
|
|
177
|
+
splitType: SplitType;
|
|
178
|
+
totalAmount: number;
|
|
179
|
+
amount: number;
|
|
180
|
+
isOwed: boolean;
|
|
181
|
+
streamId: string;
|
|
182
|
+
version: number;
|
|
183
|
+
createdAt: Date;
|
|
184
|
+
createdBy: string;
|
|
185
|
+
constructor(props: SplitTypeChangedProps);
|
|
186
|
+
apply(existing?: Model): TransactionModel;
|
|
187
|
+
activityLog(existing?: Model, actorName?: string): ActivityLogCreatedProps | undefined;
|
|
188
|
+
}
|
|
189
|
+
export interface CurrencyChangedProps {
|
|
190
|
+
currency: string;
|
|
191
|
+
streamId: string;
|
|
192
|
+
version: number;
|
|
193
|
+
createdAt: Date;
|
|
194
|
+
createdBy: string;
|
|
195
|
+
}
|
|
196
|
+
export declare class CurrencyChanged implements Event {
|
|
197
|
+
currency: string;
|
|
198
|
+
streamId: string;
|
|
199
|
+
version: number;
|
|
200
|
+
createdAt: Date;
|
|
201
|
+
createdBy: string;
|
|
202
|
+
constructor(props: CurrencyChangedProps);
|
|
203
|
+
apply(existing?: Model): TransactionModel;
|
|
204
|
+
activityLog(existing?: Model, actorName?: string): ActivityLogCreatedProps | undefined;
|
|
205
|
+
}
|
|
206
|
+
export interface TransactionDateChangedProps {
|
|
207
|
+
transactionDate: Date;
|
|
208
|
+
streamId: string;
|
|
209
|
+
version: number;
|
|
210
|
+
createdAt: Date;
|
|
211
|
+
createdBy: string;
|
|
212
|
+
}
|
|
213
|
+
export declare class TransactionDateChanged implements Event {
|
|
214
|
+
transactionDate: Date;
|
|
215
|
+
streamId: string;
|
|
216
|
+
version: number;
|
|
217
|
+
createdAt: Date;
|
|
218
|
+
createdBy: string;
|
|
219
|
+
constructor(props: TransactionDateChangedProps);
|
|
220
|
+
apply(existing?: Model): TransactionModel;
|
|
221
|
+
activityLog(existing?: Model, actorName?: string): ActivityLogCreatedProps | undefined;
|
|
222
|
+
}
|
|
223
|
+
export interface TransactionDetailsChangedProps {
|
|
224
|
+
totalAmount: number;
|
|
225
|
+
amount: number;
|
|
226
|
+
isOwed: boolean;
|
|
227
|
+
streamId: string;
|
|
228
|
+
version: number;
|
|
229
|
+
createdAt: Date;
|
|
230
|
+
createdBy: string;
|
|
231
|
+
}
|
|
232
|
+
export declare class TransactionDetailsChanged implements Event {
|
|
233
|
+
totalAmount: number;
|
|
234
|
+
amount: number;
|
|
235
|
+
isOwed: boolean;
|
|
236
|
+
streamId: string;
|
|
237
|
+
version: number;
|
|
238
|
+
createdAt: Date;
|
|
239
|
+
createdBy: string;
|
|
240
|
+
constructor(props: TransactionDetailsChangedProps);
|
|
241
|
+
apply(existing?: Model): TransactionModel;
|
|
242
|
+
activityLog(existing?: Model, actorName?: string): ActivityLogCreatedProps | undefined;
|
|
201
243
|
}
|
|
202
244
|
//# sourceMappingURL=TransactionEvents.d.ts.map
|