@zeeshan60/event-processor 1.0.14 → 1.0.16
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/README.md +29 -22
- package/dist/ActivityEventHandler.d.ts +5 -6
- package/dist/ActivityEventHandler.d.ts.map +1 -1
- package/dist/ActivityEventHandler.js +16 -8
- package/dist/ActivityLogEvents.d.ts.map +1 -1
- package/dist/BaseEventHandler.d.ts +8 -0
- package/dist/BaseEventHandler.d.ts.map +1 -0
- package/dist/BaseEventHandler.js +13 -0
- package/dist/EventProcessorSDK.d.ts +10 -2
- package/dist/EventProcessorSDK.d.ts.map +1 -1
- package/dist/EventProcessorSDK.js +21 -5
- package/dist/FriendEventHandler.d.ts +6 -2
- package/dist/FriendEventHandler.d.ts.map +1 -1
- package/dist/FriendEventHandler.js +50 -45
- package/dist/GroupEventHandler.d.ts +5 -8
- package/dist/GroupEventHandler.d.ts.map +1 -1
- package/dist/GroupEventHandler.js +241 -186
- package/dist/GroupEvents.d.ts.map +1 -1
- package/dist/GroupTransactionEventHandler.d.ts +3 -2
- package/dist/GroupTransactionEventHandler.d.ts.map +1 -1
- package/dist/GroupTransactionEventHandler.js +11 -10
- package/dist/GroupTransactionEvents.d.ts.map +1 -1
- package/dist/ModelChangeEmitter.d.ts +1 -1
- package/dist/ModelChangeEmitter.d.ts.map +1 -1
- package/dist/TransactionEventHandler.d.ts +5 -5
- package/dist/TransactionEventHandler.d.ts.map +1 -1
- package/dist/TransactionEventHandler.js +19 -30
- package/dist/TransactionEvents.d.ts.map +1 -1
- package/dist/UserEventHandler.d.ts +4 -3
- package/dist/UserEventHandler.d.ts.map +1 -1
- package/dist/UserEventHandler.js +16 -40
- package/dist/UserEvents.d.ts.map +1 -1
- package/dist/__tests__/test-helpers/IMActivityLogEventStore.d.ts +1 -2
- package/dist/__tests__/test-helpers/IMActivityLogEventStore.d.ts.map +1 -1
- package/dist/__tests__/test-helpers/IMActivityLogModelStore.d.ts +1 -2
- package/dist/__tests__/test-helpers/IMActivityLogModelStore.d.ts.map +1 -1
- package/dist/__tests__/test-helpers/IMCurrencyStore.d.ts +8 -0
- package/dist/__tests__/test-helpers/IMCurrencyStore.d.ts.map +1 -0
- package/dist/__tests__/test-helpers/IMCurrencyStore.js +16 -0
- package/dist/__tests__/test-helpers/IMFriendEventStore.d.ts +1 -2
- package/dist/__tests__/test-helpers/IMFriendEventStore.d.ts.map +1 -1
- package/dist/__tests__/test-helpers/IMFriendModelStore.d.ts +1 -2
- package/dist/__tests__/test-helpers/IMFriendModelStore.d.ts.map +1 -1
- package/dist/__tests__/test-helpers/IMGroupEventStore.d.ts +1 -2
- package/dist/__tests__/test-helpers/IMGroupEventStore.d.ts.map +1 -1
- package/dist/__tests__/test-helpers/IMGroupModelStore.d.ts +1 -2
- package/dist/__tests__/test-helpers/IMGroupModelStore.d.ts.map +1 -1
- package/dist/__tests__/test-helpers/IMGroupTransactionEventStore.d.ts +1 -2
- package/dist/__tests__/test-helpers/IMGroupTransactionEventStore.d.ts.map +1 -1
- package/dist/__tests__/test-helpers/IMGroupTransactionModelStore.d.ts +1 -2
- package/dist/__tests__/test-helpers/IMGroupTransactionModelStore.d.ts.map +1 -1
- package/dist/__tests__/test-helpers/IMTransactionEventStore.d.ts +1 -2
- package/dist/__tests__/test-helpers/IMTransactionEventStore.d.ts.map +1 -1
- package/dist/__tests__/test-helpers/IMTransactionModelStore.d.ts +3 -2
- package/dist/__tests__/test-helpers/IMTransactionModelStore.d.ts.map +1 -1
- package/dist/__tests__/test-helpers/IMTransactionModelStore.js +20 -0
- package/dist/__tests__/test-helpers/IMUserEventStore.d.ts +1 -2
- package/dist/__tests__/test-helpers/IMUserEventStore.d.ts.map +1 -1
- package/dist/__tests__/test-helpers/IMUserModelStore.d.ts +4 -2
- package/dist/__tests__/test-helpers/IMUserModelStore.d.ts.map +1 -1
- package/dist/__tests__/test-helpers/IMUserModelStore.js +10 -0
- package/dist/client/controllers/FriendController.d.ts +4 -0
- package/dist/client/controllers/FriendController.d.ts.map +1 -1
- package/dist/client/controllers/FriendController.js +45 -15
- package/dist/client/controllers/TransactionController.d.ts +18 -0
- package/dist/client/controllers/TransactionController.d.ts.map +1 -0
- package/dist/client/controllers/TransactionController.js +275 -0
- package/dist/client/handlers/UIEventHandler.d.ts +0 -1
- package/dist/client/handlers/UIEventHandler.d.ts.map +1 -1
- package/dist/client/handlers/UIEventHandler.js +4 -62
- package/dist/common/CurrencyRate.d.ts +7 -0
- package/dist/common/CurrencyRate.d.ts.map +1 -0
- package/dist/common/CurrencyRate.js +2 -0
- package/dist/common/DomainEvents.d.ts +0 -70
- package/dist/common/DomainEvents.d.ts.map +1 -1
- package/dist/common/DomainEvents.js +0 -89
- package/dist/contracts/expenses/index.d.ts.map +1 -1
- package/dist/contracts/friends/index.d.ts +1 -9
- package/dist/contracts/friends/index.d.ts.map +1 -1
- package/dist/contracts/groups/index.d.ts.map +1 -1
- package/dist/contracts/transactions/index.d.ts +1 -1
- package/dist/contracts/transactions/index.d.ts.map +1 -1
- package/dist/converters/ActivityLogConverters.d.ts +9 -0
- package/dist/converters/ActivityLogConverters.d.ts.map +1 -0
- package/dist/converters/ActivityLogConverters.js +39 -0
- package/dist/converters/EventConverterCore.d.ts +67 -0
- package/dist/converters/EventConverterCore.d.ts.map +1 -0
- package/dist/converters/EventConverterCore.js +59 -0
- package/dist/converters/FriendConverters.d.ts +33 -0
- package/dist/converters/FriendConverters.d.ts.map +1 -0
- package/dist/converters/FriendConverters.js +142 -0
- package/dist/converters/GroupConverters.d.ts +39 -0
- package/dist/converters/GroupConverters.d.ts.map +1 -0
- package/dist/converters/GroupConverters.js +160 -0
- package/dist/converters/GroupTransactionConverters.d.ts +57 -0
- package/dist/converters/GroupTransactionConverters.d.ts.map +1 -0
- package/dist/converters/GroupTransactionConverters.js +249 -0
- package/dist/converters/TransactionConverters.d.ts +51 -0
- package/dist/converters/TransactionConverters.d.ts.map +1 -0
- package/dist/converters/TransactionConverters.js +234 -0
- package/dist/converters/UserConverters.d.ts +51 -0
- package/dist/converters/UserConverters.d.ts.map +1 -0
- package/dist/converters/UserConverters.js +226 -0
- package/dist/converters/eventConverter.d.ts +10 -15
- package/dist/converters/eventConverter.d.ts.map +1 -1
- package/dist/converters/eventConverter.js +96 -377
- package/dist/environment.d.ts +12 -0
- package/dist/environment.d.ts.map +1 -0
- package/dist/environment.js +50 -0
- package/dist/events.d.ts +2 -1
- package/dist/events.d.ts.map +1 -1
- package/dist/events.js +7 -3
- package/dist/index.d.ts +7 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -31
- package/dist/store/ActivityLogModelStore.d.ts.map +1 -1
- package/dist/store/CurrencyStore.d.ts +5 -0
- package/dist/store/CurrencyStore.d.ts.map +1 -0
- package/dist/store/CurrencyStore.js +6 -0
- package/dist/store/FriendModelStore.d.ts.map +1 -1
- package/dist/store/GroupModelStore.d.ts.map +1 -1
- package/dist/store/GroupTransactionModelStore.d.ts.map +1 -1
- package/dist/store/TransactionModelStore.d.ts +2 -0
- package/dist/store/TransactionModelStore.d.ts.map +1 -1
- package/dist/store/UserModelStore.d.ts +1 -0
- package/dist/store/UserModelStore.d.ts.map +1 -1
- package/dist/utils/BalanceUtil.d.ts +13 -0
- package/dist/utils/BalanceUtil.d.ts.map +1 -0
- package/dist/utils/BalanceUtil.js +97 -0
- package/package.json +1 -1
- package/dist/client/handlers/UIFriendEventHandler.d.ts +0 -16
- package/dist/client/handlers/UIFriendEventHandler.d.ts.map +0 -1
- package/dist/client/handlers/UIFriendEventHandler.js +0 -27
- package/dist/client/handlers/UIGroupEventHandler.d.ts +0 -18
- package/dist/client/handlers/UIGroupEventHandler.d.ts.map +0 -1
- package/dist/client/handlers/UIGroupEventHandler.js +0 -28
- package/dist/client/handlers/UIGroupTransactionEventHandler.d.ts +0 -18
- package/dist/client/handlers/UIGroupTransactionEventHandler.d.ts.map +0 -1
- package/dist/client/handlers/UIGroupTransactionEventHandler.js +0 -28
- package/dist/client/handlers/UITransactionEventHandler.d.ts +0 -14
- package/dist/client/handlers/UITransactionEventHandler.d.ts.map +0 -1
- package/dist/client/handlers/UITransactionEventHandler.js +0 -26
- package/dist/client/handlers/UIUserEventHandler.d.ts +0 -12
- package/dist/client/handlers/UIUserEventHandler.d.ts.map +0 -1
- package/dist/client/handlers/UIUserEventHandler.js +0 -29
- package/dist/utils/userPathUtils.d.ts +0 -6
- package/dist/utils/userPathUtils.d.ts.map +0 -1
- package/dist/utils/userPathUtils.js +0 -16
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { UserModelStore } from "../..";
|
|
2
|
-
import { UserModel } from "../..";
|
|
1
|
+
import { UserModel, UserModelStore } from "../..";
|
|
3
2
|
export declare class IMUserModelStore implements UserModelStore {
|
|
4
3
|
private models;
|
|
4
|
+
private currentUser;
|
|
5
5
|
getByStreamId(streamId: string): Promise<UserModel | undefined>;
|
|
6
6
|
getByStreamIdWhereDeletedIsFalse(streamId: string): Promise<UserModel | undefined>;
|
|
7
7
|
save(model: UserModel): Promise<void>;
|
|
@@ -11,5 +11,7 @@ export declare class IMUserModelStore implements UserModelStore {
|
|
|
11
11
|
getAll(): UserModel[];
|
|
12
12
|
getAllWhereDeletedIsFalse(): UserModel[];
|
|
13
13
|
clear(): void;
|
|
14
|
+
setCurrentUser(user: UserModel): void;
|
|
15
|
+
appUser(): Promise<UserModel>;
|
|
14
16
|
}
|
|
15
17
|
//# sourceMappingURL=IMUserModelStore.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IMUserModelStore.d.ts","sourceRoot":"","sources":["../../../src/__tests__/test-helpers/IMUserModelStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"IMUserModelStore.d.ts","sourceRoot":"","sources":["../../../src/__tests__/test-helpers/IMUserModelStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAElD,qBAAa,gBAAiB,YAAW,cAAc;IACnD,OAAO,CAAC,MAAM,CAAqC;IACnD,OAAO,CAAC,WAAW,CAAwB;IAErC,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;IAK/D,gCAAgC,CAClC,QAAQ,EAAE,MAAM,GACjB,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;IAQ3B,IAAI,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAIrC,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;IAS1D,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;IAS1D,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;IASpE,MAAM,IAAI,SAAS,EAAE;IAIrB,yBAAyB,IAAI,SAAS,EAAE;IAMxC,KAAK,IAAI,IAAI;IAIb,cAAc,CAAC,IAAI,EAAE,SAAS,GAAG,IAAI;IAI/B,OAAO,IAAI,OAAO,CAAC,SAAS,CAAC;CAOtC"}
|
|
@@ -52,5 +52,15 @@ class IMUserModelStore {
|
|
|
52
52
|
clear() {
|
|
53
53
|
this.models.clear();
|
|
54
54
|
}
|
|
55
|
+
setCurrentUser(user) {
|
|
56
|
+
this.currentUser = user;
|
|
57
|
+
}
|
|
58
|
+
async appUser() {
|
|
59
|
+
const users = this.getAllWhereDeletedIsFalse();
|
|
60
|
+
if (users.length === 0) {
|
|
61
|
+
throw new Error("No user found in store.");
|
|
62
|
+
}
|
|
63
|
+
return users[0];
|
|
64
|
+
}
|
|
55
65
|
}
|
|
56
66
|
exports.IMUserModelStore = IMUserModelStore;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { FriendRequest, FriendResponse, FriendsResponse, UpdateFriendRequest } from "../../contracts/friends";
|
|
2
2
|
export declare class FriendController {
|
|
3
3
|
private get modelStore();
|
|
4
|
+
private get transactionModelStore();
|
|
5
|
+
private get userModelStore();
|
|
6
|
+
private get currencyStore();
|
|
4
7
|
private get friendEventHandler();
|
|
8
|
+
private get balanceUtil();
|
|
5
9
|
addFriend(userId: string, request: FriendRequest): Promise<string>;
|
|
6
10
|
updateFriend(userId: string, friendId: string, request: UpdateFriendRequest): Promise<void>;
|
|
7
11
|
deleteFriend(userId: string, friendId: string): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FriendController.d.ts","sourceRoot":"","sources":["../../../src/client/controllers/FriendController.ts"],"names":[],"mappings":"AAMA,OAAO,EACH,aAAa,EACb,cAAc,EACd,eAAe,EACf,mBAAmB,EACtB,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"FriendController.d.ts","sourceRoot":"","sources":["../../../src/client/controllers/FriendController.ts"],"names":[],"mappings":"AAMA,OAAO,EACH,aAAa,EACb,cAAc,EACd,eAAe,EACf,mBAAmB,EACtB,MAAM,yBAAyB,CAAC;AAMjC,qBAAa,gBAAgB;IACzB,OAAO,KAAK,UAAU,GAGrB;IAED,OAAO,KAAK,qBAAqB,GAGhC;IAED,OAAO,KAAK,cAAc,GAEzB;IAED,OAAO,KAAK,aAAa,GAExB;IAED,OAAO,KAAK,kBAAkB,GAE7B;IAED,OAAO,KAAK,WAAW,GAEtB;IAEK,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC;IA2BlE,YAAY,CACd,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,mBAAmB,GAC7B,OAAO,CAAC,IAAI,CAAC;IAuDV,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAiC7D,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAiCpE,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAU9D,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAuC7D,OAAO,CAAC,gBAAgB;CAmB3B"}
|
|
@@ -4,14 +4,28 @@ exports.FriendController = void 0;
|
|
|
4
4
|
const FriendEvents_1 = require("../../FriendEvents");
|
|
5
5
|
const uuid_1 = require("uuid");
|
|
6
6
|
const EventProcessorSDK_1 = require("../../EventProcessorSDK");
|
|
7
|
+
const BalanceUtil_1 = require("../../utils/BalanceUtil");
|
|
7
8
|
class FriendController {
|
|
8
9
|
get modelStore() {
|
|
9
10
|
return EventProcessorSDK_1.EventProcessorSDK.getInstance().getStoreConfig()
|
|
10
11
|
.friendModelStore;
|
|
11
12
|
}
|
|
13
|
+
get transactionModelStore() {
|
|
14
|
+
return EventProcessorSDK_1.EventProcessorSDK.getInstance().getStoreConfig()
|
|
15
|
+
.transactionModelStore;
|
|
16
|
+
}
|
|
17
|
+
get userModelStore() {
|
|
18
|
+
return EventProcessorSDK_1.EventProcessorSDK.getInstance().getStoreConfig().userModelStore;
|
|
19
|
+
}
|
|
20
|
+
get currencyStore() {
|
|
21
|
+
return EventProcessorSDK_1.EventProcessorSDK.getInstance().getStoreConfig().currencyStore;
|
|
22
|
+
}
|
|
12
23
|
get friendEventHandler() {
|
|
13
24
|
return EventProcessorSDK_1.EventProcessorSDK.getInstance().getFriendEventHandler();
|
|
14
25
|
}
|
|
26
|
+
get balanceUtil() {
|
|
27
|
+
return new BalanceUtil_1.BalanceUtil(this.userModelStore, this.currencyStore);
|
|
28
|
+
}
|
|
15
29
|
async addFriend(userId, request) {
|
|
16
30
|
if (!request.email && !request.phoneNumber) {
|
|
17
31
|
throw new Error("Either email or phoneNumber must be provided");
|
|
@@ -36,7 +50,11 @@ class FriendController {
|
|
|
36
50
|
return streamId;
|
|
37
51
|
}
|
|
38
52
|
async updateFriend(userId, friendId, request) {
|
|
39
|
-
|
|
53
|
+
let friendModel = await this.modelStore.findByUserIdAndFriendIdAndDeletedIsFalse(userId, friendId);
|
|
54
|
+
if (!friendModel) {
|
|
55
|
+
//fallback to find by streamId
|
|
56
|
+
friendModel = await this.modelStore.findByUserIdAndStreamIdAndDeletedIsFalse(userId, friendId);
|
|
57
|
+
}
|
|
40
58
|
if (!friendModel) {
|
|
41
59
|
throw new Error(`Friend not found: ${friendId}`);
|
|
42
60
|
}
|
|
@@ -70,7 +88,11 @@ class FriendController {
|
|
|
70
88
|
await this.friendEventHandler.handleEvent(event);
|
|
71
89
|
}
|
|
72
90
|
async deleteFriend(userId, friendId) {
|
|
73
|
-
|
|
91
|
+
let friendModel = await this.modelStore.findByUserIdAndFriendIdAndDeletedIsFalse(userId, friendId);
|
|
92
|
+
if (!friendModel) {
|
|
93
|
+
//fallback to find by streamId
|
|
94
|
+
friendModel = await this.modelStore.findByUserIdAndStreamIdAndDeletedIsFalse(userId, friendId);
|
|
95
|
+
}
|
|
74
96
|
if (!friendModel) {
|
|
75
97
|
throw new Error(`Friend not found: ${friendId}`);
|
|
76
98
|
}
|
|
@@ -87,11 +109,18 @@ class FriendController {
|
|
|
87
109
|
await this.friendEventHandler.handleEvent(event);
|
|
88
110
|
}
|
|
89
111
|
async getFriend(userId, friendId) {
|
|
90
|
-
|
|
112
|
+
let friendModel = await this.modelStore.findByUserIdAndFriendIdAndDeletedIsFalse(userId, friendId);
|
|
113
|
+
if (!friendModel) {
|
|
114
|
+
//fallback to find by streamId
|
|
115
|
+
friendModel = await this.modelStore.findByUserIdAndStreamIdAndDeletedIsFalse(userId, friendId);
|
|
116
|
+
}
|
|
91
117
|
if (!friendModel) {
|
|
92
118
|
throw new Error(`Friend not found: ${friendId}`);
|
|
93
119
|
}
|
|
94
|
-
|
|
120
|
+
const recipientUserId = friendModel.friendId ?? friendModel.streamId;
|
|
121
|
+
const transactions = await this.transactionModelStore.findByUserIdAndRecipientUserIdWhereDeletedIsFalse(userId, recipientUserId);
|
|
122
|
+
const balance = await this.balanceUtil.calculateBalance(transactions, userId);
|
|
123
|
+
return this.toFriendResponse(friendModel, balance);
|
|
95
124
|
}
|
|
96
125
|
async getFriendByStreamId(streamId) {
|
|
97
126
|
const friendModel = await this.modelStore.getByStreamIdWhereDeletedIsFalse(streamId);
|
|
@@ -102,17 +131,20 @@ class FriendController {
|
|
|
102
131
|
}
|
|
103
132
|
async getAllFriends(userId) {
|
|
104
133
|
const friendModels = await this.modelStore.findAllByUserIdWhereDeletedIsFalse(userId);
|
|
105
|
-
const
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
134
|
+
const allTransactions = await this.transactionModelStore.findAllByUserIdWhereDeletedIsFalse(userId);
|
|
135
|
+
const mainBalance = await this.balanceUtil.calculateBalance(allTransactions, userId);
|
|
136
|
+
const friendsWithBalance = await Promise.all(friendModels.map(async (friendModel) => {
|
|
137
|
+
const recipientUserId = friendModel.friendId ?? friendModel.streamId;
|
|
138
|
+
const friendTransactions = await this.transactionModelStore.findByUserIdAndRecipientUserIdWhereDeletedIsFalse(userId, recipientUserId);
|
|
139
|
+
const friendBalance = await this.balanceUtil.calculateBalance(friendTransactions, userId);
|
|
140
|
+
return this.toFriendResponse(friendModel, friendBalance);
|
|
141
|
+
}));
|
|
110
142
|
return {
|
|
111
|
-
friends,
|
|
112
|
-
balance:
|
|
143
|
+
friends: friendsWithBalance,
|
|
144
|
+
balance: mainBalance,
|
|
113
145
|
};
|
|
114
146
|
}
|
|
115
|
-
toFriendResponse(friendModel) {
|
|
147
|
+
toFriendResponse(friendModel, balance) {
|
|
116
148
|
const emptyBalance = {
|
|
117
149
|
main: undefined,
|
|
118
150
|
other: [],
|
|
@@ -124,9 +156,7 @@ class FriendController {
|
|
|
124
156
|
settled: false,
|
|
125
157
|
email: friendModel.friendEmail,
|
|
126
158
|
phone: friendModel.friendPhoneNumber,
|
|
127
|
-
|
|
128
|
-
otherBalances: [],
|
|
129
|
-
balance: emptyBalance,
|
|
159
|
+
balance: balance ?? emptyBalance,
|
|
130
160
|
};
|
|
131
161
|
}
|
|
132
162
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { TransactionCreateRequest, TransactionResponse, TransactionUpdateRequest, TransactionsResponse } from "../../contracts/transactions";
|
|
2
|
+
export declare class TransactionController {
|
|
3
|
+
private get modelStore();
|
|
4
|
+
private get transactionEventHandler();
|
|
5
|
+
private get userModelStore();
|
|
6
|
+
private get currencyStore();
|
|
7
|
+
private get balanceUtil();
|
|
8
|
+
private calculateAmount;
|
|
9
|
+
addTransaction(userId: string, request: TransactionCreateRequest): Promise<string>;
|
|
10
|
+
updateTransaction(userId: string, transactionId: string, request: TransactionUpdateRequest): Promise<void>;
|
|
11
|
+
deleteTransaction(userId: string, transactionId: string): Promise<void>;
|
|
12
|
+
getTransaction(userId: string, transactionId: string): Promise<TransactionResponse>;
|
|
13
|
+
getTransactionsByMonth(userId: string, friendId: string, timeZone: string): Promise<TransactionsResponse>;
|
|
14
|
+
private groupTransactionsByMonth;
|
|
15
|
+
private startOfMonth;
|
|
16
|
+
private toTransactionResponse;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=TransactionController.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TransactionController.d.ts","sourceRoot":"","sources":["../../../src/client/controllers/TransactionController.ts"],"names":[],"mappings":"AAWA,OAAO,EACH,wBAAwB,EACxB,mBAAmB,EACnB,wBAAwB,EACxB,oBAAoB,EAEvB,MAAM,8BAA8B,CAAC;AAKtC,qBAAa,qBAAqB;IAC9B,OAAO,KAAK,UAAU,GAGrB;IAED,OAAO,KAAK,uBAAuB,GAElC;IAED,OAAO,KAAK,cAAc,GAEzB;IAED,OAAO,KAAK,aAAa,GAExB;IAED,OAAO,KAAK,WAAW,GAEtB;IAED,OAAO,CAAC,eAAe;IAYjB,cAAc,CAChB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,wBAAwB,GAClC,OAAO,CAAC,MAAM,CAAC;IAgCZ,iBAAiB,CACnB,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,wBAAwB,GAClC,OAAO,CAAC,IAAI,CAAC;IAuHV,iBAAiB,CACnB,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,MAAM,GACtB,OAAO,CAAC,IAAI,CAAC;IA6BV,cAAc,CAChB,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,MAAM,GACtB,OAAO,CAAC,mBAAmB,CAAC;IAkBzB,sBAAsB,CACxB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,GACjB,OAAO,CAAC,oBAAoB,CAAC;IAyChC,OAAO,CAAC,wBAAwB;IAwBhC,OAAO,CAAC,YAAY;IAapB,OAAO,CAAC,qBAAqB;CAuChC"}
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TransactionController = void 0;
|
|
4
|
+
const TransactionEvents_1 = require("../../TransactionEvents");
|
|
5
|
+
const EventProcessorSDK_1 = require("../../EventProcessorSDK");
|
|
6
|
+
const uuid_1 = require("uuid");
|
|
7
|
+
const BalanceUtil_1 = require("../../utils/BalanceUtil");
|
|
8
|
+
class TransactionController {
|
|
9
|
+
get modelStore() {
|
|
10
|
+
return EventProcessorSDK_1.EventProcessorSDK.getInstance().getStoreConfig()
|
|
11
|
+
.transactionModelStore;
|
|
12
|
+
}
|
|
13
|
+
get transactionEventHandler() {
|
|
14
|
+
return EventProcessorSDK_1.EventProcessorSDK.getInstance().getTransactionEventHandler();
|
|
15
|
+
}
|
|
16
|
+
get userModelStore() {
|
|
17
|
+
return EventProcessorSDK_1.EventProcessorSDK.getInstance().getStoreConfig().userModelStore;
|
|
18
|
+
}
|
|
19
|
+
get currencyStore() {
|
|
20
|
+
return EventProcessorSDK_1.EventProcessorSDK.getInstance().getStoreConfig().currencyStore;
|
|
21
|
+
}
|
|
22
|
+
get balanceUtil() {
|
|
23
|
+
return new BalanceUtil_1.BalanceUtil(this.userModelStore, this.currencyStore);
|
|
24
|
+
}
|
|
25
|
+
calculateAmount(splitType, totalAmount) {
|
|
26
|
+
if (splitType === TransactionEvents_1.SplitType.TheyOweYouAll ||
|
|
27
|
+
splitType === TransactionEvents_1.SplitType.YouOweThemAll ||
|
|
28
|
+
splitType === TransactionEvents_1.SplitType.YouPaidToSettle ||
|
|
29
|
+
splitType === TransactionEvents_1.SplitType.TheyPaidToSettle) {
|
|
30
|
+
return totalAmount;
|
|
31
|
+
}
|
|
32
|
+
return totalAmount / 2;
|
|
33
|
+
}
|
|
34
|
+
async addTransaction(userId, request) {
|
|
35
|
+
const streamId = (0, uuid_1.v4)();
|
|
36
|
+
const createdAt = new Date();
|
|
37
|
+
const transactionDate = new Date(request.transactionDate);
|
|
38
|
+
const event = new TransactionEvents_1.TransactionCreated({
|
|
39
|
+
eventId: (0, uuid_1.v4)(),
|
|
40
|
+
userId,
|
|
41
|
+
recipientUserId: request.recipientId ?? "",
|
|
42
|
+
logicalTransactionId: streamId,
|
|
43
|
+
description: request.description.trim(),
|
|
44
|
+
currency: request.currency,
|
|
45
|
+
splitType: request.type,
|
|
46
|
+
totalAmount: request.amount,
|
|
47
|
+
amount: this.calculateAmount(request.type, request.amount),
|
|
48
|
+
isOwed: request.type.includes("YouPaid") ||
|
|
49
|
+
request.type === "TheyOweYouAll",
|
|
50
|
+
transactionDate,
|
|
51
|
+
groupId: undefined,
|
|
52
|
+
groupTransactionId: undefined,
|
|
53
|
+
createdAt,
|
|
54
|
+
createdBy: userId,
|
|
55
|
+
streamId,
|
|
56
|
+
version: 1,
|
|
57
|
+
systemGenerated: false,
|
|
58
|
+
});
|
|
59
|
+
await this.transactionEventHandler.handleEvent(event);
|
|
60
|
+
return streamId;
|
|
61
|
+
}
|
|
62
|
+
async updateTransaction(userId, transactionId, request) {
|
|
63
|
+
const transactionModel = await this.modelStore.getByStreamIdWhereDeletedIsFalse(transactionId);
|
|
64
|
+
if (!transactionModel) {
|
|
65
|
+
throw new Error(`Transaction not found: ${transactionId}`);
|
|
66
|
+
}
|
|
67
|
+
if (transactionModel.userId !== userId) {
|
|
68
|
+
throw new Error(`Unauthorized to update transaction: ${transactionId}`);
|
|
69
|
+
}
|
|
70
|
+
let currentVersion = transactionModel.version;
|
|
71
|
+
const createdAt = new Date();
|
|
72
|
+
if (request.description !== undefined &&
|
|
73
|
+
request.description.trim() !== "" &&
|
|
74
|
+
request.description !== transactionModel.description) {
|
|
75
|
+
currentVersion++;
|
|
76
|
+
const event = new TransactionEvents_1.DescriptionChanged({
|
|
77
|
+
eventId: (0, uuid_1.v4)(),
|
|
78
|
+
userId,
|
|
79
|
+
description: request.description.trim(),
|
|
80
|
+
createdAt,
|
|
81
|
+
createdBy: userId,
|
|
82
|
+
streamId: transactionModel.streamId,
|
|
83
|
+
version: currentVersion,
|
|
84
|
+
systemGenerated: false,
|
|
85
|
+
});
|
|
86
|
+
await this.transactionEventHandler.handleEvent(event);
|
|
87
|
+
}
|
|
88
|
+
if (request.amount !== undefined &&
|
|
89
|
+
request.amount !== transactionModel.totalAmount) {
|
|
90
|
+
currentVersion++;
|
|
91
|
+
const event = new TransactionEvents_1.TotalAmountChanged({
|
|
92
|
+
eventId: (0, uuid_1.v4)(),
|
|
93
|
+
userId,
|
|
94
|
+
totalAmount: request.amount,
|
|
95
|
+
createdAt,
|
|
96
|
+
createdBy: userId,
|
|
97
|
+
streamId: transactionModel.streamId,
|
|
98
|
+
version: currentVersion,
|
|
99
|
+
systemGenerated: false,
|
|
100
|
+
});
|
|
101
|
+
await this.transactionEventHandler.handleEvent(event);
|
|
102
|
+
}
|
|
103
|
+
if (request.currency !== undefined &&
|
|
104
|
+
request.currency !== transactionModel.currency) {
|
|
105
|
+
currentVersion++;
|
|
106
|
+
const event = new TransactionEvents_1.CurrencyChanged({
|
|
107
|
+
eventId: (0, uuid_1.v4)(),
|
|
108
|
+
userId,
|
|
109
|
+
currency: request.currency,
|
|
110
|
+
createdAt,
|
|
111
|
+
createdBy: userId,
|
|
112
|
+
streamId: transactionModel.streamId,
|
|
113
|
+
version: currentVersion,
|
|
114
|
+
systemGenerated: false,
|
|
115
|
+
});
|
|
116
|
+
await this.transactionEventHandler.handleEvent(event);
|
|
117
|
+
}
|
|
118
|
+
if (request.type !== undefined &&
|
|
119
|
+
request.type !== transactionModel.splitType) {
|
|
120
|
+
currentVersion++;
|
|
121
|
+
const calculatedAmount = request.amount ?? transactionModel.totalAmount;
|
|
122
|
+
const event = new TransactionEvents_1.SplitTypeChanged({
|
|
123
|
+
eventId: (0, uuid_1.v4)(),
|
|
124
|
+
userId,
|
|
125
|
+
splitType: request.type,
|
|
126
|
+
totalAmount: calculatedAmount,
|
|
127
|
+
amount: this.calculateAmount(request.type, calculatedAmount),
|
|
128
|
+
isOwed: request.type.includes("YouPaid") ||
|
|
129
|
+
request.type === "TheyOweYouAll",
|
|
130
|
+
createdAt,
|
|
131
|
+
createdBy: userId,
|
|
132
|
+
streamId: transactionModel.streamId,
|
|
133
|
+
version: currentVersion,
|
|
134
|
+
systemGenerated: false,
|
|
135
|
+
});
|
|
136
|
+
await this.transactionEventHandler.handleEvent(event);
|
|
137
|
+
}
|
|
138
|
+
if (request.transactionDate !== undefined &&
|
|
139
|
+
request.transactionDate !==
|
|
140
|
+
transactionModel.transactionDate.toISOString()) {
|
|
141
|
+
currentVersion++;
|
|
142
|
+
const transactionDate = new Date(request.transactionDate);
|
|
143
|
+
const event = new TransactionEvents_1.TransactionDateChanged({
|
|
144
|
+
eventId: (0, uuid_1.v4)(),
|
|
145
|
+
userId,
|
|
146
|
+
transactionDate,
|
|
147
|
+
createdAt,
|
|
148
|
+
createdBy: userId,
|
|
149
|
+
streamId: transactionModel.streamId,
|
|
150
|
+
version: currentVersion,
|
|
151
|
+
systemGenerated: false,
|
|
152
|
+
});
|
|
153
|
+
await this.transactionEventHandler.handleEvent(event);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
async deleteTransaction(userId, transactionId) {
|
|
157
|
+
const transactionModel = await this.modelStore.getByStreamIdWhereDeletedIsFalse(transactionId);
|
|
158
|
+
if (!transactionModel) {
|
|
159
|
+
throw new Error(`Transaction not found: ${transactionId}`);
|
|
160
|
+
}
|
|
161
|
+
if (transactionModel.userId !== userId) {
|
|
162
|
+
throw new Error(`Unauthorized to delete transaction: ${transactionId}`);
|
|
163
|
+
}
|
|
164
|
+
const createdAt = new Date();
|
|
165
|
+
const event = new TransactionEvents_1.TransactionDeleted({
|
|
166
|
+
eventId: (0, uuid_1.v4)(),
|
|
167
|
+
userId,
|
|
168
|
+
createdAt,
|
|
169
|
+
createdBy: userId,
|
|
170
|
+
streamId: transactionModel.streamId,
|
|
171
|
+
version: transactionModel.version + 1,
|
|
172
|
+
systemGenerated: false,
|
|
173
|
+
});
|
|
174
|
+
await this.transactionEventHandler.handleEvent(event);
|
|
175
|
+
}
|
|
176
|
+
async getTransaction(userId, transactionId) {
|
|
177
|
+
const transactionModel = await this.modelStore.getByStreamIdWhereDeletedIsFalse(transactionId);
|
|
178
|
+
if (!transactionModel) {
|
|
179
|
+
throw new Error(`Transaction not found: ${transactionId}`);
|
|
180
|
+
}
|
|
181
|
+
if (transactionModel.userId !== userId) {
|
|
182
|
+
throw new Error(`Unauthorized to view transaction: ${transactionId}`);
|
|
183
|
+
}
|
|
184
|
+
return this.toTransactionResponse(transactionModel);
|
|
185
|
+
}
|
|
186
|
+
async getTransactionsByMonth(userId, friendId, timeZone) {
|
|
187
|
+
if (!timeZone || timeZone.trim() === "") {
|
|
188
|
+
throw new Error("Invalid timezone");
|
|
189
|
+
}
|
|
190
|
+
try {
|
|
191
|
+
new Date().toLocaleString("en-US", { timeZone });
|
|
192
|
+
}
|
|
193
|
+
catch (error) {
|
|
194
|
+
throw new Error("Invalid timezone");
|
|
195
|
+
}
|
|
196
|
+
const transactions = await this.modelStore.findByUserIdAndRecipientUserIdWhereDeletedIsFalse(userId, friendId);
|
|
197
|
+
const balance = await this.balanceUtil.calculateBalance(transactions, userId);
|
|
198
|
+
const sortedTransactions = transactions
|
|
199
|
+
.sort((a, b) => new Date(b.transactionDate).getTime() -
|
|
200
|
+
new Date(a.transactionDate).getTime())
|
|
201
|
+
.map((t) => this.toTransactionResponse(t));
|
|
202
|
+
const groupedByMonth = this.groupTransactionsByMonth(sortedTransactions, timeZone);
|
|
203
|
+
return {
|
|
204
|
+
balance,
|
|
205
|
+
perMonth: groupedByMonth,
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
groupTransactionsByMonth(transactions, timeZone) {
|
|
209
|
+
const grouped = new Map();
|
|
210
|
+
for (const transaction of transactions) {
|
|
211
|
+
const monthStart = this.startOfMonth(transaction.date, timeZone);
|
|
212
|
+
const key = monthStart;
|
|
213
|
+
if (!grouped.has(key)) {
|
|
214
|
+
grouped.set(key, []);
|
|
215
|
+
}
|
|
216
|
+
grouped.get(key).push(transaction);
|
|
217
|
+
}
|
|
218
|
+
return Array.from(grouped.entries())
|
|
219
|
+
.sort((a, b) => new Date(b[0]).getTime() - new Date(a[0]).getTime())
|
|
220
|
+
.map(([date, transactions]) => ({
|
|
221
|
+
date,
|
|
222
|
+
transactions,
|
|
223
|
+
}));
|
|
224
|
+
}
|
|
225
|
+
startOfMonth(dateString, timeZone) {
|
|
226
|
+
const date = new Date(dateString);
|
|
227
|
+
const year = date.toLocaleString("en-US", {
|
|
228
|
+
year: "numeric",
|
|
229
|
+
timeZone,
|
|
230
|
+
});
|
|
231
|
+
const month = date.toLocaleString("en-US", {
|
|
232
|
+
month: "2-digit",
|
|
233
|
+
timeZone,
|
|
234
|
+
});
|
|
235
|
+
return new Date(`${year}-${month}-01T00:00:00.000Z`).toISOString();
|
|
236
|
+
}
|
|
237
|
+
toTransactionResponse(transactionModel) {
|
|
238
|
+
return {
|
|
239
|
+
date: transactionModel.transactionDate.toISOString(),
|
|
240
|
+
description: transactionModel.description,
|
|
241
|
+
transactionId: transactionModel.streamId,
|
|
242
|
+
groupTransactionId: transactionModel.groupTransactionId,
|
|
243
|
+
groupId: transactionModel.groupId,
|
|
244
|
+
groupName: undefined,
|
|
245
|
+
totalAmount: transactionModel.totalAmount,
|
|
246
|
+
splitType: transactionModel.splitType,
|
|
247
|
+
amount: {
|
|
248
|
+
amount: transactionModel.amount,
|
|
249
|
+
currency: transactionModel.currency,
|
|
250
|
+
isOwed: transactionModel.isOwed,
|
|
251
|
+
},
|
|
252
|
+
friend: {
|
|
253
|
+
friendId: transactionModel.recipientUserId,
|
|
254
|
+
email: undefined,
|
|
255
|
+
phoneNumber: undefined,
|
|
256
|
+
photoUrl: undefined,
|
|
257
|
+
name: undefined,
|
|
258
|
+
},
|
|
259
|
+
defaultCurrencyAmount: undefined,
|
|
260
|
+
history: [],
|
|
261
|
+
createdAt: transactionModel.createdAt.toISOString(),
|
|
262
|
+
updatedAt: transactionModel.updatedAt.toISOString(),
|
|
263
|
+
createdBy: {
|
|
264
|
+
id: transactionModel.createdBy,
|
|
265
|
+
name: "User",
|
|
266
|
+
},
|
|
267
|
+
updatedBy: {
|
|
268
|
+
id: transactionModel.updatedBy,
|
|
269
|
+
name: "User",
|
|
270
|
+
},
|
|
271
|
+
deleted: transactionModel.deleted,
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
exports.TransactionController = TransactionController;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UIEventHandler.d.ts","sourceRoot":"","sources":["../../../src/client/handlers/UIEventHandler.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"UIEventHandler.d.ts","sourceRoot":"","sources":["../../../src/client/handlers/UIEventHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAyB,MAAM,aAAa,CAAC;AAE3D,qBAAa,cAAc;;IAGjB,oBAAoB,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC;CAK1D"}
|
|
@@ -1,71 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.UIEventHandler = void 0;
|
|
4
|
-
const
|
|
5
|
-
const EventProcessorSDK_1 = require("../../EventProcessorSDK");
|
|
4
|
+
const index_1 = require("../../index");
|
|
6
5
|
class UIEventHandler {
|
|
7
6
|
constructor() { }
|
|
8
|
-
shouldSkipSave(existingModel, updatedModel) {
|
|
9
|
-
if (!existingModel) {
|
|
10
|
-
return false;
|
|
11
|
-
}
|
|
12
|
-
return (existingModel.streamId === updatedModel.streamId &&
|
|
13
|
-
existingModel.version === updatedModel.version);
|
|
14
|
-
}
|
|
15
7
|
async handleFirestoreEvent(event) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const existingModel = await storeConfig.userModelStore.getByStreamIdWhereDeletedIsFalse(event.streamId);
|
|
20
|
-
const updatedModel = event.apply(existingModel);
|
|
21
|
-
if (!this.shouldSkipSave(existingModel, updatedModel)) {
|
|
22
|
-
await storeConfig.userModelStore.save(updatedModel);
|
|
23
|
-
EventProcessorSDK_1.EventProcessorSDK.getInstance().emitModelChange("UserModel", updatedModel);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
else if ((0, DomainEvents_1.isValidFriendEventType)(eventType)) {
|
|
27
|
-
const existingModel = await storeConfig.friendModelStore.getByStreamIdWhereDeletedIsFalse(event.streamId);
|
|
28
|
-
const updatedModel = event.apply(existingModel);
|
|
29
|
-
if (!this.shouldSkipSave(existingModel, updatedModel)) {
|
|
30
|
-
await storeConfig.friendModelStore.save(updatedModel);
|
|
31
|
-
EventProcessorSDK_1.EventProcessorSDK.getInstance().emitModelChange("FriendModel", updatedModel);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
else if ((0, DomainEvents_1.isValidTransactionEventType)(eventType)) {
|
|
35
|
-
const existingModel = await storeConfig.transactionModelStore.getByStreamIdWhereDeletedIsFalse(event.streamId);
|
|
36
|
-
const updatedModel = event.apply(existingModel);
|
|
37
|
-
if (!this.shouldSkipSave(existingModel, updatedModel)) {
|
|
38
|
-
await storeConfig.transactionModelStore.save(updatedModel);
|
|
39
|
-
EventProcessorSDK_1.EventProcessorSDK.getInstance().emitModelChange("TransactionModel", updatedModel);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
else if ((0, DomainEvents_1.isValidGroupEventType)(eventType)) {
|
|
43
|
-
const existingModel = await storeConfig.groupModelStore.getByStreamIdWhereDeletedIsFalse(event.streamId);
|
|
44
|
-
const updatedModel = event.apply(existingModel);
|
|
45
|
-
if (!this.shouldSkipSave(existingModel, updatedModel)) {
|
|
46
|
-
await storeConfig.groupModelStore.save(updatedModel);
|
|
47
|
-
EventProcessorSDK_1.EventProcessorSDK.getInstance().emitModelChange("GroupModel", updatedModel);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
else if ((0, DomainEvents_1.isValidGroupTransactionEventType)(eventType)) {
|
|
51
|
-
const existingModel = await storeConfig.groupTransactionModelStore.getByStreamIdWhereDeletedIsFalse(event.streamId);
|
|
52
|
-
const updatedModel = event.apply(existingModel);
|
|
53
|
-
if (!this.shouldSkipSave(existingModel, updatedModel)) {
|
|
54
|
-
await storeConfig.groupTransactionModelStore.save(updatedModel);
|
|
55
|
-
EventProcessorSDK_1.EventProcessorSDK.getInstance().emitModelChange("GroupTransactionModel", updatedModel);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
else if ((0, DomainEvents_1.isValidActivityLogEventType)(eventType)) {
|
|
59
|
-
const existingModel = await storeConfig.activityLogModelStore.getByStreamIdWhereDeletedIsFalse(event.streamId);
|
|
60
|
-
const updatedModel = event.apply(existingModel);
|
|
61
|
-
if (!this.shouldSkipSave(existingModel, updatedModel)) {
|
|
62
|
-
await storeConfig.activityLogModelStore.save(updatedModel);
|
|
63
|
-
EventProcessorSDK_1.EventProcessorSDK.getInstance().emitModelChange("ActivityLogModel", updatedModel);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
throw new Error(`Unsupported event type: ${eventType}`);
|
|
68
|
-
}
|
|
8
|
+
await index_1.EventConverterFactory.getConverter(event.constructor.name)
|
|
9
|
+
.getEventHandler()
|
|
10
|
+
.handleClientEventFromRemoteListener(event);
|
|
69
11
|
}
|
|
70
12
|
}
|
|
71
13
|
exports.UIEventHandler = UIEventHandler;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CurrencyRate.d.ts","sourceRoot":"","sources":["../../src/common/CurrencyRate.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,WAAW,EAAE,IAAI,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAClB"}
|
|
@@ -14,74 +14,4 @@ export interface GroupTransactionEvent extends Event {
|
|
|
14
14
|
}
|
|
15
15
|
export interface ActivityLogEvent extends Event {
|
|
16
16
|
}
|
|
17
|
-
/**
|
|
18
|
-
* Event type definitions for each domain
|
|
19
|
-
*/
|
|
20
|
-
export declare const UserEventTypes: {
|
|
21
|
-
readonly UserCreated: "UserCreated";
|
|
22
|
-
readonly PlaceholderUserCreated: "PlaceholderUserCreated";
|
|
23
|
-
readonly UserCurrencyChanged: "UserCurrencyChanged";
|
|
24
|
-
readonly UserPhoneNumberChanged: "UserPhoneNumberChanged";
|
|
25
|
-
readonly UserDisplayNameChanged: "UserDisplayNameChanged";
|
|
26
|
-
readonly UserDeleted: "UserDeleted";
|
|
27
|
-
readonly PlaceholderUserMerged: "PlaceholderUserMerged";
|
|
28
|
-
readonly UserConvertedToPlaceholder: "UserConvertedToPlaceholder";
|
|
29
|
-
};
|
|
30
|
-
export declare const FriendEventTypes: {
|
|
31
|
-
readonly FriendCreated: "FriendCreated";
|
|
32
|
-
readonly FriendUpdated: "FriendUpdated";
|
|
33
|
-
readonly FriendDeleted: "FriendDeleted";
|
|
34
|
-
readonly FriendIdAdded: "FriendIdAdded";
|
|
35
|
-
readonly FriendIdRemoved: "FriendIdRemoved";
|
|
36
|
-
};
|
|
37
|
-
export declare const TransactionEventTypes: {
|
|
38
|
-
readonly TransactionCreated: "TransactionCreated";
|
|
39
|
-
readonly TransactionDeleted: "TransactionDeleted";
|
|
40
|
-
readonly DescriptionChanged: "DescriptionChanged";
|
|
41
|
-
readonly TotalAmountChanged: "TotalAmountChanged";
|
|
42
|
-
readonly SplitTypeChanged: "SplitTypeChanged";
|
|
43
|
-
readonly CurrencyChanged: "CurrencyChanged";
|
|
44
|
-
readonly TransactionDateChanged: "TransactionDateChanged";
|
|
45
|
-
readonly TransactionDetailsChanged: "TransactionDetailsChanged";
|
|
46
|
-
};
|
|
47
|
-
export declare const GroupEventTypes: {
|
|
48
|
-
readonly GroupCreated: "GroupCreated";
|
|
49
|
-
readonly GroupNameChanged: "GroupNameChanged";
|
|
50
|
-
readonly GroupDescriptionChanged: "GroupDescriptionChanged";
|
|
51
|
-
readonly GroupMembersAdded: "GroupMembersAdded";
|
|
52
|
-
readonly GroupMembersRemoved: "GroupMembersRemoved";
|
|
53
|
-
readonly GroupDeleted: "GroupDeleted";
|
|
54
|
-
};
|
|
55
|
-
export declare const GroupTransactionEventTypes: {
|
|
56
|
-
readonly GroupTransactionCreated: "GroupTransactionCreated";
|
|
57
|
-
readonly GroupTransactionDescriptionChanged: "GroupTransactionDescriptionChanged";
|
|
58
|
-
readonly GroupTransactionNotesChanged: "GroupTransactionNotesChanged";
|
|
59
|
-
readonly GroupTransactionTotalAmountChanged: "GroupTransactionTotalAmountChanged";
|
|
60
|
-
readonly GroupTransactionCurrencyChanged: "GroupTransactionCurrencyChanged";
|
|
61
|
-
readonly GroupTransactionSplitTypeChanged: "GroupTransactionSplitTypeChanged";
|
|
62
|
-
readonly GroupTransactionDateChanged: "GroupTransactionDateChanged";
|
|
63
|
-
readonly GroupTransactionSplitDetailsChanged: "GroupTransactionSplitDetailsChanged";
|
|
64
|
-
readonly GroupTransactionDeleted: "GroupTransactionDeleted";
|
|
65
|
-
};
|
|
66
|
-
export declare const ActivityLogEventTypes: {
|
|
67
|
-
readonly ActivityLogCreated: "ActivityLogCreated";
|
|
68
|
-
};
|
|
69
|
-
/**
|
|
70
|
-
* Valid event types arrays for validation
|
|
71
|
-
*/
|
|
72
|
-
export declare const VALID_USER_EVENT_TYPES: ("UserCreated" | "PlaceholderUserCreated" | "UserCurrencyChanged" | "UserPhoneNumberChanged" | "UserDisplayNameChanged" | "UserDeleted" | "PlaceholderUserMerged" | "UserConvertedToPlaceholder")[];
|
|
73
|
-
export declare const VALID_FRIEND_EVENT_TYPES: ("FriendCreated" | "FriendUpdated" | "FriendDeleted" | "FriendIdAdded" | "FriendIdRemoved")[];
|
|
74
|
-
export declare const VALID_TRANSACTION_EVENT_TYPES: ("TransactionCreated" | "TransactionDeleted" | "DescriptionChanged" | "TotalAmountChanged" | "SplitTypeChanged" | "CurrencyChanged" | "TransactionDateChanged" | "TransactionDetailsChanged")[];
|
|
75
|
-
export declare const VALID_GROUP_EVENT_TYPES: ("GroupCreated" | "GroupNameChanged" | "GroupDescriptionChanged" | "GroupMembersAdded" | "GroupMembersRemoved" | "GroupDeleted")[];
|
|
76
|
-
export declare const VALID_GROUP_TRANSACTION_EVENT_TYPES: ("GroupTransactionCreated" | "GroupTransactionDescriptionChanged" | "GroupTransactionNotesChanged" | "GroupTransactionTotalAmountChanged" | "GroupTransactionCurrencyChanged" | "GroupTransactionSplitTypeChanged" | "GroupTransactionDateChanged" | "GroupTransactionSplitDetailsChanged" | "GroupTransactionDeleted")[];
|
|
77
|
-
export declare const VALID_ACTIVITY_LOG_EVENT_TYPES: "ActivityLogCreated"[];
|
|
78
|
-
/**
|
|
79
|
-
* Type validation functions
|
|
80
|
-
*/
|
|
81
|
-
export declare function isValidUserEventType(eventType: string): boolean;
|
|
82
|
-
export declare function isValidFriendEventType(eventType: string): boolean;
|
|
83
|
-
export declare function isValidTransactionEventType(eventType: string): boolean;
|
|
84
|
-
export declare function isValidGroupEventType(eventType: string): boolean;
|
|
85
|
-
export declare function isValidGroupTransactionEventType(eventType: string): boolean;
|
|
86
|
-
export declare function isValidActivityLogEventType(eventType: string): boolean;
|
|
87
17
|
//# sourceMappingURL=DomainEvents.d.ts.map
|