@zeeshan60/event-processor 1.0.0 → 1.0.1

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.
@@ -1,10 +1,13 @@
1
1
  import { Event } from './common/Event';
2
2
  import { Model } from './common/Model';
3
3
  export declare enum SplitType {
4
- EQUAL = "EQUAL",
5
- EXACT = "EXACT",
6
- PERCENTAGE = "PERCENTAGE",
7
- SHARES = "SHARES"
4
+ YouPaidSplitEqually = "YouPaidSplitEqually",
5
+ TheyPaidSplitEqually = "TheyPaidSplitEqually",
6
+ TheyOweYouAll = "TheyOweYouAll",
7
+ YouOweThemAll = "YouOweThemAll",
8
+ TheyPaidToSettle = "TheyPaidToSettle",
9
+ YouPaidToSettle = "YouPaidToSettle",
10
+ SpecificAmounts = "SpecificAmounts"
8
11
  }
9
12
  export declare enum TransactionEventType {
10
13
  TRANSACTION_CREATED = "TRANSACTION_CREATED",
@@ -12,8 +15,9 @@ export declare enum TransactionEventType {
12
15
  TRANSACTION_DELETED = "TRANSACTION_DELETED"
13
16
  }
14
17
  export interface AmountDto {
15
- value: number;
18
+ amount: number;
16
19
  currency: string;
20
+ isOwed: boolean;
17
21
  }
18
22
  export interface ChangeHistoryBase {
19
23
  type: string;
@@ -59,16 +63,33 @@ export interface TransactionModel extends Model {
59
63
  currency: string;
60
64
  splitType: SplitType;
61
65
  totalAmount: number;
62
- amount: AmountDto | null;
66
+ amount: number;
63
67
  transactionDate: Date;
64
68
  createdAt: Date;
65
- updatedAt: Date | null;
69
+ updatedAt: Date;
66
70
  createdBy: string;
67
- updatedBy: string | null;
71
+ updatedBy: string;
68
72
  groupId: string | null;
69
73
  groupTransactionId: string | null;
70
74
  history: ChangeHistory;
71
75
  }
76
+ export interface TransactionCreatedProps {
77
+ userId: string;
78
+ recipientUserId: string;
79
+ logicalTransactionId: string;
80
+ description: string;
81
+ currency: string;
82
+ splitType: SplitType;
83
+ totalAmount: number;
84
+ amount: number;
85
+ transactionDate: Date;
86
+ groupId: string | null;
87
+ groupTransactionId: string | null;
88
+ createdAt: Date;
89
+ createdBy: string;
90
+ streamId: string;
91
+ version: number;
92
+ }
72
93
  export declare class TransactionCreated implements Event {
73
94
  userId: string;
74
95
  recipientUserId: string;
@@ -77,7 +98,7 @@ export declare class TransactionCreated implements Event {
77
98
  currency: string;
78
99
  splitType: SplitType;
79
100
  totalAmount: number;
80
- amount: AmountDto | null;
101
+ amount: number;
81
102
  transactionDate: Date;
82
103
  groupId: string | null;
83
104
  groupTransactionId: string | null;
@@ -85,7 +106,97 @@ export declare class TransactionCreated implements Event {
85
106
  createdBy: string;
86
107
  streamId: string;
87
108
  version: number;
88
- constructor(userId: string, recipientUserId: string, logicalTransactionId: string, description: string, currency: string, splitType: SplitType, totalAmount: number, amount: AmountDto | null, transactionDate: Date, groupId: string | null, groupTransactionId: string | null, createdAt: Date, createdBy: string, streamId: string, version: number);
109
+ constructor(props: TransactionCreatedProps);
89
110
  apply(_existing: Model | null): TransactionModel;
90
111
  }
112
+ export interface ChangeSummary {
113
+ date: Date;
114
+ changedBy: string;
115
+ oldValue: string;
116
+ newValue: string;
117
+ type: TransactionChangeType;
118
+ }
119
+ export declare enum TransactionChangeType {
120
+ TRANSACTION_DATE = "TRANSACTION_DATE",
121
+ DESCRIPTION = "DESCRIPTION",
122
+ TOTAL_AMOUNT = "TOTAL_AMOUNT",
123
+ CURRENCY = "CURRENCY",
124
+ SPLIT_TYPE = "SPLIT_TYPE",
125
+ DELETED = "DELETED"
126
+ }
127
+ export declare enum ActivityType {
128
+ CREATED = "CREATED",
129
+ UPDATED = "UPDATED",
130
+ DELETED = "DELETED"
131
+ }
132
+ export interface ActivityLog {
133
+ id: string;
134
+ userId: string;
135
+ activityByUid: string;
136
+ description: string;
137
+ activityType: ActivityType;
138
+ amount: number;
139
+ currency: string;
140
+ isOwed: boolean;
141
+ date: Date;
142
+ transactionModel: TransactionModel;
143
+ }
144
+ export interface TransactionDeletedProps {
145
+ userId: string;
146
+ recipientUserId: string;
147
+ streamId: string;
148
+ version: number;
149
+ createdAt: Date;
150
+ createdBy: string;
151
+ }
152
+ export declare class TransactionDeleted implements Event {
153
+ userId: string;
154
+ recipientUserId: string;
155
+ streamId: string;
156
+ version: number;
157
+ createdAt: Date;
158
+ createdBy: string;
159
+ constructor(props: TransactionDeletedProps);
160
+ apply(existing: Model | null): TransactionModel;
161
+ }
162
+ export interface DescriptionChangedProps {
163
+ userId: string;
164
+ recipientUserId: string;
165
+ description: string;
166
+ streamId: string;
167
+ version: number;
168
+ createdAt: Date;
169
+ createdBy: string;
170
+ }
171
+ export declare class DescriptionChanged implements Event {
172
+ userId: string;
173
+ recipientUserId: string;
174
+ description: string;
175
+ streamId: string;
176
+ version: number;
177
+ createdAt: Date;
178
+ createdBy: string;
179
+ constructor(props: DescriptionChangedProps);
180
+ apply(existing: Model | null): TransactionModel;
181
+ }
182
+ export interface TotalAmountChangedProps {
183
+ userId: string;
184
+ recipientUserId: string;
185
+ totalAmount: number;
186
+ streamId: string;
187
+ version: number;
188
+ createdAt: Date;
189
+ createdBy: string;
190
+ }
191
+ export declare class TotalAmountChanged implements Event {
192
+ userId: string;
193
+ recipientUserId: string;
194
+ totalAmount: number;
195
+ streamId: string;
196
+ version: number;
197
+ createdAt: Date;
198
+ createdBy: string;
199
+ constructor(props: TotalAmountChangedProps);
200
+ apply(existing: Model | null): TransactionModel;
201
+ }
91
202
  //# sourceMappingURL=TransactionEvents.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"TransactionEvents.d.ts","sourceRoot":"","sources":["../src/TransactionEvents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAGvC,oBAAY,SAAS;IACjB,KAAK,UAAU;IACf,KAAK,UAAU;IACf,UAAU,eAAe;IACzB,MAAM,WAAW;CACpB;AAED,oBAAY,oBAAoB;IAC5B,mBAAmB,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AM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,qBAAa,kBAAmB,YAAW,KAAK;IACvC,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;gBAEb,KAAK,EAAE,uBAAuB;IAU1C,KAAK,CAAC,QAAQ,EAAE,KAAK,GAAG,IAAI,GAAG,gBAAgB;CAahD;AAGD,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,qBAAa,kBAAmB,YAAW,KAAK;IACvC,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;gBAEb,KAAK,EAAE,uBAAuB;IAU1C,KAAK,CAAC,QAAQ,EAAE,KAAK,GAAG,IAAI,GAAG,gBAAgB;CAahD"}
@@ -1,13 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TransactionCreated = exports.ChangeHistory = exports.TransactionEventType = exports.SplitType = void 0;
3
+ exports.TotalAmountChanged = exports.DescriptionChanged = exports.TransactionDeleted = exports.ActivityType = exports.TransactionChangeType = exports.TransactionCreated = exports.ChangeHistory = exports.TransactionEventType = exports.SplitType = void 0;
4
4
  // Enums
5
5
  var SplitType;
6
6
  (function (SplitType) {
7
- SplitType["EQUAL"] = "EQUAL";
8
- SplitType["EXACT"] = "EXACT";
9
- SplitType["PERCENTAGE"] = "PERCENTAGE";
10
- SplitType["SHARES"] = "SHARES";
7
+ SplitType["YouPaidSplitEqually"] = "YouPaidSplitEqually";
8
+ SplitType["TheyPaidSplitEqually"] = "TheyPaidSplitEqually";
9
+ SplitType["TheyOweYouAll"] = "TheyOweYouAll";
10
+ SplitType["YouOweThemAll"] = "YouOweThemAll";
11
+ SplitType["TheyPaidToSettle"] = "TheyPaidToSettle";
12
+ SplitType["YouPaidToSettle"] = "YouPaidToSettle";
13
+ SplitType["SpecificAmounts"] = "SpecificAmounts";
11
14
  })(SplitType || (exports.SplitType = SplitType = {}));
12
15
  var TransactionEventType;
13
16
  (function (TransactionEventType) {
@@ -24,22 +27,22 @@ var ChangeHistory;
24
27
  })(ChangeHistory || (exports.ChangeHistory = ChangeHistory = {}));
25
28
  // Transaction Created Event
26
29
  class TransactionCreated {
27
- constructor(userId, recipientUserId, logicalTransactionId, description, currency, splitType, totalAmount, amount, transactionDate, groupId, groupTransactionId, createdAt, createdBy, streamId, version) {
28
- this.userId = userId;
29
- this.recipientUserId = recipientUserId;
30
- this.logicalTransactionId = logicalTransactionId;
31
- this.description = description;
32
- this.currency = currency;
33
- this.splitType = splitType;
34
- this.totalAmount = totalAmount;
35
- this.amount = amount;
36
- this.transactionDate = transactionDate;
37
- this.groupId = groupId;
38
- this.groupTransactionId = groupTransactionId;
39
- this.createdAt = createdAt;
40
- this.createdBy = createdBy;
41
- this.streamId = streamId;
42
- this.version = version;
30
+ constructor(props) {
31
+ this.userId = props.userId;
32
+ this.recipientUserId = props.recipientUserId;
33
+ this.logicalTransactionId = props.logicalTransactionId;
34
+ this.description = props.description;
35
+ this.currency = props.currency;
36
+ this.splitType = props.splitType;
37
+ this.totalAmount = props.totalAmount;
38
+ this.amount = props.amount;
39
+ this.transactionDate = props.transactionDate;
40
+ this.groupId = props.groupId;
41
+ this.groupTransactionId = props.groupTransactionId;
42
+ this.createdAt = props.createdAt;
43
+ this.createdBy = props.createdBy;
44
+ this.streamId = props.streamId;
45
+ this.version = props.version;
43
46
  }
44
47
  apply(_existing) {
45
48
  return {
@@ -55,15 +58,104 @@ class TransactionCreated {
55
58
  amount: this.amount,
56
59
  transactionDate: this.transactionDate,
57
60
  createdAt: this.createdAt,
58
- updatedAt: null,
61
+ updatedAt: this.createdAt,
59
62
  createdBy: this.createdBy,
60
- updatedBy: null,
61
- deleted: false,
62
- version: this.version,
63
+ updatedBy: this.createdBy,
63
64
  groupId: this.groupId,
64
65
  groupTransactionId: this.groupTransactionId,
66
+ deleted: false,
67
+ version: this.version,
65
68
  history: ChangeHistory.empty(),
66
69
  };
67
70
  }
68
71
  }
69
72
  exports.TransactionCreated = TransactionCreated;
73
+ var TransactionChangeType;
74
+ (function (TransactionChangeType) {
75
+ TransactionChangeType["TRANSACTION_DATE"] = "TRANSACTION_DATE";
76
+ TransactionChangeType["DESCRIPTION"] = "DESCRIPTION";
77
+ TransactionChangeType["TOTAL_AMOUNT"] = "TOTAL_AMOUNT";
78
+ TransactionChangeType["CURRENCY"] = "CURRENCY";
79
+ TransactionChangeType["SPLIT_TYPE"] = "SPLIT_TYPE";
80
+ TransactionChangeType["DELETED"] = "DELETED";
81
+ })(TransactionChangeType || (exports.TransactionChangeType = TransactionChangeType = {}));
82
+ var ActivityType;
83
+ (function (ActivityType) {
84
+ ActivityType["CREATED"] = "CREATED";
85
+ ActivityType["UPDATED"] = "UPDATED";
86
+ ActivityType["DELETED"] = "DELETED";
87
+ })(ActivityType || (exports.ActivityType = ActivityType = {}));
88
+ class TransactionDeleted {
89
+ constructor(props) {
90
+ this.userId = props.userId;
91
+ this.recipientUserId = props.recipientUserId;
92
+ this.streamId = props.streamId;
93
+ this.version = props.version;
94
+ this.createdAt = props.createdAt;
95
+ this.createdBy = props.createdBy;
96
+ }
97
+ apply(existing) {
98
+ if (!existing) {
99
+ throw new Error('TransactionModel cannot be null for deletion');
100
+ }
101
+ const existingTx = existing;
102
+ return {
103
+ ...existingTx,
104
+ version: this.version,
105
+ deleted: true,
106
+ updatedBy: this.createdBy,
107
+ updatedAt: this.createdAt,
108
+ };
109
+ }
110
+ }
111
+ exports.TransactionDeleted = TransactionDeleted;
112
+ class DescriptionChanged {
113
+ constructor(props) {
114
+ this.userId = props.userId;
115
+ this.recipientUserId = props.recipientUserId;
116
+ this.description = props.description;
117
+ this.streamId = props.streamId;
118
+ this.version = props.version;
119
+ this.createdAt = props.createdAt;
120
+ this.createdBy = props.createdBy;
121
+ }
122
+ apply(existing) {
123
+ if (!existing) {
124
+ throw new Error('TransactionModel cannot be null');
125
+ }
126
+ const existingTx = existing;
127
+ return {
128
+ ...existingTx,
129
+ description: this.description,
130
+ version: this.version,
131
+ updatedBy: this.createdBy,
132
+ updatedAt: this.createdAt,
133
+ };
134
+ }
135
+ }
136
+ exports.DescriptionChanged = DescriptionChanged;
137
+ class TotalAmountChanged {
138
+ constructor(props) {
139
+ this.userId = props.userId;
140
+ this.recipientUserId = props.recipientUserId;
141
+ this.totalAmount = props.totalAmount;
142
+ this.streamId = props.streamId;
143
+ this.version = props.version;
144
+ this.createdAt = props.createdAt;
145
+ this.createdBy = props.createdBy;
146
+ }
147
+ apply(existing) {
148
+ if (!existing) {
149
+ throw new Error('TransactionModel cannot be null');
150
+ }
151
+ const existingTx = existing;
152
+ return {
153
+ ...existingTx,
154
+ totalAmount: this.totalAmount,
155
+ version: this.version,
156
+ updatedBy: this.createdBy,
157
+ updatedAt: this.createdAt,
158
+ };
159
+ }
160
+ }
161
+ exports.TotalAmountChanged = TotalAmountChanged;
@@ -0,0 +1,191 @@
1
+ import { Event } from './common/Event';
2
+ import { Model } from './common/Model';
3
+ export declare enum UserEventType {
4
+ USER_CREATED = "USER_CREATED",
5
+ PLACEHOLDER_USER_CREATED = "PLACEHOLDER_USER_CREATED",
6
+ USER_DELETED = "USER_DELETED",
7
+ CURRENCY_CHANGED = "CURRENCY_CHANGED",
8
+ PHONE_NUMBER_CHANGED = "PHONE_NUMBER_CHANGED",
9
+ DISPLAY_NAME_CHANGED = "DISPLAY_NAME_CHANGED",
10
+ PLACEHOLDER_USER_MERGED = "PLACEHOLDER_USER_MERGED",
11
+ USER_CONVERTED_TO_PLACEHOLDER = "USER_CONVERTED_TO_PLACEHOLDER"
12
+ }
13
+ export interface UserModel extends Model {
14
+ uid: string | null;
15
+ displayName: string;
16
+ phoneNumber: string | null;
17
+ currency: string | null;
18
+ email: string | null;
19
+ photoUrl: string | null;
20
+ emailVerified: boolean;
21
+ isPlaceholder: boolean;
22
+ createdAt: Date;
23
+ updatedAt: Date;
24
+ createdBy: string;
25
+ updatedBy: string;
26
+ }
27
+ export interface UserCreatedProps {
28
+ userId: string;
29
+ firebaseUid: string;
30
+ displayName: string;
31
+ phoneNumber: string | null;
32
+ email: string | null;
33
+ photoUrl: string | null;
34
+ emailVerified: boolean;
35
+ createdAt: Date;
36
+ createdBy: string;
37
+ streamId: string;
38
+ version: number;
39
+ }
40
+ export declare class UserCreated implements Event {
41
+ userId: string;
42
+ firebaseUid: string;
43
+ displayName: string;
44
+ phoneNumber: string | null;
45
+ email: string | null;
46
+ photoUrl: string | null;
47
+ emailVerified: boolean;
48
+ createdAt: Date;
49
+ createdBy: string;
50
+ streamId: string;
51
+ version: number;
52
+ constructor(props: UserCreatedProps);
53
+ apply(_existing: Model | null): UserModel;
54
+ }
55
+ export interface PlaceholderUserCreatedProps {
56
+ userId: string;
57
+ displayName: string;
58
+ phoneNumber: string | null;
59
+ email: string | null;
60
+ createdAt: Date;
61
+ createdBy: string;
62
+ streamId: string;
63
+ version: number;
64
+ }
65
+ export declare class PlaceholderUserCreated implements Event {
66
+ userId: string;
67
+ displayName: string;
68
+ phoneNumber: string | null;
69
+ email: string | null;
70
+ createdAt: Date;
71
+ createdBy: string;
72
+ streamId: string;
73
+ version: number;
74
+ constructor(props: PlaceholderUserCreatedProps);
75
+ apply(_existing: Model | null): UserModel;
76
+ }
77
+ export interface UserCurrencyChangedProps {
78
+ userId: string;
79
+ currency: string | null;
80
+ createdAt: Date;
81
+ createdBy: string;
82
+ streamId: string;
83
+ version: number;
84
+ }
85
+ export declare class UserCurrencyChanged implements Event {
86
+ userId: string;
87
+ currency: string | null;
88
+ createdAt: Date;
89
+ createdBy: string;
90
+ streamId: string;
91
+ version: number;
92
+ constructor(props: UserCurrencyChangedProps);
93
+ apply(existing: Model | null): UserModel;
94
+ }
95
+ export interface UserPhoneNumberChangedProps {
96
+ userId: string;
97
+ phoneNumber: string | null;
98
+ createdAt: Date;
99
+ createdBy: string;
100
+ streamId: string;
101
+ version: number;
102
+ }
103
+ export declare class UserPhoneNumberChanged implements Event {
104
+ userId: string;
105
+ phoneNumber: string | null;
106
+ createdAt: Date;
107
+ createdBy: string;
108
+ streamId: string;
109
+ version: number;
110
+ constructor(props: UserPhoneNumberChangedProps);
111
+ apply(existing: Model | null): UserModel;
112
+ }
113
+ export interface UserDisplayNameChangedProps {
114
+ userId: string;
115
+ displayName: string;
116
+ createdAt: Date;
117
+ createdBy: string;
118
+ streamId: string;
119
+ version: number;
120
+ }
121
+ export declare class UserDisplayNameChanged implements Event {
122
+ userId: string;
123
+ displayName: string;
124
+ createdAt: Date;
125
+ createdBy: string;
126
+ streamId: string;
127
+ version: number;
128
+ constructor(props: UserDisplayNameChangedProps);
129
+ apply(existing: Model | null): UserModel;
130
+ }
131
+ export interface UserDeletedProps {
132
+ userId: string;
133
+ createdAt: Date;
134
+ createdBy: string;
135
+ streamId: string;
136
+ version: number;
137
+ }
138
+ export declare class UserDeleted implements Event {
139
+ userId: string;
140
+ createdAt: Date;
141
+ createdBy: string;
142
+ streamId: string;
143
+ version: number;
144
+ constructor(props: UserDeletedProps);
145
+ apply(existing: Model | null): UserModel;
146
+ }
147
+ export interface PlaceholderUserMergedProps {
148
+ userId: string;
149
+ firebaseUid: string;
150
+ displayName: string;
151
+ email: string | null;
152
+ phoneNumber: string | null;
153
+ photoUrl: string | null;
154
+ emailVerified: boolean;
155
+ createdAt: Date;
156
+ createdBy: string;
157
+ streamId: string;
158
+ version: number;
159
+ }
160
+ export declare class PlaceholderUserMerged implements Event {
161
+ userId: string;
162
+ firebaseUid: string;
163
+ displayName: string;
164
+ email: string | null;
165
+ phoneNumber: string | null;
166
+ photoUrl: string | null;
167
+ emailVerified: boolean;
168
+ createdAt: Date;
169
+ createdBy: string;
170
+ streamId: string;
171
+ version: number;
172
+ constructor(props: PlaceholderUserMergedProps);
173
+ apply(existing: Model | null): UserModel;
174
+ }
175
+ export interface UserConvertedToPlaceholderProps {
176
+ userId: string;
177
+ createdAt: Date;
178
+ createdBy: string;
179
+ streamId: string;
180
+ version: number;
181
+ }
182
+ export declare class UserConvertedToPlaceholder implements Event {
183
+ userId: string;
184
+ createdAt: Date;
185
+ createdBy: string;
186
+ streamId: string;
187
+ version: number;
188
+ constructor(props: UserConvertedToPlaceholderProps);
189
+ apply(existing: Model | null): UserModel;
190
+ }
191
+ //# sourceMappingURL=UserEvents.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UserEvents.d.ts","sourceRoot":"","sources":["../src/UserEvents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAGvC,oBAAY,aAAa;IACvB,YAAY,iBAAiB;IAC7B,wBAAwB,6BAA6B;IACrD,YAAY,iBAAiB;IAC7B,gBAAgB,qBAAqB;IACrC,oBAAoB,yBAAyB;IAC7C,oBAAoB,yBAAyB;IAC7C,uBAAuB,4BAA4B;IACnD,6BAA6B,kCAAkC;CAChE;AAGD,MAAM,WAAW,SAAU,SAAQ,KAAK;IACtC,GAAG,EAAE,MAAM,GAAG,IAA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C,QAAQ,EAAE,KAAK,GAAG,IAAI,GAAG,SAAS;CAsBzC;AAGD,MAAM,WAAW,+BAA+B;IAC9C,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,qBAAa,0BAA2B,YAAW,KAAK;IAC/C,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;gBAEX,KAAK,EAAE,+BAA+B;IAQlD,KAAK,CAAC,QAAQ,EAAE,KAAK,GAAG,IAAI,GAAG,SAAS;CAmBzC"}
@@ -0,0 +1,248 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UserConvertedToPlaceholder = exports.PlaceholderUserMerged = exports.UserDeleted = exports.UserDisplayNameChanged = exports.UserPhoneNumberChanged = exports.UserCurrencyChanged = exports.PlaceholderUserCreated = exports.UserCreated = exports.UserEventType = void 0;
4
+ // User Event Types
5
+ var UserEventType;
6
+ (function (UserEventType) {
7
+ UserEventType["USER_CREATED"] = "USER_CREATED";
8
+ UserEventType["PLACEHOLDER_USER_CREATED"] = "PLACEHOLDER_USER_CREATED";
9
+ UserEventType["USER_DELETED"] = "USER_DELETED";
10
+ UserEventType["CURRENCY_CHANGED"] = "CURRENCY_CHANGED";
11
+ UserEventType["PHONE_NUMBER_CHANGED"] = "PHONE_NUMBER_CHANGED";
12
+ UserEventType["DISPLAY_NAME_CHANGED"] = "DISPLAY_NAME_CHANGED";
13
+ UserEventType["PLACEHOLDER_USER_MERGED"] = "PLACEHOLDER_USER_MERGED";
14
+ UserEventType["USER_CONVERTED_TO_PLACEHOLDER"] = "USER_CONVERTED_TO_PLACEHOLDER";
15
+ })(UserEventType || (exports.UserEventType = UserEventType = {}));
16
+ class UserCreated {
17
+ constructor(props) {
18
+ this.userId = props.userId;
19
+ this.firebaseUid = props.firebaseUid;
20
+ this.displayName = props.displayName;
21
+ this.phoneNumber = props.phoneNumber;
22
+ this.email = props.email;
23
+ this.photoUrl = props.photoUrl;
24
+ this.emailVerified = props.emailVerified;
25
+ this.createdAt = props.createdAt;
26
+ this.createdBy = props.createdBy;
27
+ this.streamId = props.streamId;
28
+ this.version = props.version;
29
+ }
30
+ apply(_existing) {
31
+ return {
32
+ id: null,
33
+ streamId: this.streamId,
34
+ userId: this.userId,
35
+ uid: this.firebaseUid,
36
+ displayName: this.displayName,
37
+ phoneNumber: this.phoneNumber,
38
+ email: this.email,
39
+ photoUrl: this.photoUrl,
40
+ currency: null,
41
+ emailVerified: this.emailVerified,
42
+ isPlaceholder: false,
43
+ createdAt: this.createdAt,
44
+ updatedAt: this.createdAt,
45
+ createdBy: this.createdBy,
46
+ updatedBy: this.createdBy,
47
+ version: this.version,
48
+ deleted: false,
49
+ };
50
+ }
51
+ }
52
+ exports.UserCreated = UserCreated;
53
+ class PlaceholderUserCreated {
54
+ constructor(props) {
55
+ this.userId = props.userId;
56
+ this.displayName = props.displayName;
57
+ this.phoneNumber = props.phoneNumber;
58
+ this.email = props.email;
59
+ this.createdAt = props.createdAt;
60
+ this.createdBy = props.createdBy;
61
+ this.streamId = props.streamId;
62
+ this.version = props.version;
63
+ }
64
+ apply(_existing) {
65
+ return {
66
+ id: null,
67
+ streamId: this.streamId,
68
+ userId: this.userId,
69
+ uid: null,
70
+ displayName: this.displayName,
71
+ phoneNumber: this.phoneNumber,
72
+ email: this.email,
73
+ photoUrl: null,
74
+ currency: null,
75
+ emailVerified: false,
76
+ isPlaceholder: true,
77
+ createdAt: this.createdAt,
78
+ updatedAt: this.createdAt,
79
+ createdBy: this.createdBy,
80
+ updatedBy: this.createdBy,
81
+ version: this.version,
82
+ deleted: false,
83
+ };
84
+ }
85
+ }
86
+ exports.PlaceholderUserCreated = PlaceholderUserCreated;
87
+ class UserCurrencyChanged {
88
+ constructor(props) {
89
+ this.userId = props.userId;
90
+ this.currency = props.currency;
91
+ this.createdAt = props.createdAt;
92
+ this.createdBy = props.createdBy;
93
+ this.streamId = props.streamId;
94
+ this.version = props.version;
95
+ }
96
+ apply(existing) {
97
+ if (!existing) {
98
+ throw new Error('User must exist to change currency');
99
+ }
100
+ const existingUser = existing;
101
+ return {
102
+ ...existingUser,
103
+ currency: this.currency,
104
+ updatedAt: this.createdAt,
105
+ updatedBy: this.createdBy,
106
+ version: this.version,
107
+ };
108
+ }
109
+ }
110
+ exports.UserCurrencyChanged = UserCurrencyChanged;
111
+ class UserPhoneNumberChanged {
112
+ constructor(props) {
113
+ this.userId = props.userId;
114
+ this.phoneNumber = props.phoneNumber;
115
+ this.createdAt = props.createdAt;
116
+ this.createdBy = props.createdBy;
117
+ this.streamId = props.streamId;
118
+ this.version = props.version;
119
+ }
120
+ apply(existing) {
121
+ if (!existing) {
122
+ throw new Error('User must exist to change phone number');
123
+ }
124
+ const existingUser = existing;
125
+ return {
126
+ ...existingUser,
127
+ phoneNumber: this.phoneNumber,
128
+ updatedAt: this.createdAt,
129
+ updatedBy: this.createdBy,
130
+ version: this.version,
131
+ };
132
+ }
133
+ }
134
+ exports.UserPhoneNumberChanged = UserPhoneNumberChanged;
135
+ class UserDisplayNameChanged {
136
+ constructor(props) {
137
+ this.userId = props.userId;
138
+ this.displayName = props.displayName;
139
+ this.createdAt = props.createdAt;
140
+ this.createdBy = props.createdBy;
141
+ this.streamId = props.streamId;
142
+ this.version = props.version;
143
+ }
144
+ apply(existing) {
145
+ if (!existing) {
146
+ throw new Error('User must exist to change display name');
147
+ }
148
+ const existingUser = existing;
149
+ return {
150
+ ...existingUser,
151
+ displayName: this.displayName,
152
+ updatedAt: this.createdAt,
153
+ updatedBy: this.createdBy,
154
+ version: this.version,
155
+ };
156
+ }
157
+ }
158
+ exports.UserDisplayNameChanged = UserDisplayNameChanged;
159
+ class UserDeleted {
160
+ constructor(props) {
161
+ this.userId = props.userId;
162
+ this.createdAt = props.createdAt;
163
+ this.createdBy = props.createdBy;
164
+ this.streamId = props.streamId;
165
+ this.version = props.version;
166
+ }
167
+ apply(existing) {
168
+ if (!existing) {
169
+ throw new Error('User must exist to delete');
170
+ }
171
+ const existingUser = existing;
172
+ return {
173
+ ...existingUser,
174
+ updatedAt: this.createdAt,
175
+ updatedBy: this.createdBy,
176
+ version: this.version,
177
+ deleted: true,
178
+ };
179
+ }
180
+ }
181
+ exports.UserDeleted = UserDeleted;
182
+ class PlaceholderUserMerged {
183
+ constructor(props) {
184
+ this.userId = props.userId;
185
+ this.firebaseUid = props.firebaseUid;
186
+ this.displayName = props.displayName;
187
+ this.email = props.email;
188
+ this.phoneNumber = props.phoneNumber;
189
+ this.photoUrl = props.photoUrl;
190
+ this.emailVerified = props.emailVerified;
191
+ this.createdAt = props.createdAt;
192
+ this.createdBy = props.createdBy;
193
+ this.streamId = props.streamId;
194
+ this.version = props.version;
195
+ }
196
+ apply(existing) {
197
+ if (!existing) {
198
+ throw new Error('Placeholder user must exist to merge');
199
+ }
200
+ const existingUser = existing;
201
+ if (!existingUser.isPlaceholder) {
202
+ throw new Error('Can only merge placeholder users');
203
+ }
204
+ return {
205
+ ...existingUser,
206
+ uid: this.firebaseUid,
207
+ displayName: this.displayName,
208
+ email: this.email,
209
+ phoneNumber: this.phoneNumber,
210
+ photoUrl: this.photoUrl,
211
+ emailVerified: this.emailVerified,
212
+ isPlaceholder: false,
213
+ updatedAt: this.createdAt,
214
+ updatedBy: this.createdBy,
215
+ version: this.version,
216
+ };
217
+ }
218
+ }
219
+ exports.PlaceholderUserMerged = PlaceholderUserMerged;
220
+ class UserConvertedToPlaceholder {
221
+ constructor(props) {
222
+ this.userId = props.userId;
223
+ this.createdAt = props.createdAt;
224
+ this.createdBy = props.createdBy;
225
+ this.streamId = props.streamId;
226
+ this.version = props.version;
227
+ }
228
+ apply(existing) {
229
+ if (!existing) {
230
+ throw new Error('User must exist to convert to placeholder');
231
+ }
232
+ const existingUser = existing;
233
+ if (existingUser.isPlaceholder) {
234
+ throw new Error('User is already a placeholder');
235
+ }
236
+ return {
237
+ ...existingUser,
238
+ uid: null,
239
+ isPlaceholder: true,
240
+ photoUrl: null,
241
+ emailVerified: false,
242
+ updatedAt: this.createdAt,
243
+ updatedBy: this.createdBy,
244
+ version: this.version,
245
+ };
246
+ }
247
+ }
248
+ exports.UserConvertedToPlaceholder = UserConvertedToPlaceholder;
@@ -3,6 +3,8 @@ export interface Event {
3
3
  userId: string;
4
4
  streamId: string;
5
5
  version: number;
6
+ createdAt: Date;
7
+ createdBy: string;
6
8
  apply(existing: Model | null): Model;
7
9
  }
8
10
  //# sourceMappingURL=Event.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Event.d.ts","sourceRoot":"","sources":["../../src/common/Event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,MAAM,WAAW,KAAK;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,QAAQ,EAAE,KAAK,GAAG,IAAI,GAAG,KAAK,CAAC;CACtC"}
1
+ {"version":3,"file":"Event.d.ts","sourceRoot":"","sources":["../../src/common/Event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,MAAM,WAAW,KAAK;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,QAAQ,EAAE,KAAK,GAAG,IAAI,GAAG,KAAK,CAAC;CACtC"}
@@ -1,5 +1,3 @@
1
1
  export { Event } from './Event';
2
2
  export { Model } from './Model';
3
- export { EventStore } from './EventStore';
4
- export { ModelStore } from './ModelStore';
5
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC"}
@@ -1,7 +1,2 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ModelStore = exports.EventStore = void 0;
4
- var EventStore_1 = require("./EventStore");
5
- Object.defineProperty(exports, "EventStore", { enumerable: true, get: function () { return EventStore_1.EventStore; } });
6
- var ModelStore_1 = require("./ModelStore");
7
- Object.defineProperty(exports, "ModelStore", { enumerable: true, get: function () { return ModelStore_1.ModelStore; } });
package/dist/index.d.ts CHANGED
@@ -1,9 +1,5 @@
1
1
  export { Event } from './common/Event';
2
2
  export { Model } from './common/Model';
3
- export { EventStore } from './common/EventStore';
4
- export { ModelStore } from './common/ModelStore';
5
- export { InMemoryEventStore } from './store/InMemoryEventStore';
6
- export { InMemoryModelStore } from './store/InMemoryModelStore';
7
- export { TransactionEventHandler } from './TransactionEventHandler';
8
- export { TransactionCreated, TransactionModel, SplitType, TransactionEventType, AmountDto, ChangeHistory, ChangeHistoryItem, DescriptionUpdated, AmountUpdated, CurrencyUpdated, SplitTypeUpdated, TransactionDateUpdated, } from './TransactionEvents';
3
+ export { TransactionCreated, TransactionCreatedProps, TransactionDeleted, TransactionDeletedProps, DescriptionChanged, DescriptionChangedProps, TotalAmountChanged, TotalAmountChangedProps, TransactionModel, SplitType, TransactionEventType, TransactionChangeType, ActivityType, ActivityLog, ChangeSummary, AmountDto, ChangeHistory, ChangeHistoryItem, DescriptionUpdated, AmountUpdated, CurrencyUpdated, SplitTypeUpdated, TransactionDateUpdated, } from './TransactionEvents';
4
+ export { UserCreated, UserCreatedProps, PlaceholderUserCreated, PlaceholderUserCreatedProps, UserCurrencyChanged, UserCurrencyChangedProps, UserPhoneNumberChanged, UserPhoneNumberChangedProps, UserDisplayNameChanged, UserDisplayNameChangedProps, UserDeleted, UserDeletedProps, PlaceholderUserMerged, PlaceholderUserMergedProps, UserConvertedToPlaceholder, UserConvertedToPlaceholderProps, UserModel, UserEventType, } from './UserEvents';
9
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAGvC,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAGjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAGhE,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,SAAS,EACT,oBAAoB,EACpB,SAAS,EACT,aAAa,EACb,iBAAiB,EACjB,kBAAkB,EAClB,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,sBAAsB,GACvB,MAAM,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAGvC,OAAO,EACL,kBAAkB,EAClB,uBAAuB,EACvB,kBAAkB,EAClB,uBAAuB,EACvB,kBAAkB,EAClB,uBAAuB,EACvB,kBAAkB,EAClB,uBAAuB,EACvB,gBAAgB,EAChB,SAAS,EACT,oBAAoB,EACpB,qBAAqB,EACrB,YAAY,EACZ,WAAW,EACX,aAAa,EACb,SAAS,EACT,aAAa,EACb,iBAAiB,EACjB,kBAAkB,EAClB,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,sBAAsB,GACvB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EACL,WAAW,EACX,gBAAgB,EAChB,sBAAsB,EACtB,2BAA2B,EAC3B,mBAAmB,EACnB,wBAAwB,EACxB,sBAAsB,EACtB,2BAA2B,EAC3B,sBAAsB,EACtB,2BAA2B,EAC3B,WAAW,EACX,gBAAgB,EAChB,qBAAqB,EACrB,0BAA0B,EAC1B,0BAA0B,EAC1B,+BAA+B,EAC/B,SAAS,EACT,aAAa,GACd,MAAM,cAAc,CAAC"}
package/dist/index.js CHANGED
@@ -1,21 +1,25 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ChangeHistory = exports.TransactionEventType = exports.SplitType = exports.TransactionCreated = exports.TransactionEventHandler = exports.InMemoryModelStore = exports.InMemoryEventStore = exports.ModelStore = exports.EventStore = void 0;
4
- // Abstract stores
5
- var EventStore_1 = require("./common/EventStore");
6
- Object.defineProperty(exports, "EventStore", { enumerable: true, get: function () { return EventStore_1.EventStore; } });
7
- var ModelStore_1 = require("./common/ModelStore");
8
- Object.defineProperty(exports, "ModelStore", { enumerable: true, get: function () { return ModelStore_1.ModelStore; } });
9
- // In-memory implementations
10
- var InMemoryEventStore_1 = require("./store/InMemoryEventStore");
11
- Object.defineProperty(exports, "InMemoryEventStore", { enumerable: true, get: function () { return InMemoryEventStore_1.InMemoryEventStore; } });
12
- var InMemoryModelStore_1 = require("./store/InMemoryModelStore");
13
- Object.defineProperty(exports, "InMemoryModelStore", { enumerable: true, get: function () { return InMemoryModelStore_1.InMemoryModelStore; } });
14
- // Transaction event handler and types
15
- var TransactionEventHandler_1 = require("./TransactionEventHandler");
16
- Object.defineProperty(exports, "TransactionEventHandler", { enumerable: true, get: function () { return TransactionEventHandler_1.TransactionEventHandler; } });
3
+ exports.UserEventType = exports.UserConvertedToPlaceholder = exports.PlaceholderUserMerged = exports.UserDeleted = exports.UserDisplayNameChanged = exports.UserPhoneNumberChanged = exports.UserCurrencyChanged = exports.PlaceholderUserCreated = exports.UserCreated = exports.ChangeHistory = exports.ActivityType = exports.TransactionChangeType = exports.TransactionEventType = exports.SplitType = exports.TotalAmountChanged = exports.DescriptionChanged = exports.TransactionDeleted = exports.TransactionCreated = void 0;
4
+ // Transaction event types
17
5
  var TransactionEvents_1 = require("./TransactionEvents");
18
6
  Object.defineProperty(exports, "TransactionCreated", { enumerable: true, get: function () { return TransactionEvents_1.TransactionCreated; } });
7
+ Object.defineProperty(exports, "TransactionDeleted", { enumerable: true, get: function () { return TransactionEvents_1.TransactionDeleted; } });
8
+ Object.defineProperty(exports, "DescriptionChanged", { enumerable: true, get: function () { return TransactionEvents_1.DescriptionChanged; } });
9
+ Object.defineProperty(exports, "TotalAmountChanged", { enumerable: true, get: function () { return TransactionEvents_1.TotalAmountChanged; } });
19
10
  Object.defineProperty(exports, "SplitType", { enumerable: true, get: function () { return TransactionEvents_1.SplitType; } });
20
11
  Object.defineProperty(exports, "TransactionEventType", { enumerable: true, get: function () { return TransactionEvents_1.TransactionEventType; } });
12
+ Object.defineProperty(exports, "TransactionChangeType", { enumerable: true, get: function () { return TransactionEvents_1.TransactionChangeType; } });
13
+ Object.defineProperty(exports, "ActivityType", { enumerable: true, get: function () { return TransactionEvents_1.ActivityType; } });
21
14
  Object.defineProperty(exports, "ChangeHistory", { enumerable: true, get: function () { return TransactionEvents_1.ChangeHistory; } });
15
+ // User event types
16
+ var UserEvents_1 = require("./UserEvents");
17
+ Object.defineProperty(exports, "UserCreated", { enumerable: true, get: function () { return UserEvents_1.UserCreated; } });
18
+ Object.defineProperty(exports, "PlaceholderUserCreated", { enumerable: true, get: function () { return UserEvents_1.PlaceholderUserCreated; } });
19
+ Object.defineProperty(exports, "UserCurrencyChanged", { enumerable: true, get: function () { return UserEvents_1.UserCurrencyChanged; } });
20
+ Object.defineProperty(exports, "UserPhoneNumberChanged", { enumerable: true, get: function () { return UserEvents_1.UserPhoneNumberChanged; } });
21
+ Object.defineProperty(exports, "UserDisplayNameChanged", { enumerable: true, get: function () { return UserEvents_1.UserDisplayNameChanged; } });
22
+ Object.defineProperty(exports, "UserDeleted", { enumerable: true, get: function () { return UserEvents_1.UserDeleted; } });
23
+ Object.defineProperty(exports, "PlaceholderUserMerged", { enumerable: true, get: function () { return UserEvents_1.PlaceholderUserMerged; } });
24
+ Object.defineProperty(exports, "UserConvertedToPlaceholder", { enumerable: true, get: function () { return UserEvents_1.UserConvertedToPlaceholder; } });
25
+ Object.defineProperty(exports, "UserEventType", { enumerable: true, get: function () { return UserEvents_1.UserEventType; } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeeshan60/event-processor",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Shared event sourcing infrastructure for Loan Tracker projects",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",