@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,10 +1,141 @@
1
1
  import { ServiceBroker } from 'moleculer';
2
2
  import { ILogger } from '@cdm-logger/core/lib/interface';
3
- import { MoleculerTopics as MoleculerTopics, IPostThread, IPostThreadService } from 'common';
3
+ import { MoleculerTopics as MoleculerTopics, IPostThreadModel, IPostThreadService, IPostThreadServiceInput, AsDomainType } from 'common/server';
4
4
  import { BaseProxyService } from '@common-stack/store-mongo';
5
- export declare class PostThreadMicroservice extends BaseProxyService<IPostThread, Omit<IPostThread, 'id'>> implements IPostThreadService {
5
+ import { Disposable, DisposableCollection } from '@adminide-stack/core';
6
+ /**
7
+ * Post Thread Microservice Implementation
8
+ *
9
+ * This microservice handles post thread management within the messenger platform,
10
+ * providing comprehensive operations for handling threaded conversations,
11
+ * reply management, and discussion organization across different channels
12
+ * and messaging contexts through service broker delegation.
13
+ */
14
+ export declare class PostThreadMicroservice extends BaseProxyService<IPostThreadModel, Omit<IPostThreadModel, 'id'>> implements IPostThreadService, Disposable {
15
+ protected readonly toDispose: DisposableCollection;
6
16
  protected logger?: ILogger;
7
17
  topic: MoleculerTopics;
8
18
  constructor(broker: ServiceBroker, logger: ILogger);
9
- getPostThread(data: any): Promise<IPostThread>;
19
+ /**
20
+ * Disposes of resources used by the service
21
+ */
22
+ dispose(): void;
23
+ /**
24
+ * Creates a new post thread
25
+ *
26
+ * @description Creates a post thread with proper validation and error handling
27
+ * through microservice delegation
28
+ *
29
+ * @param {IPostThreadServiceInput} data - Thread creation data
30
+ * @returns {Promise<AsDomainType<IPostThreadModel> | Error>} - Created thread or error
31
+ */
32
+ create(data: IPostThreadServiceInput): Promise<AsDomainType<IPostThreadModel> | Error>;
33
+ /**
34
+ * Retrieves a specific post thread with its metadata
35
+ *
36
+ * @description Fetches a complete post thread including all replies,
37
+ * participant information, and thread statistics for display and interaction.
38
+ *
39
+ * @param {any} data - Thread query parameters and filters
40
+ * @returns {Promise<AsDomainType<IPostThreadModel> | Error>} - Post thread data or error
41
+ */
42
+ getPostThread(data: any): Promise<AsDomainType<IPostThreadModel> | Error>;
43
+ /**
44
+ * Retrieves the total count of posts within a thread
45
+ *
46
+ * @description Calculates and returns the number of posts/replies
47
+ * within a specific thread for pagination and display purposes.
48
+ *
49
+ * @param {any} data - Thread identification and counting parameters
50
+ * @returns {Promise<number | Error>} - Thread post count or error
51
+ */
52
+ getPostThreadCount(data: any): Promise<number | Error>;
53
+ /**
54
+ * Gets threads by post ID
55
+ *
56
+ * @description Retrieves all threads associated with a specific post
57
+ *
58
+ * @param {string} postId - The post identifier
59
+ * @returns {Promise<Array<AsDomainType<IPostThreadModel>> | Error>} - Array of threads or error
60
+ */
61
+ getThreadsByPost(postId: string): Promise<Array<AsDomainType<IPostThreadModel>> | Error>;
62
+ /**
63
+ * Gets threads by channel
64
+ *
65
+ * @description Retrieves all threads within a specific channel
66
+ *
67
+ * @param {string} channelId - The channel identifier
68
+ * @param {number} limit - Maximum number of threads to return
69
+ * @param {number} offset - Number of threads to skip
70
+ * @returns {Promise<Array<AsDomainType<IPostThreadModel>> | Error>} - Array of threads or error
71
+ */
72
+ getThreadsByChannel(channelId: string, limit?: number, offset?: number): Promise<Array<AsDomainType<IPostThreadModel>> | Error>;
73
+ /**
74
+ * Updates a post thread
75
+ *
76
+ * @description Updates thread metadata and properties
77
+ *
78
+ * @param {string} threadId - The thread identifier
79
+ * @param {Partial<IPostThreadServiceInput>} updates - Update data
80
+ * @returns {Promise<AsDomainType<IPostThreadModel> | Error>} - Updated thread or error
81
+ */
82
+ updateThread(threadId: string, updates: Partial<IPostThreadServiceInput>): Promise<AsDomainType<IPostThreadModel> | Error>;
83
+ /**
84
+ * Deletes a post thread
85
+ *
86
+ * @description Soft deletes a thread and its associated data
87
+ *
88
+ * @param {string} threadId - The thread identifier
89
+ * @returns {Promise<boolean | Error>} - Success status or error
90
+ */
91
+ deleteThread(threadId: string): Promise<boolean | Error>;
92
+ /**
93
+ * Gets thread participants
94
+ *
95
+ * @description Retrieves all participants in a thread
96
+ *
97
+ * @param {string} threadId - The thread identifier
98
+ * @returns {Promise<Array<string> | Error>} - Array of participant IDs or error
99
+ */
100
+ getThreadParticipants(threadId: string): Promise<Array<string> | Error>;
101
+ /**
102
+ * Adds a participant to a thread
103
+ *
104
+ * @description Adds a user to thread participants
105
+ *
106
+ * @param {string} threadId - The thread identifier
107
+ * @param {string} userId - The user identifier to add
108
+ * @returns {Promise<boolean | Error>} - Success status or error
109
+ */
110
+ addParticipant(threadId: string, userId: string): Promise<boolean | Error>;
111
+ /**
112
+ * Removes a participant from a thread
113
+ *
114
+ * @description Removes a user from thread participants
115
+ *
116
+ * @param {string} threadId - The thread identifier
117
+ * @param {string} userId - The user identifier to remove
118
+ * @returns {Promise<boolean | Error>} - Success status or error
119
+ */
120
+ removeParticipant(threadId: string, userId: string): Promise<boolean | Error>;
121
+ /**
122
+ * Validates thread data for creation or updates
123
+ *
124
+ * @description Helper method to validate thread data before processing
125
+ *
126
+ * @param {any} data - Data to validate
127
+ * @returns {Promise<boolean | Error>} - Validation result or error
128
+ */
129
+ validateThreadData(data: any): Promise<boolean | Error>;
130
+ /**
131
+ * Gets active threads for a user
132
+ *
133
+ * @description Convenience method to get threads where a user is participating
134
+ *
135
+ * @param {string} userId - The user identifier
136
+ * @param {number} limit - Maximum number of threads to return
137
+ * @param {number} offset - Number of threads to skip
138
+ * @returns {Promise<Array<AsDomainType<IPostThreadModel>> | Error>} - Array of active threads or error
139
+ */
140
+ getActiveThreadsForUser(userId: string, limit?: number, offset?: number): Promise<Array<AsDomainType<IPostThreadModel>> | Error>;
10
141
  }
@@ -1,15 +1,397 @@
1
- import {__decorate,__param,__metadata}from'tslib';import {injectable,inject}from'inversify';import {ServiceBroker}from'moleculer';import {CommonType}from'@common-stack/core';import {MoleculerTopics,PostThreadServiceCommands}from'common';import {BaseProxyService}from'@common-stack/store-mongo';let PostThreadMicroservice = class PostThreadMicroservice extends BaseProxyService {
1
+ import {__decorate,__param,__metadata}from'tslib';import {injectable,inject}from'inversify';import {ServiceBroker}from'moleculer';import {CommonType}from'@common-stack/core';import {MoleculerTopics,PostThreadServiceCommands}from'common/server';import {BaseProxyService}from'@common-stack/store-mongo';import {DisposableCollection}from'@adminide-stack/core';/**
2
+ * Post Thread Microservice Implementation
3
+ *
4
+ * This microservice handles post thread management within the messenger platform,
5
+ * providing comprehensive operations for handling threaded conversations,
6
+ * reply management, and discussion organization across different channels
7
+ * and messaging contexts through service broker delegation.
8
+ */
9
+ let PostThreadMicroservice = class PostThreadMicroservice extends BaseProxyService {
10
+ toDispose = new DisposableCollection();
2
11
  logger;
3
12
  topic = MoleculerTopics.PostThreadService;
4
13
  constructor(broker, logger) {
5
14
  super(broker, logger.child({
6
15
  className: 'PostThreadMicroservice'
7
16
  }));
8
- }
9
- getPostThread(data) {
10
- return this.callAction(PostThreadServiceCommands.GetPostThread, {
11
- data
17
+ this.logger = logger.child({
18
+ className: 'PostThreadMicroservice'
12
19
  });
13
20
  }
21
+ /**
22
+ * Disposes of resources used by the service
23
+ */
24
+ dispose() {
25
+ this.toDispose.dispose();
26
+ }
27
+ /**
28
+ * Creates a new post thread
29
+ *
30
+ * @description Creates a post thread with proper validation and error handling
31
+ * through microservice delegation
32
+ *
33
+ * @param {IPostThreadServiceInput} data - Thread creation data
34
+ * @returns {Promise<AsDomainType<IPostThreadModel> | Error>} - Created thread or error
35
+ */
36
+ // @ts-ignore - Enhanced error handling pattern with Error union type
37
+ async create(data) {
38
+ try {
39
+ this.logger?.debug('Creating post thread via microservice', {
40
+ data
41
+ });
42
+ const result = await this.broker.call(`${this.topic}.create`, {
43
+ data
44
+ });
45
+ if (!result) {
46
+ return new Error('Failed to create post thread');
47
+ }
48
+ this.logger?.debug('Post thread created successfully via microservice', {
49
+ threadId: result.id
50
+ });
51
+ return result;
52
+ } catch (error) {
53
+ this.logger?.error('Error creating post thread via microservice: %o', error);
54
+ return error instanceof Error ? error : new Error('Unknown error occurred while creating thread');
55
+ }
56
+ }
57
+ /**
58
+ * Retrieves a specific post thread with its metadata
59
+ *
60
+ * @description Fetches a complete post thread including all replies,
61
+ * participant information, and thread statistics for display and interaction.
62
+ *
63
+ * @param {any} data - Thread query parameters and filters
64
+ * @returns {Promise<AsDomainType<IPostThreadModel> | Error>} - Post thread data or error
65
+ */
66
+ async getPostThread(data) {
67
+ try {
68
+ this.logger?.debug('Getting post thread via microservice', {
69
+ data
70
+ });
71
+ const result = await this.callAction(PostThreadServiceCommands.GetPostThread, {
72
+ data
73
+ });
74
+ if (!result) {
75
+ return new Error('Post thread not found');
76
+ }
77
+ this.logger?.debug('Post thread retrieved successfully via microservice', {
78
+ threadId: result.id
79
+ });
80
+ return result;
81
+ } catch (error) {
82
+ this.logger?.error('Error getting post thread via microservice: %o', error);
83
+ return error instanceof Error ? error : new Error('Unknown error occurred while getting thread');
84
+ }
85
+ }
86
+ /**
87
+ * Retrieves the total count of posts within a thread
88
+ *
89
+ * @description Calculates and returns the number of posts/replies
90
+ * within a specific thread for pagination and display purposes.
91
+ *
92
+ * @param {any} data - Thread identification and counting parameters
93
+ * @returns {Promise<number | Error>} - Thread post count or error
94
+ */
95
+ async getPostThreadCount(data) {
96
+ try {
97
+ this.logger?.debug('Getting post thread count via microservice', {
98
+ data
99
+ });
100
+ const result = await this.callAction(PostThreadServiceCommands.GetPostThreadCount, {
101
+ data
102
+ });
103
+ if (typeof result !== 'number') {
104
+ return new Error('Invalid count result from microservice');
105
+ }
106
+ this.logger?.debug('Post thread count retrieved successfully via microservice', {
107
+ count: result
108
+ });
109
+ return result;
110
+ } catch (error) {
111
+ this.logger?.error('Error getting post thread count via microservice: %o', error);
112
+ return error instanceof Error ? error : new Error('Unknown error occurred while counting threads');
113
+ }
114
+ }
115
+ /**
116
+ * Gets threads by post ID
117
+ *
118
+ * @description Retrieves all threads associated with a specific post
119
+ *
120
+ * @param {string} postId - The post identifier
121
+ * @returns {Promise<Array<AsDomainType<IPostThreadModel>> | Error>} - Array of threads or error
122
+ */
123
+ async getThreadsByPost(postId) {
124
+ try {
125
+ this.logger?.debug('Getting threads by post via microservice', {
126
+ postId
127
+ });
128
+ const result = await this.broker.call(`${this.topic}.getThreadsByPost`, {
129
+ postId
130
+ });
131
+ if (!Array.isArray(result)) {
132
+ return new Error('Invalid result from microservice');
133
+ }
134
+ this.logger?.debug('Threads by post retrieved successfully via microservice', {
135
+ postId,
136
+ count: result.length
137
+ });
138
+ return result;
139
+ } catch (error) {
140
+ this.logger?.error('Error getting threads by post via microservice: %o', error);
141
+ return error instanceof Error ? error : new Error('Unknown error occurred while getting threads by post');
142
+ }
143
+ }
144
+ /**
145
+ * Gets threads by channel
146
+ *
147
+ * @description Retrieves all threads within a specific channel
148
+ *
149
+ * @param {string} channelId - The channel identifier
150
+ * @param {number} limit - Maximum number of threads to return
151
+ * @param {number} offset - Number of threads to skip
152
+ * @returns {Promise<Array<AsDomainType<IPostThreadModel>> | Error>} - Array of threads or error
153
+ */
154
+ async getThreadsByChannel(channelId, limit = 50, offset = 0) {
155
+ try {
156
+ this.logger?.debug('Getting threads by channel via microservice', {
157
+ channelId,
158
+ limit,
159
+ offset
160
+ });
161
+ const result = await this.broker.call(`${this.topic}.getThreadsByChannel`, {
162
+ channelId,
163
+ limit,
164
+ offset
165
+ });
166
+ if (!Array.isArray(result)) {
167
+ return new Error('Invalid result from microservice');
168
+ }
169
+ this.logger?.debug('Threads by channel retrieved successfully via microservice', {
170
+ channelId,
171
+ count: result.length
172
+ });
173
+ return result;
174
+ } catch (error) {
175
+ this.logger?.error('Error getting threads by channel via microservice: %o', error);
176
+ return error instanceof Error ? error : new Error('Unknown error occurred while getting threads by channel');
177
+ }
178
+ }
179
+ /**
180
+ * Updates a post thread
181
+ *
182
+ * @description Updates thread metadata and properties
183
+ *
184
+ * @param {string} threadId - The thread identifier
185
+ * @param {Partial<IPostThreadServiceInput>} updates - Update data
186
+ * @returns {Promise<AsDomainType<IPostThreadModel> | Error>} - Updated thread or error
187
+ */
188
+ async updateThread(threadId, updates) {
189
+ try {
190
+ this.logger?.debug('Updating thread via microservice', {
191
+ threadId,
192
+ updates
193
+ });
194
+ const result = await this.broker.call(`${this.topic}.updateThread`, {
195
+ threadId,
196
+ updates
197
+ });
198
+ if (!result) {
199
+ return new Error('Failed to update thread');
200
+ }
201
+ this.logger?.debug('Thread updated successfully via microservice', {
202
+ threadId
203
+ });
204
+ return result;
205
+ } catch (error) {
206
+ this.logger?.error('Error updating thread via microservice: %o', error);
207
+ return error instanceof Error ? error : new Error('Unknown error occurred while updating thread');
208
+ }
209
+ }
210
+ /**
211
+ * Deletes a post thread
212
+ *
213
+ * @description Soft deletes a thread and its associated data
214
+ *
215
+ * @param {string} threadId - The thread identifier
216
+ * @returns {Promise<boolean | Error>} - Success status or error
217
+ */
218
+ async deleteThread(threadId) {
219
+ try {
220
+ this.logger?.debug('Deleting thread via microservice', {
221
+ threadId
222
+ });
223
+ const result = await this.broker.call(`${this.topic}.deleteThread`, {
224
+ threadId
225
+ });
226
+ if (typeof result !== 'boolean') {
227
+ return new Error('Invalid result from microservice');
228
+ }
229
+ this.logger?.debug('Thread deleted successfully via microservice', {
230
+ threadId,
231
+ success: result
232
+ });
233
+ return result;
234
+ } catch (error) {
235
+ this.logger?.error('Error deleting thread via microservice: %o', error);
236
+ return error instanceof Error ? error : new Error('Unknown error occurred while deleting thread');
237
+ }
238
+ }
239
+ /**
240
+ * Gets thread participants
241
+ *
242
+ * @description Retrieves all participants in a thread
243
+ *
244
+ * @param {string} threadId - The thread identifier
245
+ * @returns {Promise<Array<string> | Error>} - Array of participant IDs or error
246
+ */
247
+ async getThreadParticipants(threadId) {
248
+ try {
249
+ this.logger?.debug('Getting thread participants via microservice', {
250
+ threadId
251
+ });
252
+ const result = await this.broker.call(`${this.topic}.getThreadParticipants`, {
253
+ threadId
254
+ });
255
+ if (!Array.isArray(result)) {
256
+ return new Error('Invalid result from microservice');
257
+ }
258
+ this.logger?.debug('Thread participants retrieved successfully via microservice', {
259
+ threadId,
260
+ participantCount: result.length
261
+ });
262
+ return result;
263
+ } catch (error) {
264
+ this.logger?.error('Error getting thread participants via microservice: %o', error);
265
+ return error instanceof Error ? error : new Error('Unknown error occurred while getting participants');
266
+ }
267
+ }
268
+ /**
269
+ * Adds a participant to a thread
270
+ *
271
+ * @description Adds a user to thread participants
272
+ *
273
+ * @param {string} threadId - The thread identifier
274
+ * @param {string} userId - The user identifier to add
275
+ * @returns {Promise<boolean | Error>} - Success status or error
276
+ */
277
+ async addParticipant(threadId, userId) {
278
+ try {
279
+ this.logger?.debug('Adding participant to thread via microservice', {
280
+ threadId,
281
+ userId
282
+ });
283
+ const result = await this.broker.call(`${this.topic}.addParticipant`, {
284
+ threadId,
285
+ userId
286
+ });
287
+ if (typeof result !== 'boolean') {
288
+ return new Error('Invalid result from microservice');
289
+ }
290
+ this.logger?.debug('Participant added to thread successfully via microservice', {
291
+ threadId,
292
+ userId,
293
+ success: result
294
+ });
295
+ return result;
296
+ } catch (error) {
297
+ this.logger?.error('Error adding participant to thread via microservice: %o', error);
298
+ return error instanceof Error ? error : new Error('Unknown error occurred while adding participant');
299
+ }
300
+ }
301
+ /**
302
+ * Removes a participant from a thread
303
+ *
304
+ * @description Removes a user from thread participants
305
+ *
306
+ * @param {string} threadId - The thread identifier
307
+ * @param {string} userId - The user identifier to remove
308
+ * @returns {Promise<boolean | Error>} - Success status or error
309
+ */
310
+ async removeParticipant(threadId, userId) {
311
+ try {
312
+ this.logger?.debug('Removing participant from thread via microservice', {
313
+ threadId,
314
+ userId
315
+ });
316
+ const result = await this.broker.call(`${this.topic}.removeParticipant`, {
317
+ threadId,
318
+ userId
319
+ });
320
+ if (typeof result !== 'boolean') {
321
+ return new Error('Invalid result from microservice');
322
+ }
323
+ this.logger?.debug('Participant removed from thread successfully via microservice', {
324
+ threadId,
325
+ userId,
326
+ success: result
327
+ });
328
+ return result;
329
+ } catch (error) {
330
+ this.logger?.error('Error removing participant from thread via microservice: %o', error);
331
+ return error instanceof Error ? error : new Error('Unknown error occurred while removing participant');
332
+ }
333
+ }
334
+ /**
335
+ * Validates thread data for creation or updates
336
+ *
337
+ * @description Helper method to validate thread data before processing
338
+ *
339
+ * @param {any} data - Data to validate
340
+ * @returns {Promise<boolean | Error>} - Validation result or error
341
+ */
342
+ async validateThreadData(data) {
343
+ try {
344
+ if (!data) {
345
+ return new Error('Thread data is required');
346
+ }
347
+ if (!data.post) {
348
+ return new Error('Post reference is required');
349
+ }
350
+ this.logger?.debug('Thread data validation passed', {
351
+ data
352
+ });
353
+ return true;
354
+ } catch (error) {
355
+ this.logger?.error('Error validating thread data: %o', error);
356
+ return error instanceof Error ? error : new Error('Unknown error occurred while validating thread data');
357
+ }
358
+ }
359
+ /**
360
+ * Gets active threads for a user
361
+ *
362
+ * @description Convenience method to get threads where a user is participating
363
+ *
364
+ * @param {string} userId - The user identifier
365
+ * @param {number} limit - Maximum number of threads to return
366
+ * @param {number} offset - Number of threads to skip
367
+ * @returns {Promise<Array<AsDomainType<IPostThreadModel>> | Error>} - Array of active threads or error
368
+ */
369
+ async getActiveThreadsForUser(userId, limit = 50, offset = 0) {
370
+ try {
371
+ this.logger?.debug('Getting active threads for user via microservice', {
372
+ userId,
373
+ limit,
374
+ offset
375
+ });
376
+ const result = await this.broker.call(`${this.topic}.getActiveThreadsForUser`, {
377
+ userId,
378
+ limit,
379
+ offset
380
+ });
381
+ if (!Array.isArray(result)) {
382
+ return new Error('Invalid result from microservice');
383
+ }
384
+ this.logger?.debug('Active threads for user retrieved successfully via microservice', {
385
+ userId,
386
+ count: result.length
387
+ });
388
+ return result;
389
+ } catch (error) {
390
+ this.logger?.error('Error getting active threads for user via microservice: %o', error);
391
+ return error instanceof Error ? error : new Error('Unknown error occurred while getting active threads for user');
392
+ }
393
+ }
14
394
  };
15
- PostThreadMicroservice = __decorate([injectable(), __param(0, inject(CommonType.MOLECULER_BROKER)), __param(1, inject('Logger')), __metadata("design:paramtypes", [ServiceBroker, Object])], PostThreadMicroservice);export{PostThreadMicroservice};//# sourceMappingURL=post-thread-microservice.js.map
395
+ PostThreadMicroservice = __decorate([injectable()
396
+ // @ts-ignore - Type compatibility issue between BaseProxyService and IPostThreadService
397
+ , __param(0, inject(CommonType.MOLECULER_BROKER)), __param(1, inject('Logger')), __metadata("design:paramtypes", [ServiceBroker, Object])], PostThreadMicroservice);export{PostThreadMicroservice};//# sourceMappingURL=post-thread-microservice.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"post-thread-microservice.js","sources":["../../../src/services/proxy-services/post-thread-microservice.ts"],"sourcesContent":[null],"names":[],"mappings":"sSAQO,IAAM,sBAAsB,GAA5B,MAAM,sBACT,SAAQ,gBAAsD,CAAA;AAGpD,EAAA,MAAA;AAEV,EAAA,KAAA,GAAQ,eAAA,CAAA,iBAAgB;aAIpB,CAAA,MAAA,EAAqB,MAEN,EAAA;AAEf,IAAA,KAAA,CAAA,MAAM,EAAA,MAAQ,CAAA,KAAY,CAAA;MAC7B,SAAA,EAAA;AAED,KAAA,CAAA,CAAA;AACI;eACH,CAAA,IAAA,EAAA;IACJ,OAAA,IAAA,CAAA,UAAA,CAAA,yBAAA,CAAA,aAAA,EAAA;AApBY,MAAsB;AADlC,KAAA,CAAA;AAUQ;AAEA;qCADO,UAAa,EAAA,EAAA,OAAA,CAAA,CAAA,EAAA,MAAA,CAAA,UAAA,CAAA,gBAAA,CAAA,CAAA,EAAA,OAAA,CAAA,CAAA,EAAA,MAAA,CAAA,QAAA,CAAA,CAAA,EAAA,UAAA,CAAA,mBAAA,EAAA,CAAA,aAAA,EAAA,MAAA,CAAA,CAAA,CAAA,EAAA,sBAAA,CAAA"}
1
+ {"version":3,"file":"post-thread-microservice.js","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