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

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 (202) hide show
  1. package/lib/config/env-config.d.ts +7 -0
  2. package/lib/config/env-config.js +20 -0
  3. package/lib/config/env-config.js.map +1 -1
  4. package/lib/containers/containers.js +9 -1
  5. package/lib/containers/containers.js.map +1 -1
  6. package/lib/containers/context-services-from-container.d.ts +1 -1
  7. package/lib/containers/context-services-from-container.js +4 -2
  8. package/lib/containers/context-services-from-container.js.map +1 -1
  9. package/lib/graphql/resolvers/ai-fragment.d.ts +3 -0
  10. package/lib/graphql/resolvers/ai-fragment.js +276 -0
  11. package/lib/graphql/resolvers/ai-fragment.js.map +1 -0
  12. package/lib/graphql/resolvers/channel-member.d.ts +3 -2
  13. package/lib/graphql/resolvers/channel-member.js +30 -5
  14. package/lib/graphql/resolvers/channel-member.js.map +1 -1
  15. package/lib/graphql/resolvers/channel.d.ts +3 -2
  16. package/lib/graphql/resolvers/channel.js +308 -53
  17. package/lib/graphql/resolvers/channel.js.map +1 -1
  18. package/lib/graphql/resolvers/extended-token-account.d.ts +3 -2
  19. package/lib/graphql/resolvers/extended-token-account.js +90 -23
  20. package/lib/graphql/resolvers/extended-token-account.js.map +1 -1
  21. package/lib/graphql/resolvers/index.d.ts +1 -1
  22. package/lib/graphql/resolvers/index.js +1 -1
  23. package/lib/graphql/resolvers/index.js.map +1 -1
  24. package/lib/graphql/resolvers/post-thread.d.ts +1 -1
  25. package/lib/graphql/resolvers/post-thread.js +294 -132
  26. package/lib/graphql/resolvers/post-thread.js.map +1 -1
  27. package/lib/graphql/resolvers/post.d.ts +2 -3
  28. package/lib/graphql/resolvers/post.js +874 -239
  29. package/lib/graphql/resolvers/post.js.map +1 -1
  30. package/lib/graphql/resolvers/reaction.d.ts +3 -2
  31. package/lib/graphql/resolvers/reaction.js +96 -14
  32. package/lib/graphql/resolvers/reaction.js.map +1 -1
  33. package/lib/graphql/schema/ai-fragment.graphql +311 -0
  34. package/lib/graphql/schema/ai-fragment.graphql.js +1 -0
  35. package/lib/graphql/schema/ai-fragment.graphql.js.map +1 -0
  36. package/lib/graphql/schema/channel-member.graphql +110 -21
  37. package/lib/graphql/schema/channel-member.graphql.js +1 -1
  38. package/lib/graphql/schema/channel.graphql +356 -38
  39. package/lib/graphql/schema/channel.graphql.js +1 -1
  40. package/lib/graphql/schema/index.js +2 -2
  41. package/lib/graphql/schema/index.js.map +1 -1
  42. package/lib/graphql/schema/post-thread.graphql +167 -21
  43. package/lib/graphql/schema/post-thread.graphql.js +1 -1
  44. package/lib/graphql/schema/post.graphql +360 -40
  45. package/lib/graphql/schema/post.graphql.js +1 -1
  46. package/lib/graphql/schema/reaction.graphql +71 -13
  47. package/lib/graphql/schema/reaction.graphql.js +1 -1
  48. package/lib/graphql/schema/services.graphql +21 -0
  49. package/lib/graphql/schema/users.graphql +76 -13
  50. package/lib/graphql/schema/users.graphql.js +1 -1
  51. package/lib/index.js +1 -1
  52. package/lib/index.js.map +1 -1
  53. package/lib/inngest/factory.d.ts +20 -0
  54. package/lib/inngest/factory.js +4 -0
  55. package/lib/inngest/factory.js.map +1 -0
  56. package/lib/inngest/functions.d.ts +235 -0
  57. package/lib/inngest/functions.js +1385 -0
  58. package/lib/inngest/functions.js.map +1 -0
  59. package/lib/inngest/index.d.ts +3 -0
  60. package/lib/inngest/prompt.d.ts +6 -0
  61. package/lib/inngest/prompt.js +871 -0
  62. package/lib/inngest/prompt.js.map +1 -0
  63. package/lib/inngest/utils.d.ts +5 -0
  64. package/lib/inngest/utils.js +32 -0
  65. package/lib/inngest/utils.js.map +1 -0
  66. package/lib/interfaces/index.d.ts +0 -1
  67. package/lib/interfaces/services.d.ts +1 -1
  68. package/lib/migrations/dbMigrations/AddPostsConfigurationsMigration.d.ts +17 -0
  69. package/lib/migrations/dbMigrations/AddPostsConfigurationsMigration.js +44 -0
  70. package/lib/migrations/dbMigrations/AddPostsConfigurationsMigration.js.map +1 -0
  71. package/lib/migrations/dbMigrations/index.d.ts +1 -0
  72. package/lib/migrations/index.d.ts +1 -0
  73. package/lib/migrations/mail-template-migration.js +1 -1
  74. package/lib/migrations/message-notification-template-migration.d.ts +1 -1
  75. package/lib/migrations/message-notification-template-migration.js +1 -1
  76. package/lib/module.js +10 -3
  77. package/lib/module.js.map +1 -1
  78. package/lib/plugins/ai-fragment-moleculer-service.d.ts +29 -0
  79. package/lib/plugins/ai-fragment-moleculer-service.js +516 -0
  80. package/lib/plugins/ai-fragment-moleculer-service.js.map +1 -0
  81. package/lib/plugins/channel-moleculer-service.d.ts +21 -1
  82. package/lib/plugins/channel-moleculer-service.js +426 -115
  83. package/lib/plugins/channel-moleculer-service.js.map +1 -1
  84. package/lib/plugins/extended-token-account-moleculer-service.d.ts +25 -1
  85. package/lib/plugins/extended-token-account-moleculer-service.js +348 -22
  86. package/lib/plugins/extended-token-account-moleculer-service.js.map +1 -1
  87. package/lib/plugins/index.d.ts +1 -0
  88. package/lib/plugins/messenger-notification-moleculer-service.d.ts +27 -3
  89. package/lib/plugins/messenger-notification-moleculer-service.js +404 -58
  90. package/lib/plugins/messenger-notification-moleculer-service.js.map +1 -1
  91. package/lib/plugins/post-moleculer-service.d.ts +85 -21
  92. package/lib/plugins/post-moleculer-service.js +1102 -256
  93. package/lib/plugins/post-moleculer-service.js.map +1 -1
  94. package/lib/plugins/post-thread-moleculer-service.d.ts +33 -1
  95. package/lib/plugins/post-thread-moleculer-service.js +326 -8
  96. package/lib/plugins/post-thread-moleculer-service.js.map +1 -1
  97. package/lib/plugins/reaction-moleculer-service.js +1 -1
  98. package/lib/plugins/reaction-moleculer-service.js.map +1 -1
  99. package/lib/preferences/settings/post-settings.d.ts +2 -0
  100. package/lib/preferences/settings/post-settings.js +47 -9
  101. package/lib/preferences/settings/post-settings.js.map +1 -1
  102. package/lib/services/ai-fragment-service.d.ts +195 -0
  103. package/lib/services/ai-fragment-service.js +631 -0
  104. package/lib/services/ai-fragment-service.js.map +1 -0
  105. package/lib/services/channel-service.d.ts +181 -33
  106. package/lib/services/channel-service.js +842 -273
  107. package/lib/services/channel-service.js.map +1 -1
  108. package/lib/services/extended-token-account-service.d.ts +130 -14
  109. package/lib/services/extended-token-account-service.js +462 -52
  110. package/lib/services/extended-token-account-service.js.map +1 -1
  111. package/lib/services/index.d.ts +3 -0
  112. package/lib/services/messenger-notification-service.d.ts +106 -13
  113. package/lib/services/messenger-notification-service.js +824 -442
  114. package/lib/services/messenger-notification-service.js.map +1 -1
  115. package/lib/services/post-service.d.ts +189 -16
  116. package/lib/services/post-service.js +949 -113
  117. package/lib/services/post-service.js.map +1 -1
  118. package/lib/services/post-thread-service.d.ts +114 -5
  119. package/lib/services/post-thread-service.js +400 -13
  120. package/lib/services/post-thread-service.js.map +1 -1
  121. package/lib/services/proxy-services/ai-fragment-microservice.d.ts +23 -0
  122. package/lib/services/proxy-services/ai-fragment-microservice.js +78 -0
  123. package/lib/services/proxy-services/ai-fragment-microservice.js.map +1 -0
  124. package/lib/services/proxy-services/channel-microservice.d.ts +6 -3
  125. package/lib/services/proxy-services/channel-microservice.js +25 -10
  126. package/lib/services/proxy-services/channel-microservice.js.map +1 -1
  127. package/lib/services/proxy-services/index.d.ts +1 -0
  128. package/lib/services/proxy-services/messenger-notification-microservice.d.ts +128 -8
  129. package/lib/services/proxy-services/messenger-notification-microservice.js +324 -29
  130. package/lib/services/proxy-services/messenger-notification-microservice.js.map +1 -1
  131. package/lib/services/proxy-services/post-microservice.d.ts +207 -12
  132. package/lib/services/proxy-services/post-microservice.js +623 -54
  133. package/lib/services/proxy-services/post-microservice.js.map +1 -1
  134. package/lib/services/proxy-services/post-thread-microservice.d.ts +134 -3
  135. package/lib/services/proxy-services/post-thread-microservice.js +388 -6
  136. package/lib/services/proxy-services/post-thread-microservice.js.map +1 -1
  137. package/lib/services/proxy-services/reaction-microservice.d.ts +161 -3
  138. package/lib/services/proxy-services/reaction-microservice.js +474 -2
  139. package/lib/services/proxy-services/reaction-microservice.js.map +1 -1
  140. package/lib/services/reaction-service.d.ts +124 -4
  141. package/lib/services/reaction-service.js +415 -3
  142. package/lib/services/reaction-service.js.map +1 -1
  143. package/lib/services/redis-cache-manager.d.ts +18 -0
  144. package/lib/services/redis-cache-manager.js +83 -0
  145. package/lib/services/redis-cache-manager.js.map +1 -0
  146. package/lib/services/sandbox-error-service.d.ts +23 -0
  147. package/lib/services/sandbox-error-service.js +422 -0
  148. package/lib/services/sandbox-error-service.js.map +1 -0
  149. package/lib/store/models/account-token-store.d.ts +1 -1
  150. package/lib/store/models/account-token-store.js.map +1 -1
  151. package/lib/store/models/ai-fragment.d.ts +4 -0
  152. package/lib/store/models/ai-fragment.js +125 -0
  153. package/lib/store/models/ai-fragment.js.map +1 -0
  154. package/lib/store/models/channel.d.ts +2 -3
  155. package/lib/store/models/channel.js +185 -71
  156. package/lib/store/models/channel.js.map +1 -1
  157. package/lib/store/models/index.d.ts +1 -0
  158. package/lib/store/models/post-thread.d.ts +3 -3
  159. package/lib/store/models/post-thread.js +96 -14
  160. package/lib/store/models/post-thread.js.map +1 -1
  161. package/lib/store/models/post.d.ts +2 -3
  162. package/lib/store/models/post.js +143 -23
  163. package/lib/store/models/post.js.map +1 -1
  164. package/lib/store/models/reaction.d.ts +2 -3
  165. package/lib/store/models/reaction.js +67 -8
  166. package/lib/store/models/reaction.js.map +1 -1
  167. package/lib/store/repositories/__tests__/__fixtures__/team-repository.d.ts +3 -3
  168. package/lib/store/repositories/ai-fragment-repository.d.ts +15 -0
  169. package/lib/store/repositories/ai-fragment-repository.js +69 -0
  170. package/lib/store/repositories/ai-fragment-repository.js.map +1 -0
  171. package/lib/store/repositories/channel-repository.d.ts +6 -6
  172. package/lib/store/repositories/channel-repository.js +5 -2
  173. package/lib/store/repositories/channel-repository.js.map +1 -1
  174. package/lib/store/repositories/index.d.ts +1 -0
  175. package/lib/store/repositories/post-repository.d.ts +6 -6
  176. package/lib/store/repositories/post-repository.js +5 -2
  177. package/lib/store/repositories/post-repository.js.map +1 -1
  178. package/lib/store/repositories/post-thread-repository.d.ts +6 -6
  179. package/lib/store/repositories/post-thread-repository.js +5 -2
  180. package/lib/store/repositories/post-thread-repository.js.map +1 -1
  181. package/lib/store/repositories/reaction-repository.d.ts +6 -6
  182. package/lib/store/repositories/reaction-repository.js +5 -2
  183. package/lib/store/repositories/reaction-repository.js.map +1 -1
  184. package/lib/templates/constants/SERVER_TYPES.ts.template +4 -4
  185. package/lib/templates/repositories/AiFragmentRepository.ts.template +4 -0
  186. package/lib/templates/repositories/ChannelRepository.ts.template +3 -3
  187. package/lib/templates/repositories/PostRepository.ts.template +3 -3
  188. package/lib/templates/repositories/PostThreadRepository.ts.template +3 -3
  189. package/lib/templates/repositories/ReactionRepository.ts.template +3 -4
  190. package/lib/templates/services/AiFragmentService.ts.template +123 -0
  191. package/lib/templates/services/ChannelService.ts.template +290 -39
  192. package/lib/templates/services/ExtendedTokenAccountService.ts.template +104 -9
  193. package/lib/templates/services/MessengerNotificationService.ts.template +94 -19
  194. package/lib/templates/services/PostService.ts.template +265 -20
  195. package/lib/templates/services/PostThreadService.ts.template +151 -6
  196. package/lib/templates/services/ReactionService.ts.template +129 -3
  197. package/lib/templates/services/RedisCacheManager.ts.template +22 -0
  198. package/lib/templates/services/SandboxErrorService.ts.template +125 -0
  199. package/package.json +14 -7
  200. package/lib/interfaces/context.d.ts +0 -14
  201. package/lib/store/models/common-options.js +0 -20
  202. package/lib/store/models/common-options.js.map +0 -1
