@zeeshan60/event-processor 1.0.16 → 1.0.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ActivityEventHandler.d.ts +4 -1
- package/dist/ActivityEventHandler.d.ts.map +1 -1
- package/dist/ActivityEventHandler.js +23 -7
- package/dist/ActivityLogEvents.d.ts.map +1 -1
- package/dist/ActivityLogEvents.js +1 -0
- package/dist/BaseEventHandler.d.ts +7 -0
- package/dist/BaseEventHandler.d.ts.map +1 -1
- package/dist/BaseEventHandler.js +4 -0
- package/dist/EventProcessorSDK.d.ts +4 -0
- package/dist/EventProcessorSDK.d.ts.map +1 -1
- package/dist/EventProcessorSDK.js +13 -6
- package/dist/FriendEventHandler.d.ts +4 -1
- package/dist/FriendEventHandler.d.ts.map +1 -1
- package/dist/FriendEventHandler.js +25 -13
- package/dist/GroupEventHandler.d.ts +4 -1
- package/dist/GroupEventHandler.d.ts.map +1 -1
- package/dist/GroupEventHandler.js +34 -18
- package/dist/GroupTransactionEventHandler.d.ts +4 -6
- package/dist/GroupTransactionEventHandler.d.ts.map +1 -1
- package/dist/GroupTransactionEventHandler.js +24 -291
- package/dist/TransactionEventHandler.d.ts +4 -1
- package/dist/TransactionEventHandler.d.ts.map +1 -1
- package/dist/TransactionEventHandler.js +24 -6
- package/dist/TransactionEvents.d.ts +10 -9
- package/dist/TransactionEvents.d.ts.map +1 -1
- package/dist/TransactionEvents.js +10 -12
- package/dist/UserEventHandler.d.ts +4 -1
- package/dist/UserEventHandler.d.ts.map +1 -1
- package/dist/UserEventHandler.js +25 -7
- package/dist/__tests__/test-helpers/IMActivityLogEventStore.d.ts +1 -0
- package/dist/__tests__/test-helpers/IMActivityLogEventStore.d.ts.map +1 -1
- package/dist/__tests__/test-helpers/IMActivityLogEventStore.js +3 -0
- package/dist/__tests__/test-helpers/IMActivityLogModelStore.d.ts +2 -0
- package/dist/__tests__/test-helpers/IMActivityLogModelStore.d.ts.map +1 -1
- package/dist/__tests__/test-helpers/IMActivityLogModelStore.js +10 -0
- package/dist/__tests__/test-helpers/IMCurrencyStore.d.ts +1 -0
- package/dist/__tests__/test-helpers/IMCurrencyStore.d.ts.map +1 -1
- package/dist/__tests__/test-helpers/IMCurrencyStore.js +3 -0
- package/dist/__tests__/test-helpers/IMFriendModelStore.d.ts +1 -0
- package/dist/__tests__/test-helpers/IMFriendModelStore.d.ts.map +1 -1
- package/dist/__tests__/test-helpers/IMFriendModelStore.js +7 -0
- package/dist/__tests__/test-helpers/IMGroupModelStore.d.ts +1 -0
- package/dist/__tests__/test-helpers/IMGroupModelStore.d.ts.map +1 -1
- package/dist/__tests__/test-helpers/IMGroupModelStore.js +7 -0
- package/dist/__tests__/test-helpers/IMGroupTransactionEventStore.d.ts +2 -0
- package/dist/__tests__/test-helpers/IMGroupTransactionEventStore.d.ts.map +1 -1
- package/dist/__tests__/test-helpers/IMGroupTransactionEventStore.js +18 -0
- package/dist/__tests__/test-helpers/IMGroupTransactionModelStore.d.ts +1 -0
- package/dist/__tests__/test-helpers/IMGroupTransactionModelStore.d.ts.map +1 -1
- package/dist/__tests__/test-helpers/IMGroupTransactionModelStore.js +7 -0
- package/dist/__tests__/test-helpers/IMTransactionEventStore.d.ts +2 -0
- package/dist/__tests__/test-helpers/IMTransactionEventStore.d.ts.map +1 -1
- package/dist/__tests__/test-helpers/IMTransactionEventStore.js +6 -0
- package/dist/__tests__/test-helpers/IMTransactionModelStore.d.ts +1 -0
- package/dist/__tests__/test-helpers/IMTransactionModelStore.d.ts.map +1 -1
- package/dist/__tests__/test-helpers/IMTransactionModelStore.js +7 -0
- package/dist/__tests__/test-helpers/IMUserModelStore.d.ts +1 -0
- package/dist/__tests__/test-helpers/IMUserModelStore.d.ts.map +1 -1
- package/dist/__tests__/test-helpers/IMUserModelStore.js +7 -0
- package/dist/client/controllers/FriendController.d.ts.map +1 -1
- package/dist/client/controllers/FriendController.js +40 -4
- package/dist/client/controllers/TransactionController.d.ts +7 -2
- package/dist/client/controllers/TransactionController.d.ts.map +1 -1
- package/dist/client/controllers/TransactionController.js +90 -17
- package/dist/client/handlers/UIEventHandler.d.ts +3 -0
- package/dist/client/handlers/UIEventHandler.d.ts.map +1 -1
- package/dist/client/handlers/UIEventHandler.js +36 -0
- package/dist/common/Model.d.ts +1 -0
- package/dist/common/Model.d.ts.map +1 -1
- package/dist/contracts/friends/index.d.ts +1 -0
- package/dist/contracts/friends/index.d.ts.map +1 -1
- package/dist/contracts/groups/index.d.ts +1 -1
- package/dist/contracts/groups/index.d.ts.map +1 -1
- package/dist/contracts/transactions/index.d.ts +33 -23
- package/dist/contracts/transactions/index.d.ts.map +1 -1
- package/dist/contracts/transactions/index.js +14 -11
- package/dist/converters/ActivityLogConverters.d.ts.map +1 -1
- package/dist/converters/ActivityLogConverters.js +3 -1
- package/dist/index.d.ts +0 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -5
- package/dist/store/CurrencyStore.d.ts +1 -0
- package/dist/store/CurrencyStore.d.ts.map +1 -1
- package/dist/store/ModelStore.d.ts +1 -0
- package/dist/store/ModelStore.d.ts.map +1 -1
- package/dist/utils/BalanceUtil.d.ts +5 -1
- package/dist/utils/BalanceUtil.d.ts.map +1 -1
- package/dist/utils/BalanceUtil.js +9 -1
- package/dist/utils/splitTypeUtils.d.ts.map +1 -1
- package/dist/utils/splitTypeUtils.js +21 -21
- package/package.json +1 -1
- package/dist/environment.d.ts +0 -12
- package/dist/environment.d.ts.map +0 -1
- package/dist/environment.js +0 -50
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { ActivityLogEvent, ActivityLogEventStore, ActivityLogModelStore, Event, Model, UserModelStore } from ".";
|
|
2
2
|
import { BaseEventHandler } from "./BaseEventHandler";
|
|
3
|
+
import { ModelChangeEmitter } from "./ModelChangeEmitter";
|
|
3
4
|
export declare class ActivityEventHandler extends BaseEventHandler<ActivityLogEvent> {
|
|
4
5
|
private activityLogModelStore;
|
|
5
6
|
private activityLogEventStore;
|
|
6
7
|
private userModelStore;
|
|
7
|
-
constructor(activityLogModelStore: ActivityLogModelStore, activityLogEventStore: ActivityLogEventStore, userModelStore: UserModelStore);
|
|
8
|
+
constructor(activityLogModelStore: ActivityLogModelStore, activityLogEventStore: ActivityLogEventStore, userModelStore: UserModelStore, isClient: boolean, modelChangeEmitter?: ModelChangeEmitter);
|
|
9
|
+
getModelStore(): ActivityLogModelStore;
|
|
8
10
|
createActivityLog(event: Event, existingModel: Model | undefined, updatedModel: Model): Promise<void>;
|
|
9
11
|
handleClientEventFromRemoteListener(event: ActivityLogEvent): Promise<void>;
|
|
12
|
+
handleClientEventsFromRemoteListenerBulk(events: ActivityLogEvent[]): Promise<void>;
|
|
10
13
|
handleEvent(event: ActivityLogEvent): Promise<any>;
|
|
11
14
|
}
|
|
12
15
|
//# sourceMappingURL=ActivityEventHandler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActivityEventHandler.d.ts","sourceRoot":"","sources":["../src/ActivityEventHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAGH,gBAAgB,EAChB,qBAAqB,EAErB,qBAAqB,EACrB,KAAK,EACL,KAAK,EACL,cAAc,EACjB,MAAM,GAAG,CAAC;AACX,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"ActivityEventHandler.d.ts","sourceRoot":"","sources":["../src/ActivityEventHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAGH,gBAAgB,EAChB,qBAAqB,EAErB,qBAAqB,EACrB,KAAK,EACL,KAAK,EACL,cAAc,EACjB,MAAM,GAAG,CAAC;AACX,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,qBAAa,oBAAqB,SAAQ,gBAAgB,CAAC,gBAAgB,CAAC;IAEpE,OAAO,CAAC,qBAAqB;IAC7B,OAAO,CAAC,qBAAqB;IAC7B,OAAO,CAAC,cAAc;gBAFd,qBAAqB,EAAE,qBAAqB,EAC5C,qBAAqB,EAAE,qBAAqB,EAC5C,cAAc,EAAE,cAAc,EACtC,QAAQ,EAAE,OAAO,EACjB,kBAAkB,CAAC,EAAE,kBAAkB;IAKpC,aAAa,IAAI,qBAAqB;IAIvC,iBAAiB,CACnB,KAAK,EAAE,KAAK,EACZ,aAAa,EAAE,KAAK,GAAG,SAAS,EAChC,YAAY,EAAE,KAAK,GACpB,OAAO,CAAC,IAAI,CAAC;IAkCV,mCAAmC,CACrC,KAAK,EAAE,gBAAgB,GACxB,OAAO,CAAC,IAAI,CAAC;IAYH,wCAAwC,CACjD,MAAM,EAAE,gBAAgB,EAAE,GAC3B,OAAO,CAAC,IAAI,CAAC;IAsBhB,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,GAAG,CAAC;CAOrD"}
|
|
@@ -3,14 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ActivityEventHandler = void 0;
|
|
4
4
|
const _1 = require(".");
|
|
5
5
|
const BaseEventHandler_1 = require("./BaseEventHandler");
|
|
6
|
-
const EventProcessorSDK_1 = require("./EventProcessorSDK");
|
|
7
6
|
class ActivityEventHandler extends BaseEventHandler_1.BaseEventHandler {
|
|
8
|
-
constructor(activityLogModelStore, activityLogEventStore, userModelStore) {
|
|
9
|
-
super();
|
|
7
|
+
constructor(activityLogModelStore, activityLogEventStore, userModelStore, isClient, modelChangeEmitter) {
|
|
8
|
+
super(isClient, modelChangeEmitter);
|
|
10
9
|
this.activityLogModelStore = activityLogModelStore;
|
|
11
10
|
this.activityLogEventStore = activityLogEventStore;
|
|
12
11
|
this.userModelStore = userModelStore;
|
|
13
12
|
}
|
|
13
|
+
getModelStore() {
|
|
14
|
+
return this.activityLogModelStore;
|
|
15
|
+
}
|
|
14
16
|
async createActivityLog(event, existingModel, updatedModel) {
|
|
15
17
|
if (!event.activityLog) {
|
|
16
18
|
return;
|
|
@@ -34,9 +36,7 @@ class ActivityEventHandler extends BaseEventHandler_1.BaseEventHandler {
|
|
|
34
36
|
await this.activityLogEventStore.addEvent(activityLogEvent);
|
|
35
37
|
if (!this.shouldSkipSave(undefined, activityLogModel)) {
|
|
36
38
|
await this.activityLogModelStore.save(activityLogModel);
|
|
37
|
-
|
|
38
|
-
EventProcessorSDK_1.EventProcessorSDK.getInstance().emitModelChange("ActivityLogModel", activityLogModel);
|
|
39
|
-
}
|
|
39
|
+
this.modelChangeEmitter?.emit("ActivityLogModel", activityLogModel);
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
async handleClientEventFromRemoteListener(event) {
|
|
@@ -44,7 +44,23 @@ class ActivityEventHandler extends BaseEventHandler_1.BaseEventHandler {
|
|
|
44
44
|
const updatedModel = event.apply(existingModel);
|
|
45
45
|
if (!this.shouldSkipSave(existingModel, updatedModel)) {
|
|
46
46
|
await this.activityLogModelStore.save(updatedModel);
|
|
47
|
-
|
|
47
|
+
this.modelChangeEmitter?.emit("ActivityLogModel", updatedModel);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
async handleClientEventsFromRemoteListenerBulk(events) {
|
|
51
|
+
const updatedModels = [];
|
|
52
|
+
for (const event of events) {
|
|
53
|
+
const existingModel = await this.activityLogModelStore.getByStreamIdWhereDeletedIsFalse(event.streamId);
|
|
54
|
+
const updatedModel = event.apply(existingModel);
|
|
55
|
+
if (!this.shouldSkipSave(existingModel, updatedModel)) {
|
|
56
|
+
await this.activityLogModelStore.save(updatedModel);
|
|
57
|
+
updatedModels.push(updatedModel);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
if (this.modelChangeEmitter && updatedModels.length > 0) {
|
|
61
|
+
for (const model of updatedModels) {
|
|
62
|
+
this.modelChangeEmitter.emit("ActivityLogModel", model);
|
|
63
|
+
}
|
|
48
64
|
}
|
|
49
65
|
}
|
|
50
66
|
handleEvent(event) {
|
|
@@ -1 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AU,EAAE,UAAU,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,IAAI,CAAC;IACX,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,OAAO,CAAC;gBAEpB,KAAK,EAAE,uBAAuB;IAe1C,KAAK,CAAC,SAAS,CAAC,EAAE,KAAK,GAAG,gBAAgB;CAc7C"}
|
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
import { Event } from "./common/Event";
|
|
2
2
|
import { Model } from "./common/Model";
|
|
3
|
+
import { ModelChangeEmitter } from "./ModelChangeEmitter";
|
|
4
|
+
import { ModelStore } from "./store/ModelStore";
|
|
3
5
|
export declare abstract class BaseEventHandler<T extends Event> {
|
|
6
|
+
protected readonly isClient: boolean;
|
|
7
|
+
protected readonly modelChangeEmitter?: ModelChangeEmitter;
|
|
8
|
+
constructor(isClient: boolean, modelChangeEmitter?: ModelChangeEmitter);
|
|
4
9
|
abstract handleEvent(event: T): Promise<any>;
|
|
5
10
|
abstract handleClientEventFromRemoteListener(event: T): Promise<void>;
|
|
11
|
+
abstract handleClientEventsFromRemoteListenerBulk(events: T[]): Promise<void>;
|
|
12
|
+
abstract getModelStore(): ModelStore;
|
|
6
13
|
protected shouldSkipSave(existingModel: Model | undefined, updatedModel: Model): boolean;
|
|
7
14
|
}
|
|
8
15
|
//# sourceMappingURL=BaseEventHandler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseEventHandler.d.ts","sourceRoot":"","sources":["../src/BaseEventHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"BaseEventHandler.d.ts","sourceRoot":"","sources":["../src/BaseEventHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,8BAAsB,gBAAgB,CAAC,CAAC,SAAS,KAAK;IAClD,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IACrC,SAAS,CAAC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;gBAE/C,QAAQ,EAAE,OAAO,EAAE,kBAAkB,CAAC,EAAE,kBAAkB;IAKtE,QAAQ,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC;IAC5C,QAAQ,CAAC,mCAAmC,CAAC,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IACrE,QAAQ,CAAC,wCAAwC,CAC7C,MAAM,EAAE,CAAC,EAAE,GACZ,OAAO,CAAC,IAAI,CAAC;IAChB,QAAQ,CAAC,aAAa,IAAI,UAAU;IAEpC,SAAS,CAAC,cAAc,CACpB,aAAa,EAAE,KAAK,GAAG,SAAS,EAChC,YAAY,EAAE,KAAK,GACpB,OAAO;CASb"}
|
package/dist/BaseEventHandler.js
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BaseEventHandler = void 0;
|
|
4
4
|
class BaseEventHandler {
|
|
5
|
+
constructor(isClient, modelChangeEmitter) {
|
|
6
|
+
this.isClient = isClient;
|
|
7
|
+
this.modelChangeEmitter = modelChangeEmitter;
|
|
8
|
+
}
|
|
5
9
|
shouldSkipSave(existingModel, updatedModel) {
|
|
6
10
|
if (!existingModel) {
|
|
7
11
|
return false;
|
|
@@ -36,10 +36,12 @@ export type StoreConfig = {
|
|
|
36
36
|
activityLogModelStore: ActivityLogModelStore;
|
|
37
37
|
activityLogEventStore: ActivityLogEventStore;
|
|
38
38
|
currencyStore: CurrencyStore;
|
|
39
|
+
isClient?: boolean;
|
|
39
40
|
};
|
|
40
41
|
export declare class EventProcessorSDK {
|
|
41
42
|
private static instance;
|
|
42
43
|
private readonly storeConfig;
|
|
44
|
+
private _isClient;
|
|
43
45
|
private userControllerInstance;
|
|
44
46
|
private friendControllerInstance;
|
|
45
47
|
private transactionControllerInstance;
|
|
@@ -55,6 +57,8 @@ export declare class EventProcessorSDK {
|
|
|
55
57
|
static initialize(config: StoreConfig): EventProcessorSDK;
|
|
56
58
|
static getInstance(): EventProcessorSDK;
|
|
57
59
|
static isInitialized(): boolean;
|
|
60
|
+
isClient(): boolean;
|
|
61
|
+
setIsClient(isClient: boolean): void;
|
|
58
62
|
static __resetForTesting(): void;
|
|
59
63
|
getStoreConfig(): StoreConfig;
|
|
60
64
|
getUserController(): UserController;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EventProcessorSDK.d.ts","sourceRoot":"","sources":["../src/EventProcessorSDK.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AAChF,OAAO,EAAE,0BAA0B,EAAE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,IAAI,4BAA4B,CAE9E;AAED,wBAAgB,uBAAuB,IAAI,oBAAoB,CAE9D;AAED,wBAAgB,kBAAkB,IAAI,eAAe,CAEpD;AAED,wBAAgB,gBAAgB,IAAI,aAAa,CAEhD;AAED,wBAAgB,wBAAwB,IAAI,UAAU,CAAC,WAAW,CAAC,CAElE;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,KAAK,GAAG,kBAAkB,CAEjE;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,kBAAkB,GAAG,KAAK,CAEhE;AAED,wBAAgB,gBAAgB,IAAI,OAAO,CAE1C;AAED,wBAAgB,oBAAoB,IAAI,IAAI,CAE3C"}
|
|
@@ -30,6 +30,7 @@ class EventProcessorSDK {
|
|
|
30
30
|
constructor(config) {
|
|
31
31
|
this.storeConfig = config;
|
|
32
32
|
this.modelChangeEmitter = new ModelChangeEmitter_1.ModelChangeEmitter();
|
|
33
|
+
this._isClient = config.isClient !== undefined ? config.isClient : true;
|
|
33
34
|
}
|
|
34
35
|
static initialize(config) {
|
|
35
36
|
EventProcessorSDK.instance = new EventProcessorSDK(config);
|
|
@@ -44,6 +45,12 @@ class EventProcessorSDK {
|
|
|
44
45
|
static isInitialized() {
|
|
45
46
|
return EventProcessorSDK.instance !== undefined;
|
|
46
47
|
}
|
|
48
|
+
isClient() {
|
|
49
|
+
return this._isClient;
|
|
50
|
+
}
|
|
51
|
+
setIsClient(isClient) {
|
|
52
|
+
this._isClient = isClient;
|
|
53
|
+
}
|
|
47
54
|
static __resetForTesting() {
|
|
48
55
|
EventProcessorSDK.instance = undefined;
|
|
49
56
|
}
|
|
@@ -76,38 +83,38 @@ class EventProcessorSDK {
|
|
|
76
83
|
}
|
|
77
84
|
getUserEventHandler() {
|
|
78
85
|
if (!this.userEventHandlerInstance) {
|
|
79
|
-
this.userEventHandlerInstance = new events_1.UserEventHandler(this.storeConfig.userModelStore, this.storeConfig.userEventStore, this.getActivityEventHandler());
|
|
86
|
+
this.userEventHandlerInstance = new events_1.UserEventHandler(this.storeConfig.userModelStore, this.storeConfig.userEventStore, this._isClient, this.modelChangeEmitter, this.getActivityEventHandler());
|
|
80
87
|
}
|
|
81
88
|
return this.userEventHandlerInstance;
|
|
82
89
|
}
|
|
83
90
|
getFriendEventHandler() {
|
|
84
91
|
if (!this.friendEventHandlerInstance) {
|
|
85
|
-
this.friendEventHandlerInstance = new events_1.FriendEventHandler(this.storeConfig.friendModelStore, this.storeConfig.userModelStore, this.storeConfig.friendEventStore, this.storeConfig.userEventStore, this.getActivityEventHandler());
|
|
92
|
+
this.friendEventHandlerInstance = new events_1.FriendEventHandler(this.storeConfig.friendModelStore, this.storeConfig.userModelStore, this.storeConfig.friendEventStore, this.storeConfig.userEventStore, this._isClient, this.modelChangeEmitter, this.getActivityEventHandler());
|
|
86
93
|
}
|
|
87
94
|
return this.friendEventHandlerInstance;
|
|
88
95
|
}
|
|
89
96
|
getTransactionEventHandler() {
|
|
90
97
|
if (!this.transactionEventHandlerInstance) {
|
|
91
|
-
this.transactionEventHandlerInstance = new events_1.TransactionEventHandler(this.storeConfig.transactionModelStore, this.storeConfig.transactionEventStore, this.getActivityEventHandler());
|
|
98
|
+
this.transactionEventHandlerInstance = new events_1.TransactionEventHandler(this.storeConfig.transactionModelStore, this.storeConfig.transactionEventStore, this._isClient, this.modelChangeEmitter, this.getActivityEventHandler());
|
|
92
99
|
}
|
|
93
100
|
return this.transactionEventHandlerInstance;
|
|
94
101
|
}
|
|
95
102
|
getGroupEventHandler() {
|
|
96
103
|
if (!this.groupEventHandlerInstance) {
|
|
97
|
-
this.groupEventHandlerInstance = new events_1.GroupEventHandler(this.storeConfig.groupModelStore, this.storeConfig.friendModelStore, this.storeConfig.userModelStore, this.storeConfig.groupEventStore, this.storeConfig.friendEventStore, this.getActivityEventHandler());
|
|
104
|
+
this.groupEventHandlerInstance = new events_1.GroupEventHandler(this.storeConfig.groupModelStore, this.storeConfig.friendModelStore, this.storeConfig.userModelStore, this.storeConfig.groupEventStore, this.storeConfig.friendEventStore, this._isClient, this.modelChangeEmitter, this.getActivityEventHandler());
|
|
98
105
|
}
|
|
99
106
|
return this.groupEventHandlerInstance;
|
|
100
107
|
}
|
|
101
108
|
getGroupTransactionEventHandler() {
|
|
102
109
|
if (!this.groupTransactionEventHandlerInstance) {
|
|
103
110
|
this.groupTransactionEventHandlerInstance =
|
|
104
|
-
new events_1.GroupTransactionEventHandler(this.storeConfig.groupTransactionModelStore, this.storeConfig.groupTransactionEventStore, this.storeConfig.groupModelStore, this.storeConfig.transactionEventStore, this.storeConfig.transactionModelStore, this.getActivityEventHandler());
|
|
111
|
+
new events_1.GroupTransactionEventHandler(this.storeConfig.groupTransactionModelStore, this.storeConfig.groupTransactionEventStore, this.storeConfig.groupModelStore, this.storeConfig.transactionEventStore, this.storeConfig.transactionModelStore, this._isClient, this.modelChangeEmitter, this.getActivityEventHandler());
|
|
105
112
|
}
|
|
106
113
|
return this.groupTransactionEventHandlerInstance;
|
|
107
114
|
}
|
|
108
115
|
getActivityEventHandler() {
|
|
109
116
|
if (!this.activityEventHandlerInstance) {
|
|
110
|
-
this.activityEventHandlerInstance = new events_1.ActivityEventHandler(this.storeConfig.activityLogModelStore, this.storeConfig.activityLogEventStore, this.storeConfig.userModelStore);
|
|
117
|
+
this.activityEventHandlerInstance = new events_1.ActivityEventHandler(this.storeConfig.activityLogModelStore, this.storeConfig.activityLogEventStore, this.storeConfig.userModelStore, this._isClient, this.modelChangeEmitter);
|
|
111
118
|
}
|
|
112
119
|
return this.activityEventHandlerInstance;
|
|
113
120
|
}
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { FriendCreated, FriendEvent, FriendEventStore, FriendModelStore, UserEventStore, UserModelStore } from ".";
|
|
2
2
|
import { BaseEventHandler } from "./BaseEventHandler";
|
|
3
3
|
import { ActivityEventHandler } from "./ActivityEventHandler";
|
|
4
|
+
import { ModelChangeEmitter } from "./ModelChangeEmitter";
|
|
4
5
|
export declare class FriendEventHandler extends BaseEventHandler<FriendEvent> {
|
|
5
6
|
private modelStore;
|
|
6
7
|
private userModelStore;
|
|
7
8
|
private friendEventStore;
|
|
8
9
|
private userEventStore;
|
|
9
10
|
private activityEventHandler?;
|
|
10
|
-
constructor(modelStore: FriendModelStore, userModelStore: UserModelStore, friendEventStore: FriendEventStore, userEventStore: UserEventStore, activityEventHandler?: ActivityEventHandler | undefined);
|
|
11
|
+
constructor(modelStore: FriendModelStore, userModelStore: UserModelStore, friendEventStore: FriendEventStore, userEventStore: UserEventStore, isClient: boolean, modelChangeEmitter?: ModelChangeEmitter, activityEventHandler?: ActivityEventHandler | undefined);
|
|
12
|
+
getModelStore(): FriendModelStore;
|
|
11
13
|
handleClientEventFromRemoteListener(event: FriendEvent): Promise<void>;
|
|
14
|
+
handleClientEventsFromRemoteListenerBulk(events: FriendEvent[]): Promise<void>;
|
|
12
15
|
handleEvent(event: FriendEvent): Promise<void>;
|
|
13
16
|
handleFriendCreated(event: FriendCreated): Promise<void>;
|
|
14
17
|
handleGenericFriendEvent(event: FriendEvent): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FriendEventHandler.d.ts","sourceRoot":"","sources":["../src/FriendEventHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,aAAa,EACb,WAAW,EACX,gBAAgB,EAGhB,gBAAgB,
|
|
1
|
+
{"version":3,"file":"FriendEventHandler.d.ts","sourceRoot":"","sources":["../src/FriendEventHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,aAAa,EACb,WAAW,EACX,gBAAgB,EAGhB,gBAAgB,EAGhB,cAAc,EAEd,cAAc,EACjB,MAAM,GAAG,CAAC;AACX,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,qBAAa,kBAAmB,SAAQ,gBAAgB,CAAC,WAAW,CAAC;IAE7D,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,cAAc;IACtB,OAAO,CAAC,gBAAgB;IACxB,OAAO,CAAC,cAAc;IAGtB,OAAO,CAAC,oBAAoB,CAAC;gBANrB,UAAU,EAAE,gBAAgB,EAC5B,cAAc,EAAE,cAAc,EAC9B,gBAAgB,EAAE,gBAAgB,EAClC,cAAc,EAAE,cAAc,EACtC,QAAQ,EAAE,OAAO,EACjB,kBAAkB,CAAC,EAAE,kBAAkB,EAC/B,oBAAoB,CAAC,EAAE,oBAAoB,YAAA;IAKhD,aAAa,IAAI,gBAAgB;IAI3B,mCAAmC,CAC5C,KAAK,EAAE,WAAW,GACnB,OAAO,CAAC,IAAI,CAAC;IAWH,wCAAwC,CACjD,MAAM,EAAE,WAAW,EAAE,GACtB,OAAO,CAAC,IAAI,CAAC;IAqBV,WAAW,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAW9C,mBAAmB,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IA0BxD,wBAAwB,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAwB3D,4BAA4B,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;YAYzD,yBAAyB;CA4I1C"}
|
|
@@ -4,23 +4,39 @@ exports.FriendEventHandler = void 0;
|
|
|
4
4
|
const _1 = require(".");
|
|
5
5
|
const BaseEventHandler_1 = require("./BaseEventHandler");
|
|
6
6
|
const uuid_1 = require("uuid");
|
|
7
|
-
const EventProcessorSDK_1 = require("./EventProcessorSDK");
|
|
8
7
|
class FriendEventHandler extends BaseEventHandler_1.BaseEventHandler {
|
|
9
|
-
constructor(modelStore, userModelStore, friendEventStore, userEventStore, activityEventHandler) {
|
|
10
|
-
super();
|
|
8
|
+
constructor(modelStore, userModelStore, friendEventStore, userEventStore, isClient, modelChangeEmitter, activityEventHandler) {
|
|
9
|
+
super(isClient, modelChangeEmitter);
|
|
11
10
|
this.modelStore = modelStore;
|
|
12
11
|
this.userModelStore = userModelStore;
|
|
13
12
|
this.friendEventStore = friendEventStore;
|
|
14
13
|
this.userEventStore = userEventStore;
|
|
15
14
|
this.activityEventHandler = activityEventHandler;
|
|
16
15
|
}
|
|
16
|
+
getModelStore() {
|
|
17
|
+
return this.modelStore;
|
|
18
|
+
}
|
|
17
19
|
async handleClientEventFromRemoteListener(event) {
|
|
18
20
|
const existingModel = await this.modelStore.getByStreamId(event.streamId);
|
|
19
21
|
const updatedModel = event.apply(existingModel);
|
|
20
22
|
if (!this.shouldSkipSave(existingModel, updatedModel)) {
|
|
21
23
|
await this.modelStore.save(updatedModel);
|
|
22
|
-
|
|
23
|
-
|
|
24
|
+
this.modelChangeEmitter?.emit("FriendModel", updatedModel);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
async handleClientEventsFromRemoteListenerBulk(events) {
|
|
28
|
+
const updatedModels = [];
|
|
29
|
+
for (const event of events) {
|
|
30
|
+
const existingModel = await this.modelStore.getByStreamId(event.streamId);
|
|
31
|
+
const updatedModel = event.apply(existingModel);
|
|
32
|
+
if (!this.shouldSkipSave(existingModel, updatedModel)) {
|
|
33
|
+
await this.modelStore.save(updatedModel);
|
|
34
|
+
updatedModels.push(updatedModel);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
if (this.modelChangeEmitter && updatedModels.length > 0) {
|
|
38
|
+
for (const model of updatedModels) {
|
|
39
|
+
this.modelChangeEmitter.emit("FriendModel", model);
|
|
24
40
|
}
|
|
25
41
|
}
|
|
26
42
|
}
|
|
@@ -40,11 +56,9 @@ class FriendEventHandler extends BaseEventHandler_1.BaseEventHandler {
|
|
|
40
56
|
return;
|
|
41
57
|
}
|
|
42
58
|
await this.modelStore.save(updatedModel);
|
|
43
|
-
if (
|
|
59
|
+
if (this.isClient) {
|
|
44
60
|
await this.friendEventStore.addEvent(event);
|
|
45
|
-
|
|
46
|
-
EventProcessorSDK_1.EventProcessorSDK.getInstance().emitModelChange("FriendModel", updatedModel);
|
|
47
|
-
}
|
|
61
|
+
this.modelChangeEmitter?.emit("FriendModel", updatedModel);
|
|
48
62
|
if (this.activityEventHandler) {
|
|
49
63
|
await this.activityEventHandler.createActivityLog(event, existingModel, updatedModel);
|
|
50
64
|
}
|
|
@@ -60,11 +74,9 @@ class FriendEventHandler extends BaseEventHandler_1.BaseEventHandler {
|
|
|
60
74
|
return;
|
|
61
75
|
}
|
|
62
76
|
await this.modelStore.save(updatedModel);
|
|
63
|
-
if (
|
|
77
|
+
if (this.isClient) {
|
|
64
78
|
await this.friendEventStore.addEvent(event);
|
|
65
|
-
|
|
66
|
-
EventProcessorSDK_1.EventProcessorSDK.getInstance().emitModelChange("FriendModel", updatedModel);
|
|
67
|
-
}
|
|
79
|
+
this.modelChangeEmitter?.emit("FriendModel", updatedModel);
|
|
68
80
|
if (this.activityEventHandler) {
|
|
69
81
|
await this.activityEventHandler.createActivityLog(event, existingModel, updatedModel);
|
|
70
82
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { FriendEventStore, FriendModelStore, GroupCreated, GroupDeleted, GroupDescriptionChanged, GroupEvent, GroupEventStore, GroupMembersAdded, GroupMembersRemoved, GroupModel, GroupModelStore, GroupNameChanged, UserModelStore } from ".";
|
|
2
2
|
import { BaseEventHandler } from "./BaseEventHandler";
|
|
3
3
|
import { ActivityEventHandler } from "./ActivityEventHandler";
|
|
4
|
+
import { ModelChangeEmitter } from "./ModelChangeEmitter";
|
|
4
5
|
export declare class GroupEventHandler extends BaseEventHandler<GroupEvent> {
|
|
5
6
|
private modelStore;
|
|
6
7
|
private friendModelStore;
|
|
@@ -8,8 +9,10 @@ export declare class GroupEventHandler extends BaseEventHandler<GroupEvent> {
|
|
|
8
9
|
private groupEventStore;
|
|
9
10
|
private friendEventStore;
|
|
10
11
|
private activityEventHandler?;
|
|
11
|
-
constructor(modelStore: GroupModelStore, friendModelStore: FriendModelStore, userModelStore: UserModelStore, groupEventStore: GroupEventStore, friendEventStore: FriendEventStore, activityEventHandler?: ActivityEventHandler | undefined);
|
|
12
|
+
constructor(modelStore: GroupModelStore, friendModelStore: FriendModelStore, userModelStore: UserModelStore, groupEventStore: GroupEventStore, friendEventStore: FriendEventStore, isClient: boolean, modelChangeEmitter?: ModelChangeEmitter, activityEventHandler?: ActivityEventHandler | undefined);
|
|
13
|
+
getModelStore(): GroupModelStore;
|
|
12
14
|
handleClientEventFromRemoteListener(event: GroupEvent): Promise<void>;
|
|
15
|
+
handleClientEventsFromRemoteListenerBulk(events: GroupEvent[]): Promise<void>;
|
|
13
16
|
currentUserId?: string;
|
|
14
17
|
handleEvent(event: GroupEvent): Promise<GroupModel>;
|
|
15
18
|
private ensureBidirectionalFriendship;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GroupEventHandler.d.ts","sourceRoot":"","sources":["../src/GroupEventHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,gBAAgB,EAChB,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,uBAAuB,EACvB,UAAU,EACV,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACnB,UAAU,EACV,eAAe,EACf,gBAAgB,EAEhB,cAAc,EACjB,MAAM,GAAG,CAAC;AACX,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"GroupEventHandler.d.ts","sourceRoot":"","sources":["../src/GroupEventHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,gBAAgB,EAChB,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,uBAAuB,EACvB,UAAU,EACV,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACnB,UAAU,EACV,eAAe,EACf,gBAAgB,EAEhB,cAAc,EACjB,MAAM,GAAG,CAAC;AACX,OAAO,EAAE,g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,OAAO,CAAC,UAAU,CAAC;IAyFhB,kBAAkB,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,UAAU,CAAC;CAuDrE"}
|
|
@@ -4,10 +4,9 @@ exports.GroupEventHandler = void 0;
|
|
|
4
4
|
const _1 = require(".");
|
|
5
5
|
const BaseEventHandler_1 = require("./BaseEventHandler");
|
|
6
6
|
const uuid_1 = require("uuid");
|
|
7
|
-
const EventProcessorSDK_1 = require("./EventProcessorSDK");
|
|
8
7
|
class GroupEventHandler extends BaseEventHandler_1.BaseEventHandler {
|
|
9
|
-
constructor(modelStore, friendModelStore, userModelStore, groupEventStore, friendEventStore, activityEventHandler) {
|
|
10
|
-
super();
|
|
8
|
+
constructor(modelStore, friendModelStore, userModelStore, groupEventStore, friendEventStore, isClient, modelChangeEmitter, activityEventHandler) {
|
|
9
|
+
super(isClient, modelChangeEmitter);
|
|
11
10
|
this.modelStore = modelStore;
|
|
12
11
|
this.friendModelStore = friendModelStore;
|
|
13
12
|
this.userModelStore = userModelStore;
|
|
@@ -15,19 +14,36 @@ class GroupEventHandler extends BaseEventHandler_1.BaseEventHandler {
|
|
|
15
14
|
this.friendEventStore = friendEventStore;
|
|
16
15
|
this.activityEventHandler = activityEventHandler;
|
|
17
16
|
}
|
|
17
|
+
getModelStore() {
|
|
18
|
+
return this.modelStore;
|
|
19
|
+
}
|
|
18
20
|
async handleClientEventFromRemoteListener(event) {
|
|
19
21
|
const existingModel = await this.modelStore.getByStreamId(event.streamId);
|
|
20
22
|
const updatedModel = event.apply(existingModel);
|
|
21
23
|
if (!this.shouldSkipSave(existingModel, updatedModel)) {
|
|
22
24
|
await this.modelStore.save(updatedModel);
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
this.modelChangeEmitter?.emit("GroupModel", updatedModel);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
async handleClientEventsFromRemoteListenerBulk(events) {
|
|
29
|
+
const updatedModels = [];
|
|
30
|
+
for (const event of events) {
|
|
31
|
+
const existingModel = await this.modelStore.getByStreamId(event.streamId);
|
|
32
|
+
const updatedModel = event.apply(existingModel);
|
|
33
|
+
if (!this.shouldSkipSave(existingModel, updatedModel)) {
|
|
34
|
+
await this.modelStore.save(updatedModel);
|
|
35
|
+
updatedModels.push(updatedModel);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
if (this.modelChangeEmitter && updatedModels.length > 0) {
|
|
39
|
+
for (const model of updatedModels) {
|
|
40
|
+
this.modelChangeEmitter.emit("GroupModel", model);
|
|
25
41
|
}
|
|
26
42
|
}
|
|
27
43
|
}
|
|
28
44
|
async handleEvent(event) {
|
|
29
45
|
const eventType = event.constructor.name;
|
|
30
|
-
if (
|
|
46
|
+
if (this.isClient) {
|
|
31
47
|
const user = await this.userModelStore.appUser();
|
|
32
48
|
this.currentUserId = user.userId;
|
|
33
49
|
}
|
|
@@ -107,9 +123,9 @@ class GroupEventHandler extends BaseEventHandler_1.BaseEventHandler {
|
|
|
107
123
|
return existingModel;
|
|
108
124
|
}
|
|
109
125
|
await this.modelStore.save(updatedModel);
|
|
110
|
-
if (
|
|
126
|
+
if (this.isClient) {
|
|
111
127
|
await this.groupEventStore.addEvent(event);
|
|
112
|
-
|
|
128
|
+
this.modelChangeEmitter?.emit("GroupModel", updatedModel);
|
|
113
129
|
if (this.activityEventHandler) {
|
|
114
130
|
await this.activityEventHandler.createActivityLog(event, undefined, updatedModel);
|
|
115
131
|
}
|
|
@@ -159,9 +175,9 @@ class GroupEventHandler extends BaseEventHandler_1.BaseEventHandler {
|
|
|
159
175
|
return existingModel;
|
|
160
176
|
}
|
|
161
177
|
await this.modelStore.save(updatedModel);
|
|
162
|
-
if (
|
|
178
|
+
if (this.isClient) {
|
|
163
179
|
await this.groupEventStore.addEvent(event);
|
|
164
|
-
|
|
180
|
+
this.modelChangeEmitter?.emit("GroupModel", updatedModel);
|
|
165
181
|
if (this.activityEventHandler) {
|
|
166
182
|
await this.activityEventHandler.createActivityLog(event, existingModel, updatedModel);
|
|
167
183
|
}
|
|
@@ -198,9 +214,9 @@ class GroupEventHandler extends BaseEventHandler_1.BaseEventHandler {
|
|
|
198
214
|
return existingModel;
|
|
199
215
|
}
|
|
200
216
|
await this.modelStore.save(updatedModel);
|
|
201
|
-
if (
|
|
217
|
+
if (this.isClient) {
|
|
202
218
|
await this.groupEventStore.addEvent(event);
|
|
203
|
-
|
|
219
|
+
this.modelChangeEmitter?.emit("GroupModel", updatedModel);
|
|
204
220
|
if (this.activityEventHandler) {
|
|
205
221
|
await this.activityEventHandler.createActivityLog(event, existingModel, updatedModel);
|
|
206
222
|
}
|
|
@@ -240,9 +256,9 @@ class GroupEventHandler extends BaseEventHandler_1.BaseEventHandler {
|
|
|
240
256
|
return existingModel;
|
|
241
257
|
}
|
|
242
258
|
await this.modelStore.save(updatedModel);
|
|
243
|
-
if (
|
|
259
|
+
if (this.isClient) {
|
|
244
260
|
await this.groupEventStore.addEvent(event);
|
|
245
|
-
|
|
261
|
+
this.modelChangeEmitter?.emit("GroupModel", updatedModel);
|
|
246
262
|
if (this.activityEventHandler) {
|
|
247
263
|
await this.activityEventHandler.createActivityLog(event, existingModel, updatedModel);
|
|
248
264
|
}
|
|
@@ -313,9 +329,9 @@ class GroupEventHandler extends BaseEventHandler_1.BaseEventHandler {
|
|
|
313
329
|
return existingModel;
|
|
314
330
|
}
|
|
315
331
|
await this.modelStore.save(updatedModel);
|
|
316
|
-
if (
|
|
332
|
+
if (this.isClient) {
|
|
317
333
|
await this.groupEventStore.addEvent(event);
|
|
318
|
-
|
|
334
|
+
this.modelChangeEmitter?.emit("GroupModel", updatedModel);
|
|
319
335
|
if (this.activityEventHandler) {
|
|
320
336
|
await this.activityEventHandler.createActivityLog(event, existingModel, updatedModel);
|
|
321
337
|
}
|
|
@@ -372,9 +388,9 @@ class GroupEventHandler extends BaseEventHandler_1.BaseEventHandler {
|
|
|
372
388
|
return existingModel;
|
|
373
389
|
}
|
|
374
390
|
await this.modelStore.save(updatedModel);
|
|
375
|
-
if (
|
|
391
|
+
if (this.isClient) {
|
|
376
392
|
await this.groupEventStore.addEvent(event);
|
|
377
|
-
|
|
393
|
+
this.modelChangeEmitter?.emit("GroupModel", updatedModel);
|
|
378
394
|
if (this.activityEventHandler) {
|
|
379
395
|
await this.activityEventHandler.createActivityLog(event, existingModel, updatedModel);
|
|
380
396
|
}
|
|
@@ -6,6 +6,7 @@ import { TransactionEventStore } from ".";
|
|
|
6
6
|
import { TransactionModelStore } from ".";
|
|
7
7
|
import { BaseEventHandler } from "./BaseEventHandler";
|
|
8
8
|
import { ActivityEventHandler } from "./ActivityEventHandler";
|
|
9
|
+
import { ModelChangeEmitter } from "./ModelChangeEmitter";
|
|
9
10
|
export declare class GroupTransactionEventHandler extends BaseEventHandler<GroupTransactionEvent> {
|
|
10
11
|
private modelStore;
|
|
11
12
|
private eventStore;
|
|
@@ -13,14 +14,11 @@ export declare class GroupTransactionEventHandler extends BaseEventHandler<Group
|
|
|
13
14
|
private transactionEventStore;
|
|
14
15
|
private transactionModelStore;
|
|
15
16
|
private activityEventHandler?;
|
|
16
|
-
constructor(modelStore: GroupTransactionModelStore, eventStore: GroupTransactionEventStore, groupModelStore: GroupModelStore, transactionEventStore: TransactionEventStore, transactionModelStore: TransactionModelStore, activityEventHandler?: ActivityEventHandler | undefined);
|
|
17
|
+
constructor(modelStore: GroupTransactionModelStore, eventStore: GroupTransactionEventStore, groupModelStore: GroupModelStore, transactionEventStore: TransactionEventStore, transactionModelStore: TransactionModelStore, isClient: boolean, modelChangeEmitter?: ModelChangeEmitter, activityEventHandler?: ActivityEventHandler | undefined);
|
|
18
|
+
getModelStore(): GroupTransactionModelStore;
|
|
17
19
|
handleClientEventFromRemoteListener(event: GroupTransactionEvent): Promise<void>;
|
|
20
|
+
handleClientEventsFromRemoteListenerBulk(events: GroupTransactionEvent[]): Promise<void>;
|
|
18
21
|
handleEvent(event: GroupTransactionEvent): Promise<GroupTransactionModel>;
|
|
19
|
-
private calculateNetBalances;
|
|
20
|
-
private createFriendTransactions;
|
|
21
|
-
private updateFriendTransactions;
|
|
22
|
-
private calculateRequiredTransactions;
|
|
23
|
-
private updateExistingFriendTransactions;
|
|
24
22
|
handleGroupTransactionCreated(event: GroupTransactionCreated): Promise<GroupTransactionModel>;
|
|
25
23
|
handleGroupTransactionSplitDetailsChanged(event: GroupTransactionSplitDetailsChanged): Promise<GroupTransactionModel>;
|
|
26
24
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GroupTransactionEventHandler.d.ts","sourceRoot":"","sources":["../src/GroupTransactionEventHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,uBAAuB,EACvB,mCAAmC,EACnC,qBAAqB,
|
|
1
|
+
{"version":3,"file":"GroupTransactionEventHandler.d.ts","sourceRoot":"","sources":["../src/GroupTransactionEventHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,uBAAuB,EACvB,mCAAmC,EACnC,qBAAqB,EACrB,qBAAqB,EAIxB,MAAM,GAAG,CAAC;AACX,OAAO,EAAE,0BAA0B,EAAE,MAAM,GAAG,CAAC;AAC/C,OAAO,EAAE,0BAA0B,EAAE,MAAM,GAAG,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,GAAG,CAAC;AACpC,OAAO,EAAE,qBAAqB,EAAE,MAAM,GAAG,CAAC;AAC1C,OAAO,EAAE,qBAAqB,EAAE,MAAM,GAAG,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,qBAAa,4BAA6B,SAAQ,gBAAgB,CAAC,qBAAqB,CAAC;IAEjF,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,eAAe;IACvB,OAAO,CAAC,qBAAqB;IAC7B,OAAO,CAAC,qBAAqB;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