@messenger-box/platform-server 10.0.3-alpha.6 → 10.0.3-alpha.62

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 (144) hide show
  1. package/lib/containers/containers.js +3 -1
  2. package/lib/containers/containers.js.map +1 -1
  3. package/lib/containers/context-services-from-container.d.ts +2 -2
  4. package/lib/containers/context-services-from-container.js +2 -1
  5. package/lib/containers/context-services-from-container.js.map +1 -1
  6. package/lib/graphql/resolvers/channel-member.d.ts +3 -3
  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 -3
  10. package/lib/graphql/resolvers/channel.js +275 -53
  11. package/lib/graphql/resolvers/channel.js.map +1 -1
  12. package/lib/graphql/resolvers/extended-token-account.d.ts +3 -32
  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 -31
  16. package/lib/graphql/resolvers/post-thread.d.ts +2 -3
  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 +697 -234
  21. package/lib/graphql/resolvers/post.js.map +1 -1
  22. package/lib/graphql/resolvers/reaction.d.ts +3 -3
  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 +331 -38
  28. package/lib/graphql/schema/channel.graphql.js +1 -1
  29. package/lib/graphql/schema/post-thread.graphql +166 -21
  30. package/lib/graphql/schema/post-thread.graphql.js +1 -1
  31. package/lib/graphql/schema/post.graphql +280 -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 -2
  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 +178 -33
  71. package/lib/services/channel-service.js +735 -276
  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/messenger-notification-service.d.ts +106 -13
  77. package/lib/services/messenger-notification-service.js +824 -442
  78. package/lib/services/messenger-notification-service.js.map +1 -1
  79. package/lib/services/post-service.d.ts +172 -16
  80. package/lib/services/post-service.js +580 -113
  81. package/lib/services/post-service.js.map +1 -1
  82. package/lib/services/post-thread-service.d.ts +114 -5
  83. package/lib/services/post-thread-service.js +400 -13
  84. package/lib/services/post-thread-service.js.map +1 -1
  85. package/lib/services/proxy-services/channel-microservice.d.ts +5 -3
  86. package/lib/services/proxy-services/channel-microservice.js +19 -10
  87. package/lib/services/proxy-services/channel-microservice.js.map +1 -1
  88. package/lib/services/proxy-services/messenger-notification-microservice.d.ts +128 -8
  89. package/lib/services/proxy-services/messenger-notification-microservice.js +324 -29
  90. package/lib/services/proxy-services/messenger-notification-microservice.js.map +1 -1
  91. package/lib/services/proxy-services/post-microservice.d.ts +186 -12
  92. package/lib/services/proxy-services/post-microservice.js +543 -54
  93. package/lib/services/proxy-services/post-microservice.js.map +1 -1
  94. package/lib/services/proxy-services/post-thread-microservice.d.ts +134 -3
  95. package/lib/services/proxy-services/post-thread-microservice.js +388 -6
  96. package/lib/services/proxy-services/post-thread-microservice.js.map +1 -1
  97. package/lib/services/proxy-services/reaction-microservice.d.ts +161 -3
  98. package/lib/services/proxy-services/reaction-microservice.js +474 -2
  99. package/lib/services/proxy-services/reaction-microservice.js.map +1 -1
  100. package/lib/services/reaction-service.d.ts +124 -4
  101. package/lib/services/reaction-service.js +415 -3
  102. package/lib/services/reaction-service.js.map +1 -1
  103. package/lib/store/models/account-token-store.d.ts +1 -1
  104. package/lib/store/models/account-token-store.js.map +1 -1
  105. package/lib/store/models/channel.d.ts +2 -3
  106. package/lib/store/models/channel.js +180 -71
  107. package/lib/store/models/channel.js.map +1 -1
  108. package/lib/store/models/post-thread.d.ts +3 -3
  109. package/lib/store/models/post-thread.js +96 -14
  110. package/lib/store/models/post-thread.js.map +1 -1
  111. package/lib/store/models/post.d.ts +2 -3
  112. package/lib/store/models/post.js +143 -23
  113. package/lib/store/models/post.js.map +1 -1
  114. package/lib/store/models/reaction.d.ts +2 -3
  115. package/lib/store/models/reaction.js +67 -8
  116. package/lib/store/models/reaction.js.map +1 -1
  117. package/lib/store/repositories/__tests__/__fixtures__/team-repository.d.ts +3 -3
  118. package/lib/store/repositories/channel-repository.d.ts +6 -6
  119. package/lib/store/repositories/channel-repository.js +5 -2
  120. package/lib/store/repositories/channel-repository.js.map +1 -1
  121. package/lib/store/repositories/post-repository.d.ts +6 -6
  122. package/lib/store/repositories/post-repository.js +5 -2
  123. package/lib/store/repositories/post-repository.js.map +1 -1
  124. package/lib/store/repositories/post-thread-repository.d.ts +6 -6
  125. package/lib/store/repositories/post-thread-repository.js +5 -2
  126. package/lib/store/repositories/post-thread-repository.js.map +1 -1
  127. package/lib/store/repositories/reaction-repository.d.ts +6 -6
  128. package/lib/store/repositories/reaction-repository.js +5 -2
  129. package/lib/store/repositories/reaction-repository.js.map +1 -1
  130. package/lib/templates/constants/SERVER_TYPES.ts.template +0 -3
  131. package/lib/templates/repositories/ChannelRepository.ts.template +3 -3
  132. package/lib/templates/repositories/PostRepository.ts.template +3 -3
  133. package/lib/templates/repositories/PostThreadRepository.ts.template +3 -3
  134. package/lib/templates/repositories/ReactionRepository.ts.template +3 -4
  135. package/lib/templates/services/ChannelService.ts.template +278 -39
  136. package/lib/templates/services/ExtendedTokenAccountService.ts.template +107 -3
  137. package/lib/templates/services/MessengerNotificationService.ts.template +94 -19
  138. package/lib/templates/services/PostService.ts.template +184 -20
  139. package/lib/templates/services/PostThreadService.ts.template +151 -6
  140. package/lib/templates/services/ReactionService.ts.template +129 -3
  141. package/package.json +4 -4
  142. package/lib/interfaces/context.d.ts +0 -14
  143. package/lib/store/models/common-options.js +0 -20
  144. 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,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<AsDomainType<IChannelModel> | null>} - The channel or null if not found
297
+ */
298
+ getByName(name: string): Promise<AsDomainType<IChannelModel> | null>;
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,4 +1,108 @@
1
- import { IPostThread, IUserAccount } 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
+ */
3
23
 
4
- export type IExtendedTokenAccountService = IBaseService<IUserAccount>;
24
+ import {IBaseService, IAccountServiceContext, IUserAccountModel, Disposable, AsDomainType } from 'common/server';
25
+
26
+
27
+ //export type IExtendedTokenAccountService = IBaseService<IUserAccount>;
28
+
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;
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
+ }