@messenger-box/platform-server 10.0.3-alpha.7 → 10.0.3-alpha.72

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 (149) hide show
  1. package/lib/containers/containers.js +4 -1
  2. package/lib/containers/containers.js.map +1 -1
  3. package/lib/containers/context-services-from-container.d.ts +1 -1
  4. package/lib/containers/context-services-from-container.js +1 -1
  5. package/lib/containers/context-services-from-container.js.map +1 -1
  6. package/lib/graphql/resolvers/channel-member.d.ts +3 -2
  7. package/lib/graphql/resolvers/channel-member.js +30 -5
  8. package/lib/graphql/resolvers/channel-member.js.map +1 -1
  9. package/lib/graphql/resolvers/channel.d.ts +3 -2
  10. package/lib/graphql/resolvers/channel.js +279 -53
  11. package/lib/graphql/resolvers/channel.js.map +1 -1
  12. package/lib/graphql/resolvers/extended-token-account.d.ts +3 -2
  13. package/lib/graphql/resolvers/extended-token-account.js +90 -23
  14. package/lib/graphql/resolvers/extended-token-account.js.map +1 -1
  15. package/lib/graphql/resolvers/index.d.ts +1 -1
  16. package/lib/graphql/resolvers/post-thread.d.ts +1 -1
  17. package/lib/graphql/resolvers/post-thread.js +294 -132
  18. package/lib/graphql/resolvers/post-thread.js.map +1 -1
  19. package/lib/graphql/resolvers/post.d.ts +2 -3
  20. package/lib/graphql/resolvers/post.js +696 -234
  21. package/lib/graphql/resolvers/post.js.map +1 -1
  22. package/lib/graphql/resolvers/reaction.d.ts +3 -2
  23. package/lib/graphql/resolvers/reaction.js +96 -14
  24. package/lib/graphql/resolvers/reaction.js.map +1 -1
  25. package/lib/graphql/schema/channel-member.graphql +110 -21
  26. package/lib/graphql/schema/channel-member.graphql.js +1 -1
  27. package/lib/graphql/schema/channel.graphql +337 -38
  28. package/lib/graphql/schema/channel.graphql.js +1 -1
  29. package/lib/graphql/schema/post-thread.graphql +167 -21
  30. package/lib/graphql/schema/post-thread.graphql.js +1 -1
  31. package/lib/graphql/schema/post.graphql +284 -40
  32. package/lib/graphql/schema/post.graphql.js +1 -1
  33. package/lib/graphql/schema/reaction.graphql +71 -13
  34. package/lib/graphql/schema/reaction.graphql.js +1 -1
  35. package/lib/graphql/schema/services.graphql +2 -0
  36. package/lib/graphql/schema/users.graphql +76 -13
  37. package/lib/graphql/schema/users.graphql.js +1 -1
  38. package/lib/index.js +1 -1
  39. package/lib/index.js.map +1 -1
  40. package/lib/interfaces/index.d.ts +0 -1
  41. package/lib/interfaces/services.d.ts +1 -1
  42. package/lib/migrations/dbMigrations/AddPostsConfigurationsMigration.d.ts +17 -0
  43. package/lib/migrations/dbMigrations/AddPostsConfigurationsMigration.js +44 -0
  44. package/lib/migrations/dbMigrations/AddPostsConfigurationsMigration.js.map +1 -0
  45. package/lib/migrations/dbMigrations/index.d.ts +1 -0
  46. package/lib/migrations/index.d.ts +1 -0
  47. package/lib/migrations/mail-template-migration.js +1 -1
  48. package/lib/migrations/message-notification-template-migration.d.ts +1 -1
  49. package/lib/migrations/message-notification-template-migration.js +1 -1
  50. package/lib/plugins/channel-moleculer-service.d.ts +21 -1
  51. package/lib/plugins/channel-moleculer-service.js +417 -115
  52. package/lib/plugins/channel-moleculer-service.js.map +1 -1
  53. package/lib/plugins/extended-token-account-moleculer-service.d.ts +25 -1
  54. package/lib/plugins/extended-token-account-moleculer-service.js +348 -22
  55. package/lib/plugins/extended-token-account-moleculer-service.js.map +1 -1
  56. package/lib/plugins/messenger-notification-moleculer-service.d.ts +27 -3
  57. package/lib/plugins/messenger-notification-moleculer-service.js +404 -58
  58. package/lib/plugins/messenger-notification-moleculer-service.js.map +1 -1
  59. package/lib/plugins/post-moleculer-service.d.ts +85 -21
  60. package/lib/plugins/post-moleculer-service.js +986 -256
  61. package/lib/plugins/post-moleculer-service.js.map +1 -1
  62. package/lib/plugins/post-thread-moleculer-service.d.ts +33 -1
  63. package/lib/plugins/post-thread-moleculer-service.js +326 -8
  64. package/lib/plugins/post-thread-moleculer-service.js.map +1 -1
  65. package/lib/plugins/reaction-moleculer-service.js +1 -1
  66. package/lib/plugins/reaction-moleculer-service.js.map +1 -1
  67. package/lib/preferences/settings/post-settings.d.ts +2 -0
  68. package/lib/preferences/settings/post-settings.js +47 -9
  69. package/lib/preferences/settings/post-settings.js.map +1 -1
  70. package/lib/services/channel-service.d.ts +179 -33
  71. package/lib/services/channel-service.js +821 -274
  72. package/lib/services/channel-service.js.map +1 -1
  73. package/lib/services/extended-token-account-service.d.ts +130 -14
  74. package/lib/services/extended-token-account-service.js +462 -52
  75. package/lib/services/extended-token-account-service.js.map +1 -1
  76. package/lib/services/index.d.ts +1 -0
  77. package/lib/services/messenger-notification-service.d.ts +106 -13
  78. package/lib/services/messenger-notification-service.js +824 -442
  79. package/lib/services/messenger-notification-service.js.map +1 -1
  80. package/lib/services/post-service.d.ts +182 -16
  81. package/lib/services/post-service.js +731 -115
  82. package/lib/services/post-service.js.map +1 -1
  83. package/lib/services/post-thread-service.d.ts +114 -5
  84. package/lib/services/post-thread-service.js +400 -13
  85. package/lib/services/post-thread-service.js.map +1 -1
  86. package/lib/services/proxy-services/channel-microservice.d.ts +5 -3
  87. package/lib/services/proxy-services/channel-microservice.js +19 -10
  88. package/lib/services/proxy-services/channel-microservice.js.map +1 -1
  89. package/lib/services/proxy-services/messenger-notification-microservice.d.ts +128 -8
  90. package/lib/services/proxy-services/messenger-notification-microservice.js +324 -29
  91. package/lib/services/proxy-services/messenger-notification-microservice.js.map +1 -1
  92. package/lib/services/proxy-services/post-microservice.d.ts +186 -12
  93. package/lib/services/proxy-services/post-microservice.js +543 -54
  94. package/lib/services/proxy-services/post-microservice.js.map +1 -1
  95. package/lib/services/proxy-services/post-thread-microservice.d.ts +134 -3
  96. package/lib/services/proxy-services/post-thread-microservice.js +388 -6
  97. package/lib/services/proxy-services/post-thread-microservice.js.map +1 -1
  98. package/lib/services/proxy-services/reaction-microservice.d.ts +161 -3
  99. package/lib/services/proxy-services/reaction-microservice.js +474 -2
  100. package/lib/services/proxy-services/reaction-microservice.js.map +1 -1
  101. package/lib/services/reaction-service.d.ts +124 -4
  102. package/lib/services/reaction-service.js +415 -3
  103. package/lib/services/reaction-service.js.map +1 -1
  104. package/lib/services/redis-cache-manager.d.ts +18 -0
  105. package/lib/services/redis-cache-manager.js +83 -0
  106. package/lib/services/redis-cache-manager.js.map +1 -0
  107. package/lib/store/models/account-token-store.d.ts +1 -1
  108. package/lib/store/models/account-token-store.js.map +1 -1
  109. package/lib/store/models/channel.d.ts +2 -3
  110. package/lib/store/models/channel.js +181 -72
  111. package/lib/store/models/channel.js.map +1 -1
  112. package/lib/store/models/post-thread.d.ts +3 -3
  113. package/lib/store/models/post-thread.js +96 -14
  114. package/lib/store/models/post-thread.js.map +1 -1
  115. package/lib/store/models/post.d.ts +2 -3
  116. package/lib/store/models/post.js +143 -23
  117. package/lib/store/models/post.js.map +1 -1
  118. package/lib/store/models/reaction.d.ts +2 -3
  119. package/lib/store/models/reaction.js +67 -8
  120. package/lib/store/models/reaction.js.map +1 -1
  121. package/lib/store/repositories/__tests__/__fixtures__/team-repository.d.ts +3 -3
  122. package/lib/store/repositories/channel-repository.d.ts +6 -6
  123. package/lib/store/repositories/channel-repository.js +5 -2
  124. package/lib/store/repositories/channel-repository.js.map +1 -1
  125. package/lib/store/repositories/post-repository.d.ts +6 -6
  126. package/lib/store/repositories/post-repository.js +5 -2
  127. package/lib/store/repositories/post-repository.js.map +1 -1
  128. package/lib/store/repositories/post-thread-repository.d.ts +6 -6
  129. package/lib/store/repositories/post-thread-repository.js +5 -2
  130. package/lib/store/repositories/post-thread-repository.js.map +1 -1
  131. package/lib/store/repositories/reaction-repository.d.ts +6 -6
  132. package/lib/store/repositories/reaction-repository.js +5 -2
  133. package/lib/store/repositories/reaction-repository.js.map +1 -1
  134. package/lib/templates/constants/SERVER_TYPES.ts.template +0 -3
  135. package/lib/templates/repositories/ChannelRepository.ts.template +3 -3
  136. package/lib/templates/repositories/PostRepository.ts.template +3 -3
  137. package/lib/templates/repositories/PostThreadRepository.ts.template +3 -3
  138. package/lib/templates/repositories/ReactionRepository.ts.template +3 -4
  139. package/lib/templates/services/ChannelService.ts.template +280 -39
  140. package/lib/templates/services/ExtendedTokenAccountService.ts.template +104 -9
  141. package/lib/templates/services/MessengerNotificationService.ts.template +94 -19
  142. package/lib/templates/services/PostService.ts.template +184 -20
  143. package/lib/templates/services/PostThreadService.ts.template +151 -6
  144. package/lib/templates/services/ReactionService.ts.template +129 -3
  145. package/lib/templates/services/RedisCacheManager.ts.template +22 -0
  146. package/package.json +6 -5
  147. package/lib/interfaces/context.d.ts +0 -14
  148. package/lib/store/models/common-options.js +0 -20
  149. package/lib/store/models/common-options.js.map +0 -1
