@zeeshan60/event-processor 1.0.4 → 1.0.5

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.
Files changed (34) hide show
  1. package/dist/ActivityEventHandler.d.ts +12 -0
  2. package/dist/ActivityEventHandler.d.ts.map +1 -0
  3. package/dist/ActivityEventHandler.js +35 -0
  4. package/dist/FriendEventHandler.d.ts +21 -0
  5. package/dist/FriendEventHandler.d.ts.map +1 -0
  6. package/dist/FriendEventHandler.js +175 -0
  7. package/dist/GroupEventHandler.d.ts +25 -0
  8. package/dist/GroupEventHandler.d.ts.map +1 -0
  9. package/dist/GroupEventHandler.js +270 -0
  10. package/dist/GroupTransactionEventHandler.d.ts +25 -0
  11. package/dist/GroupTransactionEventHandler.d.ts.map +1 -0
  12. package/dist/GroupTransactionEventHandler.js +296 -0
  13. package/dist/TransactionEventHandler.d.ts +11 -7
  14. package/dist/TransactionEventHandler.d.ts.map +1 -1
  15. package/dist/TransactionEventHandler.js +139 -10
  16. package/dist/UserEventHandler.d.ts +17 -0
  17. package/dist/UserEventHandler.d.ts.map +1 -0
  18. package/dist/UserEventHandler.js +82 -0
  19. package/dist/events.d.ts +30 -0
  20. package/dist/events.d.ts.map +1 -0
  21. package/dist/events.js +60 -0
  22. package/dist/index.d.ts +1 -21
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/index.js +16 -86
  25. package/dist/utils/eventConverter.d.ts +23 -0
  26. package/dist/utils/eventConverter.d.ts.map +1 -0
  27. package/dist/utils/eventConverter.js +370 -0
  28. package/dist/utils/splitTypeUtils.d.ts +7 -0
  29. package/dist/utils/splitTypeUtils.d.ts.map +1 -0
  30. package/dist/utils/splitTypeUtils.js +45 -0
  31. package/dist/utils/userPathUtils.d.ts +6 -0
  32. package/dist/utils/userPathUtils.d.ts.map +1 -0
  33. package/dist/utils/userPathUtils.js +16 -0
  34. package/package.json +1 -1
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.reverseSplitType = reverseSplitType;
4
+ exports.calculateMirrorAmountAndIsOwed = calculateMirrorAmountAndIsOwed;
5
+ const __1 = require("..");
6
+ function reverseSplitType(splitType) {
7
+ switch (splitType) {
8
+ case __1.SplitType.YouPaidSplitEqually:
9
+ return __1.SplitType.TheyPaidSplitEqually;
10
+ case __1.SplitType.TheyPaidSplitEqually:
11
+ return __1.SplitType.YouPaidSplitEqually;
12
+ case __1.SplitType.TheyOweYouAll:
13
+ return __1.SplitType.YouOweThemAll;
14
+ case __1.SplitType.YouOweThemAll:
15
+ return __1.SplitType.TheyOweYouAll;
16
+ case __1.SplitType.TheyPaidToSettle:
17
+ return __1.SplitType.YouPaidToSettle;
18
+ case __1.SplitType.YouPaidToSettle:
19
+ return __1.SplitType.TheyPaidToSettle;
20
+ case __1.SplitType.SpecificAmounts:
21
+ return __1.SplitType.SpecificAmounts;
22
+ default:
23
+ throw new Error(`Unknown split type: ${splitType}`);
24
+ }
25
+ }
26
+ function calculateMirrorAmountAndIsOwed(totalAmount, amount, splitType, isOwed) {
27
+ switch (splitType) {
28
+ case __1.SplitType.YouPaidSplitEqually:
29
+ return { amount: totalAmount / 2, isOwed: false };
30
+ case __1.SplitType.TheyPaidSplitEqually:
31
+ return { amount: totalAmount / 2, isOwed: true };
32
+ case __1.SplitType.TheyOweYouAll:
33
+ return { amount: totalAmount, isOwed: false };
34
+ case __1.SplitType.YouOweThemAll:
35
+ return { amount: totalAmount, isOwed: true };
36
+ case __1.SplitType.TheyPaidToSettle:
37
+ return { amount: totalAmount, isOwed: true };
38
+ case __1.SplitType.YouPaidToSettle:
39
+ return { amount: totalAmount, isOwed: false };
40
+ case __1.SplitType.SpecificAmounts:
41
+ return { amount: amount, isOwed: !isOwed };
42
+ default:
43
+ throw new Error(`Unknown split type: ${splitType}`);
44
+ }
45
+ }
@@ -0,0 +1,6 @@
1
+ import { UserModel } from '..';
2
+ export declare function getUserEventPath(userModel: UserModel | undefined, recipientStreamId: string): {
3
+ path: string;
4
+ userId: string;
5
+ };
6
+ //# sourceMappingURL=userPathUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"userPathUtils.d.ts","sourceRoot":"","sources":["../../src/utils/userPathUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAE/B,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,SAAS,GAAG,SAAS,EAChC,iBAAiB,EAAE,MAAM,GACxB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAUlC"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getUserEventPath = getUserEventPath;
4
+ function getUserEventPath(userModel, recipientStreamId) {
5
+ if (userModel) {
6
+ if (userModel.uid) {
7
+ return { path: 'users', userId: userModel.uid };
8
+ }
9
+ else {
10
+ return { path: 'placeholders', userId: userModel.streamId };
11
+ }
12
+ }
13
+ else {
14
+ return { path: 'placeholders', userId: recipientStreamId };
15
+ }
16
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeeshan60/event-processor",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "Shared event sourcing infrastructure for Loan Tracker projects",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",