@@ -1,4 +1,3 @@
1
- import { IReaction, IReactionInput } from 'common';
2
- import { IBaseRepository } from '@common-stack/store-mongo';
3
-
4
- export type IReactionRepository = IBaseRepository<IReaction, IReactionInput>;
1
+ import { IReactionInput,IBaseMongoRepository,IReactionModel } from 'common/server';
2
+ //export type IReactionRepository = IBaseRepository<IReaction, IReactionInput>;
3
+ export type IReactionRepository = IBaseMongoRepository<IReactionModel>;
@@ -0,0 +1,123 @@
1
+ /**
2
+ * AI Fragment Service Interface
3
+ * ----------------------------
4
+ *
5
+ * This interface defines the business logic layer for AI fragment management within
6
+ * the messenger platform. It provides a comprehensive set of operations for
7
+ * handling AI-generated code fragments, sandbox management, and file synchronization.
8
+ *
9
+ * Key capabilities:
10
+ * - AI fragment creation and management
11
+ * - Sandbox URL management
12
+ * - File version control and synchronization
13
+ * - Canvas layer support
14
+ * - Template-based fragment generation
15
+ * - Organization and user-based fragment retrieval
16
+ */
17
+
18
+ import { IAiFragmentModel, IBaseService, AsDomainType, Disposable, IAiFragmentCreateInput, IAiFragmentUpdateInput, AiFragmentSyncStatus } from 'common/server';
19
+
20
+
21
+
22
+ export interface AgentState {
23
+ summary: string;
24
+ files: { [path: string]: string };
25
+ canvasLayers?: any[];
26
+ }
27
+
28
+ export interface IAiFragmentService extends IBaseService<IAiFragmentModel>, Disposable {
29
+ /**
30
+ * Creates a new AI fragment with the specified parameters
31
+ *
32
+ * @param {IAiFragmentCreateInput} input - The fragment creation data
33
+ * @returns {Promise<AsDomainType<IAiFragmentModel>>}
34
+ */
35
+ createFragment(input: IAiFragmentCreateInput): Promise<AsDomainType<IAiFragmentModel>>;
36
+
37
+ /**
38
+ * Retrieves an AI fragment by its message ID
39
+ *
40
+ * @param {string} messageId - The message ID to search for
41
+ * @returns {Promise<AsDomainType<IAiFragmentModel> | null>}
42
+ */
43
+ getFragmentByMessageId(messageId: string): Promise<AsDomainType<IAiFragmentModel> | null>;
44
+
45
+ /**
46
+ * Retrieves AI fragments for a specific user and organization
47
+ *
48
+ * @param {string} orgName - Organization name
49
+ * @param {string} owner - Owner identifier
50
+ * @param {number} [limit=20] - Maximum number of fragments to return
51
+ * @param {number} [skip=0] - Number of fragments to skip
52
+ * @returns {Promise<AsDomainType<IAiFragmentModel>[]>}
53
+ */
54
+ getFragmentsByUser(orgName: string, owner: string, limit?: number, skip?: number): Promise<AsDomainType<IAiFragmentModel>[]>;
55
+
56
+ /**
57
+ * Updates the files associated with a fragment
58
+ *
59
+ * @param {string} messageId - The message ID of the fragment to update
60
+ * @param {Record<string, any>} files - The new files data
61
+ * @returns {Promise<AsDomainType<IAiFragmentModel> | null>}
62
+ */
63
+ updateFragmentFiles(messageId: string, files: Record<string, any>): Promise<AsDomainType<IAiFragmentModel> | null>;
64
+
65
+ /**
66
+ * Deletes an AI fragment by its ID
67
+ *
68
+ * @param {string} id - The fragment ID to delete
69
+ * @returns {Promise<boolean>}
70
+ */
71
+ deleteFragment(id: string): Promise<boolean>;
72
+
73
+ /**
74
+ * Deletes an AI fragment by its message ID
75
+ *
76
+ * @param {string} messageId - The message ID of the fragment to delete
77
+ * @returns {Promise<boolean>}
78
+ */
79
+ deleteFragmentByMessageId(messageId: string): Promise<boolean>;
80
+
81
+ /**
82
+ * Retrieves an AI fragment by its ID
83
+ *
84
+ * @param {string} fragmentId - The fragment ID to retrieve
85
+ * @returns {Promise<AsDomainType<IAiFragmentModel> | null>}
86
+ */
87
+ getFragmentById(fragmentId: string): Promise<AsDomainType<IAiFragmentModel> | null>;
88
+
89
+ /**
90
+ * Updates the sandbox URL for a fragment
91
+ *
92
+ * @param {string} fragmentId - The fragment ID to update
93
+ * @param {string} newSandboxUrl - The new sandbox URL
94
+ * @returns {Promise<AsDomainType<IAiFragmentModel> | null>}
95
+ */
96
+ updateSandboxUrl(fragmentId: string, newSandboxUrl: string): Promise<AsDomainType<IAiFragmentModel> | null>;
97
+
98
+ /**
99
+ * Updates file synchronization status and versions
100
+ *
101
+ * @param {string} fragmentId - The fragment ID to update
102
+ * @param {Record<string, number>} fileVersions - File version mapping
103
+ * @param {AiFragmentSyncStatus} syncStatus - Current synchronization status
104
+ * @returns {Promise<AsDomainType<IAiFragmentModel> | null>}
105
+ */
106
+ updateFileSync(fragmentId: string, fileVersions: Record<string, number>, syncStatus: AiFragmentSyncStatus): Promise<AsDomainType<IAiFragmentModel> | null>;
107
+
108
+ /**
109
+ * Updates both files and synchronization status in a single operation
110
+ *
111
+ * @param {string} messageId - The message ID of the fragment to update
112
+ * @param {Record<string, any>} files - The new files data
113
+ * @param {Record<string, number>} fileVersions - File version mapping
114
+ * @param {AiFragmentSyncStatus} syncStatus - Current synchronization status
115
+ * @returns {Promise<AsDomainType<IAiFragmentModel> | null>}
116
+ */
117
+ updateFilesAndSync(messageId: string, files: Record<string, any>, fileVersions: Record<string, number>, syncStatus: AiFragmentSyncStatus): Promise<AsDomainType<IAiFragmentModel> | null>;
118
+
119
+ /**
120
+ * Disposes of resources used by the service
121
+ */
122
+ dispose(): void;
123
+ }
@@ -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, IChannelInput } from 'common/server';
4
26
 