@@ -1,6 +1,28 @@
1
- import { IBaseService } from '@common-stack/store-mongo';
2
- import { IChannel,RoomType, IChannelUnread, IPost, IUserAccount, Maybe, Scalars } from 'common';
3
-
1
+ /**
2
+ * Channel Service Interface
3
+ * -------------------------
4
+ *
5
+ * This interface defines the business logic layer for channel management within
6
+ * the messenger platform. It provides a comprehensive set of operations for
7
+ * managing channels, their members, and related messaging workflows.
8
+ *
9
+ * Key capabilities:
10
+ * - Channel lifecycle management (creation, updates, deletion)
11
+ * - Member management (adding, removing, role assignment)
12
+ * - Direct and public channel handling
13
+ * - Message and post management within channels
14
+ * - Channel visibility and access control
15
+ * - Notification and unread message tracking
16
+ * - Team-based channel organization
17
+ * - Channel discovery and filtering
18
+ *
19
+ * The service layer abstracts the underlying data access operations and
20
+ * provides a cohesive API for channel-related functionality throughout
21
+ * the messaging platform, handling complex business rules and cross-cutting concerns.
22
+ */
23
+
24
+
25
+ import { IChannelModel, RoomType, IChannelUnread, IPost, IUserAccount, Maybe, Scalars, Disposable, AsDomainType,IBaseService } from 'common/server';
4
26
 
