@messenger-box/platform-server 10.0.3-alpha.50 → 10.0.3-alpha.54

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