5
27
  export interface INotificationProps {
6
28
  desktopNotifyProp: boolean;
@@ -18,38 +40,40 @@ 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;
56
+ projectId?: any;
33
57
  }
34
58
 
35
- export interface IAddMemberParams extends Omit<IChannel, 'channelId' | 'memberId'> {
59
+ export interface IAddMemberParams extends Omit<IChannelModel, 'channelId' | 'memberId'> {
36
60
  memberId: string;
37
61
  channelId: string;
38
62
  }
39
63
 
40
- export interface ISavePublicChannelParams extends Omit<IChannel, 'creator' | 'id' | 'orgName' | 'team'> {
64
+ export interface ISavePublicChannelParams extends Omit<IChannelModel, 'creator' | '_id' | 'orgName' | 'organization' | 'team'> {
41
65
  _id?: any;
42
66
  type: RoomType.Public;
43
67
  title: string;
44
68
  }
45
69
 
46
-
47
70
  export interface ICreateDirectChannelParams {
48
71
  sender: string;
49
72
  receiver: string[];
50
73
  displayName: string;
51
74
  channelOptions?: Record<string, unknown>;
52
75
  orgName?: string;
76
+ organization: any;
53
77
  }
54
78
 
55
79
  export interface ISaveMembersToChannelParams {
@@ -57,88 +81,315 @@ export interface ISaveMembersToChannelParams {
57
81
  channelId: string;
58
82
  }
59
83
 
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'>> {
84
+ // Based on https://github.com/mattermost/mattermost-server/blob/master/store/sqlstore/channel_store.go
85
+ export interface IChannelService extends IBaseService<IChannelModel>, Disposable {
62
86
  /**
63
- * @description Direct channel don't need team reference.
64
- * @param data
87
+ * Creates a direct channel between users
88
+ *
89
+ * @description Direct channels don't need team reference and are used for
90
+ * private conversations between specific users.
91
+ *
92
+ * @param {ICreateDirectChannelParams} data - The direct channel creation parameters
93
+ * @returns {Promise<AsDomainType<IChannelModel> | Error>} - The created channel or error
65
94
  */
66
- createDirectChannel(data: ICreateDirectChannelParams): Promise<IChannel | Error>;
95
+ createDirectChannel(data: ICreateDirectChannelParams): Promise<AsDomainType<IChannelModel> | Error>;
67
96
 
97
+ /**
98
+ * Checks if a user is a member of a specific channel
99
+ *
100
+ * @param {string} channelId - The ID of the channel to check
101
+ * @param {string} user - The ID of the user
102
+ * @returns {Promise<boolean>} - True if the user is a member
103
+ */
68
104
  isMember(channelId: string, user: string): Promise<boolean>;
69
105
 
70
- addMemberToChannel(channelId: string, memberId: string): Promise<IChannel | Error>;
106
+ /**
107
+ * Adds a single member to a channel
108
+ *
109
+ * @param {string} channelId - The ID of the channel
110
+ * @param {string} memberId - The ID of the member to add
111
+ * @returns {Promise<AsDomainType<IChannelModel> | Error>} - The updated channel or error
112
+ */
113
+ addMemberToChannel(channelId: string, memberId: string): Promise<AsDomainType<IChannelModel> | Error>;
71
114
 
72
- saveMembersToChannel(data: ISaveMembersToChannelParams): Promise<IChannel | Error>;
115
+ /**
116
+ * Adds multiple members to a channel in a single operation
117
+ *
118
+ * @param {ISaveMembersToChannelParams} data - The members and channel data
119
+ * @returns {Promise<AsDomainType<IChannelModel> | Error>} - The updated channel or error
120
+ */
121
+ saveMembersToChannel(data: ISaveMembersToChannelParams): Promise<AsDomainType<IChannelModel> | Error>;
73
122
 
74
- saveDirectChannel(channel: ISaveDirectChannelParams): Promise<IChannel | Error>;
123
+ /**
124
+ * Creates and saves a direct channel
125
+ *
126
+ * @param {ISaveDirectChannelParams} channel - The direct channel parameters
127
+ * @returns {Promise<AsDomainType<IChannelModel> | Error>} - The created channel or error
128
+ */
129
+ saveDirectChannel(channel: ISaveDirectChannelParams): Promise<AsDomainType<IChannelModel> | Error>;
75
130
 
76
- saveChannel(data: ISaveChannelParams): Promise<IChannel | Error>;
131
+ /**
132
+ * Creates and saves a team-based channel
133
+ *
134
+ * @param {ISaveChannelParams} data - The channel creation parameters
135
+ * @returns {Promise<AsDomainType<IChannelModel> | Error>} - The created channel or error
136
+ */
137
+ saveChannel(data: ISaveChannelParams): Promise<AsDomainType<IChannelModel> | Error>;
77
138
 
78
- savePublicChannel(data: ISavePublicChannelParams): Promise<IChannel | Error>;
139
+ /**
140
+ * Creates and saves a public channel
141
+ *
142
+ * @param {ISavePublicChannelParams} data - The public channel parameters
143
+ * @returns {Promise<AsDomainType<IChannelModel> | Error>} - The created channel or error
144
+ */
145
+ savePublicChannel(data: ISavePublicChannelParams): Promise<AsDomainType<IChannelModel> | Error>;
79
146
 
147
+ /**
148
+ * Retrieves unread message information for a user in a channel
149
+ *
150
+ * @param {string} channelId - The ID of the channel
151
+ * @param {string} userId - The ID of the user
152
+ * @returns {Promise<IChannelUnread | Error>} - Unread information or error
153
+ */
80
154
  getChannelUnread(channelId: string, userId: string): Promise<IChannelUnread | Error>;
81
155
 
156
+ /**
157
+ * Invalidates cached channel data by name
158
+ *
159
+ * @param {string} teamId - The ID of the team
160
+ * @param {string} name - The name of the channel
161
+ * @returns {Promise<void>} - Void promise when complete
162
+ */
82
163
  invalidateChannelByName(teamId: string, name: string): Promise<void>;
83
164
 
165
+ /**
166
+ * Retrieves all pinned posts from a channel
167
+ *
168
+ * @param {string} channelId - The ID of the channel
169
+ * @returns {Promise<IPost[] | Error>} - Array of pinned posts or error
170
+ */
84
171
  getPinnedPosts(channelId: string): Promise<IPost[] | Error>;
85
172
 
86
- getFromMaster(id: string): Promise<IChannel | Error>;
173
+ /**
174
+ * Retrieves a channel from the master database
175
+ *
176
+ * @param {string} id - The ID of the channel
177
+ * @returns {Promise<AsDomainType<IChannelModel> | Error>} - The channel or error
178
+ */
179
+ getFromMaster(id: string): Promise<AsDomainType<IChannelModel> | Error>;
87
180
 
88
- restore(channelId: string, time: Date);
181
+ /**
182
+ * Restores a previously deleted channel
183
+ *
184
+ * @param {string} channelId - The ID of the channel to restore
185
+ * @param {Date} time - The restoration timestamp
186
+ * @returns {Promise<void>} - Void promise when complete
187
+ */
188
+ restore(channelId: string, time: Date): Promise<void>;
89
189
 
90
190
  /**
91
- * @description remove all channels for the given team from the database.
92
- * @param teamId
191
+ * Permanently removes all channels for a given team
192
+ *
193
+ * @description Removes all channels associated with a team from the database.
194
+ * This operation cannot be undone.
195
+ *
196
+ * @param {string} teamId - The ID of the team
197
+ * @returns {Promise<void | Error>} - Void promise or error
93
198
  */
94
- permanentDeleteByTeam(teamId: string): void | Error;
199
+ permanentDeleteByTeam(teamId: string): Promise<void | Error>;
95
200
 
96
201
  /**
97
- * @description removes the given channel
98
- * @param channelId
202
+ * Permanently removes a specific channel
203
+ *
204
+ * @description Completely removes the channel from the database.
205
+ * This operation cannot be undone.
206
+ *
207
+ * @param {string} channelId - The ID of the channel to delete
208
+ * @returns {Promise<void | Error>} - Void promise or error
99
209
  */
100
- permanentDelete(channelId: string): void | Error;
210
+ permanentDelete(channelId: string): Promise<void | Error>;
101
211
 
102
- permanentDeleteMembersByChannel(channelId: string): void | Error;
212
+ /**
213
+ * Permanently removes all members from a channel
214
+ *
215
+ * @param {string} channelId - The ID of the channel
216
+ * @returns {Promise<void | Error>} - Void promise or error
217
+ */
218
+ permanentDeleteMembersByChannel(channelId: string): Promise<void | Error>;
103
219
 
220
+ /**
221
+ * Retrieves channels for a team with filtering options
222
+ *
223
+ * @param {string} teamId - The ID of the team
224
+ * @param {string} userId - The ID of the user
225
+ * @param {boolean} includeDeleted - Whether to include deleted channels
226
+ * @param {number} lastDeleteAt - Timestamp filter for deletions
227
+ * @param {string} orgId - The organization ID
228
+ * @returns {Promise<Array<AsDomainType<IChannelModel>> | Error>} - Array of channels or error
229
+ */
104
230
  getChannels(
105
231
  teamId: string,
106
232
  userId: string,
107
233
  includeDeleted: boolean,
108
234
  lastDeleteAt: number,
109
235
  orgId: string,
110
- ): Promise<IChannel[] | Error>;
236
+ ): Promise<Array<AsDomainType<IChannelModel>> | Error>;
111
237
 
112
- getMoreChannels(teamId: string, userId: string, offset: number, limit: number): Promise<IChannel[] | Error>;
238
+ /**
239
+ * Retrieves additional channels with pagination
240
+ *
241
+ * @param {string} teamId - The ID of the team
242
+ * @param {string} userId - The ID of the user
243
+ * @param {number} offset - Number of items to skip
244
+ * @param {number} limit - Maximum number of items to return
245
+ * @returns {Promise<Array<AsDomainType<IChannelModel>> | Error>} - Array of channels or error
246
+ */
247
+ getMoreChannels(teamId: string, userId: string, offset: number, limit: number): Promise<Array<AsDomainType<IChannelModel>> | Error>;
113
248
 
114
- getPrivateChannelsForTeam(teamId: string, offset: number, limit: number): Promise<IChannel[] | Error>;
249
+ /**
250
+ * Retrieves private channels for a team with pagination
251
+ *
252
+ * @param {string} teamId - The ID of the team
253
+ * @param {number} offset - Number of items to skip
254
+ * @param {number} limit - Maximum number of items to return
255
+ * @returns {Promise<Array<AsDomainType<IChannelModel>> | Error>} - Array of private channels or error
256
+ */
257
+ getPrivateChannelsForTeam(teamId: string, offset: number, limit: number): Promise<Array<AsDomainType<IChannelModel>> | Error>;
115
258
 
116
- getPublicChannelsForTeam(teamId: string, offset: number, limit: number): Promise<IChannel[] | Error>;
259
+ /**
260
+ * Retrieves public channels for a team with pagination
261
+ *
262
+ * @param {string} teamId - The ID of the team
263
+ * @param {number} offset - Number of items to skip
264
+ * @param {number} limit - Maximum number of items to return
265
+ * @returns {Promise<Array<AsDomainType<IChannelModel>> | Error>} - Array of public channels or error
266
+ */
267
+ getPublicChannelsForTeam(teamId: string, offset: number, limit: number): Promise<Array<AsDomainType<IChannelModel>> | Error>;
117
268
 
118
- getPublicChannelsByIdsForTeam(teamId: string, channelsIds: string[]): Promise<IChannel[] | Error>;
269
+ /**
270
+ * Retrieves specific public channels by their IDs
271
+ *
272
+ * @param {string} teamId - The ID of the team
273
+ * @param {string[]} channelsIds - Array of channel IDs to retrieve
274
+ * @returns {Promise<Array<AsDomainType<IChannelModel>> | Error>} - Array of channels or error
275
+ */
276
+ getPublicChannelsByIdsForTeam(teamId: string, channelsIds: string[]): Promise<Array<AsDomainType<IChannelModel>> | Error>;
119
277
 
278
+ /**
279
+ * Retrieves channel count statistics for a team
280
+ *
281
+ * @param {string} teamId - The ID of the team
282
+ * @param {string} userId - The ID of the user
283
+ * @returns {Promise<any | Error>} - Channel count data or error
284
+ */
120
285
  getChannelCounts(teamId: string, userId: string): Promise<any | Error>;
121
286
 
122
- getTeamChannels(teamId: string): Promise<IChannel[] | Error>;
287
+ /**
288
+ * Retrieves all channels belonging to a team
289
+ *
290
+ * @param {string} teamId - The ID of the team
291
+ * @returns {Promise<Array<AsDomainType<IChannelModel>> | Error>} - Array of team channels or error
292
+ */
293
+ getTeamChannels(teamId: string): Promise<Array<AsDomainType<IChannelModel>> | Error>;
123
294
 
124
- // getByName(teamId: string, name: string): Promise<IChannel | Error>;
125
- getByName(name: string): Promise<IChannel>;
295
+ /**
296
+ * Retrieves a channel by its name
297
+ *
298
+ * @param {string} name - The name of the channel
299
+ * @returns {Promise<AsDomainType<IChannelModel> | null>} - The channel or null if not found
300
+ */
301
+ getByName(name: string): Promise<AsDomainType<IChannelModel> | null>;
126
302
 
127
- getByNames(teamId: string, names: string[]): Promise<IChannel[] | Error>;
303
+ /**
304
+ * Retrieves multiple channels by their names
305
+ *
306
+ * @param {string} teamId - The ID of the team
307
+ * @param {string[]} names - Array of channel names
308
+ * @returns {Promise<Array<AsDomainType<IChannelModel>> | Error>} - Array of channels or error
309
+ */
310
+ getByNames(teamId: string, names: string[]): Promise<Array<AsDomainType<IChannelModel>> | Error>;
128
311
 
129
- getByNameIncludeDeleted(teamId: string, name: string): Promise<IChannel | Error>;
312
+ /**
313
+ * Retrieves a channel by name including deleted channels
314
+ *
315
+ * @param {string} teamId - The ID of the team
316
+ * @param {string} name - The name of the channel
317
+ * @returns {Promise<AsDomainType<IChannelModel> | Error>} - The channel or error
318
+ */
319
+ getByNameIncludeDeleted(teamId: string, name: string): Promise<AsDomainType<IChannelModel> | Error>;
130
320
 
131
- getDeletedByName(teamId: string, name: string): Promise<IChannel | Error>;
321
+ /**
322
+ * Retrieves a deleted channel by name
323
+ *
324
+ * @param {string} teamId - The ID of the team
325
+ * @param {string} name - The name of the deleted channel
326
+ * @returns {Promise<AsDomainType<IChannelModel> | Error>} - The deleted channel or error
327
+ */
328
+ getDeletedByName(teamId: string, name: string): Promise<AsDomainType<IChannelModel> | Error>;
132
329
 
133
- getDeleted(teamId: string, offset: number, limit: number, userId: string): Promise<IChannel[] | Error>;
330
+ /**
331
+ * Retrieves deleted channels with pagination
332
+ *
333
+ * @param {string} teamId - The ID of the team
334
+ * @param {number} offset - Number of items to skip
335
+ * @param {number} limit - Maximum number of items to return
336
+ * @param {string} userId - The ID of the user
337
+ * @returns {Promise<Array<AsDomainType<IChannelModel>> | Error>} - Array of deleted channels or error
338
+ */
339
+ getDeleted(teamId: string, offset: number, limit: number, userId: string): Promise<Array<AsDomainType<IChannelModel>> | Error>;
134
340
 
341
+ /**
342
+ * Saves multiple members to the system
343
+ *
344
+ * @param {IUserAccount[]} members - Array of user accounts to save
345
+ * @returns {Promise<IUserAccount[] | Error>} - Array of saved user accounts or error
346
+ */
135
347
  saveMultipleMembers(members: IUserAccount[]): Promise<IUserAccount[] | Error>;
136
348
 
349
+ /**
350
+ * Hides a channel from the user's view
351
+ *
352
+ * @param {string} id - The ID of the channel to hide
353
+ * @returns {Promise<boolean>} - True if successful
354
+ */
137
355
  hideChannel(id: string): Promise<boolean>;
138
356
 
357
+ /**
358
+ * Removes the current user from a channel
359
+ *
360
+ * @param {string} id - The ID of the channel to leave
361
+ * @returns {Promise<boolean>} - True if successful
362
+ */
139
363
  leaveChannel(id: string): Promise<boolean>;
140
364
 
365
+ /**
366
+ * Soft deletes a channel (marks as deleted)
367
+ *
368
+ * @param {string} id - The ID of the channel to delete
369
+ * @returns {Promise<boolean | Error>} - True if successful or error
370
+ */
141
371
  deleteChannel(id: string): Promise<boolean | Error>;
142
372
 
373
+ /**
374
+ * Marks a channel as viewed by a user
375
+ *
376
+ * @param {string} id - The ID of the channel
377
+ * @param {string} user - The ID of the user
378
+ * @returns {Promise<boolean>} - True if successful
379
+ */
143
380
  viewChannel(id: string, user: string): Promise<boolean>;
381
+
382
+ /**
383
+ * Creates a channel with a project ID
384
+ *
385
+ * @param {string} projectId - The ID of the project
386
+ * @param {string} value - The value of the channel
387
+ * @returns {Promise<boolean>} - True if successful
388
+ */
389
+ createChannelWithProjectId(projectId: string, channelInput: IChannelInput): Promise<boolean>;
390
+
391
+ /**
392
+ * Disposes of resources used by the service
393
+ */
394
+ dispose(): void;
144
395
  }
@@ -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
  }