5
27
  export interface INotificationProps {
6
28
  desktopNotifyProp: boolean;
@@ -18,38 +40,39 @@ export interface IDirectChannelMemberCreate {
18
40
  explicitRoles?: string;
19
41
  }
20
42
 
21
- export interface ISaveDirectChannelParams extends Omit<IChannel, 'creator' | 'id' | 'type' | 'members'> {
43
+ export interface ISaveDirectChannelParams extends Omit<IChannelModel, 'creator' | 'id' | 'type' | 'members'> {
22
44
  type: RoomType.Direct;
23
45
  creator: string;
24
46
  displayName: string;
25
47
  members: any;
26
48
  }
27
49
 
28
- export interface ISaveChannelParams extends Omit<IChannel, 'creator' | 'id' | 'type' | 'team'> {
50
+ export interface ISaveChannelParams extends Omit<IChannelModel, 'creator' | 'id' | 'type' | 'team'> {
29
51
  type: RoomType;
30
52
  creator: string;
31
53
  team: string;
32
54
  orgName: string;
55
+ organization: any;
33
56
  }
34
57
 
35
- export interface IAddMemberParams extends Omit<IChannel, 'channelId' | 'memberId'> {
58
+ export interface IAddMemberParams extends Omit<IChannelModel, 'channelId' | 'memberId'> {
36
59
  memberId: string;
37
60
  channelId: string;
38
61
  }
39
62
 
40
- export interface ISavePublicChannelParams extends Omit<IChannel, 'creator' | 'id' | 'orgName' | 'team'> {
63
+ export interface ISavePublicChannelParams extends Omit<IChannelModel, 'creator' | '_id' | 'orgName' | 'organization' | 'team'> {
41
64
  _id?: any;
42
65
  type: RoomType.Public;
43
66
  title: string;
44
67
  }
45
68
 
46
-
47
69
  export interface ICreateDirectChannelParams {
48
70
  sender: string;
49
71
  receiver: string[];
50
72
  displayName: string;
51
73
  channelOptions?: Record<string, unknown>;
52
74
  orgName?: string;
75
+ organization: any;
53
76
  }
54
77
 
55
78
  export interface ISaveMembersToChannelParams {
@@ -57,88 +80,306 @@ export interface ISaveMembersToChannelParams {
57
80
  channelId: string;
58
81
  }
59
82
 
60
- // based on https://github.com/mattermost/mattermost-server/blob/master/store/sqlstore/channel_store.go
61
- export interface IChannelService extends IBaseService<IChannel, Omit<IChannel, 'id'>> {
83
+ // Based on https://github.com/mattermost/mattermost-server/blob/master/store/sqlstore/channel_store.go
84
+ export interface IChannelService extends IBaseService<IChannelModel>, Disposable {
62
85
  /**
63
- * @description Direct channel don't need team reference.
64
- * @param data
86
+ * Creates a direct channel between users
87
+ *
88
+ * @description Direct channels don't need team reference and are used for
89
+ * private conversations between specific users.
90
+ *
91
+ * @param {ICreateDirectChannelParams} data - The direct channel creation parameters
92
+ * @returns {Promise<AsDomainType<IChannelModel> | Error>} - The created channel or error
65
93
  */
66
- createDirectChannel(data: ICreateDirectChannelParams): Promise<IChannel | Error>;
94
+ createDirectChannel(data: ICreateDirectChannelParams): Promise<AsDomainType<IChannelModel> | Error>;
67
95
 
96
+ /**
97
+ * Checks if a user is a member of a specific channel
98
+ *
99
+ * @param {string} channelId - The ID of the channel to check
100
+ * @param {string} user - The ID of the user
101
+ * @returns {Promise<boolean>} - True if the user is a member
102
+ */
68
103
  isMember(channelId: string, user: string): Promise<boolean>;
69
104
 
70
- addMemberToChannel(channelId: string, memberId: string): Promise<IChannel | Error>;
105
+ /**
106
+ * Adds a single member to a channel
107
+ *
108
+ * @param {string} channelId - The ID of the channel
109
+ * @param {string} memberId - The ID of the member to add
110
+ * @returns {Promise<AsDomainType<IChannelModel> | Error>} - The updated channel or error
111
+ */
112
+ addMemberToChannel(channelId: string, memberId: string): Promise<AsDomainType<IChannelModel> | Error>;
71
113
 
72
- saveMembersToChannel(data: ISaveMembersToChannelParams): Promise<IChannel | Error>;
114
+ /**
115
+ * Adds multiple members to a channel in a single operation
116
+ *
117
+ * @param {ISaveMembersToChannelParams} data - The members and channel data
118
+ * @returns {Promise<AsDomainType<IChannelModel> | Error>} - The updated channel or error
119
+ */
120
+ saveMembersToChannel(data: ISaveMembersToChannelParams): Promise<AsDomainType<IChannelModel> | Error>;
73
121
 
74
- saveDirectChannel(channel: ISaveDirectChannelParams): Promise<IChannel | Error>;
122
+ /**
123
+ * Creates and saves a direct channel
124
+ *
125
+ * @param {ISaveDirectChannelParams} channel - The direct channel parameters
126
+ * @returns {Promise<AsDomainType<IChannelModel> | Error>} - The created channel or error
127
+ */
128
+ saveDirectChannel(channel: ISaveDirectChannelParams): Promise<AsDomainType<IChannelModel> | Error>;
75
129
 
76
- saveChannel(data: ISaveChannelParams): Promise<IChannel | Error>;
130
+ /**
131
+ * Creates and saves a team-based channel
132
+ *
133
+ * @param {ISaveChannelParams} data - The channel creation parameters
134
+ * @returns {Promise<AsDomainType<IChannelModel> | Error>} - The created channel or error
135
+ */
136
+ saveChannel(data: ISaveChannelParams): Promise<AsDomainType<IChannelModel> | Error>;
77
137
 
78
- savePublicChannel(data: ISavePublicChannelParams): Promise<IChannel | Error>;
138
+ /**
139
+ * Creates and saves a public channel
140
+ *
141
+ * @param {ISavePublicChannelParams} data - The public channel parameters
142
+ * @returns {Promise<AsDomainType<IChannelModel> | Error>} - The created channel or error
143
+ */
144
+ savePublicChannel(data: ISavePublicChannelParams): Promise<AsDomainType<IChannelModel> | Error>;
79
145
 
146
+ /**
147
+ * Retrieves unread message information for a user in a channel
148
+ *
149
+ * @param {string} channelId - The ID of the channel
150
+ * @param {string} userId - The ID of the user
151
+ * @returns {Promise<IChannelUnread | Error>} - Unread information or error
152
+ */
80
153
  getChannelUnread(channelId: string, userId: string): Promise<IChannelUnread | Error>;
81
154
 
155
+ /**
156
+ * Invalidates cached channel data by name
157
+ *
158
+ * @param {string} teamId - The ID of the team
159
+ * @param {string} name - The name of the channel
160
+ * @returns {Promise<void>} - Void promise when complete
161
+ */
82
162
  invalidateChannelByName(teamId: string, name: string): Promise<void>;
83
163
 
164
+ /**
165
+ * Retrieves all pinned posts from a channel
166
+ *
167
+ * @param {string} channelId - The ID of the channel
168
+ * @returns {Promise<IPost[] | Error>} - Array of pinned posts or error
169
+ */
84
170
  getPinnedPosts(channelId: string): Promise<IPost[] | Error>;
85
171
 
86
- getFromMaster(id: string): Promise<IChannel | Error>;
172
+ /**
173
+ * Retrieves a channel from the master database
174
+ *
175
+ * @param {string} id - The ID of the channel
176
+ * @returns {Promise<AsDomainType<IChannelModel> | Error>} - The channel or error
177
+ */
178
+ getFromMaster(id: string): Promise<AsDomainType<IChannelModel> | Error>;
87
179
 
88
- restore(channelId: string, time: Date);
180
+ /**
181
+ * Restores a previously deleted channel
182
+ *
183
+ * @param {string} channelId - The ID of the channel to restore
184
+ * @param {Date} time - The restoration timestamp
185
+ * @returns {Promise<void>} - Void promise when complete
186
+ */
187
+ restore(channelId: string, time: Date): Promise<void>;
89
188
 
90
189
  /**
91
- * @description remove all channels for the given team from the database.
92
- * @param teamId
190
+ * Permanently removes all channels for a given team
191
+ *
192
+ * @description Removes all channels associated with a team from the database.
193
+ * This operation cannot be undone.
194
+ *
195
+ * @param {string} teamId - The ID of the team
196
+ * @returns {Promise<void | Error>} - Void promise or error
93
197
  */
94
- permanentDeleteByTeam(teamId: string): void | Error;
198
+ permanentDeleteByTeam(teamId: string): Promise<void | Error>;
95
199
 
96
200
  /**
97
- * @description removes the given channel
98
- * @param channelId
201
+ * Permanently removes a specific channel
202
+ *
203
+ * @description Completely removes the channel from the database.
204
+ * This operation cannot be undone.
205
+ *
206
+ * @param {string} channelId - The ID of the channel to delete
207
+ * @returns {Promise<void | Error>} - Void promise or error
99
208
  */
100
- permanentDelete(channelId: string): void | Error;
209
+ permanentDelete(channelId: string): Promise<void | Error>;
101
210
 
102
- permanentDeleteMembersByChannel(channelId: string): void | Error;
211
+ /**
212
+ * Permanently removes all members from a channel
213
+ *
214
+ * @param {string} channelId - The ID of the channel
215
+ * @returns {Promise<void | Error>} - Void promise or error
216
+ */
217
+ permanentDeleteMembersByChannel(channelId: string): Promise<void | Error>;
103
218
 
219
+ /**
220
+ * Retrieves channels for a team with filtering options
221
+ *
222
+ * @param {string} teamId - The ID of the team
223
+ * @param {string} userId - The ID of the user
224
+ * @param {boolean} includeDeleted - Whether to include deleted channels
225
+ * @param {number} lastDeleteAt - Timestamp filter for deletions
226
+ * @param {string} orgId - The organization ID
227
+ * @returns {Promise<Array<AsDomainType<IChannelModel>> | Error>} - Array of channels or error
228
+ */
104
229
  getChannels(
105
230
  teamId: string,
106
231
  userId: string,
107
232
  includeDeleted: boolean,
108
233
  lastDeleteAt: number,
109
234
  orgId: string,
110
- ): Promise<IChannel[] | Error>;
235
+ ): Promise<Array<AsDomainType<IChannelModel>> | Error>;
111
236
 
112
- getMoreChannels(teamId: string, userId: string, offset: number, limit: number): Promise<IChannel[] | Error>;
237
+ /**
238
+ * Retrieves additional channels with pagination
239
+ *
240
+ * @param {string} teamId - The ID of the team
241
+ * @param {string} userId - The ID of the user
242
+ * @param {number} offset - Number of items to skip
243
+ * @param {number} limit - Maximum number of items to return
244
+ * @returns {Promise<Array<AsDomainType<IChannelModel>> | Error>} - Array of channels or error
245
+ */
246
+ getMoreChannels(teamId: string, userId: string, offset: number, limit: number): Promise<Array<AsDomainType<IChannelModel>> | Error>;
113
247
 
114
- getPrivateChannelsForTeam(teamId: string, offset: number, limit: number): Promise<IChannel[] | Error>;
248
+ /**
249
+ * Retrieves private channels for a team with pagination
250
+ *
251
+ * @param {string} teamId - The ID of the team
252
+ * @param {number} offset - Number of items to skip
253
+ * @param {number} limit - Maximum number of items to return
254
+ * @returns {Promise<Array<AsDomainType<IChannelModel>> | Error>} - Array of private channels or error
255
+ */
256
+ getPrivateChannelsForTeam(teamId: string, offset: number, limit: number): Promise<Array<AsDomainType<IChannelModel>> | Error>;
115
257
 
116
- getPublicChannelsForTeam(teamId: string, offset: number, limit: number): Promise<IChannel[] | Error>;
258
+ /**
259
+ * Retrieves public channels for a team with pagination
260
+ *
261
+ * @param {string} teamId - The ID of the team
262
+ * @param {number} offset - Number of items to skip
263
+ * @param {number} limit - Maximum number of items to return
264
+ * @returns {Promise<Array<AsDomainType<IChannelModel>> | Error>} - Array of public channels or error
265
+ */
266
+ getPublicChannelsForTeam(teamId: string, offset: number, limit: number): Promise<Array<AsDomainType<IChannelModel>> | Error>;
117
267
 
118
- getPublicChannelsByIdsForTeam(teamId: string, channelsIds: string[]): Promise<IChannel[] | Error>;
268
+ /**
269
+ * Retrieves specific public channels by their IDs
270
+ *
271
+ * @param {string} teamId - The ID of the team
272
+ * @param {string[]} channelsIds - Array of channel IDs to retrieve
273
+ * @returns {Promise<Array<AsDomainType<IChannelModel>> | Error>} - Array of channels or error
274
+ */
275
+ getPublicChannelsByIdsForTeam(teamId: string, channelsIds: string[]): Promise<Array<AsDomainType<IChannelModel>> | Error>;
119
276
 
277
+ /**
278
+ * Retrieves channel count statistics for a team
279
+ *
280
+ * @param {string} teamId - The ID of the team
281
+ * @param {string} userId - The ID of the user
282
+ * @returns {Promise<any | Error>} - Channel count data or error
283
+ */
120
284
  getChannelCounts(teamId: string, userId: string): Promise<any | Error>;
121
285
 
122
- getTeamChannels(teamId: string): Promise<IChannel[] | Error>;
286
+ /**
287
+ * Retrieves all channels belonging to a team
288
+ *
289
+ * @param {string} teamId - The ID of the team
290
+ * @returns {Promise<Array<AsDomainType<IChannelModel>> | Error>} - Array of team channels or error
291
+ */
292
+ getTeamChannels(teamId: string): Promise<Array<AsDomainType<IChannelModel>> | Error>;
123
293
 
124
- // getByName(teamId: string, name: string): Promise<IChannel | Error>;
125
- getByName(name: string): Promise<IChannel>;
294
+ /**
295
+ * Retrieves a channel by its name
296
+ *
297
+ * @param {string} name - The name of the channel
298
+ * @returns {Promise<AsDomainType<IChannelModel> | null>} - The channel or null if not found
299
+ */
300
+ getByName(name: string): Promise<AsDomainType<IChannelModel> | null>;
126
301
 
127
- getByNames(teamId: string, names: string[]): Promise<IChannel[] | Error>;
302
+ /**
303
+ * Retrieves multiple channels by their names
304
+ *
305
+ * @param {string} teamId - The ID of the team
306
+ * @param {string[]} names - Array of channel names
307
+ * @returns {Promise<Array<AsDomainType<IChannelModel>> | Error>} - Array of channels or error
308
+ */
309
+ getByNames(teamId: string, names: string[]): Promise<Array<AsDomainType<IChannelModel>> | Error>;
128
310
 
129
- getByNameIncludeDeleted(teamId: string, name: string): Promise<IChannel | Error>;
311
+ /**
312
+ * Retrieves a channel by name including deleted channels
313
+ *
314
+ * @param {string} teamId - The ID of the team
315
+ * @param {string} name - The name of the channel
316
+ * @returns {Promise<AsDomainType<IChannelModel> | Error>} - The channel or error
317
+ */
318
+ getByNameIncludeDeleted(teamId: string, name: string): Promise<AsDomainType<IChannelModel> | Error>;
130
319
 
131
- getDeletedByName(teamId: string, name: string): Promise<IChannel | Error>;
320
+ /**
321
+ * Retrieves a deleted channel by name
322
+ *
323
+ * @param {string} teamId - The ID of the team
324
+ * @param {string} name - The name of the deleted channel
325
+ * @returns {Promise<AsDomainType<IChannelModel> | Error>} - The deleted channel or error
326
+ */
327
+ getDeletedByName(teamId: string, name: string): Promise<AsDomainType<IChannelModel> | Error>;
132
328
 
133
- getDeleted(teamId: string, offset: number, limit: number, userId: string): Promise<IChannel[] | Error>;
329
+ /**
330
+ * Retrieves deleted channels with pagination
331
+ *
332
+ * @param {string} teamId - The ID of the team
333
+ * @param {number} offset - Number of items to skip
334
+ * @param {number} limit - Maximum number of items to return
335
+ * @param {string} userId - The ID of the user
336
+ * @returns {Promise<Array<AsDomainType<IChannelModel>> | Error>} - Array of deleted channels or error
337
+ */
338
+ getDeleted(teamId: string, offset: number, limit: number, userId: string): Promise<Array<AsDomainType<IChannelModel>> | Error>;
134
339
 
340
+ /**
341
+ * Saves multiple members to the system
342
+ *
343
+ * @param {IUserAccount[]} members - Array of user accounts to save
344
+ * @returns {Promise<IUserAccount[] | Error>} - Array of saved user accounts or error
345
+ */
135
346
  saveMultipleMembers(members: IUserAccount[]): Promise<IUserAccount[] | Error>;
136
347
 
348
+ /**
349
+ * Hides a channel from the user's view
350
+ *
351
+ * @param {string} id - The ID of the channel to hide
352
+ * @returns {Promise<boolean>} - True if successful
353
+ */
137
354
  hideChannel(id: string): Promise<boolean>;
138
355
 
356
+ /**
357
+ * Removes the current user from a channel
358
+ *
359
+ * @param {string} id - The ID of the channel to leave
360
+ * @returns {Promise<boolean>} - True if successful
361
+ */
139
362
  leaveChannel(id: string): Promise<boolean>;
140
363
 
364
+ /**
365
+ * Soft deletes a channel (marks as deleted)
366
+ *
367
+ * @param {string} id - The ID of the channel to delete
368
+ * @returns {Promise<boolean | Error>} - True if successful or error
369
+ */
141
370
  deleteChannel(id: string): Promise<boolean | Error>;
142
371
 
372
+ /**
373
+ * Marks a channel as viewed by a user
374
+ *
375
+ * @param {string} id - The ID of the channel
376
+ * @param {string} user - The ID of the user
377
+ * @returns {Promise<boolean>} - True if successful
378
+ */
143
379
  viewChannel(id: string, user: string): Promise<boolean>;
380
+
381
+ /**
382
+ * Disposes of resources used by the service
383
+ */
384
+ dispose(): void;
144
385
  }
@@ -1,13 +1,108 @@
1
- import { IPostThread, IUserAccount,IAccountServiceContext } from 'common';
2
- import { IBaseService } from '@common-stack/store-mongo';
1
+ /**
2
+ * Extended Token Account Service Interface
3
+ * ----------------------------------------
4
+ *
5
+ * This interface defines the business logic layer for token-based account management
6
+ * within the messenger platform. It provides a comprehensive set of operations for
7
+ * managing user authentication, device tokens, and push notification capabilities.
8
+ *
9
+ * Key capabilities:
10
+ * - Device token lifecycle management (registration, updates, removal)
11
+ * - Auth0 integration for external authentication
12
+ * - Push notification token management
13
+ * - Cross-platform device coordination
14
+ * - Account resolution by authentication providers
15
+ * - Token-based notification delivery
16
+ * - Multi-device user session handling
17
+ * - Secure token storage and validation
18
+ *
19
+ * The service layer abstracts the underlying token management operations and
20
+ * provides a cohesive API for authentication-related functionality throughout
21
+ * the messaging platform, handling complex token flows and cross-cutting concerns.
22
+ */
23
+
24
+ import {IBaseService, IAccountServiceContext, IUserAccountModel, Disposable, AsDomainType } from 'common/server';
25
+
3
26
 
4
27
  //export type IExtendedTokenAccountService = IBaseService<IUserAccount>;
5
28
 
6
- export interface IExtendedTokenAccountService extends IBaseService<IUserAccount> {
7
- getDeviceToken(accountId: string): Promise<any>;
8
- setDeviceToken(deviceToken: string, accountId: string): Promise<any>;
9
- removeDeviceToken(deviceToken: string, accountId: string): Promise<any>;
10
- getAccountByAuth0Id(auth0Id: string, context?: IAccountServiceContext): Promise<any>;
11
- removeUserExpoTokenByAuth0Id(auth0Id: string, context?: IAccountServiceContext): Promise<any>;
12
-
29
+ /**
30
+ * Extended Token Account Service Interface
31
+ *
32
+ * @description Provides enhanced account management capabilities with focus on
33
+ * token operations, device management, and authentication integration across
34
+ * multiple platforms and providers.
35
+ */
36
+ export interface IExtendedTokenAccountService extends IBaseService<IUserAccountModel>, Disposable {
37
+ /**
38
+ * Retrieves device tokens associated with a user account
39
+ *
40
+ * @description Fetches all registered device tokens for push notifications
41
+ * and real-time messaging delivery. Used for managing notification routing
42
+ * and device-specific message delivery.
43
+ *
44
+ * @param {string} accountId - The unique identifier of the user account
45
+ * @returns {Promise<AsDomainType<IUserAccountModel> | Error>} - Device token data or error
46
+ */
47
+ getDeviceToken(accountId: string): Promise<AsDomainType<IUserAccountModel> | Error>;
48
+
49
+ /**
50
+ * Registers or updates a device token for an account
51
+ *
52
+ * @description Associates a new device token with the user account for
53
+ * push notification delivery. Handles token updates, duplicates, and ensures
54
+ * proper device registration for notification routing.
55
+ *
56
+ * @param {string} deviceToken - The device-specific push notification token
57
+ * @param {string} accountId - The unique identifier of the user account
58
+ * @returns {Promise<AsDomainType<IUserAccountModel> | Error>} - Operation result or error
59
+ */
60
+ setDeviceToken(deviceToken: string, accountId: string): Promise<AsDomainType<IUserAccountModel> | Error>;
61
+
62
+ /**
63
+ * Removes a specific device token from an account
64
+ *
65
+ * @description Unregisters a device token from push notification delivery.
66
+ * Typically called during device logout, app uninstallation, or token
67
+ * rotation scenarios to maintain clean device registration.
68
+ *
69
+ * @param {string} deviceToken - The device token to remove
70
+ * @param {string} accountId - The unique identifier of the user account
71
+ * @returns {Promise<AsDomainType<IUserAccountModel> | Error>} - Operation result or error
72
+ */
73
+ removeDeviceToken(deviceToken: string, accountId: string): Promise<AsDomainType<IUserAccountModel> | Error>;
74
+
75
+ /**
76
+ * Retrieves a user account by Auth0 authentication ID
77
+ *
78
+ * @description Resolves user account information using external Auth0
79
+ * authentication provider identifiers. Essential for SSO flows, federated
80
+ * login scenarios, and maintaining consistent user identity across auth providers.
81
+ *
82
+ * @param {string} auth0Id - The Auth0 user identifier
83
+ * @param {IAccountServiceContext} [context] - Optional service context for scoped operations
84
+ * @returns {Promise<AsDomainType<IUserAccountModel> | Error>} - User account or error
85
+ */
86
+ getAccountByAuth0Id(auth0Id: string, context?: IAccountServiceContext): Promise<AsDomainType<IUserAccountModel> | Error>;
87
+
88
+ /**
89
+ * Removes Expo push notification tokens by Auth0 ID
90
+ *
91
+ * @description Cleans up all Expo-specific push notification tokens
92
+ * associated with an Auth0 user. Critical for maintaining token hygiene
93
+ * during account deletion, logout, or platform migration scenarios.
94
+ *
95
+ * @param {string} auth0Id - The Auth0 user identifier
96
+ * @param {IAccountServiceContext} [context] - Optional service context for scoped operations
97
+ * @returns {Promise<void | Error>} - Void promise or error
98
+ */
99
+ removeUserExpoTokenByAuth0Id(auth0Id: string, context?: IAccountServiceContext): Promise<void | Error>;
100
+
101
+ /**
102
+ * Disposes of resources used by the service
103
+ *
104
+ * @description Properly cleans up any resources, connections, or subscriptions
105
+ * maintained by the service instance.
106
+ */
107
+ dispose(): void;
13
108
  }
@@ -1,37 +1,45 @@
1
- import { IPost,IExpoNotificationData } from 'common';
1
+ /**
2
+ * Messenger Notification Service Interface
3
+ * --------------------------------------
4
+ *
5
+ * This interface defines the business logic layer for notification management within
6
+ * the messenger platform. It provides a comprehensive set of operations for
7
+ * handling various types of notifications including push notifications, message alerts,
8
+ * and Expo-specific notifications.
9
+ *
10
+ * Key capabilities:
11
+ * - Unread message notifications
12
+ * - Post-based notifications
13
+ * - Alert message handling
14
+ * - Expo push notification integration
15
+ * - Service message notifications
16
+ * - Support service configuration
17
+ */
18
+
19
+ import { IPost, IExpoNotificationData, IBaseService, AsDomainType, Disposable } from 'common/server';
20
+
2
21
  export enum NotificationDurationUnitEnum {
3
22
  days = 'days',
4
23
  hours = 'hours',
5
24
  minutes = 'minutes',
6
25
  seconds = 'seconds',
7
26
  }
27
+
8
28
  export type IExpoNotification = any;
9
29
  export type IExpoNotificationTo = string | string[];
10
- export type IExpoNotificationBodyData = {
30
+
31
+ export interface IExpoNotificationBodyData {
11
32
  url: string;
12
33
  params: object;
13
34
  title?: string;
14
35
  body?: string;
15
36
  screen?: string;
16
37
  senderId?: string;
17
- thread?: { id: string; extraParams?: object };
38
+ thread?: {
39
+ id: string;
40
+ extraParams?: object
41
+ };
18
42
  other?: object;
19
- };
20
- // export interface IExpoNotificationData {
21
- // to: IExpoNotificationTo;
22
- // data?: IExpoNotificationBodyData;
23
- // title: string;
24
- // body: any;
25
- // sound?: any;
26
- // }
27
- export interface IMessengerNotificationService {
28
- sendNotificationOfUnreadMessages(unit: NotificationDurationUnitEnum, value: number): Promise<void>;
29
- sendNotificationOnPost(post: IPost): Promise<Boolean>;
30
- sendNotificationOfAlertMessages(unit: NotificationDurationUnitEnum, value: number): Promise<void>;
31
- sendPushNotificationsExpo(data: IExpoNotificationData): Promise<IExpoNotification>;
32
- sendExpoNotificationOnPost(post: IPost, notificationData?: IExpoNotificationBodyData): Promise<Boolean>;
33
- sendNotificationOfUnreadServiceMessages(unit: NotificationDurationUnitEnum, value: number): Promise<void>;
34
- setSupportServiceConfig?(config: any): Promise<void>;
35
43
  }
36
44
 
37
45
  export interface ISupportServiceConfig {
@@ -39,3 +47,70 @@ export interface ISupportServiceConfig {
39
47
  templateId?: string;
40
48
  variables?: object;
41
49
  }
50
+
51
+ export interface IMessengerNotificationService extends IBaseService<IPost>, Disposable {
52
+ /**
53
+ * Sends notifications for unread messages based on duration
54
+ *
55
+ * @param {NotificationDurationUnitEnum} unit - Time unit for notification check
56
+ * @param {number} value - Duration value in specified unit
57
+ * @returns {Promise<void>}
58
+ */
59
+ sendNotificationOfUnreadMessages(unit: NotificationDurationUnitEnum, value: number): Promise<void>;
60
+
61
+ /**
62
+ * Sends a notification when a new post is created
63
+ *
64
+ * @param {AsDomainType<IPost>} post - The post that triggered the notification
65
+ * @returns {Promise<Boolean>}
66
+ */
67
+ sendNotificationOnPost(post: AsDomainType<IPost>): Promise<Boolean>;
68
+
69
+ /**
70
+ * Sends notifications for alert messages based on duration
71
+ *
72
+ * @param {NotificationDurationUnitEnum} unit - Time unit for alert check
73
+ * @param {number} value - Duration value in specified unit
74
+ * @returns {Promise<void>}
75
+ */
76
+ sendNotificationOfAlertMessages(unit: NotificationDurationUnitEnum, value: number): Promise<void>;
77
+
78
+ /**
79
+ * Sends push notifications through Expo service
80
+ *
81
+ * @param {IExpoNotificationData} data - The notification data to send
82
+ * @returns {Promise<IExpoNotification>}
83
+ */
84
+ sendPushNotificationsExpo(data: IExpoNotificationData): Promise<IExpoNotification>;
85
+
86
+ /**
87
+ * Sends an Expo notification for a specific post
88
+ *
89
+ * @param {AsDomainType<IPost>} post - The post to send notification for
90
+ * @param {IExpoNotificationBodyData} [notificationData] - Optional custom notification data
91
+ * @returns {Promise<Boolean>}
92
+ */
93
+ sendExpoNotificationOnPost(post: AsDomainType<IPost>, notificationData?: IExpoNotificationBodyData): Promise<Boolean>;
94
+
95
+ /**
96
+ * Sends notifications for unread service messages based on duration
97
+ *
98
+ * @param {NotificationDurationUnitEnum} unit - Time unit for service message check
99
+ * @param {number} value - Duration value in specified unit
100
+ * @returns {Promise<void>}
101
+ */
102
+ sendNotificationOfUnreadServiceMessages(unit: NotificationDurationUnitEnum, value: number): Promise<void>;
103
+
104
+ /**
105
+ * Configures the support service settings
106
+ *
107
+ * @param {ISupportServiceConfig} config - Support service configuration
108
+ * @returns {Promise<void>}
109
+ */
110
+ setSupportServiceConfig?(config: ISupportServiceConfig): Promise<void>;
111
+
112
+ /**
113
+ * Disposes of resources used by the service
114
+ */
115
+ dispose(): void;
116
+ }