@zeeshan60/event-processor 1.0.156 → 1.0.158
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/EventProcessorSDK.d.ts +1 -12
- package/dist/EventProcessorSDK.d.ts.map +1 -1
- package/dist/EventProcessorSDK.js +0 -25
- package/dist/EventProcessorSDK.js.map +1 -1
- package/dist/GroupTransactionEvents.d.ts +6 -0
- package/dist/GroupTransactionEvents.d.ts.map +1 -1
- package/dist/GroupTransactionEvents.js +4 -0
- package/dist/GroupTransactionEvents.js.map +1 -1
- package/dist/TransactionEvents.d.ts +6 -0
- package/dist/TransactionEvents.d.ts.map +1 -1
- package/dist/TransactionEvents.js +4 -0
- package/dist/TransactionEvents.js.map +1 -1
- package/dist/client/controllers/GroupTransactionController.d.ts +5 -0
- package/dist/client/controllers/GroupTransactionController.d.ts.map +1 -1
- package/dist/client/controllers/GroupTransactionController.js +16 -0
- package/dist/client/controllers/GroupTransactionController.js.map +1 -1
- package/dist/client/controllers/TransactionController.d.ts +5 -0
- package/dist/client/controllers/TransactionController.d.ts.map +1 -1
- package/dist/client/controllers/TransactionController.js +21 -0
- package/dist/client/controllers/TransactionController.js.map +1 -1
- package/dist/common/DomainEvents.d.ts +0 -2
- package/dist/common/DomainEvents.d.ts.map +1 -1
- package/dist/common/EventTypes.d.ts +0 -2
- package/dist/common/EventTypes.d.ts.map +1 -1
- package/dist/common/EventTypes.js +0 -3
- package/dist/common/EventTypes.js.map +1 -1
- package/dist/contracts/groups/index.d.ts +6 -0
- package/dist/contracts/groups/index.d.ts.map +1 -1
- package/dist/contracts/groups/index.js +4 -0
- package/dist/contracts/groups/index.js.map +1 -1
- package/dist/contracts/transactions/index.d.ts +6 -0
- package/dist/contracts/transactions/index.d.ts.map +1 -1
- package/dist/contracts/transactions/index.js +4 -0
- package/dist/contracts/transactions/index.js.map +1 -1
- package/dist/converters/eventConverter.d.ts.map +1 -1
- package/dist/converters/eventConverter.js +0 -7
- package/dist/converters/eventConverter.js.map +1 -1
- package/dist/events.d.ts +0 -4
- package/dist/events.d.ts.map +1 -1
- package/dist/events.js +1 -6
- package/dist/events.js.map +1 -1
- package/dist/index.d.ts +2 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -6
- package/dist/index.js.map +1 -1
- package/dist/utils/GroupUtil.d.ts.map +1 -1
- package/dist/utils/GroupUtil.js +3 -0
- package/dist/utils/GroupUtil.js.map +1 -1
- package/package.json +1 -1
- package/dist/ReminderEventHandler.d.ts +0 -38
- package/dist/ReminderEventHandler.d.ts.map +0 -1
- package/dist/ReminderEventHandler.js +0 -190
- package/dist/ReminderEventHandler.js.map +0 -1
- package/dist/ReminderEvents.d.ts +0 -50
- package/dist/ReminderEvents.d.ts.map +0 -1
- package/dist/ReminderEvents.js +0 -51
- package/dist/ReminderEvents.js.map +0 -1
- package/dist/client/controllers/ReminderController.d.ts +0 -10
- package/dist/client/controllers/ReminderController.d.ts.map +0 -1
- package/dist/client/controllers/ReminderController.js +0 -83
- package/dist/client/controllers/ReminderController.js.map +0 -1
- package/dist/store/ReminderEventStore.d.ts +0 -5
- package/dist/store/ReminderEventStore.d.ts.map +0 -1
- package/dist/store/ReminderEventStore.js +0 -3
- package/dist/store/ReminderEventStore.js.map +0 -1
- package/dist/store/ReminderModelStore.d.ts +0 -11
- package/dist/store/ReminderModelStore.d.ts.map +0 -1
- package/dist/store/ReminderModelStore.js +0 -5
- package/dist/store/ReminderModelStore.js.map +0 -1
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ReminderEventHandler = void 0;
|
|
4
|
-
const NotificationEvents_1 = require("./NotificationEvents");
|
|
5
|
-
const EventTypes_1 = require("./common/EventTypes");
|
|
6
|
-
const BaseEventHandler_1 = require("./BaseEventHandler");
|
|
7
|
-
const BalanceUtil_1 = require("./utils/BalanceUtil");
|
|
8
|
-
const uuid_1 = require("uuid");
|
|
9
|
-
const contracts_1 = require("./contracts");
|
|
10
|
-
class ReminderEventHandler extends BaseEventHandler_1.BaseEventHandler {
|
|
11
|
-
constructor(modelStore, reminderEventStore, transactionModelStore, groupTransactionModelStore, friendModelStore, userModelStore, groupModelStore, currencyStore, notificationEventHandler, isClient, clientType, modelChangeEmitter, notificationPublisher, logger) {
|
|
12
|
-
super(isClient, clientType, modelChangeEmitter, logger);
|
|
13
|
-
this.modelStore = modelStore;
|
|
14
|
-
this.reminderEventStore = reminderEventStore;
|
|
15
|
-
this.transactionModelStore = transactionModelStore;
|
|
16
|
-
this.groupTransactionModelStore = groupTransactionModelStore;
|
|
17
|
-
this.friendModelStore = friendModelStore;
|
|
18
|
-
this.userModelStore = userModelStore;
|
|
19
|
-
this.groupModelStore = groupModelStore;
|
|
20
|
-
this.currencyStore = currencyStore;
|
|
21
|
-
this.notificationEventHandler = notificationEventHandler;
|
|
22
|
-
this.notificationPublisher = notificationPublisher;
|
|
23
|
-
}
|
|
24
|
-
getModelStore() {
|
|
25
|
-
return this.modelStore;
|
|
26
|
-
}
|
|
27
|
-
getEventStore() {
|
|
28
|
-
return this.reminderEventStore;
|
|
29
|
-
}
|
|
30
|
-
async handleEvent(event, _context) {
|
|
31
|
-
switch (event.eventType) {
|
|
32
|
-
case EventTypes_1.EventType.SETTLE_UP_REMINDER_TRIGGERED:
|
|
33
|
-
return await this.handleSettleUpReminderTriggered(event, _context);
|
|
34
|
-
default:
|
|
35
|
-
throw new Error(`Unknown reminder event type: ${event.eventType}`);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
async handleSettleUpReminderTriggered(event, context) {
|
|
39
|
-
this.logger.log("[debug] handleSettleUpReminderTriggered START", {
|
|
40
|
-
streamId: event.streamId,
|
|
41
|
-
userId: event.userId,
|
|
42
|
-
recipientUserId: event.recipientUserId,
|
|
43
|
-
groupId: event.groupId,
|
|
44
|
-
isClient: this.isClient,
|
|
45
|
-
});
|
|
46
|
-
const existingModel = await this.modelStore.getByStreamIdWhereDeletedIsFalse(event.streamId);
|
|
47
|
-
if (this.shouldSkipSave(existingModel, event)) {
|
|
48
|
-
this.logger.log("[debug] skipping save (already processed)");
|
|
49
|
-
return existingModel;
|
|
50
|
-
}
|
|
51
|
-
const updatedModel = event.apply(existingModel);
|
|
52
|
-
if (this.isNotAIClient()) {
|
|
53
|
-
await this.modelStore.save(updatedModel);
|
|
54
|
-
this.logger.log("[debug] model saved");
|
|
55
|
-
}
|
|
56
|
-
if (this.isClient) {
|
|
57
|
-
await this.reminderEventStore.addEvent(event);
|
|
58
|
-
this.modelChangeEmitter?.emit(event.eventMainType);
|
|
59
|
-
this.logger.log("[debug] client path done, event stored");
|
|
60
|
-
return updatedModel;
|
|
61
|
-
}
|
|
62
|
-
if (event.groupId) {
|
|
63
|
-
this.logger.log("[debug] routing to handleGroupReminder");
|
|
64
|
-
await this.handleGroupReminder(event, context);
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
this.logger.log("[debug] routing to handleFriendReminder");
|
|
68
|
-
await this.handleFriendReminder(event, context);
|
|
69
|
-
}
|
|
70
|
-
return updatedModel;
|
|
71
|
-
}
|
|
72
|
-
async handleFriendReminder(event, context) {
|
|
73
|
-
if (!this.notificationPublisher) {
|
|
74
|
-
this.logger.log("[debug] handleFriendReminder: no notificationPublisher, returning");
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
const transactions = await this.transactionModelStore.findByUserIdAndRecipientUserIdWhereDeletedIsFalse(event.userId, event.recipientUserId);
|
|
78
|
-
this.logger.log("[debug] handleFriendReminder: transactions found", {
|
|
79
|
-
count: transactions.length,
|
|
80
|
-
});
|
|
81
|
-
if (transactions.length === 0)
|
|
82
|
-
return;
|
|
83
|
-
const balanceUtil = new BalanceUtil_1.BalanceUtil(this.userModelStore, this.currencyStore);
|
|
84
|
-
const balance = await balanceUtil.calculateBalance(transactions, event.recipientUserId);
|
|
85
|
-
this.logger.log("[debug] handleFriendReminder: balance calculated", {
|
|
86
|
-
hasMain: !!balance.main,
|
|
87
|
-
amount: balance.main?.amount,
|
|
88
|
-
isOwed: balance.main?.isOwed,
|
|
89
|
-
currency: balance.main?.currency,
|
|
90
|
-
});
|
|
91
|
-
if (!balance.main || balance.main.amount <= 0 || balance.main.isOwed)
|
|
92
|
-
return;
|
|
93
|
-
const senderUser = await this.userModelStore.getByStreamIdWhereDeletedIsFalse(event.userId);
|
|
94
|
-
const senderName = senderUser?.displayName || "Someone";
|
|
95
|
-
const formattedAmount = balance.main.amount.toFixed(2);
|
|
96
|
-
const title = "Settle Up Reminder";
|
|
97
|
-
const body = `${senderName} is reminding you to settle up ${formattedAmount} ${balance.main.currency}`;
|
|
98
|
-
try {
|
|
99
|
-
await this.notificationPublisher.sendNotificationToUser(event.recipientUserId, { title, body });
|
|
100
|
-
await this.createNotificationEvent(event.recipientUserId, event.userId, title, body, event.streamId);
|
|
101
|
-
}
|
|
102
|
-
catch (error) {
|
|
103
|
-
this.logger.error("[ReminderEventHandler] Failed to send friend reminder notification", {
|
|
104
|
-
streamId: event.streamId,
|
|
105
|
-
recipientUserId: event.recipientUserId,
|
|
106
|
-
error: error instanceof Error ? error.message : String(error),
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
async handleGroupReminder(event, context) {
|
|
111
|
-
if (!this.notificationPublisher || !event.groupId)
|
|
112
|
-
return;
|
|
113
|
-
const groupModel = await this.groupModelStore.findByUserIdAndGroupIdAndDeletedIsFalse(event.userId, event.groupId);
|
|
114
|
-
if (!groupModel)
|
|
115
|
-
return;
|
|
116
|
-
const groupTransactions = await this.groupTransactionModelStore.findByUserIdAndGroupIdWhereDeletedIsFalse(event.userId, event.groupId);
|
|
117
|
-
if (groupTransactions.length === 0)
|
|
118
|
-
return;
|
|
119
|
-
const memberBalances = new Map();
|
|
120
|
-
for (const tx of groupTransactions) {
|
|
121
|
-
for (const owe of tx.whoOweYou) {
|
|
122
|
-
if (!memberBalances.has(owe.memberId)) {
|
|
123
|
-
memberBalances.set(owe.memberId, new Map());
|
|
124
|
-
}
|
|
125
|
-
const currencyMap = memberBalances.get(owe.memberId);
|
|
126
|
-
const existing = currencyMap.get(tx.currency) || 0;
|
|
127
|
-
currencyMap.set(tx.currency, existing + owe.amount);
|
|
128
|
-
}
|
|
129
|
-
for (const owe of tx.whoYouOwe) {
|
|
130
|
-
if (!memberBalances.has(owe.memberId)) {
|
|
131
|
-
memberBalances.set(owe.memberId, new Map());
|
|
132
|
-
}
|
|
133
|
-
const currencyMap = memberBalances.get(owe.memberId);
|
|
134
|
-
const existing = currencyMap.get(tx.currency) || 0;
|
|
135
|
-
currencyMap.set(tx.currency, existing - owe.amount);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
const senderUser = await this.userModelStore.getByStreamIdWhereDeletedIsFalse(event.userId);
|
|
139
|
-
const senderName = senderUser?.displayName || "Someone";
|
|
140
|
-
const currencyRates = (await this.currencyStore.getCurrencyRates())?.rates ?? {};
|
|
141
|
-
for (const [memberId, currencyMap] of memberBalances) {
|
|
142
|
-
const memberUser = await this.userModelStore.getByStreamIdWhereDeletedIsFalse(memberId);
|
|
143
|
-
const memberCurrency = memberUser?.currency ?? "USD";
|
|
144
|
-
let totalOwed = 0;
|
|
145
|
-
for (const [currency, balance] of currencyMap) {
|
|
146
|
-
if (balance > 0) {
|
|
147
|
-
totalOwed += (0, contracts_1.convertCurrency)(balance, currency, memberCurrency, currencyRates);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
if (totalOwed <= 0)
|
|
151
|
-
continue;
|
|
152
|
-
const formattedAmount = totalOwed.toFixed(2);
|
|
153
|
-
const title = "Settle Up Reminder";
|
|
154
|
-
const body = `${senderName} is reminding you to settle up ${formattedAmount} ${memberCurrency} in ${groupModel.name}`;
|
|
155
|
-
try {
|
|
156
|
-
await this.notificationPublisher.sendNotificationToUser(memberId, {
|
|
157
|
-
title,
|
|
158
|
-
body,
|
|
159
|
-
});
|
|
160
|
-
await this.createNotificationEvent(memberId, event.userId, title, body, event.streamId);
|
|
161
|
-
}
|
|
162
|
-
catch (error) {
|
|
163
|
-
this.logger.error("[ReminderEventHandler] Failed to send group reminder notification", {
|
|
164
|
-
streamId: event.streamId,
|
|
165
|
-
memberId,
|
|
166
|
-
error: error instanceof Error ? error.message : String(error),
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
async createNotificationEvent(recipientUserId, createdBy, title, body, sourceId) {
|
|
172
|
-
const notificationEvent = new NotificationEvents_1.NotificationCreated({
|
|
173
|
-
eventId: (0, uuid_1.v4)(),
|
|
174
|
-
userId: recipientUserId,
|
|
175
|
-
streamId: (0, uuid_1.v4)(),
|
|
176
|
-
version: 1,
|
|
177
|
-
createdAt: Date.now(),
|
|
178
|
-
createdBy,
|
|
179
|
-
systemGenerated: true,
|
|
180
|
-
title,
|
|
181
|
-
body,
|
|
182
|
-
sourceEventType: EventTypes_1.EventType.SETTLE_UP_REMINDER_TRIGGERED,
|
|
183
|
-
sourceType: EventTypes_1.EventMainType.REMINDER,
|
|
184
|
-
sourceId,
|
|
185
|
-
});
|
|
186
|
-
await this.notificationEventHandler.handleBackendEvent(notificationEvent);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
exports.ReminderEventHandler = ReminderEventHandler;
|
|
190
|
-
//# sourceMappingURL=ReminderEventHandler.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ReminderEventHandler.js","sourceRoot":"","sources":["../src/ReminderEventHandler.ts"],"names":[],"mappings":";;;AACA,6DAA2D;AAY3D,oDAA+D;AAG/D,yDAAsD;AAGtD,qDAAkD;AAClD,+BAAoC;AACpC,2CAA8C;AAE9C,MAAa,oBAAqB,SAAQ,mCAA+B;IACvE,YACU,UAA8B,EAC9B,kBAAsC,EACtC,qBAA4C,EAC5C,0BAAsD,EACtD,gBAAkC,EAClC,cAA8B,EAC9B,eAAgC,EAChC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,MAAM,EACZ,KAAK,EACL,IAAI,EACJ,KAAK,CAAC,QAAQ,CACf,CAAC;YACJ,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,IAAI,CAAC,MAAM,CAAC,KAAK,CACf,mEAAmE,EACnE;oBACE,QAAQ,EAAE,KAAK,CAAC,QAAQ;oBACxB,QAAQ;oBACR,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;iBAC9D,CACF,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;IAEO,KAAK,CAAC,uBAAuB,CACnC,eAAuB,EACvB,SAAiB,EACjB,KAAa,EACb,IAAY,EACZ,QAAgB;QAEhB,MAAM,iBAAiB,GAAG,IAAI,wCAAmB,CAAC;YAChD,OAAO,EAAE,IAAA,SAAM,GAAE;YACjB,MAAM,EAAE,eAAe;YACvB,QAAQ,EAAE,IAAA,SAAM,GAAE;YAClB,OAAO,EAAE,CAAC;YACV,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;YACrB,SAAS;YACT,eAAe,EAAE,IAAI;YACrB,KAAK;YACL,IAAI;YACJ,eAAe,EAAE,sBAAS,CAAC,4BAA4B;YACvD,UAAU,EAAE,0BAAa,CAAC,QAAQ;YAClC,QAAQ;SACT,CAAC,CAAC;QACH,MAAM,IAAI,CAAC,wBAAwB,CAAC,kBAAkB,CAAC,iBAAiB,CAAC,CAAC;IAC5E,CAAC;CACF;AAvRD,oDAuRC"}
|
package/dist/ReminderEvents.d.ts
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { ReminderEvent } from "./common/DomainEvents";
|
|
2
|
-
import { Model, ModelProps } from "./common/Model";
|
|
3
|
-
export interface ReminderModelProps extends ModelProps {
|
|
4
|
-
recipientUserId: string;
|
|
5
|
-
groupId?: string;
|
|
6
|
-
createdAt: number;
|
|
7
|
-
createdBy: string;
|
|
8
|
-
}
|
|
9
|
-
export declare class ReminderModel implements ReminderModelProps {
|
|
10
|
-
userId: string;
|
|
11
|
-
streamId: string;
|
|
12
|
-
version: number;
|
|
13
|
-
deleted: boolean;
|
|
14
|
-
updatedAt: number;
|
|
15
|
-
synced: boolean;
|
|
16
|
-
recipientUserId: string;
|
|
17
|
-
groupId?: string;
|
|
18
|
-
createdAt: number;
|
|
19
|
-
createdBy: string;
|
|
20
|
-
constructor(props: ReminderModelProps);
|
|
21
|
-
}
|
|
22
|
-
export interface SettleUpReminderTriggeredProps {
|
|
23
|
-
eventId: string;
|
|
24
|
-
userId: string;
|
|
25
|
-
streamId: string;
|
|
26
|
-
version: number;
|
|
27
|
-
createdAt: number;
|
|
28
|
-
createdBy: string;
|
|
29
|
-
systemGenerated: boolean;
|
|
30
|
-
skipNotify?: boolean;
|
|
31
|
-
recipientUserId: string;
|
|
32
|
-
groupId?: string;
|
|
33
|
-
}
|
|
34
|
-
export declare class SettleUpReminderTriggered implements ReminderEvent {
|
|
35
|
-
readonly eventMainType: "reminder";
|
|
36
|
-
readonly eventType: "SettleUpReminderTriggered";
|
|
37
|
-
eventId: string;
|
|
38
|
-
userId: string;
|
|
39
|
-
streamId: string;
|
|
40
|
-
version: number;
|
|
41
|
-
createdAt: number;
|
|
42
|
-
createdBy: string;
|
|
43
|
-
systemGenerated: boolean;
|
|
44
|
-
skipNotify?: boolean;
|
|
45
|
-
recipientUserId: string;
|
|
46
|
-
groupId?: string;
|
|
47
|
-
constructor(props: SettleUpReminderTriggeredProps);
|
|
48
|
-
apply(_existing?: Model): ReminderModel;
|
|
49
|
-
}
|
|
50
|
-
//# sourceMappingURL=ReminderEvents.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ReminderEvents.d.ts","sourceRoot":"","sources":["../src/ReminderEvents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE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EAAE,OAAO,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;gBAEZ,KAAK,EAAE,8BAA8B;IAajD,KAAK,CAAC,SAAS,CAAC,EAAE,KAAK,GAAG,aAAa;CAcxC"}
|
package/dist/ReminderEvents.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SettleUpReminderTriggered = exports.ReminderModel = void 0;
|
|
4
|
-
const EventTypes_1 = require("./common/EventTypes");
|
|
5
|
-
class ReminderModel {
|
|
6
|
-
constructor(props) {
|
|
7
|
-
this.userId = props.userId;
|
|
8
|
-
this.streamId = props.streamId;
|
|
9
|
-
this.version = props.version;
|
|
10
|
-
this.deleted = props.deleted;
|
|
11
|
-
this.updatedAt = props.updatedAt;
|
|
12
|
-
this.synced = props.synced ?? false;
|
|
13
|
-
this.recipientUserId = props.recipientUserId;
|
|
14
|
-
this.groupId = props.groupId;
|
|
15
|
-
this.createdAt = props.createdAt;
|
|
16
|
-
this.createdBy = props.createdBy;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
exports.ReminderModel = ReminderModel;
|
|
20
|
-
class SettleUpReminderTriggered {
|
|
21
|
-
constructor(props) {
|
|
22
|
-
this.eventMainType = EventTypes_1.EventMainType.REMINDER;
|
|
23
|
-
this.eventType = EventTypes_1.EventType.SETTLE_UP_REMINDER_TRIGGERED;
|
|
24
|
-
this.eventId = props.eventId;
|
|
25
|
-
this.userId = props.userId;
|
|
26
|
-
this.streamId = props.streamId;
|
|
27
|
-
this.version = props.version;
|
|
28
|
-
this.createdAt = props.createdAt;
|
|
29
|
-
this.createdBy = props.createdBy;
|
|
30
|
-
this.systemGenerated = props.systemGenerated;
|
|
31
|
-
this.skipNotify = props.skipNotify;
|
|
32
|
-
this.recipientUserId = props.recipientUserId;
|
|
33
|
-
this.groupId = props.groupId;
|
|
34
|
-
}
|
|
35
|
-
apply(_existing) {
|
|
36
|
-
return new ReminderModel({
|
|
37
|
-
streamId: this.streamId,
|
|
38
|
-
userId: this.userId,
|
|
39
|
-
version: this.version,
|
|
40
|
-
deleted: false,
|
|
41
|
-
updatedAt: this.createdAt,
|
|
42
|
-
synced: this.systemGenerated,
|
|
43
|
-
recipientUserId: this.recipientUserId,
|
|
44
|
-
groupId: this.groupId,
|
|
45
|
-
createdAt: this.createdAt,
|
|
46
|
-
createdBy: this.createdBy,
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
exports.SettleUpReminderTriggered = SettleUpReminderTriggered;
|
|
51
|
-
//# sourceMappingURL=ReminderEvents.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ReminderEvents.js","sourceRoot":"","sources":["../src/ReminderEvents.ts"],"names":[],"mappings":";;;AAEA,oDAA+D;AAS/D,MAAa,aAAa;IAYxB,YAAY,KAAyB;QACnC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;QAC3B,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;QAC/B,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;QAC7B,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;QAC7B,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC;QACjC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC;QACpC,IAAI,CAAC,eAAe,GAAG,KAAK,CAAC,eAAe,CAAC;QAC7C,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;QAC7B,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC;QACjC,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC;IACnC,CAAC;CACF;AAxBD,sCAwBC;AAeD,MAAa,yBAAyB;IAcpC,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|
-
private readonly sdk;
|
|
4
|
-
constructor(sdk: EventProcessorSDK);
|
|
5
|
-
private get reminderModelStore();
|
|
6
|
-
private get friendModelStore();
|
|
7
|
-
private get groupModelStore();
|
|
8
|
-
sendSettleUpReminder(userId: string, recipientUserId: string, groupId?: string): Promise<string>;
|
|
9
|
-
}
|
|
10
|
-
//# sourceMappingURL=ReminderController.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ReminderController.d.ts","sourceRoot":"","sources":["../../../src/client/controllers/ReminderController.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAI5D,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAoB;gBAE5B,GAAG,EAAE,iBAAiB;IAIlC,OAAO,KAAK,kBAAkB,GAE7B;IAED,OAAO,KAAK,gBAAgB,GAE3B;IAED,OAAO,KAAK,eAAe,GAE1B;IAEK,oBAAoB,CACxB,MAAM,EAAE,MAAM,EACd,eAAe,EAAE,MAAM,EACvB,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,MAAM,CAAC;CAyFnB"}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ReminderController = void 0;
|
|
4
|
-
const ReminderEvents_1 = require("../../ReminderEvents");
|
|
5
|
-
const uuid_1 = require("uuid");
|
|
6
|
-
class ReminderController {
|
|
7
|
-
constructor(sdk) {
|
|
8
|
-
this.sdk = sdk;
|
|
9
|
-
}
|
|
10
|
-
get reminderModelStore() {
|
|
11
|
-
return this.sdk.getStoreConfig().reminderModelStore;
|
|
12
|
-
}
|
|
13
|
-
get friendModelStore() {
|
|
14
|
-
return this.sdk.getStoreConfig().friendModelStore;
|
|
15
|
-
}
|
|
16
|
-
get groupModelStore() {
|
|
17
|
-
return this.sdk.getStoreConfig().groupModelStore;
|
|
18
|
-
}
|
|
19
|
-
async sendSettleUpReminder(userId, recipientUserId, groupId) {
|
|
20
|
-
console.log("[debug] ReminderController.sendSettleUpReminder START", {
|
|
21
|
-
userId,
|
|
22
|
-
recipientUserId,
|
|
23
|
-
groupId,
|
|
24
|
-
});
|
|
25
|
-
if (this.reminderModelStore) {
|
|
26
|
-
console.log("[debug] checking dedup");
|
|
27
|
-
const todayStart = new Date();
|
|
28
|
-
todayStart.setHours(0, 0, 0, 0);
|
|
29
|
-
const todayStartMs = todayStart.getTime();
|
|
30
|
-
if (groupId) {
|
|
31
|
-
const existing = await this.reminderModelStore.findByUserIdAndGroupIdAndCreatedAtAfter(userId, groupId, todayStartMs);
|
|
32
|
-
if (existing) {
|
|
33
|
-
throw new Error("You have already sent a settle up reminder for this group today.");
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
const existing = await this.reminderModelStore.findByUserIdAndRecipientUserIdAndCreatedAtAfter(userId, recipientUserId, todayStartMs);
|
|
38
|
-
if (existing) {
|
|
39
|
-
throw new Error("You have already sent a settle up reminder to this person today.");
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
console.log("[debug] dedup check passed");
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
console.log("[debug] no reminderModelStore, skipping dedup");
|
|
46
|
-
}
|
|
47
|
-
if (groupId) {
|
|
48
|
-
console.log("[debug] validating group");
|
|
49
|
-
const groupModel = await this.groupModelStore.findByUserIdAndGroupIdAndDeletedIsFalse(userId, groupId);
|
|
50
|
-
if (!groupModel) {
|
|
51
|
-
throw new Error("Group not found.");
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
if (!groupId) {
|
|
55
|
-
console.log("[debug] validating friend");
|
|
56
|
-
const friendModel = await this.friendModelStore.findByUserIdAndFriendIdAndDeletedIsFalse(userId, recipientUserId);
|
|
57
|
-
if (!friendModel) {
|
|
58
|
-
throw new Error("Recipient is not in your friends list.");
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
const streamId = (0, uuid_1.v4)();
|
|
62
|
-
const event = new ReminderEvents_1.SettleUpReminderTriggered({
|
|
63
|
-
eventId: (0, uuid_1.v4)(),
|
|
64
|
-
userId,
|
|
65
|
-
streamId,
|
|
66
|
-
version: 1,
|
|
67
|
-
createdAt: Date.now(),
|
|
68
|
-
createdBy: userId,
|
|
69
|
-
systemGenerated: false,
|
|
70
|
-
recipientUserId,
|
|
71
|
-
groupId,
|
|
72
|
-
});
|
|
73
|
-
console.log("[debug] calling handleEvent", {
|
|
74
|
-
streamId,
|
|
75
|
-
eventId: event.eventId,
|
|
76
|
-
});
|
|
77
|
-
await this.sdk.getReminderEventHandler().handleEvent(event);
|
|
78
|
-
console.log("[debug] handleEvent completed");
|
|
79
|
-
return streamId;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
exports.ReminderController = ReminderController;
|
|
83
|
-
//# sourceMappingURL=ReminderController.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ReminderController.js","sourceRoot":"","sources":["../../../src/client/controllers/ReminderController.ts"],"names":[],"mappings":";;;AACA,yDAAiE;AACjE,+BAAoC;AAEpC,MAAa,kBAAkB;IAG7B,YAAY,GAAsB;QAChC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;IAED,IAAY,kBAAkB;QAC5B,OAAO,IAAI,CAAC,GAAG,CAAC,cAAc,EAAE,CAAC,kBAAkB,CAAC;IACtD,CAAC;IAED,IAAY,gBAAgB;QAC1B,OAAO,IAAI,CAAC,GAAG,CAAC,cAAc,EAAE,CAAC,gBAAgB,CAAC;IACpD,CAAC;IAED,IAAY,eAAe;QACzB,OAAO,IAAI,CAAC,GAAG,CAAC,cAAc,EAAE,CAAC,eAAe,CAAC;IACnD,CAAC;IAED,KAAK,CAAC,oBAAoB,CACxB,MAAc,EACd,eAAuB,EACvB,OAAgB;QAEhB,OAAO,CAAC,GAAG,CAAC,uDAAu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|
|
1
|
-
{"version":3,"file":"ReminderEventStore.js","sourceRoot":"","sources":["../../src/store/ReminderEventStore.ts"],"names":[],"mappings":""}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { ReminderModel } from "../ReminderEvents";
|
|
2
|
-
import { ModelStore } from "./ModelStore";
|
|
3
|
-
export declare const REMINDER_MODEL_PATH = "models/reminders/reminderModels";
|
|
4
|
-
export interface ReminderModelStore extends ModelStore {
|
|
5
|
-
getByStreamId(streamId: string): Promise<ReminderModel | undefined>;
|
|
6
|
-
getByStreamIdWhereDeletedIsFalse(streamId: string): Promise<ReminderModel | undefined>;
|
|
7
|
-
save(model: ReminderModel): Promise<void>;
|
|
8
|
-
findByUserIdAndRecipientUserIdAndCreatedAtAfter(userId: string, recipientUserId: string, after: number): Promise<ReminderModel | undefined>;
|
|
9
|
-
findByUserIdAndGroupIdAndCreatedAtAfter(userId: string, groupId: string, after: number): Promise<ReminderModel | undefined>;
|
|
10
|
-
}
|
|
11
|
-
//# sourceMappingURL=ReminderModelStore.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ReminderModelStore.d.ts","sourceRoot":"","sources":["../../src/store/ReminderModelStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,eAAO,MAAM,mBAAmB,oCAAoC,CAAC;AAErE,MAAM,WAAW,kBAAmB,SAAQ,UAAU;IACpD,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,CAAC;IAEpE,gCAAgC,CAC9B,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,CAAC;IAEtC,IAAI,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE1C,+CAA+C,CAC7C,MAAM,EAAE,MAAM,EACd,eAAe,EAAE,MAAM,EACvB,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,CAAC;IAEtC,uCAAuC,CACrC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,CAAC;CACvC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ReminderModelStore.js","sourceRoot":"","sources":["../../src/store/ReminderModelStore.ts"],"names":[],"mappings":";;;AAGa,QAAA,mBAAmB,GAAG,iCAAiC,CAAC"}
|