@zeeshan60/event-processor 1.0.1 → 1.0.3

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.
@@ -0,0 +1,43 @@
1
+ import { Event } from './common/Event';
2
+ import { Model } from './common/Model';
3
+ export declare enum SourceType {
4
+ Transaction = "Transaction",
5
+ User = "User",
6
+ Friend = "Friend",
7
+ Group = "Group",
8
+ GroupTransaction = "GroupTransaction"
9
+ }
10
+ export interface ActivityLogModel extends Model {
11
+ activityByUid: string;
12
+ sourceStreamId: string;
13
+ sourceType: SourceType;
14
+ logMessage: string;
15
+ date: Date;
16
+ }
17
+ export interface ActivityLogCreatedProps {
18
+ userId: string;
19
+ activityByUid: string;
20
+ sourceStreamId: string;
21
+ sourceType: SourceType;
22
+ logMessage: string;
23
+ date: Date;
24
+ createdAt: Date;
25
+ createdBy: string;
26
+ streamId: string;
27
+ version: number;
28
+ }
29
+ export declare class ActivityLogCreated implements Event {
30
+ userId: string;
31
+ activityByUid: string;
32
+ sourceStreamId: string;
33
+ sourceType: SourceType;
34
+ logMessage: string;
35
+ date: Date;
36
+ createdAt: Date;
37
+ createdBy: string;
38
+ streamId: string;
39
+ version: number;
40
+ constructor(props: ActivityLogCreatedProps);
41
+ apply(_existing?: Model): ActivityLogModel;
42
+ }
43
+ //# sourceMappingURL=ActivityLogEvents.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ActivityLogEvents.d.ts","sourceRoot":"","sources":["../src/ActivityLogEvents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAEvC,oBAAY,UAAU;IACpB,WAAW,gBAAgB;IAC3B,IAAI,SAAS;IACb,MAAM,WAAW;IACjB,KAAK,UAAU;IACf,gBAAgB,qBAAqB;CACtC;AAED,MAAM,WAAW,gBAAiB,SAAQ,KAAK;IAC7C,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,UAAU,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,IAAI,CAAC;CACZ;AAED,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,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;CACjB;AAED,qBAAa,kBAAmB,YAAW,KAAK;IACvC,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,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;gBAEX,KAAK,EAAE,uBAAuB;IAa1C,KAAK,CAAC,SAAS,CAAC,EAAE,KAAK,GAAG,gBAAgB;CAa3C"}
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ActivityLogCreated = exports.SourceType = void 0;
4
+ var SourceType;
5
+ (function (SourceType) {
6
+ SourceType["Transaction"] = "Transaction";
7
+ SourceType["User"] = "User";
8
+ SourceType["Friend"] = "Friend";
9
+ SourceType["Group"] = "Group";
10
+ SourceType["GroupTransaction"] = "GroupTransaction";
11
+ })(SourceType || (exports.SourceType = SourceType = {}));
12
+ class ActivityLogCreated {
13
+ constructor(props) {
14
+ this.userId = props.userId;
15
+ this.activityByUid = props.activityByUid;
16
+ this.sourceStreamId = props.sourceStreamId;
17
+ this.sourceType = props.sourceType;
18
+ this.logMessage = props.logMessage;
19
+ this.date = props.date;
20
+ this.createdAt = props.createdAt;
21
+ this.createdBy = props.createdBy;
22
+ this.streamId = props.streamId;
23
+ this.version = props.version;
24
+ }
25
+ apply(_existing) {
26
+ return {
27
+ streamId: this.streamId,
28
+ userId: this.userId,
29
+ activityByUid: this.activityByUid,
30
+ sourceStreamId: this.sourceStreamId,
31
+ sourceType: this.sourceType,
32
+ logMessage: this.logMessage,
33
+ date: this.date,
34
+ deleted: false,
35
+ version: this.version,
36
+ };
37
+ }
38
+ }
39
+ exports.ActivityLogCreated = ActivityLogCreated;
@@ -0,0 +1,122 @@
1
+ import { Event } from './common/Event';
2
+ import { Model } from './common/Model';
3
+ import { ActivityLogCreatedProps } from './ActivityLogEvents';
4
+ export declare enum FriendEventType {
5
+ FRIEND_CREATED = "FRIEND_CREATED",
6
+ FRIEND_UPDATED = "FRIEND_UPDATED",
7
+ FRIEND_DELETED = "FRIEND_DELETED",
8
+ FRIEND_ID_ADDED = "FRIEND_ID_ADDED",
9
+ FRIEND_ID_REMOVED = "FRIEND_ID_REMOVED"
10
+ }
11
+ export interface FriendModel extends Model {
12
+ friendId?: string;
13
+ friendEmail?: string;
14
+ friendPhoneNumber?: string;
15
+ groupId?: string;
16
+ friendDisplayName: string;
17
+ createdAt: Date;
18
+ updatedAt: Date;
19
+ }
20
+ export interface FriendCreatedProps {
21
+ userId: string;
22
+ friendEmail?: string;
23
+ friendPhoneNumber?: string;
24
+ friendDisplayName: string;
25
+ friendId?: string;
26
+ groupId?: string;
27
+ createdAt: Date;
28
+ createdBy: string;
29
+ streamId: string;
30
+ version: number;
31
+ }
32
+ export declare class FriendCreated implements Event {
33
+ userId: string;
34
+ friendEmail?: string;
35
+ friendPhoneNumber?: string;
36
+ friendDisplayName: string;
37
+ friendId?: string;
38
+ groupId?: string;
39
+ createdAt: Date;
40
+ createdBy: string;
41
+ streamId: string;
42
+ version: number;
43
+ constructor(props: FriendCreatedProps);
44
+ apply(_existing?: Model): FriendModel;
45
+ activityLog(_existing?: Model, actorName?: string): ActivityLogCreatedProps | undefined;
46
+ }
47
+ export interface FriendUpdatedProps {
48
+ userId?: string;
49
+ friendEmail?: string;
50
+ friendPhoneNumber?: string;
51
+ friendDisplayName?: string;
52
+ createdAt: Date;
53
+ createdBy: string;
54
+ streamId: string;
55
+ version: number;
56
+ }
57
+ export declare class FriendUpdated implements Event {
58
+ userId?: string;
59
+ friendEmail?: string;
60
+ friendPhoneNumber?: string;
61
+ friendDisplayName?: string;
62
+ createdAt: Date;
63
+ createdBy: string;
64
+ streamId: string;
65
+ version: number;
66
+ constructor(props: FriendUpdatedProps);
67
+ apply(existing?: Model): FriendModel;
68
+ activityLog(existing?: Model, actorName?: string): ActivityLogCreatedProps | undefined;
69
+ }
70
+ export interface FriendDeletedProps {
71
+ userId?: string;
72
+ createdAt: Date;
73
+ createdBy: string;
74
+ streamId: string;
75
+ version: number;
76
+ }
77
+ export declare class FriendDeleted implements Event {
78
+ userId?: string;
79
+ createdAt: Date;
80
+ createdBy: string;
81
+ streamId: string;
82
+ version: number;
83
+ constructor(props: FriendDeletedProps);
84
+ apply(existing?: Model): FriendModel;
85
+ activityLog(existing?: Model, actorName?: string): ActivityLogCreatedProps | undefined;
86
+ }
87
+ export interface FriendIdAddedProps {
88
+ userId?: string;
89
+ friendId: string;
90
+ createdAt: Date;
91
+ createdBy: string;
92
+ streamId: string;
93
+ version: number;
94
+ }
95
+ export declare class FriendIdAdded implements Event {
96
+ userId?: string;
97
+ friendId: string;
98
+ createdAt: Date;
99
+ createdBy: string;
100
+ streamId: string;
101
+ version: number;
102
+ constructor(props: FriendIdAddedProps);
103
+ apply(existing?: Model): FriendModel;
104
+ activityLog(existing?: Model, _actorName?: string): ActivityLogCreatedProps | undefined;
105
+ }
106
+ export interface FriendIdRemovedProps {
107
+ userId?: string;
108
+ createdAt: Date;
109
+ createdBy: string;
110
+ streamId: string;
111
+ version: number;
112
+ }
113
+ export declare class FriendIdRemoved implements Event {
114
+ userId?: string;
115
+ createdAt: Date;
116
+ createdBy: string;
117
+ streamId: string;
118
+ version: number;
119
+ constructor(props: FriendIdRemovedProps);
120
+ apply(existing?: Model): FriendModel;
121
+ }
122
+ //# sourceMappingURL=FriendEvents.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FriendEvents.d.ts","sourceRoot":"","sources":["../src/FriendEvents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,uBAAuB,EAAc,MAAM,qBAAqB,CAAC;AAG1E,oBAAY,eAAe;IACzB,cAAc,mBAAmB;IACjC,cAAc,mBAAmB;IACjC,cAAc,mBAAmB;IACjC,eAAe,oBAAoB;IACnC,iBAAiB,sBAAsB;CACxC;AAED,MAAM,WAAW,WAAY,SAAQ,KAAK;IACxC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;CACjB;AAED,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,E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AQ,CAAC,EAAE,KAAK,GAAG,WAAW;IAapC,WAAW,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,uBAAuB,GAAG,SAAS;CAqBxF;AAED,MAAM,WAAW,oBAAoB;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,qBAAa,eAAgB,YAAW,KAAK;IACpC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;gBAEX,KAAK,EAAE,oBAAoB;IAQvC,KAAK,CAAC,QAAQ,CAAC,EAAE,KAAK,GAAG,WAAW;CAYrC"}
@@ -0,0 +1,213 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FriendIdRemoved = exports.FriendIdAdded = exports.FriendDeleted = exports.FriendUpdated = exports.FriendCreated = exports.FriendEventType = void 0;
4
+ const ActivityLogEvents_1 = require("./ActivityLogEvents");
5
+ const uuid_1 = require("uuid");
6
+ var FriendEventType;
7
+ (function (FriendEventType) {
8
+ FriendEventType["FRIEND_CREATED"] = "FRIEND_CREATED";
9
+ FriendEventType["FRIEND_UPDATED"] = "FRIEND_UPDATED";
10
+ FriendEventType["FRIEND_DELETED"] = "FRIEND_DELETED";
11
+ FriendEventType["FRIEND_ID_ADDED"] = "FRIEND_ID_ADDED";
12
+ FriendEventType["FRIEND_ID_REMOVED"] = "FRIEND_ID_REMOVED";
13
+ })(FriendEventType || (exports.FriendEventType = FriendEventType = {}));
14
+ class FriendCreated {
15
+ constructor(props) {
16
+ this.userId = props.userId;
17
+ this.friendEmail = props.friendEmail;
18
+ this.friendPhoneNumber = props.friendPhoneNumber;
19
+ this.friendDisplayName = props.friendDisplayName;
20
+ this.friendId = props.friendId;
21
+ this.groupId = props.groupId;
22
+ this.createdAt = props.createdAt;
23
+ this.createdBy = props.createdBy;
24
+ this.streamId = props.streamId;
25
+ this.version = props.version;
26
+ }
27
+ apply(_existing) {
28
+ return {
29
+ streamId: this.streamId,
30
+ userId: this.userId,
31
+ friendId: this.friendId,
32
+ friendEmail: this.friendEmail,
33
+ friendPhoneNumber: this.friendPhoneNumber,
34
+ groupId: this.groupId,
35
+ friendDisplayName: this.friendDisplayName,
36
+ createdAt: this.createdAt,
37
+ updatedAt: this.createdAt,
38
+ version: this.version,
39
+ deleted: false,
40
+ };
41
+ }
42
+ activityLog(_existing, actorName) {
43
+ const actor = actorName ?? 'You';
44
+ const logMessage = `${actor} added friend "${this.friendDisplayName}"`;
45
+ return {
46
+ userId: this.userId,
47
+ activityByUid: this.createdBy,
48
+ sourceStreamId: this.streamId,
49
+ sourceType: ActivityLogEvents_1.SourceType.Friend,
50
+ logMessage,
51
+ date: this.createdAt,
52
+ createdAt: this.createdAt,
53
+ createdBy: this.createdBy,
54
+ streamId: (0, uuid_1.v4)(),
55
+ version: 1,
56
+ };
57
+ }
58
+ }
59
+ exports.FriendCreated = FriendCreated;
60
+ class FriendUpdated {
61
+ constructor(props) {
62
+ this.userId = props.userId;
63
+ this.friendEmail = props.friendEmail;
64
+ this.friendPhoneNumber = props.friendPhoneNumber;
65
+ this.friendDisplayName = props.friendDisplayName;
66
+ this.createdAt = props.createdAt;
67
+ this.createdBy = props.createdBy;
68
+ this.streamId = props.streamId;
69
+ this.version = props.version;
70
+ }
71
+ apply(existing) {
72
+ if (!existing) {
73
+ throw new Error('Friend must exist to update');
74
+ }
75
+ const existingFriend = existing;
76
+ return {
77
+ ...existingFriend,
78
+ friendEmail: this.friendEmail ?? existingFriend.friendEmail,
79
+ friendPhoneNumber: this.friendPhoneNumber ?? existingFriend.friendPhoneNumber,
80
+ friendDisplayName: this.friendDisplayName ?? existingFriend.friendDisplayName,
81
+ updatedAt: this.createdAt,
82
+ version: this.version,
83
+ };
84
+ }
85
+ activityLog(existing, actorName) {
86
+ if (!existing) {
87
+ return undefined;
88
+ }
89
+ const existingFriend = existing;
90
+ const actor = actorName ?? 'You';
91
+ const friendName = this.friendDisplayName ?? existingFriend.friendDisplayName;
92
+ const logMessage = `${actor} updated friend "${friendName}"`;
93
+ return {
94
+ userId: existingFriend.userId,
95
+ activityByUid: this.createdBy,
96
+ sourceStreamId: this.streamId,
97
+ sourceType: ActivityLogEvents_1.SourceType.Friend,
98
+ logMessage,
99
+ date: this.createdAt,
100
+ createdAt: this.createdAt,
101
+ createdBy: this.createdBy,
102
+ streamId: (0, uuid_1.v4)(),
103
+ version: 1,
104
+ };
105
+ }
106
+ }
107
+ exports.FriendUpdated = FriendUpdated;
108
+ class FriendDeleted {
109
+ constructor(props) {
110
+ this.userId = props.userId;
111
+ this.createdAt = props.createdAt;
112
+ this.createdBy = props.createdBy;
113
+ this.streamId = props.streamId;
114
+ this.version = props.version;
115
+ }
116
+ apply(existing) {
117
+ if (!existing) {
118
+ throw new Error('Friend must exist to delete');
119
+ }
120
+ const existingFriend = existing;
121
+ return {
122
+ ...existingFriend,
123
+ updatedAt: this.createdAt,
124
+ version: this.version,
125
+ deleted: true,
126
+ };
127
+ }
128
+ activityLog(existing, actorName) {
129
+ if (!existing) {
130
+ return undefined;
131
+ }
132
+ const existingFriend = existing;
133
+ const actor = actorName ?? 'You';
134
+ const logMessage = `${actor} removed friend "${existingFriend.friendDisplayName}"`;
135
+ return {
136
+ userId: existingFriend.userId,
137
+ activityByUid: this.createdBy,
138
+ sourceStreamId: this.streamId,
139
+ sourceType: ActivityLogEvents_1.SourceType.Friend,
140
+ logMessage,
141
+ date: this.createdAt,
142
+ createdAt: this.createdAt,
143
+ createdBy: this.createdBy,
144
+ streamId: (0, uuid_1.v4)(),
145
+ version: 1,
146
+ };
147
+ }
148
+ }
149
+ exports.FriendDeleted = FriendDeleted;
150
+ class FriendIdAdded {
151
+ constructor(props) {
152
+ this.userId = props.userId;
153
+ this.friendId = props.friendId;
154
+ this.createdAt = props.createdAt;
155
+ this.createdBy = props.createdBy;
156
+ this.streamId = props.streamId;
157
+ this.version = props.version;
158
+ }
159
+ apply(existing) {
160
+ if (!existing) {
161
+ throw new Error('Friend must exist to add friend ID');
162
+ }
163
+ const existingFriend = existing;
164
+ return {
165
+ ...existingFriend,
166
+ friendId: this.friendId,
167
+ updatedAt: this.createdAt,
168
+ version: this.version,
169
+ };
170
+ }
171
+ activityLog(existing, _actorName) {
172
+ if (!existing) {
173
+ return undefined;
174
+ }
175
+ const existingFriend = existing;
176
+ const logMessage = `Friend "${existingFriend.friendDisplayName}" was linked to their account`;
177
+ return {
178
+ userId: existingFriend.userId,
179
+ activityByUid: this.createdBy,
180
+ sourceStreamId: this.streamId,
181
+ sourceType: ActivityLogEvents_1.SourceType.Friend,
182
+ logMessage,
183
+ date: this.createdAt,
184
+ createdAt: this.createdAt,
185
+ createdBy: this.createdBy,
186
+ streamId: (0, uuid_1.v4)(),
187
+ version: 1,
188
+ };
189
+ }
190
+ }
191
+ exports.FriendIdAdded = FriendIdAdded;
192
+ class FriendIdRemoved {
193
+ constructor(props) {
194
+ this.userId = props.userId;
195
+ this.createdAt = props.createdAt;
196
+ this.createdBy = props.createdBy;
197
+ this.streamId = props.streamId;
198
+ this.version = props.version;
199
+ }
200
+ apply(existing) {
201
+ if (!existing) {
202
+ throw new Error('Friend must exist to remove friend ID');
203
+ }
204
+ const existingFriend = existing;
205
+ return {
206
+ ...existingFriend,
207
+ friendId: undefined,
208
+ updatedAt: this.createdAt,
209
+ version: this.version,
210
+ };
211
+ }
212
+ }
213
+ exports.FriendIdRemoved = FriendIdRemoved;
@@ -0,0 +1,140 @@
1
+ import { Event } from './common/Event';
2
+ import { Model } from './common/Model';
3
+ import { ActivityLogCreatedProps } from './ActivityLogEvents';
4
+ export declare enum GroupEventType {
5
+ GROUP_CREATED = "GROUP_CREATED",
6
+ GROUP_NAME_CHANGED = "GROUP_NAME_CHANGED",
7
+ GROUP_DESCRIPTION_CHANGED = "GROUP_DESCRIPTION_CHANGED",
8
+ GROUP_MEMBERS_ADDED = "GROUP_MEMBERS_ADDED",
9
+ GROUP_MEMBERS_REMOVED = "GROUP_MEMBERS_REMOVED",
10
+ GROUP_DELETED = "GROUP_DELETED"
11
+ }
12
+ export interface GroupModel extends Model {
13
+ groupId: string;
14
+ name: string;
15
+ description?: string;
16
+ members?: string[];
17
+ createdAt: Date;
18
+ updatedAt: Date;
19
+ createdBy: string;
20
+ updatedBy: string;
21
+ }
22
+ export interface GroupCreatedProps {
23
+ userId: string;
24
+ groupId: string;
25
+ name: string;
26
+ description?: string;
27
+ members?: string[];
28
+ createdAt: Date;
29
+ createdBy: string;
30
+ streamId: string;
31
+ version: number;
32
+ }
33
+ export declare class GroupCreated implements Event {
34
+ userId: string;
35
+ groupId: string;
36
+ name: string;
37
+ description?: string;
38
+ members?: string[];
39
+ createdAt: Date;
40
+ createdBy: string;
41
+ streamId: string;
42
+ version: number;
43
+ constructor(props: GroupCreatedProps);
44
+ apply(_existing?: Model): GroupModel;
45
+ activityLog(_existing?: Model, actorName?: string): ActivityLogCreatedProps | undefined;
46
+ }
47
+ export interface GroupNameChangedProps {
48
+ userId?: string;
49
+ name: string;
50
+ createdAt: Date;
51
+ createdBy: string;
52
+ streamId: string;
53
+ version: number;
54
+ }
55
+ export declare class GroupNameChanged implements Event {
56
+ userId?: string;
57
+ name: string;
58
+ createdAt: Date;
59
+ createdBy: string;
60
+ streamId: string;
61
+ version: number;
62
+ constructor(props: GroupNameChangedProps);
63
+ apply(existing?: Model): GroupModel;
64
+ activityLog(existing?: Model, actorName?: string): ActivityLogCreatedProps | undefined;
65
+ }
66
+ export interface GroupDescriptionChangedProps {
67
+ userId?: string;
68
+ description?: string;
69
+ createdAt: Date;
70
+ createdBy: string;
71
+ streamId: string;
72
+ version: number;
73
+ }
74
+ export declare class GroupDescriptionChanged implements Event {
75
+ userId?: string;
76
+ description?: string;
77
+ createdAt: Date;
78
+ createdBy: string;
79
+ streamId: string;
80
+ version: number;
81
+ constructor(props: GroupDescriptionChangedProps);
82
+ apply(existing?: Model): GroupModel;
83
+ activityLog(existing?: Model, actorName?: string): ActivityLogCreatedProps | undefined;
84
+ }
85
+ export interface GroupMembersAddedProps {
86
+ userId?: string;
87
+ members: string[];
88
+ createdAt: Date;
89
+ createdBy: string;
90
+ streamId: string;
91
+ version: number;
92
+ }
93
+ export declare class GroupMembersAdded implements Event {
94
+ userId?: string;
95
+ members: string[];
96
+ createdAt: Date;
97
+ createdBy: string;
98
+ streamId: string;
99
+ version: number;
100
+ constructor(props: GroupMembersAddedProps);
101
+ apply(existing?: Model): GroupModel;
102
+ activityLog(existing?: Model, actorName?: string): ActivityLogCreatedProps | undefined;
103
+ }
104
+ export interface GroupMembersRemovedProps {
105
+ userId?: string;
106
+ members: string[];
107
+ createdAt: Date;
108
+ createdBy: string;
109
+ streamId: string;
110
+ version: number;
111
+ }
112
+ export declare class GroupMembersRemoved implements Event {
113
+ userId?: string;
114
+ members: string[];
115
+ createdAt: Date;
116
+ createdBy: string;
117
+ streamId: string;
118
+ version: number;
119
+ constructor(props: GroupMembersRemovedProps);
120
+ apply(existing?: Model): GroupModel;
121
+ activityLog(existing?: Model, actorName?: string): ActivityLogCreatedProps | undefined;
122
+ }
123
+ export interface GroupDeletedProps {
124
+ userId?: string;
125
+ createdAt: Date;
126
+ createdBy: string;
127
+ streamId: string;
128
+ version: number;
129
+ }
130
+ export declare class GroupDeleted implements Event {
131
+ userId?: string;
132
+ createdAt: Date;
133
+ createdBy: string;
134
+ streamId: string;
135
+ version: number;
136
+ constructor(props: GroupDeletedProps);
137
+ apply(existing?: Model): GroupModel;
138
+ activityLog(existing?: Model, actorName?: string): ActivityLogCreatedProps | undefined;
139
+ }
140
+ //# sourceMappingURL=GroupEvents.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3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